@lucern/sdk 0.2.0-alpha.6 → 0.2.0-alpha.7

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 (206) hide show
  1. package/.turbo/turbo-build.log +7 -0
  2. package/.turbo/turbo-typecheck.log +4 -0
  3. package/CHANGELOG.md +13 -0
  4. package/examples/README.md +69 -0
  5. package/examples/contradiction.ts +94 -0
  6. package/examples/investigation-context.ts +118 -0
  7. package/examples/questions-and-tasks.ts +55 -0
  8. package/examples/quickstart.ts +97 -0
  9. package/examples/shared.ts +318 -0
  10. package/examples/strict-public-types.ts +143 -0
  11. package/examples/worktree-lifecycle.ts +79 -0
  12. package/package.json +16 -58
  13. package/src/README.md +6 -0
  14. package/src/adminClient.ts +789 -0
  15. package/{dist/lib/platform/sdk/answersClient.d.ts → src/answersClient.ts} +17 -4
  16. package/src/audiencesClient.ts +209 -0
  17. package/src/auditClient.ts +50 -0
  18. package/src/beliefsClient.ts +319 -0
  19. package/src/client.ts +2647 -0
  20. package/src/contextClient.ts +130 -0
  21. package/{dist/lib/platform/sdk/contextFacade.d.ts → src/contextFacade.ts} +6 -1
  22. package/src/contextPackCompiler.ts +828 -0
  23. package/src/contextPackSchema.ts +251 -0
  24. package/src/contextTypes.ts +153 -0
  25. package/src/contracts/api-enums.contract.ts +202 -0
  26. package/src/contracts/auth-session.contract.ts +109 -0
  27. package/src/contracts/context-pack.contract.ts +700 -0
  28. package/src/contracts/contextPack.ts +1 -0
  29. package/src/contracts/index.ts +10 -0
  30. package/src/contracts/lens-filter.contract.ts +183 -0
  31. package/src/contracts/lens-workflow.contract.ts +162 -0
  32. package/src/contracts/lensFilter.ts +1 -0
  33. package/src/contracts/lensWorkflow.ts +1 -0
  34. package/src/contracts/mcp-tools.contract.ts +3636 -0
  35. package/src/contracts/mcpTools.ts +1 -0
  36. package/src/contracts/prompt.contract.ts +50 -0
  37. package/src/contracts/prompt.ts +1 -0
  38. package/src/contracts/sdk-tools.contract.ts +1457 -0
  39. package/src/contracts/sdkTools.ts +1 -0
  40. package/src/contracts/workflow-runtime.contract.ts +440 -0
  41. package/src/contracts/workflowRuntime.ts +1 -0
  42. package/src/controlObjectOwnership.ts +286 -0
  43. package/src/coreClient.ts +570 -0
  44. package/src/customTools.ts +398 -0
  45. package/src/decisionsClient.ts +286 -0
  46. package/src/domainContext.ts +15 -0
  47. package/src/events.ts +531 -0
  48. package/src/eventsCore.ts +168 -0
  49. package/src/facade/beliefs.ts +83 -0
  50. package/src/facade/context.ts +110 -0
  51. package/src/facade/contradictions.ts +29 -0
  52. package/src/facade/edges.ts +30 -0
  53. package/src/facade/events.ts +23 -0
  54. package/src/facade/evidence.ts +41 -0
  55. package/src/facade/graph.ts +38 -0
  56. package/src/facade/identity.ts +16 -0
  57. package/src/facade/ontologies.ts +34 -0
  58. package/src/facade/questions.ts +59 -0
  59. package/src/facade/search.ts +16 -0
  60. package/src/facade/tasks.ts +37 -0
  61. package/src/facade/topics.ts +42 -0
  62. package/src/facade/webhooks.ts +58 -0
  63. package/src/facade/worktrees.ts +51 -0
  64. package/src/gatewayFacades.ts +1666 -0
  65. package/src/graphClient.ts +529 -0
  66. package/src/harnessClient.ts +585 -0
  67. package/src/identityClient.ts +278 -0
  68. package/src/learningClient.ts +95 -0
  69. package/src/mcpParityClient.ts +240 -0
  70. package/src/mcpParitySurface.ts +70 -0
  71. package/src/ontologyClient.ts +275 -0
  72. package/src/packRuntime.ts +3 -0
  73. package/src/packsClient.ts +260 -0
  74. package/src/policyClient.ts +572 -0
  75. package/src/realtime/index.ts +51 -0
  76. package/src/realtime/refs.ts +17 -0
  77. package/src/reportsClient.ts +99 -0
  78. package/src/schemaClient.ts +129 -0
  79. package/src/sdkSurface.ts +190 -0
  80. package/src/topicsClient.ts +243 -0
  81. package/src/types.ts +807 -0
  82. package/src/workflowClient.ts +826 -0
  83. package/tsconfig.json +9 -0
  84. package/dist/.generated +0 -2
  85. package/dist/index.d.ts +0 -3
  86. package/dist/index.js +0 -3
  87. package/dist/lib/platform/auth/credentials.d.ts +0 -5
  88. package/dist/lib/platform/auth/credentials.js +0 -40
  89. package/dist/lib/platform/sdk/adminClient.d.ts +0 -404
  90. package/dist/lib/platform/sdk/adminClient.js +0 -384
  91. package/dist/lib/platform/sdk/answersClient.js +0 -21
  92. package/dist/lib/platform/sdk/audiencesClient.d.ts +0 -93
  93. package/dist/lib/platform/sdk/audiencesClient.js +0 -111
  94. package/dist/lib/platform/sdk/auditClient.d.ts +0 -24
  95. package/dist/lib/platform/sdk/auditClient.js +0 -21
  96. package/dist/lib/platform/sdk/beliefsClient.d.ts +0 -157
  97. package/dist/lib/platform/sdk/beliefsClient.js +0 -124
  98. package/dist/lib/platform/sdk/client.d.ts +0 -2369
  99. package/dist/lib/platform/sdk/client.js +0 -1831
  100. package/dist/lib/platform/sdk/contextClient.d.ts +0 -21
  101. package/dist/lib/platform/sdk/contextClient.js +0 -86
  102. package/dist/lib/platform/sdk/contextFacade.js +0 -10
  103. package/dist/lib/platform/sdk/contextPackCompiler.d.ts +0 -100
  104. package/dist/lib/platform/sdk/contextPackCompiler.js +0 -534
  105. package/dist/lib/platform/sdk/contextTypes.d.ts +0 -133
  106. package/dist/lib/platform/sdk/contextTypes.js +0 -1
  107. package/dist/lib/platform/sdk/controlObjectOwnership.d.ts +0 -308
  108. package/dist/lib/platform/sdk/controlObjectOwnership.js +0 -220
  109. package/dist/lib/platform/sdk/coreClient.d.ts +0 -139
  110. package/dist/lib/platform/sdk/coreClient.js +0 -366
  111. package/dist/lib/platform/sdk/customTools.d.ts +0 -83
  112. package/dist/lib/platform/sdk/customTools.js +0 -247
  113. package/dist/lib/platform/sdk/decisionsClient.d.ts +0 -106
  114. package/dist/lib/platform/sdk/decisionsClient.js +0 -129
  115. package/dist/lib/platform/sdk/domainContext.d.ts +0 -1
  116. package/dist/lib/platform/sdk/domainContext.js +0 -1
  117. package/dist/lib/platform/sdk/events.d.ts +0 -176
  118. package/dist/lib/platform/sdk/events.js +0 -261
  119. package/dist/lib/platform/sdk/eventsCore.d.ts +0 -13
  120. package/dist/lib/platform/sdk/eventsCore.js +0 -13
  121. package/dist/lib/platform/sdk/gatewayFacades.d.ts +0 -586
  122. package/dist/lib/platform/sdk/gatewayFacades.js +0 -845
  123. package/dist/lib/platform/sdk/graphClient.d.ts +0 -266
  124. package/dist/lib/platform/sdk/graphClient.js +0 -235
  125. package/dist/lib/platform/sdk/harnessClient.d.ts +0 -309
  126. package/dist/lib/platform/sdk/harnessClient.js +0 -219
  127. package/dist/lib/platform/sdk/identityClient.d.ts +0 -134
  128. package/dist/lib/platform/sdk/identityClient.js +0 -131
  129. package/dist/lib/platform/sdk/index.js +0 -49
  130. package/dist/lib/platform/sdk/learningClient.d.ts +0 -40
  131. package/dist/lib/platform/sdk/learningClient.js +0 -53
  132. package/dist/lib/platform/sdk/mcpParityClient.d.ts +0 -69
  133. package/dist/lib/platform/sdk/mcpParityClient.js +0 -196
  134. package/dist/lib/platform/sdk/mcpParitySurface.d.ts +0 -10
  135. package/dist/lib/platform/sdk/mcpParitySurface.js +0 -57
  136. package/dist/lib/platform/sdk/ontologyClient.d.ts +0 -131
  137. package/dist/lib/platform/sdk/ontologyClient.js +0 -161
  138. package/dist/lib/platform/sdk/packRuntime.d.ts +0 -1
  139. package/dist/lib/platform/sdk/packRuntime.js +0 -1
  140. package/dist/lib/platform/sdk/packsClient.d.ts +0 -126
  141. package/dist/lib/platform/sdk/packsClient.js +0 -157
  142. package/dist/lib/platform/sdk/policyClient.d.ts +0 -293
  143. package/dist/lib/platform/sdk/policyClient.js +0 -277
  144. package/dist/lib/platform/sdk/promptCatalog.js +0 -1
  145. package/dist/lib/platform/sdk/reportsClient.d.ts +0 -34
  146. package/dist/lib/platform/sdk/reportsClient.js +0 -64
  147. package/dist/lib/platform/sdk/schemaClient.d.ts +0 -59
  148. package/dist/lib/platform/sdk/schemaClient.js +0 -71
  149. package/dist/lib/platform/sdk/sdkSurface.d.ts +0 -56
  150. package/dist/lib/platform/sdk/sdkSurface.js +0 -140
  151. package/dist/lib/platform/sdk/topicsClient.d.ts +0 -78
  152. package/dist/lib/platform/sdk/topicsClient.js +0 -118
  153. package/dist/lib/platform/sdk/types.d.ts +0 -692
  154. package/dist/lib/platform/sdk/types.js +0 -1
  155. package/dist/lib/platform/sdk/version.d.ts +0 -2
  156. package/dist/lib/platform/sdk/workflowClient.d.ts +0 -313
  157. package/dist/lib/platform/sdk/workflowClient.js +0 -366
  158. package/dist/lucern/contracts/src/api-enums.contract.d.ts +0 -58
  159. package/dist/lucern/contracts/src/api-enums.contract.js +0 -147
  160. package/dist/lucern/contracts/src/auth-context.contract.d.ts +0 -8
  161. package/dist/lucern/contracts/src/auth-context.contract.js +0 -8
  162. package/dist/lucern/contracts/src/auth-session.contract.d.ts +0 -8
  163. package/dist/lucern/contracts/src/auth-session.contract.js +0 -8
  164. package/dist/lucern/contracts/src/auth.contract.d.ts +0 -88
  165. package/dist/lucern/contracts/src/auth.contract.js +0 -57
  166. package/dist/lucern/contracts/src/context-pack.contract.d.ts +0 -494
  167. package/dist/lucern/contracts/src/context-pack.contract.js +0 -169
  168. package/dist/lucern/contracts/src/convex-admin.contract.d.ts +0 -5
  169. package/dist/lucern/contracts/src/convex-admin.contract.js +0 -1
  170. package/dist/lucern/contracts/src/events-types.contract.d.ts +0 -8
  171. package/dist/lucern/contracts/src/events-types.contract.js +0 -8
  172. package/dist/lucern/contracts/src/events.contract.d.ts +0 -176
  173. package/dist/lucern/contracts/src/events.contract.js +0 -159
  174. package/dist/lucern/contracts/src/gateway.contract.d.ts +0 -74
  175. package/dist/lucern/contracts/src/gateway.contract.js +0 -19
  176. package/dist/lucern/contracts/src/ids.contract.d.ts +0 -7
  177. package/dist/lucern/contracts/src/ids.contract.js +0 -24
  178. package/dist/lucern/contracts/src/index.d.ts +0 -29
  179. package/dist/lucern/contracts/src/index.js +0 -29
  180. package/dist/lucern/contracts/src/lens-filter.contract.d.ts +0 -70
  181. package/dist/lucern/contracts/src/lens-filter.contract.js +0 -95
  182. package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +0 -84
  183. package/dist/lucern/contracts/src/lens-workflow.contract.js +0 -54
  184. package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +0 -151
  185. package/dist/lucern/contracts/src/mcp-tools.contract.js +0 -3281
  186. package/dist/lucern/contracts/src/ontology-matching.contract.d.ts +0 -8
  187. package/dist/lucern/contracts/src/ontology-matching.contract.js +0 -8
  188. package/dist/lucern/contracts/src/prompt.contract.d.ts +0 -24
  189. package/dist/lucern/contracts/src/prompt.contract.js +0 -24
  190. package/dist/lucern/contracts/src/sdk-methods.contract.d.ts +0 -358
  191. package/dist/lucern/contracts/src/sdk-methods.contract.js +0 -19
  192. package/dist/lucern/contracts/src/sdk-tools.contract.d.ts +0 -92
  193. package/dist/lucern/contracts/src/sdk-tools.contract.js +0 -1398
  194. package/dist/lucern/contracts/src/text-matching.contract.d.ts +0 -53
  195. package/dist/lucern/contracts/src/text-matching.contract.js +0 -277
  196. package/dist/lucern/contracts/src/topic-scope.contract.d.ts +0 -8
  197. package/dist/lucern/contracts/src/topic-scope.contract.js +0 -8
  198. package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +0 -161
  199. package/dist/lucern/contracts/src/workflow-runtime.contract.js +0 -257
  200. package/dist/realtime-refs.d.ts +0 -1
  201. package/dist/realtime-refs.js +0 -1
  202. package/dist/realtime.d.ts +0 -1
  203. package/dist/realtime.js +0 -1
  204. /package/{dist/lib/platform/sdk/index.d.ts → src/index.ts} +0 -0
  205. /package/{dist/lib/platform/sdk/promptCatalog.d.ts → src/promptCatalog.ts} +0 -0
  206. /package/{dist/lib/platform/sdk/version.js → src/version.ts} +0 -0
