@retaw106/mmc-oc 2.2.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +14 -3
- package/dist/config/deprecated-config.d.ts +4 -0
- package/dist/config/deprecated-config.d.ts.map +1 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/project-security.d.ts +2 -2
- package/dist/config/schema/magic-context.d.ts +36 -3
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/config-init.js +14 -3
- package/dist/{context-mrvm92n8.js → context-c72brxe5.js} +2410 -1801
- package/dist/{derive-budgets-rjjz5f7y.js → derive-budgets-s1p37t2g.js} +2 -2
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/historian-failure-reason.d.ts +7 -0
- package/dist/features/magic-context/historian-failure-reason.d.ts.map +1 -0
- package/dist/features/magic-context/memory-maintainer/launcher.d.ts +13 -4
- package/dist/features/magic-context/memory-maintainer/launcher.d.ts.map +1 -1
- package/dist/features/magic-context/memory-maintainer/manual-commands.d.ts.map +1 -1
- package/dist/features/magic-context/memory-maintainer/model-chain.d.ts +47 -0
- package/dist/features/magic-context/memory-maintainer/model-chain.d.ts.map +1 -0
- package/dist/features/magic-context/memory-maintainer/oc2-adapter.d.ts +17 -4
- package/dist/features/magic-context/memory-maintainer/oc2-adapter.d.ts.map +1 -1
- package/dist/features/magic-context/memory-maintainer/pipeline.d.ts +6 -0
- package/dist/features/magic-context/memory-maintainer/pipeline.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +21 -3
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +7 -1
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/pi-content-decisions.d.ts +7 -1
- package/dist/features/magic-context/pi-content-decisions.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +29 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-clone.d.ts +2 -0
- package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
- package/dist/features/magic-context/storage-compartment-history-version.d.ts +4 -0
- package/dist/features/magic-context/storage-compartment-history-version.d.ts.map +1 -0
- package/dist/features/magic-context/storage-db.d.ts +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +23 -5
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts +7 -1
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts +5 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tag-identity-revision.d.ts +50 -0
- package/dist/features/magic-context/storage-tag-identity-revision.d.ts.map +1 -0
- package/dist/features/magic-context/storage-tags.d.ts +159 -5
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/tagger.d.ts +2 -0
- package/dist/features/magic-context/tagger.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +60 -2
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/hooks/magic-context/__fixtures__/tail-hygiene-refresh.d.ts +34 -0
- package/dist/hooks/magic-context/__fixtures__/tail-hygiene-refresh.d.ts.map +1 -0
- package/dist/hooks/magic-context/active-anthropic-turn.d.ts +2 -0
- package/dist/hooks/magic-context/active-anthropic-turn.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +10 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts +2 -2
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +2 -2
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts +4 -0
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger-error.d.ts +11 -0
- package/dist/hooks/magic-context/compartment-trigger-error.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +1 -0
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
- package/dist/hooks/magic-context/degraded-pass-refusal.d.ts +2 -0
- package/dist/hooks/magic-context/degraded-pass-refusal.d.ts.map +1 -1
- package/dist/hooks/magic-context/edit-marker.d.ts +2 -0
- package/dist/hooks/magic-context/edit-marker.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +2 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-repair.d.ts +11 -2
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-measured-request.d.ts +3 -1
- package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts +10 -13
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +62 -0
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -0
- package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +38 -0
- package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -0
- package/dist/hooks/magic-context/lkg-replay.d.ts +16 -9
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +141 -2
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/opaque-thinking.d.ts +12 -0
- package/dist/hooks/magic-context/opaque-thinking.d.ts.map +1 -0
- package/dist/hooks/magic-context/pass-outcome.d.ts +1 -0
- package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
- package/dist/hooks/magic-context/pending-drop-eligibility.d.ts +14 -0
- package/dist/hooks/magic-context/pending-drop-eligibility.d.ts.map +1 -0
- package/dist/hooks/magic-context/pending-materialization.d.ts +10 -0
- package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -0
- package/dist/hooks/magic-context/postprocess-read-cache.d.ts.map +1 -1
- package/dist/hooks/magic-context/provider-visible-parts.d.ts +51 -0
- package/dist/hooks/magic-context/provider-visible-parts.d.ts.map +1 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts +22 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +3 -0
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts +5 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +123 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/reasoning-budget.d.ts.map +1 -1
- package/dist/hooks/magic-context/render-options.d.ts +19 -0
- package/dist/hooks/magic-context/render-options.d.ts.map +1 -0
- package/dist/hooks/magic-context/sentinel.d.ts +41 -1
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/strict-thinking-prefix.d.ts +8 -0
- package/dist/hooks/magic-context/strict-thinking-prefix.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts +38 -24
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/supersession-reclaim.d.ts +5 -3
- package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-date-refresh.d.ts +29 -0
- package/dist/hooks/magic-context/system-date-refresh.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-prompt-dates.d.ts +6 -0
- package/dist/hooks/magic-context/system-prompt-dates.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-prompt-delivery.d.ts +47 -0
- package/dist/hooks/magic-context/system-prompt-delivery.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +18 -5
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +19 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-owner-warmup.d.ts +14 -0
- package/dist/hooks/magic-context/tag-owner-warmup.d.ts.map +1 -0
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts +18 -0
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts.map +1 -0
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +8 -4
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/token-count-exact.d.ts +35 -0
- package/dist/hooks/magic-context/token-count-exact.d.ts.map +1 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts +2 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-reclaim.d.ts +5 -2
- package/dist/hooks/magic-context/tool-reclaim.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +9 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +21 -11
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts +5 -1
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts.map +1 -1
- package/dist/{index-g2z2k5m4.js → index-27ddyx39.js} +2 -2
- package/dist/{index-btp5tdc8.js → index-48e9znrc.js} +1248 -570
- package/dist/{index-5cep2r9n.js → index-5ty9rnbx.js} +60 -258
- package/dist/{index-z2g20msd.js → index-azbmnekv.js} +4 -4
- package/dist/{index-1j34a56j.js → index-dwh99z66.js} +293 -36
- package/dist/{index-qbkzdkk0.js → index-k59af64t.js} +6 -2
- package/dist/{index-5b7x80ec.js → index-kahkxcqw.js} +12532 -10348
- package/dist/{index-53g38ggt.js → index-kmbme1v1.js} +1 -1
- package/dist/{index-amycb7b1.js → index-r7s7d350.js} +3 -3
- package/dist/{index-33gprt9g.js → index-yjv8dpht.js} +1 -1
- package/dist/index-ykq24x1n.js +1477 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -2
- package/dist/{message-time-backfill-phrwp2fz.js → message-time-backfill-j96x1sab.js} +3 -3
- package/dist/model-resolution-cvyrrcjw.js +8 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{read-session-chunk-2xm4sc4y.js → read-session-chunk-t8bg6wkz.js} +6 -4
- package/dist/recomp-orchestrator-k760qy1n.js +21 -0
- package/dist/{safe-notification-target-ph3xd1ve.js → safe-notification-target-1jkf0m82.js} +2 -2
- package/dist/{send-session-notification-rnc4nrsr.js → send-session-notification-njjf3b4s.js} +5 -5
- package/dist/shared/auto-search-lifecycle.d.ts +14 -0
- package/dist/shared/auto-search-lifecycle.d.ts.map +1 -1
- package/dist/shared/logger.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts +21 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/shared/models-dev-temperature.d.ts +18 -0
- package/dist/shared/models-dev-temperature.d.ts.map +1 -0
- package/dist/shared/processed-image-eligibility.d.ts +22 -0
- package/dist/shared/processed-image-eligibility.d.ts.map +1 -0
- package/dist/shared/project-directory-key.d.ts +16 -0
- package/dist/shared/project-directory-key.d.ts.map +1 -1
- package/dist/shared/prompt-surface-runtime.d.ts +5 -0
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/shared/reclaim-distance.d.ts +33 -0
- package/dist/shared/reclaim-distance.d.ts.map +1 -0
- package/dist/shared/recovery-reasoning-prefix.d.ts +9 -0
- package/dist/shared/recovery-reasoning-prefix.d.ts.map +1 -0
- package/dist/shared/sqlite.d.ts +35 -1
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/stable-json.d.ts +7 -0
- package/dist/shared/stable-json.d.ts.map +1 -1
- package/dist/shared/storage-file-mutex.d.ts +9 -0
- package/dist/shared/storage-file-mutex.d.ts.map +1 -0
- package/dist/shared/storage-permissions.d.ts +6 -0
- package/dist/shared/storage-permissions.d.ts.map +1 -1
- package/dist/shared/subagent-temperature.d.ts +46 -0
- package/dist/shared/subagent-temperature.d.ts.map +1 -0
- package/dist/shared/tag-owner-id.d.ts +1 -0
- package/dist/shared/tag-owner-id.d.ts.map +1 -1
- package/dist/shared/tag-transcript.d.ts +9 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/tail-hygiene-json.d.ts +22 -0
- package/dist/shared/tail-hygiene-json.d.ts.map +1 -0
- package/dist/shared/user-facing-codes.d.ts +2 -2
- package/dist/shared/window-geometry.d.ts +9 -66
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/standalone-plugin-marker.d.ts +8 -0
- package/dist/standalone-plugin-marker.d.ts.map +1 -0
- package/dist/tools/ctx-expand/search-archive.d.ts +4 -0
- package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -0
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/constants.d.ts +1 -2
- package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/tools.d.ts +1 -1
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/v2/hidden-completion.d.ts +20 -1
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/copied-tag-notation.d.ts +19 -0
- package/dist/v2/hooks/copied-tag-notation.d.ts.map +1 -0
- package/dist/v2/hooks/generate.d.ts +9 -2
- package/dist/v2/hooks/generate.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +22 -1
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/system-prompt-response.d.ts +5 -0
- package/dist/v2/hooks/system-prompt-response.d.ts.map +1 -0
- package/dist/v2/server.d.ts.map +1 -1
- package/dist/v2/server.js +26593 -21940
- package/dist/v2/store-reader.d.ts +27 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/web/main.js +401 -23
- package/dist/{wrapup-orchestrator-yknks3ad.js → wrapup-orchestrator-b2gswatj.js} +10 -10
- package/package.json +1 -1
- package/src/config/deprecated-config.ts +18 -0
- package/src/config/index.test.ts +13 -37
- package/src/config/index.ts +2 -2
- package/src/config/latch-permanence-guard.test.ts +4 -0
- package/src/config/project-security.test.ts +17 -0
- package/src/config/project-security.ts +3 -3
- package/src/config/schema/magic-context.test.ts +50 -0
- package/src/config/schema/magic-context.ts +44 -7
- package/src/shared/auto-search-lifecycle.ts +43 -0
- package/src/shared/logger.ts +10 -2
- package/src/shared/model-suggestion-retry.ts +5 -1
- package/src/shared/models-dev-cache.ts +1 -7
- package/src/shared/models-dev-temperature.ts +107 -0
- package/src/shared/processed-image-eligibility.test.ts +68 -0
- package/src/shared/processed-image-eligibility.ts +41 -0
- package/src/shared/processed-image-position-review.json +20 -0
- package/src/shared/processed-image-position-review.test.ts +19 -0
- package/src/shared/project-directory-key.ts +20 -0
- package/src/shared/prompt-surface-runtime.ts +12 -0
- package/src/shared/reclaim-distance.test.ts +111 -0
- package/src/shared/reclaim-distance.ts +91 -0
- package/src/shared/recovery-reasoning-prefix.test.ts +34 -0
- package/src/shared/recovery-reasoning-prefix.ts +35 -0
- package/src/shared/root-async-context.probe.mjs +36 -0
- package/src/shared/root-async-context.test.ts +49 -0
- package/src/shared/sqlite-acquisition-routing.test.ts +4 -3
- package/src/shared/sqlite-busy-budget-review.test.ts +291 -0
- package/src/shared/sqlite-foreground-wait.test.ts +304 -0
- package/src/shared/sqlite-pass-scope.test.ts +4 -4
- package/src/shared/sqlite-writer-diagnostics.test.ts +52 -12
- package/src/shared/sqlite.ts +428 -46
- package/src/shared/stable-json.ts +79 -7
- package/src/shared/storage-file-mutex.test.ts +50 -0
- package/src/shared/storage-file-mutex.ts +130 -0
- package/src/shared/storage-permissions.ts +46 -0
- package/src/shared/subagent-temperature.ts +110 -0
- package/src/shared/tag-owner-id.ts +13 -0
- package/src/shared/tag-transcript.ts +118 -0
- package/src/shared/tail-hygiene-json.test.ts +117 -0
- package/src/shared/tail-hygiene-json.ts +217 -0
- package/src/shared/user-facing-codes.ts +2 -2
- package/src/shared/window-geometry.test.ts +102 -236
- package/src/shared/window-geometry.ts +23 -413
- package/dist/index-ramz5kkm.js +0 -514
- package/dist/model-resolution-wazv26n0.js +0 -6
- package/dist/recomp-orchestrator-frmwj9hz.js +0 -21
- package/src/shared/__fixtures__/window-overlay.v1.json +0 -337
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
// src/shared/sqlite.ts
|
|
2
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
|
|
3
3
|
import { statSync } from "node:fs";
|
|
4
|
+
var resourceRoot = new AsyncResource("magic-context:root");
|
|
5
|
+
function inRootAsyncContext(operation) {
|
|
6
|
+
return resourceRoot.runInAsyncScope(operation);
|
|
7
|
+
}
|
|
4
8
|
var reportSlowPrivilegedWrite;
|
|
5
9
|
function registerSlowWriteReporter(reporter) {
|
|
6
10
|
reportSlowPrivilegedWrite = reporter;
|
|
7
11
|
}
|
|
8
12
|
var sqliteDiagnosticSink;
|
|
9
|
-
|
|
13
|
+
var sqliteDiagnosticHost = () => "unknown";
|
|
14
|
+
function registerSqliteDiagnosticSink(sink, host) {
|
|
10
15
|
sqliteDiagnosticSink = sink;
|
|
16
|
+
if (host)
|
|
17
|
+
sqliteDiagnosticHost = host;
|
|
11
18
|
}
|
|
12
19
|
function reportSqliteDiagnostic(message) {
|
|
13
20
|
try {
|
|
14
|
-
sqliteDiagnosticSink?.(`[magic-context] ${message}`);
|
|
21
|
+
sqliteDiagnosticSink?.(`[magic-context] ${message} pid=${process.pid} host=${sqliteDiagnosticHost()}`);
|
|
15
22
|
} catch {}
|
|
16
23
|
}
|
|
17
24
|
function detectSqliteRuntime() {
|
|
@@ -47,10 +54,31 @@ class SqliteRuntimeUnavailableError extends Error {
|
|
|
47
54
|
this.specifier = specifier;
|
|
48
55
|
}
|
|
49
56
|
}
|
|
57
|
+
function isNodeSqliteExperimentalWarning(args) {
|
|
58
|
+
const [warning, options] = args;
|
|
59
|
+
const message = warning instanceof Error ? warning.message : warning;
|
|
60
|
+
const type = typeof options === "string" ? options : options && typeof options === "object" ? options.type : undefined;
|
|
61
|
+
return type === "ExperimentalWarning" && typeof message === "string" && message.startsWith("SQLite is an experimental feature");
|
|
62
|
+
}
|
|
63
|
+
async function importSqliteModuleForRuntime(runtime, specifier, importer) {
|
|
64
|
+
if (runtime !== "Node.js")
|
|
65
|
+
return importer(specifier);
|
|
66
|
+
const originalEmitWarning = process.emitWarning;
|
|
67
|
+
process.emitWarning = function(...args) {
|
|
68
|
+
if (isNodeSqliteExperimentalWarning(args))
|
|
69
|
+
return;
|
|
70
|
+
Reflect.apply(originalEmitWarning, this, args);
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
return await importer(specifier);
|
|
74
|
+
} finally {
|
|
75
|
+
process.emitWarning = originalEmitWarning;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
50
78
|
async function loadSqliteModule(runtime = detectSqliteRuntime(), importer = importSqliteModule) {
|
|
51
79
|
const specifier = runtime === "Bun" ? bunSpec : nodeSpec;
|
|
52
80
|
try {
|
|
53
|
-
return await
|
|
81
|
+
return await importSqliteModuleForRuntime(runtime, specifier, importer);
|
|
54
82
|
} catch (error) {
|
|
55
83
|
if (isModuleNotFoundError(error, specifier)) {
|
|
56
84
|
throw new SqliteRuntimeUnavailableError(runtime, specifier, error);
|
|
@@ -64,6 +92,81 @@ var sqliteModule = await loadSqliteModule(detectedRuntime);
|
|
|
64
92
|
var DatabaseImpl = isBun ? sqliteModule.Database : buildNodeSqliteDatabaseClass(sqliteModule.DatabaseSync);
|
|
65
93
|
var trackedSqliteConnections = new Map;
|
|
66
94
|
var nextSqliteConnectionSequence = 1;
|
|
95
|
+
var TAG_COLUMNS_OUTSIDE_IDENTITY = new Set([
|
|
96
|
+
"status",
|
|
97
|
+
"drop_mode",
|
|
98
|
+
"byte_size",
|
|
99
|
+
"input_byte_size",
|
|
100
|
+
"reasoning_byte_size",
|
|
101
|
+
"token_count",
|
|
102
|
+
"input_token_count",
|
|
103
|
+
"caveman_depth",
|
|
104
|
+
"entry_fingerprint",
|
|
105
|
+
"tool_name",
|
|
106
|
+
"harness"
|
|
107
|
+
]);
|
|
108
|
+
var tagIdentityWriteGeneration = 0;
|
|
109
|
+
function mayChangeTagIdentity(sql) {
|
|
110
|
+
if (!/\btags\b/i.test(sql) || /^\s*(?:SELECT|EXPLAIN|PRAGMA)\b/i.test(sql))
|
|
111
|
+
return false;
|
|
112
|
+
if (/^\s*WITH\b/i.test(sql) && !/\b(?:INSERT|UPDATE|DELETE|REPLACE)\b/i.test(sql))
|
|
113
|
+
return false;
|
|
114
|
+
if (/;\s*\S/.test(sql) || /\bREPLACE\b/i.test(sql) || /\bON\s+CONFLICT\b/i.test(sql))
|
|
115
|
+
return true;
|
|
116
|
+
const insert = /^\s*INSERT\s+INTO\s+(?:main\.)?["`]?tags["`]?\s*\(([^)]*)\)/i.exec(sql);
|
|
117
|
+
if (insert) {
|
|
118
|
+
const columns = (insert[1] ?? "").split(",").map((column) => column.trim().replace(/["`[\]]/g, "").toLowerCase());
|
|
119
|
+
return columns.includes("id") || columns.includes("rowid");
|
|
120
|
+
}
|
|
121
|
+
const update = /^\s*UPDATE\s+(?:main\.)?["`]?tags["`]?\s+SET\s+([\s\S]*?)\bWHERE\b/i.exec(sql);
|
|
122
|
+
if (update && !/\bSELECT\b/i.test(sql)) {
|
|
123
|
+
const assignments = topLevelCommaSegments(update[1] ?? "");
|
|
124
|
+
if (!assignments)
|
|
125
|
+
return true;
|
|
126
|
+
return !assignments.every((assignment) => {
|
|
127
|
+
const column = /^\s*["`]?(\w+)["`]?\s*=(?!=)/.exec(assignment)?.[1];
|
|
128
|
+
return column !== undefined && TAG_COLUMNS_OUTSIDE_IDENTITY.has(column.toLowerCase());
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
function topLevelCommaSegments(text) {
|
|
134
|
+
const segments = [];
|
|
135
|
+
let depth = 0;
|
|
136
|
+
let quote = null;
|
|
137
|
+
let start = 0;
|
|
138
|
+
for (let index = 0;index < text.length; index += 1) {
|
|
139
|
+
const char = text[index];
|
|
140
|
+
if (quote) {
|
|
141
|
+
if (char === quote) {
|
|
142
|
+
if (text[index + 1] === quote)
|
|
143
|
+
index += 1;
|
|
144
|
+
else
|
|
145
|
+
quote = null;
|
|
146
|
+
}
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (char === "'" || char === '"' || char === "`")
|
|
150
|
+
quote = char;
|
|
151
|
+
else if (char === "(")
|
|
152
|
+
depth += 1;
|
|
153
|
+
else if (char === ")") {
|
|
154
|
+
depth -= 1;
|
|
155
|
+
if (depth < 0)
|
|
156
|
+
return null;
|
|
157
|
+
} else if (char === "," && depth === 0) {
|
|
158
|
+
segments.push(text.slice(start, index));
|
|
159
|
+
start = index + 1;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (quote || depth !== 0)
|
|
163
|
+
return null;
|
|
164
|
+
segments.push(text.slice(start));
|
|
165
|
+
return segments;
|
|
166
|
+
}
|
|
167
|
+
function getTagIdentityWriteGeneration() {
|
|
168
|
+
return tagIdentityWriteGeneration;
|
|
169
|
+
}
|
|
67
170
|
function installTransactionRouting(db, readonly) {
|
|
68
171
|
const nativeExec = db.exec.bind(db);
|
|
69
172
|
Object.defineProperty(db, "exec", {
|
|
@@ -74,16 +177,30 @@ function installTransactionRouting(db, readonly) {
|
|
|
74
177
|
assertTransformWrite();
|
|
75
178
|
if (/^\s*BEGIN\s+(?:IMMEDIATE|EXCLUSIVE)(?:\s+TRANSACTION)?\s*;?\s*$/i.test(sql)) {
|
|
76
179
|
openWriterTransactions.delete(db);
|
|
77
|
-
if (transformPassScope.getStore()?.active || backgroundWriterScope.getStore())
|
|
180
|
+
if (transformPassScope.getStore()?.active || backgroundWriterScope.getStore()) {
|
|
78
181
|
acquireShort(db, () => nativeExec(sql), sql.trim());
|
|
79
|
-
else
|
|
182
|
+
} else {
|
|
80
183
|
nativeExec(sql);
|
|
184
|
+
openWriterTransactions.set(db, {
|
|
185
|
+
site: sql.trim(),
|
|
186
|
+
lane: "background",
|
|
187
|
+
acquireMs: 0,
|
|
188
|
+
attempts: 1,
|
|
189
|
+
acquiredAt: performance.now()
|
|
190
|
+
});
|
|
191
|
+
}
|
|
81
192
|
return db;
|
|
82
193
|
}
|
|
83
194
|
if (WRITER_TRANSACTION_END.test(sql) && openWriterTransactions.has(db))
|
|
84
195
|
return endWriterTransaction(db, () => nativeExec(sql), sql);
|
|
85
|
-
if (!/^\s*(?:SELECT|EXPLAIN|PRAGMA|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\b/i.test(sql))
|
|
86
|
-
|
|
196
|
+
if (!/^\s*(?:SELECT|EXPLAIN|PRAGMA|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\b/i.test(sql)) {
|
|
197
|
+
try {
|
|
198
|
+
return withAutocommitTimeout(db, () => nativeExec(sql), false);
|
|
199
|
+
} finally {
|
|
200
|
+
if (mayChangeTagIdentity(sql))
|
|
201
|
+
tagIdentityWriteGeneration += 1;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
87
204
|
return nativeExec(sql);
|
|
88
205
|
}
|
|
89
206
|
});
|
|
@@ -94,13 +211,23 @@ function installTransactionRouting(db, readonly) {
|
|
|
94
211
|
value: (sql) => {
|
|
95
212
|
const statement = nativePrepare(sql);
|
|
96
213
|
if (!readonly && !/^\s*(?:SELECT|EXPLAIN|PRAGMA)\b/i.test(sql)) {
|
|
214
|
+
const changesTagIdentity = mayChangeTagIdentity(sql);
|
|
97
215
|
for (const method of ["run", "get", "all"]) {
|
|
98
216
|
const execute = statement[method].bind(statement);
|
|
99
217
|
Object.defineProperty(statement, method, {
|
|
100
218
|
configurable: true,
|
|
101
|
-
value: (...args) =>
|
|
219
|
+
value: (...args) => {
|
|
220
|
+
try {
|
|
221
|
+
return withAutocommitTimeout(db, () => execute(...args));
|
|
222
|
+
} finally {
|
|
223
|
+
if (changesTagIdentity)
|
|
224
|
+
tagIdentityWriteGeneration += 1;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
102
227
|
});
|
|
103
228
|
}
|
|
229
|
+
if (changesTagIdentity)
|
|
230
|
+
wrapRemainingTagWriteForms(statement);
|
|
104
231
|
}
|
|
105
232
|
return statement;
|
|
106
233
|
}
|
|
@@ -148,6 +275,35 @@ function installTransactionRouting(db, readonly) {
|
|
|
148
275
|
}
|
|
149
276
|
});
|
|
150
277
|
}
|
|
278
|
+
function wrapRemainingTagWriteForms(statement) {
|
|
279
|
+
if (typeof statement.iterate === "function") {
|
|
280
|
+
const iterate = statement.iterate.bind(statement);
|
|
281
|
+
Object.defineProperty(statement, "iterate", {
|
|
282
|
+
configurable: true,
|
|
283
|
+
value: function* (...args) {
|
|
284
|
+
tagIdentityWriteGeneration += 1;
|
|
285
|
+
try {
|
|
286
|
+
yield* iterate(...args);
|
|
287
|
+
} finally {
|
|
288
|
+
tagIdentityWriteGeneration += 1;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (typeof statement.values === "function") {
|
|
294
|
+
const values = statement.values.bind(statement);
|
|
295
|
+
Object.defineProperty(statement, "values", {
|
|
296
|
+
configurable: true,
|
|
297
|
+
value: (...args) => {
|
|
298
|
+
try {
|
|
299
|
+
return values(...args);
|
|
300
|
+
} finally {
|
|
301
|
+
tagIdentityWriteGeneration += 1;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
151
307
|
function trackSqliteConnection(db, filename, options) {
|
|
152
308
|
const originalClose = db.close.bind(db);
|
|
153
309
|
const sequence = nextSqliteConnectionSequence++;
|
|
@@ -181,7 +337,7 @@ function trackSqliteConnection(db, filename, options) {
|
|
|
181
337
|
}
|
|
182
338
|
var TrackedDatabase = new Proxy(DatabaseImpl, {
|
|
183
339
|
construct(target, args) {
|
|
184
|
-
const db = Reflect.construct(target, args, target);
|
|
340
|
+
const db = inRootAsyncContext(() => Reflect.construct(target, args, target));
|
|
185
341
|
return trackSqliteConnection(db, args[0], args[1]);
|
|
186
342
|
}
|
|
187
343
|
});
|
|
@@ -208,6 +364,18 @@ function buildNodeSqliteDatabaseClass(DatabaseSync) {
|
|
|
208
364
|
return NodeSqliteDatabase;
|
|
209
365
|
}
|
|
210
366
|
var Database = TrackedDatabase;
|
|
367
|
+
function getSqliteDatabasePath(db) {
|
|
368
|
+
for (const connection of trackedSqliteConnections.values()) {
|
|
369
|
+
if (connection.reference.deref() === db) {
|
|
370
|
+
return connection.filename === ":memory:" || connection.filename === "<buffer>" ? null : connection.filename;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const native = db;
|
|
374
|
+
const path = native.filename ?? native.name;
|
|
375
|
+
if (typeof path === "string" && path !== ":memory:" && path !== "")
|
|
376
|
+
return path;
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
211
379
|
function pragmaValue(db, name) {
|
|
212
380
|
const row = db.prepare(`PRAGMA ${name}`).get();
|
|
213
381
|
if (!row)
|
|
@@ -355,22 +523,29 @@ function withSqliteTransformPass(operation) {
|
|
|
355
523
|
const existing = transformPassScope.getStore();
|
|
356
524
|
if (existing?.active)
|
|
357
525
|
return operation();
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
526
|
+
const reservation = reserveForegroundSqliteTurn();
|
|
527
|
+
const run = (release) => {
|
|
528
|
+
const lease = { active: true, remainingWaitMs: FOREGROUND_IN_PASS_BUSY_TIMEOUT_MS };
|
|
529
|
+
return transformPassScope.run(lease, () => {
|
|
530
|
+
try {
|
|
531
|
+
const result = operation();
|
|
532
|
+
if (result && typeof result.then === "function") {
|
|
533
|
+
return Promise.resolve(result).finally(() => {
|
|
534
|
+
lease.active = false;
|
|
535
|
+
release();
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
lease.active = false;
|
|
539
|
+
release();
|
|
540
|
+
return result;
|
|
541
|
+
} catch (error) {
|
|
542
|
+
lease.active = false;
|
|
543
|
+
release();
|
|
544
|
+
throw error;
|
|
366
545
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
lease.active = false;
|
|
371
|
-
throw error;
|
|
372
|
-
}
|
|
373
|
-
});
|
|
546
|
+
});
|
|
547
|
+
};
|
|
548
|
+
return typeof reservation === "function" ? run(reservation) : reservation.then(run);
|
|
374
549
|
}
|
|
375
550
|
function withoutSqliteTransformPass(operation) {
|
|
376
551
|
return transformPassScope.run(undefined, operation);
|
|
@@ -396,9 +571,9 @@ class SqliteAcquisitionBusyError extends Error {
|
|
|
396
571
|
}
|
|
397
572
|
}
|
|
398
573
|
var SHORT_BUSY_TIMEOUT_MS = 25;
|
|
399
|
-
var FOREGROUND_IN_PASS_BUSY_TIMEOUT_MS =
|
|
574
|
+
var FOREGROUND_IN_PASS_BUSY_TIMEOUT_MS = 2000;
|
|
400
575
|
var FOREGROUND_ACQUISITION_BUDGET_MS = 16500;
|
|
401
|
-
var SLOW_WRITER_LOG_MS =
|
|
576
|
+
var SLOW_WRITER_LOG_MS = 100;
|
|
402
577
|
var WRITER_TRANSACTION_END = /^\s*(?:COMMIT|END|ROLLBACK)(?:\s+TRANSACTION)?\s*;?\s*$/i;
|
|
403
578
|
var writerAcquisitionScope = new AsyncLocalStorage;
|
|
404
579
|
var openWriterTransactions = new WeakMap;
|
|
@@ -406,25 +581,52 @@ function foregroundWaitLease() {
|
|
|
406
581
|
const lease = transformPassScope.getStore();
|
|
407
582
|
return lease?.active && !admissionScope.getStore() && !backgroundWriterScope.getStore() ? lease : undefined;
|
|
408
583
|
}
|
|
409
|
-
function withAutocommitTimeout(db, operation) {
|
|
584
|
+
function withAutocommitTimeout(db, operation, singleStatement = true) {
|
|
410
585
|
assertTransformWrite();
|
|
411
586
|
const lease = foregroundWaitLease();
|
|
412
|
-
if (isInTransaction(db)
|
|
587
|
+
if (isInTransaction(db))
|
|
413
588
|
return operation();
|
|
414
|
-
const
|
|
415
|
-
|
|
589
|
+
const scoped = lease || backgroundWriterScope.getStore();
|
|
590
|
+
const previous = scoped ? pragmaNumber(db, "busy_timeout") : null;
|
|
416
591
|
const started = performance.now();
|
|
592
|
+
let completed = false;
|
|
593
|
+
const execute = () => {
|
|
594
|
+
const result = operation();
|
|
595
|
+
completed = true;
|
|
596
|
+
return result;
|
|
597
|
+
};
|
|
417
598
|
try {
|
|
418
|
-
|
|
599
|
+
if (!scoped)
|
|
600
|
+
return execute();
|
|
601
|
+
if (singleStatement) {
|
|
602
|
+
db.exec("PRAGMA busy_timeout=0");
|
|
603
|
+
try {
|
|
604
|
+
return execute();
|
|
605
|
+
} catch (error) {
|
|
606
|
+
if (!isTransientSqliteError(error) || isInTransaction(db))
|
|
607
|
+
throw error;
|
|
608
|
+
}
|
|
609
|
+
assertTransformWrite();
|
|
610
|
+
}
|
|
611
|
+
const timeout = Math.floor(Math.min(lease?.remainingWaitMs ?? SHORT_BUSY_TIMEOUT_MS, lease?.guard?.remainingMs() ?? Infinity));
|
|
612
|
+
db.exec(`PRAGMA busy_timeout=${timeout}`);
|
|
613
|
+
const waitStarted = performance.now();
|
|
614
|
+
try {
|
|
615
|
+
return execute();
|
|
616
|
+
} finally {
|
|
617
|
+
if (lease)
|
|
618
|
+
lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - (performance.now() - waitStarted));
|
|
619
|
+
}
|
|
419
620
|
} catch (error) {
|
|
420
621
|
if (lease && isTransientSqliteError(error))
|
|
421
622
|
throw new SqliteAcquisitionBusyError(error, "autocommit");
|
|
422
623
|
throw error;
|
|
423
624
|
} finally {
|
|
424
|
-
|
|
425
|
-
lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - (performance.now() - started));
|
|
625
|
+
const elapsed = performance.now() - started;
|
|
426
626
|
if (previous !== null)
|
|
427
627
|
db.exec(`PRAGMA busy_timeout=${previous}`);
|
|
628
|
+
if (elapsed >= SLOW_WRITER_LOG_MS)
|
|
629
|
+
reportSqliteDiagnostic(`sqlite writer site=autocommit lane=${lease ? "foreground" : "background"} elapsed_ms=${Math.round(elapsed)} timing=statement_including_acquisition outcome=${completed ? "completed" : "failed"} caller=${writerCaller()}`);
|
|
428
630
|
}
|
|
429
631
|
}
|
|
430
632
|
function acquireShort(db, acquire, site) {
|
|
@@ -481,11 +683,15 @@ function endWriterTransaction(db, end, sql) {
|
|
|
481
683
|
const holdMs = performance.now() - open.acquiredAt;
|
|
482
684
|
if (open.acquireMs >= SLOW_WRITER_LOG_MS || holdMs >= SLOW_WRITER_LOG_MS) {
|
|
483
685
|
const outcome = /^\s*ROLLBACK/i.test(sql) ? "rolled_back" : ended ? "committed" : "failed";
|
|
484
|
-
reportSqliteDiagnostic(`sqlite writer site=${open.site} lane=${open.lane} acquire_ms=${Math.round(open.acquireMs)} hold_ms=${Math.round(holdMs)} attempts=${open.attempts} outcome=${outcome}`);
|
|
686
|
+
reportSqliteDiagnostic(`sqlite writer site=${open.site} lane=${open.lane} acquire_ms=${Math.round(open.acquireMs)} hold_ms=${Math.round(holdMs)} attempts=${open.attempts} outcome=${outcome} timing=through_commit_upper_bound caller=${writerCaller()}`);
|
|
485
687
|
}
|
|
486
688
|
}
|
|
487
689
|
}
|
|
488
690
|
}
|
|
691
|
+
function writerCaller() {
|
|
692
|
+
return new Error().stack?.split(`
|
|
693
|
+
`).find((line) => line.includes(" at ") && !/[/\\]sqlite\.[tj]s[:)]/.test(line) && !/\b(?:writerCaller|endWriterTransaction|withAutocommitTimeout|value)\b/.test(line))?.trim().replace(/\s+/g, "_") ?? "unknown";
|
|
694
|
+
}
|
|
489
695
|
async function beginSqliteWriterAsync(db, site) {
|
|
490
696
|
const started = performance.now();
|
|
491
697
|
let attempts = 0;
|
|
@@ -621,5 +827,56 @@ function withPrivilegedWriter(db, operation) {
|
|
|
621
827
|
throw error;
|
|
622
828
|
}
|
|
623
829
|
}
|
|
830
|
+
var indexCoordinationKey = Symbol.for("magic-context.index-foreground-coordination.v1");
|
|
831
|
+
var indexCoordinationHeap = globalThis;
|
|
832
|
+
var indexCoordinationBuffer = indexCoordinationHeap[indexCoordinationKey] ?? new SharedArrayBuffer(3 * Int32Array.BYTES_PER_ELEMENT);
|
|
833
|
+
indexCoordinationHeap[indexCoordinationKey] = indexCoordinationBuffer;
|
|
834
|
+
var indexCoordinationState = new Int32Array(indexCoordinationBuffer);
|
|
835
|
+
function indexCoordinationInput() {
|
|
836
|
+
return {
|
|
837
|
+
indexCoordination: indexCoordinationBuffer,
|
|
838
|
+
indexOwner: Atomics.add(indexCoordinationState, 2, 1) + 1
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
var yieldIndexTurn = () => new Promise((resolve) => setTimeout(resolve, 1));
|
|
842
|
+
function reserveForegroundSqliteTurn() {
|
|
843
|
+
Atomics.add(indexCoordinationState, 0, 1);
|
|
844
|
+
const release = () => {
|
|
845
|
+
Atomics.sub(indexCoordinationState, 0, 1);
|
|
846
|
+
Atomics.notify(indexCoordinationState, 0);
|
|
847
|
+
};
|
|
848
|
+
if (Atomics.load(indexCoordinationState, 1) === 0)
|
|
849
|
+
return release;
|
|
850
|
+
return (async () => {
|
|
851
|
+
while (Atomics.load(indexCoordinationState, 1) !== 0)
|
|
852
|
+
await yieldIndexTurn();
|
|
853
|
+
return release;
|
|
854
|
+
})();
|
|
855
|
+
}
|
|
856
|
+
function releaseIndexOwner(input) {
|
|
857
|
+
if (!input.indexCoordination || !input.indexOwner)
|
|
858
|
+
return;
|
|
859
|
+
const shared = new Int32Array(input.indexCoordination);
|
|
860
|
+
Atomics.compareExchange(shared, 1, input.indexOwner, 0);
|
|
861
|
+
Atomics.notify(shared, 1);
|
|
862
|
+
}
|
|
863
|
+
async function withIndexChunk(input, operation) {
|
|
864
|
+
if (!input.indexCoordination || !input.indexOwner)
|
|
865
|
+
return operation();
|
|
866
|
+
const shared = new Int32Array(input.indexCoordination);
|
|
867
|
+
for (;; ) {
|
|
868
|
+
if (Atomics.load(shared, 0) === 0 && Atomics.compareExchange(shared, 1, 0, input.indexOwner) === 0) {
|
|
869
|
+
if (Atomics.load(shared, 0) === 0)
|
|
870
|
+
break;
|
|
871
|
+
releaseIndexOwner(input);
|
|
872
|
+
}
|
|
873
|
+
await yieldIndexTurn();
|
|
874
|
+
}
|
|
875
|
+
try {
|
|
876
|
+
return await operation();
|
|
877
|
+
} finally {
|
|
878
|
+
releaseIndexOwner(input);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
624
881
|
|
|
625
|
-
export { registerSlowWriteReporter, registerSqliteDiagnosticSink, detectSqliteRuntime, Database, getSqliteMemoryStats, prepareCachedStatement, withSqliteBackgroundWriter, withSqliteTransformPass, withoutSqliteTransformPass, isTransientSqliteError, SqliteAcquisitionBusyError, beginSqliteWriterAsync, withAsyncPrivilegedWriter, withPrivilegedWriter };
|
|
882
|
+
export { inRootAsyncContext, registerSlowWriteReporter, registerSqliteDiagnosticSink, detectSqliteRuntime, getTagIdentityWriteGeneration, Database, getSqliteDatabasePath, getSqliteMemoryStats, prepareCachedStatement, withSqliteBackgroundWriter, withSqliteTransformPass, withoutSqliteTransformPass, isTransientSqliteError, SqliteAcquisitionBusyError, beginSqliteWriterAsync, withAsyncPrivilegedWriter, withPrivilegedWriter, indexCoordinationInput, withIndexChunk };
|
|
@@ -431,8 +431,12 @@ function flush() {
|
|
|
431
431
|
let currentSize = getCurrentLogSize(logFile);
|
|
432
432
|
const dataSize = Buffer.byteLength(data);
|
|
433
433
|
if (currentSize > 0 && currentSize + dataSize > MAX_LOG_FILE_BYTES) {
|
|
434
|
-
|
|
435
|
-
currentSize =
|
|
434
|
+
flushesSinceSizeCheck = SIZE_CHECK_INTERVAL_FLUSHES;
|
|
435
|
+
currentSize = getCurrentLogSize(logFile);
|
|
436
|
+
if (currentSize > 0 && currentSize + dataSize > MAX_LOG_FILE_BYTES) {
|
|
437
|
+
rotateLogFile(logFile, currentSize);
|
|
438
|
+
currentSize = 0;
|
|
439
|
+
}
|
|
436
440
|
}
|
|
437
441
|
fs.appendFileSync(logFile, data, { encoding: "utf8", mode: 384 });
|
|
438
442
|
buffer = [];
|