dsh-github-copilot 0.4.0-alpha.97 → 0.4.0-alpha.98
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 +2 -0
- package/CHANGELOG.md +6 -0
- package/README.md +8 -6
- package/README.zh.md +8 -6
- package/deployment-baseline.json +18 -1
- package/docs/automatic-model-routing.md +13 -2
- package/lib/index.js +179 -78
- package/lib/types/auto-model-intent.d.ts +36 -0
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -285,6 +285,8 @@ Capture the traced `remote.githubCopilot` namespace once per account UI registra
|
|
|
285
285
|
|
|
286
286
|
Auto history compatibility (alpha.54, #204): official rc.2 `Session.append()` has no public ignorable-envelope option. Do not emit optional `github-copilot/auto-model-decision` events or borrow another event type; retain native real-model provenance and durable Auto selection without new durable decision recording. The assistant-actions selection footer reads bounded Host-lifetime decisions through native agent-scoped lookup and compatible historical events. Explicit captured fixed selection alone proves Manual; missing evidence is unknown, never reconstructed from today's picker. Do not repeat model names, add Model details, change native Usage/context metering or modify parent DOM. `scripts/repair-auto-model-history.mjs` is explicit source-checkout maintenance, not a runtime hook: strict pinned official v4 validation, check-only by default, optional detached repaired copy plus byte-exact backup. It never replaces live history. Applying a copy requires separately approved stopped writers and a fresh source-hash check. See `docs/automatic-model-routing.md`.
|
|
287
287
|
|
|
288
|
+
Auto intent continuity (#293) uses the strict `githubCopilotAutoModelIntent` public Session projection of existing owner-explicit `model/selection` events. Execution headers cannot erase intent; fixed/other-provider choices replace it for future turns. Ignore copied fork/child prefixes, retain native pending and parent-follow precedence, and diagnose missing/invalid evidence. Freeze admitted Auto route configuration across late choices without writing history, settings or historical reasons. Projection disposal must remove only its own registration.
|
|
289
|
+
|
|
288
290
|
1. Identify the owning seam using `agent-contract.json`; do not duplicate an upstream owner.
|
|
289
291
|
2. Add or update focused tests before changing deployment claims.
|
|
290
292
|
3. Update both READMEs when user behavior, setup, migration, or boundaries change.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0-alpha.98 (prepared)
|
|
4
|
+
|
|
5
|
+
- Retain owner-explicit Auto intent through a strict public Session projection when a native virtual request header consumes pending selection (#293).
|
|
6
|
+
- Preserve intent across concrete execution headers and cold replay; later fixed/other-provider choices replace it for future turns. Admitted Auto requests keep their route through late picker changes.
|
|
7
|
+
- Ignore copied fork/child prefixes as owner-explicit evidence; keep native pending/parent-follow precedence and named missing/invalid diagnostics. No Core changes, new durable events, settings/history rewrite or fabricated historical reasons.
|
|
8
|
+
|
|
3
9
|
## 0.4.0-alpha.97 (prepared)
|
|
4
10
|
|
|
5
11
|
- Add request-scoped public native body-write/header timing and optional TLS ALPN/Node buffer observations to exact verified Copilot request-body timeout diagnostics (#291).
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
GitHub Copilot account discovery, contextual Auto routing and hosted search for DSH. The plugin reuses DSH's published native adapter and one Host-owned OAuth account; it does not patch Core or maintain a second model catalog.
|
|
10
10
|
|
|
11
|
-
**Source candidate: `0.4.0-alpha.
|
|
11
|
+
**Source candidate: `0.4.0-alpha.98` (unreleased). Supported host: official DSH / Windows Desktop `0.2.0-rc.2`.** Earlier DSH pins are historical evidence, not supported installation targets. Publication, profile installation and the version loaded by a running Host are separate states. The versioned commands below are for this candidate after publication, not evidence that its assets exist.
|
|
12
12
|
|
|
13
13
|
## What you can do
|
|
14
14
|
|
|
@@ -40,10 +40,10 @@ Supply any launcher patches with repeated `--patch /absolute/file`. Require `sup
|
|
|
40
40
|
For a **standalone named profile**:
|
|
41
41
|
|
|
42
42
|
```sh
|
|
43
|
-
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
43
|
+
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.98/dsh-github-copilot-0.4.0-alpha.98.tgz
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
For **Desktop**, its native package manager accepts `dsh-github-copilot@0.4.0-alpha.
|
|
46
|
+
For **Desktop**, its native package manager accepts `dsh-github-copilot@0.4.0-alpha.98` after publication. Official rc.2's **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.
|
|
47
47
|
|
|
48
48
|
After an approved reload/restart:
|
|
49
49
|
|
|
@@ -76,6 +76,8 @@ The reply's selection disclosure shows captured reasons and optional content-fre
|
|
|
76
76
|
|
|
77
77
|
See [task assessment](./docs/auto-task-routing.md) and [routing contracts, exclusions and history recovery](./docs/automatic-model-routing.md).
|
|
78
78
|
|
|
79
|
+
Explicit Auto intent survives native pending-selection consumption and cold restore through a plugin-owned projection of existing selection events. Later explicit fixed choices still win for future turns; admitted turns keep their route. This does not backfill historical selection reasons or turn unknown evidence into guessed Auto.
|
|
80
|
+
|
|
79
81
|
## Subagents and search
|
|
80
82
|
|
|
81
83
|

|
|
@@ -177,14 +179,14 @@ Commit attribution uses `Assisted-by` with the actual tool, never the model prov
|
|
|
177
179
|
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.
|
|
178
180
|
|
|
179
181
|
```sh
|
|
180
|
-
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
181
|
-
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
182
|
+
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.98/dsh-github-copilot-0.4.0-alpha.98.tgz
|
|
183
|
+
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.98/SHA256SUMS
|
|
182
184
|
sha256sum --check SHA256SUMS
|
|
183
185
|
```
|
|
184
186
|
|
|
185
187
|
```powershell
|
|
186
188
|
$expected = (Get-Content .\SHA256SUMS).Split()[0]
|
|
187
|
-
$actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.
|
|
189
|
+
$actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.98.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
188
190
|
if ($actual -cne $expected) { throw 'Release checksum mismatch' }
|
|
189
191
|
```
|
|
190
192
|
|
package/README.zh.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
为 DSH 提供 GitHub Copilot 账号模型发现、上下文 Auto 选模和 hosted search。插件复用 DSH 公开的原生适配器与一个 Host 端 OAuth 账号,不修改 Core,也不维护第二套模型目录。
|
|
10
10
|
|
|
11
|
-
**源码候选版本:`0.4.0-alpha.
|
|
11
|
+
**源码候选版本:`0.4.0-alpha.98`(尚未发布)。支持宿主:官方 DSH / Windows Desktop `0.2.0-rc.2`。** 较早 DSH pin 仅是历史证据,不是当前安装目标。已发布、已安装到 profile、已被运行中的 Host 加载,是三个不同状态。下方带版本的命令适用于候选版本发布后,不代表对应资产已经存在。
|
|
12
12
|
|
|
13
13
|
## 你可以做什么
|
|
14
14
|
|
|
@@ -40,10 +40,10 @@ node package/scripts/check-search-composition.mjs --profile-dir /absolute/profil
|
|
|
40
40
|
**独立具名 profile**:
|
|
41
41
|
|
|
42
42
|
```sh
|
|
43
|
-
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
43
|
+
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.98/dsh-github-copilot-0.4.0-alpha.98.tgz
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
**Desktop** 原生包管理器在发布后接受 `dsh-github-copilot@0.4.0-alpha.
|
|
46
|
+
**Desktop** 原生包管理器在发布后接受 `dsh-github-copilot@0.4.0-alpha.98`。官方 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 或删除配置。
|
|
47
47
|
|
|
48
48
|
经批准 reload/restart 后:
|
|
49
49
|
|
|
@@ -76,6 +76,8 @@ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/release
|
|
|
76
76
|
|
|
77
77
|
详见[任务判断](./docs/auto-task-routing.md)与[路由合同、排除和历史恢复](./docs/automatic-model-routing.md)。
|
|
78
78
|
|
|
79
|
+
显式 Auto 意图通过插件对现有选择事件的独立投影保留,不因原生 pending 被消费或冷恢复而丢失。后续显式固定选择仍从未来轮次生效,已准入轮次保持原路由。不会补写历史选择理由,也不会把未知证据猜成 Auto。
|
|
80
|
+
|
|
79
81
|
## 子代理与搜索
|
|
80
82
|
|
|
81
83
|

|
|
@@ -177,14 +179,14 @@ Agent 从 `node scripts/agent.mjs describe --json`、`doctor --json`及`plan <ta
|
|
|
177
179
|
GitHub Releases 和 npm 分发同一原始已校验 tarball。固定版本并核验 Release SHA-256 或 npm `dist.integrity`;不重打包不可变 Release、不移动/复用 tag。
|
|
178
180
|
|
|
179
181
|
```sh
|
|
180
|
-
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
181
|
-
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.
|
|
182
|
+
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.98/dsh-github-copilot-0.4.0-alpha.98.tgz
|
|
183
|
+
curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.98/SHA256SUMS
|
|
182
184
|
sha256sum --check SHA256SUMS
|
|
183
185
|
```
|
|
184
186
|
|
|
185
187
|
```powershell
|
|
186
188
|
$expected = (Get-Content .\SHA256SUMS).Split()[0]
|
|
187
|
-
$actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.
|
|
189
|
+
$actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.98.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
188
190
|
if ($actual -cne $expected) { throw 'Release checksum mismatch' }
|
|
189
191
|
```
|
|
190
192
|
|
package/deployment-baseline.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"package": {
|
|
10
10
|
"name": "dsh-github-copilot",
|
|
11
|
-
"version": "0.4.0-alpha.
|
|
11
|
+
"version": "0.4.0-alpha.98"
|
|
12
12
|
},
|
|
13
13
|
"evidence": {
|
|
14
14
|
"kind": "source-and-synthetic-test-inventory",
|
|
@@ -1122,6 +1122,23 @@
|
|
|
1122
1122
|
{"file": "tests/client-no-model-roles.spec.ts", "name": "does not resurrect a role entry when a retained legacy Remote arrives later"}
|
|
1123
1123
|
]
|
|
1124
1124
|
},
|
|
1125
|
+
{
|
|
1126
|
+
"id": "managed-copilot-auto-intent-continuity",
|
|
1127
|
+
"required": true,
|
|
1128
|
+
"sourceMarkers": [
|
|
1129
|
+
{"file": "src/auto-model-intent.ts", "marker": "githubCopilotAutoModelIntent"},
|
|
1130
|
+
{"file": "src/auto-model-intent.ts", "marker": "state.inherited"},
|
|
1131
|
+
{"file": "src/auto-model-host.ts", "marker": "COPILOT_AUTO_INTENT_UNAVAILABLE"},
|
|
1132
|
+
{"file": "src/auto-model-host.ts", "marker": "removeIntentProjection"},
|
|
1133
|
+
{"file": "docs/automatic-model-routing.md", "marker": "Cold refolding restores intent"}
|
|
1134
|
+
],
|
|
1135
|
+
"tests": [
|
|
1136
|
+
{"file": "tests/auto-model-intent.spec.ts", "name": "retains explicit intent across virtual and concrete execution headers and cold replay"},
|
|
1137
|
+
{"file": "tests/auto-model-intent.spec.ts", "name": "does not infer intent from execution or copied fork/child prefixes"},
|
|
1138
|
+
{"file": "tests/auto-model-host.spec.ts", "name": "diagnoses unavailable continuity evidence ($error) without blocking a new explicit fixed choice"},
|
|
1139
|
+
{"file": "tests/fixtures/session-context-core.fixture.ts", "name": "retains explicit Auto after native virtual-header consumption without relabeling prior turns"}
|
|
1140
|
+
]
|
|
1141
|
+
},
|
|
1125
1142
|
{
|
|
1126
1143
|
"id": "managed-copilot-auto-model-routing",
|
|
1127
1144
|
"required": true,
|
|
@@ -17,8 +17,19 @@ turn can choose differently. Transport, replay, native Usage and billing retain
|
|
|
17
17
|
the actual model identity. Auto never crosses providers/accounts or changes an
|
|
18
18
|
explicit real-model selection.
|
|
19
19
|
|
|
20
|
-
The virtual preference remains the Session's pending selection while actual
|
|
21
|
-
request headers record real models.
|
|
20
|
+
The virtual preference normally remains the Session's pending selection while actual
|
|
21
|
+
request headers record real models. A strict plugin-owned public Session projection
|
|
22
|
+
also retains the latest owner-explicit native `model/selection`: if a virtual
|
|
23
|
+
request header consumes native pending, later concrete headers cannot erase that
|
|
24
|
+
Auto intent. Cold refolding restores intent, not old decisions or reasons.
|
|
25
|
+
Copied fork/child prefixes alone do not establish an owner-explicit choice;
|
|
26
|
+
native pending and the existing parent-following rules remain independent.
|
|
27
|
+
Missing or malformed continuity evidence produces a named diagnostic instead of
|
|
28
|
+
guessing Auto from a real model. A new explicit fixed or other-provider selection
|
|
29
|
+
replaces intent for future turns, even after its native pending is consumed.
|
|
30
|
+
Already admitted Auto turns retain their real route through late picker changes.
|
|
31
|
+
This projection neither writes history/settings nor changes native projection ownership.
|
|
32
|
+
For an otherwise unselected Session that
|
|
22
33
|
inherits default Auto, the first request persists the exact virtual
|
|
23
34
|
`model/selection` intent. A later explicit selection wins. Existing fixed
|
|
24
35
|
Sessions are not converted because the global default changes.
|
package/lib/index.js
CHANGED
|
@@ -1656,14 +1656,14 @@ function isZeroContextUsage(usage) {
|
|
|
1656
1656
|
//#endregion
|
|
1657
1657
|
//#region lib/types/context-evidence.js
|
|
1658
1658
|
const COPILOT_CONTEXT_EVIDENCE = "githubCopilotContextEvidence";
|
|
1659
|
-
const count$
|
|
1659
|
+
const count$2 = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
1660
1660
|
const routeSchema = z$1.object({
|
|
1661
1661
|
provider: z$1.string().min(1),
|
|
1662
1662
|
model: z$1.string().min(1)
|
|
1663
1663
|
}).strict();
|
|
1664
1664
|
const sampleSchema = z$1.object({
|
|
1665
|
-
tokens: count$
|
|
1666
|
-
seq: count$
|
|
1665
|
+
tokens: count$2,
|
|
1666
|
+
seq: count$2,
|
|
1667
1667
|
route: routeSchema
|
|
1668
1668
|
}).strict();
|
|
1669
1669
|
const ContextEvidenceSchema = z$1.object({
|
|
@@ -1679,14 +1679,14 @@ const ContextEvidenceSchema = z$1.object({
|
|
|
1679
1679
|
])
|
|
1680
1680
|
}).strict();
|
|
1681
1681
|
const usageSchema = z$1.object({
|
|
1682
|
-
inputTokens: count$
|
|
1683
|
-
outputTokens: count$
|
|
1684
|
-
cacheReadTokens: count$
|
|
1685
|
-
cacheWriteTokens: count$
|
|
1686
|
-
totalTokens: count$
|
|
1687
|
-
reasoningTokens: count$
|
|
1682
|
+
inputTokens: count$2,
|
|
1683
|
+
outputTokens: count$2,
|
|
1684
|
+
cacheReadTokens: count$2.optional(),
|
|
1685
|
+
cacheWriteTokens: count$2.optional(),
|
|
1686
|
+
totalTokens: count$2.optional(),
|
|
1687
|
+
reasoningTokens: count$2.optional()
|
|
1688
1688
|
});
|
|
1689
|
-
function record$
|
|
1689
|
+
function record$10(value) {
|
|
1690
1690
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1691
1691
|
}
|
|
1692
1692
|
function sameRoute$1(left, right) {
|
|
@@ -1705,10 +1705,10 @@ function initialContextEvidence() {
|
|
|
1705
1705
|
}
|
|
1706
1706
|
/** Read only counts and routing leaves; never message content or opaque replay. */
|
|
1707
1707
|
function foldContextEvidence(state, event) {
|
|
1708
|
-
if (!record$
|
|
1708
|
+
if (!record$10(event) || typeof event.type !== "string" || !record$10(event.data)) return state;
|
|
1709
1709
|
if (event.type === "request/header" || event.type === "model/selection") {
|
|
1710
|
-
const raw = event.type === "request/header" ? record$
|
|
1711
|
-
if (!record$
|
|
1710
|
+
const raw = event.type === "request/header" ? record$10(event.data.header) ? event.data.header.config : void 0 : event.data;
|
|
1711
|
+
if (!record$10(raw)) return {
|
|
1712
1712
|
...state,
|
|
1713
1713
|
route: null,
|
|
1714
1714
|
sample: null,
|
|
@@ -1747,7 +1747,7 @@ function foldContextEvidence(state, event) {
|
|
|
1747
1747
|
if (!copilot(state.route)) return state;
|
|
1748
1748
|
if (event.type === "assistant/message" && event.data.source !== void 0) {
|
|
1749
1749
|
const source = event.data.source;
|
|
1750
|
-
const parsed = routeSchema.safeParse(record$
|
|
1750
|
+
const parsed = routeSchema.safeParse(record$10(source) ? {
|
|
1751
1751
|
provider: source.provider,
|
|
1752
1752
|
model: source.model
|
|
1753
1753
|
} : source);
|
|
@@ -1763,13 +1763,13 @@ function foldContextEvidence(state, event) {
|
|
|
1763
1763
|
const settledUsage = usage !== void 0;
|
|
1764
1764
|
let terminal;
|
|
1765
1765
|
for (const entry of stream) {
|
|
1766
|
-
if (!record$
|
|
1766
|
+
if (!record$10(entry) || entry.type !== "chunk" || !record$10(entry.chunk)) continue;
|
|
1767
1767
|
if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
|
|
1768
1768
|
if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
|
|
1769
1769
|
}
|
|
1770
1770
|
if (usage === void 0) return state;
|
|
1771
1771
|
const parsed = usageSchema.safeParse(usage);
|
|
1772
|
-
if (!parsed.success || !count$
|
|
1772
|
+
if (!parsed.success || !count$2.safeParse(event.seq).success) return {
|
|
1773
1773
|
...state,
|
|
1774
1774
|
sample: null,
|
|
1775
1775
|
invalid: true,
|
|
@@ -1777,7 +1777,7 @@ function foldContextEvidence(state, event) {
|
|
|
1777
1777
|
};
|
|
1778
1778
|
const value = parsed.data;
|
|
1779
1779
|
const zero = isZeroContextUsage(value);
|
|
1780
|
-
const successful = record$
|
|
1780
|
+
const successful = record$10(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
|
|
1781
1781
|
if (zero && !successful) {
|
|
1782
1782
|
const reason = state.sample !== null || state.reason === "none" ? "failed-zero" : state.reason;
|
|
1783
1783
|
return {
|
|
@@ -1797,7 +1797,7 @@ function foldContextEvidence(state, event) {
|
|
|
1797
1797
|
...state,
|
|
1798
1798
|
sample: {
|
|
1799
1799
|
tokens,
|
|
1800
|
-
seq: count$
|
|
1800
|
+
seq: count$2.parse(event.seq),
|
|
1801
1801
|
route: state.route
|
|
1802
1802
|
},
|
|
1803
1803
|
invalid: false,
|
|
@@ -1819,7 +1819,7 @@ const contextEvidenceDefinition = {
|
|
|
1819
1819
|
function installContextEvidence(ctx) {
|
|
1820
1820
|
ctx.inject(["sessionProjections"], (scope) => {
|
|
1821
1821
|
const registry = scope.get("sessionProjections");
|
|
1822
|
-
if (!record$
|
|
1822
|
+
if (!record$10(registry) || typeof registry.register !== "function") {
|
|
1823
1823
|
scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
|
|
1824
1824
|
return;
|
|
1825
1825
|
}
|
|
@@ -1833,7 +1833,7 @@ function installContextEvidence(ctx) {
|
|
|
1833
1833
|
//#endregion
|
|
1834
1834
|
//#region package.json
|
|
1835
1835
|
var name$1 = "dsh-github-copilot";
|
|
1836
|
-
var version = "0.4.0-alpha.
|
|
1836
|
+
var version = "0.4.0-alpha.98";
|
|
1837
1837
|
//#endregion
|
|
1838
1838
|
//#region lib/types/probe.js
|
|
1839
1839
|
/**
|
|
@@ -2845,7 +2845,7 @@ function buildAnthropicWireBody(request, cfg, model) {
|
|
|
2845
2845
|
}
|
|
2846
2846
|
//#endregion
|
|
2847
2847
|
//#region lib/types/responses-reasoning-text.js
|
|
2848
|
-
function record$
|
|
2848
|
+
function record$9(value) {
|
|
2849
2849
|
return typeof value === "object" && value !== null;
|
|
2850
2850
|
}
|
|
2851
2851
|
function responseIndex(value) {
|
|
@@ -2903,13 +2903,13 @@ var ResponsesReasoningText = class {
|
|
|
2903
2903
|
}
|
|
2904
2904
|
/** Only recognized public text fields are examined; no copying of the item. */
|
|
2905
2905
|
snapshot(item) {
|
|
2906
|
-
if (!record$
|
|
2906
|
+
if (!record$9(item) || item.type !== "reasoning") return "";
|
|
2907
2907
|
let delta = "";
|
|
2908
2908
|
for (const family of ["summary", "raw"]) {
|
|
2909
2909
|
const value = family === "summary" ? item.summary : item.content;
|
|
2910
2910
|
if (!Array.isArray(value)) continue;
|
|
2911
2911
|
for (const [index, part] of value.entries()) {
|
|
2912
|
-
if (!record$
|
|
2912
|
+
if (!record$9(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
|
|
2913
2913
|
delta += this.update(family, index, part.text, true);
|
|
2914
2914
|
}
|
|
2915
2915
|
}
|
|
@@ -5456,13 +5456,13 @@ function requestBodyEvidence(body, protocol) {
|
|
|
5456
5456
|
}
|
|
5457
5457
|
//#endregion
|
|
5458
5458
|
//#region lib/types/replay-recovery.js
|
|
5459
|
-
function record$
|
|
5459
|
+
function record$8(value) {
|
|
5460
5460
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5461
5461
|
}
|
|
5462
5462
|
function parsed(body) {
|
|
5463
5463
|
if (requestBodyEvidence(body, "openai-responses").state !== "complete" || body === void 0) throw new Error("COPILOT_REPLAY_RECOVERY_EVIDENCE_UNAVAILABLE");
|
|
5464
5464
|
const payload = JSON.parse(body);
|
|
5465
|
-
if (!record$
|
|
5465
|
+
if (!record$8(payload) || !Array.isArray(payload.input) || !payload.input.every(record$8)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
|
|
5466
5466
|
return {
|
|
5467
5467
|
input: payload.input,
|
|
5468
5468
|
payload
|
|
@@ -5558,7 +5558,7 @@ var ReplayRecoveryStore = class {
|
|
|
5558
5558
|
const value = hash(item);
|
|
5559
5559
|
return value === void 0 || !admitted.has(value);
|
|
5560
5560
|
}).length === decoded.input.length) return payload;
|
|
5561
|
-
if (!record$
|
|
5561
|
+
if (!record$8(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
|
|
5562
5562
|
const input = payload.input.filter((_, index) => {
|
|
5563
5563
|
const item = decoded.input[index];
|
|
5564
5564
|
const value = hash(item);
|
|
@@ -6056,7 +6056,7 @@ const REQUEST_BODY_TIMEOUT_MARKER = "COPILOT_REQUEST_BODY_TIMEOUT: Copilot retur
|
|
|
6056
6056
|
function object$2(value) {
|
|
6057
6057
|
return typeof value === "object" && value !== null;
|
|
6058
6058
|
}
|
|
6059
|
-
function count(value) {
|
|
6059
|
+
function count$1(value) {
|
|
6060
6060
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
|
|
6061
6061
|
}
|
|
6062
6062
|
/** Observe public native events only; never read request fields, mutate transport or imply remote receipt. */
|
|
@@ -6068,7 +6068,7 @@ function createRequestUploadObserver() {
|
|
|
6068
6068
|
let socket;
|
|
6069
6069
|
let connectionAmbiguous = false, socketBoundToRequest = false;
|
|
6070
6070
|
let alpn = "unavailable", nodeWritableBufferBytes;
|
|
6071
|
-
const elapsed = () => startedAt === void 0 ? void 0 : count(Math.round(performance.now() - startedAt));
|
|
6071
|
+
const elapsed = () => startedAt === void 0 ? void 0 : count$1(Math.round(performance.now() - startedAt));
|
|
6072
6072
|
const request = (data) => !closed && object$2(data) && object$2(data.request) ? requests.get(data.request) : void 0;
|
|
6073
6073
|
const connected = (data, boundToRequest = false) => {
|
|
6074
6074
|
if (closed || !object$2(data) || !object$2(data.socket)) return;
|
|
@@ -6103,7 +6103,7 @@ function createRequestUploadObserver() {
|
|
|
6103
6103
|
if (request(data) !== 1 || bodyWrite) return;
|
|
6104
6104
|
bodyWrite = true;
|
|
6105
6105
|
bodyWriteCompleteMs = elapsed();
|
|
6106
|
-
nodeWritableBufferBytes = count(socket?.writableLength);
|
|
6106
|
+
nodeWritableBufferBytes = count$1(socket?.writableLength);
|
|
6107
6107
|
},
|
|
6108
6108
|
"undici:request:headers": (data) => {
|
|
6109
6109
|
if (request(data) === 1 && nativeResponseHeadersMs === void 0) nativeResponseHeadersMs = elapsed();
|
|
@@ -6153,16 +6153,16 @@ function formatRequestUploadEvidence(evidence) {
|
|
|
6153
6153
|
//#endregion
|
|
6154
6154
|
//#region lib/types/request-body-timeout.js
|
|
6155
6155
|
const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
|
|
6156
|
-
function record$
|
|
6156
|
+
function record$7(value) {
|
|
6157
6157
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6158
6158
|
}
|
|
6159
6159
|
/** Verified provider evidence, not guessed capabilities, token limits or network cause. */
|
|
6160
6160
|
async function requestBodyTimeoutDiagnostic(response, body, signal, dispatch) {
|
|
6161
6161
|
if (response.status !== 408 || signal?.aborted) return void 0;
|
|
6162
6162
|
const value = await readResponseErrorJson(response, signal);
|
|
6163
|
-
if (signal?.aborted || !record$
|
|
6163
|
+
if (signal?.aborted || !record$7(value)) return void 0;
|
|
6164
6164
|
const error = Object.hasOwn(value, "error") ? value.error : value;
|
|
6165
|
-
if (!record$
|
|
6165
|
+
if (!record$7(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;
|
|
6166
6166
|
const size = body === void 0 ? "Request body size unavailable." : `Request body: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`;
|
|
6167
6167
|
const composition = formatRequestBodyEvidence(dispatch === void 0 ? { state: "unavailable" } : requestBodyEvidence(body, dispatch.protocol), dispatch?.responseHeadersMs);
|
|
6168
6168
|
const upload = formatRequestUploadEvidence(dispatch?.upload);
|
|
@@ -6650,7 +6650,7 @@ var Budget = class {
|
|
|
6650
6650
|
if (this.consumed > ACCOUNT_MODEL_CATALOG_LIMITS.maxBytes) fail("CATALOG_TOO_LARGE", true);
|
|
6651
6651
|
}
|
|
6652
6652
|
};
|
|
6653
|
-
function record$
|
|
6653
|
+
function record$6(value, code) {
|
|
6654
6654
|
if (typeof value !== "object" || value === null || Array.isArray(value)) fail(code);
|
|
6655
6655
|
return value;
|
|
6656
6656
|
}
|
|
@@ -6703,11 +6703,11 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
6703
6703
|
if (options.availableModelIds?.has(id) !== true) fail("MISSING_POLICY");
|
|
6704
6704
|
policySource = "account-available-id";
|
|
6705
6705
|
} else {
|
|
6706
|
-
if (text$1(field(record$
|
|
6706
|
+
if (text$1(field(record$6(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail("POLICY_NOT_ENABLED");
|
|
6707
6707
|
policySource = "server-enabled";
|
|
6708
6708
|
}
|
|
6709
|
-
const capabilities = record$
|
|
6710
|
-
const supports = record$
|
|
6709
|
+
const capabilities = record$6(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
|
|
6710
|
+
const supports = record$6(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
|
|
6711
6711
|
const streaming = field(supports, "streaming", budget);
|
|
6712
6712
|
if (streaming === false) fail("STREAMING_UNSUPPORTED");
|
|
6713
6713
|
if (streaming !== true) fail("INVALID_SUPPORTS");
|
|
@@ -6728,7 +6728,7 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
6728
6728
|
if (selected === void 0) fail(unsupportedEndpointCount === 0 && endpoints.includes("ws:/responses") ? "WEBSOCKET_ONLY" : "UNSUPPORTED_ENDPOINTS");
|
|
6729
6729
|
const rawLimits = field(capabilities, "limits", budget);
|
|
6730
6730
|
if (rawLimits === void 0) fail("MISSING_LIMITS");
|
|
6731
|
-
const limits = record$
|
|
6731
|
+
const limits = record$6(rawLimits, "INVALID_LIMITS");
|
|
6732
6732
|
const maxContext = optionalPositive(limits, "max_context_window_tokens", "INVALID_LIMITS", budget);
|
|
6733
6733
|
const maxInputTokens = optionalPositive(limits, "max_prompt_tokens", "INVALID_LIMITS", budget);
|
|
6734
6734
|
if (maxContext === void 0 && maxInputTokens === void 0) fail("MISSING_CONTEXT_LIMIT");
|
|
@@ -6746,7 +6746,7 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
6746
6746
|
if (vision === true) {
|
|
6747
6747
|
const rawVisionLimits = field(limits, "vision", budget);
|
|
6748
6748
|
if (rawVisionLimits !== void 0) {
|
|
6749
|
-
const rawMediaTypes = field(record$
|
|
6749
|
+
const rawMediaTypes = field(record$6(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
|
|
6750
6750
|
if (rawMediaTypes !== void 0) {
|
|
6751
6751
|
const mediaTypes = stringList(rawMediaTypes, ACCOUNT_MODEL_CATALOG_LIMITS.maxMediaTypes, 128, "INVALID_VISION_LIMITS", budget);
|
|
6752
6752
|
const mime = /^[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*\/[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*$/iu;
|
|
@@ -6808,7 +6808,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
|
|
|
6808
6808
|
fail("INVALID_JSON", true);
|
|
6809
6809
|
}
|
|
6810
6810
|
}
|
|
6811
|
-
const data = field(record$
|
|
6811
|
+
const data = field(record$6(raw, "INVALID_CATALOG"), "data", budget);
|
|
6812
6812
|
if (!Array.isArray(data)) fail("INVALID_CATALOG");
|
|
6813
6813
|
const count = field(data, "length", budget);
|
|
6814
6814
|
if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) fail("INVALID_CATALOG");
|
|
@@ -6831,7 +6831,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
|
|
|
6831
6831
|
for (let index = 0; index < count; index++) {
|
|
6832
6832
|
let id;
|
|
6833
6833
|
try {
|
|
6834
|
-
const candidate = record$
|
|
6834
|
+
const candidate = record$6(field(data, String(index), budget), "INVALID_MODEL");
|
|
6835
6835
|
const candidateId = text$1(field(candidate, "id", budget), ACCOUNT_MODEL_CATALOG_LIMITS.maxIdLength, "INVALID_ID", budget);
|
|
6836
6836
|
if (!identifier.test(candidateId)) fail("INVALID_ID");
|
|
6837
6837
|
id = candidateId;
|
|
@@ -7263,7 +7263,7 @@ function createAccountModelSource(dependencies) {
|
|
|
7263
7263
|
}
|
|
7264
7264
|
//#endregion
|
|
7265
7265
|
//#region lib/types/agent-compaction.js
|
|
7266
|
-
function record$
|
|
7266
|
+
function record$5(value) {
|
|
7267
7267
|
return typeof value === "object" && value !== null;
|
|
7268
7268
|
}
|
|
7269
7269
|
/** Resolve the owning preset's service without reaching into Core's service registry. */
|
|
@@ -7271,7 +7271,7 @@ function agentCompaction(agent) {
|
|
|
7271
7271
|
if (typeof agent.ctx?.get !== "function") throw new LlmError("COPILOT_COMPACTION_AGENT_CONTEXT_UNAVAILABLE", "INVALID_REQUEST");
|
|
7272
7272
|
const presets = agent.ctx.get("agentPresets");
|
|
7273
7273
|
if (presets !== void 0) {
|
|
7274
|
-
if (!record$
|
|
7274
|
+
if (!record$5(presets) || typeof presets.composedPreset !== "function" || typeof presets.serviceFor !== "function") throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
|
|
7275
7275
|
const preset = presets.composedPreset(agent.ctx);
|
|
7276
7276
|
if (preset !== void 0) {
|
|
7277
7277
|
if (typeof preset !== "string" || preset.trim().length === 0) throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
|
|
@@ -7394,14 +7394,14 @@ function installCopilotCompactionPressure(ctx, callbacks) {
|
|
|
7394
7394
|
}
|
|
7395
7395
|
//#endregion
|
|
7396
7396
|
//#region lib/types/pre-step-pressure.js
|
|
7397
|
-
function record$
|
|
7397
|
+
function record$4(value) {
|
|
7398
7398
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7399
7399
|
}
|
|
7400
7400
|
function positive(value) {
|
|
7401
7401
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
7402
7402
|
}
|
|
7403
7403
|
function isEngine(value) {
|
|
7404
|
-
return record$
|
|
7404
|
+
return record$4(value) && record$4(value.config) && typeof value.compactIfNeeded === "function";
|
|
7405
7405
|
}
|
|
7406
7406
|
/**
|
|
7407
7407
|
* Prevent a continuing, unchanged route's known pressure from becoming an
|
|
@@ -7422,12 +7422,12 @@ function installCopilotPreStepPressure(ctx, callbacks) {
|
|
|
7422
7422
|
const header = agent.session.requestHeader();
|
|
7423
7423
|
if (header?.config.provider !== "github-copilot-preview" || !isPluginPreviewProvider(ctx, header.config.provider)) return decision;
|
|
7424
7424
|
const projections = ctx.get("sessionProjections");
|
|
7425
|
-
if (!record$
|
|
7425
|
+
if (!record$4(projections) || typeof projections.stateOf !== "function") {
|
|
7426
7426
|
unavailable();
|
|
7427
7427
|
return decision;
|
|
7428
7428
|
}
|
|
7429
7429
|
const selection = projections.stateOf(agent.session, "modelSelection");
|
|
7430
|
-
if (!record$
|
|
7430
|
+
if (!record$4(selection) || !Object.hasOwn(selection, "pending")) {
|
|
7431
7431
|
unavailable();
|
|
7432
7432
|
return decision;
|
|
7433
7433
|
}
|
|
@@ -7449,20 +7449,20 @@ function installCopilotPreStepPressure(ctx, callbacks) {
|
|
|
7449
7449
|
unavailable();
|
|
7450
7450
|
return decision;
|
|
7451
7451
|
}
|
|
7452
|
-
const policy = Array.isArray(config.modelPolicies) ? config.modelPolicies.find((value) => record$
|
|
7453
|
-
const retries = record$
|
|
7452
|
+
const policy = Array.isArray(config.modelPolicies) ? config.modelPolicies.find((value) => record$4(value) && value.provider === header.config.provider && value.model === header.config.model) : void 0;
|
|
7453
|
+
const retries = record$4(policy) ? policy.maxOverflowRetries ?? config.maxOverflowRetries : config.maxOverflowRetries;
|
|
7454
7454
|
if (retries === 0) return decision;
|
|
7455
7455
|
if (!positive(retries)) {
|
|
7456
7456
|
unavailable();
|
|
7457
7457
|
return decision;
|
|
7458
7458
|
}
|
|
7459
7459
|
const meter = ctx.get("tokenMeter");
|
|
7460
|
-
if (!record$
|
|
7460
|
+
if (!record$4(meter) || typeof meter.measure !== "function") {
|
|
7461
7461
|
unavailable();
|
|
7462
7462
|
return decision;
|
|
7463
7463
|
}
|
|
7464
7464
|
const measured = meter.measure(agent.session);
|
|
7465
|
-
if (!record$
|
|
7465
|
+
if (!record$4(measured) || typeof measured.totalTokens !== "number" || !Number.isSafeInteger(measured.totalTokens) || measured.totalTokens < 0) {
|
|
7466
7466
|
unavailable();
|
|
7467
7467
|
return decision;
|
|
7468
7468
|
}
|
|
@@ -7580,17 +7580,17 @@ const TaskAssessmentSchema = z$1.object({
|
|
|
7580
7580
|
"insufficient-evidence"
|
|
7581
7581
|
])).max(7)
|
|
7582
7582
|
}).strict();
|
|
7583
|
-
function record$
|
|
7583
|
+
function record$3(value) {
|
|
7584
7584
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7585
7585
|
}
|
|
7586
7586
|
function text(message) {
|
|
7587
|
-
if (!record$
|
|
7588
|
-
return message.content.flatMap((block) => record$
|
|
7587
|
+
if (!record$3(message) || !Array.isArray(message.content)) return "";
|
|
7588
|
+
return message.content.flatMap((block) => record$3(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
7589
7589
|
}
|
|
7590
7590
|
function user(message) {
|
|
7591
|
-
if (!record$
|
|
7592
|
-
if (record$
|
|
7593
|
-
return message.role === "user" || record$
|
|
7591
|
+
if (!record$3(message)) return false;
|
|
7592
|
+
if (record$3(message.source) && message.source.kind === "model-selection") return false;
|
|
7593
|
+
return message.role === "user" || record$3(message.source) && message.source.kind === "user";
|
|
7594
7594
|
}
|
|
7595
7595
|
function difficult(current) {
|
|
7596
7596
|
return /\b(prove|proof|theorem|debug|investigate|diagnose)\b|证明|定理|调试|排查|根因|调查/iu.test(current);
|
|
@@ -7607,8 +7607,8 @@ function assessTaskLocally(messages) {
|
|
|
7607
7607
|
const last = messages.findLast(user);
|
|
7608
7608
|
const current = text(last).trim();
|
|
7609
7609
|
const history = messages.slice(0, last === void 0 ? 0 : messages.lastIndexOf(last));
|
|
7610
|
-
const hasWork = history.some((message) => record$
|
|
7611
|
-
const nonText = record$
|
|
7610
|
+
const hasWork = history.some((message) => record$3(message) && (message.role === "assistant" || message.role === "tool" || user(message) || record$3(message.source) && message.source.kind === "model"));
|
|
7611
|
+
const nonText = record$3(last) && Array.isArray(last.content) && last.content.some((block) => !record$3(block) || block.type !== "text");
|
|
7612
7612
|
if (!hasWork && !nonText && /^(hello|hi|hey|你好|您好|嗨)[!!。.\s]*$/iu.test(current)) return {
|
|
7613
7613
|
demand: "simple",
|
|
7614
7614
|
source: "local",
|
|
@@ -7650,7 +7650,7 @@ function assessTaskLocally(messages) {
|
|
|
7650
7650
|
/** Separate text-only projection for assessment; never mutates the chat request. */
|
|
7651
7651
|
function assessmentInput(messages) {
|
|
7652
7652
|
let omitted = false;
|
|
7653
|
-
const context = messages.filter((message) => !record$
|
|
7653
|
+
const context = messages.filter((message) => !record$3(message) || message.role !== "system" && message.role !== "developer" && !(record$3(message.source) && message.source.kind === "model-selection"));
|
|
7654
7654
|
const lastUser = context.findLastIndex(user);
|
|
7655
7655
|
const priorUser = context.slice(0, lastUser < 0 ? 0 : lastUser).findLastIndex(user);
|
|
7656
7656
|
const priority = [.../* @__PURE__ */ new Set([
|
|
@@ -7662,13 +7662,13 @@ function assessmentInput(messages) {
|
|
|
7662
7662
|
let length = 0;
|
|
7663
7663
|
for (const index of priority) {
|
|
7664
7664
|
const message = context[index];
|
|
7665
|
-
if (!record$
|
|
7665
|
+
if (!record$3(message)) {
|
|
7666
7666
|
omitted = true;
|
|
7667
7667
|
continue;
|
|
7668
7668
|
}
|
|
7669
7669
|
if (!Array.isArray(message.content)) omitted = true;
|
|
7670
7670
|
const content = text(message);
|
|
7671
|
-
if (Array.isArray(message.content) && message.content.some((block) => !record$
|
|
7671
|
+
if (Array.isArray(message.content) && message.content.some((block) => !record$3(block) || block.type !== "text")) omitted = true;
|
|
7672
7672
|
if (content.length > 1600) omitted = true;
|
|
7673
7673
|
const role = typeof message.role === "string" && [
|
|
7674
7674
|
"user",
|
|
@@ -7800,14 +7800,14 @@ var AutoModelRoutingError = class extends Error {
|
|
|
7800
7800
|
this.name = "AutoModelRoutingError";
|
|
7801
7801
|
}
|
|
7802
7802
|
};
|
|
7803
|
-
function record$
|
|
7803
|
+
function record$2(value) {
|
|
7804
7804
|
return typeof value === "object" && value !== null;
|
|
7805
7805
|
}
|
|
7806
7806
|
function userMessage(value) {
|
|
7807
|
-
if (!record$
|
|
7808
|
-
if (record$
|
|
7807
|
+
if (!record$2(value)) return false;
|
|
7808
|
+
if (record$2(value.source) && value.source.kind === "model-selection") return false;
|
|
7809
7809
|
if (value.role === "user") return true;
|
|
7810
|
-
return record$
|
|
7810
|
+
return record$2(value.source) && value.source.kind === "user";
|
|
7811
7811
|
}
|
|
7812
7812
|
function latestUserContent(messages) {
|
|
7813
7813
|
for (let index = messages.length - 1; index >= 0; index--) {
|
|
@@ -7818,9 +7818,9 @@ function latestUserContent(messages) {
|
|
|
7818
7818
|
}
|
|
7819
7819
|
function classifyAutoModelTurn(messages) {
|
|
7820
7820
|
let text = "";
|
|
7821
|
-
const requiresImage = messages.some((message) => record$
|
|
7821
|
+
const requiresImage = messages.some((message) => record$2(message) && Array.isArray(message.content) && message.content.some((block) => record$2(block) && block.type === "image" && block.offloaded !== true));
|
|
7822
7822
|
for (const block of latestUserContent(messages)) {
|
|
7823
|
-
if (!record$
|
|
7823
|
+
if (!record$2(block)) continue;
|
|
7824
7824
|
if (block.type === "text" && typeof block.text === "string") text += `${block.text}\n`;
|
|
7825
7825
|
}
|
|
7826
7826
|
const codeFenceCount = text.match(/```/gu)?.length ?? 0;
|
|
@@ -7870,7 +7870,7 @@ function resolveSeed(messages, context) {
|
|
|
7870
7870
|
if (typeof context?.seed === "string" && context.seed.length > 0) return fnv1a(context.seed);
|
|
7871
7871
|
if (context?.sessionId !== void 0) return fnv1a(`${context.sessionId}:${context.turn ?? 1}`);
|
|
7872
7872
|
let text = "";
|
|
7873
|
-
for (const block of latestUserContent(messages)) if (record$
|
|
7873
|
+
for (const block of latestUserContent(messages)) if (record$2(block) && typeof block.text === "string") text += block.text;
|
|
7874
7874
|
return fnv1a(text || "default-auto-seed");
|
|
7875
7875
|
}
|
|
7876
7876
|
function targetCategory(assessment, preference) {
|
|
@@ -8274,6 +8274,60 @@ function resolveParentModel(child, bindings, lookup, followAll = false) {
|
|
|
8274
8274
|
}
|
|
8275
8275
|
}
|
|
8276
8276
|
//#endregion
|
|
8277
|
+
//#region lib/types/auto-model-intent.js
|
|
8278
|
+
const AUTO_MODEL_INTENT_PROJECTION = "githubCopilotAutoModelIntent";
|
|
8279
|
+
const count = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
8280
|
+
const selectionSchema = z$1.object({
|
|
8281
|
+
provider: z$1.string().min(1),
|
|
8282
|
+
model: z$1.string().min(1)
|
|
8283
|
+
}).strict();
|
|
8284
|
+
const AutoModelIntentSchema = z$1.object({
|
|
8285
|
+
inherited: count,
|
|
8286
|
+
selection: selectionSchema.nullable(),
|
|
8287
|
+
blocked: z$1.boolean()
|
|
8288
|
+
}).strict();
|
|
8289
|
+
function record$1(value) {
|
|
8290
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8291
|
+
}
|
|
8292
|
+
function initialAutoModelIntent(inherited = 0) {
|
|
8293
|
+
return {
|
|
8294
|
+
inherited,
|
|
8295
|
+
selection: null,
|
|
8296
|
+
blocked: false
|
|
8297
|
+
};
|
|
8298
|
+
}
|
|
8299
|
+
/** Request headers describe execution, not replacement of an explicit picker intent. */
|
|
8300
|
+
function foldAutoModelIntent(state, event) {
|
|
8301
|
+
if (!record$1(event) || event.type !== "model/selection") return state;
|
|
8302
|
+
if (!Number.isSafeInteger(event.seq) || Number(event.seq) < 0) return {
|
|
8303
|
+
...state,
|
|
8304
|
+
selection: null,
|
|
8305
|
+
blocked: true
|
|
8306
|
+
};
|
|
8307
|
+
if (Number(event.seq) < state.inherited) return state;
|
|
8308
|
+
const data = event.data;
|
|
8309
|
+
const parsed = selectionSchema.safeParse(record$1(data) ? {
|
|
8310
|
+
provider: data.provider,
|
|
8311
|
+
model: data.model
|
|
8312
|
+
} : data);
|
|
8313
|
+
return parsed.success ? {
|
|
8314
|
+
...state,
|
|
8315
|
+
selection: parsed.data,
|
|
8316
|
+
blocked: false
|
|
8317
|
+
} : {
|
|
8318
|
+
...state,
|
|
8319
|
+
selection: null,
|
|
8320
|
+
blocked: true
|
|
8321
|
+
};
|
|
8322
|
+
}
|
|
8323
|
+
const autoModelIntentDefinition = {
|
|
8324
|
+
key: AUTO_MODEL_INTENT_PROJECTION,
|
|
8325
|
+
stateVersion: 1,
|
|
8326
|
+
stateSchema: AutoModelIntentSchema,
|
|
8327
|
+
init: (_header, inherited = 0) => initialAutoModelIntent(inherited),
|
|
8328
|
+
apply: foldAutoModelIntent
|
|
8329
|
+
};
|
|
8330
|
+
//#endregion
|
|
8277
8331
|
//#region lib/types/auto-model-host.js
|
|
8278
8332
|
function failure$1(code, kind = "INVALID_REQUEST") {
|
|
8279
8333
|
return new LlmError(code, kind);
|
|
@@ -8332,13 +8386,6 @@ function buildRoutingContext(ctx, agent, turn, messages, budgetPolicyConfig) {
|
|
|
8332
8386
|
previousModelId: requestHeader?.config.provider === "github-copilot-preview" ? requestHeader.config.model : void 0
|
|
8333
8387
|
};
|
|
8334
8388
|
}
|
|
8335
|
-
function pendingAuto(ctx, agent) {
|
|
8336
|
-
const candidate = ctx.get("sessionProjections");
|
|
8337
|
-
if (!record(candidate) || typeof candidate.stateOf !== "function") return void 0;
|
|
8338
|
-
const state = candidate.stateOf(agent.session, "modelSelection");
|
|
8339
|
-
if (!record(state) || !record(state.pending) || state.pending.provider !== "github-copilot-preview") return void 0;
|
|
8340
|
-
return typeof state.pending.model === "string" && autoModelPreference(state.pending.model) !== void 0 ? state.pending.model : void 0;
|
|
8341
|
-
}
|
|
8342
8389
|
function modelSelectionNotice(value) {
|
|
8343
8390
|
return record(value) && record(value.source) && value.source.kind === "model-selection";
|
|
8344
8391
|
}
|
|
@@ -8371,6 +8418,31 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8371
8418
|
const pendingDecisions = /* @__PURE__ */ new WeakMap();
|
|
8372
8419
|
const activeDecisions = /* @__PURE__ */ new Set();
|
|
8373
8420
|
let active = true;
|
|
8421
|
+
let removeIntentProjection;
|
|
8422
|
+
const retainedAuto = (registry, session) => {
|
|
8423
|
+
if (typeof registry.register !== "function" || typeof registry.stateOf !== "function") throw failure$1("COPILOT_AUTO_INTENT_PROJECTIONS_UNAVAILABLE");
|
|
8424
|
+
if (!removeIntentProjection) {
|
|
8425
|
+
const remove = registry.register(autoModelIntentDefinition);
|
|
8426
|
+
if (typeof remove !== "function") throw failure$1("COPILOT_AUTO_INTENT_DISPOSER_UNAVAILABLE");
|
|
8427
|
+
removeIntentProjection = () => {
|
|
8428
|
+
remove();
|
|
8429
|
+
};
|
|
8430
|
+
}
|
|
8431
|
+
const intent = AutoModelIntentSchema.safeParse(registry.stateOf(session, AUTO_MODEL_INTENT_PROJECTION));
|
|
8432
|
+
if (!intent.success || intent.data.blocked) throw failure$1("COPILOT_AUTO_INTENT_UNAVAILABLE");
|
|
8433
|
+
const selection = intent.data.selection;
|
|
8434
|
+
return selection?.provider === "github-copilot-preview" && autoModelPreference(selection.model) !== void 0 ? selection.model : void 0;
|
|
8435
|
+
};
|
|
8436
|
+
const pendingAuto = (agent) => {
|
|
8437
|
+
const registry = ctx.get("sessionProjections");
|
|
8438
|
+
if (!record(registry) || typeof registry.stateOf !== "function") return void 0;
|
|
8439
|
+
const native = registry.stateOf(agent.session, "modelSelection");
|
|
8440
|
+
if (!record(native)) return void 0;
|
|
8441
|
+
const selection = native.pending;
|
|
8442
|
+
if (selection === null && agent.session.requestHeader()?.config.provider === "github-copilot-preview") return retainedAuto(registry, agent.session);
|
|
8443
|
+
if (!record(selection) || selection.provider !== "github-copilot-preview") return void 0;
|
|
8444
|
+
return typeof selection.model === "string" && autoModelPreference(selection.model) !== void 0 ? selection.model : void 0;
|
|
8445
|
+
};
|
|
8374
8446
|
const decisionFor = (agent, turn, messages, preference, signal) => {
|
|
8375
8447
|
if (!active || signal.aborted) return Promise.reject(signal.reason ?? failure$1("COPILOT_AUTO_DISPOSED", "ABORTED"));
|
|
8376
8448
|
const completed = routed.get(agent);
|
|
@@ -8460,13 +8532,18 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8460
8532
|
const pending = selection.pending === null ? null : followSelection(selection.pending);
|
|
8461
8533
|
if (pending === void 0) throw failure$1("COPILOT_PARENT_MODEL_SELECTION_UNAVAILABLE");
|
|
8462
8534
|
const header = session.requestHeader();
|
|
8535
|
+
const recorded = record(header) ? followSelection(header.config) : void 0;
|
|
8536
|
+
const retained = pending === null && recorded?.provider === "github-copilot-preview" ? retainedAuto(projections, session) : void 0;
|
|
8463
8537
|
return {
|
|
8464
8538
|
id: session.id,
|
|
8465
8539
|
parentId: typeof session.header.parentSession === "string" ? session.header.parentSession : void 0,
|
|
8466
8540
|
origin: typeof session.header.origin === "string" ? session.header.origin : void 0,
|
|
8467
8541
|
state: parsed.data,
|
|
8468
8542
|
pending,
|
|
8469
|
-
recorded:
|
|
8543
|
+
recorded: retained === void 0 ? recorded : {
|
|
8544
|
+
provider: GITHUB_COPILOT_PREVIEW_PROVIDER_ID,
|
|
8545
|
+
model: retained
|
|
8546
|
+
}
|
|
8470
8547
|
};
|
|
8471
8548
|
};
|
|
8472
8549
|
const child = readSubject(agent);
|
|
@@ -8497,7 +8574,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8497
8574
|
const effectiveAuto = (agent) => {
|
|
8498
8575
|
const inherited = followIntent(agent);
|
|
8499
8576
|
if (inherited !== void 0) return autoModelPreference(inherited.model) !== void 0 ? inherited.model : void 0;
|
|
8500
|
-
return pendingAuto(
|
|
8577
|
+
return pendingAuto(agent);
|
|
8501
8578
|
};
|
|
8502
8579
|
const installAgent = (agent) => {
|
|
8503
8580
|
if (agentDisposers.has(agent)) return;
|
|
@@ -8512,7 +8589,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8512
8589
|
model: inherited.model
|
|
8513
8590
|
}
|
|
8514
8591
|
};
|
|
8515
|
-
const pending = pendingAuto(
|
|
8592
|
+
const pending = pendingAuto(agent);
|
|
8516
8593
|
if (pending === void 0) return assembled;
|
|
8517
8594
|
return {
|
|
8518
8595
|
...assembled,
|
|
@@ -8530,6 +8607,15 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8530
8607
|
turn,
|
|
8531
8608
|
messages: entered
|
|
8532
8609
|
});
|
|
8610
|
+
const admitted = routed.get(agent);
|
|
8611
|
+
if (result.kind === "enter" && !signal.aborted && admitted?.turn === turn && admitted.admitted !== void 0) {
|
|
8612
|
+
const filtered = result.messages.filter((message) => !modelSelectionNotice(message));
|
|
8613
|
+
const notice = actualNotice(agent, admitted.decision.model.id);
|
|
8614
|
+
return {
|
|
8615
|
+
...result,
|
|
8616
|
+
messages: notice === void 0 ? filtered : [...filtered, notice]
|
|
8617
|
+
};
|
|
8618
|
+
}
|
|
8533
8619
|
const pending = effectiveAuto(agent);
|
|
8534
8620
|
const preference = pending === void 0 ? void 0 : autoModelPreference(pending);
|
|
8535
8621
|
const inherited = followIntent(agent);
|
|
@@ -8579,6 +8665,15 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8579
8665
|
const removeRequest = ctx.on("agent/request", async ({ agent, turn, signal }, next) => {
|
|
8580
8666
|
installAgent(agent);
|
|
8581
8667
|
const native = await next();
|
|
8668
|
+
const admitted = routed.get(agent);
|
|
8669
|
+
if (admitted?.turn === turn && admitted.admitted !== void 0) {
|
|
8670
|
+
if (!signal.aborted) dependencies.admitModel?.(agent, turn, admitted.decision.model.id, signal);
|
|
8671
|
+
const { reasoningEffort: _changedEffort, ...current } = native;
|
|
8672
|
+
return {
|
|
8673
|
+
...current,
|
|
8674
|
+
...admitted.admitted
|
|
8675
|
+
};
|
|
8676
|
+
}
|
|
8582
8677
|
const inherited = followIntent(agent);
|
|
8583
8678
|
const { reasoningEffort: _nativeEffort, ...withoutEffort } = native;
|
|
8584
8679
|
const resolved = inherited === void 0 ? native : {
|
|
@@ -8624,6 +8719,11 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8624
8719
|
}
|
|
8625
8720
|
if (!signal.aborted) {
|
|
8626
8721
|
dependencies.admitModel?.(agent, turn, state.decision.model.id, signal);
|
|
8722
|
+
state.admitted = {
|
|
8723
|
+
provider: resolved.provider,
|
|
8724
|
+
model: state.decision.model.id,
|
|
8725
|
+
...resolved.reasoningEffort === void 0 ? {} : { reasoningEffort: resolved.reasoningEffort }
|
|
8726
|
+
};
|
|
8627
8727
|
selections.record(agent, turn, {
|
|
8628
8728
|
mode: "auto",
|
|
8629
8729
|
preference: state.decision.preference,
|
|
@@ -8646,6 +8746,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8646
8746
|
removeDisposed();
|
|
8647
8747
|
removeRequest();
|
|
8648
8748
|
removeFollowProjection?.();
|
|
8749
|
+
removeIntentProjection?.();
|
|
8649
8750
|
for (const dispose of activeDisposers) dispose();
|
|
8650
8751
|
activeDisposers.clear();
|
|
8651
8752
|
selections.clear();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AUTO_MODEL_INTENT_PROJECTION = "githubCopilotAutoModelIntent";
|
|
3
|
+
export declare const AutoModelIntentSchema: z.ZodObject<{
|
|
4
|
+
inherited: z.ZodNumber;
|
|
5
|
+
selection: z.ZodNullable<z.ZodObject<{
|
|
6
|
+
provider: z.ZodString;
|
|
7
|
+
model: z.ZodString;
|
|
8
|
+
}, z.core.$strict>>;
|
|
9
|
+
blocked: z.ZodBoolean;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
export type AutoModelIntent = z.infer<typeof AutoModelIntentSchema>;
|
|
12
|
+
export declare function initialAutoModelIntent(inherited?: number): AutoModelIntent;
|
|
13
|
+
/** Request headers describe execution, not replacement of an explicit picker intent. */
|
|
14
|
+
export declare function foldAutoModelIntent(state: AutoModelIntent, event: unknown): AutoModelIntent;
|
|
15
|
+
export declare const autoModelIntentDefinition: {
|
|
16
|
+
key: string;
|
|
17
|
+
stateVersion: number;
|
|
18
|
+
stateSchema: z.ZodObject<{
|
|
19
|
+
inherited: z.ZodNumber;
|
|
20
|
+
selection: z.ZodNullable<z.ZodObject<{
|
|
21
|
+
provider: z.ZodString;
|
|
22
|
+
model: z.ZodString;
|
|
23
|
+
}, z.core.$strict>>;
|
|
24
|
+
blocked: z.ZodBoolean;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
init: (_header: unknown, inherited?: number) => {
|
|
27
|
+
inherited: number;
|
|
28
|
+
selection: {
|
|
29
|
+
provider: string;
|
|
30
|
+
model: string;
|
|
31
|
+
} | null;
|
|
32
|
+
blocked: boolean;
|
|
33
|
+
};
|
|
34
|
+
apply: typeof foldAutoModelIntent;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=auto-model-intent.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.
|
|
4
|
+
"version": "0.4.0-alpha.98",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/",
|