dsh-github-copilot 0.4.0-alpha.68 → 0.4.0-alpha.69
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 +1 -1
- package/CHANGELOG.md +4 -0
- package/README.md +8 -8
- package/README.zh.md +8 -8
- package/deployment-baseline.json +23 -1
- package/docs/copilot-compaction.md +1 -1
- package/docs/manual-compaction-recovery.md +46 -0
- package/lib/copilot-identity-DRZY_d2X.js +15 -0
- package/lib/index.js +45 -109
- package/lib/manual-compaction-recovery.js +159 -0
- package/lib/request-budget-DLY_aRq0.js +87 -0
- package/lib/routed-web.js +2 -1
- package/lib/{search-routing-BhrTbF-V.js → search-routing-jzNYveyK.js} +2 -15
- package/lib/types/manual-compaction-recovery.d.ts +50 -0
- package/lib/types/preview-route.d.ts +7 -1
- package/package.json +13 -1
package/AGENTS.md
CHANGED
|
@@ -42,7 +42,7 @@ This repository owns eleven narrow surfaces:
|
|
|
42
42
|
7. A bounded account-discovery route that supplies validated endpoint/capability metadata to the published native adapter, plus exact plugin-owned model exclusions enforced across its directory, Auto pools and direct admission, without maintaining model-ID routing rules or changing Core's catalog.
|
|
43
43
|
8. Optional, provider-scoped Chat presentation for completed empty reasoning disclosures; durable content and encrypted replay metadata remain Core-owned.
|
|
44
44
|
9. Compatibility-only policy restoration and request recovery for existing dedicated planner/executor Sessions. Model roles UI, settings writes and new dedicated roots are retired (#158); never reintroduce them or migrate histories implicitly.
|
|
45
|
-
10. Managed-route estimated input/output admission, optional exact-request pressure signalling through official compaction recovery, and supported low summary effort only when no effort is already resolved. See [compaction budgets](./docs/copilot-compaction.md). Preserve truthful capacities, requested output caps, native errors/replay and transaction ownership; no hidden history trimming, chunking, new retry loop, competing compaction service or automatic model switch.
|
|
45
|
+
10. Managed-route estimated input/output admission, optional exact-request pressure signalling through official compaction recovery, and supported low summary effort only when no effort is already resolved. See [compaction budgets](./docs/copilot-compaction.md). Preserve truthful capacities, requested output caps, native errors/replay and transaction ownership; no hidden history trimming, chunking, new retry loop, competing compaction service or automatic model switch. The separately selected, single-service [manual recovery engine](./docs/manual-compaction-recovery.md) may use bounded, explicit intermediate summaries through the public subclass hook; the preventive default never claims recovery of an already oversized manual summary.
|
|
46
46
|
11. Optional account quota reads and a session-scoped composer usage control through public credentials, strict Remotes and additive slots. Keep account billing-cycle credits separate from context tokens and session cost. Missing, pooled, legacy and stale data must retain their real semantics; never infer credits from token estimates or account deltas. See [quota boundaries](./docs/copilot-usage.md).
|
|
47
47
|
|
|
48
48
|
## Retired model-role compatibility boundary (#158)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0-alpha.69 (prepared)
|
|
4
|
+
|
|
5
|
+
- Add an explicit, opt-in manual compaction engine for compressible already-oversized managed Copilot histories. It uses a bounded public summary hook and native transactional replacement without changing the default compaction service. Include account-proof and failure boundaries in the recovery design.
|
|
6
|
+
|
|
3
7
|
## 0.4.0-alpha.68 (prepared)
|
|
4
8
|
|
|
5
9
|
- Add one **Follow parent model** control in plugin settings. Enable once for existing and new supported Copilot subagents and Team mates; no Session IDs or per-child setup (#234).
|
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ The Host reads GitHub's internal quota endpoint using the existing canonical OAu
|
|
|
98
98
|
|
|
99
99
|
## Install and sign in
|
|
100
100
|
|
|
101
|
-
The commands below target the package version `0.4.0-alpha.
|
|
101
|
+
The commands below target the package version `0.4.0-alpha.69`. Versioned URLs describe the intended release artifacts, not proof that publication or local activation has completed; use them only once that Release and its checksums are available. Install into the profile you use (replace `web` when targeting another profile):
|
|
102
102
|
|
|
103
103
|
Before installing/updating, unpack the **checksum-verified** archive into a temporary directory and run its read-only composition preflight (replace all paths with absolute paths for the intended profile):
|
|
104
104
|
|
|
@@ -111,10 +111,10 @@ Include any launcher patch files with repeated `--patch /absolute/file` argument
|
|
|
111
111
|
For a standalone named profile only, the supported CLI command is:
|
|
112
112
|
|
|
113
113
|
```sh
|
|
114
|
-
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
114
|
+
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.69/dsh-github-copilot-0.4.0-alpha.69.tgz
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
For Desktop profiles, use Desktop's native package manager with `dsh-github-copilot@0.4.0-alpha.
|
|
117
|
+
For Desktop profiles, use Desktop's native package manager with `dsh-github-copilot@0.4.0-alpha.69` after the same preflight and only when registry access is permitted. Desktop reserves its `desktop` profile from CLI management. If registry access is blocked or unavailable, stop; the documented [controlled offline CLI procedure](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles) is not a Desktop workaround.
|
|
118
118
|
|
|
119
119
|
Then open the Models UI listed above, find **GitHub Copilot**, select **Sign in**, and complete the GitHub device-code flow. Plugin installation changes the selected profile; activation follows that profile's normal reload/restart policy.
|
|
120
120
|
|
|
@@ -165,7 +165,7 @@ Agents should treat the browser authorization as a human handoff, not as a token
|
|
|
165
165
|
5. Confirm **Signed in** and inspect the automatic discovery result before asking the user to choose a model. Already-signed-in Models opening ensures missing/stale metadata automatically; fresh ready cache makes no request. Use visible **Retry** for errors or **Manage → Refresh models** for an intentional forced update, not routine setup. Status alone does not discover, and login, metadata and successful model calls remain separate evidence.
|
|
166
166
|
6. Use **Sign out** only when the user explicitly asks to disconnect the account. It deletes the Copilot credential record but preserves route settings.
|
|
167
167
|
|
|
168
|
-
GitHub Releases and npm are the default distribution channels for each new version, using the same verified tarball. Pin the version and verify the evidence for the channel used: Release `SHA256SUMS`, and npm `dist.integrity` when installing from npm. Install into Desktop profiles only through Desktop's native package manager; the reserved `desktop` profile is not managed by the DSH CLI. After npm publication is verified, the native manager accepts `dsh-github-copilot@0.4.0-alpha.
|
|
168
|
+
GitHub Releases and npm are the default distribution channels for each new version, using the same verified tarball. Pin the version and verify the evidence for the channel used: Release `SHA256SUMS`, and npm `dist.integrity` when installing from npm. Install into Desktop profiles only through Desktop's native package manager; the reserved `desktop` profile is not managed by the DSH CLI. After npm publication is verified, the native manager accepts `dsh-github-copilot@0.4.0-alpha.69`, not a URL or file. Controlled offline CLI maintenance is documented for standalone named profiles only, never Desktop-managed profiles. Follow the mandatory search-composition preflight, backup, single-writer and post-install checks; do not bypass a corporate registry ban, disable TLS verification or restart without separate approval. See [distribution and publication requirements](./docs/npm-distribution.md).
|
|
169
169
|
|
|
170
170
|
**Desktop package-update and Web-lifecycle boundaries:** the native manager's `restart-required` result for an in-place installed-package upgrade is authoritative and distinct from plugin-bundle removal/re-add behavior. Any disable, removal, or upgrade involving service recomposition (`cordis.patch.yml`, such as the isolated routed web search layer) may leave dependent entries pending until Desktop is fully exited and cold-restarted. If the native manager reports only entries such as `pending (waiting for service: web)` while this plugin already shows **Off**, the requested disabled state has been persisted; cold-restart Desktop instead of repeatedly toggling or reinstalling the plugin. Other errors are not covered by this guidance and must still be investigated.
|
|
171
171
|
|
|
@@ -322,7 +322,7 @@ For a marked ordinary agent-loop request with a matching initiating Session and
|
|
|
322
322
|
|
|
323
323
|
Calls explicitly marked `purpose: 'compaction'` bypass the early-pressure signal and use the full hard budget. When no caller or adapter-resolved reasoning effort is present, `prefer-low` selects an advertised supported `minimal` or `low` effort; unsupported controls preserve provider defaults. An explicit or materialized effort wins. The requested summary output cap remains unchanged, preserving Core's auxiliary summary record; the plugin does not blindly raise/lower it or accept truncated output as a checkpoint. `enabled` remains a hosted-search switch, not a switch for this managed-route protection.
|
|
324
324
|
|
|
325
|
-
**Existing oversized history is not guaranteed recoverable.**
|
|
325
|
+
**Existing oversized history is not guaranteed recoverable.** The default manual compact still rejects an oversized summary before model transport. A separately selected [manual recovery engine](./docs/manual-compaction-recovery.md) can summarize compressible, balanced managed-Copilot history through bounded intermediate calls while Core retains the only durable transaction. It is opt-in as a **replacement**, not a second compaction service; merely installing the plugin does not activate it. Indivisible input, oversized fixed prefixes and truncated output fail without replacing history. No automatic model switch or hidden history deletion occurs.
|
|
326
326
|
|
|
327
327
|
## Copilot tool compatibility
|
|
328
328
|
|
|
@@ -440,8 +440,8 @@ Report the published Release URL, version, tag/commit and verified asset SHA-256
|
|
|
440
440
|
`package.json` declares public npm distribution. A release tag must equal `v${package.json.version}`. Versions use standard SemVer prerelease labels (`alpha`, `beta`, or `rc`), each with its matching npm dist-tag; only stable versions use `latest`. The Release workflow performs the frozen install and complete verification gate, packs once (or recovers the original archive on retry), verifies `SHA256SUMS`, publishes the immutable GitHub Release and then publishes those same bytes to npm through OIDC. Either channel failing means delivery is incomplete. First package creation needs an authorized maintainer; staging requires an existing package and is not a first-package bootstrap. Historical releases are not republished.
|
|
441
441
|
|
|
442
442
|
```sh
|
|
443
|
-
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
444
|
-
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
443
|
+
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.69/dsh-github-copilot-0.4.0-alpha.69.tgz
|
|
444
|
+
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.69/SHA256SUMS
|
|
445
445
|
sha256sum --check SHA256SUMS
|
|
446
446
|
```
|
|
447
447
|
|
|
@@ -449,7 +449,7 @@ PowerShell can verify the same two downloaded files with:
|
|
|
449
449
|
|
|
450
450
|
```powershell
|
|
451
451
|
$expected = (Get-Content .\SHA256SUMS).Split()[0]
|
|
452
|
-
$actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.
|
|
452
|
+
$actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.69.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
453
453
|
if ($actual -cne $expected) { throw 'Release checksum mismatch' }
|
|
454
454
|
```
|
|
455
455
|
|
package/README.zh.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
截图来自当前构建 Client 的隔离浏览器 fixture,使用合成 Provider。它只证明已发布配置界面的形态,不证明真实凭据、账号权限、搜索成功或当前 Desktop 已加载。
|
|
22
22
|
|
|
23
|
-
> 当前文档与安装命令对应版本 `0.4.0-alpha.
|
|
23
|
+
> 当前文档与安装命令对应版本 `0.4.0-alpha.69`。源码、发布制品、已安装版本和实际加载运行时需分别确认;本地升级和中断会话的重启仍需用户批准。
|
|
24
24
|
|
|
25
25
|
Web search 路由现在优先显示在插件详情页;宿主不支持详情页插槽时才回退到 **设置 → 模型**或独立 Web search section。搜索子 Fiber 仍独立等待 Remote,不影响账号控件和既有搜索安全检查。
|
|
26
26
|
|
|
@@ -113,10 +113,10 @@ node package/scripts/check-search-composition.mjs --profile-dir /absolute/profil
|
|
|
113
113
|
仅对独立的具名 profile,获准且网络可用时,可通过受支持的 CLI 命令安装:
|
|
114
114
|
|
|
115
115
|
```sh
|
|
116
|
-
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
116
|
+
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.69/dsh-github-copilot-0.4.0-alpha.69.tgz
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
Desktop profile 请在完成同样的预检后,使用 Desktop 原生包管理器安装 `dsh-github-copilot@0.4.0-alpha.
|
|
119
|
+
Desktop profile 请在完成同样的预检后,使用 Desktop 原生包管理器安装 `dsh-github-copilot@0.4.0-alpha.69`。Desktop 保留 `desktop` profile,CLI 不负责管理。若 registry 被公司封禁或不可用,不要更换网络绕行或使用离线 CLI;请停止。[受控离线 CLI 流程](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles)仅适用于独立具名 profile,不适用于 Desktop。
|
|
120
120
|
|
|
121
121
|
随后打开上表对应的 Models UI,找到 **GitHub Copilot**,点击 **Sign in** 并完成 GitHub device-code 流程。安装会修改指定 profile;是否立即激活取决于该 profile 的常规 reload/restart 策略。
|
|
122
122
|
|
|
@@ -167,7 +167,7 @@ Agent 应把浏览器授权视为需要用户完成的 handoff,而不是自行
|
|
|
167
167
|
5. 确认 **Signed in** 并检查自动发现结果,再请用户选择模型。已登录时打开 Models 会自动确保缺失/过期元数据,新鲜 ready 缓存不发请求。错误可使用 **Retry**,有意强制更新时使用 **Manage → Refresh models**,不作为常规设置步骤。状态读取本身不发现;登录、元数据与真实调用成功是独立证据。
|
|
168
168
|
6. 只有用户明确要求断开账号时才使用 **Sign out**;它会删除 Copilot credential record,但保留 route settings。
|
|
169
169
|
|
|
170
|
-
每个新版本默认同时分发到 GitHub Releases 和 npm,两个渠道使用同一份已验证 tarball。应固定版本并核对所用渠道的证据:Release 的 `SHA256SUMS`;从 npm 安装时另核对 `dist.integrity`。Desktop profile 只能通过原生 Desktop 包管理器安装;获准且 registry 可用时输入 `dsh-github-copilot@0.4.0-alpha.
|
|
170
|
+
每个新版本默认同时分发到 GitHub Releases 和 npm,两个渠道使用同一份已验证 tarball。应固定版本并核对所用渠道的证据:Release 的 `SHA256SUMS`;从 npm 安装时另核对 `dist.integrity`。Desktop profile 只能通过原生 Desktop 包管理器安装;获准且 registry 可用时输入 `dsh-github-copilot@0.4.0-alpha.69`,不是 URL 或本地文件。Desktop 保留 `desktop` profile,不能通过 DSH CLI 管理。受控离线 CLI 维护仅适用于独立具名 profile,不得作为 Desktop 安装绕行方案。[双渠道发布与 OIDC 要求](./docs/npm-distribution.md)保持不变。
|
|
171
171
|
|
|
172
172
|
**Desktop package 更新与 Web 生命周期边界:**原生 manager 对已安装 package 原位升级返回的 `restart-required` 是权威结果,与移除/重加 plugin bundle 的行为是两个不同问题。涉及服务重编排补丁(`cordis.patch.yml`,如本插件所采用的隔离路由 Web 搜索层)的停用、移除或升级,可能让依赖条目保持 pending,直到完全退出并冷重启 Desktop。若原生 manager 只报告类似 `pending (waiting for service: web)` 的条目,同时本插件已经显示 **Off**,说明请求的停用状态已经落盘;请冷重启 Desktop,不要反复切换或重装插件。其它错误不属于此提示范围,仍需单独排查。
|
|
173
173
|
|
|
@@ -325,7 +325,7 @@ Responses 解析器会保留公开的 `reasoning_summary_text`、`reasoning_text
|
|
|
325
325
|
|
|
326
326
|
`purpose: 'compaction'` 的摘要调用绕过提前压力阈值,只检查完整硬预算。没有调用方或适配器已解析的思考等级时,`prefer-low` 从已支持的能力中选择 `minimal` 或 `low`;没有此能力则保持供应方默认。显式或已解析的等级优先。摘要请求的输出上限不被偷偷改写,保持 Core 辅助摘要记录一致;也不会将截断输出当成成功 checkpoint。`enabled` 仍仅控制 hosted search。
|
|
327
327
|
|
|
328
|
-
|
|
328
|
+
**仍不保证救回所有已经超限的旧历史。** 默认手动 compact 仍会在模型发送前拒绝超限摘要。另有可单独选择的[手动恢复引擎](./docs/manual-compaction-recovery.md):仅对可分割且工具调用配对完整的托管 Copilot 历史进行有界中间摘要,最终持久事务仍由 Core 负责。它必须**替换**原有压缩服务而非并列安装;仅安装插件不会启用。不可分割的输入、过大的固定前缀或被截断的输出都不会替换历史;不会自动切换模型或偷偷删除历史。
|
|
329
329
|
|
|
330
330
|
## Copilot Tool 兼容
|
|
331
331
|
|
|
@@ -451,8 +451,8 @@ node scripts/agent.mjs attribution "DeepSeek Harness (DSH)"
|
|
|
451
451
|
`package.json` 声明公开 npm 分发。Release tag 必须严格等于 `v${package.json.version}`。预发布使用 `alpha`、`beta` 或 `rc` 及对应 npm dist-tag,只有稳定版使用 `latest`。Release workflow 执行 frozen install 和完整门禁,只打包一次(重试恢复原始归档),验证 `SHA256SUMS`,发布不可变 GitHub Release,再通过 OIDC 将同一份字节发布到 npm。任一渠道失败都表示交付未完成。首次建包须由获准环境中的维护者完成;staging 要求包已存在,不能代替首次建包。不会批量补发历史版本。
|
|
452
452
|
|
|
453
453
|
```sh
|
|
454
|
-
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
455
|
-
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
454
|
+
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.69/dsh-github-copilot-0.4.0-alpha.69.tgz
|
|
455
|
+
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.69/SHA256SUMS
|
|
456
456
|
sha256sum --check SHA256SUMS
|
|
457
457
|
```
|
|
458
458
|
|
|
@@ -460,7 +460,7 @@ PowerShell 可以对已下载的同一组文件执行:
|
|
|
460
460
|
|
|
461
461
|
```powershell
|
|
462
462
|
$expected = (Get-Content .\SHA256SUMS).Split()[0]
|
|
463
|
-
$actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.
|
|
463
|
+
$actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.69.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
464
464
|
if ($actual -cne $expected) { throw 'Release checksum mismatch' }
|
|
465
465
|
```
|
|
466
466
|
|
package/deployment-baseline.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"package": {
|
|
10
10
|
"name": "dsh-github-copilot",
|
|
11
|
-
"version": "0.4.0-alpha.
|
|
11
|
+
"version": "0.4.0-alpha.69"
|
|
12
12
|
},
|
|
13
13
|
"evidence": {
|
|
14
14
|
"kind": "source-and-synthetic-test-inventory",
|
|
@@ -234,11 +234,15 @@
|
|
|
234
234
|
"@deepseek-ai/dsh-client-ui-renderer",
|
|
235
235
|
"@deepseek-ai/dsh-client-ui-settings-models",
|
|
236
236
|
"@deepseek-ai/dsh-client-ui-slots",
|
|
237
|
+
"@deepseek-ai/dsh-commands",
|
|
238
|
+
"@deepseek-ai/dsh-compaction",
|
|
239
|
+
"@deepseek-ai/dsh-compaction-basic",
|
|
237
240
|
"@deepseek-ai/dsh-credentials",
|
|
238
241
|
"@deepseek-ai/dsh-launch-environment",
|
|
239
242
|
"@deepseek-ai/dsh-llm",
|
|
240
243
|
"@deepseek-ai/dsh-llm-pi-ai",
|
|
241
244
|
"@deepseek-ai/dsh-scope",
|
|
245
|
+
"@deepseek-ai/dsh-session",
|
|
242
246
|
"@deepseek-ai/dsh-settings",
|
|
243
247
|
"@deepseek-ai/dsh-typert-protocol",
|
|
244
248
|
"@deepseek-ai/dsh-web",
|
|
@@ -441,6 +445,23 @@
|
|
|
441
445
|
{"file": "tests/preview-route.spec.ts", "name": "isolates concurrent chat success from a rejected compaction admission"}
|
|
442
446
|
]
|
|
443
447
|
},
|
|
448
|
+
{
|
|
449
|
+
"id": "opt-in-oversized-manual-compaction",
|
|
450
|
+
"required": true,
|
|
451
|
+
"evidenceScope": "synthetic-public-subclass-and-exact-tagged-source-no-live-inference",
|
|
452
|
+
"sourceMarkers": [
|
|
453
|
+
{"file": "src/manual-compaction-recovery.ts", "marker": "extends BasicCompactionEngine"},
|
|
454
|
+
{"file": "src/manual-compaction-recovery.ts", "marker": "COPILOT_MANUAL_RECOVERY_"},
|
|
455
|
+
{"file": "src/preview-route.ts", "marker": "recoveryLimits(modelId)"},
|
|
456
|
+
{"file": "docs/manual-compaction-recovery.md", "marker": "separately selected"}
|
|
457
|
+
],
|
|
458
|
+
"tests": [
|
|
459
|
+
{"file": "tests/manual-compaction-recovery.spec.ts", "name": "reduces an oversized balanced history with bounded complete calls and an unmarked aggregate audit"},
|
|
460
|
+
{"file": "tests/manual-compaction-recovery.spec.ts", "name": "rejects an indivisible span before dispatch and leaves recovery to native failure handling"},
|
|
461
|
+
{"file": "tests/manual-compaction-recovery.spec.ts", "name": "rejects unmatched tool calls before dispatch instead of splitting a call and result"},
|
|
462
|
+
{"file": "tests/fixtures/compaction-pressure-core.fixture.ts", "name": "recovers oversized manual history with one native transaction and honest multi-call audit"}
|
|
463
|
+
]
|
|
464
|
+
},
|
|
444
465
|
{
|
|
445
466
|
"id": "account-driven-provider-metadata",
|
|
446
467
|
"required": true,
|
|
@@ -1088,6 +1109,7 @@
|
|
|
1088
1109
|
"./remote": [],
|
|
1089
1110
|
"./routed-web": ["default"],
|
|
1090
1111
|
"./web-delegate": ["name", "inject", "apply"],
|
|
1112
|
+
"./manual-compaction-recovery": ["CopilotManualRecoveryCompactionEngine", "summarizeOversizedManualInput"],
|
|
1091
1113
|
"./deployment-baseline.json": [],
|
|
1092
1114
|
"./package.json": []
|
|
1093
1115
|
}
|
|
@@ -69,7 +69,7 @@ On official `0.2.0-rc.2`, the stock summarizer uses an explicitly configured sum
|
|
|
69
69
|
|
|
70
70
|
Official configuration already supports a separate summary route and output cap. Selecting a suitable authorized route/cap is an explicit deployment choice, not an automatic fallback. Increasing the output cap consumes combined-context headroom; decreasing it can reproduce the observed incomplete-checkpoint failure.
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
An explicit, separately selected recovery engine for compressible already-oversized **manual** summaries is specified in [manual compaction recovery](./manual-compaction-recovery.md). The default Basic engine and the preventive request guard remain unchanged. No hidden wire interceptor or automatic summary retry is used; the native summary event is unmarked when several real calls contributed to one checkpoint.
|
|
73
73
|
|
|
74
74
|
## Official-first evidence and retirement
|
|
75
75
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Oversized manual compaction recovery
|
|
2
|
+
|
|
3
|
+
Tracking: [#228](https://github.com/cloga/dsh-github-copilot/issues/228). Target: unchanged official DSH `0.2.0-rc.2` (`639ed015397290b3745d163aafe02ffee4aa3f84`). This document specifies a **separately selected** Host compaction engine; installing this plugin by itself does not replace a running Core engine.
|
|
4
|
+
|
|
5
|
+
## Requirements and failure boundary
|
|
6
|
+
|
|
7
|
+
An already oversized, compressible manual summary must be able to make progress without submitting the same over-budget prompt again. The motivating detached session had a roughly 508k estimated summary input versus a roughly 368k hard input budget with 65,536 reserved output tokens. The independent model prompt ceiling, not the output reservation alone, binds. The native one-shot summarizer sends the entire selected balanced span plus a directive, and the managed-route guard correctly refuses that input. The prior Auto meter repair prevents incorrect candidate selection; it does not shorten this summary.
|
|
8
|
+
|
|
9
|
+
Recovery must leave the original Session surface intact until a smaller *complete* checkpoint has been accepted by Core's native transaction. It must retain the system head, tool declarations and chronological content, never split a tool-call/result pair, honor cancellation and source changes, bound all provider calls, and preserve the actual summary route and output cap. If a fixed head or one indivisible unit cannot fit, an intermediate summary is truncated/empty, account proof expires, the history changes, or the call limit is exhausted, fail with a named diagnostic and no replacement. No live inference, credential changes, automatic model switch, history deletion or summary-success claim follows from a local test.
|
|
10
|
+
|
|
11
|
+
## Composition and algorithm
|
|
12
|
+
|
|
13
|
+
`CopilotManualRecoveryCompactionEngine` is an opt-in alternative to **one** official `BasicCompactionEngine` registration. Operators selecting it must replace (not mount alongside) their existing basic compaction service in the same Host scope; the default plugin registration never changes the service. It subclasses the published engine and calls `super.compactNow`: Core still owns idle maintenance, a single bracketed durable transaction, balanced range selection, checkpoint framing, source-stability/shrink checks, cancellation, failure classification, flush, and optional native pruning. The subclass hook runs recovery **only** inside an explicit manual call with an authenticated, current managed Copilot summary model. Automatic compaction and all other providers delegate to the stock hook unchanged. A pending model picker is not summary-route evidence: an explicit native summary target wins, then the latest committed header, then Agent options.
|
|
14
|
+
|
|
15
|
+
The plugin's account service supplies a current descriptor and a revocable proof without starting discovery or reading credentials into the Client. The summary budget uses `min(maxInputTokens, contextWindow - configuredOutputCap) - safetyTokens`; an additional 4096-token allowance covers Core's appended directive and estimation variance. Each candidate request is conservatively bounded by serialized UTF-8 size including system, tools, prior intermediate checkpoint and current messages. Native managed-route admission remains the final authority. A call that still exceeds that guard fails; it is never retried with a hidden wire rewrite.
|
|
16
|
+
|
|
17
|
+
The hook partitions the *original* span only at balanced boundaries, summarizes each part through `super.summarize`, and supplies the previous completed intermediate checkpoint as context for the next call. Thus the last completed summary contains all processed parts in chronological order. Default maximum: 16 calls (hard maximum 32); each carries the native cancellation signal and checks account proof before and after dispatch. The original surface is not modified between calls. Core checks for a smaller replacement and current source after the final result; any failure closes the native marker without a replacement. No background job starts this process.
|
|
18
|
+
|
|
19
|
+
**Audit:** each physical call goes through Core's public `llm.stream` seam with its actual route/cap. The final native summary event is intentionally *unmarked* (`llmStreamCall` absent), not a fabricated claim of one call. It records summed provider-reported usage only when **every** underlying call supplied usage; optional counters are included only if present on every call. The native event format has no per-call array or durable per-call transcript in a single summary event; do not infer individual request accounting from that aggregate. This is a real observability limit of the unchanged public contract.
|
|
20
|
+
|
|
21
|
+
This aggregate is not per-call attribution: it cannot reconstruct which intermediate request used which tokens, identify each physical response, or prove that native call-attribution consumers count every intermediate request. The plugin does not manufacture `llmStreamCall`, response IDs, or individual durable usage records to fill that gap. Reported aggregate provider usage and Core's native call-attribution/accounting are separate evidence layers.
|
|
22
|
+
|
|
23
|
+
## Native admission and historical usage evidence
|
|
24
|
+
|
|
25
|
+
The exact rc.2 `llm-pi-ai` public adapter converts both plain and replay-backed historical assistant messages with `emptyPiUsage()` and `timestamp: 0` (`replay.ts`); converted user messages, including new intermediate checkpoints, also have timestamp zero (`context.ts`). Therefore creating a checkpoint **does not** invalidate an old SDK usage anchor through a newer timestamp. On this pin, Core does not carry the historical assistant usage into the SDK context in the first place. Recovery neither clears that usage itself nor changes message timestamps, replay state, native conversion, the SDK estimator or the final managed guard. This behavior must be requalified when the Core/pi-ai pin changes.
|
|
26
|
+
|
|
27
|
+
The unchanged-Core fixture exercises the real managed adapter and its `inspectRequest` guard with a synthetic 27-turn history whose latest provider-reported input is 508,198 tokens. It first proves stock manual compaction fails the 12,000-token input bound without reaching the synthetic wire, then proves the opt-in engine commits one replacement through bounded calls. The captured SDK estimates include the complete native compaction directive, system policy and tool schemas, not a prompt with its final directive removed. Every dispatched estimate fits the hard limit; the 8,192 output cap is preserved, source events remain byte-identical, and every intermediate wire call observes the original surface generation. Estimator instrumentation calls the original SDK utility without altering its result. The fixture verifies zero carried usage anchors, aggregate usage and the deliberately absent single-call marker. Synthetic scaled-down input limits and transport establish native admission/transaction behavior, not provider-exact capacity or live Copilot success.
|
|
28
|
+
|
|
29
|
+
## Limitations and operational use
|
|
30
|
+
|
|
31
|
+
This path only helps histories with balanced boundaries and intermediate summaries that fit their model's input and output limits. One giant user/tool result, a huge fixed head/tool schema, an incomplete tool pair, provider truncation, or a final checkpoint that is not smaller remain explicit failures. Intermediate model summaries are lossy in the same sense as ordinary Core compaction; review important context before explicitly invoking manual compaction. The conservative UTF-8 bound may reject a request that a provider could accept. The algorithm does not claim provider-exact token measurement or repair of a damaged/unmatched pre-existing compaction bracket.
|
|
32
|
+
|
|
33
|
+
Select the exported `dsh-github-copilot/manual-compaction-recovery` Host class **instead of** the stock basic compaction plugin in a reviewed Host composition. For a composition that normally contains `- name: '@deepseek-ai/dsh-compaction-basic'`, remove that single row and use this row in the same scope:
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
- name: 'dsh-github-copilot/manual-compaction-recovery'
|
|
37
|
+
config:
|
|
38
|
+
auto: true
|
|
39
|
+
maxTokens: 65536 # example only: preserve the reviewed original cap
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Keep the existing BasicCompactionConfig, including any modelPolicies and actual maxTokens; configure a summary route deliberately if the last committed model cannot serve the summary. Do not enable two compaction services or modify a live profile without explicit approval. The normal plugin and all ordinary sessions remain usable without this replacement; the package export alone neither installs it nor changes an existing Session.
|
|
43
|
+
|
|
44
|
+
## Acceptance and retirement
|
|
45
|
+
|
|
46
|
+
Focused tests must exercise oversized balanced histories, native durable replacement and no replacement on cancellation, truncation, stale source or proof, irreducible units and bounded-call exhaustion. Verify the exact published Core source fixture, frozen install, full plugin gate and immutable package smoke before describing a deployable release. CI with synthetic transport proves no live Copilot availability. Retire this companion path only when official compaction safely handles independent prompt ceilings and multi-call/manual recovery with equivalent durable audit, lifecycle and transaction guarantees.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region lib/types/copilot-identity.js
|
|
2
|
+
/** Native OAuth ownership and the sole plugin-owned, account-discovered route. */
|
|
3
|
+
const GITHUB_COPILOT_CREDENTIAL_KEY = "llm-pi-ai/github-copilot";
|
|
4
|
+
const GITHUB_COPILOT_PROVIDER_ID = "github-copilot";
|
|
5
|
+
const GITHUB_COPILOT_PREVIEW_PROVIDER_ID = "github-copilot-preview";
|
|
6
|
+
const GITHUB_COPILOT_AUTO_MODEL_ID = "auto";
|
|
7
|
+
const GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID = "auto-efficiency";
|
|
8
|
+
const GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID = "auto-intelligence";
|
|
9
|
+
function autoModelPreference(model) {
|
|
10
|
+
if (model === "auto") return "balance";
|
|
11
|
+
if (model === "auto-efficiency") return "efficiency";
|
|
12
|
+
if (model === "auto-intelligence") return "intelligence";
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { GITHUB_COPILOT_PREVIEW_PROVIDER_ID as a, GITHUB_COPILOT_CREDENTIAL_KEY as i, GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID as n, GITHUB_COPILOT_PROVIDER_ID as o, GITHUB_COPILOT_AUTO_MODEL_ID as r, autoModelPreference as s, GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID as t };
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as GITHUB_COPILOT_PREVIEW_PROVIDER_ID, i as GITHUB_COPILOT_CREDENTIAL_KEY, n as GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID, o as GITHUB_COPILOT_PROVIDER_ID, r as GITHUB_COPILOT_AUTO_MODEL_ID, s as autoModelPreference, t as GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID } from "./copilot-identity-DRZY_d2X.js";
|
|
2
|
+
import { C as currentSearchInitiator, D as readSettingsNamespace, E as readConfigValue, O as isPluginPreviewProvider, 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, k as readCopilotCatalog, 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-jzNYveyK.js";
|
|
3
|
+
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";
|
|
2
4
|
import AuthorizationService from "@deepseek-ai/dsh-authorization";
|
|
3
5
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
6
|
import * as dshScope from "@deepseek-ai/dsh-scope";
|
|
@@ -1309,7 +1311,7 @@ var UsageFailure = class extends Error {
|
|
|
1309
1311
|
this.diagnostic = diagnostic;
|
|
1310
1312
|
}
|
|
1311
1313
|
};
|
|
1312
|
-
function failure$
|
|
1314
|
+
function failure$2(diagnostic) {
|
|
1313
1315
|
throw new UsageFailure(diagnostic);
|
|
1314
1316
|
}
|
|
1315
1317
|
function certificateFailure(error) {
|
|
@@ -1321,9 +1323,9 @@ async function readBody(response, signal) {
|
|
|
1321
1323
|
const length = response.headers.get("content-length");
|
|
1322
1324
|
if (length !== null && (!/^\d+$/u.test(length) || Number(length) > MAX_BODY_BYTES)) {
|
|
1323
1325
|
response.body?.cancel().catch(() => void 0);
|
|
1324
|
-
failure$
|
|
1326
|
+
failure$2("COPILOT_USAGE_BODY_TOO_LARGE");
|
|
1325
1327
|
}
|
|
1326
|
-
if (!response.body) failure$
|
|
1328
|
+
if (!response.body) failure$2("COPILOT_USAGE_INVALID_RESPONSE");
|
|
1327
1329
|
const reader = response.body.getReader(), chunks = [];
|
|
1328
1330
|
const cancel = () => {
|
|
1329
1331
|
reader.cancel().catch(() => void 0);
|
|
@@ -1338,7 +1340,7 @@ async function readBody(response, signal) {
|
|
|
1338
1340
|
size += next.value.byteLength;
|
|
1339
1341
|
if (size > MAX_BODY_BYTES) {
|
|
1340
1342
|
reader.cancel().catch(() => void 0);
|
|
1341
|
-
failure$
|
|
1343
|
+
failure$2("COPILOT_USAGE_BODY_TOO_LARGE");
|
|
1342
1344
|
}
|
|
1343
1345
|
chunks.push(next.value);
|
|
1344
1346
|
}
|
|
@@ -1355,7 +1357,7 @@ async function readBody(response, signal) {
|
|
|
1355
1357
|
try {
|
|
1356
1358
|
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
1357
1359
|
} catch {
|
|
1358
|
-
failure$
|
|
1360
|
+
failure$2("COPILOT_USAGE_INVALID_RESPONSE");
|
|
1359
1361
|
}
|
|
1360
1362
|
}
|
|
1361
1363
|
/** One Host-owned, memory-only account cache. No auth renewal, persistence or model transport. */
|
|
@@ -1401,8 +1403,8 @@ var CopilotUsageSource = class {
|
|
|
1401
1403
|
return this.load(true);
|
|
1402
1404
|
}
|
|
1403
1405
|
active(generation) {
|
|
1404
|
-
if (this.disposed) failure$
|
|
1405
|
-
if (generation !== this.generation) failure$
|
|
1406
|
+
if (this.disposed) failure$2("COPILOT_USAGE_DISPOSED");
|
|
1407
|
+
if (generation !== this.generation) failure$2("COPILOT_USAGE_ACCOUNT_CHANGED");
|
|
1406
1408
|
}
|
|
1407
1409
|
async readAuth(generation) {
|
|
1408
1410
|
this.active(generation);
|
|
@@ -1411,24 +1413,24 @@ var CopilotUsageSource = class {
|
|
|
1411
1413
|
stored = await this.dependencies.readCredential();
|
|
1412
1414
|
} catch {
|
|
1413
1415
|
this.active(generation);
|
|
1414
|
-
failure$
|
|
1416
|
+
failure$2("COPILOT_USAGE_CREDENTIALS_UNAVAILABLE");
|
|
1415
1417
|
}
|
|
1416
1418
|
this.active(generation);
|
|
1417
|
-
if (stored === void 0) failure$
|
|
1419
|
+
if (stored === void 0) failure$2("COPILOT_USAGE_SIGNED_OUT");
|
|
1418
1420
|
let grant;
|
|
1419
1421
|
try {
|
|
1420
1422
|
grant = normalizeGitHubCopilotOAuthCredential(stored);
|
|
1421
1423
|
} catch {
|
|
1422
|
-
failure$
|
|
1424
|
+
failure$2("COPILOT_USAGE_INVALID_GRANT");
|
|
1423
1425
|
}
|
|
1424
|
-
if (grant.enterpriseUrl !== void 0) failure$
|
|
1426
|
+
if (grant.enterpriseUrl !== void 0) failure$2("COPILOT_USAGE_ENTERPRISE_UNSUPPORTED");
|
|
1425
1427
|
return {
|
|
1426
1428
|
grant,
|
|
1427
1429
|
key: copilotAccountKey(grant)
|
|
1428
1430
|
};
|
|
1429
1431
|
}
|
|
1430
1432
|
async assertCurrent(key, generation) {
|
|
1431
|
-
if ((await this.readAuth(generation)).key !== key) failure$
|
|
1433
|
+
if ((await this.readAuth(generation)).key !== key) failure$2("COPILOT_USAGE_ACCOUNT_CHANGED");
|
|
1432
1434
|
}
|
|
1433
1435
|
diagnostic(error) {
|
|
1434
1436
|
return error instanceof UsageFailure ? error.diagnostic : "COPILOT_USAGE_NETWORK";
|
|
@@ -1439,16 +1441,16 @@ var CopilotUsageSource = class {
|
|
|
1439
1441
|
const certificates = this.dependencies.getCACertificates ?? getCACertificates;
|
|
1440
1442
|
const defaults = certificates("default");
|
|
1441
1443
|
const system = certificates("system");
|
|
1442
|
-
if (!Array.isArray(defaults) || !Array.isArray(system) || system.length === 0 || [...defaults, ...system].some((ca) => typeof ca !== "string" || ca.length === 0)) failure$
|
|
1444
|
+
if (!Array.isArray(defaults) || !Array.isArray(system) || system.length === 0 || [...defaults, ...system].some((ca) => typeof ca !== "string" || ca.length === 0)) failure$2("COPILOT_USAGE_TRUST_UNAVAILABLE");
|
|
1443
1445
|
const ca = [.../* @__PURE__ */ new Set([...defaults, ...system])];
|
|
1444
1446
|
this.dispatcher = (this.dependencies.createDispatcher ?? ((options) => new Agent(options)))({ connect: {
|
|
1445
1447
|
ca,
|
|
1446
1448
|
rejectUnauthorized: true
|
|
1447
1449
|
} });
|
|
1448
|
-
if (!this.dispatcher) failure$
|
|
1450
|
+
if (!this.dispatcher) failure$2("COPILOT_USAGE_TRUST_UNAVAILABLE");
|
|
1449
1451
|
return this.dispatcher;
|
|
1450
1452
|
} catch {
|
|
1451
|
-
failure$
|
|
1453
|
+
failure$2("COPILOT_USAGE_TRUST_UNAVAILABLE");
|
|
1452
1454
|
}
|
|
1453
1455
|
}
|
|
1454
1456
|
async load(force) {
|
|
@@ -1504,18 +1506,18 @@ var CopilotUsageSource = class {
|
|
|
1504
1506
|
...!this.dependencies.fetch && { dispatcher: this.quotaDispatcher() }
|
|
1505
1507
|
});
|
|
1506
1508
|
} catch (error) {
|
|
1507
|
-
if (certificateFailure(error)) failure$
|
|
1509
|
+
if (certificateFailure(error)) failure$2("COPILOT_USAGE_TLS");
|
|
1508
1510
|
throw error;
|
|
1509
1511
|
}
|
|
1510
1512
|
if (response.redirected || response.status >= 300 && response.status < 400) {
|
|
1511
1513
|
response.body?.cancel().catch(() => void 0);
|
|
1512
|
-
failure$
|
|
1514
|
+
failure$2("COPILOT_USAGE_REDIRECT");
|
|
1513
1515
|
}
|
|
1514
1516
|
if (!response.ok) {
|
|
1515
1517
|
response.body?.cancel().catch(() => void 0);
|
|
1516
|
-
if (response.status === 401 || response.status === 403) failure$
|
|
1517
|
-
if (response.status === 429) failure$
|
|
1518
|
-
failure$
|
|
1518
|
+
if (response.status === 401 || response.status === 403) failure$2("COPILOT_USAGE_AUTH_REJECTED");
|
|
1519
|
+
if (response.status === 429) failure$2("COPILOT_USAGE_RATE_LIMITED");
|
|
1520
|
+
failure$2("COPILOT_USAGE_HTTP_ERROR");
|
|
1519
1521
|
}
|
|
1520
1522
|
return readBody(response, abort.signal);
|
|
1521
1523
|
}
|
|
@@ -1646,7 +1648,7 @@ let GitHubCopilotUsageController = (() => {
|
|
|
1646
1648
|
//#endregion
|
|
1647
1649
|
//#region package.json
|
|
1648
1650
|
var name$1 = "dsh-github-copilot";
|
|
1649
|
-
var version = "0.4.0-alpha.
|
|
1651
|
+
var version = "0.4.0-alpha.69";
|
|
1650
1652
|
//#endregion
|
|
1651
1653
|
//#region lib/types/probe.js
|
|
1652
1654
|
/**
|
|
@@ -1948,92 +1950,6 @@ async function probeAnthropic(candidate, apiKey, signal) {
|
|
|
1948
1950
|
};
|
|
1949
1951
|
}
|
|
1950
1952
|
//#endregion
|
|
1951
|
-
//#region lib/types/request-budget.js
|
|
1952
|
-
/** The safety allowance matches the pinned native SDK; pressure is a separate opt-in check. */
|
|
1953
|
-
const DEFAULT_REQUEST_BUDGET_POLICY = Object.freeze({
|
|
1954
|
-
safetyTokens: 4096,
|
|
1955
|
-
pressureRatio: .9,
|
|
1956
|
-
compactionReasoning: "prefer-low"
|
|
1957
|
-
});
|
|
1958
|
-
/** Validate deployment policy before applying defaults; unknown keys fail rather than silently drift. */
|
|
1959
|
-
function resolveRequestBudgetPolicy(config = {}) {
|
|
1960
|
-
const keys = /* @__PURE__ */ new Set([
|
|
1961
|
-
"safetyTokens",
|
|
1962
|
-
"pressureRatio",
|
|
1963
|
-
"compactionReasoning"
|
|
1964
|
-
]);
|
|
1965
|
-
for (const key of Object.keys(config)) if (!keys.has(key)) throw new Error(`COPILOT_REQUEST_BUDGET_POLICY_INVALID: unknown setting ${key}`);
|
|
1966
|
-
const safetyTokens = config.safetyTokens === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.safetyTokens : config.safetyTokens;
|
|
1967
|
-
const pressureRatio = config.pressureRatio === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.pressureRatio : config.pressureRatio;
|
|
1968
|
-
const compactionReasoning = config.compactionReasoning === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning : config.compactionReasoning;
|
|
1969
|
-
if (!Number.isSafeInteger(safetyTokens) || safetyTokens < 0) throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: safetyTokens must be a non-negative safe integer");
|
|
1970
|
-
if (!Number.isFinite(pressureRatio) || pressureRatio <= 0 || pressureRatio > 1) throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: pressureRatio must be greater than zero and at most one");
|
|
1971
|
-
if (compactionReasoning !== "prefer-low" && compactionReasoning !== "preserve") throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: unsupported compactionReasoning");
|
|
1972
|
-
return Object.freeze({
|
|
1973
|
-
safetyTokens,
|
|
1974
|
-
pressureRatio,
|
|
1975
|
-
compactionReasoning
|
|
1976
|
-
});
|
|
1977
|
-
}
|
|
1978
|
-
function failure$2(code, message) {
|
|
1979
|
-
return Object.freeze({
|
|
1980
|
-
ok: false,
|
|
1981
|
-
code,
|
|
1982
|
-
message: `${code}: ${message}`
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
function positiveInteger$1(value) {
|
|
1986
|
-
return Number.isSafeInteger(value) && value > 0;
|
|
1987
|
-
}
|
|
1988
|
-
/**
|
|
1989
|
-
* Reserve output under the combined context and independently enforce the prompt ceiling.
|
|
1990
|
-
* `policy` must come from resolveRequestBudgetPolicy; no caller cap or catalog object is changed.
|
|
1991
|
-
*/
|
|
1992
|
-
function calculateRequestBudget(limits, requestedMaxTokens, policy = DEFAULT_REQUEST_BUDGET_POLICY) {
|
|
1993
|
-
const { contextWindow, maxInputTokens, maxTokens } = limits;
|
|
1994
|
-
if (!positiveInteger$1(contextWindow) || !positiveInteger$1(maxTokens) || maxInputTokens !== void 0 && !positiveInteger$1(maxInputTokens)) return failure$2("COPILOT_REQUEST_INVALID_LIMITS", "model token capacities must be positive safe integers");
|
|
1995
|
-
if (requestedMaxTokens !== void 0 && !positiveInteger$1(requestedMaxTokens)) return failure$2("COPILOT_REQUEST_INVALID_OUTPUT_LIMIT", "request output cap must be a positive safe integer");
|
|
1996
|
-
const outputReservation = requestedMaxTokens ?? maxTokens;
|
|
1997
|
-
if (outputReservation > maxTokens) return failure$2("COPILOT_REQUEST_OUTPUT_LIMIT_EXCEEDED", `request output cap ${outputReservation} exceeds model output capacity ${maxTokens}`);
|
|
1998
|
-
const contextInputLimit = contextWindow - outputReservation;
|
|
1999
|
-
const limitingFactor = maxInputTokens !== void 0 && maxInputTokens <= contextInputLimit ? "prompt" : "context";
|
|
2000
|
-
const hardInputLimit = Math.min(maxInputTokens ?? contextInputLimit, contextInputLimit) - policy.safetyTokens;
|
|
2001
|
-
if (hardInputLimit <= 0) return failure$2("COPILOT_REQUEST_NO_INPUT_HEADROOM", "output reservation and safety allowance leave no positive input budget");
|
|
2002
|
-
return Object.freeze({
|
|
2003
|
-
ok: true,
|
|
2004
|
-
budget: Object.freeze({
|
|
2005
|
-
contextWindow,
|
|
2006
|
-
...maxInputTokens === void 0 ? {} : { maxInputTokens },
|
|
2007
|
-
maxOutputTokens: maxTokens,
|
|
2008
|
-
outputReservation,
|
|
2009
|
-
hardInputLimit,
|
|
2010
|
-
pressureInputLimit: Math.floor(hardInputLimit * policy.pressureRatio),
|
|
2011
|
-
limitingFactor
|
|
2012
|
-
})
|
|
2013
|
-
});
|
|
2014
|
-
}
|
|
2015
|
-
/**
|
|
2016
|
-
* Check an estimated full prompt; estimates are not provider-exact token counts.
|
|
2017
|
-
* Enable pressure only for an owned ordinary loop call with a compaction recovery path.
|
|
2018
|
-
* Auxiliary and agentless calls use hard admission, including compaction itself.
|
|
2019
|
-
*/
|
|
2020
|
-
function assessRequestBudget(estimatedInput, budget, pressure = false) {
|
|
2021
|
-
if (!Number.isFinite(estimatedInput) || estimatedInput < 0 || estimatedInput > Number.MAX_SAFE_INTEGER) return failure$2("COPILOT_REQUEST_INVALID_ESTIMATE", "estimated input must be finite, non-negative, and safely representable");
|
|
2022
|
-
const input = Math.ceil(estimatedInput);
|
|
2023
|
-
if (input > budget.hardInputLimit) return failure$2(budget.limitingFactor === "prompt" ? "COPILOT_REQUEST_INPUT_LIMIT_EXCEEDED" : "COPILOT_REQUEST_CONTEXT_LIMIT_EXCEEDED", `estimated input ${input} exceeds input budget ${budget.hardInputLimit} with output reservation ${budget.outputReservation}`);
|
|
2024
|
-
if (pressure && input > budget.pressureInputLimit) return failure$2("COPILOT_REQUEST_PRESSURE_EXCEEDED", `estimated input ${input} exceeds proactive compaction budget ${budget.pressureInputLimit}`);
|
|
2025
|
-
return Object.freeze({ ok: true });
|
|
2026
|
-
}
|
|
2027
|
-
/**
|
|
2028
|
-
* Select a low-cost supported effort only for a caller-confirmed compaction request.
|
|
2029
|
-
* A supplied effort, including a materialized provider default, wins unchanged; native validation
|
|
2030
|
-
* remains authoritative. Unsupported low-cost controls preserve the provider default, never off/none.
|
|
2031
|
-
*/
|
|
2032
|
-
function selectCompactionReasoning(supportedEfforts, requestedEffort, mode = DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning) {
|
|
2033
|
-
if (requestedEffort !== void 0 || mode === "preserve") return requestedEffort;
|
|
2034
|
-
return supportedEfforts.find((effort) => effort === "minimal") ?? supportedEfforts.find((effort) => effort === "low");
|
|
2035
|
-
}
|
|
2036
|
-
//#endregion
|
|
2037
1953
|
//#region lib/types/search-routing-policy.js
|
|
2038
1954
|
/** Resolve old and new settings without guessing registered providers or dropping unknown ids. */
|
|
2039
1955
|
function normalizeWebSearchRouting(config) {
|
|
@@ -7582,7 +7498,8 @@ var PreviewAdapter = class extends PiAiAdapter {
|
|
|
7582
7498
|
throw requestFailure;
|
|
7583
7499
|
}
|
|
7584
7500
|
const fresh = context.messages.reduce((tokens, message) => tokens + estimateMessageTokens(message), 0);
|
|
7585
|
-
const
|
|
7501
|
+
const estimate = Math.max(estimateContextTokens(context).tokens, fresh);
|
|
7502
|
+
const admitted = assessRequestBudget(estimate, calculated.budget);
|
|
7586
7503
|
if (!admitted.ok) {
|
|
7587
7504
|
requestFailure = budgetFailure(admitted);
|
|
7588
7505
|
throw requestFailure;
|
|
@@ -7929,6 +7846,25 @@ function apply$1(ctx, config = {}) {
|
|
|
7929
7846
|
ctx.provide("githubCopilotPreview", {
|
|
7930
7847
|
getView,
|
|
7931
7848
|
refresh,
|
|
7849
|
+
recoveryLimits(modelId) {
|
|
7850
|
+
const snapshot = source.readSnapshot();
|
|
7851
|
+
if (snapshot === void 0 || proofFor(snapshot) === void 0 || !getView().available || excludedModels().has(modelId)) return void 0;
|
|
7852
|
+
const descriptor = snapshot.models.find((model) => model.id === modelId);
|
|
7853
|
+
if (descriptor === void 0) return void 0;
|
|
7854
|
+
const revision = lifetime.revision;
|
|
7855
|
+
const proof = snapshotProof;
|
|
7856
|
+
return Object.freeze({
|
|
7857
|
+
limits: Object.freeze({
|
|
7858
|
+
contextWindow: descriptor.contextWindow,
|
|
7859
|
+
maxTokens: descriptor.maxTokens,
|
|
7860
|
+
...descriptor.maxInputTokens === void 0 ? {} : { maxInputTokens: descriptor.maxInputTokens }
|
|
7861
|
+
}),
|
|
7862
|
+
policy: Object.freeze({ ...budgetSettings() }),
|
|
7863
|
+
assertCurrent: () => {
|
|
7864
|
+
if (!lifetime.isCurrent(revision) || snapshotProof !== proof || proofFor(snapshot) === void 0 || source.readSnapshot() !== snapshot || excludedModels().has(modelId)) throw new Error("COPILOT_MANUAL_RECOVERY_ACCOUNT_PROOF_CHANGED");
|
|
7865
|
+
}
|
|
7866
|
+
});
|
|
7867
|
+
},
|
|
7932
7868
|
captureSearchProof() {
|
|
7933
7869
|
const revision = lifetime.revision;
|
|
7934
7870
|
const captured = snapshotProof;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import "./copilot-identity-DRZY_d2X.js";
|
|
2
|
+
import { i as resolveRequestBudgetPolicy, r as calculateRequestBudget } from "./request-budget-DLY_aRq0.js";
|
|
3
|
+
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
4
|
+
import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
|
|
5
|
+
//#region lib/types/manual-compaction-recovery.js
|
|
6
|
+
function recoverError(code) {
|
|
7
|
+
return /* @__PURE__ */ new Error(`COPILOT_MANUAL_RECOVERY_${code}`);
|
|
8
|
+
}
|
|
9
|
+
function sumUsage(usages) {
|
|
10
|
+
const required = (key) => usages.reduce((sum, usage) => sum + usage[key], 0);
|
|
11
|
+
const optional = (key) => usages.every((usage) => usage[key] !== void 0) ? { [key]: usages.reduce((sum, usage) => sum + usage[key], 0) } : {};
|
|
12
|
+
return {
|
|
13
|
+
inputTokens: required("inputTokens"),
|
|
14
|
+
outputTokens: required("outputTokens"),
|
|
15
|
+
...optional("totalTokens"),
|
|
16
|
+
...optional("cacheReadTokens"),
|
|
17
|
+
...optional("cacheWriteTokens"),
|
|
18
|
+
...optional("reasoningTokens")
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Bounded, explicit manual-only map/fold. The native engine still owns the only
|
|
23
|
+
* durable transaction, source-stability check, shrink check and cancellation.
|
|
24
|
+
*/
|
|
25
|
+
async function summarizeOversizedManualInput(options) {
|
|
26
|
+
const { input, signal, estimate, summarize, makeCheckpoint, assertCurrent } = options;
|
|
27
|
+
const maxCalls = options.maxCalls ?? 16;
|
|
28
|
+
if (!Number.isSafeInteger(maxCalls) || maxCalls < 2 || maxCalls > 32 || !Number.isSafeInteger(options.inputLimit) || options.inputLimit <= 0) throw recoverError("INVALID_POLICY");
|
|
29
|
+
const prefix = input.messages[0]?.role === "system" ? input.messages.slice(0, 1) : [];
|
|
30
|
+
const messages = input.messages.slice(prefix.length);
|
|
31
|
+
if (messages.length === 0) throw recoverError("NO_HISTORY");
|
|
32
|
+
const pending = /* @__PURE__ */ new Set();
|
|
33
|
+
const safeBoundaries = /* @__PURE__ */ new Set([0]);
|
|
34
|
+
for (let index = 0; index < messages.length; index++) {
|
|
35
|
+
const message = messages[index];
|
|
36
|
+
if (message.role === "assistant") {
|
|
37
|
+
for (const block of message.content) if (block.type === "tool-call") {
|
|
38
|
+
if (!block.id || pending.has(block.id)) throw recoverError("UNBALANCED");
|
|
39
|
+
pending.add(block.id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (message.role === "tool") {
|
|
43
|
+
if (!message.toolCallId || !pending.delete(message.toolCallId)) throw recoverError("UNBALANCED");
|
|
44
|
+
}
|
|
45
|
+
if (pending.size === 0) safeBoundaries.add(index + 1);
|
|
46
|
+
}
|
|
47
|
+
if (pending.size !== 0) throw recoverError("UNBALANCED");
|
|
48
|
+
let previous;
|
|
49
|
+
let offset = 0;
|
|
50
|
+
let calls = 0;
|
|
51
|
+
const usages = [];
|
|
52
|
+
while (offset < messages.length) {
|
|
53
|
+
signal.throwIfAborted();
|
|
54
|
+
assertCurrent?.();
|
|
55
|
+
const carry = previous === void 0 ? [] : [makeCheckpoint(previous.summary)];
|
|
56
|
+
const head = [...prefix, ...carry];
|
|
57
|
+
if (estimate({
|
|
58
|
+
tools: input.tools,
|
|
59
|
+
messages: head
|
|
60
|
+
}) >= options.inputLimit) throw recoverError("FIXED_PREFIX");
|
|
61
|
+
let end = offset;
|
|
62
|
+
for (let index = offset + 1; index <= messages.length; index++) {
|
|
63
|
+
if (estimate({
|
|
64
|
+
tools: input.tools,
|
|
65
|
+
messages: [...head, ...messages.slice(offset, index)]
|
|
66
|
+
}) > options.inputLimit) break;
|
|
67
|
+
if (safeBoundaries.has(index)) end = index;
|
|
68
|
+
}
|
|
69
|
+
if (end === offset) throw recoverError("INDIVISIBLE");
|
|
70
|
+
if (++calls > maxCalls) throw recoverError("CALL_LIMIT");
|
|
71
|
+
const result = await summarize({
|
|
72
|
+
tools: input.tools,
|
|
73
|
+
messages: [...head, ...messages.slice(offset, end)]
|
|
74
|
+
});
|
|
75
|
+
signal.throwIfAborted();
|
|
76
|
+
assertCurrent?.();
|
|
77
|
+
if (previous !== void 0 && (result.provider !== previous.provider || result.model !== previous.model || result.maxTokens !== previous.maxTokens)) throw recoverError("ROUTE_CHANGED");
|
|
78
|
+
if (result.summary.length === 0 || result.summary.some((block) => block.type !== "text") || !result.summary.some((block) => block.type === "text" && block.text.trim())) throw recoverError("EMPTY_SUMMARY");
|
|
79
|
+
if (result.usage !== void 0) usages.push(result.usage);
|
|
80
|
+
previous = result;
|
|
81
|
+
offset = end;
|
|
82
|
+
}
|
|
83
|
+
if (previous === void 0) throw recoverError("NO_HISTORY");
|
|
84
|
+
return {
|
|
85
|
+
summary: [...previous.summary],
|
|
86
|
+
provider: previous.provider,
|
|
87
|
+
model: previous.model,
|
|
88
|
+
...previous.maxTokens === void 0 ? {} : { maxTokens: previous.maxTokens },
|
|
89
|
+
...usages.length === calls ? { usage: sumUsage(usages) } : {}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Deployment-selected alternative to stock BasicCompactionEngine. Do not
|
|
94
|
+
* mount both: Cordis compaction is a singleton, not an overridable service.
|
|
95
|
+
*/
|
|
96
|
+
var CopilotManualRecoveryCompactionEngine = class extends BasicCompactionEngine {
|
|
97
|
+
manual = /* @__PURE__ */ new WeakMap();
|
|
98
|
+
async compactNow(agent, signal, sourceCommandId) {
|
|
99
|
+
this.manual.set(agent, (this.manual.get(agent) ?? 0) + 1);
|
|
100
|
+
try {
|
|
101
|
+
return await super.compactNow(agent, signal, sourceCommandId);
|
|
102
|
+
} finally {
|
|
103
|
+
const remaining = this.manual.get(agent) - 1;
|
|
104
|
+
if (remaining === 0) this.manual.delete(agent);
|
|
105
|
+
else this.manual.set(agent, remaining);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async summarize(input, agent, signal) {
|
|
109
|
+
const routed = agent.session.requestHeader()?.config;
|
|
110
|
+
const policy = this.config.modelPolicies.find((item) => item.provider === routed?.provider && item.model === routed.model);
|
|
111
|
+
const configuredProvider = policy?.summarizationProvider ?? this.config.summarizationProvider;
|
|
112
|
+
const configuredModel = policy?.summarizationModel ?? this.config.summarizationModel;
|
|
113
|
+
const selected = configuredProvider.length > 0 ? {
|
|
114
|
+
provider: configuredProvider,
|
|
115
|
+
model: configuredModel
|
|
116
|
+
} : routed?.provider && routed.model ? routed : {
|
|
117
|
+
provider: agent.options.provider,
|
|
118
|
+
model: agent.options.model
|
|
119
|
+
};
|
|
120
|
+
const summaryProvider = selected.provider;
|
|
121
|
+
const summaryModel = selected.model;
|
|
122
|
+
if (!this.manual.has(agent) || summaryProvider !== "github-copilot-preview" || !summaryModel) return super.summarize(input, agent, signal);
|
|
123
|
+
const lease = this.ctx.get("githubCopilotPreview")?.recoveryLimits(summaryModel);
|
|
124
|
+
if (lease === void 0) throw recoverError("ACCOUNT_PROOF_UNAVAILABLE");
|
|
125
|
+
const maxTokens = policy?.maxTokens ?? this.config.maxTokens;
|
|
126
|
+
const budget = calculateRequestBudget(lease.limits, maxTokens, resolveRequestBudgetPolicy(lease.policy));
|
|
127
|
+
if (!budget.ok) throw recoverError(budget.code);
|
|
128
|
+
const toolHistoryBytes = Buffer.byteLength(JSON.stringify(agent.session.toolHistory()), "utf8");
|
|
129
|
+
const inputLimit = budget.budget.hardInputLimit - 4096 - toolHistoryBytes;
|
|
130
|
+
if (inputLimit <= 0) throw recoverError("FIXED_PREFIX");
|
|
131
|
+
const operationSignal = signal ?? new AbortController().signal;
|
|
132
|
+
const estimate = (candidate) => Buffer.byteLength(JSON.stringify(candidate), "utf8");
|
|
133
|
+
if (estimate(input) <= inputLimit) return super.summarize(input, agent, signal);
|
|
134
|
+
return summarizeOversizedManualInput({
|
|
135
|
+
input,
|
|
136
|
+
inputLimit,
|
|
137
|
+
signal: operationSignal,
|
|
138
|
+
estimate,
|
|
139
|
+
assertCurrent: lease.assertCurrent,
|
|
140
|
+
makeCheckpoint: (summary) => createUserMessage({
|
|
141
|
+
source: { kind: "user" },
|
|
142
|
+
content: [
|
|
143
|
+
{
|
|
144
|
+
type: "text",
|
|
145
|
+
text: "Prior intermediate checkpoint (merge with newer context):\n<compacted-summary>"
|
|
146
|
+
},
|
|
147
|
+
...summary,
|
|
148
|
+
{
|
|
149
|
+
type: "text",
|
|
150
|
+
text: "</compacted-summary>"
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}),
|
|
154
|
+
summarize: (candidate) => super.summarize(candidate, agent, signal)
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
//#endregion
|
|
159
|
+
export { CopilotManualRecoveryCompactionEngine, CopilotManualRecoveryCompactionEngine as default, summarizeOversizedManualInput };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region lib/types/request-budget.js
|
|
2
|
+
/** The safety allowance matches the pinned native SDK; pressure is a separate opt-in check. */
|
|
3
|
+
const DEFAULT_REQUEST_BUDGET_POLICY = Object.freeze({
|
|
4
|
+
safetyTokens: 4096,
|
|
5
|
+
pressureRatio: .9,
|
|
6
|
+
compactionReasoning: "prefer-low"
|
|
7
|
+
});
|
|
8
|
+
/** Validate deployment policy before applying defaults; unknown keys fail rather than silently drift. */
|
|
9
|
+
function resolveRequestBudgetPolicy(config = {}) {
|
|
10
|
+
const keys = /* @__PURE__ */ new Set([
|
|
11
|
+
"safetyTokens",
|
|
12
|
+
"pressureRatio",
|
|
13
|
+
"compactionReasoning"
|
|
14
|
+
]);
|
|
15
|
+
for (const key of Object.keys(config)) if (!keys.has(key)) throw new Error(`COPILOT_REQUEST_BUDGET_POLICY_INVALID: unknown setting ${key}`);
|
|
16
|
+
const safetyTokens = config.safetyTokens === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.safetyTokens : config.safetyTokens;
|
|
17
|
+
const pressureRatio = config.pressureRatio === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.pressureRatio : config.pressureRatio;
|
|
18
|
+
const compactionReasoning = config.compactionReasoning === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning : config.compactionReasoning;
|
|
19
|
+
if (!Number.isSafeInteger(safetyTokens) || safetyTokens < 0) throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: safetyTokens must be a non-negative safe integer");
|
|
20
|
+
if (!Number.isFinite(pressureRatio) || pressureRatio <= 0 || pressureRatio > 1) throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: pressureRatio must be greater than zero and at most one");
|
|
21
|
+
if (compactionReasoning !== "prefer-low" && compactionReasoning !== "preserve") throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: unsupported compactionReasoning");
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
safetyTokens,
|
|
24
|
+
pressureRatio,
|
|
25
|
+
compactionReasoning
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function failure(code, message) {
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
ok: false,
|
|
31
|
+
code,
|
|
32
|
+
message: `${code}: ${message}`
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function positiveInteger(value) {
|
|
36
|
+
return Number.isSafeInteger(value) && value > 0;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reserve output under the combined context and independently enforce the prompt ceiling.
|
|
40
|
+
* `policy` must come from resolveRequestBudgetPolicy; no caller cap or catalog object is changed.
|
|
41
|
+
*/
|
|
42
|
+
function calculateRequestBudget(limits, requestedMaxTokens, policy = DEFAULT_REQUEST_BUDGET_POLICY) {
|
|
43
|
+
const { contextWindow, maxInputTokens, maxTokens } = limits;
|
|
44
|
+
if (!positiveInteger(contextWindow) || !positiveInteger(maxTokens) || maxInputTokens !== void 0 && !positiveInteger(maxInputTokens)) return failure("COPILOT_REQUEST_INVALID_LIMITS", "model token capacities must be positive safe integers");
|
|
45
|
+
if (requestedMaxTokens !== void 0 && !positiveInteger(requestedMaxTokens)) return failure("COPILOT_REQUEST_INVALID_OUTPUT_LIMIT", "request output cap must be a positive safe integer");
|
|
46
|
+
const outputReservation = requestedMaxTokens ?? maxTokens;
|
|
47
|
+
if (outputReservation > maxTokens) return failure("COPILOT_REQUEST_OUTPUT_LIMIT_EXCEEDED", `request output cap ${outputReservation} exceeds model output capacity ${maxTokens}`);
|
|
48
|
+
const contextInputLimit = contextWindow - outputReservation;
|
|
49
|
+
const limitingFactor = maxInputTokens !== void 0 && maxInputTokens <= contextInputLimit ? "prompt" : "context";
|
|
50
|
+
const hardInputLimit = Math.min(maxInputTokens ?? contextInputLimit, contextInputLimit) - policy.safetyTokens;
|
|
51
|
+
if (hardInputLimit <= 0) return failure("COPILOT_REQUEST_NO_INPUT_HEADROOM", "output reservation and safety allowance leave no positive input budget");
|
|
52
|
+
return Object.freeze({
|
|
53
|
+
ok: true,
|
|
54
|
+
budget: Object.freeze({
|
|
55
|
+
contextWindow,
|
|
56
|
+
...maxInputTokens === void 0 ? {} : { maxInputTokens },
|
|
57
|
+
maxOutputTokens: maxTokens,
|
|
58
|
+
outputReservation,
|
|
59
|
+
hardInputLimit,
|
|
60
|
+
pressureInputLimit: Math.floor(hardInputLimit * policy.pressureRatio),
|
|
61
|
+
limitingFactor
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check an estimated full prompt; estimates are not provider-exact token counts.
|
|
67
|
+
* Enable pressure only for an owned ordinary loop call with a compaction recovery path.
|
|
68
|
+
* Auxiliary and agentless calls use hard admission, including compaction itself.
|
|
69
|
+
*/
|
|
70
|
+
function assessRequestBudget(estimatedInput, budget, pressure = false) {
|
|
71
|
+
if (!Number.isFinite(estimatedInput) || estimatedInput < 0 || estimatedInput > Number.MAX_SAFE_INTEGER) return failure("COPILOT_REQUEST_INVALID_ESTIMATE", "estimated input must be finite, non-negative, and safely representable");
|
|
72
|
+
const input = Math.ceil(estimatedInput);
|
|
73
|
+
if (input > budget.hardInputLimit) return failure(budget.limitingFactor === "prompt" ? "COPILOT_REQUEST_INPUT_LIMIT_EXCEEDED" : "COPILOT_REQUEST_CONTEXT_LIMIT_EXCEEDED", `estimated input ${input} exceeds input budget ${budget.hardInputLimit} with output reservation ${budget.outputReservation}`);
|
|
74
|
+
if (pressure && input > budget.pressureInputLimit) return failure("COPILOT_REQUEST_PRESSURE_EXCEEDED", `estimated input ${input} exceeds proactive compaction budget ${budget.pressureInputLimit}`);
|
|
75
|
+
return Object.freeze({ ok: true });
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Select a low-cost supported effort only for a caller-confirmed compaction request.
|
|
79
|
+
* A supplied effort, including a materialized provider default, wins unchanged; native validation
|
|
80
|
+
* remains authoritative. Unsupported low-cost controls preserve the provider default, never off/none.
|
|
81
|
+
*/
|
|
82
|
+
function selectCompactionReasoning(supportedEfforts, requestedEffort, mode = DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning) {
|
|
83
|
+
if (requestedEffort !== void 0 || mode === "preserve") return requestedEffort;
|
|
84
|
+
return supportedEfforts.find((effort) => effort === "minimal") ?? supportedEfforts.find((effort) => effort === "low");
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { selectCompactionReasoning as a, resolveRequestBudgetPolicy as i, assessRequestBudget as n, calculateRequestBudget as r, DEFAULT_REQUEST_BUDGET_POLICY as t };
|
package/lib/routed-web.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./copilot-identity-DRZY_d2X.js";
|
|
2
|
+
import { C as currentSearchInitiator, O as isPluginPreviewProvider, t as isCopilotSearchSelection, w as currentSearchSelection } from "./search-routing-jzNYveyK.js";
|
|
2
3
|
import { WebError, WebRuntime } from "@deepseek-ai/dsh-web";
|
|
3
4
|
//#region lib/types/routed-web.js
|
|
4
5
|
/**
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
+
import "./copilot-identity-DRZY_d2X.js";
|
|
1
2
|
import { getSupportedThinkingLevels } from "@earendil-works/pi-ai";
|
|
2
3
|
import { builtinProviders, getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
|
|
3
4
|
import { attributionHeaders } from "@deepseek-ai/dsh-llm";
|
|
4
5
|
import { WebError } from "@deepseek-ai/dsh-web";
|
|
5
|
-
//#region lib/types/copilot-identity.js
|
|
6
|
-
/** Native OAuth ownership and the sole plugin-owned, account-discovered route. */
|
|
7
|
-
const GITHUB_COPILOT_CREDENTIAL_KEY$1 = "llm-pi-ai/github-copilot";
|
|
8
|
-
const GITHUB_COPILOT_PROVIDER_ID = "github-copilot";
|
|
9
|
-
const GITHUB_COPILOT_PREVIEW_PROVIDER_ID = "github-copilot-preview";
|
|
10
|
-
const GITHUB_COPILOT_AUTO_MODEL_ID = "auto";
|
|
11
|
-
const GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID = "auto-efficiency";
|
|
12
|
-
const GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID = "auto-intelligence";
|
|
13
|
-
function autoModelPreference(model) {
|
|
14
|
-
if (model === "auto") return "balance";
|
|
15
|
-
if (model === "auto-efficiency") return "efficiency";
|
|
16
|
-
if (model === "auto-intelligence") return "intelligence";
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
6
|
//#region lib/types/model-protocol.js
|
|
20
7
|
/** Project only public leaves and the same pi library's supported wire efforts. */
|
|
21
8
|
function projectModelFacts(model) {
|
|
@@ -802,4 +789,4 @@ async function routeSessionSearch(request, signal, deps) {
|
|
|
802
789
|
};
|
|
803
790
|
}
|
|
804
791
|
//#endregion
|
|
805
|
-
export {
|
|
792
|
+
export { currentSearchInitiator as C, readSettingsNamespace as D, readConfigValue as E, isPluginPreviewProvider 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, readCopilotCatalog 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 };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
2
|
+
import BasicCompactionEngine from '@deepseek-ai/dsh-compaction-basic';
|
|
3
|
+
import type { ContentBlock, Message, TokenUsage, ToolSchema } from '@deepseek-ai/dsh-llm';
|
|
4
|
+
import type { CommandId } from '@deepseek-ai/dsh-commands/brand';
|
|
5
|
+
import type { CompactionResult } from '@deepseek-ai/dsh-compaction';
|
|
6
|
+
interface RecoveryMessage {
|
|
7
|
+
readonly role: string;
|
|
8
|
+
readonly content: readonly {
|
|
9
|
+
readonly type: string;
|
|
10
|
+
readonly id?: string;
|
|
11
|
+
}[];
|
|
12
|
+
readonly toolCallId?: string;
|
|
13
|
+
}
|
|
14
|
+
interface RecoveryInput<M> {
|
|
15
|
+
readonly messages: readonly M[];
|
|
16
|
+
readonly tools?: readonly ToolSchema[];
|
|
17
|
+
}
|
|
18
|
+
interface RecoveryResult {
|
|
19
|
+
readonly summary: ContentBlock[];
|
|
20
|
+
readonly provider: string;
|
|
21
|
+
readonly model: string;
|
|
22
|
+
readonly maxTokens?: number;
|
|
23
|
+
readonly usage?: TokenUsage;
|
|
24
|
+
}
|
|
25
|
+
interface RecoveryOptions<M extends RecoveryMessage, R extends RecoveryResult> {
|
|
26
|
+
readonly input: RecoveryInput<M>;
|
|
27
|
+
readonly inputLimit: number;
|
|
28
|
+
readonly maxCalls?: number;
|
|
29
|
+
readonly signal: AbortSignal;
|
|
30
|
+
readonly estimate: (input: RecoveryInput<M>) => number;
|
|
31
|
+
readonly summarize: (input: RecoveryInput<M>) => Promise<R>;
|
|
32
|
+
readonly makeCheckpoint: (summary: readonly ContentBlock[]) => M;
|
|
33
|
+
readonly assertCurrent?: () => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Bounded, explicit manual-only map/fold. The native engine still owns the only
|
|
37
|
+
* durable transaction, source-stability check, shrink check and cancellation.
|
|
38
|
+
*/
|
|
39
|
+
export declare function summarizeOversizedManualInput<M extends RecoveryMessage, R extends RecoveryResult>(options: RecoveryOptions<M, R>): Promise<RecoveryResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Deployment-selected alternative to stock BasicCompactionEngine. Do not
|
|
42
|
+
* mount both: Cordis compaction is a singleton, not an overridable service.
|
|
43
|
+
*/
|
|
44
|
+
export declare class CopilotManualRecoveryCompactionEngine extends BasicCompactionEngine {
|
|
45
|
+
private readonly manual;
|
|
46
|
+
compactNow(agent: Agent, signal: AbortSignal, sourceCommandId?: CommandId): Promise<CompactionResult | null>;
|
|
47
|
+
protected summarize(input: RecoveryInput<Message>, agent: Agent, signal?: AbortSignal): Promise<RecoveryResult>;
|
|
48
|
+
}
|
|
49
|
+
export default CopilotManualRecoveryCompactionEngine;
|
|
50
|
+
//# sourceMappingURL=manual-compaction-recovery.d.ts.map
|
|
@@ -2,7 +2,7 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
2
2
|
import type { PiAiProviderProfile } from '@deepseek-ai/dsh-llm-pi-ai';
|
|
3
3
|
import { GITHUB_COPILOT_PREVIEW_PROVIDER_ID } from './copilot-identity.ts';
|
|
4
4
|
import type { AccountModelLoadOptions } from './account-model-source.ts';
|
|
5
|
-
import type { AccountModelRejection } from './account-model-catalog.ts';
|
|
5
|
+
import type { AccountModelDescriptor, AccountModelRejection } from './account-model-catalog.ts';
|
|
6
6
|
import type { InlineConfig } from './config.ts';
|
|
7
7
|
import type { RequestBudgetPolicy } from './request-budget.ts';
|
|
8
8
|
/** Safe request knobs; identities, model tables, endpoints and credentials are not configurable. */
|
|
@@ -32,6 +32,12 @@ export interface GitHubCopilotPreviewView {
|
|
|
32
32
|
}
|
|
33
33
|
export interface GitHubCopilotPreview {
|
|
34
34
|
getView(): GitHubCopilotPreviewView;
|
|
35
|
+
/** Synchronous, account-proven capacities for an explicit manual summary; never triggers discovery. */
|
|
36
|
+
recoveryLimits(modelId: string): {
|
|
37
|
+
readonly limits: Pick<AccountModelDescriptor, 'contextWindow' | 'maxInputTokens' | 'maxTokens'>;
|
|
38
|
+
readonly policy: Partial<RequestBudgetPolicy>;
|
|
39
|
+
readonly assertCurrent: () => void;
|
|
40
|
+
} | undefined;
|
|
35
41
|
/** Host-only current endpoint facts; no discovery and no credential material. */
|
|
36
42
|
routeFacts(modelId: string): {
|
|
37
43
|
readonly api: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-github-copilot",
|
|
3
3
|
"description": "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
|
|
4
|
-
"version": "0.4.0-alpha.
|
|
4
|
+
"version": "0.4.0-alpha.69",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
"types": "./lib/types/routed-web.d.ts",
|
|
34
34
|
"default": "./lib/routed-web.js"
|
|
35
35
|
},
|
|
36
|
+
"./manual-compaction-recovery": {
|
|
37
|
+
"types": "./lib/types/manual-compaction-recovery.d.ts",
|
|
38
|
+
"default": "./lib/manual-compaction-recovery.js"
|
|
39
|
+
},
|
|
36
40
|
"./deployment-baseline.json": "./deployment-baseline.json",
|
|
37
41
|
"./package.json": "./package.json"
|
|
38
42
|
},
|
|
@@ -59,6 +63,7 @@
|
|
|
59
63
|
"docs/official-first-020-rc2.md",
|
|
60
64
|
"docs/web-lifecycle-rc2.md",
|
|
61
65
|
"docs/copilot-compaction.md",
|
|
66
|
+
"docs/manual-compaction-recovery.md",
|
|
62
67
|
"docs/copilot-usage.md",
|
|
63
68
|
"docs/automatic-model-routing.md",
|
|
64
69
|
"output/auto-model-mockup/index.html",
|
|
@@ -88,6 +93,9 @@
|
|
|
88
93
|
"@deepseek-ai/cordis": "^4.0.4",
|
|
89
94
|
"@deepseek-ai/dsh-agent": "0.2.0-rc.2",
|
|
90
95
|
"@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.2",
|
|
96
|
+
"@deepseek-ai/dsh-commands": "0.2.0-rc.2",
|
|
97
|
+
"@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
|
|
98
|
+
"@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
|
|
91
99
|
"@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
|
|
92
100
|
"@deepseek-ai/dsh-authorization": "0.2.0-rc.2",
|
|
93
101
|
"@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
|
|
@@ -97,6 +105,7 @@
|
|
|
97
105
|
"@deepseek-ai/dsh-launch-environment": "0.2.0-rc.2",
|
|
98
106
|
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
99
107
|
"@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
|
|
108
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
100
109
|
"@deepseek-ai/dsh-scope": "0.2.0-rc.2",
|
|
101
110
|
"@deepseek-ai/dsh-settings": "0.2.0-rc.2",
|
|
102
111
|
"@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2",
|
|
@@ -136,6 +145,9 @@
|
|
|
136
145
|
"@deepseek-ai/cordis": "~4.0.4",
|
|
137
146
|
"@deepseek-ai/dsh-agent": "0.2.0-rc.2",
|
|
138
147
|
"@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.2",
|
|
148
|
+
"@deepseek-ai/dsh-commands": "0.2.0-rc.2",
|
|
149
|
+
"@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
|
|
150
|
+
"@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
|
|
139
151
|
"@deepseek-ai/dsh-api-gateway": "0.2.0-rc.2",
|
|
140
152
|
"@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
|
|
141
153
|
"@deepseek-ai/dsh-app-boot": "0.2.0-rc.2",
|