dsh-github-copilot 0.4.0-alpha.73 → 0.4.0-alpha.74

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0-alpha.74 (prepared)
4
+
5
+ - Add `/copilot-compact [status|cancel]` to the explicitly selected recovery engine when native commands/jobs are available (#244).
6
+ - Acknowledge a Session-owned background job promptly instead of holding Desktop's unary command request past its response-header timeout. Preserve native `/compact`, maintenance locks and compaction transactions.
7
+ - Deduplicate active starts, cancel and drain on teardown, and collect native settlement without waking the model or resuming a Goal. Admission is not completion; failed summaries retain their native diagnostics.
8
+
3
9
  ## 0.4.0-alpha.73 (prepared)
4
10
 
5
11
  - Prevent managed Copilot failure/cancellation terminal zero-usage samples from resetting native context pressure; preserve successful zero and real nonzero usage (#242).
package/README.md CHANGED
@@ -104,7 +104,7 @@ The Host reads GitHub's internal quota endpoint using the existing canonical OAu
104
104
 
105
105
  ## Install and sign in
106
106
 
107
- The commands below target the package version `0.4.0-alpha.73`. 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):
107
+ The commands below target the package version `0.4.0-alpha.74`. 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):
108
108
 
109
109
  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):
110
110
 
@@ -117,10 +117,10 @@ Include any launcher patch files with repeated `--patch /absolute/file` argument
117
117
  For a standalone named profile only, the supported CLI command is:
118
118
 
119
119
  ```sh
120
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.73/dsh-github-copilot-0.4.0-alpha.73.tgz
120
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.74/dsh-github-copilot-0.4.0-alpha.74.tgz
121
121
  ```
122
122
 
123
- For Desktop profiles, use Desktop's native package manager with `dsh-github-copilot@0.4.0-alpha.73` 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.
123
+ For Desktop profiles, use Desktop's native package manager with `dsh-github-copilot@0.4.0-alpha.74` 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.
124
124
 
125
125
  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.
126
126
 
@@ -173,7 +173,7 @@ Agents should treat the browser authorization as a human handoff, not as a token
173
173
  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.
174
174
  6. Use **Sign out** only when the user explicitly asks to disconnect the account. It deletes the Copilot credential record but preserves route settings.
175
175
 
176
- 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.73`, 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).
176
+ 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.74`, 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).
177
177
 
178
178
  **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.
179
179
 
@@ -332,6 +332,8 @@ Calls explicitly marked `purpose: 'compaction'` bypass the early-pressure signal
332
332
 
333
333
  **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.
334
334
 
335
+ When that recovery engine and native jobs are available, `/copilot-compact` starts a Session-owned background compaction without holding Desktop's command HTTP request open for the entire summary. Use `/copilot-compact status` or `/copilot-compact cancel` for its latest job. Admission is not summary success; failures remain explicit. Completion does not wake the model or resume a Goal. Native `/compact` stays unchanged, and job status is process-local.
336
+
335
337
  ## Copilot tool compatibility
336
338
 
337
339
  To prevent observed invalid Copilot tool payloads, the package sets the managed route's `compat.supportsStrictMode` leaf to `false` and applies two schema-only fixes when the selected provider is canonical `github-copilot` or the plugin-owned account route `github-copilot-preview`: it removes top-level `sandbox_permissions` and `justification` properties, and rewrites Core's multi-action `update_goal` parameters as a discriminated `oneOf`. Each Goal action then advertises only its legal fields: `complete`, `pause`, and `resume` cannot carry edit or blocker fields; `blocked` requires `blocked_reason`; and `edit` alone exposes replacement fields. Execution still uses Core's original Goal tool and service. Non-Copilot prompt assemblies are unchanged.
@@ -448,8 +450,8 @@ Report the published Release URL, version, tag/commit and verified asset SHA-256
448
450
  `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.
449
451
 
450
452
  ```sh
451
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.73/dsh-github-copilot-0.4.0-alpha.73.tgz
452
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.73/SHA256SUMS
453
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.74/dsh-github-copilot-0.4.0-alpha.74.tgz
454
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.74/SHA256SUMS
453
455
  sha256sum --check SHA256SUMS
