@sparkelf/dsh-plus 0.2.9-alpha.91 → 0.2.9-alpha.93

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.
@@ -60,10 +60,9 @@ index 23e71c9c..50e1d3a9 100644
60
60
 
61
61
  /** Subscribe to the main key without subscribing the column frame to each panel id. */
62
62
  diff --git a/packages/client/ui-model-selection/src/client/ModelSelect.tsx b/packages/client/ui-model-selection/src/client/ModelSelect.tsx
63
- index 3eea3e37..df98d1a4 100644
64
63
  --- a/packages/client/ui-model-selection/src/client/ModelSelect.tsx
65
64
  +++ b/packages/client/ui-model-selection/src/client/ModelSelect.tsx
66
- @@ -81,11 +81,19 @@ export function ModelSelect(
65
+ @@ -93,11 +93,19 @@
67
66
  const lastActionRef = useRef<'load' | 'select'>('load')
68
67
  const [toast, setToast] = useState<{ seq: number; text: string } | null>(null)
69
68
  const toastSeq = useRef(0)
@@ -83,14 +82,14 @@ index 3eea3e37..df98d1a4 100644
83
82
  const itemRefs = useRef<(HTMLButtonElement | null)[]>([])
84
83
  const id = useId()
85
84
  const anchorStyle: CSSProperties & Record<'--dsh-model-anchor', string> = {
86
- @@ -481,7 +489,9 @@ export function ModelSelect(
87
- ref={menuRef}
85
+ @@ -538,7 +546,9 @@
86
+ tabIndex={pane.kind === 'detail' ? -1 : undefined}
88
87
  id={`${id}-menu`}
89
- className={css.menu}
88
+ className={clsx(css.menu, (pane.kind === 'root' || pane.kind === 'detail') && css.settingsMenu)}
90
89
  - style={anchorStyle}
91
90
  + style={{ ...anchorStyle, ...(columnWidth === null
92
91
  + ? {}
93
92
  + : { maxWidth: Math.max(0, columnWidth - 24) }) }}
94
- role={pane === 'model' ? 'group' : 'menu'}
95
- aria-label={t('menu.aria')}
96
- aria-busy={state.status === 'loading' || busy}
93
+ // A detail pane holds plugin controls and prose, not menu items.
94
+ role={pane.kind === 'model' || pane.kind === 'detail' ? 'group' : 'menu'}
95
+ aria-label={pane.kind === 'detail' ? pane.pane.title : t('menu.aria')}
@@ -172,12 +172,11 @@ index 0c82575d..e3217782 100644
172
172
  + })
173
173
  })
174
174
  diff --git a/packages/session-query/session-query-sqlite/src/index.ts b/packages/session-query/session-query-sqlite/src/index.ts
175
- index 7c95afa2..97d1763e 100644
176
175
  --- a/packages/session-query/session-query-sqlite/src/index.ts
177
176
  +++ b/packages/session-query/session-query-sqlite/src/index.ts
178
- @@ -9,11 +9,12 @@ import { SESSION_FORMAT_VERSION, SessionSeq } from '@deepseek-ai/dsh-session'
179
- import type { DatabaseSync } from 'node:sqlite'
177
+ @@ -10,11 +10,12 @@
180
178
  import { Context, Service, type Fiber } from '@deepseek-ai/cordis'
179
+ import { brandString } from '@deepseek-ai/dsh-brand'
181
180
  import z from '@deepseek-ai/schemastery'
182
181
  -import type { Session, SessionEvent, SessionHeader, SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session'
183
182
  +import type { Session, SessionEvent, SessionHeader, SessionId, SessionLogOffset, SessionMessageProjection } from '@deepseek-ai/dsh-session'
@@ -192,7 +191,7 @@ index 7c95afa2..97d1763e 100644
192
191
  } from '@deepseek-ai/dsh-session-persistence'
