Merge remote-tracking branch 'origin/master' into worktree/job-kill-delivery

# Conflicts:
#	docs/config-catalog.i18n.yaml
#	docs/config-catalog.md
#	docs/config-catalog.zh.md
#	packages/client/ui-chat/src/client/contract/slots.ts
#	packages/client/ui-chat/src/client/conversation-nodes/chat-snapshot-builder.ts
#	packages/client/ui-jobs/package.json
#	packages/extensions/cordis-client-runner/src/client/slot-catalog.ts
#	snapshots/web/ptc-round/session.jsonl
#	snapshots/web/ptc-round/system-prompt.expected.md
This commit is contained in:
Yichen Jiang committed 2026-09-02 21:40:24 +08:00
commit d1ec8baaf5
834 files changed
+16455 -15106

No files matched your search

+15 -7
View File
@@ -19,7 +19,11 @@ import { SessionControlController } from './control.ts'
import { SessionHistoryController } from './history.ts'
import { observeJobRecord } from './observe-job.ts'
import { SessionFileReferences } from './file-references.ts'
import { ApiSessionList, DEFAULT_COLD_BLANK_PROBE_MAX_BYTES } from './list.ts'
import {
ApiSessionList,
DEFAULT_COLD_BLANK_PROBE_MAX_BYTES,
DEFAULT_COLD_BLANK_PROBE_MAX_EVENTS,
} from './list.ts'
import { buildModelCatalog } from './catalog.ts'
import { installModelSelectionProjection } from './model-selection-projection.ts'
import { SessionSkillCatalog } from './skill-catalog.ts'
@@ -78,7 +82,9 @@ const DEFAULT_OBSERVE_MAX_FRAME_BYTES = 64 * 1024
/** Session Controller deployment policy. */
export interface Config {
/** Maximum cold Session artifact size eligible for one full projection observation. */
/** Maximum stat-reported event count eligible for one full cold projection observation; `0` disables the event-count gate. */
readonly coldBlankProbeMaxEvents?: number
/** Maximum stat-reported artifact byte size eligible for one full cold projection observation; `0` disables the byte-size gate. */
readonly coldBlankProbeMaxBytes?: number
/** Override platform desktop-opener detection. */
readonly nativeOpen?: boolean
@@ -111,6 +117,7 @@ export class SessionController extends TypertRemoteService {
]
static Config: z<Config> = z.object({
coldBlankProbeMaxEvents: z.natural().default(DEFAULT_COLD_BLANK_PROBE_MAX_EVENTS),
coldBlankProbeMaxBytes: z.natural().default(DEFAULT_COLD_BLANK_PROBE_MAX_BYTES),
nativeOpen: z.boolean(),
observeFlushMs: z.natural().min(1).default(DEFAULT_OBSERVE_FLUSH_MS),
@@ -130,7 +137,8 @@ export class SessionController extends TypertRemoteService {
/**
* @param ctx - Host context containing the Session capability assembly.
* @param config - cold-list observation policy.
* @param config - cold-list observation and native-opener deployment policy.
* @param internals - host integrations replaceable by direct unit tests.
*/
constructor(ctx: Context, config: Config, internals: SessionControllerInternals = {}) {
super(ctx, 'sessionController', { namespace: 'session' })
@@ -144,10 +152,10 @@ export class SessionController extends TypertRemoteService {
await Promise.allSettled([...this.promotions])
}, 'session-controller.promotions')
this.history = new SessionHistoryController(ctx, (observation) => { this.promote(observation) })
this.listState = new ApiSessionList(
ctx,
config.coldBlankProbeMaxBytes ?? DEFAULT_COLD_BLANK_PROBE_MAX_BYTES,
)
this.listState = new ApiSessionList(ctx, {
coldBlankProbeMaxEvents: config.coldBlankProbeMaxEvents ?? DEFAULT_COLD_BLANK_PROBE_MAX_EVENTS,
coldBlankProbeMaxBytes: config.coldBlankProbeMaxBytes ?? DEFAULT_COLD_BLANK_PROBE_MAX_BYTES,
})
this.openPath = internals.openPath ?? openNativePath
this.canOpenPath = internals.canOpenPath
?? (() => config.nativeOpen ?? (internals.openPath !== undefined || canOpenNativePath()))
+35 -10
View File
@@ -1,6 +1,5 @@
/** Cold-safe Session list and search projection. */
import { stat } from 'node:fs/promises'
import type { Context } from '@deepseek-ai/cordis'
import type {} from '@deepseek-ai/dsh-agent-presets'
import type { ImageAttachmentLimits } from '@deepseek-ai/dsh-attachment'
@@ -20,9 +19,20 @@ import type {
SessionSearchValue, SessionSummary,
} from './types.ts'
/** Default maximum artifact size eligible for one cold projection observation. */
/** Default maximum stat-reported event count eligible for one cold projection observation. */
export const DEFAULT_COLD_BLANK_PROBE_MAX_EVENTS = 16
/** Default maximum stat-reported artifact size eligible for one cold projection observation. */
export const DEFAULT_COLD_BLANK_PROBE_MAX_BYTES = 1024
/** Resolved cold-blank probe policy: each threshold gates its stat metric; `0` disables that gate. */
export interface ColdBlankProbePolicy {
/** Maximum stat-reported `eventCount` eligible for a full observation. */
readonly coldBlankProbeMaxEvents: number
/** Maximum stat-reported `sizeBytes` eligible for a full observation. */
readonly coldBlankProbeMaxBytes: number
}
const COLD_SUMMARY_BATCH_SIZE = 16
const SEARCH_PROVIDER_CALL_LIMIT = 100
const SESSION_SEARCH_QUERY_MAX_CHARS = 500
@@ -82,11 +92,11 @@ export function truncateUnicodeCodePoints(value: string, maximum: number): strin
export class ApiSessionList {
/**
* @param ctx - Host context carrying Session, query, persistence, and projection services.
* @param coldBlankProbeMaxBytes - maximum physical artifact size eligible for a full observation.
* @param probe - stat-metadata thresholds gating a full cold observation.
*/
constructor(
private readonly ctx: Context,
private readonly coldBlankProbeMaxBytes: number,
private readonly probe: ColdBlankProbePolicy,
) {
ctx.sessionProjections.register<'sessionListMetadata', SessionListMetadata>({
key: 'sessionListMetadata',
@@ -176,7 +186,7 @@ export class ApiSessionList {
sessionId: header.id,
updatedAt: updatedAt(header, metadata),
running: false,
// A large or inaccessible cache miss remains unknown and visible.
// A large, metadata-less, or inaccessible cache miss remains unknown and visible.
blank: metadata?.blank ?? false,
...listFields(header),
...(projections === undefined ? {} : { projections }),
@@ -187,15 +197,30 @@ export class ApiSessionList {
header: SessionHeader,
signal: AbortSignal | undefined,
): Promise<SessionProjectionHints | undefined> {
if (this.coldBlankProbeMaxBytes === 0) return undefined
const { coldBlankProbeMaxEvents, coldBlankProbeMaxBytes } = this.probe
if (coldBlankProbeMaxEvents === 0 && coldBlankProbeMaxBytes === 0) return undefined
const persistence = this.ctx.get('sessionPersistence')
const location = persistence?.locate(header)
if (location === undefined) return undefined
if (persistence === undefined) return undefined
signal?.throwIfAborted()
let snapshot: Awaited<ReturnType<typeof persistence.stat>>
try {
if ((await stat(location.path)).size > this.coldBlankProbeMaxBytes) return undefined
} catch {
snapshot = await persistence.stat(header.id, signal === undefined ? {} : { signal })
} catch (error: unknown) {
// An unreadable single session degrades to unknown state instead of
// failing the whole list request.
signal?.throwIfAborted()
this.ctx.logger.warn(
`api-session.list: cold stat for "${header.id}" failed; serving it as visible: ${String(error)}`,
)
return undefined
}
if (snapshot === undefined) return undefined
if (snapshot.eventCount !== undefined) {
if (coldBlankProbeMaxEvents === 0 || snapshot.eventCount > coldBlankProbeMaxEvents) return undefined
} else if (snapshot.sizeBytes !== undefined) {
if (coldBlankProbeMaxBytes === 0 || snapshot.sizeBytes > coldBlankProbeMaxBytes) return undefined
} else {
// The backend offers no cheap size hint, so a full observation is unbounded work.
return undefined
}
try {