@aislop-inc/opencode-mem 0.0.0-stage → 2.41.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +811 -2
- package/dist/config.d.ts +577 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1141 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1268 -0
- package/dist/plugin.d.ts +10 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +10 -0
- package/dist/services/ai/ai-provider-factory.d.ts +8 -0
- package/dist/services/ai/ai-provider-factory.d.ts.map +1 -0
- package/dist/services/ai/ai-provider-factory.js +61 -0
- package/dist/services/ai/api-key-placeholder.d.ts +2 -0
- package/dist/services/ai/api-key-placeholder.d.ts.map +1 -0
- package/dist/services/ai/api-key-placeholder.js +14 -0
- package/dist/services/ai/internal-capture-sessions.d.ts +7 -0
- package/dist/services/ai/internal-capture-sessions.d.ts.map +1 -0
- package/dist/services/ai/internal-capture-sessions.js +31 -0
- package/dist/services/ai/opencode-diagnostics.d.ts +8 -0
- package/dist/services/ai/opencode-diagnostics.d.ts.map +1 -0
- package/dist/services/ai/opencode-diagnostics.js +36 -0
- package/dist/services/ai/opencode-host-config.d.ts +11 -0
- package/dist/services/ai/opencode-host-config.d.ts.map +1 -0
- package/dist/services/ai/opencode-host-config.js +51 -0
- package/dist/services/ai/opencode-provider-loader.d.ts +4 -0
- package/dist/services/ai/opencode-provider-loader.d.ts.map +1 -0
- package/dist/services/ai/opencode-provider-loader.js +4 -0
- package/dist/services/ai/opencode-provider.d.ts +154 -0
- package/dist/services/ai/opencode-provider.d.ts.map +1 -0
- package/dist/services/ai/opencode-provider.js +731 -0
- package/dist/services/ai/opencode-sdk-client.d.ts +7 -0
- package/dist/services/ai/opencode-sdk-client.d.ts.map +1 -0
- package/dist/services/ai/opencode-sdk-client.js +38 -0
- package/dist/services/ai/profile-llm-client.d.ts +3 -0
- package/dist/services/ai/profile-llm-client.d.ts.map +1 -0
- package/dist/services/ai/profile-llm-client.js +29 -0
- package/dist/services/ai/provider-config.d.ts +19 -0
- package/dist/services/ai/provider-config.d.ts.map +1 -0
- package/dist/services/ai/provider-config.js +36 -0
- package/dist/services/ai/providers/anthropic-messages.d.ts +35 -0
- package/dist/services/ai/providers/anthropic-messages.d.ts.map +1 -0
- package/dist/services/ai/providers/anthropic-messages.js +220 -0
- package/dist/services/ai/providers/api-route.d.ts +49 -0
- package/dist/services/ai/providers/api-route.d.ts.map +1 -0
- package/dist/services/ai/providers/api-route.js +57 -0
- package/dist/services/ai/providers/atlas-cloud.d.ts +51 -0
- package/dist/services/ai/providers/atlas-cloud.d.ts.map +1 -0
- package/dist/services/ai/providers/atlas-cloud.js +59 -0
- package/dist/services/ai/providers/base-provider.d.ts +33 -0
- package/dist/services/ai/providers/base-provider.d.ts.map +1 -0
- package/dist/services/ai/providers/base-provider.js +24 -0
- package/dist/services/ai/providers/cheaper-inference.d.ts +50 -0
- package/dist/services/ai/providers/cheaper-inference.d.ts.map +1 -0
- package/dist/services/ai/providers/cheaper-inference.js +58 -0
- package/dist/services/ai/providers/cloudgpu.d.ts +52 -0
- package/dist/services/ai/providers/cloudgpu.d.ts.map +1 -0
- package/dist/services/ai/providers/cloudgpu.js +60 -0
- package/dist/services/ai/providers/google-gemini.d.ts +16 -0
- package/dist/services/ai/providers/google-gemini.d.ts.map +1 -0
- package/dist/services/ai/providers/google-gemini.js +228 -0
- package/dist/services/ai/providers/minimax.d.ts +38 -0
- package/dist/services/ai/providers/minimax.d.ts.map +1 -0
- package/dist/services/ai/providers/minimax.js +57 -0
- package/dist/services/ai/providers/openai-chat-completion.d.ts +30 -0
- package/dist/services/ai/providers/openai-chat-completion.d.ts.map +1 -0
- package/dist/services/ai/providers/openai-chat-completion.js +532 -0
- package/dist/services/ai/providers/openai-responses.d.ts +14 -0
- package/dist/services/ai/providers/openai-responses.d.ts.map +1 -0
- package/dist/services/ai/providers/openai-responses.js +182 -0
- package/dist/services/ai/providers/orcarouter.d.ts +52 -0
- package/dist/services/ai/providers/orcarouter.d.ts.map +1 -0
- package/dist/services/ai/providers/orcarouter.js +66 -0
- package/dist/services/ai/providers/runcrate.d.ts +49 -0
- package/dist/services/ai/providers/runcrate.d.ts.map +1 -0
- package/dist/services/ai/providers/runcrate.js +57 -0
- package/dist/services/ai/session/ai-session-manager.d.ts +25 -0
- package/dist/services/ai/session/ai-session-manager.d.ts.map +1 -0
- package/dist/services/ai/session/ai-session-manager.js +180 -0
- package/dist/services/ai/session/session-types.d.ts +43 -0
- package/dist/services/ai/session/session-types.d.ts.map +1 -0
- package/dist/services/ai/session/session-types.js +1 -0
- package/dist/services/ai/tools/tool-schema.d.ts +41 -0
- package/dist/services/ai/tools/tool-schema.d.ts.map +1 -0
- package/dist/services/ai/tools/tool-schema.js +24 -0
- package/dist/services/ai/validators/user-profile-validator.d.ts +13 -0
- package/dist/services/ai/validators/user-profile-validator.d.ts.map +1 -0
- package/dist/services/ai/validators/user-profile-validator.js +114 -0
- package/dist/services/api-handlers.d.ts +277 -0
- package/dist/services/api-handlers.d.ts.map +1 -0
- package/dist/services/api-handlers.js +1740 -0
- package/dist/services/auth-token.d.ts +11 -0
- package/dist/services/auth-token.d.ts.map +1 -0
- package/dist/services/auth-token.js +44 -0
- package/dist/services/auto-capture-config-status.d.ts +15 -0
- package/dist/services/auto-capture-config-status.d.ts.map +1 -0
- package/dist/services/auto-capture-config-status.js +31 -0
- package/dist/services/auto-capture.d.ts +33 -0
- package/dist/services/auto-capture.d.ts.map +1 -0
- package/dist/services/auto-capture.js +906 -0
- package/dist/services/auto-update.d.ts +28 -0
- package/dist/services/auto-update.d.ts.map +1 -0
- package/dist/services/auto-update.js +197 -0
- package/dist/services/capture-evidence-events.d.ts +3 -0
- package/dist/services/capture-evidence-events.d.ts.map +1 -0
- package/dist/services/capture-evidence-events.js +15 -0
- package/dist/services/capture-evidence.d.ts +21 -0
- package/dist/services/capture-evidence.d.ts.map +1 -0
- package/dist/services/capture-evidence.js +168 -0
- package/dist/services/capture-tool-evidence.d.ts +21 -0
- package/dist/services/capture-tool-evidence.d.ts.map +1 -0
- package/dist/services/capture-tool-evidence.js +109 -0
- package/dist/services/cleanup-service.d.ts +26 -0
- package/dist/services/cleanup-service.d.ts.map +1 -0
- package/dist/services/cleanup-service.js +199 -0
- package/dist/services/client.d.ts +167 -0
- package/dist/services/client.d.ts.map +1 -0
- package/dist/services/client.js +535 -0
- package/dist/services/context.d.ts +15 -0
- package/dist/services/context.d.ts.map +1 -0
- package/dist/services/context.js +44 -0
- package/dist/services/cors.d.ts +13 -0
- package/dist/services/cors.d.ts.map +1 -0
- package/dist/services/cors.js +52 -0
- package/dist/services/deduplication-service.d.ts +29 -0
- package/dist/services/deduplication-service.d.ts.map +1 -0
- package/dist/services/deduplication-service.js +113 -0
- package/dist/services/dreaming-lock.d.ts +6 -0
- package/dist/services/dreaming-lock.d.ts.map +1 -0
- package/dist/services/dreaming-lock.js +84 -0
- package/dist/services/dreaming-service.d.ts +96 -0
- package/dist/services/dreaming-service.d.ts.map +1 -0
- package/dist/services/dreaming-service.js +626 -0
- package/dist/services/embedding.d.ts +92 -0
- package/dist/services/embedding.d.ts.map +1 -0
- package/dist/services/embedding.js +467 -0
- package/dist/services/injected-prompt-filter.d.ts +49 -0
- package/dist/services/injected-prompt-filter.d.ts.map +1 -0
- package/dist/services/injected-prompt-filter.js +79 -0
- package/dist/services/jsonc.d.ts +7 -0
- package/dist/services/jsonc.d.ts.map +1 -0
- package/dist/services/jsonc.js +110 -0
- package/dist/services/language-detector.d.ts +3 -0
- package/dist/services/language-detector.d.ts.map +1 -0
- package/dist/services/language-detector.js +33 -0
- package/dist/services/logger.d.ts +15 -0
- package/dist/services/logger.d.ts.map +1 -0
- package/dist/services/logger.js +171 -0
- package/dist/services/markdown/backend.d.ts +35 -0
- package/dist/services/markdown/backend.d.ts.map +1 -0
- package/dist/services/markdown/backend.js +111 -0
- package/dist/services/markdown/document.d.ts +44 -0
- package/dist/services/markdown/document.d.ts.map +1 -0
- package/dist/services/markdown/document.js +159 -0
- package/dist/services/markdown/reconcile.d.ts +26 -0
- package/dist/services/markdown/reconcile.d.ts.map +1 -0
- package/dist/services/markdown/reconcile.js +333 -0
- package/dist/services/markdown/vault.d.ts +32 -0
- package/dist/services/markdown/vault.d.ts.map +1 -0
- package/dist/services/markdown/vault.js +142 -0
- package/dist/services/markdown/watcher.d.ts +22 -0
- package/dist/services/markdown/watcher.d.ts.map +1 -0
- package/dist/services/markdown/watcher.js +131 -0
- package/dist/services/memory-portability-service.d.ts +38 -0
- package/dist/services/memory-portability-service.d.ts.map +1 -0
- package/dist/services/memory-portability-service.js +372 -0
- package/dist/services/memory-provenance.d.ts +16 -0
- package/dist/services/memory-provenance.d.ts.map +1 -0
- package/dist/services/memory-provenance.js +115 -0
- package/dist/services/memory-recall.d.ts +49 -0
- package/dist/services/memory-recall.d.ts.map +1 -0
- package/dist/services/memory-recall.js +196 -0
- package/dist/services/memory-scope.d.ts +17 -0
- package/dist/services/memory-scope.d.ts.map +1 -0
- package/dist/services/memory-scope.js +43 -0
- package/dist/services/migration-service.d.ts +43 -0
- package/dist/services/migration-service.d.ts.map +1 -0
- package/dist/services/migration-service.js +333 -0
- package/dist/services/onnxruntime-resolve.d.ts +25 -0
- package/dist/services/onnxruntime-resolve.d.ts.map +1 -0
- package/dist/services/onnxruntime-resolve.js +176 -0
- package/dist/services/privacy.d.ts +38 -0
- package/dist/services/privacy.d.ts.map +1 -0
- package/dist/services/privacy.js +156 -0
- package/dist/services/request-timeouts.d.ts +4 -0
- package/dist/services/request-timeouts.d.ts.map +1 -0
- package/dist/services/request-timeouts.js +5 -0
- package/dist/services/runtime-require.d.ts +18 -0
- package/dist/services/runtime-require.d.ts.map +1 -0
- package/dist/services/runtime-require.js +75 -0
- package/dist/services/secret-resolver.d.ts +2 -0
- package/dist/services/secret-resolver.d.ts.map +1 -0
- package/dist/services/secret-resolver.js +65 -0
- package/dist/services/shard-inventory-service.d.ts +70 -0
- package/dist/services/shard-inventory-service.d.ts.map +1 -0
- package/dist/services/shard-inventory-service.js +315 -0
- package/dist/services/shard-path-migration-service.d.ts +32 -0
- package/dist/services/shard-path-migration-service.d.ts.map +1 -0
- package/dist/services/shard-path-migration-service.js +386 -0
- package/dist/services/skills/skills-manager.d.ts +39 -0
- package/dist/services/skills/skills-manager.d.ts.map +1 -0
- package/dist/services/skills/skills-manager.js +231 -0
- package/dist/services/skills/types.d.ts +32 -0
- package/dist/services/skills/types.d.ts.map +1 -0
- package/dist/services/skills/types.js +5 -0
- package/dist/services/stats-service.d.ts +71 -0
- package/dist/services/stats-service.d.ts.map +1 -0
- package/dist/services/stats-service.js +288 -0
- package/dist/services/tags.d.ts +30 -0
- package/dist/services/tags.d.ts.map +1 -0
- package/dist/services/tags.js +245 -0
- package/dist/services/transformers-resolve.d.ts +17 -0
- package/dist/services/transformers-resolve.d.ts.map +1 -0
- package/dist/services/transformers-resolve.js +142 -0
- package/dist/services/turso/connection-manager.d.ts +66 -0
- package/dist/services/turso/connection-manager.d.ts.map +1 -0
- package/dist/services/turso/connection-manager.js +408 -0
- package/dist/services/turso/encryption-key.d.ts +17 -0
- package/dist/services/turso/encryption-key.d.ts.map +1 -0
- package/dist/services/turso/encryption-key.js +111 -0
- package/dist/services/turso/encryption-migrator.d.ts +6 -0
- package/dist/services/turso/encryption-migrator.d.ts.map +1 -0
- package/dist/services/turso/encryption-migrator.js +234 -0
- package/dist/services/turso/engine-migrator.d.ts +6 -0
- package/dist/services/turso/engine-migrator.d.ts.map +1 -0
- package/dist/services/turso/engine-migrator.js +318 -0
- package/dist/services/turso/error-classifiers.d.ts +4 -0
- package/dist/services/turso/error-classifiers.d.ts.map +1 -0
- package/dist/services/turso/error-classifiers.js +19 -0
- package/dist/services/turso/legacy-migrator.d.ts +2 -0
- package/dist/services/turso/legacy-migrator.d.ts.map +1 -0
- package/dist/services/turso/legacy-migrator.js +535 -0
- package/dist/services/turso/lifecycle.d.ts +11 -0
- package/dist/services/turso/lifecycle.d.ts.map +1 -0
- package/dist/services/turso/lifecycle.js +32 -0
- package/dist/services/turso/operation-lock.d.ts +26 -0
- package/dist/services/turso/operation-lock.d.ts.map +1 -0
- package/dist/services/turso/operation-lock.js +188 -0
- package/dist/services/turso/plugin-refs.d.ts +13 -0
- package/dist/services/turso/plugin-refs.d.ts.map +1 -0
- package/dist/services/turso/plugin-refs.js +43 -0
- package/dist/services/turso/ready.d.ts +3 -0
- package/dist/services/turso/ready.d.ts.map +1 -0
- package/dist/services/turso/ready.js +32 -0
- package/dist/services/turso/schema-migrations.d.ts +24 -0
- package/dist/services/turso/schema-migrations.d.ts.map +1 -0
- package/dist/services/turso/schema-migrations.js +367 -0
- package/dist/services/turso/shard-manager.d.ts +41 -0
- package/dist/services/turso/shard-manager.d.ts.map +1 -0
- package/dist/services/turso/shard-manager.js +419 -0
- package/dist/services/turso/sqlite-handle-release.d.ts +31 -0
- package/dist/services/turso/sqlite-handle-release.d.ts.map +1 -0
- package/dist/services/turso/sqlite-handle-release.js +101 -0
- package/dist/services/turso/turso-db.d.ts +61 -0
- package/dist/services/turso/turso-db.d.ts.map +1 -0
- package/dist/services/turso/turso-db.js +214 -0
- package/dist/services/turso/types.d.ts +52 -0
- package/dist/services/turso/types.d.ts.map +1 -0
- package/dist/services/turso/types.js +1 -0
- package/dist/services/turso/vector-search.d.ts +63 -0
- package/dist/services/turso/vector-search.d.ts.map +1 -0
- package/dist/services/turso/vector-search.js +510 -0
- package/dist/services/turso/vector-utils.d.ts +16 -0
- package/dist/services/turso/vector-utils.d.ts.map +1 -0
- package/dist/services/turso/vector-utils.js +98 -0
- package/dist/services/turso/wal-index-recovery.d.ts +51 -0
- package/dist/services/turso/wal-index-recovery.d.ts.map +1 -0
- package/dist/services/turso/wal-index-recovery.js +248 -0
- package/dist/services/update-on-capture.d.ts +77 -0
- package/dist/services/update-on-capture.d.ts.map +1 -0
- package/dist/services/update-on-capture.js +116 -0
- package/dist/services/user-memory-learning.d.ts +137 -0
- package/dist/services/user-memory-learning.d.ts.map +1 -0
- package/dist/services/user-memory-learning.js +787 -0
- package/dist/services/user-profile/ai-cleanup.d.ts +59 -0
- package/dist/services/user-profile/ai-cleanup.d.ts.map +1 -0
- package/dist/services/user-profile/ai-cleanup.js +488 -0
- package/dist/services/user-profile/learning-lock.d.ts +41 -0
- package/dist/services/user-profile/learning-lock.d.ts.map +1 -0
- package/dist/services/user-profile/learning-lock.js +619 -0
- package/dist/services/user-profile/profile-context.d.ts +2 -0
- package/dist/services/user-profile/profile-context.d.ts.map +1 -0
- package/dist/services/user-profile/profile-context.js +105 -0
- package/dist/services/user-profile/profile-utils.d.ts +17 -0
- package/dist/services/user-profile/profile-utils.d.ts.map +1 -0
- package/dist/services/user-profile/profile-utils.js +77 -0
- package/dist/services/user-profile/types.d.ts +93 -0
- package/dist/services/user-profile/types.d.ts.map +1 -0
- package/dist/services/user-profile/types.js +1 -0
- package/dist/services/user-profile/user-profile-manager.d.ts +106 -0
- package/dist/services/user-profile/user-profile-manager.d.ts.map +1 -0
- package/dist/services/user-profile/user-profile-manager.js +1793 -0
- package/dist/services/user-prompt/user-prompt-manager.d.ts +64 -0
- package/dist/services/user-prompt/user-prompt-manager.d.ts.map +1 -0
- package/dist/services/user-prompt/user-prompt-manager.js +428 -0
- package/dist/services/web-api-auth.d.ts +4 -0
- package/dist/services/web-api-auth.d.ts.map +1 -0
- package/dist/services/web-api-auth.js +24 -0
- package/dist/services/web-auth.d.ts +47 -0
- package/dist/services/web-auth.d.ts.map +1 -0
- package/dist/services/web-auth.js +105 -0
- package/dist/services/web-server.d.ts +58 -0
- package/dist/services/web-server.d.ts.map +1 -0
- package/dist/services/web-server.js +774 -0
- package/dist/shared/api/index.d.ts +5 -0
- package/dist/shared/api/index.d.ts.map +1 -0
- package/dist/shared/api/index.js +2 -0
- package/dist/shared/api/portability-schemas.d.ts +57 -0
- package/dist/shared/api/portability-schemas.d.ts.map +1 -0
- package/dist/shared/api/portability-schemas.js +39 -0
- package/dist/shared/api/schemas.d.ts +296 -0
- package/dist/shared/api/schemas.d.ts.map +1 -0
- package/dist/shared/api/schemas.js +134 -0
- package/dist/shared/api/types.d.ts +29 -0
- package/dist/shared/api/types.d.ts.map +1 -0
- package/dist/shared/api/types.js +1 -0
- package/dist/tui.d.ts +10 -0
- package/dist/tui.d.ts.map +1 -0
- package/dist/tui.js +17 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/context-limit.d.ts +11 -0
- package/dist/utils/context-limit.d.ts.map +1 -0
- package/dist/utils/context-limit.js +43 -0
- package/dist/utils/math.d.ts +8 -0
- package/dist/utils/math.d.ts.map +1 -0
- package/dist/utils/math.js +48 -0
- package/dist/utils/profile.d.ts +3 -0
- package/dist/utils/profile.d.ts.map +1 -0
- package/dist/utils/profile.js +15 -0
- package/dist/v2/adapter.d.ts +3 -0
- package/dist/v2/adapter.d.ts.map +1 -0
- package/dist/v2/adapter.js +217 -0
- package/dist/v2/legacy-client.d.ts +22 -0
- package/dist/v2/legacy-client.d.ts.map +1 -0
- package/dist/v2/legacy-client.js +410 -0
- package/dist/v2/plugin.d.ts +4 -0
- package/dist/v2/plugin.d.ts.map +1 -0
- package/dist/v2/plugin.js +34 -0
- package/dist/v2/toast-rpc.d.ts +43 -0
- package/dist/v2/toast-rpc.d.ts.map +1 -0
- package/dist/v2/toast-rpc.js +26 -0
- package/dist/web/accent-preview.html +444 -0
- package/dist/web/assets/index-mTgxOb5l.css +2 -0
- package/dist/web/assets/index-ysje17yK.js +109 -0
- package/dist/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/web/favicon.ico +0 -0
- package/dist/web/favicon.svg +11 -0
- package/dist/web/index.html +29 -0
- package/dist/web/opencode-mem-icon.png +0 -0
- package/package.json +122 -4
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { CONFIG } from "../config.js";
|
|
4
|
+
import { normalize, resolve, isAbsolute, basename, dirname, join, delimiter, relative, } from "node:path";
|
|
5
|
+
import { accessSync, constants, realpathSync, existsSync } from "node:fs";
|
|
6
|
+
function sha256(input) {
|
|
7
|
+
return createHash("sha256").update(input).digest("hex").slice(0, 16);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Marker file whose presence pins a directory as the opencode-mem project root.
|
|
11
|
+
*
|
|
12
|
+
* A multi-repo workspace (e.g. a tree managed by Google `repo`, a monorepo,
|
|
13
|
+
* or any layout where several nested git repositories should share one memory
|
|
14
|
+
* store) drops this file at the workspace root. Every session started anywhere
|
|
15
|
+
* underneath then resolves onto that root instead of onto whichever physical
|
|
16
|
+
* git repository the working directory happens to live in.
|
|
17
|
+
*
|
|
18
|
+
* Unlike an environment variable or a config-file value, the marker is found
|
|
19
|
+
* by walking up from the working directory that every code path already passes
|
|
20
|
+
* in (the plugin's `ctx.directory`, the web API's `process.cwd()`), so project
|
|
21
|
+
* identity never depends on which long-lived opencode process happens to own
|
|
22
|
+
* the shared web server.
|
|
23
|
+
*/
|
|
24
|
+
const PROJECT_MARKER = ".opencode-mem-project";
|
|
25
|
+
function canonicalPath(path) {
|
|
26
|
+
try {
|
|
27
|
+
return process.platform === "win32"
|
|
28
|
+
? normalize(realpathSync.native(path))
|
|
29
|
+
: normalize(realpathSync(path));
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return normalize(resolve(path));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function isPathInside(root, candidate) {
|
|
36
|
+
const rel = relative(root, candidate);
|
|
37
|
+
return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel));
|
|
38
|
+
}
|
|
39
|
+
function findUntrustedProjectRoot(directory) {
|
|
40
|
+
let current = canonicalPath(directory);
|
|
41
|
+
while (true) {
|
|
42
|
+
if (existsSync(join(current, ".git")) || existsSync(join(current, PROJECT_MARKER))) {
|
|
43
|
+
return current;
|
|
44
|
+
}
|
|
45
|
+
const parent = dirname(current);
|
|
46
|
+
if (parent === current)
|
|
47
|
+
return canonicalPath(directory);
|
|
48
|
+
current = parent;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function resolveTrustedWindowsShell(untrustedRoot) {
|
|
52
|
+
const candidates = [
|
|
53
|
+
process.env.ComSpec,
|
|
54
|
+
process.env.SystemRoot ? join(process.env.SystemRoot, "System32", "cmd.exe") : undefined,
|
|
55
|
+
];
|
|
56
|
+
for (const path of candidates) {
|
|
57
|
+
if (!path || !isAbsolute(path))
|
|
58
|
+
continue;
|
|
59
|
+
try {
|
|
60
|
+
accessSync(path, constants.X_OK);
|
|
61
|
+
const candidate = canonicalPath(path);
|
|
62
|
+
if (!isPathInside(untrustedRoot, candidate))
|
|
63
|
+
return candidate;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// ignore unreadable or untrusted PATH entries
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function resolveTrustedGitCommand(directory) {
|
|
72
|
+
const untrustedRoot = findUntrustedProjectRoot(directory);
|
|
73
|
+
const executableNames = process.platform === "win32" ? ["git.exe", "git.cmd", "git.bat"] : ["git"];
|
|
74
|
+
for (const rawEntry of (process.env.PATH ?? "").split(delimiter)) {
|
|
75
|
+
const entry = rawEntry.trim().replace(/^"(.*)"$/, "$1");
|
|
76
|
+
if (!entry || !isAbsolute(entry))
|
|
77
|
+
continue;
|
|
78
|
+
for (const executableName of executableNames) {
|
|
79
|
+
const candidatePath = join(entry, executableName);
|
|
80
|
+
try {
|
|
81
|
+
accessSync(candidatePath, constants.X_OK);
|
|
82
|
+
const executable = canonicalPath(candidatePath);
|
|
83
|
+
if (isPathInside(untrustedRoot, executable))
|
|
84
|
+
continue;
|
|
85
|
+
if (executableName === "git.exe" || process.platform !== "win32") {
|
|
86
|
+
return { executable, shell: false };
|
|
87
|
+
}
|
|
88
|
+
const shell = resolveTrustedWindowsShell(untrustedRoot);
|
|
89
|
+
if (shell)
|
|
90
|
+
return { executable, shell };
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// ignore unreadable or untrusted PATH entries
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
function runGit(args, directory = process.cwd()) {
|
|
100
|
+
const gitCommand = resolveTrustedGitCommand(directory);
|
|
101
|
+
if (!gitCommand)
|
|
102
|
+
return null;
|
|
103
|
+
try {
|
|
104
|
+
const output = execFileSync(gitCommand.executable, args, {
|
|
105
|
+
encoding: "utf-8",
|
|
106
|
+
cwd: directory,
|
|
107
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
108
|
+
shell: gitCommand.shell,
|
|
109
|
+
windowsHide: true,
|
|
110
|
+
}).trim();
|
|
111
|
+
return output || null;
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Walk up from `directory` (inclusive) to the filesystem root looking for the
|
|
119
|
+
* {@link PROJECT_MARKER}. Returns the first directory that contains it, or
|
|
120
|
+
* `null` when no marker is found so the caller can fall back to git detection.
|
|
121
|
+
*/
|
|
122
|
+
export function findMarkerProjectRoot(directory) {
|
|
123
|
+
let dir = resolve(directory);
|
|
124
|
+
while (true) {
|
|
125
|
+
if (existsSync(join(dir, PROJECT_MARKER))) {
|
|
126
|
+
return dir;
|
|
127
|
+
}
|
|
128
|
+
const parent = dirname(dir);
|
|
129
|
+
if (parent === dir) {
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
dir = parent;
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
export function getGitEmail(directory = process.cwd()) {
|
|
137
|
+
return runGit(["config", "user.email"], directory);
|
|
138
|
+
}
|
|
139
|
+
export function getGitName(directory = process.cwd()) {
|
|
140
|
+
return runGit(["config", "user.name"], directory);
|
|
141
|
+
}
|
|
142
|
+
export function getGitRepoUrl(directory) {
|
|
143
|
+
return runGit(["config", "--get", "remote.origin.url"], directory);
|
|
144
|
+
}
|
|
145
|
+
export function getGitCommonDir(directory) {
|
|
146
|
+
try {
|
|
147
|
+
const commonDir = runGit(["rev-parse", "--git-common-dir"], directory);
|
|
148
|
+
if (!commonDir)
|
|
149
|
+
return null;
|
|
150
|
+
const resolved = isAbsolute(commonDir)
|
|
151
|
+
? normalize(commonDir)
|
|
152
|
+
: normalize(resolve(directory, commonDir));
|
|
153
|
+
if (existsSync(resolved)) {
|
|
154
|
+
const canonical = process.platform === "win32" ? realpathSync.native(resolved) : realpathSync(resolved);
|
|
155
|
+
return normalize(canonical);
|
|
156
|
+
}
|
|
157
|
+
return resolved;
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export function getGitTopLevel(directory) {
|
|
164
|
+
return runGit(["rev-parse", "--show-toplevel"], directory);
|
|
165
|
+
}
|
|
166
|
+
// Git-only fallbacks, kept separate so the marker-aware entry points below
|
|
167
|
+
// can short-circuit on a marker and reuse these without re-running detection.
|
|
168
|
+
function getGitProjectRoot(directory) {
|
|
169
|
+
const commonDir = getGitCommonDir(directory);
|
|
170
|
+
if (commonDir && basename(commonDir) === ".git") {
|
|
171
|
+
return dirname(commonDir);
|
|
172
|
+
}
|
|
173
|
+
const topLevel = getGitTopLevel(directory);
|
|
174
|
+
if (topLevel) {
|
|
175
|
+
return topLevel;
|
|
176
|
+
}
|
|
177
|
+
return directory;
|
|
178
|
+
}
|
|
179
|
+
function getGitProjectIdentity(directory) {
|
|
180
|
+
const commonDir = getGitCommonDir(directory);
|
|
181
|
+
if (commonDir) {
|
|
182
|
+
return `git-common:${commonDir}`;
|
|
183
|
+
}
|
|
184
|
+
const gitRepoUrl = getGitRepoUrl(directory);
|
|
185
|
+
if (gitRepoUrl) {
|
|
186
|
+
return `remote:${gitRepoUrl}`;
|
|
187
|
+
}
|
|
188
|
+
return `path:${normalize(directory)}`;
|
|
189
|
+
}
|
|
190
|
+
export function getProjectRoot(directory) {
|
|
191
|
+
return findMarkerProjectRoot(directory) ?? getGitProjectRoot(directory);
|
|
192
|
+
}
|
|
193
|
+
export function getProjectIdentity(directory) {
|
|
194
|
+
const markerRoot = findMarkerProjectRoot(directory);
|
|
195
|
+
return markerRoot ? `path:${markerRoot}` : getGitProjectIdentity(directory);
|
|
196
|
+
}
|
|
197
|
+
export function getProjectName(directory) {
|
|
198
|
+
const normalized = normalize(directory).replace(/\\/g, "/");
|
|
199
|
+
const parts = normalized.split("/").filter((p) => p && p !== ".");
|
|
200
|
+
return parts[parts.length - 1] || directory;
|
|
201
|
+
}
|
|
202
|
+
export function getUserTagInfo(directory = process.cwd()) {
|
|
203
|
+
const email = CONFIG.userEmailOverride || getGitEmail(directory);
|
|
204
|
+
const name = CONFIG.userNameOverride || getGitName(directory);
|
|
205
|
+
if (email) {
|
|
206
|
+
return {
|
|
207
|
+
tag: `${CONFIG.containerTagPrefix}_user_${sha256(email)}`,
|
|
208
|
+
displayName: name || email,
|
|
209
|
+
userName: name || undefined,
|
|
210
|
+
userEmail: email,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
const fallback = name || process.env.USER || process.env.USERNAME || "anonymous";
|
|
214
|
+
return {
|
|
215
|
+
tag: `${CONFIG.containerTagPrefix}_user_${sha256(fallback)}`,
|
|
216
|
+
displayName: fallback,
|
|
217
|
+
userName: fallback,
|
|
218
|
+
userEmail: undefined,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
export function getProjectTagInfo(directory) {
|
|
222
|
+
// Resolve the marker exactly once and derive root + identity from it, so a
|
|
223
|
+
// single getProjectTagInfo call never walks the ancestry more than once.
|
|
224
|
+
const markerRoot = findMarkerProjectRoot(directory);
|
|
225
|
+
const projectRoot = markerRoot ?? getGitProjectRoot(directory);
|
|
226
|
+
const projectName = getProjectName(projectRoot);
|
|
227
|
+
// When a marker pins the project root, any git remote belongs to a single
|
|
228
|
+
// nested sub-repo and would be misleading for the grouped workspace, so
|
|
229
|
+
// leave it unset.
|
|
230
|
+
const gitRepoUrl = markerRoot ? null : getGitRepoUrl(directory);
|
|
231
|
+
const projectIdentity = markerRoot ? `path:${markerRoot}` : getGitProjectIdentity(projectRoot);
|
|
232
|
+
return {
|
|
233
|
+
tag: `${CONFIG.containerTagPrefix}_project_${sha256(projectIdentity)}`,
|
|
234
|
+
displayName: projectRoot,
|
|
235
|
+
projectPath: projectRoot,
|
|
236
|
+
projectName,
|
|
237
|
+
gitRepoUrl: gitRepoUrl || undefined,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
export function getTags(directory) {
|
|
241
|
+
return {
|
|
242
|
+
user: getUserTagInfo(directory),
|
|
243
|
+
project: getProjectTagInfo(directory),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const TRANSFORMERS_PACKAGE: string;
|
|
2
|
+
/** Non-literal specifier so plugin bundlers do not eagerly traverse transformers. */
|
|
3
|
+
export declare function getTransformersPackageSpecifier(): string;
|
|
4
|
+
/** Pick the Node CJS entry from a transformers package.json. */
|
|
5
|
+
export declare function cjsEntryFromPackageJson(pkgJsonPath: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve Bun's install layout when Node createRequire cannot see the package.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveWithBun(specifier: string, fromPath: string): string | null;
|
|
10
|
+
export declare function resolveTransformersCjsEntry(options: {
|
|
11
|
+
requireFn: NodeRequire;
|
|
12
|
+
startPaths?: Array<string | undefined | null>;
|
|
13
|
+
specifier?: string;
|
|
14
|
+
}): string;
|
|
15
|
+
/** Test helper: expose path→fileURL conversion for Bun resolve roots. */
|
|
16
|
+
export declare function toFileUrlIfNeeded(path: string): string;
|
|
17
|
+
//# sourceMappingURL=transformers-resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformers-resolve.d.ts","sourceRoot":"","sources":["../../src/services/transformers-resolve.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,oBAAoB,QAA6C,CAAC;AAE/E,qFAAqF;AACrF,wBAAgB,+BAA+B,IAAI,MAAM,CAExD;AA+BD,gEAAgE;AAChE,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAUnE;AA0BD;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASjF;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAsDT;AAED,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the CJS entry of `@huggingface/transformers` for OpenCode hosts (#463).
|
|
3
|
+
*
|
|
4
|
+
* OpenCode nested installs (Bun linker / npm cache layouts) sometimes make
|
|
5
|
+
* Node's createRequire(packageName) fail even when the package exists on disk.
|
|
6
|
+
* Walk node_modules and prefer Bun.resolveSync, then load the package's
|
|
7
|
+
* `exports.node.require` entry so the onnxruntime pin shim still applies.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
10
|
+
import { dirname, join, sep } from "node:path";
|
|
11
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
12
|
+
export const TRANSFORMERS_PACKAGE = ["@huggingface", "transformers"].join("/");
|
|
13
|
+
/** Non-literal specifier so plugin bundlers do not eagerly traverse transformers. */
|
|
14
|
+
export function getTransformersPackageSpecifier() {
|
|
15
|
+
return TRANSFORMERS_PACKAGE;
|
|
16
|
+
}
|
|
17
|
+
function readJson(path) {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function asExportPath(value) {
|
|
26
|
+
if (typeof value === "string" && value.length > 0)
|
|
27
|
+
return value;
|
|
28
|
+
if (value &&
|
|
29
|
+
typeof value === "object" &&
|
|
30
|
+
typeof value.default === "string") {
|
|
31
|
+
return value.default;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/** Pick the Node CJS entry from a transformers package.json. */
|
|
36
|
+
export function cjsEntryFromPackageJson(pkgJsonPath) {
|
|
37
|
+
const pkg = readJson(pkgJsonPath);
|
|
38
|
+
if (!pkg)
|
|
39
|
+
throw new Error(`Unable to read ${pkgJsonPath}`);
|
|
40
|
+
const exportsField = pkg.exports;
|
|
41
|
+
const relative = asExportPath(exportsField?.node?.require) ||
|
|
42
|
+
asExportPath(exportsField?.require) ||
|
|
43
|
+
(typeof pkg.main === "string" ? pkg.main : null) ||
|
|
44
|
+
"./dist/transformers.node.cjs";
|
|
45
|
+
return join(dirname(pkgJsonPath), relative);
|
|
46
|
+
}
|
|
47
|
+
function packageJsonCandidates(startDir, packageName) {
|
|
48
|
+
const parts = packageName.split("/");
|
|
49
|
+
const out = [];
|
|
50
|
+
let dir = startDir;
|
|
51
|
+
for (let i = 0; i < 16; i++) {
|
|
52
|
+
out.push(join(dir, "node_modules", ...parts, "package.json"));
|
|
53
|
+
const parent = dirname(dir);
|
|
54
|
+
if (parent === dir)
|
|
55
|
+
break;
|
|
56
|
+
dir = parent;
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
function normalizeStartPath(value) {
|
|
61
|
+
if (value.startsWith("file:")) {
|
|
62
|
+
try {
|
|
63
|
+
return fileURLToPath(value);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolve Bun's install layout when Node createRequire cannot see the package.
|
|
73
|
+
*/
|
|
74
|
+
export function resolveWithBun(specifier, fromPath) {
|
|
75
|
+
const bun = globalThis.Bun;
|
|
76
|
+
if (typeof bun?.resolveSync !== "function")
|
|
77
|
+
return null;
|
|
78
|
+
try {
|
|
79
|
+
const fromDir = fromPath.endsWith(sep) ? fromPath : dirname(fromPath);
|
|
80
|
+
return bun.resolveSync(specifier, fromDir);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function resolveTransformersCjsEntry(options) {
|
|
87
|
+
const specifier = options.specifier ?? TRANSFORMERS_PACKAGE;
|
|
88
|
+
const errors = [];
|
|
89
|
+
try {
|
|
90
|
+
return options.requireFn.resolve(specifier);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
errors.push(`require.resolve: ${error instanceof Error ? error.message : String(error)}`);
|
|
94
|
+
}
|
|
95
|
+
const starts = (options.startPaths ?? [])
|
|
96
|
+
.filter((p) => typeof p === "string" && p.trim().length > 0)
|
|
97
|
+
.map(normalizeStartPath);
|
|
98
|
+
for (const start of starts) {
|
|
99
|
+
const bunResolved = resolveWithBun(specifier, start);
|
|
100
|
+
if (bunResolved) {
|
|
101
|
+
// Bun may return the ESM entry; normalize to CJS via package.json.
|
|
102
|
+
let dir = dirname(bunResolved);
|
|
103
|
+
for (let i = 0; i < 6; i++) {
|
|
104
|
+
const pkgJson = join(dir, "package.json");
|
|
105
|
+
if (existsSync(pkgJson)) {
|
|
106
|
+
const pkg = readJson(pkgJson);
|
|
107
|
+
if (pkg?.name === specifier)
|
|
108
|
+
return cjsEntryFromPackageJson(pkgJson);
|
|
109
|
+
}
|
|
110
|
+
const parent = dirname(dir);
|
|
111
|
+
if (parent === dir)
|
|
112
|
+
break;
|
|
113
|
+
dir = parent;
|
|
114
|
+
}
|
|
115
|
+
if (bunResolved.endsWith(".cjs") || bunResolved.endsWith(".js"))
|
|
116
|
+
return bunResolved;
|
|
117
|
+
errors.push(`Bun.resolveSync returned non-CJS entry: ${bunResolved}`);
|
|
118
|
+
}
|
|
119
|
+
for (const candidate of packageJsonCandidates(dirname(start), specifier)) {
|
|
120
|
+
if (!existsSync(candidate))
|
|
121
|
+
continue;
|
|
122
|
+
try {
|
|
123
|
+
return cjsEntryFromPackageJson(candidate);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
errors.push(`${candidate}: ${error instanceof Error ? error.message : String(error)}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
throw new Error([
|
|
131
|
+
`Cannot resolve ${specifier} before installing the onnxruntime pin shim (#463).`,
|
|
132
|
+
"The package should be installed next to opencode-mem; OpenCode nested installs sometimes hide it from Node createRequire.",
|
|
133
|
+
"Fix: clear the OpenCode plugin cache (e.g. ~/.cache/opencode/npm/opencode-mem@* and ~/.cache/opencode/packages/opencode-mem@*) and reinstall, or set embeddingApiUrl + embeddingApiKey for remote embeddings.",
|
|
134
|
+
errors.length > 0 ? `Attempts: ${errors.join(" | ")}` : null,
|
|
135
|
+
]
|
|
136
|
+
.filter(Boolean)
|
|
137
|
+
.join(" "), { cause: errors[0] });
|
|
138
|
+
}
|
|
139
|
+
/** Test helper: expose path→fileURL conversion for Bun resolve roots. */
|
|
140
|
+
export function toFileUrlIfNeeded(path) {
|
|
141
|
+
return path.startsWith("file:") ? path : pathToFileURL(path).href;
|
|
142
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type Database } from "@tursodatabase/database";
|
|
2
|
+
import type { DatabaseOpts, EncryptionOpts } from "@tursodatabase/database-common";
|
|
3
|
+
import { TursoDb } from "./turso-db.js";
|
|
4
|
+
export type ConnectFactory = (path: string, opts?: DatabaseOpts) => Promise<Database>;
|
|
5
|
+
/** Always-on experimental flags for every Turso open. */
|
|
6
|
+
export declare const TURSO_BASE_EXPERIMENTAL_FEATURES: readonly ["encryption", "vacuum"];
|
|
7
|
+
/**
|
|
8
|
+
* Multiprocess WAL is Unix-only. On Windows/WASM/32-bit the flag is accepted but
|
|
9
|
+
* ignored (single-process mode) — see Turso multi-process docs.
|
|
10
|
+
*/
|
|
11
|
+
export declare function supportsTursoMultiprocessWal(platform?: NodeJS.Platform): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Experimental flags required on every Turso open for the current platform.
|
|
14
|
+
* `multiprocessWal: false` opts into single-owner mode (Unix), so a foreign
|
|
15
|
+
* process gets a loud "database is locked" instead of silent divergence.
|
|
16
|
+
*/
|
|
17
|
+
export declare function tursoExperimentalFeatures(platform?: NodeJS.Platform, multiprocessWal?: boolean): Array<(typeof TURSO_BASE_EXPERIMENTAL_FEATURES)[number] | "multiprocess_wal">;
|
|
18
|
+
/**
|
|
19
|
+
* Shared connect options for `@tursodatabase/database`.
|
|
20
|
+
* Always enables encryption; adds multiprocess_wal on Unix so concurrent
|
|
21
|
+
* OpenCode sessions can share the store. Windows stays single-process.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildConnectOptions(encryption?: EncryptionOpts | null): DatabaseOpts;
|
|
24
|
+
export declare function resolveDatabaseEncryption(): EncryptionOpts | null;
|
|
25
|
+
export declare function isTursoMultiProcessLockError(error: unknown): boolean;
|
|
26
|
+
export declare function wrapTursoOpenError(dbPath: string, error: unknown): Error;
|
|
27
|
+
export declare class TursoConnectionManager {
|
|
28
|
+
private readonly connectFactory;
|
|
29
|
+
private readonly connections;
|
|
30
|
+
private readonly pending;
|
|
31
|
+
private readonly closingConnections;
|
|
32
|
+
private closingPromise;
|
|
33
|
+
/**
|
|
34
|
+
* Paths that already had a completed recovery attempt this process (no loop).
|
|
35
|
+
* Set after a successful quarantine or a definitive skip — not when quarantine
|
|
36
|
+
* moved nothing, so a later open can still finish a blocked first attempt.
|
|
37
|
+
*/
|
|
38
|
+
private readonly healedPaths;
|
|
39
|
+
private readonly warnedForeignShmPaths;
|
|
40
|
+
constructor(connectFactory?: ConnectFactory);
|
|
41
|
+
/**
|
|
42
|
+
* Connect, and on a stale-WAL-index failure quarantine the index sidecars once
|
|
43
|
+
* and retry once. Only the two known signatures heal (see #435); any other open
|
|
44
|
+
* error propagates unchanged.
|
|
45
|
+
*
|
|
46
|
+
* Recovery is serialised across processes (they share `storagePath` through
|
|
47
|
+
* `multiprocess_wal`) with `<storagePath>/recovery/<dbstem>.lock`. Under that
|
|
48
|
+
* lock the open is re-attempted before any file is moved, so a peer that
|
|
49
|
+
* healed first leaves us nothing to do. A non-empty WAL is never moved — see
|
|
50
|
+
* `wal-index-recovery.ts` for the data-safety contract.
|
|
51
|
+
*/
|
|
52
|
+
private connectWithWalIndexRecovery;
|
|
53
|
+
/**
|
|
54
|
+
* A foreign sqlite process that wrote this store leaves `-shm` next to a
|
|
55
|
+
* Turso `-tshm`. Read-only access is harmless; a foreign writer diverges
|
|
56
|
+
* silently and loses its own next write, so warn once per path. Never delete
|
|
57
|
+
* `-shm` here — it may belong to a live reader.
|
|
58
|
+
*/
|
|
59
|
+
private warnOnForeignSqliteShm;
|
|
60
|
+
getConnection(dbPath: string): Promise<TursoDb>;
|
|
61
|
+
closeConnection(dbPath: string): Promise<void>;
|
|
62
|
+
closeAll(): Promise<void>;
|
|
63
|
+
closeAllSync(): void;
|
|
64
|
+
}
|
|
65
|
+
export declare const tursoConnectionManager: TursoConnectionManager;
|
|
66
|
+
//# sourceMappingURL=connection-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../src/services/turso/connection-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAMnF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAQxC,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEtF,yDAAyD;AACzD,eAAO,MAAM,gCAAgC,mCAAoC,CAAC;AAElF;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,OAAO,CAET;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,eAAe,GAAE,OAAqC,GACrD,KAAK,CAAC,CAAC,OAAO,gCAAgC,CAAC,CAAC,MAAM,CAAC,GAAG,kBAAkB,CAAC,CAK/E;AAYD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,cAAc,GAAG,IAAI,GAAG,YAAY,CAQpF;AAED,wBAAgB,yBAAyB,IAAI,cAAc,GAAG,IAAI,CAOjE;AAKD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAGpE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAYxE;AAED,qBAAa,sBAAsB;IAarB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAZ3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoC;IACvE,OAAO,CAAC,cAAc,CAA8B;IACpD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAqB;gBAE9B,cAAc,GAAE,cAAwB;IAErE;;;;;;;;;;OAUG;YACW,2BAA2B;IAuJzC;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAaxB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAuE/C,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC9C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B/B,YAAY,IAAI,IAAI;CAWrB;AAED,eAAO,MAAM,sBAAsB,wBAA+B,CAAC"}
|