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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1646,9 +1646,208 @@ let GitHubCopilotUsageController = (() => {
1646
1646
  };
1647
1647
  })();
1648
1648
  //#endregion
1649
+ //#region lib/types/context-usage-guard.js
1650
+ /** All observed counters are zero, not proof that an attempted prompt was empty. */
1651
+ function isZeroContextUsage(usage) {
1652
+ return usage.inputTokens === 0 && usage.outputTokens === 0 && (usage.cacheReadTokens ?? 0) === 0 && (usage.cacheWriteTokens ?? 0) === 0 && (usage.totalTokens ?? 0) === 0 && (usage.reasoningTokens ?? 0) === 0;
1653
+ }
1654
+ /**
1655
+ * Native pi-ai emits terminal usage immediately before finish, including a
1656
+ * default zero sample when no provider usage arrived. Delay only that sample;
1657
+ * failed, cancelled or truncated attempts must not reset Core's last reading.
1658
+ */
1659
+ async function* guardContextUsage(stream) {
1660
+ let pending;
1661
+ for await (const chunk of stream) {
1662
+ if (pending !== void 0) {
1663
+ if (chunk.type !== "finish" || chunk.reason.kind !== "error" && chunk.reason.kind !== "aborted") yield pending;
1664
+ pending = void 0;
1665
+ }
1666
+ if (chunk.type === "usage" && isZeroContextUsage(chunk.usage)) pending = chunk;
1667
+ else yield chunk;
1668
+ }
1669
+ }
1670
+ //#endregion
1671
+ //#region lib/types/context-evidence.js
1672
+ const COPILOT_CONTEXT_EVIDENCE = "githubCopilotContextEvidence";
1673
+ const count = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
1674
+ const routeSchema = z$1.object({
1675
+ provider: z$1.string().min(1),
1676
+ model: z$1.string().min(1)
1677
+ }).strict();
1678
+ const sampleSchema = z$1.object({
1679
+ tokens: count,
1680
+ seq: count,
1681
+ route: routeSchema
1682
+ }).strict();
1683
+ const ContextEvidenceSchema = z$1.object({
1684
+ route: routeSchema.nullable(),
1685
+ sample: sampleSchema.nullable(),
1686
+ invalid: z$1.boolean(),
1687
+ reason: z$1.enum([
1688
+ "none",
1689
+ "failed-zero",
1690
+ "compaction",
1691
+ "selection",
1692
+ "unknown"
1693
+ ])
1694
+ }).strict();
1695
+ const usageSchema = z$1.object({
1696
+ inputTokens: count,
1697
+ outputTokens: count,
1698
+ cacheReadTokens: count.optional(),
1699
+ cacheWriteTokens: count.optional(),
1700
+ totalTokens: count.optional(),
1701
+ reasoningTokens: count.optional()
1702
+ });
1703
+ function record$4(value) {
1704
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1705
+ }
1706
+ function sameRoute$1(left, right) {
1707
+ return left !== null && right !== null && left.provider === right.provider && left.model === right.model;
1708
+ }
1709
+ function copilot(route) {
1710
+ return route?.provider === "github-copilot" || route?.provider === "github-copilot-preview";
1711
+ }
1712
+ function initialContextEvidence() {
1713
+ return {
1714
+ route: null,
1715
+ sample: null,
1716
+ invalid: false,
1717
+ reason: "none"
1718
+ };
1719
+ }
1720
+ /** Read only counts and routing leaves; never message content or opaque replay. */
1721
+ function foldContextEvidence(state, event) {
1722
+ if (!record$4(event) || typeof event.type !== "string" || !record$4(event.data)) return state;
1723
+ if (event.type === "request/header" || event.type === "model/selection") {
1724
+ const raw = event.type === "request/header" ? record$4(event.data.header) ? event.data.header.config : void 0 : event.data;
1725
+ if (!record$4(raw)) return {
1726
+ ...state,
1727
+ route: null,
1728
+ sample: null,
1729
+ invalid: true,
1730
+ reason: "unknown"
1731
+ };
1732
+ const parsed = routeSchema.safeParse({
1733
+ provider: raw.provider,
1734
+ model: raw.model
1735
+ });
1736
+ if (!parsed.success) return {
1737
+ ...state,
1738
+ route: null,
1739
+ sample: null,
1740
+ invalid: true,
1741
+ reason: "unknown"
1742
+ };
1743
+ const route = parsed.data;
1744
+ if (sameRoute$1(state.route, route)) return state;
1745
+ return {
1746
+ ...state,
1747
+ route,
1748
+ sample: null,
1749
+ reason: "selection"
1750
+ };
1751
+ }
1752
+ if (event.type.startsWith("compaction/") || event.surfaceOp !== void 0 && event.surfaceOp !== "append") {
1753
+ if (state.sample === null) return state;
1754
+ return {
1755
+ ...state,
1756
+ sample: null,
1757
+ reason: "compaction"
1758
+ };
1759
+ }
1760
+ if (event.type !== "assistant/message" && event.type !== "assistant/attempt") return state;
1761
+ if (!copilot(state.route)) return state;
1762
+ if (event.type === "assistant/message" && event.data.source !== void 0) {
1763
+ const source = event.data.source;
1764
+ const parsed = routeSchema.safeParse(record$4(source) ? {
1765
+ provider: source.provider,
1766
+ model: source.model
1767
+ } : source);
1768
+ if (!parsed.success || !sameRoute$1(state.route, parsed.data)) return {
1769
+ ...state,
1770
+ sample: null,
1771
+ invalid: true,
1772
+ reason: "unknown"
1773
+ };
1774
+ }
1775
+ const stream = Array.isArray(event.data.stream) ? event.data.stream : [];
1776
+ let usage = event.type === "assistant/message" ? event.data.usage : void 0;
1777
+ const settledUsage = usage !== void 0;
1778
+ let terminal;
1779
+ for (const entry of stream) {
1780
+ if (!record$4(entry) || entry.type !== "chunk" || !record$4(entry.chunk)) continue;
1781
+ if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
1782
+ if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
1783
+ }
1784
+ if (usage === void 0) return state;
1785
+ const parsed = usageSchema.safeParse(usage);
1786
+ if (!parsed.success || !count.safeParse(event.seq).success) return {
1787
+ ...state,
1788
+ sample: null,
1789
+ invalid: true,
1790
+ reason: "unknown"
1791
+ };
1792
+ const value = parsed.data;
1793
+ const zero = isZeroContextUsage(value);
1794
+ const successful = record$4(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
1795
+ if (zero && !successful) {
1796
+ const reason = state.sample !== null || state.reason === "none" ? "failed-zero" : state.reason;
1797
+ return {
1798
+ ...state,
1799
+ invalid: true,
1800
+ reason
1801
+ };
1802
+ }
1803
+ const tokens = value.inputTokens + (value.cacheReadTokens ?? 0) + (value.cacheWriteTokens ?? 0);
1804
+ if (!Number.isSafeInteger(tokens) || state.route === null) return {
1805
+ ...state,
1806
+ sample: null,
1807
+ invalid: true,
1808
+ reason: "unknown"
1809
+ };
1810
+ return {
1811
+ ...state,
1812
+ sample: {
1813
+ tokens,
1814
+ seq: count.parse(event.seq),
1815
+ route: state.route
1816
+ },
1817
+ invalid: false,
1818
+ reason: "none"
1819
+ };
1820
+ }
1821
+ /** Separate bounded replay unit; never register under or modify a Core key. */
1822
+ const contextEvidenceDefinition = {
1823
+ key: COPILOT_CONTEXT_EVIDENCE,
1824
+ stateVersion: 1,
1825
+ stateSchema: ContextEvidenceSchema,
1826
+ init: initialContextEvidence,
1827
+ apply: foldContextEvidence,
1828
+ wire: {
1829
+ viewSchema: ContextEvidenceSchema,
1830
+ view: (state) => state
1831
+ }
1832
+ };
1833
+ function installContextEvidence(ctx) {
1834
+ ctx.inject(["sessionProjections"], (scope) => {
1835
+ const registry = scope.get("sessionProjections");
1836
+ if (!record$4(registry) || typeof registry.register !== "function") {
1837
+ scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
1838
+ return;
1839
+ }
1840
+ const remove = registry.register(contextEvidenceDefinition);
1841
+ if (typeof remove !== "function") throw new Error("COPILOT_CONTEXT_PROJECTION_DISPOSER_UNAVAILABLE");
1842
+ return () => {
1843
+ remove();
1844
+ };
1845
+ });
1846
+ }
1847
+ //#endregion
1649
1848
  //#region package.json
1650
1849
  var name$1 = "dsh-github-copilot";
1651
- var version = "0.4.0-alpha.72";
1850
+ var version = "0.4.0-alpha.74";
1652
1851
  //#endregion
1653
1852
  //#region lib/types/probe.js
1654
1853
  /**
@@ -7491,7 +7690,7 @@ var PreviewAdapter = class extends PiAiAdapter {
7491
7690
  }
7492
7691
  guardedStream(lease, options) {
7493
7692
  const owner = this;
7494
- return (async function* () {
7693
+ return guardContextUsage((async function* () {
7495
7694
  owner.lifetime.start(lease);
7496
7695
  owned(options.provider);
7497
7696
  if (options.model !== lease.descriptor.id) throw failure("COPILOT_PREVIEW_MODEL_MISMATCH");
@@ -7561,7 +7760,7 @@ var PreviewAdapter = class extends PiAiAdapter {
7561
7760
  if (cause instanceof LlmError && cause.code === "UNKNOWN_MODEL") await owner.refreshRejected(lease.snapshot, signal);
7562
7761
  throw requestFailure ?? cause;
7563
7762
  }
7564
- })();
7763
+ })());
7565
7764
  }
7566
7765
  excludedModels() {
7567
7766
  return excludedModelSet(this.accountModelSettings().excludedModelIds);
@@ -8009,6 +8208,7 @@ function observeSettingsNamespace(ctx, namespace, config, hooks) {
8009
8208
  */
8010
8209
  function apply(ctx, config) {
8011
8210
  installCopilotToolSchemaCompatibility(ctx);
8211
+ installContextEvidence(ctx);
8012
8212
  let promptText = () => "";
8013
8213
  ctx.on("system-prompt/assemble", async (_assembly, _context, next) => {
8014
8214
  const owner = currentSearchInitiator(ctx);
@@ -2,6 +2,156 @@ import "./copilot-identity-DRZY_d2X.js";
2
2
  import { i as resolveRequestBudgetPolicy, r as calculateRequestBudget } from "./request-budget-DLY_aRq0.js";
3
3
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
4
4
  import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
5
+ import { CommandDefinitionId } from "@deepseek-ai/dsh-commands/brand";
6
+ //#region lib/types/background-compaction.js
7
+ const WAIT_MS = 2147483647;
8
+ const USAGE = "Usage: /copilot-compact [status|cancel]";
9
+ const FAILED = "COPILOT_BACKGROUND_COMPACTION_FAILED: inspect the native compaction/end record; no success is implied.";
10
+ /** Own only admission and job lifetime; the selected engine owns all history transactions. */
11
+ var BackgroundCompaction = class {
12
+ jobs;
13
+ compact;
14
+ warn;
15
+ latest = /* @__PURE__ */ new WeakMap();
16
+ active = /* @__PURE__ */ new Map();
17
+ closed = false;
18
+ constructor(jobs, compact, warn) {
19
+ this.jobs = jobs;
20
+ this.compact = compact;
21
+ this.warn = warn;
22
+ }
23
+ execute(agent, rawInput, signal) {
24
+ if (this.closed) return {
25
+ kind: "error",
26
+ text: "COPILOT_BACKGROUND_COMPACTION_DISPOSED"
27
+ };
28
+ if (signal.aborted) return {
29
+ kind: "error",
30
+ text: "Compaction admission cancelled."
31
+ };
32
+ const action = rawInput.trim();
33
+ if (action !== "" && action !== "status" && action !== "cancel") return {
34
+ kind: "error",
35
+ text: USAGE
36
+ };
37
+ const id = this.latest.get(agent);
38
+ if (action !== "") {
39
+ if (id === void 0) return {
40
+ kind: "error",
41
+ text: "No background compaction job for this Session."
42
+ };
43
+ try {
44
+ if (action === "cancel") return {
45
+ kind: "success",
46
+ text: `${id}: cancellation ${this.jobs.kill(id, agent.id)}.`
47
+ };
48
+ const job = this.jobs.get(id, agent.id);
49
+ return {
50
+ kind: "success",
51
+ text: `${id}: ${job.status}${job.detail ? `; ${job.detail}` : ""}`
52
+ };
53
+ } catch {
54
+ return {
55
+ kind: "error",
56
+ text: "COPILOT_BACKGROUND_COMPACTION_JOB_UNAVAILABLE"
57
+ };
58
+ }
59
+ }
60
+ const existing = this.active.get(agent);
61
+ if (existing !== void 0) return {
62
+ kind: "success",
63
+ text: `${existing.id}: already running; use /copilot-compact status or cancel.`
64
+ };
65
+ const cancel = new AbortController();
66
+ let done;
67
+ try {
68
+ const jobId = this.jobs.start({
69
+ kind: "copilot-compaction",
70
+ label: "Manual Copilot context compaction",
71
+ owner: agent.id,
72
+ run: (job) => {
73
+ job.updateProgress("Compacting context; the original history remains until native commit.");
74
+ done = Promise.resolve().then(async () => {
75
+ try {
76
+ cancel.signal.throwIfAborted();
77
+ const result = await this.compact(agent, cancel.signal);
78
+ return {
79
+ status: "completed",
80
+ detail: result === null ? "No compactable history." : `Compacted ${result.shadowedSeqs.length} history items (~${result.shadowedTokenCount} tokens).`
81
+ };
82
+ } catch {
83
+ if (cancel.signal.aborted) return {
84
+ status: "killed",
85
+ detail: "Compaction cancelled; inspect native history for its transaction outcome."
86
+ };
87
+ this.warn(FAILED);
88
+ return {
89
+ status: "failed",
90
+ detail: FAILED
91
+ };
92
+ } finally {
93
+ this.active.delete(agent);
94
+ }
95
+ });
96
+ return {
97
+ cancel: () => {
98
+ cancel.abort();
99
+ },
100
+ done
101
+ };
102
+ }
103
+ });
104
+ if (done === void 0) throw new Error("COPILOT_BACKGROUND_COMPACTION_STARTER_MISSING");
105
+ this.active.set(agent, {
106
+ id: jobId,
107
+ cancel,
108
+ done
109
+ });
110
+ this.latest.set(agent, jobId);
111
+ this.jobs.wait(jobId, WAIT_MS, agent.id).then((view) => {
112
+ if (view.status === "running" || view.status === "stopping") {
113
+ this.warn("COPILOT_BACKGROUND_COMPACTION_OBSERVER_EXPIRED");
114
+ cancel.abort();
115
+ }
116
+ }, () => {
117
+ this.warn("COPILOT_BACKGROUND_COMPACTION_OBSERVER_FAILED");
118
+ cancel.abort();
119
+ });
120
+ return {
121
+ kind: "success",
122
+ text: `${jobId}: background compaction started, not completed. Use /copilot-compact status or /copilot-compact cancel.`
123
+ };
124
+ } catch {
125
+ cancel.abort();
126
+ this.warn("COPILOT_BACKGROUND_COMPACTION_ADMISSION_FAILED");
127
+ return {
128
+ kind: "error",
129
+ text: "COPILOT_BACKGROUND_COMPACTION_ADMISSION_FAILED: jobs and a live Session owner are required."
130
+ };
131
+ }
132
+ }
133
+ async dispose() {
134
+ this.closed = true;
135
+ const work = [...this.active.values()];
136
+ for (const entry of work) entry.cancel.abort();
137
+ await Promise.all(work.map((entry) => entry.done));
138
+ }
139
+ };
140
+ function installBackgroundCompaction(ctx, compact) {
141
+ const controller = new BackgroundCompaction(ctx.jobs, compact, (message) => ctx.logger.warn(message));
142
+ ctx.effect(function* () {
143
+ yield () => controller.dispose();
144
+ yield ctx.jobs.attachController("copilot-background-compaction");
145
+ yield ctx.commands.register({
146
+ definitionId: CommandDefinitionId("dsh-github-copilot/background-compaction"),
147
+ name: "copilot-compact",
148
+ description: "Start background manual compaction, inspect status, or cancel",
149
+ input: { hint: "status | cancel (omit to start)" },
150
+ handler: (invocation) => controller.execute(invocation.agent, invocation.rawInput, invocation.signal)
151
+ });
152
+ }, "Copilot background compaction");
153
+ }
154
+ //#endregion
5
155
  //#region lib/types/manual-compaction-recovery.js
6
156
  function recoverError(code) {
7
157
  return /* @__PURE__ */ new Error(`COPILOT_MANUAL_RECOVERY_${code}`);
@@ -95,6 +245,12 @@ async function summarizeOversizedManualInput(options) {
95
245
  */
96
246
  var CopilotManualRecoveryCompactionEngine = class extends BasicCompactionEngine {
97
247
  manual = /* @__PURE__ */ new WeakMap();
248
+ constructor(ctx, config = {}) {
249
+ super(ctx, config);
250
+ ctx.inject(["commands", "jobs"], (scope) => {
251
+ installBackgroundCompaction(scope, (agent, signal) => this.compactNow(agent, signal));
252
+ });
253
+ }
98
254
  async compactNow(agent, signal, sourceCommandId) {
99
255
  this.manual.set(agent, (this.manual.get(agent) ?? 0) + 1);
100
256
  try {
@@ -0,0 +1,30 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { Agent } from '@deepseek-ai/dsh-agent';
3
+ import type { CommandResult } from '@deepseek-ai/dsh-commands';
4
+ import type { CompactionResult } from '@deepseek-ai/dsh-compaction';
5
+ import type { JobRegistry } from '@deepseek-ai/dsh-jobs';
6
+ import type { SessionId } from '@deepseek-ai/dsh-session';
7
+ declare module '@deepseek-ai/dsh-jobs/view' {
8
+ interface JobKindMap {
9
+ 'copilot-compaction': 'copilot-compaction';
10
+ }
11
+ }
12
+ type Jobs = Pick<JobRegistry, 'start' | 'get' | 'wait' | 'kill'>;
13
+ type Result = Pick<CompactionResult, 'shadowedSeqs' | 'shadowedTokenCount'> | null;
14
+ /** Own only admission and job lifetime; the selected engine owns all history transactions. */
15
+ export declare class BackgroundCompaction<A extends {
16
+ readonly id: SessionId;
17
+ }> {
18
+ private readonly jobs;
19
+ private readonly compact;
20
+ private readonly warn;
21
+ private readonly latest;
22
+ private readonly active;
23
+ private closed;
24
+ constructor(jobs: Jobs, compact: (agent: A, signal: AbortSignal) => Promise<Result>, warn: (message: string) => void);
25
+ execute(agent: A, rawInput: string, signal: AbortSignal): CommandResult;
26
+ dispose(): Promise<void>;
27
+ }
28
+ export declare function installBackgroundCompaction(ctx: Context, compact: (agent: Agent, signal: AbortSignal) => Promise<CompactionResult | null>): void;
29
+ export {};
30
+ //# sourceMappingURL=background-compaction.d.ts.map
@@ -0,0 +1,11 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { ReactElement } from 'react';
3
+ import type { ContextEvidence } from './context-evidence.ts';
4
+ export declare function ContextEvidenceNotice({ evidence, locale, applicable }: {
5
+ evidence: ContextEvidence | undefined;
6
+ locale?: string;
7
+ applicable?: boolean;
8
+ }): ReactElement | null;
9
+ /** Additive disclosure only: native input, context ring and billing remain untouched. */
10
+ export declare function registerContextEvidenceUi(ctx: Context): () => void;
11
+ //# sourceMappingURL=context-evidence-ui.d.ts.map
@@ -0,0 +1,108 @@
1
+ import { z } from 'zod';
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ export declare const COPILOT_CONTEXT_EVIDENCE = "githubCopilotContextEvidence";
4
+ export declare const ContextEvidenceSchema: z.ZodObject<{
5
+ route: z.ZodNullable<z.ZodObject<{
6
+ provider: z.ZodString;
7
+ model: z.ZodString;
8
+ }, z.core.$strict>>;
9
+ sample: z.ZodNullable<z.ZodObject<{
10
+ tokens: z.ZodNumber;
11
+ seq: z.ZodNumber;
12
+ route: z.ZodObject<{
13
+ provider: z.ZodString;
14
+ model: z.ZodString;
15
+ }, z.core.$strict>;
16
+ }, z.core.$strict>>;
17
+ invalid: z.ZodBoolean;
18
+ reason: z.ZodEnum<{
19
+ none: "none";
20
+ compaction: "compaction";
21
+ unknown: "unknown";
22
+ selection: "selection";
23
+ "failed-zero": "failed-zero";
24
+ }>;
25
+ }, z.core.$strict>;
26
+ export type ContextEvidence = z.infer<typeof ContextEvidenceSchema>;
27
+ declare module '@deepseek-ai/dsh-session-projection/types' {
28
+ interface SessionProjectionMap {
29
+ githubCopilotContextEvidence: ContextEvidence;
30
+ }
31
+ interface SessionProjectionStateMap {
32
+ githubCopilotContextEvidence: ContextEvidence;
33
+ }
34
+ }
35
+ export declare function initialContextEvidence(): ContextEvidence;
36
+ /** Read only counts and routing leaves; never message content or opaque replay. */
37
+ export declare function foldContextEvidence(state: ContextEvidence, event: unknown): ContextEvidence;
38
+ /** Separate bounded replay unit; never register under or modify a Core key. */
39
+ export declare const contextEvidenceDefinition: {
40
+ key: "githubCopilotContextEvidence";
41
+ stateVersion: number;
42
+ stateSchema: z.ZodObject<{
43
+ route: z.ZodNullable<z.ZodObject<{
44
+ provider: z.ZodString;
45
+ model: z.ZodString;
46
+ }, z.core.$strict>>;
47
+ sample: z.ZodNullable<z.ZodObject<{
48
+ tokens: z.ZodNumber;
49
+ seq: z.ZodNumber;
50
+ route: z.ZodObject<{
51
+ provider: z.ZodString;
52
+ model: z.ZodString;
53
+ }, z.core.$strict>;
54
+ }, z.core.$strict>>;
55
+ invalid: z.ZodBoolean;
56
+ reason: z.ZodEnum<{
57
+ none: "none";
58
+ compaction: "compaction";
59
+ unknown: "unknown";
60
+ selection: "selection";
61
+ "failed-zero": "failed-zero";
62
+ }>;
63
+ }, z.core.$strict>;
64
+ init: typeof initialContextEvidence;
65
+ apply: typeof foldContextEvidence;
66
+ wire: {
67
+ viewSchema: z.ZodObject<{
68
+ route: z.ZodNullable<z.ZodObject<{
69
+ provider: z.ZodString;
70
+ model: z.ZodString;
71
+ }, z.core.$strict>>;
72
+ sample: z.ZodNullable<z.ZodObject<{
73
+ tokens: z.ZodNumber;
74
+ seq: z.ZodNumber;
75
+ route: z.ZodObject<{
76
+ provider: z.ZodString;
77
+ model: z.ZodString;
78
+ }, z.core.$strict>;
79
+ }, z.core.$strict>>;
80
+ invalid: z.ZodBoolean;
81
+ reason: z.ZodEnum<{
82
+ none: "none";
83
+ compaction: "compaction";
84
+ unknown: "unknown";
85
+ selection: "selection";
86
+ "failed-zero": "failed-zero";
87
+ }>;
88
+ }, z.core.$strict>;
89
+ view: (state: ContextEvidence) => {
90
+ route: {
91
+ provider: string;
92
+ model: string;
93
+ } | null;
94
+ sample: {
95
+ tokens: number;
96
+ seq: number;
97
+ route: {
98
+ provider: string;
99
+ model: string;
100
+ };
101
+ } | null;
102
+ invalid: boolean;
103
+ reason: "none" | "compaction" | "unknown" | "selection" | "failed-zero";
104
+ };
105
+ };
106
+ };
107
+ export declare function installContextEvidence(ctx: Context): void;
108
+ //# sourceMappingURL=context-evidence.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { StreamChunk, TokenUsage } from '@deepseek-ai/dsh-llm';
2
+ /** All observed counters are zero, not proof that an attempted prompt was empty. */
3
+ export declare function isZeroContextUsage(usage: TokenUsage): boolean;
4
+ /**
5
+ * Native pi-ai emits terminal usage immediately before finish, including a
6
+ * default zero sample when no provider usage arrived. Delay only that sample;
7
+ * failed, cancelled or truncated attempts must not reset Core's last reading.
8
+ */
9
+ export declare function guardContextUsage(stream: AsyncIterable<StreamChunk>): AsyncGenerator<StreamChunk>;
10
+ //# sourceMappingURL=context-usage-guard.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import type { Agent } from '@deepseek-ai/dsh-agent';
2
+ import type { Context } from '@deepseek-ai/cordis';
2
3
  import BasicCompactionEngine from '@deepseek-ai/dsh-compaction-basic';
3
4
  import type { ContentBlock, Message, TokenUsage, ToolSchema } from '@deepseek-ai/dsh-llm';
4
5
  import type { CommandId } from '@deepseek-ai/dsh-commands/brand';
@@ -43,6 +44,7 @@ export declare function summarizeOversizedManualInput<M extends RecoveryMessage,
43
44
  */
44
45
  export declare class CopilotManualRecoveryCompactionEngine extends BasicCompactionEngine {
45
46
  private readonly manual;
47
+ constructor(ctx: Context, config?: ConstructorParameters<typeof BasicCompactionEngine>[1]);
46
48
  compactNow(agent: Agent, signal: AbortSignal, sourceCommandId?: CommandId): Promise<CompactionResult | null>;
47
49
  protected summarize(input: RecoveryInput<Message>, agent: Agent, signal?: AbortSignal): Promise<RecoveryResult>;
48
50
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-github-copilot",
3
3
  "description": "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
4
- "version": "0.4.0-alpha.72",
4
+ "version": "0.4.0-alpha.74",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",
@@ -149,6 +149,7 @@
149
149
  "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
150
150
  "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
151
151
  "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
152
+ "@deepseek-ai/dsh-jobs": "0.2.0-rc.2",
152
153
  "@deepseek-ai/dsh-api-gateway": "0.2.0-rc.2",
153
154
  "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
154
155
  "@deepseek-ai/dsh-app-boot": "0.2.0-rc.2",
@@ -167,6 +168,7 @@
167
168
  "@deepseek-ai/dsh-scope": "0.2.0-rc.2",
168
169
  "@deepseek-ai/dsh-session": "0.2.0-rc.2",
169
170
  "@deepseek-ai/dsh-session-format-catalog": "0.2.0-rc.2",
171
+ "@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
170
172
  "@deepseek-ai/dsh-settings": "0.2.0-rc.2",
171
173
  "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
172
174
  "@deepseek-ai/dsh-tool-web": "0.2.0-rc.2",