@klarkxy/dsh-memory 0.1.2 → 0.1.4
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.
- package/README.md +16 -16
- package/cordis.patch.yml +1 -1
- package/docs/README.zh-CN.md +25 -4
- package/lib/client.inner.cjs +110 -69
- package/lib/client.inner.cjs.map +1 -1
- package/lib/client.js +110 -69
- package/lib/contracts.d.ts +9 -0
- package/lib/contracts.js +3 -1
- package/lib/contracts.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.js +410 -42
- package/lib/index.js.map +1 -1
- package/package.json +9 -9
package/lib/client.inner.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.inner.cjs","names":["useSyncExternalStore","useCallback","useRef","captured","useRef","useState","useId"],"sources":["../../dsh-ai-services/src/client-utils.ts","../src/contracts.ts","../src/view-lifetime.ts","../src/client.tsx"],"sourcesContent":["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","/** Browser-safe contracts. MemoryRecord / MemoryService match frozen @klarkxy/dsh-ai-services. */\nimport {\n CHAT_EVENTS_SLOT as FROZEN_CHAT_EVENTS_SLOT,\n projectIdFromCwd as frozenProjectIdFromCwd,\n} from '@klarkxy/dsh-ai-services/contracts'\nimport type {\n AiFeatureScope,\n AiServices,\n AuxiliaryRequest,\n AuxiliaryResult,\n EvidenceRef,\n KnowledgeKind,\n KnowledgeScope,\n MemoryQuery,\n MemoryRecord,\n MemoryService,\n NewMemoryRecord,\n PurposeSpec,\n ProducerMessageSource,\n RpcResult,\n UsageReceipt,\n} from '@klarkxy/dsh-ai-services/contracts'\n\nexport type {\n AiFeatureScope,\n AiServices,\n AuxiliaryRequest,\n AuxiliaryResult,\n EvidenceRef,\n KnowledgeKind,\n KnowledgeScope,\n MemoryQuery,\n MemoryRecord,\n MemoryService,\n NewMemoryRecord,\n PurposeSpec,\n ProducerMessageSource,\n RpcResult,\n UsageReceipt,\n}\n\n/** Frozen shared chat-events seat. Must stay equal to @klarkxy/dsh-ai-services CHAT_EVENTS_SLOT. */\nexport const CHAT_EVENTS_SLOT = FROZEN_CHAT_EVENTS_SLOT\n/** Shared untruncated cwd identity. Drive roots (`/` / `C:/`) stay intact. */\nexport const projectIdFromCwd = frozenProjectIdFromCwd\nexport const MEMORY_PLUGIN = '@klarkxy/dsh-memory'\nexport const MEMORY_SOURCE_KIND = 'plugin:@klarkxy/dsh-memory' as const\nexport const MEMORY_RPC_CHANNEL = '/dsh-memory'\nexport const MEMORY_DREAM_PURPOSE = 'memory.dream'\nexport const MEMORY_INJECTION_SECTION = 'dsh-memory:recall'\n/** Frozen pluginName now accepts scoped ids. */\nexport const MEMORY_ACTIVATE_ID = MEMORY_PLUGIN\n\nexport const DEFAULT_IDLE_MS = 15 * 60 * 1000\nexport const MIN_IDLE_MS = 60_000\nexport const MAX_IDLE_MS = 180 * 60_000\nexport const DREAM_MIN_INTERVAL_MS = 24 * 60 * 60 * 1000\nexport const DREAM_MIN_MATERIAL = 3\nexport const MIN_RECALL_RECORDS = 1\nexport const MAX_RECALL_RECORDS = 5\nexport const MAX_RECALL_TOKENS = 800\nexport const MAX_PROJECT_ID_CHARS = 32_768\nexport const INJECT_KINDS: readonly KnowledgeKind[] = ['preference', 'project-fact', 'decision']\nexport const RECALL_EXCLUDED_STATUSES: readonly MemoryRecord['status'][] = [\n 'candidate', 'rejected', 'revoked', 'deleted', 'superseded',\n]\n\nexport interface MemorySettings {\n revision: number\n injectEnabled: boolean\n dreamIdleEnabled: boolean\n idleMs: number\n}\n\nexport const defaultSettings = (): MemorySettings => ({\n revision: 0,\n injectEnabled: true,\n dreamIdleEnabled: true,\n idleMs: DEFAULT_IDLE_MS,\n})\n\nexport type DreamPlanStatus = 'preview' | 'applied' | 'cancelled' | 'stale' | 'failed' | 'noop'\n\nexport interface DreamSnapshotEntry {\n id: string\n revision: number\n status: MemoryRecord['status']\n scope: KnowledgeScope\n expiresAt?: number\n}\n\nexport interface DreamProposal {\n title: string\n content: string\n kind: Exclude<KnowledgeKind, 'lesson'>\n tags: string[]\n exceptions: string[]\n evidence: EvidenceRef[]\n sourceIds: string[]\n scope: KnowledgeScope\n}\n\nexport interface DreamPlan {\n id: string\n revision: number\n sessionId: string\n projectId?: string\n status: DreamPlanStatus\n sourceVersion: string\n snapshot: DreamSnapshotEntry[]\n proposals: DreamProposal[]\n generation: number\n createdAt: number\n updatedAt: number\n error?: string\n}\n\nexport interface MemoryTombstone {\n id: string\n deletedAt: number\n lastRevision: number\n}\n\nexport interface MemoryPersistedState {\n settings: MemorySettings\n records: MemoryRecord[]\n tombstones: MemoryTombstone[]\n dreams: DreamPlan[]\n lastAttemptAt?: number\n}\n\nexport interface MemoryStatus {\n runningDreams?: string[]\n settings: MemorySettings\n records: MemoryRecord[]\n dreams: DreamPlan[]\n projectId?: string\n storageFailed: boolean\n aiAvailable: boolean\n}\n\n/** Matches frozen MemoryService optional mutation identity/lifetime guards. */\nexport interface MemoryMutationOptions { signal?: AbortSignal; isCurrent?: () => boolean }\n\nexport interface PreStepEnter {\n kind: 'enter'\n messages: unknown[]\n startsRequestSeries?: true\n}\nexport type PreStepDecision = { kind: 'reject' } | PreStepEnter\n\nexport interface InjectedMemoryMessage {\n content: Array<{ type: 'text'; text: string }>\n source: ProducerMessageSource & {\n kind: typeof MEMORY_SOURCE_KIND\n plugin: typeof MEMORY_PLUGIN\n form: 'snapshot'\n sections: Array<{ name: string; text: string }>\n }\n}\n\nexport function fail<T = never>(code: string, message: string): RpcResult<T> {\n return { ok: false, error: { code, message } }\n}\n\nexport function ok<T>(value: T): RpcResult<T> {\n return { ok: true, value }\n}\n\nexport function parseSessionId(payload: unknown): string | undefined {\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return undefined\n const sessionId = (payload as { sessionId?: unknown }).sessionId\n return typeof sessionId === 'string' && sessionId.length > 0 && sessionId.length <= 200 ? sessionId : undefined\n}\n\nexport function sessionCwd(session: unknown): string | undefined {\n if (!session || typeof session !== 'object') return undefined\n const row = session as { meta?: { cwd?: unknown }; header?: { cwd?: unknown } }\n const cwd = row.meta?.cwd ?? row.header?.cwd\n return typeof cwd === 'string' ? cwd : undefined\n}\n\nexport function scopesEqual(left: KnowledgeScope, right: KnowledgeScope): boolean {\n if (left.kind === 'global') return right.kind === 'global'\n return right.kind === 'project' && left.projectId === right.projectId\n}\n\nexport function scopeKey(scope: KnowledgeScope): string {\n return scope.kind === 'global' ? 'global' : `project:${scope.projectId}`\n}\n\nexport function cloneRecord(record: MemoryRecord): MemoryRecord {\n return structuredClone(record)\n}\n","import type { MemoryStatus, RpcResult } from './contracts.ts'\n\nexport type MemoryGenerationGate = {\n current: () => number\n next: () => number\n isCurrent: (token: number) => boolean\n}\n\nexport function createMemoryGeneration(start = 0): MemoryGenerationGate {\n let current = start\n return {\n current: () => current,\n next: () => {\n current += 1\n return current\n },\n isCurrent: token => token === current,\n }\n}\n\nexport function memoryRequestStillCurrent(input: {\n token: number\n gate: Pick<MemoryGenerationGate, 'isCurrent'>\n signal: AbortSignal\n sessionId: string\n viewSessionId: string\n}): boolean {\n return input.gate.isCurrent(input.token)\n && !input.signal.aborted\n && input.sessionId === input.viewSessionId\n}\n\nexport type MemoryViewRequest = {\n sessionId: string\n token: number\n signal: AbortSignal\n controller: AbortController\n}\n\n/** Capture session, generation token, and abort lifetime before the first await. */\nexport function beginMemoryRequest(\n gate: MemoryGenerationGate,\n sessionId: string,\n previous?: AbortController | null,\n): MemoryViewRequest {\n previous?.abort()\n const controller = new AbortController()\n const captured = sessionId\n const token = gate.next()\n return { sessionId: captured, token, signal: controller.signal, controller }\n}\n\nexport function disposeMemoryRequest(gate: MemoryGenerationGate, controller: AbortController): void {\n controller.abort()\n gate.next()\n}\n\nexport type MemoryRpc = (endpoint: string, payload: unknown, signal?: AbortSignal) => Promise<unknown>\n\nexport function unwrapMemoryResult<T>(result: RpcResult<T>): T {\n if (!result.ok) throw new Error(result.error.message)\n return result.value\n}\n\nexport function shouldSkipMemoryRefresh(input: { busy: boolean; editing: boolean }): boolean {\n return input.busy || input.editing\n}\n\nexport async function loadMemoryStatus(input: {\n rpc: MemoryRpc\n sessionId: string\n token: number\n gate: Pick<MemoryGenerationGate, 'isCurrent'>\n signal: AbortSignal\n viewSessionId: () => string\n}): Promise<MemoryStatus | undefined> {\n const captured = input.sessionId\n const raw = await input.rpc('status', captured ? { sessionId: captured } : {}, input.signal)\n if (!memoryRequestStillCurrent({\n token: input.token, gate: input.gate, signal: input.signal, sessionId: captured, viewSessionId: input.viewSessionId(),\n })) return undefined\n return unwrapMemoryResult(raw as RpcResult<MemoryStatus>)\n}\n\n/** Read-only status peek; uses an independent signal so it cannot abort an in-flight write. */\nexport async function peekMemoryStatus(input: {\n rpc: MemoryRpc\n sessionId: string\n token: number\n gate: Pick<MemoryGenerationGate, 'isCurrent'>\n viewSessionId: () => string\n busy: () => boolean\n editing?: () => boolean\n}): Promise<MemoryStatus | undefined> {\n if (shouldSkipMemoryRefresh({ busy: input.busy(), editing: input.editing?.() === true })) return undefined\n const token = input.token\n if (!input.gate.isCurrent(token) || token === 0) return undefined\n const next = await loadMemoryStatus({\n rpc: input.rpc,\n sessionId: input.sessionId,\n token,\n gate: input.gate,\n signal: new AbortController().signal,\n viewSessionId: input.viewSessionId,\n })\n if (!next) return undefined\n if (shouldSkipMemoryRefresh({ busy: input.busy(), editing: input.editing?.() === true })) return undefined\n return next\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { useFeatureRefresh, useNativeSeat, type NativeSurfaceClient } from '@klarkxy/dsh-ai-services/client-utils'\nimport { useEffect, useId, useRef, useState, type ReactNode } from 'react'\nimport {\n MEMORY_RPC_CHANNEL,\n type DreamPlan, type MemoryRecord, type MemorySettings, type MemoryStatus, type RpcResult,\n} from './contracts.ts'\nimport {\n beginMemoryRequest, createMemoryGeneration, disposeMemoryRequest, loadMemoryStatus, memoryRequestStillCurrent,\n peekMemoryStatus, shouldSkipMemoryRefresh, unwrapMemoryResult,\n} from './view-lifetime.ts'\n\nexport const name = 'dsh-memory-client'\nexport const inject = ['slots', 'connection', 'sessions', 'locale', 'uiWorkspace', 'uiSession'] as const\nexport {\n beginMemoryRequest, createMemoryGeneration, disposeMemoryRequest, loadMemoryStatus, memoryRequestStillCurrent,\n peekMemoryStatus, shouldSkipMemoryRefresh, unwrapMemoryResult,\n} from './view-lifetime.ts'\n\ntype Client = NativeSurfaceClient & {\n connection: {\n rpc: { call(channel: string, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown> }\n generation?: { subscribe(listener: () => void): () => void }\n }\n slots: {\n inject(key: string, callback: () => unknown): () => void\n register(spec: { name: string; id: string; label: string; order: number }, render: unknown): () => void\n }\n}\n\nexport type Locale = 'zh' | 'en'\nexport type SeatProps = { sessionId: string; locale: Locale; hidden: boolean }\n\nexport function parseSeatProps(props: unknown): SeatProps {\n const row = props && typeof props === 'object' ? props as Record<string, unknown> : {}\n const nested = row.owner && typeof row.owner === 'object' ? row.owner as Record<string, unknown> : undefined\n const sessionId = typeof row.sessionId === 'string' && row.sessionId\n ? row.sessionId\n : typeof nested?.sessionId === 'string' ? nested.sessionId : ''\n const locale = row.locale === 'en' || nested?.locale === 'en' ? 'en' : 'zh'\n const hidden = row.hidden === true || nested?.hidden === true\n return { sessionId, locale, hidden }\n}\n\nexport function memoryPanelKey(sessionId: string, locale: Locale): string {\n return `${sessionId}:${locale}`\n}\n\nexport function chatSummaryTitle(locale: Locale): string {\n return locale === 'en' ? 'Memory' : '记忆'\n}\n\nexport function candidateAvailabilityLabel(count: number, locale: Locale): string {\n if (count > 0) return locale === 'en' ? `${count} to review` : `${count} 条候选`\n return locale === 'en' ? 'No candidates' : '暂无候选'\n}\n\nexport function kindLabel(kind: MemoryRecord['kind'], locale: Locale): string {\n if (locale === 'en') {\n return kind === 'preference' ? 'Preference' : kind === 'project-fact' ? 'Project fact' : kind === 'decision' ? 'Decision' : 'Lesson'\n }\n return kind === 'preference' ? '偏好' : kind === 'project-fact' ? '项目事实' : kind === 'decision' ? '决策' : '教训'\n}\n\nexport function statusLabel(status: MemoryRecord['status'], locale: Locale): string {\n const zh: Record<MemoryRecord['status'], string> = {\n candidate: '候选', active: '已生效', rejected: '已拒绝', superseded: '已替代', revoked: '已撤销', deleted: '已删除',\n }\n const en: Record<MemoryRecord['status'], string> = {\n candidate: 'Candidate', active: 'Active', rejected: 'Rejected', superseded: 'Superseded', revoked: 'Revoked', deleted: 'Deleted',\n }\n return locale === 'en' ? en[status] : zh[status]\n}\n\nexport function canAccept(record: MemoryRecord): boolean { return record.status === 'candidate' }\nexport function canReject(record: MemoryRecord): boolean { return record.status === 'candidate' }\nexport function canRevoke(record: MemoryRecord): boolean { return record.status === 'active' }\n\nfunction t(locale: Locale, zh: string, en: string): string {\n return locale === 'en' ? en : zh\n}\n\nexport function MemoryChatShell(props: { locale: Locale; candidateCount: number; children?: ReactNode }) {\n return <details className=\"dsh-memory-chat\" data-testid=\"memory-chat\">\n <summary>\n <span>{chatSummaryTitle(props.locale)}</span>\n <span className=\"dsh-memory-meta\">{candidateAvailabilityLabel(props.candidateCount, props.locale)}</span>\n </summary>\n <div className=\"dsh-memory-chat-body\">{props.children}</div>\n </details>\n}\n\nfunction MemorySettingsPanel({ client, sessionId, locale }: { client: Client; sessionId: string; locale: Locale }) {\n const gate = useRef(createMemoryGeneration())\n const sessionRef = useRef(sessionId)\n const workRef = useRef<AbortController | null>(null)\n sessionRef.current = sessionId\n const [status, setStatus] = useState<MemoryStatus>()\n const [draft, setDraft] = useState<MemorySettings>()\n const [busy, setBusy] = useState(false)\n const [error, setError] = useState('')\n const [note, setNote] = useState('')\n const busyRef = useRef(false)\n const settingsDirty = useRef(false)\n busyRef.current = busy\n\n async function rpc(endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown> {\n const result = await client.connection.rpc.call(MEMORY_RPC_CHANNEL, endpoint, payload, signal)\n unwrapMemoryResult(result as RpcResult<unknown>)\n return result\n }\n\n useEffect(() => {\n const request = beginMemoryRequest(gate.current, sessionId, workRef.current)\n workRef.current = request.controller\n setError('')\n setNote('')\n void loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n }).then(next => {\n if (!next) return\n setStatus(next)\n setDraft(next.settings)\n settingsDirty.current = false\n }).catch(cause => {\n if (!memoryRequestStillCurrent({\n token: request.token, gate: gate.current, signal: request.signal,\n sessionId: request.sessionId, viewSessionId: sessionRef.current,\n })) return\n setError(cause instanceof Error ? cause.message : t(locale, '无法读取记忆设置。', 'Unable to load memory settings.'))\n })\n return () => disposeMemoryRequest(gate.current, workRef.current ?? request.controller)\n }, [client, sessionId, locale])\n\n useFeatureRefresh(client, sessionId, () => {\n void peekMemoryStatus({\n rpc, sessionId: sessionRef.current, token: gate.current.current(), gate: gate.current,\n viewSessionId: () => sessionRef.current, busy: () => busyRef.current, editing: () => settingsDirty.current,\n }).then(next => {\n if (next) { setStatus(next); setDraft(next.settings) }\n }).catch(() => {})\n }, false, true)\n\n async function action(run: (sessionId: string) => Promise<void>) {\n const request = beginMemoryRequest(gate.current, sessionId, workRef.current)\n workRef.current = request.controller\n setBusy(true); setNote(''); setError('')\n const still = () => memoryRequestStillCurrent({\n token: request.token, gate: gate.current, signal: request.signal,\n sessionId: request.sessionId, viewSessionId: sessionRef.current,\n })\n try {\n await run(request.sessionId)\n const next = await loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n })\n if (!next || !still()) return\n setStatus(next)\n setDraft(next.settings)\n settingsDirty.current = false\n setNote(t(locale, '已保存。', 'Saved.'))\n } catch (cause) {\n if (!still()) return\n setError(cause instanceof Error ? cause.message : t(locale, '操作失败。', 'Failed.'))\n const next = await loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n }).catch(() => undefined)\n if (next && still()) {\n setStatus(next)\n setDraft(next.settings)\n settingsDirty.current = false\n }\n } finally {\n if (still()) setBusy(false)\n }\n }\n\n if (!status || !draft) {\n return <section className=\"dsh-memory-settings\">\n <p role=\"status\">{error || t(locale, '正在读取设置…', 'Loading settings…')}</p>\n <button type=\"button\" onClick={() => void action(async () => {})}>{t(locale, '重新连接', 'Reconnect')}</button>\n </section>\n }\n\n return <section className=\"dsh-memory-settings\" data-testid=\"memory-settings\">\n {error && <p role=\"alert\" className=\"dsh-memory-error\">{error}</p>}\n {note && <p role=\"status\">{note}</p>}\n {status.storageFailed && <p role=\"alert\">{t(locale, '保存失败,已保留原内容。', 'Save failed; previous content was kept.')}</p>}\n {!status.aiAvailable && <p className=\"dsh-memory-meta\">{t(locale, '梦境整理需要单独加载 @klarkxy/dsh-ai-services。', 'Dream needs @klarkxy/dsh-ai-services loaded separately.')}</p>}\n <article className=\"dsh-memory-card\">\n <header>\n <div>\n <h3>{t(locale, '写入提示', 'Prompt injection')}</h3>\n <p className=\"dsh-memory-meta\">{t(locale, '关闭后不再注入记忆;存储保留。', 'Turns off injection; stored records remain.')}</p>\n </div>\n <button type=\"button\" role=\"switch\" className={`dsh-memory-switch${draft.injectEnabled ? ' is-on' : ''}`}\n aria-checked={draft.injectEnabled} aria-label={draft.injectEnabled ? t(locale, '关闭记忆注入', 'Disable memory injection') : t(locale, '启用记忆注入', 'Enable memory injection')}\n disabled={busy}\n onClick={() => void action(async () => {\n await rpc('settings.update', {\n expectedRevision: draft.revision,\n settings: { ...editable(draft), injectEnabled: !draft.injectEnabled },\n })\n })}>\n <span className=\"dsh-memory-switch-thumb\" aria-hidden=\"true\" />\n </button>\n </header>\n </article>\n <article className=\"dsh-memory-card\">\n <header>\n <div>\n <h3>{t(locale, '闲时梦境', 'Idle Dream')}</h3>\n <p className=\"dsh-memory-meta\">{t(locale, '闲时自动整理记忆(每天至多一次,自动生效)。', 'Auto-organizes memory while idle (at most once a day, applies automatically).')}</p>\n </div>\n <button type=\"button\" role=\"switch\" className={`dsh-memory-switch${draft.dreamIdleEnabled ? ' is-on' : ''}`}\n aria-checked={draft.dreamIdleEnabled} aria-label={draft.dreamIdleEnabled ? t(locale, '关闭闲时整理', 'Disable idle Dream') : t(locale, '启用闲时整理', 'Enable idle Dream')}\n disabled={busy}\n onClick={() => void action(async () => {\n await rpc('settings.update', {\n expectedRevision: draft.revision,\n settings: { ...editable(draft), dreamIdleEnabled: !draft.dreamIdleEnabled },\n })\n })}>\n <span className=\"dsh-memory-switch-thumb\" aria-hidden=\"true\" />\n </button>\n </header>\n <label>{t(locale, '空闲间隔(分钟)', 'Idle interval (minutes)')}\n <input type=\"number\" min={1} max={180} step={1} disabled={busy}\n value={Math.round(draft.idleMs / 60_000)}\n onChange={event => { settingsDirty.current = true; setDraft({ ...draft, idleMs: Math.round(Number(event.target.value) * 60_000) }) }} />\n </label>\n <button type=\"button\" disabled={busy} onClick={() => void action(async () => {\n await rpc('settings.update', {\n expectedRevision: draft.revision,\n settings: editable(draft),\n })\n })}>{t(locale, '保存', 'Save')}</button>\n </article>\n </section>\n}\n\nfunction editable(settings: MemorySettings): Omit<MemorySettings, 'revision'> {\n const { revision: _revision, ...rest } = settings\n return rest\n}\n\nfunction MemoryChatPanel({ client, sessionId, locale }: { client: Client; sessionId: string; locale: Locale }) {\n const formId = useId()\n const gate = useRef(createMemoryGeneration())\n const sessionRef = useRef(sessionId)\n const workRef = useRef<AbortController | null>(null)\n sessionRef.current = sessionId\n const [status, setStatus] = useState<MemoryStatus>()\n const [query, setQuery] = useState('')\n const [title, setTitle] = useState('')\n const [content, setContent] = useState('')\n const [kind, setKind] = useState<MemoryRecord['kind']>('preference')\n const [global, setGlobal] = useState(false)\n const [evidence, setEvidence] = useState('')\n const [busy, setBusy] = useState(false)\n const [error, setError] = useState('')\n const [note, setNote] = useState('')\n const [editing, setEditing] = useState(false)\n const busyRef = useRef(false)\n const editingRef = useRef(false)\n busyRef.current = busy\n editingRef.current = editing\n\n async function rpc(endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown> {\n const result = await client.connection.rpc.call(MEMORY_RPC_CHANNEL, endpoint, payload, signal)\n unwrapMemoryResult(result as RpcResult<unknown>)\n return result\n }\n\n useEffect(() => {\n const request = beginMemoryRequest(gate.current, sessionId, workRef.current)\n workRef.current = request.controller\n setError('')\n setNote('')\n void loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n }).then(next => {\n if (!next) return\n setStatus(next)\n }).catch(cause => {\n if (!memoryRequestStillCurrent({\n token: request.token, gate: gate.current, signal: request.signal,\n sessionId: request.sessionId, viewSessionId: sessionRef.current,\n })) return\n setError(cause instanceof Error ? cause.message : t(locale, '无法读取记忆。', 'Unable to load memory.'))\n })\n return () => disposeMemoryRequest(gate.current, workRef.current ?? request.controller)\n }, [client, sessionId, locale])\n\n useFeatureRefresh(client, sessionId, () => {\n void peekMemoryStatus({\n rpc, sessionId: sessionRef.current, token: gate.current.current(), gate: gate.current,\n viewSessionId: () => sessionRef.current, busy: () => busyRef.current, editing: () => editingRef.current,\n }).then(next => { if (next) setStatus(next) }).catch(() => {})\n }, Boolean(status?.runningDreams?.length), Boolean(sessionId))\n\n async function action(run: (sessionId: string) => Promise<void>) {\n const request = beginMemoryRequest(gate.current, sessionId, workRef.current)\n workRef.current = request.controller\n setBusy(true); setNote(''); setError('')\n const still = () => memoryRequestStillCurrent({\n token: request.token, gate: gate.current, signal: request.signal,\n sessionId: request.sessionId, viewSessionId: sessionRef.current,\n })\n try {\n await run(request.sessionId)\n const next = await loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n })\n if (!next || !still()) return\n setStatus(next)\n } catch (cause) {\n if (!still()) return\n setError(cause instanceof Error ? cause.message : t(locale, '操作失败。', 'Failed.'))\n const next = await loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n }).catch(() => undefined)\n if (next && still()) setStatus(next)\n } finally {\n if (still()) setBusy(false)\n }\n }\n\n const records = (status?.records ?? []).filter(record => {\n if (!query.trim()) return true\n return `${record.title}\\n${record.content}`.toLowerCase().includes(query.trim().toLowerCase())\n })\n const dreams = (status?.dreams ?? []).slice().sort((a, b) => b.updatedAt - a.updatedAt).slice(0, 8)\n const candidateCount = (status?.records ?? []).filter(record => record.status === 'candidate').length\n\n const body = <>\n <header>\n <p className=\"dsh-memory-meta\">{status?.projectId\n ? t(locale, '当前项目', 'This project')\n : t(locale, '无项目目录;全局写入需勾选。', 'No project path; global write must be explicit.')}</p>\n </header>\n {error && <p role=\"alert\" className=\"dsh-memory-error\">{error}</p>}\n {note && <p role=\"status\">{note}</p>}\n <label className=\"dsh-memory-search\">{t(locale, '搜索', 'Search')}\n <input value={query} onChange={event => setQuery(event.target.value)} disabled={busy}\n aria-label={t(locale, '搜索记忆', 'Search memory')} />\n </label>\n <ul className=\"dsh-memory-list\">\n {records.length === 0 ? <li className=\"dsh-memory-meta\">{query.trim() ? t(locale, '没有匹配的条目。', 'No matching records.') : t(locale, '暂无条目。', 'No records.')}</li> : records.map(record => (\n <MemoryRow key={record.id} record={record} locale={locale} busy={busy}\n onEditingChange={setEditing}\n onAccept={() => void action(captured => rpc('records.accept', { sessionId: captured, id: record.id, expectedRevision: record.revision }).then(() => { if (sessionRef.current === captured) setNote(t(locale, '已采纳。', 'Accepted.')) }))}\n onReject={() => void action(captured => rpc('records.reject', { sessionId: captured, id: record.id, expectedRevision: record.revision }).then(() => { if (sessionRef.current === captured) setNote(t(locale, '已拒绝。', 'Rejected.')) }))}\n onRevoke={() => void action(captured => rpc('records.revoke', { sessionId: captured, id: record.id, expectedRevision: record.revision }).then(() => { if (sessionRef.current === captured) setNote(t(locale, '已撤销。', 'Revoked.')) }))}\n onDelete={() => void action(captured => rpc('records.remove', { sessionId: captured, id: record.id, expectedRevision: record.revision }).then(() => { if (sessionRef.current === captured) setNote(t(locale, '已删除。', 'Deleted.')) }))}\n onSave={(nextTitle, nextContent) => void action(captured => rpc('records.update', { sessionId: captured, id: record.id, expectedRevision: record.revision, title: nextTitle, content: nextContent }).then(() => { if (sessionRef.current === captured) setNote(t(locale, '已更新。', 'Updated.')) }))}\n />\n ))}\n </ul>\n <form className=\"dsh-memory-add\" onSubmit={event => {\n event.preventDefault()\n void action(async captured => {\n await rpc('records.create', {\n sessionId: captured, title, content, kind, global,\n evidence: evidence.trim() ? [{ sessionId: captured, seq: 0, kind: 'manual', excerpt: evidence.trim().slice(0, 400) }] : [],\n })\n if (sessionRef.current !== captured) return\n setTitle(''); setContent(''); setEvidence(''); setNote(t(locale, '已添加。', 'Added.'))\n })\n }}>\n <h4>{t(locale, '手动添加', 'Add')}</h4>\n <label htmlFor={formId + '-title'}>{t(locale, '标题', 'Title')}\n <input id={formId + '-title'} value={title} required maxLength={160} disabled={busy}\n onChange={event => setTitle(event.target.value)} />\n </label>\n <label htmlFor={formId + '-body'}>{t(locale, '内容', 'Content')}\n <textarea id={formId + '-body'} value={content} required maxLength={4000} disabled={busy} rows={3}\n onChange={event => setContent(event.target.value)} />\n </label>\n <label>{t(locale, '类型', 'Kind')}\n <select value={kind} disabled={busy} onChange={event => setKind(event.target.value as MemoryRecord['kind'])}>\n <option value=\"preference\">{kindLabel('preference', locale)}</option>\n <option value=\"project-fact\">{kindLabel('project-fact', locale)}</option>\n <option value=\"decision\">{kindLabel('decision', locale)}</option>\n </select>\n </label>\n <label htmlFor={formId + '-evidence'}>{t(locale, '依据(可选)', 'Evidence (optional)')}\n <input id={formId + '-evidence'} value={evidence} maxLength={400} disabled={busy}\n onChange={event => setEvidence(event.target.value)} />\n </label>\n <label className=\"dsh-memory-check\">\n <input type=\"checkbox\" checked={global} disabled={busy} onChange={event => setGlobal(event.target.checked)} />\n {t(locale, '写入全局(跨项目)', 'Write as global')}\n </label>\n <button type=\"submit\" disabled={busy}>{t(locale, '添加', 'Add')}</button>\n </form>\n <DreamPanel locale={locale} busy={busy} dreams={dreams} running={Boolean(status?.runningDreams?.length)}\n aiAvailable={status?.aiAvailable === true} action={action} rpc={rpc} />\n </>\n\n return <MemoryChatShell locale={locale} candidateCount={candidateCount}>{body}</MemoryChatShell>\n}\n\nfunction MemoryRow(props: {\n record: MemoryRecord; locale: Locale; busy: boolean\n onEditingChange?: (editing: boolean) => void\n onAccept(): void; onReject(): void; onRevoke(): void; onDelete(): void\n onSave(title: string, content: string): void\n}) {\n const { record, locale } = props\n const [editing, setEditing] = useState(false)\n const [title, setTitle] = useState(record.title)\n const [content, setContent] = useState(record.content)\n const scope = record.scope.kind === 'global' ? t(locale, '全局', 'Global') : t(locale, '项目', 'Project')\n function setRowEditing(next: boolean) {\n setEditing(next)\n props.onEditingChange?.(next)\n }\n if (editing) {\n return <li>\n <label>{t(locale, '标题', 'Title')}\n <input value={title} disabled={props.busy} onChange={event => setTitle(event.target.value)} />\n </label>\n <label>{t(locale, '内容', 'Content')}\n <textarea value={content} disabled={props.busy} rows={3} maxLength={4000} onChange={event => setContent(event.target.value)} />\n </label>\n <div className=\"dsh-memory-row-actions\">\n <button type=\"button\" disabled={props.busy} onClick={() => { props.onSave(title, content); setRowEditing(false) }}>{t(locale, '保存', 'Save')}</button>\n <button type=\"button\" disabled={props.busy} onClick={() => setRowEditing(false)}>{t(locale, '取消', 'Cancel')}</button>\n </div>\n </li>\n }\n return <li>\n <strong>{record.title}</strong>\n <p className=\"dsh-memory-meta\">{kindLabel(record.kind, locale)} · {statusLabel(record.status, locale)} · {scope}</p>\n <p>{record.content}</p>\n {record.evidence.length > 0 && <p className=\"dsh-memory-meta\">{t(locale, '依据', 'Evidence')}:{record.evidence.map(item => item.excerpt ?? `${item.kind}#${item.seq}`).join(';')}</p>}\n <div className=\"dsh-memory-row-actions\">\n {record.status !== 'deleted' && <button type=\"button\" disabled={props.busy} onClick={() => { setTitle(record.title); setContent(record.content); setRowEditing(true) }}>{t(locale, '编辑', 'Edit')}</button>}\n {canAccept(record) && <button type=\"button\" disabled={props.busy} onClick={props.onAccept}>{t(locale, '采纳', 'Accept')}</button>}\n {canReject(record) && <button type=\"button\" disabled={props.busy} onClick={props.onReject}>{t(locale, '拒绝', 'Reject')}</button>}\n {canRevoke(record) && <button type=\"button\" disabled={props.busy} onClick={props.onRevoke}>{t(locale, '撤销', 'Revoke')}</button>}\n <ConfirmButton disabled={props.busy} label={t(locale, '删除', 'Delete')} confirmLabel={t(locale, '确认删除?', 'Confirm delete?')} onConfirm={props.onDelete} />\n </div>\n </li>\n}\n\nfunction ConfirmButton(props: { label: string; confirmLabel: string; disabled?: boolean; onConfirm(): void }) {\n const [armed, setArmed] = useState(false)\n const timer = useRef<ReturnType<typeof setTimeout>>(undefined)\n useEffect(() => () => clearTimeout(timer.current), [])\n function disarm() {\n clearTimeout(timer.current)\n setArmed(false)\n }\n return <button type=\"button\" className=\"dsh-memory-danger\" disabled={props.disabled}\n onClick={() => {\n if (!armed) {\n setArmed(true)\n timer.current = setTimeout(() => setArmed(false), 3000)\n return\n }\n disarm()\n props.onConfirm()\n }}\n onBlur={disarm}>{armed ? props.confirmLabel : props.label}</button>\n}\n\nexport function dreamStatusLabel(plan: DreamPlan, locale: Locale): string {\n if (plan.status === 'applied') return t(locale, '已应用', 'Applied')\n if (plan.status === 'noop') return t(locale, '无变化', 'No change')\n if (plan.status === 'failed' || plan.status === 'stale') return t(locale, '失败', 'Failed')\n if (plan.status === 'cancelled') return t(locale, '已取消', 'Cancelled')\n return plan.proposals.length ? t(locale, '未应用', 'Not applied') : t(locale, '无变化', 'No change')\n}\n\nfunction DreamPanel(props: {\n running: boolean\n locale: Locale; busy: boolean; dreams: DreamPlan[]; aiAvailable: boolean\n action(run: (sessionId: string) => Promise<void>): Promise<void>\n rpc(endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown>\n}) {\n const locale = props.locale\n return <article className=\"dsh-memory-dream\">\n <h4>{t(locale, '梦境整理', 'Dream')}</h4>\n <p className=\"dsh-memory-meta\">{t(locale, '闲置且新材料足够时每天至多自动整理一次,结果自动生效。', 'Runs at most once a day when idle with enough new material; results apply automatically.')}</p>\n <div className=\"dsh-memory-row-actions\">\n <button type=\"button\" disabled={props.busy || props.running || !props.aiAvailable} onClick={() => void props.action(async captured => {\n await props.rpc('dream.run', { sessionId: captured })\n })}>{t(locale, '立即整理', 'Organize now')}</button>\n {props.running && <span className=\"dsh-memory-meta\">{t(locale, '整理中…', 'Organizing…')}</span>}\n </div>\n {props.dreams.length > 0 && <ul>\n {props.dreams.map(plan => (\n <li key={plan.id}>\n <strong>{dreamStatusLabel(plan, locale)}</strong>{' '}\n <span className=\"dsh-memory-meta\">{new Date(plan.createdAt).toLocaleString(locale === 'zh' ? 'zh-CN' : 'en-US')}</span>\n {plan.proposals.length > 0 && <p className=\"dsh-memory-meta\">{plan.proposals.map(proposal => proposal.title).join('、')}</p>}\n {plan.error && <p className=\"dsh-memory-error\">{plan.error}</p>}\n </li>\n ))}\n </ul>}\n </article>\n}\n\nexport function MemorySettings({ client, props }: { client: Client; props: unknown }) {\n const seat = useNativeSeat(client, props)\n return <div className=\"dsh-memory-settings-root\" data-testid=\"memory-settings-root\">\n <MemorySettingsPanel key={`settings:${memoryPanelKey(seat.sessionId, seat.locale)}`} client={client} sessionId={seat.sessionId} locale={seat.locale} />\n {seat.sessionId && !seat.hidden\n ? <MemoryChatPanel key={`manage:${memoryPanelKey(seat.sessionId, seat.locale)}`} client={client} sessionId={seat.sessionId} locale={seat.locale} />\n : <p className=\"dsh-memory-meta\">{t(seat.locale, '选择一个会话后可以管理该会话的记忆。', 'Select a session to manage its memory.')}</p>}\n </div>\n}\n\nconst styles = `\n.dsh-memory-settings-root,.dsh-memory-settings,.dsh-memory-chat{max-width:760px;color:inherit;font:400 var(--font-size-2,14px)/1.5 var(--default-font-family,system-ui,sans-serif)}\n.dsh-memory-settings-root,.dsh-memory-settings{display:grid;gap:16px}\n.dsh-memory-chat-body{display:grid;gap:12px;margin-top:8px}\n.dsh-memory-settings p,.dsh-memory-chat p{margin:0;line-height:1.5}\n.dsh-memory-meta,.dsh-memory-chat small{font-size:var(--font-size-1,13px);color:var(--gray-11,inherit)}\n.dsh-memory-error{color:var(--red-11,#b42318)}\n.dsh-memory-card,.dsh-memory-dream,.dsh-memory-add{display:grid;gap:10px;padding:14px 16px;border:1px solid var(--gray-6,color-mix(in srgb,currentColor 15%,transparent));border-radius:12px}\n.dsh-memory-card header,.dsh-memory-chat-body header{display:flex;justify-content:space-between;gap:12px;align-items:center}\n.dsh-memory-card h3,.dsh-memory-add h4,.dsh-memory-dream h4{margin:0;font-size:var(--font-size-3,16px);font-weight:600}\n.dsh-memory-settings input,.dsh-memory-chat input,.dsh-memory-chat textarea,.dsh-memory-chat select{box-sizing:border-box;width:100%;min-width:0;padding:8px 10px;border:1px solid var(--gray-6,color-mix(in srgb,currentColor 22%,transparent));border-radius:8px;background:var(--color-surface,transparent);color:inherit;font:inherit;transition:border-color 150ms ease,box-shadow 150ms ease}\n.dsh-memory-settings input:focus,.dsh-memory-chat input:focus,.dsh-memory-chat textarea:focus,.dsh-memory-chat select:focus{border-color:var(--accent-9,#3b82f6);box-shadow:0 0 0 2px color-mix(in srgb,var(--accent-9,#3b82f6) 25%,transparent)}\n.dsh-memory-settings button:not([role=\"switch\"]),.dsh-memory-chat button:not([role=\"switch\"]){min-height:34px;padding:6px 12px;border:1px solid color-mix(in srgb,currentColor 25%,transparent);border-radius:8px;background:transparent;color:inherit;cursor:pointer;font:inherit;justify-self:start;transition:background-color 150ms ease,color 150ms ease,border-color 150ms ease,box-shadow 150ms ease,transform 150ms ease}\n.dsh-memory-settings button:not([role=\"switch\"]):hover:not(:disabled),.dsh-memory-chat button:not([role=\"switch\"]):hover:not(:disabled){background:var(--gray-3,color-mix(in srgb,currentColor 6%,transparent));border-color:color-mix(in srgb,currentColor 35%,transparent)}\n.dsh-memory-settings button:not([role=\"switch\"]):active:not(:disabled),.dsh-memory-chat button:not([role=\"switch\"]):active:not(:disabled){transform:scale(.97)}\n.dsh-memory-danger:hover:not(:disabled){border-color:var(--red-11,#b42318);color:var(--red-11,#b42318);background:color-mix(in srgb,var(--red-11,#b42318) 8%,transparent)}\n.dsh-memory-settings button:disabled,.dsh-memory-chat button:disabled{opacity:.45;cursor:not-allowed}\n.dsh-memory-settings .dsh-memory-switch,.dsh-memory-chat .dsh-memory-switch{all:unset;box-sizing:border-box;position:relative;display:inline-block;width:36px;height:20px;flex:none;border-radius:999px;background:var(--gray-7,color-mix(in srgb,currentColor 28%,transparent));cursor:pointer}\n.dsh-memory-switch.is-on{background:var(--accent-9,#3b82f6)}\n.dsh-memory-switch-thumb{position:absolute;top:3px;left:3px;width:14px;height:14px;border-radius:999px;background:#fff;transition:transform 150ms ease}\n.dsh-memory-switch.is-on .dsh-memory-switch-thumb{transform:translateX(16px)}\n.dsh-memory-settings :focus-visible,.dsh-memory-chat :focus-visible{outline:2px solid var(--accent-9,currentColor);outline-offset:3px}\n.dsh-memory-list{list-style:none;margin:0;padding:0;display:grid;gap:12px}\n.dsh-memory-list li{display:grid;gap:6px;padding:10px 4px;border-top:1px solid var(--gray-6,color-mix(in srgb,currentColor 15%,transparent));border-radius:10px;overflow-wrap:anywhere}\n.dsh-memory-row-actions{display:flex;flex-wrap:wrap;gap:8px}\n.dsh-memory-check{display:flex;gap:8px;align-items:center}\n.dsh-memory-check input{width:auto}\n.dsh-memory-chat>summary{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:baseline;cursor:pointer;min-height:34px;list-style:revert}\n@media(prefers-reduced-motion:reduce){.dsh-memory-switch-thumb{transition:none}.dsh-memory-settings button:not([role=\"switch\"]),.dsh-memory-chat button:not([role=\"switch\"]),.dsh-memory-settings input,.dsh-memory-chat input,.dsh-memory-chat textarea,.dsh-memory-chat select{transition:none}}\n`\n\nexport function apply(ctx: Context): void {\n const client = ctx as unknown as Client\n ctx.effect(() => {\n if (typeof document === 'undefined') return () => {}\n const style = document.createElement('style')\n style.setAttribute('data-plugin', '@klarkxy/dsh-memory')\n style.textContent = styles\n document.head.appendChild(style)\n return () => style.remove()\n }, 'dsh-memory.styles')\n ctx.effect(() => client.slots.inject('settings.section', () => client.slots.register({\n name: 'settings.section', id: 'memory', order: 65, label: '记忆',\n }, (props: unknown) => <MemorySettings client={client} props={props} />)), 'dsh-memory.settings')\n}\n"],"mappings":";;;;;AAaA,SAAgB,kBAAkB,QAAwE;CACxG,OAAO,OAAO,YAAY,UACtB,OAAO,YAAY,QAAQ,YAAY,CAAC,EAAE,aAAa,KACvD,OAAO,UAAU,QAAQ,QAAQ,YAAY,CAAC,CAAC,OAAO;AAC5D;;AAGA,SAAgB,cAAc,QAA6B,OAAgB;CACzE,MAAM,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AK,CAAA,CACnH;;AACP;AAEA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Bf,SAAgB,MAAM,KAAoB;CACxC,MAAM,SAAS;CACf,IAAI,aAAa;EACf,IAAI,OAAO,aAAa,aAAa,aAAa,CAAC;EACnD,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,aAAa,eAAe,qBAAqB;EACvD,MAAM,cAAc;EACpB,SAAS,KAAK,YAAY,KAAK;EAC/B,aAAa,MAAM,OAAO;CAC5B,GAAG,mBAAmB;CACtB,IAAI,aAAa,OAAO,MAAM,OAAO,0BAA0B,OAAO,MAAM,SAAS;EACnF,MAAM;EAAoB,IAAI;EAAU,OAAO;EAAI,OAAO;CAC5D,IAAI,UAAmB,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD;EAAwB;EAAe;CAAQ,CAAA,CAAC,CAAC,GAAG,qBAAqB;AAClG"}
|
|
1
|
+
{"version":3,"file":"client.inner.cjs","names":["useSyncExternalStore","useCallback","useRef","captured","useRef","useState","useId"],"sources":["../../dsh-ai-services/src/client-utils.ts","../src/contracts.ts","../src/view-lifetime.ts","../src/client.tsx"],"sourcesContent":["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","/** Browser-safe contracts. MemoryRecord / MemoryService match frozen @klarkxy/dsh-ai-services. */\nimport {\n CHAT_EVENTS_SLOT as FROZEN_CHAT_EVENTS_SLOT,\n projectIdFromCwd as frozenProjectIdFromCwd,\n} from '@klarkxy/dsh-ai-services/contracts'\nimport type {\n AiFeatureScope,\n AiServices,\n AuxiliaryRequest,\n AuxiliaryResult,\n EvidenceRef,\n KnowledgeKind,\n KnowledgeScope,\n MemoryQuery,\n MemoryRecord,\n MemoryService,\n NewMemoryRecord,\n PurposeSpec,\n ProducerMessageSource,\n RpcResult,\n UsageReceipt,\n} from '@klarkxy/dsh-ai-services/contracts'\n\nexport type {\n AiFeatureScope,\n AiServices,\n AuxiliaryRequest,\n AuxiliaryResult,\n EvidenceRef,\n KnowledgeKind,\n KnowledgeScope,\n MemoryQuery,\n MemoryRecord,\n MemoryService,\n NewMemoryRecord,\n PurposeSpec,\n ProducerMessageSource,\n RpcResult,\n UsageReceipt,\n}\n\n/** Frozen shared chat-events seat. Must stay equal to @klarkxy/dsh-ai-services CHAT_EVENTS_SLOT. */\nexport const CHAT_EVENTS_SLOT = FROZEN_CHAT_EVENTS_SLOT\n/** Shared untruncated cwd identity. Drive roots (`/` / `C:/`) stay intact. */\nexport const projectIdFromCwd = frozenProjectIdFromCwd\nexport const MEMORY_PLUGIN = '@klarkxy/dsh-memory'\nexport const MEMORY_SOURCE_KIND = 'plugin:@klarkxy/dsh-memory' as const\nexport const MEMORY_RPC_CHANNEL = '/dsh-memory'\nexport const MEMORY_DREAM_PURPOSE = 'memory.dream'\nexport const MEMORY_INJECTION_SECTION = 'dsh-memory:recall'\n/** Frozen pluginName now accepts scoped ids. */\nexport const MEMORY_ACTIVATE_ID = MEMORY_PLUGIN\n\nexport const DEFAULT_IDLE_MS = 15 * 60 * 1000\nexport const MIN_IDLE_MS = 60_000\nexport const MAX_IDLE_MS = 180 * 60_000\nexport const DREAM_MIN_INTERVAL_MS = 24 * 60 * 60 * 1000\nexport const DREAM_MIN_MATERIAL = 3\nexport const MIN_RECALL_RECORDS = 1\nexport const MAX_RECALL_RECORDS = 5\nexport const MAX_RECALL_TOKENS = 800\nexport const MAX_PROJECT_ID_CHARS = 32_768\nexport const INJECT_KINDS: readonly KnowledgeKind[] = ['preference', 'project-fact', 'decision', 'vocabulary', 'activity']\nexport const RECALL_EXCLUDED_STATUSES: readonly MemoryRecord['status'][] = [\n 'candidate', 'rejected', 'revoked', 'deleted', 'superseded',\n]\n\nexport interface MemorySettings {\n revision: number\n injectEnabled: boolean\n dreamIdleEnabled: boolean\n idleMs: number\n}\n\nexport const defaultSettings = (): MemorySettings => ({\n revision: 0,\n injectEnabled: true,\n dreamIdleEnabled: true,\n idleMs: DEFAULT_IDLE_MS,\n})\n\nexport type DreamPlanStatus = 'preview' | 'applied' | 'cancelled' | 'stale' | 'failed' | 'noop'\n\nexport interface DreamSnapshotEntry {\n id: string\n revision: number\n status: MemoryRecord['status']\n scope: KnowledgeScope\n expiresAt?: number\n kind?: KnowledgeKind\n context?: MemoryRecord['context']\n}\n\nexport interface DreamProposal {\n title: string\n content: string\n kind: Exclude<KnowledgeKind, 'lesson'>\n tags: string[]\n exceptions: string[]\n evidence: EvidenceRef[]\n sourceIds: string[]\n scope: KnowledgeScope\n context?: MemoryRecord['context']\n}\n\nexport interface DreamPlan {\n id: string\n revision: number\n sessionId: string\n projectId?: string\n status: DreamPlanStatus\n sourceVersion: string\n snapshot: DreamSnapshotEntry[]\n proposals: DreamProposal[]\n generation: number\n createdAt: number\n updatedAt: number\n error?: string\n}\n\nexport interface MemoryTombstone {\n id: string\n deletedAt: number\n lastRevision: number\n}\n\nexport interface MemoryPersistedState {\n settings: MemorySettings\n records: MemoryRecord[]\n tombstones: MemoryTombstone[]\n dreams: DreamPlan[]\n lastAttemptAt?: number\n /** Bounded per-session source cursors; retained when a derived record is deleted. */\n observations?: Array<{ sessionId: string; seq: number; updatedAt: number }>\n}\n\nexport interface MemoryStatus {\n runningDreams?: string[]\n settings: MemorySettings\n records: MemoryRecord[]\n dreams: DreamPlan[]\n projectId?: string\n storageFailed: boolean\n aiAvailable: boolean\n}\n\n/** Matches frozen MemoryService optional mutation identity/lifetime guards. */\nexport interface MemoryMutationOptions { signal?: AbortSignal; isCurrent?: () => boolean }\n\nexport interface PreStepEnter {\n kind: 'enter'\n messages: unknown[]\n startsRequestSeries?: true\n}\nexport type PreStepDecision = { kind: 'reject' } | PreStepEnter\n\nexport interface InjectedMemoryMessage {\n content: Array<{ type: 'text'; text: string }>\n source: ProducerMessageSource & {\n kind: typeof MEMORY_SOURCE_KIND\n plugin: typeof MEMORY_PLUGIN\n form: 'snapshot'\n sections: Array<{ name: string; text: string }>\n }\n}\n\nexport function fail<T = never>(code: string, message: string): RpcResult<T> {\n return { ok: false, error: { code, message } }\n}\n\nexport function ok<T>(value: T): RpcResult<T> {\n return { ok: true, value }\n}\n\nexport function parseSessionId(payload: unknown): string | undefined {\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return undefined\n const sessionId = (payload as { sessionId?: unknown }).sessionId\n return typeof sessionId === 'string' && sessionId.length > 0 && sessionId.length <= 200 ? sessionId : undefined\n}\n\nexport function sessionCwd(session: unknown): string | undefined {\n if (!session || typeof session !== 'object') return undefined\n const row = session as { meta?: { cwd?: unknown }; header?: { cwd?: unknown } }\n const cwd = row.meta?.cwd ?? row.header?.cwd\n return typeof cwd === 'string' ? cwd : undefined\n}\n\nexport function scopesEqual(left: KnowledgeScope, right: KnowledgeScope): boolean {\n if (left.kind === 'global') return right.kind === 'global'\n return right.kind === 'project' && left.projectId === right.projectId\n}\n\nexport function scopeKey(scope: KnowledgeScope): string {\n return scope.kind === 'global' ? 'global' : `project:${scope.projectId}`\n}\n\nexport function cloneRecord(record: MemoryRecord): MemoryRecord {\n return structuredClone(record)\n}\n","import type { MemoryStatus, RpcResult } from './contracts.ts'\n\nexport type MemoryGenerationGate = {\n current: () => number\n next: () => number\n isCurrent: (token: number) => boolean\n}\n\nexport function createMemoryGeneration(start = 0): MemoryGenerationGate {\n let current = start\n return {\n current: () => current,\n next: () => {\n current += 1\n return current\n },\n isCurrent: token => token === current,\n }\n}\n\nexport function memoryRequestStillCurrent(input: {\n token: number\n gate: Pick<MemoryGenerationGate, 'isCurrent'>\n signal: AbortSignal\n sessionId: string\n viewSessionId: string\n}): boolean {\n return input.gate.isCurrent(input.token)\n && !input.signal.aborted\n && input.sessionId === input.viewSessionId\n}\n\nexport type MemoryViewRequest = {\n sessionId: string\n token: number\n signal: AbortSignal\n controller: AbortController\n}\n\n/** Capture session, generation token, and abort lifetime before the first await. */\nexport function beginMemoryRequest(\n gate: MemoryGenerationGate,\n sessionId: string,\n previous?: AbortController | null,\n): MemoryViewRequest {\n previous?.abort()\n const controller = new AbortController()\n const captured = sessionId\n const token = gate.next()\n return { sessionId: captured, token, signal: controller.signal, controller }\n}\n\nexport function disposeMemoryRequest(gate: MemoryGenerationGate, controller: AbortController): void {\n controller.abort()\n gate.next()\n}\n\nexport type MemoryRpc = (endpoint: string, payload: unknown, signal?: AbortSignal) => Promise<unknown>\n\nexport function unwrapMemoryResult<T>(result: RpcResult<T>): T {\n if (!result.ok) throw new Error(result.error.message)\n return result.value\n}\n\nexport function shouldSkipMemoryRefresh(input: { busy: boolean; editing: boolean }): boolean {\n return input.busy || input.editing\n}\n\nexport async function loadMemoryStatus(input: {\n rpc: MemoryRpc\n sessionId: string\n token: number\n gate: Pick<MemoryGenerationGate, 'isCurrent'>\n signal: AbortSignal\n viewSessionId: () => string\n}): Promise<MemoryStatus | undefined> {\n const captured = input.sessionId\n const raw = await input.rpc('status', captured ? { sessionId: captured } : {}, input.signal)\n if (!memoryRequestStillCurrent({\n token: input.token, gate: input.gate, signal: input.signal, sessionId: captured, viewSessionId: input.viewSessionId(),\n })) return undefined\n return unwrapMemoryResult(raw as RpcResult<MemoryStatus>)\n}\n\n/** Read-only status peek; uses an independent signal so it cannot abort an in-flight write. */\nexport async function peekMemoryStatus(input: {\n rpc: MemoryRpc\n sessionId: string\n token: number\n gate: Pick<MemoryGenerationGate, 'isCurrent'>\n viewSessionId: () => string\n busy: () => boolean\n editing?: () => boolean\n}): Promise<MemoryStatus | undefined> {\n if (shouldSkipMemoryRefresh({ busy: input.busy(), editing: input.editing?.() === true })) return undefined\n const token = input.token\n if (!input.gate.isCurrent(token) || token === 0) return undefined\n const next = await loadMemoryStatus({\n rpc: input.rpc,\n sessionId: input.sessionId,\n token,\n gate: input.gate,\n signal: new AbortController().signal,\n viewSessionId: input.viewSessionId,\n })\n if (!next) return undefined\n if (shouldSkipMemoryRefresh({ busy: input.busy(), editing: input.editing?.() === true })) return undefined\n return next\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { useFeatureRefresh, useNativeSeat, type NativeSurfaceClient } from '@klarkxy/dsh-ai-services/client-utils'\nimport { useEffect, useId, useRef, useState, type ReactNode } from 'react'\nimport {\n MEMORY_RPC_CHANNEL,\n type DreamPlan, type MemoryRecord, type MemorySettings, type MemoryStatus, type RpcResult,\n} from './contracts.ts'\nimport {\n beginMemoryRequest, createMemoryGeneration, disposeMemoryRequest, loadMemoryStatus, memoryRequestStillCurrent,\n peekMemoryStatus, shouldSkipMemoryRefresh, unwrapMemoryResult,\n} from './view-lifetime.ts'\n\nexport const name = 'dsh-memory-client'\nexport const inject = ['slots', 'connection', 'sessions', 'locale', 'uiWorkspace', 'uiSession'] as const\nexport {\n beginMemoryRequest, createMemoryGeneration, disposeMemoryRequest, loadMemoryStatus, memoryRequestStillCurrent,\n peekMemoryStatus, shouldSkipMemoryRefresh, unwrapMemoryResult,\n} from './view-lifetime.ts'\n\ntype Client = NativeSurfaceClient & {\n connection: {\n rpc: { call(channel: string, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown> }\n generation?: { subscribe(listener: () => void): () => void }\n }\n slots: {\n inject(key: string, callback: () => unknown): () => void\n register(spec: { name: string; id: string; label: string; order: number }, render: unknown): () => void\n }\n}\n\nexport type Locale = 'zh' | 'en'\nexport type SeatProps = { sessionId: string; locale: Locale; hidden: boolean }\n\nexport function parseSeatProps(props: unknown): SeatProps {\n const row = props && typeof props === 'object' ? props as Record<string, unknown> : {}\n const nested = row.owner && typeof row.owner === 'object' ? row.owner as Record<string, unknown> : undefined\n const sessionId = typeof row.sessionId === 'string' && row.sessionId\n ? row.sessionId\n : typeof nested?.sessionId === 'string' ? nested.sessionId : ''\n const locale = row.locale === 'en' || nested?.locale === 'en' ? 'en' : 'zh'\n const hidden = row.hidden === true || nested?.hidden === true\n return { sessionId, locale, hidden }\n}\n\nexport function memoryPanelKey(sessionId: string, locale: Locale): string {\n return `${sessionId}:${locale}`\n}\n\nexport function chatSummaryTitle(locale: Locale): string {\n return locale === 'en' ? 'Memory' : '记忆'\n}\n\nexport function candidateAvailabilityLabel(count: number, locale: Locale): string {\n if (count > 0) return locale === 'en' ? `${count} to review` : `${count} 条候选`\n return locale === 'en' ? 'No candidates' : '暂无候选'\n}\n\nexport function kindLabel(kind: MemoryRecord['kind'], locale: Locale): string {\n const labels: Record<MemoryRecord['kind'], [string, string]> = {\n preference: ['偏好', 'Preference'], 'project-fact': ['项目事实', 'Project fact'], decision: ['决策', 'Decision'],\n vocabulary: ['用语释义', 'Vocabulary'], activity: ['近期状态', 'Recent activity'], lesson: ['行动经验', 'Method'],\n }\n return labels[kind][locale === 'en' ? 1 : 0]\n}\n\nexport function statusLabel(status: MemoryRecord['status'], locale: Locale): string {\n const zh: Record<MemoryRecord['status'], string> = {\n candidate: '候选', active: '已生效', rejected: '已拒绝', superseded: '已替代', revoked: '已撤销', deleted: '已删除',\n }\n const en: Record<MemoryRecord['status'], string> = {\n candidate: 'Candidate', active: 'Active', rejected: 'Rejected', superseded: 'Superseded', revoked: 'Revoked', deleted: 'Deleted',\n }\n return locale === 'en' ? en[status] : zh[status]\n}\n\nexport function canAccept(record: MemoryRecord): boolean { return record.status === 'candidate' }\nexport function canReject(record: MemoryRecord): boolean { return record.status === 'candidate' }\nexport function canRevoke(record: MemoryRecord): boolean { return record.status === 'active' }\n\nfunction t(locale: Locale, zh: string, en: string): string {\n return locale === 'en' ? en : zh\n}\n\nexport function MemoryChatShell(props: { locale: Locale; candidateCount: number; children?: ReactNode }) {\n return <details className=\"dsh-memory-chat\" data-testid=\"memory-chat\">\n <summary>\n <span>{chatSummaryTitle(props.locale)}</span>\n <span className=\"dsh-memory-meta\">{candidateAvailabilityLabel(props.candidateCount, props.locale)}</span>\n </summary>\n <div className=\"dsh-memory-chat-body\">{props.children}</div>\n </details>\n}\n\nfunction MemorySettingsPanel({ client, sessionId, locale }: { client: Client; sessionId: string; locale: Locale }) {\n const gate = useRef(createMemoryGeneration())\n const sessionRef = useRef(sessionId)\n const workRef = useRef<AbortController | null>(null)\n sessionRef.current = sessionId\n const [status, setStatus] = useState<MemoryStatus>()\n const [draft, setDraft] = useState<MemorySettings>()\n const [busy, setBusy] = useState(false)\n const [error, setError] = useState('')\n const [note, setNote] = useState('')\n const busyRef = useRef(false)\n const settingsDirty = useRef(false)\n busyRef.current = busy\n\n async function rpc(endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown> {\n const result = await client.connection.rpc.call(MEMORY_RPC_CHANNEL, endpoint, payload, signal)\n unwrapMemoryResult(result as RpcResult<unknown>)\n return result\n }\n\n useEffect(() => {\n const request = beginMemoryRequest(gate.current, sessionId, workRef.current)\n workRef.current = request.controller\n setError('')\n setNote('')\n void loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n }).then(next => {\n if (!next) return\n setStatus(next)\n setDraft(next.settings)\n settingsDirty.current = false\n }).catch(cause => {\n if (!memoryRequestStillCurrent({\n token: request.token, gate: gate.current, signal: request.signal,\n sessionId: request.sessionId, viewSessionId: sessionRef.current,\n })) return\n setError(cause instanceof Error ? cause.message : t(locale, '无法读取记忆设置。', 'Unable to load memory settings.'))\n })\n return () => disposeMemoryRequest(gate.current, workRef.current ?? request.controller)\n }, [client, sessionId, locale])\n\n useFeatureRefresh(client, sessionId, () => {\n void peekMemoryStatus({\n rpc, sessionId: sessionRef.current, token: gate.current.current(), gate: gate.current,\n viewSessionId: () => sessionRef.current, busy: () => busyRef.current, editing: () => settingsDirty.current,\n }).then(next => {\n if (next) { setStatus(next); setDraft(next.settings) }\n }).catch(() => {})\n }, false, true)\n\n async function action(run: (sessionId: string) => Promise<void>) {\n const request = beginMemoryRequest(gate.current, sessionId, workRef.current)\n workRef.current = request.controller\n setBusy(true); setNote(''); setError('')\n const still = () => memoryRequestStillCurrent({\n token: request.token, gate: gate.current, signal: request.signal,\n sessionId: request.sessionId, viewSessionId: sessionRef.current,\n })\n try {\n await run(request.sessionId)\n const next = await loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n })\n if (!next || !still()) return\n setStatus(next)\n setDraft(next.settings)\n settingsDirty.current = false\n setNote(t(locale, '已保存。', 'Saved.'))\n } catch (cause) {\n if (!still()) return\n setError(cause instanceof Error ? cause.message : t(locale, '操作失败。', 'Failed.'))\n const next = await loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n }).catch(() => undefined)\n if (next && still()) {\n setStatus(next)\n setDraft(next.settings)\n settingsDirty.current = false\n }\n } finally {\n if (still()) setBusy(false)\n }\n }\n\n if (!status || !draft) {\n return <section className=\"dsh-memory-settings\">\n <p role=\"status\">{error || t(locale, '正在读取设置…', 'Loading settings…')}</p>\n <button type=\"button\" onClick={() => void action(async () => {})}>{t(locale, '重新连接', 'Reconnect')}</button>\n </section>\n }\n\n return <section className=\"dsh-memory-settings\" data-testid=\"memory-settings\">\n {error && <p role=\"alert\" className=\"dsh-memory-error\">{error}</p>}\n {note && <p role=\"status\">{note}</p>}\n {status.storageFailed && <p role=\"alert\">{t(locale, '保存失败,已保留原内容。', 'Save failed; previous content was kept.')}</p>}\n {!status.aiAvailable && <p className=\"dsh-memory-meta\">{t(locale, '梦境整理需要单独加载 @klarkxy/dsh-ai-services。', 'Dream needs @klarkxy/dsh-ai-services loaded separately.')}</p>}\n <article className=\"dsh-memory-card\">\n <header>\n <div>\n <h3>{t(locale, '写入提示', 'Prompt injection')}</h3>\n <p className=\"dsh-memory-meta\">{t(locale, '关闭后不再注入记忆;存储保留。', 'Turns off injection; stored records remain.')}</p>\n </div>\n <button type=\"button\" role=\"switch\" className={`dsh-memory-switch${draft.injectEnabled ? ' is-on' : ''}`}\n aria-checked={draft.injectEnabled} aria-label={draft.injectEnabled ? t(locale, '关闭记忆注入', 'Disable memory injection') : t(locale, '启用记忆注入', 'Enable memory injection')}\n disabled={busy}\n onClick={() => void action(async () => {\n await rpc('settings.update', {\n expectedRevision: draft.revision,\n settings: { ...editable(draft), injectEnabled: !draft.injectEnabled },\n })\n })}>\n <span className=\"dsh-memory-switch-thumb\" aria-hidden=\"true\" />\n </button>\n </header>\n </article>\n <article className=\"dsh-memory-card\">\n <header>\n <div>\n <h3>{t(locale, 'Dream 语境记忆', 'Dream context memory')}</h3>\n <p className=\"dsh-memory-meta\">{t(locale, '从原始用户消息记录用语与近期状态,闲时整理已有语境。行动方法由自我改进负责。', 'Records vocabulary and recent activity from original user messages, then consolidates context while idle. Self Improve owns methods.')}</p>\n </div>\n <button type=\"button\" role=\"switch\" className={`dsh-memory-switch${draft.dreamIdleEnabled ? ' is-on' : ''}`}\n aria-checked={draft.dreamIdleEnabled} aria-label={draft.dreamIdleEnabled ? t(locale, '关闭 Dream 观察与整理', 'Disable Dream observation and consolidation') : t(locale, '启用 Dream 观察与整理', 'Enable Dream observation and consolidation')}\n disabled={busy}\n onClick={() => void action(async () => {\n await rpc('settings.update', {\n expectedRevision: draft.revision,\n settings: { ...editable(draft), dreamIdleEnabled: !draft.dreamIdleEnabled },\n })\n })}>\n <span className=\"dsh-memory-switch-thumb\" aria-hidden=\"true\" />\n </button>\n </header>\n <p className=\"dsh-memory-meta\">{t(locale, '闲时整理在会话空闲约 15 分钟后尝试。', 'Idle organization waits about 15 minutes of inactivity.')}</p>\n </article>\n </section>\n}\n\nfunction editable(settings: MemorySettings): Omit<MemorySettings, 'revision'> {\n const { revision: _revision, ...rest } = settings\n return rest\n}\n\nfunction MemoryChatPanel({ client, sessionId, locale }: { client: Client; sessionId: string; locale: Locale }) {\n const formId = useId()\n const gate = useRef(createMemoryGeneration())\n const sessionRef = useRef(sessionId)\n const workRef = useRef<AbortController | null>(null)\n sessionRef.current = sessionId\n const [status, setStatus] = useState<MemoryStatus>()\n const [query, setQuery] = useState('')\n const [title, setTitle] = useState('')\n const [content, setContent] = useState('')\n const [kind, setKind] = useState<MemoryRecord['kind']>('preference')\n const [global, setGlobal] = useState(false)\n const [evidence, setEvidence] = useState('')\n const [busy, setBusy] = useState(false)\n const [error, setError] = useState('')\n const [note, setNote] = useState('')\n const [editing, setEditing] = useState(false)\n const busyRef = useRef(false)\n const editingRef = useRef(false)\n busyRef.current = busy\n editingRef.current = editing\n\n async function rpc(endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown> {\n const result = await client.connection.rpc.call(MEMORY_RPC_CHANNEL, endpoint, payload, signal)\n unwrapMemoryResult(result as RpcResult<unknown>)\n return result\n }\n\n useEffect(() => {\n const request = beginMemoryRequest(gate.current, sessionId, workRef.current)\n workRef.current = request.controller\n setError('')\n setNote('')\n void loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n }).then(next => {\n if (!next) return\n setStatus(next)\n }).catch(cause => {\n if (!memoryRequestStillCurrent({\n token: request.token, gate: gate.current, signal: request.signal,\n sessionId: request.sessionId, viewSessionId: sessionRef.current,\n })) return\n setError(cause instanceof Error ? cause.message : t(locale, '无法读取记忆。', 'Unable to load memory.'))\n })\n return () => disposeMemoryRequest(gate.current, workRef.current ?? request.controller)\n }, [client, sessionId, locale])\n\n useFeatureRefresh(client, sessionId, () => {\n void peekMemoryStatus({\n rpc, sessionId: sessionRef.current, token: gate.current.current(), gate: gate.current,\n viewSessionId: () => sessionRef.current, busy: () => busyRef.current, editing: () => editingRef.current,\n }).then(next => { if (next) setStatus(next) }).catch(() => {})\n }, Boolean(status?.runningDreams?.length), Boolean(sessionId))\n\n async function action(run: (sessionId: string) => Promise<void>) {\n const request = beginMemoryRequest(gate.current, sessionId, workRef.current)\n workRef.current = request.controller\n setBusy(true); setNote(''); setError('')\n const still = () => memoryRequestStillCurrent({\n token: request.token, gate: gate.current, signal: request.signal,\n sessionId: request.sessionId, viewSessionId: sessionRef.current,\n })\n try {\n await run(request.sessionId)\n const next = await loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n })\n if (!next || !still()) return\n setStatus(next)\n } catch (cause) {\n if (!still()) return\n setError(cause instanceof Error ? cause.message : t(locale, '操作失败。', 'Failed.'))\n const next = await loadMemoryStatus({\n rpc, sessionId: request.sessionId, token: request.token, gate: gate.current, signal: request.signal,\n viewSessionId: () => sessionRef.current,\n }).catch(() => undefined)\n if (next && still()) setStatus(next)\n } finally {\n if (still()) setBusy(false)\n }\n }\n\n const records = (status?.records ?? []).filter(record => {\n if (!query.trim()) return true\n return `${record.title}\\n${record.content}`.toLowerCase().includes(query.trim().toLowerCase())\n })\n const dreams = (status?.dreams ?? []).slice().sort((a, b) => b.updatedAt - a.updatedAt).slice(0, 8)\n const candidateCount = (status?.records ?? []).filter(record => record.status === 'candidate').length\n\n const body = <>\n <header>\n <p className=\"dsh-memory-meta\">{status?.projectId\n ? t(locale, '当前项目', 'This project')\n : t(locale, '无项目目录;全局写入需勾选。', 'No project path; global write must be explicit.')}</p>\n </header>\n {error && <p role=\"alert\" className=\"dsh-memory-error\">{error}</p>}\n {note && <p role=\"status\">{note}</p>}\n <label className=\"dsh-memory-search\">{t(locale, '搜索', 'Search')}\n <input value={query} onChange={event => setQuery(event.target.value)} disabled={busy}\n aria-label={t(locale, '搜索记忆', 'Search memory')} />\n </label>\n <ul className=\"dsh-memory-list\">\n {records.length === 0 ? <li className=\"dsh-memory-meta\">{query.trim() ? t(locale, '没有匹配的条目。', 'No matching records.') : t(locale, '暂无条目。', 'No records.')}</li> : records.map(record => (\n <MemoryRow key={record.id} record={record} locale={locale} busy={busy}\n onEditingChange={setEditing}\n onAccept={() => void action(captured => rpc('records.accept', { sessionId: captured, id: record.id, expectedRevision: record.revision }).then(() => { if (sessionRef.current === captured) setNote(t(locale, '已采纳。', 'Accepted.')) }))}\n onReject={() => void action(captured => rpc('records.reject', { sessionId: captured, id: record.id, expectedRevision: record.revision }).then(() => { if (sessionRef.current === captured) setNote(t(locale, '已拒绝。', 'Rejected.')) }))}\n onRevoke={() => void action(captured => rpc('records.revoke', { sessionId: captured, id: record.id, expectedRevision: record.revision }).then(() => { if (sessionRef.current === captured) setNote(t(locale, '已撤销。', 'Revoked.')) }))}\n onDelete={() => void action(captured => rpc('records.remove', { sessionId: captured, id: record.id, expectedRevision: record.revision }).then(() => { if (sessionRef.current === captured) setNote(t(locale, '已删除。', 'Deleted.')) }))}\n onSave={(nextTitle, nextContent) => void action(captured => rpc('records.update', { sessionId: captured, id: record.id, expectedRevision: record.revision, title: nextTitle, content: nextContent }).then(() => { if (sessionRef.current === captured) setNote(t(locale, '已更新。', 'Updated.')) }))}\n />\n ))}\n </ul>\n <form className=\"dsh-memory-add\" onSubmit={event => {\n event.preventDefault()\n void action(async captured => {\n await rpc('records.create', {\n sessionId: captured, title, content, kind, global,\n evidence: evidence.trim() ? [{ sessionId: captured, seq: 0, kind: 'manual', excerpt: evidence.trim().slice(0, 400) }] : [],\n })\n if (sessionRef.current !== captured) return\n setTitle(''); setContent(''); setEvidence(''); setNote(t(locale, '已添加。', 'Added.'))\n })\n }}>\n <h4>{t(locale, '手动添加', 'Add')}</h4>\n <label htmlFor={formId + '-title'}>{t(locale, '标题', 'Title')}\n <input id={formId + '-title'} value={title} required maxLength={160} disabled={busy}\n onChange={event => setTitle(event.target.value)} />\n </label>\n <label htmlFor={formId + '-body'}>{t(locale, '内容', 'Content')}\n <textarea id={formId + '-body'} value={content} required maxLength={4000} disabled={busy} rows={3}\n onChange={event => setContent(event.target.value)} />\n </label>\n <label>{t(locale, '类型', 'Kind')}\n <select value={kind} disabled={busy} onChange={event => setKind(event.target.value as MemoryRecord['kind'])}>\n <option value=\"preference\">{kindLabel('preference', locale)}</option>\n <option value=\"project-fact\">{kindLabel('project-fact', locale)}</option>\n <option value=\"decision\">{kindLabel('decision', locale)}</option>\n <option value=\"vocabulary\">{kindLabel('vocabulary', locale)}</option>\n <option value=\"activity\">{kindLabel('activity', locale)}</option>\n </select>\n </label>\n <label htmlFor={formId + '-evidence'}>{t(locale, '依据(可选)', 'Evidence (optional)')}\n <input id={formId + '-evidence'} value={evidence} maxLength={400} disabled={busy}\n onChange={event => setEvidence(event.target.value)} />\n </label>\n <label className=\"dsh-memory-check\">\n <input type=\"checkbox\" checked={global} disabled={busy} onChange={event => setGlobal(event.target.checked)} />\n {t(locale, '写入全局(跨项目)', 'Write as global')}\n </label>\n <button type=\"submit\" disabled={busy}>{t(locale, '添加', 'Add')}</button>\n </form>\n <DreamPanel locale={locale} busy={busy} dreams={dreams} running={Boolean(status?.runningDreams?.length)}\n aiAvailable={status?.aiAvailable === true} action={action} rpc={rpc} />\n </>\n\n return <MemoryChatShell locale={locale} candidateCount={candidateCount}>{body}</MemoryChatShell>\n}\n\nfunction MemoryRow(props: {\n record: MemoryRecord; locale: Locale; busy: boolean\n onEditingChange?: (editing: boolean) => void\n onAccept(): void; onReject(): void; onRevoke(): void; onDelete(): void\n onSave(title: string, content: string): void\n}) {\n const { record, locale } = props\n const [editing, setEditing] = useState(false)\n const [title, setTitle] = useState(record.title)\n const [content, setContent] = useState(record.content)\n const scope = record.scope.kind === 'global' ? t(locale, '全局', 'Global') : t(locale, '项目', 'Project')\n function setRowEditing(next: boolean) {\n setEditing(next)\n props.onEditingChange?.(next)\n }\n if (editing) {\n return <li>\n <label>{t(locale, '标题', 'Title')}\n <input value={title} disabled={props.busy} onChange={event => setTitle(event.target.value)} />\n </label>\n <label>{t(locale, '内容', 'Content')}\n <textarea value={content} disabled={props.busy} rows={3} maxLength={4000} onChange={event => setContent(event.target.value)} />\n </label>\n <div className=\"dsh-memory-row-actions\">\n <button type=\"button\" disabled={props.busy} onClick={() => { props.onSave(title, content); setRowEditing(false) }}>{t(locale, '保存', 'Save')}</button>\n <button type=\"button\" disabled={props.busy} onClick={() => setRowEditing(false)}>{t(locale, '取消', 'Cancel')}</button>\n </div>\n </li>\n }\n return <li>\n <strong>{record.title}</strong>\n <p className=\"dsh-memory-meta\">{kindLabel(record.kind, locale)} · {statusLabel(record.status, locale)} · {scope}</p>\n {record.context && <p className=\"dsh-memory-meta\">{record.context.subject} · {record.context.domain} · {record.context.key}\n {' · '}{t(locale, '记录于', 'Observed')} {new Date(record.context.observedAt).toLocaleString(locale === 'en' ? 'en-US' : 'zh-CN')}\n {record.context.activityStatus && ` · ${record.context.activityStatus}`}\n {record.context.eventTime && ` · ${record.context.eventTime}`}\n </p>}\n {record.kind === 'activity' && <p className=\"dsh-memory-meta\">{t(locale, '仅表示上次报告的状态;到期不代表任务已完成。', 'Last reported state only; expiry never means completion.')}</p>}\n <p>{record.content}</p>\n {record.evidence.length > 0 && <p className=\"dsh-memory-meta\">{t(locale, '依据', 'Evidence')}:{record.evidence.map(item => item.excerpt ?? `${item.kind}#${item.seq}`).join(';')}</p>}\n <div className=\"dsh-memory-row-actions\">\n {record.status !== 'deleted' && <button type=\"button\" disabled={props.busy} onClick={() => { setTitle(record.title); setContent(record.content); setRowEditing(true) }}>{t(locale, '编辑', 'Edit')}</button>}\n {canAccept(record) && <button type=\"button\" disabled={props.busy} onClick={props.onAccept}>{t(locale, '采纳', 'Accept')}</button>}\n {canReject(record) && <button type=\"button\" disabled={props.busy} onClick={props.onReject}>{t(locale, '拒绝', 'Reject')}</button>}\n {canRevoke(record) && <button type=\"button\" disabled={props.busy} onClick={props.onRevoke}>{t(locale, '撤销', 'Revoke')}</button>}\n <ConfirmButton disabled={props.busy} label={t(locale, '删除', 'Delete')} confirmLabel={t(locale, '确认删除?', 'Confirm delete?')} onConfirm={props.onDelete} />\n </div>\n </li>\n}\n\nfunction ConfirmButton(props: { label: string; confirmLabel: string; disabled?: boolean; onConfirm(): void }) {\n const [armed, setArmed] = useState(false)\n const timer = useRef<ReturnType<typeof setTimeout>>(undefined)\n useEffect(() => () => clearTimeout(timer.current), [])\n function disarm() {\n clearTimeout(timer.current)\n setArmed(false)\n }\n return <button type=\"button\" className=\"dsh-memory-danger\" disabled={props.disabled}\n onClick={() => {\n if (!armed) {\n setArmed(true)\n timer.current = setTimeout(() => setArmed(false), 3000)\n return\n }\n disarm()\n props.onConfirm()\n }}\n onBlur={disarm}>{armed ? props.confirmLabel : props.label}</button>\n}\n\nexport function dreamStatusLabel(plan: DreamPlan, locale: Locale): string {\n if (plan.status === 'applied') return t(locale, '已应用', 'Applied')\n if (plan.status === 'noop') return t(locale, '无变化', 'No change')\n if (plan.status === 'failed' || plan.status === 'stale') return t(locale, '失败', 'Failed')\n if (plan.status === 'cancelled') return t(locale, '已取消', 'Cancelled')\n return plan.proposals.length ? t(locale, '未应用', 'Not applied') : t(locale, '无变化', 'No change')\n}\n\nfunction DreamPanel(props: {\n running: boolean\n locale: Locale; busy: boolean; dreams: DreamPlan[]; aiAvailable: boolean\n action(run: (sessionId: string) => Promise<void>): Promise<void>\n rpc(endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown>\n}) {\n const locale = props.locale\n return <article className=\"dsh-memory-dream\">\n <h4>{t(locale, '梦境整理', 'Dream')}</h4>\n <p className=\"dsh-memory-meta\">{t(locale, '每天至多闲时整理一次;不把候选升级为事实,不延长近期状态的有效期。', 'Consolidates at most once a day while idle, without confirming candidates or extending activity freshness.')}</p>\n <div className=\"dsh-memory-row-actions\">\n <button type=\"button\" disabled={props.busy || props.running || !props.aiAvailable} onClick={() => void props.action(async captured => {\n await props.rpc('dream.run', { sessionId: captured })\n })}>{t(locale, '立即整理', 'Organize now')}</button>\n {props.running && <span className=\"dsh-memory-meta\">{t(locale, '整理中…', 'Organizing…')}</span>}\n </div>\n {props.dreams.length > 0 && <ul>\n {props.dreams.map(plan => (\n <li key={plan.id}>\n <strong>{dreamStatusLabel(plan, locale)}</strong>{' '}\n <span className=\"dsh-memory-meta\">{new Date(plan.createdAt).toLocaleString(locale === 'zh' ? 'zh-CN' : 'en-US')}</span>\n {plan.proposals.length > 0 && <p className=\"dsh-memory-meta\">{plan.proposals.map(proposal => proposal.title).join('、')}</p>}\n {plan.error && <p className=\"dsh-memory-error\">{plan.error}</p>}\n </li>\n ))}\n </ul>}\n </article>\n}\n\nfunction readSelfImprovementReview(host: unknown): { render(props: unknown): ReactNode } | undefined {\n if (!host || typeof host !== 'object') return undefined\n const context = host as { get?: (name: string) => unknown }\n if (typeof context.get !== 'function') return undefined\n let row: unknown\n try { row = context.get('dshSelfImprovementReview') } catch { return undefined }\n if (!row || typeof row !== 'object') return undefined\n const render = (row as { render?: unknown }).render\n if (typeof render !== 'function') return undefined\n return { render: render as (props: unknown) => ReactNode }\n}\n\nexport function MemorySettings({ client, host, props }: { client: Client; host?: unknown; props: unknown }) {\n const seat = useNativeSeat(client, props)\n const review = readSelfImprovementReview(host)\n return <div className=\"dsh-memory-settings-root\" data-testid=\"memory-settings-root\">\n <MemorySettingsPanel key={`settings:${memoryPanelKey(seat.sessionId, seat.locale)}`} client={client} sessionId={seat.sessionId} locale={seat.locale} />\n {review && seat.sessionId && !seat.hidden\n ? <details className=\"dsh-memory-si\" data-testid=\"self-improvement-entry\">\n <summary>{t(seat.locale, '自我改进', 'Self-improvement')}</summary>\n <div className=\"dsh-memory-si-body\">{review.render({ sessionId: seat.sessionId, locale: seat.locale })}</div>\n </details>\n : null}\n {seat.sessionId && !seat.hidden\n ? <MemoryChatPanel key={`manage:${memoryPanelKey(seat.sessionId, seat.locale)}`} client={client} sessionId={seat.sessionId} locale={seat.locale} />\n : <p className=\"dsh-memory-meta\">{t(seat.locale, '选择一个会话后可以管理该会话的记忆。', 'Select a session to manage its memory.')}</p>}\n </div>\n}\n\nconst styles = `\n.dsh-memory-settings-root,.dsh-memory-settings,.dsh-memory-chat{max-width:760px;color:inherit;font:400 var(--font-size-2,14px)/1.5 var(--default-font-family,system-ui,sans-serif)}\n.dsh-memory-settings-root,.dsh-memory-settings{display:grid;gap:16px}\n.dsh-memory-chat-body{display:grid;gap:12px;margin-top:8px}\n.dsh-memory-settings p,.dsh-memory-chat p{margin:0;line-height:1.5}\n.dsh-memory-meta,.dsh-memory-chat small{font-size:var(--font-size-1,13px);color:var(--gray-11,inherit)}\n.dsh-memory-error{color:var(--red-11,#b42318)}\n.dsh-memory-card,.dsh-memory-dream,.dsh-memory-add,.dsh-memory-si{display:grid;gap:10px;padding:14px 16px;border:1px solid var(--gray-6,color-mix(in srgb,currentColor 15%,transparent));border-radius:12px}\n.dsh-memory-card header,.dsh-memory-chat-body header{display:flex;justify-content:space-between;gap:12px;align-items:center}\n.dsh-memory-card h3,.dsh-memory-add h4,.dsh-memory-dream h4{margin:0;font-size:var(--font-size-3,16px);font-weight:600}\n.dsh-memory-settings input,.dsh-memory-chat input,.dsh-memory-chat textarea,.dsh-memory-chat select{box-sizing:border-box;width:100%;min-width:0;padding:8px 10px;border:1px solid var(--gray-6,color-mix(in srgb,currentColor 22%,transparent));border-radius:8px;background:var(--color-surface,transparent);color:inherit;font:inherit;transition:border-color 150ms ease,box-shadow 150ms ease}\n.dsh-memory-settings input:focus,.dsh-memory-chat input:focus,.dsh-memory-chat textarea:focus,.dsh-memory-chat select:focus{border-color:var(--accent-9,#3b82f6);box-shadow:0 0 0 2px color-mix(in srgb,var(--accent-9,#3b82f6) 25%,transparent)}\n.dsh-memory-settings button:not([role=\"switch\"]),.dsh-memory-chat button:not([role=\"switch\"]){min-height:34px;padding:6px 12px;border:1px solid color-mix(in srgb,currentColor 25%,transparent);border-radius:8px;background:transparent;color:inherit;cursor:pointer;font:inherit;justify-self:start;transition:background-color 150ms ease,color 150ms ease,border-color 150ms ease,box-shadow 150ms ease,transform 150ms ease}\n.dsh-memory-settings button:not([role=\"switch\"]):hover:not(:disabled),.dsh-memory-chat button:not([role=\"switch\"]):hover:not(:disabled){background:var(--gray-3,color-mix(in srgb,currentColor 6%,transparent));border-color:color-mix(in srgb,currentColor 35%,transparent)}\n.dsh-memory-settings button:not([role=\"switch\"]):active:not(:disabled),.dsh-memory-chat button:not([role=\"switch\"]):active:not(:disabled){transform:scale(.97)}\n.dsh-memory-danger:hover:not(:disabled){border-color:var(--red-11,#b42318);color:var(--red-11,#b42318);background:color-mix(in srgb,var(--red-11,#b42318) 8%,transparent)}\n.dsh-memory-settings button:disabled,.dsh-memory-chat button:disabled{opacity:.45;cursor:not-allowed}\n.dsh-memory-settings .dsh-memory-switch,.dsh-memory-chat .dsh-memory-switch{all:unset;box-sizing:border-box;position:relative;display:inline-block;width:36px;height:20px;flex:none;border-radius:999px;background:var(--gray-7,color-mix(in srgb,currentColor 28%,transparent));cursor:pointer}\n.dsh-memory-switch.is-on{background:var(--accent-9,#3b82f6)}\n.dsh-memory-switch-thumb{position:absolute;top:3px;left:3px;width:14px;height:14px;border-radius:999px;background:#fff;transition:transform 150ms ease}\n.dsh-memory-switch.is-on .dsh-memory-switch-thumb{transform:translateX(16px)}\n.dsh-memory-settings :focus-visible,.dsh-memory-chat :focus-visible{outline:2px solid var(--accent-9,currentColor);outline-offset:3px}\n.dsh-memory-list{list-style:none;margin:0;padding:0;display:grid;gap:12px}\n.dsh-memory-list li{display:grid;gap:6px;padding:10px 4px;border-top:1px solid var(--gray-6,color-mix(in srgb,currentColor 15%,transparent));border-radius:10px;overflow-wrap:anywhere}\n.dsh-memory-row-actions{display:flex;flex-wrap:wrap;gap:8px}\n.dsh-memory-check{display:flex;gap:8px;align-items:center}\n.dsh-memory-check input{width:auto}\n.dsh-memory-chat>summary,.dsh-memory-si>summary{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:baseline;cursor:pointer;min-height:34px;list-style:revert}\n.dsh-memory-si-body{margin-top:8px}\n@media(prefers-reduced-motion:reduce){.dsh-memory-switch-thumb{transition:none}.dsh-memory-settings button:not([role=\"switch\"]),.dsh-memory-chat button:not([role=\"switch\"]),.dsh-memory-settings input,.dsh-memory-chat input,.dsh-memory-chat textarea,.dsh-memory-chat select{transition:none}}\n`\n\nexport function apply(ctx: Context): void {\n const client = ctx as unknown as Client\n ctx.effect(() => {\n if (typeof document === 'undefined') return () => {}\n const style = document.createElement('style')\n style.setAttribute('data-plugin', '@klarkxy/dsh-memory')\n style.textContent = styles\n document.head.appendChild(style)\n return () => style.remove()\n }, 'dsh-memory.styles')\n ctx.effect(() => client.slots.inject('settings.section', () => client.slots.register({\n name: 'settings.section', id: 'memory', order: 65, label: '记忆',\n }, (props: unknown) => <MemorySettings client={client} host={ctx} props={props} />)), 'dsh-memory.settings')\n}\n"],"mappings":";;;;;AAaA,SAAgB,kBAAkB,QAAwE;CACxG,OAAO,OAAO,YAAY,UACtB,OAAO,YAAY,QAAQ,YAAY,CAAC,EAAE,aAAa,KACvD,OAAO,UAAU,QAAQ,QAAQ,YAAY,CAAC,CAAC,OAAO;AAC5D;;AAGA,SAAgB,cAAc,QAA6B,OAAgB;CACzE,MAAM,WAAA,GAAUA,MAAAA,qBAAAA,EAAAA,GACdC,MAAAA,YAAAA,EAAa,QAAoB,OAAO,YAAY,WA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Aa,eAAe,qBAAqB;EACvD,MAAM,cAAc;EACpB,SAAS,KAAK,YAAY,KAAK;EAC/B,aAAa,MAAM,OAAO;CAC5B,GAAG,mBAAmB;CACtB,IAAI,aAAa,OAAO,MAAM,OAAO,0BAA0B,OAAO,MAAM,SAAS;EACnF,MAAM;EAAoB,IAAI;EAAU,OAAO;EAAI,OAAO;CAC5D,IAAI,UAAmB,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD;EAAwB;EAAQ,MAAM;EAAY;CAAQ,CAAA,CAAC,CAAC,GAAG,qBAAqB;AAC7G"}
|
package/lib/client.js
CHANGED
|
@@ -347,8 +347,14 @@ function candidateAvailabilityLabel(count, locale) {
|
|
|
347
347
|
return locale === "en" ? "No candidates" : "暂无候选";
|
|
348
348
|
}
|
|
349
349
|
function kindLabel(kind, locale) {
|
|
350
|
-
|
|
351
|
-
|
|
350
|
+
return {
|
|
351
|
+
preference: ["偏好", "Preference"],
|
|
352
|
+
"project-fact": ["项目事实", "Project fact"],
|
|
353
|
+
decision: ["决策", "Decision"],
|
|
354
|
+
vocabulary: ["用语释义", "Vocabulary"],
|
|
355
|
+
activity: ["近期状态", "Recent activity"],
|
|
356
|
+
lesson: ["行动经验", "Method"]
|
|
357
|
+
}[kind][locale === "en" ? 1 : 0];
|
|
352
358
|
}
|
|
353
359
|
function statusLabel(status, locale) {
|
|
354
360
|
return locale === "en" ? {
|
|
@@ -568,58 +574,33 @@ function MemorySettingsPanel({ client, sessionId, locale }) {
|
|
|
568
574
|
}),
|
|
569
575
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
570
576
|
className: "dsh-memory-card",
|
|
571
|
-
children: [
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
"aria-hidden": "true"
|
|
594
|
-
})
|
|
595
|
-
})] }),
|
|
596
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [t(locale, "空闲间隔(分钟)", "Idle interval (minutes)"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
597
|
-
type: "number",
|
|
598
|
-
min: 1,
|
|
599
|
-
max: 180,
|
|
600
|
-
step: 1,
|
|
601
|
-
disabled: busy,
|
|
602
|
-
value: Math.round(draft.idleMs / 6e4),
|
|
603
|
-
onChange: (event) => {
|
|
604
|
-
settingsDirty.current = true;
|
|
605
|
-
setDraft({
|
|
606
|
-
...draft,
|
|
607
|
-
idleMs: Math.round(Number(event.target.value) * 6e4)
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
})] }),
|
|
611
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
612
|
-
type: "button",
|
|
613
|
-
disabled: busy,
|
|
614
|
-
onClick: () => void action(async () => {
|
|
615
|
-
await rpc("settings.update", {
|
|
616
|
-
expectedRevision: draft.revision,
|
|
617
|
-
settings: editable(draft)
|
|
618
|
-
});
|
|
619
|
-
}),
|
|
620
|
-
children: t(locale, "保存", "Save")
|
|
577
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t(locale, "Dream 语境记忆", "Dream context memory") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
578
|
+
className: "dsh-memory-meta",
|
|
579
|
+
children: t(locale, "从原始用户消息记录用语与近期状态,闲时整理已有语境。行动方法由自我改进负责。", "Records vocabulary and recent activity from original user messages, then consolidates context while idle. Self Improve owns methods.")
|
|
580
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
581
|
+
type: "button",
|
|
582
|
+
role: "switch",
|
|
583
|
+
className: `dsh-memory-switch${draft.dreamIdleEnabled ? " is-on" : ""}`,
|
|
584
|
+
"aria-checked": draft.dreamIdleEnabled,
|
|
585
|
+
"aria-label": draft.dreamIdleEnabled ? t(locale, "关闭 Dream 观察与整理", "Disable Dream observation and consolidation") : t(locale, "启用 Dream 观察与整理", "Enable Dream observation and consolidation"),
|
|
586
|
+
disabled: busy,
|
|
587
|
+
onClick: () => void action(async () => {
|
|
588
|
+
await rpc("settings.update", {
|
|
589
|
+
expectedRevision: draft.revision,
|
|
590
|
+
settings: {
|
|
591
|
+
...editable(draft),
|
|
592
|
+
dreamIdleEnabled: !draft.dreamIdleEnabled
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}),
|
|
596
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
597
|
+
className: "dsh-memory-switch-thumb",
|
|
598
|
+
"aria-hidden": "true"
|
|
621
599
|
})
|
|
622
|
-
]
|
|
600
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
601
|
+
className: "dsh-memory-meta",
|
|
602
|
+
children: t(locale, "闲时整理在会话空闲约 15 分钟后尝试。", "Idle organization waits about 15 minutes of inactivity.")
|
|
603
|
+
})]
|
|
623
604
|
})
|
|
624
605
|
]
|
|
625
606
|
});
|
|
@@ -883,6 +864,14 @@ function MemoryChatPanel({ client, sessionId, locale }) {
|
|
|
883
864
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
884
865
|
value: "decision",
|
|
885
866
|
children: kindLabel("decision", locale)
|
|
867
|
+
}),
|
|
868
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
869
|
+
value: "vocabulary",
|
|
870
|
+
children: kindLabel("vocabulary", locale)
|
|
871
|
+
}),
|
|
872
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
873
|
+
value: "activity",
|
|
874
|
+
children: kindLabel("activity", locale)
|
|
886
875
|
})
|
|
887
876
|
]
|
|
888
877
|
})] }),
|
|
@@ -981,6 +970,26 @@ function MemoryRow(props) {
|
|
|
981
970
|
scope
|
|
982
971
|
]
|
|
983
972
|
}),
|
|
973
|
+
record.context && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
974
|
+
className: "dsh-memory-meta",
|
|
975
|
+
children: [
|
|
976
|
+
record.context.subject,
|
|
977
|
+
" · ",
|
|
978
|
+
record.context.domain,
|
|
979
|
+
" · ",
|
|
980
|
+
record.context.key,
|
|
981
|
+
" · ",
|
|
982
|
+
t(locale, "记录于", "Observed"),
|
|
983
|
+
" ",
|
|
984
|
+
new Date(record.context.observedAt).toLocaleString(locale === "en" ? "en-US" : "zh-CN"),
|
|
985
|
+
record.context.activityStatus && ` · ${record.context.activityStatus}`,
|
|
986
|
+
record.context.eventTime && ` · ${record.context.eventTime}`
|
|
987
|
+
]
|
|
988
|
+
}),
|
|
989
|
+
record.kind === "activity" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
990
|
+
className: "dsh-memory-meta",
|
|
991
|
+
children: t(locale, "仅表示上次报告的状态;到期不代表任务已完成。", "Last reported state only; expiry never means completion.")
|
|
992
|
+
}),
|
|
984
993
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: record.content }),
|
|
985
994
|
record.evidence.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
986
995
|
className: "dsh-memory-meta",
|
|
@@ -1071,7 +1080,7 @@ function DreamPanel(props) {
|
|
|
1071
1080
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", { children: t(locale, "梦境整理", "Dream") }),
|
|
1072
1081
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1073
1082
|
className: "dsh-memory-meta",
|
|
1074
|
-
children: t(locale, "
|
|
1083
|
+
children: t(locale, "每天至多闲时整理一次;不把候选升级为事实,不延长近期状态的有效期。", "Consolidates at most once a day while idle, without confirming candidates or extending activity freshness.")
|
|
1075
1084
|
}),
|
|
1076
1085
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1077
1086
|
className: "dsh-memory-row-actions",
|
|
@@ -1106,23 +1115,53 @@ function DreamPanel(props) {
|
|
|
1106
1115
|
]
|
|
1107
1116
|
});
|
|
1108
1117
|
}
|
|
1109
|
-
function
|
|
1118
|
+
function readSelfImprovementReview(host) {
|
|
1119
|
+
if (!host || typeof host !== "object") return void 0;
|
|
1120
|
+
const context = host;
|
|
1121
|
+
if (typeof context.get !== "function") return void 0;
|
|
1122
|
+
let row;
|
|
1123
|
+
try {
|
|
1124
|
+
row = context.get("dshSelfImprovementReview");
|
|
1125
|
+
} catch {
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
if (!row || typeof row !== "object") return void 0;
|
|
1129
|
+
const render = row.render;
|
|
1130
|
+
if (typeof render !== "function") return void 0;
|
|
1131
|
+
return { render };
|
|
1132
|
+
}
|
|
1133
|
+
function MemorySettings({ client, host, props }) {
|
|
1110
1134
|
const seat = useNativeSeat(client, props);
|
|
1135
|
+
const review = readSelfImprovementReview(host);
|
|
1111
1136
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1112
1137
|
className: "dsh-memory-settings-root",
|
|
1113
1138
|
"data-testid": "memory-settings-root",
|
|
1114
|
-
children: [
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
sessionId
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1139
|
+
children: [
|
|
1140
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemorySettingsPanel, {
|
|
1141
|
+
client,
|
|
1142
|
+
sessionId: seat.sessionId,
|
|
1143
|
+
locale: seat.locale
|
|
1144
|
+
}, `settings:${memoryPanelKey(seat.sessionId, seat.locale)}`),
|
|
1145
|
+
review && seat.sessionId && !seat.hidden ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
1146
|
+
className: "dsh-memory-si",
|
|
1147
|
+
"data-testid": "self-improvement-entry",
|
|
1148
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: t(seat.locale, "自我改进", "Self-improvement") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1149
|
+
className: "dsh-memory-si-body",
|
|
1150
|
+
children: review.render({
|
|
1151
|
+
sessionId: seat.sessionId,
|
|
1152
|
+
locale: seat.locale
|
|
1153
|
+
})
|
|
1154
|
+
})]
|
|
1155
|
+
}) : null,
|
|
1156
|
+
seat.sessionId && !seat.hidden ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoryChatPanel, {
|
|
1157
|
+
client,
|
|
1158
|
+
sessionId: seat.sessionId,
|
|
1159
|
+
locale: seat.locale
|
|
1160
|
+
}, `manage:${memoryPanelKey(seat.sessionId, seat.locale)}`) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1161
|
+
className: "dsh-memory-meta",
|
|
1162
|
+
children: t(seat.locale, "选择一个会话后可以管理该会话的记忆。", "Select a session to manage its memory.")
|
|
1163
|
+
})
|
|
1164
|
+
]
|
|
1126
1165
|
});
|
|
1127
1166
|
}
|
|
1128
1167
|
const styles = `
|
|
@@ -1132,7 +1171,7 @@ const styles = `
|
|
|
1132
1171
|
.dsh-memory-settings p,.dsh-memory-chat p{margin:0;line-height:1.5}
|
|
1133
1172
|
.dsh-memory-meta,.dsh-memory-chat small{font-size:var(--font-size-1,13px);color:var(--gray-11,inherit)}
|
|
1134
1173
|
.dsh-memory-error{color:var(--red-11,#b42318)}
|
|
1135
|
-
.dsh-memory-card,.dsh-memory-dream,.dsh-memory-add{display:grid;gap:10px;padding:14px 16px;border:1px solid var(--gray-6,color-mix(in srgb,currentColor 15%,transparent));border-radius:12px}
|
|
1174
|
+
.dsh-memory-card,.dsh-memory-dream,.dsh-memory-add,.dsh-memory-si{display:grid;gap:10px;padding:14px 16px;border:1px solid var(--gray-6,color-mix(in srgb,currentColor 15%,transparent));border-radius:12px}
|
|
1136
1175
|
.dsh-memory-card header,.dsh-memory-chat-body header{display:flex;justify-content:space-between;gap:12px;align-items:center}
|
|
1137
1176
|
.dsh-memory-card h3,.dsh-memory-add h4,.dsh-memory-dream h4{margin:0;font-size:var(--font-size-3,16px);font-weight:600}
|
|
1138
1177
|
.dsh-memory-settings input,.dsh-memory-chat input,.dsh-memory-chat textarea,.dsh-memory-chat select{box-sizing:border-box;width:100%;min-width:0;padding:8px 10px;border:1px solid var(--gray-6,color-mix(in srgb,currentColor 22%,transparent));border-radius:8px;background:var(--color-surface,transparent);color:inherit;font:inherit;transition:border-color 150ms ease,box-shadow 150ms ease}
|
|
@@ -1152,7 +1191,8 @@ const styles = `
|
|
|
1152
1191
|
.dsh-memory-row-actions{display:flex;flex-wrap:wrap;gap:8px}
|
|
1153
1192
|
.dsh-memory-check{display:flex;gap:8px;align-items:center}
|
|
1154
1193
|
.dsh-memory-check input{width:auto}
|
|
1155
|
-
.dsh-memory-chat>summary{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:baseline;cursor:pointer;min-height:34px;list-style:revert}
|
|
1194
|
+
.dsh-memory-chat>summary,.dsh-memory-si>summary{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:baseline;cursor:pointer;min-height:34px;list-style:revert}
|
|
1195
|
+
.dsh-memory-si-body{margin-top:8px}
|
|
1156
1196
|
@media(prefers-reduced-motion:reduce){.dsh-memory-switch-thumb{transition:none}.dsh-memory-settings button:not([role="switch"]),.dsh-memory-chat button:not([role="switch"]),.dsh-memory-settings input,.dsh-memory-chat input,.dsh-memory-chat textarea,.dsh-memory-chat select{transition:none}}
|
|
1157
1197
|
`;
|
|
1158
1198
|
function apply(ctx) {
|
|
@@ -1172,6 +1212,7 @@ function apply(ctx) {
|
|
|
1172
1212
|
label: "记忆"
|
|
1173
1213
|
}, (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemorySettings, {
|
|
1174
1214
|
client,
|
|
1215
|
+
host: ctx,
|
|
1175
1216
|
props
|
|
1176
1217
|
}))), "dsh-memory.settings");
|
|
1177
1218
|
}
|