Merge origin/master into xtr/content-to-text

This commit is contained in:
_Kerman committed 2026-11-11 16:05:11 +08:00
commit 92fca8b2b3
1448 files changed
+14815 -9290

No files matched your search

+4 -3
View File
@@ -1,7 +1,8 @@
/** Empty POSIX filesystem fixture whose execution coordinates differ from the Harness host. */
import { posix } from 'node:path'
import { Context } from '@deepseek-ai/cordis'
import { FileSystem, FsError, FsTargetKey, FsVersion, type FsTarget, type FsInfo } from '@deepseek-ai/dsh-fs'
import { FileSystem, FsError, type FsTargetKey, type FsVersion, type FsTarget, type FsInfo } from '@deepseek-ai/dsh-fs'
import { brandString } from '@deepseek-ai/dsh-brand'
import schema from '@deepseek-ai/schemastery'
/** Deployment coordinates for the deterministic provider. */
@@ -23,7 +24,7 @@ export default class ProviderCwdFileSystem extends FileSystem {
override async resolve(path: string, opts?: { cwd?: string; signal?: AbortSignal }): Promise<FsTarget> {
opts?.signal?.throwIfAborted()
const absolute = posix.resolve(opts?.cwd ?? this.config.root, path)
return { targetKey: FsTargetKey(absolute), displayPath: path }
return { targetKey: brandString<FsTargetKey>(absolute), displayPath: path }
}
override processPath(target: FsTarget): string { return String(target.targetKey) }
override fileUrl(target: FsTarget): string {
@@ -36,7 +37,7 @@ export default class ProviderCwdFileSystem extends FileSystem {
return relative === '' || (relative !== '..' && !relative.startsWith('../'))
}
override async stat(target: FsTarget): Promise<FsInfo | undefined> {
return this.processPath(target) === this.config.root ? { type: 'directory', version: FsVersion('empty-workspace') } : undefined
return this.processPath(target) === this.config.root ? { type: 'directory', version: brandString<FsVersion>('empty-workspace') } : undefined
}
override async lstat(path: string, opts?: { cwd?: string }): Promise<FsInfo | undefined> {
return this.stat(await this.resolve(path, opts))
@@ -13,7 +13,7 @@ import type {
ResumeAgentOptions,
} from '@deepseek-ai/dsh-agent'
import AgentDefaultModelConfig from '@deepseek-ai/dsh-agent-default-model'
import { LlmAttemptId, ReasoningEffortId, ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage, type MessageId, type StreamChunk } from '@deepseek-ai/dsh-llm'
import { type LlmAttemptId, type ReasoningEffortId, type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage, type MessageId, type StreamChunk } from '@deepseek-ai/dsh-llm'
import SessionStore, { SessionLogOffset } from '@deepseek-ai/dsh-session'
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
import SandboxPolicyService from '@deepseek-ai/dsh-sandbox-policy'
@@ -70,10 +70,10 @@ interface BenchOptions {
afterIdle?: () => void
}
const frameStates = new WeakMap<Agent, { attemptId: ReturnType<typeof LlmAttemptId>; revision: number; index: number }>()
const frameStates = new WeakMap<Agent, { attemptId: LlmAttemptId; revision: number; index: number }>()
function startFrames(agent: Agent, turn = 1, step = 1): void {
const state = { attemptId: LlmAttemptId(`${agent.id}:test`), revision: 1, index: 0 }
const state = { attemptId: brandString<LlmAttemptId>(`${agent.id}:test`), revision: 1, index: 0 }
frameStates.set(agent, state)
agent.ctx.emit('agent/assistant-stream', {
agent,
@@ -615,7 +615,7 @@ describe('headless runner', () => {
test.ctx.emit('agent/assistant-stream', {
agent: { session: other } as Agent,
frame: {
type: 'chunk', attemptId: LlmAttemptId('other'), revision: 1,
type: 'chunk', attemptId: brandString<LlmAttemptId>('other'), revision: 1,
index: 0, time: Date.now(), chunk: { type: 'reasoning-delta', index: 0, text: 'other session' },
},
})
@@ -894,7 +894,7 @@ describe('headless runner', () => {
})
try {
const session = test.ctx.sessions.create(brandString<SessionId>('session-effort'), { meta: { cwd: process.cwd() } })
session.append('model/selection', { provider: 'test-provider', model: savedModel, reasoningEffort: ReasoningEffortId('high') })
session.append('model/selection', { provider: 'test-provider', model: savedModel, reasoningEffort: brandString<ReasoningEffortId>('high') })
expect(await test.run()).toMatchObject({ code: 0, out: 'resumed answer\n', err: '' })
} finally {
await test.ctx.fiber.dispose()
@@ -1210,19 +1210,19 @@ describe('headless runner', () => {
content: [
{ type: 'reasoning', text: 'thinking hard' },
{ type: 'text', text: 'answer' },
{ type: 'tool-call', id: ToolCallId('call-1'), name: 'bash', arguments: '{"command":"ls"}' },
{ type: 'tool-call', id: brandString<ToolCallId>('call-1'), name: 'bash', arguments: '{"command":"ls"}' },
],
source: { provider: 'test-provider', model: 'test-model' },
}),
}, { surfaceOp: 'append' })
session.append('tool/call', {
turn: 1, step: 1, callId: ToolCallId('call-1'), name: 'bash', arguments: '{"command":"ls"}',
turn: 1, step: 1, callId: brandString<ToolCallId>('call-1'), name: 'bash', arguments: '{"command":"ls"}',
})
session.append('tool/result', {
turn: 1,
step: 1,
message: createToolResultMessage({
callId: ToolCallId('call-1'),
callId: brandString<ToolCallId>('call-1'),
content: [{ type: 'text', text: 'a.txt' }],
isError: false,
}),
@@ -7,10 +7,11 @@ import AgentDefaultModelConfig from '@deepseek-ai/dsh-agent-default-model'
import AgentLoop from '@deepseek-ai/dsh-agent-loop'
import { mountAgentLoopTestDependencies } from '@deepseek-ai/dsh-agent-loop-testkit'
import { createUserMessage } from '@deepseek-ai/dsh-llm'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import { MockAdapter, textResponse } from '../../../core/agent-loop/tests/mock-adapter.ts'
import { apply } from '../src/index.ts'
import { internals } from '../src/runner-internals.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const originalInternals = { ...internals }
let ctx: Context | undefined
@@ -134,7 +135,7 @@ describe('headless terminal failures', () => {
it('ignores a different Agent failure during root completion', async () => {
const test = await harness()
const { agent: other } = await test.ctx.agents.create({
sessionId: SessionId('other'), agentOptions: { provider: 'mock', model: 'mock' },
sessionId: brandString<SessionId>('other'), agentOptions: { provider: 'mock', model: 'mock' },
})
test.ctx.on('agent/pre-step', ({ agent }, next) => {
if (agent === other) throw new Error('another Agent failed')
+4
View File
@@ -276,6 +276,10 @@
- id: ui-session
name: '@deepseek-ai/dsh-client-ui-session'
# Session status table behind ctx.uiSession.sessionStatus and useSessionStatus.
- id: ui-session-status
name: '@deepseek-ai/dsh-client-ui-session-status'
# Unified resource model: protocol providers behind the useResource hook.
- id: resources
name: '@deepseek-ai/dsh-client-resources'
+2
View File
@@ -110,6 +110,7 @@
"@deepseek-ai/dsh-client-ui-schedule": "workspace:*",
"@deepseek-ai/dsh-client-ui-secret-mask": "workspace:*",
"@deepseek-ai/dsh-client-ui-session": "workspace:*",
"@deepseek-ai/dsh-client-ui-session-status": "workspace:*",
"@deepseek-ai/dsh-client-ui-settings": "workspace:*",
"@deepseek-ai/dsh-client-ui-settings-account": "workspace:*",
"@deepseek-ai/dsh-client-ui-settings-agent-loop": "workspace:*",
@@ -215,6 +216,7 @@
"@deepseek-ai/cordis-plugin-loader": "workspace:~",
"@deepseek-ai/dsh-agent": "workspace:*",
"@deepseek-ai/dsh-agent-loop-testkit": "workspace:*",
"@deepseek-ai/dsh-brand": "workspace:*",
"@deepseek-ai/dsh-fs": "workspace:*",
"@deepseek-ai/dsh-fs-local": "workspace:*",
"@deepseek-ai/dsh-home-paths": "workspace:*",
@@ -11,10 +11,11 @@ import { loadOverlayPatches } from '@deepseek-ai/dsh-app-boot'
import { provideWorkingDirectoryFixture } from '@deepseek-ai/dsh-agent-loop-testkit'
import LocalFileSystem from '@deepseek-ai/dsh-fs-local'
import { dshHomePath } from '@deepseek-ai/dsh-home-paths'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import OfficeKit from '@deepseek-ai/dsh-office-kit'
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import { resolveKitModule } from '@deepseek-ai/dsh-office-kit/src/locate.ts'
import SkillRegistry from '@deepseek-ai/dsh-skill'
import * as SkillOffice from '@deepseek-ai/dsh-skill-office'
@@ -102,7 +103,7 @@ async function boot(profile: string, primaryRuntime: (root: string) => string |
/** Convert through `office_convert` as an Agent whose previous request declared the Office tools. */
async function convertReport(ctx: Context, workspace: string, callId: string) {
const id = SessionId(callId)
const id = brandString<SessionId>(callId)
const session = Session.create(id, [], { version: SESSION_FORMAT_VERSION, id, createdAt: 0, cwd: workspace, isSeeded: false })
vi.spyOn(session, 'requestHeader').mockReturnValue({ config: { provider: 'fixture', model: 'fixture' }, tools: ctx.tools.schemas() })
const agent = { session, options: {} } as never
@@ -110,7 +111,7 @@ async function convertReport(ctx: Context, workspace: string, callId: string) {
const toolSet = await ctx.tools.resolve({ agent, modelSelection: { provider: 'fixture', model: 'fixture' }, signal })
try {
return await executeToolFixture(ctx, {
signal, callId: ToolCallId(callId), name: 'office_convert', agent, toolSet, arguments: { input: 'report.docx', format: 'pdf' },
signal, callId: brandString<ToolCallId>(callId), name: 'office_convert', agent, toolSet, arguments: { input: 'report.docx', format: 'pdf' },
})
} finally { toolSet.dispose() }
}
@@ -7,7 +7,8 @@ import { Context } from '@deepseek-ai/cordis'
import Loader from '@deepseek-ai/cordis-plugin-loader'
import Include, { applyEntryPatches } from '@deepseek-ai/cordis-plugin-include'
import { loadOverlayPatches } from '@deepseek-ai/dsh-app-boot'
import { OfficeSourceKey, type OfficeKitRequest } from '@deepseek-ai/dsh-office-kit'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { OfficeSourceKey, OfficeKitRequest } from '@deepseek-ai/dsh-office-kit/types'
import * as LibreOfficeProvider from '@deepseek-ai/dsh-office-kit'
import { expect, it, onTestFinished } from 'vitest'
@@ -51,7 +52,7 @@ it('loads one shared conversion row and retains caller-owned PDFs after disposal
let reads = 0
const request = (key: string): OfficeKitRequest => ({
extension: 'docx', priority: 'foreground',
source: { key: OfficeSourceKey(key), version: 'fixture', bytes: bytes.length,
source: { key: brandString<OfficeSourceKey>(key), version: 'fixture', bytes: bytes.length,
async read(signal, maxBytes) {
signal.throwIfAborted()
expect(bytes.length).toBeLessThanOrEqual(maxBytes)
@@ -11,7 +11,7 @@ import WorkspaceFiles, { type WorkspaceFileScope } from '@deepseek-ai/dsh-api-wo
import OfficeKit from '@deepseek-ai/dsh-office-kit'
import * as DocumentPreview from '@deepseek-ai/dsh-client-ui-sidebar-documentpreview'
import type { IndexInjection, WebServer } from '@deepseek-ai/dsh-host-webserver'
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
import SessionStore, { type SessionId } from '@deepseek-ai/dsh-session'
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
import SandboxPolicyService from '@deepseek-ai/dsh-sandbox-policy'
import LocalFileSystem from '@deepseek-ai/dsh-fs-local'
@@ -19,6 +19,7 @@ import { FsError } from '@deepseek-ai/dsh-fs'
import TypertRegistry from '@deepseek-ai/dsh-typert-registry'
import type { Converter, ConverterOptions } from '@deepseek-ai/libreoffice-kit'
import { expect, it, onTestFinished, vi } from 'vitest'
import { brandString } from '@deepseek-ai/dsh-brand'
/** The Peer an index render speaks for; this listener reads no field of it. */
const PAGE_PEER = { principal: { kind: 'owner' } } as Parameters<WebServer['renderIndex']>[1]
@@ -106,12 +107,12 @@ it('loads the shipped Office rows with separately patched settings and authorize
{ kind: 'global', name: '__DSH_DOCUMENT_PREVIEW_CONFIG__', value: clientConfig },
])
const id = SessionId('office-loader')
const id = brandString<SessionId>('office-loader')
const session = ctx.sessions.create(id, { meta: { cwd: directory } })
const lookup = ctx.typert.lookups.get('workspaceFileScope')!
const scope = await lookup.resolve(id) as WorkspaceFileScope | undefined
if (scope === undefined) throw new Error('Expected the Session workspace scope')
expect(await lookup.resolve(SessionId('missing'))).toBeUndefined()
expect(await lookup.resolve(brandString<SessionId>('missing'))).toBeUndefined()
const sourcePath = join(directory, 'report.docx')
await writeFile(sourcePath, 'authorized OOXML')
const signal = new AbortController().signal