454
456
  ```
455
457
 
@@ -457,7 +459,7 @@ PowerShell can verify the same two downloaded files with:
457
459
 
458
460
  ```powershell
459
461
  $expected = (Get-Content .\SHA256SUMS).Split()[0]
460
- $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.73.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
462
+ $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.74.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
461
463
  if ($actual -cne $expected) { throw 'Release checksum mismatch' }
462
464
  ```
463
465
 
package/README.zh.md CHANGED
@@ -26,7 +26,7 @@ Core 管理。详见[图片兼容性与限制](./docs/image-input-compatibility.
26
26
 
27
27
  截图来自当前构建 Client 的隔离浏览器 fixture,使用合成 Provider。它只证明已发布配置界面的形态,不证明真实凭据、账号权限、搜索成功或当前 Desktop 已加载。
28
28
 
29
- > 当前文档与安装命令对应版本 `0.4.0-alpha.73`。源码、发布制品、已安装版本和实际加载运行时需分别确认;本地升级和中断会话的重启仍需用户批准。
29
+ > 当前文档与安装命令对应版本 `0.4.0-alpha.74`。源码、发布制品、已安装版本和实际加载运行时需分别确认;本地升级和中断会话的重启仍需用户批准。
30
30
 
31
31
  Web search 路由现在优先显示在插件详情页;宿主不支持详情页插槽时才回退到 **设置 → 模型**或独立 Web search section。搜索子 Fiber 仍独立等待 Remote,不影响账号控件和既有搜索安全检查。
32
32
 
@@ -119,10 +119,10 @@ node package/scripts/check-search-composition.mjs --profile-dir /absolute/profil
119
119
  仅对独立的具名 profile,获准且网络可用时,可通过受支持的 CLI 命令安装:
120
120
 
121
121
  ```sh
122
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.73/dsh-github-copilot-0.4.0-alpha.73.tgz
122
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.74/dsh-github-copilot-0.4.0-alpha.74.tgz
123
123
  ```
124
124
 
125
- Desktop profile 请在完成同样的预检后,使用 Desktop 原生包管理器安装 `dsh-github-copilot@0.4.0-alpha.73`。Desktop 保留 `desktop` profile,CLI 不负责管理。若 registry 被公司封禁或不可用,不要更换网络绕行或使用离线 CLI;请停止。[受控离线 CLI 流程](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles)仅适用于独立具名 profile,不适用于 Desktop。
125
+ Desktop profile 请在完成同样的预检后,使用 Desktop 原生包管理器安装 `dsh-github-copilot@0.4.0-alpha.74`。Desktop 保留 `desktop` profile,CLI 不负责管理。若 registry 被公司封禁或不可用,不要更换网络绕行或使用离线 CLI;请停止。[受控离线 CLI 流程](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles)仅适用于独立具名 profile,不适用于 Desktop。
126
126
 
127
127
  随后打开上表对应的 Models UI,找到 **GitHub Copilot**,点击 **Sign in** 并完成 GitHub device-code 流程。安装会修改指定 profile;是否立即激活取决于该 profile 的常规 reload/restart 策略。
128
128
 
@@ -175,7 +175,7 @@ Agent 应把浏览器授权视为需要用户完成的 handoff,而不是自行
175
175
  5. 确认 **Signed in** 并检查自动发现结果,再请用户选择模型。已登录时打开 Models 会自动确保缺失/过期元数据,新鲜 ready 缓存不发请求。错误可使用 **Retry**,有意强制更新时使用 **Manage → Refresh models**,不作为常规设置步骤。状态读取本身不发现;登录、元数据与真实调用成功是独立证据。
176
176
  6. 只有用户明确要求断开账号时才使用 **Sign out**;它会删除 Copilot credential record,但保留 route settings。
177
177
 
178
- 每个新版本默认同时分发到 GitHub Releases 和 npm,两个渠道使用同一份已验证 tarball。应固定版本并核对所用渠道的证据:Release 的 `SHA256SUMS`;从 npm 安装时另核对 `dist.integrity`。Desktop profile 只能通过原生 Desktop 包管理器安装;获准且 registry 可用时输入 `dsh-github-copilot@0.4.0-alpha.73`,不是 URL 或本地文件。Desktop 保留 `desktop` profile,不能通过 DSH CLI 管理。受控离线 CLI 维护仅适用于独立具名 profile,不得作为 Desktop 安装绕行方案。[双渠道发布与 OIDC 要求](./docs/npm-distribution.md)保持不变。
178
+ 每个新版本默认同时分发到 GitHub Releases 和 npm,两个渠道使用同一份已验证 tarball。应固定版本并核对所用渠道的证据:Release 的 `SHA256SUMS`;从 npm 安装时另核对 `dist.integrity`。Desktop profile 只能通过原生 Desktop 包管理器安装;获准且 registry 可用时输入 `dsh-github-copilot@0.4.0-alpha.74`,不是 URL 或本地文件。Desktop 保留 `desktop` profile,不能通过 DSH CLI 管理。受控离线 CLI 维护仅适用于独立具名 profile,不得作为 Desktop 安装绕行方案。[双渠道发布与 OIDC 要求](./docs/npm-distribution.md)保持不变。
179
179
 
180
180
  **Desktop package 更新与 Web 生命周期边界:**原生 manager 对已安装 package 原位升级返回的 `restart-required` 是权威结果,与移除/重加 plugin bundle 的行为是两个不同问题。涉及服务重编排补丁(`cordis.patch.yml`,如本插件所采用的隔离路由 Web 搜索层)的停用、移除或升级,可能让依赖条目保持 pending,直到完全退出并冷重启 Desktop。若原生 manager 只报告类似 `pending (waiting for service: web)` 的条目,同时本插件已经显示 **Off**,说明请求的停用状态已经落盘;请冷重启 Desktop,不要反复切换或重装插件。其它错误不属于此提示范围,仍需单独排查。
181
181
 
@@ -335,6 +335,8 @@ Responses 解析器会保留公开的 `reasoning_summary_text`、`reasoning_text
335
335
 
