dsh-github-copilot 0.4.0-alpha.83 → 0.4.0-alpha.84

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
@@ -73,6 +73,7 @@ Alpha.25 admits native `subagent/descriptor` v3, already v3 in the retained rc.1
73
73
  - `src/traditional-search.ts`: `github-copilot-hosted` `ctx.web` provider.
74
74
  - `src/serialize.ts`, `src/sse.ts`, `src/failure.ts`: protocol conversion and bounded error handling.
75
75
  - `src/response-error-body.ts`, `src/request-body-timeout.ts`: bounded clone-only HTTP error evidence and safe managed upload-timeout guidance. Exact verified `408/user_request_timeout` preserves native failure classification/retry metadata; final JSON bytes are not tokens or a payload limit. Never infer overflow, auto-compact, trim history, switch models or add retries from a 408.
76
+ - `src/request-body-evidence.ts`: verified-408-only, bounded numeric original-JSON span accounting through the existing fetch hook. Conversation/tool definitions/top-level system/residual partition total bytes; structural image and opaque replay spans are disjoint conversation subsets, never decoded contents. Unknown/limited evidence stays explicit. Fetch-to-header time excludes clone inspection and is not upload duration. No success-path analysis, retained body, automatic mitigation or supplier-limit claim.
76
77
  - `src/copilot-stream-liveness.ts`: request-local HTTP/SSE byte-idle observation, paired with the public native adapter's bounded assistant-chunk deadline. Default five-minute byte idle and ten-minute semantic silence; no fake assistant output, private watchdog access, new retry or Core patch. Consumer think time is excluded; explicit WebSocket/auto stays native-only. `chatStreamLiveness: false` restores native-only timing. `chatMaxRequestImageBytes` retains Core's 20 MiB default; smaller explicit settings authorize only native image offload, not hidden history trimming or a guessed supplier limit. Synthetic heartbeat evidence is not production heartbeat proof.
77
78
  - `tests/`: unit and integration evidence; mirror the source area being changed.
78
79
  - `deployment-baseline.json`: declared machine-readable compatibility and capability evidence inventory.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0-alpha.84 (prepared)
4
+
5
+ - Add bounded numeric composition of the actual final request for verified Copilot `408 / user_request_timeout`, distinguishing conversation, tool definitions, protocol-owned system/instructions and residual framing (#263).
6
+ - Within conversation, count structural image blocks and opaque replay as disjoint wire-byte subsets without decoding or reporting their content. Missing, unsupported, malformed and work-limited evidence remains explicit.
7
+ - Capture per-dispatch fetch-to-response-header elapsed time before clone observation, honestly labeled as round trip rather than upload duration. Preserve native payload/response bytes, failure classification, retry, cancellation and credentials; no automatic settings change, trimming, compaction or model switch. Diagnostics guide explicit mitigation, not a claim to cure recurring 408.
8
+
3
9
  ## 0.4.0-alpha.83 (prepared)
4
10
 
5
11
  - Reduce avoidable Auto uncertainty through bounded difficult-task continuation and isolated fenced mechanical-transform recognition (#262); preserve unknown for new, incomplete and ambiguous work.
package/README.md CHANGED
@@ -31,7 +31,7 @@ On official rc.2, routing is exposed through native live `Config` fields, not a
31
31
 
32
32
  ## Compatibility baselines and qualification targets
33
33
 
34
- Managed Copilot HTTP `408 / user_request_timeout` with the verified request-body timeout message now reports `COPILOT_REQUEST_BODY_TIMEOUT` and the final JSON request's UTF-8 byte count when observable. Bytes are not context tokens, and a request-body timeout does not prove context overflow. Native retries and failure classification remain unchanged. If retries exhaust, explicitly compact the conversation or reduce attachments/tool output before retrying, and check network/proxy health and [GitHub service status](https://www.githubstatus.com/). Compaction is not guaranteed to succeed or cure network/service faults; increasing a client timeout cannot change the server timeout. No automatic history trimming, model switch, compaction or new retry loop is introduced. Unknown errors retain native behavior.
34
+ Managed Copilot HTTP `408 / user_request_timeout` with the verified request-body timeout message reports `COPILOT_REQUEST_BODY_TIMEOUT`, the final JSON request's UTF-8 byte count, bounded numeric composition and fetch-to-response-header elapsed time when observable. Composition partitions conversation, tool definitions, top-level system/instructions and other/framing; image blocks and opaque replay are disjoint subsets of conversation. Remaining conversation includes text/tool history, framing and unknown fields, not a proven text-only count. Image blocks include URLs/references, not decoded image sizes. Timing is a round trip, **not upload duration**; bytes are not context tokens, a supplier payload limit or proof of the cause. Missing, unsupported or work-limited evidence stays explicit. Analysis runs only after the exact error is verified and never records request text, credentials or replay contents. Native retries and failure classification remain unchanged. After retries exhaust, these numbers can inform an **explicit** native image-offload budget change or compaction for compressible history; tool definitions and opaque replay may remain. Also check network/proxy health and [GitHub service status](https://www.githubstatus.com/). Compaction is not guaranteed to succeed or cure network/service faults; increasing a client timeout cannot change the server timeout. No automatic history trimming, settings change, model switch, compaction or new retry loop is introduced. Unknown errors retain native behavior.
35
35
 
36
36
  Managed HTTP/SSE chat now distinguishes **byte idle** from **assistant-output silence**. Native Core ignores SSE heartbeats when timing assistant chunks; synthetic unchanged-adapter tests reproduce a timeout despite incoming bytes. By default, five minutes without response headers/nonempty body bytes still fails, but real byte progress permits up to ten minutes without an assistant chunk. Endless heartbeats cannot postpone failure indefinitely, and consumer think time is excluded. `chatStreamLiveness: false` restores native-only timing; explicit WebSocket/`auto` transport remains native-only. This fixes the reproduced false-idle mechanism, not every retry or upstream HTTP 408, and does not establish heartbeat activity in a production incident.
37
37
 
@@ -109,7 +109,7 @@ The Host reads GitHub's internal quota endpoint using the existing canonical OAu
109
109
 
110
110
  ## Install and sign in
111
111
 
112
- The commands below target the package version `0.4.0-alpha.83`. 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):
112
+ The commands below target the package version `0.4.0-alpha.84`. 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):
113
113
 
114
114
  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):
115
115
 
@@ -122,10 +122,10 @@ Include any launcher patch files with repeated `--patch /absolute/file` argument
122
122
  For a standalone named profile only, the supported CLI command is:
123
123
 
124
124
  ```sh
125
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.83/dsh-github-copilot-0.4.0-alpha.83.tgz
125
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.84/dsh-github-copilot-0.4.0-alpha.84.tgz
126
126
  ```
127
127
 
128
- For Desktop profiles, use Desktop's native package manager with `dsh-github-copilot@0.4.0-alpha.83` 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.
128
+ For Desktop profiles, use Desktop's native package manager with `dsh-github-copilot@0.4.0-alpha.84` 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.
129
129
 
130
130
  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.
131
131
 
@@ -186,7 +186,7 @@ Agents should treat the browser authorization as a human handoff, not as a token
186
186
  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.
187
187
  6. Use **Sign out** only when the user explicitly asks to disconnect the account. It deletes the Copilot credential record but preserves route settings.
188
188
 
189
- 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.83`, 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).
189
+ 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.84`, 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).
190
190
 
191
191
  **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.
192
192
 
@@ -468,8 +468,8 @@ Report the published Release URL, version, tag/commit and verified asset SHA-256
468
468
  `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.
469
469
 
470
470
  ```sh
