dsh-github-copilot 0.1.0-alpha.15.dsh.0.2.2.rc.3 → 0.1.0-alpha.16.dsh.0.2.2.rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ release tags do not update this file after publication. Check the exact
5
5
  [GitHub Release](https://github.com/cloga/dsh-github-copilot/releases) and npm
6
6
  version separately rather than treating an old `prepared` label as current status.
7
7
 
8
+ ## 0.1.0-alpha.16.dsh.0.2.2.rc.3 (prepared)
9
+
10
+ - Record native Copilot turn-account evidence only after an ordinary native stream chunk is yielded for the admitted account (#488).
11
+ - Exclude auxiliary calls and require native route and canonical-account proof; mismatches and credential changes leave evidence unknown.
12
+ - Retain bounded, Host-memory-only history; never infer older turns from current settings.
13
+
8
14
  ## 0.1.0-alpha.15.dsh.0.2.2.rc.3 (prepared)
9
15
 
10
16
  - Include an optional, bounded offline multi-turn autonomy trace evaluator and synthetic examples (#494).
package/README.md CHANGED
@@ -73,15 +73,15 @@ After the exact compatible release is available and verified, download its
73
73
  original asset and checksum in an empty directory:
74
74
 
75
75
  ```sh
76
- curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.15.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.15.dsh.0.2.2.rc.3.tgz
77
- curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.15.dsh.0.2.2.rc.3/SHA256SUMS
76
+ curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.16.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.16.dsh.0.2.2.rc.3.tgz
77
+ curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.16.dsh.0.2.2.rc.3/SHA256SUMS
78
78
  sha256sum --check SHA256SUMS
79
79
  ```
80
80
 
81
81
  For the `web` profile, install the same Release asset:
82
82
 
83
83
  ```sh
84
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.15.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.15.dsh.0.2.2.rc.3.tgz
84
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.16.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.16.dsh.0.2.2.rc.3.tgz
85
85
  ```
86
86
 
87
87
  Choose the intended profile explicitly. Then:
@@ -174,6 +174,13 @@ The native route's quota and optional identity display use only the canonical OA
174
174
  provider names a credential, endpoint or nonempty headers override, or its configuration
175
175
  cannot be verified, quota is shown as unavailable rather than attributed to a
176
176
  different account. This is not proof of request-level billing attribution.
177
+ Completed-turn Account evidence is also captured for the native provider, but
178
+ only after an actual native stream chunk for that admitted request. It reflects
179
+ the profile-wide account bound to the canonical credential, not a Session
180
+ override, billing attribution or subagent rollup. A mismatched account,
181
+ unproven native route or credential change before delivery leaves it unknown.
182
+ Evidence is Host-memory-only;
183
+ older turns and turns missing after a restart or eviction remain unknown.
177
184
  Native context-incident diagnostics remain available without the optional
178
185
  managed continuation service; they do not replace DSH's context meter.
179
186
  Local diagnostics also offers separately opt-in, content-free logical
package/README.zh.md CHANGED
@@ -61,15 +61,15 @@ node scripts/select-core-release.mjs 0.2.2-rc.3
61
61
  精确兼容版本发布且通过验证后,在空目录下载原始制品并校验:
62
62
 
63
63
  ```sh
64
- curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.15.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.15.dsh.0.2.2.rc.3.tgz
65
- curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.15.dsh.0.2.2.rc.3/SHA256SUMS
64
+ curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.16.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.16.dsh.0.2.2.rc.3.tgz
65
+ curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.16.dsh.0.2.2.rc.3/SHA256SUMS
66
66
  sha256sum --check SHA256SUMS
67
67
  ```
68
68
 
69
69
  例如安装到 `web` profile:
70
70
 
71
71
  ```sh
72
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.15.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.15.dsh.0.2.2.rc.3.tgz
72
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.16.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.16.dsh.0.2.2.rc.3.tgz
73
73
  ```
74
74
 
75
75
  请明确选择目标 profile,然后:
@@ -136,6 +136,10 @@ alpha.13 发布版本修复了该资格判断;实际运行状态仍需单独
136
136
  原生路线的额度和可选身份显示只使用 canonical OAuth 账号;如果 provider 指定了其他凭据、
137
137
  端点或非空请求头,或无法确认其配置,则显示额度不可用,不会将其他账号的额度归到原生路线。
138
138
  这不证明单次请求实际计费的账号。
139
+ 原生 provider 的已完成轮次也会记录账号证据,但仅在对应请求实际返回原生流数据后记录。
140
+ 记录的是绑定到 canonical 凭据的 profile 全局账号,不是 Session 覆盖、计费归属或子 Agent 汇总。
141
+ 账号不匹配、原生路线无法确认,或返回数据前凭据发生变化时,账号证据显示未知。
142
+ 证据仅保留在 Host 内存中;更早的历史,以及重启或淘汰后缺失的记录仍显示未知。
139
143
  原生上下文异常诊断不依赖可选的托管续接服务,也不会替代 DSH 的上下文计量。
140
144
  Local diagnostics 可另行启用不含内容的原生 Copilot 逻辑流和可选 Copilot 搜索观察;
141
145
  它不显示 HTTP 细节,也不证明供应商收到请求或执行成功。参见
@@ -8,14 +8,14 @@
8
8
  },
9
9
  "package": {
10
10
  "name": "dsh-github-copilot",
11
- "version": "0.1.0-alpha.15.dsh.0.2.2.rc.3"
11
+ "version": "0.1.0-alpha.16.dsh.0.2.2.rc.3"
12
12
  },
13
13
  "releaseLines": [
14
14
  { "core": "0.2.0-rc.2", "version": "0.4.2-alpha.15", "status": "published" },
15
15
  { "core": "0.2.1-alpha.4", "version": "0.4.2-alpha.16", "status": "published" },
16
16
  { "core": "0.2.1-alpha.5", "version": "0.1.0-alpha.2.dsh.0.2.1.alpha.5", "status": "published" },
17
17
  { "core": "0.2.1-rc.3", "version": "0.1.0-alpha.5.dsh.0.2.1.rc.3", "status": "published" },
18
- { "core": "0.2.2-rc.3", "version": "0.1.0-alpha.15.dsh.0.2.2.rc.3", "status": "pending" }
18
+ { "core": "0.2.2-rc.3", "version": "0.1.0-alpha.16.dsh.0.2.2.rc.3", "status": "pending" }
19
19
  ],
20
20
  "evidence": {
21
21
  "kind": "source-and-synthetic-test-inventory",
@@ -451,7 +451,7 @@
451
451
  "id": "copilot-session-accounts",
452
452
  "required": true,
453
453
  "evidenceScope": "synthetic-turn-routing-native-gateways-settings-persistence-and-ui-not-live-account-access",
454
- "activation": "managed-only-explicit-session-choice-or-global-default",
454
+ "activation": "managed-session-choice-or-global-default-with-qualified-native-turn-evidence",
455
455
  "sourceMarkers": [
456
456
  {"file": "src/session-accounts-host.ts", "marker": "class SessionAccountsHost"},
457
457
  {"file": "src/session-accounts-controller.ts", "marker": "extends TypertRemoteService"},
@@ -464,6 +464,10 @@
464
464
  {"file": "tests/session-accounts.spec.ts", "name": "freezes each turn across preference changes, steps and retries"},
465
465
  {"file": "tests/session-accounts-host.spec.ts", "name": "holds account mutation fencing through abort until the actual turn boundary"},
466
466
  {"file": "tests/session-accounts-host.spec.ts", "name": "ignores identity completion after the turn ends"},
467
+ {"file": "tests/session-accounts-host.spec.ts", "name": "records native evidence only after matching account proof and delivery"},
468
+ {"file": "tests/session-accounts-host.spec.ts", "name": "keeps native evidence separate from managed account admission and identity"},
469
+ {"file": "tests/session-accounts-host.spec.ts", "name": "leaves native evidence unknown when the selected and canonical accounts differ"},
470
+ {"file": "tests/native-account-coexistence.spec.ts", "name": "applies confirmed account switches to native credentials and retains the native route after disposal"},
467
471
  {"file": "tests/copilot-usage-card.spec.ts", "name": "switches only subsequent Session turns inside Credits and can restore inheritance"},
468
472
  {"file": "tests/fixtures/remote-core.fixture.ts", "name": "binds Session account choices and historical reads through native Client and %s Host gateways"},
469
473
  {"file": "tests/fixtures/copilot-accounts-persistence-core.fixture.ts", "name": "persists independent accounts and SettingsForms CAS across restart with native sign-out recovery"}
@@ -422,16 +422,23 @@ send or retry a message. See the [synthetic composer capture](./images/copilot-s
422
422
  and [continuation contract](./session-continuation.md). When off, an account change pauses for explicit
423
423
  persistent-enable/keep-off/cancel consent. See the [approved experience and mock](./account-management-experience.md).
424
424
 
425
- Completed managed turns have a compact **Account** disclosure alongside native
426
- Usage actions through the public assistant-actions slot. This is
427
- request-account evidence, not billing attribution or a subagent account rollup.
425
+ Completed native and managed turns have a compact **Account** disclosure
426
+ alongside native Usage actions through the public assistant-actions slot. This
427
+ is request-account evidence, not billing attribution or a subagent account rollup.
428
428
  It freezes a verified cached identity at admission. Missing identity starts one
429
429
  nonforcing, bounded lookup for the exact admitted account without delaying model
430
430
  delivery. A successful lookup may fill missing identity only while that same
431
431
  turn/signal remains active and uncancelled, retaining the first verified name.
432
- Account execution evidence is still created only on the first real ordinary
433
- native chunk, not discovery, preparation or auxiliary Auto assessment. Late
434
- lookups never backfill completed turns. Host memory retains at
432
+ Native turns use the profile-wide canonical credential, not plugin Session-account
433
+ overrides. Native evidence additionally requires the public native adapter and
434
+ configuration proof, a canonical OAuth grant, and a match with the selected
435
+ account. A credential change before qualification and delivery, an unproven
436
+ route, or an account mismatch leaves the evidence unknown. Qualification does
437
+ not delay the model stream. Account execution evidence is created only after an
438
+ ordinary AgentLoop chunk for the same Session and signal, not selection,
439
+ discovery, preparation or auxiliary calls; it is not proof of supplier execution.
440
+ Native evidence does not change managed Session-account admission. Late lookups
441
+ never backfill completed turns. Host memory retains at
435
442
  most 64 Sessions and 128 turns per Session. Restart, cold history, eviction or a
436
443
  request with no native delivery is unknown. Failed reads are distinct from
437
444
  unknown evidence; Retry rereads the same turn without inference. Official rc.2
package/lib/client.js CHANGED
@@ -7775,7 +7775,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7775
7775
  };
7776
7776
  //#endregion
7777
7777
  //#region package.json
7778
- var version = "0.1.0-alpha.15.dsh.0.2.2.rc.3";
7778
+ var version = "0.1.0-alpha.16.dsh.0.2.2.rc.3";
7779
7779
  //#endregion
7780
7780
  //#region lib/types/diagnostics-client.js
7781
7781
  let owner;
package/lib/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { a as nativeCopilotUsesCanonicalOAuth, i as autoModelPreference, n as GITHUB_COPILOT_PREVIEW_PROVIDER_ID, r as GITHUB_COPILOT_PROVIDER_ID, t as GITHUB_COPILOT_CREDENTIAL_KEY } from "./copilot-identity-BpfZQOip.js";
2
2
  import { C as excludedModelSet, S as ModelExclusionTurns, _ as emptyAutoAllocationDiagnostics, a as DIAGNOSTICS_RETENTION_MS, b as AutoAllocationSchema, c as DiagnosticsSnapshotSchema, d as diagnosticsOutcome, f as diagnosticsReason, g as AutoAllocationDiagnosticsCollector, h as RequestDiagnosticSchema, l as DiagnosticsViewSchema, m as REQUEST_DIAGNOSTICS_RETENTION_MS, p as CredentialChangeSchema, s as DiagnosticsRowSchema, u as diagnosticsBucket, v as AUTO_ALLOCATION_POLICIES, w as normalizeExcludedModelIds, x as normalizeHighCostModelIds, y as AUTO_ALLOCATION_POLICY } from "./diagnostics-types-o02ogaiI.js";
3
- import { i as currentSearchInitiator, n as GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID, o as abortable$1, r as normalizeSearchResponse, s as isPluginPreviewProvider, t as COPILOT_HOSTED_SEARCH_PROVIDER_ID } from "./traditional-search-DP4tbmsO.js";
3
+ import { i as currentSearchInitiator, n as GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID, o as abortable$1, r as normalizeSearchResponse, s as isPluginPreviewProvider, t as COPILOT_HOSTED_SEARCH_PROVIDER_ID } from "./traditional-search-6Gf2GmQW.js";
4
4
  import { a as selectCompactionReasoning, i as resolveRequestBudgetPolicy, n as assessRequestBudget, r as calculateRequestBudget, t as DEFAULT_REQUEST_BUDGET_POLICY } from "./request-budget-DLY_aRq0.js";
5
5
  import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
6
6
  import { z } from "zod";
7
7
  import AuthorizationService from "@deepseek-ai/dsh-authorization";
8
+ import { CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, ReasoningEffortId, attributionHeaders, callConfigEquals, isAgentLoopRequest, resolveImageAttachmentAccess, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
8
9
  import { createHash, randomUUID } from "node:crypto";
9
10
  import * as dshScope from "@deepseek-ai/dsh-scope";
10
11
  import { NativeToolExecutor } from "@deepseek-ai/dsh-tool-executor-native";
@@ -15,7 +16,6 @@ import { symbols } from "@deepseek-ai/cordis";
15
16
  import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
16
17
  import { credentialKey } from "@deepseek-ai/dsh-credentials";
17
18
  import { WebError } from "@deepseek-ai/dsh-web";
18
- import { CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, ReasoningEffortId, attributionHeaders, callConfigEquals, isAgentLoopRequest, resolveImageAttachmentAccess, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
19
19
  import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "@earendil-works/pi-ai/api/github-copilot-headers";
20
20
  import { setImmediate } from "node:timers/promises";
21
21
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -741,7 +741,7 @@ function observeNativeStream(options, next, collector, warn) {
741
741
  var package_default = {
742
742
  name: "dsh-github-copilot",
743
743
  description: "Account-aware GitHub Copilot models for DeepSeek Harness through its published native adapter.",
744
- version: "0.1.0-alpha.15.dsh.0.2.2.rc.3",
744
+ version: "0.1.0-alpha.16.dsh.0.2.2.rc.3",
745
745
  releaseNotes: "CHANGELOG.md",
746
746
  publishConfig: {
747
747
  "access": "public",
@@ -7039,6 +7039,182 @@ let GitHubCopilotUsageController = (() => {
7039
7039
  }
7040
7040
  };
7041
7041
  })();
7042
+ //#endregion
7043
+ //#region lib/types/native-copilot-access.js
7044
+ var __rewriteRelativeImportExtension$1 = function(path, preserveJsx) {
7045
+ if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
7046
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
7047
+ });
7048
+ return path;
7049
+ };
7050
+ const NATIVE = "@deepseek-ai/dsh-llm-pi-ai";
7051
+ const PI = "@earendil-works/pi-ai";
7052
+ const NATIVE_COPILOT = "github-copilot";
7053
+ function record$10(value) {
7054
+ return value !== null && typeof value === "object" && !Array.isArray(value);
7055
+ }
7056
+ function plainRecord(value) {
7057
+ if (!record$10(value)) return false;
7058
+ const prototype = Object.getPrototypeOf(value);
7059
+ return prototype === Object.prototype || prototype === null;
7060
+ }
7061
+ /**
7062
+ * Native Config materializes empty template maps at provider, model and override
7063
+ * scope. They do not add template values; supportsStrictMode only controls native
7064
+ * JSON-schema tool conversion, not the credential, endpoint or model protocol.
7065
+ * Qualify these exact shapes without deleting or overriding any native setting.
7066
+ */
7067
+ function nativeCompat(value) {
7068
+ if (value === void 0) return true;
7069
+ if (!plainRecord(value)) return false;
7070
+ return Reflect.ownKeys(value).every((key) => {
7071
+ if (key === "supportsStrictMode") return typeof value[key] === "boolean";
7072
+ if (key !== "chatTemplateKwargs" && key !== "chatTemplateArgs") return false;
7073
+ const template = value[key];
7074
+ return plainRecord(template) && Reflect.ownKeys(template).length === 0;
7075
+ });
7076
+ }
7077
+ function customTransport(value) {
7078
+ return !nativeCompat(value.compat) || [
7079
+ "apiKeyEnv",
7080
+ "baseURL",
7081
+ "headers"
7082
+ ].some((key) => {
7083
+ const field = value[key];
7084
+ return field !== void 0 && field !== "" && (!record$10(field) || Object.keys(field).length > 0);
7085
+ });
7086
+ }
7087
+ /** Only the adapter's native catalog and its explicit native narrowing are qualified. */
7088
+ function nativeCopilotModels(profile, catalog) {
7089
+ if (!record$10(profile) || customTransport(profile) || !Array.isArray(catalog)) return void 0;
7090
+ const configured = profile.models;
7091
+ if (configured !== void 0 && !Array.isArray(configured)) return void 0;
7092
+ if (Array.isArray(configured) && configured.some((value) => !record$10(value) || customTransport(value))) return void 0;
7093
+ if (record$10(profile.modelOverrides) && Object.values(profile.modelOverrides).some((value) => !record$10(value) || customTransport(value))) return void 0;
7094
+ const ids = Array.isArray(configured) && configured.length > 0 ? new Set(configured.filter(record$10).map((value) => value.id)) : void 0;
7095
+ const api = profile.api;
7096
+ if (api !== void 0 && api !== "" && api !== "openai-responses" && api !== "openai-completions" && api !== "anthropic-messages") return void 0;
7097
+ const models = /* @__PURE__ */ new Map();
7098
+ for (const model of catalog) {
7099
+ if (!record$10(model) || typeof model.id !== "string" || model.id.length === 0 || model.id !== model.id.trim() || typeof model.api !== "string" || model.api.length === 0 || model.api !== model.api.trim() || models.has(model.id)) return void 0;
7100
+ models.set(model.id, {
7101
+ id: model.id,
7102
+ api: api || model.api
7103
+ });
7104
+ }
7105
+ if (ids !== void 0) {
7106
+ for (const id of models.keys()) if (!ids.has(id)) models.delete(id);
7107
+ }
7108
+ return models;
7109
+ }
7110
+ function nativeCatalogUrl(manifestPath, exports) {
7111
+ if (!record$10(exports)) return void 0;
7112
+ const exact = exports["./providers/all"];
7113
+ const wildcard = exact === void 0;
7114
+ if (wildcard && Object.keys(exports).some((key) => {
7115
+ if (key === "./providers/*") return false;
7116
+ const parts = key.split("*");
7117
+ if (parts.length !== 2) return false;
7118
+ const [prefix = "", suffix = ""] = parts;
7119
+ return "./providers/all".startsWith(prefix) && "./providers/all".endsWith(suffix) && prefix.length + suffix.length <= 15;
7120
+ })) return void 0;
7121
+ const descriptor = wildcard ? exports["./providers/*"] : exact;
7122
+ const target = typeof descriptor === "string" ? descriptor : record$10(descriptor) && Object.keys(descriptor).every((key) => key === "types" || key === "import") && typeof descriptor.import === "string" ? descriptor.import : void 0;
7123
+ if (!target || !/^\.\/(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._*-]+\.m?js$/u.test(target) || target.split("/").slice(1).some((part) => part === "." || part === "..")) return void 0;
7124
+ if ([...target].filter((character) => character === "*").length !== (wildcard ? 1 : 0)) return void 0;
7125
+ const base = new URL(".", pathToFileURL(manifestPath));
7126
+ const url = new URL(wildcard ? target.replace("*", "all") : target, base);
7127
+ return url.href.startsWith(base.href) ? url.href : void 0;
7128
+ }
7129
+ /**
7130
+ * Qualify the native Loader root and its exact published pi-ai dependency.
7131
+ * No credential, discovery, settings write or private adapter registry access.
7132
+ */
7133
+ async function captureNativeCopilotCatalog(ctx, diagnose = () => {}) {
7134
+ const unproven = (code) => {
7135
+ diagnose(code);
7136
+ };
7137
+ const llm = ctx.get("llm");
7138
+ const settings = ctx.get("settings");
7139
+ const loader = ctx.get("loader");
7140
+ const packages = ctx.get("pluginPackages");
7141
+ if (!llm || !settings || !loader || !packages) return unproven("COPILOT_NATIVE_SERVICES_UNAVAILABLE");
7142
+ const directory = llm.listConfigurableProviders().find((value) => value.provider === NATIVE_COPILOT);
7143
+ if (!directory || directory.declared !== false || directory.error !== void 0 || directory.settingsPath.length !== 2 || directory.settingsPath[0] !== "providers" || directory.settingsPath[1] !== "github-copilot" || directory.nativeAuth?.oauth !== true || !llm.listProviders().some((value) => value.id === "github-copilot")) return unproven("COPILOT_NATIVE_DIRECTORY_UNPROVEN");
7144
+ const entries = [...loader.entries()].filter((entry) => entry.options.id === directory.settingsNs);
7145
+ if (entries.length !== 1) return unproven("COPILOT_NATIVE_ENTRY_UNPROVEN");
7146
+ const entry = entries[0];
7147
+ const fiber = entry.fiber?.ctx.fiber;
7148
+ const base = entry.parent.tree.ctx.baseUrl;
7149
+ if (!fiber || fiber.uid === null || entry.options.name !== NATIVE || !base) return unproven("COPILOT_NATIVE_FIBER_UNPROVEN");
7150
+ const owner = packages.packageOf(NATIVE, base);
7151
+ const importedOwner = packages.packageOf(NATIVE, import.meta.url);
7152
+ if (owner?.version !== "0.2.2-rc.3" || owner.manifestPath !== importedOwner?.manifestPath) return unproven("COPILOT_NATIVE_PACKAGE_UNPROVEN");
7153
+ const nativePi = packages.packageOf(PI, pathToFileURL(owner.manifestPath).href);
7154
+ const localPi = packages.packageOf(PI, import.meta.url);
7155
+ if (nativePi?.name !== PI || nativePi.version !== "1.3.0" || localPi?.name !== PI || localPi.version !== "1.3.0") return unproven("COPILOT_NATIVE_PI_UNPROVEN");
7156
+ const ownerPath = owner.manifestPath;
7157
+ const nativePiPath = nativePi.manifestPath;
7158
+ const localPiPath = localPi.manifestPath;
7159
+ const view = () => settings.describe({ redactSecrets: true }).find((value) => value.ns === directory.settingsNs);
7160
+ const captured = view();
7161
+ if (!captured || !record$10(captured.value) || !record$10(captured.value.providers)) return unproven("COPILOT_NATIVE_SETTINGS_UNPROVEN");
7162
+ const catalogUrl = nativeCatalogUrl(nativePiPath, nativePi.manifest.exports);
7163
+ if (!catalogUrl) return unproven("COPILOT_NATIVE_CATALOG_UNAVAILABLE");
7164
+ let catalog;
7165
+ try {
7166
+ const nativeModule = await import(__rewriteRelativeImportExtension$1(
7167
+ /* @vite-ignore */
7168
+ catalogUrl
7169
+ ));
7170
+ if (!record$10(nativeModule) || typeof nativeModule.getBuiltinModels !== "function") return unproven("COPILOT_NATIVE_CATALOG_UNAVAILABLE");
7171
+ catalog = nativeModule.getBuiltinModels(NATIVE_COPILOT);
7172
+ } catch {
7173
+ return unproven("COPILOT_NATIVE_CATALOG_UNAVAILABLE");
7174
+ }
7175
+ const nativeCatalog = nativeCopilotModels({}, catalog);
7176
+ if (!nativeCatalog) return unproven("COPILOT_NATIVE_MODELS_UNPROVEN");
7177
+ const configuredModels = nativeCopilotModels(captured.value.providers[NATIVE_COPILOT], catalog);
7178
+ const module = await import("@deepseek-ai/dsh-llm-pi-ai");
7179
+ const current = () => {
7180
+ const currentLlm = ctx.get("llm");
7181
+ const currentSettings = ctx.get("settings");
7182
+ const currentLoader = ctx.get("loader");
7183
+ const currentPackages = ctx.get("pluginPackages");
7184
+ if (!currentLlm || !currentSettings || !currentLoader || !currentPackages) return false;
7185
+ const currentEntries = [...currentLoader.entries()].filter((value) => value.options.id === directory.settingsNs);
7186
+ if (currentEntries.length !== 1 || currentEntries[0] !== entry) return false;
7187
+ const currentDirectory = currentLlm.listConfigurableProviders().find((value) => value.provider === NATIVE_COPILOT);
7188
+ if (!currentDirectory || currentDirectory.declared !== false || currentDirectory.error !== void 0 || currentDirectory.settingsNs !== directory.settingsNs || currentDirectory.settingsPath.length !== 2 || currentDirectory.settingsPath[0] !== "providers" || currentDirectory.settingsPath[1] !== "github-copilot" || currentDirectory.nativeAuth?.oauth !== true) return false;
7189
+ const nativeOwner = currentPackages.packageOf(NATIVE, base);
7190
+ const importedOwner = currentPackages.packageOf(NATIVE, import.meta.url);
7191
+ const nativeCatalog = currentPackages.packageOf(PI, pathToFileURL(ownerPath).href);
7192
+ const pluginCatalog = currentPackages.packageOf(PI, import.meta.url);
7193
+ return fiber.uid !== null && entry.fiber?.ctx.fiber === fiber && fiber.runtime?.callback === module.apply && entry.options.name === NATIVE && currentSettings.describe({ redactSecrets: true }).find((value) => value.ns === directory.settingsNs)?.revision === captured.revision && nativeOwner?.manifestPath === ownerPath && nativeOwner.version === "0.2.2-rc.3" && importedOwner?.manifestPath === ownerPath && importedOwner.version === "0.2.2-rc.3" && nativeCatalog?.manifestPath === nativePiPath && nativeCatalog.version === "1.3.0" && pluginCatalog?.manifestPath === localPiPath && pluginCatalog.version === "1.3.0" && currentLlm.listProviders().some((value) => value.id === "github-copilot");
7194
+ };
7195
+ if (!current()) return unproven("COPILOT_NATIVE_SNAPSHOT_REVOKED");
7196
+ return {
7197
+ catalog: nativeCatalog,
7198
+ configuredModels,
7199
+ namespace: directory.settingsNs,
7200
+ assertCurrent() {
7201
+ if (!current()) throw new Error("COPILOT_NATIVE_ROUTE_CHANGED");
7202
+ }
7203
+ };
7204
+ }
7205
+ async function captureNativeCopilot(ctx, diagnose = () => {}) {
7206
+ const snapshot = await captureNativeCopilotCatalog(ctx, diagnose);
7207
+ if (snapshot === void 0) return void 0;
7208
+ if (snapshot.configuredModels === void 0) {
7209
+ diagnose("COPILOT_NATIVE_MODELS_UNPROVEN");
7210
+ return;
7211
+ }
7212
+ return {
7213
+ models: snapshot.configuredModels,
7214
+ namespace: snapshot.namespace,
7215
+ assertCurrent: snapshot.assertCurrent
7216
+ };
7217
+ }
7042
7218
  function invalid() {
7043
7219
  throw new Error("COPILOT_SESSION_ACCOUNTS_INVALID");
7044
7220
  }
@@ -7065,10 +7241,13 @@ function resolveSessionAccount(sessionId, preferences, globalAccountId) {
7065
7241
  }
7066
7242
  /** Active turns are never evicted; bounded historical evidence may become unknown. */
7067
7243
  var SessionAccountTurns = class {
7244
+ history;
7068
7245
  active = /* @__PURE__ */ new Map();
7069
7246
  signals = /* @__PURE__ */ new WeakMap();
7070
7247
  identities = /* @__PURE__ */ new WeakMap();
7071
- history = /* @__PURE__ */ new Map();
7248
+ constructor(history = /* @__PURE__ */ new Map()) {
7249
+ this.history = history;
7250
+ }
7072
7251
  admit(agent, turn, signal, selection) {
7073
7252
  if (!Number.isSafeInteger(turn) || turn < 0 || signal.aborted) throw new Error("COPILOT_SESSION_ACCOUNT_TURN_INVALID");
7074
7253
  const previous = this.active.get(agent);
@@ -7147,7 +7326,7 @@ var SessionAccountTurns = class {
7147
7326
  this.identities.set(entry.admission, captured);
7148
7327
  const turns = this.history.get(entry.agent);
7149
7328
  const evidence = turns?.get(entry.admission.turn);
7150
- if (turns && evidence && !evidence.identity) turns.set(entry.admission.turn, Object.freeze({
7329
+ if (turns && evidence && evidence.accountId === entry.admission.accountId && evidence.source === entry.admission.source && !evidence.identity) turns.set(entry.admission.turn, Object.freeze({
7151
7330
  ...evidence,
7152
7331
  identity: captured
7153
7332
  }));
@@ -7158,8 +7337,12 @@ var SessionAccountTurns = class {
7158
7337
  /** Host-only routing owner; credentials remain in the existing account service. */
7159
7338
  var SessionAccountsHost = class {
7160
7339
  ctx;
7161
- turns = new SessionAccountTurns();
7340
+ history = /* @__PURE__ */ new Map();
7341
+ turns = new SessionAccountTurns(this.history);
7342
+ nativeAccountTurns = new SessionAccountTurns(this.history);
7162
7343
  leases = /* @__PURE__ */ new Map();
7344
+ nativeTurns = /* @__PURE__ */ new Map();
7345
+ nativeSignals = /* @__PURE__ */ new WeakMap();
7163
7346
  constructor(ctx) {
7164
7347
  this.ctx = ctx;
7165
7348
  }
@@ -7191,18 +7374,136 @@ var SessionAccountsHost = class {
7191
7374
  throw error;
7192
7375
  }
7193
7376
  }
7377
+ admitNative(agent, turn, signal, accountId, model) {
7378
+ let binding;
7379
+ try {
7380
+ binding = this.bindingForAccount(accountId);
7381
+ } catch {
7382
+ this.ctx.logger.warn("[github-copilot] %s", "COPILOT_NATIVE_ACCOUNT_EVIDENCE_UNAVAILABLE");
7383
+ return;
7384
+ }
7385
+ const existing = this.nativeTurns.get(agent.session);
7386
+ if (existing) {
7387
+ if (existing.turn === turn && existing.signal === signal && existing.accountId === binding.accountId) return;
7388
+ this.ctx.logger.warn("[github-copilot] %s", "COPILOT_NATIVE_ACCOUNT_TURN_CONFLICT");
7389
+ return;
7390
+ }
7391
+ if (this.nativeSignals.has(signal)) {
7392
+ this.ctx.logger.warn("[github-copilot] %s", "COPILOT_NATIVE_ACCOUNT_EVIDENCE_SIGNAL_CONFLICT");
7393
+ return;
7394
+ }
7395
+ if (this.nativeTurns.size >= 2048) {
7396
+ this.ctx.logger.warn("[github-copilot] %s", "COPILOT_NATIVE_ACCOUNT_EVIDENCE_LIMIT");
7397
+ return;
7398
+ }
7399
+ const evidence = {
7400
+ session: agent.session,
7401
+ turn,
7402
+ signal,
7403
+ accountId: binding.accountId,
7404
+ accountKey: binding.key,
7405
+ model,
7406
+ valid: true,
7407
+ delivered: false,
7408
+ ownsAdmission: false
7409
+ };
7410
+ this.nativeTurns.set(agent.session, evidence);
7411
+ this.nativeSignals.set(signal, evidence);
7412
+ this.qualifyNative(evidence);
7413
+ }
7414
+ nativeCurrent(evidence) {
7415
+ return evidence.valid && !evidence.signal.aborted && this.nativeTurns.get(evidence.session) === evidence && this.nativeSignals.get(evidence.signal) === evidence;
7416
+ }
7417
+ invalidateNative(evidence) {
7418
+ evidence.valid = false;
7419
+ if (evidence.ownsAdmission) this.nativeAccountTurns.end(evidence.session, evidence.turn);
7420
+ }
7421
+ async qualifyNative(evidence) {
7422
+ try {
7423
+ const accounts = this.ctx.get("githubCopilotAccounts");
7424
+ if (!accounts) throw new Error("COPILOT_SESSION_ACCOUNTS_UNAVAILABLE");
7425
+ const [route, credential, matches] = await Promise.all([
7426
+ captureNativeCopilot(this.ctx),
7427
+ createGitHubCopilotCredentialStore(this.ctx).read(GITHUB_COPILOT_PROVIDER_ID),
7428
+ accounts.host.nativeCredentialMatches(evidence.accountId)
7429
+ ]);
7430
+ if (!this.nativeCurrent(evidence)) return;
7431
+ if (!matches) {
7432
+ this.invalidateNative(evidence);
7433
+ this.ctx.logger.warn("[github-copilot] %s", "COPILOT_NATIVE_ACCOUNT_EVIDENCE_MISMATCH");
7434
+ return;
7435
+ }
7436
+ if (!route || !route.models.has(evidence.model) || credential?.type !== "oauth") {
7437
+ this.invalidateNative(evidence);
7438
+ this.ctx.logger.warn("[github-copilot] %s", "COPILOT_NATIVE_ACCOUNT_EVIDENCE_UNPROVEN");
7439
+ return;
7440
+ }
7441
+ route.assertCurrent();
7442
+ this.nativeAccountTurns.admit(evidence.session, evidence.turn, evidence.signal, {
7443
+ accountId: evidence.accountId,
7444
+ source: "global"
7445
+ });
7446
+ evidence.ownsAdmission = true;
7447
+ evidence.route = route;
7448
+ this.captureIdentity(evidence.signal, evidence.accountId, () => this.nativeCurrent(evidence), this.nativeAccountTurns);
7449
+ this.recordNativeEvidence(evidence);
7450
+ } catch {
7451
+ if (this.nativeCurrent(evidence)) {
7452
+ this.invalidateNative(evidence);
7453
+ this.ctx.logger.warn("[github-copilot] %s", "COPILOT_NATIVE_ACCOUNT_EVIDENCE_UNAVAILABLE");
7454
+ }
7455
+ }
7456
+ }
7457
+ recordNativeEvidence(evidence) {
7458
+ if (!this.nativeCurrent(evidence) || !evidence.delivered || !evidence.route || this.nativeAccountTurns.forSignal(evidence.signal)?.turn !== evidence.turn) return;
7459
+ try {
7460
+ evidence.route.assertCurrent();
7461
+ this.nativeAccountTurns.recordSignal(evidence.signal, this.ctx.get("githubCopilotAccounts")?.host.cachedIdentity(evidence.accountId));
7462
+ } catch {
7463
+ this.invalidateNative(evidence);
7464
+ this.ctx.logger.warn("[github-copilot] %s", "COPILOT_NATIVE_ACCOUNT_EVIDENCE_UNAVAILABLE");
7465
+ }
7466
+ }
7467
+ recordNativeRequest(signal, sessionId, model) {
7468
+ const evidence = this.nativeSignals.get(signal);
7469
+ if (!evidence || !this.nativeCurrent(evidence) || evidence.session.id !== sessionId || evidence.model !== model) return;
7470
+ evidence.delivered = true;
7471
+ this.recordNativeEvidence(evidence);
7472
+ }
7473
+ credentialChanged(key) {
7474
+ for (const evidence of this.nativeTurns.values()) if (evidence.valid && (key === "llm-pi-ai/github-copilot" || key === evidence.accountKey)) this.invalidateNative(evidence);
7475
+ }
7194
7476
  end(session, turn) {
7477
+ const native = this.nativeTurns.get(session);
7478
+ if (native?.turn === turn) {
7479
+ this.invalidateNative(native);
7480
+ this.nativeSignals.delete(native.signal);
7481
+ this.nativeTurns.delete(session);
7482
+ }
7195
7483
  if (this.turns.current(session)?.turn !== turn) return;
7196
7484
  this.leases.get(session)?.release();
7197
7485
  this.leases.delete(session);
7198
7486
  this.turns.end(session, turn);
7199
7487
  }
7200
7488
  remove(session) {
7489
+ const native = this.nativeTurns.get(session);
7490
+ if (native) {
7491
+ this.invalidateNative(native);
7492
+ this.nativeSignals.delete(native.signal);
7493
+ this.nativeTurns.delete(session);
7494
+ }
7495
+ this.nativeAccountTurns.remove(session);
7201
7496
  this.leases.get(session)?.release();
7202
7497
  this.leases.delete(session);
7203
7498
  this.turns.remove(session);
7204
7499
  }
7205
7500
  dispose() {
7501
+ for (const native of this.nativeTurns.values()) {
7502
+ this.invalidateNative(native);
7503
+ this.nativeSignals.delete(native.signal);
7504
+ }
7505
+ this.nativeTurns.clear();
7506
+ this.nativeAccountTurns.clear();
7206
7507
  for (const lease of this.leases.values()) lease.release();
7207
7508
  this.leases.clear();
7208
7509
  this.turns.clear();
@@ -7212,25 +7513,25 @@ var SessionAccountsHost = class {
7212
7513
  if (!accounts) throw new Error("COPILOT_SESSION_ACCOUNTS_UNAVAILABLE");
7213
7514
  return accounts.host.captureAccount(accountId);
7214
7515
  }
7215
- captureIdentity(signal, accountId) {
7516
+ captureIdentity(signal, accountId, eligible = () => true, turns = this.turns) {
7216
7517
  const accounts = this.ctx.get("githubCopilotAccounts");
7217
7518
  if (!accounts) throw new Error("COPILOT_SESSION_ACCOUNTS_UNAVAILABLE");
7218
7519
  const cached = accounts.host.cachedIdentity(accountId);
7219
7520
  if (cached) {
7220
- this.turns.captureIdentity(signal, cached);
7521
+ if (eligible()) turns.captureIdentity(signal, cached);
7221
7522
  return;
7222
7523
  }
7223
- const admission = this.turns.forSignal(signal);
7524
+ const admission = turns.forSignal(signal);
7224
7525
  accounts.host.ensureIdentityFor(accountId).then((view) => {
7225
- if (this.turns.forSignal(signal) !== admission || signal.aborted) return;
7526
+ if (turns.forSignal(signal) !== admission || signal.aborted || !eligible()) return;
7226
7527
  if (view.state === "error") {
7227
7528
  this.ctx.logger.warn("[github-copilot] %s", view.diagnostic ?? "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE");
7228
7529
  return;
7229
7530
  }
7230
7531
  const identity = accounts.host.cachedIdentity(accountId);
7231
- if (identity) this.turns.captureIdentity(signal, identity);
7532
+ if (identity) turns.captureIdentity(signal, identity);
7232
7533
  }, () => {
7233
- if (this.turns.forSignal(signal) === admission && !signal.aborted) this.ctx.logger.warn("[github-copilot] COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE");
7534
+ if (turns.forSignal(signal) === admission && !signal.aborted && eligible()) this.ctx.logger.warn("[github-copilot] COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE");
7234
7535
  });
7235
7536
  }
7236
7537
  recordRequest(signal) {
@@ -7580,7 +7881,7 @@ const usageSchema = z.object({
7580
7881
  totalTokens: count$2.optional(),
7581
7882
  reasoningTokens: count$2.optional()
7582
7883
  });
7583
- function record$10(value) {
7884
+ function record$9(value) {
7584
7885
  return typeof value === "object" && value !== null && !Array.isArray(value);
7585
7886
  }
7586
7887
  function sameRoute(left, right) {
@@ -7602,7 +7903,7 @@ function initialContextEvidence() {
7602
7903
  }
7603
7904
  /** Read only counts and routing leaves; never message content or opaque replay. */
7604
7905
  function foldContextEvidence(state, event) {
7605
- if (!record$10(event) || typeof event.type !== "string" || !record$10(event.data)) return state;
7906
+ if (!record$9(event) || typeof event.type !== "string" || !record$9(event.data)) return state;
7606
7907
  if (event.type === "step/start") {
7607
7908
  const step = stepSchema.safeParse({
7608
7909
  turn: event.data.turn,
@@ -7664,7 +7965,7 @@ function foldContextEvidence(state, event) {
7664
7965
  };
7665
7966
  const operation = state.compaction;
7666
7967
  if (operation?.state === "running" && count$2.safeParse(event.seq).success && Number(event.seq) > operation.startSeq) {
7667
- if (event.type === "user/message" && record$10(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === operation.id) state = {
7968
+ if (event.type === "user/message" && record$9(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === operation.id) state = {
7668
7969
  ...state,
7669
7970
  compaction: {
7670
7971
  ...operation,
@@ -7681,7 +7982,7 @@ function foldContextEvidence(state, event) {
7681
7982
  };
7682
7983
  }
7683
7984
  if (event.type === "request/header" || event.type === "model/selection") {
7684
- const raw = event.type === "request/header" ? record$10(event.data.header) ? event.data.header.config : void 0 : event.data;
7985
+ const raw = event.type === "request/header" ? record$9(event.data.header) ? event.data.header.config : void 0 : event.data;
7685
7986
  const revoke = () => state.compaction ? {
7686
7987
  ...state.compaction,
7687
7988
  headerSeq: null,
@@ -7689,7 +7990,7 @@ function foldContextEvidence(state, event) {
7689
7990
  step: null,
7690
7991
  request: "unknown"
7691
7992
  } : state.compaction;
7692
- if (!record$10(raw)) return {
7993
+ if (!record$9(raw)) return {
7693
7994
  ...state,
7694
7995
  route: null,
7695
7996
  sample: null,
@@ -7740,7 +8041,7 @@ function foldContextEvidence(state, event) {
7740
8041
  };
7741
8042
  }
7742
8043
  if (event.type.startsWith("compaction/") || event.surfaceOp !== void 0 && event.surfaceOp !== "append") {
7743
- const checkpoint = event.type === "user/message" && record$10(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === state.compaction?.id;
8044
+ const checkpoint = event.type === "user/message" && record$9(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === state.compaction?.id;
7744
8045
  return {
7745
8046
  ...state,
7746
8047
  sample: null,
@@ -7758,9 +8059,9 @@ function foldContextEvidence(state, event) {
7758
8059
  }
7759
8060
  if (event.type !== "assistant/message" && event.type !== "assistant/attempt") return state;
7760
8061
  if (!copilot(state.route)) return state;
7761
- const source = record$10(event.data.message) ? event.data.message.source : event.data.source;
8062
+ const source = record$9(event.data.message) ? event.data.message.source : event.data.source;
7762
8063
  if (event.type === "assistant/message" && source !== void 0) {
7763
- const parsed = routeSchema.safeParse(record$10(source) ? {
8064
+ const parsed = routeSchema.safeParse(record$9(source) ? {
7764
8065
  provider: source.provider,
7765
8066
  model: source.model
7766
8067
  } : source);
@@ -7790,11 +8091,11 @@ function foldContextEvidence(state, event) {
7790
8091
  const settledUsage = usage !== void 0;
7791
8092
  let terminal;
7792
8093
  for (const entry of stream) {
7793
- if (!record$10(entry) || entry.type !== "chunk" || !record$10(entry.chunk)) continue;
8094
+ if (!record$9(entry) || entry.type !== "chunk" || !record$9(entry.chunk)) continue;
7794
8095
  if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
7795
8096
  if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
7796
8097
  }
7797
- const successful = event.data.interrupted !== true && record$10(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
8098
+ const successful = event.data.interrupted !== true && record$9(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
7798
8099
  const compact = state.compaction;
7799
8100
  if (compact?.state === "completed") {
7800
8101
  if (compact.headerSeq === null || !count$2.safeParse(event.seq).success || Number(event.seq) <= compact.headerSeq) return state;
@@ -7811,7 +8112,7 @@ function foldContextEvidence(state, event) {
7811
8112
  ...state,
7812
8113
  compaction: {
7813
8114
  ...compact,
7814
- request: event.type === "assistant/message" && successful && source !== void 0 ? "succeeded" : record$10(terminal) && terminal.kind === "aborted" ? "cancelled" : record$10(terminal) && terminal.kind === "error" ? "failed" : "unknown"
8115
+ request: event.type === "assistant/message" && successful && source !== void 0 ? "succeeded" : record$9(terminal) && terminal.kind === "aborted" ? "cancelled" : record$9(terminal) && terminal.kind === "error" ? "failed" : "unknown"
7815
8116
  }
7816
8117
  };
7817
8118
  } else if (compact?.state === "running") return state;
@@ -7878,7 +8179,7 @@ const contextEvidenceDefinition = {
7878
8179
  function installContextEvidence(ctx) {
7879
8180
  ctx.inject(["sessionProjections"], (scope) => {
7880
8181
  const registry = scope.get("sessionProjections");
7881
- if (!record$10(registry) || typeof registry.register !== "function") {
8182
+ if (!record$9(registry) || typeof registry.register !== "function") {
7882
8183
  scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
7883
8184
  return;
7884
8185
  }
@@ -8456,182 +8757,6 @@ function planNativeModelSync(input) {
8456
8757
  };
8457
8758
  }
8458
8759
  //#endregion
8459
- //#region lib/types/native-copilot-access.js
8460
- var __rewriteRelativeImportExtension$1 = function(path, preserveJsx) {
8461
- if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
8462
- return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
8463
- });
8464
- return path;
8465
- };
8466
- const NATIVE = "@deepseek-ai/dsh-llm-pi-ai";
8467
- const PI = "@earendil-works/pi-ai";
8468
- const NATIVE_COPILOT = "github-copilot";
8469
- function record$9(value) {
8470
- return value !== null && typeof value === "object" && !Array.isArray(value);
8471
- }
8472
- function plainRecord(value) {
8473
- if (!record$9(value)) return false;
8474
- const prototype = Object.getPrototypeOf(value);
8475
- return prototype === Object.prototype || prototype === null;
8476
- }
8477
- /**
8478
- * Native Config materializes empty template maps at provider, model and override
8479
- * scope. They do not add template values; supportsStrictMode only controls native
8480
- * JSON-schema tool conversion, not the credential, endpoint or model protocol.
8481
- * Qualify these exact shapes without deleting or overriding any native setting.
8482
- */
8483
- function nativeCompat(value) {
8484
- if (value === void 0) return true;
8485
- if (!plainRecord(value)) return false;
8486
- return Reflect.ownKeys(value).every((key) => {
8487
- if (key === "supportsStrictMode") return typeof value[key] === "boolean";
8488
- if (key !== "chatTemplateKwargs" && key !== "chatTemplateArgs") return false;
8489
- const template = value[key];
8490
- return plainRecord(template) && Reflect.ownKeys(template).length === 0;
8491
- });
8492
- }
8493
- function customTransport(value) {
8494
- return !nativeCompat(value.compat) || [
8495
- "apiKeyEnv",
8496
- "baseURL",
8497
- "headers"
8498
- ].some((key) => {
8499
- const field = value[key];
8500
- return field !== void 0 && field !== "" && (!record$9(field) || Object.keys(field).length > 0);
8501
- });
8502
- }
8503
- /** Only the adapter's native catalog and its explicit native narrowing are qualified. */
8504
- function nativeCopilotModels(profile, catalog) {
8505
- if (!record$9(profile) || customTransport(profile) || !Array.isArray(catalog)) return void 0;
8506
- const configured = profile.models;
8507
- if (configured !== void 0 && !Array.isArray(configured)) return void 0;
8508
- if (Array.isArray(configured) && configured.some((value) => !record$9(value) || customTransport(value))) return void 0;
8509
- if (record$9(profile.modelOverrides) && Object.values(profile.modelOverrides).some((value) => !record$9(value) || customTransport(value))) return void 0;
8510
- const ids = Array.isArray(configured) && configured.length > 0 ? new Set(configured.filter(record$9).map((value) => value.id)) : void 0;
8511
- const api = profile.api;
8512
- if (api !== void 0 && api !== "" && api !== "openai-responses" && api !== "openai-completions" && api !== "anthropic-messages") return void 0;
8513
- const models = /* @__PURE__ */ new Map();
8514
- for (const model of catalog) {
8515
- if (!record$9(model) || typeof model.id !== "string" || model.id.length === 0 || model.id !== model.id.trim() || typeof model.api !== "string" || model.api.length === 0 || model.api !== model.api.trim() || models.has(model.id)) return void 0;
8516
- models.set(model.id, {
8517
- id: model.id,
8518
- api: api || model.api
8519
- });
8520
- }
8521
- if (ids !== void 0) {
8522
- for (const id of models.keys()) if (!ids.has(id)) models.delete(id);
8523
- }
8524
- return models;
8525
- }
8526
- function nativeCatalogUrl(manifestPath, exports) {
8527
- if (!record$9(exports)) return void 0;
8528
- const exact = exports["./providers/all"];
8529
- const wildcard = exact === void 0;
8530
- if (wildcard && Object.keys(exports).some((key) => {
8531
- if (key === "./providers/*") return false;
8532
- const parts = key.split("*");
8533
- if (parts.length !== 2) return false;
8534
- const [prefix = "", suffix = ""] = parts;
8535
- return "./providers/all".startsWith(prefix) && "./providers/all".endsWith(suffix) && prefix.length + suffix.length <= 15;
8536
- })) return void 0;
8537
- const descriptor = wildcard ? exports["./providers/*"] : exact;
8538
- const target = typeof descriptor === "string" ? descriptor : record$9(descriptor) && Object.keys(descriptor).every((key) => key === "types" || key === "import") && typeof descriptor.import === "string" ? descriptor.import : void 0;
8539
- if (!target || !/^\.\/(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._*-]+\.m?js$/u.test(target) || target.split("/").slice(1).some((part) => part === "." || part === "..")) return void 0;
8540
- if ([...target].filter((character) => character === "*").length !== (wildcard ? 1 : 0)) return void 0;
8541
- const base = new URL(".", pathToFileURL(manifestPath));
8542
- const url = new URL(wildcard ? target.replace("*", "all") : target, base);
8543
- return url.href.startsWith(base.href) ? url.href : void 0;
8544
- }
8545
- /**
8546
- * Qualify the native Loader root and its exact published pi-ai dependency.
8547
- * No credential, discovery, settings write or private adapter registry access.
8548
- */
8549
- async function captureNativeCopilotCatalog(ctx, diagnose = () => {}) {
8550
- const unproven = (code) => {
8551
- diagnose(code);
8552
- };
8553
- const llm = ctx.get("llm");
8554
- const settings = ctx.get("settings");
8555
- const loader = ctx.get("loader");
8556
- const packages = ctx.get("pluginPackages");
8557
- if (!llm || !settings || !loader || !packages) return unproven("COPILOT_NATIVE_SERVICES_UNAVAILABLE");
8558
- const directory = llm.listConfigurableProviders().find((value) => value.provider === NATIVE_COPILOT);
8559
- if (!directory || directory.declared !== false || directory.error !== void 0 || directory.settingsPath.length !== 2 || directory.settingsPath[0] !== "providers" || directory.settingsPath[1] !== "github-copilot" || directory.nativeAuth?.oauth !== true || !llm.listProviders().some((value) => value.id === "github-copilot")) return unproven("COPILOT_NATIVE_DIRECTORY_UNPROVEN");
8560
- const entries = [...loader.entries()].filter((entry) => entry.options.id === directory.settingsNs);
8561
- if (entries.length !== 1) return unproven("COPILOT_NATIVE_ENTRY_UNPROVEN");
8562
- const entry = entries[0];
8563
- const fiber = entry.fiber?.ctx.fiber;
8564
- const base = entry.parent.tree.ctx.baseUrl;
8565
- if (!fiber || fiber.uid === null || entry.options.name !== NATIVE || !base) return unproven("COPILOT_NATIVE_FIBER_UNPROVEN");
8566
- const owner = packages.packageOf(NATIVE, base);
8567
- const importedOwner = packages.packageOf(NATIVE, import.meta.url);
8568
- if (owner?.version !== "0.2.2-rc.3" || owner.manifestPath !== importedOwner?.manifestPath) return unproven("COPILOT_NATIVE_PACKAGE_UNPROVEN");
8569
- const nativePi = packages.packageOf(PI, pathToFileURL(owner.manifestPath).href);
8570
- const localPi = packages.packageOf(PI, import.meta.url);
8571
- if (nativePi?.name !== PI || nativePi.version !== "1.3.0" || localPi?.name !== PI || localPi.version !== "1.3.0") return unproven("COPILOT_NATIVE_PI_UNPROVEN");
8572
- const ownerPath = owner.manifestPath;
8573
- const nativePiPath = nativePi.manifestPath;
8574
- const localPiPath = localPi.manifestPath;
8575
- const view = () => settings.describe({ redactSecrets: true }).find((value) => value.ns === directory.settingsNs);
8576
- const captured = view();
8577
- if (!captured || !record$9(captured.value) || !record$9(captured.value.providers)) return unproven("COPILOT_NATIVE_SETTINGS_UNPROVEN");
8578
- const catalogUrl = nativeCatalogUrl(nativePiPath, nativePi.manifest.exports);
8579
- if (!catalogUrl) return unproven("COPILOT_NATIVE_CATALOG_UNAVAILABLE");
8580
- let catalog;
8581
- try {
8582
- const nativeModule = await import(__rewriteRelativeImportExtension$1(
8583
- /* @vite-ignore */
8584
- catalogUrl
8585
- ));
8586
- if (!record$9(nativeModule) || typeof nativeModule.getBuiltinModels !== "function") return unproven("COPILOT_NATIVE_CATALOG_UNAVAILABLE");
8587
- catalog = nativeModule.getBuiltinModels(NATIVE_COPILOT);
8588
- } catch {
8589
- return unproven("COPILOT_NATIVE_CATALOG_UNAVAILABLE");
8590
- }
8591
- const nativeCatalog = nativeCopilotModels({}, catalog);
8592
- if (!nativeCatalog) return unproven("COPILOT_NATIVE_MODELS_UNPROVEN");
8593
- const configuredModels = nativeCopilotModels(captured.value.providers[NATIVE_COPILOT], catalog);
8594
- const module = await import("@deepseek-ai/dsh-llm-pi-ai");
8595
- const current = () => {
8596
- const currentLlm = ctx.get("llm");
8597
- const currentSettings = ctx.get("settings");
8598
- const currentLoader = ctx.get("loader");
8599
- const currentPackages = ctx.get("pluginPackages");
8600
- if (!currentLlm || !currentSettings || !currentLoader || !currentPackages) return false;
8601
- const currentEntries = [...currentLoader.entries()].filter((value) => value.options.id === directory.settingsNs);
8602
- if (currentEntries.length !== 1 || currentEntries[0] !== entry) return false;
8603
- const currentDirectory = currentLlm.listConfigurableProviders().find((value) => value.provider === NATIVE_COPILOT);
8604
- if (!currentDirectory || currentDirectory.declared !== false || currentDirectory.error !== void 0 || currentDirectory.settingsNs !== directory.settingsNs || currentDirectory.settingsPath.length !== 2 || currentDirectory.settingsPath[0] !== "providers" || currentDirectory.settingsPath[1] !== "github-copilot" || currentDirectory.nativeAuth?.oauth !== true) return false;
8605
- const nativeOwner = currentPackages.packageOf(NATIVE, base);
8606
- const importedOwner = currentPackages.packageOf(NATIVE, import.meta.url);
8607
- const nativeCatalog = currentPackages.packageOf(PI, pathToFileURL(ownerPath).href);
8608
- const pluginCatalog = currentPackages.packageOf(PI, import.meta.url);
8609
- return fiber.uid !== null && entry.fiber?.ctx.fiber === fiber && fiber.runtime?.callback === module.apply && entry.options.name === NATIVE && currentSettings.describe({ redactSecrets: true }).find((value) => value.ns === directory.settingsNs)?.revision === captured.revision && nativeOwner?.manifestPath === ownerPath && nativeOwner.version === "0.2.2-rc.3" && importedOwner?.manifestPath === ownerPath && importedOwner.version === "0.2.2-rc.3" && nativeCatalog?.manifestPath === nativePiPath && nativeCatalog.version === "1.3.0" && pluginCatalog?.manifestPath === localPiPath && pluginCatalog.version === "1.3.0" && currentLlm.listProviders().some((value) => value.id === "github-copilot");
8610
- };
8611
- if (!current()) return unproven("COPILOT_NATIVE_SNAPSHOT_REVOKED");
8612
- return {
8613
- catalog: nativeCatalog,
8614
- configuredModels,
8615
- namespace: directory.settingsNs,
8616
- assertCurrent() {
8617
- if (!current()) throw new Error("COPILOT_NATIVE_ROUTE_CHANGED");
8618
- }
8619
- };
8620
- }
8621
- async function captureNativeCopilot(ctx, diagnose = () => {}) {
8622
- const snapshot = await captureNativeCopilotCatalog(ctx, diagnose);
8623
- if (snapshot === void 0) return void 0;
8624
- if (snapshot.configuredModels === void 0) {
8625
- diagnose("COPILOT_NATIVE_MODELS_UNPROVEN");
8626
- return;
8627
- }
8628
- return {
8629
- models: snapshot.configuredModels,
8630
- namespace: snapshot.namespace,
8631
- assertCurrent: snapshot.assertCurrent
8632
- };
8633
- }
8634
- //#endregion
8635
8760
  //#region lib/types/authorization-controller.js
8636
8761
  /**
8637
8762
  * Host-side bridge between the Models-page companion UI and DSH's neutral
@@ -13289,6 +13414,8 @@ function activate(ctx, config) {
13289
13414
  new SessionAccountController(scope, sessionAccounts);
13290
13415
  } });
13291
13416
  const accountTurns = /* @__PURE__ */ new Map();
13417
+ const nativePreSteps = /* @__PURE__ */ new WeakMap();
13418
+ ctx.on("credentials/record-updated", (key) => sessionAccounts.credentialChanged(key));
13292
13419
  ctx.on("session/event", (session, event) => {
13293
13420
  if (event.type !== "turn/end") return;
13294
13421
  accountTurns.get(session.id)?.release();
@@ -13305,6 +13432,7 @@ function activate(ctx, config) {
13305
13432
  return ctx.get("githubCopilotAccounts")?.host.acquire(signal, true, binding.accountId);
13306
13433
  };
13307
13434
  ctx.on("agent/pre-step", async (payload, next) => {
13435
+ nativePreSteps.delete(payload.signal);
13308
13436
  if (Object.hasOwn(payload, "modelSelection")) {
13309
13437
  const selection = Reflect.get(payload, "modelSelection");
13310
13438
  if (typeof selection !== "object" || selection === null) throw new Error("COPILOT_PRE_STEP_MODEL_SELECTION_INVALID");
@@ -13312,9 +13440,15 @@ function activate(ctx, config) {
13312
13440
  const model = Reflect.get(selection, "model");
13313
13441
  if (typeof provider !== "string" || provider.length === 0 || typeof model !== "string" || model.length === 0) throw new Error("COPILOT_PRE_STEP_MODEL_SELECTION_INVALID");
13314
13442
  if (provider === "github-copilot-preview") sessionAccounts.admit(payload.agent, payload.turn, payload.signal);
13315
- else if (provider === "github-copilot" && !accountTurns.has(payload.agent.session.id)) {
13316
- const lease = ctx.get("githubCopilotAccounts")?.host.acquire(payload.signal, false);
13317
- if (lease) accountTurns.set(payload.agent.session.id, lease);
13443
+ else if (provider === "github-copilot") {
13444
+ nativePreSteps.set(payload.signal, {
13445
+ session: payload.agent.session,
13446
+ turn: payload.turn
13447
+ });
13448
+ if (!accountTurns.has(payload.agent.session.id)) {
13449
+ const lease = ctx.get("githubCopilotAccounts")?.host.acquire(payload.signal, false);
13450
+ if (lease) accountTurns.set(payload.agent.session.id, lease);
13451
+ }
13318
13452
  }
13319
13453
  }
13320
13454
  return next();
@@ -13323,13 +13457,18 @@ function activate(ctx, config) {
13323
13457
  const projections = ctx.get("sessionProjections");
13324
13458
  const state = typeof projections === "object" && projections !== null && "stateOf" in projections && typeof projections.stateOf === "function" ? Reflect.apply(projections.stateOf, projections, [agent.session, "modelSelection"]) : void 0;
13325
13459
  const pending = typeof state === "object" && state !== null && "pending" in state ? state.pending : void 0;
13326
- const selectedProvider = (typeof pending === "object" && pending !== null && "provider" in pending ? pending.provider : void 0) ?? agent.session.requestHeader()?.config.provider;
13460
+ const pendingProvider = typeof pending === "object" && pending !== null && "provider" in pending ? pending.provider : void 0;
13461
+ const nativePreStep = nativePreSteps.get(signal);
13462
+ const selectedProvider = nativePreStep?.session === agent.session && nativePreStep.turn === turn ? GITHUB_COPILOT_PROVIDER_ID : pendingProvider ?? agent.session.requestHeader()?.config.provider;
13327
13463
  const managedRequest = selectedProvider === "github-copilot-preview" || sessionAccounts.turns.current(agent.session) !== void 0;
13328
13464
  const nativeRequest = selectedProvider === GITHUB_COPILOT_PROVIDER_ID;
13329
13465
  if (!managedRequest && !nativeRequest) return next();
13330
13466
  if (nativeRequest && accountTurns.has(agent.session.id)) {
13331
- accountTurns.get(agent.session.id)?.binding.assertCurrent();
13332
- return next();
13467
+ const binding = accountTurns.get(agent.session.id)?.binding;
13468
+ binding?.assertCurrent();
13469
+ const result = await next();
13470
+ if (binding && result.provider === "github-copilot" && !signal.aborted) sessionAccounts.admitNative(agent, turn, signal, binding.accountId, result.model);
13471
+ return result;
13333
13472
  }
13334
13473
  if (managedRequest) sessionAccounts.admit(agent, turn, signal);
13335
13474
  const lease = managedRequest ? acquireAccount(signal) : ctx.get("githubCopilotAccounts")?.host.acquire(signal, false);
@@ -13337,6 +13476,7 @@ function activate(ctx, config) {
13337
13476
  try {
13338
13477
  const result = await next();
13339
13478
  lease?.binding.assertCurrent();
13479
+ if (nativeRequest && lease && result.provider === "github-copilot" && !signal.aborted) sessionAccounts.admitNative(agent, turn, signal, lease.binding.accountId, result.model);
13340
13480
  if (lease && (result.provider === "github-copilot-preview" || result.provider === "github-copilot") && !signal.aborted) {
13341
13481
  accountTurns.get(agent.session.id)?.release();
13342
13482
  accountTurns.set(agent.session.id, lease);
@@ -13347,6 +13487,21 @@ function activate(ctx, config) {
13347
13487
  if (!retained) lease?.release();
13348
13488
  }
13349
13489
  }, { prepend: true });
13490
+ ctx.on("llm/stream", (options, next) => {
13491
+ const stream = next();
13492
+ const { signal, sessionId } = options;
13493
+ if (options.provider !== "github-copilot" || signal === void 0 || sessionId === void 0 || options.purpose !== void 0 || !isAgentLoopRequest(options)) return stream;
13494
+ return (async function* () {
13495
+ let recorded = false;
13496
+ for await (const chunk of stream) {
13497
+ if (!recorded) {
13498
+ recorded = true;
13499
+ sessionAccounts.recordNativeRequest(signal, sessionId, options.model);
13500
+ }
13501
+ yield chunk;
13502
+ }
13503
+ })();
13504
+ });
13350
13505
  ctx.effect(() => () => {
13351
13506
  for (const lease of accountTurns.values()) lease.release();
13352
13507
  accountTurns.clear();
@@ -1,8 +1,8 @@
1
1
  import "./copilot-identity-BpfZQOip.js";
2
2
  import { d as diagnosticsOutcome, f as diagnosticsReason } from "./diagnostics-types-o02ogaiI.js";
3
3
  import { i as resolveRequestBudgetPolicy, r as calculateRequestBudget } from "./request-budget-DLY_aRq0.js";
4
- import z from "@deepseek-ai/schemastery";
5
4
  import { LlmError, createUserMessage } from "@deepseek-ai/dsh-llm";
5
+ import z from "@deepseek-ai/schemastery";
6
6
  import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
7
7
  import { CommandDefinitionId } from "@deepseek-ai/dsh-commands/brand";
8
8
  //#region lib/types/background-compaction.js
package/lib/routed-web.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./copilot-identity-BpfZQOip.js";
2
- import { a as currentSearchSelection, i as currentSearchInitiator, s as isPluginPreviewProvider } from "./traditional-search-DP4tbmsO.js";
2
+ import { a as currentSearchSelection, i as currentSearchInitiator, s as isPluginPreviewProvider } from "./traditional-search-6Gf2GmQW.js";
3
3
  import { WebError, WebRuntime } from "@deepseek-ai/dsh-web";
4
4
  //#region lib/types/search-routing.js
5
5
  /** Match only the canonical route or a verified plugin-owned managed route. */
@@ -15,11 +15,22 @@ interface SessionOwner {
15
15
  /** Host-only routing owner; credentials remain in the existing account service. */
16
16
  export declare class SessionAccountsHost {
17
17
  private readonly ctx;
18
+ private readonly history;
18
19
  readonly turns: SessionAccountTurns;
20
+ private readonly nativeAccountTurns;
19
21
  private readonly leases;
22
+ private readonly nativeTurns;
23
+ private readonly nativeSignals;
20
24
  constructor(ctx: Context);
21
25
  selected(agent: SessionOwner): SessionAccountSelection;
22
26
  admit(agent: SessionOwner, turn: number, signal: AbortSignal): CopilotAccountBinding;
27
+ admitNative(agent: SessionOwner, turn: number, signal: AbortSignal, accountId: string, model: string): void;
28
+ private nativeCurrent;
29
+ private invalidateNative;
30
+ private qualifyNative;
31
+ private recordNativeEvidence;
32
+ recordNativeRequest(signal: AbortSignal, sessionId: string, model: string): void;
33
+ credentialChanged(key: string): void;
23
34
  end(session: object, turn: number): void;
24
35
  remove(session: object): void;
25
36
  dispose(): void;
@@ -19,10 +19,11 @@ export declare function parseSessionAccounts(value: unknown): readonly SessionAc
19
19
  export declare function resolveSessionAccount(sessionId: string, preferences: readonly SessionAccountPreference[], globalAccountId: string): SessionAccountSelection;
20
20
  /** Active turns are never evicted; bounded historical evidence may become unknown. */
21
21
  export declare class SessionAccountTurns {
22
+ private readonly history;
22
23
  private readonly active;
23
24
  private readonly signals;
24
25
  private readonly identities;
25
- private readonly history;
26
+ constructor(history?: Map<object, Map<number, TurnAccountEvidence>>);
26
27
  admit(agent: object, turn: number, signal: AbortSignal, selection: SessionAccountSelection): Admission;
27
28
  record(agent: object, turn: number, identity?: CopilotAccountIdentity): void;
28
29
  current(agent: object): Admission | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-github-copilot",
3
3
  "description": "Account-aware GitHub Copilot models for DeepSeek Harness through its published native adapter.",
4
- "version": "0.1.0-alpha.15.dsh.0.2.2.rc.3",
4
+ "version": "0.1.0-alpha.16.dsh.0.2.2.rc.3",
5
5
  "releaseNotes": "CHANGELOG.md",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -1,8 +1,8 @@
1
1
  import "./copilot-identity-BpfZQOip.js";
2
+ import "@deepseek-ai/dsh-llm";
2
3
  import "@earendil-works/pi-ai";
3
4
  import "@earendil-works/pi-ai/providers/all";
4
5
  import { WebError } from "@deepseek-ai/dsh-web";
5
- import "@deepseek-ai/dsh-llm";
6
6
  //#region lib/types/model-protocol.js
7
7
  /** Scope optional preview contributions to this plugin's successfully mounted route service. */
8
8
  function isPluginPreviewProvider(ctx, provider) {