diff --git a/.github/workflows/memos-local-plugin-install-contract.yml b/.github/workflows/memos-local-plugin-install-contract.yml new file mode 100644 index 000000000..a198c336c --- /dev/null +++ b/.github/workflows/memos-local-plugin-install-contract.yml @@ -0,0 +1,55 @@ +name: Local plugin installation contract + +on: + pull_request: + paths: + - 'apps/memos-local-plugin/**' + - '.github/workflows/memos-local-plugin-install-contract.yml' + workflow_dispatch: + +permissions: + contents: read + +jobs: + clean-install: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + node: ['22', '24'] + manager: [npm, pnpm] + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + working-directory: apps/memos-local-plugin + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + - name: Pin installation tools + run: | + npm install --global npm@11.17.0 pnpm@11.7.0 --ignore-scripts --no-audit --no-fund + test "$(npm --version)" = 11.17.0 + test "$(pnpm --version)" = 11.7.0 + - name: Verify reviewed lock metadata + run: | + npm run lock:check + npm run verify:script-policy + - name: Clean npm installation + if: matrix.manager == 'npm' + run: npm ci --no-audit --no-fund + - name: Frozen pnpm installation + if: matrix.manager == 'pnpm' + run: pnpm install --frozen-lockfile + - name: SQLite and CPU ONNX runtime smoke + run: node scripts/verify-native-runtime.cjs + - name: Type check and build package + run: | + npm run lint + npm run build:package + - name: Check runtime and lock contracts + run: | + npm exec -- vitest run tests/unit/install/sqlite-install-contract.test.ts + git diff --exit-code -- package.json package-lock.json pnpm-lock.yaml diff --git a/.github/workflows/memos-local-plugin-publish.yml b/.github/workflows/memos-local-plugin-publish.yml index 60478c396..bd65c52eb 100644 --- a/.github/workflows/memos-local-plugin-publish.yml +++ b/.github/workflows/memos-local-plugin-publish.yml @@ -388,19 +388,17 @@ jobs: - name: Install dependencies shell: bash - run: bash ../../.github/scripts/retry.sh --label "npm ci" -- npm ci - - - name: Rebuild for x64 under Rosetta (darwin-x64 only) - if: matrix.platform == 'darwin-x64' - shell: bash - run: bash ../../.github/scripts/retry.sh --label "npm rebuild better-sqlite3 under Rosetta" -- arch -x86_64 npm rebuild better-sqlite3 + run: | + npm install --global npm@11.17.0 --ignore-scripts --no-audit --no-fund + npm run lock:check + bash ../../.github/scripts/retry.sh --label "npm ci" -- npm ci - name: Collect prebuild shell: bash run: | bash ../../.github/scripts/retry.sh --label "collect ${{ matrix.platform }} prebuild" -- bash -euo pipefail -c ' mkdir -p prebuilds/${{ matrix.platform }} - cp node_modules/better-sqlite3/build/Release/better_sqlite3.node prebuilds/${{ matrix.platform }}/ + cp node_modules/better-sqlite3/prebuilds/${{ matrix.platform }}.node prebuilds/${{ matrix.platform }}/better_sqlite3.node ' - name: Upload prebuild artifact @@ -492,16 +490,12 @@ jobs: find . -name "*.node" -exec ls -lh {} \; ' - - name: Install dependencies (skip native build) - run: bash ../../.github/scripts/retry.sh --label "npm ci --ignore-scripts" -- npm ci --ignore-scripts - - - name: Install Linux sqlite binding for validation + - name: Install dependencies with reviewed scripts run: | - bash ../../.github/scripts/retry.sh --label "install linux sqlite binding for validation" -- bash -euo pipefail -c ' - test -s prebuilds/linux-x64/better_sqlite3.node - mkdir -p node_modules/better-sqlite3/build/Release - cp prebuilds/linux-x64/better_sqlite3.node node_modules/better-sqlite3/build/Release/better_sqlite3.node - ' + npm install --global npm@11.17.0 --ignore-scripts --no-audit --no-fund + npm run lock:check + bash ../../.github/scripts/retry.sh --label "npm ci" -- npm ci + npm run verify:native - name: Generate telemetry credentials for a real publish if: ${{ inputs.dry_run != true && (inputs.publish_phase || 'full') != 'stage_release' }} diff --git a/apps/memos-local-plugin/.npmrc b/apps/memos-local-plugin/.npmrc new file mode 100644 index 000000000..3cefa3035 --- /dev/null +++ b/apps/memos-local-plugin/.npmrc @@ -0,0 +1,2 @@ +engine-strict=true +strict-allow-scripts=true diff --git a/apps/memos-local-plugin/README.md b/apps/memos-local-plugin/README.md index 9b2939490..2a35d5a74 100644 --- a/apps/memos-local-plugin/README.md +++ b/apps/memos-local-plugin/README.md @@ -1,5 +1,69 @@ # @memtensor/memos-local-plugin +> **Runtime compatibility change:** this development version requires Node.js +> **22 or newer in the actual host process**, including Electron's embedded Node. +> It pins `better-sqlite3` to `13.0.3`, using packaged Node-API prebuilds instead +> of per-Node/Electron ABI rebuilds. Node 20 users must keep their previously +> installed compatible release until upgrading the host; this version rejects +> Node 20 before opening storage. This is a breaking runtime requirement and +> must be called out in the release version/notes; no database schema migration +> is introduced by this dependency change. + +### Reproducible dependency maintenance + +Use npm **11.17.0** and pnpm **11.7.0** with a supported Node runtime. These are +our installation-policy validation versions; installing a different package +manager version must not silently regenerate the release locks. + +From `apps/memos-local-plugin`, after a reviewed dependency edit: + +```sh +npm install --package-lock-only --ignore-scripts +npm run lock:normalize +pnpm import +npm run lock:check +``` + +`--ignore-scripts` is only for lock generation, not the release installation. +`lock:normalize` repairs npm's SQLite install-metadata inference only for the +reviewed 13.0.3 tarball URL and integrity. It refuses unknown artifacts and is +never invoked during end-user installation. Commit both lockfiles together. +`pnpm import` can change peer layouts; inspect every version change rather than +assuming a one-to-one conversion. The release validation command checks the +SQLite lock metadata, and the installation contract tests compare both locks. + +Validate `npm ci` and `pnpm install --frozen-lockfile` in separate clean checkouts +with independent `node_modules`. Both must load SQLite, create a table, write, +query and close under the actual Node/Electron runtime. Repeat lock generation +and normalization to check that it leaves the committed locks unchanged. +Runtime tarballs installed by DSH use the profile owner's dependency graph; +the source checkout locks alone do not establish the packed-install result. + +### Dependency install-script policy + +npm policy lives in this package's `allowScripts`; `.npmrc` enables engine and +script strictness for source/CI installs. pnpm 11 uses the separate +`pnpm-workspace.yaml#allowBuilds` policy. Reviewed esbuild and Sharp versions +may run scripts; SQLite 13.0.3, protobufjs, optional fsevents, and the ONNX CUDA +downloader are denied. CPU ONNX and SQLite prebuilds must pass runtime smoke +checks even when these scripts are denied. New versions require review. + +These policies belong to the installing root, not arbitrary transitive +packages. For DSH, prepare the equivalent policy in the selected profile before +the first add. Do not overwrite another plugin's settings or an explicit script +denial. The installer rejects unknown pending builds instead of approving them. +Direct host-managed installs must configure the host's policy as well. +Do not bypass this with `--dangerously-allow-all-scripts`, blanket approval or +`--ignore-scripts`. Older npm versions have different policy behavior and are +not the release installation validation path. + +A failed prebuilt probe is an installation failure, not permission to invoke +node-gyp automatically. Preserve the old deployment and diagnose the actual +host/runtime and binary resolution. Standard installs do not require MSVC, +Python or Electron headers. Windows Desktop must be revalidated with the final +package; isolated dependency-smoke results do not replace integration tests. + + > Reflect2Evolve memory plugin for AI agents. > One algorithm core, with adapters for OpenClaw, Hermes Agent, and DeepSeek > Harness. @@ -261,6 +325,113 @@ The runtime/config location is resolved in the following priority order: 4. **`DSH_HOME`** (DSH only) — defaults the DSH memory root to `$DSH_HOME/memos-plugin/` 5. **Default path** — `~/.hermes/memos-plugin/`, `~/.openclaw/memos-plugin/`, or `~/.dsh/memos-plugin/` based on the agent +### Local embedding model sources + +For `embedding.provider: local`, the Viewer Settings page exposes the same +options as `config.yaml`: + +```yaml +embedding: + provider: local + model: Xenova/all-MiniLM-L6-v2 + local: + remoteHost: "" # Optional HTTP(S) mirror base URL + modelPath: "" # Optional local model root containing / files + cacheDir: "" # Empty: ~/.cache/memos/models, outside installed packages + offline: false # true: load local/cache files only, without downloads + loadTimeoutMs: 120000 +``` + +`local.remoteHost` takes precedence over `HF_ENDPOINT`; leaving both empty uses +Hugging Face. Use absolute directory paths (a leading `~/` is also supported). +For offline use, place the model's config, tokenizer and quantized ONNX files +under `//`, or point `cacheDir` to an existing Transformers.js +cache. Changing the model/source settings causes a fresh pipeline load. + +The Settings **Test** button uses the form's unsaved local settings and shows a +loading notice. Logs report `loading`, per-file `download.progress`, `ready`, +and `load_failed`. The load timeout bounds the caller's wait; Transformers +loading can continue in the background and warm the next request. + +### Windows native-library isolation + +On Windows, local embedding inference runs in a separate Node process so the +plugin's Transformers/Sharp/libvips libraries cannot occupy DLL names in the +host process. The model process is shared, starts lazily, and stops when its +last provider closes or after five minutes without requests. Cancelling one +request does not cancel other callers. A crashed child is restarted on the +next request; failures are reported as `embedding_unavailable`, without +falling back to loading these libraries inside the host. macOS/Linux keep +the existing in-process embedding path. + +Electron hosts must support `ELECTRON_RUN_AS_NODE`/`child_process.fork`. +The child reuses the host executable, clears inherited `NODE_OPTIONS` and +`NODE_PATH` preloads, and sends only model settings/text/vectors and model +logs over IPC. No DLL replacement or host Sharp version pin is required. + +To verify the native collision fix on Windows, build this branch and run +`scripts/verify-windows-dll-isolation.mjs` against the **host's** Sharp package. +For a DSH installation whose JavaScript is inside `app.asar`, use its Electron +executable so ASAR paths remain readable (replace the example install paths): + +```powershell +npm ci +npm run build:package +$DshExe = "C:\path\to\DeepSeek Harness.exe" +$HostSharp = "C:\path\to\resources\app.asar\dsh\node_modules\sharp" +$ModelCache = "$env:USERPROFILE\.cache\memos\models" +$PreviousRunAsNode = $env:ELECTRON_RUN_AS_NODE +$env:ELECTRON_RUN_AS_NODE = "1" +try { + & $DshExe .\scripts\verify-windows-dll-isolation.mjs --host-sharp $HostSharp --cache-dir $ModelCache --offline +} finally { + $env:ELECTRON_RUN_AS_NODE = $PreviousRunAsNode +} +``` + +Use an existing Transformers model cache with `--offline`; omit that flag to +allow downloading (including through `HF_ENDPOINT`). Each of the two load +orders runs in a fresh process: plugin model before host Sharp, and host +Sharp before plugin model. Both must return a 384-dimensional vector and +successfully encode a PNG with host Sharp; model inference must add no +Sharp/libvips/ONNX libraries to the parent process. The script reports the +separate host/worker PIDs and host library versions. + +Then restart DSH completely, enable this plugin build and the local model, +and verify both a new conversation and a long conversation that previously +failed, including any image processing path. Windows DLL behavior requires +this native check; passing the cross-platform IPC tests alone does not prove +that the original Windows failure is resolved. + +### Bundle import preview and ownership + +Choosing a JSON bundle in the Viewer previews it without writing records. +Choose either preserving original ownership (default) or importing into the +active agent's current/named profile. Sharing scopes are preserved. Preview +shows how many candidate rows would be visible to the active profile. +Existing IDs are skipped, including on a target-profile import; this does not +change ownership of records already stored. + +`POST /api/v1/import` accepts the same JSON or multipart body as before, with +optional query parameters `dryRun=true`, `ownership=preserve|target` and +`targetProfileId` (only with `ownership=target`). The response retains +`imported` and `skipped`, adding `duplicates`, `invalid`, `failed`, `visible`, +`hidden`, `dryRun` and up to 50 row diagnostics (`kind`, zero-based `index`, +`field`, `code`, `message`). Timestamps and integer IDs such as `turnId` must +be safe integers; invalid values are rejected rather than rounded. + +Preview counts are estimates: database write failures can only be reported +on the real import. A rejected trace rolls back its synthetic session and +episode. Use **Repair embeddings** after import to enable semantic retrieval +for imported rows; JSON bundles do not contain embedding vectors. +API callers should use `POST /api/v1/embeddings/rebuild` with +`{"mode":"repair","limit":100}` and repeat batches until `done` is true; +`Repair embeddings` is the Viewer button label, not an `/embeddings/repair` route. + +DSH memory ownership follows the configured `profileId`, independently of +agent presets. See [legacy preset ownership repair](adapters/deepseek-harness/README.md#legacy-preset-ownership) +for explicitly migrating older `standard`/other preset partitions after backup. + ### Docker Deployment When running the daemon in a Docker container, you must explicitly specify the config location if it differs from the default path. There are three ways to do this: diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/README.md b/apps/memos-local-plugin/adapters/deepseek-harness/README.md index 5c18bc682..e8241ee5a 100644 --- a/apps/memos-local-plugin/adapters/deepseek-harness/README.md +++ b/apps/memos-local-plugin/adapters/deepseek-harness/README.md @@ -117,7 +117,7 @@ Prerequisites: - A Node.js version accepted by the DSH release. DSH `0.1.0-rc.5` requires Node.js `^22.19.0 || >=24.0.0`; this stricter host requirement takes - precedence over the MemOS package's standalone `>=20` engine. + precedence over the MemOS package's standalone `>=22` engine. - A working DSH installation. The recommended one-command installer prepares an isolated `pnpm@11.7.0` for the install when pnpm is absent. Lower-level direct `dsh plugin` commands still require pnpm on `PATH`. @@ -206,34 +206,35 @@ approve only the dependencies you trust. `dsh plugin` forwards this command to dsh plugin --profile web approve-builds ``` -For the tested `2.0.16-beta.1` package, pnpm reported `better-sqlite3`, -`esbuild`, `onnxruntime-node`, `protobufjs`, `sharp`, and the MemOS package's -own postinstall hint. Review found that the -required set was `better-sqlite3`, `esbuild`, `onnxruntime-node`, and `sharp`; -`protobufjs` and the package's own postinstall hint were not needed. The -equivalent reviewed profile policy was: +This candidate requires Node **22+** in the host, pins SQLite to **13.0.3**, +and uses its packaged Node-API prebuild. Do not carry over the previous +`better-sqlite3: true` rebuild policy. For the current locked dependencies the +reviewed profile policy is: ```yaml -# $DSH_HOME/profiles/web/pnpm-workspace.yaml +# $DSH_HOME/profiles//pnpm-workspace.yaml +strictDepBuilds: true allowBuilds: '@memtensor/memos-local-plugin': false - better-sqlite3: true - esbuild: true - onnxruntime-node: true + better-sqlite3: false + esbuild@0.27.7: true + esbuild@0.21.5: true + sharp@0.34.5: true + onnxruntime-node: false protobufjs: false - sharp: true ``` -Dependency sets can change by package version and platform, so use pnpm's -current output as the source of truth; do not use `approve-builds --all` or -copy this allowlist blindly. Install scripts execute with the current user's -permissions, outside the agent tool sandbox. After approval, rerun the same -`dsh plugin --profile web add ...` command so DSH can finish installation and -reconcile the bundle layer. +Prepare policy before the first installation. The ONNX CPU backend is bundled; +the optional CUDA download is not needed for local CPU embeddings. A clean +profile must still pass the CPU runtime smoke check. Preserve unrelated policy +entries and stop for review when an existing denial conflicts with a required +script or a new version requires approval. Do not approve all scripts. -The one-command installer automates this exact reviewed policy only when the -pending set contains no other package. Direct `dsh plugin add` users retain the -manual review flow above. +The one-command installer merges this reviewed policy before calling DSH. +Unknown pending scripts stop installation. A SQLite smoke failure is reported +without attempting source compilation. Profile package-manager policy is +separate from npm's source-checkout `allowScripts`; see the package README for +both lockfile maintenance and the fixed npm/pnpm validation versions. This branch pins Transformers.js to `4.2.0`; the tested lock and DSH profile resolve Transformers.js 4.2.0 with `onnxruntime-node` 1.24.3. The earlier @@ -320,7 +321,7 @@ deep-merging keys, so keep every field when overriding one. | Field | Default | Meaning | | --- | --- | --- | | `enabled` | `true` | Mount or disable the adapter. | -| `profileId` | `default` | Fallback namespace; a non-empty session `agentPreset` overrides it consistently for recall, capture, and tools. | +| `profileId` | `default` | Stable memory namespace for recall, capture, tools and Viewer; independent of session `agentPreset`. | | `home` | `''` | Empty means `$DSH_HOME/memos-plugin` (default `~/.dsh/memos-plugin`); otherwise an absolute or `~`-relative runtime root. | | `recallEnabled` | `true` | Run one automatic recall for every accepted, non-empty direct-user turn. Re-entry within the same logical turn is de-duplicated; there is no greeting or restored-session exception. | | `captureEnabled` | `true` | Capture completed DSH turns and tool outcomes. | @@ -487,14 +488,46 @@ rephrased, or explicitly scoped follow-up lookup. Automatic recall and `memos_search` use the same absolute deadline (`min(recallTimeoutMs, 3000)` ms) and DSH-specific no-malformed-retry filter policy. When tools are disabled, the system-prompt guidance omits the tool suggestion. Automatic -recall, capture, and all explicit tools use the same `agentPreset`-aware -namespace resolver. +recall, capture, and all explicit tools use the configured `profileId` through +the same namespace resolver. Changing `agentPreset` changes agent behavior, +not memory ownership, so Web UI and headless sessions can recall each other's +memories when configured with the same memory profile. + +The default runtime home is shared across DSH profiles and the default memory +`profileId` is `default`. Profiles using the same home and memory profile ID +intentionally share memories. Set a unique `profileId` per profile (or a +separate `home`) when that sharing is not desired. + +### Legacy preset ownership + +Earlier versions treated the session's `agentPreset` (e.g. `standard`) as the +memory profile. Those records remain in their original namespace after this +fix; they are not automatically shared or moved. If that namespace was meant +to be separate, keep it separate by configuring its explicit `profileId`. + +To reunite accidental preset partitions, stop DSH and **all** other writers to +the same database, then run the packaged repair tool from the plugin directory: + +```sh +# Read-only counts for exactly one source profile; no changes or backup yet. +node scripts/migrate-dsh-preset-profile.mjs --db /path/to/memos.db --from standard --to default +# Apply only after checking the source/target. The backup path must not exist. +node scripts/migrate-dsh-preset-profile.mjs --db /path/to/memos.db --from standard --to default --apply --backup /path/to/memos-before-preset-repair.db +``` + +Use the actual configured memory profile as `--to`; do not blindly merge every +profile into `default`. The tool changes only DSH-owned records from the named +source profile. It uses SQLite backup (including committed WAL data), then one +transaction across ownership tables, preserving IDs, vectors, sharing scopes +and references. Routing metadata in sessions/episodes is updated too. Any +constraint conflict, such as an existing skill name, rolls back all changes +and leaves the backup intact. Historical audit payload text is not rewritten. -The default runtime home is shared across DSH profiles and the fallback -`profileId` is `default`. If multiple profiles point at that same home and a -session has no distinct `agentPreset`, they intentionally share a namespace. -Set a unique `profileId` per profile (or a separate `home`) when that sharing is -not desired. +Use a runtime compatible with the installed `better-sqlite3` binary. For a +DSH install compiled for Electron, run the script with DSH's executable and +`ELECTRON_RUN_AS_NODE=1`, as shown in the package README's Windows validation +example. Restart DSH after a successful repair. To revert, stop all writers +and restore the backup as the database; do not mix it with newer WAL/SHM files. ## Failure behavior @@ -567,6 +600,25 @@ errors and are not fail-open. as untrusted and potentially stale, especially when it contains copied tool output or repository text. +## V4 message-source regression tests + +From `apps/memos-local-plugin`, run: + +```sh +npm ci +npx vitest run tests/unit/adapters/deepseek-harness-{bridge,host-llm,runtime}.test.ts +``` + +These tests use the published `@deepseek-ai/dsh-session-format-v3-to-v4` +`0.2.0-rc.2` codec, without a DSH desktop installation, account, or network +calls during testing. They check real recall and host-LLM messages through +both `assertV4RowAdmission` and `encodeEvent`, including a pre-step inbox +batch and rejection of retired `kind: "plugin"` sources. The codec is a dev +dependency only. Its Cordis peer is satisfied by the development range; +existing DSH brand/protocol peers remain pinned to the older adapter test +stack. This validates V4 attribution, not general compatibility with every +DSH API in the codec's release line. + ## Known limitations 1. **Developer-preview compatibility.** The initial compatibility target is diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/bridge.ts b/apps/memos-local-plugin/adapters/deepseek-harness/bridge.ts index a2ea43b38..270d18145 100644 --- a/apps/memos-local-plugin/adapters/deepseek-harness/bridge.ts +++ b/apps/memos-local-plugin/adapters/deepseek-harness/bridge.ts @@ -15,6 +15,7 @@ import type { } from "../../agent-contract/dto.js"; import type { MemoryCore } from "../../agent-contract/memory-core.js"; import type { DeepSeekHarnessLlmRoute } from "./host-llm.js"; +import { deepSeekHarnessNamespace } from "./namespace.js"; import { waitForDeepSeekHarnessDeadline } from "./deadline.js"; export const DEEPSEEK_HARNESS_AGENT = "deepseek-harness"; @@ -386,17 +387,7 @@ export class DeepSeekHarnessBridge { } namespaceFor(session: DshSessionLike): RuntimeNamespace { - const preset = session.header?.["agentPreset"]; - const profileId = typeof preset === "string" && preset.trim() - ? preset.trim() - : this.profileId; - return { - agentKind: DEEPSEEK_HARNESS_AGENT, - profileId, - profileLabel: profileId, - workspacePath: session.header?.cwd, - sessionKey: session.id, - }; + return deepSeekHarnessNamespace(session, this.profileId); } async flush(sessionId?: string): Promise { diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/host-llm.ts b/apps/memos-local-plugin/adapters/deepseek-harness/host-llm.ts index a755efb98..3334f9021 100644 --- a/apps/memos-local-plugin/adapters/deepseek-harness/host-llm.ts +++ b/apps/memos-local-plugin/adapters/deepseek-harness/host-llm.ts @@ -16,6 +16,7 @@ import { } from "@deepseek-ai/dsh-llm"; import { deadline, timeoutOf } from "@deepseek-ai/dsh-timeout"; import { AsyncLocalStorage } from "node:async_hooks"; +import { memosMessageSource } from "./message-source.js"; import { ERROR_CODES, MemosError } from "../../agent-contract/errors.js"; import type { @@ -27,7 +28,6 @@ import type { LlmMessage, LlmUsage } from "../../core/llm/types.js"; const HOST_LLM_BRIDGE_ID = "deepseek-harness.host.v1"; const HOST_LLM_TIMEOUT_CODE = "MEMOS_DSH_HOST_LLM_TIMEOUT"; -const HOST_LLM_MESSAGE_SOURCE = "memos-local-memory"; const NO_REASONING_EFFORT = ReasoningEffortId("off"); const UNSUPPORTED_REASONING_EFFORT = "UNSUPPORTED_REASONING_EFFORT"; const MODEL_CAPABILITY_TTL_MS = 10 * 60 * 1_000; @@ -366,7 +366,7 @@ function toDshMessage( if (message.role === "user") { return createUserMessage({ content, - source: { kind: "plugin", plugin: HOST_LLM_MESSAGE_SOURCE }, + source: memosMessageSource(), }); } return createAssistantMessage({ diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/index.ts b/apps/memos-local-plugin/adapters/deepseek-harness/index.ts index bc63ba5d6..eec0cea5c 100644 --- a/apps/memos-local-plugin/adapters/deepseek-harness/index.ts +++ b/apps/memos-local-plugin/adapters/deepseek-harness/index.ts @@ -39,9 +39,17 @@ import { type DeepSeekHarnessHostLlmBridge, } from "./host-llm.js"; import { registerDeepSeekHarnessTools } from "./tools.js"; +import { memosMessageSource } from "./message-source.js"; export const name = DEEPSEEK_HARNESS_PLUGIN; export const inject = ["systemPrompt", "tools", "llm"]; + +export function createDeepSeekHarnessRecallMessage(text: string): ReturnType { + return createUserMessage({ + content: [{ type: "text", text }], + source: memosMessageSource("recall"), + }); +} export const DEEPSEEK_HARNESS_VIEWER_PORT = 18_801; export const DEEPSEEK_HARNESS_VIEWER_RETRY_DELAYS_MS = [ 250, @@ -384,14 +392,7 @@ export async function apply( recallTimeoutMs: foregroundSearchTimeoutMs, contextMaxChars: config.contextMaxChars, runWithLlmRoute: (route, operation) => routes.run(route, operation), - createRecallMessage: (text) => createUserMessage({ - content: [{ type: "text", text }], - source: { - kind: "plugin", - plugin: DEEPSEEK_HARNESS_PLUGIN, - form: "recall", - }, - }) as unknown as DshUserMessageLike, + createRecallMessage: (text) => createDeepSeekHarnessRecallMessage(text) as unknown as DshUserMessageLike, onWarn: (message, error) => { ctx.logger.warn(`memos-local-memory: ${message}`); if (error instanceof Error && error.stack) ctx.logger.warn(error.stack); diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/message-source.ts b/apps/memos-local-plugin/adapters/deepseek-harness/message-source.ts new file mode 100644 index 000000000..58f345fc5 --- /dev/null +++ b/apps/memos-local-plugin/adapters/deepseek-harness/message-source.ts @@ -0,0 +1,20 @@ +/** Producer attribution accepted by both extensible V3 and native V4 sessions. */ +export interface MemOSMessageSource { + kind: "plugin:memos-local-memory"; + plugin: "memos-local-memory"; + form?: "recall"; +} + +declare module "@deepseek-ai/dsh-llm" { + interface MessageSourceMap { + "plugin:memos-local-memory": MemOSMessageSource; + } +} + +export function memosMessageSource(form?: "recall"): MemOSMessageSource { + return { + kind: "plugin:memos-local-memory", + plugin: "memos-local-memory", + ...(form ? { form } : {}), + }; +} diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/namespace.ts b/apps/memos-local-plugin/adapters/deepseek-harness/namespace.ts new file mode 100644 index 000000000..ad1bd7cfe --- /dev/null +++ b/apps/memos-local-plugin/adapters/deepseek-harness/namespace.ts @@ -0,0 +1,16 @@ +import type { RuntimeNamespace } from "../../agent-contract/dto.js"; +import type { DshSessionLike } from "./bridge.js"; + +/** Agent presets choose behavior, not memory ownership or visibility. */ +export function deepSeekHarnessNamespace( + session: DshSessionLike | undefined, + profileId: string, +): RuntimeNamespace { + return { + agentKind: "deepseek-harness", + profileId, + profileLabel: profileId, + workspacePath: session?.header?.cwd, + sessionKey: session?.id, + }; +} diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/tools.ts b/apps/memos-local-plugin/adapters/deepseek-harness/tools.ts index 20f2fd518..f45fdefbd 100644 --- a/apps/memos-local-plugin/adapters/deepseek-harness/tools.ts +++ b/apps/memos-local-plugin/adapters/deepseek-harness/tools.ts @@ -19,6 +19,7 @@ import { type DshAgentLike, type DshSessionLike, } from "./bridge.js"; +import { deepSeekHarnessNamespace } from "./namespace.js"; import type { DeepSeekHarnessLlmRoute } from "./host-llm.js"; import { isDeepSeekHarnessTimeout, @@ -451,17 +452,7 @@ function namespaceFor( session: DshSessionLike | undefined, profileId: string, ): RuntimeNamespace { - const preset = session?.header?.["agentPreset"]; - const resolvedProfileId = typeof preset === "string" && preset.trim() - ? preset.trim() - : profileId; - return { - agentKind: DEEPSEEK_HARNESS_AGENT, - profileId: resolvedProfileId, - profileLabel: resolvedProfileId, - workspacePath: session?.header?.cwd, - sessionKey: session?.id, - }; + return deepSeekHarnessNamespace(session, profileId); } function requireText(value: unknown, field: string): string { diff --git a/apps/memos-local-plugin/adapters/hermes/install.hermes.sh b/apps/memos-local-plugin/adapters/hermes/install.hermes.sh index a010c68d0..b8d3c7cb4 100755 --- a/apps/memos-local-plugin/adapters/hermes/install.hermes.sh +++ b/apps/memos-local-plugin/adapters/hermes/install.hermes.sh @@ -48,7 +48,7 @@ if command -v npm >/dev/null 2>&1; then npm install --no-audit --no-fund --prefer-offline fi else - warn "npm not found on PATH; the bridge runtime requires Node.js ≥ 20." + warn "npm not found on PATH; the bridge runtime requires Node.js ≥ 22." fi # ── 2. viewer bundle ────────────────────────────────────────────────────────── diff --git a/apps/memos-local-plugin/agent-contract/import.ts b/apps/memos-local-plugin/agent-contract/import.ts new file mode 100644 index 000000000..20d1c271c --- /dev/null +++ b/apps/memos-local-plugin/agent-contract/import.ts @@ -0,0 +1,40 @@ +export interface MemoryImportBundle { + version?: number; + traces?: unknown[]; + policies?: unknown[]; + worldModels?: unknown[]; + skills?: unknown[]; +} + +export interface MemoryImportOptions { + /** Preserve source ownership unless the caller explicitly requests migration. */ + ownership?: "preserve" | "target"; + /** Target the active agent's named profile; omitted means its active profile. */ + targetProfileId?: string; + /** Validate and estimate visibility without writing any records. */ + dryRun?: boolean; +} + +export interface MemoryImportIssue { + kind: "trace" | "policy" | "worldModel" | "skill"; + /** Zero-based index in the corresponding bundle collection. */ + index: number; + field?: string; + code: string; + message: string; +} + +export interface MemoryImportResult { + imported: number; + /** Backwards-compatible total: duplicates + invalid + failed. */ + skipped: number; + duplicates: number; + invalid: number; + failed: number; + /** Successful (or preview candidate) rows visible to the active profile. */ + visible: number; + hidden: number; + dryRun: boolean; + /** At most 50 diagnostics; never includes row text or raw database errors. */ + issues: MemoryImportIssue[]; +} diff --git a/apps/memos-local-plugin/agent-contract/memory-core.ts b/apps/memos-local-plugin/agent-contract/memory-core.ts index be0e8563d..0bdd10d05 100644 --- a/apps/memos-local-plugin/agent-contract/memory-core.ts +++ b/apps/memos-local-plugin/agent-contract/memory-core.ts @@ -33,6 +33,7 @@ import type { } from "./dto.js"; import type { CoreEvent } from "./events.js"; import type { LogRecord } from "./log-record.js"; +import type { MemoryImportBundle, MemoryImportOptions, MemoryImportResult } from "./import.js"; // ─── Public lifecycle / status ──────────────────────────────────────────────── @@ -588,13 +589,7 @@ export interface MemoryCore { worldModels: WorldModelDTO[]; skills: SkillDTO[]; }>; - importBundle(bundle: { - version?: number; - traces?: unknown[]; - policies?: unknown[]; - worldModels?: unknown[]; - skills?: unknown[]; - }): Promise<{ imported: number; skipped: number }>; + importBundle(bundle: MemoryImportBundle, options?: MemoryImportOptions): Promise; // ── embedding maintenance ── embeddingMaintenanceStats(): Promise; diff --git a/apps/memos-local-plugin/core/config/defaults.ts b/apps/memos-local-plugin/core/config/defaults.ts index b09307c2a..093e06035 100644 --- a/apps/memos-local-plugin/core/config/defaults.ts +++ b/apps/memos-local-plugin/core/config/defaults.ts @@ -36,6 +36,7 @@ export const DEFAULT_CONFIG: ResolvedConfig = { provider: "local", endpoint: "", model: "Xenova/all-MiniLM-L6-v2", + local: { remoteHost: "", modelPath: "", cacheDir: "", offline: false, loadTimeoutMs: 120_000 }, apiKey: "", providerIgnore: [], providerOrder: [], diff --git a/apps/memos-local-plugin/core/config/schema.ts b/apps/memos-local-plugin/core/config/schema.ts index a5d394b49..49c6ad6e1 100644 --- a/apps/memos-local-plugin/core/config/schema.ts +++ b/apps/memos-local-plugin/core/config/schema.ts @@ -43,6 +43,13 @@ const EmbeddingSchema = Type.Object({ ], { default: "local" }), endpoint: StringWithDefault(""), model: StringWithDefault("Xenova/all-MiniLM-L6-v2"), + local: Type.Optional(Type.Object({ + remoteHost: StringWithDefault(""), + modelPath: StringWithDefault(""), + cacheDir: StringWithDefault(""), + offline: Bool(false), + loadTimeoutMs: NumberInRange(120_000, 1, 3_600_000), + }, { default: {} })), apiKey: StringWithDefault(""), /** OpenRouter provider routing — providers to skip. */ providerIgnore: Type.Optional(Type.Array(Type.String(), { default: [] })), diff --git a/apps/memos-local-plugin/core/embedding/providers/local-process-entry.ts b/apps/memos-local-plugin/core/embedding/providers/local-process-entry.ts new file mode 100644 index 000000000..23e32a4dc --- /dev/null +++ b/apps/memos-local-plugin/core/embedding/providers/local-process-entry.ts @@ -0,0 +1,70 @@ +/** Child-only entry point. Never import this module from a host adapter. */ +import { InProcessLocalEmbeddingProvider } from "./local.js"; +import type { ProviderLogger } from "../types.js"; +import type { + LocalProcessRequest, + LocalProcessResponse, +} from "./local-process-protocol.js"; + +const provider = new InProcessLocalEmbeddingProvider(); +const controllers = new Map(); +function send(message: LocalProcessResponse): void { + if (!process.connected) return; + try { + process.send?.(message, () => {}); + } catch { + /* Parent disconnected. */ + } +} +async function handle(message: LocalProcessRequest): Promise { + if (message.type === "cancel") { + controllers.get(message.id)?.abort(); + return; + } + const controller = new AbortController(); + controllers.set(message.id, controller); + const log = Object.fromEntries( + ["trace", "debug", "info", "warn", "error"].map((level) => [ + level, + (text: string, data?: Record) => + send({ + type: "log", + id: message.id, + level: level as keyof ProviderLogger, + message: text, + data, + }), + ]), + ) as unknown as ProviderLogger; + try { + const vectors = await provider.embed(message.texts, "query", { + config: { + provider: "local", + model: message.model, + local: message.local, + dimensions: 384, + openRouter: false, + cache: { enabled: false, maxItems: 0 }, + }, + log, + signal: controller.signal, + }); + send({ type: "result", id: message.id, vectors }); + } catch (error) { + send({ + type: "error", + id: message.id, + message: + error instanceof Error + ? error.message + : "Local model loading or inference failed.", + }); + } finally { + controllers.delete(message.id); + } +} +process.on("message", (message: LocalProcessRequest) => { + void handle(message); +}); +// No orphan model process after a host crash, restart or normal exit. +process.on("disconnect", () => process.exit(0)); diff --git a/apps/memos-local-plugin/core/embedding/providers/local-process-protocol.ts b/apps/memos-local-plugin/core/embedding/providers/local-process-protocol.ts new file mode 100644 index 000000000..f71a700af --- /dev/null +++ b/apps/memos-local-plugin/core/embedding/providers/local-process-protocol.ts @@ -0,0 +1,22 @@ +import type { EmbeddingConfig, ProviderLogger } from "../types.js"; + +/** Only model settings cross IPC: never forward API keys or the full runtime config. */ +export type LocalProcessRequest = + | { + type: "embed"; + id: number; + texts: string[]; + model: string; + local?: EmbeddingConfig["local"]; + } + | { type: "cancel"; id: number }; +export type LocalProcessResponse = + | { type: "result"; id: number; vectors: number[][] } + | { type: "error"; id: number; message: string } + | { + type: "log"; + id: number; + level: keyof ProviderLogger; + message: string; + data?: Record; + }; diff --git a/apps/memos-local-plugin/core/embedding/providers/local-process.ts b/apps/memos-local-plugin/core/embedding/providers/local-process.ts new file mode 100644 index 000000000..6be6d5bf0 --- /dev/null +++ b/apps/memos-local-plugin/core/embedding/providers/local-process.ts @@ -0,0 +1,214 @@ +/** Windows DLL isolation. A thread would still share the host's native DLLs. */ +import { fork, type ChildProcess, type ForkOptions } from "node:child_process"; +import { existsSync } from "node:fs"; +import { createRequire } from "node:module"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import { MemosError } from "../../../agent-contract/errors.js"; +import type { ProviderCallCtx } from "../types.js"; +import type { + LocalProcessRequest, + LocalProcessResponse, +} from "./local-process-protocol.js"; + +interface PendingCall { + resolve(vectors: number[][]): void; + reject(error: unknown): void; + ctx: ProviderCallCtx; + count: number; + cleanup(): void; +} +const IDLE_MS = 5 * 60_000; + +class LocalEmbeddingProcess { + private child?: ChildProcess; + private pending = new Map(); + private nextId = 0; + private idleTimer?: ReturnType; + private lastLog?: ProviderCallCtx["log"]; + + private start(): ChildProcess { + if (this.child) return this.child; + let entry = new URL("./local-process-entry.js", import.meta.url); + let execArgv: string[] = []; + if (!existsSync(entry)) { + // Source checkouts use the declared tsx runtime; published packages use JS. + entry = new URL("./local-process-entry.ts", import.meta.url); + execArgv = [ + "--import", + pathToFileURL(createRequire(import.meta.url).resolve("tsx")).href, + ]; + } + const env: NodeJS.ProcessEnv = { + ...process.env, + ELECTRON_RUN_AS_NODE: "1", + }; + // Do not re-run a host's preloads or resolver hooks in the isolated process. + delete env.NODE_OPTIONS; + delete env.NODE_PATH; + const options: ForkOptions & { windowsHide: boolean } = { + execArgv, + env, + windowsHide: true, + stdio: ["ignore", "ignore", "ignore", "ipc"], + }; + const child = fork(fileURLToPath(entry), [], options); + this.child = child; + child.on("message", (message) => + this.receive(child, message as LocalProcessResponse), + ); + child.on("error", () => + this.fail( + child, + "Local embedding process failed to start or communicate.", + ), + ); + child.on("exit", () => + this.fail( + child, + "Local embedding process exited; the next request will restart it.", + ), + ); + return child; + } + + private fail(child: ChildProcess, message: string): void { + if (this.child !== child) return; + this.child = undefined; + clearTimeout(this.idleTimer); + for (const call of this.pending.values()) { + call.cleanup(); + call.reject(new MemosError("embedding_unavailable", message)); + } + this.pending.clear(); + child.kill(); + } + + private send(child: ChildProcess, message: LocalProcessRequest): void { + try { + child.send(message, (error) => { + if (error) this.fail(child, "Local embedding process IPC failed."); + }); + } catch { + this.fail(child, "Local embedding process IPC failed."); + } + } + + private receive(child: ChildProcess, message: LocalProcessResponse): void { + if (this.child !== child || !message || typeof message !== "object") return; + const call = this.pending.get(message.id); + if (message.type === "log") { + const log = call?.ctx.log ?? this.lastLog; + if (["trace", "debug", "info", "warn", "error"].includes(message.level)) + log?.[message.level](message.message, message.data); + return; + } + if (!call || !["result", "error"].includes(message.type)) return; + this.pending.delete(message.id); + call.cleanup(); + if (message.type === "error") { + call.reject(new MemosError("embedding_unavailable", message.message)); + } else if (message.type === "result") { + const vectors = message.vectors; + if ( + !Array.isArray(vectors) || + vectors.length !== call.count || + vectors.some( + (vector) => + !Array.isArray(vector) || + !vector.length || + vector.some((n) => typeof n !== "number" || !Number.isFinite(n)), + ) + ) { + call.reject( + new MemosError( + "embedding_unavailable", + "Local embedding process returned invalid vectors.", + ), + ); + } else call.resolve(vectors); + } + this.updateLiveness(); + } + + private updateLiveness(): void { + clearTimeout(this.idleTimer); + if (this.pending.size) { + this.child?.ref(); + this.child?.channel?.ref(); + } else { + // Keep a warm model without preventing the host from exiting. Idle cleanup + // also bounds resources used by throwaway Settings model probes. + this.child?.unref(); + this.child?.channel?.unref(); + this.idleTimer = setTimeout(() => this.close(), IDLE_MS); + this.idleTimer.unref(); + } + } + + embed(texts: string[], ctx: ProviderCallCtx): Promise { + if (ctx.signal?.aborted) return Promise.reject(ctx.signal.reason); + let child: ChildProcess; + try { + child = this.start(); + } catch { + return Promise.reject( + new MemosError( + "embedding_unavailable", + "Cannot start the isolated local embedding process.", + ), + ); + } + const id = ++this.nextId; + this.lastLog = ctx.log; + ctx.log.debug("process.request", { pid: child.pid, requestId: id }); + return new Promise((resolve, reject) => { + const onAbort = () => { + if (!this.pending.delete(id)) return; + ctx.signal?.removeEventListener("abort", onAbort); + reject(ctx.signal?.reason ?? new DOMException("Aborted", "AbortError")); + this.send(child, { type: "cancel", id }); + this.updateLiveness(); + }; + this.pending.set(id, { + resolve, + reject, + ctx, + count: texts.length, + cleanup: () => ctx.signal?.removeEventListener("abort", onAbort), + }); + ctx.signal?.addEventListener("abort", onAbort, { once: true }); + this.updateLiveness(); + this.send(child, { + type: "embed", + id, + texts, + model: ctx.config.model, + local: ctx.config.local, + }); + }); + } + + close(): void { + if (this.child) this.fail(this.child, "Local embedding process closed."); + clearTimeout(this.idleTimer); + this.lastLog = undefined; + } +} + +// Share a warm process across cores and Settings probes; closing one provider +// must not interrupt another provider's pending inference. +let shared: { client: LocalEmbeddingProcess; users: number } | undefined; +export function acquireLocalEmbeddingProcess(): LocalEmbeddingProcess { + shared ??= { client: new LocalEmbeddingProcess(), users: 0 }; + shared.users++; + return shared.client; +} +export function releaseLocalEmbeddingProcess( + client: LocalEmbeddingProcess, +): void { + if (!shared || shared.client !== client) return; + if (--shared.users === 0) { + shared = undefined; + client.close(); + } +} diff --git a/apps/memos-local-plugin/core/embedding/providers/local.ts b/apps/memos-local-plugin/core/embedding/providers/local.ts index 01c00d7c3..50ac037c6 100644 --- a/apps/memos-local-plugin/core/embedding/providers/local.ts +++ b/apps/memos-local-plugin/core/embedding/providers/local.ts @@ -10,7 +10,15 @@ * don't normalize again on top of that. */ +import { homedir, platform } from "node:os"; +import { + acquireLocalEmbeddingProcess, + releaseLocalEmbeddingProcess, +} from "./local-process.js"; +import { join, resolve } from "node:path"; +import { MemosError } from "../../../agent-contract/errors.js"; import type { + EmbeddingConfig, EmbedRole, EmbeddingProvider, EmbeddingProviderName, @@ -18,10 +26,16 @@ import type { } from "../types.js"; // eslint-disable-next-line @typescript-eslint/no-explicit-any -type Extractor = (text: string, options?: Record) => Promise; +type Extractor = ( + text: string, + options?: Record, +) => Promise; let extractorPromise: Promise | null = null; -let currentModel: string | null = null; +let currentKey: string | null = null; +// Transformers has a process-wide env. Keep our differently configured loads +// exclusive until pipeline creation has finished, including background warmup. +let loadQueue: Promise = Promise.resolve(); function abortReason(signal: AbortSignal): unknown { return signal.reason ?? new DOMException("Aborted", "AbortError"); @@ -36,7 +50,10 @@ function abortReason(signal: AbortSignal): unknown { * cache for the next request. Attaching both promise handlers also prevents a * late native failure from becoming an unhandled rejection. */ -function awaitWithAbort(promise: Promise, signal?: AbortSignal): Promise { +function awaitWithAbort( + promise: Promise, + signal?: AbortSignal, +): Promise { if (!signal) return promise; if (signal.aborted) return Promise.reject(abortReason(signal)); @@ -59,35 +76,159 @@ function awaitWithAbort(promise: Promise, signal?: AbortSignal): Promise { - if (extractorPromise && currentModel === model) return extractorPromise; - if (extractorPromise && currentModel && currentModel !== model) { - log.warn("model.swap", { from: currentModel, to: model }); - extractorPromise = null; +function localPath(value?: string): string | undefined { + if (!value?.trim()) return undefined; + const path = value.trim(); + return resolve( + path === "~" + ? homedir() + : path.startsWith("~/") + ? join(homedir(), path.slice(2)) + : path, + ); +} + +function localSettings(config: EmbeddingConfig) { + let remoteHost = + config.local?.remoteHost?.trim() || + process.env.HF_ENDPOINT?.trim() || + undefined; + if (remoteHost) { + try { + const url = new URL(remoteHost); + if ( + !["https:", "http:"].includes(url.protocol) || + url.username || + url.password || + url.search || + url.hash + ) + throw new Error(); + remoteHost = url.href.endsWith("/") ? url.href : `${url.href}/`; + } catch { + throw new MemosError( + "config_invalid", + "Local model remoteHost/HF_ENDPOINT must be an HTTP(S) base URL without credentials, query or fragment.", + ); + } } - log.info("loading", { model }); + return { + remoteHost, + modelPath: localPath(config.local?.modelPath), + cacheDir: + localPath(config.local?.cacheDir) ?? + join(homedir(), ".cache", "memos", "models"), + offline: config.local?.offline === true, + }; +} + +function ensureExtractor( + config: EmbeddingConfig, + log: ProviderCallCtx["log"], +): Promise { + const { model } = config; + const settings = localSettings(config); + const key = JSON.stringify([model, settings]); + if (extractorPromise && currentKey === key) return extractorPromise; + log.info("loading", { model, offline: settings.offline }); const t0 = Date.now(); - extractorPromise = (async () => { - // Dynamic import keeps the heavy dep out of the hot path for tests that - // don't need it. + const previous = loadQueue; + const pending = previous.then(async () => { const mod = await import("@huggingface/transformers"); const pipeline = (mod as unknown as { pipeline: PipelineFn }).pipeline; - const ext = (await pipeline("feature-extraction", model, { - dtype: "q8", - device: "cpu", - })) as unknown as Extractor; - log.info("ready", { model, durationMs: Date.now() - t0 }); - return ext; - })().catch((err) => { - extractorPromise = null; + const env = mod.env; + const saved = { + remoteHost: env.remoteHost, + localModelPath: env.localModelPath, + cacheDir: env.cacheDir, + allowRemoteModels: env.allowRemoteModels, + }; + if (settings.remoteHost) env.remoteHost = settings.remoteHost; + if (settings.modelPath) env.localModelPath = settings.modelPath; + if (settings.cacheDir) env.cacheDir = settings.cacheDir; + env.allowRemoteModels = !settings.offline; + const progressByFile = new Map(); + try { + const ext = (await pipeline("feature-extraction", model, { + dtype: "q8", + device: "cpu", + local_files_only: settings.offline, + progress_callback: (event: { + status?: string; + file?: string; + progress?: number; + }) => { + if ( + event.status !== "progress" || + typeof event.progress !== "number" || + !Number.isFinite(event.progress) + ) + return; + const file = event.file ?? "model"; + const progress = Math.max( + 0, + Math.min(100, Math.floor(event.progress)), + ); + if ( + progressByFile.get(file) === progress || + (progress < (progressByFile.get(file) ?? -10) + 10 && + progress !== 100) + ) + return; + progressByFile.set(file, progress); + log.info("download.progress", { model, file, progress }); + }, + })) as unknown as Extractor; + log.info("ready", { model, durationMs: Date.now() - t0 }); + return ext; + } finally { + Object.assign(env, saved); + } + }); + const observed = pending.catch((err) => { + if (extractorPromise === observed) { + extractorPromise = null; + currentKey = null; + } log.error("load_failed", { model, err: { name: (err as Error).name, message: (err as Error).message }, }); throw err; }); - currentModel = model; - return extractorPromise; + loadQueue = observed.then( + () => undefined, + () => undefined, + ); + currentKey = key; + extractorPromise = observed; + return observed; +} + +async function waitForModel( + load: Promise, + timeoutMs: number, +): Promise { + let timer: ReturnType | undefined; + try { + return await Promise.race([ + load, + new Promise((_, reject) => { + timer = setTimeout( + () => + reject( + new MemosError( + "embedding_unavailable", + `Local model loading exceeded ${timeoutMs} ms. Check download progress, configure a mirror or local model directory, then retry. Background loading may still complete.`, + ), + ), + timeoutMs, + ); + }), + ]); + } finally { + if (timer) clearTimeout(timer); + } } /** @@ -101,14 +242,24 @@ type PipelineFn = ( options?: Record, ) => Promise; -export class LocalEmbeddingProvider implements EmbeddingProvider { +export class InProcessLocalEmbeddingProvider implements EmbeddingProvider { readonly name: EmbeddingProviderName = "local"; - async embed(texts: string[], _role: EmbedRole, ctx: ProviderCallCtx): Promise { + async embed( + texts: string[], + _role: EmbedRole, + ctx: ProviderCallCtx, + ): Promise { const { config, log } = ctx; // Avoid starting a costly lazy model load for an already-expired request. if (ctx.signal?.aborted) throw abortReason(ctx.signal); - const ext = await awaitWithAbort(ensureExtractor(config.model, log), ctx.signal); + const ext = await awaitWithAbort( + waitForModel( + ensureExtractor(config, log), + config.local?.loadTimeoutMs ?? 120_000, + ), + ctx.signal, + ); const out: number[][] = []; for (let i = 0; i < texts.length; i++) { if (ctx.signal?.aborted) throw abortReason(ctx.signal); @@ -128,12 +279,40 @@ export class LocalEmbeddingProvider implements EmbeddingProvider { async close(): Promise { // The transformers pipeline doesn't expose a .close(); GC handles it. extractorPromise = null; - currentModel = null; + currentKey = null; + } +} + +/** Windows native DLLs must remain outside the host process. */ +export class LocalEmbeddingProvider implements EmbeddingProvider { + readonly name: EmbeddingProviderName = "local"; + private inProcess = new InProcessLocalEmbeddingProvider(); + private isolated?: ReturnType; + + embed( + texts: string[], + role: EmbedRole, + ctx: ProviderCallCtx, + ): Promise { + if (ctx.signal?.aborted) return Promise.reject(abortReason(ctx.signal)); + if (platform() !== "win32") return this.inProcess.embed(texts, role, ctx); + this.isolated ??= acquireLocalEmbeddingProcess(); + return this.isolated.embed(texts, ctx); + } + + async close(): Promise { + if (this.isolated) { + releaseLocalEmbeddingProcess(this.isolated); + this.isolated = undefined; + } else { + await this.inProcess.close(); + } } } // Test hook — tests can reset the cached extractor without touching internals. export function __resetLocalExtractorForTests(): void { extractorPromise = null; - currentModel = null; + currentKey = null; + loadQueue = Promise.resolve(); } diff --git a/apps/memos-local-plugin/core/embedding/types.ts b/apps/memos-local-plugin/core/embedding/types.ts index 9e190ea58..c27b7b7f6 100644 --- a/apps/memos-local-plugin/core/embedding/types.ts +++ b/apps/memos-local-plugin/core/embedding/types.ts @@ -27,6 +27,13 @@ export interface EmbeddingConfig { provider: EmbeddingProviderName; endpoint?: string; model: string; + local?: { + remoteHost?: string; + modelPath?: string; + cacheDir?: string; + offline?: boolean; + loadTimeoutMs?: number; + }; dimensions: number; apiKey?: string; /** OpenRouter provider routing — providers to skip. */ diff --git a/apps/memos-local-plugin/core/pipeline/bundle-import.ts b/apps/memos-local-plugin/core/pipeline/bundle-import.ts new file mode 100644 index 000000000..2cc48d996 --- /dev/null +++ b/apps/memos-local-plugin/core/pipeline/bundle-import.ts @@ -0,0 +1,601 @@ +import type { + MemoryImportBundle, + MemoryImportIssue, + MemoryImportOptions, + MemoryImportResult, +} from "../../agent-contract/import.js"; +import type { + PolicyDTO, + RuntimeNamespace, + SkillDTO, + TraceDTO, + WorldModelDTO, +} from "../../agent-contract/dto.js"; +import { MemosError } from "../../agent-contract/errors.js"; +import { + isVisibleTo, + normalizeNamespace, + ownerFromNamespace, +} from "../runtime/namespace.js"; +import { rootLogger } from "../logger/index.js"; +import type { Repos, StorageDb } from "../storage/index.js"; +import type { + EpisodeId, + SkillRow, + TraceId, + TraceRow, + WorldModelRow, +} from "../types.js"; + +type Kind = MemoryImportIssue["kind"]; +type RecordRow = Record; +type Owner = ReturnType; +const BATCH_SIZE = 100; + +function validationIssue( + kind: Kind, + value: unknown, +): Omit | undefined { + if (!value || typeof value !== "object" || Array.isArray(value)) { + return { code: "invalid_row", message: "Row must be an object." }; + } + const row = value as RecordRow; + const required = + kind === "trace" + ? ["id", "sessionId", "episodeId"] + : kind === "policy" + ? [ + "id", + "title", + "trigger", + "procedure", + "verification", + "boundary", + "status", + ] + : kind === "skill" + ? ["id", "name", "invocationGuide", "status"] + : ["id", "title", "body"]; + for (const field of required) { + if ( + typeof row[field] !== "string" || + (["id", "sessionId", "episodeId"].includes(field) && !row[field].trim()) + ) { + return { + field, + code: "invalid_field", + message: `${field} must be a string${field === "id" ? " with a nonempty id" : ""}.`, + }; + } + } + if ( + row.status != null && + !( + kind === "worldModel" + ? ["active", "archived"] + : ["candidate", "active", "archived"] + ).includes(String(row.status)) + ) { + return { + field: "status", + code: "invalid_field", + message: "status is not a supported lifecycle state.", + }; + } + for (const field of [ + "ts", + "turnId", + "createdAt", + "updatedAt", + "lastUsedAt", + "version", + ]) { + if (row[field] != null && !Number.isSafeInteger(row[field])) { + return { + field, + code: "invalid_integer", + message: `${field} must be a safe integer; timestamps use milliseconds.`, + }; + } + } + for (const field of [ + "userText", + "agentText", + "summary", + "reflection", + "agentThinking", + "ownerAgentKind", + "ownerProfileId", + "ownerWorkspaceId", + ]) { + if (row[field] != null && typeof row[field] !== "string") { + return { + field, + code: "invalid_field", + message: `${field} must be a string.`, + }; + } + } + for (const field of [ + "value", + "alpha", + "priority", + "rHuman", + "support", + "gain", + "eta", + "salience", + "confidence", + ]) { + if ( + row[field] != null && + (typeof row[field] !== "number" || !Number.isFinite(row[field])) + ) { + return { + field, + code: "invalid_field", + message: `${field} must be a finite number.`, + }; + } + } + for (const field of [ + "toolCalls", + "tags", + "preference", + "antiPattern", + "policyIds", + "sourceEpisodeIds", + "sourceFeedbackIds", + "sourceTraceIds", + "sourcePolicyIds", + "sourceWorldModelIds", + "evidenceAnchors", + ]) { + if (row[field] != null && !Array.isArray(row[field])) { + return { + field, + code: "invalid_field", + message: `${field} must be an array.`, + }; + } + if ( + field !== "toolCalls" && + Array.isArray(row[field]) && + row[field].some((value) => typeof value !== "string") + ) { + return { + field, + code: "invalid_field", + message: `${field} must contain strings.`, + }; + } + } + if (kind === "worldModel" && row.structure != null) { + const structure = row.structure as RecordRow; + if (typeof structure !== "object" || Array.isArray(structure)) { + return { + field: "structure", + code: "invalid_field", + message: "structure must be an object.", + }; + } + for (const facet of ["environment", "inference", "constraints"]) { + const entries = structure[facet]; + if (entries === undefined) continue; + if ( + !Array.isArray(entries) || + entries.some((entry) => { + // Earlier exports used plain strings. Preserve those as well as the + // current labelled entries rather than silently discarding evidence. + if (typeof entry === "string") return false; + if (!entry || typeof entry !== "object" || Array.isArray(entry)) + return true; + return ( + typeof entry.label !== "string" || + typeof entry.description !== "string" || + (entry.evidenceIds !== undefined && + (!Array.isArray(entry.evidenceIds) || + entry.evidenceIds.some( + (id: unknown) => typeof id !== "string", + ))) + ); + }) + ) { + return { + field: `structure.${facet}`, + code: "invalid_field", + message: `structure.${facet} must contain strings or labelled entries with optional string evidenceIds.`, + }; + } + } + } + if (row.share != null) { + const share = row.share as RecordRow; + if ( + typeof share !== "object" || + Array.isArray(share) || + !["private", "local", "public", "hub"].includes(String(share.scope)) + ) { + return { + field: "share", + code: "invalid_field", + message: "share must specify a valid scope.", + }; + } + if (share.sharedAt != null && !Number.isSafeInteger(share.sharedAt)) { + return { + field: "share.sharedAt", + code: "invalid_integer", + message: "share.sharedAt must be an integer timestamp in milliseconds.", + }; + } + } + return undefined; +} + +function ownerFor( + row: RecordRow, + fallback: Owner, + options: MemoryImportOptions, +): Owner { + if (options.ownership === "target") return fallback; + return { + ownerAgentKind: (row.ownerAgentKind as string) ?? fallback.ownerAgentKind, + ownerProfileId: (row.ownerProfileId as string) ?? fallback.ownerProfileId, + ownerWorkspaceId: + (row.ownerWorkspaceId as string | null) ?? fallback.ownerWorkspaceId, + }; +} + +type ParentState = { + sessions: Map; + episodes: Map; +}; + +function conflictingParent( + row: RecordRow & Owner, + repos: Repos, + planned: ParentState, +): Omit | undefined { + const sessionId = row.sessionId as string; + const episodeId = row.episodeId as string; + const episode = + planned.episodes.get(episodeId) ?? + repos.episodes.getById(episodeId as EpisodeId); + if (episode && episode.sessionId !== sessionId) { + return { + field: "sessionId", + code: "conflicting_parent", + message: "sessionId does not match the existing episode's session.", + }; + } + const session = + planned.sessions.get(sessionId) ?? + repos.sessions.getById(sessionId as TraceDTO["sessionId"]); + for (const [field, parent] of [ + ["sessionId", session], + ["episodeId", episode], + ] as const) { + if ( + parent && + ((parent.ownerAgentKind ?? "unknown") !== row.ownerAgentKind || + (parent.ownerProfileId ?? "default") !== row.ownerProfileId) + ) { + return { + field, + code: "conflicting_parent", + message: `${field} belongs to another memory owner.`, + }; + } + } + return undefined; +} + +/** Import each row atomically; a rejected trace must not leave synthetic parents behind. */ +export async function importMemoryBundle( + bundle: MemoryImportBundle, + options: MemoryImportOptions, + context: { db: StorageDb; repos: Repos; namespace: RuntimeNamespace }, +): Promise { + if (!bundle || typeof bundle !== "object" || Array.isArray(bundle)) + throw new MemosError("invalid_argument", "bundle must be an object"); + if (bundle.version !== undefined && bundle.version !== 1) + throw new MemosError("unsupported", "unsupported bundle version"); + if ( + options.ownership !== undefined && + !["preserve", "target"].includes(options.ownership) + ) + throw new MemosError( + "invalid_argument", + "ownership must be preserve or target", + ); + if ( + options.targetProfileId !== undefined && + (options.ownership !== "target" || + typeof options.targetProfileId !== "string" || + !options.targetProfileId.trim()) + ) { + throw new MemosError( + "invalid_argument", + "targetProfileId requires target ownership and a nonempty profile id", + ); + } + if (options.dryRun !== undefined && typeof options.dryRun !== "boolean") + throw new MemosError("invalid_argument", "dryRun must be boolean"); + const collections = [ + ["trace", "traces"], + ["policy", "policies"], + ["skill", "skills"], + ["worldModel", "worldModels"], + ] as const; + for (const [, name] of collections) { + if (bundle[name] !== undefined && !Array.isArray(bundle[name])) + throw new MemosError("invalid_argument", `${name} must be an array`); + } + const { db, repos, namespace } = context; + const target = normalizeNamespace({ + ...namespace, + profileId: options.targetProfileId ?? namespace.profileId, + }); + const fallback = ownerFromNamespace( + options.ownership === "target" ? target : namespace, + ); + const result: MemoryImportResult = { + imported: 0, + skipped: 0, + duplicates: 0, + invalid: 0, + failed: 0, + visible: 0, + hidden: 0, + dryRun: options.dryRun === true, + issues: [], + }; + const planned: ParentState = { sessions: new Map(), episodes: new Map() }; + const issue = (value: MemoryImportIssue) => { + if (result.issues.length < 50) result.issues.push(value); + }; + + for (const [kind, name] of collections) { + const rows = bundle[name] ?? []; + const ids = new Set(); + for (let offset = 0; offset < rows.length; offset += BATCH_SIZE) { + const batch = rows.slice(offset, offset + BATCH_SIZE); + const existingTraces = + kind === "trace" + ? new Set( + repos.traces + .getManyByIds( + batch + .filter( + (row): row is RecordRow => + !!row && + typeof row === "object" && + typeof (row as RecordRow).id === "string", + ) + .map((row) => row.id as TraceId), + ) + .map((row) => row.id as string), + ) + : new Set(); + db.tx(() => { + for (let i = 0; i < batch.length; i++) { + const index = offset + i; + const invalid = validationIssue(kind, batch[i]); + if (invalid) { + result.invalid++; + result.skipped++; + issue({ kind, index, ...invalid }); + continue; + } + const raw = batch[i] as RecordRow; + const id = raw.id as string; + const exists = + ids.has(id) || + (kind === "trace" + ? existingTraces.has(id) + : kind === "policy" + ? !!repos.policies.getById(id) + : kind === "skill" + ? !!repos.skills.getById(id) + : !!repos.worldModel.getById(id)); + if (exists) { + result.duplicates++; + result.skipped++; + continue; + } + const owner = ownerFor(raw, fallback, options); + const row: RecordRow & Owner = { ...raw, ...owner }; + const conflict = + kind === "trace" + ? conflictingParent(row, repos, planned) + : undefined; + if (conflict) { + result.invalid++; + result.skipped++; + issue({ kind, index, ...conflict }); + continue; + } + try { + if (!options.dryRun) db.tx(() => insertRow(kind, row, repos)); + ids.add(id); + if (kind === "trace") { + // Preview must resolve later rows against the same accepted + // parents as a real import, including across batch boundaries. + planned.sessions.set(row.sessionId as string, owner); + planned.episodes.set(row.episodeId as string, { + ...owner, + sessionId: row.sessionId as string, + }); + } + result.imported++; + if (isVisibleTo(row, namespace)) result.visible++; + else result.hidden++; + } catch { + result.failed++; + result.skipped++; + issue({ + kind, + index, + code: "write_failed", + message: + "Database rejected this row; verify its fields and references.", + }); + } + } + }); + await new Promise((resolve) => setImmediate(resolve)); + } + } + if (!options.dryRun && (result.failed || result.invalid)) { + rootLogger.child({ channel: "core.import" }).warn("rows_rejected", { + invalid: result.invalid, + failed: result.failed, + issues: result.issues, + }); + } + return result; +} + +function insertRow(kind: Kind, raw: RecordRow & Owner, repos: Repos): void { + const owner: Owner = { + ownerAgentKind: raw.ownerAgentKind, + ownerProfileId: raw.ownerProfileId, + ownerWorkspaceId: raw.ownerWorkspaceId, + }; + const now = Date.now(); + if (kind === "trace") { + const dto = raw as unknown as TraceDTO; + const ts = dto.ts ?? now; + if (!repos.sessions.getById(dto.sessionId)) + repos.sessions.upsert({ + id: dto.sessionId, + agent: owner.ownerAgentKind, + ...owner, + startedAt: ts, + lastSeenAt: ts, + meta: { source: "import" }, + }); + const episode = repos.episodes.getById(dto.episodeId); + if (!episode) + repos.episodes.upsert({ + id: dto.episodeId, + sessionId: dto.sessionId, + ...owner, + share: dto.share ?? null, + startedAt: ts, + endedAt: ts, + traceIds: [], + rTask: null, + status: "closed", + meta: { source: "import" }, + }); + repos.traces.insert({ + ...owner, + id: dto.id, + episodeId: dto.episodeId, + sessionId: dto.sessionId, + ts, + userText: dto.userText ?? "", + agentText: dto.agentText ?? "", + summary: dto.summary ?? null, + share: dto.share ?? null, + toolCalls: dto.toolCalls ?? [], + agentThinking: dto.agentThinking ?? null, + reflection: dto.reflection ?? null, + value: dto.value ?? 0, + alpha: dto.alpha ?? 0, + rHuman: dto.rHuman ?? null, + priority: dto.priority ?? 0, + tags: dto.tags ?? [], + vecSummary: null, + vecAction: null, + turnId: dto.turnId ?? ts, + schemaVersion: 1, + } as TraceRow); + repos.episodes.appendTrace(dto.episodeId as EpisodeId, [ + ...new Set([...(episode?.traceIds ?? []), dto.id]), + ]); + } else if (kind === "policy") { + const dto = raw as unknown as PolicyDTO; + repos.policies.insert({ + ...owner, + id: dto.id, + title: dto.title, + trigger: dto.trigger, + procedure: dto.procedure, + verification: dto.verification, + boundary: dto.boundary, + support: dto.support ?? 0, + gain: dto.gain ?? 0, + status: dto.status, + experienceType: dto.experienceType ?? "success_pattern", + evidencePolarity: dto.evidencePolarity ?? "positive", + salience: dto.salience ?? 0, + confidence: dto.confidence ?? 0.5, + skillEligible: dto.skillEligible !== false, + sourceEpisodeIds: dto.sourceEpisodeIds ?? [], + sourceFeedbackIds: dto.sourceFeedbackIds ?? [], + sourceTraceIds: dto.sourceTraceIds ?? [], + inducedBy: "import", + decisionGuidance: { + preference: [...(dto.preference ?? [])], + antiPattern: [...(dto.antiPattern ?? [])], + }, + verifierMeta: dto.verifierMeta ?? null, + share: dto.share ?? null, + vec: null, + createdAt: dto.createdAt ?? now, + updatedAt: dto.updatedAt ?? now, + }); + } else if (kind === "skill") { + const dto = raw as unknown as SkillDTO; + repos.skills.insert({ + ...owner, + id: dto.id, + name: dto.name, + status: dto.status, + invocationGuide: dto.invocationGuide, + eta: dto.eta ?? 0, + support: dto.support ?? 0, + gain: dto.gain ?? 0, + trialsAttempted: 0, + trialsPassed: 0, + sourcePolicyIds: dto.sourcePolicyIds ?? [], + sourceWorldModelIds: dto.sourceWorldModelIds ?? [], + evidenceAnchors: dto.evidenceAnchors ?? [], + procedureJson: {}, + share: dto.share ?? null, + vec: null, + createdAt: dto.createdAt ?? now, + updatedAt: dto.updatedAt ?? now, + version: dto.version ?? 1, + usageCount: dto.usageCount ?? 0, + lastUsedAt: dto.lastUsedAt ?? null, + } as SkillRow); + } else { + const dto = raw as unknown as WorldModelDTO; + repos.worldModel.insert({ + ...owner, + id: dto.id, + title: dto.title, + body: dto.body, + structure: { + environment: dto.structure?.environment ?? [], + inference: dto.structure?.inference ?? [], + constraints: dto.structure?.constraints ?? [], + }, + domainTags: [], + confidence: 0.5, + policyIds: dto.policyIds ?? [], + sourceEpisodeIds: [], + inducedBy: "import", + share: dto.share ?? null, + vec: null, + createdAt: dto.createdAt ?? now, + updatedAt: dto.updatedAt ?? now, + version: dto.version ?? 1, + status: dto.status ?? "active", + } as WorldModelRow); + } +} diff --git a/apps/memos-local-plugin/core/pipeline/memory-core.ts b/apps/memos-local-plugin/core/pipeline/memory-core.ts index c7b2782e4..4f9ad2c01 100644 --- a/apps/memos-local-plugin/core/pipeline/memory-core.ts +++ b/apps/memos-local-plugin/core/pipeline/memory-core.ts @@ -23,6 +23,8 @@ * minimal `{ agent, home?, config? }` input. Used by adapters. */ +import type { MemoryImportBundle, MemoryImportOptions, MemoryImportResult } from "../../agent-contract/import.js"; +import { importMemoryBundle } from "./bundle-import.js"; import { randomUUID } from "node:crypto"; import { MemosError } from "../../agent-contract/errors.js"; @@ -129,7 +131,6 @@ import type { UserFeedback } from "../reward/types.js"; const FINAL_HUB_LLM_FILTER_TIMEOUT_MS = 3_000; const DEADLINE_FILTER_SAFE_CUTOFF_MS = 2_000; -const IMPORT_WRITE_BATCH_SIZE = 500; type DedicatedLlmConfig = { provider?: string; @@ -224,6 +225,10 @@ export async function bootstrapMemoryCore( export async function bootstrapMemoryCoreFull( options: BootstrapOptions, ): Promise { + const nodeMajor = Number(process.versions.node.split(".")[0]); + if (!Number.isInteger(nodeMajor) || nodeMajor < 22) { + throw new MemosError("config_invalid", `MemOS requires Node.js >=22 in the actual host runtime (received ${process.versions.node}). Upgrade the host before installing this version.`); + } const home = options.home ?? resolveHome(options.agent); const configResult = options.config ? { config: options.config, fromDisk: true, warnings: [], source: home.configFile } @@ -4358,276 +4363,9 @@ export function createMemoryCore( }; } - async function importBundle(bundle: { - version?: number; - traces?: unknown[]; - policies?: unknown[]; - worldModels?: unknown[]; - skills?: unknown[]; - }): Promise<{ imported: number; skipped: number }> { + async function importBundle(bundle: MemoryImportBundle, options: MemoryImportOptions = {}): Promise { ensureLive(); - if (bundle.version && bundle.version !== 1) { - throw new MemosError("unsupported", `unsupported bundle version: ${bundle.version}`); - } - let imported = 0; - let skipped = 0; - - // Best-effort: only insert rows that don't collide with existing - // ids. We don't re-mint fresh ids on collision to keep the shape - // deterministic for the user — they opt in via a de-duplicating - // pre-pass if they want merging. - const traces = Array.isArray(bundle.traces) ? bundle.traces : []; - const defaultOwner = ownerFromNamespace(activeNamespace); - const seenSessions = new Set(); - const seenEpisodes = new Set(); - - for (const batch of chunkArray(traces, IMPORT_WRITE_BATCH_SIZE)) { - const result = handle.db.tx(() => { - let batchImported = 0; - let batchSkipped = 0; - const valid = batch - .map((raw) => raw as TraceDTO) - .filter((dto) => dto?.id && dto.episodeId && dto.sessionId); - batchSkipped += batch.length - valid.length; - - // Phase 0 — ensure every referenced (sessionId, episodeId) row - // exists before `traces.insert`, otherwise the FK constraint would - // bounce imported legacy/external rows. - for (const dto of valid) { - const owner = importOwnerFields(dto, defaultOwner); - const ts = Number.isFinite(dto.ts) ? dto.ts : Date.now(); - if (!seenSessions.has(dto.sessionId)) { - try { - if (!handle.repos.sessions.getById(dto.sessionId)) { - handle.repos.sessions.upsert({ - id: dto.sessionId, - agent: dto.ownerAgentKind ?? handle.agent, - ...owner, - startedAt: ts, - lastSeenAt: ts, - meta: { source: "import" }, - } as never); - } - } catch { - // If the synthetic session row is rejected, the FK insert - // below will fail and be counted as `skipped`. - } - seenSessions.add(dto.sessionId); - } - if (!seenEpisodes.has(dto.episodeId)) { - try { - if (!handle.repos.episodes.getById(dto.episodeId)) { - handle.repos.episodes.upsert({ - id: dto.episodeId, - sessionId: dto.sessionId, - ...owner, - share: dto.share ?? null, - startedAt: ts, - endedAt: ts, - traceIds: [], - rTask: null, - status: "closed", - meta: { source: "import" }, - } as never); - } - } catch { - /* see comment above */ - } - seenEpisodes.add(dto.episodeId); - } - } - - const existingIds = new Set( - handle.repos.traces - .getManyByIds(valid.map((dto) => dto.id as TraceId)) - .map((row) => row.id), - ); - const addedByEpisode = new Map(); - for (const dto of valid) { - try { - if (existingIds.has(dto.id)) { batchSkipped++; continue; } - const owner = importOwnerFields(dto, defaultOwner); - const ts = Number.isFinite(dto.ts) ? dto.ts : Date.now(); - const turnId = Number.isFinite(dto.turnId) ? dto.turnId : ts; - handle.repos.traces.insert({ - ...owner, - id: dto.id, - episodeId: dto.episodeId, - sessionId: dto.sessionId, - ts, - userText: dto.userText ?? "", - agentText: dto.agentText ?? "", - summary: dto.summary ?? null, - share: dto.share ?? null, - toolCalls: dto.toolCalls ?? [], - agentThinking: dto.agentThinking ?? null, - reflection: dto.reflection ?? null, - value: dto.value ?? 0, - alpha: dto.alpha ?? 0, - rHuman: dto.rHuman ?? null, - priority: dto.priority ?? 0, - tags: dto.tags ?? [], - vecSummary: null, - vecAction: null, - turnId, - schemaVersion: 1, - } as TraceRow); - existingIds.add(dto.id); - if (!addedByEpisode.has(dto.episodeId)) addedByEpisode.set(dto.episodeId, []); - addedByEpisode.get(dto.episodeId)!.push(dto.id as TraceId); - batchImported++; - } catch { - batchSkipped++; - } - } - for (const [episodeId, ids] of addedByEpisode) { - const episode = handle.repos.episodes.getById(episodeId); - if (!episode) continue; - handle.repos.episodes.appendTrace( - episodeId, - dedupeTraceIds([...episode.traceIds, ...ids]) as string[], - ); - } - return { imported: batchImported, skipped: batchSkipped }; - }); - imported += result.imported; - skipped += result.skipped; - await yieldToEventLoop(); - } - - // Policies / world models / skills use existing repo.insert shape. - for (const batch of chunkArray(bundle.policies ?? [], IMPORT_WRITE_BATCH_SIZE)) { - const result = handle.db.tx(() => { - let batchImported = 0; - let batchSkipped = 0; - for (const raw of batch) { - try { - const dto = raw as PolicyDTO; - if (!dto?.id || handle.repos.policies.getById(dto.id)) { batchSkipped++; continue; } - handle.repos.policies.insert({ - ...importOwnerFields(dto, defaultOwner), - id: dto.id, - title: dto.title, - trigger: dto.trigger, - procedure: dto.procedure, - verification: dto.verification, - boundary: dto.boundary, - support: dto.support ?? 0, - gain: dto.gain ?? 0, - status: dto.status, - experienceType: dto.experienceType ?? "success_pattern", - evidencePolarity: dto.evidencePolarity ?? "positive", - salience: dto.salience ?? 0, - confidence: dto.confidence ?? 0.5, - skillEligible: dto.skillEligible !== false, - sourceEpisodeIds: dto.sourceEpisodeIds ?? [], - sourceFeedbackIds: dto.sourceFeedbackIds ?? [], - sourceTraceIds: dto.sourceTraceIds ?? [], - inducedBy: "import", - decisionGuidance: { - preference: [...(dto.preference ?? [])], - antiPattern: [...(dto.antiPattern ?? [])], - }, - verifierMeta: dto.verifierMeta ?? null, - share: dto.share ?? null, - vec: null, - createdAt: dto.createdAt ?? Date.now(), - updatedAt: dto.updatedAt ?? Date.now(), - }); - batchImported++; - } catch { - batchSkipped++; - } - } - return { imported: batchImported, skipped: batchSkipped }; - }); - imported += result.imported; - skipped += result.skipped; - await yieldToEventLoop(); - } - - for (const batch of chunkArray(bundle.skills ?? [], IMPORT_WRITE_BATCH_SIZE)) { - const result = handle.db.tx(() => { - let batchImported = 0; - let batchSkipped = 0; - for (const raw of batch) { - try { - const dto = raw as SkillDTO; - if (!dto?.id || handle.repos.skills.getById(dto.id)) { batchSkipped++; continue; } - handle.repos.skills.insert({ - ...importOwnerFields(dto, defaultOwner), - id: dto.id, - name: dto.name, - status: dto.status, - invocationGuide: dto.invocationGuide, - eta: dto.eta ?? 0, - support: dto.support ?? 0, - gain: dto.gain ?? 0, - trialsAttempted: 0, - trialsPassed: 0, - sourcePolicyIds: dto.sourcePolicyIds ?? [], - sourceWorldModelIds: dto.sourceWorldModelIds ?? [], - evidenceAnchors: dto.evidenceAnchors ?? [], - procedureJson: {}, - share: dto.share ?? null, - vec: null, - createdAt: dto.createdAt ?? Date.now(), - updatedAt: dto.updatedAt ?? Date.now(), - version: dto.version ?? 1, - usageCount: dto.usageCount ?? 0, - lastUsedAt: dto.lastUsedAt ?? null, - } as SkillRow); - batchImported++; - } catch { - batchSkipped++; - } - } - return { imported: batchImported, skipped: batchSkipped }; - }); - imported += result.imported; - skipped += result.skipped; - await yieldToEventLoop(); - } - - for (const batch of chunkArray(bundle.worldModels ?? [], IMPORT_WRITE_BATCH_SIZE)) { - const result = handle.db.tx(() => { - let batchImported = 0; - let batchSkipped = 0; - for (const raw of batch) { - try { - const dto = raw as WorldModelDTO; - if (!dto?.id || handle.repos.worldModel.getById(dto.id)) { batchSkipped++; continue; } - handle.repos.worldModel.insert({ - ...importOwnerFields(dto, defaultOwner), - id: dto.id, - title: dto.title, - body: dto.body, - structure: { environment: [], inference: [], constraints: [] }, - domainTags: [], - confidence: 0.5, - policyIds: dto.policyIds ?? [], - sourceEpisodeIds: [], - inducedBy: "import", - share: dto.share ?? null, - vec: null, - createdAt: dto.createdAt ?? Date.now(), - updatedAt: dto.updatedAt ?? Date.now(), - version: dto.version ?? 1, - status: dto.status ?? "active", - } as WorldModelRow); - batchImported++; - } catch { - batchSkipped++; - } - } - return { imported: batchImported, skipped: batchSkipped }; - }); - imported += result.imported; - skipped += result.skipped; - await yieldToEventLoop(); - } - - return { imported, skipped }; + return importMemoryBundle(bundle, options, { db: handle.db, repos: handle.repos, namespace: activeNamespace }); } async function embeddingMaintenanceStats(): Promise { @@ -5579,25 +5317,6 @@ function compareTraceRowsForEpisodeOrder( return a.ts - b.ts; } -function importOwnerFields( - row: { - ownerAgentKind?: AgentKind; - ownerProfileId?: string; - ownerWorkspaceId?: string | null; - }, - fallback: ReturnType, -): { - ownerAgentKind: AgentKind; - ownerProfileId: string; - ownerWorkspaceId: string | null; -} { - return { - ownerAgentKind: row.ownerAgentKind ?? fallback.ownerAgentKind, - ownerProfileId: row.ownerProfileId ?? fallback.ownerProfileId, - ownerWorkspaceId: row.ownerWorkspaceId ?? fallback.ownerWorkspaceId ?? null, - }; -} - function dedupeTraceIds(ids: readonly TraceId[]): TraceId[] { const seen = new Set(); const out: TraceId[] = []; @@ -5609,18 +5328,6 @@ function dedupeTraceIds(ids: readonly TraceId[]): TraceId[] { return out; } -function chunkArray(items: readonly T[], size: number): T[][] { - const out: T[][] = []; - for (let i = 0; i < items.length; i += size) { - out.push(items.slice(i, i + size)); - } - return out; -} - -function yieldToEventLoop(): Promise { - return new Promise((resolve) => setTimeout(resolve, 0)); -} - // ─── Row → DTO mappers ─────────────────────────────────────────────────────── export function traceRowToDTO(row: TraceRow, episode?: EpisodeRow | null): TraceDTO { diff --git a/apps/memos-local-plugin/install.ps1 b/apps/memos-local-plugin/install.ps1 index 184997b30..6d8f29c4b 100644 --- a/apps/memos-local-plugin/install.ps1 +++ b/apps/memos-local-plugin/install.ps1 @@ -175,6 +175,9 @@ Write-Host "" try { $NodeVersionStr = (node -v 2>$null) if (-not $NodeVersionStr) { Stop-Die "Node.js is not installed or not in PATH." } + if ([int]($NodeVersionStr.TrimStart('v').Split('.')[0]) -lt 22) { + Stop-Die "Node.js >=22 is required. Upgrade the actual host runtime before replacing the existing plugin." + } Write-Success "Node.js $NodeVersionStr" } catch { Stop-Die "Node.js is not installed or not in PATH." @@ -341,6 +344,9 @@ function Prepare-StagedPackage { Remove-Item -Recurse -Force $StagedPrefix -ErrorAction SilentlyContinue throw "Node.js executable not found for staged install" } + & $NodeForBridge -e 'if (Number(process.versions.node.split(".")[0]) < 22) { console.error("MemOS requires Node.js >=22 in the bridge runtime"); process.exit(1); }' + if ($LASTEXITCODE -ne 0) { Remove-Item -Recurse -Force $StagedPrefix; throw "Bridge Node.js runtime is unsupported; existing installation is unchanged." } + $NpmCommand = (Get-Command "npm.cmd" -ErrorAction SilentlyContinue).Source if (-not $NpmCommand) { $NpmCommand = (Get-Command "npm" -ErrorAction SilentlyContinue).Source } if (-not $NpmCommand) { @@ -364,7 +370,7 @@ function Prepare-StagedPackage { # npm 11 still resolves omitted DSH development peer trees unless # legacy peer resolution is requested for the packed runtime. Invoke-NativeChecked -Command $NpmCommand -Arguments @( - "install", "--omit=dev", "--legacy-peer-deps", "--no-fund", "--no-audit", "--loglevel=error" + "install", "--omit=dev", "--legacy-peer-deps", "--strict-allow-scripts", "--engine-strict", "--no-fund", "--no-audit", "--loglevel=error" ) -FailureMessage "npm install failed" } finally { if ($null -eq $PreviousSkipSetup) { @@ -376,18 +382,7 @@ function Prepare-StagedPackage { } if (-not (Test-BetterSqlite3 -NodeBin $NodeForBridge -Prefix $StagedPrefix)) { - Write-Info "Rebuilding better-sqlite3 in staging..." - Push-Location $StagedPrefix - try { - Invoke-NativeChecked -Command $NpmCommand -Arguments @( - "rebuild", "better-sqlite3", "--loglevel=error" - ) -FailureMessage "better-sqlite3 rebuild failed" - } finally { - Pop-Location - } - if (-not (Test-BetterSqlite3 -NodeBin $NodeForBridge -Prefix $StagedPrefix)) { - throw "better-sqlite3 is not loadable after rebuild" - } + throw "better-sqlite3 is not loadable: SQLite prebuilt failed its staging smoke test. No source rebuild was attempted; existing installation is unchanged." } Set-Content -Path (Join-Path $StagedPrefix ".memos-node-bin") -Value $NodeForBridge -Encoding UTF8 diff --git a/apps/memos-local-plugin/install.sh b/apps/memos-local-plugin/install.sh index eb30bff68..0c114eb76 100755 --- a/apps/memos-local-plugin/install.sh +++ b/apps/memos-local-plugin/install.sh @@ -88,7 +88,7 @@ OPENCLAW_PORT="18799" HERMES_PORT="18800" DSH_PORT="18801" DSH_PNPM_VERSION="11.7.0" -REQUIRED_NODE_MAJOR=20 +REQUIRED_NODE_MAJOR=22 OPENCLAW_RUNTIME_ENTRY="./dist/adapters/openclaw/index.js" # Older plugin IDs disabled on install so they don't fight for the # memory slot. We never touch the old plugin's data. @@ -211,22 +211,9 @@ install_node_linux() { ensure_node() { local current; current="$(node_major)" if ! [[ "${current}" =~ ^[0-9]+$ ]] || (( current < REQUIRED_NODE_MAJOR )); then - warn "Node.js >= ${REQUIRED_NODE_MAJOR} required (have ${current}). Auto-installing..." - case "${OS_NAME}" in - Darwin) install_node_mac ;; - Linux) install_node_linux ;; - esac - current="$(node_major)" - [[ "${current}" =~ ^[0-9]+$ ]] && (( current >= REQUIRED_NODE_MAJOR )) \ - || die "Node.js install failed. Install ≥ ${REQUIRED_NODE_MAJOR} and re-run." + die "Node.js >= ${REQUIRED_NODE_MAJOR} is required. Upgrade the actual host runtime before installing; the existing plugin has not been replaced." fi - # Node 25+ has no better-sqlite3 prebuilts → must compile. Warn the - # user (but don't block; the rebuild step below tries regardless). - if (( current >= 25 )); then - warn "Node $(node -v) — no better-sqlite3 prebuild available, will compile from source." - printf " ${DIM}Tip: switch to Node LTS for prebuilt binaries: nvm install 22${NC}\n" >&2 - fi success "Node.js $(node -v)" } @@ -382,13 +369,37 @@ resolve_tarball() { # the user's memory DB on every re-install. # # We mitigate that by preserving a well-known allowlist of user-data -# artefacts across the rm/extract cycle. node_modules is preserved too -# so npm install stays fast on re-install. +# artefacts across replacement. Dependencies are staged afresh and verified +# before any existing deployment is changed. deploy_tarball_to_prefix() { local prefix="$1" + local staged_prefix + staged_prefix="$(mktemp -d)" + tar xzf "${BUILT_TARBALL}" -C "${staged_prefix}" --strip-components=1 \ + || { rm -rf "${staged_prefix}"; die "Package extraction failed; existing installation is unchanged."; } + [[ -f "${staged_prefix}/package.json" ]] \ + || { rm -rf "${staged_prefix}"; die "Staged package.json missing; existing installation is unchanged."; } + step "Installing npm dependencies" + local node_bin node_dir node_version + node_bin="$(command -v node || true)" + [[ -n "${node_bin}" && -x "${node_bin}" ]] || die "Node.js not found after bootstrap." + node_dir="$(dirname "${node_bin}")" + node_version="$("${node_bin}" -v 2>/dev/null || echo "unknown")" + printf "%s\n" "${node_bin}" > "${staged_prefix}/.memos-node-bin" + # npm 11 still resolves omitted devDependency peer trees unless legacy peer + # resolution is requested. DSH peers are intentionally absent from the + # standalone OpenClaw/Hermes runtime. + ( cd "${staged_prefix}" && PATH="${node_dir}:${PATH}" MEMOS_SKIP_SETUP=1 npm install --omit=dev --legacy-peer-deps --strict-allow-scripts --engine-strict --no-fund --no-audit --loglevel=error ) || { rm -rf "${staged_prefix}"; die "Dependency staging failed; existing installation is unchanged."; } + [[ -d "${staged_prefix}/node_modules" ]] || die "npm install failed in ${staged_prefix}" + + step "Verifying SQLite prebuilt runtime" + ( cd "${staged_prefix}" && "${node_bin}" -e 'const Database = require("better-sqlite3"); const db = new Database(":memory:"); try { db.exec("CREATE TABLE probe (value TEXT)"); db.prepare("INSERT INTO probe VALUES (?)").run("ok"); if (db.prepare("SELECT value FROM probe").get().value !== "ok") throw new Error("SQLite probe failed"); } finally { db.close(); }' ) \ + || { rm -rf "${staged_prefix}"; die "SQLite prebuilt cannot load in ${node_bin}. Existing installation is unchanged; no source rebuild was attempted."; } + success "better-sqlite3 native module OK" + success "Dependencies ready" step "Deploying to ${prefix}" local saved_dir="" - local preserve=(node_modules data logs skills daemon .migrations config.yaml .auth.json .memos-node-bin) + local preserve=(data logs skills daemon .migrations config.yaml .auth.json) if [[ -d "${prefix}" ]]; then saved_dir="$(mktemp -d)" local item @@ -400,7 +411,7 @@ deploy_tarball_to_prefix() { done rm -rf "${prefix}" mkdir -p "${prefix}" - tar xzf "${BUILT_TARBALL}" -C "${prefix}" --strip-components=1 + cp -R "${staged_prefix}/." "${prefix}/" for item in "${preserve[@]}"; do if [[ -e "${saved_dir}/${item}" ]]; then rm -rf "${prefix}/${item}" @@ -410,37 +421,12 @@ deploy_tarball_to_prefix() { rm -rf "${saved_dir}" else mkdir -p "${prefix}" - tar xzf "${BUILT_TARBALL}" -C "${prefix}" --strip-components=1 + cp -R "${staged_prefix}/." "${prefix}/" fi [[ -f "${prefix}/package.json" ]] || die "Extraction failed: ${prefix}/package.json missing" - success "Package extracted" + rm -rf "${staged_prefix}" + success "Verified package deployed" - step "Installing npm dependencies" - local node_bin node_dir node_version - node_bin="$(command -v node || true)" - [[ -n "${node_bin}" && -x "${node_bin}" ]] || die "Node.js not found after bootstrap." - node_dir="$(dirname "${node_bin}")" - node_version="$("${node_bin}" -v 2>/dev/null || echo "unknown")" - printf "%s\n" "${node_bin}" > "${prefix}/.memos-node-bin" - # npm 11 still resolves omitted devDependency peer trees unless legacy peer - # resolution is requested. DSH peers are intentionally absent from the - # standalone OpenClaw/Hermes runtime. - ( cd "${prefix}" && PATH="${node_dir}:${PATH}" MEMOS_SKIP_SETUP=1 npm install --omit=dev --legacy-peer-deps --no-fund --no-audit --loglevel=error >/dev/null 2>&1 ) - [[ -d "${prefix}/node_modules" ]] || die "npm install failed in ${prefix}" - - if [[ -d "${prefix}/node_modules/better-sqlite3" ]]; then - step "Rebuilding better-sqlite3 for Node ${node_version}" - ( cd "${prefix}" && PATH="${node_dir}:${PATH}" npm rebuild better-sqlite3 --loglevel=error >/dev/null 2>&1 ) \ - || ( cd "${prefix}" && PATH="${node_dir}:${PATH}" npm rebuild better-sqlite3 --build-from-source --loglevel=error >/dev/null 2>&1 ) \ - || warn "better-sqlite3 rebuild did not complete cleanly." - if ( cd "${prefix}" && "${node_bin}" -e "require('better-sqlite3')" >/dev/null 2>&1 ); then - success "better-sqlite3 native module OK" - else - warn "better-sqlite3 not loadable — plugin will fail at startup." - printf " ${DIM}Fix: cd ${prefix} && PATH=${node_dir}:\$PATH npm rebuild better-sqlite3${NC}\n" >&2 - fi - fi - success "Dependencies ready" warn "Local MiniLM model weights are not bundled." printf " ${DIM}If embedding.provider is local, the first Viewer test or use downloads about 23 MB from Hugging Face.${NC}\n" } @@ -1407,11 +1393,9 @@ CFGEOF # ─── DeepSeek Harness install ───────────────────────────────────────────── # DSH owns its profile dependency graph and bundle reconciliation. We never # unpack into the profile or edit package.json/cordis.patch.yml ourselves. -# pnpm 11 deliberately blocks unreviewed lifecycle scripts. On that one -# expected failure we approve only the exact dependency names reviewed for -# this package, deny unnecessary scripts (including ONNX Runtime's optional -# Linux CUDA download), and repeat the same add so DSH can reconcile the -# bundle after pnpm exits successfully. +# Preseed the reviewed pnpm 11 build policy before the first add. Unknown +# scripts and conflicting explicit denials stop installation for review; +# no pending package is approved automatically after a failed install. read_pending_dsh_builds() { local workspace="$1" [[ -f "${workspace}" ]] || return 0 @@ -1470,10 +1454,45 @@ resolve_dsh_home_for_installer() { node -e 'const path = require("node:path"); const os = require("node:os"); const MEMOS_DSH_HOME = true; const configured = process.env.DSH_HOME; const selected = configured !== undefined && configured.trim().length > 0 ? configured : path.join(os.homedir(), ".dsh"); const expanded = selected === "~" ? os.homedir() : selected.startsWith("~/") || selected.startsWith("~\\") ? path.join(os.homedir(), selected.slice(2)) : selected; process.stdout.write(path.resolve(expanded));' } -deny_existing_dsh_onnx_build() { +prepare_dsh_build_policy() { local workspace="$1" - [[ -f "${workspace}" ]] || return 0 - node -e 'const fs = require("node:fs"); const MEMOS_DSH_POLICY = true; const file = process.argv[1]; const raw = fs.readFileSync(file, "utf8"); const eol = raw.includes("\r\n") ? "\r\n" : "\n"; const hadFinalEol = raw.endsWith(eol); const lines = raw.split(/\r?\n/); if (hadFinalEol) lines.pop(); let inAllowBuilds = false; let changed = false; const key = /^(\s+)(["\x27]?)onnxruntime-node\2:\s*(?:true|false|set this to true or false)(\s*(?:#.*)?)$/; for (let i = 0; i < lines.length; i += 1) { if (/^allowBuilds:\s*(?:#.*)?$/.test(lines[i])) { inAllowBuilds = true; continue; } if (inAllowBuilds && /^[^\s#]/.test(lines[i])) break; if (!inAllowBuilds) continue; const match = key.exec(lines[i]); if (!match) continue; const replacement = `${match[1]}${match[2]}onnxruntime-node${match[2]}: false${match[3]}`; if (replacement !== lines[i]) { lines[i] = replacement; changed = true; } break; } if (changed) fs.writeFileSync(file, `${lines.join(eol)}${hadFinalEol ? eol : ""}`, "utf8");' "${workspace}" + node -e 'const fs = require("node:fs"); +const path = require("node:path"); +const MEMOS_DSH_POLICY = true; +const file = process.argv[1]; +let raw = fs.existsSync(file) ? fs.readFileSync(file, "utf8") : ""; +const eol = raw.includes("\r\n") ? "\r\n" : "\n"; +const lines = raw.split(/\r?\n/); +const policy = {"better-sqlite3": false, "esbuild@0.27.7": true, "esbuild@0.21.5": true, "sharp@0.34.5": true, "onnxruntime-node": false, "protobufjs": false, "@memtensor/memos-local-plugin": false}; +let block = -1, end = -1; +const seen = new Set(); +for (let i = 0; i < lines.length; i++) { + if (/^strictDepBuilds:/.test(lines[i]) && !/^strictDepBuilds:\s*true\s*(#.*)?$/.test(lines[i])) throw new Error("Preserve existing strictDepBuilds policy; review it before installing"); + if (/^allowBuilds:/.test(lines[i])) { + if (block >= 0 || !/^allowBuilds:\s*(#.*)?$/.test(lines[i])) throw new Error("Unsupported allowBuilds YAML; review before installing"); + block = i; end = i + 1; + while (end < lines.length && (!/^[^\s#]/.test(lines[end]) || !lines[end].trim())) end++; + for (let j = i + 1; j < end; j++) { + if (!lines[j].trim() || /^\s*#/.test(lines[j])) continue; + const match = lines[j].match(/^\s+(["\x27]?)(.+?)\1:\s*(true|false|set this to true or false)\s*(#.*)?$/); + if (!match || seen.has(match[2])) throw new Error("Unsupported/duplicate allowBuilds entry"); + const key = match[2]; seen.add(key); + if (match[3] === "false" && key.includes("*")) throw new Error("Existing wildcard script denial requires explicit review"); + if ((key === "esbuild" || key.startsWith("esbuild@") || key === "sharp" || key.startsWith("sharp@")) && match[3] === "false") throw new Error("Existing script denial for " + key + "; explicit review required"); + if (key in policy) { + if (policy[key] === true && match[3] === "false") throw new Error("Existing script denial for " + key); + lines[j] = " " + JSON.stringify(key) + ": " + policy[key]; + delete policy[key]; + } + } + } +} +const additions = Object.entries(policy).map(([k,v]) => " " + JSON.stringify(k) + ": " + v); +if (block < 0) lines.push("allowBuilds:", ...additions); +else lines.splice(end, 0, ...additions); +if (!/^strictDepBuilds:/m.test(raw)) lines.push("strictDepBuilds: true"); +fs.mkdirSync(path.dirname(file), {recursive: true}); +fs.writeFileSync(file, lines.join(eol).replace(/(?:\r?\n)*$/, eol));' "${workspace}" } run_dsh_plugin_without_onnx_cuda() { @@ -1484,7 +1503,7 @@ verify_dsh_better_sqlite3() { local profile_dir="$1" ( cd "${profile_dir}" - node -e 'const Database = require("better-sqlite3"); const db = new Database(":memory:"); try { db.prepare("SELECT 1").get(); } finally { db.close(); }' + node -e 'const { createRequire } = require("node:module"); const fromPlugin = createRequire(require.resolve("@memtensor/memos-local-plugin/dist/adapters/deepseek-harness/index.js")); const Database = fromPlugin("better-sqlite3"); const db = new Database(":memory:"); try { db.exec("CREATE TABLE probe (v TEXT)"); db.prepare("INSERT INTO probe VALUES (?)").run("ok"); if (db.prepare("SELECT v FROM probe").get().v !== "ok") throw new Error("SQLite probe failed"); } finally { db.close(); }' ) } @@ -1492,7 +1511,7 @@ verify_dsh_onnx_cpu() { local profile_dir="$1" ( cd "${profile_dir}" - node -e 'const ort = require("onnxruntime-node"); const cpu = ort.listSupportedBackends().find((backend) => backend.name === "cpu"); if (!cpu || cpu.bundled !== true) throw new Error("onnxruntime-node CPU backend is unavailable");' + node -e 'const { createRequire } = require("node:module"); const fromPlugin = createRequire(require.resolve("@memtensor/memos-local-plugin/dist/adapters/deepseek-harness/index.js")); const fromTransformers = createRequire(fromPlugin.resolve("@huggingface/transformers")); const ort = fromTransformers("onnxruntime-node"); const cpu = ort.listSupportedBackends().find((backend) => backend.name === "cpu"); if (!cpu || cpu.bundled !== true) throw new Error("onnxruntime-node CPU backend is unavailable");' ) } @@ -1525,8 +1544,8 @@ install_dsh() { profile_dir="${dsh_home}/profiles/${DSH_PROFILE}" profile_workspace="${profile_dir}/pnpm-workspace.yaml" - if ! deny_existing_dsh_onnx_build "${profile_workspace}"; then - error "Unable to disable the unnecessary onnxruntime-node CUDA installer in ${profile_workspace}." + if ! prepare_dsh_build_policy "${profile_workspace}"; then + error "Unable to prepare the reviewed dependency script policy in ${profile_workspace}." return 1 fi @@ -1566,34 +1585,14 @@ install_dsh() { return 1 fi - local -a approval_args=() - for package in better-sqlite3 esbuild sharp; do - if grep -Fxq "${package}" <<< "${pending}"; then approval_args+=("${package}"); fi - done - for package in onnxruntime-node protobufjs "${NPM_PACKAGE}"; do - if grep -Fxq "${package}" <<< "${pending}"; then approval_args+=("!${package}"); fi - done - - info "pnpm requested build-script review for this fresh DSH profile." - info "Allowing reviewed native installers: better-sqlite3, esbuild, sharp" - info "Denying unnecessary scripts: onnxruntime-node CUDA download, protobufjs, ${NPM_PACKAGE}" - if ! run_dsh_plugin_without_onnx_cuda "${dsh_bin}" plugin --profile "${DSH_PROFILE}" approve-builds "${approval_args[@]}"; then - rm -f "${add_log}" - error "DSH dependency build approval failed." - return 1 - fi - - step "Completing DSH bundle activation" - if ! run_dsh_plugin_without_onnx_cuda "${dsh_bin}" plugin --profile "${DSH_PROFILE}" add "${spec}"; then - rm -f "${add_log}" - error "DSH plugin installation still failed after reviewed build approval." - return 1 - fi + rm -f "${add_log}" + error "DSH reported pending scripts after policy preparation. Review the package versions before changing the allowlist." + return 1 fi rm -f "${add_log}" - if ! deny_existing_dsh_onnx_build "${profile_workspace}"; then - error "Unable to persist the onnxruntime-node CUDA build denial in ${profile_workspace}." + if ! prepare_dsh_build_policy "${profile_workspace}"; then + error "Unable to persist the reviewed dependency script policy in ${profile_workspace}." return 1 fi @@ -1616,20 +1615,11 @@ install_dsh() { return 1 fi - if verify_dsh_better_sqlite3 "${profile_dir}"; then - success "better-sqlite3 native binding OK" - else - warn "better-sqlite3 native binding is not loadable; rebuilding it in the DSH profile." - if ! (cd "${profile_dir}" && pnpm rebuild better-sqlite3); then - error "better-sqlite3 rebuild failed in ${profile_dir}." - return 1 - fi - if ! verify_dsh_better_sqlite3 "${profile_dir}"; then - error "better-sqlite3 native binding is not loadable after rebuild." - return 1 - fi - success "better-sqlite3 native binding repaired" + if ! verify_dsh_better_sqlite3 "${profile_dir}"; then + error "better-sqlite3 native binding is not loadable in the selected runtime; no source rebuild was attempted." + return 1 fi + success "better-sqlite3 native binding OK" if ! verify_dsh_onnx_cpu "${profile_dir}"; then error "onnxruntime-node CPU binding is not loadable." diff --git a/apps/memos-local-plugin/package-lock.json b/apps/memos-local-plugin/package-lock.json index fb4d188f0..5902e431a 100644 --- a/apps/memos-local-plugin/package-lock.json +++ b/apps/memos-local-plugin/package-lock.json @@ -13,20 +13,23 @@ "@huggingface/transformers": "4.2.0", "@preact/signals": "^2.9.0", "@sinclair/typebox": "^0.34.48", - "better-sqlite3": "^12.10.0", + "better-sqlite3": "13.0.3", "preact": "^10.29.1", "tsx": "^4.21.0", "uuid": "^10.0.0", "yaml": "^2.6.0" }, "devDependencies": { - "@deepseek-ai/cordis": "^4.0.1", + "@deepseek-ai/cordis": "~4.0.4", "@deepseek-ai/dsh-agent": "0.1.0-rc.6", + "@deepseek-ai/dsh-brand": "0.1.0-rc.6", "@deepseek-ai/dsh-llm": "0.1.0-rc.6", "@deepseek-ai/dsh-session": "0.1.0-rc.6", + "@deepseek-ai/dsh-session-format-v3-to-v4": "0.2.0-rc.2", "@deepseek-ai/dsh-system-prompt": "0.1.0-rc.6", "@deepseek-ai/dsh-timeout": "0.1.0-rc.6", "@deepseek-ai/dsh-tools": "0.1.0-rc.6", + "@deepseek-ai/dsh-typert-protocol": "0.1.0-rc.6", "@deepseek-ai/schemastery": "^3.18.1", "@preact/preset-vite": "^2.10.5", "@types/better-sqlite3": "^7.6.12", @@ -37,7 +40,7 @@ "vitest": "^2.1.9" }, "engines": { - "node": ">=20.0.0" + "node": ">=22.0.0" }, "peerDependencies": { "@deepseek-ai/cordis": "^4.0.1", @@ -412,21 +415,21 @@ } }, "node_modules/@deepseek-ai/cordis": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@deepseek-ai/cordis/-/cordis-4.0.1.tgz", - "integrity": "sha512-YBdskTU2Po1kru3GgcUWUbkTsPMA9LkSQDAY8rBkFJeajdgcQad3QPJZE26JyK99Xb6HaASvoXg2DSUTeN/0Nw==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@deepseek-ai/cordis/-/cordis-4.0.5.tgz", + "integrity": "sha512-Sktq5axy0owk9PdnivBRNOJjHEVEibCt0+TDDZcv0+UH2KS1M910fX4kn5y45YFsrpZIi1mJf/1s5VzywMUnyg==", "dev": true, "license": "MIT", "dependencies": { - "@deepseek-ai/cosmokit": "^1.8.2", + "@deepseek-ai/cosmokit": "~1.8.6", "@standard-schema/spec": "^1.1.0" }, "bin": { "cordis": "bin.js" }, "peerDependencies": { - "@deepseek-ai/cordis-plugin-include": "^1.0.6", - "@deepseek-ai/cordis-plugin-loader": "^1.0.2" + "@deepseek-ai/cordis-plugin-include": "~1.0.10", + "@deepseek-ai/cordis-plugin-loader": "~1.0.6" }, "peerDependenciesMeta": { "@deepseek-ai/cordis-plugin-include": { @@ -438,9 +441,9 @@ } }, "node_modules/@deepseek-ai/cosmokit": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/@deepseek-ai/cosmokit/-/cosmokit-1.8.2.tgz", - "integrity": "sha512-muBOKtSrUKU5m/xpq8ZXWL6hQ/jgd4PhU2PqH97bcxIiLEJfNwZOGQEx4t/aS/GgxRAR+ra9pMHPMtTHU4sqqA==", + "version": "1.8.6", + "resolved": "https://registry.npmjs.org/@deepseek-ai/cosmokit/-/cosmokit-1.8.6.tgz", + "integrity": "sha512-ZSD/fN52L498LBIOYwjIOlaLv5veY6ZEwI2yzvZUKQtctn0QAPqu8tKdJ+OF5+Tv6NBq1U+wJWH+QI6OGy5EvQ==", "dev": true, "license": "MIT" }, @@ -479,7 +482,6 @@ "integrity": "sha512-E8j9Nby24qP4rfrdcfc7bpt1CHpGT3tYmycOJJkEOH4ptIdT1m2ro9nmnSd5CWYukTr64A77vjm2WGqHRI92UA==", "dev": true, "license": "MIT", - "peer": true, "peerDependencies": { "@deepseek-ai/cordis": "^4.0.1", "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6" @@ -555,6 +557,130 @@ "@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.6" } }, + "node_modules/@deepseek-ai/dsh-session-format": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session-format/-/dsh-session-format-0.2.0-rc.2.tgz", + "integrity": "sha512-qdWtsJt1cLJbUAMCgzRBZ2LyW+XRJpetnle4N/0X/pkmJ9eOM6Y+QqwRQdcEcI4pWuEbPwuq7/HrnqoanVaiwg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-util-values": "0.2.0-rc.2" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, + "node_modules/@deepseek-ai/dsh-session-format-v0-to-v1": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session-format-v0-to-v1/-/dsh-session-format-v0-to-v1-0.2.0-rc.2.tgz", + "integrity": "sha512-PPcfT7txn82/sZnFNxsuxEEUSSdEfBTkNTuOCaiu5ANDMmxUaxOOW6gXt+zBKndGJZRgCR/u9SoAdKv659FSZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-session-format": "0.2.0-rc.2", + "@deepseek-ai/dsh-util-values": "0.2.0-rc.2" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, + "node_modules/@deepseek-ai/dsh-session-format-v1-to-v2": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session-format-v1-to-v2/-/dsh-session-format-v1-to-v2-0.2.0-rc.2.tgz", + "integrity": "sha512-PBIsz4OBE0wNnapaD87lz6255em24Kn53BKV4K1AqiNH9OWf1+m29TLXs/ICtZ2xigk6TK5H9q6oOVBBmbZyVw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-llm": "0.2.0-rc.2", + "@deepseek-ai/dsh-session-format": "0.2.0-rc.2", + "@deepseek-ai/dsh-session-format-v0-to-v1": "0.2.0-rc.2", + "@deepseek-ai/dsh-util-values": "0.2.0-rc.2" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, + "node_modules/@deepseek-ai/dsh-session-format-v1-to-v2/node_modules/@deepseek-ai/dsh-brand": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-brand/-/dsh-brand-0.2.0-rc.2.tgz", + "integrity": "sha512-A5XlN4tIgP0qObkYFhcZ7Oz/tM2oESEZqLwS0Qq+sM1ivGx6o4AMPgJdfKQlwLzqk0cMLNtAaVBHfiYoElt4lw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, + "node_modules/@deepseek-ai/dsh-session-format-v1-to-v2/node_modules/@deepseek-ai/dsh-llm": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-llm/-/dsh-llm-0.2.0-rc.2.tgz", + "integrity": "sha512-6QFrQn/h0iNqCfPpgQidnHtLSpA99A7ZND/uYKaGSd/4BGP8KBhuRd0w63e9s4u+hfW8jc3j29WKcNLIOeUfcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.0-rc.2", + "@deepseek-ai/dsh-timeout": "0.2.0-rc.2", + "@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2", + "@deepseek-ai/dsh-util-crypto": "0.2.0-rc.2", + "@deepseek-ai/dsh-util-values": "0.2.0-rc.2", + "@deepseek-ai/schemastery": "~3.18.4", + "zod": "^4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, + "node_modules/@deepseek-ai/dsh-session-format-v1-to-v2/node_modules/@deepseek-ai/dsh-timeout": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-timeout/-/dsh-timeout-0.2.0-rc.2.tgz", + "integrity": "sha512-NDob8b8DJDB/sDPz3P7xhrkxOh1O9FbN1EZRKsxP4fuTfp4hrQU7aekYS5qZENFKoR8dBJMTh/zcEBw4m31glQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, + "node_modules/@deepseek-ai/dsh-session-format-v1-to-v2/node_modules/@deepseek-ai/dsh-typert-protocol": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-typert-protocol/-/dsh-typert-protocol-0.2.0-rc.2.tgz", + "integrity": "sha512-95RvIDcVac2BWdv1IxN6yKlRV+8eEvkofqSxV+d0r8x1kx2EIWEsbdxz6C+coYIm+8e03MiN+rwOt8J7sLfe7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.0-rc.2" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, + "node_modules/@deepseek-ai/dsh-session-format-v2-to-v3": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session-format-v2-to-v3/-/dsh-session-format-v2-to-v3-0.2.0-rc.2.tgz", + "integrity": "sha512-vrQQ1l3JgPIv/19mhm50FVD40hjro+tAkP3L1PNtGHrbBoYriNWXpR4QDOCQsHdPhg3vpnp9MmARMr8vZzl0Nw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-session-format": "0.2.0-rc.2", + "@deepseek-ai/dsh-session-format-v0-to-v1": "0.2.0-rc.2", + "@deepseek-ai/dsh-session-format-v1-to-v2": "0.2.0-rc.2" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, + "node_modules/@deepseek-ai/dsh-session-format-v3-to-v4": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session-format-v3-to-v4/-/dsh-session-format-v3-to-v4-0.2.0-rc.2.tgz", + "integrity": "sha512-UkiNDdGS8cwJKqjvHs52BKi+3NuKhoziz/l0IrDoDYpSdgDfK8HrrXkvIxOi+QaBUgIxNTQzA6tsI+TAIMDsGQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-session-format": "0.2.0-rc.2", + "@deepseek-ai/dsh-session-format-v2-to-v3": "0.2.0-rc.2" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, "node_modules/@deepseek-ai/dsh-system-prompt": { "version": "0.1.0-rc.6", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-system-prompt/-/dsh-system-prompt-0.1.0-rc.6.tgz", @@ -609,7 +735,6 @@ "integrity": "sha512-weWzN8r01YCkoDCAM7BsKw2YhRrD4zL8N2SAZu9hovYtXSq8xHXsP4Zh8RLYIlYcuotjyff/6hic+0TJPd14YA==", "dev": true, "license": "MIT", - "peer": true, "peerDependencies": { "@deepseek-ai/cordis": "^4.0.1", "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6" @@ -636,14 +761,34 @@ "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.6" } }, + "node_modules/@deepseek-ai/dsh-util-crypto": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-util-crypto/-/dsh-util-crypto-0.2.0-rc.2.tgz", + "integrity": "sha512-5OvvmepY69uXTagUMlnoHqg7euI4ZMifLgfdV8xZO20OslWGGiRCkJbZRyDtcJG9GsXWz9UimfWmUu52zKXJ5w==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, + "node_modules/@deepseek-ai/dsh-util-values": { + "version": "0.2.0-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-util-values/-/dsh-util-values-0.2.0-rc.2.tgz", + "integrity": "sha512-qgpsbgiZABuE9UvgNaVo9b2HiWwLeU93CTl9PFXqE0jN8ap1ALxzQsLGvr/q2MJuWDYqnFBg60XnqnY8ZxPWEg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.4" + } + }, "node_modules/@deepseek-ai/schemastery": { - "version": "3.18.1", - "resolved": "https://registry.npmjs.org/@deepseek-ai/schemastery/-/schemastery-3.18.1.tgz", - "integrity": "sha512-Qn0FCSwCQnpnj6SB31I6i2sIKgKWnkbJM8O0EU91Gv2UsYVvtZTl6IA0sCwk2e2MZf5S8w5hpq9QkeVvK9qwxg==", + "version": "3.18.5", + "resolved": "https://registry.npmjs.org/@deepseek-ai/schemastery/-/schemastery-3.18.5.tgz", + "integrity": "sha512-Mnobvqf9rHsZYv4g5edj5ddxS1oF1kIdSlz0DunUgnY3LWG5F26MqvH3YOOsSaodCgyzJ16OMN9O99/s5Crtdw==", "dev": true, "license": "MIT", "dependencies": { - "@deepseek-ai/cosmokit": "^1.8.2", + "@deepseek-ai/cosmokit": "~1.8.6", "@standard-schema/spec": "^1.1.0" } }, @@ -2366,26 +2511,6 @@ "@babel/core": "^7.12.10" } }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/baseline-browser-mapping": { "version": "2.10.19", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.19.tgz", @@ -2400,38 +2525,18 @@ } }, "node_modules/better-sqlite3": { - "version": "12.10.0", - "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-12.10.0.tgz", - "integrity": "sha512-CyzaZRQKyHkB2ZInfTTl2nvT33EbDpjkLEbE8/Zck3Ll6O0qqvuGdrJ45HgtH+HykRg88ITY3AdreBGN70aBSQ==", - "hasInstallScript": true, + "version": "13.0.3", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-13.0.3.tgz", + "integrity": "sha512-RbOBxmLBG8uvFUc15X9+9SFemKcQ0WBuISBVkpuiaUB2qblC8UWlHEjdWVoZ8AdhSwmoEgsiXKfopX0CQxaACQ==", "license": "MIT", "dependencies": { - "bindings": "^1.5.0", - "prebuild-install": "^7.1.1" + "node-addon-api": "^8.0.0" }, "engines": { - "node": "20.x || 22.x || 23.x || 24.x || 25.x || 26.x" - } - }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "license": "MIT", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, - "node_modules/bl": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", - "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "license": "MIT", - "dependencies": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } + "node": ">=22" + }, + "gypfile": false, + "hasInstallScript": false }, "node_modules/boolbase": { "version": "1.0.0", @@ -2481,30 +2586,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -2618,21 +2699,6 @@ } } }, - "node_modules/decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "license": "MIT", - "dependencies": { - "mimic-response": "^3.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/deep-eql": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", @@ -2643,15 +2709,6 @@ "node": ">=6" } }, - "node_modules/deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "license": "MIT", - "engines": { - "node": ">=4.0.0" - } - }, "node_modules/define-data-property": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", @@ -2767,15 +2824,6 @@ "dev": true, "license": "ISC" }, - "node_modules/end-of-stream": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", - "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", - "license": "MIT", - "dependencies": { - "once": "^1.4.0" - } - }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", @@ -2893,15 +2941,6 @@ "@types/estree": "^1.0.0" } }, - "node_modules/expand-template": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", - "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", - "license": "(MIT OR WTFPL)", - "engines": { - "node": ">=6" - } - }, "node_modules/expect-type": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", @@ -2912,24 +2951,12 @@ "node": ">=12.0.0" } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "license": "MIT" - }, "node_modules/flatbuffers": { "version": "25.9.23", "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-25.9.23.tgz", "integrity": "sha512-MI1qs7Lo4Syw0EOzUl0xjs2lsoeqFku44KpngfIduHBYvzm8h2+7K8YMQh1JtVVVrUvhLpNwqVi4DERegUJhPQ==", "license": "Apache-2.0" }, - "node_modules/fs-constants": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", - "license": "MIT" - }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -2966,12 +2993,6 @@ "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" } }, - "node_modules/github-from-package": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", - "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", - "license": "MIT" - }, "node_modules/global-agent": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/global-agent/-/global-agent-3.0.0.tgz", @@ -3045,38 +3066,6 @@ "he": "bin/he" } }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "BSD-3-Clause" - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "license": "ISC" - }, - "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "license": "ISC" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -3175,33 +3164,6 @@ "node": ">=10" } }, - "node_modules/mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "license": "MIT" - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -3228,22 +3190,13 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, - "node_modules/napi-build-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz", - "integrity": "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==", - "license": "MIT" - }, - "node_modules/node-abi": { - "version": "3.89.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.89.0.tgz", - "integrity": "sha512-6u9UwL0HlAl21+agMN3YAMXcKByMqwGx+pq+P76vii5f7hTPtKDp08/H9py6DY+cfDw7kQNTGEj/rly3IgbNQA==", + "node_modules/node-addon-api": { + "version": "8.9.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.9.2.tgz", + "integrity": "sha512-VijLXbi3UACN69I0JVXJsX4tjACjNoQDgv2gTF6sx2wWEi8tkSg2eX8p5gSIFi8z2+DL3oHmY6OyKce38SDolg==", "license": "MIT", - "dependencies": { - "semver": "^7.3.5" - }, "engines": { - "node": ">=10" + "node": "^18 || ^20 || >= 21" } }, "node_modules/node-html-parser": { @@ -3286,15 +3239,6 @@ "node": ">= 0.4" } }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "license": "ISC", - "dependencies": { - "wrappy": "1" - } - }, "node_modules/onnxruntime-common": { "version": "1.24.3", "resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.24.3.tgz", @@ -3420,33 +3364,6 @@ "url": "https://opencollective.com/preact" } }, - "node_modules/prebuild-install": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz", - "integrity": "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==", - "deprecated": "No longer maintained. Please contact the author of the relevant native addon; alternatives are available.", - "license": "MIT", - "dependencies": { - "detect-libc": "^2.0.0", - "expand-template": "^2.0.3", - "github-from-package": "0.0.0", - "minimist": "^1.2.3", - "mkdirp-classic": "^0.5.3", - "napi-build-utils": "^2.0.0", - "node-abi": "^3.3.0", - "pump": "^3.0.0", - "rc": "^1.2.7", - "simple-get": "^4.0.0", - "tar-fs": "^2.0.0", - "tunnel-agent": "^0.6.0" - }, - "bin": { - "prebuild-install": "bin.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/protobufjs": { "version": "7.6.5", "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.6.5.tgz", @@ -3470,45 +3387,6 @@ "node": ">=12.0.0" } }, - "node_modules/pump": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz", - "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==", - "license": "MIT", - "dependencies": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "node_modules/rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "license": "(BSD-2-Clause OR MIT OR Apache-2.0)", - "dependencies": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "bin": { - "rc": "cli.js" - } - }, - "node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "license": "MIT", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/resolve-pkg-maps": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", @@ -3580,26 +3458,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/semver": { "version": "7.7.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", @@ -3694,51 +3552,6 @@ "kolorist": "^1.6.0" } }, - "node_modules/simple-concat": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", - "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/simple-get": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", - "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "decompress-response": "^6.0.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" - } - }, "node_modules/source-map": { "version": "0.7.6", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz", @@ -3789,58 +3602,6 @@ "dev": true, "license": "MIT" }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "license": "MIT", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, - "node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/tar-fs": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", - "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", - "license": "MIT", - "dependencies": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.1.4" - } - }, - "node_modules/tar-fs/node_modules/chownr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", - "license": "ISC" - }, - "node_modules/tar-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "license": "MIT", - "dependencies": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", @@ -3911,18 +3672,6 @@ "fsevents": "~2.3.3" } }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "license": "Apache-2.0", - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, "node_modules/type-fest": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", @@ -3986,12 +3735,6 @@ "browserslist": ">= 4.21.0" } }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "license": "MIT" - }, "node_modules/uuid": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", @@ -4619,12 +4362,6 @@ "node": ">=8" } }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "license": "ISC" - }, "node_modules/yaml": { "version": "2.8.3", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz", @@ -4646,6 +4383,16 @@ "integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==", "dev": true, "license": "MIT" + }, + "node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/apps/memos-local-plugin/package.json b/apps/memos-local-plugin/package.json index d9d5e3099..7e6366228 100644 --- a/apps/memos-local-plugin/package.json +++ b/apps/memos-local-plugin/package.json @@ -39,6 +39,7 @@ "templates/README.user.md", "viewer/dist", "scripts/postinstall.cjs", + "scripts/migrate-dsh-preset-profile.mjs", "scripts/sync-hermes-version.cjs", "install.sh", "install.ps1", @@ -51,7 +52,9 @@ "!**/.gitkeep", "!**/*.map", "!dist/tests", - "!dist/tests/**" + "!dist/tests/**", + "scripts/normalize-sqlite-lock.cjs", + "scripts/verify-native-runtime.cjs" ], "scripts": { "build": "tsc -p tsconfig.build.json && node scripts/copy-runtime-assets.cjs", @@ -60,7 +63,7 @@ "prepack": "npm run check:hermes-version && npm run build:package", "sync:hermes-version": "node scripts/sync-hermes-version.cjs", "check:hermes-version": "node scripts/sync-hermes-version.cjs --check", - "release:validate": "npm run check:hermes-version && npm run lint && npm test", + "release:validate": "npm run lock:check && npm run verify:script-policy && npm run check:hermes-version && npm run lint && npm test", "dev": "tsc -p tsconfig.json --watch", "viewer:dev": "vite --config vite.config.ts", "bridge": "tsx bridge.cts", @@ -71,7 +74,11 @@ "test:integration": "vitest run tests/integration", "test:e2e": "vitest run tests/e2e", "lint": "tsc -p tsconfig.json --noEmit", - "postinstall": "node scripts/postinstall.cjs" + "postinstall": "node scripts/postinstall.cjs", + "lock:normalize": "node scripts/normalize-sqlite-lock.cjs", + "lock:check": "node scripts/normalize-sqlite-lock.cjs --check", + "verify:native": "node scripts/verify-native-runtime.cjs", + "verify:script-policy": "node scripts/verify-script-policy.cjs" }, "keywords": [ "memory", @@ -86,13 +93,13 @@ ], "license": "MIT", "engines": { - "node": ">=20.0.0" + "node": ">=22.0.0" }, "dependencies": { "@huggingface/transformers": "4.2.0", "@preact/signals": "^2.9.0", "@sinclair/typebox": "^0.34.48", - "better-sqlite3": "^12.10.0", + "better-sqlite3": "13.0.3", "preact": "^10.29.1", "tsx": "^4.21.0", "uuid": "^10.0.0", @@ -135,13 +142,16 @@ } }, "devDependencies": { - "@deepseek-ai/cordis": "^4.0.1", + "@deepseek-ai/cordis": "~4.0.4", "@deepseek-ai/dsh-agent": "0.1.0-rc.6", + "@deepseek-ai/dsh-brand": "0.1.0-rc.6", "@deepseek-ai/dsh-llm": "0.1.0-rc.6", "@deepseek-ai/dsh-session": "0.1.0-rc.6", + "@deepseek-ai/dsh-session-format-v3-to-v4": "0.2.0-rc.2", "@deepseek-ai/dsh-system-prompt": "0.1.0-rc.6", "@deepseek-ai/dsh-timeout": "0.1.0-rc.6", "@deepseek-ai/dsh-tools": "0.1.0-rc.6", + "@deepseek-ai/dsh-typert-protocol": "0.1.0-rc.6", "@deepseek-ai/schemastery": "^3.18.1", "@preact/preset-vite": "^2.10.5", "@types/better-sqlite3": "^7.6.12", @@ -150,5 +160,14 @@ "typescript": "^5.7.0", "vite": "^5.4.10", "vitest": "^2.1.9" + }, + "allowScripts": { + "better-sqlite3": false, + "esbuild@0.27.7": true, + "esbuild@0.21.5": true, + "sharp@0.34.5": true, + "onnxruntime-node": false, + "protobufjs": false, + "fsevents": false } } diff --git a/apps/memos-local-plugin/pnpm-lock.yaml b/apps/memos-local-plugin/pnpm-lock.yaml index 6e94638a6..5116f3c47 100644 --- a/apps/memos-local-plugin/pnpm-lock.yaml +++ b/apps/memos-local-plugin/pnpm-lock.yaml @@ -18,8 +18,8 @@ importers: specifier: ^0.34.48 version: 0.34.49 better-sqlite3: - specifier: ^12.10.0 - version: 12.11.1 + specifier: 13.0.3 + version: 13.0.3 preact: specifier: ^10.29.1 version: 10.29.1 @@ -34,32 +34,41 @@ importers: version: 2.8.3 devDependencies: '@deepseek-ai/cordis': - specifier: ^4.0.1 - version: 4.0.1 + specifier: ~4.0.4 + version: 4.0.5 '@deepseek-ai/dsh-agent': specifier: 0.1.0-rc.6 - version: 0.1.0-rc.6(b0514d7a320728b6d8f5a31eb3960e10) + version: 0.1.0-rc.6(6889e29676788162cc6455c880e3b4a2) + '@deepseek-ai/dsh-brand': + specifier: 0.1.0-rc.6 + version: 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) '@deepseek-ai/dsh-llm': specifier: 0.1.0-rc.6 - version: 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))) + version: 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))) '@deepseek-ai/dsh-session': specifier: 0.1.0-rc.6 - version: 0.1.0-rc.6(6fd26f59436a18b115f326d6060415e6) + version: 0.1.0-rc.6(f5e28831e96e72c33b5ea3a797f6fddf) + '@deepseek-ai/dsh-session-format-v3-to-v4': + specifier: 0.2.0-rc.2 + version: 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) '@deepseek-ai/dsh-system-prompt': specifier: 0.1.0-rc.6 - version: 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))))(@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))) + version: 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))))(@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))) '@deepseek-ai/dsh-timeout': specifier: 0.1.0-rc.6 - version: 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) + version: 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) '@deepseek-ai/dsh-tools': specifier: 0.1.0-rc.6 - version: 0.1.0-rc.6(f8724372086ccc1457fc84e7becee2e0) + version: 0.1.0-rc.6(14b150c73c93dfea9f66b8be648ac0d7) + '@deepseek-ai/dsh-typert-protocol': + specifier: 0.1.0-rc.6 + version: 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) '@deepseek-ai/schemastery': specifier: ^3.18.1 - version: 3.18.1 + version: 3.18.5 '@preact/preset-vite': specifier: ^2.10.5 - version: 2.10.5(@babel/core@7.29.0)(preact@10.29.1)(rollup@4.60.2)(vite@5.4.21(@types/node@22.19.17)) + version: 2.10.5(@babel/core@7.29.0)(preact@10.29.1)(rollup@4.60.1)(vite@5.4.21(@types/node@22.19.17)) '@types/better-sqlite3': specifier: ^7.6.12 version: 7.6.13 @@ -174,20 +183,20 @@ packages: resolution: {integrity: sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==} engines: {node: '>=6.9.0'} - '@deepseek-ai/cordis@4.0.1': - resolution: {integrity: sha512-YBdskTU2Po1kru3GgcUWUbkTsPMA9LkSQDAY8rBkFJeajdgcQad3QPJZE26JyK99Xb6HaASvoXg2DSUTeN/0Nw==} + '@deepseek-ai/cordis@4.0.5': + resolution: {integrity: sha512-Sktq5axy0owk9PdnivBRNOJjHEVEibCt0+TDDZcv0+UH2KS1M910fX4kn5y45YFsrpZIi1mJf/1s5VzywMUnyg==} hasBin: true peerDependencies: - '@deepseek-ai/cordis-plugin-include': ^1.0.6 - '@deepseek-ai/cordis-plugin-loader': ^1.0.2 + '@deepseek-ai/cordis-plugin-include': ~1.0.10 + '@deepseek-ai/cordis-plugin-loader': ~1.0.6 peerDependenciesMeta: '@deepseek-ai/cordis-plugin-include': optional: true '@deepseek-ai/cordis-plugin-loader': optional: true - '@deepseek-ai/cosmokit@1.8.2': - resolution: {integrity: sha512-muBOKtSrUKU5m/xpq8ZXWL6hQ/jgd4PhU2PqH97bcxIiLEJfNwZOGQEx4t/aS/GgxRAR+ra9pMHPMtTHU4sqqA==} + '@deepseek-ai/cosmokit@1.8.6': + resolution: {integrity: sha512-ZSD/fN52L498LBIOYwjIOlaLv5veY6ZEwI2yzvZUKQtctn0QAPqu8tKdJ+OF5+Tv6NBq1U+wJWH+QI6OGy5EvQ==} '@deepseek-ai/dsh-agent@0.1.0-rc.6': resolution: {integrity: sha512-vtqq2pWTrzn0dKfj5kREZRpP82AwtGjGx9V1lYnKvF+Uc/a8zyWbSvjDE7V1d3YQAQJzs2cWO31hURWDekDXIA==} @@ -213,6 +222,11 @@ packages: '@deepseek-ai/cordis': ^4.0.1 '@deepseek-ai/dsh-invariants': ^0.1.0-rc.6 + '@deepseek-ai/dsh-brand@0.2.0-rc.2': + resolution: {integrity: sha512-A5XlN4tIgP0qObkYFhcZ7Oz/tM2oESEZqLwS0Qq+sM1ivGx6o4AMPgJdfKQlwLzqk0cMLNtAaVBHfiYoElt4lw==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + '@deepseek-ai/dsh-code-runtime@0.1.0-rc.6': resolution: {integrity: sha512-aw8D4IOeMo11A3uxQeE4LFoW3bvaQnVkGFqqtS+lsINDARrOCJHXLUgecoKpys+Lc5erZZ4UQDnymJmL4OCcKA==} peerDependencies: @@ -233,12 +247,42 @@ packages: '@deepseek-ai/dsh-invariants': ^0.1.0-rc.6 '@deepseek-ai/dsh-timeout': ^0.1.0-rc.6 + '@deepseek-ai/dsh-llm@0.2.0-rc.2': + resolution: {integrity: sha512-6QFrQn/h0iNqCfPpgQidnHtLSpA99A7ZND/uYKaGSd/4BGP8KBhuRd0w63e9s4u+hfW8jc3j29WKcNLIOeUfcA==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + '@deepseek-ai/dsh-scope@0.1.0-rc.6': resolution: {integrity: sha512-UlDLV4syLoJinNg9imhXrSAHrdaTa5Ff8gg46rzjFJGPUOhAk3DZff0hryT5OhrBi0A5Tj92qVpg2pRVvxnUzQ==} peerDependencies: '@deepseek-ai/cordis': ^4.0.1 '@deepseek-ai/dsh-invariants': ^0.1.0-rc.6 + '@deepseek-ai/dsh-session-format-v0-to-v1@0.2.0-rc.2': + resolution: {integrity: sha512-PPcfT7txn82/sZnFNxsuxEEUSSdEfBTkNTuOCaiu5ANDMmxUaxOOW6gXt+zBKndGJZRgCR/u9SoAdKv659FSZQ==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + + '@deepseek-ai/dsh-session-format-v1-to-v2@0.2.0-rc.2': + resolution: {integrity: sha512-PBIsz4OBE0wNnapaD87lz6255em24Kn53BKV4K1AqiNH9OWf1+m29TLXs/ICtZ2xigk6TK5H9q6oOVBBmbZyVw==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + + '@deepseek-ai/dsh-session-format-v2-to-v3@0.2.0-rc.2': + resolution: {integrity: sha512-vrQQ1l3JgPIv/19mhm50FVD40hjro+tAkP3L1PNtGHrbBoYriNWXpR4QDOCQsHdPhg3vpnp9MmARMr8vZzl0Nw==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + + '@deepseek-ai/dsh-session-format-v3-to-v4@0.2.0-rc.2': + resolution: {integrity: sha512-UkiNDdGS8cwJKqjvHs52BKi+3NuKhoziz/l0IrDoDYpSdgDfK8HrrXkvIxOi+QaBUgIxNTQzA6tsI+TAIMDsGQ==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + + '@deepseek-ai/dsh-session-format@0.2.0-rc.2': + resolution: {integrity: sha512-qdWtsJt1cLJbUAMCgzRBZ2LyW+XRJpetnle4N/0X/pkmJ9eOM6Y+QqwRQdcEcI4pWuEbPwuq7/HrnqoanVaiwg==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + '@deepseek-ai/dsh-session@0.1.0-rc.6': resolution: {integrity: sha512-8tu8I6VWC7050GAUXWhcEWQw4pakALQc8TlhKr52m7Y4+kIKeNt3FBgP86PaGPBtpK0p5zUPRQNkFpzZbBdxyw==} peerDependencies: @@ -263,6 +307,11 @@ packages: '@deepseek-ai/cordis': ^4.0.1 '@deepseek-ai/dsh-invariants': ^0.1.0-rc.6 + '@deepseek-ai/dsh-timeout@0.2.0-rc.2': + resolution: {integrity: sha512-NDob8b8DJDB/sDPz3P7xhrkxOh1O9FbN1EZRKsxP4fuTfp4hrQU7aekYS5qZENFKoR8dBJMTh/zcEBw4m31glQ==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + '@deepseek-ai/dsh-tools@0.1.0-rc.6': resolution: {integrity: sha512-Tu08EPK3JyK0iNjH4FGzu/1uADynNSS6SmwOLdfytUN0YNqwNuKFSt2OJUg19famNlTgy992DcHfDu0T+gLXFg==} peerDependencies: @@ -282,6 +331,11 @@ packages: '@deepseek-ai/cordis': ^4.0.1 '@deepseek-ai/dsh-invariants': ^0.1.0-rc.6 + '@deepseek-ai/dsh-typert-protocol@0.2.0-rc.2': + resolution: {integrity: sha512-95RvIDcVac2BWdv1IxN6yKlRV+8eEvkofqSxV+d0r8x1kx2EIWEsbdxz6C+coYIm+8e03MiN+rwOt8J7sLfe7Q==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + '@deepseek-ai/dsh-user-approval@0.1.0-rc.6': resolution: {integrity: sha512-9rnkSDGOpu2XUeGwbPeTzVUTFWTND1PMPM5L/ZQPptV5yyZlQiNxM2rCC6OdL+ZVerwxEqrRhZIQn/KVtQfKag==} peerDependencies: @@ -294,8 +348,18 @@ packages: '@deepseek-ai/dsh-session': ^0.1.0-rc.6 '@deepseek-ai/dsh-system-prompt': ^0.1.0-rc.6 - '@deepseek-ai/schemastery@3.18.1': - resolution: {integrity: sha512-Qn0FCSwCQnpnj6SB31I6i2sIKgKWnkbJM8O0EU91Gv2UsYVvtZTl6IA0sCwk2e2MZf5S8w5hpq9QkeVvK9qwxg==} + '@deepseek-ai/dsh-util-crypto@0.2.0-rc.2': + resolution: {integrity: sha512-5OvvmepY69uXTagUMlnoHqg7euI4ZMifLgfdV8xZO20OslWGGiRCkJbZRyDtcJG9GsXWz9UimfWmUu52zKXJ5w==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + + '@deepseek-ai/dsh-util-values@0.2.0-rc.2': + resolution: {integrity: sha512-qgpsbgiZABuE9UvgNaVo9b2HiWwLeU93CTl9PFXqE0jN8ap1ALxzQsLGvr/q2MJuWDYqnFBg60XnqnY8ZxPWEg==} + peerDependencies: + '@deepseek-ai/cordis': ~4.0.4 + + '@deepseek-ai/schemastery@3.18.5': + resolution: {integrity: sha512-Mnobvqf9rHsZYv4g5edj5ddxS1oF1kIdSlz0DunUgnY3LWG5F26MqvH3YOOsSaodCgyzJ16OMN9O99/s5Crtdw==} '@emnapi/runtime@1.10.0': resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==} @@ -810,29 +874,26 @@ packages: '@protobufjs/base64@1.1.2': resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==} - '@protobufjs/codegen@2.0.4': - resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==} + '@protobufjs/codegen@2.0.5': + resolution: {integrity: sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g==} - '@protobufjs/eventemitter@1.1.0': - resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==} + '@protobufjs/eventemitter@1.1.1': + resolution: {integrity: sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg==} - '@protobufjs/fetch@1.1.0': - resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==} + '@protobufjs/fetch@1.1.1': + resolution: {integrity: sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw==} '@protobufjs/float@1.0.2': resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==} - '@protobufjs/inquire@1.1.0': - resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==} - '@protobufjs/path@1.1.2': resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==} '@protobufjs/pool@1.1.0': resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==} - '@protobufjs/utf8@1.1.0': - resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} + '@protobufjs/utf8@1.1.2': + resolution: {integrity: sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==} '@rollup/pluginutils@4.2.1': resolution: {integrity: sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==} @@ -847,141 +908,141 @@ packages: rollup: optional: true - '@rollup/rollup-android-arm-eabi@4.60.2': - resolution: {integrity: sha512-dnlp69efPPg6Uaw2dVqzWRfAWRnYVb1XJ8CyyhIbZeaq4CA5/mLeZ1IEt9QqQxmbdvagjLIm2ZL8BxXv5lH4Yw==} + '@rollup/rollup-android-arm-eabi@4.60.1': + resolution: {integrity: sha512-d6FinEBLdIiK+1uACUttJKfgZREXrF0Qc2SmLII7W2AD8FfiZ9Wjd+rD/iRuf5s5dWrr1GgwXCvPqOuDquOowA==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.60.2': - resolution: {integrity: sha512-OqZTwDRDchGRHHm/hwLOL7uVPB9aUvI0am/eQuWMNyFHf5PSEQmyEeYYheA0EPPKUO/l0uigCp+iaTjoLjVoHg==} + '@rollup/rollup-android-arm64@4.60.1': + resolution: {integrity: sha512-YjG/EwIDvvYI1YvYbHvDz/BYHtkY4ygUIXHnTdLhG+hKIQFBiosfWiACWortsKPKU/+dUwQQCKQM3qrDe8c9BA==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.60.2': - resolution: {integrity: sha512-UwRE7CGpvSVEQS8gUMBe1uADWjNnVgP3Iusyda1nSRwNDCsRjnGc7w6El6WLQsXmZTbLZx9cecegumcitNfpmA==} + '@rollup/rollup-darwin-arm64@4.60.1': + resolution: {integrity: sha512-mjCpF7GmkRtSJwon+Rq1N8+pI+8l7w5g9Z3vWj4T7abguC4Czwi3Yu/pFaLvA3TTeMVjnu3ctigusqWUfjZzvw==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.60.2': - resolution: {integrity: sha512-gjEtURKLCC5VXm1I+2i1u9OhxFsKAQJKTVB8WvDAHF+oZlq0GTVFOlTlO1q3AlCTE/DF32c16ESvfgqR7343/g==} + '@rollup/rollup-darwin-x64@4.60.1': + resolution: {integrity: sha512-haZ7hJ1JT4e9hqkoT9R/19XW2QKqjfJVv+i5AGg57S+nLk9lQnJ1F/eZloRO3o9Scy9CM3wQ9l+dkXtcBgN5Ew==} cpu: [x64] os: [darwin] - '@rollup/rollup-freebsd-arm64@4.60.2': - resolution: {integrity: sha512-Bcl6CYDeAgE70cqZaMojOi/eK63h5Me97ZqAQoh77VPjMysA/4ORQBRGo3rRy45x4MzVlU9uZxs8Uwy7ZaKnBw==} + '@rollup/rollup-freebsd-arm64@4.60.1': + resolution: {integrity: sha512-czw90wpQq3ZsAVBlinZjAYTKduOjTywlG7fEeWKUA7oCmpA8xdTkxZZlwNJKWqILlq0wehoZcJYfBvOyhPTQ6w==} cpu: [arm64] os: [freebsd] - '@rollup/rollup-freebsd-x64@4.60.2': - resolution: {integrity: sha512-LU+TPda3mAE2QB0/Hp5VyeKJivpC6+tlOXd1VMoXV/YFMvk/MNk5iXeBfB4MQGRWyOYVJ01625vjkr0Az98OJQ==} + '@rollup/rollup-freebsd-x64@4.60.1': + resolution: {integrity: sha512-KVB2rqsxTHuBtfOeySEyzEOB7ltlB/ux38iu2rBQzkjbwRVlkhAGIEDiiYnO2kFOkJp+Z7pUXKyrRRFuFUKt+g==} cpu: [x64] os: [freebsd] - '@rollup/rollup-linux-arm-gnueabihf@4.60.2': - resolution: {integrity: sha512-2QxQrM+KQ7DAW4o22j+XZ6RKdxjLD7BOWTP0Bv0tmjdyhXSsr2Ul1oJDQqh9Zf5qOwTuTc7Ek83mOFaKnodPjg==} + '@rollup/rollup-linux-arm-gnueabihf@4.60.1': + resolution: {integrity: sha512-L+34Qqil+v5uC0zEubW7uByo78WOCIrBvci69E7sFASRl0X7b/MB6Cqd1lky/CtcSVTydWa2WZwFuWexjS5o6g==} cpu: [arm] os: [linux] libc: [glibc] - '@rollup/rollup-linux-arm-musleabihf@4.60.2': - resolution: {integrity: sha512-TbziEu2DVsTEOPif2mKWkMeDMLoYjx95oESa9fkQQK7r/Orta0gnkcDpzwufEcAO2BLBsD7mZkXGFqEdMRRwfw==} + '@rollup/rollup-linux-arm-musleabihf@4.60.1': + resolution: {integrity: sha512-n83O8rt4v34hgFzlkb1ycniJh7IR5RCIqt6mz1VRJD6pmhRi0CXdmfnLu9dIUS6buzh60IvACM842Ffb3xd6Gg==} cpu: [arm] os: [linux] libc: [musl] - '@rollup/rollup-linux-arm64-gnu@4.60.2': - resolution: {integrity: sha512-bO/rVDiDUuM2YfuCUwZ1t1cP+/yqjqz+Xf2VtkdppefuOFS2OSeAfgafaHNkFn0t02hEyXngZkxtGqXcXwO8Rg==} + '@rollup/rollup-linux-arm64-gnu@4.60.1': + resolution: {integrity: sha512-Nql7sTeAzhTAja3QXeAI48+/+GjBJ+QmAH13snn0AJSNL50JsDqotyudHyMbO2RbJkskbMbFJfIJKWA6R1LCJQ==} cpu: [arm64] os: [linux] libc: [glibc] - '@rollup/rollup-linux-arm64-musl@4.60.2': - resolution: {integrity: sha512-hr26p7e93Rl0Za+JwW7EAnwAvKkehh12BU1Llm9Ykiibg4uIr2rbpxG9WCf56GuvidlTG9KiiQT/TXT1yAWxTA==} + '@rollup/rollup-linux-arm64-musl@4.60.1': + resolution: {integrity: sha512-+pUymDhd0ys9GcKZPPWlFiZ67sTWV5UU6zOJat02M1+PiuSGDziyRuI/pPue3hoUwm2uGfxdL+trT6Z9rxnlMA==} cpu: [arm64] os: [linux] libc: [musl] - '@rollup/rollup-linux-loong64-gnu@4.60.2': - resolution: {integrity: sha512-pOjB/uSIyDt+ow3k/RcLvUAOGpysT2phDn7TTUB3n75SlIgZzM6NKAqlErPhoFU+npgY3/n+2HYIQVbF70P9/A==} + '@rollup/rollup-linux-loong64-gnu@4.60.1': + resolution: {integrity: sha512-VSvgvQeIcsEvY4bKDHEDWcpW4Yw7BtlKG1GUT4FzBUlEKQK0rWHYBqQt6Fm2taXS+1bXvJT6kICu5ZwqKCnvlQ==} cpu: [loong64] os: [linux] libc: [glibc] - '@rollup/rollup-linux-loong64-musl@4.60.2': - resolution: {integrity: sha512-2/w+q8jszv9Ww1c+6uJT3OwqhdmGP2/4T17cu8WuwyUuuaCDDJ2ojdyYwZzCxx0GcsZBhzi3HmH+J5pZNXnd+Q==} + '@rollup/rollup-linux-loong64-musl@4.60.1': + resolution: {integrity: sha512-4LqhUomJqwe641gsPp6xLfhqWMbQV04KtPp7/dIp0nzPxAkNY1AbwL5W0MQpcalLYk07vaW9Kp1PBhdpZYYcEw==} cpu: [loong64] os: [linux] libc: [musl] - '@rollup/rollup-linux-ppc64-gnu@4.60.2': - resolution: {integrity: sha512-11+aL5vKheYgczxtPVVRhdptAM2H7fcDR5Gw4/bTcteuZBlH4oP9f5s9zYO9aGZvoGeBpqXI/9TZZihZ609wKw==} + '@rollup/rollup-linux-ppc64-gnu@4.60.1': + resolution: {integrity: sha512-tLQQ9aPvkBxOc/EUT6j3pyeMD6Hb8QF2BTBnCQWP/uu1lhc9AIrIjKnLYMEroIz/JvtGYgI9dF3AxHZNaEH0rw==} cpu: [ppc64] os: [linux] libc: [glibc] - '@rollup/rollup-linux-ppc64-musl@4.60.2': - resolution: {integrity: sha512-i16fokAGK46IVZuV8LIIwMdtqhin9hfYkCh8pf8iC3QU3LpwL+1FSFGej+O7l3E/AoknL6Dclh2oTdnRMpTzFQ==} + '@rollup/rollup-linux-ppc64-musl@4.60.1': + resolution: {integrity: sha512-RMxFhJwc9fSXP6PqmAz4cbv3kAyvD1etJFjTx4ONqFP9DkTkXsAMU4v3Vyc5BgzC+anz7nS/9tp4obsKfqkDHg==} cpu: [ppc64] os: [linux] libc: [musl] - '@rollup/rollup-linux-riscv64-gnu@4.60.2': - resolution: {integrity: sha512-49FkKS6RGQoriDSK/6E2GkAsAuU5kETFCh7pG4yD/ylj9rKhTmO3elsnmBvRD4PgJPds5W2PkhC82aVwmUcJ7A==} + '@rollup/rollup-linux-riscv64-gnu@4.60.1': + resolution: {integrity: sha512-QKgFl+Yc1eEk6MmOBfRHYF6lTxiiiV3/z/BRrbSiW2I7AFTXoBFvdMEyglohPj//2mZS4hDOqeB0H1ACh3sBbg==} cpu: [riscv64] os: [linux] libc: [glibc] - '@rollup/rollup-linux-riscv64-musl@4.60.2': - resolution: {integrity: sha512-mjYNkHPfGpUR00DuM1ZZIgs64Hpf4bWcz9Z41+4Q+pgDx73UwWdAYyf6EG/lRFldmdHHzgrYyge5akFUW0D3mQ==} + '@rollup/rollup-linux-riscv64-musl@4.60.1': + resolution: {integrity: sha512-RAjXjP/8c6ZtzatZcA1RaQr6O1TRhzC+adn8YZDnChliZHviqIjmvFwHcxi4JKPSDAt6Uhf/7vqcBzQJy0PDJg==} cpu: [riscv64] os: [linux] libc: [musl] - '@rollup/rollup-linux-s390x-gnu@4.60.2': - resolution: {integrity: sha512-ALyvJz965BQk8E9Al/JDKKDLH2kfKFLTGMlgkAbbYtZuJt9LU8DW3ZoDMCtQpXAltZxwBHevXz5u+gf0yA0YoA==} + '@rollup/rollup-linux-s390x-gnu@4.60.1': + resolution: {integrity: sha512-wcuocpaOlaL1COBYiA89O6yfjlp3RwKDeTIA0hM7OpmhR1Bjo9j31G1uQVpDlTvwxGn2nQs65fBFL5UFd76FcQ==} cpu: [s390x] os: [linux] libc: [glibc] - '@rollup/rollup-linux-x64-gnu@4.60.2': - resolution: {integrity: sha512-UQjrkIdWrKI626Du8lCQ6MJp/6V1LAo2bOK9OTu4mSn8GGXIkPXk/Vsp4bLHCd9Z9Iz2OTEaokUE90VweJgIYQ==} + '@rollup/rollup-linux-x64-gnu@4.60.1': + resolution: {integrity: sha512-77PpsFQUCOiZR9+LQEFg9GClyfkNXj1MP6wRnzYs0EeWbPcHs02AXu4xuUbM1zhwn3wqaizle3AEYg5aeoohhg==} cpu: [x64] os: [linux] libc: [glibc] - '@rollup/rollup-linux-x64-musl@4.60.2': - resolution: {integrity: sha512-bTsRGj6VlSdn/XD4CGyzMnzaBs9bsRxy79eTqTCBsA8TMIEky7qg48aPkvJvFe1HyzQ5oMZdg7AnVlWQSKLTnw==} + '@rollup/rollup-linux-x64-musl@4.60.1': + resolution: {integrity: sha512-5cIATbk5vynAjqqmyBjlciMJl1+R/CwX9oLk/EyiFXDWd95KpHdrOJT//rnUl4cUcskrd0jCCw3wpZnhIHdD9w==} cpu: [x64] os: [linux] libc: [musl] - '@rollup/rollup-openbsd-x64@4.60.2': - resolution: {integrity: sha512-6d4Z3534xitaA1FcMWP7mQPq5zGwBmGbhphh2DwaA1aNIXUu3KTOfwrWpbwI4/Gr0uANo7NTtaykFyO2hPuFLg==} + '@rollup/rollup-openbsd-x64@4.60.1': + resolution: {integrity: sha512-cl0w09WsCi17mcmWqqglez9Gk8isgeWvoUZ3WiJFYSR3zjBQc2J5/ihSjpl+VLjPqjQ/1hJRcqBfLjssREQILw==} cpu: [x64] os: [openbsd] - '@rollup/rollup-openharmony-arm64@4.60.2': - resolution: {integrity: sha512-NetAg5iO2uN7eB8zE5qrZ3CSil+7IJt4WDFLcC75Ymywq1VZVD6qJ6EvNLjZ3rEm6gB7XW5JdT60c6MN35Z85Q==} + '@rollup/rollup-openharmony-arm64@4.60.1': + resolution: {integrity: sha512-4Cv23ZrONRbNtbZa37mLSueXUCtN7MXccChtKpUnQNgF010rjrjfHx3QxkS2PI7LqGT5xXyYs1a7LbzAwT0iCA==} cpu: [arm64] os: [openharmony] - '@rollup/rollup-win32-arm64-msvc@4.60.2': - resolution: {integrity: sha512-NCYhOotpgWZ5kdxCZsv6Iudx0wX8980Q/oW4pNFNihpBKsDbEA1zpkfxJGC0yugsUuyDZ7gL37dbzwhR0VI7pQ==} + '@rollup/rollup-win32-arm64-msvc@4.60.1': + resolution: {integrity: sha512-i1okWYkA4FJICtr7KpYzFpRTHgy5jdDbZiWfvny21iIKky5YExiDXP+zbXzm3dUcFpkEeYNHgQ5fuG236JPq0g==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.60.2': - resolution: {integrity: sha512-RXsaOqXxfoUBQoOgvmmijVxJnW2IGB0eoMO7F8FAjaj0UTywUO/luSqimWBJn04WNgUkeNhh7fs7pESXajWmkg==} + '@rollup/rollup-win32-ia32-msvc@4.60.1': + resolution: {integrity: sha512-u09m3CuwLzShA0EYKMNiFgcjjzwqtUMLmuCJLeZWjjOYA3IT2Di09KaxGBTP9xVztWyIWjVdsB2E9goMjZvTQg==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-gnu@4.60.2': - resolution: {integrity: sha512-qdAzEULD+/hzObedtmV6iBpdL5TIbKVztGiK7O3/KYSf+HIzU257+MX1EXJcyIiDbMAqmbwaufcYPvyRryeZtA==} + '@rollup/rollup-win32-x64-gnu@4.60.1': + resolution: {integrity: sha512-k+600V9Zl1CM7eZxJgMyTUzmrmhB/0XZnF4pRypKAlAgxmedUA+1v9R+XOFv56W4SlHEzfeMtzujLJD22Uz5zg==} cpu: [x64] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.60.2': - resolution: {integrity: sha512-Nd/SgG27WoA9e+/TdK74KnHz852TLa94ovOYySo/yMPuTmpckK/jIF2jSwS3g7ELSKXK13/cVdmg1Z/DaCWKxA==} + '@rollup/rollup-win32-x64-msvc@4.60.1': + resolution: {integrity: sha512-lWMnixq/QzxyhTV6NjQJ4SFo1J6PvOX8vUx5Wb4bBPsEb+8xZ89Bz6kOXpfXj9ak9AHTQVQzlgzBEc1SyM27xQ==} cpu: [x64] os: [win32] @@ -1045,23 +1106,14 @@ packages: peerDependencies: '@babel/core': ^7.12.10 - base64-js@1.5.1: - resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - - baseline-browser-mapping@2.10.20: - resolution: {integrity: sha512-1AaXxEPfXT+GvTBJFuy4yXVHWJBXa4OdbIebGN/wX5DlsIkU0+wzGnd2lOzokSk51d5LUmqjgBLRLlypLUqInQ==} + baseline-browser-mapping@2.10.19: + resolution: {integrity: sha512-qCkNLi2sfBOn8XhZQ0FXsT1Ki/Yo5P90hrkRamVFRS7/KV9hpfA4HkoWNU152+8w0zPjnxo5psx5NL3PSGgv5g==} engines: {node: '>=6.0.0'} hasBin: true - better-sqlite3@12.11.1: - resolution: {integrity: sha512-dq9AtApgg5PGFtBzPFSBl3HZQjHok5gaQCM6zh2Yk0aSmDCs1CbnVI8/HgASQkNKsWFpseIO9beg5xxpYhbIfA==} - engines: {node: 20.x || 22.x || 23.x || 24.x || 25.x || 26.x} - - bindings@1.5.0: - resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} - - bl@4.1.0: - resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} + better-sqlite3@13.0.3: + resolution: {integrity: sha512-RbOBxmLBG8uvFUc15X9+9SFemKcQ0WBuISBVkpuiaUB2qblC8UWlHEjdWVoZ8AdhSwmoEgsiXKfopX0CQxaACQ==} + engines: {node: '>=22'} boolbase@1.0.0: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} @@ -1075,9 +1127,6 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true - buffer@5.7.1: - resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} - cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} @@ -1093,9 +1142,6 @@ packages: resolution: {integrity: sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==} engines: {node: '>= 16'} - chownr@1.1.4: - resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} - convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} @@ -1115,18 +1161,10 @@ packages: supports-color: optional: true - decompress-response@6.0.0: - resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==} - engines: {node: '>=10'} - deep-eql@5.0.2: resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} engines: {node: '>=6'} - deep-extend@0.6.0: - resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} - engines: {node: '>=4.0.0'} - define-data-property@1.1.4: resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} engines: {node: '>= 0.4'} @@ -1155,11 +1193,8 @@ packages: domutils@3.2.2: resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==} - electron-to-chromium@1.5.343: - resolution: {integrity: sha512-YHnQ3MXI08icvL9ZKnEBy05F2EQ8ob01UaMOuMbM8l+4UcAq6MPPbBTJBbsBUg3H8JeZNt+O4fjsoWth3p6IFg==} - - end-of-stream@1.4.5: - resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==} + electron-to-chromium@1.5.340: + resolution: {integrity: sha512-908qahOGocRMinT2nM3ajCEM99H4iPdv84eagPP3FfZy/1ZGeOy2CZYzjhms81ckOPCXPlW7LkY4XpxD8r1DrA==} entities@4.5.0: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} @@ -1203,23 +1238,13 @@ packages: estree-walker@3.0.3: resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} - expand-template@2.0.3: - resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} - engines: {node: '>=6'} - expect-type@1.3.0: resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==} engines: {node: '>=12.0.0'} - file-uri-to-path@1.0.0: - resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} - flatbuffers@25.9.23: resolution: {integrity: sha512-MI1qs7Lo4Syw0EOzUl0xjs2lsoeqFku44KpngfIduHBYvzm8h2+7K8YMQh1JtVVVrUvhLpNwqVi4DERegUJhPQ==} - fs-constants@1.0.0: - resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} - fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -1232,9 +1257,6 @@ packages: get-tsconfig@4.14.0: resolution: {integrity: sha512-yTb+8DXzDREzgvYmh6s9vHsSVCHeC0G3PI5bEXNBHtmshPnO+S5O7qgLEOn0I5QvMy6kpZN8K1NKGyilLb93wA==} - github-from-package@0.0.0: - resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} - global-agent@3.0.0: resolution: {integrity: sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==} engines: {node: '>=10.0'} @@ -1257,15 +1279,6 @@ packages: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true - ieee754@1.2.1: - resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} - - inherits@2.0.4: - resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - - ini@1.3.8: - resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} - js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -1301,16 +1314,6 @@ packages: resolution: {integrity: sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==} engines: {node: '>=10'} - mimic-response@3.1.0: - resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} - engines: {node: '>=10'} - - minimist@1.2.8: - resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - - mkdirp-classic@0.5.3: - resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} - ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -1319,18 +1322,15 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - napi-build-utils@2.0.0: - resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==} - - node-abi@3.89.0: - resolution: {integrity: sha512-6u9UwL0HlAl21+agMN3YAMXcKByMqwGx+pq+P76vii5f7hTPtKDp08/H9py6DY+cfDw7kQNTGEj/rly3IgbNQA==} - engines: {node: '>=10'} + node-addon-api@8.9.2: + resolution: {integrity: sha512-VijLXbi3UACN69I0JVXJsX4tjACjNoQDgv2gTF6sx2wWEi8tkSg2eX8p5gSIFi8z2+DL3oHmY6OyKce38SDolg==} + engines: {node: ^18 || ^20 || >= 21} node-html-parser@6.1.13: resolution: {integrity: sha512-qIsTMOY4C/dAa5Q5vsobRpOOvPfC4pB61UVW2uSwZNUp0QU/jCekTal1vMmbO0DgdHeLUJpv/ARmDqErVxA3Sg==} - node-releases@2.0.38: - resolution: {integrity: sha512-3qT/88Y3FbH/Kx4szpQQ4HzUbVrHPKTLVpVocKiLfoYvw9XSGOX2FmD2d6DrXbVYyAQTF2HeF6My8jmzx7/CRw==} + node-releases@2.0.37: + resolution: {integrity: sha512-1h5gKZCF+pO/o3Iqt5Jp7wc9rH3eJJ0+nh/CIoiRwjRxde/hAHyLPXYN4V3CqKAbiZPSeJFSWHmJsbkicta0Eg==} nth-check@2.1.1: resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} @@ -1339,9 +1339,6 @@ packages: resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} engines: {node: '>= 0.4'} - once@1.4.0: - resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} - onnxruntime-common@1.24.0-dev.20251116-b39e144322: resolution: {integrity: sha512-BOoomdHYmNRL5r4iQ4bMvsl2t0/hzVQ3OM3PHD0gxeXu1PmggqBv3puZicEUVOA3AtHHYmqZtjMj9FOfGrATTw==} @@ -1383,27 +1380,10 @@ packages: preact@10.29.1: resolution: {integrity: sha512-gQCLc/vWroE8lIpleXtdJhTFDogTdZG9AjMUpVkDf2iTCNwYNWA+u16dL41TqUDJO4gm2IgrcMv3uTpjd4Pwmg==} - prebuild-install@7.1.3: - resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==} - engines: {node: '>=10'} - deprecated: No longer maintained. Please contact the author of the relevant native addon; alternatives are available. - hasBin: true - - protobufjs@7.5.5: - resolution: {integrity: sha512-3wY1AxV+VBNW8Yypfd1yQY9pXnqTAN+KwQxL8iYm3/BjKYMNg4i0owhEe26PWDOMaIrzeeF98Lqd5NGz4omiIg==} + protobufjs@7.6.5: + resolution: {integrity: sha512-/FPD0nUc9jH6rfFjji9IBqOz4pcSE3CsT1m7Ep6Mdb0LxSUMj8hgl6GomOvZzpNpAqqGaXA0P3VSrZLFzIhQrw==} engines: {node: '>=12.0.0'} - pump@3.0.4: - resolution: {integrity: sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==} - - rc@1.2.8: - resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} - hasBin: true - - readable-stream@3.6.2: - resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} - engines: {node: '>= 6'} - resolve-pkg-maps@1.0.0: resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} @@ -1411,14 +1391,11 @@ packages: resolution: {integrity: sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A==} engines: {node: '>=8.0'} - rollup@4.60.2: - resolution: {integrity: sha512-J9qZyW++QK/09NyN/zeO0dG/1GdGfyp9lV8ajHnRVLfo/uFsbji5mHnDgn/qYdUHyCkM2N+8VyspgZclfAh0eQ==} + rollup@4.60.1: + resolution: {integrity: sha512-VmtB2rFU/GroZ4oL8+ZqXgSA38O6GR8KSIvWmEFv63pQ0G6KaBH9s07PO8XTXP4vI+3UJUEypOfjkGfmSBBR0w==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true - safe-buffer@5.2.1: - resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - semver-compare@1.0.0: resolution: {integrity: sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==} @@ -1445,12 +1422,6 @@ packages: simple-code-frame@1.3.0: resolution: {integrity: sha512-MB4pQmETUBlNs62BBeRjIFGeuy/x6gGKh7+eRUemn1rCFhqo7K+4slPqsyizCbcbYLnaYqaoZ2FWsZ/jN06D8w==} - simple-concat@1.0.1: - resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==} - - simple-get@4.0.1: - resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==} - source-map-js@1.2.1: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} @@ -1472,20 +1443,6 @@ packages: std-env@3.10.0: resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==} - string_decoder@1.3.0: - resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} - - strip-json-comments@2.0.1: - resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==} - engines: {node: '>=0.10.0'} - - tar-fs@2.1.4: - resolution: {integrity: sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==} - - tar-stream@2.2.0: - resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} - engines: {node: '>=6'} - tinybench@2.9.0: resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} @@ -1512,9 +1469,6 @@ packages: engines: {node: '>=18.0.0'} hasBin: true - tunnel-agent@0.6.0: - resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} - type-fest@0.13.1: resolution: {integrity: sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==} engines: {node: '>=10'} @@ -1533,9 +1487,6 @@ packages: peerDependencies: browserslist: '>= 4.21.0' - util-deprecate@1.0.2: - resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} - uuid@10.0.0: resolution: {integrity: sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==} deprecated: uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028). @@ -1612,9 +1563,6 @@ packages: engines: {node: '>=8'} hasBin: true - wrappy@1.0.2: - resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} @@ -1626,6 +1574,9 @@ packages: zimmerframe@1.1.4: resolution: {integrity: sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==} + zod@4.6.7: + resolution: {integrity: sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==} + snapshots: '@babel/code-frame@7.29.0': @@ -1757,113 +1708,177 @@ snapshots: '@babel/helper-string-parser': 7.27.1 '@babel/helper-validator-identifier': 7.28.5 - '@deepseek-ai/cordis@4.0.1': + '@deepseek-ai/cordis@4.0.5': dependencies: - '@deepseek-ai/cosmokit': 1.8.2 + '@deepseek-ai/cosmokit': 1.8.6 '@standard-schema/spec': 1.1.0 - '@deepseek-ai/cosmokit@1.8.2': {} + '@deepseek-ai/cosmokit@1.8.6': {} + + '@deepseek-ai/dsh-agent@0.1.0-rc.6(6889e29676788162cc6455c880e3b4a2)': + dependencies: + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-llm': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))) + '@deepseek-ai/dsh-scope': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/dsh-session': 0.1.0-rc.6(f5e28831e96e72c33b5ea3a797f6fddf) + '@deepseek-ai/dsh-system-prompt': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))))(@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))) + '@deepseek-ai/dsh-typert-protocol': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) - '@deepseek-ai/dsh-agent@0.1.0-rc.6(b0514d7a320728b6d8f5a31eb3960e10)': + '@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) - '@deepseek-ai/dsh-llm': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))) - '@deepseek-ai/dsh-scope': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/dsh-session': 0.1.0-rc.6(6fd26f59436a18b115f326d6060415e6) - '@deepseek-ai/dsh-system-prompt': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))))(@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))) - '@deepseek-ai/dsh-typert-protocol': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-brand': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) - '@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))': + '@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-brand': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) - '@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))': + '@deepseek-ai/dsh-brand@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) + '@deepseek-ai/cordis': 4.0.5 - '@deepseek-ai/dsh-code-runtime@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))': + '@deepseek-ai/dsh-code-runtime@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) - '@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)': + '@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/schemastery': 3.18.1 + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/schemastery': 3.18.5 - '@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))': + '@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-attachment': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/dsh-brand': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) - '@deepseek-ai/dsh-timeout': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/schemastery': 3.18.1 + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-attachment': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/dsh-brand': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-timeout': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/schemastery': 3.18.5 - '@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))': + '@deepseek-ai/dsh-llm@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-brand': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-timeout': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-typert-protocol': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-util-crypto': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-util-values': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/schemastery': 3.18.5 + zod: 4.6.7 - '@deepseek-ai/dsh-session@0.1.0-rc.6(6fd26f59436a18b115f326d6060415e6)': + '@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-brand': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) - '@deepseek-ai/dsh-llm': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))) - '@deepseek-ai/dsh-scope': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/dsh-typert-protocol': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) - '@deepseek-ai/dsh-system-prompt@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))))(@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))': + '@deepseek-ai/dsh-session-format-v0-to-v1@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) - '@deepseek-ai/dsh-llm': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))) - '@deepseek-ai/dsh-scope': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/schemastery': 3.18.1 + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-session-format': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-util-values': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) - '@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))': + '@deepseek-ai/dsh-session-format-v1-to-v2@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-llm': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-session-format': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-session-format-v0-to-v1': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-util-values': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) - '@deepseek-ai/dsh-tools@0.1.0-rc.6(f8724372086ccc1457fc84e7becee2e0)': + '@deepseek-ai/dsh-session-format-v2-to-v3@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-agent': 0.1.0-rc.6(b0514d7a320728b6d8f5a31eb3960e10) - '@deepseek-ai/dsh-code-runtime': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) - '@deepseek-ai/dsh-llm': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))) - '@deepseek-ai/dsh-scope': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/dsh-session': 0.1.0-rc.6(6fd26f59436a18b115f326d6060415e6) - '@deepseek-ai/dsh-system-prompt': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))))(@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))) - '@deepseek-ai/dsh-user-approval': 0.1.0-rc.6(dbdaba06c174c5e30e3a58edf3cc27a9) - '@deepseek-ai/schemastery': 3.18.1 + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-session-format': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-session-format-v0-to-v1': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-session-format-v1-to-v2': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) - '@deepseek-ai/dsh-typert-protocol@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))': + '@deepseek-ai/dsh-session-format-v3-to-v4@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-session-format': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-session-format-v2-to-v3': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) - '@deepseek-ai/dsh-user-approval@0.1.0-rc.6(dbdaba06c174c5e30e3a58edf3cc27a9)': + '@deepseek-ai/dsh-session-format@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': dependencies: - '@deepseek-ai/cordis': 4.0.1 - '@deepseek-ai/dsh-agent': 0.1.0-rc.6(b0514d7a320728b6d8f5a31eb3960e10) - '@deepseek-ai/dsh-brand': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1) - '@deepseek-ai/dsh-llm': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))) - '@deepseek-ai/dsh-scope': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)) - '@deepseek-ai/dsh-session': 0.1.0-rc.6(6fd26f59436a18b115f326d6060415e6) - '@deepseek-ai/dsh-system-prompt': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))))(@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.1))) - '@deepseek-ai/schemastery': 3.18.1 + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-util-values': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) - '@deepseek-ai/schemastery@3.18.1': + '@deepseek-ai/dsh-session@0.1.0-rc.6(f5e28831e96e72c33b5ea3a797f6fddf)': dependencies: - '@deepseek-ai/cosmokit': 1.8.2 + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-brand': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-llm': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))) + '@deepseek-ai/dsh-scope': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/dsh-typert-protocol': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + + '@deepseek-ai/dsh-system-prompt@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))))(@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))': + dependencies: + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-llm': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))) + '@deepseek-ai/dsh-scope': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/schemastery': 3.18.5 + + '@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))': + dependencies: + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) + + '@deepseek-ai/dsh-timeout@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': + dependencies: + '@deepseek-ai/cordis': 4.0.5 + + '@deepseek-ai/dsh-tools@0.1.0-rc.6(14b150c73c93dfea9f66b8be648ac0d7)': + dependencies: + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-agent': 0.1.0-rc.6(6889e29676788162cc6455c880e3b4a2) + '@deepseek-ai/dsh-code-runtime': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-llm': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))) + '@deepseek-ai/dsh-scope': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/dsh-session': 0.1.0-rc.6(f5e28831e96e72c33b5ea3a797f6fddf) + '@deepseek-ai/dsh-system-prompt': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))))(@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))) + '@deepseek-ai/dsh-user-approval': 0.1.0-rc.6(731c4b6587473c7b25a7e36b8e78ec80) + '@deepseek-ai/schemastery': 3.18.5 + + '@deepseek-ai/dsh-typert-protocol@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))': + dependencies: + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) + + '@deepseek-ai/dsh-typert-protocol@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': + dependencies: + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-brand': 0.2.0-rc.2(@deepseek-ai/cordis@4.0.5) + + '@deepseek-ai/dsh-user-approval@0.1.0-rc.6(731c4b6587473c7b25a7e36b8e78ec80)': + dependencies: + '@deepseek-ai/cordis': 4.0.5 + '@deepseek-ai/dsh-agent': 0.1.0-rc.6(6889e29676788162cc6455c880e3b4a2) + '@deepseek-ai/dsh-brand': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/dsh-invariants': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5) + '@deepseek-ai/dsh-llm': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))) + '@deepseek-ai/dsh-scope': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)) + '@deepseek-ai/dsh-session': 0.1.0-rc.6(f5e28831e96e72c33b5ea3a797f6fddf) + '@deepseek-ai/dsh-system-prompt': 0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-llm@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-attachment@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-brand@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)))(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))(@deepseek-ai/dsh-timeout@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))))(@deepseek-ai/dsh-scope@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5)(@deepseek-ai/dsh-invariants@0.1.0-rc.6(@deepseek-ai/cordis@4.0.5))) + '@deepseek-ai/schemastery': 3.18.5 + + '@deepseek-ai/dsh-util-crypto@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': + dependencies: + '@deepseek-ai/cordis': 4.0.5 + + '@deepseek-ai/dsh-util-values@0.2.0-rc.2(@deepseek-ai/cordis@4.0.5)': + dependencies: + '@deepseek-ai/cordis': 4.0.5 + + '@deepseek-ai/schemastery@3.18.5': + dependencies: + '@deepseek-ai/cosmokit': 1.8.6 '@standard-schema/spec': 1.1.0 '@emnapi/runtime@1.10.0': @@ -2145,13 +2160,13 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 - '@preact/preset-vite@2.10.5(@babel/core@7.29.0)(preact@10.29.1)(rollup@4.60.2)(vite@5.4.21(@types/node@22.19.17))': + '@preact/preset-vite@2.10.5(@babel/core@7.29.0)(preact@10.29.1)(rollup@4.60.1)(vite@5.4.21(@types/node@22.19.17))': dependencies: '@babel/core': 7.29.0 '@babel/plugin-transform-react-jsx': 7.28.6(@babel/core@7.29.0) '@babel/plugin-transform-react-jsx-development': 7.27.1(@babel/core@7.29.0) '@prefresh/vite': 2.4.12(preact@10.29.1)(vite@5.4.21(@types/node@22.19.17)) - '@rollup/pluginutils': 5.3.0(rollup@4.60.2) + '@rollup/pluginutils': 5.3.0(rollup@4.60.1) babel-plugin-transform-hook-names: 1.0.2(@babel/core@7.29.0) debug: 4.4.3 magic-string: 0.30.21 @@ -2195,111 +2210,108 @@ snapshots: '@protobufjs/base64@1.1.2': {} - '@protobufjs/codegen@2.0.4': {} + '@protobufjs/codegen@2.0.5': {} - '@protobufjs/eventemitter@1.1.0': {} + '@protobufjs/eventemitter@1.1.1': {} - '@protobufjs/fetch@1.1.0': + '@protobufjs/fetch@1.1.1': dependencies: '@protobufjs/aspromise': 1.1.2 - '@protobufjs/inquire': 1.1.0 '@protobufjs/float@1.0.2': {} - '@protobufjs/inquire@1.1.0': {} - '@protobufjs/path@1.1.2': {} '@protobufjs/pool@1.1.0': {} - '@protobufjs/utf8@1.1.0': {} + '@protobufjs/utf8@1.1.2': {} '@rollup/pluginutils@4.2.1': dependencies: estree-walker: 2.0.2 picomatch: 2.3.2 - '@rollup/pluginutils@5.3.0(rollup@4.60.2)': + '@rollup/pluginutils@5.3.0(rollup@4.60.1)': dependencies: '@types/estree': 1.0.8 estree-walker: 2.0.2 picomatch: 4.0.4 optionalDependencies: - rollup: 4.60.2 + rollup: 4.60.1 - '@rollup/rollup-android-arm-eabi@4.60.2': + '@rollup/rollup-android-arm-eabi@4.60.1': optional: true - '@rollup/rollup-android-arm64@4.60.2': + '@rollup/rollup-android-arm64@4.60.1': optional: true - '@rollup/rollup-darwin-arm64@4.60.2': + '@rollup/rollup-darwin-arm64@4.60.1': optional: true - '@rollup/rollup-darwin-x64@4.60.2': + '@rollup/rollup-darwin-x64@4.60.1': optional: true - '@rollup/rollup-freebsd-arm64@4.60.2': + '@rollup/rollup-freebsd-arm64@4.60.1': optional: true - '@rollup/rollup-freebsd-x64@4.60.2': + '@rollup/rollup-freebsd-x64@4.60.1': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.60.2': + '@rollup/rollup-linux-arm-gnueabihf@4.60.1': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.60.2': + '@rollup/rollup-linux-arm-musleabihf@4.60.1': optional: true - '@rollup/rollup-linux-arm64-gnu@4.60.2': + '@rollup/rollup-linux-arm64-gnu@4.60.1': optional: true - '@rollup/rollup-linux-arm64-musl@4.60.2': + '@rollup/rollup-linux-arm64-musl@4.60.1': optional: true - '@rollup/rollup-linux-loong64-gnu@4.60.2': + '@rollup/rollup-linux-loong64-gnu@4.60.1': optional: true - '@rollup/rollup-linux-loong64-musl@4.60.2': + '@rollup/rollup-linux-loong64-musl@4.60.1': optional: true - '@rollup/rollup-linux-ppc64-gnu@4.60.2': + '@rollup/rollup-linux-ppc64-gnu@4.60.1': optional: true - '@rollup/rollup-linux-ppc64-musl@4.60.2': + '@rollup/rollup-linux-ppc64-musl@4.60.1': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.60.2': + '@rollup/rollup-linux-riscv64-gnu@4.60.1': optional: true - '@rollup/rollup-linux-riscv64-musl@4.60.2': + '@rollup/rollup-linux-riscv64-musl@4.60.1': optional: true - '@rollup/rollup-linux-s390x-gnu@4.60.2': + '@rollup/rollup-linux-s390x-gnu@4.60.1': optional: true - '@rollup/rollup-linux-x64-gnu@4.60.2': + '@rollup/rollup-linux-x64-gnu@4.60.1': optional: true - '@rollup/rollup-linux-x64-musl@4.60.2': + '@rollup/rollup-linux-x64-musl@4.60.1': optional: true - '@rollup/rollup-openbsd-x64@4.60.2': + '@rollup/rollup-openbsd-x64@4.60.1': optional: true - '@rollup/rollup-openharmony-arm64@4.60.2': + '@rollup/rollup-openharmony-arm64@4.60.1': optional: true - '@rollup/rollup-win32-arm64-msvc@4.60.2': + '@rollup/rollup-win32-arm64-msvc@4.60.1': optional: true - '@rollup/rollup-win32-ia32-msvc@4.60.2': + '@rollup/rollup-win32-ia32-msvc@4.60.1': optional: true - '@rollup/rollup-win32-x64-gnu@4.60.2': + '@rollup/rollup-win32-x64-gnu@4.60.1': optional: true - '@rollup/rollup-win32-x64-msvc@4.60.2': + '@rollup/rollup-win32-x64-msvc@4.60.1': optional: true '@sinclair/typebox@0.34.49': {} @@ -2366,24 +2378,11 @@ snapshots: dependencies: '@babel/core': 7.29.0 - base64-js@1.5.1: {} - - baseline-browser-mapping@2.10.20: {} - - better-sqlite3@12.11.1: - dependencies: - bindings: 1.5.0 - prebuild-install: 7.1.3 + baseline-browser-mapping@2.10.19: {} - bindings@1.5.0: + better-sqlite3@13.0.3: dependencies: - file-uri-to-path: 1.0.0 - - bl@4.1.0: - dependencies: - buffer: 5.7.1 - inherits: 2.0.4 - readable-stream: 3.6.2 + node-addon-api: 8.9.2 boolbase@1.0.0: {} @@ -2391,17 +2390,12 @@ snapshots: browserslist@4.28.2: dependencies: - baseline-browser-mapping: 2.10.20 + baseline-browser-mapping: 2.10.19 caniuse-lite: 1.0.30001788 - electron-to-chromium: 1.5.343 - node-releases: 2.0.38 + electron-to-chromium: 1.5.340 + node-releases: 2.0.37 update-browserslist-db: 1.2.3(browserslist@4.28.2) - buffer@5.7.1: - dependencies: - base64-js: 1.5.1 - ieee754: 1.2.1 - cac@6.7.14: {} caniuse-lite@1.0.30001788: {} @@ -2416,8 +2410,6 @@ snapshots: check-error@2.1.3: {} - chownr@1.1.4: {} - convert-source-map@2.0.0: {} css-select@5.2.2: @@ -2434,14 +2426,8 @@ snapshots: dependencies: ms: 2.1.3 - decompress-response@6.0.0: - dependencies: - mimic-response: 3.1.0 - deep-eql@5.0.2: {} - deep-extend@0.6.0: {} - define-data-property@1.1.4: dependencies: es-define-property: 1.0.1 @@ -2476,11 +2462,7 @@ snapshots: domelementtype: 2.3.0 domhandler: 5.0.3 - electron-to-chromium@1.5.343: {} - - end-of-stream@1.4.5: - dependencies: - once: 1.4.0 + electron-to-chromium@1.5.340: {} entities@4.5.0: {} @@ -2557,16 +2539,10 @@ snapshots: dependencies: '@types/estree': 1.0.8 - expand-template@2.0.3: {} - expect-type@1.3.0: {} - file-uri-to-path@1.0.0: {} - flatbuffers@25.9.23: {} - fs-constants@1.0.0: {} - fsevents@2.3.3: optional: true @@ -2576,8 +2552,6 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 - github-from-package@0.0.0: {} - global-agent@3.0.0: dependencies: boolean: 3.2.0 @@ -2602,12 +2576,6 @@ snapshots: he@1.2.0: {} - ieee754@1.2.1: {} - - inherits@2.0.4: {} - - ini@1.3.8: {} - js-tokens@4.0.0: {} jsesc@3.1.0: {} @@ -2634,28 +2602,18 @@ snapshots: dependencies: escape-string-regexp: 4.0.0 - mimic-response@3.1.0: {} - - minimist@1.2.8: {} - - mkdirp-classic@0.5.3: {} - ms@2.1.3: {} nanoid@3.3.11: {} - napi-build-utils@2.0.0: {} - - node-abi@3.89.0: - dependencies: - semver: 7.7.4 + node-addon-api@8.9.2: {} node-html-parser@6.1.13: dependencies: css-select: 5.2.2 he: 1.2.0 - node-releases@2.0.38: {} + node-releases@2.0.37: {} nth-check@2.1.1: dependencies: @@ -2663,10 +2621,6 @@ snapshots: object-keys@1.1.1: {} - once@1.4.0: - dependencies: - wrappy: 1.0.2 - onnxruntime-common@1.24.0-dev.20251116-b39e144322: {} onnxruntime-common@1.24.3: {} @@ -2684,7 +2638,7 @@ snapshots: long: 5.3.2 onnxruntime-common: 1.24.0-dev.20251116-b39e144322 platform: 1.3.6 - protobufjs: 7.5.5 + protobufjs: 7.6.5 pathe@1.1.2: {} @@ -2706,54 +2660,20 @@ snapshots: preact@10.29.1: {} - prebuild-install@7.1.3: - dependencies: - detect-libc: 2.1.2 - expand-template: 2.0.3 - github-from-package: 0.0.0 - minimist: 1.2.8 - mkdirp-classic: 0.5.3 - napi-build-utils: 2.0.0 - node-abi: 3.89.0 - pump: 3.0.4 - rc: 1.2.8 - simple-get: 4.0.1 - tar-fs: 2.1.4 - tunnel-agent: 0.6.0 - - protobufjs@7.5.5: + protobufjs@7.6.5: dependencies: '@protobufjs/aspromise': 1.1.2 '@protobufjs/base64': 1.1.2 - '@protobufjs/codegen': 2.0.4 - '@protobufjs/eventemitter': 1.1.0 - '@protobufjs/fetch': 1.1.0 + '@protobufjs/codegen': 2.0.5 + '@protobufjs/eventemitter': 1.1.1 + '@protobufjs/fetch': 1.1.1 '@protobufjs/float': 1.0.2 - '@protobufjs/inquire': 1.1.0 '@protobufjs/path': 1.1.2 '@protobufjs/pool': 1.1.0 - '@protobufjs/utf8': 1.1.0 + '@protobufjs/utf8': 1.1.2 '@types/node': 22.19.17 long: 5.3.2 - pump@3.0.4: - dependencies: - end-of-stream: 1.4.5 - once: 1.4.0 - - rc@1.2.8: - dependencies: - deep-extend: 0.6.0 - ini: 1.3.8 - minimist: 1.2.8 - strip-json-comments: 2.0.1 - - readable-stream@3.6.2: - dependencies: - inherits: 2.0.4 - string_decoder: 1.3.0 - util-deprecate: 1.0.2 - resolve-pkg-maps@1.0.0: {} roarr@2.15.4: @@ -2765,39 +2685,37 @@ snapshots: semver-compare: 1.0.0 sprintf-js: 1.1.3 - rollup@4.60.2: + rollup@4.60.1: dependencies: '@types/estree': 1.0.8 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.60.2 - '@rollup/rollup-android-arm64': 4.60.2 - '@rollup/rollup-darwin-arm64': 4.60.2 - '@rollup/rollup-darwin-x64': 4.60.2 - '@rollup/rollup-freebsd-arm64': 4.60.2 - '@rollup/rollup-freebsd-x64': 4.60.2 - '@rollup/rollup-linux-arm-gnueabihf': 4.60.2 - '@rollup/rollup-linux-arm-musleabihf': 4.60.2 - '@rollup/rollup-linux-arm64-gnu': 4.60.2 - '@rollup/rollup-linux-arm64-musl': 4.60.2 - '@rollup/rollup-linux-loong64-gnu': 4.60.2 - '@rollup/rollup-linux-loong64-musl': 4.60.2 - '@rollup/rollup-linux-ppc64-gnu': 4.60.2 - '@rollup/rollup-linux-ppc64-musl': 4.60.2 - '@rollup/rollup-linux-riscv64-gnu': 4.60.2 - '@rollup/rollup-linux-riscv64-musl': 4.60.2 - '@rollup/rollup-linux-s390x-gnu': 4.60.2 - '@rollup/rollup-linux-x64-gnu': 4.60.2 - '@rollup/rollup-linux-x64-musl': 4.60.2 - '@rollup/rollup-openbsd-x64': 4.60.2 - '@rollup/rollup-openharmony-arm64': 4.60.2 - '@rollup/rollup-win32-arm64-msvc': 4.60.2 - '@rollup/rollup-win32-ia32-msvc': 4.60.2 - '@rollup/rollup-win32-x64-gnu': 4.60.2 - '@rollup/rollup-win32-x64-msvc': 4.60.2 + '@rollup/rollup-android-arm-eabi': 4.60.1 + '@rollup/rollup-android-arm64': 4.60.1 + '@rollup/rollup-darwin-arm64': 4.60.1 + '@rollup/rollup-darwin-x64': 4.60.1 + '@rollup/rollup-freebsd-arm64': 4.60.1 + '@rollup/rollup-freebsd-x64': 4.60.1 + '@rollup/rollup-linux-arm-gnueabihf': 4.60.1 + '@rollup/rollup-linux-arm-musleabihf': 4.60.1 + '@rollup/rollup-linux-arm64-gnu': 4.60.1 + '@rollup/rollup-linux-arm64-musl': 4.60.1 + '@rollup/rollup-linux-loong64-gnu': 4.60.1 + '@rollup/rollup-linux-loong64-musl': 4.60.1 + '@rollup/rollup-linux-ppc64-gnu': 4.60.1 + '@rollup/rollup-linux-ppc64-musl': 4.60.1 + '@rollup/rollup-linux-riscv64-gnu': 4.60.1 + '@rollup/rollup-linux-riscv64-musl': 4.60.1 + '@rollup/rollup-linux-s390x-gnu': 4.60.1 + '@rollup/rollup-linux-x64-gnu': 4.60.1 + '@rollup/rollup-linux-x64-musl': 4.60.1 + '@rollup/rollup-openbsd-x64': 4.60.1 + '@rollup/rollup-openharmony-arm64': 4.60.1 + '@rollup/rollup-win32-arm64-msvc': 4.60.1 + '@rollup/rollup-win32-ia32-msvc': 4.60.1 + '@rollup/rollup-win32-x64-gnu': 4.60.1 + '@rollup/rollup-win32-x64-msvc': 4.60.1 fsevents: 2.3.3 - safe-buffer@5.2.1: {} - semver-compare@1.0.0: {} semver@6.3.1: {} @@ -2845,14 +2763,6 @@ snapshots: dependencies: kolorist: 1.8.0 - simple-concat@1.0.1: {} - - simple-get@4.0.1: - dependencies: - decompress-response: 6.0.0 - once: 1.4.0 - simple-concat: 1.0.1 - source-map-js@1.2.1: {} source-map@0.7.6: {} @@ -2865,27 +2775,6 @@ snapshots: std-env@3.10.0: {} - string_decoder@1.3.0: - dependencies: - safe-buffer: 5.2.1 - - strip-json-comments@2.0.1: {} - - tar-fs@2.1.4: - dependencies: - chownr: 1.1.4 - mkdirp-classic: 0.5.3 - pump: 3.0.4 - tar-stream: 2.2.0 - - tar-stream@2.2.0: - dependencies: - bl: 4.1.0 - end-of-stream: 1.4.5 - fs-constants: 1.0.0 - inherits: 2.0.4 - readable-stream: 3.6.2 - tinybench@2.9.0: {} tinyexec@0.3.2: {} @@ -2906,10 +2795,6 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - tunnel-agent@0.6.0: - dependencies: - safe-buffer: 5.2.1 - type-fest@0.13.1: {} typescript@5.9.3: {} @@ -2922,8 +2807,6 @@ snapshots: escalade: 3.2.0 picocolors: 1.1.1 - util-deprecate@1.0.2: {} - uuid@10.0.0: {} vite-node@2.1.9(@types/node@22.19.17): @@ -2958,7 +2841,7 @@ snapshots: dependencies: esbuild: 0.21.5 postcss: 8.5.10 - rollup: 4.60.2 + rollup: 4.60.1 optionalDependencies: '@types/node': 22.19.17 fsevents: 2.3.3 @@ -3003,10 +2886,10 @@ snapshots: siginfo: 2.0.0 stackback: 0.0.2 - wrappy@1.0.2: {} - yallist@3.1.1: {} yaml@2.8.3: {} zimmerframe@1.1.4: {} + + zod@4.6.7: {} diff --git a/apps/memos-local-plugin/pnpm-workspace.yaml b/apps/memos-local-plugin/pnpm-workspace.yaml new file mode 100644 index 000000000..6ee7f50e9 --- /dev/null +++ b/apps/memos-local-plugin/pnpm-workspace.yaml @@ -0,0 +1,10 @@ +# pnpm 11.7.0; npm's independent policy is package.json#allowScripts. +strictDepBuilds: true +allowBuilds: + better-sqlite3: false + esbuild@0.27.7: true + esbuild@0.21.5: true + sharp@0.34.5: true + onnxruntime-node: false + protobufjs: false + fsevents: false diff --git a/apps/memos-local-plugin/scripts/migrate-dsh-preset-profile.mjs b/apps/memos-local-plugin/scripts/migrate-dsh-preset-profile.mjs new file mode 100644 index 000000000..48246f9b3 --- /dev/null +++ b/apps/memos-local-plugin/scripts/migrate-dsh-preset-profile.mjs @@ -0,0 +1,150 @@ +#!/usr/bin/env node +/** Explicit data repair only; never run automatically when the plugin starts. */ +import Database from "better-sqlite3"; +import { closeSync, openSync } from "node:fs"; +import { resolve } from "node:path"; +import { pathToFileURL } from "node:url"; +import { parseArgs } from "node:util"; + +const AGENT = "deepseek-harness"; +const quote = (name) => `"${name.replaceAll('"', '""')}"`; + +/** + * Move only the selected DSH profile. IDs, vectors, sharing and references stay + * intact. Stop every writer to this database before applying the repair. + * @param {{dbPath:string, from:string, to:string, apply?:boolean, backupPath?:string}} options + */ +export async function migrateDshPresetProfile(options) { + const { from, to } = options; + if ( + ![from, to].every( + (id) => typeof id === "string" && /^[a-z0-9][a-z0-9_-]*$/.test(id), + ) || + from === to + ) { + throw new Error( + "Specify two distinct canonical profile IDs using lowercase letters, digits, hyphens or underscores.", + ); + } + const dbPath = resolve(options.dbPath); + const apply = options.apply === true; + if ( + apply && + (!options.backupPath || resolve(options.backupPath) === dbPath) + ) { + throw new Error( + "Applying migration requires --backup with a new path distinct from the database.", + ); + } + const db = new Database(dbPath, { readonly: !apply, fileMustExist: true }); + try { + db.pragma("busy_timeout = 5000"); + const tables = db + .prepare( + "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name", + ) + .all() + .filter(({ name }) => { + const columns = new Set( + db + .prepare(`PRAGMA table_info(${quote(name)})`) + .all() + .map((column) => column.name), + ); + return ( + columns.has("owner_agent_kind") && columns.has("owner_profile_id") + ); + }); + const counts = Object.fromEntries( + tables.map(({ name }) => [ + name, + db + .prepare( + `SELECT COUNT(*) AS n FROM ${quote(name)} WHERE owner_agent_kind=? AND owner_profile_id=?`, + ) + .get(AGENT, from).n, + ]), + ); + if (!apply) return { from, to, dryRun: true, counts }; + + const backupPath = resolve(options.backupPath); + // Reserve without clobbering an existing backup. SQLite's backup API includes + // committed WAL data, unlike copying only the main .db file. + closeSync(openSync(backupPath, "wx", 0o600)); + await db.backup(backupPath); + db.transaction(() => { + for (const { name } of tables) { + if (name === "sessions" || name === "episodes") { + const rows = db + .prepare( + `SELECT id,meta_json FROM ${quote(name)} WHERE owner_agent_kind=? AND owner_profile_id=?`, + ) + .all(AGENT, from); + const updateMeta = db.prepare( + `UPDATE ${quote(name)} SET meta_json=? WHERE id=?`, + ); + for (const row of rows) { + const meta = JSON.parse(row.meta_json); + if (meta && typeof meta === "object" && !Array.isArray(meta)) { + if ( + meta.namespace?.agentKind === AGENT && + meta.namespace.profileId === from + ) { + meta.namespace.profileId = to; + if (meta.namespace.profileLabel === from) + meta.namespace.profileLabel = to; + } + if (meta.ownerProfileId === from) meta.ownerProfileId = to; + updateMeta.run(JSON.stringify(meta), row.id); + } + } + } + // Uniqueness conflicts (e.g. skill names) abort the entire transaction; + // never overwrite the target profile's data to make a merge succeed. + db.prepare( + `UPDATE ${quote(name)} SET owner_profile_id=? WHERE owner_agent_kind=? AND owner_profile_id=?`, + ).run(to, AGENT, from); + } + })(); + return { from, to, dryRun: false, counts, backupPath }; + } finally { + db.close(); + } +} + +if ( + process.argv[1] && + import.meta.url === pathToFileURL(resolve(process.argv[1])).href +) { + try { + const { values } = parseArgs({ + options: { + db: { type: "string" }, + from: { type: "string" }, + to: { type: "string" }, + backup: { type: "string" }, + apply: { type: "boolean", default: false }, + }, + }); + if (!values.db || !values.from || !values.to) + throw new Error( + "Usage: node scripts/migrate-dsh-preset-profile.mjs --db --from --to [--apply --backup ]", + ); + console.log( + JSON.stringify( + await migrateDshPresetProfile({ + dbPath: values.db, + from: values.from, + to: values.to, + apply: values.apply, + backupPath: values.backup, + }), + null, + 2, + ), + ); + } catch (error) { + console.error(error instanceof Error ? error.message : String(error)); + process.exitCode = 1; + } +} diff --git a/apps/memos-local-plugin/scripts/normalize-sqlite-lock.cjs b/apps/memos-local-plugin/scripts/normalize-sqlite-lock.cjs new file mode 100644 index 000000000..e8c11d5f3 --- /dev/null +++ b/apps/memos-local-plugin/scripts/normalize-sqlite-lock.cjs @@ -0,0 +1,24 @@ +#!/usr/bin/env node +// npm 11 can drop gypfile:false while serializing a lock, then infer a rebuild. +// Never generalize this repair to unreviewed artifacts or run it during install. +"use strict"; +const fs = require("node:fs"); +const path = require("node:path"); +const args = process.argv.slice(2); +const file = args.find(arg => !arg.startsWith("--")) || path.join(__dirname, "../package-lock.json"); +const lock = JSON.parse(fs.readFileSync(file, "utf8")); +const entry = lock.packages?.["node_modules/better-sqlite3"]; +const expectedIntegrity = "sha512-RbOBxmLBG8uvFUc15X9+9SFemKcQ0WBuISBVkpuiaUB2qblC8UWlHEjdWVoZ8AdhSwmoEgsiXKfopX0CQxaACQ=="; +if (lock.packages?.[""]?.dependencies?.["better-sqlite3"] !== "13.0.3" || + entry?.version !== "13.0.3" || entry?.integrity !== expectedIntegrity || + entry?.resolved !== "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-13.0.3.tgz") { + throw new Error("Unreviewed better-sqlite3 lock entry: verify version, URL and integrity before changing the normalizer."); +} +const changed = entry.gypfile !== false || entry.hasInstallScript !== false; +if (changed && args.includes("--check")) throw new Error("SQLite lock metadata drift; run npm run lock:normalize before committing."); +if (changed) { + entry.gypfile = false; + entry.hasInstallScript = false; + fs.writeFileSync(file, JSON.stringify(lock, null, 2) + "\n"); +} +console.log("SQLite 13.0.3 lock metadata verified"); diff --git a/apps/memos-local-plugin/scripts/verify-native-runtime.cjs b/apps/memos-local-plugin/scripts/verify-native-runtime.cjs new file mode 100644 index 000000000..f32ad8864 --- /dev/null +++ b/apps/memos-local-plugin/scripts/verify-native-runtime.cjs @@ -0,0 +1,19 @@ +#!/usr/bin/env node +"use strict"; +const assert = require("node:assert/strict"); +const { createRequire } = require("node:module"); +if (Number(process.versions.node.split(".")[0]) < 22) { + throw new Error("MemOS requires Node.js >=22 in the actual host runtime"); +} +const Database = require("better-sqlite3"); +const db = new Database(":memory:"); +try { + db.exec("CREATE TABLE probe (v TEXT)"); + db.prepare("INSERT INTO probe VALUES (?)").run("ok"); + assert.equal(db.prepare("SELECT v FROM probe").get().v, "ok"); +} finally { db.close(); } +const fromTransformers = createRequire(require.resolve("@huggingface/transformers")); +const ort = fromTransformers("onnxruntime-node"); +assert.ok(ort.listSupportedBackends().some(backend => backend.name === "cpu" && backend.bundled)); +console.log(JSON.stringify({ node: process.versions.node, electron: process.versions.electron ?? null, + sqlite: require("better-sqlite3/package.json").version, cpuOnnx: true })); diff --git a/apps/memos-local-plugin/scripts/verify-script-policy.cjs b/apps/memos-local-plugin/scripts/verify-script-policy.cjs new file mode 100644 index 000000000..2a513cbb9 --- /dev/null +++ b/apps/memos-local-plugin/scripts/verify-script-policy.cjs @@ -0,0 +1,35 @@ +#!/usr/bin/env node +// Negative control: a previously unseen dependency must not execute its script. +"use strict"; +const fs = require("node:fs"); +const os = require("node:os"); +const path = require("node:path"); +const { spawnSync } = require("node:child_process"); +const assert = require("node:assert/strict"); +const npmCli = process.env.npm_execpath; +assert.ok(npmCli, "Run through npm run verify:script-policy with npm 11.17.0"); +const temp = fs.mkdtempSync(path.join(os.tmpdir(), "memos-script-policy-")); +const dep = path.join(temp, "dependency"), project = path.join(temp, "project"); +fs.mkdirSync(dep); fs.mkdirSync(project); +const marker = path.join(temp, "unexpected-script-ran"); +const run = (cwd, args) => spawnSync(process.execPath, [npmCli, ...args], { + cwd, encoding: "utf8", timeout: 30_000, + env: { ...process.env, MEMOS_POLICY_MARKER: marker }, +}); +try { + fs.writeFileSync(path.join(dep, "package.json"), JSON.stringify({name: "memos-unreviewed-policy-probe", version: "1.0.0", scripts: {postinstall: "node postinstall.cjs"}})); + fs.writeFileSync(path.join(dep, "postinstall.cjs"), 'require("node:fs").writeFileSync(process.env.MEMOS_POLICY_MARKER, "unexpected");'); + const pack = run(dep, ["pack", "--ignore-scripts", "--json"]); + assert.equal(pack.status, 0, pack.stderr); + const tar = JSON.parse(pack.stdout)[0].filename; + fs.writeFileSync(path.join(project, "package.json"), JSON.stringify({name: "memos-policy-root", version: "1.0.0", private: true, + dependencies: {"memos-unreviewed-policy-probe": `file:../dependency/${tar}`}, allowScripts: {}})); + fs.writeFileSync(path.join(project, ".npmrc"), "strict-allow-scripts=true\n"); + const lock = run(project, ["install", "--package-lock-only", "--ignore-scripts", "--no-audit", "--no-fund"]); + assert.equal(lock.status, 0, lock.stderr); + const install = run(project, ["ci", "--no-audit", "--no-fund"]); + assert.notEqual(install.status, 0, "Unreviewed install script did not fail installation"); + assert.match(install.stdout + install.stderr, /memos-unreviewed-policy-probe/); + assert.equal(fs.existsSync(marker), false, "Unreviewed script executed"); + console.log("PASS: strict npm policy rejected the unknown script without executing it"); +} finally { fs.rmSync(temp, { recursive: true, force: true }); } diff --git a/apps/memos-local-plugin/scripts/verify-windows-dll-isolation.mjs b/apps/memos-local-plugin/scripts/verify-windows-dll-isolation.mjs new file mode 100644 index 000000000..a46c6f294 --- /dev/null +++ b/apps/memos-local-plugin/scripts/verify-windows-dll-isolation.mjs @@ -0,0 +1,123 @@ +#!/usr/bin/env node +/** Run against the host's real Sharp; each load order starts in a fresh process. */ +import assert from "node:assert/strict"; +import { execFile } from "node:child_process"; +import { createRequire } from "node:module"; +import { fileURLToPath } from "node:url"; +import { resolve } from "node:path"; +import { promisify } from "node:util"; + +const args = process.argv.slice(2); +const option = (name) => { + const i = args.indexOf(name); + return i < 0 ? undefined : args[i + 1]; +}; +if (process.platform !== "win32") { + console.log("SKIP: native DLL collision verification requires Windows."); + process.exit(0); +} +const hostSharp = option("--host-sharp"); +if (!hostSharp) + throw new Error( + "Pass --host-sharp . Run npm run build first.", + ); +const order = option("--order"); +if (!order) { + const env = { ...process.env, ELECTRON_RUN_AS_NODE: "1" }; + delete env.NODE_OPTIONS; + delete env.NODE_PATH; + for (const sequence of ["plugin-first", "host-first"]) { + const result = await promisify(execFile)( + process.execPath, + [fileURLToPath(import.meta.url), ...args, "--order", sequence], + { env, windowsHide: true, timeout: 180_000 }, + ); + process.stdout.write(result.stdout); + process.stderr.write(result.stderr); + } + process.exit(0); +} +assert.ok(["plugin-first", "host-first"].includes(order)); +const { LocalEmbeddingProvider } = await import( + "../dist/core/embedding/providers/local.js" +); +const provider = new LocalEmbeddingProvider(); +let hostVersion; +let workerPid; +async function hostImage() { + const sharp = createRequire(import.meta.url)(resolve(hostSharp)); + const image = await sharp({ + create: { width: 1, height: 1, channels: 3, background: "#ffffff" }, + }) + .png() + .toBuffer(); + assert.ok(image.length > 0); + hostVersion = sharp.versions; +} +async function embed() { + const before = new Set(process.report.getReport().sharedObjects); + const log = Object.fromEntries( + ["trace", "debug", "info", "warn", "error"].map((level) => [ + level, + (message, data) => { + if (message === "process.request") workerPid = data.pid; + }, + ]), + ); + const vectors = await provider.embed( + ["Synthetic Windows DLL isolation verification."], + "query", + { + config: { + provider: "local", + model: option("--model") ?? "Xenova/all-MiniLM-L6-v2", + dimensions: 384, + local: { + cacheDir: option("--cache-dir"), + offline: args.includes("--offline"), + loadTimeoutMs: 120_000, + }, + openRouter: false, + cache: { enabled: false, maxItems: 0 }, + }, + log, + signal: AbortSignal.timeout(150_000), + }, + ); + assert.equal(vectors.length, 1); + assert.equal(vectors[0].length, 384); + assert.ok(vectors[0].every(Number.isFinite)); + assert.ok( + Number.isInteger(workerPid) && workerPid !== process.pid, + "Local model must run in a separate process", + ); + const added = process.report + .getReport() + .sharedObjects.filter( + (path) => !before.has(path) && /sharp|vips|onnxruntime/i.test(path), + ); + assert.deepEqual( + added, + [], + "Local embeddings must not load native model/image libraries into the host", + ); +} +try { + if (order === "host-first") await hostImage(); + await embed(); + // Exercise the real host image path after model initialization in both orders. + await hostImage(); + console.log( + JSON.stringify({ + order, + passed: true, + hostPid: process.pid, + workerPid, + dimensions: 384, + hostSharp: hostVersion.sharp, + hostVips: hostVersion.vips, + }), + ); +} finally { + await provider.close(); +} diff --git a/apps/memos-local-plugin/server/routes/import-export.ts b/apps/memos-local-plugin/server/routes/import-export.ts index 082aabe23..954349fbc 100644 --- a/apps/memos-local-plugin/server/routes/import-export.ts +++ b/apps/memos-local-plugin/server/routes/import-export.ts @@ -127,7 +127,17 @@ export function registerImportExportRoutes( writeError(ctx, 400, "invalid_argument", "bundle must be a JSON object"); return; } - return await deps.core.importBundle(bundle); + const ownership = ctx.url.searchParams.get("ownership") ?? "preserve"; + const dryRun = ctx.url.searchParams.get("dryRun") ?? "false"; + const targetProfileId = ctx.url.searchParams.get("targetProfileId") ?? undefined; + if (!["preserve", "target"].includes(ownership) || !["true", "false"].includes(dryRun) + || (targetProfileId !== undefined && (ownership !== "target" || !targetProfileId.trim()))) { + writeError(ctx, 400, "invalid_argument", "invalid import ownership, targetProfileId or dryRun option"); + return; + } + return await deps.core.importBundle(bundle, { + ownership: ownership as "preserve" | "target", dryRun: dryRun === "true", targetProfileId, + }); }); routes.set("GET /api/v1/import/hermes-native/scan", async () => { diff --git a/apps/memos-local-plugin/server/routes/models.ts b/apps/memos-local-plugin/server/routes/models.ts index fb186bf1a..620fdc325 100644 --- a/apps/memos-local-plugin/server/routes/models.ts +++ b/apps/memos-local-plugin/server/routes/models.ts @@ -20,6 +20,7 @@ * The test runs with values from the request body only. */ import { createEmbedder, type Embedder } from "../../core/embedding/index.js"; +import type { EmbeddingConfig } from "../../core/embedding/types.js"; import type { ServerDeps } from "../types.js"; import { parseJson, writeError, type Routes } from "./registry.js"; @@ -29,6 +30,7 @@ interface TestRequest { endpoint?: string; model?: string; apiKey?: string; + local?: EmbeddingConfig["local"]; } export function registerModelsRoutes(routes: Routes, deps: ServerDeps): void { @@ -157,12 +159,13 @@ async function resolveSecrets( const DEFAULT_LOCAL_EMBEDDING_MODEL = "Xenova/all-MiniLM-L6-v2"; type LocalProbeEmbedder = Pick; -type LocalProbeEmbedderFactory = (model: string) => LocalProbeEmbedder; +type LocalProbeEmbedderFactory = (model: string, local?: EmbeddingConfig["local"]) => LocalProbeEmbedder; -function createLocalProbeEmbedder(model: string): LocalProbeEmbedder { +function createLocalProbeEmbedder(model: string, local?: EmbeddingConfig["local"]): LocalProbeEmbedder { return createEmbedder({ provider: "local", model, + local, dimensions: 384, openRouter: false, cache: { enabled: false, maxItems: 0 }, @@ -176,10 +179,12 @@ function createLocalProbeEmbedder(model: string): LocalProbeEmbedder { export async function probeLocalEmbedding( model: string, create: LocalProbeEmbedderFactory = createLocalProbeEmbedder, + local?: EmbeddingConfig["local"], ): Promise { const resolvedModel = model.trim() || DEFAULT_LOCAL_EMBEDDING_MODEL; try { - const vector = await create(resolvedModel).embedOne("ping"); + const embedder = local === undefined ? create(resolvedModel) : create(resolvedModel, local); + const vector = await embedder.embedOne("ping"); if (vector.length === 0) throw new Error("no embedding vector returned"); return vector.length; } catch (err) { @@ -281,7 +286,7 @@ async function probeEmbedding(req: TestRequest): Promise { return first.length; } case "local": - return probeLocalEmbedding(model); + return probeLocalEmbedding(model, undefined, req.local); default: throw new Error(`unsupported embedding provider: ${provider}`); } diff --git a/apps/memos-local-plugin/tests/helpers/deepseek-harness-v4.ts b/apps/memos-local-plugin/tests/helpers/deepseek-harness-v4.ts new file mode 100644 index 000000000..2005b1e39 --- /dev/null +++ b/apps/memos-local-plugin/tests/helpers/deepseek-harness-v4.ts @@ -0,0 +1,9 @@ +import { releasedV4SessionFormatCodec } from "@deepseek-ai/dsh-session-format-v3-to-v4"; + +/** Use the same JSON boundary as durable DSH events, without a desktop install. */ +export function dshV4Event( + type: string, + data: unknown, +): Parameters[0] { + return JSON.parse(JSON.stringify({ type, seq: 1, time: 1, data })); +} diff --git a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-bridge.test.ts b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-bridge.test.ts index 4c5404365..fea695ec6 100644 --- a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-bridge.test.ts +++ b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-bridge.test.ts @@ -1,5 +1,7 @@ +import { assertV4RowAdmission, releasedV4SessionFormatCodec } from "@deepseek-ai/dsh-session-format-v3-to-v4"; import { describe, expect, it, vi } from "vitest"; +import { dshV4Event } from "../../helpers/deepseek-harness-v4.js"; import type { MemoryCore } from "../../../agent-contract/memory-core.js"; import { createDeepSeekHarnessBridge, @@ -7,6 +9,7 @@ import { type DshSessionLike, type DshUserMessageLike, } from "../../../adapters/deepseek-harness/bridge.js"; +import { createDeepSeekHarnessRecallMessage } from "../../../adapters/deepseek-harness/index.js"; import { DeepSeekHarnessLlmRouteContext } from "../../../adapters/deepseek-harness/host-llm.js"; function userMessage(text: string): DshUserMessageLike { @@ -19,16 +22,7 @@ function userMessage(text: string): DshUserMessageLike { } function recallMessage(text: string): DshUserMessageLike { - return { - id: `recall-${text.length}`, - role: "user", - content: [{ type: "text", text }], - source: { - kind: "plugin", - plugin: "memos-local-memory", - form: "recall", - }, - }; + return createDeepSeekHarnessRecallMessage(text) as unknown as DshUserMessageLike; } function makeCore(overrides: Partial = {}): MemoryCore { @@ -116,6 +110,61 @@ const session: DshSessionLike = { }; describe("DeepSeek Harness bridge", () => { + it.each([undefined, "standard", "research"])( + "uses the configured memory profile for recall and capture with preset %s", + async (preset) => { + const core = makeCore(); + const bridge = makeBridge(core); + const current = { + id: `preset-${preset ?? "headless"}`, + header: { + cwd: "/workspace/project", + ...(preset ? { agentPreset: preset } : {}), + }, + }; + bridge.onSessionEvent(current, { + type: "turn/start", + seq: 0, + time: 100, + data: { turn: 1 }, + }); + const prompt = userMessage("Synthetic memory lookup"); + await bridge.beforeStep( + { + agent: { id: current.id, session: current }, + messages: [prompt], + turn: 1, + step: 1, + signal: new AbortController().signal, + }, + async () => ({ kind: "enter", messages: [prompt] }), + ); + bridge.onSessionEvent(current, { + type: "assistant/message", + seq: 1, + time: 110, + data: { + turn: 1, + message: { content: [{ type: "text", text: "Synthetic answer" }] }, + }, + }); + bridge.onSessionEvent(current, { + type: "turn/end", + seq: 2, + time: 120, + data: { turn: 1, reason: { kind: "completed" } }, + }); + await bridge.flush(current.id); + const scoped = expect.objectContaining({ + namespace: expect.objectContaining({ profileId: "web" }), + }); + expect(core.searchMemory).toHaveBeenCalledWith(scoped, expect.anything()); + expect(core.prepareTurn).toHaveBeenCalledWith(scoped); + expect(core.onTurnEnd).toHaveBeenCalledWith(scoped); + await bridge.closeSession(current); + }, + ); + it("prefers the persisted request route and falls back to agent defaults", () => { const routedSession: DshSessionLike = { id: "route-session", @@ -539,7 +588,7 @@ describe("DeepSeek Harness bridge", () => { expect(first.messages[1]).toMatchObject({ role: "user", source: { - kind: "plugin", + kind: "plugin:memos-local-memory", plugin: "memos-local-memory", form: "recall", }, @@ -548,12 +597,24 @@ describe("DeepSeek Harness bridge", () => { text: expect.stringContaining("The user prefers concise technical answers."), }], }); + // Pre-step persists the original query and recall together. Both must pass V4. + const batch = dshV4Event("agent/inbox/spliced", { + removedCount: 1, + inserted: first.messages, + }); + expect(() => assertV4RowAdmission(batch)).not.toThrow(); + expect(() => releasedV4SessionFormatCodec.encodeEvent(batch)).not.toThrow(); + for (const message of first.messages) { + const event = dshV4Event("user/message", message); + expect(() => assertV4RowAdmission(event)).not.toThrow(); + expect(() => releasedV4SessionFormatCodec.encodeEvent(event)).not.toThrow(); + } expect(replayedFirstStep).toEqual({ kind: "enter", messages: [prompt] }); expect(second).toEqual({ kind: "enter", messages: [] }); expect(followUp).toMatchObject({ kind: "enter", messages: [followUpPrompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); }); @@ -590,7 +651,7 @@ describe("DeepSeek Harness bridge", () => { expect(result).toMatchObject({ kind: "enter", messages: [prompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); expect(core.searchMemory).toHaveBeenCalledTimes(1); @@ -637,7 +698,7 @@ describe("DeepSeek Harness bridge", () => { expect(result).toMatchObject({ kind: "enter", messages: [prompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); }); @@ -682,7 +743,7 @@ describe("DeepSeek Harness bridge", () => { expect(result).toMatchObject({ kind: "enter", messages: [prompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); expect(core.searchMemory).toHaveBeenCalledTimes(1); @@ -836,7 +897,7 @@ describe("DeepSeek Harness bridge", () => { expect(result).toMatchObject({ kind: "enter", messages: [retry, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); @@ -959,7 +1020,7 @@ describe("DeepSeek Harness bridge", () => { await expect(nextStep).resolves.toMatchObject({ kind: "enter", messages: [secondPrompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); expect(core.searchMemory).toHaveBeenCalledTimes(2); @@ -1037,7 +1098,7 @@ describe("DeepSeek Harness bridge", () => { await expect(nextStep).resolves.toMatchObject({ kind: "enter", messages: [secondPrompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); expect(core.searchMemory).toHaveBeenCalledTimes(2); diff --git a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-host-llm.test.ts b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-host-llm.test.ts index 493fba9e7..4f91e310c 100644 --- a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-host-llm.test.ts +++ b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-host-llm.test.ts @@ -1,3 +1,4 @@ +import { assertV4RowAdmission, releasedV4SessionFormatCodec } from "@deepseek-ai/dsh-session-format-v3-to-v4"; import { Context } from "@deepseek-ai/cordis"; import LlmRuntime, { LlmAdapter, @@ -12,6 +13,7 @@ import LlmRuntime, { } from "@deepseek-ai/dsh-llm"; import { describe, expect, it, vi } from "vitest"; +import { dshV4Event } from "../../helpers/deepseek-harness-v4.js"; import { createDeepSeekHarnessHostLlmBridge, DeepSeekHarnessLlmRouteContext, @@ -165,6 +167,13 @@ describe("DeepSeek Harness host LLM bridge", () => { timeoutMs: 2_000, })); + // Exercise the actual host bridge output; auxiliary messages need no form. + const message = request!.messages[0]!; + expect(message.source).not.toHaveProperty("form"); + const event = dshV4Event("user/message", message); + expect(() => assertV4RowAdmission(event)).not.toThrow(); + expect(() => releasedV4SessionFormatCodec.encodeEvent(event)).not.toThrow(); + expect(request).toMatchObject({ provider: "deepseek", model: "deepseek-chat", @@ -176,7 +185,7 @@ describe("DeepSeek Harness host LLM bridge", () => { { role: "user", content: [{ type: "text", text: "Question" }], - source: { kind: "plugin", plugin: "memos-local-memory" }, + source: { kind: "plugin:memos-local-memory", plugin: "memos-local-memory" }, }, { role: "assistant", diff --git a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-runtime.test.ts b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-runtime.test.ts index 7d6c515ef..01ddeb8f8 100644 --- a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-runtime.test.ts +++ b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-runtime.test.ts @@ -1,10 +1,12 @@ import { join } from "node:path"; +import { assertV4RowAdmission, releasedV4SessionFormatCodec } from "@deepseek-ai/dsh-session-format-v3-to-v4"; import type { Context } from "@deepseek-ai/cordis"; import { describe, expect, it, vi } from "vitest"; import { configureDeepSeekHarnessHostLlm, + createDeepSeekHarnessRecallMessage, deepSeekHarnessAutoRecoveryEnabled, deepSeekHarnessMemoryGuidance, defaultDeepSeekHarnessHome, @@ -14,9 +16,42 @@ import { import type { DeepSeekHarnessHostLlmBridge, } from "../../../adapters/deepseek-harness/host-llm.js"; +import { dshV4Event } from "../../helpers/deepseek-harness-v4.js"; import { DEFAULT_CONFIG } from "../../../core/config/index.js"; describe("DeepSeek Harness adapter runtime defaults", () => { + it("creates producer-owned recall messages admitted by DSH V4", () => { + const message = createDeepSeekHarnessRecallMessage("synthetic recall"); + const event = dshV4Event("user/message", message); + expect(() => assertV4RowAdmission(event)).not.toThrow(); + expect(() => releasedV4SessionFormatCodec.encodeEvent(event)).not.toThrow(); + expect(message).toMatchObject({ + role: "user", + content: [{ type: "text", text: "synthetic recall" }], + source: { kind: "plugin:memos-local-memory", plugin: "memos-local-memory", form: "recall" }, + }); + }); + + it.each([ + { kind: "plugin", plugin: "memos-local-memory", form: "recall" }, + { kind: "plugin", plugin: "memos-local-memory" }, + ])("rejects retired plugin sources at both V4 gates: %j", (source) => { + const message = { ...createDeepSeekHarnessRecallMessage("synthetic recall"), source }; + const user = { ...message, source: { kind: "user" } }; + const events = [ + dshV4Event("user/message", message), + dshV4Event("agent/inbox/spliced", { removedCount: 1, inserted: [user, message] }), + ]; + for (const event of events) { + expect(() => assertV4RowAdmission(event)).toThrow( + "format v4 message requires a producer-owned source kind", + ); + expect(() => releasedV4SessionFormatCodec.encodeEvent(event)).toThrow( + "format v4 message requires a producer-owned source kind", + ); + } + }); + it("injects the DSH LLM service and uses it for an otherwise unconfigured MemOS LLM", () => { expect(inject).toContain("llm"); diff --git a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-tools.test.ts b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-tools.test.ts index 192d9b4fb..0ae4222ee 100644 --- a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-tools.test.ts +++ b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-tools.test.ts @@ -118,8 +118,8 @@ describe("DeepSeek Harness memory tools", () => { agent: "deepseek-harness", namespace: { agentKind: "deepseek-harness", - profileId: "standard", - profileLabel: "standard", + profileId: "web", + profileLabel: "web", workspacePath: "/workspace/project", sessionKey: "dsh-session-a", }, @@ -207,7 +207,7 @@ describe("DeepSeek Harness memory tools", () => { sessionId: "dsh-session-a", episodeId: "episode-1", toolCallId: "tool-call-1", - namespace: expect.objectContaining({ profileId: "standard" }), + namespace: expect.objectContaining({ profileId: "web" }), })); expect(result).toMatchObject({ found: true, diff --git a/apps/memos-local-plugin/tests/unit/embedding/local-abort.test.ts b/apps/memos-local-plugin/tests/unit/embedding/local-abort.test.ts index ad9d90fba..ceeb45d14 100644 --- a/apps/memos-local-plugin/tests/unit/embedding/local-abort.test.ts +++ b/apps/memos-local-plugin/tests/unit/embedding/local-abort.test.ts @@ -6,6 +6,7 @@ const { pipelineMock } = vi.hoisted(() => ({ vi.mock("@huggingface/transformers", () => ({ pipeline: pipelineMock, + env: { remoteHost: "https://huggingface.co/", localModelPath: "/models", cacheDir: "/cache", allowRemoteModels: true }, })); import { diff --git a/apps/memos-local-plugin/tests/unit/embedding/local-config.test.ts b/apps/memos-local-plugin/tests/unit/embedding/local-config.test.ts new file mode 100644 index 000000000..23da461c2 --- /dev/null +++ b/apps/memos-local-plugin/tests/unit/embedding/local-config.test.ts @@ -0,0 +1,207 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import type { ProviderCallCtx } from "../../../core/embedding/types.js"; +import { homedir } from "node:os"; +import { join } from "node:path"; + +const { pipeline, env } = vi.hoisted(() => ({ + pipeline: vi.fn(), + env: { + remoteHost: "https://huggingface.co/", + localModelPath: "/original/models", + cacheDir: "/original/cache", + allowRemoteModels: true, + }, +})); +vi.mock("@huggingface/transformers", () => ({ pipeline, env })); +import { + LocalEmbeddingProvider, + __resetLocalExtractorForTests, +} from "../../../core/embedding/providers/local.js"; + +const extractor = async () => ({ data: new Float32Array([1, 0]) }); +function ctx(local: Record = {}): ProviderCallCtx { + return { + config: { + provider: "local", + model: "test/model", + dimensions: 2, + local, + openRouter: false, + cache: { enabled: false, maxItems: 0 }, + }, + log: { + trace: vi.fn(), + debug: vi.fn(), + info: vi.fn(), + warn: vi.fn(), + error: vi.fn(), + }, + }; +} + +describe("local model source and load status", () => { + beforeEach(() => { + __resetLocalExtractorForTests(); + pipeline.mockReset().mockResolvedValue(extractor); + Object.assign(env, { + remoteHost: "https://huggingface.co/", + localModelPath: "/original/models", + cacheDir: "/original/cache", + allowRemoteModels: true, + }); + vi.stubEnv("HF_ENDPOINT", ""); + }); + afterEach(() => { + vi.unstubAllEnvs(); + vi.useRealTimers(); + }); + + it("keeps the default model cache outside installed package files", async () => { + pipeline.mockImplementation(async () => { + expect(env.cacheDir).toBe(join(homedir(), ".cache", "memos", "models")); + return extractor; + }); + await new LocalEmbeddingProvider().embed(["test"], "query", ctx()); + }); + + it("uses HF_ENDPOINT but lets explicit local configuration take precedence", async () => { + vi.stubEnv("HF_ENDPOINT", "https://env-mirror.example/"); + const observed: string[] = []; + pipeline.mockImplementation(async () => { + observed.push(env.remoteHost); + return extractor; + }); + const provider = new LocalEmbeddingProvider(); + await provider.embed(["test"], "query", ctx()); + await provider.embed( + ["test"], + "query", + ctx({ remoteHost: "https://config-mirror.example" }), + ); + expect(observed).toEqual([ + "https://env-mirror.example/", + "https://config-mirror.example/", + ]); + expect(env.remoteHost).toBe("https://huggingface.co/"); + }); + + it("applies offline directories before loading and restores the shared environment", async () => { + pipeline.mockImplementation(async (_task, _model, options) => { + expect(env).toMatchObject({ + localModelPath: "/models", + cacheDir: "/cache", + allowRemoteModels: false, + }); + expect(options).toMatchObject({ local_files_only: true }); + return extractor; + }); + await new LocalEmbeddingProvider().embed( + ["test"], + "query", + ctx({ modelPath: "/models", cacheDir: "/cache", offline: true }), + ); + expect(env).toMatchObject({ + localModelPath: "/original/models", + cacheDir: "/original/cache", + allowRemoteModels: true, + }); + }); + + it("restores environment after a failure and permits a later retry", async () => { + pipeline + .mockRejectedValueOnce(new Error("synthetic failure")) + .mockResolvedValue(extractor); + const provider = new LocalEmbeddingProvider(); + await expect( + provider.embed( + ["test"], + "query", + ctx({ remoteHost: "https://mirror.example" }), + ), + ).rejects.toThrow("synthetic failure"); + expect(env.remoteHost).toBe("https://huggingface.co/"); + await expect( + provider.embed( + ["test"], + "query", + ctx({ remoteHost: "https://mirror.example" }), + ), + ).resolves.toEqual([[1, 0]]); + expect(pipeline).toHaveBeenCalledTimes(2); + }); + + it("serializes loads with different sources so their global settings do not overlap", async () => { + let finish!: (value: typeof extractor) => void; + const first = new Promise((resolve) => { + finish = resolve; + }); + const sources: string[] = []; + pipeline.mockImplementation(async () => { + sources.push(env.remoteHost); + return sources.length === 1 ? first : extractor; + }); + const provider = new LocalEmbeddingProvider(); + const a = provider.embed( + ["a"], + "query", + ctx({ remoteHost: "https://a.example/" }), + ); + await vi.waitFor(() => expect(pipeline).toHaveBeenCalledTimes(1)); + const b = provider.embed( + ["b"], + "query", + ctx({ remoteHost: "https://b.example/" }), + ); + await Promise.resolve(); + expect(pipeline).toHaveBeenCalledTimes(1); + finish(extractor); + await Promise.all([a, b]); + expect(sources).toEqual(["https://a.example/", "https://b.example/"]); + expect(env.remoteHost).toBe("https://huggingface.co/"); + }); + + it("reports file download progress", async () => { + const context = ctx(); + pipeline.mockImplementation(async (_task, _model, options) => { + options.progress_callback({ + status: "progress", + file: "onnx/model_quantized.onnx", + progress: 50, + }); + return extractor; + }); + await new LocalEmbeddingProvider().embed(["test"], "query", context); + expect(context.log.info).toHaveBeenCalledWith( + "download.progress", + expect.objectContaining({ + progress: 50, + file: "onnx/model_quantized.onnx", + }), + ); + }); + + it("bounds the initial wait while allowing a slow shared model load to warm up", async () => { + vi.useFakeTimers(); + let finish!: (value: typeof extractor) => void; + pipeline.mockReturnValue( + new Promise((resolve) => { + finish = resolve; + }), + ); + const provider = new LocalEmbeddingProvider(); + const pending = provider.embed( + ["test"], + "query", + ctx({ loadTimeoutMs: 50 }), + ); + const failure = expect(pending).rejects.toMatchObject({ + code: "embedding_unavailable", + }); + await vi.advanceTimersByTimeAsync(51); + await failure; + finish(extractor); + await expect( + provider.embed(["test"], "query", ctx({ loadTimeoutMs: 50 })), + ).resolves.toEqual([[1, 0]]); + }); +}); diff --git a/apps/memos-local-plugin/tests/unit/embedding/local-process.test.ts b/apps/memos-local-plugin/tests/unit/embedding/local-process.test.ts new file mode 100644 index 000000000..5e2297286 --- /dev/null +++ b/apps/memos-local-plugin/tests/unit/embedding/local-process.test.ts @@ -0,0 +1,246 @@ +import { EventEmitter } from "node:events"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import type { ProviderCallCtx } from "../../../core/embedding/types.js"; + +const { fork, pipeline, osPlatform } = vi.hoisted(() => ({ + fork: vi.fn(), + pipeline: vi.fn(), + osPlatform: vi.fn(() => "win32"), +})); +vi.mock("node:child_process", () => ({ fork })); +vi.mock("node:os", async (original) => ({ + ...(await original()), + platform: osPlatform, +})); +vi.mock("@huggingface/transformers", () => ({ pipeline })); +import { LocalEmbeddingProvider } from "../../../core/embedding/providers/local.js"; + +class FakeChild extends EventEmitter { + connected = true; + channel = { ref: vi.fn(), unref: vi.fn() }; + ref = vi.fn(); + unref = vi.fn(); + send = vi.fn( + (_message: unknown, callback?: (error: Error | null) => void) => { + callback?.(null); + return true; + }, + ); + kill = vi.fn(() => { + this.connected = false; + this.emit("exit", 0, null); + return true; + }); +} +let children: FakeChild[]; +let providers: LocalEmbeddingProvider[]; +function provider() { + const p = new LocalEmbeddingProvider(); + providers.push(p); + return p; +} +function ctx(signal?: AbortSignal): ProviderCallCtx { + return { + config: { + provider: "local", + model: "synthetic/model", + dimensions: 2, + local: { offline: true }, + openRouter: false, + cache: { enabled: false, maxItems: 0 }, + }, + signal, + log: { + trace: vi.fn(), + debug: vi.fn(), + info: vi.fn(), + warn: vi.fn(), + error: vi.fn(), + }, + }; +} +function request(child = children[0]!) { + return child.send.mock.calls + .map(([m]) => m as any) + .find((m) => m.type === "embed"); +} +function success(child = children[0]!, vectors = [[1, 0]]) { + child.emit("message", { type: "result", id: request(child).id, vectors }); +} + +beforeEach(() => { + children = []; + providers = []; + pipeline.mockReset(); + fork.mockReset(); + fork.mockImplementation(() => { + const child = new FakeChild(); + children.push(child); + return child; + }); +}); +afterEach(async () => { + await Promise.all(providers.map((p) => p.close())); + vi.unstubAllEnvs(); +}); + +describe("Windows local embedding process isolation", () => { + it("loads embeddings in a child without importing Transformers into the host", async () => { + vi.stubEnv("NODE_OPTIONS", "--require host-preload.cjs"); + vi.stubEnv("NODE_PATH", "host-modules"); + const pending = provider().embed(["synthetic"], "query", ctx()); + await vi.waitFor(() => expect(fork).toHaveBeenCalledTimes(1)); + const [entry, args, options] = fork.mock.calls[0]!; + expect(String(entry)).toMatch(/local-process-entry\.(js|ts)$/); + expect(args).toEqual([]); + expect(options).toMatchObject({ + windowsHide: true, + env: { ELECTRON_RUN_AS_NODE: "1" }, + stdio: ["ignore", "ignore", "ignore", "ipc"], + }); + expect(options.env.NODE_OPTIONS).toBeUndefined(); + expect(options.env.NODE_PATH).toBeUndefined(); + expect(pipeline).not.toHaveBeenCalled(); + success(); + await expect(pending).resolves.toEqual([[1, 0]]); + }); + + it("routes concurrent results and progress to the matching caller", async () => { + const p = provider(); + const a = ctx(); + const b = ctx(); + const first = p.embed(["first"], "query", a); + const second = p.embed(["second"], "query", b); + await vi.waitFor(() => expect(children[0]?.send).toHaveBeenCalledTimes(2)); + const messages = children[0]!.send.mock.calls.map(([m]) => m as any); + children[0]!.emit("message", { + type: "log", + id: messages[1].id, + level: "info", + message: "download.progress", + data: { progress: 50 }, + }); + expect(b.log.info).toHaveBeenCalledWith("download.progress", { + progress: 50, + }); + children[0]!.emit("message", { + type: "result", + id: messages[1].id, + vectors: [[0, 1]], + }); + children[0]!.emit("message", { + type: "result", + id: messages[0].id, + vectors: [[1, 0]], + }); + await expect(first).resolves.toEqual([[1, 0]]); + await expect(second).resolves.toEqual([[0, 1]]); + }); + + it("does not spawn for an aborted request, and cancels only the matching pending call", async () => { + const p = provider(); + const controller = new AbortController(); + controller.abort(new Error("expired")); + await expect( + p.embed(["skip"], "query", ctx(controller.signal)), + ).rejects.toThrow("expired"); + expect(fork).not.toHaveBeenCalled(); + const active = new AbortController(); + const pending = p.embed(["slow"], "query", ctx(active.signal)); + const rejected = expect(pending).rejects.toThrow("cancelled"); + await vi.waitFor(() => expect(fork).toHaveBeenCalledTimes(1)); + active.abort(new Error("cancelled")); + await rejected; + expect(children[0]!.send).toHaveBeenCalledWith( + { type: "cancel", id: request().id }, + expect.any(Function), + ); + success(); // Late completion must be harmless. + }); + + it("rejects crashed work and starts a fresh process for the next request", async () => { + const p = provider(); + const pending = p.embed(["first"], "query", ctx()); + const rejected = expect(pending).rejects.toMatchObject({ + code: "embedding_unavailable", + }); + await vi.waitFor(() => expect(fork).toHaveBeenCalledTimes(1)); + children[0]!.emit("exit", 1, null); + await rejected; + const next = p.embed(["retry"], "query", ctx()); + await vi.waitFor(() => expect(fork).toHaveBeenCalledTimes(2)); + success(children[1]); + await expect(next).resolves.toEqual([[1, 0]]); + }); + + it("propagates load failures and validates worker vectors", async () => { + const p = provider(); + const pending = p.embed(["first"], "query", ctx()); + const failed = expect(pending).rejects.toMatchObject({ + code: "embedding_unavailable", + message: "offline model missing", + }); + await vi.waitFor(() => expect(fork).toHaveBeenCalledTimes(1)); + children[0]!.emit("message", { + type: "error", + id: request().id, + message: "offline model missing", + }); + await failed; + const invalid = p.embed(["invalid"], "query", ctx()); + const rejected = expect(invalid).rejects.toMatchObject({ + code: "embedding_unavailable", + }); + const messages = children[0]!.send.mock.calls + .map(([m]) => m as any) + .filter((m) => m.type === "embed"); + children[0]!.emit("message", { + type: "result", + id: messages.at(-1).id, + vectors: [[NaN]], + }); + await rejected; + }); + + it("rejects startup and IPC errors without loading native code in the host", async () => { + const p = provider(); + fork.mockImplementationOnce(() => { + throw new Error("spawn denied"); + }); + await expect(p.embed(["start"], "query", ctx())).rejects.toMatchObject({ + code: "embedding_unavailable", + }); + fork.mockImplementationOnce(() => { + const child = new FakeChild(); + children.push(child); + child.send.mockImplementation((_m, callback) => { + callback?.(new Error("closed IPC")); + return false; + }); + return child; + }); + await expect(p.embed(["IPC"], "query", ctx())).rejects.toMatchObject({ + code: "embedding_unavailable", + }); + expect(pipeline).not.toHaveBeenCalled(); + }); + + it("shares a process and releases it only after the last provider closes", async () => { + const a = provider(); + const b = provider(); + const first = a.embed(["a"], "query", ctx()); + const second = b.embed(["b"], "query", ctx()); + await vi.waitFor(() => expect(children[0]?.send).toHaveBeenCalledTimes(2)); + for (const [m] of children[0]!.send.mock.calls) + children[0]!.emit("message", { + type: "result", + id: (m as any).id, + vectors: [[1, 0]], + }); + await Promise.all([first, second]); + await a.close(); + expect(children[0]!.kill).not.toHaveBeenCalled(); + await b.close(); + expect(children[0]!.kill).toHaveBeenCalledOnce(); + }); +}); diff --git a/apps/memos-local-plugin/tests/unit/install/hermes-provider-link.test.ts b/apps/memos-local-plugin/tests/unit/install/hermes-provider-link.test.ts index ffa33f0a0..0a5885684 100644 --- a/apps/memos-local-plugin/tests/unit/install/hermes-provider-link.test.ts +++ b/apps/memos-local-plugin/tests/unit/install/hermes-provider-link.test.ts @@ -125,7 +125,7 @@ describe("Hermes provider install links", () => { expect(unixSource).toContain("npm install --omit=dev --legacy-peer-deps"); expect(windowsSource).toMatch( - /"install", "--omit=dev", "--legacy-peer-deps", "--no-fund"/, + /"install", "--omit=dev", "--legacy-peer-deps", "--strict-allow-scripts", "--engine-strict", "--no-fund"/, ); }); diff --git a/apps/memos-local-plugin/tests/unit/install/hermes-version-sync.test.ts b/apps/memos-local-plugin/tests/unit/install/hermes-version-sync.test.ts index 6f2ce6993..e471d0a48 100644 --- a/apps/memos-local-plugin/tests/unit/install/hermes-version-sync.test.ts +++ b/apps/memos-local-plugin/tests/unit/install/hermes-version-sync.test.ts @@ -115,7 +115,7 @@ describe("Hermes version synchronization", () => { expect(syncPosition).toBeGreaterThan(bumpPosition); expect(validationPosition).toBeGreaterThan(syncPosition); expect(packageJson.scripts["release:validate"]).toBe( - "npm run check:hermes-version && npm run lint && npm test", + "npm run lock:check && npm run verify:script-policy && npm run check:hermes-version && npm run lint && npm test", ); expect(workflow).toContain("npm pack --json --silent --pack-destination"); expect(workflow).toContain("raw.match(/^\\[/m)"); diff --git a/apps/memos-local-plugin/tests/unit/install/install-sh.test.ts b/apps/memos-local-plugin/tests/unit/install/install-sh.test.ts index 943345fdd..a436b74c0 100644 --- a/apps/memos-local-plugin/tests/unit/install/install-sh.test.ts +++ b/apps/memos-local-plugin/tests/unit/install/install-sh.test.ts @@ -232,7 +232,7 @@ exit 64 `, ); - const firstAdd = options.firstAdd ?? "ignored-builds"; + const firstAdd = options.firstAdd ?? "success"; const approval = options.approval ?? "success"; const secondAdd = options.secondAdd ?? "success"; const dump = options.dump ?? "success"; @@ -374,8 +374,6 @@ describe("install.sh — CLI surface", () => { expect(r.code).toBe(0); const calls = readFileSync(fixture.log, "utf8").trim().split("\n"); expect(calls).toEqual([ - `plugin --profile web add ${tarball}`, - "plugin --profile web approve-builds better-sqlite3 esbuild sharp !onnxruntime-node !protobufjs !@memtensor/memos-local-plugin", `plugin --profile web add ${tarball}`, "--profile web --dump-config", ]); @@ -385,11 +383,9 @@ describe("install.sh — CLI surface", () => { ]); expect(readFileSync(fixture.dshEnvLog, "utf8").trim().split("\n")).toEqual([ "skip", - "skip", - "skip", ]); expect(readFileSync(fixture.profileWorkspace, "utf8")).toContain( - "onnxruntime-node: false", + '"onnxruntime-node": false', ); expect(r.stdout).toContain("DeepSeek Harness install complete"); expect(r.stdout).toContain("http://127.0.0.1:18801"); @@ -446,7 +442,7 @@ exit 90 expect(calls).toHaveLength(2); expect(readFileSync(fixture.dshEnvLog, "utf8").trim()).toBe("skip"); expect(readFileSync(fixture.profileWorkspace, "utf8")).toContain( - "onnxruntime-node: false", + '"onnxruntime-node": false', ); } finally { rmSync(fixture.root, { recursive: true, force: true }); @@ -520,101 +516,26 @@ exit 90 } }); - it("does not retry installation when reviewed build approval fails", () => { - const fixture = makeDshFixture({ approval: "error" }); + it("does not auto-approve unexpected pending builds", () => { + const fixture = makeDshFixture({ firstAdd: "ignored-builds" }); try { - const tarball = path.join(fixture.root, "memos-local-plugin.tgz"); - writeFileSync(tarball, "fixture", "utf8"); - const r = run(["--agent", "dsh", "--version", tarball], fixture.env); - + const r = run(["--agent", "dsh", "--version", "2.0.16-beta.1"], fixture.env); expect(r.code).not.toBe(0); - const calls = readFileSync(fixture.log, "utf8").trim().split("\n"); - expect(calls).toHaveLength(2); - expect(calls[1]).toContain("approve-builds"); - } finally { - rmSync(fixture.root, { recursive: true, force: true }); - } + expect(readFileSync(fixture.log, "utf8")).not.toContain("approve-builds"); + expect(`${r.stdout}\n${r.stderr}`).toContain("Review the package versions"); + } finally { rmSync(fixture.root, { recursive: true, force: true }); } }); - it("repairs a missing DSH better-sqlite3 binding before reporting success", () => { - const fixture = makeDshFixture({ - firstAdd: "success", - sqliteProbe: "repairable", - }); + it.each(["repairable", "error"] as const)("fails without rebuilding a %s SQLite prebuilt", (sqliteProbe) => { + const fixture = makeDshFixture({ firstAdd: "success", sqliteProbe }); try { - const tarball = path.join(fixture.root, "memos-local-plugin.tgz"); - writeFileSync(tarball, "fixture", "utf8"); - - const r = run(["--agent", "dsh", "--version", tarball], fixture.env); - - expect(r.code).toBe(0); - expect(readFileSync(fixture.pnpmActionLog, "utf8").trim()).toBe( - "rebuild better-sqlite3", - ); - expect(readFileSync(fixture.nativeProbeLog, "utf8").trim().split("\n")).toEqual([ - "better-sqlite3", - "better-sqlite3", - "onnxruntime-node", - ]); - expect(r.stdout).toContain("better-sqlite3 native binding repaired"); - expect(r.stdout).toContain("DeepSeek Harness install complete"); - } finally { - rmSync(fixture.root, { recursive: true, force: true }); - } - }); - - it("fails DSH installation when the targeted better-sqlite3 rebuild fails", () => { - const fixture = makeDshFixture({ - firstAdd: "success", - sqliteProbe: "repairable", - rebuild: "error", - }); - try { - const tarball = path.join(fixture.root, "memos-local-plugin.tgz"); - writeFileSync(tarball, "fixture", "utf8"); - - const r = run(["--agent", "dsh", "--version", tarball], fixture.env); - + const r = run(["--agent", "dsh", "--version", "2.0.16-beta.1"], fixture.env); expect(r.code).not.toBe(0); - expect(readFileSync(fixture.pnpmActionLog, "utf8").trim()).toBe( - "rebuild better-sqlite3", - ); - expect(`${r.stdout}\n${r.stderr}`).toContain( - "better-sqlite3 rebuild failed", - ); + expect(existsSync(fixture.pnpmActionLog)).toBe(false); + expect(readFileSync(fixture.nativeProbeLog, "utf8").trim()).toBe("better-sqlite3"); + expect(`${r.stdout}\n${r.stderr}`).toContain("no source rebuild was attempted"); expect(r.stdout).not.toContain("DeepSeek Harness install complete"); - expect(r.stdout).not.toContain("MemOS Local installed successfully"); - } finally { - rmSync(fixture.root, { recursive: true, force: true }); - } - }); - - it("fails DSH installation when better-sqlite3 remains unusable after rebuild", () => { - const fixture = makeDshFixture({ - firstAdd: "success", - sqliteProbe: "error", - }); - try { - const tarball = path.join(fixture.root, "memos-local-plugin.tgz"); - writeFileSync(tarball, "fixture", "utf8"); - - const r = run(["--agent", "dsh", "--version", tarball], fixture.env); - - expect(r.code).not.toBe(0); - expect(readFileSync(fixture.pnpmActionLog, "utf8").trim()).toBe( - "rebuild better-sqlite3", - ); - expect(readFileSync(fixture.nativeProbeLog, "utf8").trim().split("\n")).toEqual([ - "better-sqlite3", - "better-sqlite3", - ]); - expect(`${r.stdout}\n${r.stderr}`).toContain( - "better-sqlite3 native binding is not loadable", - ); - expect(r.stdout).not.toContain("DeepSeek Harness install complete"); - } finally { - rmSync(fixture.root, { recursive: true, force: true }); - } + } finally { rmSync(fixture.root, { recursive: true, force: true }); } }); it("fails DSH installation when the bundled ONNX CPU backend cannot load", () => { diff --git a/apps/memos-local-plugin/tests/unit/install/sqlite-install-contract.test.ts b/apps/memos-local-plugin/tests/unit/install/sqlite-install-contract.test.ts new file mode 100644 index 000000000..fbc96d250 --- /dev/null +++ b/apps/memos-local-plugin/tests/unit/install/sqlite-install-contract.test.ts @@ -0,0 +1,95 @@ +import { mkdtempSync, readFileSync, writeFileSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { spawnSync } from "node:child_process"; +import { describe, expect, it } from "vitest"; +import { bootstrapMemoryCoreFull } from "../../../core/pipeline/memory-core.js"; +const root = path.resolve(__dirname, "../../.."); +const normalizer = path.join(root, "scripts/normalize-sqlite-lock.cjs"); +describe("SQLite prebuilt installation contract", () => { + it("rejects an old actual host runtime before opening storage", async () => { + const descriptor = Object.getOwnPropertyDescriptor(process.versions, "node")!; + Object.defineProperty(process.versions, "node", { value: "20.19.0", configurable: true }); + try { + await expect(bootstrapMemoryCoreFull({ agent: "deepseek-harness", get home(): never { throw new Error("storage must not be resolved"); } })).rejects.toThrow(/Node.js >=22/); + } finally { Object.defineProperty(process.versions, "node", descriptor); } + }); + it("keeps runtime declarations, both lockfiles and build policy consistent", () => { + const pkg = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")); + const lock = JSON.parse(readFileSync(path.join(root, "package-lock.json"), "utf8")); + expect(pkg.engines.node).toBe(">=22.0.0"); + expect(pkg.dependencies["better-sqlite3"]).toBe("13.0.3"); + expect(lock.packages[""].dependencies["better-sqlite3"]).toBe("13.0.3"); + expect(lock.packages["node_modules/better-sqlite3"]).toMatchObject({version: "13.0.3", gypfile: false, hasInstallScript: false}); + expect(pkg.allowScripts["better-sqlite3"]).toBe(false); + expect(readFileSync(path.join(root, "pnpm-lock.yaml"), "utf8")).toMatch(/better-sqlite3:\s+specifier: 13\.0\.3\s+version: 13\.0\.3/); + }); + it("normalizes only reviewed SQLite metadata and detects later drift", () => { + const dir = mkdtempSync(path.join(tmpdir(), "sqlite-lock-test-")); + const file = path.join(dir, "package-lock.json"); + const actual = JSON.parse(readFileSync(path.join(root, "package-lock.json"), "utf8")); + delete actual.packages["node_modules/better-sqlite3"].gypfile; + delete actual.packages["node_modules/better-sqlite3"].hasInstallScript; + writeFileSync(file, JSON.stringify(actual)); + const run = (...args: string[]) => spawnSync(process.execPath, [normalizer, file, ...args], { encoding: "utf8" }); + try { + expect(run("--check").status).not.toBe(0); + expect(run().status).toBe(0); + expect(run("--check").status).toBe(0); + const repaired = JSON.parse(readFileSync(file, "utf8")); + expect(repaired.packages["node_modules/better-sqlite3"]).toMatchObject({gypfile: false, hasInstallScript: false}); + repaired.packages["node_modules/better-sqlite3"].integrity = "unreviewed"; + writeFileSync(file, JSON.stringify(repaired)); + expect(run().status).not.toBe(0); + expect(JSON.parse(readFileSync(file, "utf8")).packages["node_modules/better-sqlite3"].integrity).toBe("unreviewed"); + } finally { rmSync(dir, { recursive: true, force: true }); } + }); + it("preseeds DSH policy, preserves unrelated settings and refuses an explicit denial", () => { + const source = readFileSync(path.join(root, "install.sh"), "utf8"); + const fn = source.slice(source.indexOf("prepare_dsh_build_policy() {"), source.indexOf("\nrun_dsh_plugin_without_onnx_cuda()")); + const dir = mkdtempSync(path.join(tmpdir(), "dsh-policy-test-")); + const file = path.join(dir, "pnpm-workspace.yaml"); + const run = () => spawnSync("bash", ["-c", `${fn}\nprepare_dsh_build_policy "$1"`, "bash", file], { encoding: "utf8" }); + try { + writeFileSync(file, "packages:\n - .\nallowBuilds:\n other: false\n"); + expect(run().status).toBe(0); + const once = readFileSync(file, "utf8"); + expect(once).toContain('"better-sqlite3": false'); + expect(once).toContain("other: false"); + expect(run().status).toBe(0); + expect(readFileSync(file, "utf8")).toBe(once); + writeFileSync(file, "allowBuilds:\n esbuild: false\n"); + expect(run().status).not.toBe(0); + expect(readFileSync(file, "utf8")).toBe("allowBuilds:\n esbuild: false\n"); + } finally { rmSync(dir, { recursive: true, force: true }); } + }); + it("refuses Node 20 before attempting a deployment", () => { + const source = readFileSync(path.join(root, "install.sh"), "utf8"); + const fn = source.slice(source.indexOf("ensure_node() {"), source.indexOf("\n}", source.indexOf("ensure_node() {")) + 2); + const run = spawnSync("bash", ["-c", `REQUIRED_NODE_MAJOR=22; node_major() { echo 20; }; die() { echo "$*"; exit 1; }; ${fn}\nensure_node`], { encoding: "utf8" }); + expect(run.status).not.toBe(0); + expect(run.stdout).toContain("existing plugin has not been replaced"); + }); + + it.skipIf(process.platform === "win32")("leaves an existing deployment untouched when dependency staging fails", () => { + const source = readFileSync(path.join(root, "install.sh"), "utf8"); + const start = source.indexOf("deploy_tarball_to_prefix() {"); + const fn = source.slice(start, source.indexOf("\n# ─── Generate runtime", start)); + const dir = mkdtempSync(path.join(tmpdir(), "sqlite-stage-test-")); + const prefix = path.join(dir, "existing"); + const unpacked = path.join(dir, "package"); + // Use a real tarball but a failing npm boundary; no user host is involved. + spawnSync("mkdir", ["-p", prefix, unpacked]); + writeFileSync(path.join(prefix, "package.json"), "old-install"); + writeFileSync(path.join(unpacked, "package.json"), "{}"); + const tarball = path.join(dir, "candidate.tgz"); + expect(spawnSync("tar", ["czf", tarball, "-C", dir, "package"]).status).toBe(0); + try { + const result = spawnSync("bash", ["-c", `step() { :; }; success() { :; }; warn() { :; }; die() { echo "$*"; exit 1; }; npm() { return 66; }; BUILT_TARBALL="$2"; ${fn}\ndeploy_tarball_to_prefix "$1"`, "bash", prefix, tarball], { encoding: "utf8" }); + expect(result.status).not.toBe(0); + expect(result.stdout).toContain("existing installation is unchanged"); + expect(readFileSync(path.join(prefix, "package.json"), "utf8")).toBe("old-install"); + } finally { rmSync(dir, { recursive: true, force: true }); } + }); + +}); diff --git a/apps/memos-local-plugin/tests/unit/pipeline/import-bundle.test.ts b/apps/memos-local-plugin/tests/unit/pipeline/import-bundle.test.ts new file mode 100644 index 000000000..01fc8fe30 --- /dev/null +++ b/apps/memos-local-plugin/tests/unit/pipeline/import-bundle.test.ts @@ -0,0 +1,377 @@ +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; + +import { afterEach, beforeEach, describe, expect, it } from "vitest"; + +import type { MemoryCore } from "../../../agent-contract/memory-core.js"; +import { DEFAULT_CONFIG, resolveHome } from "../../../core/config/index.js"; +import { bootstrapMemoryCore } from "../../../core/pipeline/memory-core.js"; +import { openDb } from "../../../core/storage/index.js"; +import { deepSeekHarnessNamespace } from "../../../adapters/deepseek-harness/namespace.js"; + +let dir: string; +let core: MemoryCore; +const row = (id: string, extra: Record = {}) => ({ + id, + episodeId: `episode-${id}`, + sessionId: `session-${id}`, + ts: 1_700_000_000_000, + turnId: 1, + userText: "Synthetic import test", + agentText: "Synthetic answer", + ...extra, +}); + +describe("bundle import validation and ownership", () => { + beforeEach(async () => { + dir = fs.mkdtempSync(path.join(os.tmpdir(), "memos-import-test-")); + core = await bootstrapMemoryCore({ + agent: "deepseek-harness", + namespace: { agentKind: "deepseek-harness", profileId: "default" }, + home: resolveHome("deepseek-harness", dir), + config: structuredClone(DEFAULT_CONFIG), + autoRecovery: false, + }); + }); + + afterEach(async () => { + await core?.shutdown(); + fs.rmSync(dir, { recursive: true, force: true }); + }); + + it("distinguishes invalid integer fields from duplicates without leaking row content", async () => { + const valid = row("valid"); + const result = await core.importBundle({ + traces: [ + valid, + row("fractional-ts", { ts: 12.5 }), + row("fractional-turn", { turnId: 1.5 }), + row("unsafe", { ts: Number.MAX_SAFE_INTEGER + 1 }), + null, + valid, + ], + }); + expect(result).toMatchObject({ + imported: 1, + skipped: 5, + duplicates: 1, + invalid: 4, + failed: 0, + visible: 1, + hidden: 0, + }); + expect(result.issues).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + kind: "trace", + index: 1, + field: "ts", + code: "invalid_integer", + }), + expect.objectContaining({ + kind: "trace", + index: 2, + field: "turnId", + code: "invalid_integer", + }), + ]), + ); + expect(JSON.stringify(result)).not.toContain("Synthetic import test"); + expect((await core.exportBundle()).traces).toHaveLength(1); + }); + + it("reports database failures separately and rolls back synthetic parents", async () => { + const db = openDb({ + filepath: resolveHome("deepseek-harness", dir).dbFile, + agent: "deepseek-harness", + }); + try { + db.exec( + "CREATE TRIGGER reject_import BEFORE INSERT ON traces BEGIN SELECT RAISE(ABORT, 'sensitive database detail'); END", + ); + const result = await core.importBundle({ traces: [row("rejected")] }); + expect(result).toMatchObject({ + imported: 0, + skipped: 1, + failed: 1, + invalid: 0, + duplicates: 0, + }); + expect(result.issues).toContainEqual( + expect.objectContaining({ code: "write_failed", index: 0 }), + ); + expect(JSON.stringify(result)).not.toContain("sensitive database detail"); + expect(db.prepare("SELECT COUNT(*) AS n FROM sessions").get()).toEqual({ + n: 0, + }); + expect(db.prepare("SELECT COUNT(*) AS n FROM episodes").get()).toEqual({ + n: 0, + }); + } finally { + db.close(); + } + }); + + it("previews visibility without writes and explicitly migrates private rows to a target profile", async () => { + const seeded = row("seeded", { + ownerAgentKind: "deepseek-harness", + ownerProfileId: "seed", + }); + const preview = await core.importBundle( + { traces: [seeded] }, + { dryRun: true }, + ); + expect(preview).toMatchObject({ + imported: 1, + visible: 0, + hidden: 1, + dryRun: true, + }); + expect((await core.exportBundle()).traces).toHaveLength(0); + const movedPreview = await core.importBundle( + { traces: [seeded] }, + { dryRun: true, ownership: "target" }, + ); + expect(movedPreview).toMatchObject({ visible: 1, hidden: 0 }); + const result = await core.importBundle( + { traces: [seeded] }, + { ownership: "target" }, + ); + expect(result).toMatchObject({ imported: 1, visible: 1, hidden: 0 }); + expect(await core.getTrace("seeded")).toMatchObject({ + ownerProfileId: "default", + share: { scope: "private" }, + }); + }); + + it("preserves original ownership by default and supports an explicit target profile", async () => { + const seeded = row("preserved", { + ownerAgentKind: "deepseek-harness", + ownerProfileId: "seed", + }); + expect(await core.importBundle({ traces: [seeded] })).toMatchObject({ + hidden: 1, + }); + expect(await core.getTrace("preserved")).toBeNull(); + const result = await core.importBundle( + { traces: [row("target")] }, + { ownership: "target", targetProfileId: "work" }, + ); + expect(result).toMatchObject({ hidden: 1 }); + expect( + await core.getTrace("target", { + agentKind: "deepseek-harness", + profileId: "work", + }), + ).toMatchObject({ ownerProfileId: "work", share: { scope: "private" } }); + }); + + it("round-trips world model structure and evidence without losing legacy string entries", async () => { + const structure = { + environment: [ + { + label: "cloud", + description: "synthetic cloud", + evidenceIds: ["trace-evidence"], + }, + ], + inference: [{ label: "region", description: "synthetic-region" }], + constraints: [ + { + label: "boundary", + description: "synthetic constraint", + evidenceIds: [], + }, + ], + }; + await core.importBundle({ + worldModels: [ + { + id: "world-source", + title: "Synthetic", + body: "Synthetic body", + structure, + version: 3, + status: "active", + }, + ], + }); + const exported = (await core.exportBundle()).worldModels[0]!; + expect(exported.structure).toEqual(structure); + await core.importBundle({ + worldModels: [{ ...exported, id: "world-copy" }], + }); + expect( + (await core.exportBundle()).worldModels.find( + (row) => row.id === "world-copy", + ), + ).toMatchObject({ structure, version: 3 }); + const legacy = { + environment: ["aws"], + inference: ["region=synthetic"], + constraints: ["synthetic-limit"], + }; + await core.importBundle({ + worldModels: [ + { + id: "world-legacy", + title: "Legacy", + body: "Synthetic body", + structure: legacy, + }, + ], + }); + expect( + (await core.exportBundle()).worldModels.find( + (row) => row.id === "world-legacy", + )!.structure, + ).toEqual(legacy); + }); + + it.each([[], { environment: "not-an-array" }, { constraints: [123] }])( + "rejects malformed world model structure in preview and actual import: %j", + async (structure) => { + for (const dryRun of [true, false]) { + const result = await core.importBundle( + { + worldModels: [ + { + id: "invalid-structure", + title: "Synthetic", + body: "Synthetic body", + structure, + }, + ], + }, + { dryRun }, + ); + expect(result).toMatchObject({ imported: 0, invalid: 1, failed: 0 }); + expect(result.issues[0]).toMatchObject({ + code: "invalid_field", + field: expect.stringContaining("structure"), + }); + } + }, + ); + + it("rejects an existing episode's conflicting session in preview and write without synthetic parents", async () => { + const parent = row("parent"); + await core.importBundle({ traces: [parent] }); + const conflict = row("conflict", { episodeId: parent.episodeId }); + for (const dryRun of [true, false]) { + const result = await core.importBundle( + { traces: [conflict] }, + { dryRun }, + ); + expect(result).toMatchObject({ + imported: 0, + invalid: 1, + failed: 0, + skipped: 1, + }); + expect(result.issues[0]).toMatchObject({ + code: "conflicting_parent", + field: "sessionId", + }); + } + const db = openDb({ + filepath: resolveHome("deepseek-harness", dir).dbFile, + agent: "deepseek-harness", + }); + try { + expect(db.prepare("SELECT COUNT(*) AS n FROM sessions").get()).toEqual({ + n: 1, + }); + expect(db.prepare("SELECT trace_ids_json FROM episodes").get()).toEqual({ + trace_ids_json: JSON.stringify([parent.id]), + }); + } finally { + db.close(); + } + }); + + it("detects parent conflicts created earlier in the bundle, including across preview batches", async () => { + const parent = row("batch-parent"); + const traces = [ + parent, + ...Array.from({ length: 100 }, (_, i) => row(`independent-${i}`)), + row("batch-conflict", { episodeId: parent.episodeId }), + ]; + for (const dryRun of [true, false]) { + const result = await core.importBundle({ traces }, { dryRun }); + expect(result).toMatchObject({ imported: 101, invalid: 1, failed: 0 }); + expect(result.issues[0]).toMatchObject({ + index: 101, + code: "conflicting_parent", + }); + if (dryRun) expect((await core.exportBundle()).traces).toHaveLength(0); + } + }); + + it("refuses to attach rows to another profile's session or episode", async () => { + const parent = row("foreign-parent", { + ownerAgentKind: "deepseek-harness", + ownerProfileId: "foreign", + }); + await core.importBundle({ traces: [parent] }); + for (const dryRun of [true, false]) { + const result = await core.importBundle( + { + traces: [ + row("foreign-session", { sessionId: parent.sessionId }), + row("foreign-episode", { + sessionId: parent.sessionId, + episodeId: parent.episodeId, + }), + ], + }, + { dryRun }, + ); + expect(result).toMatchObject({ imported: 0, invalid: 2, failed: 0 }); + expect( + result.issues.every((issue) => issue.code === "conflicting_parent"), + ).toBe(true); + } + }); + + it("makes UI presets and headless share configured-profile records without exposing other profiles", async () => { + const ui = deepSeekHarnessNamespace( + { id: "ui", header: { agentPreset: "standard" } }, + "default", + ); + const headless = deepSeekHarnessNamespace({ id: "headless" }, "default"); + await core.importBundle({ + traces: [ + row("ui-memory", { + ownerAgentKind: ui.agentKind, + ownerProfileId: ui.profileId, + }), + ], + }); + expect(await core.getTrace("ui-memory", headless)).not.toBeNull(); + expect( + await core.getTrace( + "ui-memory", + deepSeekHarnessNamespace( + { id: "other", header: { agentPreset: "standard" } }, + "work", + ), + ), + ).toBeNull(); + }); + + it("bounds detailed issues while retaining accurate totals", async () => { + const result = await core.importBundle({ + traces: Array.from({ length: 80 }, () => null), + }); + expect(result).toMatchObject({ imported: 0, invalid: 80, skipped: 80 }); + expect(result.issues).toHaveLength(50); + }); + + it("rejects malformed top-level collections instead of silently importing nothing", async () => { + await expect( + core.importBundle({ traces: {} as never }), + ).rejects.toMatchObject({ code: "invalid_argument" }); + }); +}); diff --git a/apps/memos-local-plugin/tests/unit/pipeline/memory-core.test.ts b/apps/memos-local-plugin/tests/unit/pipeline/memory-core.test.ts index 2759ae5bd..39241cf40 100644 --- a/apps/memos-local-plugin/tests/unit/pipeline/memory-core.test.ts +++ b/apps/memos-local-plugin/tests/unit/pipeline/memory-core.test.ts @@ -7,6 +7,7 @@ */ import net from "node:net"; +import * as embeddingModule from "../../../core/embedding/index.js"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; @@ -1622,64 +1623,71 @@ describe("bootstrapMemoryCore", () => { }); it("persists lightweight summarizer model status for Hermes overview", async () => { - home = await makeTmpHome({ - agent: "hermes", - configYaml: ` -llm: - provider: host - model: hermes-summary-test -algorithm: - lightweightMemory: - enabled: true -`, - }); - const bridge: HostLlmBridge = { - id: "test-host-llm", - async complete() { - return { - text: JSON.stringify({ summary: "Hermes remembered the overview status fact" }), - model: "hermes-summary-test", - durationMs: 1, - }; - }, - }; - core = await bootstrapMemoryCore({ - agent: "hermes", - home: home.home, - config: home.config, - pkgVersion: "bootstrap-test", - hostLlmBridge: bridge, - now: () => 1_700_000_000_000, - }); - await core.init(); + // This test verifies summarizer status, without downloading embedding models. + const embeddingFactory = vi.spyOn(embeddingModule, "createEmbedder") + .mockReturnValue(fakeEmbedder({ dimensions: TEST_EMBED_DIMENSIONS })); + try { + home = await makeTmpHome({ + agent: "hermes", + configYaml: ` + llm: + provider: host + model: hermes-summary-test + algorithm: + lightweightMemory: + enabled: true + `, + }); + const bridge: HostLlmBridge = { + id: "test-host-llm", + async complete() { + return { + text: JSON.stringify({ summary: "Hermes remembered the overview status fact" }), + model: "hermes-summary-test", + durationMs: 1, + }; + }, + }; + core = await bootstrapMemoryCore({ + agent: "hermes", + home: home.home, + config: home.config, + pkgVersion: "bootstrap-test", + hostLlmBridge: bridge, + now: () => 1_700_000_000_000, + }); + await core.init(); - const start = await core.onTurnStart({ - agent: "hermes", - sessionId: "hermes-lightweight-status", - userText: "请记住 Hermes 摘要模型状态应该显示已调用", - ts: 1_700_000_000_000, - }); - await core.onTurnEnd({ - agent: "hermes", - sessionId: "hermes-lightweight-status", - episodeId: start.query.episodeId!, - agentText: "已记住。", - toolCalls: [], - ts: 1_700_000_000_100, - }); - - const logs = await core.listApiLogs({ toolName: "system_model_status", limit: 10 }); - const llmRows = logs.logs - .map((row) => JSON.parse(row.outputJson) as { role?: string; status?: string; op?: string }) - .filter((row) => row.role === "llm"); - expect(llmRows).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - status: "ok", - op: "capture.summarize", - }), - ]), - ); + const start = await core.onTurnStart({ + agent: "hermes", + sessionId: "hermes-lightweight-status", + userText: "请记住 Hermes 摘要模型状态应该显示已调用", + ts: 1_700_000_000_000, + }); + await core.onTurnEnd({ + agent: "hermes", + sessionId: "hermes-lightweight-status", + episodeId: start.query.episodeId!, + agentText: "已记住。", + toolCalls: [], + ts: 1_700_000_000_100, + }); + + const logs = await core.listApiLogs({ toolName: "system_model_status", limit: 10 }); + const llmRows = logs.logs + .map((row) => JSON.parse(row.outputJson) as { role?: string; status?: string; op?: string }) + .filter((row) => row.role === "llm"); + expect(llmRows).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + status: "ok", + op: "capture.summarize", + }), + ]), + ); + } finally { + embeddingFactory.mockRestore(); + } }); it("init() recovers orphaned open episodes left behind by a previous crash", async () => { diff --git a/apps/memos-local-plugin/tests/unit/scripts/migrate-dsh-preset-profile.test.ts b/apps/memos-local-plugin/tests/unit/scripts/migrate-dsh-preset-profile.test.ts new file mode 100644 index 000000000..1cfed23b1 --- /dev/null +++ b/apps/memos-local-plugin/tests/unit/scripts/migrate-dsh-preset-profile.test.ts @@ -0,0 +1,135 @@ +import fs from "node:fs"; +import path from "node:path"; +import Database from "better-sqlite3"; +import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import { makeTmpDb, type TmpDbHandle } from "../../helpers/tmp-db.js"; +import { migrateDshPresetProfile } from "../../../scripts/migrate-dsh-preset-profile.mjs"; + +let handle: TmpDbHandle; +beforeEach(() => { + handle = makeTmpDb({ agent: "deepseek-harness" }); + const meta = JSON.stringify({ + namespace: { + agentKind: "deepseek-harness", + profileId: "standard", + profileLabel: "standard", + }, + ownerProfileId: "standard", + }); + handle.db + .prepare( + "INSERT INTO sessions(id,agent,owner_agent_kind,owner_profile_id,started_at,last_seen_at,meta_json) VALUES('s','deepseek-harness','deepseek-harness','standard',1,1,?)", + ) + .run(meta); + handle.db.exec( + "INSERT INTO episodes(id,session_id,owner_agent_kind,owner_profile_id,started_at) VALUES('e','s','deepseek-harness','standard',1)", + ); + handle.db.exec( + "INSERT INTO traces(id,session_id,episode_id,owner_agent_kind,owner_profile_id,ts,user_text,agent_text,turn_id,vec_summary) VALUES('t','s','e','deepseek-harness','standard',1,'Synthetic migration','Synthetic answer',1,X'0000803F')", + ); + handle.db.exec( + "INSERT INTO sessions(id,agent,owner_agent_kind,owner_profile_id,started_at,last_seen_at) VALUES('other','deepseek-harness','deepseek-harness','work',1,1),('other-agent','hermes','hermes','standard',1,1)", + ); +}); +afterEach(() => handle.cleanup()); +const options = () => ({ + dbPath: handle.filepath, + from: "standard", + to: "default", +}); + +describe("explicit migration of legacy DSH preset ownership", () => { + it("defaults to a read-only preview and never merges other profiles", async () => { + const result = await migrateDshPresetProfile(options()); + expect(result).toMatchObject({ + dryRun: true, + counts: { traces: 1, sessions: 1, episodes: 1 }, + }); + expect( + handle.db.prepare("SELECT owner_profile_id FROM traces").get(), + ).toEqual({ owner_profile_id: "standard" }); + }); + + it("backs up first and atomically preserves IDs, vectors, sharing and namespace metadata", async () => { + const backupPath = path.join(handle.dir, "before.db"); + const result = await migrateDshPresetProfile({ + ...options(), + apply: true, + backupPath, + }); + expect(result).toMatchObject({ dryRun: false, backupPath }); + const saved = new Database(backupPath, { readonly: true }); + try { + expect( + saved.prepare("SELECT owner_profile_id FROM traces").get(), + ).toEqual({ owner_profile_id: "standard" }); + } finally { + saved.close(); + } + expect( + handle.db + .prepare( + "SELECT id,owner_profile_id,hex(vec_summary) AS vec,share_scope FROM traces", + ) + .get(), + ).toEqual({ + id: "t", + owner_profile_id: "default", + vec: "0000803F", + share_scope: "private", + }); + const session = handle.db + .prepare("SELECT meta_json FROM sessions WHERE id='s'") + .get() as { meta_json: string }; + expect(JSON.parse(session.meta_json)).toMatchObject({ + ownerProfileId: "default", + namespace: { profileId: "default" }, + }); + expect( + handle.db + .prepare("SELECT owner_profile_id FROM sessions WHERE id='other'") + .get(), + ).toEqual({ owner_profile_id: "work" }); + expect( + handle.db + .prepare("SELECT owner_profile_id FROM sessions WHERE id='other-agent'") + .get(), + ).toEqual({ owner_profile_id: "standard" }); + }); + + it("rolls back all ownership updates on a conflicting skill name", async () => { + handle.db.exec( + "INSERT INTO skills(id,owner_agent_kind,owner_profile_id,name,invocation_guide,created_at,updated_at) VALUES('a','deepseek-harness','standard','synthetic','guide',1,1),('b','deepseek-harness','default','synthetic','guide',1,1)", + ); + const backupPath = path.join(handle.dir, "before.db"); + await expect( + migrateDshPresetProfile({ ...options(), apply: true, backupPath }), + ).rejects.toThrow(); + expect( + handle.db.prepare("SELECT owner_profile_id FROM episodes").get(), + ).toEqual({ owner_profile_id: "standard" }); + expect( + handle.db.prepare("SELECT owner_profile_id FROM traces").get(), + ).toEqual({ owner_profile_id: "standard" }); + expect(fs.existsSync(backupPath)).toBe(true); + }); + + it("requires a new backup path before applying changes", async () => { + await expect( + migrateDshPresetProfile({ ...options(), apply: true }), + ).rejects.toThrow(/backup/i); + const backupPath = path.join(handle.dir, "protected.db"); + fs.writeFileSync(backupPath, "keep"); + await expect( + migrateDshPresetProfile({ ...options(), apply: true, backupPath }), + ).rejects.toThrow(); + expect(fs.readFileSync(backupPath, "utf8")).toBe("keep"); + await expect( + migrateDshPresetProfile({ + ...options(), + apply: true, + backupPath: handle.filepath, + }), + ).rejects.toThrow(); + }); +}); diff --git a/apps/memos-local-plugin/tests/unit/server/http.test.ts b/apps/memos-local-plugin/tests/unit/server/http.test.ts index 8291e01bd..c7072e7c3 100644 --- a/apps/memos-local-plugin/tests/unit/server/http.test.ts +++ b/apps/memos-local-plugin/tests/unit/server/http.test.ts @@ -668,6 +668,25 @@ describe("HTTP server — REST routes", () => { expect(body.imported).toBe(0); }); + it("forwards preview and explicit import ownership choices", async () => { + const r = await fetch(`${handle.url}/api/v1/import?dryRun=true&ownership=target&targetProfileId=work`, { + method: "POST", headers: { "content-type": "application/json" }, + body: JSON.stringify({ version: 1, traces: [] }), + }); + expect(r.status).toBe(200); + expect(core.importBundle).toHaveBeenCalledWith({ version: 1, traces: [] }, { + dryRun: true, ownership: "target", targetProfileId: "work", + }); + }); + + it("rejects invalid import options before calling the core", async () => { + const r = await fetch(`${handle.url}/api/v1/import?ownership=public`, { + method: "POST", headers: { "content-type": "application/json" }, body: "{}", + }); + expect(r.status).toBe(400); + expect(core.importBundle).not.toHaveBeenCalled(); + }); + it("GET /api/v1/embeddings/maintenance returns vector health", async () => { const r = await fetch(`${handle.url}/api/v1/embeddings/maintenance`); expect(r.status).toBe(200); diff --git a/apps/memos-local-plugin/tests/unit/server/models.test.ts b/apps/memos-local-plugin/tests/unit/server/models.test.ts index 43e292050..18cfef5cf 100644 --- a/apps/memos-local-plugin/tests/unit/server/models.test.ts +++ b/apps/memos-local-plugin/tests/unit/server/models.test.ts @@ -3,6 +3,12 @@ import { describe, expect, it, vi } from "vitest"; import { probeLocalEmbedding } from "../../../server/routes/models.js"; describe("local embedding model probe", () => { + it("tests unsaved local model source and offline settings", async () => { + const create = vi.fn(() => ({ embedOne: vi.fn(async () => Float32Array.from([1, 0])) })); + const local = { remoteHost: "https://mirror.example/", modelPath: "/models", offline: true }; + await expect(probeLocalEmbedding("test/model", create, local)).resolves.toBe(2); + expect(create).toHaveBeenCalledWith("test/model", local); + }); it("loads the default MiniLM model and verifies a real vector", async () => { const embedOne = vi.fn(async () => Float32Array.from([0.1, 0.2, 0.3])); const create = vi.fn(() => ({ embedOne })); diff --git a/apps/memos-local-plugin/viewer/src/stores/i18n.ts b/apps/memos-local-plugin/viewer/src/stores/i18n.ts index 0833819c5..cf5564050 100644 --- a/apps/memos-local-plugin/viewer/src/stores/i18n.ts +++ b/apps/memos-local-plugin/viewer/src/stores/i18n.ts @@ -776,9 +776,25 @@ const en = { "import.export.desc": "Save every memory, experience, environment knowledge entry and skill to a portable JSON bundle. Safe to share with other local installs.", "import.export.btn": "Export JSON bundle", + "import.preview": "Preview import", + "import.confirm": "Import valid rows", + "import.ownership": "Memory ownership", + "import.ownership.preserve": "Preserve original ownership", + "import.ownership.target": "Move to a target profile", + "import.targetProfile": "Target profile", + "import.targetProfile.hint": "Leave empty to use the active profile", + "import.visibility.hint": "Preview makes no writes. Visibility is calculated for the active profile. Private memories remain private.", + "import.preview.done": "Preview: {imported} candidates; {duplicates} duplicates, {invalid} invalid, {failed} failed. Visible here: {visible}; hidden: {hidden}.", + "import.result.done": "Imported {imported}; duplicates {duplicates}, invalid {invalid}, failed {failed}. Visible here: {visible}; hidden: {hidden}.", + "settings.embedding.remoteHost": "Model mirror URL (empty uses HF_ENDPOINT)", + "settings.embedding.modelPath": "Local model directory", + "settings.embedding.cacheDir": "Model cache directory", + "settings.embedding.offline": "Use local files only", + "settings.embedding.loadTimeout": "Model loading timeout (seconds)", + "settings.embedding.loading": "Loading the local model. First use may download model files; progress is available in Logs. A request timeout can leave background warmup running.", "import.import.title": "Import a bundle", "import.import.desc": - "Restore memories, experiences, environment knowledge and skills from a JSON bundle. Your existing data is preserved; imported rows are added alongside with new ids.", + "Restore memories, experiences, environment knowledge and skills from a JSON bundle. Existing ids are preserved; duplicates are skipped. Preview ownership and visibility before importing.", "import.import.btn": "Choose JSON bundle…", "import.migrate.title": "Migrate from legacy plugin (memos-local-openclaw / memos-local-hermes)", "import.migrate.desc": @@ -1651,9 +1667,25 @@ const zh: Record = { "import.export.title": "导出当前数据库", "import.export.desc": "把记忆、经验、环境认知和技能全部导成 JSON 包,可分享给其他本机实例。", "import.export.btn": "导出 JSON 包", + "import.preview": "预览导入", + "import.confirm": "导入有效记录", + "import.ownership": "记忆归属", + "import.ownership.preserve": "保留原有归属", + "import.ownership.target": "迁移到目标 profile", + "import.targetProfile": "目标 profile", + "import.targetProfile.hint": "留空使用当前 profile", + "import.visibility.hint": "预览不会写入数据。可见性按当前运行的 profile 计算,私有记忆仍保持私有。", + "import.preview.done": "预览:预计可导入 {imported} 条;重复 {duplicates},无效 {invalid},失败 {failed}。当前可见 {visible},不可见 {hidden}。", + "import.result.done": "已导入 {imported} 条;重复 {duplicates},无效 {invalid},失败 {failed}。当前可见 {visible},不可见 {hidden}。", + "settings.embedding.remoteHost": "模型镜像地址(留空使用 HF_ENDPOINT)", + "settings.embedding.modelPath": "本地模型目录", + "settings.embedding.cacheDir": "模型缓存目录", + "settings.embedding.offline": "仅使用本地文件", + "settings.embedding.loadTimeout": "模型加载超时(秒)", + "settings.embedding.loading": "正在加载本地模型,首次使用可能需要下载文件;进度可在日志中查看。请求超时后,后台预热仍可能继续。", "import.import.title": "导入一个包", "import.import.desc": - "从 JSON 包中恢复记忆、经验、环境认知和技能。原有数据保留,导入内容以新 id 追加。", + "从 JSON 包中恢复记忆、经验、环境认知和技能。保留原有 id,跳过重复记录;导入前可预览归属和可见性。", "import.import.btn": "选择 JSON 文件…", "import.migrate.title": "从旧插件迁入(memos-local-openclaw / memos-local-hermes)", "import.migrate.desc": diff --git a/apps/memos-local-plugin/viewer/src/views/ImportView.tsx b/apps/memos-local-plugin/viewer/src/views/ImportView.tsx index 6cac347a9..51effd25e 100644 --- a/apps/memos-local-plugin/viewer/src/views/ImportView.tsx +++ b/apps/memos-local-plugin/viewer/src/views/ImportView.tsx @@ -4,7 +4,7 @@ * - Export: `GET /api/v1/export` returns a JSON bundle of every * trace/policy/world-model/skill. We trigger a browser download. * - Import: POST the file back to `/api/v1/import`. The server - * preserves existing data and assigns fresh ids to imported rows. + * preserves existing ids and skips duplicates. * - Migrate: `POST /api/v1/migrate/legacy/run` — scans the legacy * SQLite file for the **currently running agent** (openclaw or * hermes — the server picks the right path based on its own @@ -20,6 +20,7 @@ import { api } from "../api/client"; import { health } from "../stores/health"; import { t } from "../stores/i18n"; import { Icon } from "../components/Icon"; +import type { MemoryImportResult } from "../../../agent-contract/import"; type NativeImportKind = "hermes" | "openclaw"; @@ -160,24 +161,36 @@ function ExportCard() { function ImportCard() { const [busy, setBusy] = useState(false); + const [file, setFile] = useState(null); + const [ownership, setOwnership] = useState<"preserve" | "target">("preserve"); + const [targetProfileId, setTargetProfileId] = useState(""); + const [preview, setPreview] = useState(null); + const [result, setResult] = useState(null); const [status, setStatus] = useState<{ kind: "ok" | "error"; text: string; } | null>(null); - const run = async (file: File) => { + const resetPreview = () => { setPreview(null); setResult(null); setStatus(null); }; + const run = async (file: File, dryRun: boolean) => { setBusy(true); setStatus(null); try { const form = new FormData(); form.append("bundle", file); - const r = await api.postRaw<{ imported: number; skipped: number }>( - "/api/v1/import", + const query = new URLSearchParams({ ownership, dryRun: String(dryRun) }); + if (ownership === "target" && targetProfileId.trim()) query.set("targetProfileId", targetProfileId.trim()); + const r = await api.postRaw( + `/api/v1/import?${query}`, form, ); + if (dryRun) { setPreview(r); setResult(null); } else { setResult(r); setPreview(null); } setStatus({ - kind: "ok", - text: `Imported ${r.imported} / skipped ${r.skipped}`, + kind: r.invalid || r.failed ? "error" : "ok", + text: t(dryRun ? "import.preview.done" : "import.result.done", { + imported: r.imported, duplicates: r.duplicates, invalid: r.invalid, failed: r.failed, + visible: r.visible, hidden: r.hidden, + }), }); } catch (err) { setStatus({ kind: "error", text: (err as Error).message }); @@ -206,6 +219,22 @@ function ImportCard() { +
+ + {ownership === "target" && } +

