@klarkxy/dsh-fusion 0.1.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.inner.cjs","names":["useSyncExternalStore","useCallback","useCallback","useSyncExternalStore","useRef","useId","useState"],"sources":["../../dsh-ai-services/src/contracts.ts","../../dsh-ai-services/src/client-utils.ts","../src/contracts.ts","../src/client-projection.ts","../src/client-store.ts","../src/presentation.ts","../src/client-styles.ts","../src/client.tsx"],"sourcesContent":["import type { ContextFormed } from '@deepseek-ai/dsh-llm'\n\n/** Public, browser-safe contracts. Host implementations stay in their owning packages. */\nexport type ProducerSourceKind = `plugin:${string}`\nexport type ProducerMessageSource = { kind: ProducerSourceKind; plugin: string } & ContextFormed\n\n/**\n * V4 sessions persist the producing extension in `kind`; the retired generic\n * `plugin` wrapper is not admitted. The AI service is the shared producer for\n * feature scopes, so its map must cover every registered feature id.\n */\ndeclare module '@deepseek-ai/dsh-llm' {\n interface MessageSourceMap {\n [kind: ProducerSourceKind]: ProducerMessageSource\n }\n}\n\nexport function producerMessageSource(plugin: string): ProducerMessageSource {\n return { kind: `plugin:${plugin}`, plugin }\n}\nexport type ModelRole = 'normal' | 'weak' | 'strong' | 'fantasy'\nexport interface ModelRoute { provider: string; model: string; reasoningEffort?: string }\nexport type ModelTarget = { kind: 'role'; role: ModelRole } | { kind: 'session' } | ({ kind: 'model' } & ModelRoute)\nexport interface AiPolicy {\n revision: number\n roles: Partial<Record<ModelRole, ModelRoute>>\n purposes: Record<string, ModelTarget>\n limits: { concurrency: number; timeoutMs: number; maxInputChars: number; maxOutputTokens: number; maxAttempts: number }\n}\nexport interface PurposeSpec {\n id: string\n label: string\n defaultTarget: ModelTarget\n maxOutputTokens?: number\n maxInputChars?: number\n timeoutMs?: number\n}\nexport interface ResolvedRoute extends ModelRoute {\n source: 'override' | 'purpose' | 'default'\n target: ModelTarget\n policyRevision: number\n inheritedRole?: ModelRole\n}\nexport interface AuxiliaryRequest {\n purpose: string\n sessionId?: string\n input: string\n system: string\n sourceVersion: string\n contractVersion?: number\n promptVersion?: string\n schemaVersion?: string\n override?: ModelTarget\n signal?: AbortSignal\n /** Rechecked after every await and before returning a publishable result. */\n isCurrent?: () => boolean\n priority?: 'interactive' | 'background'\n /** Plain writing candidates can stop once this many visible characters are available. */\n insert?: { maxChars: number }\n}\nexport interface UsageReceipt {\n id: string\n plugin: string\n purpose: string\n sessionId?: string\n sourceVersion: string\n contractVersion?: number\n promptVersion?: string\n schemaVersion?: string\n route?: ResolvedRoute\n status: 'success' | 'failed' | 'cancelled' | 'superseded' | 'skipped'\n attempts: number\n inputTokens?: number\n outputTokens?: number\n cost: number | null\n startedAt: number\n finishedAt: number\n error?: string\n}\nexport interface AuxiliaryResult { text: string; receipt: UsageReceipt }\nexport interface AiFeatureScope {\n readonly plugin: string\n readonly signal: AbortSignal\n readonly active: boolean\n registerPurpose(spec: PurposeSpec): () => void\n run(request: AuxiliaryRequest): Promise<AuxiliaryResult>\n dispose(): void\n}\nexport interface AiServices {\n activate(plugin: string): AiFeatureScope\n /** Atomically import missing purpose defaults once; host-only compatibility entrypoint. */\n importPurposes(migrationId: string, defaults: Record<string, ModelTarget>, roles?: AiPolicy['roles']): Promise<AiPolicy>\n getPolicy(): AiPolicy\n updatePolicy(policy: Omit<AiPolicy, 'revision'>, expectedRevision: number): Promise<AiPolicy>\n resolve(purpose: string, sessionId?: string, override?: ModelTarget): Promise<ResolvedRoute>\n purposes(): Array<PurposeSpec & { plugin: string }>\n usage(): UsageReceipt[]\n}\nexport type RpcResult<T = unknown> = { ok: true; value: T } | { ok: false; error: { code: string; message: string } }\nexport const AI_RPC_CHANNEL = '/dsh-ai-services'\nexport const CHAT_EVENTS_SLOT = 'dsh-editor.chat.events'\nexport const MODEL_SETTINGS_SLOT = 'dsh-editor.settings.models'\nexport interface EvidenceRef { sessionId: string; seq: number; kind: 'user' | 'tool' | 'turn' | 'manual'; excerpt?: string }\nexport interface TaskContract {\n id: string\n sessionId: string\n sourceVersion: string\n revision: number\n goal: string\n deliverables: string[]\n inScope: string[]\n outOfScope: string[]\n constraints: string[]\n acceptance: string[]\n assumptions: string[]\n questions: string[]\n evidence: EvidenceRef[]\n readiness: 'pending' | 'clear-request' | 'user-confirmed' | 'disclosed-assumptions' | 'cancelled' | 'stale'\n updatedAt: number\n}\nexport interface TaskCheckpoint {\n id: string\n sessionId: string\n sourceVersion: string\n contractVersion?: number\n fromSeq: number\n toSeq: number\n revision: number\n status: 'running' | 'completed' | 'failed' | 'cancelled'\n items: Array<{ label: string; state: 'pending' | 'verified' | 'failed'; evidence: EvidenceRef[] }>\n constraints: string[]\n nextAction: string\n createdAt: number\n}\nexport type KnowledgeScope = { kind: 'global' } | { kind: 'project'; projectId: string }\nexport type KnowledgeKind = 'preference' | 'project-fact' | 'decision' | 'vocabulary' | 'activity' | 'lesson'\n/** Descriptive context, never an executable instruction or authorization. */\nexport interface ContextKnowledge {\n subject: string\n domain: string\n key: string\n aliases: string[]\n observedAt: number\n /** The user's own time expression, not an inferred completion date. */\n eventTime?: string\n activityStatus?: 'planned' | 'in-progress' | 'blocked' | 'paused' | 'completed' | 'cancelled' | 'unknown'\n}\n/** A scoped method. Observations remain candidates until explicitly accepted. */\nexport interface ProcedureKnowledge {\n origin: 'instruction' | 'observation'\n goal: string\n when: string[]\n steps: string[]\n avoid: string[]\n verify: string[]\n}\nexport interface MemoryRecord {\n id: string\n revision: number\n scope: KnowledgeScope\n kind: KnowledgeKind\n status: 'candidate' | 'active' | 'rejected' | 'superseded' | 'revoked' | 'deleted'\n title: string\n content: string\n tags: string[]\n evidence: EvidenceRef[]\n exceptions: string[]\n source: 'user' | 'memory' | 'dream' | 'self-improvement'\n context?: ContextKnowledge\n procedure?: ProcedureKnowledge\n createdAt: number\n updatedAt: number\n expiresAt?: number\n supersedes?: string[]\n /** Exact record revisions behind a derived candidate; revalidated on adoption. */\n basis?: Array<{ id: string; revision: number }>\n}\nexport type NewMemoryRecord = Omit<MemoryRecord, 'id' | 'revision' | 'createdAt' | 'updatedAt'>\nexport interface MemoryQuery { scope: KnowledgeScope; query?: string; kinds?: KnowledgeKind[]; statuses?: MemoryRecord['status'][]; limit?: number }\nexport interface MemoryMutationOptions { signal?: AbortSignal; isCurrent?: () => boolean }\nexport interface MemoryService {\n list(query: MemoryQuery): Promise<MemoryRecord[]>\n create(record: NewMemoryRecord, options?: MemoryMutationOptions): Promise<MemoryRecord>\n update(id: string, patch: Partial<Pick<MemoryRecord, 'title' | 'content' | 'tags' | 'exceptions' | 'status' | 'expiresAt'>>, expectedRevision: number, options?: MemoryMutationOptions): Promise<MemoryRecord>\n /** Explicit user promotion, persisted atomically on the same record; preserves expiry and evidence. */\n promoteToGlobal(id: string, expectedRevision: number, options?: MemoryMutationOptions): Promise<MemoryRecord>\n remove(id: string, expectedRevision: number, options?: MemoryMutationOptions): Promise<void>\n recall(query: MemoryQuery): Promise<MemoryRecord[]>\n}\n\n/** Project keys come only from the host-validated session directory, never client input. */\nexport function projectIdFromCwd(cwd: string | undefined): string | undefined {\n if (typeof cwd !== 'string') return undefined\n const normalized = cwd.trim().replaceAll('\\\\', '/')\n if (!normalized) return undefined\n return normalized === '/' || /^[A-Za-z]:\\/$/.test(normalized) ? normalized : normalized.replace(/\\/+$/, '')\n}\n","import { useCallback, useEffect, useRef, useSyncExternalStore } from 'react'\n\nexport interface NativeSurfaceClient {\n sessions: {\n binding?(sessionId: string): { eventSource: { subscribe(listener: () => void): () => void } } | undefined\n }\n uiWorkspace: { current?: { getSnapshot(): { sessionId: string } | undefined; subscribe(listener: () => void): () => void } }\n uiSession: { adapter: { current: { getSnapshot(): { key?: string }; subscribe(listener: () => void): () => void } } }\n locale: { getSnapshot(): { active: string }; subscribe(listener: () => void): () => void }\n connection?: { generation?: { subscribe(listener: () => void): () => void } }\n}\n\n/** The Editor retains its manuscript session separately; native DSH exposes the main-view binding. */\nexport function selectedSessionId(client: Pick<NativeSurfaceClient, 'uiWorkspace' | 'uiSession'>): string {\n return client.uiWorkspace.current\n ? client.uiWorkspace.current.getSnapshot()?.sessionId ?? ''\n : client.uiSession.adapter.current.getSnapshot().key ?? ''\n}\n\n/** Owner props win; native settings only supplies close, so resolve its selected session. */\nexport function useNativeSeat(client: NativeSurfaceClient, props: unknown) {\n const current = useSyncExternalStore(\n useCallback((fn: () => void) => (client.uiWorkspace.current ?? client.uiSession.adapter.current).subscribe(fn), [client]),\n useCallback(() => selectedSessionId(client), [client]),\n () => '',\n )\n const language = useSyncExternalStore(\n useCallback((fn: () => void) => client.locale.subscribe(fn), [client]),\n useCallback(() => client.locale.getSnapshot().active, [client]),\n () => 'en',\n )\n const row = props && typeof props === 'object' ? props as Record<string, unknown> : {}\n const owner = row.owner && typeof row.owner === 'object' ? row.owner as Record<string, unknown> : {}\n const sessionId = typeof row.sessionId === 'string' ? row.sessionId\n : typeof owner.sessionId === 'string' ? owner.sessionId : current\n const requestedLocale = row.locale ?? owner.locale ?? language\n return { sessionId, locale: (String(requestedLocale).startsWith('zh') ? 'zh' : 'en') as 'zh' | 'en',\n hidden: row.hidden === true || owner.hidden === true }\n}\n\n/** Refresh on native log boundaries/reconnect/focus. Read-only settling is bounded to an observed job. */\nexport function useFeatureRefresh(\n client: NativeSurfaceClient, sessionId: string, refresh: () => void,\n working = false, enabled = true,\n): void {\n const refreshRef = useRef(refresh)\n refreshRef.current = refresh\n useEffect(() => {\n if (!enabled) return\n let timer: ReturnType<typeof setTimeout> | undefined\n const queue = () => {\n if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return\n clearTimeout(timer)\n timer = setTimeout(() => refreshRef.current(), 150)\n }\n const source = sessionId ? client.sessions.binding?.(sessionId)?.eventSource : undefined\n const stopEvents = source?.subscribe(queue)\n const stopConnection = client.connection?.generation?.subscribe(queue)\n const visibility = () => { if (document.visibilityState === 'visible') queue() }\n window.addEventListener('focus', queue)\n document.addEventListener('visibilitychange', visibility)\n // Details are collapsed by default; opening an existing panel must get current state.\n document.addEventListener('toggle', queue, true)\n return () => {\n clearTimeout(timer)\n stopEvents?.(); stopConnection?.()\n window.removeEventListener('focus', queue)\n document.removeEventListener('visibilitychange', visibility)\n document.removeEventListener('toggle', queue, true)\n }\n }, [client, sessionId, enabled])\n useEffect(() => {\n if (!enabled || !working) return\n let delay = 250\n const until = Date.now() + 300_000\n let timer: ReturnType<typeof setTimeout>\n const tick = () => {\n if (Date.now() >= until) return\n if (document.visibilityState !== 'hidden') refreshRef.current()\n delay = Math.min(delay * 2, 2000)\n timer = setTimeout(tick, delay)\n }\n timer = setTimeout(tick, delay)\n return () => clearTimeout(timer)\n }, [client, sessionId, working, enabled])\n}\n","/** Public, browser-safe Fusion records. Native Sessions remain the transcript authority. */\nexport const FUSION_PLUGIN = '@klarkxy/dsh-fusion'\nexport const FUSION_RPC_CHANNEL = '/dsh-fusion'\nexport const FUSION_PURPOSE = 'fusion.sidekick'\nexport const FUSION_TOOLS = ['fusion_delegate', 'fusion_report', 'fusion_review', 'fusion_read', 'fusion_decide', 'fusion_cancel'] as const\nexport type FusionProfile = 'generic' | 'writing'\nexport type TaskState = 'dispatching' | 'working' | 'decision' | 'review' | 'accepted' | 'cancelled' | 'failed' | 'interrupted'\nexport type ModelRoute = { provider: string; model: string; reasoningEffort?: string }\nexport type Json = null | boolean | number | string | Json[] | { [key: string]: Json }\nexport interface FusionActor { sessionId: string; parentSessionId?: string; project: string }\nexport interface FusionBrief {\n title: string\n goal: string\n context: string\n constraints: string[]\n acceptance: string[]\n}\n/** A domain-owned, versioned destination. The Writer cannot replace this target. */\nexport interface FusionTarget { domain: string; data: { [key: string]: Json } }\nexport interface FusionCandidate {\n id: string\n taskRevision: number\n revision: number\n text: string\n hash: string\n report: string\n createdAt: number\n}\nexport interface FusionReview {\n candidateId: string\n candidateHash: string\n verdict: 'accept' | 'revise' | 'reject'\n feedback: string\n createdAt: number\n}\nexport interface FusionTask {\n id: string\n revision: number\n state: TaskState\n brief: FusionBrief\n target?: FusionTarget\n candidates: FusionCandidate[]\n reviews: FusionReview[]\n messageIds: string[]\n dispatchId: string\n reportIds: string[]\n /** Last report whose native Lead notification was confirmed and durably recorded. */\n notifiedReportId?: string\n /** Whether the latest native inbox submission is known to have been accepted. */\n delivery: 'pending' | 'accepted' | 'uncertain'\n decision?: string\n error?: string\n cleanup?: 'pending' | 'done' | 'failed'\n adoption?: 'pending' | 'applied' | 'dismissed' | 'conflict'\n /** Persist before filesystem mutation; never replay an uncertain write. */\n application?: {\n id: string; candidateId: string; candidateHash: string; path: string\n beforeVersion: string; afterHash: string; state: 'pending' | 'applied' | 'conflict'; version?: string\n }\n createdAt: number\n updatedAt: number\n}\nexport interface FusionPair {\n id: string\n leadSessionId: string\n childSessionId: string\n project: string\n profile: FusionProfile\n route: ModelRoute\n /** A successful initial inbox admission, not a claim about provider prompt caching. */\n established: boolean\n tasks: FusionTask[]\n createdAt: number\n}\nexport interface FusionState { version: 1; revision: number; pairs: FusionPair[] }\nexport interface FusionStore { load(): FusionState; save(next: FusionState): Promise<void> }\n/** This port adapts native subagents. It must not own another Agent loop or inbox. */\nexport interface FusionNative {\n dispatch(input: { pair: FusionPair; task: FusionTask; prompt: string; signal: AbortSignal }): Promise<{ messageId: string }>\n notify(input: { pair: FusionPair; task: FusionTask; actor: FusionActor; text: string; signal: AbortSignal }): Promise<void>\n stop(pair: FusionPair, stopLead: boolean): Promise<void>\n}\nexport interface FusionStatus {\n available: boolean\n profile: FusionProfile\n configured: boolean\n revision?: number\n error?: string\n pair?: FusionPair\n /** Cumulative native-session figures, not an estimate of this task's cost. */\n usage?: { leadTokens: number | null; sidekickTokens: number | null; cost: null }\n activity?: { lead: string; sidekick: string }\n}\nexport type RpcResult<T = unknown> = { ok: true; value: T } | { ok: false; error: { code: string; message: string } }\nexport const isWorking = (state: TaskState): boolean => ['dispatching', 'working', 'decision', 'review'].includes(state)\nexport const emptyFusionState = (): FusionState => ({ version: 1, revision: 0, pairs: [] })\n\n/** Browser commands identify stored authority; no command accepts replacement candidate text. */\nexport interface FusionCandidateAction {\n sessionId: string; taskId: string; taskRevision: number; candidateId: string; hash: string\n}\nexport interface FusionPreview {\n path: string; before: string; after: string; version: string\n candidateId: string; hash: string\n}\n","import type { FusionCandidate, FusionPair, FusionPreview, FusionTask } from './contracts.ts'\n\n/** The last task is the only one the Lead may still act on. Older tasks remain in native history. */\nexport function currentTask(pair: FusionPair | undefined): FusionTask | undefined {\n return pair?.tasks.at(-1)\n}\n\n/** An accepted review identifies an exact Writer revision; the newest draft alone grants no adoption. */\nexport function acceptedCandidate(task: FusionTask): FusionCandidate | undefined {\n if (task.state !== 'accepted') return undefined\n const review = task.reviews.at(-1)\n if (review?.verdict !== 'accept') return undefined\n return task.candidates.find(candidate => candidate.id === review.candidateId\n && candidate.hash === review.candidateHash && candidate.taskRevision === task.revision)\n}\n\nexport function canAdopt(pair: FusionPair, task: FusionTask): boolean {\n const candidate = acceptedCandidate(task)\n return pair.profile === 'writing' && Boolean(task.target && candidate\n && task.candidates.at(-1)?.id === candidate.id\n && task.adoption !== 'applied' && task.adoption !== 'dismissed'\n && task.application?.state !== 'pending')\n}\n\nexport interface TurnEvent { time: number; data?: { turn?: number } }\nexport interface TurnEntry { event: TurnEvent }\n\n/** Anchor a durable task near its latest Lead turn instead of repeating it after every turn. */\nexport function taskAnchorTurn(task: FusionTask, entries: readonly TurnEntry[]): number | undefined {\n let eligible: number | undefined\n let latest: number | undefined\n for (const { event } of entries) {\n const turn = event.data?.turn\n if (!Number.isSafeInteger(turn) || (turn ?? 0) < 0) continue\n latest = turn\n if (event.time <= task.updatedAt) eligible = turn\n }\n return eligible ?? latest\n}\n\nexport function needsRefresh(task: FusionTask | undefined): boolean {\n return Boolean(task && (['dispatching', 'working', 'decision', 'review'].includes(task.state)\n || task.cleanup === 'pending'))\n}\n\n/** Capture every authority field that can invalidate an in-flight author action. */\nexport function actionIdentity(sessionId: string, task: FusionTask, candidate?: FusionCandidate): string {\n return [sessionId, task.id, task.revision, candidate?.id ?? '', candidate?.hash ?? ''].join('\\u0000')\n}\n\nexport function isCurrentAction(mounted: boolean, captured: string, current: string): boolean {\n return mounted && captured === current\n}\nexport interface AppliedReceipt { id: string; path: string }\n\n/** Only a Host receipt for the exact preview may request an Editor view refresh. */\nexport function appliedReceipt(value: unknown, task: FusionTask, candidate: FusionCandidate, preview: FusionPreview): AppliedReceipt | undefined {\n if (!value || typeof value !== 'object') return undefined\n const row = value as Partial<FusionTask>\n const application = row.application\n if (row.id !== task.id || row.revision !== task.revision || row.adoption !== 'applied'\n || application?.state !== 'applied' || typeof application.id !== 'string' || !application.id\n || application.candidateId !== candidate.id || application.candidateHash !== candidate.hash\n || application.path !== preview.path || application.beforeVersion !== preview.version\n || preview.candidateId !== candidate.id || preview.hash !== candidate.hash) return undefined\n return { id: application.id, path: application.path }\n}\n\n/** A late response has no authority over the newly selected Session's view. */\nexport function notifyAppliedReceipt(input: {\n value: unknown; task: FusionTask; candidate: FusionCandidate; preview: FusionPreview\n isCurrent(): boolean; notify(receipt: AppliedReceipt): void\n}): boolean {\n if (!input.isCurrent()) return false\n const receipt = appliedReceipt(input.value, input.task, input.candidate, input.preview)\n if (!receipt) return false\n input.notify(receipt)\n return true\n}\nexport interface ObservedPendingApplication {\n sessionId: string; taskId: string; id: string; path: string; candidateId: string; candidateHash: string\n}\n\n/** Cold-start applied history cannot navigate the author; only a seen pending intent may refresh. */\nexport function reconciledReceipt(observed: ObservedPendingApplication | undefined, sessionId: string, task: FusionTask | undefined): AppliedReceipt | undefined {\n const application = task?.application\n if (!observed || !task || task.adoption !== 'applied' || application?.state !== 'applied') return undefined\n if (observed.sessionId !== sessionId || observed.taskId !== task.id || observed.id !== application.id\n || observed.path !== application.path || observed.candidateId !== application.candidateId\n || observed.candidateHash !== application.candidateHash) return undefined\n return { id: application.id, path: application.path }\n}\n/** Native Agent.status has only idle/running on the pinned runtime; retain future values verbatim. */\nexport function activityLabel(value: string, locale: 'zh' | 'en'): string {\n if (locale === 'en') return value\n if (value === 'idle') return '待命'\n if (value === 'running') return '运行中'\n return value\n}","import { FUSION_RPC_CHANNEL, type FusionStatus, type RpcResult } from './contracts.ts'\nimport { currentTask, needsRefresh } from './client-projection.ts'\n\nexport interface FusionRpc { call(channel: string, endpoint: string, payload: unknown): Promise<unknown> }\nexport interface FusionEventSource { subscribe(listener: () => void): () => void }\nexport interface FusionClientSources {\n sessions: { binding?(sessionId: string): { eventSource: FusionEventSource } | undefined }\n connection: { rpc: FusionRpc; generation?: FusionEventSource }\n}\nexport interface FusionSnapshot { status?: FusionStatus; error?: string }\nconst EMPTY: FusionSnapshot = Object.freeze({})\ntype Entry = {\n snapshot: FusionSnapshot; listeners: Set<() => void>; epoch: number; inFlight?: Promise<void>\n timer?: ReturnType<typeof setTimeout>; dispose?: () => void\n}\n\n/** One read-only status projection per viewed Session; no task or native state is copied back to DSH. */\nexport class FusionClientStore {\n private entries = new Map<string, Entry>()\n private announcedApplied = new Set<string>()\n private readonly client: FusionClientSources\n constructor(client: FusionClientSources) { this.client = client }\n\n snapshot(sessionId: string): FusionSnapshot { return this.entries.get(sessionId)?.snapshot ?? EMPTY }\n\n subscribe(sessionId: string, listener: () => void): () => void {\n let entry = this.entries.get(sessionId)\n if (!entry) {\n entry = { snapshot: EMPTY, listeners: new Set(), epoch: 0 }\n this.entries.set(sessionId, entry)\n const queue = () => {\n if (typeof document === 'undefined' || document.visibilityState === 'visible') void this.refresh(sessionId)\n }\n const stopEvents = this.client.sessions.binding?.(sessionId)?.eventSource.subscribe(queue)\n const stopConnection = this.client.connection.generation?.subscribe(queue)\n if (typeof window !== 'undefined') window.addEventListener('focus', queue)\n if (typeof document !== 'undefined') document.addEventListener('visibilitychange', queue)\n entry.dispose = () => {\n stopEvents?.(); stopConnection?.()\n if (typeof window !== 'undefined') window.removeEventListener('focus', queue)\n if (typeof document !== 'undefined') document.removeEventListener('visibilitychange', queue)\n }\n void this.refresh(sessionId)\n }\n entry.listeners.add(listener)\n return () => {\n entry!.listeners.delete(listener)\n if (entry!.listeners.size) return\n entry!.epoch++\n clearTimeout(entry!.timer)\n entry!.dispose?.()\n this.entries.delete(sessionId)\n }\n }\n\n /** Supersede older reads before a user mutation so a late status cannot erase its result. */\n invalidate(sessionId: string): void {\n const entry = this.entries.get(sessionId)\n if (!entry) return\n entry.epoch++\n entry.inFlight = undefined\n clearTimeout(entry.timer)\n }\n\n async refresh(sessionId: string): Promise<void> {\n const entry = this.entries.get(sessionId)\n if (!entry) return\n if (entry.inFlight) return entry.inFlight\n const epoch = ++entry.epoch\n const work = (async () => {\n try {\n const result = await this.client.connection.rpc.call(FUSION_RPC_CHANNEL, 'status', { sessionId }) as RpcResult<FusionStatus>\n if (this.entries.get(sessionId) !== entry || entry.epoch !== epoch) return\n if (!result.ok) throw new Error(result.error.message)\n entry.snapshot = { status: result.value }\n } catch (error) {\n if (this.entries.get(sessionId) !== entry || entry.epoch !== epoch) return\n entry.snapshot = { ...entry.snapshot, error: error instanceof Error ? error.message : String(error) }\n } finally {\n if (this.entries.get(sessionId) !== entry || entry.epoch !== epoch) return\n entry.inFlight = undefined\n for (const listener of entry.listeners) listener()\n this.schedule(sessionId, entry)\n }\n })()\n entry.inFlight = work\n return work\n }\n\n private schedule(sessionId: string, entry: Entry): void {\n clearTimeout(entry.timer)\n if (!needsRefresh(currentTask(entry.snapshot.status?.pair))) return\n // Keep a visible, active task fresh for its entire lifetime, including work past five minutes.\n entry.timer = setTimeout(() => {\n if (typeof document === 'undefined' || document.visibilityState === 'visible') void this.refresh(sessionId)\n }, 2500)\n }\n\n /** A Host-confirmed application refreshes one Editor view once per UI lifetime. */\n announceApplied(sessionId: string, receiptId: string, path: string, notify: (path: string) => void): boolean {\n const key = `${sessionId}\\u0000${receiptId}`\n if (this.announcedApplied.has(key)) return false\n this.announcedApplied.add(key)\n try { notify(path) }\n catch (error) { this.announcedApplied.delete(key); throw error }\n return true\n }\n\n dispose(): void {\n this.announcedApplied.clear()\n for (const [sessionId, entry] of this.entries) {\n entry.epoch++\n clearTimeout(entry.timer)\n entry.dispose?.()\n this.entries.delete(sessionId)\n }\n }\n}\n","import { isWorking, type FusionPair, type FusionTask } from './contracts.ts'\n\nexport type FusionLocale = 'zh' | 'en'\nexport interface FusionTaskView {\n id: string\n title: string\n status: string\n detail: string\n working: boolean\n canStop: boolean\n canPreview: boolean\n candidateLabel?: string\n /** Native child address, never a human-readable label used as a routing key. */\n executionAddress: string\n}\nconst labels = {\n zh: { dispatching: '正在交接', working: '执行中', decision: '等待主代理决策', review: '主代理审查中', accepted: '审查通过', cancelled: '已停止', failed: '执行失败', interrupted: '执行已中断' },\n en: { dispatching: 'Handing off', working: 'Executing', decision: 'Waiting for Lead decision', review: 'Lead review', accepted: 'Review passed', cancelled: 'Stopped', failed: 'Failed', interrupted: 'Interrupted' },\n} as const\n\n/** Pure task projection. No percentages, idle-to-success inference, or provider-cost estimates. */\nexport function taskView(pair: FusionPair, task: FusionTask, locale: FusionLocale): FusionTaskView {\n const zh = locale === 'zh', writing = pair.profile === 'writing'\n let status: string = labels[locale][task.state]\n if (zh && writing && task.state === 'working') status = '执笔中'\n if (zh && writing && task.state === 'decision') status = '等待统筹决策'\n if (zh && writing && task.state === 'review') status = '统筹审阅中'\n let detail = task.error ?? ''\n if (task.state === 'accepted') {\n if (writing && task.target) {\n status = task.adoption === 'applied' ? (zh ? '已采用' : 'Applied')\n : task.adoption === 'conflict' ? (zh ? '原文已变化' : 'Source changed')\n : task.adoption === 'dismissed' ? (zh ? '候选已放弃' : 'Candidate dismissed')\n : (zh ? '待你采用' : 'Awaiting author adoption')\n detail = zh ? '审阅通过不等于已写入稿件。' : 'Model review does not apply changes to the manuscript.'\n if (task.adoption === 'applied') detail = zh ? '宿主已确认应用。' : 'Application confirmed by the Host.'\n } else detail = zh ? '结果已通过模型审查;文件操作以原生执行记录为准。' : 'Review passed. Native execution records remain authoritative for file changes.'\n }\n if (task.cleanup === 'pending') status = zh ? '正在停止' : 'Stopping'\n if (task.cleanup === 'failed') { status = zh ? '停止未完全完成' : 'Stop incomplete'; detail = zh ? '旧结果已失效,但资源清理需要重试。' : 'Old results are invalid, but resource cleanup needs retry.' }\n const candidate = task.candidates.at(-1)\n return { id: task.id, title: task.brief.title, status, detail, working: isWorking(task.state) || task.cleanup === 'pending',\n canStop: task.adoption !== 'applied' && (isWorking(task.state) || task.cleanup === 'failed' || task.state === 'interrupted'),\n canPreview: Boolean(candidate), ...(candidate ? { candidateLabel: zh ? `候选第 ${candidate.revision} 版` : `Candidate v${candidate.revision}` } : {}),\n executionAddress: `dsh-resource://subagentchat/session/${encodeURIComponent(pair.childSessionId)}?parent=${encodeURIComponent(pair.leadSessionId)}&mode=continuable` }\n}\n\n/** Only a structured and matching source can suppress a cancelled child's late wakeup. */\nexport function isOwnedChildNotice(source: unknown, childId: string): boolean {\n if (!source || typeof source !== 'object') return false\n const row = source as Record<string, unknown>\n return (row.kind === 'subagent-settled' || row.kind === 'agent-message') && row.senderSessionId === childId\n}\n","/** Scoped plugin styling. Editor tokens are inherited; native DSH uses its own gray/accent scales. */\nexport const fusionClientStyles = `\n.dsh-fusion-card{min-width:0;margin-block:var(--dsh-ui-space-3,12px);padding:var(--dsh-ui-space-3,12px);border:1px solid var(--dsh-ui-line,var(--dsw-alias-border-l1));border-radius:var(--dsh-ui-radius-md,12px);background:var(--dsh-ui-raised,var(--dsw-alias-bg-module-platform));color:var(--dsh-ui-text,var(--dsw-alias-label-primary));font:inherit;font-size:var(--dsh-ui-text-base,var(--dsh-content-font-size,14px));overflow-wrap:anywhere}\n.dsh-fusion-card.is-native{margin-inline:var(--dsh-ui-space-3,12px)}\n.dsh-fusion-head{display:flex;align-items:center;flex-wrap:wrap;gap:var(--dsh-ui-space-2,8px);min-width:0}\n.dsh-fusion-head strong{min-width:0;flex:1 1 8rem;font-size:inherit;line-height:1.45}\n.dsh-fusion-kicker,.dsh-fusion-state{white-space:nowrap;color:var(--dsh-ui-muted,var(--dsw-alias-label-tertiary))}\n.dsh-fusion-kicker{font-weight:600}\n.dsh-fusion-state{font-size:var(--dsh-ui-text-sm,var(--dsh-content-font-size-secondary,13px))}\n.dsh-fusion-card p{margin:var(--dsh-ui-space-2,8px) 0 0;line-height:1.55}\n.dsh-fusion-detail,.dsh-fusion-activity,.dsh-fusion-usage,.dsh-fusion-hint{color:var(--dsh-ui-muted,var(--dsw-alias-label-tertiary))}\n.dsh-fusion-card button,.dsh-fusion-dialog button{min-height:32px;padding:var(--dsh-ui-space-1,4px) var(--dsh-ui-space-2,8px);border:1px solid var(--dsh-ui-line-strong,var(--dsw-alias-border-l3));border-radius:var(--dsh-ui-radius-sm,6px);background:var(--dsh-ui-bg,var(--dsw-alias-bg-base));color:inherit;font:inherit;cursor:pointer}\n.dsh-fusion-card button:hover:not(:disabled),.dsh-fusion-dialog button:hover:not(:disabled){background:var(--dsh-ui-hover,var(--dsw-alias-interactive-bg-hover))}\n.dsh-fusion-card button:focus-visible,.dsh-fusion-dialog button:focus-visible,.dsh-fusion-card textarea:focus-visible{outline:2px solid var(--dsh-ui-accent,var(--dsw-alias-button-info-fill));outline-offset:2px}\n.dsh-fusion-card button:disabled,.dsh-fusion-dialog button:disabled{opacity:.55;cursor:not-allowed}\n.dsh-fusion-details{margin-inline-start:auto}\n.dsh-fusion-actions{display:flex;flex-wrap:wrap;gap:var(--dsh-ui-space-2,8px);margin-top:var(--dsh-ui-space-3,12px)}\n.dsh-fusion-body{margin-top:var(--dsh-ui-space-3,12px);padding-top:var(--dsh-ui-space-3,12px);border-top:1px solid var(--dsh-ui-line,var(--dsw-alias-border-l1))}\n.dsh-fusion-body details{margin-top:var(--dsh-ui-space-2,8px)}\n.dsh-fusion-body summary{cursor:pointer;min-height:32px}\n.dsh-fusion-body ul{margin:var(--dsh-ui-space-2,8px) 0;padding-inline-start:1.5em}\n.dsh-fusion-report{white-space:pre-wrap}\n.dsh-fusion-candidate{max-height:18rem;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;font:inherit;padding:var(--dsh-ui-space-2,8px);background:var(--dsh-ui-bg,var(--dsw-alias-bg-base));border:1px solid var(--dsh-ui-line,var(--dsw-alias-border-l1))}\n.dsh-fusion-error,.dsh-fusion-warning{color:var(--dsh-ui-text,var(--dsw-alias-label-primary));font-weight:600}\n.dsh-fusion-resume{display:grid;gap:var(--dsh-ui-space-2,8px);margin-top:var(--dsh-ui-space-3,12px)}\n.dsh-fusion-resume textarea{box-sizing:border-box;width:100%;min-height:3.5rem;padding:var(--dsh-ui-space-2,8px);border:1px solid var(--dsh-ui-line-strong,var(--dsw-alias-border-l3));border-radius:var(--dsh-ui-radius-sm,6px);background:var(--dsh-ui-bg,var(--dsw-alias-bg-base));color:inherit;font:inherit;resize:vertical}\n.dsh-fusion-resume button{justify-self:start}\n.dsh-fusion-dialog{box-sizing:border-box;width:min(92vw,80rem);max-width:92vw;max-height:90vh;padding:var(--dsh-ui-space-4,16px);border:1px solid var(--dsh-ui-line-strong,var(--dsw-alias-border-l3));border-radius:var(--dsh-ui-radius-lg,16px);background:var(--dsh-ui-raised,var(--dsw-alias-bg-module-platform));color:var(--dsh-ui-text,var(--dsw-alias-label-primary));font:inherit;box-shadow:var(--dsh-ui-shadow-lg,var(--dsw-elevation-panel))}\n.dsh-fusion-dialog::backdrop{background:var(--dsh-ui-scrim,var(--dsw-alias-bg-mask-drop))}\n.dsh-fusion-dialog-head{display:flex;align-items:center;justify-content:space-between;gap:var(--dsh-ui-space-3,12px)}\n.dsh-fusion-dialog h3,.dsh-fusion-dialog h4{margin:0;font:inherit;font-weight:600}\n.dsh-fusion-path{overflow-wrap:anywhere}\n.dsh-fusion-compare{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--dsh-ui-space-3,12px)}\n.dsh-fusion-compare section{min-width:0}\n.dsh-fusion-compare h4{margin-bottom:var(--dsh-ui-space-2,8px)}\n.dsh-fusion-compare pre{box-sizing:border-box;max-height:55vh;min-height:12rem;overflow:auto;margin:0;padding:var(--dsh-ui-space-3,12px);border:1px solid var(--dsh-ui-line,var(--dsw-alias-border-l1));border-radius:var(--dsh-ui-radius-sm,6px);background:var(--dsh-ui-bg,var(--dsw-alias-bg-base));color:inherit;font:inherit;white-space:pre-wrap;overflow-wrap:anywhere}\n.dsh-fusion-dialog .dsh-fusion-actions{justify-content:flex-end}\n.dsh-fusion-dialog .dsh-fusion-primary{background:var(--dsh-ui-accent-solid,var(--dsw-alias-button-primary-fill));border-color:var(--dsh-ui-accent-solid,var(--dsw-alias-button-primary-fill));color:var(--dsh-ui-on-accent,var(--dsw-alias-label-primary-foreground))}\n@media(max-width:700px){.dsh-fusion-compare{grid-template-columns:minmax(0,1fr)}.dsh-fusion-compare pre{max-height:30vh;min-height:6rem}.dsh-fusion-dialog{max-height:95vh}}\n@media(forced-colors:active){.dsh-fusion-card,.dsh-fusion-dialog,.dsh-fusion-compare pre{border:1px solid CanvasText}.dsh-fusion-card button:focus-visible,.dsh-fusion-dialog button:focus-visible{outline:2px solid Highlight}}\n`\n","import type { Context } from '@deepseek-ai/cordis'\nimport { CHAT_EVENTS_SLOT } from '@klarkxy/dsh-ai-services/contracts'\nimport { useNativeSeat, type NativeSurfaceClient } from '@klarkxy/dsh-ai-services/client-utils'\nimport { useCallback, useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore, type KeyboardEvent } from 'react'\nimport { FUSION_RPC_CHANNEL, type FusionCandidate, type FusionCandidateAction, type FusionPreview,\n type FusionStatus, type FusionTask, type RpcResult } from './contracts.ts'\nimport { acceptedCandidate, actionIdentity, activityLabel, canAdopt, currentTask, isCurrentAction, notifyAppliedReceipt, reconciledReceipt, taskAnchorTurn, type ObservedPendingApplication, type TurnEntry } from './client-projection.ts'\nimport { FusionClientStore, type FusionClientSources, type FusionEventSource } from './client-store.ts'\nimport { taskView, type FusionLocale } from './presentation.ts'\nimport { fusionClientStyles } from './client-styles.ts'\n\nexport const name = 'dsh-fusion-client'\nexport const inject = ['slots', 'connection', 'sessions', 'locale', 'uiWorkspace', 'uiSession'] as const\nexport const NATIVE_TURN_TAIL_SLOT = 'conversation.chat.turnTail'\n\ntype FusionClient = Omit<NativeSurfaceClient, 'sessions' | 'connection'> & {\n connection: FusionClientSources['connection']\n slots: {\n inject(key: string, register: () => unknown): () => void\n register(spec: { name: string; id: string; order: number; label: string }, render: unknown): () => void\n }\n sidebarRight?: { openResource(address: string, options?: { kind?: string; preferNewPane?: boolean }): void }\n sessions: {\n binding?(sessionId: string): { eventSource: FusionEventSource & { getSnapshot(): { entries: readonly TurnEntry[] } } } | undefined\n }\n}\n\nfunction label(locale: FusionLocale, zh: string, en: string): string { return locale === 'zh' ? zh : en }\nfunction errorText(error: unknown): string { return error instanceof Error ? error.message : String(error) }\n\nexport function candidateAction(sessionId: string, task: FusionTask, candidate: FusionCandidate): FusionCandidateAction {\n return { sessionId, taskId: task.id, taskRevision: task.revision, candidateId: candidate.id, hash: candidate.hash }\n}\n\nexport function canRecover(task: FusionTask): boolean {\n return ['interrupted', 'review', 'decision'].includes(task.state)\n && Boolean(task.reportIds.at(-1)?.startsWith(`${task.revision}:`))\n}\n\nexport function canResume(task: FusionTask): boolean {\n return ['decision', 'interrupted', 'failed'].includes(task.state) && task.delivery !== 'pending' && task.cleanup !== 'pending'\n}\n\nfunction useStatus(store: FusionClientStore, sessionId: string) {\n const subscribe = useCallback((listener: () => void) => sessionId ? store.subscribe(sessionId, listener) : () => {}, [store, sessionId])\n const snapshot = useCallback(() => store.snapshot(sessionId), [store, sessionId])\n return useSyncExternalStore(subscribe, snapshot, snapshot)\n}\n\nfunction ExactPreview({ preview, locale }: { preview: FusionPreview; locale: FusionLocale }) {\n return <div className=\"dsh-fusion-preview-content\">\n <p className=\"dsh-fusion-path\" title={preview.path}>{preview.path}</p>\n <div className=\"dsh-fusion-compare\">\n <section><h4>{label(locale, '当前原文', 'Current file')}</h4><pre>{preview.before}</pre></section>\n <section><h4>{label(locale, '采用后全文', 'Exact result')}</h4><pre>{preview.after}</pre></section>\n </div>\n </div>\n}\n\nfunction PreviewDialog(props: {\n preview: FusionPreview; locale: FusionLocale; busy: boolean; onClose(): void; onApply(): void; returnTo: HTMLElement | null\n}) {\n const ref = useRef<HTMLDialogElement>(null)\n const titleId = useId()\n useEffect(() => {\n const dialog = ref.current\n dialog?.showModal()\n return () => { dialog?.close(); props.returnTo?.focus() }\n }, [props.returnTo])\n return <dialog ref={ref} className=\"dsh-fusion-dialog\" aria-labelledby={titleId}\n onCancel={event => { event.preventDefault(); if (!props.busy) props.onClose() }}\n onClose={() => { if (!props.busy) props.onClose() }}>\n <div className=\"dsh-fusion-dialog-head\">\n <h3 id={titleId}>{label(props.locale, '审阅写入内容', 'Review exact change')}</h3>\n <button type=\"button\" onClick={props.onClose} disabled={props.busy} aria-label={label(props.locale, '关闭预览', 'Close preview')}>×</button>\n </div>\n <ExactPreview preview={props.preview} locale={props.locale} />\n <p className=\"dsh-fusion-hint\">{label(props.locale, '确认后将按当前文件版本写入;原文变化会阻止应用。', 'Confirming writes against this file version; changes to the source will block application.')}</p>\n <div className=\"dsh-fusion-actions\">\n <button type=\"button\" onClick={props.onClose} disabled={props.busy}>{label(props.locale, '返回', 'Back')}</button>\n <button type=\"button\" className=\"dsh-fusion-primary\" onClick={props.onApply} disabled={props.busy}>\n {props.busy ? label(props.locale, '正在应用…', 'Applying…') : label(props.locale, '确认采用', 'Apply change')}\n </button>\n </div>\n </dialog>\n}\n\nfunction FusionTaskCard(props: {\n client: FusionClient; store: FusionClientStore; status: FusionStatus; sessionId: string; locale: FusionLocale; native: boolean; loadError?: string; onApplied?: (path: string) => void\n}) {\n const { client, store, status, sessionId, locale, native } = props\n const pair = status.pair\n const task = currentTask(pair)\n const [expanded, setExpanded] = useState(false)\n const [busy, setBusy] = useState('')\n const [error, setError] = useState('')\n const [preview, setPreview] = useState<FusionPreview>()\n const [feedback, setFeedback] = useState('')\n const returnTo = useRef<HTMLElement | null>(null)\n const mounted = useRef(true)\n const current = useRef('')\n const busyRef = useRef(false)\n const candidate = task?.candidates.at(-1)\n current.current = task ? actionIdentity(sessionId, task, candidate) : ''\n useLayoutEffect(() => { mounted.current = true; return () => { mounted.current = false } }, [])\n useEffect(() => { setError(''); setPreview(undefined); setFeedback(''); setBusy(''); busyRef.current = false }, [sessionId, task?.id, task?.revision, task?.state, task?.updatedAt, task?.adoption, candidate?.hash])\n useEffect(() => {\n if (!task || !candidate || !preview) return\n if (preview.candidateId !== candidate.id || preview.hash !== candidate.hash || !pair || !canAdopt(pair, task) || props.loadError || status.error) setPreview(undefined)\n }, [task, candidate, pair, preview, props.loadError, status.error])\n if (!pair || !task || pair.leadSessionId !== sessionId) return null\n const view = taskView(pair, task, locale)\n const staleStatus = Boolean(props.loadError || status.error)\n const allowed = !staleStatus && canAdopt(pair, task)\n const accepted = acceptedCandidate(task)\n const key = actionIdentity(sessionId, task, candidate)\n const isCurrent = () => isCurrentAction(mounted.current, key, current.current)\n const identity = { sessionId, taskId: task.id, taskRevision: task.revision }\n\n async function call(endpoint: string, payload: unknown): Promise<unknown> {\n const result = await client.connection.rpc.call(FUSION_RPC_CHANNEL, endpoint, payload) as RpcResult\n if (!result.ok) throw new Error(result.error.message)\n return result.value\n }\n\n async function act(endpoint: string, payload: unknown, success?: (value: unknown) => void): Promise<void> {\n if (!isCurrent() || busyRef.current || staleStatus) return\n busyRef.current = true; setBusy(endpoint); setError('')\n store.invalidate(sessionId)\n try {\n const value = await call(endpoint, payload)\n if (isCurrent()) success?.(value)\n } catch (cause) {\n if (isCurrent()) setError(errorText(cause))\n } finally {\n if (isCurrent()) { busyRef.current = false; setBusy('') }\n await store.refresh(sessionId)\n }\n }\n\n // Preview is a read, but must retain the exact Host version returned by the command.\n async function loadPreview(event: React.MouseEvent<HTMLButtonElement>): Promise<void> {\n if (!allowed || !candidate || candidate.id !== accepted?.id || busyRef.current || !isCurrent()) return\n returnTo.current = event.currentTarget\n busyRef.current = true; setBusy('preview'); setError('')\n try {\n const value = await call('preview', candidateAction(sessionId, task!, candidate)) as FusionPreview\n if (isCurrent() && value.candidateId === candidate.id && value.hash === candidate.hash) setPreview(value)\n } catch (cause) {\n if (isCurrent()) setError(errorText(cause))\n } finally {\n if (isCurrent()) { busyRef.current = false; setBusy('') }\n }\n }\n\n async function applyPreview(): Promise<void> {\n if (!preview || staleStatus || !allowed || !candidate || preview.candidateId !== candidate.id || preview.hash !== candidate.hash) return\n const exactPreview = preview\n await act('apply', { ...candidateAction(sessionId, task!, candidate), expectedVersion: exactPreview.version }, value => {\n const confirmed = notifyAppliedReceipt({ value, task: task!, candidate, preview: exactPreview, isCurrent,\n notify: receipt => { if (props.onApplied) store.announceApplied(sessionId, receipt.id, receipt.path, props.onApplied) },\n })\n if (!confirmed) throw new Error(label(locale, '宿主未确认当前预览已应用,请刷新状态核对。',\n 'The Host did not confirm this exact preview. Refresh status to inspect the result.'))\n setPreview(undefined)\n })\n }\n\n function openChild(): void {\n try { if (!client.sidebarRight) throw new Error(label(locale, '原生侧栏不可用。', 'Native sidebar unavailable.'))\n client.sidebarRight.openResource(view.executionAddress, { kind: 'subagentchat', preferNewPane: true }) }\n catch (cause) { setError(errorText(cause)) }\n }\n\n function onFeedbackKey(event: KeyboardEvent<HTMLTextAreaElement>): void {\n if (event.key === 'Escape') { setFeedback(''); event.currentTarget.blur() }\n }\n\n const recoverable = !staleStatus && canRecover(task) && (task.delivery === 'uncertain' || task.state === 'interrupted' || !task.notifiedReportId)\n const resumable = !staleStatus && canResume(task)\n const latestReview = task.reviews.at(-1)\n return <section className={`dsh-fusion-card${native ? ' is-native' : ''}`} data-session={sessionId} aria-label={label(locale, '协作任务', 'Collaboration task')}>\n <div className=\"dsh-fusion-head\">\n <span className=\"dsh-fusion-kicker\">{label(locale, '协作', 'Collaboration')}</span>\n <strong title={task.brief.title}>{task.brief.title}</strong>\n <span className=\"dsh-fusion-state\" role=\"status\">{view.status}</span>\n <button type=\"button\" className=\"dsh-fusion-details\" aria-expanded={expanded}\n onClick={() => setExpanded(value => !value)}>{expanded ? label(locale, '收起', 'Collapse') : label(locale, '详情', 'Details')}</button>\n </div>\n {view.detail ? <p className=\"dsh-fusion-detail\">{view.detail}</p> : null}\n {status.activity ? <p className=\"dsh-fusion-activity\">\n {label(locale, '统筹', 'Lead')}: {activityLabel(status.activity.lead, locale)} · {label(locale, pair.profile === 'writing' ? '执笔' : '搭档', 'Sidekick')}: {activityLabel(status.activity.sidekick, locale)}\n </p> : null}\n {status.usage && (status.usage.leadTokens !== null || status.usage.sidekickTokens !== null) ?\n <p className=\"dsh-fusion-usage\">{label(locale, '原生会话累计 token', 'Native session tokens')} ·\n {status.usage.leadTokens !== null ? ` ${label(locale, '统筹', 'Lead')} ${status.usage.leadTokens.toLocaleString()}` : ''}\n {status.usage.sidekickTokens !== null ? ` ${label(locale, pair.profile === 'writing' ? '执笔' : '搭档', 'Sidekick')} ${status.usage.sidekickTokens.toLocaleString()}` : ''}\n </p> : null}\n {error || props.loadError ? <p className=\"dsh-fusion-error\" role=\"alert\">{error || props.loadError}</p> : null}\n {props.loadError ? <button type=\"button\" onClick={() => void store.refresh(sessionId)}>{label(locale, '重试读取', 'Retry status')}</button> : null}\n {expanded ? <div className=\"dsh-fusion-body\">\n <p className=\"dsh-fusion-goal\">{task.brief.goal}</p>\n <p className=\"dsh-fusion-route\">{label(locale, '搭档模型', 'Sidekick model')}: {pair.route.provider} / {pair.route.model}{pair.route.reasoningEffort ? ` · ${pair.route.reasoningEffort}` : ''}</p>\n {task.brief.acceptance.length ? <details><summary>{label(locale, '验收要求', 'Acceptance')}</summary><ul>\n {task.brief.acceptance.map((item, index) => <li key={index}>{item}</li>)}\n </ul></details> : null}\n {candidate ? <details><summary>{view.candidateLabel ?? label(locale, '候选', 'Candidate')}</summary>\n <p className=\"dsh-fusion-report\">{candidate.report}</p>\n <pre className=\"dsh-fusion-candidate\">{candidate.text}</pre>\n </details> : task.decision ? <p>{task.decision}</p> : null}\n {latestReview ? <p className=\"dsh-fusion-review\">\n {label(locale, '统筹审查', 'Lead review')}: {latestReview.verdict === 'accept' ? label(locale, '通过', 'Accepted')\n : latestReview.verdict === 'revise' ? label(locale, '要求修改', 'Revision requested') : label(locale, '未通过', 'Rejected')}\n {latestReview.feedback ? ` · ${latestReview.feedback}` : ''}\n </p> : null}\n {task.delivery === 'uncertain' ? <p className=\"dsh-fusion-warning\" role=\"status\">{task.reportIds.length\n ? label(locale, '报告通知结果不确定。请核对原生记录,再明确重送已保存的报告。',\n 'Report notification is uncertain. Inspect native history, then explicitly re-notify the Lead of the saved report.')\n : label(locale, '初次交接结果不确定。请核对搭档会话,勿直接重发同一任务。',\n 'Initial admission is uncertain. Inspect the Sidekick session before starting another task.')}</p> : null}\n {task.application?.state === 'pending' ? <p className=\"dsh-fusion-warning\">{label(locale,\n '写入结果待宿主核对,请刷新状态后再操作。', 'The Host is reconciling the write. Refresh status before acting.')}</p> : null}\n {native ? <button type=\"button\" onClick={openChild}>{label(locale, pair.profile === 'writing' ? '查看执笔会话' : '查看搭档会话', 'Open Sidekick session')}</button> : null}\n </div> : null}\n <div className=\"dsh-fusion-actions\">\n {allowed ? <button type=\"button\" disabled={Boolean(busy)} onClick={event => void loadPreview(event)}>\n {label(locale, '预览采用', 'Preview adoption')}</button> : null}\n {allowed && candidate ? <button type=\"button\" disabled={Boolean(busy)}\n onClick={() => void act('dismiss', candidateAction(sessionId, task!, candidate))}>\n {label(locale, '放弃候选', 'Dismiss candidate')}</button> : null}\n {view.canStop ? <button type=\"button\" disabled={Boolean(busy) || staleStatus}\n onClick={() => void act('cancel', identity)}>{label(locale, '停止协作任务', 'Stop task')}</button> : null}\n {recoverable ? <button type=\"button\" disabled={Boolean(busy)}\n onClick={() => void act('recover', identity)}>{label(locale, '重送已保存报告', 'Re-notify saved report')}</button> : null}\n {task.cleanup === 'failed' || task.adoption === 'conflict' ? <button type=\"button\" disabled={Boolean(busy)}\n onClick={() => void store.refresh(sessionId)}>{label(locale, '刷新状态', 'Refresh status')}</button> : null}\n </div>\n {resumable ? <div className=\"dsh-fusion-resume\">\n <label htmlFor={`dsh-fusion-feedback-${task.id}`}>{label(locale, '给统筹的后续要求', 'Feedback to Lead')}</label>\n <textarea id={`dsh-fusion-feedback-${task.id}`} value={feedback} onChange={event => setFeedback(event.target.value)}\n onKeyDown={onFeedbackKey} rows={2} maxLength={4000} />\n <button type=\"button\" disabled={Boolean(busy) || !feedback.trim()}\n onClick={() => void act('resume', { ...identity, feedback: feedback.trim() }, () => setFeedback(''))}>\n {label(locale, '继续协作', 'Continue collaboration')}</button>\n </div> : null}\n {preview ? <PreviewDialog preview={preview} locale={locale} busy={busy === 'apply'}\n returnTo={returnTo.current} onClose={() => setPreview(undefined)} onApply={() => void applyPreview()} /> : null}\n </section>\n}\n\nfunction appliedOwnerCallback(owner: unknown): ((path: string) => void) | undefined {\n if (!owner || typeof owner !== 'object') return undefined\n const row = owner as Record<string, unknown>\n const nested = row.owner && typeof row.owner === 'object' ? row.owner as Record<string, unknown> : undefined\n const callback = row.onApplied ?? nested?.onApplied\n return typeof callback === 'function' ? callback as (path: string) => void : undefined\n}\n\nfunction FusionSeat(props: { client: FusionClient; store: FusionClientStore; native: boolean; owner: unknown }) {\n const { client, store, native, owner } = props\n const seat = useNativeSeat(client, owner)\n const snapshot = useStatus(store, seat.sessionId)\n const task = currentTask(snapshot.status?.pair)\n const onApplied = native ? undefined : appliedOwnerCallback(owner)\n const observedPending = useRef<ObservedPendingApplication>()\n useEffect(() => {\n if (!onApplied || !seat.sessionId || seat.hidden || snapshot.error) { observedPending.current = undefined; return }\n const application = task?.application\n if (application?.state === 'pending' && task) {\n observedPending.current = { sessionId: seat.sessionId, taskId: task.id, id: application.id,\n path: application.path, candidateId: application.candidateId, candidateHash: application.candidateHash }\n return\n }\n const receipt = reconciledReceipt(observedPending.current, seat.sessionId, task)\n observedPending.current = undefined\n if (receipt) store.announceApplied(seat.sessionId, receipt.id, receipt.path, onApplied)\n }, [onApplied, seat.sessionId, seat.hidden, snapshot.error, task?.id, task?.adoption, task?.application, store])\n if (!seat.sessionId || seat.hidden) return null\n if (native && client.uiWorkspace.current) return null\n if (!native && !client.uiWorkspace.current) return null\n if (native) {\n const row = owner && typeof owner === 'object' ? owner as Record<string, unknown> : {}\n const turn = row.turn && typeof row.turn === 'object' ? (row.turn as { turn?: number }).turn : undefined\n const entries = client.sessions.binding?.(seat.sessionId)?.eventSource.getSnapshot().entries ?? []\n const anchor = task ? taskAnchorTurn(task, entries) : entries.map(item => item.event.data?.turn).filter(value => typeof value === 'number').at(-1)\n if (turn === undefined || anchor !== turn) return null\n }\n if (!snapshot.status) return snapshot.error ? <section className=\"dsh-fusion-card\" role=\"alert\">\n <strong>{label(seat.locale, '协作状态读取失败', 'Collaboration status unavailable')}</strong><p>{snapshot.error}</p>\n <button type=\"button\" onClick={() => void store.refresh(seat.sessionId)}>{label(seat.locale, '重试', 'Retry')}</button>\n </section> : null\n if (!snapshot.status.available) return <section className=\"dsh-fusion-card\" role=\"status\">\n <strong>{label(seat.locale, '协作暂不可用', 'Collaboration unavailable')}</strong>\n <p>{snapshot.status.error ?? label(seat.locale, '检查插件或模型配置后刷新。', 'Check plugin or model configuration, then refresh.')}</p>\n <button type=\"button\" onClick={() => void store.refresh(seat.sessionId)}>{label(seat.locale, '刷新状态', 'Refresh status')}</button>\n </section>\n if (!task) return native ? null : <section className=\"dsh-fusion-card\" aria-label={label(seat.locale, '协作', 'Collaboration')}>\n <strong>{label(seat.locale, '协作', 'Collaboration')}</strong><p className=\"dsh-fusion-detail\">{snapshot.status.error ?? (snapshot.status.configured\n ? label(seat.locale, '与统筹继续对话;需要执笔时由统筹交接。', 'Continue with the Lead; the Lead delegates writing when needed.')\n : label(seat.locale, '协作模型尚未配置,请在模型设置中完成配置。', 'Configure the collaboration model in model settings.'))}</p>\n {snapshot.status.error ? <button type=\"button\" onClick={() => void store.refresh(seat.sessionId)}>{label(seat.locale, '刷新状态', 'Refresh status')}</button> : null}\n </section>\n return <FusionTaskCard client={client} store={store} status={snapshot.status} loadError={snapshot.error} onApplied={onApplied}\n sessionId={seat.sessionId} locale={seat.locale} native={native} />\n}\n\n/** The native turn-tail slot is session scoped. Its own SessionSnapshot identifies subagent children. */\nfunction NativeFusionSeat(props: { client: FusionClient; store: FusionClientStore; owner: unknown }) {\n const row = props.owner && typeof props.owner === 'object' ? props.owner as Record<string, unknown> : {}\n const useSession = row.useSession as ((select: (snapshot: { subagent: unknown }) => boolean) => boolean) | undefined\n // The pinned native slot always injects useSession. Without it, fail closed before any Lead RPC.\n if (!useSession) return null\n const isChild = useSession(snapshot => Boolean(snapshot.subagent))\n if (isChild) return null\n return <FusionSeat client={props.client} store={props.store} native owner={props.owner} />\n}\n\nexport function apply(ctx: Context): void {\n const client = ctx as unknown as FusionClient\n const store = new FusionClientStore(client)\n ctx.effect(() => () => store.dispose(), 'dsh-fusion-client.store')\n ctx.effect(() => {\n if (typeof document === 'undefined') return () => {}\n const style = document.createElement('style')\n style.setAttribute('data-plugin', '@klarkxy/dsh-fusion')\n style.textContent = fusionClientStyles\n document.head.appendChild(style)\n return () => style.remove()\n }, 'dsh-fusion-client.styles')\n ctx.effect(() => client.slots.inject(CHAT_EVENTS_SLOT, () => client.slots.register({\n name: CHAT_EVENTS_SLOT, id: 'fusion', order: 30, label: '协作',\n }, (owner: unknown) => <FusionSeat key={seatKey(owner)} client={client} store={store} native={false} owner={owner} />)),\n 'dsh-fusion-client.editor')\n // The Editor shell has no native right sidebar; register this seat only in native Web.\n ctx.inject(['sidebarRight'], scope => {\n const nativeClient = scope as unknown as FusionClient\n return nativeClient.slots.inject(NATIVE_TURN_TAIL_SLOT, () => nativeClient.slots.register({\n name: NATIVE_TURN_TAIL_SLOT, id: 'fusion', order: 30, label: 'Collaboration',\n }, (owner: unknown) => <NativeFusionSeat client={nativeClient} store={store} owner={owner} />))\n })\n}\n\nfunction seatKey(owner: unknown): string {\n if (!owner || typeof owner !== 'object') return ''\n const row = owner as Record<string, unknown>\n const source = row.owner && typeof row.owner === 'object' ? row.owner as Record<string, unknown> : row\n return typeof source.sessionId === 'string' ? source.s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