dsh-github-copilot 0.4.0 → 0.4.1

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 CHANGED
@@ -148,6 +148,14 @@ Alpha.25 admits native `subagent/descriptor` v3, already v3 in the retained rc.1
148
148
  - The canonical compatibility credential record key is `llm-pi-ai/github-copilot`; additional account records are limited to the approved #297 contract above.
149
149
  - OAuth credential payloads stay Host-only. Client Remote methods may expose status, notices, and errors only.
150
150
  - Refresh must run through pi-ai `Models.getAuth()` and DSH `credentials.modifyRecord()`.
151
+ - A plugin-owned native refresh may retain only already-dispatched HTTP streams
152
+ when account, entitlements and public OAuth-derived endpoint agree, its exact
153
+ returned object passes through the serialized store, and one synchronous
154
+ notification plus exact commit readback qualify that write. Invalidate all
155
+ reusable metadata/prepared proof immediately. Unknown, duplicate, delayed,
156
+ failed or external/Core-only changes revoke work; never use a refresh timing
157
+ window, unchanged bytes alone, old proof for a new request or a hidden retry.
158
+ See `docs/copilot-accounts.md` (#385).
151
159
  - Copilot OAuth grant writes must rebuild only pi-ai's documented provider fields as a fresh plain JSON object; unrelated extension values never reach DSH credential storage.
152
160
  - Settings changes are path-level. Never replace the whole `llm-pi-ai` section or unrelated provider profiles.
153
161
  - Sign-out deletes only the active Copilot credential record and keeps other records, the selector and route settings. A missing selected noncanonical slot fails explicitly; only an explicit eligible Add or Switch recovers it, never automatic canonical fallback.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1
4
+
5
+ - Upgrade from 0.4.0: fix normal plugin-owned same-account native OAuth refresh aborting concurrent already-dispatched managed HTTP streams with `COPILOT_PREVIEW_CREDENTIAL_CHANGED`.
6
+ - Qualify unchanged account, entitlements and official OAuth-derived endpoint through an exact single serialized credential notification and commit result. Immediately invalidate reusable metadata/prepared proof; subsequent requests resolve fresh native auth and metadata without redirecting a frozen account or replaying the user query.
7
+ - Keep unknown/external/Core-only notifications, duplicate/delayed/failed writes, revocation, cancellation and disposal fail-closed. Provider rejection remains an ordinary native error; this is not blanket invisible recovery or a new retry owner.
8
+ - Synthetic native-adapter and credential-store regressions establish this scope, not attribution of any particular live incident. Retain 0.4.0's original immutable tag/archive; use the new stable patch. No installation, restart or live settings mutation is included.
9
+
10
+ ## 0.4.0
11
+
12
+ - First stable release, retaining official DSH / Windows Desktop 0.2.0-rc.2 support and plugin-only boundaries.
13
+ - Synchronize bilingual configuration documentation and synthetic built-Client screenshots. The same-account refresh interruption described above is corrected in 0.4.1.
14
+
3
15
  ## 0.4.0-alpha.134 (prepared)
4
16
 
5
17
  - Automatically omit temperature only for the authenticated official rc.2 Auto reviewer root calling an account-proven managed Responses route. Ordinary concurrent Chat and other tool listeners retain their sampling; no opt-in or settings migration is required.
package/README.md CHANGED
@@ -8,7 +8,9 @@
8
8
 
9
9
  GitHub Copilot account discovery, contextual Auto routing and hosted search for DSH. The plugin reuses DSH's published native adapter, retaining a profile-wide account default with independent Session next-turn choices; it does not patch Core or maintain a second model catalog.
10
10
 
11
- **First stable release: [`0.4.0`](https://github.com/cloga/dsh-github-copilot/releases/tag/v0.4.0). Supported host: official DSH / Windows Desktop `0.2.0-rc.2`.** The stable version is also published on npm's `latest` dist-tag; prereleases remain on their channel tags. Stability-channel promotion does not expand the qualified host baseline or prove live account, model, search or Desktop health. Earlier DSH pins are historical evidence, not supported installation targets. Published, installed in a profile and loaded by a running Host are separate states.
11
+ **Stable release: [`0.4.1`](https://github.com/cloga/dsh-github-copilot/releases/tag/v0.4.1). Supported host: official DSH / Windows Desktop `0.2.0-rc.2`.** The stable version is also published on npm's `latest` dist-tag; prereleases remain on their channel tags. Stability-channel promotion does not expand the qualified host baseline or prove live account, model, search or Desktop health. Earlier DSH pins are historical evidence, not supported installation targets. Published, installed in a profile and loaded by a running Host are separate states.
12
+
13
+ **Upgrade from 0.4.0:** that first stable release can interrupt concurrent managed requests with `COPILOT_PREVIEW_CREDENTIAL_CHANGED` during normal same-account native OAuth renewal. In 0.4.1, a proven plugin-owned refresh with unchanged account, endpoint and entitlements preserves already-dispatched HTTP streams; subsequent requests use freshly validated auth and metadata. Unknown/external credential notifications, revocation, cancellation and provider rejections remain explicit—not a promise of invisible recovery or automatic retry. See [the refresh boundary](./docs/copilot-accounts.md#native-oauth-refresh-and-dispatched-requests-385).
12
14
 
13
15
  ## What you can do
14
16
 
@@ -90,10 +92,10 @@ Supply any launcher patches with repeated `--patch /absolute/file`. Require `sup
90
92
  For a **standalone named profile**:
91
93
 
92
94
  ```sh
93
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0/dsh-github-copilot-0.4.0.tgz
95
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.1/dsh-github-copilot-0.4.1.tgz
94
96
  ```
95
97
 
96
- For **Desktop**, its native package manager accepts the exact stable npm spec `dsh-github-copilot@0.4.0`; stable versions publish on npm's `latest` dist-tag. The official rc.2 **Desktop-bundled CLI** also supports reserved-profile plugin management; a global/generic `dsh` shim is not equivalent. Qualify the installed entry before use. See [Desktop CLI qualification](./docs/npm-distribution.md#desktop-bundled-cli-on-official-rc2) and the distinct [standalone offline procedure](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles). Neither path authorizes registry-policy bypass, peer patches or configuration deletion.
98
+ For **Desktop**, its native package manager accepts the exact stable npm spec `dsh-github-copilot@0.4.1`; stable versions publish on npm's `latest` dist-tag. The official rc.2 **Desktop-bundled CLI** also supports reserved-profile plugin management; a global/generic `dsh` shim is not equivalent. Qualify the installed entry before use. See [Desktop CLI qualification](./docs/npm-distribution.md#desktop-bundled-cli-on-official-rc2) and the distinct [standalone offline procedure](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles). Neither path authorizes registry-policy bypass, peer patches or configuration deletion.
97
99
 
98
100
  After an approved reload/restart:
99
101
 
@@ -269,14 +271,14 @@ Commit attribution uses `Assisted-by` with the actual tool, never the model prov
269
271
  GitHub Releases and npm distribute the same original verified tarball. Pin a version; verify Release SHA-256 or npm `dist.integrity`. Never repack an immutable release or move/reuse its tag.
270
272
 
271
273
  ```sh
272
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0/dsh-github-copilot-0.4.0.tgz
273
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0/SHA256SUMS
274
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.1/dsh-github-copilot-0.4.1.tgz
275
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.1/SHA256SUMS
274
276
  sha256sum --check SHA256SUMS
275
277
  ```
276
278
 
277
279
  ```powershell
278
280
  $expected = (Get-Content .\SHA256SUMS).Split()[0]
279
- $actual = (Get-FileHash .\dsh-github-copilot-0.4.0.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
281
+ $actual = (Get-FileHash .\dsh-github-copilot-0.4.1.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
280
282
  if ($actual -cne $expected) { throw 'Release checksum mismatch' }
281
283
  ```
282
284
 
package/README.zh.md CHANGED
@@ -8,7 +8,9 @@
8
8
 
9
9
  为 DSH 提供 GitHub Copilot 账号模型发现、上下文 Auto 选模和 hosted search。插件复用 DSH 公开的原生适配器,保留 profile 全局默认账号,并支持 Session 后续 turn 指定独立账号;不修改 Core,也不维护第二套模型目录。
10
10
 
11
- **首个稳定版:[`0.4.0`](https://github.com/cloga/dsh-github-copilot/releases/tag/v0.4.0)。支持宿主:官方 DSH / Windows Desktop `0.2.0-rc.2`。** 稳定版也发布到 npm 的 `latest` dist-tag;预发布版本仍使用各自渠道 tag。稳定渠道不扩大已验证的宿主基线,也不证明实时账号、模型、搜索或 Desktop 健康状态。较早 DSH pin 仅是历史证据,不是当前安装目标。已发布、已安装到 profile、已被运行中的 Host 加载,是三个不同状态。
11
+ **稳定版:[`0.4.1`](https://github.com/cloga/dsh-github-copilot/releases/tag/v0.4.1)。支持宿主:官方 DSH / Windows Desktop `0.2.0-rc.2`。** 稳定版也发布到 npm 的 `latest` dist-tag;预发布版本仍使用各自渠道 tag。稳定渠道不扩大已验证的宿主基线,也不证明实时账号、模型、搜索或 Desktop 健康状态。较早 DSH pin 仅是历史证据,不是当前安装目标。已发布、已安装到 profile、已被运行中的 Host 加载,是三个不同状态。
12
+
13
+ **从 0.4.0 升级:**首个正式版在同账号正常原生 OAuth 刷新时,可能以 `COPILOT_PREVIEW_CREDENTIAL_CHANGED` 中止并行托管请求。0.4.1 仅在插件拥有的原生刷新被精确验证,且账号、端点与权限连续时,保留已发出的 HTTP 流;后续请求重新验证认证与模型元数据。未知/外部凭据通知、撤销、取消与供应商拒绝仍明确报错,不承诺所有刷新无感,也不自动重试。参见[刷新边界](./docs/copilot-accounts.md#native-oauth-refresh-and-dispatched-requests-385)。
12
14
 
13
15
  ## 你可以做什么
14
16
 
@@ -81,10 +83,10 @@ node package/scripts/check-search-composition.mjs --profile-dir /absolute/profil
81
83
  **独立具名 profile**:
82
84
 
83
85
  ```sh
84
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0/dsh-github-copilot-0.4.0.tgz
86
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.1/dsh-github-copilot-0.4.1.tgz
85
87
  ```
86
88
 
87
- **Desktop** 原生包管理器接受精确稳定版 npm spec `dsh-github-copilot@0.4.0`;稳定版发布到 npm `latest` dist-tag。官方 rc.2 **Desktop 随附的专属 CLI**也支持管理保留 profile;全局/普通 `dsh` shim 不等价。使用前核验实际安装入口,参见[Desktop CLI 核验](./docs/npm-distribution.md#desktop-bundled-cli-on-official-rc2)及独立的[具名 profile 离线流程](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles)。两种路径都不授权绕过包源政策、修改 peer 或删除配置。
89
+ **Desktop** 原生包管理器接受精确稳定版 npm spec `dsh-github-copilot@0.4.1`;稳定版发布到 npm `latest` dist-tag。官方 rc.2 **Desktop 随附的专属 CLI**也支持管理保留 profile;全局/普通 `dsh` shim 不等价。使用前核验实际安装入口,参见[Desktop CLI 核验](./docs/npm-distribution.md#desktop-bundled-cli-on-official-rc2)及独立的[具名 profile 离线流程](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles)。两种路径都不授权绕过包源政策、修改 peer 或删除配置。
88
90
 
89
91
  经批准 reload/restart 后:
90
92
 
@@ -260,14 +262,14 @@ Agent 从 `node scripts/agent.mjs describe --json`、`doctor --json`及`plan <ta
260
262
  GitHub Releases 和 npm 分发同一原始已校验 tarball。固定版本并核验 Release SHA-256 或 npm `dist.integrity`;不重打包不可变 Release、不移动/复用 tag。
261
263
 
262
264
  ```sh
263
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0/dsh-github-copilot-0.4.0.tgz
264
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0/SHA256SUMS
265
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.1/dsh-github-copilot-0.4.1.tgz
266
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.1/SHA256SUMS
265
267
  sha256sum --check SHA256SUMS
266
268
  ```
267
269
 
268
270
  ```powershell
269
271
  $expected = (Get-Content .\SHA256SUMS).Split()[0]
270
- $actual = (Get-FileHash .\dsh-github-copilot-0.4.0.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
272
+ $actual = (Get-FileHash .\dsh-github-copilot-0.4.1.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
271
273
  if ($actual -cne $expected) { throw 'Release checksum mismatch' }
272
274
  ```
273
275
 
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "package": {
10
10
  "name": "dsh-github-copilot",
11
- "version": "0.4.0"
11
+ "version": "0.4.1"
12
12
  },
13
13
  "evidence": {
14
14
  "kind": "source-and-synthetic-test-inventory",
@@ -10,6 +10,39 @@ separate evidence.
10
10
 
11
11
  ## Requirements
12
12
 
13
+ ### Native OAuth refresh and dispatched requests (#385)
14
+
15
+ In 0.4.0, every matching credential notification aborts managed wires, including
16
+ normal native refresh by another same-account request. Upgrade to 0.4.1 for the
17
+ narrow plugin-owned refresh exception. This is synthetic regression evidence,
18
+ not attribution of a particular live error to refresh.
19
+
20
+ Only a genuine native refresh through the plugin's public credential-store bridge
21
+ may qualify: normalized account grant, model entitlements and official
22
+ OAuth-derived endpoint must remain unchanged. Its exact returned object is
23
+ consumed once inside the serialized `modifyRecord` callback. Exactly one
24
+ synchronous record notification and matching returned committed grant confirm
25
+ the write. No refresh-wide timing flag or unchanged-token heuristic is used.
26
+ Failed, duplicated, delayed, unknown or externally produced notifications remain
27
+ revocation; Core's separately owned canonical adapter has no provenance seam
28
+ through this bridge and remains fail-closed.
29
+
30
+ The exception retains only HTTP streams already dispatched through the native
31
+ adapter's public Fetch seam, including concurrent streams for the same frozen
32
+ account. Metadata, prepared leases, search/recovery proof and retry snapshots are
33
+ still invalidated immediately. A new step/request must resolve fresh native auth
34
+ and validate current account metadata. An old prepared request cannot dispatch
35
+ after renewal; an already-dispatched request cannot use its old lease to make a
36
+ second physical HTTP attempt after renewal. Core retains retry/transaction
37
+ ownership; this plugin adds no resend or automatic retry. Account default changes
38
+ do not redirect frozen requests; each account's record remains isolated.
39
+
40
+ Account/endpoint/permission replacement, record removal, read/commit failure,
41
+ caller cancellation and disposal still revoke. Supplier expired-token rejection
42
+ and network failures can still terminate the original request; preserving a local
43
+ stream does not prove supplier acceptance. Identity/quota presentation caches
44
+ continue to invalidate on every notification, not reuse old credentials.
45
+
13
46
  ### Selector switching and account-bound turns (#344)
14
47
 
15
48
  A global switch changes only the selector. Explicit record-bound request leases
@@ -49,6 +49,11 @@ Verification already built/prepacked. Recovery downloads the original uploaded
49
49
  archive, verifies tag/source, size/digests, SHA-256/SHA-512 and build equality,
50
50
  and never repacks/overwrites immutable bytes. Release assets include
51
51
  `SHA256SUMS`; npm receives that same archive with lifecycle scripts disabled.
52
+ When the tagged package declares `releaseNotes: "CHANGELOG.md"`, publication
53
+ uses only the exact matching version section from that tracked checkout.
54
+ Reconciliation requires the identical body; older tags without that declaration
55
+ retain their original `Release v<version>.` body. A warning must never be added
56
+ to an old Release in a way that breaks its immutable provenance checks.
52
57
 
53
58
  Only registry E404 establishes absence. Auth, TLS, malformed metadata and network
54
59
  failures stop delivery. Existing exact versions require matching SRI and a
@@ -60,7 +65,10 @@ A missing/older tag needs review, not a hidden dist-tag write.
60
65
  SemVer ordering prevents downgrades. Missing older releases are not published
61
66
  when their channel already points newer; reconciling existing older bytes never
62
67
  lowers the pointer. Report GitHub tag/commit/assets/SHA-256 and npm version/SRI
63
- separately. One channel succeeding is partial delivery.
68
+ separately. A stable release may advance `latest` from a prerelease only when
69
+ that pointer names a prerelease of the exact same SemVer core version; other
70
+ cross-channel pointers and newer versions still fail closed. One channel
71
+ succeeding is partial delivery.
64
72
  [Read-only reconciliation](./npm-publication-readback.md).
65
73
 
66
74
  ## Installation preflight still applies
package/lib/client.js CHANGED
@@ -6988,7 +6988,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6988
6988
  };
6989
6989
  //#endregion
6990
6990
  //#region package.json
6991
- var version = "0.4.0";
6991
+ var version = "0.4.1";
6992
6992
  //#endregion
6993
6993
  //#region lib/types/diagnostics-client.js
6994
6994
  let owner;
package/lib/index.js CHANGED
@@ -311,7 +311,8 @@ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", Diagnos
311
311
  var package_default = {
312
312
  name: "dsh-github-copilot",
313
313
  description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
314
- version: "0.4.0",
314
+ version: "0.4.1",
315
+ releaseNotes: "CHANGELOG.md",
315
316
  publishConfig: {
316
317
  "access": "public",
317
318
  "registry": "https://registry.npmjs.org/",
@@ -443,20 +444,20 @@ var package_default = {
443
444
  "@deepseek-ai/cordis": "^4.0.4",
444
445
  "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
445
446
  "@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.2",
446
- "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
447
- "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
448
- "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
449
447
  "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
450
448
  "@deepseek-ai/dsh-authorization": "0.2.0-rc.2",
451
449
  "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
452
450
  "@deepseek-ai/dsh-client-ui-settings-models": "0.2.0-rc.2",
453
451
  "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
452
+ "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
453
+ "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
454
+ "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
454
455
  "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
455
456
  "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.2",
456
457
  "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
457
458
  "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
458
- "@deepseek-ai/dsh-session": "0.2.0-rc.2",
459
459
  "@deepseek-ai/dsh-scope": "0.2.0-rc.2",
460
+ "@deepseek-ai/dsh-session": "0.2.0-rc.2",
460
461
  "@deepseek-ai/dsh-settings": "0.2.0-rc.2",
461
462
  "@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2",
462
463
  "@deepseek-ai/dsh-web": "0.2.0-rc.2",
@@ -481,22 +482,22 @@ var package_default = {
481
482
  "@deepseek-ai/cordis": "~4.0.4",
482
483
  "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
483
484
  "@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.2",
484
- "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
485
- "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
486
- "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
487
- "@deepseek-ai/dsh-jobs": "0.2.0-rc.2",
488
485
  "@deepseek-ai/dsh-api-gateway": "0.2.0-rc.2",
489
486
  "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
490
487
  "@deepseek-ai/dsh-app-boot": "0.2.0-rc.2",
491
- "@deepseek-ai/dsh-config-editor": "0.2.0-rc.2",
492
488
  "@deepseek-ai/dsh-attachment": "0.2.0-rc.2",
493
489
  "@deepseek-ai/dsh-authorization": "0.2.0-rc.2",
494
490
  "@deepseek-ai/dsh-client-connection": "0.2.0-rc.2",
495
491
  "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
496
492
  "@deepseek-ai/dsh-client-ui-settings-models": "0.2.0-rc.2",
497
493
  "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
494
+ "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
495
+ "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
496
+ "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
497
+ "@deepseek-ai/dsh-config-editor": "0.2.0-rc.2",
498
498
  "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
499
499
  "@deepseek-ai/dsh-fs": "0.2.0-rc.2",
500
+ "@deepseek-ai/dsh-jobs": "0.2.0-rc.2",
500
501
  "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.2",
501
502
  "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
502
503
  "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
@@ -1714,6 +1715,28 @@ function normalizeGitHubCopilotOAuthCredential(credential) {
1714
1715
  * Provider-side GitHub Copilot auth resolution over the same credential record
1715
1716
  * that DSH's built-in llm-pi-ai adapter owns.
1716
1717
  */
1718
+ const nativeRefreshResults = /* @__PURE__ */ new WeakSet();
1719
+ const refreshWrites = /* @__PURE__ */ new WeakMap();
1720
+ /** Only a validated native OAuth refresh may certify its exact returned object. */
1721
+ async function certifyCopilotNativeRefresh(previous, result, derive, signal) {
1722
+ const ids = (grant) => grant.availableModelIds === void 0 ? void 0 : JSON.stringify([...grant.availableModelIds].sort());
1723
+ if (previous.refresh !== result.refresh || previous.enterpriseUrl !== result.enterpriseUrl || ids(previous) !== ids(result) || result.expires <= Date.now()) return;
1724
+ const before = await derive(previous);
1725
+ const after = await derive(result);
1726
+ signal?.throwIfAborted();
1727
+ if (before.apiKey === previous.access && after.apiKey === result.access && trustedGitHubCopilotBaseUrl(before.baseUrl, previous) === trustedGitHubCopilotBaseUrl(after.baseUrl, result)) nativeRefreshResults.add(result);
1728
+ }
1729
+ /** Consume exactly one notification from the serialized, certified write. */
1730
+ function observeCopilotNativeRefresh(ctx, key) {
1731
+ const service = ctx.get("credentials");
1732
+ const write = service === void 0 ? void 0 : refreshWrites.get(service)?.get(key);
1733
+ if (!write) return void 0;
1734
+ if (++write.notifications !== 1) {
1735
+ write.settle(false);
1736
+ return;
1737
+ }
1738
+ return write.committed;
1739
+ }
1717
1740
  function captureActiveGitHubCopilotBinding(ctx) {
1718
1741
  const accounts = ctx.get("githubCopilotAccounts");
1719
1742
  if (accounts) return accounts.host.capture();
@@ -1778,12 +1801,45 @@ function createGitHubCopilotCredentialStore(ctx, logicalProviderId = GITHUB_COPI
1778
1801
  modify: async (providerId, mutate) => {
1779
1802
  assertProvider(providerId);
1780
1803
  binding?.assertCurrent();
1781
- return toCredential(await credentialService(ctx).modifyRecord(key, async (current) => {
1782
- binding?.assertCurrent();
1783
- const next = await mutate(toCredential(current));
1804
+ const service = credentialService(ctx);
1805
+ let pending;
1806
+ let expected;
1807
+ let writes = refreshWrites.get(service);
1808
+ if (!writes) {
1809
+ writes = /* @__PURE__ */ new Map();
1810
+ refreshWrites.set(service, writes);
1811
+ }
1812
+ try {
1813
+ const stored = await service.modifyRecord(key, async (current) => {
1814
+ binding?.assertCurrent();
1815
+ const next = await mutate(toCredential(current));
1816
+ binding?.assertCurrent();
1817
+ const record = next === void 0 ? void 0 : toRecord(next);
1818
+ if (next !== void 0 && nativeRefreshResults.delete(next)) {
1819
+ expected = record;
1820
+ let settle;
1821
+ const committed = new Promise((resolve) => {
1822
+ settle = resolve;
1823
+ });
1824
+ pending = {
1825
+ notifications: 0,
1826
+ settle,
1827
+ committed
1828
+ };
1829
+ if (writes.has(key)) {
1830
+ writes.get(key)?.settle(false);
1831
+ pending.settle(false);
1832
+ } else writes.set(key, pending);
1833
+ }
1834
+ return record;
1835
+ });
1784
1836
  binding?.assertCurrent();
1785
- return next === void 0 ? void 0 : toRecord(next);
1786
- }));
1837
+ pending?.settle(pending.notifications === 1 && stored?.kind === "grant" && expected?.kind === "grant" && JSON.stringify(normalizeGitHubCopilotOAuthCredential(stored.payload)) === JSON.stringify(normalizeGitHubCopilotOAuthCredential(expected.payload)));
1838
+ return toCredential(stored);
1839
+ } finally {
1840
+ pending?.settle(false);
1841
+ if (writes.get(key) === pending) writes.delete(key);
1842
+ }
1787
1843
  },
1788
1844
  delete: async (providerId) => {
1789
1845
  assertProvider(providerId);
@@ -1800,9 +1856,18 @@ function createGitHubCopilotTokenResolver(ctx, onCredentialChanged) {
1800
1856
  const models = createModels({ credentials: createGitHubCopilotCredentialStore(ctx) });
1801
1857
  const provider = githubCopilotProvider();
1802
1858
  if (provider.auth.oauth === void 0) throw new Error("github-copilot: native OAuth method is unavailable");
1859
+ const oauth = provider.auth.oauth;
1803
1860
  models.setProvider({
1804
1861
  ...provider,
1805
- auth: { oauth: provider.auth.oauth }
1862
+ auth: { oauth: {
1863
+ ...oauth,
1864
+ async refresh(credential, signal) {
1865
+ const previous = normalizeGitHubCopilotOAuthCredential(credential);
1866
+ const result = normalizeGitHubCopilotOAuthCredential(await oauth.refresh(credential, signal));
1867
+ await certifyCopilotNativeRefresh(previous, result, oauth.toAuth, signal);
1868
+ return result;
1869
+ }
1870
+ } }
1806
1871
  });
1807
1872
  return async (modelId) => {
1808
1873
  const binding = captureActiveGitHubCopilotBinding(ctx);
@@ -1945,10 +2010,13 @@ function createAccountModelAuth(credentials, renewRejectedCredential) {
1945
2010
  },
1946
2011
  async refresh(credential, requestSignal) {
1947
2012
  active(signal);
1948
- matches(normalizeGitHubCopilotOAuthCredential(credential), key);
2013
+ const previous = normalizeGitHubCopilotOAuthCredential(credential);
2014
+ matches(previous, key);
1949
2015
  const result = normalizeGitHubCopilotOAuthCredential(await oauth.refresh(credential, requestSignal === void 0 ? signal : AbortSignal.any([signal, requestSignal])));
1950
2016
  active(signal);
1951
2017
  matches(result, key);
2018
+ await certifyCopilotNativeRefresh(previous, result, oauth.toAuth, signal);
2019
+ active(signal);
1952
2020
  return result;
1953
2021
  },
1954
2022
  async toAuth(credential) {
@@ -3756,6 +3824,8 @@ function createAccountProvider(descriptors, guard, baseURL) {
3756
3824
  guard.assertActive();
3757
3825
  const result = normalizeGitHubCopilotOAuthCredential(fresh);
3758
3826
  guard.assertAccount(result);
3827
+ await certifyCopilotNativeRefresh(current, result, oauth.toAuth, operationSignal);
3828
+ guard.assertActive();
3759
3829
  return result;
3760
3830
  },
3761
3831
  toAuth: async (credential) => {
@@ -3888,6 +3958,7 @@ function createAccountProvider(descriptors, guard, baseURL) {
3888
3958
  dispatchInit = prepared.init;
3889
3959
  compression = prepared.evidence;
3890
3960
  }
3961
+ lease.dispatch?.();
3891
3962
  liveness?.beginRequest(originalBody);
3892
3963
  let response;
3893
3964
  const upload = guard.onRequestBodyTimeout === void 0 ? void 0 : createRequestUploadObserver();
@@ -12760,7 +12831,7 @@ var PreviewLifetime = class {
12760
12831
  turns;
12761
12832
  acquire;
12762
12833
  controller = new AbortController();
12763
- wires = /* @__PURE__ */ new Set();
12834
+ wires = /* @__PURE__ */ new Map();
12764
12835
  retryEntries = /* @__PURE__ */ new Map();
12765
12836
  revision = 0;
12766
12837
  active = true;
@@ -12814,12 +12885,12 @@ var PreviewLifetime = class {
12814
12885
  });
12815
12886
  return replay;
12816
12887
  }
12817
- change() {
12888
+ change(preserveDispatched = false) {
12818
12889
  this.assertActive();
12819
12890
  this.revision++;
12820
12891
  this.clearRetries();
12821
12892
  this.source.invalidate();
12822
- for (const wire of this.wires) wire.abort(new ManagedWireAbortError("COPILOT_PREVIEW_CREDENTIAL_CHANGED"));
12893
+ for (const [wire, state] of this.wires) if (!preserveDispatched || !state.dispatched) wire.abort(new ManagedWireAbortError("COPILOT_PREVIEW_CREDENTIAL_CHANGED"));
12823
12894
  }
12824
12895
  dispose() {
12825
12896
  if (!this.active) return;
@@ -12827,7 +12898,7 @@ var PreviewLifetime = class {
12827
12898
  this.clearRetries();
12828
12899
  this.source.dispose();
12829
12900
  this.controller.abort(new ManagedWireAbortError("COPILOT_PREVIEW_DISPOSED"));
12830
- for (const wire of this.wires) wire.abort();
12901
+ for (const wire of this.wires.keys()) wire.abort();
12831
12902
  this.wires.clear();
12832
12903
  }
12833
12904
  async read(signal = this.controller.signal, ticket) {
@@ -12943,9 +13014,14 @@ var PreviewLifetime = class {
12943
13014
  if (options?.apiKey !== grant.access) throw failure("COPILOT_PREVIEW_CREDENTIAL_CHANGED");
12944
13015
  if (trustedGitHubCopilotBaseUrl(model.baseUrl, grant) !== lease.proof.baseURL) throw failure("COPILOT_PREVIEW_CREDENTIAL_CHANGED");
12945
13016
  const controller = new AbortController();
12946
- this.wires.add(controller);
13017
+ const state = { dispatched: false };
13018
+ this.wires.set(controller, state);
12947
13019
  return {
12948
13020
  signal: AbortSignal.any([signal, controller.signal]),
13021
+ dispatch: () => {
13022
+ if (!this.isCurrent(lease.revision)) throw failure("COPILOT_PREVIEW_PREPARED_CALL_INVALIDATED", "ABORTED");
13023
+ state.dispatched = true;
13024
+ },
12949
13025
  release: () => {
12950
13026
  this.wires.delete(controller);
12951
13027
  controller.abort();
@@ -13675,8 +13751,8 @@ function createAccountRuntime(ctx, config, binding, exclusionTurns, replayRecove
13675
13751
  if (snapshotProof === void 0 || snapshotProof.expires <= Date.now()) return void 0;
13676
13752
  return `${binding?.accountId ?? "canonical"}:${lifetime.revision}:${snapshotProof.accountKey}:${snapshotProof.tokenFingerprint}`;
13677
13753
  },
13678
- invalidate() {
13679
- lifetime.change();
13754
+ invalidate(preserveDispatched = false) {
13755
+ lifetime.change(preserveDispatched);
13680
13756
  provenSnapshot = void 0;
13681
13757
  snapshotProof = void 0;
13682
13758
  lastValidatedProof = void 0;
@@ -13813,7 +13889,13 @@ function apply$1(ctx, config = {}) {
13813
13889
  if (event.type === "turn/end") exclusionTurns.end(session);
13814
13890
  });
13815
13891
  const removeListener = ctx.on("credentials/record-updated", (key) => {
13816
- for (const [accountId, runtime] of runtimes) if ((accountId === "canonical" ? "llm-pi-ai/github-copilot" : `github-copilot/account-${accountId}`) === key) runtime.invalidate();
13892
+ const refresh = observeCopilotNativeRefresh(ctx, key);
13893
+ for (const [accountId, runtime] of runtimes) if ((accountId === "canonical" ? "llm-pi-ai/github-copilot" : `github-copilot/account-${accountId}`) === key) {
13894
+ runtime.invalidate(refresh !== void 0);
13895
+ if (refresh !== void 0) refresh.then((committed) => {
13896
+ if (!committed && !disposed) runtime.invalidate();
13897
+ });
13898
+ }
13817
13899
  });
13818
13900
  const removeAccountListener = ctx.get("githubCopilotAccounts")?.host.onChanged(() => {
13819
13901
  publishedDirectory = "";
@@ -3,10 +3,15 @@
3
3
  * that DSH's built-in llm-pi-ai adapter owns.
4
4
  */
5
5
  import type { Context } from '@deepseek-ai/cordis';
6
- import { type CredentialStore } from '@earendil-works/pi-ai';
6
+ import { type CredentialStore, type OAuthAuth } from '@earendil-works/pi-ai';
7
7
  import { GITHUB_COPILOT_PROVIDER_ID, GITHUB_COPILOT_PREVIEW_PROVIDER_ID } from './copilot-identity.ts';
8
+ import type { GitHubCopilotOAuthCredential } from './copilot-grant.ts';
8
9
  import type { CopilotAccountBinding } from './copilot-accounts-types.ts';
9
10
  export { normalizeGitHubCopilotOAuthCredential } from './copilot-grant.ts';
11
+ /** Only a validated native OAuth refresh may certify its exact returned object. */
12
+ export declare function certifyCopilotNativeRefresh(previous: GitHubCopilotOAuthCredential, result: GitHubCopilotOAuthCredential, derive: OAuthAuth['toAuth'], signal?: AbortSignal): Promise<void>;
13
+ /** Consume exactly one notification from the serialized, certified write. */
14
+ export declare function observeCopilotNativeRefresh(ctx: Context, key: string): Promise<boolean> | undefined;
10
15
  export declare function captureActiveGitHubCopilotBinding(ctx: Context): CopilotAccountBinding | undefined;
11
16
  /** Bind exactly one logical route to the canonical Host-owned credential record. */
12
17
  export declare function createGitHubCopilotCredentialStore(ctx: Context, logicalProviderId?: typeof GITHUB_COPILOT_PROVIDER_ID | typeof GITHUB_COPILOT_PREVIEW_PROVIDER_ID, binding?: CopilotAccountBinding): CredentialStore;
@@ -19,6 +19,7 @@ export interface PreviewProviderGuard {
19
19
  beforeWire(model: Model<Api>, options?: StreamOptions): Promise<{
20
20
  signal: AbortSignal;
21
21
  release(): void;
22
+ dispatch?(): void;
22
23
  }>;
23
24
  /** Actual model HTTP 401, excluding proven Responses replay-scope failures; no request replay. */
24
25
  onUnauthorized?(): void;
package/package.json CHANGED
@@ -1,7 +1,8 @@
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",
4
+ "version": "0.4.1",
5
+ "releaseNotes": "CHANGELOG.md",
5
6
  "publishConfig": {
6
7
  "access": "public",
7
8
  "registry": "https://registry.npmjs.org/",
@@ -107,20 +108,20 @@
107
108
  "@deepseek-ai/cordis": "^4.0.4",
108
109
  "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
109
110
  "@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.2",
110
- "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
111
- "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
112
- "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
113
111
  "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
114
112
  "@deepseek-ai/dsh-authorization": "0.2.0-rc.2",
115
113
  "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
116
114
  "@deepseek-ai/dsh-client-ui-settings-models": "0.2.0-rc.2",
117
115
  "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
116
+ "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
117
+ "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
118
+ "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
118
119
  "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
119
120
  "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.2",
120
121
  "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
121
122
  "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
122
- "@deepseek-ai/dsh-session": "0.2.0-rc.2",
123
123
  "@deepseek-ai/dsh-scope": "0.2.0-rc.2",
124
+ "@deepseek-ai/dsh-session": "0.2.0-rc.2",
124
125
  "@deepseek-ai/dsh-settings": "0.2.0-rc.2",
125
126
  "@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2",
126
127
  "@deepseek-ai/dsh-web": "0.2.0-rc.2",
@@ -159,22 +160,22 @@
159
160
  "@deepseek-ai/cordis": "~4.0.4",
160
161
  "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
161
162
  "@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.2",
162
- "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
163
- "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
164
- "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
165
- "@deepseek-ai/dsh-jobs": "0.2.0-rc.2",
166
163
  "@deepseek-ai/dsh-api-gateway": "0.2.0-rc.2",
167
164
  "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
168
165
  "@deepseek-ai/dsh-app-boot": "0.2.0-rc.2",
169
- "@deepseek-ai/dsh-config-editor": "0.2.0-rc.2",
170
166
  "@deepseek-ai/dsh-attachment": "0.2.0-rc.2",
171
167
  "@deepseek-ai/dsh-authorization": "0.2.0-rc.2",
172
168
  "@deepseek-ai/dsh-client-connection": "0.2.0-rc.2",
173
169
  "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
174
170
  "@deepseek-ai/dsh-client-ui-settings-models": "0.2.0-rc.2",
175
171
  "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
172
+ "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
173
+ "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
174
+ "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
175
+ "@deepseek-ai/dsh-config-editor": "0.2.0-rc.2",
176
176
  "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
177
177
  "@deepseek-ai/dsh-fs": "0.2.0-rc.2",
178
+ "@deepseek-ai/dsh-jobs": "0.2.0-rc.2",
178
179
  "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.2",
179
180
  "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
180
181
  "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",