dsh-github-copilot 0.4.0-alpha.120 → 0.4.0-alpha.122

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.
@@ -6,8 +6,32 @@ import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
6
6
  import { CommandDefinitionId } from "@deepseek-ai/dsh-commands/brand";
7
7
  //#region lib/types/background-compaction.js
8
8
  const WAIT_MS = 2147483647;
9
- const USAGE = "Usage: /copilot-compact [status|cancel]";
9
+ const USAGE = "Usage: /copilot-compact [status|cancel|visible-history]. visible-history authorizes one lossy summary without old encrypted reasoning or its embedded summaries; stored source history is unchanged.";
10
10
  const FAILED = "COPILOT_BACKGROUND_COMPACTION_FAILED: inspect the native compaction/end record; no success is implied.";
11
+ function failureDetail(cause) {
12
+ const allowed = /* @__PURE__ */ new Set([
13
+ "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH",
14
+ "COPILOT_RESPONSES_REPLAY_UNSUPPORTED",
15
+ "COPILOT_RESPONSES_REPLAY_INVALID_PAYLOAD",
16
+ "CONTEXT_WINDOW_EXCEEDED",
17
+ "COPILOT_MANUAL_RECOVERY_ACCOUNT_PROOF_UNAVAILABLE",
18
+ "COPILOT_MANUAL_RECOVERY_FIXED_PREFIX",
19
+ "COPILOT_MANUAL_RECOVERY_INDIVISIBLE",
20
+ "COPILOT_MANUAL_RECOVERY_CALL_LIMIT",
21
+ "COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY",
22
+ "COPILOT_MANUAL_RECOVERY_UNBALANCED",
23
+ "COPILOT_COMPACTION_REPLAY_UNAVAILABLE",
24
+ "COPILOT_COMPACTION_REPLAY_REVOKED"
25
+ ]);
26
+ const visited = /* @__PURE__ */ new Set();
27
+ for (let depth = 0; depth < 8 && cause instanceof Error && !visited.has(cause); depth++) {
28
+ visited.add(cause);
29
+ const code = /^[A-Z][A-Z_]+(?=:|$)/.exec(cause.message)?.[0];
30
+ if (code && allowed.has(code)) return `${code}: compaction failed; stored source history is unchanged.${code === "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH" ? " Review loss of hidden context before explicitly using /copilot-compact visible-history. No automatic retry." : ""} Inspect the native compaction/end record.`;
31
+ cause = cause.cause;
32
+ }
33
+ return FAILED;
34
+ }
11
35
  /** Own only admission and job lifetime; the selected engine owns all history transactions. */
