@lucern/contracts 0.1.0 → 0.1.2-alpha.1

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.
Files changed (128) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +3 -0
  3. package/dist/agents/v1.d.ts +2 -0
  4. package/dist/agents/v1.js +3 -0
  5. package/dist/agents/v1.js.map +1 -0
  6. package/dist/api-enums.contract.d.ts +30 -29
  7. package/dist/api-enums.contract.js +145 -133
  8. package/dist/api-enums.contract.js.map +1 -1
  9. package/dist/auth-context.contract.d.ts +2 -0
  10. package/dist/auth-context.contract.js +48 -0
  11. package/dist/auth-context.contract.js.map +1 -0
  12. package/dist/auth-session.contract.d.ts +2 -54
  13. package/dist/auth-session.contract.js +41 -43
  14. package/dist/auth-session.contract.js.map +1 -1
  15. package/dist/auth.contract.d.ts +92 -0
  16. package/dist/auth.contract.js +48 -0
  17. package/dist/auth.contract.js.map +1 -0
  18. package/dist/beliefs/v1.d.ts +2 -0
  19. package/dist/beliefs/v1.js +3 -0
  20. package/dist/beliefs/v1.js.map +1 -0
  21. package/dist/context-pack.contract.d.ts +55 -54
  22. package/dist/context-pack.contract.js +88 -160
  23. package/dist/context-pack.contract.js.map +1 -1
  24. package/dist/convex-admin.contract.d.ts +7 -0
  25. package/dist/convex-admin.contract.js +3 -0
  26. package/dist/convex-admin.contract.js.map +1 -0
  27. package/dist/events-types.contract.d.ts +1 -0
  28. package/dist/events-types.contract.js +136 -0
  29. package/dist/events-types.contract.js.map +1 -0
  30. package/dist/events.contract.d.ts +178 -0
  31. package/dist/events.contract.js +136 -0
  32. package/dist/events.contract.js.map +1 -0
  33. package/dist/evidence/v1.d.ts +2 -0
  34. package/dist/evidence/v1.js +3 -0
  35. package/dist/evidence/v1.js.map +1 -0
  36. package/dist/gateway.contract.d.ts +17 -12
  37. package/dist/gateway.contract.js +11 -11
  38. package/dist/gateway.contract.js.map +1 -1
  39. package/dist/graph/v1.d.ts +2 -0
  40. package/dist/graph/v1.js +3 -0
  41. package/dist/graph/v1.js.map +1 -0
  42. package/dist/ids.contract.d.ts +9 -0
  43. package/dist/ids.contract.js +29 -0
  44. package/dist/ids.contract.js.map +1 -0
  45. package/dist/index.d.ts +15 -22
  46. package/dist/index.js +5525 -21
  47. package/dist/index.js.map +1 -1
  48. package/dist/lens-filter.contract.d.ts +10 -9
  49. package/dist/lens-filter.contract.js +59 -84
  50. package/dist/lens-filter.contract.js.map +1 -1
  51. package/dist/lens-workflow.contract.d.ts +23 -21
  52. package/dist/lens-workflow.contract.js +116 -48
  53. package/dist/lens-workflow.contract.js.map +1 -1
  54. package/dist/mcp-tools.contract-D8kXcP6d.d.ts +254 -0
  55. package/dist/mcp-tools.contract.d.ts +1 -152
  56. package/dist/mcp-tools.contract.js +2984 -3280
  57. package/dist/mcp-tools.contract.js.map +1 -1
  58. package/dist/ontologies/v1.d.ts +2 -0
  59. package/dist/ontologies/v1.js +3 -0
  60. package/dist/ontologies/v1.js.map +1 -0
  61. package/dist/ontology-matching.contract.d.ts +1 -0
  62. package/dist/ontology-matching.contract.js +346 -0
  63. package/dist/ontology-matching.contract.js.map +1 -0
  64. package/dist/prompt.contract.d.ts +5 -4
  65. package/dist/prompt.contract.js +10 -23
  66. package/dist/prompt.contract.js.map +1 -1
  67. package/dist/questions/v1.d.ts +2 -0
  68. package/dist/questions/v1.js +3 -0
  69. package/dist/questions/v1.js.map +1 -0
  70. package/dist/sdk-methods.contract.d.ts +51 -45
  71. package/dist/sdk-methods.contract.js +2 -16
  72. package/dist/sdk-methods.contract.js.map +1 -1
  73. package/dist/sdk-tools.contract-BnV0hKLp.d.ts +150 -0
  74. package/dist/sdk-tools.contract.d.ts +2 -93
  75. package/dist/sdk-tools.contract.js +4220 -1397
  76. package/dist/sdk-tools.contract.js.map +1 -1
  77. package/dist/text-matching.contract.d.ts +55 -0
  78. package/dist/text-matching.contract.js +246 -0
  79. package/dist/text-matching.contract.js.map +1 -0
  80. package/dist/topic-scope.contract.d.ts +1 -0
  81. package/dist/topic-scope.contract.js +54 -0
  82. package/dist/topic-scope.contract.js.map +1 -0
  83. package/dist/topics/v1.d.ts +2 -0
  84. package/dist/topics/v1.js +3 -0
  85. package/dist/topics/v1.js.map +1 -0
  86. package/dist/v1/agents/v1.d.ts +2 -0
  87. package/dist/v1/agents/v1.js +3 -0
  88. package/dist/v1/agents/v1.js.map +1 -0
  89. package/dist/v1/beliefs/v1.d.ts +2 -0
  90. package/dist/v1/beliefs/v1.js +3 -0
  91. package/dist/v1/beliefs/v1.js.map +1 -0
  92. package/dist/v1/evidence/v1.d.ts +2 -0
  93. package/dist/v1/evidence/v1.js +3 -0
  94. package/dist/v1/evidence/v1.js.map +1 -0
  95. package/dist/v1/graph/v1.d.ts +2 -0
  96. package/dist/v1/graph/v1.js +3 -0
  97. package/dist/v1/graph/v1.js.map +1 -0
  98. package/dist/v1/ontologies/v1.d.ts +78 -0
  99. package/dist/v1/ontologies/v1.js +346 -0
  100. package/dist/v1/ontologies/v1.js.map +1 -0
  101. package/dist/v1/questions/v1.d.ts +2 -0
  102. package/dist/v1/questions/v1.js +3 -0
  103. package/dist/v1/questions/v1.js.map +1 -0
  104. package/dist/v1/topics/v1.d.ts +21 -0
  105. package/dist/v1/topics/v1.js +54 -0
  106. package/dist/v1/topics/v1.js.map +1 -0
  107. package/dist/v1/worktrees/v1.d.ts +2 -0
  108. package/dist/v1/worktrees/v1.js +3 -0
  109. package/dist/v1/worktrees/v1.js.map +1 -0
  110. package/dist/workflow-runtime.contract.d.ts +46 -45
  111. package/dist/workflow-runtime.contract.js +228 -241
  112. package/dist/workflow-runtime.contract.js.map +1 -1
  113. package/dist/worktrees/v1.d.ts +2 -0
  114. package/dist/worktrees/v1.js +3 -0
  115. package/dist/worktrees/v1.js.map +1 -0
  116. package/package.json +19 -13
  117. package/dist/api-enums.contract.d.ts.map +0 -1
  118. package/dist/auth-session.contract.d.ts.map +0 -1
  119. package/dist/context-pack.contract.d.ts.map +0 -1
  120. package/dist/gateway.contract.d.ts.map +0 -1
  121. package/dist/index.d.ts.map +0 -1
  122. package/dist/lens-filter.contract.d.ts.map +0 -1
  123. package/dist/lens-workflow.contract.d.ts.map +0 -1
  124. package/dist/mcp-tools.contract.d.ts.map +0 -1
  125. package/dist/prompt.contract.d.ts.map +0 -1
  126. package/dist/sdk-methods.contract.d.ts.map +0 -1
  127. package/dist/sdk-tools.contract.d.ts.map +0 -1
  128. package/dist/workflow-runtime.contract.d.ts.map +0 -1
