@deepseek-ai/dsh-client-test-runtime 0.2.2-rc.5 → 0.2.3-alpha.2

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/src/sessions.ts CHANGED
@@ -7,10 +7,15 @@ import {
7
7
  import type {
8
8
  AgentContext, ISessions, ProjectionsFace, SessionBinding, SessionFace, SessionListState,
9
9
  SessionEventLikeEntry, SessionLiveEventEntry, SessionSearchResultItem,
10
- SessionReference, SessionReferenceSource, SessionRetainInfo, SessionRetainOptions,
10
+ SessionReference, SessionReferenceSource, SessionRetainFacet, SessionRetainInfo, SessionRetainOptions,
11
11
  SessionSnapshot, SessionSummary, SessionTarget, SubmissionHandle,
12
12
  } from '@deepseek-ai/dsh-api-session-controller/client'
13
13
  import { scopeIdentityOf } from '@deepseek-ai/dsh-api-session-controller/src/client/scope.ts'
14
+ import {
15
+ EMPTY_RETAIN_INFO,
16
+ heldFacets,
17
+ shiftRetention,
18
+ } from '@deepseek-ai/dsh-api-session-controller/src/client/sessions/facets.ts'
14
19
  import type { SessionRequestId } from '@deepseek-ai/dsh-api-session-controller/types'
15
20
  import type { SubagentAddress } from '@deepseek-ai/dsh-subagent/client'
16
21
  import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
@@ -214,17 +219,8 @@ interface OpeningControl {
214
219
  readonly reject: (error: unknown) => void
215
220
  }
216
221
 
217
- function freezeRetainedBy(
218
- counts: Partial<Record<SessionReferenceSource, number>>,
219
- ): SessionRetainInfo['retainedBy'] {
220
- Object.setPrototypeOf(counts, null)
221
- return Object.freeze(counts)
222
- }
223
-
224
- const EMPTY_RETAIN_INFO: SessionRetainInfo = Object.freeze({
225
- referenceCount: 0,
226
- retainedBy: freezeRetainedBy({}),
227
- })
222
+ /** Fixture references default to a rendering use, so Conversation assembly runs as it does under a main view. */
223
+ const DEFAULT_TEST_RETAIN: SessionRetainOptions = { source: 'testFixture', facets: { conversation: true } }
228
224
 
229
225
  // TestSessions implements SessionReference against its fixture-owned
230
226
  // SessionGeneration without importing the production service's private record.
@@ -526,16 +522,17 @@ export class TestSessions implements ISessions {
526
522
  /* jscpd:ignore-start -- The fixture intentionally mirrors production SessionReference acquisition and release semantics. */
527
523
  retain(
528
524
  target: SessionTarget,
529
- options: SessionRetainOptions = { source: 'testFixture' },
525
+ options: SessionRetainOptions = DEFAULT_TEST_RETAIN,
530
526
  ): SessionReference {
531
- const { source, signal } = options
527
+ const { source, signal, facets } = options
532
528
  signal?.throwIfAborted()
533
529
  if (this.closed) throw new Error('test Session Controller is disposed')
534
530
  const id = this.resolveTarget(target)
535
531
  const generation = this.generations.get(id) ?? this.materialize(id, this.require(id))
536
- const reference = this.retainGeneration(id, generation, source)
532
+ const connected = options.connection !== false
533
+ const reference = this.retainGeneration(id, generation, source, heldFacets(facets), connected)
537
534
  try {
538
- reference.attachOpening(generation.opening, signal)
535
+ reference.attachOpening(connected ? generation.opening : Promise.resolve(), signal)
539
536
  return reference
540
537
  } catch (error: unknown) {
541
538
  reference.release()
@@ -577,7 +574,7 @@ export class TestSessions implements ISessions {
577
574
  retainFor(
578
575
  ownerCtx: Context,
579
576
  target: SessionTarget,
580
- options: SessionRetainOptions = { source: 'testFixture' },
577
+ options: SessionRetainOptions = DEFAULT_TEST_RETAIN,
581
578
  ): SessionReference {
582
579
  const reference = this.retain(target, options)
583
580
  try {
@@ -720,26 +717,15 @@ export class TestSessions implements ISessions {
720
717
  id: SessionId,
721
718
  generation: SessionGeneration,
722
719
  source: SessionReferenceSource,
720
+ facets: readonly SessionRetainFacet[],
721
+ connected: boolean,
723
722
  ): TestSessionReference {
724
- const previous = generation.retention
725
- generation.retention = Object.freeze({
726
- referenceCount: previous.referenceCount + 1,
727
- retainedBy: freezeRetainedBy({
728
- ...previous.retainedBy,
729
- [source]: (previous.retainedBy[source] ?? 0) + 1,
730
- }),
731
- })
723
+ const use = { source, facets, connected }
724
+ generation.retention = shiftRetention(generation.retention, use, 1)
732
725
  const reference = new TestSessionReference(id, generation, () => {
733
726
  if (!generation.live) return
734
- const count = generation.retention.referenceCount - 1
735
- const { [source]: sourceCount = 0, ...otherSources } = generation.retention.retainedBy
736
- const retainedBy = sourceCount > 1
737
- ? { ...otherSources, [source]: sourceCount - 1 }
738
- : otherSources
739
- generation.retention = count === 0
740
- ? EMPTY_RETAIN_INFO
741
- : Object.freeze({ referenceCount: count, retainedBy: freezeRetainedBy(retainedBy) })
742
- if (count === 0) this.drop(id, generation)
727
+ generation.retention = shiftRetention(generation.retention, use, -1)
728
+ if (generation.retention.referenceCount === 0) this.drop(id, generation)
743
729
  else this.publishRetention(id)
744
730
  })
745
731
  this.publishRetention(id)
@@ -0,0 +1,12 @@
1
+ /** Synced Config objects for specs that mount a Client plugin face directly instead of through the page entry controller. */
2
+ import type { SyncedConfig, SyncedConfigValues } from '@deepseek-ai/dsh-client-config/types'
3
+ import { SyncedConfigEntry } from '@deepseek-ai/dsh-client-modules/src/client/synced-config.ts'
4
+
5
+ /**
6
+ * Build the object a plugin activation receives as its `apply` config, holding fixed values.
7
+ * @param values - JSON values of the plugin's top-level volatile fields.
8
+ * @returns the activation's read-only Config object.
9
+ */
10
+ export function syncedConfig<C>(values: SyncedConfigValues): SyncedConfig<C> {
11
+ return new SyncedConfigEntry(values).activate() as SyncedConfig<C>
12
+ }