@lucern/sdk 0.2.0-alpha.6 → 0.2.0-alpha.8
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 +13 -0
- package/dist/{lib/platform/sdk/adminClient.d.ts → adminClient.d.ts} +56 -51
- package/dist/adminClient.js +755 -0
- package/dist/adminClient.js.map +1 -0
- package/dist/answersClient.d.ts +23 -0
- package/dist/answersClient.js +333 -0
- package/dist/answersClient.js.map +1 -0
- package/dist/{lib/platform/sdk/audiencesClient.d.ts → audiencesClient.d.ts} +24 -18
- package/dist/audiencesClient.js +472 -0
- package/dist/audiencesClient.js.map +1 -0
- package/dist/auditClient.d.ts +29 -0
- package/dist/auditClient.js +386 -0
- package/dist/auditClient.js.map +1 -0
- package/dist/{lib/platform/sdk/beliefsClient.d.ts → beliefsClient.d.ts} +32 -27
- package/dist/beliefsClient.js +477 -0
- package/dist/beliefsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/client.d.ts → client.d.ts} +404 -395
- package/dist/client.js +6134 -0
- package/dist/client.js.map +1 -0
- package/dist/{lib/platform/sdk/contextClient.d.ts → contextClient.d.ts} +13 -7
- package/dist/contextClient.js +396 -0
- package/dist/contextClient.js.map +1 -0
- package/dist/contextFacade.d.ts +2 -0
- package/dist/contextFacade.js +73 -0
- package/dist/contextFacade.js.map +1 -0
- package/dist/{lib/platform/sdk/contextPackCompiler.d.ts → contextPackCompiler.d.ts} +11 -9
- package/dist/contextPackCompiler.js +1091 -0
- package/dist/contextPackCompiler.js.map +1 -0
- package/dist/contextPackPolicy.d.ts +84 -0
- package/dist/contextPackPolicy.js +347 -0
- package/dist/contextPackPolicy.js.map +1 -0
- package/dist/contextPackSchema.d.ts +7 -0
- package/dist/contextPackSchema.js +203 -0
- package/dist/contextPackSchema.js.map +1 -0
- package/dist/{lib/platform/sdk/contextTypes.d.ts → contextTypes.d.ts} +15 -13
- package/dist/contextTypes.js +3 -0
- package/dist/contextTypes.js.map +1 -0
- package/dist/contracts/api-enums.contract.d.ts +81 -0
- package/dist/contracts/api-enums.contract.js +92 -0
- package/dist/contracts/api-enums.contract.js.map +1 -0
- package/dist/contracts/auth-session.contract.d.ts +55 -0
- package/dist/contracts/auth-session.contract.js +48 -0
- package/dist/contracts/auth-session.contract.js.map +1 -0
- package/dist/{lucern/contracts/src → contracts}/context-pack.contract.d.ts +56 -58
- package/dist/contracts/context-pack.contract.js +98 -0
- package/dist/contracts/context-pack.contract.js.map +1 -0
- package/dist/contracts/contextPack.d.ts +1 -0
- package/dist/contracts/contextPack.js +98 -0
- package/dist/contracts/contextPack.js.map +1 -0
- package/dist/contracts/index.d.ts +9 -0
- package/dist/contracts/index.js +4892 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/{lucern/contracts/src → contracts}/lens-filter.contract.d.ts +10 -8
- package/dist/contracts/lens-filter.contract.js +71 -0
- package/dist/contracts/lens-filter.contract.js.map +1 -0
- package/dist/contracts/lens-workflow.contract.d.ts +87 -0
- package/dist/contracts/lens-workflow.contract.js +123 -0
- package/dist/contracts/lens-workflow.contract.js.map +1 -0
- package/dist/contracts/lensFilter.d.ts +1 -0
- package/dist/contracts/lensFilter.js +71 -0
- package/dist/contracts/lensFilter.js.map +1 -0
- package/dist/contracts/lensWorkflow.d.ts +2 -0
- package/dist/contracts/lensWorkflow.js +123 -0
- package/dist/contracts/lensWorkflow.js.map +1 -0
- package/dist/contracts/mcp-tools.contract.d.ts +1 -0
- package/dist/contracts/mcp-tools.contract.js +2986 -0
- package/dist/contracts/mcp-tools.contract.js.map +1 -0
- package/dist/contracts/mcpTools.d.ts +1 -0
- package/dist/contracts/mcpTools.js +2986 -0
- package/dist/contracts/mcpTools.js.map +1 -0
- package/dist/{lucern/contracts/src → contracts}/prompt.contract.d.ts +5 -3
- package/dist/contracts/prompt.contract.js +12 -0
- package/dist/contracts/prompt.contract.js.map +1 -0
- package/dist/contracts/prompt.d.ts +1 -0
- package/dist/contracts/prompt.js +12 -0
- package/dist/contracts/prompt.js.map +1 -0
- package/dist/contracts/sdk-tools.contract.d.ts +2 -0
- package/dist/contracts/sdk-tools.contract.js +4134 -0
- package/dist/contracts/sdk-tools.contract.js.map +1 -0
- package/dist/contracts/sdkTools.d.ts +2 -0
- package/dist/contracts/sdkTools.js +4134 -0
- package/dist/contracts/sdkTools.js.map +1 -0
- package/dist/contracts/workflow-runtime.contract.d.ts +163 -0
- package/dist/contracts/workflow-runtime.contract.js +245 -0
- package/dist/contracts/workflow-runtime.contract.js.map +1 -0
- package/dist/contracts/workflowRuntime.d.ts +1 -0
- package/dist/contracts/workflowRuntime.js +245 -0
- package/dist/contracts/workflowRuntime.js.map +1 -0
- package/dist/{lib/platform/sdk/controlObjectOwnership.d.ts → controlObjectOwnership.d.ts} +20 -18
- package/dist/controlObjectOwnership.js +215 -0
- package/dist/controlObjectOwnership.js.map +1 -0
- package/dist/{lib/platform/sdk/coreClient.d.ts → coreClient.d.ts} +19 -14
- package/dist/coreClient.js +339 -0
- package/dist/coreClient.js.map +1 -0
- package/dist/{lib/platform/sdk/customTools.d.ts → customTools.d.ts} +21 -16
- package/dist/customTools.js +248 -0
- package/dist/customTools.js.map +1 -0
- package/dist/{lib/platform/sdk/decisionsClient.d.ts → decisionsClient.d.ts} +29 -24
- package/dist/decisionsClient.js +522 -0
- package/dist/decisionsClient.js.map +1 -0
- package/dist/domainContext.d.ts +1 -0
- package/dist/domainContext.js +3 -0
- package/dist/domainContext.js.map +1 -0
- package/dist/events.d.ts +178 -0
- package/dist/events.js +249 -0
- package/dist/events.js.map +1 -0
- package/dist/eventsCore.d.ts +49 -0
- package/dist/eventsCore.js +429 -0
- package/dist/eventsCore.js.map +1 -0
- package/dist/facade/context.d.ts +18 -0
- package/dist/facade/context.js +73 -0
- package/dist/facade/context.js.map +1 -0
- package/dist/{lib/platform/sdk/gatewayFacades.d.ts → gatewayFacades.d.ts} +31 -26
- package/dist/gatewayFacades.js +1953 -0
- package/dist/gatewayFacades.js.map +1 -0
- package/dist/{lib/platform/sdk/graphClient.d.ts → graphClient.d.ts} +57 -52
- package/dist/graphClient.js +698 -0
- package/dist/graphClient.js.map +1 -0
- package/dist/{lib/platform/sdk/harnessClient.d.ts → harnessClient.d.ts} +44 -39
- package/dist/harnessClient.js +607 -0
- package/dist/harnessClient.js.map +1 -0
- package/dist/{lib/platform/sdk/identityClient.d.ts → identityClient.d.ts} +17 -11
- package/dist/identityClient.js +497 -0
- package/dist/identityClient.js.map +1 -0
- package/dist/index.d.ts +42 -3
- package/dist/index.js +11381 -3
- package/dist/index.js.map +1 -0
- package/dist/{lib/platform/sdk/learningClient.d.ts → learningClient.d.ts} +13 -7
- package/dist/learningClient.js +409 -0
- package/dist/learningClient.js.map +1 -0
- package/dist/{lib/platform/sdk/mcpParityClient.d.ts → mcpParityClient.d.ts} +10 -5
- package/dist/mcpParityClient.js +516 -0
- package/dist/mcpParityClient.js.map +1 -0
- package/dist/mcpParitySurface.d.ts +12 -0
- package/dist/mcpParitySurface.js +65 -0
- package/dist/mcpParitySurface.js.map +1 -0
- package/dist/mcpTools-DPZxowDX.d.ts +254 -0
- package/dist/{lib/platform/sdk/ontologyClient.d.ts → ontologyClient.d.ts} +28 -22
- package/dist/ontologyClient.js +513 -0
- package/dist/ontologyClient.js.map +1 -0
- package/dist/packRuntime.d.ts +2 -0
- package/dist/packRuntime.js +3 -0
- package/dist/packRuntime.js.map +1 -0
- package/dist/{lib/platform/sdk/packsClient.d.ts → packsClient.d.ts} +34 -29
- package/dist/packsClient.js +525 -0
- package/dist/packsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/policyClient.d.ts → policyClient.d.ts} +26 -20
- package/dist/policyClient.js +625 -0
- package/dist/policyClient.js.map +1 -0
- package/dist/realtime/index.d.ts +29 -0
- package/dist/realtime/index.js +23 -0
- package/dist/realtime/index.js.map +1 -0
- package/dist/realtime/refs.d.ts +17 -0
- package/dist/realtime/refs.js +9 -0
- package/dist/realtime/refs.js.map +1 -0
- package/dist/reportsClient.d.ts +41 -0
- package/dist/reportsClient.js +418 -0
- package/dist/reportsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/schemaClient.d.ts → schemaClient.d.ts} +20 -15
- package/dist/schemaClient.js +434 -0
- package/dist/schemaClient.js.map +1 -0
- package/dist/sdkSurface.d.ts +61 -0
- package/dist/sdkSurface.js +112 -0
- package/dist/sdkSurface.js.map +1 -0
- package/dist/sdkTools-CwXJDACb.d.ts +150 -0
- package/dist/{lib/platform/sdk/topicsClient.d.ts → topicsClient.d.ts} +24 -18
- package/dist/topicsClient.js +492 -0
- package/dist/topicsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/types.d.ts → types.d.ts} +84 -80
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/{lib/platform/sdk/workflowClient.d.ts → workflowClient.d.ts} +60 -57
- package/dist/workflowClient.js +830 -0
- package/dist/workflowClient.js.map +1 -0
- package/package.json +25 -43
- package/dist/.generated +0 -2
- package/dist/lib/platform/auth/credentials.d.ts +0 -5
- package/dist/lib/platform/auth/credentials.js +0 -40
- package/dist/lib/platform/sdk/adminClient.js +0 -384
- package/dist/lib/platform/sdk/answersClient.d.ts +0 -16
- package/dist/lib/platform/sdk/answersClient.js +0 -21
- package/dist/lib/platform/sdk/audiencesClient.js +0 -111
- package/dist/lib/platform/sdk/auditClient.d.ts +0 -24
- package/dist/lib/platform/sdk/auditClient.js +0 -21
- package/dist/lib/platform/sdk/beliefsClient.js +0 -124
- package/dist/lib/platform/sdk/client.js +0 -1831
- package/dist/lib/platform/sdk/contextClient.js +0 -86
- package/dist/lib/platform/sdk/contextFacade.d.ts +0 -10
- package/dist/lib/platform/sdk/contextFacade.js +0 -10
- package/dist/lib/platform/sdk/contextPackCompiler.js +0 -534
- package/dist/lib/platform/sdk/contextTypes.js +0 -1
- package/dist/lib/platform/sdk/controlObjectOwnership.js +0 -220
- package/dist/lib/platform/sdk/coreClient.js +0 -366
- package/dist/lib/platform/sdk/customTools.js +0 -247
- package/dist/lib/platform/sdk/decisionsClient.js +0 -129
- package/dist/lib/platform/sdk/domainContext.d.ts +0 -1
- package/dist/lib/platform/sdk/domainContext.js +0 -1
- package/dist/lib/platform/sdk/events.d.ts +0 -176
- package/dist/lib/platform/sdk/events.js +0 -261
- package/dist/lib/platform/sdk/eventsCore.d.ts +0 -13
- package/dist/lib/platform/sdk/eventsCore.js +0 -13
- package/dist/lib/platform/sdk/gatewayFacades.js +0 -845
- package/dist/lib/platform/sdk/graphClient.js +0 -235
- package/dist/lib/platform/sdk/harnessClient.js +0 -219
- package/dist/lib/platform/sdk/identityClient.js +0 -131
- package/dist/lib/platform/sdk/index.d.ts +0 -49
- package/dist/lib/platform/sdk/index.js +0 -49
- package/dist/lib/platform/sdk/learningClient.js +0 -53
- package/dist/lib/platform/sdk/mcpParityClient.js +0 -196
- package/dist/lib/platform/sdk/mcpParitySurface.d.ts +0 -10
- package/dist/lib/platform/sdk/mcpParitySurface.js +0 -57
- package/dist/lib/platform/sdk/ontologyClient.js +0 -161
- package/dist/lib/platform/sdk/packRuntime.d.ts +0 -1
- package/dist/lib/platform/sdk/packRuntime.js +0 -1
- package/dist/lib/platform/sdk/packsClient.js +0 -157
- package/dist/lib/platform/sdk/policyClient.js +0 -277
- package/dist/lib/platform/sdk/promptCatalog.d.ts +0 -1
- package/dist/lib/platform/sdk/promptCatalog.js +0 -1
- package/dist/lib/platform/sdk/reportsClient.d.ts +0 -34
- package/dist/lib/platform/sdk/reportsClient.js +0 -64
- package/dist/lib/platform/sdk/schemaClient.js +0 -71
- package/dist/lib/platform/sdk/sdkSurface.d.ts +0 -56
- package/dist/lib/platform/sdk/sdkSurface.js +0 -140
- package/dist/lib/platform/sdk/topicsClient.js +0 -118
- package/dist/lib/platform/sdk/types.js +0 -1
- package/dist/lib/platform/sdk/version.d.ts +0 -2
- package/dist/lib/platform/sdk/version.js +0 -2
- package/dist/lib/platform/sdk/workflowClient.js +0 -366
- package/dist/lucern/contracts/src/api-enums.contract.d.ts +0 -58
- package/dist/lucern/contracts/src/api-enums.contract.js +0 -147
- package/dist/lucern/contracts/src/auth-context.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/auth-context.contract.js +0 -8
- package/dist/lucern/contracts/src/auth-session.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/auth-session.contract.js +0 -8
- package/dist/lucern/contracts/src/auth.contract.d.ts +0 -88
- package/dist/lucern/contracts/src/auth.contract.js +0 -57
- package/dist/lucern/contracts/src/context-pack.contract.js +0 -169
- package/dist/lucern/contracts/src/convex-admin.contract.d.ts +0 -5
- package/dist/lucern/contracts/src/convex-admin.contract.js +0 -1
- package/dist/lucern/contracts/src/events-types.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/events-types.contract.js +0 -8
- package/dist/lucern/contracts/src/events.contract.d.ts +0 -176
- package/dist/lucern/contracts/src/events.contract.js +0 -159
- package/dist/lucern/contracts/src/gateway.contract.d.ts +0 -74
- package/dist/lucern/contracts/src/gateway.contract.js +0 -19
- package/dist/lucern/contracts/src/ids.contract.d.ts +0 -7
- package/dist/lucern/contracts/src/ids.contract.js +0 -24
- package/dist/lucern/contracts/src/index.d.ts +0 -29
- package/dist/lucern/contracts/src/index.js +0 -29
- package/dist/lucern/contracts/src/lens-filter.contract.js +0 -95
- package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +0 -84
- package/dist/lucern/contracts/src/lens-workflow.contract.js +0 -54
- package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +0 -151
- package/dist/lucern/contracts/src/mcp-tools.contract.js +0 -3281
- package/dist/lucern/contracts/src/ontology-matching.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/ontology-matching.contract.js +0 -8
- package/dist/lucern/contracts/src/prompt.contract.js +0 -24
- package/dist/lucern/contracts/src/sdk-methods.contract.d.ts +0 -358
- package/dist/lucern/contracts/src/sdk-methods.contract.js +0 -19
- package/dist/lucern/contracts/src/sdk-tools.contract.d.ts +0 -92
- package/dist/lucern/contracts/src/sdk-tools.contract.js +0 -1398
- package/dist/lucern/contracts/src/text-matching.contract.d.ts +0 -53
- package/dist/lucern/contracts/src/text-matching.contract.js +0 -277
- package/dist/lucern/contracts/src/topic-scope.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/topic-scope.contract.js +0 -8
- package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +0 -161
- package/dist/lucern/contracts/src/workflow-runtime.contract.js +0 -257
- package/dist/realtime-refs.d.ts +0 -1
- package/dist/realtime-refs.js +0 -1
- package/dist/realtime.d.ts +0 -1
- package/dist/realtime.js +0 -1
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared lexical matching primitives used across MCP handlers and graph utilities.
|
|
3
|
-
*
|
|
4
|
-
* The goal is not to replace downstream LLM scoring. It provides a fast,
|
|
5
|
-
* deterministic substrate for candidate generation, reranking, and light
|
|
6
|
-
* classification across belief/question/evidence/entity surfaces.
|
|
7
|
-
*/
|
|
8
|
-
export type LexicalStrategy = "tokenOverlap" | "bigramJaccard" | "wordOverlap";
|
|
9
|
-
export type PreparedLexicalQuery = {
|
|
10
|
-
raw: string;
|
|
11
|
-
tokens: string[];
|
|
12
|
-
words: string[];
|
|
13
|
-
bigrams: Set<string>;
|
|
14
|
-
};
|
|
15
|
-
export type LexicalSignal = {
|
|
16
|
-
strategy?: LexicalStrategy;
|
|
17
|
-
text: string | null | undefined;
|
|
18
|
-
weight: number;
|
|
19
|
-
};
|
|
20
|
-
export type LexicalRerankOptions = {
|
|
21
|
-
lexicalWeight?: number;
|
|
22
|
-
rankWeight?: number;
|
|
23
|
-
};
|
|
24
|
-
/** Tokenize a string into lowercase words, removing stop words. */
|
|
25
|
-
export declare function tokenizeSearchText(text: string): string[];
|
|
26
|
-
/** Simple stemmer: strip common English suffixes for fuzzy matching. */
|
|
27
|
-
export declare function stemToken(word: string): string;
|
|
28
|
-
/** Compute token overlap score between query tokens and text tokens. */
|
|
29
|
-
export declare function tokenOverlapScore(queryTokens: string[], textTokens: string[]): number;
|
|
30
|
-
/**
|
|
31
|
-
* Extract character bigrams from text. Normalizes to lowercase, removes
|
|
32
|
-
* non-alphanumeric characters, and generates overlapping pairs.
|
|
33
|
-
*/
|
|
34
|
-
export declare function bigramTokenize(text: string): Set<string>;
|
|
35
|
-
/**
|
|
36
|
-
* Extract word-level tokens from text (for coarser matching).
|
|
37
|
-
* Normalizes to lowercase, splits on non-alphanumeric.
|
|
38
|
-
*/
|
|
39
|
-
export declare function wordTokenize(text: string): string[];
|
|
40
|
-
/** Jaccard similarity between two sets: |A ∩ B| / |A ∪ B|. */
|
|
41
|
-
export declare function jaccardSimilarity(setA: Set<string>, setB: Set<string>): number;
|
|
42
|
-
/** Exact word overlap score: fraction of type words found in input text. */
|
|
43
|
-
export declare function wordOverlapScore(inputWords: string[], typeWords: string[]): number;
|
|
44
|
-
/** Pre-compute reusable lexical structures for a query. */
|
|
45
|
-
export declare function prepareLexicalQuery(query: string): PreparedLexicalQuery;
|
|
46
|
-
/** Score a single lexical signal against a prepared query. */
|
|
47
|
-
export declare function scoreLexicalSignal(query: PreparedLexicalQuery, signal: LexicalSignal): number;
|
|
48
|
-
/** Weighted lexical score across multiple textual signals. */
|
|
49
|
-
export declare function scoreLexicalSignals(query: PreparedLexicalQuery, signals: LexicalSignal[]): number;
|
|
50
|
-
/** Map a candidate's original rank position into a 0..1 prior. */
|
|
51
|
-
export declare function rankWindowScore(index: number, total: number): number;
|
|
52
|
-
/** Rerank a candidate window by lexical overlap while preserving original-rank prior. */
|
|
53
|
-
export declare function rerankLexicalWindow<T>(query: string, items: T[], getText: (item: T) => string | null | undefined, options?: LexicalRerankOptions): T[];
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared lexical matching primitives used across MCP handlers and graph utilities.
|
|
3
|
-
*
|
|
4
|
-
* The goal is not to replace downstream LLM scoring. It provides a fast,
|
|
5
|
-
* deterministic substrate for candidate generation, reranking, and light
|
|
6
|
-
* classification across belief/question/evidence/entity surfaces.
|
|
7
|
-
*/
|
|
8
|
-
const TOKEN_SPLIT_REGEX = /[^a-z0-9]+/;
|
|
9
|
-
const NON_ALPHANUMERIC_REGEX = /[^a-z0-9]/g;
|
|
10
|
-
/** Stop words that add noise to scoring. */
|
|
11
|
-
const STOP_WORDS = new Set([
|
|
12
|
-
"the",
|
|
13
|
-
"a",
|
|
14
|
-
"an",
|
|
15
|
-
"and",
|
|
16
|
-
"or",
|
|
17
|
-
"but",
|
|
18
|
-
"in",
|
|
19
|
-
"on",
|
|
20
|
-
"at",
|
|
21
|
-
"to",
|
|
22
|
-
"for",
|
|
23
|
-
"of",
|
|
24
|
-
"with",
|
|
25
|
-
"by",
|
|
26
|
-
"from",
|
|
27
|
-
"is",
|
|
28
|
-
"it",
|
|
29
|
-
"as",
|
|
30
|
-
"be",
|
|
31
|
-
"was",
|
|
32
|
-
"are",
|
|
33
|
-
"this",
|
|
34
|
-
"that",
|
|
35
|
-
"has",
|
|
36
|
-
"had",
|
|
37
|
-
"have",
|
|
38
|
-
"not",
|
|
39
|
-
"all",
|
|
40
|
-
"can",
|
|
41
|
-
"do",
|
|
42
|
-
"its",
|
|
43
|
-
"may",
|
|
44
|
-
"will",
|
|
45
|
-
"how",
|
|
46
|
-
"what",
|
|
47
|
-
"which",
|
|
48
|
-
"who",
|
|
49
|
-
"when",
|
|
50
|
-
"where",
|
|
51
|
-
"than",
|
|
52
|
-
"then",
|
|
53
|
-
"each",
|
|
54
|
-
"into",
|
|
55
|
-
"such",
|
|
56
|
-
"any",
|
|
57
|
-
"been",
|
|
58
|
-
"if",
|
|
59
|
-
"would",
|
|
60
|
-
"about",
|
|
61
|
-
"should",
|
|
62
|
-
"these",
|
|
63
|
-
"those",
|
|
64
|
-
"their",
|
|
65
|
-
"we",
|
|
66
|
-
"our",
|
|
67
|
-
"so",
|
|
68
|
-
]);
|
|
69
|
-
/** Tokenize a string into lowercase words, removing stop words. */
|
|
70
|
-
export function tokenizeSearchText(text) {
|
|
71
|
-
return text
|
|
72
|
-
.toLowerCase()
|
|
73
|
-
.split(TOKEN_SPLIT_REGEX)
|
|
74
|
-
.filter((token) => token.length >= 2 && !STOP_WORDS.has(token));
|
|
75
|
-
}
|
|
76
|
-
/** Simple stemmer: strip common English suffixes for fuzzy matching. */
|
|
77
|
-
export function stemToken(word) {
|
|
78
|
-
if (word.length <= 4) {
|
|
79
|
-
return word;
|
|
80
|
-
}
|
|
81
|
-
if (word.endsWith("ation")) {
|
|
82
|
-
return word.slice(0, -5);
|
|
83
|
-
}
|
|
84
|
-
if (word.endsWith("ment")) {
|
|
85
|
-
return word.slice(0, -4);
|
|
86
|
-
}
|
|
87
|
-
if (word.endsWith("ness")) {
|
|
88
|
-
return word.slice(0, -4);
|
|
89
|
-
}
|
|
90
|
-
if (word.endsWith("ical")) {
|
|
91
|
-
return word.slice(0, -4);
|
|
92
|
-
}
|
|
93
|
-
if (word.endsWith("tion")) {
|
|
94
|
-
return word.slice(0, -4);
|
|
95
|
-
}
|
|
96
|
-
if (word.endsWith("sion")) {
|
|
97
|
-
return word.slice(0, -4);
|
|
98
|
-
}
|
|
99
|
-
if (word.endsWith("ing")) {
|
|
100
|
-
return word.slice(0, -3);
|
|
101
|
-
}
|
|
102
|
-
if (word.endsWith("ous")) {
|
|
103
|
-
return word.slice(0, -3);
|
|
104
|
-
}
|
|
105
|
-
if (word.endsWith("ive")) {
|
|
106
|
-
return word.slice(0, -3);
|
|
107
|
-
}
|
|
108
|
-
if (word.endsWith("ity")) {
|
|
109
|
-
return word.slice(0, -3);
|
|
110
|
-
}
|
|
111
|
-
if (word.endsWith("ics")) {
|
|
112
|
-
return word.slice(0, -3);
|
|
113
|
-
}
|
|
114
|
-
if (word.endsWith("ly")) {
|
|
115
|
-
return word.slice(0, -2);
|
|
116
|
-
}
|
|
117
|
-
if (word.endsWith("ed")) {
|
|
118
|
-
return word.slice(0, -2);
|
|
119
|
-
}
|
|
120
|
-
if (word.endsWith("er")) {
|
|
121
|
-
return word.slice(0, -2);
|
|
122
|
-
}
|
|
123
|
-
if (word.endsWith("es")) {
|
|
124
|
-
return word.slice(0, -2);
|
|
125
|
-
}
|
|
126
|
-
if (word.endsWith("al")) {
|
|
127
|
-
return word.slice(0, -2);
|
|
128
|
-
}
|
|
129
|
-
if (word.endsWith("ic")) {
|
|
130
|
-
return word.slice(0, -2);
|
|
131
|
-
}
|
|
132
|
-
if (word.endsWith("s") && !word.endsWith("ss")) {
|
|
133
|
-
return word.slice(0, -1);
|
|
134
|
-
}
|
|
135
|
-
return word;
|
|
136
|
-
}
|
|
137
|
-
/** Compute token overlap score between query tokens and text tokens. */
|
|
138
|
-
export function tokenOverlapScore(queryTokens, textTokens) {
|
|
139
|
-
if (queryTokens.length === 0 || textTokens.length === 0) {
|
|
140
|
-
return 0;
|
|
141
|
-
}
|
|
142
|
-
const stemmedText = new Set(textTokens.map(stemToken));
|
|
143
|
-
let matchCount = 0;
|
|
144
|
-
for (const queryToken of queryTokens) {
|
|
145
|
-
const stemmedQuery = stemToken(queryToken);
|
|
146
|
-
if (stemmedText.has(stemmedQuery)) {
|
|
147
|
-
matchCount += 1;
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
for (const textToken of stemmedText) {
|
|
151
|
-
if (textToken.startsWith(stemmedQuery) ||
|
|
152
|
-
stemmedQuery.startsWith(textToken)) {
|
|
153
|
-
matchCount += 0.5;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return matchCount / queryTokens.length;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Extract character bigrams from text. Normalizes to lowercase, removes
|
|
162
|
-
* non-alphanumeric characters, and generates overlapping pairs.
|
|
163
|
-
*/
|
|
164
|
-
export function bigramTokenize(text) {
|
|
165
|
-
const normalized = text.toLowerCase().replace(NON_ALPHANUMERIC_REGEX, "");
|
|
166
|
-
const bigrams = new Set();
|
|
167
|
-
for (let i = 0; i < normalized.length - 1; i++) {
|
|
168
|
-
bigrams.add(normalized.slice(i, i + 2));
|
|
169
|
-
}
|
|
170
|
-
return bigrams;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Extract word-level tokens from text (for coarser matching).
|
|
174
|
-
* Normalizes to lowercase, splits on non-alphanumeric.
|
|
175
|
-
*/
|
|
176
|
-
export function wordTokenize(text) {
|
|
177
|
-
return text
|
|
178
|
-
.toLowerCase()
|
|
179
|
-
.split(TOKEN_SPLIT_REGEX)
|
|
180
|
-
.filter((token) => token.length > 1);
|
|
181
|
-
}
|
|
182
|
-
/** Jaccard similarity between two sets: |A ∩ B| / |A ∪ B|. */
|
|
183
|
-
export function jaccardSimilarity(setA, setB) {
|
|
184
|
-
if (setA.size === 0 && setB.size === 0) {
|
|
185
|
-
return 0;
|
|
186
|
-
}
|
|
187
|
-
let intersectionSize = 0;
|
|
188
|
-
const smaller = setA.size <= setB.size ? setA : setB;
|
|
189
|
-
const larger = setA.size <= setB.size ? setB : setA;
|
|
190
|
-
for (const item of smaller) {
|
|
191
|
-
if (larger.has(item)) {
|
|
192
|
-
intersectionSize++;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
const unionSize = setA.size + setB.size - intersectionSize;
|
|
196
|
-
return unionSize === 0 ? 0 : intersectionSize / unionSize;
|
|
197
|
-
}
|
|
198
|
-
/** Exact word overlap score: fraction of type words found in input text. */
|
|
199
|
-
export function wordOverlapScore(inputWords, typeWords) {
|
|
200
|
-
if (typeWords.length === 0) {
|
|
201
|
-
return 0;
|
|
202
|
-
}
|
|
203
|
-
let matches = 0;
|
|
204
|
-
for (const word of typeWords) {
|
|
205
|
-
if (inputWords.includes(word)) {
|
|
206
|
-
matches++;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return matches / typeWords.length;
|
|
210
|
-
}
|
|
211
|
-
/** Pre-compute reusable lexical structures for a query. */
|
|
212
|
-
export function prepareLexicalQuery(query) {
|
|
213
|
-
return {
|
|
214
|
-
raw: query,
|
|
215
|
-
tokens: tokenizeSearchText(query),
|
|
216
|
-
words: wordTokenize(query),
|
|
217
|
-
bigrams: bigramTokenize(query),
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
/** Score a single lexical signal against a prepared query. */
|
|
221
|
-
export function scoreLexicalSignal(query, signal) {
|
|
222
|
-
const text = signal.text?.trim();
|
|
223
|
-
if (!text) {
|
|
224
|
-
return 0;
|
|
225
|
-
}
|
|
226
|
-
switch (signal.strategy ?? "tokenOverlap") {
|
|
227
|
-
case "bigramJaccard":
|
|
228
|
-
return jaccardSimilarity(query.bigrams, bigramTokenize(text));
|
|
229
|
-
case "wordOverlap":
|
|
230
|
-
return wordOverlapScore(query.words, wordTokenize(text));
|
|
231
|
-
default:
|
|
232
|
-
return tokenOverlapScore(query.tokens, tokenizeSearchText(text));
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
/** Weighted lexical score across multiple textual signals. */
|
|
236
|
-
export function scoreLexicalSignals(query, signals) {
|
|
237
|
-
let weightedScore = 0;
|
|
238
|
-
let totalWeight = 0;
|
|
239
|
-
for (const signal of signals) {
|
|
240
|
-
if (!signal.text?.trim() || signal.weight <= 0) {
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
weightedScore += scoreLexicalSignal(query, signal) * signal.weight;
|
|
244
|
-
totalWeight += signal.weight;
|
|
245
|
-
}
|
|
246
|
-
return totalWeight === 0 ? 0 : weightedScore / totalWeight;
|
|
247
|
-
}
|
|
248
|
-
/** Map a candidate's original rank position into a 0..1 prior. */
|
|
249
|
-
export function rankWindowScore(index, total) {
|
|
250
|
-
if (total <= 1) {
|
|
251
|
-
return 1;
|
|
252
|
-
}
|
|
253
|
-
const clampedIndex = Math.max(0, Math.min(index, total - 1));
|
|
254
|
-
return 1 - clampedIndex / (total - 1);
|
|
255
|
-
}
|
|
256
|
-
/** Rerank a candidate window by lexical overlap while preserving original-rank prior. */
|
|
257
|
-
export function rerankLexicalWindow(query, items, getText, options) {
|
|
258
|
-
const preparedQuery = prepareLexicalQuery(query);
|
|
259
|
-
if (preparedQuery.tokens.length === 0 || items.length <= 1) {
|
|
260
|
-
return items;
|
|
261
|
-
}
|
|
262
|
-
const lexicalWeight = options?.lexicalWeight ?? 0.65;
|
|
263
|
-
const rankWeight = options?.rankWeight ?? 0.35;
|
|
264
|
-
return items
|
|
265
|
-
.map((item, index) => {
|
|
266
|
-
const lexicalScore = scoreLexicalSignals(preparedQuery, [
|
|
267
|
-
{ text: getText(item) ?? "", weight: 1, strategy: "tokenOverlap" },
|
|
268
|
-
]);
|
|
269
|
-
const rankScore = rankWindowScore(index, items.length);
|
|
270
|
-
return {
|
|
271
|
-
item,
|
|
272
|
-
combinedScore: lexicalScore * lexicalWeight + rankScore * rankWeight,
|
|
273
|
-
};
|
|
274
|
-
})
|
|
275
|
-
.sort((left, right) => right.combinedScore - left.combinedScore)
|
|
276
|
-
.map(({ item }) => item);
|
|
277
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @lucern/contracts — topic-scope compat shim
|
|
3
|
-
*
|
|
4
|
-
* This file moved to ./v1/topics/v1.ts during EK-16 T1 PR 2.
|
|
5
|
-
* Retained here until the Lucern 1.0.0 barrel-sunset cut (D12).
|
|
6
|
-
* New code should import from "@lucern/contracts/v1/topics" directly.
|
|
7
|
-
*/
|
|
8
|
-
export * from "./v1/topics/v1";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @lucern/contracts — topic-scope compat shim
|
|
3
|
-
*
|
|
4
|
-
* This file moved to ./v1/topics/v1.ts during EK-16 T1 PR 2.
|
|
5
|
-
* Retained here until the Lucern 1.0.0 barrel-sunset cut (D12).
|
|
6
|
-
* New code should import from "@lucern/contracts/v1/topics" directly.
|
|
7
|
-
*/
|
|
8
|
-
export * from "./v1/topics/v1.js";
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workflow Runtime Contract v1
|
|
3
|
-
*
|
|
4
|
-
* Canonical TypeScript contract for Lucern's graph-local workflow runtime.
|
|
5
|
-
* WF-1 defines the typed substrate for:
|
|
6
|
-
* - workflow definitions and run receipts
|
|
7
|
-
* - action mutation tiering and approval expectations
|
|
8
|
-
* - hooks over worktree/question/evidence/inbox events
|
|
9
|
-
* - output unions for domain-specific artifacts
|
|
10
|
-
* - deterministic integrity checks and operational metadata
|
|
11
|
-
*
|
|
12
|
-
* BREAKING CHANGE RULES:
|
|
13
|
-
* - Adding optional fields is NON-breaking
|
|
14
|
-
* - Removing fields or renaming enum values is BREAKING
|
|
15
|
-
* - Reclassifying a mutation tier is BREAKING
|
|
16
|
-
* - Changing canonical workflow IDs is BREAKING
|
|
17
|
-
*/
|
|
18
|
-
export declare const WORKFLOW_RUNTIME_SCHEMA_VERSION: "1.0.0";
|
|
19
|
-
export declare const WORKFLOW_MUTATION_TIERS: readonly ["read_only", "low_risk_write", "high_risk_write"];
|
|
20
|
-
export type WorkflowMutationTier = (typeof WORKFLOW_MUTATION_TIERS)[number];
|
|
21
|
-
export declare const WORKFLOW_APPROVAL_MODES: readonly ["none", "audit_only", "human_required", "auto_approve"];
|
|
22
|
-
export type WorkflowApprovalMode = (typeof WORKFLOW_APPROVAL_MODES)[number];
|
|
23
|
-
export declare const DEFAULT_TIER_APPROVAL_MODE: Readonly<Record<WorkflowMutationTier, WorkflowApprovalMode>>;
|
|
24
|
-
export declare const WORKFLOW_ACTION_KINDS: readonly ["context_pack", "integrity_check", "lucern_tool", "report_compile", "brief_publish", "notification", "custom"];
|
|
25
|
-
export type WorkflowActionKind = (typeof WORKFLOW_ACTION_KINDS)[number];
|
|
26
|
-
export declare const WORKFLOW_HOOK_EVENTS: readonly ["schedule.tick", "worktree.activated", "worktree.completed", "question.created", "question.answered", "evidence.appended", "inbox.item_created"];
|
|
27
|
-
export type WorkflowHookEvent = (typeof WORKFLOW_HOOK_EVENTS)[number];
|
|
28
|
-
export declare const WORKFLOW_OUTPUT_KINDS: readonly ["engineering_brief", "research_memo", "strategy_artifact", "inbox_summary", "pipeline_brief", "structured_payload"];
|
|
29
|
-
export type WorkflowOutputKind = (typeof WORKFLOW_OUTPUT_KINDS)[number];
|
|
30
|
-
export declare const WORKFLOW_RUN_STATUSES: readonly ["queued", "running", "awaiting_approval", "completed", "failed", "cancelled"];
|
|
31
|
-
export type WorkflowRunStatus = (typeof WORKFLOW_RUN_STATUSES)[number];
|
|
32
|
-
export declare const WORKFLOW_TRIGGER_KINDS: readonly ["manual", "schedule", "hook"];
|
|
33
|
-
export type WorkflowTriggerKind = (typeof WORKFLOW_TRIGGER_KINDS)[number];
|
|
34
|
-
export declare const WORKFLOW_PROOF_ARTIFACT_KINDS: readonly ["report", "brief", "artifact", "dashboard", "test_evidence"];
|
|
35
|
-
export type WorkflowProofArtifactKind = (typeof WORKFLOW_PROOF_ARTIFACT_KINDS)[number];
|
|
36
|
-
export declare const WORKFLOW_STAFFING_HINTS: readonly ["solo", "backend+tests", "fullstack", "mcp+tests"];
|
|
37
|
-
export type WorkflowStaffingHint = (typeof WORKFLOW_STAFFING_HINTS)[number];
|
|
38
|
-
export declare const WORKFLOW_AUTO_FIX_MODES: readonly ["disabled", "dry_run", "safe", "aggressive"];
|
|
39
|
-
export type WorkflowAutoFixMode = (typeof WORKFLOW_AUTO_FIX_MODES)[number];
|
|
40
|
-
export declare const WORKFLOW_INTEGRITY_CHECKS: readonly ["null_dependency_refs", "superseded_blockers", "band_order_inconsistency", "sparse_shaping", "failed_completed_gate"];
|
|
41
|
-
export type WorkflowIntegrityCheckId = (typeof WORKFLOW_INTEGRITY_CHECKS)[number];
|
|
42
|
-
export type WorkflowProofArtifact = {
|
|
43
|
-
kind: WorkflowProofArtifactKind;
|
|
44
|
-
label: string;
|
|
45
|
-
required?: boolean;
|
|
46
|
-
sourceRef?: string;
|
|
47
|
-
};
|
|
48
|
-
export type WorkflowAutoFixPolicy = {
|
|
49
|
-
mode: WorkflowAutoFixMode;
|
|
50
|
-
maxActionsPerRun?: number;
|
|
51
|
-
permittedMutationTiers?: WorkflowMutationTier[];
|
|
52
|
-
requireAuditTrail?: boolean;
|
|
53
|
-
escalationGate?: string;
|
|
54
|
-
};
|
|
55
|
-
export declare const DEFAULT_WORKFLOW_AUTO_FIX_POLICY: WorkflowAutoFixPolicy;
|
|
56
|
-
export type WorkflowApprovalPolicy = {
|
|
57
|
-
mode: WorkflowApprovalMode;
|
|
58
|
-
approvalGate?: string;
|
|
59
|
-
autoApprovePolicyKey?: string;
|
|
60
|
-
rationaleRequired?: boolean;
|
|
61
|
-
};
|
|
62
|
-
export type WorkflowOutputBase = {
|
|
63
|
-
outputId: string;
|
|
64
|
-
kind: WorkflowOutputKind;
|
|
65
|
-
title: string;
|
|
66
|
-
summary: string;
|
|
67
|
-
generatedAt?: number;
|
|
68
|
-
};
|
|
69
|
-
export type EngineeringBriefOutput = WorkflowOutputBase & {
|
|
70
|
-
kind: "engineering_brief";
|
|
71
|
-
sections: Array<{
|
|
72
|
-
heading: string;
|
|
73
|
-
body: string;
|
|
74
|
-
}>;
|
|
75
|
-
touchedPaths?: string[];
|
|
76
|
-
};
|
|
77
|
-
export type ResearchMemoOutput = WorkflowOutputBase & {
|
|
78
|
-
kind: "research_memo";
|
|
79
|
-
claims: string[];
|
|
80
|
-
evidenceRefs?: string[];
|
|
81
|
-
};
|
|
82
|
-
export type StrategyArtifactOutput = WorkflowOutputBase & {
|
|
83
|
-
kind: "strategy_artifact";
|
|
84
|
-
recommendations: string[];
|
|
85
|
-
decisionWindow?: string;
|
|
86
|
-
};
|
|
87
|
-
export type InboxSummaryOutput = WorkflowOutputBase & {
|
|
88
|
-
kind: "inbox_summary";
|
|
89
|
-
channel: "developer_portal" | "chat" | "ops";
|
|
90
|
-
inboxTitle: string;
|
|
91
|
-
inboxBody: string;
|
|
92
|
-
};
|
|
93
|
-
export type PipelineBriefOutput = WorkflowOutputBase & {
|
|
94
|
-
kind: "pipeline_brief";
|
|
95
|
-
hingeWorktreeId?: string;
|
|
96
|
-
groupedBlockers: Array<{
|
|
97
|
-
blocker: string;
|
|
98
|
-
blockedWorktreeIds: string[];
|
|
99
|
-
}>;
|
|
100
|
-
};
|
|
101
|
-
export type StructuredPayloadOutput = WorkflowOutputBase & {
|
|
102
|
-
kind: "structured_payload";
|
|
103
|
-
payload: Record<string, unknown>;
|
|
104
|
-
};
|
|
105
|
-
export type WorkflowOutputContract = EngineeringBriefOutput | ResearchMemoOutput | StrategyArtifactOutput | InboxSummaryOutput | PipelineBriefOutput | StructuredPayloadOutput;
|
|
106
|
-
export type WorkflowActionContract = {
|
|
107
|
-
actionId: string;
|
|
108
|
-
kind: WorkflowActionKind;
|
|
109
|
-
title: string;
|
|
110
|
-
description: string;
|
|
111
|
-
mutationTier: WorkflowMutationTier;
|
|
112
|
-
toolName?: string;
|
|
113
|
-
produces?: WorkflowOutputKind[];
|
|
114
|
-
idempotent?: boolean;
|
|
115
|
-
approval: WorkflowApprovalPolicy;
|
|
116
|
-
};
|
|
117
|
-
export type WorkflowHookContract = {
|
|
118
|
-
hookId: string;
|
|
119
|
-
event: WorkflowHookEvent;
|
|
120
|
-
description: string;
|
|
121
|
-
condition?: string;
|
|
122
|
-
actionIds: string[];
|
|
123
|
-
};
|
|
124
|
-
export type WorkflowTriggerContract = {
|
|
125
|
-
kind: "manual";
|
|
126
|
-
description?: string;
|
|
127
|
-
} | {
|
|
128
|
-
kind: "schedule";
|
|
129
|
-
cadence: "hourly" | "daily" | "weekly";
|
|
130
|
-
timezone?: string;
|
|
131
|
-
} | {
|
|
132
|
-
kind: "hook";
|
|
133
|
-
event: WorkflowHookEvent;
|
|
134
|
-
};
|
|
135
|
-
export type WorkflowDefinitionV1 = {
|
|
136
|
-
workflowId: string;
|
|
137
|
-
version: typeof WORKFLOW_RUNTIME_SCHEMA_VERSION;
|
|
138
|
-
title: string;
|
|
139
|
-
description: string;
|
|
140
|
-
trigger: WorkflowTriggerContract;
|
|
141
|
-
staffingHint?: WorkflowStaffingHint;
|
|
142
|
-
proofArtifacts?: WorkflowProofArtifact[];
|
|
143
|
-
autoFixPolicy?: WorkflowAutoFixPolicy;
|
|
144
|
-
actions: readonly WorkflowActionContract[];
|
|
145
|
-
hooks?: readonly WorkflowHookContract[];
|
|
146
|
-
outputs: readonly WorkflowOutputKind[];
|
|
147
|
-
integrityChecks?: readonly WorkflowIntegrityCheckId[];
|
|
148
|
-
};
|
|
149
|
-
export type WorkflowRunReceiptV1 = {
|
|
150
|
-
runId: string;
|
|
151
|
-
workflowId: string;
|
|
152
|
-
status: WorkflowRunStatus;
|
|
153
|
-
triggeredBy: WorkflowTriggerKind;
|
|
154
|
-
startedAt: number;
|
|
155
|
-
completedAt?: number;
|
|
156
|
-
outputKinds: WorkflowOutputKind[];
|
|
157
|
-
approvalsRequired?: number;
|
|
158
|
-
};
|
|
159
|
-
export declare const NIGHTLY_RECONCILIATION_WORKFLOW_ID: "workflow.pipeline_reconciliation.v1";
|
|
160
|
-
export declare const MORNING_BRIEF_WORKFLOW_ID: "workflow.morning_brief.v1";
|
|
161
|
-
export declare const CANONICAL_WORKFLOW_DEFINITIONS: readonly WorkflowDefinitionV1[];
|