471
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.83/dsh-github-copilot-0.4.0-alpha.83.tgz
472
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.83/SHA256SUMS
471
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.84/dsh-github-copilot-0.4.0-alpha.84.tgz
472
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.84/SHA256SUMS
473
473
  sha256sum --check SHA256SUMS
474
474
  ```
475
475
 
@@ -477,7 +477,7 @@ PowerShell can verify the same two downloaded files with:
477
477
 
478
478
  ```powershell
479
479
  $expected = (Get-Content .\SHA256SUMS).Split()[0]
480
- $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.83.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
480
+ $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.84.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
481
481
  if ($actual -cne $expected) { throw 'Release checksum mismatch' }
482
482
  ```
483
483
 
package/README.zh.md CHANGED
@@ -27,7 +27,7 @@ Core 管理。详见[图片兼容性与限制](./docs/image-input-compatibility.
27
27
 
28
28
  截图来自当前构建 Client 的隔离浏览器 fixture,使用合成 Provider。它只证明已发布配置界面的形态,不证明真实凭据、账号权限、搜索成功或当前 Desktop 已加载。
29
29
 
30
- > 当前文档与安装命令对应版本 `0.4.0-alpha.83`。源码、发布制品、已安装版本和实际加载运行时需分别确认;本地升级和中断会话的重启仍需用户批准。
30
+ > 当前文档与安装命令对应版本 `0.4.0-alpha.84`。源码、发布制品、已安装版本和实际加载运行时需分别确认;本地升级和中断会话的重启仍需用户批准。
31
31
 
32
32
  Web search 路由现在优先显示在插件详情页;宿主不支持详情页插槽时才回退到 **设置 → 模型**或独立 Web search section。搜索子 Fiber 仍独立等待 Remote,不影响账号控件和既有搜索安全检查。
33
33
 
@@ -35,7 +35,7 @@ Web search 路由现在优先显示在插件详情页;宿主不支持详情页
35
35
 
36
36
  ## 兼容基线与待验收目标
37
37
 
38
- 托管 Copilot 返回 `408 / user_request_timeout` 且确认是读取请求体超时时,现会显示 `COPILOT_REQUEST_BODY_TIMEOUT`,并在可观测时给出最终 JSON 请求的 UTF-8 字节数。字节不是上下文 token,上传超时也不证明上下文超限。原生重试与失败分类保持不变。重试耗尽后,可显式压缩会话或减少附件/工具输出再试,并检查网络/代理及 [GitHub 服务状态](https://www.githubstatus.com/)。压缩不保证成功,也无法修复网络或服务故障;调大客户端超时不会改变服务端超时。插件不会自动裁剪历史、切换模型、压缩或新增重试循环,未识别错误仍由原生流程处理。
38
+ 托管 Copilot 返回 `408 / user_request_timeout` 且确认是读取请求体超时时,会显示 `COPILOT_REQUEST_BODY_TIMEOUT`,并在可观测时给出最终 JSON 的 UTF-8 字节数、有界的纯数字构成统计和 fetch 到响应头的耗时。构成分为会话、工具定义、顶层 system/instructions 和其他/封装;图片块与 opaque replay 是会话内互不重叠的子集。会话剩余部分包括文本/工具历史、封装及未知字段,不代表纯文本量;图片块包含 URL/引用,不是解码后的图片大小。耗时是往返时间,**不是上传时长**;字节不是 token、供应商大小上限或原因证明。缺失、未知结构、超出工作界限的证据明确标为不可用。仅在确认对应错误后才分析,不记录正文、凭证或 replay 内容。原生重试与失败分类保持不变。重试耗尽后,可据此选择**显式**调整原生图片 offload 预算或压缩可压缩历史;工具定义及 opaque replay 仍可能保留。另需检查网络/代理及 [GitHub 服务状态](https://www.githubstatus.com/)。压缩不保证成功,也无法修复网络或服务故障;调大客户端超时不会改变服务端超时。插件不会自动裁剪历史、改配置、切换模型、压缩或新增重试循环,未识别错误仍由原生流程处理。
39
39
 
40
40
  托管 HTTP/SSE 聊天现区分**字节空闲**与**助手输出静默**。Core 原生计时只看助手 chunk,忽略 SSE 心跳;未修改原生适配器的合成测试已复现“仍有字节却超时”。默认连续五分钟无响应头/非空响应体字节仍失败;实际字节进展只允许助手输出静默延长到十分钟,持续心跳也不能无限等待,消费者处理输出的时间不计入空闲。`chatStreamLiveness: false` 恢复纯原生计时;显式 WebSocket/`auto` transport 保持原生行为。这修复已复现的误判机制,不保证消除所有重试或服务端 HTTP 408,也不证明某次生产故障中实际存在心跳。
41
41
 
@@ -124,10 +124,10 @@ node package/scripts/check-search-composition.mjs --profile-dir /absolute/profil
124
124
  仅对独立的具名 profile,获准且网络可用时,可通过受支持的 CLI 命令安装:
125
125
 
126
126
  ```sh
127
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.83/dsh-github-copilot-0.4.0-alpha.83.tgz
127
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.84/dsh-github-copilot-0.4.0-alpha.84.tgz
128
128
  ```
129
129
 
130
- Desktop profile 请在完成同样的预检后,使用 Desktop 原生包管理器安装 `dsh-github-copilot@0.4.0-alpha.83`。Desktop 保留 `desktop` profile,CLI 不负责管理。若 registry 被公司封禁或不可用,不要更换网络绕行或使用离线 CLI;请停止。[受控离线 CLI 流程](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles)仅适用于独立具名 profile,不适用于 Desktop。
130
+ Desktop profile 请在完成同样的预检后,使用 Desktop 原生包管理器安装 `dsh-github-copilot@0.4.0-alpha.84`。Desktop 保留 `desktop` profile,CLI 不负责管理。若 registry 被公司封禁或不可用,不要更换网络绕行或使用离线 CLI;请停止。[受控离线 CLI 流程](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles)仅适用于独立具名 profile,不适用于 Desktop。
131
131
 
132
132
  随后打开上表对应的 Models UI,找到 **GitHub Copilot**,点击 **Sign in** 并完成 GitHub device-code 流程。安装会修改指定 profile;是否立即激活取决于该 profile 的常规 reload/restart 策略。
133
133
 
@@ -188,7 +188,7 @@ Agent 应把浏览器授权视为需要用户完成的 handoff,而不是自行
188
188
  5. 确认 **Signed in** 并检查自动发现结果,再请用户选择模型。已登录时打开 Models 会自动确保缺失/过期元数据,新鲜 ready 缓存不发请求。错误可使用 **Retry**,有意强制更新时使用 **Manage → Refresh models**,不作为常规设置步骤。状态读取本身不发现;登录、元数据与真实调用成功是独立证据。
189
189
  6. 只有用户明确要求断开账号时才使用 **Sign out**;它会删除 Copilot credential record,但保留 route settings。
190
190
 
191
- 每个新版本默认同时分发到 GitHub Releases 和 npm,两个渠道使用同一份已验证 tarball。应固定版本并核对所用渠道的证据:Release 的 `SHA256SUMS`;从 npm 安装时另核对 `dist.integrity`。Desktop profile 只能通过原生 Desktop 包管理器安装;获准且 registry 可用时输入 `dsh-github-copilot@0.4.0-alpha.83`,不是 URL 或本地文件。Desktop 保留 `desktop` profile,不能通过 DSH CLI 管理。受控离线 CLI 维护仅适用于独立具名 profile,不得作为 Desktop 安装绕行方案。[双渠道发布与 OIDC 要求](./docs/npm-distribution.md)保持不变。
191
+ 每个新版本默认同时分发到 GitHub Releases 和 npm,两个渠道使用同一份已验证 tarball。应固定版本并核对所用渠道的证据:Release 的 `SHA256SUMS`;从 npm 安装时另核对 `dist.integrity`。Desktop profile 只能通过原生 Desktop 包管理器安装;获准且 registry 可用时输入 `dsh-github-copilot@0.4.0-alpha.84`,不是 URL 或本地文件。Desktop 保留 `desktop` profile,不能通过 DSH CLI 管理。受控离线 CLI 维护仅适用于独立具名 profile,不得作为 Desktop 安装绕行方案。[双渠道发布与 OIDC 要求](./docs/npm-distribution.md)保持不变。
192
192
 
193
193
  **Desktop package 更新与 Web 生命周期边界:**原生 manager 对已安装 package 原位升级返回的 `restart-required` 是权威结果,与移除/重加 plugin bundle 的行为是两个不同问题。涉及服务重编排补丁(`cordis.patch.yml`,如本插件所采用的隔离路由 Web 搜索层)的停用、移除或升级,可能让依赖条目保持 pending,直到完全退出并冷重启 Desktop。若原生 manager 只报告类似 `pending (waiting for service: web)` 的条目,同时本插件已经显示 **Off**,说明请求的停用状态已经落盘;请冷重启 Desktop,不要反复切换或重装插件。其它错误不属于此提示范围,仍需单独排查。
194
194
 
@@ -479,8 +479,8 @@ node scripts/agent.mjs attribution "DeepSeek Harness (DSH)"
479
479
  `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 要求包已存在,不能代替首次建包。不会批量补发历史版本。