{t("import.visibility.hint")}

+ {file &&
+ {file.name} + + +
} +
{status && (
)} - {status?.kind === "ok" && } + {(preview ?? result)?.issues?.length ?
    + {(preview ?? result)!.issues.map(issue =>
  • + {issue.kind}[{issue.index + 1}]{issue.field ? ` · ${issue.field}` : ""}: {issue.message} ({issue.code}) +
  • )} +
: null} + {result && result.imported > 0 && } ); } diff --git a/apps/memos-local-plugin/viewer/src/views/SettingsView.tsx b/apps/memos-local-plugin/viewer/src/views/SettingsView.tsx index d3e62fdd5..43d2efb1a 100644 --- a/apps/memos-local-plugin/viewer/src/views/SettingsView.tsx +++ b/apps/memos-local-plugin/viewer/src/views/SettingsView.tsx @@ -39,6 +39,13 @@ interface ProviderBlock { temperature?: number; maxInputTokens?: number; batchSize?: number; + local?: { + remoteHost?: string; + modelPath?: string; + cacheDir?: string; + offline?: boolean; + loadTimeoutMs?: number; + }; } interface AlgorithmBlock { @@ -408,6 +415,7 @@ function ModelCard({ provider: block.provider, endpoint: block.endpoint, model: block.model, + local: block.local, apiKey: sanitizeApiKey(block.apiKey), }); setResult(r); @@ -472,6 +480,7 @@ function ModelCard({ {localHint}
)} + {isLocal && testing &&
{t("settings.embedding.loading")}
}
onPatch({ model: (e.target as HTMLInputElement).value })} /> - + {!isLocal && onPatch({ endpoint: (e.target as HTMLInputElement).value })} /> - - + } + {!isLocal && onPatch({ apiKey: (e.target as HTMLInputElement).value })} /> - + } + {isLocal && ([ + ["remoteHost", "settings.embedding.remoteHost"], + ["modelPath", "settings.embedding.modelPath"], + ["cacheDir", "settings.embedding.cacheDir"], + ] as const).map(([key, label]) => + onPatch({ local: { ...block.local, [key]: (event.target as HTMLInputElement).value } })} /> + )} + {isLocal && + onPatch({ local: { ...block.local, offline: (event.target as HTMLInputElement).checked } })} /> + } + {isLocal && + onPatch({ local: { ...block.local, loadTimeoutMs: Math.min(3600, Math.max(1, Number((event.target as HTMLInputElement).value) || 120)) * 1000 } })} /> + } {type === "embedding" && (