@cortexkit/opencode-magic-context 0.49.20 → 0.49.22
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/auto-search-worker.js +6 -6
- package/dist/chunk-embedding-write-worker.js +9 -9
- package/dist/{compaction-marker-candidates-b2q30cft.js → compaction-marker-candidates-31h86ph0.js} +2 -2
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/{compartment-chunk-embedding-va090as0.js → compartment-chunk-embedding-he60aaa2.js} +5 -5
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +37 -3
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-frp3z2wk.js → conflict-warning-hook-2r32hyx6.js} +5 -5
- package/dist/{context-mkece1db.js → context-j7hp43a0.js} +153 -83
- package/dist/{embedding-backfill-gy3p78py.js → embedding-backfill-dtke6tck.js} +11 -11
- package/dist/embedding-worker-process.js +1 -1
- package/dist/embedding-worker.js +4 -4
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts +1 -0
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts +7 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +7 -2
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +2 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search-rerank.d.ts +9 -2
- package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +2 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -0
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +1 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +1 -0
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/served-shape-repair.d.ts +19 -0
- package/dist/hooks/magic-context/served-shape-repair.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts +4 -2
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-content-primitives.d.ts +1 -1
- package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +2 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/text-complete.d.ts +1 -1
- package/dist/hooks/magic-context/text-complete.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +2 -2
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-t7hx3qcb.js → index-11gzxvf4.js} +101 -46
- package/dist/{index-neb2jaed.js → index-1gtfne2c.js} +1 -1
- package/dist/{index-67nyj0gy.js → index-1kbznkft.js} +48 -24
- package/dist/{index-1pefp8ar.js → index-3svaejkh.js} +4 -4
- package/dist/{index-0wthn7fp.js → index-51rdvtkz.js} +35 -4
- package/dist/{index-kc9pn495.js → index-66eby7hx.js} +1 -1
- package/dist/{index-pnjwa6qa.js → index-9q1g3c5q.js} +2 -2
- package/dist/{index-rmd0069m.js → index-a9zvn5fe.js} +24 -10
- package/dist/{index-jfh3cktr.js → index-ffzhwfzy.js} +3 -3
- package/dist/{v2/server-1zx2pa5d.js → index-gzy5w8ya.js} +193 -4
- package/dist/{index-d6rp4dxh.js → index-j32jj2t8.js} +4 -4
- package/dist/{index-35qc6606.js → index-jfem3dgz.js} +1 -1
- package/dist/{index-y4a3nhtk.js → index-jjvbk92s.js} +1 -1
- package/dist/{index-4n7w9rad.js → index-jmq8kfe7.js} +5 -5
- package/dist/{index-c4b76d4t.js → index-kfyb3k6n.js} +1 -1
- package/dist/{index-vkc1ca9p.js → index-kq5w68dp.js} +1 -1
- package/dist/{index-11zf2wwc.js → index-ksq50rg0.js} +2 -2
- package/dist/{index-153r2q6z.js → index-m32esgmj.js} +2 -2
- package/dist/{index-x4k3f4mf.js → index-mnhcdfxg.js} +148 -8
- package/dist/{index-48stjd56.js → index-mnnkgq0q.js} +10 -4
- package/dist/{index-wgypt3cs.js → index-nxrsns5x.js} +2466 -1290
- package/dist/{index-616rsjrv.js → index-qgh1qwjj.js} +1 -1
- package/dist/{index-jr5na10t.js → index-rxqr723x.js} +4 -4
- package/dist/{index-dc8hy95c.js → index-syaazvy2.js} +123 -40
- package/dist/{index-adk2z5d8.js → index-wfybj1dw.js} +2 -4
- package/dist/{index-305y133n.js → index-whcgcfrv.js} +6 -3
- package/dist/{index-jmycsey7.js → index-x6cbrv9h.js} +2 -2
- package/dist/{index-v7r4td4c.js → index-y76rhsnr.js} +28 -17
- package/dist/{index-2yhtnfcf.js → index-zy67whjr.js} +26 -8
- package/dist/index.js +43 -42
- package/dist/{message-fts-rowid-map-22tevnnj.js → message-fts-rowid-map-e79b7b6x.js} +3 -3
- package/dist/{message-index-5qxcz6h7.js → message-index-4q8ek2fc.js} +10 -10
- package/dist/{message-index-bounded-n0m0t7tv.js → message-index-bounded-rydsg9r5.js} +10 -10
- package/dist/{message-time-backfill-0myx7fz3.js → message-time-backfill-4qva0b4f.js} +1 -1
- package/dist/migration-worker.js +6 -6
- package/dist/plugin/embedding-bootstrap.d.ts +1 -0
- package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +1 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/{project-embedding-registry-s2pqgec9.js → project-embedding-registry-hn529988.js} +12 -10
- package/dist/raw-ordinal-warmup-worker.js +8 -8
- package/dist/{read-session-chunk-0a8vdyqp.js → read-session-chunk-t039f0m5.js} +6 -6
- package/dist/{read-session-raw-y5cszf0b.js → read-session-raw-aw6jgvwg.js} +2 -2
- package/dist/{recomp-orchestrator-61vyha9j.js → recomp-orchestrator-hbm53jj5.js} +23 -23
- package/dist/{search-archive-8q9s49p5.js → search-archive-weh164mh.js} +7 -7
- package/dist/{search-v1y9ejws.js → search-hea079d7.js} +19 -19
- package/dist/{send-session-notification-0k6qzydk.js → send-session-notification-gqzkz7da.js} +4 -4
- package/dist/shared/sqlite.d.ts +5 -0
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/tag-transcript.d.ts +2 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/{sqlite-1rpvw2rj.js → sqlite-zdgm52sv.js} +5 -1
- package/dist/{storage-memory-nm7v82mj.js → storage-memory-e6a7mb0k.js} +2 -2
- package/dist/{storage-tags-r6nk29n4.js → storage-tags-a77q4v77.js} +2 -2
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/types.d.ts +1 -0
- package/dist/tools/ctx-search/types.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-vtrgb7m6.js → transform-postprocess-phase-0b04tm1p.js} +23 -23
- package/dist/v2/auto-search-worker.js +6 -6
- package/dist/v2/chunk-embedding-write-worker.js +11 -11
- package/dist/v2/{compaction-marker-candidates-cfab70cs.js → compaction-marker-candidates-m4vmye3w.js} +2 -2
- package/dist/v2/compaction-marker-candidates-worker.js +2 -2
- package/dist/v2/{compartment-chunk-embedding-nbdqx1td.js → compartment-chunk-embedding-8jjmcgeg.js} +5 -5
- package/dist/v2/{context-cc33tv2z.js → context-ea3x7smm.js} +652 -468
- package/dist/v2/{embedding-backfill-yxv2h5mc.js → embedding-backfill-5e74ae0m.js} +11 -11
- package/dist/v2/embedding-worker-process.js +1 -1
- package/dist/v2/embedding-worker.js +4 -4
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/copied-tag-notation.d.ts +1 -1
- package/dist/v2/hooks/copied-tag-notation.d.ts.map +1 -1
- package/dist/v2/hooks/dream-timer.d.ts +2 -0
- package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
- package/dist/v2/hooks/embedding-lifecycle.d.ts +7 -0
- package/dist/v2/hooks/embedding-lifecycle.d.ts.map +1 -0
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts +2 -0
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts +2 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/hooks/transform-features.d.ts +2 -2
- package/dist/v2/hooks/transform-features.d.ts.map +1 -1
- package/dist/v2/{message-fts-rowid-map-dg12wymk.js → message-fts-rowid-map-n8fdg2ja.js} +3 -3
- package/dist/v2/{message-index-bounded-f4e01xk0.js → message-index-bounded-8rcd7qq9.js} +12 -12
- package/dist/v2/{message-index-ydzrp6y6.js → message-index-qz9wdp82.js} +12 -12
- package/dist/v2/{message-time-backfill-ddh8n9gy.js → message-time-backfill-zvthw6xb.js} +1 -1
- package/dist/v2/migration-worker.js +8 -8
- package/dist/v2/{project-embedding-registry-deza9ksw.js → project-embedding-registry-v38q4xd5.js} +12 -10
- package/dist/v2/raw-ordinal-warmup-worker.js +8 -8
- package/dist/v2/{read-session-chunk-8cxfagky.js → read-session-chunk-wazfyxcg.js} +8 -8
- package/dist/v2/{read-session-raw-1nrrecvx.js → read-session-raw-b70cpwzj.js} +2 -2
- package/dist/v2/{recomp-orchestrator-47m4hv5g.js → recomp-orchestrator-b12zaptj.js} +25 -25
- package/dist/v2/{search-archive-e80cvc09.js → search-archive-x64rtz1z.js} +9 -9
- package/dist/v2/{search-fjz746zr.js → search-hza9x72a.js} +21 -21
- package/dist/v2/{send-session-notification-nwvrv34d.js → send-session-notification-8eqe259v.js} +4 -4
- package/dist/v2/{server-4sxjs6hn.js → server-132h8twc.js} +4 -4
- package/dist/v2/{server-271qxsf5.js → server-24g8r2d0.js} +2466 -1290
- package/dist/v2/{server-m91f9m5s.js → server-33nqbqkw.js} +123 -40
- package/dist/v2/{server-brj8j2gk.js → server-3vhxy2k5.js} +1 -1
- package/dist/v2/{server-55rgxfrw.js → server-4kjmrjn4.js} +1 -1
- package/dist/v2/{server-wyawsa88.js → server-62g58aaz.js} +2 -2
- package/dist/v2/{server-230fnbws.js → server-6v3cdzsx.js} +1 -1
- package/dist/v2/{server-ygtykank.js → server-806rzhs6.js} +1 -1
- package/dist/v2/{server-5arr9ecn.js → server-94wk1ey3.js} +12 -1
- package/dist/v2/{server-af2pght7.js → server-ab1g0wn9.js} +2 -4
- package/dist/v2/{server-0epqaxhd.js → server-ad18djzs.js} +26 -8
- package/dist/v2/{server-4nw4fqhr.js → server-bsgd4dk1.js} +1 -1
- package/dist/v2/{server-dj7tz4ph.js → server-d1dzgvwd.js} +1 -1
- package/dist/v2/{server-vn2nwcv6.js → server-d48x3m4x.js} +4 -4
- package/dist/v2/{server-br1x0tev.js → server-dtp8hcjh.js} +2 -2
- package/dist/v2/{server-a3dwxfgd.js → server-fa7vtp40.js} +7 -4
- package/dist/{index-1zx2pa5d.js → v2/server-gzy5w8ya.js} +193 -4
- package/dist/v2/{server-hqzyq8n4.js → server-j8h7bsca.js} +26 -12
- package/dist/v2/{server-y4a3nhtk.js → server-jjvbk92s.js} +1 -1
- package/dist/v2/{server-ej96a39v.js → server-m4bfaevz.js} +1186 -1046
- package/dist/v2/{server-63fqdghs.js → server-ppcd1qxh.js} +92 -86
- package/dist/v2/{server-ne8arh8t.js → server-qjvk4a9t.js} +1 -1
- package/dist/v2/{server-xsryvyf6.js → server-qteg2kt9.js} +4 -4
- package/dist/v2/{server-168pb207.js → server-rqebawx1.js} +1 -1
- package/dist/v2/{server-j4jnp9b5.js → server-vr4szghm.js} +35 -4
- package/dist/v2/{server-9x0kmta4.js → server-wwaw5npa.js} +3 -3
- package/dist/v2/{server-c7dxxsj7.js → server-zg5y109h.js} +33 -33
- package/dist/v2/server.js +6 -6
- package/dist/v2/{sqlite-1rpvw2rj.js → sqlite-zdgm52sv.js} +5 -1
- package/dist/v2/{storage-memory-nm7v82mj.js → storage-memory-e6a7mb0k.js} +2 -2
- package/dist/v2/{storage-tags-ss08kj5r.js → storage-tags-q71rnr9f.js} +3 -3
- package/dist/v2/store-reader.d.ts +2 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-639whfhq.js → wrapup-orchestrator-3ssd5yy1.js} +25 -25
- package/dist/wrapup-orchestrator-5vpcd1zx.js +49 -0
- package/package.json +2 -2
- package/src/config/index.test.ts +44 -0
- package/src/config/project-security.ts +15 -0
- package/src/config/rerank.test.ts +60 -0
- package/src/config/schema/magic-context.ts +57 -0
- package/src/shared/model-suggestion-retry.ts +1 -1
- package/src/shared/sqlite-turn-deadline.test.ts +270 -0
- package/src/shared/sqlite.ts +235 -7
- package/src/shared/tag-transcript.ts +9 -1
- package/dist/wrapup-orchestrator-mnvt2g8m.js +0 -49
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
StaleRouteHandleError,
|
|
7
7
|
SubcClient,
|
|
8
8
|
isConsumerReconnectTransient
|
|
9
|
-
} from "./server-
|
|
9
|
+
} from "./server-ab1g0wn9.js";
|
|
10
10
|
import {
|
|
11
11
|
getHarness2
|
|
12
12
|
} from "./server-pavzsdc6.js";
|
|
@@ -16,13 +16,13 @@ import {
|
|
|
16
16
|
} from "./server-6495nmn9.js";
|
|
17
17
|
import {
|
|
18
18
|
inRootAsyncContext2
|
|
19
|
-
} from "./server-
|
|
19
|
+
} from "./server-gzy5w8ya.js";
|
|
20
20
|
import {
|
|
21
21
|
buildCanonicalChunkTextFromFts2,
|
|
22
22
|
loadCompartmentChunkEmbeddingsForSearch2,
|
|
23
23
|
peekCompartmentChunkSearchPool2,
|
|
24
24
|
warmCompartmentChunkSearchPool2
|
|
25
|
-
} from "./server-
|
|
25
|
+
} from "./server-62g58aaz.js";
|
|
26
26
|
import {
|
|
27
27
|
recordEmbeddingMeasurement,
|
|
28
28
|
saveCommitEmbedding,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
enqueueShadowEmbeddingItems2,
|
|
40
40
|
getProjectEmbeddingSnapshot2,
|
|
41
41
|
embedItemsForProject2
|
|
42
|
-
} from "./server-
|
|
42
|
+
} from "./server-ad18djzs.js";
|
|
43
43
|
import {
|
|
44
44
|
getProjectEmbeddings2
|
|
45
45
|
} from "./server-4dhv7mqz.js";
|
|
@@ -48,13 +48,13 @@ import {
|
|
|
48
48
|
isEmbeddingEnabled,
|
|
49
49
|
embedText,
|
|
50
50
|
ensureMemoryEmbeddings2
|
|
51
|
-
} from "./server-
|
|
51
|
+
} from "./server-qteg2kt9.js";
|
|
52
52
|
import {
|
|
53
53
|
ModuleMemoryAuthorityError2,
|
|
54
54
|
getMemoriesByProject2,
|
|
55
55
|
getMemoriesByProjects2,
|
|
56
56
|
updateMemoryRetrievalCount2
|
|
57
|
-
} from "./server-
|
|
57
|
+
} from "./server-jjvbk92s.js";
|
|
58
58
|
import {
|
|
59
59
|
getNotes,
|
|
60
60
|
getActivePrimers,
|
|
@@ -63,27 +63,27 @@ import {
|
|
|
63
63
|
sanitizeFtsQuery,
|
|
64
64
|
searchMemoriesFTS,
|
|
65
65
|
searchMemoriesFTSUnion
|
|
66
|
-
} from "./server-
|
|
66
|
+
} from "./server-d48x3m4x.js";
|
|
67
67
|
import {
|
|
68
68
|
cleanSearchText,
|
|
69
69
|
keywordRelevance,
|
|
70
70
|
matchedSearchSnippet,
|
|
71
71
|
getIndexedMessageCorpusSize2
|
|
72
|
-
} from "./server-
|
|
72
|
+
} from "./server-ppcd1qxh.js";
|
|
73
73
|
import {
|
|
74
74
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
75
75
|
withMessageFtsSessionFilter
|
|
76
76
|
} from "./server-kaqs6h31.js";
|
|
77
77
|
import {
|
|
78
78
|
isRecord
|
|
79
|
-
} from "./server-
|
|
79
|
+
} from "./server-fa7vtp40.js";
|
|
80
80
|
import {
|
|
81
81
|
resolveWorkspaceShareCategories,
|
|
82
82
|
resolveWorkspaceIdentitySet,
|
|
83
83
|
expandWorkspaceIdentitySetWithAliases,
|
|
84
84
|
resolveStoredPathWorkspaceIdentity,
|
|
85
85
|
sourceNameForMemory
|
|
86
|
-
} from "./server-
|
|
86
|
+
} from "./server-wwaw5npa.js";
|
|
87
87
|
import {
|
|
88
88
|
isKnownAutocommit
|
|
89
89
|
} from "./server-8ajstryz.js";
|
|
@@ -1427,6 +1427,7 @@ function sha256(value) {
|
|
|
1427
1427
|
var RERANK_MODEL = "gte-reranker-modernbert-base-f32";
|
|
1428
1428
|
var RERANK_LANE_LIMIT = 25;
|
|
1429
1429
|
var DEADLINE_MS = 1500;
|
|
1430
|
+
var DOCUMENT_BYTES = 1024;
|
|
1430
1431
|
function isProseQuery(query) {
|
|
1431
1432
|
const text = query.trim();
|
|
1432
1433
|
if (!text || /[\n;]|^["'`]|["'`]$/.test(text))
|
|
@@ -1506,7 +1507,7 @@ function candidateText(location, title, body) {
|
|
|
1506
1507
|
${truncateUtf8(title.replaceAll(`
|
|
1507
1508
|
`, " "), 120)}
|
|
1508
1509
|
`;
|
|
1509
|
-
return header + truncateUtf8(body,
|
|
1510
|
+
return header + truncateUtf8(body, DOCUMENT_BYTES - Buffer.byteLength(header));
|
|
1510
1511
|
}
|
|
1511
1512
|
|
|
1512
1513
|
class RerankFailure extends Error {
|
|
@@ -1576,7 +1577,79 @@ async function connect(connectionFile) {
|
|
|
1576
1577
|
}
|
|
1577
1578
|
return bounded(connection);
|
|
1578
1579
|
}
|
|
1579
|
-
async function
|
|
1580
|
+
async function remoteScores(config, query, documents, signal) {
|
|
1581
|
+
const controller = new AbortController;
|
|
1582
|
+
let timer;
|
|
1583
|
+
let onAbort;
|
|
1584
|
+
try {
|
|
1585
|
+
const cancelled = new Promise((_, reject) => {
|
|
1586
|
+
const cancel = (reason) => {
|
|
1587
|
+
reject(new RerankFailure(reason));
|
|
1588
|
+
controller.abort();
|
|
1589
|
+
};
|
|
1590
|
+
onAbort = () => cancel("aborted");
|
|
1591
|
+
if (signal?.aborted)
|
|
1592
|
+
onAbort();
|
|
1593
|
+
else
|
|
1594
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1595
|
+
timer = setTimeout(() => cancel("timeout"), Math.max(50, Math.min(15000, config.timeout_ms ?? DEADLINE_MS)));
|
|
1596
|
+
});
|
|
1597
|
+
const request = async () => {
|
|
1598
|
+
const tei = config.endpoint?.startsWith("tei+");
|
|
1599
|
+
const endpoint = (tei ? config.endpoint?.slice(4) : config.endpoint)?.replace(/\/+$/, "");
|
|
1600
|
+
if (!endpoint || !/^https?:\/\//.test(endpoint))
|
|
1601
|
+
throw new RerankFailure("invalid_endpoint");
|
|
1602
|
+
const response = await fetch(`${endpoint}/rerank`, {
|
|
1603
|
+
method: "POST",
|
|
1604
|
+
headers: {
|
|
1605
|
+
"Content-Type": "application/json",
|
|
1606
|
+
...config.api_key ? { Authorization: `Bearer ${config.api_key}` } : {}
|
|
1607
|
+
},
|
|
1608
|
+
body: JSON.stringify(tei ? { query, texts: documents } : {
|
|
1609
|
+
model: config.model,
|
|
1610
|
+
query,
|
|
1611
|
+
documents,
|
|
1612
|
+
top_n: documents.length
|
|
1613
|
+
}),
|
|
1614
|
+
signal: controller.signal,
|
|
1615
|
+
redirect: "error"
|
|
1616
|
+
});
|
|
1617
|
+
if (!response.ok)
|
|
1618
|
+
throw new RerankFailure(`http_${response.status}`);
|
|
1619
|
+
const body = await response.json();
|
|
1620
|
+
const rows = tei ? body : body?.results;
|
|
1621
|
+
if (!Array.isArray(rows) || rows.length !== documents.length)
|
|
1622
|
+
throw new RerankFailure("invalid_reply");
|
|
1623
|
+
const scores = new Array(documents.length);
|
|
1624
|
+
const seen = new Set;
|
|
1625
|
+
for (const row of rows) {
|
|
1626
|
+
const index = row?.index;
|
|
1627
|
+
const score = tei ? row?.score : row?.relevance_score;
|
|
1628
|
+
if (!Number.isInteger(index) || index < 0 || index >= documents.length || seen.has(index) || typeof score !== "number" || !Number.isFinite(score))
|
|
1629
|
+
throw new RerankFailure("invalid_reply");
|
|
1630
|
+
seen.add(index);
|
|
1631
|
+
scores[index] = score;
|
|
1632
|
+
}
|
|
1633
|
+
return scores;
|
|
1634
|
+
};
|
|
1635
|
+
return await Promise.race([cancelled, request()]);
|
|
1636
|
+
} finally {
|
|
1637
|
+
clearTimeout(timer);
|
|
1638
|
+
if (onAbort)
|
|
1639
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
function remoteRerankSkipped(reason, onSkipped) {
|
|
1643
|
+
const safe = /^(?:invalid_reply|invalid_endpoint|validation|timeout|aborted|candidate_validation|http_\d{3})$/.test(reason) ? reason : "remote_error";
|
|
1644
|
+
const line = `Reranking skipped: ${safe}`;
|
|
1645
|
+
logRerankFallback(safe);
|
|
1646
|
+
onSkipped?.(line);
|
|
1647
|
+
}
|
|
1648
|
+
async function prepareReranker(projectRoot, sessionId, connectionFile, injectedClient, config) {
|
|
1649
|
+
if (config?.provider === "off")
|
|
1650
|
+
return null;
|
|
1651
|
+
if (config?.provider === "remote")
|
|
1652
|
+
return { remote: config };
|
|
1580
1653
|
try {
|
|
1581
1654
|
if (injectedClient === null)
|
|
1582
1655
|
throw new RerankFailure("missing_synapse");
|
|
@@ -1593,36 +1666,43 @@ async function prepareReranker(projectRoot, sessionId, connectionFile, injectedC
|
|
|
1593
1666
|
return null;
|
|
1594
1667
|
}
|
|
1595
1668
|
}
|
|
1596
|
-
async function rerankSearchResults(session, query, baseline, pool, texts, limit) {
|
|
1669
|
+
async function rerankSearchResults(session, query, baseline, pool, texts, limit, signal, onSkipped) {
|
|
1597
1670
|
if (!pool.length)
|
|
1598
1671
|
return baseline;
|
|
1599
1672
|
try {
|
|
1600
|
-
if (pool.length > 20 || texts.length !== pool.length || texts.some((text) => Buffer.byteLength(text) >
|
|
1601
|
-
throw new RerankFailure("validation");
|
|
1602
|
-
const body = unwrap(await bounded(session.client.call("synapse", "rerank.score", {
|
|
1603
|
-
model: RERANK_MODEL,
|
|
1604
|
-
query,
|
|
1605
|
-
candidates: texts,
|
|
1606
|
-
required_fingerprint: session.lane.fingerprint,
|
|
1607
|
-
allow_equivalent: false,
|
|
1608
|
-
accept_declared: false,
|
|
1609
|
-
max_queue_ms: 100,
|
|
1610
|
-
deadline_ms: DEADLINE_MS
|
|
1611
|
-
}, {
|
|
1612
|
-
timeoutMs: DEADLINE_MS,
|
|
1613
|
-
targetKind: "management_surface",
|
|
1614
|
-
identity: session.identity
|
|
1615
|
-
})));
|
|
1616
|
-
if (body.fingerprint !== session.lane.fingerprint)
|
|
1617
|
-
throw new RerankFailure("fingerprint_mismatch");
|
|
1618
|
-
if (body.table_epoch !== session.lane.tableEpoch)
|
|
1619
|
-
throw new RerankFailure("epoch_mismatch");
|
|
1620
|
-
if (!Array.isArray(body.scores) || body.scores.length !== pool.length || body.scores.some((score) => typeof score !== "number" || !Number.isFinite(score)))
|
|
1673
|
+
if (pool.length > 20 || texts.length !== pool.length || texts.some((text) => Buffer.byteLength(text) > DOCUMENT_BYTES))
|
|
1621
1674
|
throw new RerankFailure("validation");
|
|
1622
|
-
|
|
1675
|
+
let scores;
|
|
1676
|
+
if ("remote" in session) {
|
|
1677
|
+
scores = await remoteScores(session.remote, query, texts, signal);
|
|
1678
|
+
} else {
|
|
1679
|
+
const body = unwrap(await bounded(session.client.call("synapse", "rerank.score", {
|
|
1680
|
+
model: RERANK_MODEL,
|
|
1681
|
+
query,
|
|
1682
|
+
candidates: texts,
|
|
1683
|
+
required_fingerprint: session.lane.fingerprint,
|
|
1684
|
+
allow_equivalent: false,
|
|
1685
|
+
max_queue_ms: 100,
|
|
1686
|
+
deadline_ms: DEADLINE_MS
|
|
1687
|
+
}, {
|
|
1688
|
+
timeoutMs: DEADLINE_MS,
|
|
1689
|
+
targetKind: "management_surface",
|
|
1690
|
+
identity: session.identity
|
|
1691
|
+
})));
|
|
1692
|
+
if (body.fingerprint !== session.lane.fingerprint)
|
|
1693
|
+
throw new RerankFailure("fingerprint_mismatch");
|
|
1694
|
+
if (body.table_epoch !== session.lane.tableEpoch)
|
|
1695
|
+
throw new RerankFailure("epoch_mismatch");
|
|
1696
|
+
if (!Array.isArray(body.scores) || body.scores.length !== pool.length || body.scores.some((score) => typeof score !== "number" || !Number.isFinite(score)))
|
|
1697
|
+
throw new RerankFailure("validation");
|
|
1698
|
+
scores = body.scores;
|
|
1699
|
+
}
|
|
1623
1700
|
return pool.map((hit, index) => ({ hit, index, score: scores[index] })).sort((a, b) => b.score - a.score || a.index - b.index).slice(0, limit).map((row) => row.hit);
|
|
1624
1701
|
} catch (error) {
|
|
1625
|
-
|
|
1702
|
+
if ("remote" in session)
|
|
1703
|
+
remoteRerankSkipped(error instanceof RerankFailure ? error.reason : "remote_error", onSkipped);
|
|
1704
|
+
else
|
|
1705
|
+
logRerankFallback(reasonOf(error));
|
|
1626
1706
|
return baseline;
|
|
1627
1707
|
}
|
|
1628
1708
|
}
|
|
@@ -2943,7 +3023,7 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
2943
3023
|
return [];
|
|
2944
3024
|
}
|
|
2945
3025
|
const limit = normalizeLimit(options.limit);
|
|
2946
|
-
const reranker = options.explicitSearch && options.rerank !== false && isProseQuery(trimmedQuery) ? await prepareReranker(projectPath, sessionId, options.rerankConnectionFile, options.rerankClient) : null;
|
|
3026
|
+
const reranker = options.explicitSearch && options.rerank !== false && isProseQuery(trimmedQuery) ? await prepareReranker(projectPath, sessionId, options.rerankConnectionFile, options.rerankClient, options.rerankConfig) : null;
|
|
2947
3027
|
const lanes = reranker || options.captureRerankLanes ? emptySearchLanes() : undefined;
|
|
2948
3028
|
const dateRange = normalizeDateRange(options.from, options.to);
|
|
2949
3029
|
const tierLimit = Math.max(limit * 3, DEFAULT_UNIFIED_SEARCH_LIMIT);
|
|
@@ -3113,11 +3193,14 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3113
3193
|
options.captureRerankLanes?.(lanes);
|
|
3114
3194
|
}
|
|
3115
3195
|
if (reranker && lanes) {
|
|
3116
|
-
const pool = fuseSearchLanes(lanes);
|
|
3196
|
+
const pool = fuseSearchLanes(lanes).slice(0, "remote" in reranker ? reranker.remote.top_n : 20);
|
|
3117
3197
|
try {
|
|
3118
|
-
results = await rerankSearchResults(reranker, trimmedQuery, results, pool, candidateTexts(db, sessionId, projectPath, pool), limit);
|
|
3198
|
+
results = await rerankSearchResults(reranker, trimmedQuery, results, pool, candidateTexts(db, sessionId, projectPath, pool), limit, options.signal, options.onRerankSkipped);
|
|
3119
3199
|
} catch {
|
|
3120
|
-
|
|
3200
|
+
if ("remote" in reranker)
|
|
3201
|
+
remoteRerankSkipped("candidate_validation", options.onRerankSkipped);
|
|
3202
|
+
else
|
|
3203
|
+
logRerankFallback("candidate_validation");
|
|
3121
3204
|
}
|
|
3122
3205
|
}
|
|
3123
3206
|
if (!options.measurementDisabled) {
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
} from "./server-6495nmn9.js";
|
|
11
11
|
import {
|
|
12
12
|
isSynapseEmbeddingTruncated
|
|
13
|
-
} from "./server-
|
|
13
|
+
} from "./server-ab1g0wn9.js";
|
|
14
14
|
import {
|
|
15
15
|
messageFtsOrdinalRangeIsMapped2
|
|
16
|
-
} from "./server-
|
|
16
|
+
} from "./server-dtp8hcjh.js";
|
|
17
17
|
|
|
18
18
|
// src/features/magic-context/compartment-chunk-embedding.ts
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
PER_HARNESS_MODEL_KEYS,
|
|
12
12
|
ConfigProfilesSchema,
|
|
13
13
|
MagicContextConfigSchema
|
|
14
|
-
} from "./server-
|
|
14
|
+
} from "./server-24g8r2d0.js";
|
|
15
15
|
import {
|
|
16
16
|
isCompactionEnabled,
|
|
17
17
|
migrateLegacyAgentEnabledInMemory
|
|
@@ -2439,6 +2439,17 @@ function stripUnsafeProjectConfigFields(projectRaw) {
|
|
|
2439
2439
|
warnings.push(`Ignoring ${field} from project config (security: daemon routing and developer-only embedding traffic are user-level settings).`);
|
|
2440
2440
|
}
|
|
2441
2441
|
}
|
|
2442
|
+
if ("rerank" in projectRaw) {
|
|
2443
|
+
const rerank = projectRaw.rerank;
|
|
2444
|
+
const off = isPlainObject(rerank) && rerank.provider === "off";
|
|
2445
|
+
const removed = !isPlainObject(rerank) || Object.keys(rerank).some((key) => key !== "provider") || !off;
|
|
2446
|
+
if (off)
|
|
2447
|
+
projectRaw.rerank = { provider: "off" };
|
|
2448
|
+
else
|
|
2449
|
+
delete projectRaw.rerank;
|
|
2450
|
+
if (removed)
|
|
2451
|
+
warnings.push("Ignoring rerank settings from project config (security: projects may only set rerank.provider to off; hosted routing, credentials and limits are user-level only).");
|
|
2452
|
+
}
|
|
2442
2453
|
const embedding = projectRaw.embedding;
|
|
2443
2454
|
if (isPlainObject(embedding)) {
|
|
2444
2455
|
const removed = [];
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./server-6495nmn9.js";
|
|
10
10
|
import {
|
|
11
11
|
inRootAsyncContext2
|
|
12
|
-
} from "./server-
|
|
12
|
+
} from "./server-gzy5w8ya.js";
|
|
13
13
|
|
|
14
14
|
// src/features/magic-context/memory/embedding-synapse.ts
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
@@ -1788,7 +1788,6 @@ function getSynapseBatchRequestKey(args) {
|
|
|
1788
1788
|
required_fingerprint: args.fingerprint,
|
|
1789
1789
|
required_epoch: args.tableEpoch,
|
|
1790
1790
|
allow_equivalent: false,
|
|
1791
|
-
accept_declared: false,
|
|
1792
1791
|
ids: args.items.map((item) => item.id),
|
|
1793
1792
|
content_sha256: args.items.map((item) => item.contentSha256),
|
|
1794
1793
|
...args.purpose === "query" ? { purpose: args.purpose } : {}
|
|
@@ -2177,8 +2176,7 @@ class SynapseEmbeddingProvider {
|
|
|
2177
2176
|
model: metadata.model,
|
|
2178
2177
|
required_fingerprint: metadata.fingerprint,
|
|
2179
2178
|
required_epoch: metadata.table_epoch,
|
|
2180
|
-
allow_equivalent: false
|
|
2181
|
-
accept_declared: false
|
|
2179
|
+
allow_equivalent: false
|
|
2182
2180
|
};
|
|
2183
2181
|
}
|
|
2184
2182
|
batchRequest(items, requestKey, purpose) {
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
withSqliteBackgroundWriter2,
|
|
5
5
|
withoutSqliteTransformPass2,
|
|
6
6
|
isTransientSqliteError2
|
|
7
|
-
} from "./server-
|
|
7
|
+
} from "./server-gzy5w8ya.js";
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
10
|
-
} from "./server-
|
|
10
|
+
} from "./server-24g8r2d0.js";
|
|
11
11
|
import {
|
|
12
12
|
setBootQuietPeriodForTests
|
|
13
|
-
} from "./server-
|
|
13
|
+
} from "./server-qjvk4a9t.js";
|
|
14
14
|
import {
|
|
15
15
|
isEmbeddingHostBusy2
|
|
16
16
|
} from "./server-qt1qqasc.js";
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
isSynapseEmbeddingTruncated,
|
|
30
30
|
getSynapseBatchRequestKey,
|
|
31
31
|
SynapseEmbeddingProvider
|
|
32
|
-
} from "./server-
|
|
32
|
+
} from "./server-ab1g0wn9.js";
|
|
33
33
|
import {
|
|
34
34
|
estimateTokens
|
|
35
35
|
} from "./server-3mz2qh5a.js";
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
countSessionCompartmentEmbedCoverage2,
|
|
51
51
|
countSessionCompartmentEmbedCoveragePolite2,
|
|
52
52
|
countUnembeddedSessionCompartmentsPolite2
|
|
53
|
-
} from "./server-
|
|
53
|
+
} from "./server-62g58aaz.js";
|
|
54
54
|
import {
|
|
55
55
|
acquireGitSweepLease,
|
|
56
56
|
renewGitSweepLease,
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
findMisScopedCompartmentChunkEmbeddingIdsForProject,
|
|
59
59
|
recordSessionProjectIdentity,
|
|
60
60
|
repairMisScopedCompartmentChunkEmbeddingsForProject
|
|
61
|
-
} from "./server-
|
|
61
|
+
} from "./server-bsgd4dk1.js";
|
|
62
62
|
import {
|
|
63
63
|
saveEmbeddingIfHashMatches,
|
|
64
64
|
getMemoryEmbedCoverage,
|
|
@@ -73,7 +73,7 @@ import {
|
|
|
73
73
|
logLocalEmbeddingPoolingUnavailableOnce,
|
|
74
74
|
getEmbeddingProviderIdentity,
|
|
75
75
|
LocalEmbeddingProvider
|
|
76
|
-
} from "./server-
|
|
76
|
+
} from "./server-vr4szghm.js";
|
|
77
77
|
import {
|
|
78
78
|
logSlowWriteTransaction
|
|
79
79
|
} from "./server-gyy4k6mf.js";
|
|
@@ -1069,6 +1069,23 @@ var EMBED_SLICE_RETRY_BASE_MS = 250;
|
|
|
1069
1069
|
var EMBED_SLOW_FAILURE_NO_RETRY_MS = 1e4;
|
|
1070
1070
|
var MAX_CONSECUTIVE_FAILED_BATCHES = 3;
|
|
1071
1071
|
var projectRegistrations = new Map;
|
|
1072
|
+
var projectContextUsers = new Map;
|
|
1073
|
+
function retainProjectEmbedding2(projectIdentity) {
|
|
1074
|
+
projectContextUsers.set(projectIdentity, (projectContextUsers.get(projectIdentity) ?? 0) + 1);
|
|
1075
|
+
let released = false;
|
|
1076
|
+
return () => {
|
|
1077
|
+
if (released)
|
|
1078
|
+
return;
|
|
1079
|
+
released = true;
|
|
1080
|
+
const remaining = (projectContextUsers.get(projectIdentity) ?? 1) - 1;
|
|
1081
|
+
if (remaining > 0) {
|
|
1082
|
+
projectContextUsers.set(projectIdentity, remaining);
|
|
1083
|
+
} else {
|
|
1084
|
+
projectContextUsers.delete(projectIdentity);
|
|
1085
|
+
unregisterProjectEmbedding2(projectIdentity);
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1072
1089
|
var shadowRegistrations = new Map;
|
|
1073
1090
|
var shadowQueue = [];
|
|
1074
1091
|
var shadowWorker = null;
|
|
@@ -3111,6 +3128,7 @@ function _resetProjectEmbeddingRegistryForTests2() {
|
|
|
3111
3128
|
disposeProvider(registration.provider);
|
|
3112
3129
|
}
|
|
3113
3130
|
projectRegistrations.clear();
|
|
3131
|
+
projectContextUsers.clear();
|
|
3114
3132
|
shadowRegistrations.clear();
|
|
3115
3133
|
shadowQueue.length = 0;
|
|
3116
3134
|
pendingShadowBackfills.clear();
|
|
@@ -3126,4 +3144,4 @@ function _resetProjectEmbeddingRegistryForTests2() {
|
|
|
3126
3144
|
setBootQuietPeriodForTests(null);
|
|
3127
3145
|
}
|
|
3128
3146
|
|
|
3129
|
-
export { embedPauseBySession, embedRunStateBySession, activeEmbeddingSessions, autoEmbedAttemptedBySession, autoEmbedIdentityBySession, autoEmbedRetryAfterBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, clearEmbedSessionState, drainBackgroundBatches, recordEmbeddingMeasurement, saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitSha, enforceProjectCap, OpenAICompatibleEmbeddingProvider, describeShadowBackfillWriteRefusal2, listShadowBackfillStalls2, getShadowBackfillStopReason2, markProjectLoadUntrusted2, contentSha2562, drainProjectEmbeddingIdentityMaintenance2, drainStaleEmbeddingIdentitiesForProject2, registerProjectEmbedding2, registerProjectShadowEmbedding2, getShadowEmbeddingMeasurementCohort2, getPrimaryEmbeddingMeasurementCohort2, embedShadowTextForProject2, enqueueShadowEmbeddingItems2, getShadowBackfillRemaining2, flushShadowEmbeddingBacklog2, registerProjectInObservationMode2, unregisterProjectShadowEmbedding2, unregisterProjectEmbedding2, getProjectEmbeddingSnapshot2, installProjectEmbeddingSearchBridge2, getProjectChunkEmbeddingModelId2, getProjectEmbeddingMaxInputTokens2, embedTextForProject2, embedBatchForProject2, embedItemsForProject2, embedUnembeddedMemoriesForProject2, embedUnembeddedMemoriesForProjectOutcome2, drainCommitBacklogForProject2, embedUnembeddedCompartmentChunksForProject2, embedSessionCompartmentChunks2, getEmbeddingCoverageStatus2, getAutoEmbeddingSessionCoverage2, sweepAllRegisteredProjects2, _setTestProviderFactoryForProject2, _resetProjectEmbeddingRegistryForTests2 };
|
|
3147
|
+
export { embedPauseBySession, embedRunStateBySession, activeEmbeddingSessions, autoEmbedAttemptedBySession, autoEmbedIdentityBySession, autoEmbedRetryAfterBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, clearEmbedSessionState, drainBackgroundBatches, recordEmbeddingMeasurement, saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitSha, enforceProjectCap, OpenAICompatibleEmbeddingProvider, describeShadowBackfillWriteRefusal2, listShadowBackfillStalls2, retainProjectEmbedding2, getShadowBackfillStopReason2, markProjectLoadUntrusted2, contentSha2562, drainProjectEmbeddingIdentityMaintenance2, drainStaleEmbeddingIdentitiesForProject2, registerProjectEmbedding2, registerProjectShadowEmbedding2, getShadowEmbeddingMeasurementCohort2, getPrimaryEmbeddingMeasurementCohort2, embedShadowTextForProject2, enqueueShadowEmbeddingItems2, getShadowBackfillRemaining2, flushShadowEmbeddingBacklog2, registerProjectInObservationMode2, unregisterProjectShadowEmbedding2, unregisterProjectEmbedding2, getProjectEmbeddingSnapshot2, installProjectEmbeddingSearchBridge2, getProjectChunkEmbeddingModelId2, getProjectEmbeddingMaxInputTokens2, embedTextForProject2, embedBatchForProject2, embedItemsForProject2, embedUnembeddedMemoriesForProject2, embedUnembeddedMemoriesForProjectOutcome2, drainCommitBacklogForProject2, embedUnembeddedCompartmentChunksForProject2, embedSessionCompartmentChunks2, getEmbeddingCoverageStatus2, getAutoEmbeddingSessionCoverage2, sweepAllRegisteredProjects2, _setTestProviderFactoryForProject2, _resetProjectEmbeddingRegistryForTests2 };
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./server-pavzsdc6.js";
|
|
4
4
|
import {
|
|
5
5
|
isTransientSqliteError2
|
|
6
|
-
} from "./server-
|
|
6
|
+
} from "./server-gzy5w8ya.js";
|
|
7
7
|
import {
|
|
8
8
|
PROMOTABLE_CATEGORIES,
|
|
9
9
|
CATEGORY_DEFAULT_TTL
|
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
} from "./server-6495nmn9.js";
|
|
15
15
|
import {
|
|
16
16
|
managedAuthorityNoteRow
|
|
17
|
-
} from "./server-
|
|
17
|
+
} from "./server-wwaw5npa.js";
|
|
18
18
|
import {
|
|
19
19
|
embedTextForProject2
|
|
20
|
-
} from "./server-
|
|
20
|
+
} from "./server-ad18djzs.js";
|
|
21
21
|
import {
|
|
22
22
|
saveEmbeddingIfHashMatches
|
|
23
23
|
} from "./server-4dhv7mqz.js";
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
buildWorkspaceMemorySqlFilter2,
|
|
31
31
|
getMemoryById2,
|
|
32
32
|
updateMemorySeenCount2
|
|
33
|
-
} from "./server-
|
|
33
|
+
} from "./server-jjvbk92s.js";
|
|
34
34
|
import {
|
|
35
35
|
computeNormalizedHash
|
|
36
36
|
} from "./server-2bvekkfy.js";
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
getSqliteDatabasePath2,
|
|
3
3
|
withSqliteBackgroundWriter2,
|
|
4
4
|
withoutSqliteTransformPass2
|
|
5
|
-
} from "./server-
|
|
5
|
+
} from "./server-gzy5w8ya.js";
|
|
6
6
|
import {
|
|
7
7
|
runSessionWarmupWorker
|
|
8
|
-
} from "./server-
|
|
8
|
+
} from "./server-4kjmrjn4.js";
|
|
9
9
|
import {
|
|
10
10
|
logSlowWriteTransaction
|
|
11
11
|
} from "./server-gyy4k6mf.js";
|
|
@@ -14,13 +14,13 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
getTagIdentityWriteGeneration2,
|
|
16
16
|
getSqliteDatabasePath2
|
|
17
|
-
} from "./server-
|
|
17
|
+
} from "./server-gzy5w8ya.js";
|
|
18
18
|
import {
|
|
19
19
|
stableStringify,
|
|
20
20
|
stableStringifyHash,
|
|
21
21
|
tagOrderConstraintIndex,
|
|
22
22
|
tagIdentityRevisionKey
|
|
23
|
-
} from "./server-
|
|
23
|
+
} from "./server-rqebawx1.js";
|
|
24
24
|
import {
|
|
25
25
|
DEFAULT_PROTECTED_TOOLS,
|
|
26
26
|
normalizeProtectedToolName,
|
|
@@ -83,13 +83,16 @@ function stripDanglingTagNotationGlobally(value) {
|
|
|
83
83
|
function stripTagSectionCharacters(value) {
|
|
84
84
|
return value.replace(STRAY_SECTION_CHAR_REGEX, "");
|
|
85
85
|
}
|
|
86
|
-
function stripPersistedAssistantText(value) {
|
|
86
|
+
function stripPersistedAssistantText(value, acceptsEmpty = true) {
|
|
87
|
+
if (!acceptsEmpty && !value.includes("§") && !value.trim())
|
|
88
|
+
return value;
|
|
87
89
|
let text = stripWellFormedLeadingTagPrefix(value);
|
|
88
90
|
text = stripCompleteTagPairsGlobally(text);
|
|
89
91
|
text = stripMalformedTagNotationGlobally(text);
|
|
90
92
|
text = stripDanglingTagNotationGlobally(text);
|
|
91
93
|
text = stripTagSectionCharacters(text);
|
|
92
|
-
|
|
94
|
+
const stripped = text.trim();
|
|
95
|
+
return !acceptsEmpty && value.trim().length > 0 && stripped.length === 0 ? value : stripped;
|
|
93
96
|
}
|
|
94
97
|
function byteSize(value) {
|
|
95
98
|
return encoder.encode(value).length;
|