@retaw106/mmc-oc 2.3.0 → 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 +12 -1
- package/dist/config/schema/magic-context.d.ts +33 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/config-init.js +12 -1
- package/dist/{context-wt7g4f8k.js → context-c72brxe5.js} +717 -206
- 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/storage-tags.d.ts +4 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +57 -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/apply-operations.d.ts +3 -1
- package/dist/hooks/magic-context/apply-operations.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/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 +2 -0
- package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -1
- package/dist/hooks/magic-context/provider-visible-parts.d.ts +10 -4
- package/dist/hooks/magic-context/provider-visible-parts.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/supersession-reclaim.d.ts +5 -3
- package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- 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/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 +2 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +0 -7
- 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-3gj1ak4c.js → index-27ddyx39.js} +1 -1
- package/dist/{index-z2w1eq3y.js → index-48e9znrc.js} +491 -197
- package/dist/{index-z2g20msd.js → index-azbmnekv.js} +4 -4
- package/dist/{index-czba8tw3.js → index-dwh99z66.js} +33 -10
- package/dist/{index-kw21z5pe.js → index-kahkxcqw.js} +7005 -6903
- package/dist/{index-a5mw0xp3.js → index-r7s7d350.js} +1 -1
- package/dist/{index-18yrysyj.js → index-ykq24x1n.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{message-time-backfill-sykevdax.js → message-time-backfill-j96x1sab.js} +1 -1
- package/dist/model-resolution-cvyrrcjw.js +8 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{read-session-chunk-863d6c06.js → read-session-chunk-t8bg6wkz.js} +3 -3
- package/dist/{recomp-orchestrator-wrjy3qym.js → recomp-orchestrator-k760qy1n.js} +6 -6
- package/dist/{send-session-notification-cz6ev088.js → send-session-notification-njjf3b4s.js} +3 -3
- package/dist/shared/model-suggestion-retry.d.ts +21 -0
- package/dist/shared/model-suggestion-retry.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/sqlite.d.ts +2 -0
- 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/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/v2/hidden-completion.d.ts +20 -1
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.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/server.js +8312 -7354
- package/dist/v2/store-reader.d.ts +27 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/web/main.js +34 -10
- package/dist/{wrapup-orchestrator-bmybc5p5.js → wrapup-orchestrator-b2gswatj.js} +6 -6
- package/package.json +1 -1
- package/src/config/latch-permanence-guard.test.ts +4 -0
- package/src/config/project-security.test.ts +17 -0
- package/src/config/schema/magic-context.test.ts +50 -0
- package/src/config/schema/magic-context.ts +34 -1
- package/src/shared/model-suggestion-retry.ts +5 -1
- 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/root-async-context.probe.mjs +36 -0
- package/src/shared/root-async-context.test.ts +49 -0
- package/src/shared/sqlite-busy-budget-review.test.ts +291 -0
- package/src/shared/sqlite-foreground-wait.test.ts +237 -1
- package/src/shared/sqlite.ts +55 -14
- package/src/shared/stable-json.ts +56 -14
- 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/dist/model-resolution-wazv26n0.js +0 -6
|
@@ -8,7 +8,7 @@ function readString(value) {
|
|
|
8
8
|
const trimmed = value.trim();
|
|
9
9
|
return trimmed.length > 0 ? trimmed : undefined;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function normalizeModelEntry2(entry, harness) {
|
|
12
12
|
if (typeof entry === "string") {
|
|
13
13
|
const model = readString(entry);
|
|
14
14
|
return model ? { model } : undefined;
|
|
@@ -33,7 +33,7 @@ function resolveFallbackEntries(value, harness) {
|
|
|
33
33
|
const values = Array.isArray(value) ? value : value === undefined ? [] : [value];
|
|
34
34
|
const resolved = [];
|
|
35
35
|
for (const value of values) {
|
|
36
|
-
const entry =
|
|
36
|
+
const entry = normalizeModelEntry2(value, harness);
|
|
37
37
|
if (!entry || !isValidModelReference(entry))
|
|
38
38
|
continue;
|
|
39
39
|
if (resolved.some((candidate) => sameAttempt(candidate, entry)))
|
|
@@ -43,7 +43,7 @@ function resolveFallbackEntries(value, harness) {
|
|
|
43
43
|
return resolved;
|
|
44
44
|
}
|
|
45
45
|
function resolvePrimaryEntry(args) {
|
|
46
|
-
const entry =
|
|
46
|
+
const entry = normalizeModelEntry2(args.entry, args.harness);
|
|
47
47
|
if (!entry)
|
|
48
48
|
return;
|
|
49
49
|
const qualifier = entry.qualifier ?? readString(args.defaultQualifier);
|
|
@@ -62,4 +62,4 @@ function resolveHistorianModel2(config, harness) {
|
|
|
62
62
|
fallbacks: resolveFallbackEntries(historian.fallback_models, harness)
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
export { resolveHistorianModel2 };
|
|
65
|
+
export { normalizeModelEntry2, resolveHistorianModel2 };
|
|
@@ -1,6 +1,10 @@
|
|
|
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;
|
|
@@ -191,7 +195,7 @@ function installTransactionRouting(db, readonly) {
|
|
|
191
195
|
return endWriterTransaction(db, () => nativeExec(sql), sql);
|
|
192
196
|
if (!/^\s*(?:SELECT|EXPLAIN|PRAGMA|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\b/i.test(sql)) {
|
|
193
197
|
try {
|
|
194
|
-
return withAutocommitTimeout(db, () => nativeExec(sql));
|
|
198
|
+
return withAutocommitTimeout(db, () => nativeExec(sql), false);
|
|
195
199
|
} finally {
|
|
196
200
|
if (mayChangeTagIdentity(sql))
|
|
197
201
|
tagIdentityWriteGeneration += 1;
|
|
@@ -333,7 +337,7 @@ function trackSqliteConnection(db, filename, options) {
|
|
|
333
337
|
}
|
|
334
338
|
var TrackedDatabase = new Proxy(DatabaseImpl, {
|
|
335
339
|
construct(target, args) {
|
|
336
|
-
const db = Reflect.construct(target, args, target);
|
|
340
|
+
const db = inRootAsyncContext(() => Reflect.construct(target, args, target));
|
|
337
341
|
return trackSqliteConnection(db, args[0], args[1]);
|
|
338
342
|
}
|
|
339
343
|
});
|
|
@@ -577,29 +581,48 @@ function foregroundWaitLease() {
|
|
|
577
581
|
const lease = transformPassScope.getStore();
|
|
578
582
|
return lease?.active && !admissionScope.getStore() && !backgroundWriterScope.getStore() ? lease : undefined;
|
|
579
583
|
}
|
|
580
|
-
function withAutocommitTimeout(db, operation) {
|
|
584
|
+
function withAutocommitTimeout(db, operation, singleStatement = true) {
|
|
581
585
|
assertTransformWrite();
|
|
582
586
|
const lease = foregroundWaitLease();
|
|
583
587
|
if (isInTransaction(db))
|
|
584
588
|
return operation();
|
|
585
589
|
const scoped = lease || backgroundWriterScope.getStore();
|
|
586
590
|
const previous = scoped ? pragmaNumber(db, "busy_timeout") : null;
|
|
587
|
-
if (scoped)
|
|
588
|
-
db.exec(`PRAGMA busy_timeout=${lease ? Math.floor(Math.min(lease.remainingWaitMs, lease.guard?.remainingMs() ?? Infinity)) : SHORT_BUSY_TIMEOUT_MS}`);
|
|
589
591
|
const started = performance.now();
|
|
590
592
|
let completed = false;
|
|
591
|
-
|
|
593
|
+
const execute = () => {
|
|
592
594
|
const result = operation();
|
|
593
595
|
completed = true;
|
|
594
596
|
return result;
|
|
597
|
+
};
|
|
598
|
+
try {
|
|
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
|
+
}
|
|
595
620
|
} catch (error) {
|
|
596
621
|
if (lease && isTransientSqliteError(error))
|
|
597
622
|
throw new SqliteAcquisitionBusyError(error, "autocommit");
|
|
598
623
|
throw error;
|
|
599
624
|
} finally {
|
|
600
625
|
const elapsed = performance.now() - started;
|
|
601
|
-
if (lease)
|
|
602
|
-
lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - elapsed);
|
|
603
626
|
if (previous !== null)
|
|
604
627
|
db.exec(`PRAGMA busy_timeout=${previous}`);
|
|
605
628
|
if (elapsed >= SLOW_WRITER_LOG_MS)
|
|
@@ -856,4 +879,4 @@ async function withIndexChunk(input, operation) {
|
|
|
856
879
|
}
|
|
857
880
|
}
|
|
858
881
|
|
|
859
|
-
export { registerSlowWriteReporter, registerSqliteDiagnosticSink, detectSqliteRuntime, getTagIdentityWriteGeneration, Database, getSqliteDatabasePath, getSqliteMemoryStats, prepareCachedStatement, withSqliteBackgroundWriter, withSqliteTransformPass, withoutSqliteTransformPass, isTransientSqliteError, SqliteAcquisitionBusyError, beginSqliteWriterAsync, withAsyncPrivilegedWriter, withPrivilegedWriter, indexCoordinationInput, withIndexChunk };
|
|
882
|
+
export { inRootAsyncContext, registerSlowWriteReporter, registerSqliteDiagnosticSink, detectSqliteRuntime, getTagIdentityWriteGeneration, Database, getSqliteDatabasePath, getSqliteMemoryStats, prepareCachedStatement, withSqliteBackgroundWriter, withSqliteTransformPass, withoutSqliteTransformPass, isTransientSqliteError, SqliteAcquisitionBusyError, beginSqliteWriterAsync, withAsyncPrivilegedWriter, withPrivilegedWriter, indexCoordinationInput, withIndexChunk };
|