dsh-github-copilot 0.4.0-alpha.95 → 0.4.0-alpha.96

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
@@ -1831,7 +1831,7 @@ function installContextEvidence(ctx) {
1831
1831
  //#endregion
1832
1832
  //#region package.json
1833
1833
  var name$1 = "dsh-github-copilot";
1834
- var version = "0.4.0-alpha.95";
1834
+ var version = "0.4.0-alpha.96";
1835
1835
  //#endregion
1836
1836
  //#region lib/types/probe.js
1837
1837
  /**
@@ -5492,7 +5492,9 @@ var ReplayRecoveryStore = class {
5492
5492
  state: state.enabled ? "enabled" : "available",
5493
5493
  revision: state.revision,
5494
5494
  itemCount: state.hashes.size,
5495
- model: state.model
5495
+ model: state.model,
5496
+ expiresAt: state.at + 36e5,
5497
+ ...state.enabled && state.duration ? { duration: state.duration } : {}
5496
5498
  } : { state: "unavailable" };
5497
5499
  }
5498
5500
  recordFailure(owner, proof, model, body) {
@@ -5512,14 +5514,34 @@ var ReplayRecoveryStore = class {
5512
5514
  if (this.owners.size > 64) this.owners.delete(this.owners.keys().next().value);
5513
5515
  }
5514
5516
  setEnabled(owner, proof, revision, enabled) {
5517
+ if (enabled) return this.authorize(owner, proof, revision, "session");
5515
5518
  const state = this.current(owner, proof);
5516
5519
  if (!state || revision !== state.revision) throw new Error("COPILOT_REPLAY_RECOVERY_STALE_EVIDENCE");
5517
- state.enabled = enabled;
5520
+ state.enabled = false;
5518
5521
  return this.view(owner, proof);
5519
5522
  }
5520
- prepare(owner, proof, model) {
5523
+ authorize(owner, proof, revision, duration) {
5521
5524
  const state = this.current(owner, proof);
5522
- const admitted = state?.enabled && state.model === model ? state.hashes : void 0;
5525
+ if (!state || revision !== state.revision) throw new Error("COPILOT_REPLAY_RECOVERY_STALE_EVIDENCE");
5526
+ state.enabled = true;
5527
+ state.duration = duration;
5528
+ delete state.turn;
5529
+ return this.view(owner, proof);
5530
+ }
5531
+ endTurn(owner, turn) {
5532
+ const state = this.owners.get(owner);
5533
+ if (state?.duration === "next-turn" && state.turn === turn) state.enabled = false;
5534
+ }
5535
+ prepare(owner, proof, model, turn) {
5536
+ const state = this.current(owner, proof);
5537
+ let admitted;
5538
+ if (state?.enabled && state.model === model) {
5539
+ if (state.duration !== "next-turn") admitted = state.hashes;
5540
+ else if (turn !== void 0 && Number.isSafeInteger(turn) && turn >= 0) {
5541
+ state.turn ??= turn;
5542
+ if (state.turn === turn) admitted = state.hashes;
5543
+ }
5544
+ }
5523
5545
  return (payload) => {
5524
5546
  if (!admitted) return payload;
5525
5547
  if (this.current(owner, proof) !== state) throw new Error("COPILOT_REPLAY_RECOVERY_REVOKED");
@@ -5600,11 +5622,13 @@ let ReplayRecoveryController = (() => {
5600
5622
  let _instanceExtraInitializers = [];
5601
5623
  let _get_decorators;
5602
5624
  let _setEnabled_decorators;
5625
+ let _authorize_decorators;
5603
5626
  return class ReplayRecoveryController extends _classSuper {
5604
5627
  static {
5605
5628
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
5606
5629
  _get_decorators = [Remote];
5607
5630
  _setEnabled_decorators = [Remote];
5631
+ _authorize_decorators = [Remote];
5608
5632
  __esDecorate$1(this, null, _get_decorators, {
5609
5633
  kind: "method",
5610
5634
  name: "get",
@@ -5627,6 +5651,17 @@ let ReplayRecoveryController = (() => {
5627
5651
  },
5628
5652
  metadata: _metadata
5629
5653
  }, null, _instanceExtraInitializers);
5654
+ __esDecorate$1(this, null, _authorize_decorators, {
5655
+ kind: "method",
5656
+ name: "authorize",
5657
+ static: false,
5658
+ private: false,
5659
+ access: {
5660
+ has: (obj) => "authorize" in obj,
5661
+ get: (obj) => obj.authorize
5662
+ },
5663
+ metadata: _metadata
5664
+ }, null, _instanceExtraInitializers);
5630
5665
  if (_metadata) Object.defineProperty(this, Symbol.metadata, {
5631
5666
  enumerable: true,
5632
5667
  configurable: true,
@@ -5650,6 +5685,10 @@ let ReplayRecoveryController = (() => {
5650
5685
  if (this.busy.has(agent.session)) throw new Error("COPILOT_REPLAY_RECOVERY_TURN_ACTIVE");
5651
5686
  return this.store.setEnabled(agent.session, this.proof(), revision, enabled);
5652
5687
  }
5688
+ authorize(agent, revision, duration) {
5689
+ if (this.busy.has(agent.session)) throw new Error("COPILOT_REPLAY_RECOVERY_TURN_ACTIVE");
5690
+ return this.store.authorize(agent.session, this.proof(), revision, duration);
5691
+ }
5653
5692
  };
5654
5693
  })();
5655
5694
  function installReplayRecovery(ctx, proof) {
@@ -5672,6 +5711,7 @@ function installReplayRecovery(ctx, proof) {
5672
5711
  });
5673
5712
  const removeEvents = ctx.on("session/event", (session, event) => {
5674
5713
  if (event.type === "turn/end") {
5714
+ store.endTurn(session, event.data.turn);
5675
5715
  busy.delete(session);
5676
5716
  currentRequests.delete(session);
5677
5717
  }
@@ -5687,8 +5727,8 @@ function installReplayRecovery(ctx, proof) {
5687
5727
  if (!active || request.signal === void 0 || request.signal.aborted || request.purpose !== void 0 || request.provider !== "github-copilot-preview") return void 0;
5688
5728
  const binding = requests.get(request.signal);
5689
5729
  const currentProof = proof();
5690
- if (!binding || binding.session.id !== request.sessionId || !busy.has(binding.session) || currentProof === void 0) return void 0;
5691
- const transform = store.prepare(binding.session, currentProof, request.model);
5730
+ if (!binding || binding.session.id !== request.sessionId || !busy.has(binding.session) || currentProof === void 0 || currentRequests.get(binding.session) !== request.signal) return void 0;
5731
+ const transform = store.prepare(binding.session, currentProof, request.model, binding.turn);
5692
5732
  const current = () => active && !request.signal?.aborted && proof() === currentProof && currentRequests.get(binding.session) === request.signal && busy.has(binding.session);
5693
5733
  return {
5694
5734
  transform(payload) {
package/lib/remote.js CHANGED
@@ -333,11 +333,14 @@ const contribution$2 = {
333
333
  };
334
334
  //#endregion
335
335
  //#region lib/types/replay-recovery-types.js
336
+ const ReplayRecoveryDurationSchema = z.enum(["next-turn", "session"]);
336
337
  const ReplayRecoveryViewSchema = z.discriminatedUnion("state", [z.object({ state: z.literal("unavailable") }).strict(), z.object({
337
338
  state: z.enum(["available", "enabled"]),
338
339
  revision: z.string().uuid(),
339
340
  itemCount: z.number().int().positive().max(512),
340
- model: z.string().min(1).max(256)
341
+ model: z.string().min(1).max(256),
342
+ duration: ReplayRecoveryDurationSchema.optional(),
343
+ expiresAt: z.number().int().nonnegative().optional()
341
344
  }).strict()]);
342
345
  //#endregion
343
346
  //#region lib/types/replay-recovery-remote.js
@@ -350,37 +353,63 @@ const agent = {
350
353
  };
351
354
  const contribution$1 = {
352
355
  package: "dsh-github-copilot",
353
- descriptors: [{
354
- id: "dsh-github-copilot:githubCopilotReplayRecovery.get",
355
- namespace: "githubCopilotReplayRecovery",
356
- service: "githubCopilotReplayRecovery",
357
- method: "get",
358
- invocation: { kind: "direct" },
359
- parameters: [agent],
360
- result: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryView", ReplayRecoveryViewSchema)
361
- }, {
362
- id: "dsh-github-copilot:githubCopilotReplayRecovery.setEnabled",
363
- namespace: "githubCopilotReplayRecovery",
364
- service: "githubCopilotReplayRecovery",
365
- method: "setEnabled",
366
- invocation: { kind: "direct" },
367
- parameters: [
368
- agent,
369
- {
370
- name: "revision",
371
- wire: "revision",
372
- source: "json",
373
- codec: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryRevision", z.string().uuid())
374
- },
375
- {
376
- name: "enabled",
377
- wire: "enabled",
378
- source: "json",
379
- codec: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryEnabled", z.boolean())
380
- }
381
- ],
382
- result: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryView", ReplayRecoveryViewSchema)
383
- }]
356
+ descriptors: [
357
+ {
358
+ id: "dsh-github-copilot:githubCopilotReplayRecovery.get",
359
+ namespace: "githubCopilotReplayRecovery",
360
+ service: "githubCopilotReplayRecovery",
361
+ method: "get",
362
+ invocation: { kind: "direct" },
363
+ parameters: [agent],
364
+ result: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryView", ReplayRecoveryViewSchema)
365
+ },
366
+ {
367
+ id: "dsh-github-copilot:githubCopilotReplayRecovery.authorize",
368
+ namespace: "githubCopilotReplayRecovery",
369
+ service: "githubCopilotReplayRecovery",
370
+ method: "authorize",
371
+ invocation: { kind: "direct" },
372
+ parameters: [
373
+ agent,
374
+ {
375
+ name: "revision",
376
+ wire: "revision",
377
+ source: "json",
378
+ codec: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryRevision", z.string().uuid())
379
+ },
380
+ {
381
+ name: "duration",
382
+ wire: "duration",
383
+ source: "json",
384
+ codec: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryDuration", ReplayRecoveryDurationSchema)
385
+ }
386
+ ],
387
+ result: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryView", ReplayRecoveryViewSchema)
388
+ },
389
+ {
390
+ id: "dsh-github-copilot:githubCopilotReplayRecovery.setEnabled",
391
+ namespace: "githubCopilotReplayRecovery",
392
+ service: "githubCopilotReplayRecovery",
393
+ method: "setEnabled",
394
+ invocation: { kind: "direct" },
395
+ parameters: [
396
+ agent,
397
+ {
398
+ name: "revision",
399
+ wire: "revision",
400
+ source: "json",
401
+ codec: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryRevision", z.string().uuid())
402
+ },
403
+ {
404
+ name: "enabled",
405
+ wire: "enabled",
406
+ source: "json",
407
+ codec: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryEnabled", z.boolean())
408
+ }
409
+ ],
410
+ result: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryView", ReplayRecoveryViewSchema)
411
+ }
412
+ ]
384
413
  };
385
414
  //#endregion
386
415
  //#region lib/types/remote.js
@@ -3,7 +3,7 @@ import type { Agent } from '@deepseek-ai/dsh-agent';
3
3
  import type { GenerateOptions } from '@deepseek-ai/dsh-llm';
4
4
  import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
5
5
  import { ReplayRecoveryStore } from './replay-recovery.ts';
6
- import type { ReplayRecoveryView } from './replay-recovery-types.ts';
6
+ import type { ReplayRecoveryDuration, ReplayRecoveryView } from './replay-recovery-types.ts';
7
7
  declare module '@deepseek-ai/cordis' {
8
8
  interface Context {
9
9
  githubCopilotReplayRecovery: ReplayRecoveryController;
@@ -16,6 +16,7 @@ export declare class ReplayRecoveryController extends TypertRemoteService {
16
16
  constructor(ctx: Context, store: ReplayRecoveryStore, proof: () => string | undefined, busy: WeakSet<object>);
17
17
  get(agent: Agent): ReplayRecoveryView;
18
18
  setEnabled(agent: Agent, revision: string, enabled: boolean): ReplayRecoveryView;
19
+ authorize(agent: Agent, revision: string, duration: ReplayRecoveryDuration): ReplayRecoveryView;
19
20
  }
20
21
  export declare function installReplayRecovery(ctx: Context, proof: () => string | undefined): {
21
22
  prepare(request: GenerateOptions): {
@@ -1,10 +1,11 @@
1
1
  import type { RemoteResult, TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol';
2
- import type { ReplayRecoveryView } from './replay-recovery-types.ts';
2
+ import type { ReplayRecoveryDuration, ReplayRecoveryView } from './replay-recovery-types.ts';
3
3
  declare module '@deepseek-ai/dsh-typert-protocol' {
4
4
  interface TypertRemoteNamespaceMap {
5
5
  githubCopilotReplayRecovery: {
6
6
  get(agentId: string): Promise<RemoteResult<ReplayRecoveryView>>;
7
7
  setEnabled(agentId: string, revision: string, enabled: boolean): Promise<RemoteResult<ReplayRecoveryView>>;
8
+ authorize(agentId: string, revision: string, duration: ReplayRecoveryDuration): Promise<RemoteResult<ReplayRecoveryView>>;
8
9
  };
9
10
  }
10
11
  }
@@ -1,4 +1,9 @@
1
1
  import { z } from 'zod';
2
+ export declare const ReplayRecoveryDurationSchema: z.ZodEnum<{
3
+ session: "session";
4
+ "next-turn": "next-turn";
5
+ }>;
6
+ export type ReplayRecoveryDuration = z.infer<typeof ReplayRecoveryDurationSchema>;
2
7
  export declare const ReplayRecoveryViewSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
8
  state: z.ZodLiteral<"unavailable">;
4
9
  }, z.core.$strict>, z.ZodObject<{
@@ -9,6 +14,11 @@ export declare const ReplayRecoveryViewSchema: z.ZodDiscriminatedUnion<[z.ZodObj
9
14
  revision: z.ZodString;
10
15
  itemCount: z.ZodNumber;
11
16
  model: z.ZodString;
17
+ duration: z.ZodOptional<z.ZodEnum<{
18
+ session: "session";
19
+ "next-turn": "next-turn";
20
+ }>>;
21
+ expiresAt: z.ZodOptional<z.ZodNumber>;
12
22
  }, z.core.$strict>], "state">;
13
23
  export type ReplayRecoveryView = z.infer<typeof ReplayRecoveryViewSchema>;
14
24
  //# sourceMappingURL=replay-recovery-types.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import type { ReactElement } from 'react';
3
+ import type { ReplayRecoveryDuration } from './replay-recovery-types.ts';
3
4
  export interface ReplayRecoveryRemote {
4
5
  get(agentId: string): Promise<{
5
6
  ok: boolean;
@@ -9,11 +10,17 @@ export interface ReplayRecoveryRemote {
9
10
  ok: boolean;
10
11
  value?: unknown;
11
12
  }>;
13
+ authorize(agentId: string, revision: string, duration: ReplayRecoveryDuration): Promise<{
14
+ ok: boolean;
15
+ value?: unknown;
16
+ }>;
12
17
  }
13
- export declare function ReplayRecoveryCard({ sessionId, remote, locale }: {
18
+ export declare function ReplayRecoveryCard({ sessionId, remote, locale, running, refreshKey }: {
14
19
  sessionId: string;
15
20
  remote: ReplayRecoveryRemote;
16
21
  locale?: string;
17
- }): ReactElement;
22
+ running?: boolean;
23
+ refreshKey?: string;
24
+ }): ReactElement | null;
18
25
  export declare function registerReplayRecoveryUi(ctx: Context): () => void;
19
26
  //# sourceMappingURL=replay-recovery-ui.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { ReplayRecoveryView } from './replay-recovery-types.ts';
1
+ import type { ReplayRecoveryDuration, ReplayRecoveryView } from './replay-recovery-types.ts';
2
2
  /** Host-lifetime opt-in only. Stores fingerprints, never request bodies or opaque replay. */
3
3
  export declare class ReplayRecoveryStore {
4
4
  private readonly now;
@@ -8,7 +8,9 @@ export declare class ReplayRecoveryStore {
8
8
  view(owner: object, proof: string | undefined): ReplayRecoveryView;
9
9
  recordFailure(owner: object, proof: string, model: string, body: string | undefined): void;
10
10
  setEnabled(owner: object, proof: string | undefined, revision: string, enabled: boolean): ReplayRecoveryView;
11
- prepare(owner: object, proof: string, model: string): (payload: unknown) => unknown;
11
+ authorize(owner: object, proof: string | undefined, revision: string, duration: ReplayRecoveryDuration): ReplayRecoveryView;
12
+ endTurn(owner: object, turn: number): void;
13
+ prepare(owner: object, proof: string, model: string, turn?: number): (payload: unknown) => unknown;
12
14
  remove(owner: object): void;
13
15
  clear(): void;
14
16
  }
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.95",
4
+ "version": "0.4.0-alpha.96",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",