336
336
  **仍不保证救回所有已经超限的旧历史。** 默认手动 compact 仍会在模型发送前拒绝超限摘要。另有可单独选择的[手动恢复引擎](./docs/manual-compaction-recovery.md):仅对可分割且工具调用配对完整的托管 Copilot 历史进行有界中间摘要,最终持久事务仍由 Core 负责。它必须**替换**原有压缩服务而非并列安装;仅安装插件不会启用。不可分割的输入、过大的固定前缀或被截断的输出都不会替换历史;不会自动切换模型或偷偷删除历史。
337
337
 
338
+ 选用该恢复引擎且原生 jobs 服务可用时,`/copilot-compact` 会启动属于当前 Session 的后台压缩,不再让 Desktop 的命令 HTTP 请求等待整个摘要完成。使用 `/copilot-compact status` 查询最新任务,或 `/copilot-compact cancel` 请求取消。“已启动”不代表摘要成功,失败仍明确报告。完成后不会唤醒模型或恢复 Goal;原生 `/compact` 不变,任务状态不跨 Host 重启保存。
339
+
338
340
  ## Copilot Tool 兼容
339
341
 
340
342
  为避免已观察到的无效 Copilot Tool payload,本包会把托管 route 的 `compat.supportsStrictMode` 叶节点设为 `false`,并在所选 provider 为 `github-copilot`,或已确认由本插件挂载的 `github-copilot-preview` 时执行两项仅作用于 Schema 的修复:从 Tool Schema 顶层删除 `sandbox_permissions` 与 `justification`,并把 Core 的多动作 `update_goal` 参数改写为带判别字段的 `oneOf`。这样每种 Goal action 只暴露合法字段:`complete`、`pause`、`resume` 不会携带编辑或阻塞字段,`blocked` 必须提供 `blocked_reason`,只有 `edit` 暴露替换字段。执行仍使用 Core 原本的 Goal Tool 与 Service。非 Copilot prompt assembly 完全不变。
@@ -459,8 +461,8 @@ node scripts/agent.mjs attribution "DeepSeek Harness (DSH)"
459
461
  `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 要求包已存在,不能代替首次建包。不会批量补发历史版本。
460
462
 
461
463
  ```sh
