Merge remote-tracking branch 'origin/master' into feat/session-workspace-root

master moved the `workingDirectory` projection-key declaration to
`src/types.ts`; this branch's `workspaceRoot` key follows it there. The three
recorded scenarios master added (`session-list-tools`,
`computer-use-cua-driver-mcp-ptc`, `sdk/subagent-dsh-sdk-empty-route`) drop the
removed `working_directory` tool and the delegation `cwd` parameter from their
sidecars.
This commit is contained in:
LegGasai committed 2026-11-16 17:59:21 +08:00
commit 23734da2b6
763 files changed
+23895 -10244

No files matched your search

+2 -30
View File
@@ -13,7 +13,7 @@ import { canOpenNativePath, nativeFileManager, nativeFileApplications, openNativ
import type { SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-projection-cache'
import type { SessionObservation } from '@deepseek-ai/dsh-session-query'
import { Remote, RemoteError, TypertRemoteService, principalOf, type TypertResourceResolveInput } from '@deepseek-ai/dsh-typert-protocol'
import { Remote, RemoteError, TypertRemoteService, principalOf } from '@deepseek-ai/dsh-typert-protocol'
import { canonicalClientTimeZone } from '@deepseek-ai/dsh-util-time'
import { assertNever } from '@deepseek-ai/dsh-util-values'
import type {} from '@deepseek-ai/dsh-api-remote-access'
@@ -22,6 +22,7 @@ import {
type ApiSessionAgentResult,
} from './agent.ts'
import { SessionCommandController, hasPromptContent } from './commands.ts'
import { resolveSessionResource } from './session-resource.ts'
import { SessionControlController } from './control.ts'
import { HistoryController } from './history/controller.ts'
import { StateController } from './state/controller.ts'
@@ -35,7 +36,6 @@ import { ArchivedSessionGate } from './archived-session-gate.ts'
import type {
ModelCatalog,
SessionWorkspacePathApplication,
SessionAddress,
SessionAttachmentRequest,
SessionAttachmentValue,
SessionCancelRequest,
@@ -79,34 +79,6 @@ declare module '@deepseek-ai/cordis' {
}
}
/**
* Extract the Session resource from an ID or a history address.
*
* Registers as the `session` kind default, so it applies to every Remote method of
* every namespace: a top-level `sessionId` parameter, otherwise the first object
* parameter carrying `sessionId` or an `address`. A new request type whose first
* object parameter has an unrelated `address` field would be read as an address.
* @param input - validated wire arguments and their ordered parameter descriptions.
* @returns the named Session identity, otherwise the first object's Session identity or history address.
* @throws Error when the request object supplies both sessionId and address.
*/
function resolveSessionResource({ args, parameters }: TypertResourceResolveInput): SessionId | undefined {
const sessionParameter = parameters.find(parameter => parameter.name === 'sessionId' || parameter.wire === 'sessionId')
if (sessionParameter !== undefined) return args[sessionParameter.wire] as SessionId | undefined
for (const parameter of parameters) {
const value = args[parameter.wire]
if (typeof value !== 'object' || value === null || Array.isArray(value)) continue
const request = value as { readonly sessionId?: SessionId; readonly address?: SessionAddress }
const address = request.address
if (request.sessionId !== undefined && address !== undefined) {
throw new Error('Session resource request must not contain both sessionId and address')
}
return request.sessionId ?? (address === undefined ? undefined
: address.kind === 'session' ? address.sessionId : address.childSessionId)
}
return undefined
}
/** Session Controller deployment policy. */
export interface Config {
/** Override platform desktop-opener detection. */
+6 -40
View File
@@ -5,8 +5,8 @@ import { scheduler } from 'node:timers/promises'
import type { Context } from '@deepseek-ai/cordis'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import type { ImageAttachmentLimits } from '@deepseek-ai/dsh-attachment'
import type { Session, SessionEvent, SessionHeader, SessionId } from '@deepseek-ai/dsh-session'
import type { ProjectionHandle, ProjectionSnapshot } from '@deepseek-ai/dsh-session-projection'
import type { Session, SessionHeader, SessionId } from '@deepseek-ai/dsh-session'
import type { ProjectionSnapshot } from '@deepseek-ai/dsh-session-projection'
import type {} from '@deepseek-ai/dsh-session-projection-cache'
import { SessionQueryError, type SessionRecord, type SessionSearchCursor } from '@deepseek-ai/dsh-session-query'
import { RemoteError } from '@deepseek-ai/dsh-typert-protocol'
@@ -24,11 +24,6 @@ const SEARCH_PROVIDER_CALL_LIMIT = 100
const SESSION_SEARCH_QUERY_MAX_CHARS = 500
const MESSAGE_TYPES = new Set(['user/message', 'assistant/message'])
const sessionListMetadataSchema: z.ZodType<SessionListMetadata> = z.object({
blank: z.boolean(),
lastPromptAt: z.number().nullable(),
})
const imageLimitsSchema = z.object({
maxImageBytes: z.number().int().positive(),
maxImagesPerMessage: z.number().int().positive(),
@@ -38,25 +33,6 @@ const imageLimitsSchema = z.object({
mediaTypes: z.array(z.string()),
}) as unknown as z.ZodType<ImageAttachmentLimits>
/**
* Advance the Session-list metadata projection by one committed event.
* @param state - metadata before the event.
* @param event - next committed Session event.
* @returns the original or advanced metadata value.
*/
export function applySessionListMetadata(
state: SessionListMetadata,
event: SessionEvent,
): SessionListMetadata {
const blank = state.blank && event.type !== 'turn/start'
const lastPromptAt = event.type === 'user/message' && event.data.source.kind === 'user'
? event.time
: state.lastPromptAt
return blank === state.blank && lastPromptAt === state.lastPromptAt
? state
: { blank, lastPromptAt }
}
/**
* Return the longest prefix containing at most `maximum` Unicode code points.
* @param value - source text.
@@ -76,8 +52,6 @@ export function truncateUnicodeCodePoints(value: string, maximum: number): strin
/** Owns list projection registration, bounded cold summaries, and authorized search. */
export class ApiSessionList {
private listMetadata!: ProjectionHandle<SessionListMetadata>
/**
* @param ctx - Host context carrying Session, query, persistence, and projection services.
* @param workSliceMs - Resolved positive integral list-work budget in milliseconds.
@@ -89,14 +63,6 @@ export class ApiSessionList {
* @returns when all required registrations are ready.
*/
async initialize(): Promise<void> {
this.listMetadata = await this.ctx.sessionProjections.register<'sessionListMetadata', SessionListMetadata>({
key: 'sessionListMetadata',
stateSchema: sessionListMetadataSchema,
init: () => ({ blank: true, lastPromptAt: null }),
apply: applySessionListMetadata,
wire: { viewSchema: sessionListMetadataSchema, view: state => state },
stateVersion: 1,
})
await this.ctx.sessionProjections.register<'imageLimits', null>({
key: 'imageLimits',
stateSchema: z.null(),
@@ -113,17 +79,17 @@ export class ApiSessionList {
/**
* Build one current attached-Session summary.
* Blankness and recency come from the `sessionListMetadata` handle; projection
* Blankness and recency come from `sessionQuery.getListMetadata`; projection
* hints carry every summary key computed through `snapshot`. The first call
* for a Session computes these projections over its whole in-memory log, and
* later calls advance them incrementally. The handle read and the hint with
* the same key come from one cell; the handle read does not depend on any
* later calls advance them incrementally. The metadata read and the hint with
* the same key come from one cell; the metadata read does not depend on any
* other unit's view.
* @param session - attached Session to summarize.
* @returns current list metadata and available projections.
*/
summaryFor(session: Session): SessionSummary {
const metadata = this.listMetadata.stateOf(session)
const metadata = this.ctx.sessionQuery.getListMetadata(session)
const projections = this.projectionsFor(session.header, session)
return {
sessionId: session.id,
@@ -0,0 +1,38 @@
/**
* The `session` resource kind's default identity extraction: the Session one
* Remote call names, read from its validated wire arguments.
* @module @deepseek-ai/dsh-api-session-controller/session-resource
*/
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { TypertResourceResolveInput } from '@deepseek-ai/dsh-typert-protocol'
import type { SessionAddress } from './types.ts'
/**
* Extract the Session resource from an ID or a history address.
*
* Registers as the `session` kind default, so it applies to every Remote method of
* every namespace: a top-level `sessionId` parameter, otherwise the first object
* parameter carrying `sessionId` or an `address`. A new request type whose first
* object parameter has an unrelated `address` field would be read as an address.
* @param input - validated wire arguments and their ordered parameter descriptions.
* @returns the named Session identity, otherwise the first object's Session identity or history address.
* @throws Error when the request object supplies both sessionId and address.
*/
export function resolveSessionResource(input: TypertResourceResolveInput): SessionId | undefined {
const { args, parameters } = input
const sessionParameter = parameters.find(parameter => parameter.name === 'sessionId' || parameter.wire === 'sessionId')
if (sessionParameter !== undefined) return args[sessionParameter.wire] as SessionId | undefined
for (const parameter of parameters) {
const value = args[parameter.wire]
if (typeof value !== 'object' || value === null || Array.isArray(value)) continue
const request = value as { readonly sessionId?: SessionId; readonly address?: SessionAddress }
const address = request.address
if (request.sessionId !== undefined && address !== undefined) {
throw new Error('Session resource request must not contain both sessionId and address')
}
return request.sessionId ?? (address === undefined ? undefined
: address.kind === 'session' ? address.sessionId : address.childSessionId)
}
return undefined
}
+2 -10
View File
@@ -14,12 +14,12 @@ import type { Principal } from '@deepseek-ai/dsh-typert-protocol'
import type { JsonValue } from '@deepseek-ai/dsh-util-values'
import type { WorkspaceId } from '@deepseek-ai/dsh-workspace/types'
export type { SessionListMetadata } from '@deepseek-ai/dsh-session-query/types'
declare module '@deepseek-ai/dsh-session-projection/types' {
interface SessionProjectionMap {
/** Eligible latest failed turn/end for an empty prompt, or null. */
conversationContinuation: SessionSeq | null
/** Persisted facts used to summarize a Session without activating it. */
sessionListMetadata: SessionListMetadata
/**
* Image-intake limits enforced by the Session prompt endpoint. Boot
* constant, excluded from Session summary payloads: every Session shares
@@ -29,14 +29,6 @@ declare module '@deepseek-ai/dsh-session-projection/types' {
}
}
/** Persisted hints used to summarize a cold Session. */
export interface SessionListMetadata {
/** Whether the folded prefix contains no turn. */
readonly blank: boolean
/** Latest human-authored prompt time in the folded prefix. */
readonly lastPromptAt: number | null
}
/**
* Summary wire values a Session-list row carries. A `sequenced` block carries
* every summary key computed at its `asOfSeq`; a `cached` block carries the