@contractspec/lib.contracts 1.56.1 → 1.57.0

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 (212) hide show
  1. package/dist/_virtual/{rolldown_runtime.js → _rolldown/runtime.js} +3 -3
  2. package/dist/app-config/app-config.contracts.d.ts +50 -50
  3. package/dist/app-config/events.d.ts +27 -27
  4. package/dist/app-config/lifecycle-contracts.d.ts +54 -54
  5. package/dist/app-config/runtime.js +3 -3
  6. package/dist/app-config/validation.js +3 -3
  7. package/dist/capabilities/capabilities.js +20 -20
  8. package/dist/capabilities/context.d.ts +0 -1
  9. package/dist/capabilities/context.js +1 -1
  10. package/dist/capabilities/guards.d.ts +0 -1
  11. package/dist/capabilities/index.d.ts +2 -1
  12. package/dist/capabilities/index.js +2 -1
  13. package/dist/capabilities/meeting-recorder.d.ts +10 -0
  14. package/dist/capabilities/meeting-recorder.js +82 -0
  15. package/dist/capabilities/validation.d.ts +0 -1
  16. package/dist/client/react/drivers/rn-reusables.d.ts +0 -1
  17. package/dist/client/react/drivers/shadcn.d.ts +0 -1
  18. package/dist/client/react/form-render.js +3 -3
  19. package/dist/contract-registry/schemas.d.ts +2 -2
  20. package/dist/data-views/registry.d.ts +0 -1
  21. package/dist/data-views/spec.d.ts +0 -1
  22. package/dist/docs/commands/docsPublish.command.d.ts +13 -13
  23. package/dist/docs/contracts.d.ts +103 -103
  24. package/dist/docs/events/docsGenerated.event.d.ts +13 -13
  25. package/dist/docs/events/docsPublished.event.d.ts +15 -15
  26. package/dist/docs/forms/docsSearch.form.d.ts +4 -4
  27. package/dist/docs/queries/contractReference.query.d.ts +47 -47
  28. package/dist/docs/queries/docsIndex.query.d.ts +57 -57
  29. package/dist/docs/tech/llm/llm-integration.docblock.d.ts +0 -1
  30. package/dist/docs/tech/mcp-endpoints.docblock.js +5 -0
  31. package/dist/events.d.ts +0 -1
  32. package/dist/examples/index.d.ts +0 -1
  33. package/dist/examples/registry.d.ts +0 -1
  34. package/dist/examples/schema.d.ts +17 -17
  35. package/dist/experiments/spec.d.ts +2 -4
  36. package/dist/features/index.d.ts +0 -1
  37. package/dist/features/types.d.ts +2 -5
  38. package/dist/forms/forms.d.ts +1 -2
  39. package/dist/forms/forms.js +1 -2
  40. package/dist/index.d.ts +42 -1
  41. package/dist/index.js +36 -1
  42. package/dist/install.d.ts +2 -5
  43. package/dist/integrations/docs/integrations.docblock.js +19 -1
  44. package/dist/integrations/index.d.ts +26 -1
  45. package/dist/integrations/index.js +20 -1
  46. package/dist/integrations/meeting-recorder/contracts/index.d.ts +10 -0
  47. package/dist/integrations/meeting-recorder/contracts/index.js +12 -0
  48. package/dist/integrations/meeting-recorder/contracts/meetings.d.ts +458 -0
  49. package/dist/integrations/meeting-recorder/contracts/meetings.js +149 -0
  50. package/dist/integrations/meeting-recorder/contracts/transcripts.d.ts +173 -0
  51. package/dist/integrations/meeting-recorder/contracts/transcripts.js +156 -0
  52. package/dist/integrations/meeting-recorder/contracts/webhooks.d.ts +92 -0
  53. package/dist/integrations/meeting-recorder/contracts/webhooks.js +82 -0
  54. package/dist/integrations/meeting-recorder/meeting-recorder.capability.d.ts +7 -0
  55. package/dist/integrations/meeting-recorder/meeting-recorder.capability.js +21 -0
  56. package/dist/integrations/meeting-recorder/meeting-recorder.feature.d.ts +11 -0
  57. package/dist/integrations/meeting-recorder/meeting-recorder.feature.js +67 -0
  58. package/dist/integrations/meeting-recorder/models.d.ts +407 -0
  59. package/dist/integrations/meeting-recorder/models.js +295 -0
  60. package/dist/integrations/meeting-recorder/telemetry.d.ts +16 -0
  61. package/dist/integrations/meeting-recorder/telemetry.js +42 -0
  62. package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
  63. package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
  64. package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
  65. package/dist/integrations/openbanking/models.d.ts +55 -55
  66. package/dist/integrations/operations.d.ts +102 -102
  67. package/dist/integrations/providers/analytics-reader.d.ts +107 -0
  68. package/dist/integrations/providers/analytics-reader.js +0 -0
  69. package/dist/integrations/providers/analytics-writer.d.ts +10 -0
  70. package/dist/integrations/providers/analytics-writer.js +0 -0
  71. package/dist/integrations/providers/analytics.d.ts +49 -0
  72. package/dist/integrations/providers/analytics.js +0 -0
  73. package/dist/integrations/providers/database.d.ts +15 -0
  74. package/dist/integrations/providers/database.js +0 -0
  75. package/dist/integrations/providers/fal.d.ts +8 -0
  76. package/dist/integrations/providers/fal.js +94 -0
  77. package/dist/integrations/providers/fathom.d.ts +8 -0
  78. package/dist/integrations/providers/fathom.js +114 -0
  79. package/dist/integrations/providers/fireflies.d.ts +8 -0
  80. package/dist/integrations/providers/fireflies.js +98 -0
  81. package/dist/integrations/providers/gradium.d.ts +8 -0
  82. package/dist/integrations/providers/gradium.js +92 -0
  83. package/dist/integrations/providers/granola.d.ts +8 -0
  84. package/dist/integrations/providers/granola.js +71 -0
  85. package/dist/integrations/providers/index.d.ts +19 -1
  86. package/dist/integrations/providers/index.js +13 -1
  87. package/dist/integrations/providers/jira.d.ts +8 -0
  88. package/dist/integrations/providers/jira.js +90 -0
  89. package/dist/integrations/providers/linear.d.ts +8 -0
  90. package/dist/integrations/providers/linear.js +85 -0
  91. package/dist/integrations/providers/meeting-recorder.d.ts +132 -0
  92. package/dist/integrations/providers/meeting-recorder.js +0 -0
  93. package/dist/integrations/providers/notion.d.ts +8 -0
  94. package/dist/integrations/providers/notion.js +91 -0
  95. package/dist/integrations/providers/posthog.d.ts +8 -0
  96. package/dist/integrations/providers/posthog.js +107 -0
  97. package/dist/integrations/providers/project-management.d.ts +35 -0
  98. package/dist/integrations/providers/project-management.js +0 -0
  99. package/dist/integrations/providers/registry.d.ts +0 -1
  100. package/dist/integrations/providers/registry.js +24 -0
  101. package/dist/integrations/providers/supabase-postgres.d.ts +8 -0
  102. package/dist/integrations/providers/supabase-postgres.js +73 -0
  103. package/dist/integrations/providers/supabase-vector.d.ts +8 -0
  104. package/dist/integrations/providers/supabase-vector.js +93 -0
  105. package/dist/integrations/providers/tldv.d.ts +8 -0
  106. package/dist/integrations/providers/tldv.js +98 -0
  107. package/dist/integrations/runtime.js +0 -1
  108. package/dist/integrations/spec.d.ts +1 -1
  109. package/dist/jobs/queue.d.ts +0 -1
  110. package/dist/knowledge/binding.d.ts +1 -3
  111. package/dist/knowledge/operations.d.ts +66 -66
  112. package/dist/llm/exporters.d.ts +0 -1
  113. package/dist/llm/exporters.js +0 -1
  114. package/dist/llm/prompts.d.ts +0 -1
  115. package/dist/llm/types.d.ts +0 -1
  116. package/dist/onboarding-base.d.ts +29 -29
  117. package/dist/openapi.d.ts +0 -1
  118. package/dist/operations/operation.d.ts +19 -43
  119. package/dist/operations/registry.d.ts +0 -1
  120. package/dist/operations/registry.js +2 -2
  121. package/dist/operations/report/getContractVerificationStatus.d.ts +10 -10
  122. package/dist/ownership.d.ts +41 -88
  123. package/dist/policy/guards.d.ts +0 -1
  124. package/dist/policy/guards.js +3 -3
  125. package/dist/policy/index.d.ts +0 -1
  126. package/dist/policy/validation.d.ts +0 -1
  127. package/dist/product-intent/contract-patch-intent.d.ts +103 -0
  128. package/dist/product-intent/contract-patch-intent.js +33 -0
  129. package/dist/product-intent/contract-spec-patch.d.ts +89 -0
  130. package/dist/product-intent/contract-spec-patch.js +27 -0
  131. package/dist/product-intent/evidence.d.ts +17 -0
  132. package/dist/product-intent/evidence.js +13 -0
  133. package/dist/product-intent/findings.d.ts +60 -0
  134. package/dist/product-intent/findings.js +17 -0
  135. package/dist/product-intent/impact-report.d.ts +60 -0
  136. package/dist/product-intent/impact-report.js +27 -0
  137. package/dist/product-intent/index.d.ts +16 -0
  138. package/dist/product-intent/index.js +17 -0
  139. package/dist/product-intent/insights.d.ts +65 -0
  140. package/dist/product-intent/insights.js +23 -0
  141. package/dist/product-intent/opportunity-brief.d.ts +195 -0
  142. package/dist/product-intent/opportunity-brief.js +42 -0
  143. package/dist/product-intent/problems.d.ts +62 -0
  144. package/dist/product-intent/problems.js +22 -0
  145. package/dist/product-intent/registry.d.ts +32 -0
  146. package/dist/product-intent/registry.js +49 -0
  147. package/dist/product-intent/runtime.d.ts +103 -0
  148. package/dist/product-intent/runtime.js +101 -0
  149. package/dist/product-intent/spec.d.ts +676 -0
  150. package/dist/product-intent/spec.js +53 -0
  151. package/dist/product-intent/task-pack.d.ts +101 -0
  152. package/dist/product-intent/task-pack.js +34 -0
  153. package/dist/product-intent/tickets.d.ts +70 -0
  154. package/dist/product-intent/tickets.js +24 -0
  155. package/dist/product-intent/types.d.ts +12 -0
  156. package/dist/product-intent/types.js +13 -0
  157. package/dist/product-intent/ui-wireframe.d.ts +103 -0
  158. package/dist/product-intent/ui-wireframe.js +33 -0
  159. package/dist/registry-utils.d.ts +0 -1
  160. package/dist/registry-utils.js +3 -3
  161. package/dist/resources.js +1 -1
  162. package/dist/schema-to-markdown.d.ts +0 -1
  163. package/dist/server/contracts-adapter-input.js +2 -2
  164. package/dist/server/graphql-pothos.d.ts +0 -1
  165. package/dist/server/mcp/createMcpServer.d.ts +0 -1
  166. package/dist/server/rest-express.d.ts +0 -1
  167. package/dist/server/rest-generic.js +3 -3
  168. package/dist/server/rest-next-app.d.ts +0 -1
  169. package/dist/tests/spec.d.ts +0 -1
  170. package/dist/translations/registry.d.ts +0 -1
  171. package/dist/translations/spec.d.ts +0 -1
  172. package/dist/translations/validation.d.ts +0 -1
  173. package/dist/types.d.ts +5 -12
  174. package/dist/versioning/types.d.ts +0 -1
  175. package/dist/versioning/utils.d.ts +0 -1
  176. package/dist/workflow/adapters/memory-store.d.ts +0 -1
  177. package/dist/workflow/context.d.ts +0 -1
  178. package/dist/workflow/context.js +2 -2
  179. package/dist/workflow/runner.d.ts +1 -2
  180. package/dist/workspace-config/contractsrc-schema.d.ts +0 -1
  181. package/dist/workspace-config/contractsrc-types.d.ts +1 -3
  182. package/package.json +110 -32
  183. package/dist/integrations/providers/impls/elevenlabs-voice.d.ts +0 -20
  184. package/dist/integrations/providers/impls/elevenlabs-voice.js +0 -95
  185. package/dist/integrations/providers/impls/gcs-storage.d.ts +0 -24
  186. package/dist/integrations/providers/impls/gcs-storage.js +0 -88
  187. package/dist/integrations/providers/impls/gmail-inbound.d.ts +0 -26
  188. package/dist/integrations/providers/impls/gmail-inbound.js +0 -200
  189. package/dist/integrations/providers/impls/gmail-outbound.d.ts +0 -18
  190. package/dist/integrations/providers/impls/gmail-outbound.js +0 -105
  191. package/dist/integrations/providers/impls/google-calendar.d.ts +0 -23
  192. package/dist/integrations/providers/impls/google-calendar.js +0 -154
  193. package/dist/integrations/providers/impls/index.d.ts +0 -15
  194. package/dist/integrations/providers/impls/index.js +0 -16
  195. package/dist/integrations/providers/impls/mistral-embedding.d.ts +0 -23
  196. package/dist/integrations/providers/impls/mistral-embedding.js +0 -41
  197. package/dist/integrations/providers/impls/mistral-llm.d.ts +0 -31
  198. package/dist/integrations/providers/impls/mistral-llm.js +0 -247
  199. package/dist/integrations/providers/impls/postmark-email.d.ts +0 -19
  200. package/dist/integrations/providers/impls/postmark-email.js +0 -55
  201. package/dist/integrations/providers/impls/powens-client.d.ts +0 -124
  202. package/dist/integrations/providers/impls/powens-client.js +0 -171
  203. package/dist/integrations/providers/impls/powens-openbanking.d.ts +0 -27
  204. package/dist/integrations/providers/impls/powens-openbanking.js +0 -218
  205. package/dist/integrations/providers/impls/provider-factory.d.ts +0 -26
  206. package/dist/integrations/providers/impls/provider-factory.js +0 -146
  207. package/dist/integrations/providers/impls/qdrant-vector.d.ts +0 -24
  208. package/dist/integrations/providers/impls/qdrant-vector.js +0 -69
  209. package/dist/integrations/providers/impls/stripe-payments.d.ts +0 -28
  210. package/dist/integrations/providers/impls/stripe-payments.js +0 -202
  211. package/dist/integrations/providers/impls/twilio-sms.d.ts +0 -20
  212. package/dist/integrations/providers/impls/twilio-sms.js +0 -58
