@lucern/sdk 1.0.29 → 1.0.30
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/CHANGELOG.md +8 -0
- package/dist/accessControl.d.ts +31 -31
- package/dist/accessControl.js +1 -0
- package/dist/adminClient.d.ts +74 -74
- package/dist/adminClient.js +38 -30
- package/dist/{answersClient.d.ts → answers-client.d.ts} +1 -1
- package/dist/{answersClient.js → answers-client.js} +2 -2
- package/dist/audience/index.d.ts +12 -12
- package/dist/{audiencesClient.d.ts → audiences-client.d.ts} +1 -1
- package/dist/audiences-client.js +107 -0
- package/dist/{auditClient.d.ts → audit-client.d.ts} +2 -3
- package/dist/{auditClient.js → audit-client.js} +8 -7
- package/dist/authContext.d.ts +26 -26
- package/dist/authDeviceClient.d.ts +11 -11
- package/dist/authDeviceClient.js +4 -6
- package/dist/beliefs/index.d.ts +56 -28
- package/dist/beliefs/index.js +2 -1
- package/dist/beliefsClient.d.ts +71 -63
- package/dist/beliefsClient.js +90 -67
- package/dist/{boundaryClientSurface.d.ts → boundary-client-surface.d.ts} +4 -4
- package/dist/{boundaryClientSurface.js → boundary-client-surface.js} +9 -7
- package/dist/client-assembly-types.d.ts +219 -0
- package/dist/client-assembly-types.js +2 -0
- package/dist/{clientConfig.d.ts → client-config.d.ts} +16 -32
- package/dist/client-config.js +2 -0
- package/dist/{clientEvidenceCompat.d.ts → client-evidence-compat.d.ts} +24 -24
- package/dist/{clientEvidenceCompat.js → client-evidence-compat.js} +2 -2
- package/dist/client.d.ts +1906 -352
- package/dist/client.js +34 -30
- package/dist/clientGraphNamespaces.d.ts +35 -25
- package/dist/clientGraphNamespaces.js +11 -5
- package/dist/clientHelpers.js +8 -5
- package/dist/clientKnowledgeNamespaces.d.ts +124 -84
- package/dist/clientKnowledgeNamespaces.js +35 -34
- package/dist/clientLocalHelpers.d.ts +81 -52
- package/dist/clientLocalHelpers.js +193 -43
- package/dist/clientPlatformNamespaces.d.ts +1541 -150
- package/dist/clientPlatformNamespaces.js +10 -5
- package/dist/clientRuntime.d.ts +1 -1
- package/dist/clientRuntime.js +1 -1
- package/dist/clientWorkflowNamespaces.d.ts +211 -97
- package/dist/clientWorkflowNamespaces.js +22 -19
- package/dist/contextClient.d.ts +2 -2
- package/dist/contextClient.js +79 -50
- package/dist/contextFacade.d.ts +1 -1
- package/dist/contextFacade.js +2 -0
- package/dist/contextPackCompiler.d.ts +52 -52
- package/dist/contextPackCompiler.js +192 -122
- package/dist/contextPackPolicy.d.ts +22 -22
- package/dist/contextPackPolicy.js +21 -9
- package/dist/contextPackSchema.d.ts +3 -3
- package/dist/contextPackSchema.js +1 -0
- package/dist/contextTypes.d.ts +155 -155
- package/dist/contracts/api-enums.contract.js +2 -11
- package/dist/contracts/auth-session.contract.d.ts +16 -16
- package/dist/contracts/auth-session.contract.js +3 -2
- package/dist/contracts/context-pack.contract.d.ts +216 -216
- package/dist/contracts/contextPack.js +2 -0
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.js +2 -1
- package/dist/contracts/lens-filter.contract.d.ts +8 -8
- package/dist/contracts/lens-filter.contract.js +10 -10
- package/dist/contracts/lens-workflow.contract.d.ts +32 -32
- package/dist/contracts/lens-workflow.contract.js +2 -1
- package/dist/contracts/lensFilter.js +2 -0
- package/dist/contracts/lensWorkflow.js +2 -0
- package/dist/contracts/mcpTools.d.ts +19 -19
- package/dist/contracts/mcpTools.js +3 -1
- package/dist/contracts/prompt.contract.d.ts +12 -12
- package/dist/contracts/prompt.js +1 -0
- package/dist/contracts/sdk-tools.contract.js +1 -0
- package/dist/contracts/sdkTools.js +2 -0
- package/dist/contracts/tool-contracts.js +1 -0
- package/dist/contracts/workflow-runtime.contract.d.ts +45 -45
- package/dist/contracts/workflow-runtime.contract.js +1 -5
- package/dist/contracts/workflowRuntime.js +2 -0
- package/dist/contradictions/index.d.ts +8 -8
- package/dist/contradictions/index.js +1 -0
- package/dist/control-plane.d.ts +10 -10
- package/dist/control-plane.js +2 -2
- package/dist/controlObjectOwnership.d.ts +11 -11
- package/dist/controlObjectOwnership.js +1 -0
- package/dist/coreClient.d.ts +51 -51
- package/dist/coreClient.js +269 -101
- package/dist/customTools.d.ts +19 -19
- package/dist/customTools.js +4 -2
- package/dist/decisions/index.d.ts +18 -18
- package/dist/decisions/index.js +1 -0
- package/dist/decisionsClient.d.ts +4 -4
- package/dist/decisionsClient.js +36 -27
- package/dist/edges/index.d.ts +20 -18
- package/dist/edges/index.js +1 -0
- package/dist/embeddingsClient.d.ts +29 -29
- package/dist/embeddingsClient.js +15 -8
- package/dist/eventingClient.d.ts +27 -27
- package/dist/eventingClient.js +10 -5
- package/dist/events.d.ts +83 -83
- package/dist/events.js +19 -15
- package/dist/eventsCore.d.ts +7 -7
- package/dist/eventsCore.js +11 -10
- package/dist/evidence/index.d.ts +23 -21
- package/dist/evidence/index.js +1 -0
- package/dist/evidenceClient.d.ts +23 -23
- package/dist/evidenceClient.js +10 -6
- package/dist/facade/context.d.ts +9 -9
- package/dist/facade/context.js +67 -41
- package/dist/functionSurface.js +2 -0
- package/dist/functionSurfaceClient.js +2 -0
- package/dist/gatewayFacades.d.ts +215 -215
- package/dist/gatewayFacades.factories.d.ts +23 -44
- package/dist/gatewayFacades.factories.js +63 -62
- package/dist/gatewayFacades.js +31 -32
- package/dist/graphAnalysisClient.d.ts +60 -60
- package/dist/graphAnalysisClient.js +19 -18
- package/dist/graphClient.d.ts +34 -34
- package/dist/graphClient.js +56 -35
- package/dist/graphIntel.js +2 -0
- package/dist/graphIntelligence.d.ts +2 -2
- package/dist/graphIntelligence.js +1 -1
- package/dist/graphRecommendationsClient.d.ts +24 -24
- package/dist/graphRecommendationsClient.js +12 -7
- package/dist/graphStateClassifierClient.d.ts +13 -13
- package/dist/graphStateClassifierClient.js +10 -5
- package/dist/harnessClient.d.ts +61 -61
- package/dist/harnessClient.js +44 -31
- package/dist/identityClient.d.ts +33 -59
- package/dist/identityClient.js +126 -98
- package/dist/index.d.ts +20 -20
- package/dist/index.js +20 -19
- package/dist/infisicalRuntime.d.ts +11 -11
- package/dist/infisicalRuntime.js +20 -14
- package/dist/jobsClient.d.ts +28 -28
- package/dist/jobsClient.js +6 -3
- package/dist/learningClient.js +13 -8
- package/dist/lenses/index.d.ts +124 -28
- package/dist/lenses/index.js +1 -0
- package/dist/mcpClient.d.ts +1 -1
- package/dist/mcpClient.js +3 -3
- package/dist/modelRuntimeClient.d.ts +27 -27
- package/dist/modelRuntimeClient.js +10 -5
- package/dist/nodes/index.d.ts +9 -9
- package/dist/nodes/index.js +1 -0
- package/dist/ontologies/index.d.ts +68 -22
- package/dist/ontologies/index.js +1 -0
- package/dist/ontologyClient.js +24 -17
- package/dist/ontologyLinksClient.d.ts +35 -35
- package/dist/ontologyLinksClient.js +9 -6
- package/dist/opinion.d.ts +3 -3
- package/dist/opinion.js +12 -5
- package/dist/orgGraphSearchClient.d.ts +39 -39
- package/dist/orgGraphSearchClient.js +22 -13
- package/dist/packsClient.d.ts +1 -1
- package/dist/packsClient.js +28 -19
- package/dist/policyClient.d.ts +79 -68
- package/dist/policyClient.js +18 -12
- package/dist/proof-attestation.json +1 -1
- package/dist/questions/index.d.ts +38 -27
- package/dist/questions/index.js +1 -0
- package/dist/realtime/index.d.ts +3 -3
- package/dist/realtime/index.js +1 -0
- package/dist/realtime/refs.d.ts +2 -2
- package/dist/{reportsClient.d.ts → reports-client.d.ts} +2 -2
- package/dist/{reportsClient.js → reports-client.js} +19 -13
- package/dist/{schemaClient.d.ts → schema-client.d.ts} +2 -3
- package/dist/{schemaClient.js → schema-client.js} +14 -11
- package/dist/sdkSurface.d.ts +12 -12
- package/dist/sdkSurface.js +14 -10
- package/dist/secrets.d.ts +1 -1
- package/dist/secrets.js +2 -1
- package/dist/{sourcesClient.d.ts → sources-client.d.ts} +8 -9
- package/dist/{sourcesClient.js → sources-client.js} +4 -5
- package/dist/{telemetryClient.d.ts → telemetry-client.d.ts} +14 -14
- package/dist/{telemetryClient.js → telemetry-client.js} +6 -4
- package/dist/toolRegistryClient.d.ts +46 -46
- package/dist/toolRegistryClient.js +22 -11
- package/dist/topics/index.d.ts +23 -23
- package/dist/topics/index.js +2 -1
- package/dist/topicsClient.d.ts +6 -6
- package/dist/topicsClient.js +29 -18
- package/dist/types.d.ts +356 -355
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workflowClient.d.ts +36 -35
- package/dist/workflowClient.js +88 -60
- package/dist/worktrees/index.d.ts +118 -32
- package/dist/worktrees/index.js +2 -1
- package/package.json +45 -5
- package/dist/audiencesClient.js +0 -115
- package/dist/clientAssemblyTypes.d.ts +0 -33
- package/dist/clientAssemblyTypes.js +0 -2
- package/dist/clientConfig.js +0 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
// biome-ignore-all lint/style/useFilenamingConvention: This file is an @lucern/sdk public import ABI / package subpath compatibility surface; the camelCase filename is intentional.
|
|
2
2
|
import { buildInjectionPlan, parseTokenBudget, rankContextSection, rankEntities, resolveEffectiveWeights, } from "./contextPackPolicy.js";
|
|
3
3
|
import { validateContextPackSchema } from "./contextPackSchema.js";
|
|
4
|
+
import { CONTEXT_PACK_SCHEMA_VERSION, DEFAULT_COMPILATION_MODE, DEFAULT_ENTITY_LIMIT, MAX_ENTITY_LIMIT, } from "./contracts/context-pack.contract.js";
|
|
5
|
+
const QUERY_TOKEN_SPLIT_PATTERN = /[^a-z0-9]+/;
|
|
4
6
|
function assertContextPackSchema(payload) {
|
|
5
7
|
const result = validateContextPackSchema(payload);
|
|
6
8
|
if (!result.valid) {
|
|
@@ -28,7 +30,7 @@ function normalizeQueryTokens(query) {
|
|
|
28
30
|
}
|
|
29
31
|
return query
|
|
30
32
|
.toLowerCase()
|
|
31
|
-
.split(
|
|
33
|
+
.split(QUERY_TOKEN_SPLIT_PATTERN)
|
|
32
34
|
.map((token) => token.trim())
|
|
33
35
|
.filter((token) => token.length >= 2);
|
|
34
36
|
}
|
|
@@ -129,7 +131,11 @@ function candidateTimestamp(candidate) {
|
|
|
129
131
|
if (!isRecord(candidate)) {
|
|
130
132
|
return 0;
|
|
131
133
|
}
|
|
132
|
-
const timestamps = [
|
|
134
|
+
const timestamps = [
|
|
135
|
+
candidate.updatedAt,
|
|
136
|
+
candidate.createdAt,
|
|
137
|
+
candidate.generatedAt,
|
|
138
|
+
].filter((value) => typeof value === "number" && Number.isFinite(value));
|
|
133
139
|
return timestamps.length > 0 ? Math.max(...timestamps) : 0;
|
|
134
140
|
}
|
|
135
141
|
function resolveReferenceTimeMs(...collections) {
|
|
@@ -144,45 +150,73 @@ function resolveReferenceTimeMs(...collections) {
|
|
|
144
150
|
}
|
|
145
151
|
return maxTimestamp;
|
|
146
152
|
}
|
|
153
|
+
function contradictionSeverity(weight) {
|
|
154
|
+
if (weight <= -0.9) {
|
|
155
|
+
return "critical";
|
|
156
|
+
}
|
|
157
|
+
if (weight <= -0.7) {
|
|
158
|
+
return "high";
|
|
159
|
+
}
|
|
160
|
+
if (weight <= -0.5) {
|
|
161
|
+
return "medium";
|
|
162
|
+
}
|
|
163
|
+
return "low";
|
|
164
|
+
}
|
|
165
|
+
function optionalArgString(args, key) {
|
|
166
|
+
const value = args[key];
|
|
167
|
+
return typeof value === "string" && value.trim().length > 0
|
|
168
|
+
? value.trim()
|
|
169
|
+
: undefined;
|
|
170
|
+
}
|
|
171
|
+
function rankingProfileFromArgs(args) {
|
|
172
|
+
return parseRankingProfile(typeof args.ranking === "string" ? args.ranking : args.rankingProfile);
|
|
173
|
+
}
|
|
174
|
+
function tokenBudgetFromArgs(args) {
|
|
175
|
+
return parseTokenBudget(typeof args.budget === "number" ? args.budget : args.tokenBudget, 1800);
|
|
176
|
+
}
|
|
177
|
+
function descendantDepthFromArgs(args, topic) {
|
|
178
|
+
const topicDepth = typeof topic.depth === "number" && Number.isFinite(topic.depth)
|
|
179
|
+
? topic.depth
|
|
180
|
+
: 0;
|
|
181
|
+
if (typeof args.maxDepth === "number" && Number.isFinite(args.maxDepth)) {
|
|
182
|
+
return Math.max(1, Math.min(Math.floor(args.maxDepth), 6));
|
|
183
|
+
}
|
|
184
|
+
return topicDepth <= 1 ? 4 : 2;
|
|
185
|
+
}
|
|
186
|
+
function packWeightOverridesFromArgs(args) {
|
|
187
|
+
return Array.isArray(args.packWeightOverrides)
|
|
188
|
+
? args.packWeightOverrides
|
|
189
|
+
: undefined;
|
|
190
|
+
}
|
|
191
|
+
function scopedTopicIdsForPlan(input, topicId, descendantDepth, args) {
|
|
192
|
+
const scopedTopicIds = collectTopicNeighborhood(input.allTopics, topicId, descendantDepth);
|
|
193
|
+
const allowedTopicIds = asStringArray(args.allowedTopicIds);
|
|
194
|
+
if (allowedTopicIds.length === 0) {
|
|
195
|
+
return scopedTopicIds;
|
|
196
|
+
}
|
|
197
|
+
const allowedSet = new Set(allowedTopicIds);
|
|
198
|
+
if (!allowedSet.has(topicId)) {
|
|
199
|
+
throw new Error(`Access denied to compile context for topic ${topicId}.`);
|
|
200
|
+
}
|
|
201
|
+
return scopedTopicIds.filter((id) => allowedSet.has(id));
|
|
202
|
+
}
|
|
147
203
|
export function planContextPackCompilation(input) {
|
|
148
204
|
const args = input.args ?? {};
|
|
149
205
|
const topicId = String(input.topic._id);
|
|
150
|
-
const queryText =
|
|
151
|
-
? args.query.trim()
|
|
152
|
-
: undefined;
|
|
206
|
+
const queryText = optionalArgString(args, "query");
|
|
153
207
|
const tokens = normalizeQueryTokens(queryText);
|
|
154
208
|
const limit = toPositiveInt(args.limit, 8, 25);
|
|
155
|
-
const rankingProfile =
|
|
156
|
-
const tokenBudget =
|
|
157
|
-
const
|
|
158
|
-
? input.topic.depth
|
|
159
|
-
: 0;
|
|
160
|
-
const requestedMaxDepth = typeof args.maxDepth === "number" && Number.isFinite(args.maxDepth)
|
|
161
|
-
? Math.max(1, Math.min(Math.floor(args.maxDepth), 6))
|
|
162
|
-
: undefined;
|
|
163
|
-
const descendantDepth = requestedMaxDepth ?? (topicDepth <= 1 ? 4 : 2);
|
|
209
|
+
const rankingProfile = rankingProfileFromArgs(args);
|
|
210
|
+
const tokenBudget = tokenBudgetFromArgs(args);
|
|
211
|
+
const descendantDepth = descendantDepthFromArgs(args, input.topic);
|
|
164
212
|
const includeEntities = args.includeEntities !== false;
|
|
165
213
|
const compilationMode = args.mode === "delta" ? "delta" : DEFAULT_COMPILATION_MODE;
|
|
166
214
|
const includeFailures = compilationMode === "delta" || args.includeFailures === true;
|
|
167
|
-
const worktreeId =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const sessionId = typeof args.sessionId === "string" && args.sessionId.trim().length > 0
|
|
171
|
-
? args.sessionId.trim()
|
|
172
|
-
: undefined;
|
|
173
|
-
const packWeightOverrides = Array.isArray(args.packWeightOverrides)
|
|
174
|
-
? args.packWeightOverrides
|
|
175
|
-
: undefined;
|
|
215
|
+
const worktreeId = optionalArgString(args, "worktreeId");
|
|
216
|
+
const sessionId = optionalArgString(args, "sessionId");
|
|
217
|
+
const packWeightOverrides = packWeightOverridesFromArgs(args);
|
|
176
218
|
const effectiveWeights = resolveEffectiveWeights(packWeightOverrides);
|
|
177
|
-
|
|
178
|
-
const allowedTopicIds = asStringArray(args.allowedTopicIds);
|
|
179
|
-
if (allowedTopicIds.length > 0) {
|
|
180
|
-
const allowedSet = new Set(allowedTopicIds);
|
|
181
|
-
if (!allowedSet.has(topicId)) {
|
|
182
|
-
throw new Error(`Access denied to compile context for topic ${topicId}.`);
|
|
183
|
-
}
|
|
184
|
-
scopedTopicIds = scopedTopicIds.filter((id) => allowedSet.has(id));
|
|
185
|
-
}
|
|
219
|
+
const scopedTopicIds = scopedTopicIdsForPlan(input, topicId, descendantDepth, args);
|
|
186
220
|
return {
|
|
187
221
|
topicId,
|
|
188
222
|
...(queryText ? { queryText } : {}),
|
|
@@ -201,17 +235,7 @@ export function planContextPackCompilation(input) {
|
|
|
201
235
|
scopedTopicIds,
|
|
202
236
|
};
|
|
203
237
|
}
|
|
204
|
-
|
|
205
|
-
const uniqueBeliefs = dedupeById(snapshot.beliefs);
|
|
206
|
-
const uniqueQuestions = dedupeById(snapshot.questions);
|
|
207
|
-
const uniqueEvidence = dedupeById(snapshot.evidence);
|
|
208
|
-
const uniqueContradictions = dedupeById(snapshot.contradictions);
|
|
209
|
-
const referenceTimeMs = resolveReferenceTimeMs([snapshot.topic], uniqueBeliefs, uniqueQuestions, uniqueEvidence, uniqueContradictions, snapshot.entities) || 0;
|
|
210
|
-
const rankOptions = {
|
|
211
|
-
effectiveWeights: snapshot.plan.effectiveWeights,
|
|
212
|
-
includeJustifications: snapshot.plan.compilationMode === "delta",
|
|
213
|
-
referenceTimeMs,
|
|
214
|
-
};
|
|
238
|
+
function compileBeliefSections(uniqueBeliefs, plan, rankOptions) {
|
|
215
239
|
const invariantCandidates = uniqueBeliefs
|
|
216
240
|
.filter((belief) => beliefTypeOf(belief).toLowerCase() === "invariant")
|
|
217
241
|
.map((belief) => ({
|
|
@@ -225,7 +249,7 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
225
249
|
...candidate,
|
|
226
250
|
id: candidate.nodeId,
|
|
227
251
|
text: `${candidate.canonicalText} ${candidate.beliefType}`,
|
|
228
|
-
})),
|
|
252
|
+
})), plan.tokens, plan.limit, plan.rankingProfile, rankOptions).map((row) => ({
|
|
229
253
|
nodeId: row.nodeId,
|
|
230
254
|
canonicalText: row.canonicalText,
|
|
231
255
|
confidence: row.confidence,
|
|
@@ -250,7 +274,7 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
250
274
|
...candidate,
|
|
251
275
|
id: candidate.nodeId,
|
|
252
276
|
text: `${candidate.canonicalText} ${candidate.metadataText}`,
|
|
253
|
-
})),
|
|
277
|
+
})), plan.tokens, plan.limit, plan.rankingProfile, rankOptions).map((row) => ({
|
|
254
278
|
nodeId: row.nodeId,
|
|
255
279
|
canonicalText: row.canonicalText,
|
|
256
280
|
confidence: row.confidence,
|
|
@@ -260,6 +284,14 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
260
284
|
score: row.score,
|
|
261
285
|
...(row.justification ? { justification: row.justification } : {}),
|
|
262
286
|
}));
|
|
287
|
+
return {
|
|
288
|
+
activeBeliefCandidates,
|
|
289
|
+
activeBeliefs,
|
|
290
|
+
invariantCandidates,
|
|
291
|
+
invariants,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
function compileOpenQuestions(uniqueQuestions, plan, rankOptions) {
|
|
263
295
|
const openQuestionCandidates = uniqueQuestions
|
|
264
296
|
.map((question) => {
|
|
265
297
|
const status = questionStatusOf(question);
|
|
@@ -280,7 +312,7 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
280
312
|
...candidate,
|
|
281
313
|
id: candidate.questionId,
|
|
282
314
|
text: `${candidate.text} ${candidate.metadataText}`,
|
|
283
|
-
})),
|
|
315
|
+
})), plan.tokens, plan.limit, plan.rankingProfile, rankOptions).map((row) => ({
|
|
284
316
|
questionId: row.questionId,
|
|
285
317
|
text: row.text,
|
|
286
318
|
status: row.status,
|
|
@@ -289,6 +321,9 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
289
321
|
score: row.score,
|
|
290
322
|
...(row.justification ? { justification: row.justification } : {}),
|
|
291
323
|
}));
|
|
324
|
+
return { openQuestionCandidates, openQuestions };
|
|
325
|
+
}
|
|
326
|
+
function compileRecentEvidence(uniqueEvidence, plan, rankOptions) {
|
|
292
327
|
const evidenceCandidates = uniqueEvidence.map((item) => {
|
|
293
328
|
const metadata = item.metadata && typeof item.metadata === "object" ? item.metadata : {};
|
|
294
329
|
return {
|
|
@@ -307,7 +342,7 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
307
342
|
...candidate,
|
|
308
343
|
id: candidate.nodeId,
|
|
309
344
|
text: `${candidate.canonicalText} ${candidate.metadataText}`,
|
|
310
|
-
})),
|
|
345
|
+
})), plan.tokens, plan.limit, plan.rankingProfile, rankOptions).map((row) => ({
|
|
311
346
|
nodeId: row.nodeId,
|
|
312
347
|
canonicalText: row.canonicalText,
|
|
313
348
|
sourceUrl: row.sourceUrl,
|
|
@@ -316,18 +351,14 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
316
351
|
score: row.score,
|
|
317
352
|
...(row.justification ? { justification: row.justification } : {}),
|
|
318
353
|
}));
|
|
354
|
+
return { evidenceCandidates, recentEvidence };
|
|
355
|
+
}
|
|
356
|
+
function compileContradictions(uniqueContradictions, plan, rankOptions) {
|
|
319
357
|
const contradictionCandidates = uniqueContradictions.map((row) => {
|
|
320
358
|
const weight = typeof row.weight === "number" ? row.weight : 0;
|
|
321
|
-
const severity = weight <= -0.9
|
|
322
|
-
? "critical"
|
|
323
|
-
: weight <= -0.7
|
|
324
|
-
? "high"
|
|
325
|
-
: weight <= -0.5
|
|
326
|
-
? "medium"
|
|
327
|
-
: "low";
|
|
328
359
|
return {
|
|
329
360
|
contradictionId: String(row._id || row.globalId || ""),
|
|
330
|
-
severity,
|
|
361
|
+
severity: contradictionSeverity(weight),
|
|
331
362
|
status: "active",
|
|
332
363
|
description: row.context || row.description || row.summary || "",
|
|
333
364
|
updatedAt: row.updatedAt || row.createdAt || null,
|
|
@@ -337,7 +368,7 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
337
368
|
...candidate,
|
|
338
369
|
id: candidate.contradictionId,
|
|
339
370
|
text: `${candidate.description} ${candidate.severity}`,
|
|
340
|
-
})),
|
|
371
|
+
})), plan.tokens, plan.limit, plan.rankingProfile, rankOptions).map((row) => ({
|
|
341
372
|
contradictionId: row.contradictionId,
|
|
342
373
|
severity: row.severity,
|
|
343
374
|
status: row.status,
|
|
@@ -345,85 +376,123 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
345
376
|
score: row.score,
|
|
346
377
|
...(row.justification ? { justification: row.justification } : {}),
|
|
347
378
|
}));
|
|
348
|
-
|
|
379
|
+
return { contradictionCandidates, contradictions };
|
|
380
|
+
}
|
|
381
|
+
function compileEntities(entities, plan) {
|
|
382
|
+
const entityCandidates = entities.map((row) => ({
|
|
349
383
|
nodeId: String(row._id),
|
|
350
384
|
entityType: String(row.nodeType || ""),
|
|
351
385
|
title: String(row.title || ""),
|
|
352
386
|
canonicalText: String(row.canonicalText || ""),
|
|
353
|
-
connectedBeliefCount: typeof row.connectedBeliefCount === "number"
|
|
387
|
+
connectedBeliefCount: typeof row.connectedBeliefCount === "number"
|
|
388
|
+
? row.connectedBeliefCount
|
|
389
|
+
: 0,
|
|
354
390
|
connectedEvidenceCount: typeof row.connectedEvidenceCount === "number"
|
|
355
391
|
? row.connectedEvidenceCount
|
|
356
392
|
: 0,
|
|
357
393
|
metadata: row.metadata && typeof row.metadata === "object" ? row.metadata : {},
|
|
358
394
|
updatedAt: row.updatedAt || null,
|
|
359
395
|
}));
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
396
|
+
if (!plan.includeEntities) {
|
|
397
|
+
return { entityCandidates };
|
|
398
|
+
}
|
|
399
|
+
const entityLimit = toPositiveInt(plan.limit, DEFAULT_ENTITY_LIMIT, MAX_ENTITY_LIMIT);
|
|
400
|
+
const rankedEntities = rankEntities(entityCandidates, plan.tokens, entityLimit).map((row) => ({
|
|
401
|
+
nodeId: row.nodeId,
|
|
402
|
+
entityType: row.entityType,
|
|
403
|
+
title: row.title,
|
|
404
|
+
connectedBeliefCount: row.connectedBeliefCount,
|
|
405
|
+
connectedEvidenceCount: row.connectedEvidenceCount,
|
|
406
|
+
score: row.score,
|
|
407
|
+
...(Object.keys(row.metadata).length > 0 ? { metadata: row.metadata } : {}),
|
|
408
|
+
}));
|
|
409
|
+
return { entityCandidates, rankedEntities };
|
|
410
|
+
}
|
|
411
|
+
function compileFailureContext(args) {
|
|
412
|
+
if (!(args.plan.includeFailures && args.failures)) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const allFailures = args.failures.filter((node) => {
|
|
416
|
+
const metadata = isRecord(node.metadata) ? node.metadata : {};
|
|
417
|
+
return (metadata.failedApproach === true || metadata.isFailedAttempt === true);
|
|
418
|
+
});
|
|
419
|
+
const rankedFailures = rankContextSection("recentEvidence", allFailures.map((node) => ({
|
|
420
|
+
id: String(node._id),
|
|
421
|
+
text: String(node.canonicalText || ""),
|
|
422
|
+
createdAt: node.createdAt || null,
|
|
423
|
+
updatedAt: node.updatedAt || node.createdAt || null,
|
|
424
|
+
})), args.plan.tokens, 10, args.plan.rankingProfile, args.rankOptions);
|
|
425
|
+
const failures = rankedFailures.map((row) => {
|
|
426
|
+
const original = allFailures.find((node) => String(node._id) === row.id);
|
|
427
|
+
const metadata = isRecord(original?.metadata) ? original?.metadata : {};
|
|
428
|
+
return {
|
|
429
|
+
attemptId: row.id,
|
|
430
|
+
approach: String(row.text || ""),
|
|
431
|
+
outcome: String(metadata.errorMessage || "Failed"),
|
|
432
|
+
recordedAt: row.createdAt || args.referenceTimeMs || 0,
|
|
368
433
|
score: row.score,
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const failures = rankedFailures.map((row) => {
|
|
387
|
-
const original = allFailures.find((node) => String(node._id) === row.id);
|
|
388
|
-
const metadata = isRecord(original?.metadata) ? original?.metadata : {};
|
|
389
|
-
return {
|
|
390
|
-
attemptId: row.id,
|
|
391
|
-
approach: String(row.text || ""),
|
|
392
|
-
outcome: String(metadata.errorMessage || "Failed"),
|
|
393
|
-
recordedAt: row.createdAt || referenceTimeMs || 0,
|
|
394
|
-
score: row.score,
|
|
395
|
-
};
|
|
396
|
-
});
|
|
397
|
-
const failureTexts = new Set(failures.map((failure) => failure.approach.toLowerCase().slice(0, 100)));
|
|
398
|
-
const suppressionIds = new Set();
|
|
399
|
-
if (snapshot.plan.sessionId && failureTexts.size > 0) {
|
|
400
|
-
for (const evidenceRow of recentEvidence) {
|
|
401
|
-
const evidenceText = evidenceRow.canonicalText.toLowerCase().slice(0, 100);
|
|
402
|
-
for (const failureText of failureTexts) {
|
|
403
|
-
if (evidenceText.includes(failureText) ||
|
|
404
|
-
failureText.includes(evidenceText)) {
|
|
405
|
-
suppressionIds.add(evidenceRow.nodeId);
|
|
406
|
-
break;
|
|
407
|
-
}
|
|
434
|
+
};
|
|
435
|
+
});
|
|
436
|
+
if (failures.length === 0) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
const failureTexts = new Set(failures.map((failure) => failure.approach.toLowerCase().slice(0, 100)));
|
|
440
|
+
const suppressionIds = new Set();
|
|
441
|
+
if (args.plan.sessionId && failureTexts.size > 0) {
|
|
442
|
+
for (const evidenceRow of args.recentEvidence) {
|
|
443
|
+
const evidenceText = evidenceRow.canonicalText
|
|
444
|
+
.toLowerCase()
|
|
445
|
+
.slice(0, 100);
|
|
446
|
+
for (const failureText of failureTexts) {
|
|
447
|
+
if (evidenceText.includes(failureText) ||
|
|
448
|
+
failureText.includes(evidenceText)) {
|
|
449
|
+
suppressionIds.add(evidenceRow.nodeId);
|
|
450
|
+
break;
|
|
408
451
|
}
|
|
409
452
|
}
|
|
410
453
|
}
|
|
411
|
-
if (failures.length > 0) {
|
|
412
|
-
failureContext = {
|
|
413
|
-
failures,
|
|
414
|
-
suppressedIds: Array.from(suppressionIds),
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
454
|
}
|
|
455
|
+
return {
|
|
456
|
+
failures,
|
|
457
|
+
suppressedIds: Array.from(suppressionIds),
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
function applyFailureSuppression(recentEvidence, failureContext) {
|
|
418
461
|
const suppressionSet = new Set(failureContext?.suppressedIds || []);
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
462
|
+
if (suppressionSet.size === 0) {
|
|
463
|
+
return { effectiveEvidence: recentEvidence, suppressedEvidenceIds: [] };
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
effectiveEvidence: recentEvidence.filter((row) => !suppressionSet.has(row.nodeId)),
|
|
467
|
+
suppressedEvidenceIds: recentEvidence
|
|
424
468
|
.filter((row) => suppressionSet.has(row.nodeId))
|
|
425
|
-
.map((row) => row.nodeId)
|
|
426
|
-
|
|
469
|
+
.map((row) => row.nodeId),
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
export function compileContextPackFromSnapshot(snapshot) {
|
|
473
|
+
const uniqueBeliefs = dedupeById(snapshot.beliefs);
|
|
474
|
+
const uniqueQuestions = dedupeById(snapshot.questions);
|
|
475
|
+
const uniqueEvidence = dedupeById(snapshot.evidence);
|
|
476
|
+
const uniqueContradictions = dedupeById(snapshot.contradictions);
|
|
477
|
+
const referenceTimeMs = resolveReferenceTimeMs([snapshot.topic], uniqueBeliefs, uniqueQuestions, uniqueEvidence, uniqueContradictions, snapshot.entities) || 0;
|
|
478
|
+
const rankOptions = {
|
|
479
|
+
effectiveWeights: snapshot.plan.effectiveWeights,
|
|
480
|
+
includeJustifications: snapshot.plan.compilationMode === "delta",
|
|
481
|
+
referenceTimeMs,
|
|
482
|
+
};
|
|
483
|
+
const { activeBeliefCandidates, activeBeliefs, invariantCandidates, invariants, } = compileBeliefSections(uniqueBeliefs, snapshot.plan, rankOptions);
|
|
484
|
+
const { openQuestionCandidates, openQuestions } = compileOpenQuestions(uniqueQuestions, snapshot.plan, rankOptions);
|
|
485
|
+
const { evidenceCandidates, recentEvidence } = compileRecentEvidence(uniqueEvidence, snapshot.plan, rankOptions);
|
|
486
|
+
const { contradictionCandidates, contradictions } = compileContradictions(uniqueContradictions, snapshot.plan, rankOptions);
|
|
487
|
+
const { entityCandidates, rankedEntities } = compileEntities(snapshot.entities, snapshot.plan);
|
|
488
|
+
const failureContext = compileFailureContext({
|
|
489
|
+
failures: snapshot.failures,
|
|
490
|
+
plan: snapshot.plan,
|
|
491
|
+
rankOptions,
|
|
492
|
+
recentEvidence,
|
|
493
|
+
referenceTimeMs,
|
|
494
|
+
});
|
|
495
|
+
const { effectiveEvidence, suppressedEvidenceIds } = applyFailureSuppression(recentEvidence, failureContext);
|
|
427
496
|
const summary = {
|
|
428
497
|
totalBeliefs: uniqueBeliefs.length,
|
|
429
498
|
invariants: invariants.length,
|
|
@@ -493,6 +562,7 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
493
562
|
topicName: snapshot.topic.name || "Untitled Topic",
|
|
494
563
|
scopedTopicIds: snapshot.plan.scopedTopicIds,
|
|
495
564
|
generatedAt: referenceTimeMs,
|
|
565
|
+
ranking: snapshot.plan.rankingProfile,
|
|
496
566
|
rankingProfile: snapshot.plan.rankingProfile,
|
|
497
567
|
summary,
|
|
498
568
|
invariants,
|
|
@@ -518,9 +588,9 @@ export function compileContextPackFromSnapshot(snapshot) {
|
|
|
518
588
|
: Number((injectionPolicy.estimatedTokens / injectionPolicy.tokenBudget).toFixed(4)),
|
|
519
589
|
referenceTimeMs,
|
|
520
590
|
},
|
|
521
|
-
...(snapshot.plan.compilationMode
|
|
522
|
-
? {
|
|
523
|
-
: {}),
|
|
591
|
+
...(snapshot.plan.compilationMode === "standard"
|
|
592
|
+
? {}
|
|
593
|
+
: { compilationMode: snapshot.plan.compilationMode }),
|
|
524
594
|
...(failureContext ? { failureContext } : {}),
|
|
525
595
|
...(deltaReport ? { deltaReport } : {}),
|
|
526
596
|
...(snapshot.plan.packWeightOverrides &&
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ContextPackSectionKey, type ContextRankingProfile, type PackWeightOverride, type RankingWeightVector } from "./contracts/context-pack.contract";
|
|
2
2
|
export type SectionKey = ContextPackSectionKey;
|
|
3
|
-
export
|
|
4
|
-
id: string;
|
|
5
|
-
text: string;
|
|
6
|
-
updatedAt?: number | null;
|
|
7
|
-
createdAt?: number | null;
|
|
8
|
-
confidence?: number | null;
|
|
3
|
+
export interface RankCandidate {
|
|
9
4
|
beliefType?: string | null;
|
|
5
|
+
confidence?: number | null;
|
|
6
|
+
createdAt?: number | null;
|
|
7
|
+
id: string;
|
|
10
8
|
priority?: string | null;
|
|
11
9
|
severity?: string | null;
|
|
12
|
-
|
|
10
|
+
text: string;
|
|
11
|
+
updatedAt?: number | null;
|
|
12
|
+
}
|
|
13
13
|
export type RankedCandidate<T extends RankCandidate> = T & {
|
|
14
14
|
score: number;
|
|
15
15
|
justification?: string;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
interface LexicalExclusion {
|
|
18
18
|
id: string;
|
|
19
|
-
section: SectionKey;
|
|
20
19
|
reason: "budget_exceeded" | "anti_repetition" | "below_threshold";
|
|
21
20
|
score: number;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
section: SectionKey;
|
|
22
|
+
}
|
|
23
|
+
export interface InjectionPlan {
|
|
25
24
|
estimatedTokens: number;
|
|
25
|
+
excludedItems?: LexicalExclusion[];
|
|
26
26
|
sectionBudgets: Record<SectionKey, number>;
|
|
27
27
|
sectionUsage: Record<SectionKey, number>;
|
|
28
28
|
selected: Record<SectionKey, string[]>;
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
29
|
+
tokenBudget: number;
|
|
30
|
+
}
|
|
31
|
+
interface RankContextOptions {
|
|
32
32
|
effectiveWeights?: Readonly<Record<ContextPackSectionKey, RankingWeightVector>>;
|
|
33
33
|
includeJustifications?: boolean;
|
|
34
34
|
referenceTimeMs?: number;
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
export declare function resolveEffectiveWeights(overrides?: PackWeightOverride[]): Readonly<Record<ContextPackSectionKey, RankingWeightVector>>;
|
|
37
37
|
export declare function rankContextSection<T extends RankCandidate>(section: SectionKey, rows: T[], queryTokens: string[], limit: number, profile: ContextRankingProfile, options?: RankContextOptions): RankedCandidate<T>[];
|
|
38
38
|
export declare function parseTokenBudget(value: unknown, fallback?: number): number;
|
|
@@ -65,16 +65,16 @@ export declare function buildInjectionPlan(args: {
|
|
|
65
65
|
}>;
|
|
66
66
|
trackExclusions?: boolean;
|
|
67
67
|
}): InjectionPlan;
|
|
68
|
-
export
|
|
69
|
-
nodeId: string;
|
|
70
|
-
entityType: string;
|
|
71
|
-
title: string;
|
|
68
|
+
export interface EntityCandidate {
|
|
72
69
|
canonicalText: string;
|
|
73
70
|
connectedBeliefCount: number;
|
|
74
71
|
connectedEvidenceCount: number;
|
|
72
|
+
entityType: string;
|
|
75
73
|
metadata: Record<string, unknown>;
|
|
74
|
+
nodeId: string;
|
|
75
|
+
title: string;
|
|
76
76
|
updatedAt?: number | null;
|
|
77
|
-
}
|
|
77
|
+
}
|
|
78
78
|
export type RankedEntity = EntityCandidate & {
|
|
79
79
|
score: number;
|
|
80
80
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// biome-ignore-all lint/style/useFilenamingConvention: This file is an @lucern/sdk public import ABI / package subpath compatibility surface; the camelCase filename is intentional.
|
|
2
|
+
import { BELIEF_TYPE_BONUS, DEFAULT_BELIEF_TYPE_BONUS, DEFAULT_ENTITY_LIMIT, DEFAULT_PRIORITY_SCORE, DEFAULT_SEVERITY_SCORE, DEFAULT_TOKEN_BUDGET, ENTITY_RANKING_WEIGHTS, MAX_ENTITY_LIMIT, MAX_TOKEN_BUDGET, MIN_CONTRADICTION_BUDGET, MIN_TOKEN_BUDGET, MIN_TOKEN_ESTIMATE, PRIORITY_SCORES, RANKING_WEIGHTS, RECENCY_HALF_LIFE_DAYS, SECTION_BUDGET_RATIOS, SEVERITY_SCORES, TOKENS_PER_WORD, } from "./contracts/context-pack.contract.js";
|
|
3
|
+
const TOKEN_SPLIT_PATTERN = /\s+/;
|
|
2
4
|
function tokenHits(text, tokens) {
|
|
3
5
|
if (tokens.length === 0) {
|
|
4
6
|
return 1;
|
|
@@ -19,7 +21,7 @@ function clamp01(value) {
|
|
|
19
21
|
return Math.max(0, Math.min(1, value));
|
|
20
22
|
}
|
|
21
23
|
function recencyScore(updatedAt, referenceTimeMs = Date.now()) {
|
|
22
|
-
if (!updatedAt
|
|
24
|
+
if (!(updatedAt && Number.isFinite(updatedAt))) {
|
|
23
25
|
return 0.25;
|
|
24
26
|
}
|
|
25
27
|
const ageMs = Math.max(0, referenceTimeMs - updatedAt);
|
|
@@ -58,15 +60,16 @@ export function resolveEffectiveWeights(overrides) {
|
|
|
58
60
|
}
|
|
59
61
|
return result;
|
|
60
62
|
}
|
|
61
|
-
function
|
|
62
|
-
const
|
|
63
|
-
const hits = tokenHits(candidate.text, queryTokens);
|
|
63
|
+
function appendQueryJustification(parts, text, queryTokens) {
|
|
64
|
+
const hits = tokenHits(text, queryTokens);
|
|
64
65
|
if (queryTokens.length > 0 && hits > 0) {
|
|
65
66
|
parts.push(`${hits}/${queryTokens.length} query terms matched`);
|
|
66
67
|
}
|
|
67
68
|
else if (queryTokens.length === 0) {
|
|
68
69
|
parts.push("no query filter");
|
|
69
70
|
}
|
|
71
|
+
}
|
|
72
|
+
function appendFreshnessJustification(parts, candidate) {
|
|
70
73
|
const ts = candidate.updatedAt || candidate.createdAt || null;
|
|
71
74
|
if (ts && Number.isFinite(ts)) {
|
|
72
75
|
const ageDays = Math.max(0, Date.now() - ts) / (1000 * 60 * 60 * 24);
|
|
@@ -83,6 +86,8 @@ function generateJustification(_section, candidate, queryTokens, weights) {
|
|
|
83
86
|
parts.push(`updated ${Math.floor(ageDays)}d ago (decayed)`);
|
|
84
87
|
}
|
|
85
88
|
}
|
|
89
|
+
}
|
|
90
|
+
function appendWeightedFieldJustifications(parts, candidate, weights) {
|
|
86
91
|
if (weights.confidence !== undefined &&
|
|
87
92
|
candidate.confidence !== null &&
|
|
88
93
|
candidate.confidence !== undefined) {
|
|
@@ -97,8 +102,17 @@ function generateJustification(_section, candidate, queryTokens, weights) {
|
|
|
97
102
|
if (weights.severity !== undefined && candidate.severity) {
|
|
98
103
|
parts.push(`severity=${candidate.severity}`);
|
|
99
104
|
}
|
|
105
|
+
}
|
|
106
|
+
function generateJustification(_section, candidate, queryTokens, weights) {
|
|
107
|
+
const parts = [];
|
|
108
|
+
appendQueryJustification(parts, candidate.text, queryTokens);
|
|
109
|
+
appendFreshnessJustification(parts, candidate);
|
|
110
|
+
appendWeightedFieldJustifications(parts, candidate, weights);
|
|
100
111
|
return parts.join(", ");
|
|
101
112
|
}
|
|
113
|
+
function computeBaselineScore(candidate, queryTokens) {
|
|
114
|
+
return queryTokens.length === 0 ? 1 : tokenHits(candidate.text, queryTokens);
|
|
115
|
+
}
|
|
102
116
|
function computeWeightedScore(section, candidate, queryTokens, effectiveWeights, referenceTimeMs) {
|
|
103
117
|
const weights = (effectiveWeights ?? RANKING_WEIGHTS)[section];
|
|
104
118
|
const queryComponent = queryTokens.length === 0
|
|
@@ -127,9 +141,7 @@ export function rankContextSection(section, rows, queryTokens, limit, profile, o
|
|
|
127
141
|
const scored = rows.map((row) => {
|
|
128
142
|
const score = profile === "weighted_v1"
|
|
129
143
|
? computeWeightedScore(section, row, queryTokens, effectiveWeights, referenceTimeMs)
|
|
130
|
-
: queryTokens
|
|
131
|
-
? 1
|
|
132
|
-
: tokenHits(row.text, queryTokens);
|
|
144
|
+
: computeBaselineScore(row, queryTokens);
|
|
133
145
|
const result = { ...row, score };
|
|
134
146
|
if (includeJustifications && profile === "weighted_v1") {
|
|
135
147
|
const weights = (effectiveWeights ?? RANKING_WEIGHTS)[section];
|
|
@@ -155,7 +167,7 @@ export function parseTokenBudget(value, fallback = DEFAULT_TOKEN_BUDGET) {
|
|
|
155
167
|
return Math.max(MIN_TOKEN_BUDGET, Math.min(MAX_TOKEN_BUDGET, parsed));
|
|
156
168
|
}
|
|
157
169
|
function estimateTokens(text) {
|
|
158
|
-
const words = text.trim().split(
|
|
170
|
+
const words = text.trim().split(TOKEN_SPLIT_PATTERN).filter(Boolean).length;
|
|
159
171
|
return Math.max(MIN_TOKEN_ESTIMATE, Math.ceil(words * TOKENS_PER_WORD));
|
|
160
172
|
}
|
|
161
173
|
export function buildInjectionPlan(args) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
valid: boolean;
|
|
1
|
+
interface ValidationResult {
|
|
3
2
|
errors: string[];
|
|
4
|
-
|
|
3
|
+
valid: boolean;
|
|
4
|
+
}
|
|
5
5
|
export declare function validateContextPackSchema(payload: unknown): ValidationResult;
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=contextPackSchema.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// biome-ignore-all lint/style/useFilenamingConvention: This file is an @lucern/sdk public import ABI / package subpath compatibility surface; the camelCase filename is intentional.
|
|
1
2
|
const CONTEXT_PACK_SCHEMA_VERSION = "1.0.0";
|
|
2
3
|
function isObject(value) {
|
|
3
4
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|