193
192
  import SessionQueryEngine, {
194
193
  SESSION_QUERY_DEFAULT_PERSISTED_INSPECT_CONCURRENCY,
195
- @@ -24,6 +25,7 @@ import SessionQueryEngine, {
194
+ @@ -24,6 +25,7 @@
196
195
  assertSessionHeadersCompatible,
197
196
  buildSessionEventSearchDocuments,
198
197
  readColdSessionLog,
@@ -200,7 +199,7 @@ index 7c95afa2..97d1763e 100644
200
199
  } from '@deepseek-ai/dsh-session-query'
201
200
  import type {
202
201
  Config as SessionQueryConfig,
203
- @@ -519,10 +521,27 @@ export class SqliteSessionQueryEngine extends SessionQueryEngine {
202
+ @@ -520,10 +522,27 @@
204
203
  // live-preferred.
205
204
  if (initiallyLive.has(entry.header.id) || this.ctx.sessions.get(entry.header.id) !== undefined) continue
206
205
  assertNotAborted(signal)
@@ -230,7 +229,7 @@ index 7c95afa2..97d1763e 100644
230
229
  }
231
230
  assertNotAborted(signal)
232
231
  const afterSnapshots = await persistence.list(listOptions)
233
- @@ -547,7 +566,7 @@ export class SqliteSessionQueryEngine extends SessionQueryEngine {
232
+ @@ -548,7 +567,7 @@
234
233
  }
235
234
  const live = new Map<SessionId, ObservedSession>()
236
235
  for (const session of this.ctx.sessions.list()) {
@@ -239,7 +238,7 @@ index 7c95afa2..97d1763e 100644
239
238
  const durable = persisted.get(session.id)
240
239
  if (durable !== undefined) assertSessionHeadersCompatible(observed.header, durable.header)
241
240
  live.set(session.id, observed)
242
- @@ -613,6 +632,34 @@ export class SqliteSessionQueryEngine extends SessionQueryEngine {
241
+ @@ -614,6 +633,34 @@
243
242
  }
244
243
  }
245
244
 
@@ -274,7 +273,7 @@ index 7c95afa2..97d1763e 100644
274
273
  private _replaceLiveSession(entry: ObservedSession, generation: number, persisted: boolean): void {
275
274
  this._deleteSession('live', entry.header.id)
276
275
  const db = this._requireDb()
277
- @@ -868,22 +915,23 @@ function selectedDocumentsParams(query: string, persistenceVisible: boolean): Ar
276
+ @@ -869,22 +916,23 @@
278
277
  ]
279
278
  }
280
279
 
@@ -365,18 +364,17 @@ index 8788c8ea..d191b9cc 100644
365
364
  throw new SessionQueryError(
366
365
  /* v8 ignore next -- foldSurface throws Error instances */
367
366
  diff --git a/packages/session-query/session-query/src/index.ts b/packages/session-query/session-query/src/index.ts
368
- index dfb11fec..2d1f095a 100644
369
367
  --- a/packages/session-query/session-query/src/index.ts
370
368
  +++ b/packages/session-query/session-query/src/index.ts
371
- @@ -11,6 +11,7 @@ import {
372
- SessionSeq,
369
+ @@ -12,6 +12,7 @@
373
370
  snapshotSessionEvent,
371
+ validateSessionLog,
374
372
  type SessionId,
375
373
  + type SessionMessageProjection,
376
374
  type SessionSeq as SessionSeqType,
377
375
  } from '@deepseek-ai/dsh-session'
378
- import { foldSessionTitle } from '@deepseek-ai/dsh-session-title'
379
- @@ -131,6 +132,27 @@ export abstract class SessionQueryEngine extends Service {
376
+ import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection'
377
+ @@ -136,6 +137,23 @@
380
378
  this._observations = new SessionObservationReader(ctx, preparedSessionCacheSize)
381
379
  }
382
380
 
@@ -385,13 +383,9 @@ index dfb11fec..2d1f095a 100644
385
383
  + *
386
384
  + * A log is interpreted by whichever projections were mounted when its durable
387
385
  + * decisions were written, so a cold read must use the mounted set rather than
388
- + * the first-party catalog alone. Replaying with only the catalog is what makes
389
- + * an `image/offload` decision recorded against an already-hoisted message
390
- + * throw on a later read: `image/hoist` moved those image occurrences onto an
391
- + * earlier carrier, so the recorded depth-first indexes no longer resolve.
392
- + *
393
- + * Catalog definitions are kept first; a live contribution of the same event
394
- + * type is dropped because the fold rejects duplicate ownership anyway.
386
+ + * the first-party catalog alone. Catalog definitions are kept first; a live
387
+ + * contribution of the same event type is dropped because the fold rejects
388
+ + * duplicate ownership anyway.
395
389
  + * @returns borrowed catalog definitions followed by live plugin contributions.
396
390
  + */
397
391
  + protected get replayMessageProjections(): readonly SessionMessageProjection[] {
@@ -401,19 +395,19 @@ index dfb11fec..2d1f095a 100644
401
395
  + return [...currentSessionMessageProjections, ...live.filter(projection => !seen.has(projection.type))]
402
396
  + }
403
397
  +
404
- /**
405
- * Observe one exact live or prepared Session without a persistence listing preflight.
406
- * @param sessionId - logical Session identity.
407
- @@ -200,7 +222,7 @@ export abstract class SessionQueryEngine extends Service {
398
+ /** Register the Session-list metadata projection for this service's lifetime. */
399
+ protected async [Service.init](): Promise<void> {
400
+ this._listMetadata = await this.ctx.sessionProjections.register(sessionListMetadataDefinition)
401
+ @@ -207,7 +225,7 @@
408
402
  loaded.events,
409
- loaded.header,
410
403
  loaded.inheritedEventCount,
404
+ undefined,
411
405
  - currentSessionMessageProjections,
412
406
  + this.replayMessageProjections,
413
407
  )
414
408
  return {
415
409
  session: structuredClone(loaded.header),
416
- @@ -280,7 +302,7 @@ export abstract class SessionQueryEngine extends Service {
410
+ @@ -287,7 +305,7 @@
417
411
  */
418
412
  async listEvents(sessionId: SessionId): Promise<SessionEventRecord[]> {
419
413
  const loaded = await this._corpus.load(sessionId)
@@ -422,7 +416,7 @@ index dfb11fec..2d1f095a 100644
422
416
  }
423
417
 
424
418
  /**
425
- @@ -309,7 +331,7 @@ export abstract class SessionQueryEngine extends Service {
419
+ @@ -316,7 +334,7 @@
426
420
  filters: readonly SessionEventResultFilter[],
427
421
  ): Promise<SessionEventSearchDocument[]> {
428
422
  const loaded = await this._corpus.load(sessionId)
@@ -431,7 +425,7 @@ index dfb11fec..2d1f095a 100644
431
425
  return filterSessionEventDocuments(documents, filters)
432
426
  }
433
427
 
434
- @@ -325,7 +347,7 @@ export abstract class SessionQueryEngine extends Service {
428
+ @@ -332,7 +350,7 @@
435
429
  session: structuredClone(loaded.header),
436
430
  inheritedEventCount: loaded.inheritedEventCount,
437
431
  capturedThroughSeq: loaded.events.at(-1)?.seq ?? null,
@@ -440,7 +434,7 @@ index dfb11fec..2d1f095a 100644
440
434
  }
441
435
  }
442
436
 
443
- @@ -354,7 +376,7 @@ export abstract class SessionQueryEngine extends Service {
437
+ @@ -361,7 +379,7 @@
444
438
  signal?.throwIfAborted()
445
439
  return {
446
440
  session: loaded.header,
@@ -195,22 +195,21 @@ index 5dec1bda..f596cd47 100644
195
195
  customBaseUrlInvalid: 'Insira um URL HTTP ou HTTPS válido.',
196
196
  customNeedsModels: 'Um provedor personalizado precisa de pelo menos um modelo.',
197
197
  diff --git a/packages/llm/llm-pi-ai/src/adapter.ts b/packages/llm/llm-pi-ai/src/adapter.ts
198
- index f3f9ac00..f5ef95a1 100644
199
198
  --- a/packages/llm/llm-pi-ai/src/adapter.ts
200
199
  +++ b/packages/llm/llm-pi-ai/src/adapter.ts
201
- @@ -58,7 +58,7 @@ import type {
202
- } from '@deepseek-ai/dsh-llm'
200
+ @@ -58,7 +58,7 @@
203
201
  import type { AttachmentStore, ImageAttachmentRef } from '@deepseek-ai/dsh-attachment'
202
+ import { brandString } from '@deepseek-ai/dsh-brand'
204
203
  import { idleWatchdog, timeoutOf } from '@deepseek-ai/dsh-timeout'
205
204
  -import type { ResolvedPiAiProviderProfile } from './config.ts'
206
205
  +import type { PiAiReasoningSummary, ResolvedPiAiProviderProfile } from './config.ts'
207
206
  import { requestImageTarget, toPiContext } from './context.ts'
207
+ import { resolveImageRequestBudget } from './image-policy.ts'
208
208
  import { conversationUpdates, createModels, getSupportedThinkingLevels } from './models.ts'
209
- import { toStreamChunks } from './stream.ts'
210
- @@ -145,9 +145,85 @@ export interface PiAiAuthInjection {
209
+ @@ -146,9 +146,76 @@
211
210
  authContext: AuthContext
212
211
  }
213
-
212
+
214
213
  +/** Whether one Responses input item is replayed reasoning with response status metadata. */
215
214
  +function hasReasoningInputStatus(item: unknown): boolean {
216
215
  + const inputItem = item as Record<string, unknown>
@@ -231,12 +230,6 @@ index f3f9ac00..f5ef95a1 100644
231
230
  +
232
231
  +/**
233
232
  + * Force one model's `reasoning.summary` to a chosen spelling, or drop it.
234
- + *
235
- + * pi-ai writes `summary: options?.reasoningSummary || 'auto'` whenever a
236
- + * Responses model reasons, so the field leaves even when nothing asked for it.
237
- + * A gateway that refuses the field therefore fails every reply from that model
238
- + * rather than merely omitting a summary, and only a payload hook can keep the
239
- + * field off the wire.
240
233
  + * @param payload - the request body pi-ai built.
241
234
  + * @param summary - the configured spelling, or `omit` to drop the field.
242
235
  + * @returns the adjusted body, or undefined to leave the request untouched.
@@ -253,9 +246,6 @@ index f3f9ac00..f5ef95a1 100644
253
246
  +
254
247
  +/**
255
248
  + * The payload hook a model needs, if any.
256
- + *
257
- + * One hook field is a function, so a model needing both adjustments gets a
258
- + * composition rather than one silently replacing the other.
259
249
  + * @param profile - the resolved route profile.
260
250
  + * @param model - the model being called, which may pin its own summary.
261
251
  + * @returns the `onPayload` option for this call, or an empty object.
@@ -293,7 +283,7 @@ index f3f9ac00..f5ef95a1 100644
293
283
  reasoning: ModelThinkingLevel | undefined,
294
284
  apiKey: string | undefined,
295
285
  ): SimpleStreamOptions {
296
- @@ -160,6 +236,7 @@ function profileOptions(
286
+ @@ -161,6 +228,7 @@
297
287
  ...profile.transport === undefined ? {} : { transport: profile.transport },
298
288
  ...profile.timeoutMs === undefined ? {} : { timeoutMs: profile.timeoutMs },
299
289
  ...profile.websocketConnectTimeoutMs === undefined ? {} : { websocketConnectTimeoutMs: profile.websocketConnectTimeoutMs },
@@ -301,7 +291,7 @@ index f3f9ac00..f5ef95a1 100644
301
291
  // The agent recovery layer owns visible attempts; one adapter call is one SDK attempt.
302
292
  maxRetries: 0,
303
293
  }
304
- @@ -473,7 +550,7 @@ export class PiAiAdapter extends LlmAdapter {
294
+ @@ -471,7 +539,7 @@
305
295
  this.config.onThinkingOmitted?.({ provider: options.provider, model: options.model, count })
306
296
  })
307
297
  const events = snapshot.models.streamSimple(model, context, {
@@ -1,127 +0,0 @@
1
- diff --git a/packages/client/connection/src/browser-auth.ts b/packages/client/connection/src/browser-auth.ts
2
- index 5c8594df..e5f5fa9f 100644
3
- --- a/packages/client/connection/src/browser-auth.ts
4
- +++ b/packages/client/connection/src/browser-auth.ts
5
- @@ -198,12 +198,40 @@ async function initializeSecret(credentials: CredentialProvider): Promise<Buffer
6
- return secret
7
- }
8
-
9
- +/** Browser-session policy selected once while Connection activates. */
10
- +export interface BrowserAuthentication {
11
- + /** Add any authentication input to the clean application URL. */
12
- + authenticatedUrl(baseUrl: string): string
13
- + /** Authorize one frontend index request, owning the response when denied or redirected. */
14
- + authorizeIndex(req: ConnectionIndexRequest, res: ConnectionIndexResponse, secure?: boolean): boolean
15
- + /** Authorize one connect request, owning the response when denied or redirected. */
16
- + authorizeConnect(
17
- + req: ConnectionIndexRequest,
18
- + res: ConnectionIndexResponse,
19
- + secure: boolean,
20
- + publish: (interactions: ConnectionInteractions) => PeerId,
21
- + ): void
22
- + /** Decide whether a trusted Host request has the required browser identity. */
23
- + isAuthenticated(request: ConnectionTrustRequest, secure?: boolean): boolean
24
- + /** Resolve the peer identity of an authenticated API request, or undefined when it is not. */
25
- + authenticateApi(request: ConnectionTrustRequest, secure?: boolean): PeerId | undefined
26
- +}
27
- +
28
- +/** Profile-selected policy that admits every request after the independent Host/Origin fence. */
29
- +export const DISABLED_BROWSER_AUTHENTICATION: BrowserAuthentication = {
30
- + authenticatedUrl: baseUrl => new URL(baseUrl).href,
31
- + authorizeIndex: () => true,
32
- + authorizeConnect: () => undefined,
33
- + isAuthenticated: () => true,
34
- + authenticateApi: () => undefined,
35
- +}
36
- +
37
- /**
38
- * Process launch-token exchange and persistent signed-cookie verification.
39
- * Connection loads the credential provider's signing secret during activation
40
- * and retains it for synchronous request authentication.
41
- */
42
- -export class BrowserAuth {
43
- +export class BrowserAuth implements BrowserAuthentication {
44
- private readonly launchToken: string
45
- private readonly maxAgeMilliseconds: number
46
-
47
- diff --git a/packages/client/connection/src/index.ts b/packages/client/connection/src/index.ts
48
- index d563cd40..0c0d2279 100644
49
- --- a/packages/client/connection/src/index.ts
50
- +++ b/packages/client/connection/src/index.ts
51
- @@ -10,7 +10,7 @@ import { API_PATH } from './api-path.ts'
52
- import { CONNECT_PATH } from './connect-protocol.ts'
53
- import { bridge, DEFAULT_MAX_REQUEST_BODY_BYTES } from './http-bridge.ts'
54
- import { assertTrustedAuthority } from './api-request-trust.ts'
55
- -import { BrowserAuth } from './browser-auth.ts'
56
- +import { BrowserAuth, DISABLED_BROWSER_AUTHENTICATION } from './browser-auth.ts'
57
- import { HostConnectionService } from './rpc-host.ts'
58
- import { ConnectionRecoveryConfigSchema, resolveConnectionConfig, type ConnectionRecoveryConfig } from './recovery-config.ts'
59
-
60
- @@ -103,6 +103,8 @@ export interface ConnectionConfig {
61
- * an entry here. A non-canonical or non-bare authority fails plugin load.
62
- */
63
- trustedHosts?: string[]
64
- + /** Host API browser identity policy; Host/Origin trust remains independent. Default: `required`. */
65
- + browserAuthentication?: 'required' | 'disabled'
66
- /** Absolute browser and API cookie lifetime in days. Default: 30. */
67
- cookieMaxAgeDays?: number
68
- /** Maximum buffered JSON body for every `/api` request. Default: 300 MiB. */
69
- @@ -112,6 +114,7 @@ export interface ConnectionConfig {
70
- export const Config: z<ConnectionConfig> = z.object({
71
- recovery: ConnectionRecoveryConfigSchema.default({}),
72
- trustedHosts: z.array(String).default([]),
73
- + browserAuthentication: z.union(['required', 'disabled']).default('required'),
74
- cookieMaxAgeDays: z.natural().min(1).default(30),
75
- maxRequestBodyBytes: z.natural().min(1).default(DEFAULT_MAX_REQUEST_BODY_BYTES),
76
- })
77
- @@ -127,16 +130,21 @@ export async function apply(ctx: Context, config?: ConnectionConfig): Promise<vo
78
- const recovery = resolveConnectionConfig(config?.recovery)
79
- // The Loader resolves schema defaults; hand-built test contexts may pass none.
80
- const trustedHosts = config?.trustedHosts ?? []
81
- + const browserAuthentication = config?.browserAuthentication ?? 'required'
82
- const cookieMaxAgeDays = config?.cookieMaxAgeDays ?? 30
83
- const maxRequestBodyBytes = config?.maxRequestBodyBytes ?? DEFAULT_MAX_REQUEST_BODY_BYTES
84
- // Config boundary: a malformed entry fails the load loudly here rather than
85
- // silently authorizing its hostname prefix at request time.
86
- for (const entry of trustedHosts) assertTrustedAuthority(entry)
87
- assertImageBodyCapacity(ctx, maxRequestBodyBytes)
88
- + // 配置在激活时只选择一次策略;disabled不会创建token或credential record。
89
- + const browserAuth = browserAuthentication === 'required'
90
- + ? await BrowserAuth.create(ctx.root, ctx.credentials, cookieMaxAgeDays)
91
- + : DISABLED_BROWSER_AUTHENTICATION
92
- const connection = new HostConnectionService(
93
- ctx,
94
- trustedHosts,
95
- - await BrowserAuth.create(ctx.root, ctx.credentials, cookieMaxAgeDays),
96
- + browserAuth,
97
- )
98
- ctx.inject(['webServer'], (webCtx) => {
99
- assertImageBodyCapacity(webCtx, maxRequestBodyBytes)
100
- diff --git a/packages/client/connection/src/rpc-host.ts b/packages/client/connection/src/rpc-host.ts
101
- index 88e7b48b..43a3feb7 100644
102
- --- a/packages/client/connection/src/rpc-host.ts
103
- +++ b/packages/client/connection/src/rpc-host.ts
104
- @@ -13,7 +13,7 @@ import { clientRequestSchema } from './rpc-schema.ts'
105
- import { bridge } from './http-bridge.ts'
106
- import { isRemoteAuthority, isTrustedApiRequest } from './api-request-trust.ts'
107
- import { API_PATH } from './api-path.ts'
108
- -import type { BrowserAuth } from './browser-auth.ts'
109
- +import type { BrowserAuthentication } from './browser-auth.ts'
110
- import { Peer } from './peer.ts'
111
- import type {
112
- PeerAdmission,
113
- @@ -82,12 +82,12 @@ export class HostConnectionService extends Service implements HostConnectionHand
114
- * Provide the Host half over the active HTTP server.
115
- * @param ctx - owning Connection plugin context.
116
- * @param trustedHosts - deployment authorities accepted by the Host/Origin fence.
117
- - * @param browserAuth - process token and persistent browser-session owner.
118
- + * @param browserAuth - profile-selected browser-session policy.
119
- */
120
- constructor(
121
- ctx: Context,
122
- private readonly trustedHosts: readonly string[],
123
- - private readonly browserAuth: BrowserAuth,
124
- + private readonly browserAuth: BrowserAuthentication,
125
- ) {
126
- super(ctx, 'connection')
127
- this.owner = ctx