@@ -0,0 +1,22 @@
1
+ import { ZodSchemaType } from "@contractspec/lib.schema";
2
+ import * as z$2 from "zod";
3
+
4
+ //#region src/product-intent/problems.ts
5
+ const ProblemSeveritySchema = z$2.enum([
6
+ "low",
7
+ "medium",
8
+ "high"
9
+ ]);
10
+ const ProblemStatementSchema = z$2.object({
11
+ problemId: z$2.string().min(1),
12
+ statement: z$2.string().min(1),
13
+ evidenceIds: z$2.array(z$2.string().min(1)).min(1),
14
+ tags: z$2.array(z$2.string().min(1)).optional(),
15
+ severity: ProblemSeveritySchema.optional()
16
+ });
17
+ const ProblemStatementModel = new ZodSchemaType(ProblemStatementSchema, { name: "ProblemStatement" });
18
+ const ProblemGroupingSchema = z$2.object({ problems: z$2.array(ProblemStatementSchema) });
19
+ const ProblemGroupingModel = new ZodSchemaType(ProblemGroupingSchema, { name: "ProblemGrouping" });
20
+
21
+ //#endregion
22
+ export { ProblemGroupingModel, ProblemStatementModel };
@@ -0,0 +1,32 @@
1
+ import { SpecContractRegistry } from "../registry.js";
2
+ import { ProductIntentSpec } from "./spec.js";
3
+
4
+ //#region src/product-intent/registry.d.ts
5
+ /**
6
+ * Registry for ProductIntentSpec contracts.
7
+ */
8
+ declare class ProductIntentRegistry extends SpecContractRegistry<'product-intent', ProductIntentSpec> {
9
+ constructor(items?: ProductIntentSpec[]);
10
+ /**
11
+ * Add or replace a spec by meta key and version.
12
+ */
13
+ set(spec: ProductIntentSpec): this;
14
+ /**
15
+ * Retrieve a product intent spec by runtime id.
16
+ */
17
+ getById<Context = unknown>(id: string): ProductIntentSpec<Context> | undefined;
18
+ /**
19
+ * Delete a spec by runtime id.
20
+ */
21
+ delete(id: string): boolean;
22
+ /**
23
+ * Delete a spec by contract key and version.
24
+ */
25
+ deleteByKey(key: string, version: string): boolean;
26
+ /**
27
+ * Clear all registered specs.
28
+ */
29
+ clear(): void;
30
+ }
31
+ //#endregion
32
+ export { ProductIntentRegistry };
@@ -0,0 +1,49 @@
1
+ import { SpecContractRegistry, keyOfSpecContract } from "../registry.js";
2
+
3
+ //#region src/product-intent/registry.ts
4
+ /**
5
+ * Registry for ProductIntentSpec contracts.
6
+ */
7
+ var ProductIntentRegistry = class extends SpecContractRegistry {
8
+ constructor(items) {
9
+ super("product-intent", items);
10
+ }
11
+ /**
12
+ * Add or replace a spec by meta key and version.
13
+ */
14
+ set(spec) {
15
+ const key = keyOfSpecContract(spec);
16
+ this.items.set(key, spec);
17
+ return this;
18
+ }
19
+ /**
20
+ * Retrieve a product intent spec by runtime id.
21
+ */
22
+ getById(id) {
23
+ return this.list().find((spec) => spec.id === id);
24
+ }
25
+ /**
26
+ * Delete a spec by runtime id.
27
+ */
28
+ delete(id) {
29
+ const target = this.list().find((spec) => spec.id === id);
30
+ if (!target) return false;
31
+ const key = keyOfSpecContract(target);
32
+ return this.items.delete(key);
33
+ }
34
+ /**
35
+ * Delete a spec by contract key and version.
36
+ */
37
+ deleteByKey(key, version) {
38
+ return this.items.delete(`${key}.v${version}`);
39
+ }
40
+ /**
41
+ * Clear all registered specs.
42
+ */
43
+ clear() {
44
+ this.items.clear();
45
+ }
46
+ };
47
+
48
+ //#endregion
49
+ export { ProductIntentRegistry };
@@ -0,0 +1,103 @@
1
+ import { EvidenceChunk } from "./evidence.js";
2
+ import { InsightExtraction } from "./insights.js";
3
+ import { OpportunityBrief } from "./opportunity-brief.js";
4
+ import { ContractPatchIntent } from "./contract-patch-intent.js";
5
+ import { ContractSpecPatch } from "./contract-spec-patch.js";
6
+ import { ImpactReport } from "./impact-report.js";
7
+ import { TaskPack } from "./task-pack.js";
8
+ import "./types.js";
9
+ import { ProductIntentMeta, ProductIntentSpec } from "./spec.js";
10
+ import { ProductIntentRegistry } from "./registry.js";
11
+
12
+ //#region src/product-intent/runtime.d.ts
13
+ interface ProductIntentRuntimeOptions<Context = unknown> {
14
+ /**
15
+ * Fetch evidence relevant to a discovery question.
16
+ */
17
+ fetchEvidence: (params: {
18
+ query: string;
19
+ maxChunks?: number;
20
+ context?: Context;
21
+ }) => Promise<EvidenceChunk[]>;
22
+ /**
23
+ * Default maximum number of evidence chunks to retrieve.
24
+ */
25
+ maxEvidenceChunks?: number;
26
+ /**
27
+ * Optional callback invoked after insight extraction.
28
+ */
29
+ onInsightsGenerated?: (insights: InsightExtraction, ctx?: Context) => Promise<void>;
30
+ /**
31
+ * Optional callback invoked after brief synthesis.
32
+ */
33
+ onBriefSynthesised?: (brief: OpportunityBrief, ctx?: Context) => Promise<void>;
34
+ /**
35
+ * Optional callback invoked after patch intent generation.
36
+ */
37
+ onPatchIntentGenerated?: (intent: ContractPatchIntent, ctx?: Context) => Promise<void>;
38
+ /**
39
+ * Optional callback invoked after concrete patch generation.
40
+ */
41
+ onPatchGenerated?: (patch: ContractSpecPatch, ctx?: Context) => Promise<void>;
42
+ /**
43
+ * Optional callback invoked after impact report generation.
44
+ */
45
+ onImpactGenerated?: (impact: ImpactReport, ctx?: Context) => Promise<void>;
46
+ /**
47
+ * Optional callback invoked after task pack generation.
48
+ */
49
+ onTasksGenerated?: (tasks: TaskPack, ctx?: Context) => Promise<void>;
50
+ }
51
+ interface ProductIntentDiscoveryParams<Context = unknown> {
52
+ id: string;
53
+ meta: ProductIntentMeta;
54
+ question: string;
55
+ context?: Context;
56
+ maxEvidenceChunks?: number;
57
+ }
58
+ /**
59
+ * ProductIntentRuntime orchestrates the multi-step pipeline of evidence
60
+ * retrieval, insight extraction, brief synthesis, patch generation and
61
+ * task generation. Consumers should extend this class and override
62
+ * extractInsights, synthesiseBrief, generatePatchIntent, generatePatch,
63
+ * generateImpactReport, and generateTasks.
64
+ */
65
+ declare class ProductIntentRuntime<Context = unknown> {
66
+ private registry;
67
+ private opts;
68
+ constructor(opts: ProductIntentRuntimeOptions<Context>, registry?: ProductIntentRegistry);
69
+ /**
70
+ * Register an intent spec with this runtime.
71
+ */
72
+ registerIntent(spec: ProductIntentSpec<Context>): void;
73
+ /**
74
+ * Main entrypoint for running the discovery loop.
75
+ */
76
+ runDiscovery(params: ProductIntentDiscoveryParams<Context>): Promise<ProductIntentSpec<Context>>;
77
+ /**
78
+ * Extract insights from evidence. Override in subclasses.
79
+ */
80
+ protected extractInsights(_question: string, _evidence: EvidenceChunk[], _context?: Context): Promise<InsightExtraction>;
81
+ /**
82
+ * Synthesize a brief from extracted insights. Override in subclasses.
83
+ */
84
+ protected synthesiseBrief(_question: string, _insights: InsightExtraction, _context?: Context): Promise<OpportunityBrief>;
85
+ /**
86
+ * Generate a patch intent from a brief. Override in subclasses.
87
+ */
88
+ protected generatePatchIntent(_brief: OpportunityBrief, _context?: Context): Promise<ContractPatchIntent>;
89
+ /**
90
+ * Translate a patch intent into a concrete ContractSpec patch.
91
+ */
92
+ protected generatePatch(_intent: ContractPatchIntent, _context?: Context): Promise<ContractSpecPatch>;
93
+ /**
94
+ * Produce an impact report for a given intent and patch.
95
+ */
96
+ protected generateImpactReport(_intent: ContractPatchIntent, _patch: ContractSpecPatch, _context?: Context): Promise<ImpactReport>;
97
+ /**
98
+ * Generate a task pack from the brief, intent and impact report.
99
+ */
100
+ protected generateTasks(_brief: OpportunityBrief, _intent: ContractPatchIntent, _impact: ImpactReport, _context?: Context): Promise<TaskPack>;
101
+ }
102
+ //#endregion
103
+ export { ProductIntentDiscoveryParams, ProductIntentRuntime, ProductIntentRuntimeOptions };
@@ -0,0 +1,101 @@
1
+ import { ProductIntentRegistry } from "./registry.js";
2
+
3
+ //#region src/product-intent/runtime.ts
4
+ /**
5
+ * ProductIntentRuntime orchestrates the multi-step pipeline of evidence
6
+ * retrieval, insight extraction, brief synthesis, patch generation and
7
+ * task generation. Consumers should extend this class and override
8
+ * extractInsights, synthesiseBrief, generatePatchIntent, generatePatch,
9
+ * generateImpactReport, and generateTasks.
10
+ */
11
+ var ProductIntentRuntime = class {
12
+ registry;
13
+ opts;
14
+ constructor(opts, registry) {
15
+ this.opts = opts;
16
+ this.registry = registry ?? new ProductIntentRegistry();
17
+ }
18
+ /**
19
+ * Register an intent spec with this runtime.
20
+ */
21
+ registerIntent(spec) {
22
+ this.registry.register(spec);
23
+ }
24
+ /**
25
+ * Main entrypoint for running the discovery loop.
26
+ */
27
+ async runDiscovery(params) {
28
+ const { id, meta, question, context } = params;
29
+ const maxEvidenceChunks = params.maxEvidenceChunks ?? this.opts.maxEvidenceChunks ?? 20;
30
+ const spec = {
31
+ id,
32
+ meta,
33
+ question,
34
+ runtimeContext: context
35
+ };
36
+ const evidence = await this.opts.fetchEvidence({
37
+ query: question,
38
+ maxChunks: maxEvidenceChunks,
39
+ context
40
+ });
41
+ const insights = await this.extractInsights(question, evidence, context);
42
+ spec.insights = insights;
43
+ if (this.opts.onInsightsGenerated) await this.opts.onInsightsGenerated(insights, context);
44
+ const brief = await this.synthesiseBrief(question, insights, context);
45
+ spec.brief = brief;
46
+ if (this.opts.onBriefSynthesised) await this.opts.onBriefSynthesised(brief, context);
47
+ const intent = await this.generatePatchIntent(brief, context);
48
+ spec.patchIntent = intent;
49
+ if (this.opts.onPatchIntentGenerated) await this.opts.onPatchIntentGenerated(intent, context);
50
+ const patch = await this.generatePatch(intent, context);
51
+ spec.patch = patch;
52
+ if (this.opts.onPatchGenerated) await this.opts.onPatchGenerated(patch, context);
53
+ const impact = await this.generateImpactReport(intent, patch, context);
54
+ spec.impact = impact;
55
+ if (this.opts.onImpactGenerated) await this.opts.onImpactGenerated(impact, context);
56
+ const tasks = await this.generateTasks(brief, intent, impact, context);
57
+ spec.tasks = tasks;
58
+ if (this.opts.onTasksGenerated) await this.opts.onTasksGenerated(tasks, context);
59
+ this.registry.set(spec);
60
+ return spec;
61
+ }
62
+ /**
63
+ * Extract insights from evidence. Override in subclasses.
64
+ */
65
+ async extractInsights(_question, _evidence, _context) {
66
+ throw new Error("extractInsights() not implemented. Provide an implementation in a subclass.");
67
+ }
68
+ /**
69
+ * Synthesize a brief from extracted insights. Override in subclasses.
70
+ */
71
+ async synthesiseBrief(_question, _insights, _context) {
72
+ throw new Error("synthesiseBrief() not implemented. Provide an implementation in a subclass.");
73
+ }
74
+ /**
75
+ * Generate a patch intent from a brief. Override in subclasses.
76
+ */
77
+ async generatePatchIntent(_brief, _context) {
78
+ throw new Error("generatePatchIntent() not implemented. Provide an implementation in a subclass.");
79
+ }
80
+ /**
81
+ * Translate a patch intent into a concrete ContractSpec patch.
82
+ */
83
+ async generatePatch(_intent, _context) {
84
+ throw new Error("generatePatch() not implemented. Provide an implementation in a subclass.");
85
+ }
86
+ /**
87
+ * Produce an impact report for a given intent and patch.
88
+ */
89
+ async generateImpactReport(_intent, _patch, _context) {
90
+ throw new Error("generateImpactReport() not implemented. Provide an implementation in a subclass.");
91
+ }
92
+ /**
93
+ * Generate a task pack from the brief, intent and impact report.
94
+ */
95
+ async generateTasks(_brief, _intent, _impact, _context) {
96
+ throw new Error("generateTasks() not implemented. Provide an implementation in a subclass.");
97
+ }
98
+ };
99
+
100
+ //#endregion
101
+ export { ProductIntentRuntime };