@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,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getHarness,
|
|
3
|
-
getDataDir,
|
|
4
3
|
getMagicContextStorageDir,
|
|
5
4
|
log,
|
|
6
5
|
sessionLog
|
|
7
|
-
} from "./index-
|
|
6
|
+
} from "./index-k59af64t.js";
|
|
8
7
|
import {
|
|
9
8
|
modelRefLookupOrder,
|
|
10
9
|
localBudget,
|
|
@@ -12,8 +11,8 @@ import {
|
|
|
12
11
|
} from "./index-x37vg474.js";
|
|
13
12
|
|
|
14
13
|
// src/shared/models-dev-cache.ts
|
|
15
|
-
import { readFileSync
|
|
16
|
-
import { join as
|
|
14
|
+
import { readFileSync } from "node:fs";
|
|
15
|
+
import { join as join2 } from "node:path";
|
|
17
16
|
|
|
18
17
|
// src/shared/storage-permissions.ts
|
|
19
18
|
import { randomBytes } from "node:crypto";
|
|
@@ -21,6 +20,7 @@ import {
|
|
|
21
20
|
chmodSync,
|
|
22
21
|
closeSync,
|
|
23
22
|
createWriteStream,
|
|
23
|
+
fsyncSync,
|
|
24
24
|
lstatSync,
|
|
25
25
|
mkdirSync,
|
|
26
26
|
openSync,
|
|
@@ -46,6 +46,14 @@ function ensureStorageDirectorySync(directory, forcePrivate = false, recursive =
|
|
|
46
46
|
...privateMode ? { mode: 448 } : {}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
+
function ensurePrivateStorageDirectorySync(directory) {
|
|
50
|
+
ensureStorageDirectorySync(directory, true);
|
|
51
|
+
const stat = lstatSync(directory);
|
|
52
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
53
|
+
throw new Error("Private storage directory is not a real directory");
|
|
54
|
+
if (process.platform !== "win32")
|
|
55
|
+
chmodSync(directory, 448);
|
|
56
|
+
}
|
|
49
57
|
function writeStorageFileSync(filePath, content, options = {}) {
|
|
50
58
|
const { forcePrivate = false, ...writeOptions } = options;
|
|
51
59
|
const privateMode = forcePrivate || shouldEnforcePrivateStoragePermissions();
|
|
@@ -65,6 +73,35 @@ function writeStorageFileAtomicSync(filePath, content, forcePrivate = false) {
|
|
|
65
73
|
throw error;
|
|
66
74
|
}
|
|
67
75
|
}
|
|
76
|
+
function syncStorageDirectorySync(directory) {
|
|
77
|
+
const fd = openSync(directory, "r");
|
|
78
|
+
try {
|
|
79
|
+
fsyncSync(fd);
|
|
80
|
+
} finally {
|
|
81
|
+
closeSync(fd);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function writeStorageFileDurableAtomicSync(filePath, content, afterTempSync) {
|
|
85
|
+
const directory = dirname(filePath);
|
|
86
|
+
ensurePrivateStorageDirectorySync(directory);
|
|
87
|
+
const tempPath = `${filePath}.${process.pid}.${randomBytes(12).toString("hex")}.tmp`;
|
|
88
|
+
let fd;
|
|
89
|
+
try {
|
|
90
|
+
fd = openStorageFileSync(tempPath, "wx", true);
|
|
91
|
+
writeFileSync(fd, content, "utf8");
|
|
92
|
+
fsyncSync(fd);
|
|
93
|
+
closeSync(fd);
|
|
94
|
+
fd = undefined;
|
|
95
|
+
afterTempSync?.();
|
|
96
|
+
renameSync(tempPath, filePath);
|
|
97
|
+
syncStorageDirectorySync(directory);
|
|
98
|
+
syncStorageDirectorySync(dirname(directory));
|
|
99
|
+
} finally {
|
|
100
|
+
if (fd !== undefined)
|
|
101
|
+
closeSync(fd);
|
|
102
|
+
rmSync(tempPath, { force: true });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
68
105
|
function copyStorageFileSync(sourcePath, destinationPath, forcePrivate = false) {
|
|
69
106
|
ensureStorageDirectorySync(dirname(destinationPath), forcePrivate);
|
|
70
107
|
const privateMode = forcePrivate || shouldEnforcePrivateStoragePermissions();
|
|
@@ -92,6 +129,11 @@ function copyStorageFileSync(sourcePath, destinationPath, forcePrivate = false)
|
|
|
92
129
|
closeSync(destinationFd);
|
|
93
130
|
}
|
|
94
131
|
}
|
|
132
|
+
function openStorageFileSync(filePath, flags, forcePrivate = false) {
|
|
133
|
+
ensureStorageDirectorySync(dirname(filePath), forcePrivate);
|
|
134
|
+
const privateMode = forcePrivate || shouldEnforcePrivateStoragePermissions();
|
|
135
|
+
return openSync(filePath, flags, privateMode ? 384 : 438);
|
|
136
|
+
}
|
|
95
137
|
async function writeStorageFileAsync(filePath, content, forcePrivate = false) {
|
|
96
138
|
const privateMode = forcePrivate || shouldEnforcePrivateStoragePermissions();
|
|
97
139
|
ensureStorageDirectorySync(dirname(filePath), privateMode);
|
|
@@ -143,9 +185,6 @@ function tightenStorageTreeSync(root) {
|
|
|
143
185
|
}
|
|
144
186
|
|
|
145
187
|
// src/shared/window-geometry.ts
|
|
146
|
-
import { readFileSync } from "node:fs";
|
|
147
|
-
import { join as join2 } from "node:path";
|
|
148
|
-
var WINDOW_OVERLAY_SCHEMA = "fusiform-window-overlay/v1";
|
|
149
188
|
var PROMPT_WALL_MARGIN = 4096;
|
|
150
189
|
var PI_OUTPUT_FLOOR = 4096;
|
|
151
190
|
var OPENCODE_OUTPUT_CAP = 32000;
|
|
@@ -160,241 +199,10 @@ var PROVIDER_GEOMETRY = {
|
|
|
160
199
|
google: "separate",
|
|
161
200
|
"google-antigravity": "separate"
|
|
162
201
|
};
|
|
163
|
-
var GRADES = new Set([
|
|
164
|
-
"provider_asserted_runtime",
|
|
165
|
-
"measured",
|
|
166
|
-
"provider_asserted_doc",
|
|
167
|
-
"catalog",
|
|
168
|
-
"unknown"
|
|
169
|
-
]);
|
|
170
|
-
var UNITS = new Set(["provider", "estimate"]);
|
|
171
|
-
var BOUNDARIES = new Set(["Observed", "Asserted", "Corrected"]);
|
|
172
|
-
var UNKNOWN_REASONS = new Set([
|
|
173
|
-
"placeholder_output_equals_context",
|
|
174
|
-
"placeholder_zero",
|
|
175
|
-
"never_measured",
|
|
176
|
-
"not_single_valued_at_key",
|
|
177
|
-
"retracted"
|
|
178
|
-
]);
|
|
179
|
-
var NUMERIC_FACT_KEYS = new Set([
|
|
180
|
-
"window.advertised",
|
|
181
|
-
"window.enforced",
|
|
182
|
-
"output.advertised",
|
|
183
|
-
"output.enforced",
|
|
184
|
-
"output.default"
|
|
185
|
-
]);
|
|
186
|
-
var configuredOverlayPath;
|
|
187
|
-
var loadedOverlayPath;
|
|
188
|
-
var loadedOverlay;
|
|
189
202
|
var geometryClampLogSeen = new Set;
|
|
190
|
-
function isRecord(value) {
|
|
191
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
192
|
-
}
|
|
193
203
|
function isFinitePositive(value) {
|
|
194
204
|
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
195
205
|
}
|
|
196
|
-
function scalarizeFact(value) {
|
|
197
|
-
if (value.kind === "stated")
|
|
198
|
-
return isFinitePositive(value.value) ? value.value : undefined;
|
|
199
|
-
if (value.kind === "bracket") {
|
|
200
|
-
return isFinitePositive(value.at_least) ? value.at_least : undefined;
|
|
201
|
-
}
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
function parseFactValue(value) {
|
|
205
|
-
if (!isRecord(value) || typeof value.kind !== "string")
|
|
206
|
-
return;
|
|
207
|
-
if (value.kind === "stated") {
|
|
208
|
-
if ((typeof value.value !== "number" || !Number.isFinite(value.value)) && typeof value.value !== "string") {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
return { kind: "stated", value: value.value };
|
|
212
|
-
}
|
|
213
|
-
if (value.kind === "bracket") {
|
|
214
|
-
const atLeast = value.at_least;
|
|
215
|
-
const below = value.below;
|
|
216
|
-
if (atLeast === undefined && below === undefined)
|
|
217
|
-
return { kind: "bracket" };
|
|
218
|
-
if (atLeast !== undefined && !isFinitePositive(atLeast))
|
|
219
|
-
return;
|
|
220
|
-
if (below !== undefined && !isFinitePositive(below))
|
|
221
|
-
return;
|
|
222
|
-
if (isFinitePositive(atLeast) && isFinitePositive(below) && below <= atLeast) {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
return {
|
|
226
|
-
kind: "bracket",
|
|
227
|
-
...isFinitePositive(atLeast) ? { at_least: atLeast } : {},
|
|
228
|
-
...isFinitePositive(below) ? { below } : {}
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
if (value.kind === "unknown" && UNKNOWN_REASONS.has(value.why)) {
|
|
232
|
-
return { kind: "unknown", why: value.why };
|
|
233
|
-
}
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
function parseFact(key, value) {
|
|
237
|
-
if (!isRecord(value))
|
|
238
|
-
return;
|
|
239
|
-
const parsedValue = parseFactValue(value.value);
|
|
240
|
-
if (!parsedValue || !GRADES.has(value.grade) || !UNITS.has(value.units) || !BOUNDARIES.has(value.boundary) || typeof value.source_ref !== "string" || value.source_ref.length === 0 || typeof value.observed_at !== "string" || value.observed_at.length === 0) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
if (NUMERIC_FACT_KEYS.has(key) && parsedValue.kind === "stated" && !isFinitePositive(parsedValue.value)) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (key === "geometry" && parsedValue.kind === "stated" && !["shared_upfront", "shared_truncating", "separate"].includes(String(parsedValue.value))) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
return {
|
|
250
|
-
...value,
|
|
251
|
-
value: parsedValue,
|
|
252
|
-
grade: value.grade,
|
|
253
|
-
units: value.units,
|
|
254
|
-
boundary: value.boundary,
|
|
255
|
-
source_ref: value.source_ref,
|
|
256
|
-
observed_at: value.observed_at
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
function parseWindowOverlay(value) {
|
|
260
|
-
if (!isRecord(value)) {
|
|
261
|
-
return { badCells: 0, refusal: "overlay root is not an object" };
|
|
262
|
-
}
|
|
263
|
-
if (value.schema !== WINDOW_OVERLAY_SCHEMA) {
|
|
264
|
-
return {
|
|
265
|
-
badCells: 0,
|
|
266
|
-
refusal: `unrecognized schema ${JSON.stringify(value.schema)}`
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
if (typeof value.generated_at !== "string" || !Array.isArray(value.minted_provider_ids) || !value.minted_provider_ids.every((id) => typeof id === "string" && id.length > 0) || !Array.isArray(value.cells)) {
|
|
270
|
-
return { badCells: 0, refusal: "invalid v1 envelope" };
|
|
271
|
-
}
|
|
272
|
-
const cells = [];
|
|
273
|
-
let badCells = 0;
|
|
274
|
-
for (const rawCell of value.cells) {
|
|
275
|
-
if (!isRecord(rawCell) || typeof rawCell.provider_id !== "string" || rawCell.provider_id.length === 0 || typeof rawCell.model_id !== "string" || rawCell.model_id.length === 0 || !isRecord(rawCell.facts)) {
|
|
276
|
-
badCells++;
|
|
277
|
-
continue;
|
|
278
|
-
}
|
|
279
|
-
const facts = {};
|
|
280
|
-
let valid = true;
|
|
281
|
-
for (const [key, rawFact] of Object.entries(rawCell.facts)) {
|
|
282
|
-
const fact = parseFact(key, rawFact);
|
|
283
|
-
if (!fact) {
|
|
284
|
-
valid = false;
|
|
285
|
-
break;
|
|
286
|
-
}
|
|
287
|
-
facts[key] = fact;
|
|
288
|
-
}
|
|
289
|
-
if (!valid) {
|
|
290
|
-
badCells++;
|
|
291
|
-
continue;
|
|
292
|
-
}
|
|
293
|
-
cells.push({
|
|
294
|
-
provider_id: rawCell.provider_id,
|
|
295
|
-
model_id: rawCell.model_id,
|
|
296
|
-
facts
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
return {
|
|
300
|
-
overlay: {
|
|
301
|
-
schema: WINDOW_OVERLAY_SCHEMA,
|
|
302
|
-
generated_at: value.generated_at,
|
|
303
|
-
minted_provider_ids: [...value.minted_provider_ids],
|
|
304
|
-
cells
|
|
305
|
-
},
|
|
306
|
-
badCells
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
function defaultWindowOverlayPath() {
|
|
310
|
-
return join2(getDataDir(), "fusiform", "window-overlay.json");
|
|
311
|
-
}
|
|
312
|
-
function readWindowOverlayFile(path, log = (message) => sessionLog("global", message)) {
|
|
313
|
-
let raw;
|
|
314
|
-
try {
|
|
315
|
-
raw = readFileSync(path, "utf8");
|
|
316
|
-
} catch (error) {
|
|
317
|
-
if (error.code === "ENOENT")
|
|
318
|
-
return;
|
|
319
|
-
log(`window-overlay: unable to read ${path}; overlay ignored`);
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
let decoded;
|
|
323
|
-
try {
|
|
324
|
-
decoded = JSON.parse(raw);
|
|
325
|
-
} catch {
|
|
326
|
-
log(`window-overlay: invalid JSON in ${path}; overlay ignored`);
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
const parsed = parseWindowOverlay(decoded);
|
|
330
|
-
if (parsed.refusal) {
|
|
331
|
-
log(`window-overlay: ${parsed.refusal} in ${path}; entire overlay ignored`);
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
if (parsed.badCells > 0) {
|
|
335
|
-
log(`window-overlay: skipped ${parsed.badCells} invalid cell(s) from ${path}`);
|
|
336
|
-
}
|
|
337
|
-
return parsed.overlay;
|
|
338
|
-
}
|
|
339
|
-
function setWindowOverlayPath(path) {
|
|
340
|
-
if (configuredOverlayPath === path)
|
|
341
|
-
return;
|
|
342
|
-
reloadWindowOverlay(path);
|
|
343
|
-
}
|
|
344
|
-
function reloadWindowOverlay(path) {
|
|
345
|
-
configuredOverlayPath = path;
|
|
346
|
-
loadedOverlayPath = undefined;
|
|
347
|
-
loadedOverlay = undefined;
|
|
348
|
-
}
|
|
349
|
-
function getWindowOverlay() {
|
|
350
|
-
const path = configuredOverlayPath ?? defaultWindowOverlayPath();
|
|
351
|
-
if (loadedOverlayPath === path && loadedOverlay !== undefined) {
|
|
352
|
-
return loadedOverlay ?? undefined;
|
|
353
|
-
}
|
|
354
|
-
loadedOverlayPath = path;
|
|
355
|
-
loadedOverlay = readWindowOverlayFile(path) ?? null;
|
|
356
|
-
return loadedOverlay ?? undefined;
|
|
357
|
-
}
|
|
358
|
-
function resolveWindowOverlayFacts(providerID, modelID, overlay = getWindowOverlay()) {
|
|
359
|
-
if (!overlay)
|
|
360
|
-
return;
|
|
361
|
-
const modelRefs = modelRefLookupOrder(`${providerID}/${modelID}`);
|
|
362
|
-
const providerCandidates = new Set(modelRefs.map((ref) => ref.slice(0, ref.indexOf("/"))));
|
|
363
|
-
const modelCandidates = new Set([
|
|
364
|
-
modelID,
|
|
365
|
-
...modelRefs.map((ref) => ref.slice(ref.indexOf("/") + 1))
|
|
366
|
-
]);
|
|
367
|
-
const colon = modelID.lastIndexOf(":");
|
|
368
|
-
if (colon > 0)
|
|
369
|
-
modelCandidates.add(modelID.slice(0, colon));
|
|
370
|
-
const wildcardFacts = {};
|
|
371
|
-
const specificFacts = {};
|
|
372
|
-
for (const cell of overlay.cells) {
|
|
373
|
-
if (!providerCandidates.has(cell.provider_id))
|
|
374
|
-
continue;
|
|
375
|
-
if (cell.model_id === "*")
|
|
376
|
-
Object.assign(wildcardFacts, cell.facts);
|
|
377
|
-
else if (modelCandidates.has(cell.model_id))
|
|
378
|
-
Object.assign(specificFacts, cell.facts);
|
|
379
|
-
}
|
|
380
|
-
const facts = { ...wildcardFacts, ...specificFacts };
|
|
381
|
-
return Object.keys(facts).length > 0 ? { facts } : undefined;
|
|
382
|
-
}
|
|
383
|
-
function numericOverlayFact(overlay, key) {
|
|
384
|
-
const fact = overlay?.facts[key];
|
|
385
|
-
return fact ? scalarizeFact(fact.value) : undefined;
|
|
386
|
-
}
|
|
387
|
-
function overlayGeometry(overlay) {
|
|
388
|
-
const fact = overlay?.facts.geometry;
|
|
389
|
-
if (fact === undefined)
|
|
390
|
-
return;
|
|
391
|
-
if (fact.value.kind === "unknown")
|
|
392
|
-
return { kind: "unknown" };
|
|
393
|
-
if (fact.value.kind !== "stated")
|
|
394
|
-
return;
|
|
395
|
-
const value = fact.value.value;
|
|
396
|
-
return value === "shared_upfront" || value === "shared_truncating" || value === "separate" ? { kind: "stated", value } : undefined;
|
|
397
|
-
}
|
|
398
206
|
function placeholderFilteredOutput(output, context) {
|
|
399
207
|
if (!isFinitePositive(output))
|
|
400
208
|
return;
|
|
@@ -402,8 +210,8 @@ function placeholderFilteredOutput(output, context) {
|
|
|
402
210
|
return;
|
|
403
211
|
return output;
|
|
404
212
|
}
|
|
405
|
-
function mergePositive(
|
|
406
|
-
return isFinitePositive(providerValue) ? providerValue :
|
|
213
|
+
function mergePositive(catalogValue, providerValue) {
|
|
214
|
+
return isFinitePositive(providerValue) ? providerValue : catalogValue;
|
|
407
215
|
}
|
|
408
216
|
function logGeometryClampOnce(key, message, log) {
|
|
409
217
|
if (geometryClampLogSeen.has(key))
|
|
@@ -417,10 +225,8 @@ function deriveWindowGeometry(providerID, modelID, catalogLimit, options = {}) {
|
|
|
417
225
|
const providerLimit = options.providerLimit;
|
|
418
226
|
const catalogContext = isFinitePositive(catalogLimit?.context) ? catalogLimit.context : undefined;
|
|
419
227
|
const providerContext = isFinitePositive(providerLimit?.context) ? providerLimit.context : undefined;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
let softContext = mergePositive(enforced ?? advertised ?? catalogContext, providerContext);
|
|
423
|
-
let hardContext = mergePositive(enforced ?? softContext, providerContext);
|
|
228
|
+
let softContext = mergePositive(catalogContext, providerContext);
|
|
229
|
+
let hardContext = mergePositive(softContext, providerContext);
|
|
424
230
|
const contextCap = isFinitePositive(options.contextCap) ? options.contextCap : undefined;
|
|
425
231
|
const hasContextCap = contextCap !== undefined;
|
|
426
232
|
if (contextCap !== undefined) {
|
|
@@ -430,13 +236,10 @@ function deriveWindowGeometry(providerID, modelID, catalogLimit, options = {}) {
|
|
|
430
236
|
const input = mergePositive(isFinitePositive(catalogLimit?.input) ? catalogLimit.input : undefined, providerLimit?.input);
|
|
431
237
|
if (!isFinitePositive(softContext) && !isFinitePositive(input))
|
|
432
238
|
return;
|
|
433
|
-
const catalogOutput = options.
|
|
434
|
-
const overlayOutput = placeholderFilteredOutput(numericOverlayFact(options.overlay, "output.enforced") ?? numericOverlayFact(options.overlay, "output.default") ?? numericOverlayFact(options.overlay, "output.advertised"), softContext);
|
|
239
|
+
const catalogOutput = options.providerLimit === undefined ? isFinitePositive(catalogLimit?.output) ? catalogLimit.output : undefined : placeholderFilteredOutput(catalogLimit?.output, softContext);
|
|
435
240
|
const providerOutput = placeholderFilteredOutput(providerLimit?.output, softContext);
|
|
436
|
-
const output = providerOutput ??
|
|
437
|
-
const
|
|
438
|
-
const geometry = geometryFact?.kind === "stated" ? geometryFact.value : geometryFact?.kind === "unknown" ? "shared_upfront" : PROVIDER_GEOMETRY[providerID] ?? "shared_upfront";
|
|
439
|
-
const geometryOverride = geometryFact?.kind === "stated" ? geometryFact.value : undefined;
|
|
241
|
+
const output = providerOutput ?? catalogOutput;
|
|
242
|
+
const geometry = PROVIDER_GEOMETRY[providerID] ?? "shared_upfront";
|
|
440
243
|
const preCarvedInput = isFinitePositive(input) && (!isFinitePositive(softContext) || input < softContext);
|
|
441
244
|
const outputReserveOverride = typeof options.outputReserveOverride === "number" && Number.isFinite(options.outputReserveOverride) && options.outputReserveOverride >= 0 ? options.outputReserveOverride : undefined;
|
|
442
245
|
let derivationWindow = softContext ?? input;
|
|
@@ -464,14 +267,14 @@ function deriveWindowGeometry(providerID, modelID, catalogLimit, options = {}) {
|
|
|
464
267
|
reserveSource = "output_catalog";
|
|
465
268
|
}
|
|
466
269
|
} else if (isFinitePositive(softContext)) {
|
|
467
|
-
if (geometry === "separate"
|
|
270
|
+
if (geometry === "separate") {
|
|
468
271
|
softReserve = 0;
|
|
469
272
|
reserveSource = "none";
|
|
470
273
|
} else {
|
|
471
274
|
softReserve = output ?? 0;
|
|
472
275
|
reserveSource = output === undefined ? "none" : "output_catalog";
|
|
473
276
|
const cap = softContext * OUTPUT_RESERVE_CAP_RATIO;
|
|
474
|
-
softReserve = Math.min(softReserve,
|
|
277
|
+
softReserve = Math.min(softReserve, cap);
|
|
475
278
|
}
|
|
476
279
|
const floor = Math.max(MIN_PLAUSIBLE_CONTEXT_LIMIT, softContext * 0.5);
|
|
477
280
|
const flooredReserve = Math.min(softReserve, Math.max(0, softContext - floor));
|
|
@@ -486,7 +289,7 @@ function deriveWindowGeometry(providerID, modelID, catalogLimit, options = {}) {
|
|
|
486
289
|
const hardWindow = hardContext ?? softContext ?? input;
|
|
487
290
|
if (!isFinitePositive(hardWindow))
|
|
488
291
|
return;
|
|
489
|
-
const windowSource = hasContextCap ? "detected" : providerContext !== undefined ? "provider" :
|
|
292
|
+
const windowSource = hasContextCap ? "detected" : providerContext !== undefined ? "provider" : "catalog";
|
|
490
293
|
let usableHard;
|
|
491
294
|
if (geometry === "separate") {
|
|
492
295
|
usableHard = hardWindow;
|
|
@@ -502,7 +305,7 @@ function deriveWindowGeometry(providerID, modelID, catalogLimit, options = {}) {
|
|
|
502
305
|
}
|
|
503
306
|
usableHard = Math.max(MIN_PLAUSIBLE_CONTEXT_LIMIT, Math.floor(usableHard));
|
|
504
307
|
if (usableHard < usableSoft) {
|
|
505
|
-
logGeometryClampOnce(`${providerID}/${modelID}|${usableSoft}|${usableHard}`, `usable hard limit clamped for ${providerID}/${modelID}: ${usableHard} → ${usableSoft} (
|
|
308
|
+
logGeometryClampOnce(`${providerID}/${modelID}|${usableSoft}|${usableHard}`, `usable hard limit clamped for ${providerID}/${modelID}: ${usableHard} → ${usableSoft} (window limit inversion)`, options.log);
|
|
506
309
|
usableHard = usableSoft;
|
|
507
310
|
}
|
|
508
311
|
const resolvedWindow = derivationWindow ?? usableSoft;
|
|
@@ -569,14 +372,14 @@ var apiCache = null;
|
|
|
569
372
|
var apiLoadedAt = 0;
|
|
570
373
|
var persistSeedLoaded = false;
|
|
571
374
|
function persistFilePath() {
|
|
572
|
-
return
|
|
375
|
+
return join2(getMagicContextStorageDir(), `model-context-limits-${getHarness()}.json`);
|
|
573
376
|
}
|
|
574
377
|
function loadPersistedApiCacheOnce() {
|
|
575
378
|
if (persistSeedLoaded || apiCache !== null)
|
|
576
379
|
return;
|
|
577
380
|
persistSeedLoaded = true;
|
|
578
381
|
try {
|
|
579
|
-
const raw =
|
|
382
|
+
const raw = readFileSync(persistFilePath(), "utf-8");
|
|
580
383
|
const obj = JSON.parse(raw);
|
|
581
384
|
const map = new Map;
|
|
582
385
|
for (const [key, persisted] of Object.entries(obj)) {
|
|
@@ -766,7 +569,6 @@ function getSdkWindowGeometry(providerID, modelID, detectedContextLimit, options
|
|
|
766
569
|
input: metadata.inputLimit,
|
|
767
570
|
output: metadata.outputLimit
|
|
768
571
|
}, {
|
|
769
|
-
overlay: resolveWindowOverlayFacts(providerID, modelID, getWindowOverlay()),
|
|
770
572
|
outputReserveOverride: resolveOutputReserve(providerID, modelID),
|
|
771
573
|
harness: options?.harness ?? "opencode",
|
|
772
574
|
contextCap: promptOnlyDetected === undefined && isFinitePositive2(detectedContextLimit) ? detectedContextLimit : undefined
|
|
@@ -905,4 +707,4 @@ function producerSourceLocalBudget2(providerTokens, modelKey) {
|
|
|
905
707
|
return ratio === 1 ? providerTokens : localBudget(providerTokens, ratio);
|
|
906
708
|
}
|
|
907
709
|
|
|
908
|
-
export { shouldEnforcePrivateStoragePermissions, ensureStorageDirectorySync, writeStorageFileSync, writeStorageFileAtomicSync, copyStorageFileSync, writeStorageFileAsync, createStorageWriteStream, tightenStorageTreeSync, catalogOutputReserve,
|
|
710
|
+
export { shouldEnforcePrivateStoragePermissions, ensureStorageDirectorySync, ensurePrivateStorageDirectorySync, writeStorageFileSync, writeStorageFileAtomicSync, syncStorageDirectorySync, writeStorageFileDurableAtomicSync, copyStorageFileSync, writeStorageFileAsync, createStorageWriteStream, tightenStorageTreeSync, catalogOutputReserve, hasTrustedAbsoluteWall, applyProvenInputFloor, isSaneLimit, setOutputReserveConfig, resolveLimit, refreshModelLimitsFromApi, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getModelsDevCacheState, deriveTriggerBudget2, deriveHistorianChunkTokens2, resolveKnownHistorianContextLimit2, resolveHistorianProducerLimits2, resolveHistorianContextLimit2, producerSourceLocalBudget2 };
|
|
@@ -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 };
|