@@ -0,0 +1,10 @@
1
+ export * from "./api-enums.contract";
2
+ export * from "./auth-session.contract";
3
+ export * from "./contextPack";
4
+ export * from "./lensFilter";
5
+ export * from "./lensWorkflow";
6
+ export * from "./mcpTools";
7
+ export * as mcpToolsContract from "./mcp-tools.contract";
8
+ export * from "./prompt";
9
+ export * as sdkToolsContract from "./sdk-tools.contract";
10
+ export * from "./workflowRuntime";
@@ -0,0 +1,183 @@
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
+
19
+ // ---------------------------------------------------------------------------
20
+ // V1: Taxonomy Filter — entity type + subtype matching
21
+ // ---------------------------------------------------------------------------
22
+
23
+ /**
24
+ * A single entity type filter entry. Matches nodes whose `nodeType` equals
25
+ * `entityTypeValue`, optionally further narrowed by subtype membership.
26
+ *
27
+ * V2 will add `propertyMatchers` here for arbitrary JSON Schema facet queries.
28
+ */
29
+ export type EntityTypeFilterV1 = {
30
+ /** References ontologyVersion.entityTypes[].value, e.g. "company" */
31
+ entityTypeValue: string;
32
+
33
+ /** Optional subtype narrowing. If omitted or empty, all subtypes match. */
34
+ subtypeValues?: string[];
35
+ };
36
+
37
+ /**
38
+ * Optional scope to restrict which ontology the filter resolves against.
39
+ * If omitted, resolution uses whatever ontology is active in the workspace.
40
+ */
41
+ export type OntologyScope = {
42
+ /** Restrict to a specific ontology by key, e.g. "vc-investment" */
43
+ ontologyKey?: string;
44
+ };
45
+
46
+ /**
47
+ * Taxonomy filter criteria v1: entity type + subtype matching over ontology.
48
+ */
49
+ export type TaxonomyFilterCriteriaV1 = {
50
+ version: 1;
51
+ kind: "taxonomy";
52
+ entityTypeFilters: EntityTypeFilterV1[];
53
+ ontologyScope?: OntologyScope;
54
+ };
55
+
56
+ // ---------------------------------------------------------------------------
57
+ // Union: All filter criteria versions and kinds
58
+ // ---------------------------------------------------------------------------
59
+
60
+ /**
61
+ * Discriminated union of all supported filter criteria.
62
+ * Resolution logic switches on `version` + `kind`.
63
+ *
64
+ * To add a new filter kind:
65
+ * 1. Define a new type (e.g., TemporalFilterCriteriaV1)
66
+ * 2. Add it to this union
67
+ * 3. Add a resolver in taxonomy-filter.ts
68
+ * 4. No schema migration needed — filterCriteria is v.any()
69
+ */
70
+ export type LensFilterCriteria = TaxonomyFilterCriteriaV1;
71
+ // Future: | TemporalFilterCriteriaV1 | ConfidenceRangeFilterCriteriaV1 | ...
72
+
73
+ // ---------------------------------------------------------------------------
74
+ // Type guards
75
+ // ---------------------------------------------------------------------------
76
+
77
+ export function isLensFilterCriteria(
78
+ value: unknown
79
+ ): value is LensFilterCriteria {
80
+ if (!value || typeof value !== "object") return false;
81
+ const obj = value as Record<string, unknown>;
82
+ return typeof obj.version === "number" && typeof obj.kind === "string";
83
+ }
84
+
85
+ export function isTaxonomyFilterCriteriaV1(
86
+ value: unknown
87
+ ): value is TaxonomyFilterCriteriaV1 {
88
+ if (!isLensFilterCriteria(value)) return false;
89
+ return value.version === 1 && value.kind === "taxonomy";
90
+ }
91
+
92
+ // ---------------------------------------------------------------------------
93
+ // Validation
94
+ // ---------------------------------------------------------------------------
95
+
96
+ export type FilterValidationResult =
97
+ | { valid: true }
98
+ | { valid: false; errors: string[] };
99
+
100
+ /**
101
+ * Validate a filter criteria document at the contract layer.
102
+ * This runs before persisting to Convex.
103
+ */
104
+ export function validateFilterCriteria(
105
+ value: unknown
106
+ ): FilterValidationResult {
107
+ if (value === undefined || value === null) {
108
+ return { valid: true }; // filterCriteria is optional
109
+ }
110
+
111
+ if (!isLensFilterCriteria(value)) {
112
+ return {
113
+ valid: false,
114
+ errors: [
115
+ 'filterCriteria must have numeric "version" and string "kind" fields',
116
+ ],
117
+ };
118
+ }
119
+
120
+ if (isTaxonomyFilterCriteriaV1(value)) {
121
+ return validateTaxonomyFilterV1(value);
122
+ }
123
+
124
+ // Cast to access properties — TypeScript narrows to `never` when all union
125
+ // members are exhausted, but at runtime unknown version/kind combos are possible.
126
+ const raw = value as { version: number; kind: string };
127
+ return {
128
+ valid: false,
129
+ errors: [
130
+ `Unsupported filter criteria: version=${raw.version}, kind=${raw.kind}`,
131
+ ],
132
+ };
133
+ }
134
+
135
+ function validateTaxonomyFilterV1(
136
+ criteria: TaxonomyFilterCriteriaV1
137
+ ): FilterValidationResult {
138
+ const errors: string[] = [];
139
+
140
+ if (!Array.isArray(criteria.entityTypeFilters)) {
141
+ errors.push("entityTypeFilters must be an array");
142
+ return { valid: false, errors };
143
+ }
144
+
145
+ if (criteria.entityTypeFilters.length === 0) {
146
+ errors.push("entityTypeFilters must contain at least one entry");
147
+ return { valid: false, errors };
148
+ }
149
+
150
+ for (let i = 0; i < criteria.entityTypeFilters.length; i++) {
151
+ const filter = criteria.entityTypeFilters[i];
152
+ if (!filter || typeof filter.entityTypeValue !== "string") {
153
+ errors.push(
154
+ `entityTypeFilters[${i}].entityTypeValue must be a non-empty string`
155
+ );
156
+ continue;
157
+ }
158
+ if (filter.entityTypeValue.trim().length === 0) {
159
+ errors.push(
160
+ `entityTypeFilters[${i}].entityTypeValue must be a non-empty string`
161
+ );
162
+ }
163
+ if (
164
+ filter.subtypeValues !== undefined &&
165
+ !Array.isArray(filter.subtypeValues)
166
+ ) {
167
+ errors.push(`entityTypeFilters[${i}].subtypeValues must be an array`);
168
+ }
169
+ }
170
+
171
+ if (criteria.ontologyScope !== undefined) {
172
+ if (
173
+ typeof criteria.ontologyScope !== "object" ||
174
+ criteria.ontologyScope === null
175
+ ) {
176
+ errors.push("ontologyScope must be an object");
177
+ }
178
+ }
179
+
180
+ return errors.length === 0
181
+ ? { valid: true }
182
+ : { valid: false, errors };
183
+ }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Canonical lens workflow contract shared across schema, SDK, and MCP surfaces.
3
+ */
4
+
5
+ // Re-export filter criteria types for consumers who import from lens-workflow
6
+ export type {
7
+ LensFilterCriteria,
8
+ TaxonomyFilterCriteriaV1,
9
+ EntityTypeFilterV1,
10
+ OntologyScope,
11
+ FilterValidationResult,
12
+ } from "./lens-filter.contract";
13
+ export {
14
+ validateFilterCriteria,
15
+ isLensFilterCriteria,
16
+ isTaxonomyFilterCriteriaV1,
17
+ } from "./lens-filter.contract";
18
+
19
+ export const LENS_PERSPECTIVE_TYPES = [
20
+ "investigation",
21
+ "monitoring",
22
+ "analysis",
23
+ "comparison",
24
+ "taxonomy",
25
+ ] as const;
26
+
27
+ export type LensPerspectiveType = (typeof LENS_PERSPECTIVE_TYPES)[number];
28
+
29
+ export const LENS_STATUSES = ["draft", "active", "archived"] as const;
30
+
31
+ export type LensStatus = (typeof LENS_STATUSES)[number];
32
+
33
+ export const LENS_TASK_TEMPLATE_PRIORITIES = [
34
+ "critical",
35
+ "high",
36
+ "medium",
37
+ "low",
38
+ ] as const;
39
+
40
+ export type LensTaskTemplatePriority =
41
+ (typeof LENS_TASK_TEMPLATE_PRIORITIES)[number];
42
+
43
+ export type LensLooseMetadata = Record<string, unknown>;
44
+
45
+ export type LensPromptTemplateReference = {
46
+ key: string;
47
+ promptRef: string;
48
+ phase?: string;
49
+ role?: string;
50
+ version?: string;
51
+ required?: boolean;
52
+ metadata?: LensLooseMetadata;
53
+ };
54
+
55
+ export type LensWorkflowStepTemplate = {
56
+ key: string;
57
+ title: string;
58
+ description?: string;
59
+ promptTemplateKey?: string;
60
+ taskTemplateKeys?: string[];
61
+ metadata?: LensLooseMetadata;
62
+ };
63
+
64
+ export type LensWorkflowTemplate = {
65
+ key: string;
66
+ name: string;
67
+ description?: string;
68
+ steps: LensWorkflowStepTemplate[];
69
+ metadata?: LensLooseMetadata;
70
+ };
71
+
72
+ export type LensTaskTemplate = {
73
+ key: string;
74
+ title: string;
75
+ description?: string;
76
+ priority?: LensTaskTemplatePriority;
77
+ phase?: string;
78
+ metadata?: LensLooseMetadata;
79
+ };
80
+
81
+ export type LensQuestionTemplate = {
82
+ key: string;
83
+ text: string;
84
+ priority?: LensTaskTemplatePriority;
85
+ linkedBeliefKey?: string;
86
+ metadata?: LensLooseMetadata;
87
+ };
88
+
89
+ export type LensBranchMigrationSuggestion = {
90
+ recommendedTool: "create_lens";
91
+ perspectiveType: LensPerspectiveType;
92
+ message: string;
93
+ suggestedPayload: {
94
+ name: string;
95
+ description?: string;
96
+ topicId?: string;
97
+ workspaceId?: string;
98
+ perspectiveType: LensPerspectiveType;
99
+ };
100
+ };
101
+
102
+ export const BRANCH_DEPRECATION_MESSAGE =
103
+ "Branches are deprecated for operational framing. Create a workspace-scoped lens instead.";
104
+
105
+ export type DeprecatedBranchMetadata = {
106
+ deprecated: true;
107
+ deprecationMessage: string;
108
+ lensSuggestion: LensBranchMigrationSuggestion;
109
+ };
110
+
111
+ export function inferLensPerspectiveTypeFromBranchSchema(
112
+ schema?: string | null
113
+ ): LensPerspectiveType {
114
+ const normalized = schema?.trim().toLowerCase();
115
+ if (normalized === "phase") {
116
+ return "monitoring";
117
+ }
118
+ if (normalized === "axis" || normalized === "dimension") {
119
+ return "comparison";
120
+ }
121
+ if (normalized === "track") {
122
+ return "investigation";
123
+ }
124
+ return "analysis";
125
+ }
126
+
127
+ export function migrateBranchToLens(args: {
128
+ name: string;
129
+ description?: string;
130
+ topicId?: string;
131
+ workspaceId?: string;
132
+ schema?: string | null;
133
+ }): LensBranchMigrationSuggestion {
134
+ const perspectiveType = inferLensPerspectiveTypeFromBranchSchema(args.schema);
135
+ return {
136
+ recommendedTool: "create_lens",
137
+ perspectiveType,
138
+ message:
139
+ "Branches are deprecated for operational framing. Create a workspace-scoped lens with the suggested payload instead.",
140
+ suggestedPayload: {
141
+ name: args.name,
142
+ description: args.description,
143
+ topicId: args.topicId,
144
+ workspaceId: args.workspaceId,
145
+ perspectiveType,
146
+ },
147
+ };
148
+ }
149
+
150
+ export function buildDeprecatedBranchMetadata(args: {
151
+ name: string;
152
+ description?: string;
153
+ topicId?: string;
154
+ workspaceId?: string;
155
+ schema?: string | null;
156
+ }): DeprecatedBranchMetadata {
157
+ return {
158
+ deprecated: true,
159
+ deprecationMessage: BRANCH_DEPRECATION_MESSAGE,
160
+ lensSuggestion: migrateBranchToLens(args),
161
+ };
162
+ }
@@ -0,0 +1 @@
1
+ export * from "./lens-filter.contract";
@@ -0,0 +1 @@
1
+ export * from "./lens-workflow.contract";