480
480
 
481
481
  ```sh
482
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.83/dsh-github-copilot-0.4.0-alpha.83.tgz
483
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.83/SHA256SUMS
482
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.84/dsh-github-copilot-0.4.0-alpha.84.tgz
483
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.84/SHA256SUMS
484
484
  sha256sum --check SHA256SUMS
485
485
  ```
486
486
 
@@ -488,7 +488,7 @@ PowerShell 可以对已下载的同一组文件执行:
488
488
 
489
489
  ```powershell
490
490
  $expected = (Get-Content .\SHA256SUMS).Split()[0]
491
- $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.83.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
491
+ $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.84.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
492
492
  if ($actual -cne $expected) { throw 'Release checksum mismatch' }
493
493
  ```
494
494
 
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "package": {
10
10
  "name": "dsh-github-copilot",
11
- "version": "0.4.0-alpha.83"
11
+ "version": "0.4.0-alpha.84"
12
12
  },
13
13
  "evidence": {
14
14
  "kind": "source-and-synthetic-test-inventory",
@@ -572,6 +572,7 @@
572
572
  {"file": "src/remote.ts", "marker": "githubCopilot.setModelExcluded"},
573
573
  {"file": "src/preview-provider.ts", "marker": "native.streamSimple"},
574
574
  {"file": "src/request-body-timeout.ts", "marker": "COPILOT_REQUEST_BODY_TIMEOUT"},
575
+ {"file": "src/request-body-evidence.ts", "marker": "REQUEST_BODY_EVIDENCE_LIMITS"},
575
576
  {"file": "src/copilot-stream-liveness.ts", "marker": "COPILOT_STREAM_IDLE_TIMEOUT"},
576
577
  {"file": "src/preview-route.ts", "marker": "Math.min(idle * 2, 2_147_483_647)"},
577
578
  {"file": "src/response-error-body.ts", "marker": "readResponseErrorJson"},
@@ -591,6 +592,8 @@
591
592
  {"file": "tests/preview-route.spec.ts", "name": "enriches only a verified 408 while preserving native failure classification and retry ownership"},
592
593
  {"file": "tests/preview-provider.spec.ts", "name": "observes verified %s timeout without changing bytes, Response, native retries or credential ownership"},
593
594
  {"file": "tests/request-body-timeout.spec.ts", "name": "bounds stalled response observation and gives cancellation priority"},
595
+ {"file": "tests/request-body-evidence.spec.ts", "name": "measures a nine MiB native-style inline image without exposing or decoding it"},
596
+ {"file": "tests/preview-provider.spec.ts", "name": "captures final %s callback bytes and dispatch-local header time before clone observation"},
594
597
  {"file": "tests/copilot-stream-liveness.spec.ts", "name": "does not count consumer think time as provider idle"},
595
598
  {"file": "tests/copilot-stream-adapter.spec.ts", "name": "reproduces native semantic timeout despite ongoing SSE bytes"},
596
599
  {"file": "tests/copilot-stream-adapter.spec.ts", "name": "allows real late output after the original semantic-idle boundary"},
@@ -67,6 +67,12 @@ The existing `enabled` switch remains hosted-search-only. These controls do not
67
67
 
68
68
  HTTP `408 / user_request_timeout` is separate from input-budget overflow. For the exact observed request-body timeout response, the managed route supplies a safe `COPILOT_REQUEST_BODY_TIMEOUT` diagnostic and final JSON UTF-8 byte count when available, while preserving native failure classification and retries. These bytes include serialized messages, tools and replay/attachments; they are not token occupancy or an advertised HTTP-size limit. Repeated unchanged retries cannot reduce the request. After retries exhaust, an explicit native compaction may reduce compressible history, but giant fixed prefixes/attachments and network/service faults may remain. The existing optional manual recovery engine must be separately selected; installing the account plugin does not enable it. No 408 triggers automatic compaction, hidden history trimming, credential refresh, model switching, timeout changes or a second retry loop. Consult [GitHub troubleshooting](https://docs.github.com/en/copilot/how-tos/troubleshoot-copilot/troubleshoot-common-issues) and [service status](https://www.githubstatus.com/) without bypassing network policy.
69
69
 
70
+ For [#263](https://github.com/cloga/dsh-github-copilot/issues/263), the same public final-body fetch hook additionally captures a monotonic fetch-invocation-to-response-header duration, before clone observation. This is round-trip latency, not measured upload progress, throughput or time spent reading the body. Only a verified exact error triggers numeric composition analysis; successful requests are not analyzed or retained.
71
+
72
+ Original serialized value spans partition total bytes into `input`/`messages`, tool definitions, protocol-owned top-level `instructions`/`system` and residual keys/framing. Within conversation only, supported structural image blocks and opaque replay string spans form disjoint subsets; the rest includes text/tool history, framing and unknown representations. Completions system/developer messages stay in conversation. Image URLs and file references are counted as wire blocks, not fetched/decoded file sizes. Responses encrypted content and Anthropic signature/redacted data are counted without interpreting or decrypting replay; no raw contents, IDs, hashes or credentials are reported.
73
+
74
+ Analysis accepts at most 16 MiB of UTF-8 JSON, with a pre-parse depth/token bound (64 levels / 131072 tokens), followed by at most 65536 values and 128 serialized key characters. Missing, malformed, unsupported, size-limited and work-limited evidence has a named unavailable state with no partial success-shaped totals. Limits bound diagnostic cost and are **not supplier request limits or admission controls**. A reported 9 MiB body may be analyzed, but its size does not establish why a timeout occurred. If image blocks dominate, an explicitly selected smaller `chatMaxRequestImageBytes` can authorize native image offload; if compressible history dominates, explicit native compaction can help. Tool definitions and opaque replay may remain; small failing requests still warrant network/service investigation. Neither choice is performed automatically or guaranteed to reduce 408 frequency.
75
+
70
76
  This implementation is preventive, not a general rescue summarizer. A manual summary whose full input already exceeds the hard budget fails before model transport. It does not silently trim, fabricate a partial checkpoint, or claim that refusing the request recovered the history. Giant fixed prefixes or an indivisible latest unit can also prevent useful reduction.
71
77
 
72
78
  The #228 investigation confirmed a separate Auto undercount (#230): Core reasoning blocks caused the incompatible pi-ai estimator to throw and drop complete assistant messages. Auto now uses the native Core meter, without changing final native provider admission. This fixes candidate selection evidence, not a genuinely oversized summary. In the reported failure class, a roughly 508k-token summary input exceeded a roughly 368k-token input budget even with a 65,536-token output reservation. Reducing output reservation cannot remove an independently binding prompt ceiling.
package/lib/index.js CHANGED
@@ -193,12 +193,12 @@ function fail$1(reason, creation) {
193
193
  function creationOf(error) {
194
194
  return ownRemoteFailure(error)?.creation ?? "uncertain";
195
195
  }
196
- function object$5(value) {
196
+ function object$6(value) {
197
197
  return typeof value === "object" && value !== null && !Array.isArray(value);
198
198
  }
199
199
  function api$1(ctx, key, methods) {
200
200
  const value = ctx.get(key);
201
- return object$5(value) && methods.every((method) => typeof value[method] === "function") ? value : void 0;
201
+ return object$6(value) && methods.every((method) => typeof value[method] === "function") ? value : void 0;
202
202
  }
203
203
  function revision(value) {
204
204
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
@@ -223,7 +223,7 @@ const ERROR_REASONS = /* @__PURE__ */ new Set([
223
223
  /** Remote errors cross bundle/realm boundaries; constructor identity is not a protocol. */
224
224
  function ownRemoteFailure(error) {
225
225
  try {
226
- if (!object$5(error) || error.isDSHRemoteError !== true || error.code !== "copilot/dual-model" || !object$5(error.details)) return void 0;
226
+ if (!object$6(error) || error.isDSHRemoteError !== true || error.code !== "copilot/dual-model" || !object$6(error.details)) return void 0;
227
227
  const reason = error.details.reason;
228
228
  if (typeof reason !== "string" || !ERROR_REASONS.has(reason)) return void 0;
229
229
  const creation = error.details.creation;
@@ -239,7 +239,7 @@ function reasonOf(error, fallback) {
239
239
  const own = ownRemoteFailure(error);
240
240
  if (own) return own.reason;
241
241
  try {
242
- if (object$5(error) && error.code === "SETTINGS_CONFLICT") return "DUAL_MODEL_REVISION_CONFLICT";
242
+ if (object$6(error) && error.code === "SETTINGS_CONFLICT") return "DUAL_MODEL_REVISION_CONFLICT";
243
243
  } catch {}
244
244
  return fallback;
245
245
  }
@@ -367,7 +367,7 @@ let GitHubCopilotDualModel = (() => {
367
367
  }, { prepend: true });
368
368
  ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
369
369
  const candidate = context.scope;
370
- if (!candidate || !object$5(candidate.session) || !object$5(candidate.session.header) || !dedicatedAddress(candidate)) return next();
370
+ if (!candidate || !object$6(candidate.session) || !object$6(candidate.session.header) || !dedicatedAddress(candidate)) return next();
371
371
  const rehydrating = !this.overlays.has(candidate);
372
372
  if (rehydrating) this.restore(candidate);
373
373
  const installed = this.overlays.get(candidate);
@@ -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.83";
1850
+ var version = "0.4.0-alpha.84";
1851
1851
  //#endregion
1852
1852
  //#region lib/types/probe.js
1853
1853
  /**
@@ -4043,19 +4043,19 @@ var TemporaryRouteConflictError = class extends Error {
4043
4043
  this.name = "TemporaryRouteConflictError";
4044
4044
  }
4045
4045
  };
4046
- function object$4(value) {
4046
+ function object$5(value) {
4047
4047
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
4048
4048
  }
4049
4049
  function profileAt(value) {
4050
- return object$4(object$4(object$4(value)?.providers)?.["github-copilot"]);
4050
+ return object$5(object$5(object$5(value)?.providers)?.["github-copilot"]);
4051
4051
  }
4052
4052
  /** Bounded comparison; never stringify or copy unknown model extras or headers. */
4053
4053
  function equalJson(a, b, depth = 0) {
4054
4054
  if (a === b) return true;
4055
4055
  if (depth > 12) return false;
4056
4056
  if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length <= 512 && a.length === b.length && a.every((value, i) => equalJson(value, b[i], depth + 1));
4057
- const left = object$4(a);
4058
- const right = object$4(b);
4057
+ const left = object$5(a);
4058
+ const right = object$5(b);
4059
4059
  if (!left || !right) return false;
4060
4060
  const keys = Object.keys(left);
4061
4061
  return keys.length <= 512 && keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && equalJson(left[key], right[key], depth + 1));
@@ -4064,7 +4064,7 @@ const MAX_BACKUP = 131072;
4064
4064
  function safeModels(value) {
4065
4065
  if (!Array.isArray(value) || value.length > 512) throw new TemporaryRouteConflictError();
4066
4066
  return value.map((entry) => {
4067
- const model = object$4(entry);
4067
+ const model = object$5(entry);
4068
4068
  if (!model || typeof model.id !== "string" || !/^[a-zA-Z0-9._:/-]{1,200}$/.test(model.id)) throw new TemporaryRouteConflictError();
4069
4069
  const overlay = temporaryGitHubCopilotModel(model.id, /* @__PURE__ */ new Map());
4070
4070
  if (overlay && Object.keys(model).some((key) => key !== "id" && key !== "api")) {
@@ -4095,10 +4095,10 @@ function readBackup(value) {
4095
4095
  if (value === void 0) return void 0;
4096
4096
  if (typeof value !== "string" || value.length > MAX_BACKUP) throw new TemporaryRouteConflictError("TEMPORARY_ROUTE_INVALID_BACKUP");
4097
4097
  try {
4098
- const decoded = object$4(JSON.parse(value));
4098
+ const decoded = object$5(JSON.parse(value));
4099
4099
  if (!decoded) throw new Error();
4100
4100
  if (decoded.version === void 0 || decoded.version === 2 && decoded.sourceEpoch === void 0) throw new TemporaryRouteConflictError("TEMPORARY_ROUTE_LEGACY_CONFLICT");
4101
- if (decoded.version !== 2 || typeof decoded.providerExisted !== "boolean" || typeof decoded.sourceEpoch !== "string" || !/^[a-f0-9-]{36}$/.test(decoded.sourceEpoch) || !Number.isSafeInteger(decoded.sourceRevision) || Number(decoded.sourceRevision) < 0 || !["overlay", "restoring"].includes(String(decoded.phase)) || !object$4(decoded.preimage) || !object$4(decoded.postimage) || !object$4(decoded.ownedHeaders) || Object.keys(decoded).some((key) => ![
4101
+ if (decoded.version !== 2 || typeof decoded.providerExisted !== "boolean" || typeof decoded.sourceEpoch !== "string" || !/^[a-f0-9-]{36}$/.test(decoded.sourceEpoch) || !Number.isSafeInteger(decoded.sourceRevision) || Number(decoded.sourceRevision) < 0 || !["overlay", "restoring"].includes(String(decoded.phase)) || !object$5(decoded.preimage) || !object$5(decoded.postimage) || !object$5(decoded.ownedHeaders) || Object.keys(decoded).some((key) => ![
4102
4102
  "version",
4103
4103
  "providerExisted",
4104
4104
  "preimage",
@@ -4115,15 +4115,15 @@ function readBackup(value) {
4115
4115
  decoded.postimage,
4116
4116
  ...decoded.phase === "restoring" ? [decoded.target] : []
4117
4117
  ]) {
4118
- const record = object$4(leaf);
4118
+ const record = object$5(leaf);
4119
4119
  if (!record || !equalJson(record, leavesOf(record))) throw new Error();
4120
4120
  }
4121
- const models = object$4(decoded.postimage)?.models ?? [];
4121
+ const models = object$5(decoded.postimage)?.models ?? [];
4122
4122
  const knownHeaders = Object.assign({}, ...models.flatMap((model) => {
4123
4123
  const overlay = temporaryGitHubCopilotModelFromProfile(model);
4124
4124
  return overlay ? [overlay.headers] : [];
4125
4125
  }));
4126
- if (!Object.entries(object$4(decoded.ownedHeaders)).every(([name, header]) => knownHeaders[name] === header)) throw new Error();
4126
+ if (!Object.entries(object$5(decoded.ownedHeaders)).every(([name, header]) => knownHeaders[name] === header)) throw new Error();
4127
4127
  if (decoded.removeProfile !== void 0 && typeof decoded.removeProfile !== "boolean") throw new Error();
4128
4128
  return decoded;
4129
4129
  } catch (error) {
@@ -4149,7 +4149,7 @@ function settingsSnapshot(settings) {
4149
4149
  hasOwnedSecrets,
4150
4150
  routeRevision: route.revision,
4151
4151
  markerRevision: marker.revision,
4152
- backup: readBackup(object$4(marker.value)?.temporaryRouteBackup)
4152
+ backup: readBackup(object$5(marker.value)?.temporaryRouteBackup)
4153
4153
  };
4154
4154
  }
4155
4155
  function assertOwned(current, backup) {
@@ -4182,7 +4182,7 @@ function leafOperations(current, target) {
4182
4182
  }]);
4183
4183
  }
4184
4184
  function ownedHeaderRemoval(current, backup) {
4185
- return Object.entries(object$4(current?.headers) ?? {}).flatMap(([name, value]) => Object.entries(backup.ownedHeaders).some(([ownedName, ownedValue]) => name.toLowerCase() === ownedName.toLowerCase() && value === ownedValue) ? [{
4185
+ return Object.entries(object$5(current?.headers) ?? {}).flatMap(([name, value]) => Object.entries(backup.ownedHeaders).some(([ownedName, ownedValue]) => name.toLowerCase() === ownedName.toLowerCase() && value === ownedValue) ? [{
4186
4186
  op: "unset",
4187
4187
  path: [
4188
4188
  "providers",
@@ -4204,7 +4204,7 @@ function wholeProfileOwned(snapshot, backup) {
4204
4204
  //#endregion
4205
4205
  //#region lib/types/migration-status.js
4206
4206
  const LIMIT = 1024;
4207
- function object$3(value) {
4207
+ function object$4(value) {
4208
4208
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("Invalid evidence");
4209
4209
  return value;
4210
4210
  }
@@ -4213,7 +4213,7 @@ function text$2(value) {
4213
4213
  return value;
4214
4214
  }
4215
4215
  function selection(value, omitDefaultEffort = false) {
4216
- const item = object$3(value);
4216
+ const item = object$4(value);
4217
4217
  const provider = text$2(item.provider), model = text$2(item.model), effort = item.reasoningEffort;
4218
4218
  if (effort !== void 0) text$2(effort);
4219
4219
  return {
@@ -4228,7 +4228,7 @@ function array(value) {
4228
4228
  }
4229
4229
  function api(ctx, name, methods) {
4230
4230
  try {
4231
- const candidate = object$3(ctx.get(name));
4231
+ const candidate = object$4(ctx.get(name));
4232
4232
  return methods.every((key) => typeof candidate[key] === "function") ? candidate : void 0;
4233
4233
  } catch {
4234
4234
  return;
@@ -4298,26 +4298,26 @@ function migrationStatus(ctx) {
4298
4298
  const rows = [], ids = /* @__PURE__ */ new Set();
4299
4299
  let complete = projections !== void 0;
4300
4300
  for (const candidate of array(call(agents, "list"))) {
4301
- const agent = object$3(candidate), id = text$2(agent.id), status = agent.status;
4301
+ const agent = object$4(candidate), id = text$2(agent.id), status = agent.status;
4302
4302
  if (ids.has(id) || status !== "idle" && status !== "running") throw new Error("Invalid agent inventory");
4303
4303
  ids.add(id);
4304
- const session = object$3(agent.session);
4304
+ const session = object$4(agent.session);
4305
4305
  if (text$2(session.id) !== id) throw new Error("Invalid agent identity");
4306
4306
  const header = call(session, "requestHeader");
4307
- const request = header === void 0 ? null : selection(object$3(header).config);
4307
+ const request = header === void 0 ? null : selection(object$4(header).config);
4308
4308
  let effective = null, source = "unknown";
4309
4309
  if (projections) {
4310
4310
  const state = call(projections, "stateOf", session, "modelSelection");
4311
4311
  if (state !== void 0) {
4312
- const pending = object$3(state).pending;
4312
+ const pending = object$4(state).pending;
4313
4313
  if (pending !== null) {
4314
4314
  effective = selection(pending);
4315
4315
  source = "pending";
4316
4316
  } else if (header !== void 0) {
4317
- const defaults = object$3(header).adapterDefaults;
4318
- const defaultEffort = defaults === void 0 ? false : object$3(defaults).reasoningEffort;
4317
+ const defaults = object$4(header).adapterDefaults;
4318
+ const defaultEffort = defaults === void 0 ? false : object$4(defaults).reasoningEffort;
4319
4319
  if (defaultEffort !== void 0 && typeof defaultEffort !== "boolean") throw new Error("Invalid adapter defaults");
4320
- effective = selection(object$3(header).config, defaultEffort === true);
4320
+ effective = selection(object$4(header).config, defaultEffort === true);
4321
4321
  source = "request-header";
4322
4322
  } else if (result.complete.defaultSelection) {
4323
4323
  effective = result.defaultSelection;
@@ -4341,23 +4341,23 @@ function migrationStatus(ctx) {
4341
4341
  const descriptors = array(call(settings, "describe", { redactSecrets: true }));
4342
4342
  const found = /* @__PURE__ */ new Set();
4343
4343
  for (const value of descriptors) {
4344
- const descriptor = object$3(value);
4344
+ const descriptor = object$4(value);
4345
4345
  const ns = text$2(descriptor.ns);
4346
4346
  if (ns !== "llm-pi-ai" && ns !== "github-copilot") continue;
4347
4347
  if (found.has(ns) || !Number.isSafeInteger(descriptor.revision) || descriptor.revision < 0) throw new Error("Invalid settings evidence");
4348
4348
  found.add(ns);
4349
4349
  }
4350
4350
  if (found.size !== 2) throw new Error("Unregistered settings");
4351
- const config = object$3(call(settings, "get", "llm-pi-ai"));
4352
- const profile = (config.providers === void 0 ? void 0 : object$3(config.providers))?.[GITHUB_COPILOT_PROVIDER_ID];
4353
- if (profile !== void 0) object$3(profile);
4351
+ const config = object$4(call(settings, "get", "llm-pi-ai"));
4352
+ const profile = (config.providers === void 0 ? void 0 : object$4(config.providers))?.[GITHUB_COPILOT_PROVIDER_ID];
4353
+ if (profile !== void 0) object$4(profile);
4354
4354
  result.capabilities.settingsCas = true;
4355
4355
  result.routes.nativeConfigured = profile !== void 0;
4356
4356
  } catch {}
4357
4357
  if (llm) try {
4358
4358
  const ids = /* @__PURE__ */ new Set();
4359
4359
  for (const value of array(call(llm, "listProviders"))) {
4360
- const id = text$2(object$3(value).id);
4360
+ const id = text$2(object$4(value).id);
4361
4361
  if (ids.has(id)) throw new Error("Invalid registry evidence");
4362
4362
  ids.add(id);
4363
4363
  }
@@ -4559,7 +4559,7 @@ function modelPreferencesView(ctx, accountModels, error) {
4559
4559
  if (!Number.isSafeInteger(descriptor.revision) || descriptor.revision < 0) return unavailable("COPILOT_MODEL_SETTINGS_INVALID");
4560
4560
  let excludedModelIds;
4561
4561
  try {
4562
- const raw = object$4(descriptor.value);
4562
+ const raw = object$5(descriptor.value);
4563
4563
  if (raw === void 0) return unavailable("COPILOT_MODEL_SETTINGS_INVALID");
4564
4564
  excludedModelIds = normalizeExcludedModelIds(raw.excludedModelIds);
4565
4565
  } catch {
@@ -4676,7 +4676,7 @@ async function repairGitHubCopilotProviderProfile(ctx) {
4676
4676
  try {
4677
4677
  await settings.mutate(namespace, operations, revision);
4678
4678
  } catch (error) {
4679
- if (object$4(error)?.code === "SETTINGS_CONFLICT") throw new TemporaryRouteConflictError();
4679
+ if (object$5(error)?.code === "SETTINGS_CONFLICT") throw new TemporaryRouteConflictError();
4680
4680
  throw error;
4681
4681
  }
4682
4682
  };
@@ -5102,7 +5102,7 @@ let GitHubCopilotAuthorizationController = (() => {
5102
5102
  }], current.revision);
5103
5103
  this.modelPreferenceFailure = void 0;
5104
5104
  } catch (cause) {
5105
- const record = object$4(cause);
5105
+ const record = object$5(cause);
5106
5106
  this.modelPreferenceFailure = record?.code === "SETTINGS_CONFLICT" || cause instanceof Error && /conflict/i.test(cause.message) ? "COPILOT_MODEL_EXCLUSION_CONFLICT" : "COPILOT_MODEL_EXCLUSION_SAVE_FAILED";
5107
5107
  }
5108
5108
  return view();
@@ -5247,7 +5247,7 @@ const levels = [
5247
5247
  "xhigh",
5248
5248
  "max"
5249
5249
  ];
5250
- function object$2(value) {
5250
+ function object$3(value) {
5251
5251
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
5252
5252
  }
5253
5253
  function unavailable() {
@@ -5256,18 +5256,18 @@ function unavailable() {
5256
5256
  /** Resolve only the selected model's declared/native efforts, with the same precedence as Core. */
5257
5257
  function resolveCopilotResponsesReasoning(ctx, request, candidate) {
5258
5258
  if (request.provider !== "github-copilot" || candidate.protocol !== "openai-responses" || candidate.model !== request.model) return unavailable();
5259
- const profile = object$2(object$2(object$2(readSettingsNamespace(ctx, "llm-pi-ai"))?.providers)?.["github-copilot"]);
5259
+ const profile = object$3(object$3(object$3(readSettingsNamespace(ctx, "llm-pi-ai"))?.providers)?.["github-copilot"]);
5260
5260
  const effort = request.reasoningEffort ?? profile?.reasoning;
5261
5261
  if (effort === void 0) return void 0;
5262
5262
  const level = levels.find((value) => value === effort);
5263
5263
  if (level === void 0 || profile === void 0) return unavailable();
5264
5264
  const configured = Array.isArray(profile.models) ? profile.models : [];
5265
- const entry = configured.length > 0 ? object$2(configured.find((value) => object$2(value)?.id === request.model)) : object$2(object$2(profile.modelOverrides)?.[request.model]);
5265
+ const entry = configured.length > 0 ? object$3(configured.find((value) => object$3(value)?.id === request.model)) : object$3(object$3(profile.modelOverrides)?.[request.model]);
5266
5266
  if (configured.length > 0 && entry === void 0) return unavailable();
5267
5267
  const declared = entry?.reasoningEfforts;
5268
5268
  if (declared !== void 0) {
5269
5269
  if (declared === false) return level === "off" ? void 0 : unavailable();
5270
- const mapping = object$2(declared);
5270
+ const mapping = object$3(declared);
5271
5271
  if (mapping === void 0) return unavailable();
5272
5272
  const wire = mapping[level];
5273
5273
  if (level === "off" && (wire === null || typeof wire === "string" && wire.length > 0)) return void 0;
@@ -5539,19 +5539,207 @@ async function isCopilotInputItemScopeError(response, signal) {
5539
5539
  return !signal?.aborted && isScopeError(body);
5540
5540
  }
5541
5541
  //#endregion
5542
+ //#region lib/types/request-body-evidence.js
5543
+ const REQUEST_BODY_EVIDENCE_LIMITS = Object.freeze({
5544
+ bytes: 16777216,
5545
+ values: 65536,
5546
+ tokens: 131072,
5547
+ depth: 64,
5548
+ keyCharacters: 128
5549
+ });
5550
+ function formatRequestBodyEvidence(evidence, responseHeadersMs) {
5551
+ const elapsed = responseHeadersMs === void 0 ? void 0 : Math.round(responseHeadersMs);
5552
+ const timing = responseHeadersMs !== void 0 && responseHeadersMs >= 0 && elapsed !== void 0 && Number.isSafeInteger(elapsed) ? `Fetch-to-response-headers: ${elapsed} ms (round trip, not upload duration).` : "Fetch-to-response-headers timing unavailable.";
5553
+ if (evidence.state !== "complete") return `Composition unavailable (${evidence.state}); no partial totals inferred. ${timing}`;
5554
+ return `Composition (wire UTF-8 bytes): conversation ${evidence.conversationBytes}, tool definitions ${evidence.toolSchemaBytes}, top-level system/instructions ${evidence.systemBytes}, other/framing ${evidence.otherBytes}. Within conversation (disjoint subsets): image blocks ${evidence.imageBlockBytes}, opaque replay ${evidence.opaqueReplayBytes}, remaining ${evidence.remainingConversationBytes} (text/tool history, framing and unrecognized fields). Image blocks include URLs/references, not decoded image sizes; unknown encodings stay in remaining/other. ${timing}`;
5555
+ }
5556
+ var EvidenceParseError = class extends Error {
5557
+ state;
5558
+ constructor(state) {
5559
+ super(state);
5560
+ this.state = state;
5561
+ }
5562
+ };
5563
+ function object$2(value) {
5564
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5565
+ }
5566
+ /** Diagnostic-only traversal of the original JSON spans; never reserializes or changes a request. */
5567
+ function requestBodyEvidence(body, protocol) {
5568
+ if (body === void 0) return { state: "unavailable" };
5569
+ const totalBytes = Buffer.byteLength(body, "utf8");
5570
+ if (totalBytes > REQUEST_BODY_EVIDENCE_LIMITS.bytes) return {
5571
+ state: "size-limit",
5572
+ totalBytes
5573
+ };
5574
+ let nesting = 0, tokens = 0;
5575
+ for (let index = 0; index < body.length; index++) {
5576
+ const character = body[index];
5577
+ if (character === "{" || character === "[") {
5578
+ if (++nesting > REQUEST_BODY_EVIDENCE_LIMITS.depth) return {
5579
+ state: "work-limit",
5580
+ totalBytes
5581
+ };
5582
+ tokens++;
5583
+ } else if (character === "}" || character === "]") nesting--;
5584
+ else if (character === "\"") {
5585
+ tokens++;
5586
+ while (++index < body.length) if (body[index] === "\\") index++;
5587
+ else if (body[index] === "\"") break;
5588
+ } else if (character !== " " && character !== "\n" && character !== "\r" && character !== " " && character !== ":" && character !== ",") {
5589
+ tokens++;
5590
+ while (index + 1 < body.length && !/[\s,\]}]/u.test(body[index + 1])) index++;
5591
+ }
5592
+ if (tokens > REQUEST_BODY_EVIDENCE_LIMITS.tokens) return {
5593
+ state: "work-limit",
5594
+ totalBytes
5595
+ };
5596
+ }
5597
+ let parsed;
5598
+ try {
5599
+ parsed = JSON.parse(body);
5600
+ } catch (error) {
5601
+ if (!(error instanceof SyntaxError)) throw error;
5602
+ return {
5603
+ state: "invalid-json",
5604
+ totalBytes
5605
+ };
5606
+ }
5607
+ const conversationKey = protocol === "openai-responses" ? "input" : "messages";
5608
+ const systemKey = protocol === "openai-responses" ? "instructions" : protocol === "anthropic-messages" ? "system" : void 0;
5609
+ if (!object$2(parsed) || !Array.isArray(parsed[conversationKey])) return {
5610
+ state: "unsupported-shape",
5611
+ totalBytes
5612
+ };
5613
+ let position = 0, values = 0, conversationBytes = 0, toolSchemaBytes = 0, systemBytes = 0;
5614
+ let imageBlockBytes = 0, opaqueReplayBytes = 0;
5615
+ const whitespace = () => {
5616
+ while (position < body.length && /\s/u.test(body[position])) position++;
5617
+ };
5618
+ const bytes = (start) => Buffer.byteLength(body.slice(start, position), "utf8");
5619
+ const stringEnd = () => {
5620
+ if (body[position++] !== "\"") throw new EvidenceParseError("invalid-json");
5621
+ while (position < body.length) {
5622
+ const character = body[position++];
5623
+ if (character === "\"") return;
5624
+ if (character === "\\") position++;
5625
+ }
5626
+ throw new EvidenceParseError("invalid-json");
5627
+ };
5628
+ const isImage = (value) => protocol === "anthropic-messages" ? value.type === "image" && object$2(value.source) && (value.source.type === "base64" && typeof value.source.data === "string" || value.source.type === "url" && typeof value.source.url === "string") : protocol === "openai-responses" ? value.type === "input_image" && (typeof value.image_url === "string" || typeof value.file_id === "string") : value.type === "image_url" && object$2(value.image_url) && typeof value.image_url.url === "string";
5629
+ const isOpaque = (parent, key, location) => protocol === "openai-responses" ? location === "conversation" && parent.type === "reasoning" && key === "encrypted_content" : location === "content" && protocol === "anthropic-messages" && (parent.type === "thinking" && key === "signature" || parent.type === "redacted_thinking" && key === "data");
5630
+ const visit = (value, depth, location) => {
5631
+ if (++values > REQUEST_BODY_EVIDENCE_LIMITS.values || depth > REQUEST_BODY_EVIDENCE_LIMITS.depth) throw new EvidenceParseError("work-limit");
5632
+ whitespace();
5633
+ const start = position;
5634
+ let image = 0, replay = 0;
5635
+ if (Array.isArray(value)) {
5636
+ if (body[position++] !== "[") throw new EvidenceParseError("invalid-json");
5637
+ for (let index = 0; index < value.length; index++) {
5638
+ if (index > 0) {
5639
+ whitespace();
5640
+ if (body[position++] !== ",") throw new EvidenceParseError("invalid-json");
5641
+ }
5642
+ const child = visit(value[index], depth + 1, location);
5643
+ image += child.image;
5644
+ replay += child.replay;
5645
+ }
5646
+ whitespace();
5647
+ if (body[position++] !== "]") throw new EvidenceParseError("invalid-json");
5648
+ } else if (object$2(value)) {
5649
+ if (body[position++] !== "{") throw new EvidenceParseError("invalid-json");
5650
+ const imageBlock = location === "content" && isImage(value);
5651
+ const seen = /* @__PURE__ */ new Set();
5652
+ whitespace();
5653
+ while (body[position] !== "}") {
5654
+ if (seen.size > 0) {
5655
+ if (body[position++] !== ",") throw new EvidenceParseError("invalid-json");
5656
+ whitespace();
5657
+ }
5658
+ const keyStart = position;
5659
+ stringEnd();
5660
+ if (position - keyStart > REQUEST_BODY_EVIDENCE_LIMITS.keyCharacters) throw new EvidenceParseError("work-limit");
5661
+ const key = JSON.parse(body.slice(keyStart, position));
5662
+ if (typeof key !== "string" || seen.has(key) || !Object.hasOwn(value, key)) throw new EvidenceParseError("invalid-json");
5663
+ seen.add(key);
5664
+ whitespace();
5665
+ if (body[position++] !== ":") throw new EvidenceParseError("invalid-json");
5666
+ whitespace();
5667
+ const childLocation = imageBlock ? "other" : depth === 0 && key === conversationKey ? "conversation" : key === "content" && (location === "conversation" || location === "content") && Array.isArray(value[key]) ? "content" : "other";
5668
+ const childStart = position, child = visit(value[key], depth + 1, childLocation);
5669
+ const childBytes = depth === 0 || isOpaque(value, key, location) && typeof value[key] === "string" ? bytes(childStart) : 0;
5670
+ if (depth === 0) {
5671
+ if (key === conversationKey) {
5672
+ conversationBytes = childBytes;
5673
+ imageBlockBytes = child.image;
5674
+ opaqueReplayBytes = child.replay;
5675
+ } else if ((key === "tools" || protocol === "openai-completions" && key === "functions") && Array.isArray(value[key])) toolSchemaBytes += childBytes;
5676
+ else if (key === systemKey && (typeof value[key] === "string" || Array.isArray(value[key]))) systemBytes += childBytes;
5677
+ }
5678
+ image += child.image;
5679
+ replay += isOpaque(value, key, location) && typeof value[key] === "string" ? childBytes : child.replay;
5680
+ whitespace();
5681
+ }
5682
+ position++;
5683
+ if (imageBlock) {
5684
+ image = bytes(start);
5685
+ replay = 0;
5686
+ }
5687
+ } else if (typeof value === "string") stringEnd();
5688
+ else {
5689
+ while (position < body.length && !/[\s,\]}]/u.test(body[position])) position++;
5690
+ if (position === start) throw new EvidenceParseError("invalid-json");
5691
+ }
5692
+ return {
5693
+ image,
5694
+ replay
5695
+ };
5696
+ };
5697
+ try {
5698
+ visit(parsed, 0, "root");
5699
+ whitespace();
5700
+ if (position !== body.length) return {
5701
+ state: "invalid-json",
5702
+ totalBytes
5703
+ };
5704
+ } catch (cause) {
5705
+ if (!(cause instanceof EvidenceParseError)) throw cause;
5706
+ return {
5707
+ state: cause.state,
5708
+ totalBytes
5709
+ };
5710
+ }
5711
+ const otherBytes = totalBytes - conversationBytes - toolSchemaBytes - systemBytes;
5712
+ const remainingConversationBytes = conversationBytes - imageBlockBytes - opaqueReplayBytes;
5713
+ if (otherBytes < 0 || remainingConversationBytes < 0) return {
5714
+ state: "invalid-json",
5715
+ totalBytes
5716
+ };
5717
+ return {
5718
+ state: "complete",
5719
+ totalBytes,
5720
+ conversationBytes,
5721
+ toolSchemaBytes,
5722
+ systemBytes,
5723
+ otherBytes,
5724
+ imageBlockBytes,
5725
+ opaqueReplayBytes,
5726
+ remainingConversationBytes
5727
+ };
5728
+ }
5729
+ //#endregion
5542
5730
  //#region lib/types/request-body-timeout.js
5543
5731
  const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
5544
5732
  function record$5(value) {
5545
5733
  return typeof value === "object" && value !== null && !Array.isArray(value);
5546
5734
  }
5547
5735
  /** Verified provider evidence, not guessed capabilities, token limits or network cause. */
5548
- async function requestBodyTimeoutDiagnostic(response, body, signal) {
5736
+ async function requestBodyTimeoutDiagnostic(response, body, signal, dispatch) {
5549
5737
  if (response.status !== 408 || signal?.aborted) return void 0;
5550
5738
  const value = await readResponseErrorJson(response, signal);
5551
- if (!record$5(value)) return void 0;
5739
+ if (signal?.aborted || !record$5(value)) return void 0;
5552
5740
  const error = Object.hasOwn(value, "error") ? value.error : value;
5553
5741
  if (!record$5(error) || error.code !== "user_request_timeout" || error.message !== observedMessage || value.code !== void 0 && value.code !== error.code || value.message !== void 0 && value.message !== error.message) return void 0;
5554
- return `COPILOT_REQUEST_BODY_TIMEOUT: Copilot returned HTTP 408 / user_request_timeout while reading the request body; this is not context-window overflow. ${body === void 0 ? "Request body size unavailable." : `Request body: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`} Native retry policy is unchanged. If retries exhaust, explicitly compact the conversation or reduce attachments/tool output before retrying; also check network/proxy health and GitHub service status. A larger client timeout does not change this server timeout. No history was trimmed or model switched.`;
5742
+ return `COPILOT_REQUEST_BODY_TIMEOUT: Copilot returned HTTP 408 / user_request_timeout while reading the request body; this is not context-window overflow. ${body === void 0 ? "Request body size unavailable." : `Request body: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`} ${formatRequestBodyEvidence(dispatch === void 0 ? { state: "unavailable" } : requestBodyEvidence(body, dispatch.protocol), dispatch?.responseHeadersMs)} Native retry policy is unchanged. If retries exhaust, use these numbers to choose an explicit attachment/image-offload budget change or native compaction for compressible history; tool definitions and opaque replay may remain. Also check network/proxy health and GitHub service status. Composition alone does not establish a cause or supplier size limit. A larger client timeout does not change this server timeout. No history was trimmed or model switched.`;
5555
5743
  }
5556
5744
  //#endregion
5557
5745
  //#region lib/types/copilot-stream-liveness.js
@@ -5897,15 +6085,20 @@ function createAccountProvider(descriptors, guard, baseURL) {
5897
6085
  guard.onRequestBodyTimeout?.(void 0);
5898
6086
  liveness?.beginRequest(typeof init?.body === "string" ? init.body : void 0);
5899
6087
  let response;
6088
+ const startedAt = performance.now();
5900
6089
  try {
5901
6090
  response = await fetch(input, init);
5902
6091
  } catch (error) {
5903
6092
  retry?.observe(void 0, 0);
5904
6093
  throw error;
5905
6094
  }
6095
+ const responseHeadersMs = performance.now() - startedAt;
5906
6096
  retry?.observe(typeof init?.body === "string" ? init.body : void 0, response.status);
5907
6097
  if (response.status === 408 && guard.onRequestBodyTimeout !== void 0) {
5908
- const diagnostic = await requestBodyTimeoutDiagnostic(response, typeof init?.body === "string" ? init.body : void 0, lease.signal);
6098
+ const diagnostic = await requestBodyTimeoutDiagnostic(response, typeof init?.body === "string" ? init.body : void 0, lease.signal, {
6099
+ protocol: entry.api,
6100
+ responseHeadersMs
6101
+ });
5909
6102
  if (!lease.signal.aborted && !options.signal?.aborted) guard.onRequestBodyTimeout(diagnostic);
5910
6103
  }
5911
6104
  if (response.status === 401) {
@@ -0,0 +1,32 @@
1
+ export type RequestBodyProtocol = 'openai-responses' | 'openai-completions' | 'anthropic-messages';
2
+ export declare const REQUEST_BODY_EVIDENCE_LIMITS: Readonly<{
3
+ bytes: number;
4
+ values: 65536;
5
+ tokens: 131072;
6
+ depth: 64;
7
+ keyCharacters: 128;
8
+ }>;
9
+ export type RequestBodyEvidence = {
10
+ readonly state: 'complete';
11
+ readonly totalBytes: number;
12
+ readonly conversationBytes: number;
13
+ readonly toolSchemaBytes: number;
14
+ readonly systemBytes: number;
15
+ readonly otherBytes: number;
16
+ /** Disjoint subsets of conversationBytes, not additional payload bytes. */
17
+ readonly imageBlockBytes: number;
18
+ readonly opaqueReplayBytes: number;
19
+ readonly remainingConversationBytes: number;
20
+ } | {
21
+ readonly state: 'unavailable' | 'size-limit' | 'work-limit' | 'invalid-json' | 'unsupported-shape';
22
+ readonly totalBytes?: number;
23
+ };
24
+ export interface RequestBodyDispatchEvidence {
25
+ readonly protocol: RequestBodyProtocol;
26
+ /** Fetch invocation to response headers, not upload duration or clone-observation time. */
27
+ readonly responseHeadersMs: number;
28
+ }
29
+ export declare function formatRequestBodyEvidence(evidence: RequestBodyEvidence, responseHeadersMs?: number): string;
30
+ /** Diagnostic-only traversal of the original JSON spans; never reserializes or changes a request. */
31
+ export declare function requestBodyEvidence(body: string | undefined, protocol: RequestBodyProtocol): RequestBodyEvidence;
32
+ //# sourceMappingURL=request-body-evidence.d.ts.map
@@ -1,3 +1,4 @@
1
+ import type { RequestBodyDispatchEvidence } from './request-body-evidence.ts';
1
2
  /** Verified provider evidence, not guessed capabilities, token limits or network cause. */
2
- export declare function requestBodyTimeoutDiagnostic(response: Response, body?: string, signal?: AbortSignal): Promise<string | undefined>;
3
+ export declare function requestBodyTimeoutDiagnostic(response: Response, body?: string, signal?: AbortSignal, dispatch?: RequestBodyDispatchEvidence): Promise<string | undefined>;
3
4
  //# sourceMappingURL=request-body-timeout.d.ts.map
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.83",
4
+ "version": "0.4.0-alpha.84",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",