462
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.73/dsh-github-copilot-0.4.0-alpha.73.tgz
463
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.73/SHA256SUMS
464
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.74/dsh-github-copilot-0.4.0-alpha.74.tgz
465
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.74/SHA256SUMS
464
466
  sha256sum --check SHA256SUMS
465
467
  ```
466
468
 
@@ -468,7 +470,7 @@ PowerShell 可以对已下载的同一组文件执行:
468
470
 
469
471
  ```powershell
470
472
  $expected = (Get-Content .\SHA256SUMS).Split()[0]
471
- $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.73.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
473
+ $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.74.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
472
474
  if ($actual -cne $expected) { throw 'Release checksum mismatch' }
473
475
  ```
474
476
 
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "package": {
10
10
  "name": "dsh-github-copilot",
11
- "version": "0.4.0-alpha.73"
11
+ "version": "0.4.0-alpha.74"
12
12
  },
13
13
  "evidence": {
14
14
  "kind": "source-and-synthetic-test-inventory",
@@ -471,6 +471,8 @@
471
471
  "sourceMarkers": [
472
472
  {"file": "src/manual-compaction-recovery.ts", "marker": "extends BasicCompactionEngine"},
473
473
  {"file": "src/manual-compaction-recovery.ts", "marker": "COPILOT_MANUAL_RECOVERY_"},
474
+ {"file": "src/background-compaction.ts", "marker": "copilot-compact"},
475
+ {"file": "src/background-compaction.ts", "marker": "this.jobs.wait(jobId"},
474
476
  {"file": "src/preview-route.ts", "marker": "recoveryLimits(modelId)"},
475
477
  {"file": "docs/manual-compaction-recovery.md", "marker": "separately selected"}
476
478
  ],
@@ -478,6 +480,8 @@
478
480
  {"file": "tests/manual-compaction-recovery.spec.ts", "name": "reduces an oversized balanced history with bounded complete calls and an unmarked aggregate audit"},
479
481
  {"file": "tests/manual-compaction-recovery.spec.ts", "name": "rejects an indivisible span before dispatch and leaves recovery to native failure handling"},
480
482
  {"file": "tests/manual-compaction-recovery.spec.ts", "name": "rejects unmatched tool calls before dispatch instead of splitting a call and result"},
483
+ {"file": "tests/background-compaction.spec.ts", "name": "acknowledges before completion and outlives a five-minute caller deadline"},
484
+ {"file": "tests/fixtures/compaction-pressure-core.fixture.ts", "name": "commits beyond the carrier deadline without a model wakeup and keeps status owner-scoped"},
481
485
  {"file": "tests/fixtures/compaction-pressure-core.fixture.ts", "name": "recovers oversized manual history with one native transaction and honest multi-call audit"}
482
486
  ]
483
487
  },
@@ -14,7 +14,25 @@ Recovery must leave the original Session surface intact until a smaller *complet
14
14
 
15
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
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.
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. Only an explicit manual command starts this process.
18
+
19
+ ## Background command for Desktop
20
+
21
+ With this engine selected and the public `commands` and `jobs` services available in its scope, use:
22
+
23
+ ```text
24
+ /copilot-compact
25
+ /copilot-compact status
26
+ /copilot-compact cancel
27
+ ```
28
+
29
+ The jobs package is a development-only type dependency: the plugin imports no jobs runtime implementation, and the engine's public declaration does not expose its types. Runtime access is through the optionally injected Host service; no jobs package is bundled, installed as a new peer, or registered by this plugin.
30
+
31
+ The first command acknowledges **job admission**, not a completed summary. The existing native `/compact` command remains unchanged. Desktop rc.2 forwards unary command requests through Node `fetch`; a long synchronous compact can exceed the default 300-second response-header wait and lose its caller connection. The background command returns promptly and transfers work to a Session-owned native job with its own cancellation controller. A later HTTP disconnect does not cancel admitted work.
32
+
33
+ Status and cancellation apply only to the invoking Agent's latest job. Duplicate starts return the current running job rather than starting another transaction. The selected engine still acquires Core's maintenance lock and owns the only native transaction; another active turn or compaction can cause the admitted job to fail. Job status distinguishes running, completed, failed and cancelled work. Failure details are sanitized; consult the native compaction/end record for the underlying summary/transaction diagnostic. Provider timeout, truncation, capacity and account-proof failures remain failures.
34
+
35
+ The plugin collects the job's native settlement with `jobs.wait`, so the ordinary job reporter does not wake the model or resume its Goal. It never calls followup or inject. Explicit cancellation, owner disposal and plugin/Host teardown cancel and drain the producer. Owner teardown can fail native maintenance before the job receives cancellation; that outcome remains failed rather than being relabeled successful or cancelled. Jobs are process-local: status does not survive a Host restart, and the plugin does not silently restart interrupted work. Durable Core compaction events remain the outcome evidence. Merely installing the main plugin does not select this engine or make this command available; missing commands/jobs services leave the background entry unavailable without changing ordinary compaction.
18
36
 
19
37
  **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
38
 
package/lib/index.js CHANGED
@@ -1847,7 +1847,7 @@ function installContextEvidence(ctx) {
1847
1847
  //#endregion
1848
1848
  //#region package.json
1849
1849
  var name$1 = "dsh-github-copilot";
1850
- var version = "0.4.0-alpha.73";
1850
+ var version = "0.4.0-alpha.74";
1851
1851
  //#endregion
1852
1852
  //#region lib/types/probe.js
1853
1853
  /**
@@ -2,6 +2,156 @@ import "./copilot-identity-DRZY_d2X.js";
2
2
  import { i as resolveRequestBudgetPolicy, r as calculateRequestBudget } from "./request-budget-DLY_aRq0.js";
3
3
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
4
4
  import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
5
+ import { CommandDefinitionId } from "@deepseek-ai/dsh-commands/brand";
6
+ //#region lib/types/background-compaction.js
7
+ const WAIT_MS = 2147483647;
8
+ const USAGE = "Usage: /copilot-compact [status|cancel]";
9
+ const FAILED = "COPILOT_BACKGROUND_COMPACTION_FAILED: inspect the native compaction/end record; no success is implied.";
10
+ /** Own only admission and job lifetime; the selected engine owns all history transactions. */
11
+ var BackgroundCompaction = class {
12
+ jobs;
13
+ compact;
14
+ warn;
15
+ latest = /* @__PURE__ */ new WeakMap();
16
+ active = /* @__PURE__ */ new Map();
17
+ closed = false;
18
+ constructor(jobs, compact, warn) {
19
+ this.jobs = jobs;
20
+ this.compact = compact;
21
+ this.warn = warn;
22
+ }
23
+ execute(agent, rawInput, signal) {
24
+ if (this.closed) return {
25
+ kind: "error",
26
+ text: "COPILOT_BACKGROUND_COMPACTION_DISPOSED"
27
+ };
28
+ if (signal.aborted) return {
29
+ kind: "error",
30
+ text: "Compaction admission cancelled."
31
+ };
32
+ const action = rawInput.trim();
33
+ if (action !== "" && action !== "status" && action !== "cancel") return {
34
+ kind: "error",
35
+ text: USAGE
36
+ };
37
+ const id = this.latest.get(agent);
38
+ if (action !== "") {
39
+ if (id === void 0) return {
40
+ kind: "error",
41
+ text: "No background compaction job for this Session."
42
+ };
43
+ try {
44
+ if (action === "cancel") return {
45
+ kind: "success",
46
+ text: `${id}: cancellation ${this.jobs.kill(id, agent.id)}.`
47
+ };
48
+ const job = this.jobs.get(id, agent.id);
49
+ return {
50
+ kind: "success",
51
+ text: `${id}: ${job.status}${job.detail ? `; ${job.detail}` : ""}`
52
+ };
53
+ } catch {
54
+ return {
55
+ kind: "error",
56
+ text: "COPILOT_BACKGROUND_COMPACTION_JOB_UNAVAILABLE"
57
+ };
58
+ }
59
+ }
60
+ const existing = this.active.get(agent);
61
+ if (existing !== void 0) return {
62
+ kind: "success",
63
+ text: `${existing.id}: already running; use /copilot-compact status or cancel.`
64
+ };
65
+ const cancel = new AbortController();
66
+ let done;
67
+ try {
68
+ const jobId = this.jobs.start({
69
+ kind: "copilot-compaction",
70
+ label: "Manual Copilot context compaction",
71
+ owner: agent.id,
72
+ run: (job) => {
73
+ job.updateProgress("Compacting context; the original history remains until native commit.");
74
+ done = Promise.resolve().then(async () => {
75
+ try {
76
+ cancel.signal.throwIfAborted();
77
+ const result = await this.compact(agent, cancel.signal);
78
+ return {
79
+ status: "completed",
80
+ detail: result === null ? "No compactable history." : `Compacted ${result.shadowedSeqs.length} history items (~${result.shadowedTokenCount} tokens).`
81
+ };
82
+ } catch {
83
+ if (cancel.signal.aborted) return {
84
+ status: "killed",
85
+ detail: "Compaction cancelled; inspect native history for its transaction outcome."
86
+ };
87
+ this.warn(FAILED);
88
+ return {
89
+ status: "failed",
90
+ detail: FAILED
91
+ };
92
+ } finally {
93
+ this.active.delete(agent);
94
+ }
95
+ });
96
+ return {
97
+ cancel: () => {
98
+ cancel.abort();
99
+ },
100
+ done
101
+ };
102
+ }
103
+ });
104
+ if (done === void 0) throw new Error("COPILOT_BACKGROUND_COMPACTION_STARTER_MISSING");
105
+ this.active.set(agent, {
106
+ id: jobId,
107
+ cancel,
108
+ done
109
+ });
110
+ this.latest.set(agent, jobId);
111
+ this.jobs.wait(jobId, WAIT_MS, agent.id).then((view) => {
112
+ if (view.status === "running" || view.status === "stopping") {
113
+ this.warn("COPILOT_BACKGROUND_COMPACTION_OBSERVER_EXPIRED");
114
+ cancel.abort();
115
+ }
116
+ }, () => {
117
+ this.warn("COPILOT_BACKGROUND_COMPACTION_OBSERVER_FAILED");
118
+ cancel.abort();
119
+ });
120
+ return {
121
+ kind: "success",
122
+ text: `${jobId}: background compaction started, not completed. Use /copilot-compact status or /copilot-compact cancel.`
123
+ };
124
+ } catch {
125
+ cancel.abort();
126
+ this.warn("COPILOT_BACKGROUND_COMPACTION_ADMISSION_FAILED");
127
+ return {
128
+ kind: "error",
129
+ text: "COPILOT_BACKGROUND_COMPACTION_ADMISSION_FAILED: jobs and a live Session owner are required."
130
+ };
131
+ }
132
+ }
133
+ async dispose() {
134
+ this.closed = true;
135
+ const work = [...this.active.values()];
136
+ for (const entry of work) entry.cancel.abort();
137
+ await Promise.all(work.map((entry) => entry.done));
138
+ }
139
+ };
140
+ function installBackgroundCompaction(ctx, compact) {
141
+ const controller = new BackgroundCompaction(ctx.jobs, compact, (message) => ctx.logger.warn(message));
142
+ ctx.effect(function* () {
143
+ yield () => controller.dispose();
144
+ yield ctx.jobs.attachController("copilot-background-compaction");
145
+ yield ctx.commands.register({
146
+ definitionId: CommandDefinitionId("dsh-github-copilot/background-compaction"),
147
+ name: "copilot-compact",
148
+ description: "Start background manual compaction, inspect status, or cancel",
149
+ input: { hint: "status | cancel (omit to start)" },
150
+ handler: (invocation) => controller.execute(invocation.agent, invocation.rawInput, invocation.signal)
151
+ });
152
+ }, "Copilot background compaction");
153
+ }
154
+ //#endregion
5
155
  //#region lib/types/manual-compaction-recovery.js
6
156
  function recoverError(code) {
7
157
  return /* @__PURE__ */ new Error(`COPILOT_MANUAL_RECOVERY_${code}`);
@@ -95,6 +245,12 @@ async function summarizeOversizedManualInput(options) {
95
245
  */
96
246
  var CopilotManualRecoveryCompactionEngine = class extends BasicCompactionEngine {
97
247
  manual = /* @__PURE__ */ new WeakMap();
248
+ constructor(ctx, config = {}) {
249
+ super(ctx, config);
250
+ ctx.inject(["commands", "jobs"], (scope) => {
251
+ installBackgroundCompaction(scope, (agent, signal) => this.compactNow(agent, signal));
252
+ });
253
+ }
98
254
  async compactNow(agent, signal, sourceCommandId) {
99
255
  this.manual.set(agent, (this.manual.get(agent) ?? 0) + 1);
100
256
  try {
@@ -0,0 +1,30 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { Agent } from '@deepseek-ai/dsh-agent';
3
+ import type { CommandResult } from '@deepseek-ai/dsh-commands';
4
+ import type { CompactionResult } from '@deepseek-ai/dsh-compaction';
5
+ import type { JobRegistry } from '@deepseek-ai/dsh-jobs';
6
+ import type { SessionId } from '@deepseek-ai/dsh-session';
7
+ declare module '@deepseek-ai/dsh-jobs/view' {
8
+ interface JobKindMap {
9
+ 'copilot-compaction': 'copilot-compaction';
10
+ }
11
+ }
12
+ type Jobs = Pick<JobRegistry, 'start' | 'get' | 'wait' | 'kill'>;
13
+ type Result = Pick<CompactionResult, 'shadowedSeqs' | 'shadowedTokenCount'> | null;
14
+ /** Own only admission and job lifetime; the selected engine owns all history transactions. */
15
+ export declare class BackgroundCompaction<A extends {
16
+ readonly id: SessionId;
17
+ }> {
18
+ private readonly jobs;
19
+ private readonly compact;
20
+ private readonly warn;
21
+ private readonly latest;
22
+ private readonly active;
23
+ private closed;
24
+ constructor(jobs: Jobs, compact: (agent: A, signal: AbortSignal) => Promise<Result>, warn: (message: string) => void);
25
+ execute(agent: A, rawInput: string, signal: AbortSignal): CommandResult;
26
+ dispose(): Promise<void>;
27
+ }
28
+ export declare function installBackgroundCompaction(ctx: Context, compact: (agent: Agent, signal: AbortSignal) => Promise<CompactionResult | null>): void;
29
+ export {};
30
+ //# sourceMappingURL=background-compaction.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import type { Agent } from '@deepseek-ai/dsh-agent';
2
+ import type { Context } from '@deepseek-ai/cordis';
2
3
  import BasicCompactionEngine from '@deepseek-ai/dsh-compaction-basic';
3
4
  import type { ContentBlock, Message, TokenUsage, ToolSchema } from '@deepseek-ai/dsh-llm';
4
5
  import type { CommandId } from '@deepseek-ai/dsh-commands/brand';
@@ -43,6 +44,7 @@ export declare function summarizeOversizedManualInput<M extends RecoveryMessage,
43
44
  */
44
45
  export declare class CopilotManualRecoveryCompactionEngine extends BasicCompactionEngine {
45
46
  private readonly manual;
47
+ constructor(ctx: Context, config?: ConstructorParameters<typeof BasicCompactionEngine>[1]);
46
48
  compactNow(agent: Agent, signal: AbortSignal, sourceCommandId?: CommandId): Promise<CompactionResult | null>;
47
49
  protected summarize(input: RecoveryInput<Message>, agent: Agent, signal?: AbortSignal): Promise<RecoveryResult>;
48
50
  }
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.73",
4
+ "version": "0.4.0-alpha.74",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",
@@ -149,6 +149,7 @@
149
149
  "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
150
150
  "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
151
151
  "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
152
+ "@deepseek-ai/dsh-jobs": "0.2.0-rc.2",
152
153
  "@deepseek-ai/dsh-api-gateway": "0.2.0-rc.2",
153
154
  "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
154
155
  "@deepseek-ai/dsh-app-boot": "0.2.0-rc.2",