12
36
  var BackgroundCompaction = class {
13
37
  jobs;
@@ -31,12 +55,12 @@ var BackgroundCompaction = class {
31
55
  text: "Compaction admission cancelled."
32
56
  };
33
57
  const action = rawInput.trim();
34
- if (action !== "" && action !== "status" && action !== "cancel") return {
58
+ if (action !== "" && action !== "status" && action !== "cancel" && action !== "visible-history") return {
35
59
  kind: "error",
36
60
  text: USAGE
37
61
  };
38
62
  const id = this.latest.get(agent);
39
- if (action !== "") {
63
+ if (action === "status" || action === "cancel") {
40
64
  if (id === void 0) return {
41
65
  kind: "error",
42
66
  text: "No background compaction job for this Session."
@@ -75,20 +99,21 @@ var BackgroundCompaction = class {
75
99
  done = Promise.resolve().then(async () => {
76
100
  try {
77
101
  cancel.signal.throwIfAborted();
78
- const result = await this.compact(agent, cancel.signal);
102
+ const result = await this.compact(agent, cancel.signal, action === "visible-history");
79
103
  return {
80
104
  status: "completed",
81
105
  detail: result === null ? "No compactable history." : `Compacted ${result.shadowedSeqs.length} history items (~${result.shadowedTokenCount} tokens).`
82
106
  };
83
- } catch {
107
+ } catch (cause) {
84
108
  if (cancel.signal.aborted) return {
85
109
  status: "killed",
86
110
  detail: "Compaction cancelled; inspect native history for its transaction outcome."
87
111
  };
88
- this.warn(FAILED);
112
+ const detail = failureDetail(cause);
113
+ this.warn(detail);
89
114
  return {
90
115
  status: "failed",
91
- detail: FAILED
116
+ detail
92
117
  };
93
118
  } finally {
94
119
  this.active.delete(agent);
@@ -147,7 +172,7 @@ function installBackgroundCompaction(ctx, compact) {
147
172
  definitionId: CommandDefinitionId("dsh-github-copilot/background-compaction"),
148
173
  name: "copilot-compact",
149
174
  description: "Start background manual compaction, inspect status, or cancel",
150
- input: { hint: "status | cancel (omit to start)" },
175
+ input: { hint: "status | cancel | visible-history (explicit lossy recovery; omit for normal compaction)" },
151
176
  handler: (invocation) => controller.execute(invocation.agent, invocation.rawInput, invocation.signal)
152
177
  });
153
178
  }, "Copilot background compaction");
@@ -247,6 +272,7 @@ async function summarizeOversizedManualInput(options) {
247
272
  var CopilotManualRecoveryCompactionEngine = class extends BasicCompactionEngine {
248
273
  static Config = z.intersect([BasicCompactionEngine.Config, z.object({ automaticRecovery: z.boolean().default(true) })]);
249
274
  manual = /* @__PURE__ */ new WeakMap();
275
+ visibleHistory = /* @__PURE__ */ new WeakSet();
250
276
  automaticRecovery;
251
277
  constructor(ctx, config = {}) {
252
278
  const { automaticRecovery = true, ...nativeConfig } = config;
@@ -254,7 +280,12 @@ var CopilotManualRecoveryCompactionEngine = class extends BasicCompactionEngine
254
280
  super(ctx, nativeConfig);
255
281
  this.automaticRecovery = automaticRecovery;
256
282
  ctx.inject(["commands", "jobs"], (scope) => {
257
- installBackgroundCompaction(scope, (agent, signal) => this.compactNow(agent, signal));
283
+ installBackgroundCompaction(scope, (agent, signal, visibleHistory) => {
284
+ if (!visibleHistory) return this.compactNow(agent, signal);
285
+ if (this.manual.has(agent)) throw recoverError("BUSY");
286
+ this.visibleHistory.add(agent);
287
+ return this.compactNow(agent, signal).finally(() => this.visibleHistory.delete(agent));
288
+ });
258
289
  });
259
290
  }
260
291
  async compactNow(agent, signal, sourceCommandId) {
@@ -282,19 +313,30 @@ var CopilotManualRecoveryCompactionEngine = class extends BasicCompactionEngine
282
313
  };
283
314
  const summaryProvider = selected.provider;
284
315
  const summaryModel = selected.model;
285
- if (!this.manual.has(agent) && !this.automaticRecovery || summaryProvider !== "github-copilot-preview" || !summaryModel) return super.summarize(input, agent, signal);
316
+ if (!this.manual.has(agent) && !this.automaticRecovery || summaryProvider !== "github-copilot-preview" || !summaryModel) {
317
+ if (this.visibleHistory.has(agent)) throw new Error("COPILOT_COMPACTION_REPLAY_UNAVAILABLE");
318
+ return super.summarize(input, agent, signal);
319
+ }
320
+ const maxTokens = policy?.maxTokens ?? this.config.maxTokens;
321
+ const operationSignal = signal ?? new AbortController().signal;
322
+ const summarize = () => this.summarizeManaged(input, agent, summaryModel, maxTokens, operationSignal);
323
+ if (!this.visibleHistory.has(agent)) return summarize();
324
+ const recovery = this.ctx.get("githubCopilotCompactionReplay");
325
+ if (!recovery) throw new Error("COPILOT_COMPACTION_REPLAY_UNAVAILABLE");
326
+ return recovery.run(agent.session.id, summaryModel, operationSignal, summarize);
327
+ }
328
+ async summarizeManaged(input, agent, summaryModel, maxTokens, operationSignal) {
286
329
  const lease = this.ctx.get("githubCopilotPreview")?.recoveryLimits(summaryModel, agent);
287
330
  if (lease === void 0) throw recoverError("ACCOUNT_PROOF_UNAVAILABLE");
331
+ if (this.visibleHistory.has(agent) && lease.api !== "openai-responses") throw new Error("COPILOT_COMPACTION_REPLAY_UNAVAILABLE");
288
332
  const agents = this.ctx.get("agents");
289
333
  if (this.ctx.get("githubCopilotSessionAccounts") !== void 0 && agents === void 0) throw recoverError("INITIATOR_UNAVAILABLE");
290
- const summarize = (candidate) => agents === void 0 ? super.summarize(candidate, agent, signal) : agents.withInitiator(agent, () => super.summarize(candidate, agent, signal));
291
- const maxTokens = policy?.maxTokens ?? this.config.maxTokens;
334
+ const summarize = (candidate) => agents === void 0 ? super.summarize(candidate, agent, operationSignal) : agents.withInitiator(agent, () => super.summarize(candidate, agent, operationSignal));
292
335
  const budget = calculateRequestBudget(lease.limits, maxTokens, resolveRequestBudgetPolicy(lease.policy));
293
336
  if (!budget.ok) throw recoverError(budget.code);
294
337
  const toolHistoryBytes = Buffer.byteLength(JSON.stringify(agent.session.toolHistory()), "utf8");
295
338
  let inputLimit = budget.budget.hardInputLimit - 4096 - toolHistoryBytes;
296
339
  if (inputLimit <= 0) throw recoverError("FIXED_PREFIX");
297
- const operationSignal = signal ?? new AbortController().signal;
298
340
  const estimate = (candidate) => Buffer.byteLength(JSON.stringify(candidate), "utf8");
299
341
  operationSignal.throwIfAborted();
300
342
  lease.assertCurrent();
package/lib/remote.js CHANGED
@@ -687,6 +687,20 @@ const contribution$2 = {
687
687
  };
688
688
  //#endregion
689
689
  //#region lib/types/session-continuation-types.js
690
+ const CompactionContinuationStatusSchema = z.object({
691
+ id: z.string().min(1).max(256),
692
+ state: z.enum([
693
+ "running",
694
+ "completed",
695
+ "failed",
696
+ "cancelled",
697
+ "blocked"
698
+ ])
699
+ }).strict();
700
+ z.object({
701
+ id: z.string().nullable(),
702
+ running: z.boolean()
703
+ }).strict();
690
704
  const SessionContinuationPreferenceSchema = z.object({
691
705
  sessionId: z.string().min(1).max(256).refine((value) => !/[\p{Cc}\p{Cf}]/u.test(value)),
692
706
  version: z.literal(1),
@@ -707,7 +721,8 @@ const SessionContinuationViewSchema = z.object({
707
721
  revision: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
708
722
  activeTurnEnabled: z.boolean().optional(),
709
723
  source: z.enum(["default", "session"]).optional(),
710
- nextTurnAuthorized: z.boolean().optional()
724
+ nextTurnAuthorized: z.boolean().optional(),
725
+ compaction: CompactionContinuationStatusSchema.optional()
711
726
  }).strict();
712
727
  //#endregion
713
728
  //#region lib/types/session-continuation-remote.js
@@ -21,10 +21,10 @@ export declare class BackgroundCompaction<A extends {
21
21
  private readonly latest;
22
22
  private readonly active;
23
23
  private closed;
24
- constructor(jobs: Jobs, compact: (agent: A, signal: AbortSignal) => Promise<Result>, warn: (message: string) => void);
24
+ constructor(jobs: Jobs, compact: (agent: A, signal: AbortSignal, visibleHistory: boolean) => Promise<Result>, warn: (message: string) => void);
25
25
  execute(agent: A, rawInput: string, signal: AbortSignal): CommandResult;
26
26
  dispose(): Promise<void>;
27
27
  }
28
- export declare function installBackgroundCompaction(ctx: Context, compact: (agent: Agent, signal: AbortSignal) => Promise<CompactionResult | null>): void;
28
+ export declare function installBackgroundCompaction(ctx: Context, compact: (agent: Agent, signal: AbortSignal, visibleHistory: boolean) => Promise<CompactionResult | null>): void;
29
29
  export {};
30
30
  //# sourceMappingURL=background-compaction.d.ts.map
@@ -0,0 +1,11 @@
1
+ import type { SessionContinuationRemote } from './session-continuation-ui.ts';
2
+ export declare function CompactionContinuationNotice({ sessionId, remote, lifecycle, locale }: {
3
+ sessionId: string;
4
+ remote?: SessionContinuationRemote;
5
+ lifecycle: unknown;
6
+ locale?: string;
7
+ }): import("react").DetailedReactHTMLElement<{
8
+ 'data-copilot-composer-notice': string;
9
+ style: import("react").CSSProperties;
10
+ }, HTMLElement> | null;
11
+ //# sourceMappingURL=compaction-continuation-ui.d.ts.map
@@ -0,0 +1,48 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { Agent } from '@deepseek-ai/dsh-agent';
3
+ import type { GenerateOptions } from '@deepseek-ai/dsh-llm';
4
+ import type { CompactionContinuationLifecycle } from './session-continuation-types.ts';
5
+ declare module '@deepseek-ai/dsh-session-projection/types' {
6
+ interface SessionProjectionMap {
7
+ githubCopilotCompactionLifecycle: CompactionContinuationLifecycle;
8
+ }
9
+ interface SessionProjectionStateMap {
10
+ githubCopilotCompactionLifecycle: CompactionContinuationLifecycle;
11
+ }
12
+ }
13
+ export declare const compactionContinuationDefinition: {
14
+ key: "githubCopilotCompactionLifecycle";
15
+ stateVersion: number;
16
+ stateSchema: import("zod").ZodObject<{
17
+ id: import("zod").ZodNullable<import("zod").ZodString>;
18
+ running: import("zod").ZodBoolean;
19
+ }, import("zod/v4/core").$strict>;
20
+ init: () => CompactionContinuationLifecycle;
21
+ apply(state: NoInfer<{
22
+ id: string | null;
23
+ running: boolean;
24
+ }>, event: import("@deepseek-ai/dsh-session").SessionEvent): {
25
+ id: string | null;
26
+ running: boolean;
27
+ };
28
+ wire: {
29
+ viewSchema: import("zod").ZodObject<{
30
+ id: import("zod").ZodNullable<import("zod").ZodString>;
31
+ running: import("zod").ZodBoolean;
32
+ }, import("zod/v4/core").$strict>;
33
+ view: (state: CompactionContinuationLifecycle) => {
34
+ id: string | null;
35
+ running: boolean;
36
+ };
37
+ };
38
+ };
39
+ /** Native brackets authorize scope, never loss; the existing Session policy authorizes loss. */
40
+ export declare function installCompactionContinuation(ctx: Context, enabled: (agent: Agent) => boolean): {
41
+ status(agent: Agent): {
42
+ id: string;
43
+ state: "running" | "completed" | "cancelled" | "failed" | "blocked";
44
+ } | undefined;
45
+ prepare(request: GenerateOptions): ((payload: unknown) => Promise<unknown>) | undefined;
46
+ dispose(): void;
47
+ };
48
+ //# sourceMappingURL=compaction-continuation.d.ts.map
@@ -0,0 +1,18 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { GenerateOptions } from '@deepseek-ai/dsh-llm';
3
+ import type { SessionId } from '@deepseek-ai/dsh-session';
4
+ declare module '@deepseek-ai/cordis' {
5
+ interface Context {
6
+ githubCopilotCompactionReplay: CompactionReplayRecovery;
7
+ }
8
+ }
9
+ /** Explicit manual consent lasts only for the native summarizer hook's exact signal. */
10
+ export declare class CompactionReplayRecovery {
11
+ private readonly operations;
12
+ private closed;
13
+ run<T>(sessionId: SessionId, model: string, signal: AbortSignal, operation: () => Promise<T>): Promise<T>;
14
+ prepare(request: GenerateOptions): ((payload: unknown) => Promise<unknown>) | undefined;
15
+ dispose(): void;
16
+ }
17
+ export declare function installCompactionReplay(ctx: Context): CompactionReplayRecovery;
18
+ //# sourceMappingURL=compaction-replay.d.ts.map
@@ -49,6 +49,7 @@ export declare class CopilotManualRecoveryCompactionEngine extends BasicCompacti
49
49
  automaticRecovery?: boolean;
50
50
  }>;
51
51
  private readonly manual;
52
+ private readonly visibleHistory;
52
53
  private readonly automaticRecovery;
53
54
  constructor(ctx: Context, config?: BasicCompactionConfig & {
54
55
  automaticRecovery?: boolean;
@@ -60,6 +61,7 @@ export declare class CopilotManualRecoveryCompactionEngine extends BasicCompacti
60
61
  model: string;
61
62
  maxTokens?: number;
62
63
  }>;
64
+ private summarizeManaged;
63
65
  }
64
66
  export default CopilotManualRecoveryCompactionEngine;
65
67
  //# sourceMappingURL=manual-compaction-recovery.d.ts.map
@@ -37,6 +37,7 @@ export interface GitHubCopilotPreview {
37
37
  getView(): GitHubCopilotPreviewView;
38
38
  /** Synchronous, account-proven summary capacities for the initiating Agent; never triggers discovery. */
39
39
  recoveryLimits(modelId: string, agent?: Agent): {
40
+ readonly api: AccountModelDescriptor['api'];
40
41
  readonly limits: Pick<AccountModelDescriptor, 'contextWindow' | 'maxInputTokens' | 'maxTokens'>;
41
42
  readonly policy: Partial<RequestBudgetPolicy>;
42
43
  readonly assertCurrent: () => void;
@@ -4,6 +4,7 @@ import type { GenerateOptions } from '@deepseek-ai/dsh-llm';
4
4
  import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
5
5
  import { SessionContinuationTurn } from './session-continuation.ts';
6
6
  import type { SessionContinuationView } from './session-continuation-types.ts';
7
+ import type { CompactionContinuationStatus } from './session-continuation-types.ts';
7
8
  declare module '@deepseek-ai/cordis' {
8
9
  interface Context {
9
10
  githubCopilotSessionContinuation: SessionContinuationController;
@@ -12,6 +13,7 @@ declare module '@deepseek-ai/cordis' {
12
13
  interface Admission {
13
14
  readonly turn: number;
14
15
  readonly enabled: boolean;
16
+ readonly persistentEnabled: boolean;
15
17
  readonly filter: SessionContinuationTurn;
16
18
  step: number;
17
19
  signal: AbortSignal;
@@ -20,7 +22,8 @@ export declare class SessionContinuationController extends TypertRemoteService {
20
22
  private readonly active;
21
23
  private readonly once;
22
24
  private readonly ready;
23
- constructor(ctx: Context, active: Map<object, Admission>, once?: Set<object>, ready?: Promise<void>);
25
+ private readonly summaryStatus;
26
+ constructor(ctx: Context, active: Map<object, Admission>, once?: Set<object>, ready?: Promise<void>, summaryStatus?: (agent: Agent) => CompactionContinuationStatus | undefined);
24
27
  get(agent: Agent): Promise<SessionContinuationView>;
25
28
  set(agent: Agent, revision: number, enabled: boolean | null): Promise<SessionContinuationView>;
26
29
  authorizeNext(agent: Agent, revision: number, enabled: boolean): Promise<SessionContinuationView>;
@@ -1,4 +1,21 @@
1
1
  import { z } from 'zod';
2
+ export declare const COMPACTION_CONTINUATION = "githubCopilotCompactionLifecycle";
3
+ export declare const CompactionContinuationStatusSchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ state: z.ZodEnum<{
6
+ running: "running";
7
+ completed: "completed";
8
+ cancelled: "cancelled";
9
+ failed: "failed";
10
+ blocked: "blocked";
11
+ }>;
12
+ }, z.core.$strict>;
13
+ export type CompactionContinuationStatus = z.infer<typeof CompactionContinuationStatusSchema>;
14
+ export declare const CompactionContinuationLifecycleSchema: z.ZodObject<{
15
+ id: z.ZodNullable<z.ZodString>;
16
+ running: z.ZodBoolean;
17
+ }, z.core.$strict>;
18
+ export type CompactionContinuationLifecycle = z.infer<typeof CompactionContinuationLifecycleSchema>;
2
19
  export declare const SessionContinuationPreferenceSchema: z.ZodObject<{
3
20
  sessionId: z.ZodString;
4
21
  version: z.ZodLiteral<1>;
@@ -30,6 +47,16 @@ export declare const SessionContinuationViewSchema: z.ZodObject<{
30
47
  session: "session";
31
48
  }>>;
32
49
  nextTurnAuthorized: z.ZodOptional<z.ZodBoolean>;
50
+ compaction: z.ZodOptional<z.ZodObject<{
51
+ id: z.ZodString;
52
+ state: z.ZodEnum<{
53
+ running: "running";
54
+ completed: "completed";
55
+ cancelled: "cancelled";
56
+ failed: "failed";
57
+ blocked: "blocked";
58
+ }>;
59
+ }, z.core.$strict>>;
33
60
  }, z.core.$strict>;
34
61
  export type SessionContinuationView = z.infer<typeof SessionContinuationViewSchema>;
35
62
  //# sourceMappingURL=session-continuation-types.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.120",
4
+ "version": "0.4.0-alpha.122",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",