@@ -21,7 +21,7 @@
21
21
  *
22
22
  * V2 will add `propertyMatchers` here for arbitrary JSON Schema facet queries.
23
23
  */
24
- export type EntityTypeFilterV1 = {
24
+ type EntityTypeFilterV1 = {
25
25
  /** References ontologyVersion.entityTypes[].value, e.g. "company" */
26
26
  entityTypeValue: string;
27
27
  /** Optional subtype narrowing. If omitted or empty, all subtypes match. */
@@ -31,14 +31,14 @@ export type EntityTypeFilterV1 = {
31
31
  * Optional scope to restrict which ontology the filter resolves against.
32
32
  * If omitted, resolution uses whatever ontology is active in the workspace.
33
33
  */
34
- export type OntologyScope = {
34
+ type OntologyScope = {
35
35
  /** Restrict to a specific ontology by key, e.g. "vc-investment" */
36
36
  ontologyKey?: string;
37
37
  };
38
38
  /**
39
39
  * Taxonomy filter criteria v1: entity type + subtype matching over ontology.
40
40
  */
41
- export type TaxonomyFilterCriteriaV1 = {
41
+ type TaxonomyFilterCriteriaV1 = {
42
42
  version: 1;
43
43
  kind: "taxonomy";
44
44
  entityTypeFilters: EntityTypeFilterV1[];
@@ -54,10 +54,10 @@ export type TaxonomyFilterCriteriaV1 = {
54
54
  * 3. Add a resolver in taxonomy-filter.ts
55
55
  * 4. No schema migration needed — filterCriteria is v.any()
56
56
  */
57
- export type LensFilterCriteria = TaxonomyFilterCriteriaV1;
58
- export declare function isLensFilterCriteria(value: unknown): value is LensFilterCriteria;
59
- export declare function isTaxonomyFilterCriteriaV1(value: unknown): value is TaxonomyFilterCriteriaV1;
60
- export type FilterValidationResult = {
57
+ type LensFilterCriteria = TaxonomyFilterCriteriaV1;
58
+ declare function isLensFilterCriteria(value: unknown): value is LensFilterCriteria;
59
+ declare function isTaxonomyFilterCriteriaV1(value: unknown): value is TaxonomyFilterCriteriaV1;
60
+ type FilterValidationResult = {
61
61
  valid: true;
62
62
  } | {
63
63
  valid: false;
@@ -67,5 +67,6 @@ export type FilterValidationResult = {
67
67
  * Validate a filter criteria document at the contract layer.
68
68
  * This runs before persisting to Convex.
69
69
  */
70
- export declare function validateFilterCriteria(value: unknown): FilterValidationResult;
71
- //# sourceMappingURL=lens-filter.contract.d.ts.map
70
+ declare function validateFilterCriteria(value: unknown): FilterValidationResult;
71
+
72
+ export { type EntityTypeFilterV1, type FilterValidationResult, type LensFilterCriteria, type OntologyScope, type TaxonomyFilterCriteriaV1, isLensFilterCriteria, isTaxonomyFilterCriteriaV1, validateFilterCriteria };
@@ -1,96 +1,71 @@
1
- /**
2
- * Lens Filter Criteria Contract
3
- *
4
- * Version-discriminated filter DSL for lenses. Each filter criteria document
5
- * carries a `version` and `kind` discriminator so future shapes can coexist
6
- * without schema migrations. The Convex `filterCriteria` field remains v.any()
7
- * — all type enforcement happens here at the TypeScript contract layer.
8
- *
9
- * Forward-compatibility guarantees:
10
- * - `version` field: new versions add fields, never remove or rename existing ones
11
- * - `kind` field: new filter kinds (temporal, confidence-range) can be added
12
- * without touching taxonomy code paths
13
- * - `entityTypeFilters` array items are open to extension in future versions
14
- * - Resolution logic switches on `version` + `kind` to select the right resolver
15
- *
16
- * @module lucern/contracts/src/lens-filter
17
- */
18
- // Future: | TemporalFilterCriteriaV1 | ConfidenceRangeFilterCriteriaV1 | ...
19
- // ---------------------------------------------------------------------------
20
- // Type guards
21
- // ---------------------------------------------------------------------------
22
- export function isLensFilterCriteria(value) {
23
- if (!value || typeof value !== "object")
24
- return false;
25
- const obj = value;
26
- return typeof obj.version === "number" && typeof obj.kind === "string";
1
+ // src/lens-filter.contract.ts
2
+ function isLensFilterCriteria(value) {
3
+ if (!value || typeof value !== "object") return false;
4
+ const obj = value;
5
+ return typeof obj.version === "number" && typeof obj.kind === "string";
27
6
  }
28
- export function isTaxonomyFilterCriteriaV1(value) {
29
- if (!isLensFilterCriteria(value))
30
- return false;
31
- return value.version === 1 && value.kind === "taxonomy";
7
+ function isTaxonomyFilterCriteriaV1(value) {
8
+ if (!isLensFilterCriteria(value)) return false;
9
+ return value.version === 1 && value.kind === "taxonomy";
32
10
  }
33
- /**
34
- * Validate a filter criteria document at the contract layer.
35
- * This runs before persisting to Convex.
36
- */
37
- export function validateFilterCriteria(value) {
38
- if (value === undefined || value === null) {
39
- return { valid: true }; // filterCriteria is optional
40
- }
41
- if (!isLensFilterCriteria(value)) {
42
- return {
43
- valid: false,
44
- errors: [
45
- 'filterCriteria must have numeric "version" and string "kind" fields',
46
- ],
47
- };
48
- }
49
- if (isTaxonomyFilterCriteriaV1(value)) {
50
- return validateTaxonomyFilterV1(value);
51
- }
52
- // Cast to access properties — TypeScript narrows to `never` when all union
53
- // members are exhausted, but at runtime unknown version/kind combos are possible.
54
- const raw = value;
11
+ function validateFilterCriteria(value) {
12
+ if (value === void 0 || value === null) {
13
+ return { valid: true };
14
+ }
15
+ if (!isLensFilterCriteria(value)) {
55
16
  return {
56
- valid: false,
57
- errors: [
58
- `Unsupported filter criteria: version=${raw.version}, kind=${raw.kind}`,
59
- ],
17
+ valid: false,
18
+ errors: [
19
+ 'filterCriteria must have numeric "version" and string "kind" fields'
20
+ ]
60
21
  };
22
+ }
23
+ if (isTaxonomyFilterCriteriaV1(value)) {
24
+ return validateTaxonomyFilterV1(value);
25
+ }
26
+ const raw = value;
27
+ return {
28
+ valid: false,
29
+ errors: [
30
+ `Unsupported filter criteria: version=${raw.version}, kind=${raw.kind}`
31
+ ]
32
+ };
61
33
  }
62
34
  function validateTaxonomyFilterV1(criteria) {
63
- const errors = [];
64
- if (!Array.isArray(criteria.entityTypeFilters)) {
65
- errors.push("entityTypeFilters must be an array");
66
- return { valid: false, errors };
35
+ const errors = [];
36
+ if (!Array.isArray(criteria.entityTypeFilters)) {
37
+ errors.push("entityTypeFilters must be an array");
38
+ return { valid: false, errors };
39
+ }
40
+ if (criteria.entityTypeFilters.length === 0) {
41
+ errors.push("entityTypeFilters must contain at least one entry");
42
+ return { valid: false, errors };
43
+ }
44
+ for (let i = 0; i < criteria.entityTypeFilters.length; i++) {
45
+ const filter = criteria.entityTypeFilters[i];
46
+ if (!filter || typeof filter.entityTypeValue !== "string") {
47
+ errors.push(
48
+ `entityTypeFilters[${i}].entityTypeValue must be a non-empty string`
49
+ );
50
+ continue;
67
51
  }
68
- if (criteria.entityTypeFilters.length === 0) {
69
- errors.push("entityTypeFilters must contain at least one entry");
70
- return { valid: false, errors };
52
+ if (filter.entityTypeValue.trim().length === 0) {
53
+ errors.push(
54
+ `entityTypeFilters[${i}].entityTypeValue must be a non-empty string`
55
+ );
71
56
  }
72
- for (let i = 0; i < criteria.entityTypeFilters.length; i++) {
73
- const filter = criteria.entityTypeFilters[i];
74
- if (!filter || typeof filter.entityTypeValue !== "string") {
75
- errors.push(`entityTypeFilters[${i}].entityTypeValue must be a non-empty string`);
76
- continue;
77
- }
78
- if (filter.entityTypeValue.trim().length === 0) {
79
- errors.push(`entityTypeFilters[${i}].entityTypeValue must be a non-empty string`);
80
- }
81
- if (filter.subtypeValues !== undefined &&
82
- !Array.isArray(filter.subtypeValues)) {
83
- errors.push(`entityTypeFilters[${i}].subtypeValues must be an array`);
84
- }
57
+ if (filter.subtypeValues !== void 0 && !Array.isArray(filter.subtypeValues)) {
58
+ errors.push(`entityTypeFilters[${i}].subtypeValues must be an array`);
85
59
  }
86
- if (criteria.ontologyScope !== undefined) {
87
- if (typeof criteria.ontologyScope !== "object" ||
88
- criteria.ontologyScope === null) {
89
- errors.push("ontologyScope must be an object");
90
- }
60
+ }
61
+ if (criteria.ontologyScope !== void 0) {
62
+ if (typeof criteria.ontologyScope !== "object" || criteria.ontologyScope === null) {
63
+ errors.push("ontologyScope must be an object");
91
64
  }
92
- return errors.length === 0
93
- ? { valid: true }
94
- : { valid: false, errors };
65
+ }
66
+ return errors.length === 0 ? { valid: true } : { valid: false, errors };
95
67
  }
68
+
69
+ export { isLensFilterCriteria, isTaxonomyFilterCriteriaV1, validateFilterCriteria };
70
+ //# sourceMappingURL=lens-filter.contract.js.map
96
71
  //# sourceMappingURL=lens-filter.contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lens-filter.contract.js","sourceRoot":"","sources":["../src/lens-filter.contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAsDH,6EAA6E;AAE7E,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E,MAAM,UAAU,oBAAoB,CAClC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,GAAG,GAAG,KAAgC,CAAC;IAC7C,OAAO,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAAc;IAEd,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/C,OAAO,KAAK,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC;AAC1D,CAAC;AAUD;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAc;IAEd,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,6BAA6B;IACvD,CAAC;IAED,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE;gBACN,qEAAqE;aACtE;SACF,CA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CAAO,oBAAoB,QAAA,EAAU;AACzD,MAAA,MAAA,CAAO,IAAA;AAAA,QACL,qBAAqB,CAAC,CAAA,4CAAA;AAAA,OACxB;AACA,MAAA;AAAA,IACF;AACA,IAAA,IAAI,MAAA,CAAO,eAAA,CAAgB,IAAA,EAAK,CAAE,WAAW,CAAA,EAAG;AAC9C,MAAA,MAAA,CAAO,IAAA;AAAA,QACL,qBAAqB,CAAC,CAAA,4CAAA;AAAA,OACxB;AAAA,IACF;AACA,IAAA,IACE,MAAA,CAAO,kBAAkB,MAAA,IACzB,CAAC,MAAM,OAAA,CAAQ,MAAA,CAAO,aAAa,CAAA,EACnC;AACA,MAAA,MAAA,CAAO,IAAA,CAAK,CAAA,kBAAA,EAAqB,CAAC,CAAA,gCAAA,CAAkC,CAAA;AAAA,IACtE;AAAA,EACF;AAEA,EAAA,IAAI,QAAA,CAAS,kBAAkB,MAAA,EAAW;AACxC,IAAA,IACE,OAAO,QAAA,CAAS,aAAA,KAAkB,QAAA,IAClC,QAAA,CAAS,kBAAkB,IAAA,EAC3B;AACA,MAAA,MAAA,CAAO,KAAK,iCAAiC,CAAA;AAAA,IAC/C;AAAA,EACF;AAEA,EAAA,OAAO,MAAA,CAAO,MAAA,KAAW,CAAA,GACrB,EAAE,KAAA,EAAO,MAAK,GACd,EAAE,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AAC7B","file":"lens-filter.contract.js","sourcesContent":["/**\n * Lens Filter Criteria Contract\n *\n * Version-discriminated filter DSL for lenses. Each filter criteria document\n * carries a `version` and `kind` discriminator so future shapes can coexist\n * without schema migrations. The Convex `filterCriteria` field remains v.any()\n * — all type enforcement happens here at the TypeScript contract layer.\n *\n * Forward-compatibility guarantees:\n * - `version` field: new versions add fields, never remove or rename existing ones\n * - `kind` field: new filter kinds (temporal, confidence-range) can be added\n * without touching taxonomy code paths\n * - `entityTypeFilters` array items are open to extension in future versions\n * - Resolution logic switches on `version` + `kind` to select the right resolver\n *\n * @module lucern/contracts/src/lens-filter\n */\n\n// ---------------------------------------------------------------------------\n// V1: Taxonomy Filter — entity type + subtype matching\n// ---------------------------------------------------------------------------\n\n/**\n * A single entity type filter entry. Matches nodes whose `nodeType` equals\n * `entityTypeValue`, optionally further narrowed by subtype membership.\n *\n * V2 will add `propertyMatchers` here for arbitrary JSON Schema facet queries.\n */\nexport type EntityTypeFilterV1 = {\n /** References ontologyVersion.entityTypes[].value, e.g. \"company\" */\n entityTypeValue: string;\n\n /** Optional subtype narrowing. If omitted or empty, all subtypes match. */\n subtypeValues?: string[];\n};\n\n/**\n * Optional scope to restrict which ontology the filter resolves against.\n * If omitted, resolution uses whatever ontology is active in the workspace.\n */\nexport type OntologyScope = {\n /** Restrict to a specific ontology by key, e.g. \"vc-investment\" */\n ontologyKey?: string;\n};\n\n/**\n * Taxonomy filter criteria v1: entity type + subtype matching over ontology.\n */\nexport type TaxonomyFilterCriteriaV1 = {\n version: 1;\n kind: \"taxonomy\";\n entityTypeFilters: EntityTypeFilterV1[];\n ontologyScope?: OntologyScope;\n};\n\n// ---------------------------------------------------------------------------\n// Union: All filter criteria versions and kinds\n// ---------------------------------------------------------------------------\n\n/**\n * Discriminated union of all supported filter criteria.\n * Resolution logic switches on `version` + `kind`.\n *\n * To add a new filter kind:\n * 1. Define a new type (e.g., TemporalFilterCriteriaV1)\n * 2. Add it to this union\n * 3. Add a resolver in taxonomy-filter.ts\n * 4. No schema migration needed — filterCriteria is v.any()\n */\nexport type LensFilterCriteria = TaxonomyFilterCriteriaV1;\n// Future: | TemporalFilterCriteriaV1 | ConfidenceRangeFilterCriteriaV1 | ...\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport function isLensFilterCriteria(\n value: unknown\n): value is LensFilterCriteria {\n if (!value || typeof value !== \"object\") return false;\n const obj = value as Record<string, unknown>;\n return typeof obj.version === \"number\" && typeof obj.kind === \"string\";\n}\n\nexport function isTaxonomyFilterCriteriaV1(\n value: unknown\n): value is TaxonomyFilterCriteriaV1 {\n if (!isLensFilterCriteria(value)) return false;\n return value.version === 1 && value.kind === \"taxonomy\";\n}\n\n// ---------------------------------------------------------------------------\n// Validation\n// ---------------------------------------------------------------------------\n\nexport type FilterValidationResult =\n | { valid: true }\n | { valid: false; errors: string[] };\n\n/**\n * Validate a filter criteria document at the contract layer.\n * This runs before persisting to Convex.\n */\nexport function validateFilterCriteria(\n value: unknown\n): FilterValidationResult {\n if (value === undefined || value === null) {\n return { valid: true }; // filterCriteria is optional\n }\n\n if (!isLensFilterCriteria(value)) {\n return {\n valid: false,\n errors: [\n 'filterCriteria must have numeric \"version\" and string \"kind\" fields',\n ],\n };\n }\n\n if (isTaxonomyFilterCriteriaV1(value)) {\n return validateTaxonomyFilterV1(value);\n }\n\n // Cast to access properties — TypeScript narrows to `never` when all union\n // members are exhausted, but at runtime unknown version/kind combos are possible.\n const raw = value as { version: number; kind: string };\n return {\n valid: false,\n errors: [\n `Unsupported filter criteria: version=${raw.version}, kind=${raw.kind}`,\n ],\n };\n}\n\nfunction validateTaxonomyFilterV1(\n criteria: TaxonomyFilterCriteriaV1\n): FilterValidationResult {\n const errors: string[] = [];\n\n if (!Array.isArray(criteria.entityTypeFilters)) {\n errors.push(\"entityTypeFilters must be an array\");\n return { valid: false, errors };\n }\n\n if (criteria.entityTypeFilters.length === 0) {\n errors.push(\"entityTypeFilters must contain at least one entry\");\n return { valid: false, errors };\n }\n\n for (let i = 0; i < criteria.entityTypeFilters.length; i++) {\n const filter = criteria.entityTypeFilters[i];\n if (!filter || typeof filter.entityTypeValue !== \"string\") {\n errors.push(\n `entityTypeFilters[${i}].entityTypeValue must be a non-empty string`\n );\n continue;\n }\n if (filter.entityTypeValue.trim().length === 0) {\n errors.push(\n `entityTypeFilters[${i}].entityTypeValue must be a non-empty string`\n );\n }\n if (\n filter.subtypeValues !== undefined &&\n !Array.isArray(filter.subtypeValues)\n ) {\n errors.push(`entityTypeFilters[${i}].subtypeValues must be an array`);\n }\n }\n\n if (criteria.ontologyScope !== undefined) {\n if (\n typeof criteria.ontologyScope !== \"object\" ||\n criteria.ontologyScope === null\n ) {\n errors.push(\"ontologyScope must be an object\");\n }\n }\n\n return errors.length === 0\n ? { valid: true }\n : { valid: false, errors };\n}\n"]}
@@ -1,16 +1,17 @@
1
+ export { EntityTypeFilterV1, FilterValidationResult, LensFilterCriteria, OntologyScope, TaxonomyFilterCriteriaV1, isLensFilterCriteria, isTaxonomyFilterCriteriaV1, validateFilterCriteria } from './lens-filter.contract.js';
2
+
1
3
  /**
2
4
  * Canonical lens workflow contract shared across schema, SDK, and MCP surfaces.
3
5
  */
4
- export type { LensFilterCriteria, TaxonomyFilterCriteriaV1, EntityTypeFilterV1, OntologyScope, FilterValidationResult, } from "./lens-filter.contract";
5
- export { validateFilterCriteria, isLensFilterCriteria, isTaxonomyFilterCriteriaV1, } from "./lens-filter.contract";
6
- export declare const LENS_PERSPECTIVE_TYPES: readonly ["investigation", "monitoring", "analysis", "comparison", "taxonomy"];
7
- export type LensPerspectiveType = (typeof LENS_PERSPECTIVE_TYPES)[number];
8
- export declare const LENS_STATUSES: readonly ["draft", "active", "archived"];
9
- export type LensStatus = (typeof LENS_STATUSES)[number];
10
- export declare const LENS_TASK_TEMPLATE_PRIORITIES: readonly ["critical", "high", "medium", "low"];
11
- export type LensTaskTemplatePriority = (typeof LENS_TASK_TEMPLATE_PRIORITIES)[number];
12
- export type LensLooseMetadata = Record<string, unknown>;
13
- export type LensPromptTemplateReference = {
6
+
7
+ declare const LENS_PERSPECTIVE_TYPES: readonly ["investigation", "monitoring", "analysis", "comparison", "taxonomy"];
8
+ type LensPerspectiveType = (typeof LENS_PERSPECTIVE_TYPES)[number];
9
+ declare const LENS_STATUSES: readonly ["draft", "active", "archived"];
10
+ type LensStatus = (typeof LENS_STATUSES)[number];
11
+ declare const LENS_TASK_TEMPLATE_PRIORITIES: readonly ["critical", "high", "medium", "low"];
12
+ type LensTaskTemplatePriority = (typeof LENS_TASK_TEMPLATE_PRIORITIES)[number];
13
+ type LensLooseMetadata = Record<string, unknown>;
14
+ type LensPromptTemplateReference = {
14
15
  key: string;
15
16
  promptRef: string;
16
17
  phase?: string;
@@ -19,7 +20,7 @@ export type LensPromptTemplateReference = {
19
20
  required?: boolean;
20
21
  metadata?: LensLooseMetadata;
21
22
  };
22
- export type LensWorkflowStepTemplate = {
23
+ type LensWorkflowStepTemplate = {
23
24
  key: string;
24
25
  title: string;
25
26
  description?: string;
@@ -27,14 +28,14 @@ export type LensWorkflowStepTemplate = {
27
28
  taskTemplateKeys?: string[];
28
29
  metadata?: LensLooseMetadata;
29
30
  };
30
- export type LensWorkflowTemplate = {
31
+ type LensWorkflowTemplate = {
31
32
  key: string;
32
33
  name: string;
33
34
  description?: string;
34
35
  steps: LensWorkflowStepTemplate[];
35
36
  metadata?: LensLooseMetadata;
36
37
  };
37
- export type LensTaskTemplate = {
38
+ type LensTaskTemplate = {
38
39
  key: string;
39
40
  title: string;
40
41
  description?: string;
@@ -42,14 +43,14 @@ export type LensTaskTemplate = {
42
43
  phase?: string;
43
44
  metadata?: LensLooseMetadata;
44
45
  };
45
- export type LensQuestionTemplate = {
46
+ type LensQuestionTemplate = {
46
47
  key: string;
47
48
  text: string;
48
49
  priority?: LensTaskTemplatePriority;
49
50
  linkedBeliefKey?: string;
50
51
  metadata?: LensLooseMetadata;
51
52
  };
52
- export type LensBranchMigrationSuggestion = {
53
+ type LensBranchMigrationSuggestion = {
53
54
  recommendedTool: "create_lens";
54
55
  perspectiveType: LensPerspectiveType;
55
56
  message: string;
@@ -61,25 +62,26 @@ export type LensBranchMigrationSuggestion = {
61
62
  perspectiveType: LensPerspectiveType;
62
63
  };
63
64
  };
64
- export declare const BRANCH_DEPRECATION_MESSAGE = "Branches are deprecated for operational framing. Create a workspace-scoped lens instead.";
65
- export type DeprecatedBranchMetadata = {
65
+ declare const BRANCH_DEPRECATION_MESSAGE = "Branches are deprecated for operational framing. Create a workspace-scoped lens instead.";
66
+ type DeprecatedBranchMetadata = {
66
67
  deprecated: true;
67
68
  deprecationMessage: string;
68
69
  lensSuggestion: LensBranchMigrationSuggestion;
69
70
  };
70
- export declare function inferLensPerspectiveTypeFromBranchSchema(schema?: string | null): LensPerspectiveType;
71
- export declare function migrateBranchToLens(args: {
71
+ declare function inferLensPerspectiveTypeFromBranchSchema(schema?: string | null): LensPerspectiveType;
72
+ declare function migrateBranchToLens(args: {
72
73
  name: string;
73
74
  description?: string;
74
75
  topicId?: string;
75
76
  workspaceId?: string;
76
77
  schema?: string | null;
77
78
  }): LensBranchMigrationSuggestion;
78
- export declare function buildDeprecatedBranchMetadata(args: {
79
+ declare function buildDeprecatedBranchMetadata(args: {
79
80
  name: string;
80
81
  description?: string;
81
82
  topicId?: string;
82
83
  workspaceId?: string;
83
84
  schema?: string | null;
84
85
  }): DeprecatedBranchMetadata;
85
- //# sourceMappingURL=lens-workflow.contract.d.ts.map
86
+
87
+ export { BRANCH_DEPRECATION_MESSAGE, type DeprecatedBranchMetadata, LENS_PERSPECTIVE_TYPES, LENS_STATUSES, LENS_TASK_TEMPLATE_PRIORITIES, type LensBranchMigrationSuggestion, type LensLooseMetadata, type LensPerspectiveType, type LensPromptTemplateReference, type LensQuestionTemplate, type LensStatus, type LensTaskTemplate, type LensTaskTemplatePriority, type LensWorkflowStepTemplate, type LensWorkflowTemplate, buildDeprecatedBranchMetadata, inferLensPerspectiveTypeFromBranchSchema, migrateBranchToLens };
@@ -1,55 +1,123 @@
1
- /**
2
- * Canonical lens workflow contract shared across schema, SDK, and MCP surfaces.
3
- */
4
- export { validateFilterCriteria, isLensFilterCriteria, isTaxonomyFilterCriteriaV1, } from "./lens-filter.contract";
5
- export const LENS_PERSPECTIVE_TYPES = [
6
- "investigation",
7
- "monitoring",
8
- "analysis",
9
- "comparison",
10
- "taxonomy",
11
- ];
12
- export const LENS_STATUSES = ["draft", "active", "archived"];
13
- export const LENS_TASK_TEMPLATE_PRIORITIES = [
14
- "critical",
15
- "high",
16
- "medium",
17
- "low",
18
- ];
19
- export const BRANCH_DEPRECATION_MESSAGE = "Branches are deprecated for operational framing. Create a workspace-scoped lens instead.";
20
- export function inferLensPerspectiveTypeFromBranchSchema(schema) {
21
- const normalized = schema?.trim().toLowerCase();
22
- if (normalized === "phase") {
23
- return "monitoring";
1
+ // src/lens-filter.contract.ts
2
+ function isLensFilterCriteria(value) {
3
+ if (!value || typeof value !== "object") return false;
4
+ const obj = value;
5
+ return typeof obj.version === "number" && typeof obj.kind === "string";
6
+ }
7
+ function isTaxonomyFilterCriteriaV1(value) {
8
+ if (!isLensFilterCriteria(value)) return false;
9
+ return value.version === 1 && value.kind === "taxonomy";
10
+ }
11
+ function validateFilterCriteria(value) {
12
+ if (value === void 0 || value === null) {
13
+ return { valid: true };
14
+ }
15
+ if (!isLensFilterCriteria(value)) {
16
+ return {
17
+ valid: false,
18
+ errors: [
19
+ 'filterCriteria must have numeric "version" and string "kind" fields'
20
+ ]
21
+ };
22
+ }
23
+ if (isTaxonomyFilterCriteriaV1(value)) {
24
+ return validateTaxonomyFilterV1(value);
25
+ }
26
+ const raw = value;
27
+ return {
28
+ valid: false,
29
+ errors: [
30
+ `Unsupported filter criteria: version=${raw.version}, kind=${raw.kind}`
31
+ ]
32
+ };
33
+ }
34
+ function validateTaxonomyFilterV1(criteria) {
35
+ const errors = [];
36
+ if (!Array.isArray(criteria.entityTypeFilters)) {
37
+ errors.push("entityTypeFilters must be an array");
38
+ return { valid: false, errors };
39
+ }
40
+ if (criteria.entityTypeFilters.length === 0) {
41
+ errors.push("entityTypeFilters must contain at least one entry");
42
+ return { valid: false, errors };
43
+ }
44
+ for (let i = 0; i < criteria.entityTypeFilters.length; i++) {
45
+ const filter = criteria.entityTypeFilters[i];
46
+ if (!filter || typeof filter.entityTypeValue !== "string") {
47
+ errors.push(
48
+ `entityTypeFilters[${i}].entityTypeValue must be a non-empty string`
49
+ );
50
+ continue;
51
+ }
52
+ if (filter.entityTypeValue.trim().length === 0) {
53
+ errors.push(
54
+ `entityTypeFilters[${i}].entityTypeValue must be a non-empty string`
55
+ );
24
56
  }
25
- if (normalized === "axis" || normalized === "dimension") {
26
- return "comparison";
57
+ if (filter.subtypeValues !== void 0 && !Array.isArray(filter.subtypeValues)) {
58
+ errors.push(`entityTypeFilters[${i}].subtypeValues must be an array`);
27
59
  }
28
- if (normalized === "track") {
29
- return "investigation";
60
+ }
61
+ if (criteria.ontologyScope !== void 0) {
62
+ if (typeof criteria.ontologyScope !== "object" || criteria.ontologyScope === null) {
63
+ errors.push("ontologyScope must be an object");
30
64
  }
31
- return "analysis";
65
+ }
66
+ return errors.length === 0 ? { valid: true } : { valid: false, errors };
32
67
  }
33
- export function migrateBranchToLens(args) {
34
- const perspectiveType = inferLensPerspectiveTypeFromBranchSchema(args.schema);
35
- return {
36
- recommendedTool: "create_lens",
37
- perspectiveType,
38
- message: "Branches are deprecated for operational framing. Create a workspace-scoped lens with the suggested payload instead.",
39
- suggestedPayload: {
40
- name: args.name,
41
- description: args.description,
42
- topicId: args.topicId,
43
- workspaceId: args.workspaceId,
44
- perspectiveType,
45
- },
46
- };
68
+
69
+ // src/lens-workflow.contract.ts
70
+ var LENS_PERSPECTIVE_TYPES = [
71
+ "investigation",
72
+ "monitoring",
73
+ "analysis",
74
+ "comparison",
75
+ "taxonomy"
76
+ ];
77
+ var LENS_STATUSES = ["draft", "active", "archived"];
78
+ var LENS_TASK_TEMPLATE_PRIORITIES = [
79
+ "critical",
80
+ "high",
81
+ "medium",
82
+ "low"
83
+ ];
84
+ var BRANCH_DEPRECATION_MESSAGE = "Branches are deprecated for operational framing. Create a workspace-scoped lens instead.";
85
+ function inferLensPerspectiveTypeFromBranchSchema(schema) {
86
+ const normalized = schema?.trim().toLowerCase();
87
+ if (normalized === "phase") {
88
+ return "monitoring";
89
+ }
90
+ if (normalized === "axis" || normalized === "dimension") {
91
+ return "comparison";
92
+ }
93
+ if (normalized === "track") {
94
+ return "investigation";
95
+ }
96
+ return "analysis";
47
97
  }
48
- export function buildDeprecatedBranchMetadata(args) {
49
- return {
50
- deprecated: true,
51
- deprecationMessage: BRANCH_DEPRECATION_MESSAGE,
52
- lensSuggestion: migrateBranchToLens(args),
53
- };
98
+ function migrateBranchToLens(args) {
99
+ const perspectiveType = inferLensPerspectiveTypeFromBranchSchema(args.schema);
100
+ return {
101
+ recommendedTool: "create_lens",
102
+ perspectiveType,
103
+ message: "Branches are deprecated for operational framing. Create a workspace-scoped lens with the suggested payload instead.",
104
+ suggestedPayload: {
105
+ name: args.name,
106
+ description: args.description,
107
+ topicId: args.topicId,
108
+ workspaceId: args.workspaceId,
109
+ perspectiveType
110
+ }
111
+ };
112
+ }
113
+ function buildDeprecatedBranchMetadata(args) {
114
+ return {
115
+ deprecated: true,
116
+ deprecationMessage: BRANCH_DEPRECATION_MESSAGE,
117
+ lensSuggestion: migrateBranchToLens(args)
118
+ };
54
119
  }
120
+
121
+ export { BRANCH_DEPRECATION_MESSAGE, LENS_PERSPECTIVE_TYPES, LENS_STATUSES, LENS_TASK_TEMPLATE_PRIORITIES, buildDeprecatedBranchMetadata, inferLensPerspectiveTypeFromBranchSchema, isLensFilterCriteria, isTaxonomyFilterCriteriaV1, migrateBranchToLens, validateFilterCriteria };
122
+ //# sourceMappingURL=lens-workflow.contract.js.map
55
123
  //# sourceMappingURL=lens-workflow.contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lens-workflow.contract.js","sourceRoot":"","sources":["../src/lens-workflow.contract.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,eAAe;IACf,YAAY;IACZ,UAAU;IACV,YAAY;IACZ,UAAU;CACF,CAAC;AAIX,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAC;AAItE,MAAM,CAAC,MAAM,6BAA6B,GAA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AA;AAAA,IACpB,cAAA,EAAgB,oBAAoB,IAAI;AAAA,GAC1C;AACF","file":"lens-workflow.contract.js","sourcesContent":["/**\n * Lens Filter Criteria Contract\n *\n * Version-discriminated filter DSL for lenses. Each filter criteria document\n * carries a `version` and `kind` discriminator so future shapes can coexist\n * without schema migrations. The Convex `filterCriteria` field remains v.any()\n * — all type enforcement happens here at the TypeScript contract layer.\n *\n * Forward-compatibility guarantees:\n * - `version` field: new versions add fields, never remove or rename existing ones\n * - `kind` field: new filter kinds (temporal, confidence-range) can be added\n * without touching taxonomy code paths\n * - `entityTypeFilters` array items are open to extension in future versions\n * - Resolution logic switches on `version` + `kind` to select the right resolver\n *\n * @module lucern/contracts/src/lens-filter\n */\n\n// ---------------------------------------------------------------------------\n// V1: Taxonomy Filter — entity type + subtype matching\n// ---------------------------------------------------------------------------\n\n/**\n * A single entity type filter entry. Matches nodes whose `nodeType` equals\n * `entityTypeValue`, optionally further narrowed by subtype membership.\n *\n * V2 will add `propertyMatchers` here for arbitrary JSON Schema facet queries.\n */\nexport type EntityTypeFilterV1 = {\n /** References ontologyVersion.entityTypes[].value, e.g. \"company\" */\n entityTypeValue: string;\n\n /** Optional subtype narrowing. If omitted or empty, all subtypes match. */\n subtypeValues?: string[];\n};\n\n/**\n * Optional scope to restrict which ontology the filter resolves against.\n * If omitted, resolution uses whatever ontology is active in the workspace.\n */\nexport type OntologyScope = {\n /** Restrict to a specific ontology by key, e.g. \"vc-investment\" */\n ontologyKey?: string;\n};\n\n/**\n * Taxonomy filter criteria v1: entity type + subtype matching over ontology.\n */\nexport type TaxonomyFilterCriteriaV1 = {\n version: 1;\n kind: \"taxonomy\";\n entityTypeFilters: EntityTypeFilterV1[];\n ontologyScope?: OntologyScope;\n};\n\n// ---------------------------------------------------------------------------\n// Union: All filter criteria versions and kinds\n// ---------------------------------------------------------------------------\n\n/**\n * Discriminated union of all supported filter criteria.\n * Resolution logic switches on `version` + `kind`.\n *\n * To add a new filter kind:\n * 1. Define a new type (e.g., TemporalFilterCriteriaV1)\n * 2. Add it to this union\n * 3. Add a resolver in taxonomy-filter.ts\n * 4. No schema migration needed — filterCriteria is v.any()\n */\nexport type LensFilterCriteria = TaxonomyFilterCriteriaV1;\n// Future: | TemporalFilterCriteriaV1 | ConfidenceRangeFilterCriteriaV1 | ...\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport function isLensFilterCriteria(\n value: unknown\n): value is LensFilterCriteria {\n if (!value || typeof value !== \"object\") return false;\n const obj = value as Record<string, unknown>;\n return typeof obj.version === \"number\" && typeof obj.kind === \"string\";\n}\n\nexport function isTaxonomyFilterCriteriaV1(\n value: unknown\n): value is TaxonomyFilterCriteriaV1 {\n if (!isLensFilterCriteria(value)) return false;\n return value.version === 1 && value.kind === \"taxonomy\";\n}\n\n// ---------------------------------------------------------------------------\n// Validation\n// ---------------------------------------------------------------------------\n\nexport type FilterValidationResult =\n | { valid: true }\n | { valid: false; errors: string[] };\n\n/**\n * Validate a filter criteria document at the contract layer.\n * This runs before persisting to Convex.\n */\nexport function validateFilterCriteria(\n value: unknown\n): FilterValidationResult {\n if (value === undefined || value === null) {\n return { valid: true }; // filterCriteria is optional\n }\n\n if (!isLensFilterCriteria(value)) {\n return {\n valid: false,\n errors: [\n 'filterCriteria must have numeric \"version\" and string \"kind\" fields',\n ],\n };\n }\n\n if (isTaxonomyFilterCriteriaV1(value)) {\n return validateTaxonomyFilterV1(value);\n }\n\n // Cast to access properties — TypeScript narrows to `never` when all union\n // members are exhausted, but at runtime unknown version/kind combos are possible.\n const raw = value as { version: number; kind: string };\n return {\n valid: false,\n errors: [\n `Unsupported filter criteria: version=${raw.version}, kind=${raw.kind}`,\n ],\n };\n}\n\nfunction validateTaxonomyFilterV1(\n criteria: TaxonomyFilterCriteriaV1\n): FilterValidationResult {\n const errors: string[] = [];\n\n if (!Array.isArray(criteria.entityTypeFilters)) {\n errors.push(\"entityTypeFilters must be an array\");\n return { valid: false, errors };\n }\n\n if (criteria.entityTypeFilters.length === 0) {\n errors.push(\"entityTypeFilters must contain at least one entry\");\n return { valid: false, errors };\n }\n\n for (let i = 0; i < criteria.entityTypeFilters.length; i++) {\n const filter = criteria.entityTypeFilters[i];\n if (!filter || typeof filter.entityTypeValue !== \"string\") {\n errors.push(\n `entityTypeFilters[${i}].entityTypeValue must be a non-empty string`\n );\n continue;\n }\n if (filter.entityTypeValue.trim().length === 0) {\n errors.push(\n `entityTypeFilters[${i}].entityTypeValue must be a non-empty string`\n );\n }\n if (\n filter.subtypeValues !== undefined &&\n !Array.isArray(filter.subtypeValues)\n ) {\n errors.push(`entityTypeFilters[${i}].subtypeValues must be an array`);\n }\n }\n\n if (criteria.ontologyScope !== undefined) {\n if (\n typeof criteria.ontologyScope !== \"object\" ||\n criteria.ontologyScope === null\n ) {\n errors.push(\"ontologyScope must be an object\");\n }\n }\n\n return errors.length === 0\n ? { valid: true }\n : { valid: false, errors };\n}\n","/**\n * Canonical lens workflow contract shared across schema, SDK, and MCP surfaces.\n */\n\n// Re-export filter criteria types for consumers who import from lens-workflow\nexport type {\n LensFilterCriteria,\n TaxonomyFilterCriteriaV1,\n EntityTypeFilterV1,\n OntologyScope,\n FilterValidationResult,\n} from \"./lens-filter.contract\";\nexport {\n validateFilterCriteria,\n isLensFilterCriteria,\n isTaxonomyFilterCriteriaV1,\n} from \"./lens-filter.contract\";\n\nexport const LENS_PERSPECTIVE_TYPES = [\n \"investigation\",\n \"monitoring\",\n \"analysis\",\n \"comparison\",\n \"taxonomy\",\n] as const;\n\nexport type LensPerspectiveType = (typeof LENS_PERSPECTIVE_TYPES)[number];\n\nexport const LENS_STATUSES = [\"draft\", \"active\", \"archived\"] as const;\n\nexport type LensStatus = (typeof LENS_STATUSES)[number];\n\nexport const LENS_TASK_TEMPLATE_PRIORITIES = [\n \"critical\",\n \"high\",\n \"medium\",\n \"low\",\n] as const;\n\nexport type LensTaskTemplatePriority =\n (typeof LENS_TASK_TEMPLATE_PRIORITIES)[number];\n\nexport type LensLooseMetadata = Record<string, unknown>;\n\nexport type LensPromptTemplateReference = {\n key: string;\n promptRef: string;\n phase?: string;\n role?: string;\n version?: string;\n required?: boolean;\n metadata?: LensLooseMetadata;\n};\n\nexport type LensWorkflowStepTemplate = {\n key: string;\n title: string;\n description?: string;\n promptTemplateKey?: string;\n taskTemplateKeys?: string[];\n metadata?: LensLooseMetadata;\n};\n\nexport type LensWorkflowTemplate = {\n key: string;\n name: string;\n description?: string;\n steps: LensWorkflowStepTemplate[];\n metadata?: LensLooseMetadata;\n};\n\nexport type LensTaskTemplate = {\n key: string;\n title: string;\n description?: string;\n priority?: LensTaskTemplatePriority;\n phase?: string;\n metadata?: LensLooseMetadata;\n};\n\nexport type LensQuestionTemplate = {\n key: string;\n text: string;\n priority?: LensTaskTemplatePriority;\n linkedBeliefKey?: string;\n metadata?: LensLooseMetadata;\n};\n\nexport type LensBranchMigrationSuggestion = {\n recommendedTool: \"create_lens\";\n perspectiveType: LensPerspectiveType;\n message: string;\n suggestedPayload: {\n name: string;\n description?: string;\n topicId?: string;\n workspaceId?: string;\n perspectiveType: LensPerspectiveType;\n };\n};\n\nexport const BRANCH_DEPRECATION_MESSAGE =\n \"Branches are deprecated for operational framing. Create a workspace-scoped lens instead.\";\n\nexport type DeprecatedBranchMetadata = {\n deprecated: true;\n deprecationMessage: string;\n lensSuggestion: LensBranchMigrationSuggestion;\n};\n\nexport function inferLensPerspectiveTypeFromBranchSchema(\n schema?: string | null\n): LensPerspectiveType {\n const normalized = schema?.trim().toLowerCase();\n if (normalized === \"phase\") {\n return \"monitoring\";\n }\n if (normalized === \"axis\" || normalized === \"dimension\") {\n return \"comparison\";\n }\n if (normalized === \"track\") {\n return \"investigation\";\n }\n return \"analysis\";\n}\n\nexport function migrateBranchToLens(args: {\n name: string;\n description?: string;\n topicId?: string;\n workspaceId?: string;\n schema?: string | null;\n}): LensBranchMigrationSuggestion {\n const perspectiveType = inferLensPerspectiveTypeFromBranchSchema(args.schema);\n return {\n recommendedTool: \"create_lens\",\n perspectiveType,\n message:\n \"Branches are deprecated for operational framing. Create a workspace-scoped lens with the suggested payload instead.\",\n suggestedPayload: {\n name: args.name,\n description: args.description,\n topicId: args.topicId,\n workspaceId: args.workspaceId,\n perspectiveType,\n },\n };\n}\n\nexport function buildDeprecatedBranchMetadata(args: {\n name: string;\n description?: string;\n topicId?: string;\n workspaceId?: string;\n schema?: string | null;\n}): DeprecatedBranchMetadata {\n return {\n deprecated: true,\n deprecationMessage: BRANCH_DEPRECATION_MESSAGE,\n lensSuggestion: migrateBranchToLens(args),\n };\n}\n"]}