@larkup/workspace-server 0.0.0-stage → 0.2.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 (180) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +2 -2
  3. package/dist-types/app/api/chat/feedback/route.d.ts +4 -0
  4. package/dist-types/app/api/chat/feedback/route.d.ts.map +1 -0
  5. package/dist-types/app/api/chat/route.d.ts +3 -0
  6. package/dist-types/app/api/chat/route.d.ts.map +1 -0
  7. package/dist-types/app/api/chat/tools.d.ts +67 -0
  8. package/dist-types/app/api/chat/tools.d.ts.map +1 -0
  9. package/dist-types/app/api/config/test-embedding/route.d.ts +3 -0
  10. package/dist-types/app/api/config/test-embedding/route.d.ts.map +1 -0
  11. package/dist-types/app/api/config/verify/route.d.ts +3 -0
  12. package/dist-types/app/api/config/verify/route.d.ts.map +1 -0
  13. package/dist-types/app/api/describe-image/route.d.ts +4 -0
  14. package/dist-types/app/api/describe-image/route.d.ts.map +1 -0
  15. package/dist-types/app/api/doc-editor/edit/route.d.ts +10 -0
  16. package/dist-types/app/api/doc-editor/edit/route.d.ts.map +1 -0
  17. package/dist-types/app/api/doc-editor/export/route.d.ts +9 -0
  18. package/dist-types/app/api/doc-editor/export/route.d.ts.map +1 -0
  19. package/dist-types/app/api/doc-editor/parse/route.d.ts +10 -0
  20. package/dist-types/app/api/doc-editor/parse/route.d.ts.map +1 -0
  21. package/dist-types/app/api/doc-editor/restore/route.d.ts +2 -0
  22. package/dist-types/app/api/doc-editor/restore/route.d.ts.map +1 -0
  23. package/dist-types/app/api/document/sign/route.d.ts +2 -0
  24. package/dist-types/app/api/document/sign/route.d.ts.map +1 -0
  25. package/dist-types/app/api/files/remote/route.d.ts +5 -0
  26. package/dist-types/app/api/files/remote/route.d.ts.map +1 -0
  27. package/dist-types/app/api/mcp/[connectionId]/route.d.ts +9 -0
  28. package/dist-types/app/api/mcp/[connectionId]/route.d.ts.map +1 -0
  29. package/dist-types/app/api/mcp/[connectionId]/test/route.d.ts +8 -0
  30. package/dist-types/app/api/mcp/[connectionId]/test/route.d.ts.map +1 -0
  31. package/dist-types/app/api/mcp/route.d.ts +4 -0
  32. package/dist-types/app/api/mcp/route.d.ts.map +1 -0
  33. package/dist-types/app/api/parse-file/route.d.ts +6 -0
  34. package/dist-types/app/api/parse-file/route.d.ts.map +1 -0
  35. package/dist-types/app/api/pdf-page/route.d.ts +4 -0
  36. package/dist-types/app/api/pdf-page/route.d.ts.map +1 -0
  37. package/dist-types/app/api/proxy/verify/route.d.ts +4 -0
  38. package/dist-types/app/api/proxy/verify/route.d.ts.map +1 -0
  39. package/dist-types/app/api/search/bing/route.d.ts +5 -0
  40. package/dist-types/app/api/search/bing/route.d.ts.map +1 -0
  41. package/dist-types/app/api/search/brave/route.d.ts +5 -0
  42. package/dist-types/app/api/search/brave/route.d.ts.map +1 -0
  43. package/dist-types/app/api/search/exa/route.d.ts +5 -0
  44. package/dist-types/app/api/search/exa/route.d.ts.map +1 -0
  45. package/dist-types/app/api/search/google/route.d.ts +30 -0
  46. package/dist-types/app/api/search/google/route.d.ts.map +1 -0
  47. package/dist-types/app/api/search/route.d.ts +7 -0
  48. package/dist-types/app/api/search/route.d.ts.map +1 -0
  49. package/dist-types/app/api/search/tavily/route.d.ts +5 -0
  50. package/dist-types/app/api/search/tavily/route.d.ts.map +1 -0
  51. package/dist-types/app/api/search/verify/route.d.ts +4 -0
  52. package/dist-types/app/api/search/verify/route.d.ts.map +1 -0
  53. package/dist-types/app/api/tabular/route.d.ts +9 -0
  54. package/dist-types/app/api/tabular/route.d.ts.map +1 -0
  55. package/dist-types/lib/chat/assistant-source-scope.d.ts +10 -0
  56. package/dist-types/lib/chat/assistant-source-scope.d.ts.map +1 -0
  57. package/dist-types/lib/chat/conversation-memory.d.ts +80 -0
  58. package/dist-types/lib/chat/conversation-memory.d.ts.map +1 -0
  59. package/dist-types/lib/chat/gateway-fallbacks.d.ts +7 -0
  60. package/dist-types/lib/chat/gateway-fallbacks.d.ts.map +1 -0
  61. package/dist-types/lib/chat/image-description.d.ts +10 -0
  62. package/dist-types/lib/chat/image-description.d.ts.map +1 -0
  63. package/dist-types/lib/chat/media-retrieval-routing.d.ts +14 -0
  64. package/dist-types/lib/chat/media-retrieval-routing.d.ts.map +1 -0
  65. package/dist-types/lib/chat/media-source-routing.d.ts +53 -0
  66. package/dist-types/lib/chat/media-source-routing.d.ts.map +1 -0
  67. package/dist-types/lib/chat/message-input.d.ts +8 -0
  68. package/dist-types/lib/chat/message-input.d.ts.map +1 -0
  69. package/dist-types/lib/chat/model-provider.d.ts +23 -0
  70. package/dist-types/lib/chat/model-provider.d.ts.map +1 -0
  71. package/dist-types/lib/chat/response-style.d.ts +2 -0
  72. package/dist-types/lib/chat/response-style.d.ts.map +1 -0
  73. package/dist-types/lib/chat/retrieval-ranking.d.ts +32 -0
  74. package/dist-types/lib/chat/retrieval-ranking.d.ts.map +1 -0
  75. package/dist-types/lib/chat/retrieval-routing.d.ts +39 -0
  76. package/dist-types/lib/chat/retrieval-routing.d.ts.map +1 -0
  77. package/dist-types/lib/chat/tabular-dataset-routing.d.ts +15 -0
  78. package/dist-types/lib/chat/tabular-dataset-routing.d.ts.map +1 -0
  79. package/dist-types/lib/chat/tabular-query-plan.d.ts +12 -0
  80. package/dist-types/lib/chat/tabular-query-plan.d.ts.map +1 -0
  81. package/dist-types/lib/chat/tabular-routing.d.ts +41 -0
  82. package/dist-types/lib/chat/tabular-routing.d.ts.map +1 -0
  83. package/dist-types/lib/chat/tabular-sandbox-files.d.ts +33 -0
  84. package/dist-types/lib/chat/tabular-sandbox-files.d.ts.map +1 -0
  85. package/dist-types/lib/chat/tabular-visualization.d.ts +31 -0
  86. package/dist-types/lib/chat/tabular-visualization.d.ts.map +1 -0
  87. package/dist-types/lib/chat/tool-call-repair.d.ts +11 -0
  88. package/dist-types/lib/chat/tool-call-repair.d.ts.map +1 -0
  89. package/dist-types/lib/chat/tool-context.d.ts +72 -0
  90. package/dist-types/lib/chat/tool-context.d.ts.map +1 -0
  91. package/dist-types/lib/chat/tool-registry.d.ts +3 -0
  92. package/dist-types/lib/chat/tool-registry.d.ts.map +1 -0
  93. package/dist-types/lib/chat/video-rag-routing.d.ts +33 -0
  94. package/dist-types/lib/chat/video-rag-routing.d.ts.map +1 -0
  95. package/dist-types/lib/chat/visual-routing.d.ts +53 -0
  96. package/dist-types/lib/chat/visual-routing.d.ts.map +1 -0
  97. package/dist-types/lib/enterprise-client.d.ts +31 -0
  98. package/dist-types/lib/enterprise-client.d.ts.map +1 -0
  99. package/dist-types/lib/marketplace/tool-runtime-config.d.ts +7 -0
  100. package/dist-types/lib/marketplace/tool-runtime-config.d.ts.map +1 -0
  101. package/dist-types/lib/media/knowledge.d.ts +47 -0
  102. package/dist-types/lib/media/knowledge.d.ts.map +1 -0
  103. package/dist-types/lib/media/pdf-inspection.d.ts +30 -0
  104. package/dist-types/lib/media/pdf-inspection.d.ts.map +1 -0
  105. package/dist-types/lib/media/source-identity.d.ts +12 -0
  106. package/dist-types/lib/media/source-identity.d.ts.map +1 -0
  107. package/dist-types/lib/media/source-utils.d.ts +157 -0
  108. package/dist-types/lib/media/source-utils.d.ts.map +1 -0
  109. package/dist-types/lib/media/video/quick-look.d.ts +60 -0
  110. package/dist-types/lib/media/video/quick-look.d.ts.map +1 -0
  111. package/dist-types/lib/media/video-intelligence-adapter.d.ts +521 -0
  112. package/dist-types/lib/media/video-intelligence-adapter.d.ts.map +1 -0
  113. package/dist-types/lib/media/video-intelligence-connection.d.ts +32 -0
  114. package/dist-types/lib/media/video-intelligence-connection.d.ts.map +1 -0
  115. package/dist-types/lib/remote-files.d.ts +12 -0
  116. package/dist-types/lib/remote-files.d.ts.map +1 -0
  117. package/dist-types/lib/search/provider-verification.d.ts +5 -0
  118. package/dist-types/lib/search/provider-verification.d.ts.map +1 -0
  119. package/dist-types/runtime-host.d.ts +20 -0
  120. package/dist-types/runtime-host.d.ts.map +1 -0
  121. package/package.json +338 -3
  122. package/src/app/api/chat/feedback/route.ts +77 -0
  123. package/src/app/api/chat/route.ts +2277 -0
  124. package/src/app/api/chat/tools.ts +3563 -0
  125. package/src/app/api/config/test-embedding/route.ts +39 -0
  126. package/src/app/api/config/verify/route.ts +309 -0
  127. package/src/app/api/describe-image/route.ts +108 -0
  128. package/src/app/api/doc-editor/edit/route.ts +87 -0
  129. package/src/app/api/doc-editor/export/route.ts +32 -0
  130. package/src/app/api/doc-editor/parse/route.ts +74 -0
  131. package/src/app/api/doc-editor/restore/route.ts +70 -0
  132. package/src/app/api/document/sign/route.ts +55 -0
  133. package/src/app/api/files/remote/route.ts +32 -0
  134. package/src/app/api/mcp/[connectionId]/route.ts +29 -0
  135. package/src/app/api/mcp/[connectionId]/test/route.ts +13 -0
  136. package/src/app/api/mcp/route.ts +22 -0
  137. package/src/app/api/parse-file/route.ts +86 -0
  138. package/src/app/api/pdf-page/route.ts +40 -0
  139. package/src/app/api/proxy/verify/route.ts +78 -0
  140. package/src/app/api/search/bing/route.ts +86 -0
  141. package/src/app/api/search/brave/route.ts +88 -0
  142. package/src/app/api/search/exa/route.ts +100 -0
  143. package/src/app/api/search/google/route.ts +147 -0
  144. package/src/app/api/search/route.ts +28 -0
  145. package/src/app/api/search/tavily/route.ts +93 -0
  146. package/src/app/api/search/verify/route.ts +27 -0
  147. package/src/app/api/tabular/route.ts +68 -0
  148. package/src/lib/chat/assistant-source-scope.ts +32 -0
  149. package/src/lib/chat/conversation-memory.ts +621 -0
  150. package/src/lib/chat/gateway-fallbacks.ts +12 -0
  151. package/src/lib/chat/image-description.ts +21 -0
  152. package/src/lib/chat/media-retrieval-routing.ts +37 -0
  153. package/src/lib/chat/media-source-routing.ts +100 -0
  154. package/src/lib/chat/message-input.ts +48 -0
  155. package/src/lib/chat/model-provider.ts +157 -0
  156. package/src/lib/chat/response-style.ts +3 -0
  157. package/src/lib/chat/retrieval-ranking.ts +126 -0
  158. package/src/lib/chat/retrieval-routing.ts +221 -0
  159. package/src/lib/chat/tabular-dataset-routing.ts +93 -0
  160. package/src/lib/chat/tabular-query-plan.ts +195 -0
  161. package/src/lib/chat/tabular-routing.ts +122 -0
  162. package/src/lib/chat/tabular-sandbox-files.ts +78 -0
  163. package/src/lib/chat/tabular-visualization.ts +165 -0
  164. package/src/lib/chat/tool-call-repair.ts +84 -0
  165. package/src/lib/chat/tool-context.ts +1222 -0
  166. package/src/lib/chat/tool-registry.ts +6 -0
  167. package/src/lib/chat/video-rag-routing.ts +149 -0
  168. package/src/lib/chat/visual-routing.ts +225 -0
  169. package/src/lib/enterprise-client.ts +96 -0
  170. package/src/lib/marketplace/tool-runtime-config.ts +155 -0
  171. package/src/lib/media/knowledge.ts +489 -0
  172. package/src/lib/media/pdf-inspection.ts +280 -0
  173. package/src/lib/media/source-identity.ts +50 -0
  174. package/src/lib/media/source-utils.ts +1156 -0
  175. package/src/lib/media/video/quick-look.ts +368 -0
  176. package/src/lib/media/video-intelligence-adapter.ts +1946 -0
  177. package/src/lib/media/video-intelligence-connection.ts +151 -0
  178. package/src/lib/remote-files.ts +182 -0
  179. package/src/lib/search/provider-verification.ts +95 -0
  180. package/src/runtime-host.ts +31 -0
@@ -0,0 +1,80 @@
1
+ type ChatMessage = {
2
+ role?: string;
3
+ parts?: unknown;
4
+ toolInvocations?: unknown;
5
+ metadata?: unknown;
6
+ };
7
+ export type ExactGroundedAnswer = {
8
+ answer: string;
9
+ sourceScopeFingerprint: string;
10
+ };
11
+ export type ReusableImageEvidence = {
12
+ imageUrl: string;
13
+ pageNumber?: number;
14
+ index?: number;
15
+ title?: string;
16
+ };
17
+ export type ReusableTabularEvidence = {
18
+ datasetId?: string;
19
+ columns: string[];
20
+ rows: Array<Record<string, unknown>>;
21
+ totalRows: number;
22
+ };
23
+ /** Only reuse table evidence while its source is still present in the live data store. */
24
+ export declare function tabularEvidenceDatasetIsAvailable(evidence: ReusableTabularEvidence | undefined, availableDatasetIds: ReadonlySet<string>): boolean;
25
+ export type ConversationEvidence = {
26
+ sources: Array<{
27
+ title?: string;
28
+ text?: string;
29
+ }>;
30
+ images: ReusableImageEvidence[];
31
+ /** Compact IDs let a direct correction address the same video without a fresh search. */
32
+ mediaAssetIds: string[];
33
+ /** Last question sent to the selected media capability, used only to resolve a follow-up. */
34
+ mediaQuestion?: string;
35
+ /** The latest bounded table result is safe to reuse for a direct follow-up. */
36
+ tabular?: ReusableTabularEvidence;
37
+ };
38
+ /**
39
+ * Find an immediately repeated plain-document question whose prior answer was
40
+ * backed only by a completed local search. Media, tabular, and multi-tool
41
+ * answers keep their specialized verification paths and are never reused here.
42
+ */
43
+ export declare function findImmediateExactGroundedAnswer(messages: readonly ChatMessage[], currentQuestion: string): ExactGroundedAnswer | undefined;
44
+ /** Keep the complete bounded query result for an immediate export follow-up. */
45
+ export declare function extractLatestTabularExportResult(messages: readonly ChatMessage[]): ReusableTabularEvidence | undefined;
46
+ /** Keep only enough exact table evidence for a direct follow-up, never raw sheets. */
47
+ export declare function compactTabularRowsForConversation(values: unknown[], columns: string[]): Array<Record<string, unknown>>;
48
+ /**
49
+ * Preserve only the latest successful retrieval as compact, reusable evidence.
50
+ * Raw tool results stay out of history so a follow-up cannot flood the model context.
51
+ */
52
+ export declare function extractConversationEvidence(messages: readonly ChatMessage[]): ConversationEvidence;
53
+ /**
54
+ * Resolve concise questions such as "which is biggest?" against the table
55
+ * just shown to the user. A bounded typo tolerance makes ordinary typos work
56
+ * without turning arbitrary new questions into table follow-ups.
57
+ */
58
+ export declare function isTabularFollowUp(text: string, evidence: ConversationEvidence): boolean;
59
+ export declare function isImagePreviewFollowUp(text: string, evidence: ConversationEvidence): boolean;
60
+ /**
61
+ * A source is selected by structured evidence from the immediately preceding
62
+ * turn. Keep it until a later source-selection event replaces it; never infer
63
+ * a source switch from vocabulary in the question.
64
+ */
65
+ export declare function continuesRecentMediaTopic(text: string, evidence: ConversationEvidence): boolean;
66
+ /**
67
+ * Resolve a short parallel preference question without carrying the previous
68
+ * answer forward. "What is my favorite anime?" → "and fruits" must search
69
+ * for favorite fruits, not treat Naruto as evidence for the new subject.
70
+ */
71
+ export declare function resolveParallelPreferenceQuestion(currentQuestion: string, previousQuestion: string): string | undefined;
72
+ /**
73
+ * Qualify a vague immediate follow-up with the prior non-media source before
74
+ * embedding it. This changes retrieval only; the original user wording stays
75
+ * visible in chat and the model transcript remains bounded.
76
+ */
77
+ export declare function contextualizeKnowledgeFollowUpQuery(text: string, evidence: ConversationEvidence): string | undefined;
78
+ export declare function formatConversationEvidence(evidence: ConversationEvidence): string;
79
+ export {};
80
+ //# sourceMappingURL=conversation-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-memory.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/conversation-memory.ts"],"names":[],"mappings":"AAeA,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,0FAA0F;AAC1F,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,uBAAuB,GAAG,SAAS,EAC7C,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAAC,GACvC,OAAO,CAET;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,yFAAyF;IACzF,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,6FAA6F;IAC7F,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACnC,CAAC;AAoFF;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,SAAS,WAAW,EAAE,EAChC,eAAe,EAAE,MAAM,GACtB,mBAAmB,GAAG,SAAS,CA0DjC;AAuED,gFAAgF;AAChF,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,SAAS,WAAW,EAAE,GAC/B,uBAAuB,GAAG,SAAS,CAUrC;AAED,sFAAsF;AACtF,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,OAAO,EAAE,EACjB,OAAO,EAAE,MAAM,EAAE,GAChB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAuBhC;AAYD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAC/B,oBAAoB,CA0GtB;AAmCD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAavF;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAK5F;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAE/F;AAUD;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,GAAG,SAAS,CAepB;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,oBAAoB,GAC7B,MAAM,GAAG,SAAS,CAyBpB;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,CAoCjF"}
@@ -0,0 +1,7 @@
1
+ export declare const GATEWAY_FALLBACK_MODELS: readonly ["google/gemini-2.5-flash", "openai/gpt-4o-mini", "meta/llama-4-maverick"];
2
+ export declare function gatewayProviderOptions(provider: string, primaryModelId: string): {
3
+ gateway: {
4
+ models: ("openai/gpt-4o-mini" | "google/gemini-2.5-flash" | "meta/llama-4-maverick")[];
5
+ };
6
+ } | undefined;
7
+ //# sourceMappingURL=gateway-fallbacks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-fallbacks.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/gateway-fallbacks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,qFAI1B,CAAC;AAEX,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;;;;cAK9E"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Image descriptions are often requested by a background media job. Their
3
+ * provider request must not inherit the browser or internal fetch signal: an
4
+ * outer request can finish/retry while the provider is waiting to retry a
5
+ * rate-limited call, which otherwise aborts the AI SDK's retry delay.
6
+ */
7
+ export declare const IMAGE_DESCRIPTION_TIMEOUT_MS = 90000;
8
+ export declare function createImageDescriptionSignal(): AbortSignal;
9
+ export declare function isImageDescriptionAbort(error: unknown): boolean;
10
+ //# sourceMappingURL=image-description.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-description.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/image-description.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD,wBAAgB,4BAA4B,IAAI,WAAW,CAE1D;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQ/D"}
@@ -0,0 +1,14 @@
1
+ type RetrievalHit = {
2
+ documentId?: unknown;
3
+ metadata?: {
4
+ mediaAssetId?: unknown;
5
+ };
6
+ };
7
+ /** Route to media analysis only when the best-ranked source is itself media. */
8
+ export declare function leadingMediaAssetId(retrieval: {
9
+ hits?: RetrievalHit[];
10
+ }, activeAssetIds: ReadonlySet<string>, assetIdByDocumentId: ReadonlyMap<string, string>): string | undefined;
11
+ /** Read only an explicitly routed media source, never metadata on secondary search hits. */
12
+ export declare function explicitMediaEvidenceAssetId(value: unknown): string | null;
13
+ export {};
14
+ //# sourceMappingURL=media-retrieval-routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-retrieval-routing.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/media-retrieval-routing.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACvC,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,mBAAmB,CACjC,SAAS,EAAE;IAAE,IAAI,CAAC,EAAE,YAAY,EAAE,CAAA;CAAE,EACpC,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,EACnC,mBAAmB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/C,MAAM,GAAG,SAAS,CASpB;AAED,4FAA4F;AAC5F,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAc1E"}
@@ -0,0 +1,53 @@
1
+ export type RoutableMediaAsset = {
2
+ id: string;
3
+ fileName: string;
4
+ originalUrl?: string;
5
+ processingStatus: string;
6
+ activeVideoKnowledgeRevisionId?: string;
7
+ type: string;
8
+ documentIds: string[];
9
+ };
10
+ /** Select a title only when it has a clear lexical lead over every other source. */
11
+ export declare function clearlyTitleMatchedMediaAsset<T extends RoutableMediaAsset>(query: string, assets: readonly T[]): T | undefined;
12
+ /**
13
+ * Before ordinary retrieval runs, media may become authoritative only when
14
+ * the question explicitly names it. A sole video is a safe fallback after a
15
+ * retrieval miss, but it must never pre-empt a document or tabular hit.
16
+ */
17
+ export declare function explicitlySelectedMediaAsset<T extends RoutableMediaAsset>(query: string, assets: readonly T[]): T | undefined;
18
+ /**
19
+ * Detect an explicitly named source that exists but is outside the Assistant
20
+ * source scope. A generic single-source fallback must not silently replace it
21
+ * with an unrelated enabled recording.
22
+ */
23
+ export declare function clearlyUnavailableTitleMatchedMediaAsset<T extends RoutableMediaAsset>(query: string, availableAssets: readonly T[], allAssets: readonly T[]): T | undefined;
24
+ /**
25
+ * A conversation carries a source selection as structured state. Once a
26
+ * source is selected, do not reinterpret ordinary user prose in an attempt
27
+ * to switch it: that is language- and genre-dependent, and can silently send
28
+ * a precise question to a different recording. A source switch must be
29
+ * represented by a new selected source in the conversation.
30
+ */
31
+ export declare function shouldKeepActiveMediaSource<T extends RoutableMediaAsset>(_query: string, activeAsset: T, availableAssets: readonly T[]): boolean;
32
+ /** A conversational follow-up stays on its active source and skips global reranking. */
33
+ export declare function activeMediaFollowUpResult(query: string, asset: RoutableMediaAsset, indexedContext?: string): {
34
+ query: string;
35
+ hits: {
36
+ metadata: {
37
+ mediaAssetId: string;
38
+ mediaType: string;
39
+ fileName: string;
40
+ };
41
+ context?: string | undefined;
42
+ title: string;
43
+ url: string;
44
+ score: number;
45
+ text: string;
46
+ }[];
47
+ videoEvidence: {
48
+ mediaAssetId: string;
49
+ fileName: string;
50
+ retrievalFallback: "active-conversation-media-source";
51
+ };
52
+ };
53
+ //# sourceMappingURL=media-source-routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-source-routing.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/media-source-routing.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,kBAAkB,EACxE,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,SAAS,CAAC,EAAE,GACnB,CAAC,GAAG,SAAS,CAUf;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,SAAS,kBAAkB,EACvE,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,SAAS,CAAC,EAAE,GACnB,CAAC,GAAG,SAAS,CAEf;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CAAC,CAAC,SAAS,kBAAkB,EACnF,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,SAAS,CAAC,EAAE,EAC7B,SAAS,EAAE,SAAS,CAAC,EAAE,GACtB,CAAC,GAAG,SAAS,CAIf;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,kBAAkB,EACtE,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,CAAC,EACd,eAAe,EAAE,SAAS,CAAC,EAAE,WAG9B;AAED,wFAAwF;AACxF,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,kBAAkB,EACzB,cAAc,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;EAyBxB"}
@@ -0,0 +1,8 @@
1
+ /** Accept UI messages and the common curl-friendly `{ role, content }` shape. */
2
+ export declare function normalizeIncomingMessages(value: unknown): {
3
+ id: string;
4
+ role: "user" | "assistant" | "system";
5
+ parts: Record<string, unknown>[];
6
+ content?: unknown;
7
+ }[];
8
+ //# sourceMappingURL=message-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-input.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/message-input.ts"],"names":[],"mappings":"AAOA,iFAAiF;AACjF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO;;UAkC1B,MAAM,GAAG,WAAW,GAAG,QAAQ;;cAtCjD,OAAO;IA2ClB"}
@@ -0,0 +1,23 @@
1
+ import { createOpenAI } from '@ai-sdk/openai';
2
+ import type { GatewayModel } from '@larkup/core/models-cache';
3
+ import type { CustomModelConfig, RagConfig } from '@larkup/core/types';
4
+ export interface ResolvedChatModel {
5
+ provider: string;
6
+ modelId: string;
7
+ apiKey?: string;
8
+ }
9
+ export interface ResolveChatModelOptions {
10
+ requiredTag?: string;
11
+ }
12
+ /**
13
+ * Resolve an LLM from persisted settings. The configured provider is
14
+ * authoritative: a gateway key must never be passed to a model vendor SDK.
15
+ */
16
+ export declare function resolveConfiguredChatModel(config: RagConfig, availableModels?: GatewayModel[], options?: ResolveChatModelOptions): ResolvedChatModel;
17
+ /**
18
+ * Resolve the workspace-wide vision-language model. Image-capable tools share
19
+ * this setting so they do not accidentally run on a text-only chat model.
20
+ */
21
+ export declare function resolveConfiguredVisionModel(config: RagConfig, availableModels?: GatewayModel[]): ResolvedChatModel;
22
+ export declare function createChatModel(provider: string, modelId: string, apiKey?: string, customChatModels?: CustomModelConfig[]): ReturnType<ReturnType<typeof createOpenAI>>;
23
+ //# sourceMappingURL=model-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-provider.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/model-provider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAWvE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,EACjB,eAAe,GAAE,YAAY,EAAO,EACpC,OAAO,GAAE,uBAA4B,GACpC,iBAAiB,CA6BnB;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,SAAS,EACjB,eAAe,GAAE,YAAY,EAAO,GACnC,iBAAiB,CA2BnB;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,gBAAgB,GAAE,iBAAiB,EAAO,GACzC,UAAU,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAwC7C"}
@@ -0,0 +1,2 @@
1
+ export declare const PERSONALIZED_RESPONSE_STYLE = "\nSpeak as a personalized assistant that already knows the user's context. Never mention or imply documents, files, stored data, a knowledge base, search, retrieval, sources, indexing, or tool calls. Do not start with phrases such as \"Based on\", \"According to\", \"I found\", \"Your document says\", or \"The search results show\". Start with the answer naturally and directly.\n";
2
+ //# sourceMappingURL=response-style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-style.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/response-style.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,mYAEvC,CAAC"}
@@ -0,0 +1,32 @@
1
+ export declare function searchTerms(text: string): string[];
2
+ export interface QueryTermMatcher {
3
+ term: string;
4
+ regex: RegExp;
5
+ }
6
+ /**
7
+ * Extracts a query's significant terms and compiles their matchers once, so
8
+ * a caller scanning many candidates (e.g. every document's title) doesn't
9
+ * redo term extraction and regex compilation on every single one of them.
10
+ */
11
+ export declare function buildQueryTermMatchers(query: string): QueryTermMatcher[];
12
+ /** How many of a precomputed set of query-term matchers appear (word-boundary
13
+ * aware) in `text`. */
14
+ export declare function countMatchesIn(matchers: QueryTermMatcher[], text: string): number;
15
+ /**
16
+ * How many of the query's significant terms appear (word-boundary aware) in
17
+ * `title`. Exposed so a candidate-pool builder can pull in a document whose
18
+ * title is an obvious match for the query even when pure vector similarity
19
+ * placed it outside the retrieved pool entirely -- reranking can only
20
+ * reorder what's already in the pool, it can't recover a document that
21
+ * never made it in. Scanning many titles for the same query should use
22
+ * `buildQueryTermMatchers` once and call `countMatchesIn` per title instead
23
+ * of this convenience wrapper, which redoes both on every call.
24
+ */
25
+ export declare function countTitleTermMatches(query: string, title: string): number;
26
+ /** Merge semantic recall with exact terminology from names, labels, and IDs. */
27
+ export declare function rankKnowledgeHits<T extends {
28
+ text?: string;
29
+ title?: string;
30
+ metadata?: any;
31
+ }>(query: string, hits: T[]): T[];
32
+ //# sourceMappingURL=retrieval-ranking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retrieval-ranking.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/retrieval-ranking.ts"],"names":[],"mappings":"AAmCA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CASlD;AAgBD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAExE;AAED;uBACuB;AACvB,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIjF;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,EAC3F,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,EAAE,GACR,CAAC,EAAE,CAyBL"}
@@ -0,0 +1,39 @@
1
+ export declare function requiresKnowledgeBaseSearch(text: string): boolean;
2
+ type ChatMessageWithToolParts = {
3
+ role?: string;
4
+ parts?: unknown;
5
+ toolInvocations?: unknown;
6
+ };
7
+ /**
8
+ * A follow-up may safely reuse evidence that is still in the conversation.
9
+ * Do not reuse an empty search: a new, more specific wording can surface a
10
+ * relevant chunk on the next attempt.
11
+ */
12
+ export declare function hasPriorKnowledgeBaseEvidence(messages: ChatMessageWithToolParts[]): boolean;
13
+ /**
14
+ * Keep retrieval efficient for natural continuations such as "what about it?"
15
+ * while treating every new standalone question as a fresh lookup.
16
+ */
17
+ export declare function isLikelyKnowledgeFollowUp(text: string, messages?: ChatMessageWithToolParts[]): boolean;
18
+ export declare function canReuseKnowledgeBaseEvidence(text: string, messages: ChatMessageWithToolParts[]): boolean;
19
+ /** The chat workspace is intentionally a retrieval-only experience. */
20
+ export declare function requiresCurrentWebSearch(text: string): boolean;
21
+ /** Only the first retrieval is forced. The other source remains available for
22
+ * exactly one recovery attempt; subsequent steps are reserved for analysis and
23
+ * the final answer. */
24
+ export declare function retrievalToolsForStep<ToolName extends string>(options: {
25
+ stepNumber: number;
26
+ forceKnowledgeBaseSearch: boolean;
27
+ forceWebSearch: boolean;
28
+ toolNames: readonly ToolName[];
29
+ /** Reserve this and every later step for the model's final answer. */
30
+ finalAnswerStep?: number;
31
+ }): {
32
+ toolChoice?: {
33
+ type: 'tool';
34
+ toolName: ToolName;
35
+ } | 'none';
36
+ activeTools?: ToolName[];
37
+ } | undefined;
38
+ export {};
39
+ //# sourceMappingURL=retrieval-routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retrieval-routing.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/retrieval-routing.ts"],"names":[],"mappings":"AAiCA,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAwBjE;AAED,KAAK,wBAAwB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AA0BF;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,wBAAwB,EAAE,GAAG,OAAO,CAqB3F;AAgBD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,wBAAwB,EAAE,GACpC,OAAO,CAsBT;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,wBAAwB,EAAE,GACnC,OAAO,CAET;AAED,uEAAuE;AACvE,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG9D;AAED;;uBAEuB;AACvB,wBAAgB,qBAAqB,CAAC,QAAQ,SAAS,MAAM,EAAE,OAAO,EAAE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,wBAAwB,EAAE,OAAO,CAAC;IAClC,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC/B,sEAAsE;IACtE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GACG;IACE,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,MAAM,CAAC;IAC3D,WAAW,CAAC,EAAE,QAAQ,EAAE,CAAC;CAC1B,GACD,SAAS,CA8BZ"}
@@ -0,0 +1,15 @@
1
+ import type { TabularDatasetMeta } from '@larkup/core/tabular-store';
2
+ /**
3
+ * Find one unambiguous dataset for code analysis when a model omitted the
4
+ * optional datasetId. This is intentionally schema-led: a matching filename
5
+ * alone is not enough to stage a potentially large source in the sandbox.
6
+ */
7
+ export declare function selectTabularDatasetForQuestion(text: string | undefined, datasets: TabularDatasetMeta[]): string | undefined;
8
+ /**
9
+ * Correct a model-selected sheet only when the question's schema makes a
10
+ * different dataset objectively better. This keeps workbook selection
11
+ * generic while avoiding a filename such as "sales.xlsx" winning over a
12
+ * sheet that actually contains both Sales and Profit.
13
+ */
14
+ export declare function resolveTabularDatasetForQuestion(text: string | undefined, datasets: TabularDatasetMeta[], selectedDatasetId: string): string;
15
+ //# sourceMappingURL=tabular-dataset-routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabular-dataset-routing.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/tabular-dataset-routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAoDrE;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,QAAQ,EAAE,kBAAkB,EAAE,sBAY/B;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,QAAQ,EAAE,kBAAkB,EAAE,EAC9B,iBAAiB,EAAE,MAAM,UAU1B"}
@@ -0,0 +1,12 @@
1
+ import type { TabularDataset, TabularQueryRequest } from '@larkup/core/tabular-store';
2
+ export type InferredTabularPlan = {
3
+ request: TabularQueryRequest;
4
+ chartTitle?: string;
5
+ };
6
+ /**
7
+ * Normalize a clear calendar request from the dataset schema. It never
8
+ * assumes business columns or domain names: a time series is derived only
9
+ * when there is one date column and one numeric measure.
10
+ */
11
+ export declare function inferTabularPlan(requestText: string | undefined, dataset: TabularDataset, request: TabularQueryRequest): InferredTabularPlan;
12
+ //# sourceMappingURL=tabular-query-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabular-query-plan.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/tabular-query-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAiHF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CAmErB"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Route ordinary sheet questions through the structured query engine, while
3
+ * sending explicit joins and advanced analytics to the sandbox. This keeps
4
+ * common Excel/CSV questions independent from local Python availability.
5
+ */
6
+ export declare function tabularToolsForStep(input: {
7
+ stepNumber: number;
8
+ toolNames: string[];
9
+ requiresSandbox?: boolean;
10
+ }): {
11
+ toolChoice: {
12
+ type: "tool";
13
+ toolName: string;
14
+ };
15
+ activeTools: string[];
16
+ } | {
17
+ toolChoice: "none";
18
+ activeTools: never[];
19
+ };
20
+ /** Stop once the host has attached a renderable chart to authoritative rows. */
21
+ export declare function hasCompletedTabularVisualizationStep(steps: Array<{
22
+ toolResults?: readonly unknown[];
23
+ }>): boolean;
24
+ /**
25
+ * Identify requests whose answer requires an out-of-core calculation rather
26
+ * than a single structured table query. This is phrased around analytical
27
+ * operations, so it works for any workbook and does not depend on sheet or
28
+ * column names.
29
+ */
30
+ export declare function requiresTabularSandbox(text: string): boolean;
31
+ /**
32
+ * A workspace can contain spreadsheets alongside PDFs, media, and notes.
33
+ * Only force the table path when the wording actually asks for tabular facts;
34
+ * otherwise normal source retrieval remains free to select the right modality.
35
+ */
36
+ export declare function isLikelyTabularQuestion(input: {
37
+ text: string;
38
+ columnNames: string[];
39
+ datasetNames: string[];
40
+ }): boolean;
41
+ //# sourceMappingURL=tabular-routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabular-routing.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/tabular-routing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;;;;;;;;;EAqBA;AAED,gFAAgF;AAChF,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,KAAK,CAAC;IACX,WAAW,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAClC,CAAC,WAgBH;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAI5D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,WA8CA"}
@@ -0,0 +1,33 @@
1
+ import type { TabularDataset } from '@larkup/core/tabular-store';
2
+ export type TabularSandboxFile = {
3
+ name: string;
4
+ content: string;
5
+ };
6
+ export type TabularSandboxManifest = {
7
+ datasets: Array<{
8
+ id: string;
9
+ fileName: string;
10
+ file: string;
11
+ rowCount: number;
12
+ columns: string[];
13
+ }>;
14
+ };
15
+ /** Serialize a stored dataset with RFC 4180-compatible quoting for sandbox analysis. */
16
+ export declare function tabularDatasetToCsv(dataset: TabularDataset): string;
17
+ /**
18
+ * Stage one or more selected datasets for a sandbox without exposing row data
19
+ * to the chat model. A single dataset keeps the long-standing `data.csv`
20
+ * contract; multiple datasets receive stable generic filenames plus a manifest
21
+ * that maps each source ID and sheet name to its CSV file.
22
+ */
23
+ export declare function createTabularSandboxFiles(datasets: TabularDataset[]): {
24
+ files: TabularSandboxFile[];
25
+ manifest?: TabularSandboxManifest;
26
+ };
27
+ /**
28
+ * Recover a common single-sheet code pattern when every selected dataset was
29
+ * requested but the generated code still reads `data.csv`. Rewriting is safe
30
+ * only when the number of reads exactly matches the selected datasets.
31
+ */
32
+ export declare function remapLegacyMultiDatasetReads(code: string, datasetCount: number): string;
33
+ //# sourceMappingURL=tabular-sandbox-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabular-sandbox-files.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/tabular-sandbox-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,KAAK,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC,CAAC;CACJ,CAAC;AASF,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,UAM1D;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG;IACrE,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CACnC,CAuBA;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAQvF"}
@@ -0,0 +1,31 @@
1
+ export type TabularChartConfig = {
2
+ chartType: 'bar' | 'line';
3
+ title: string;
4
+ data: Record<string, unknown>[];
5
+ xAxisKey: string;
6
+ series: {
7
+ dataKey: string;
8
+ label: string;
9
+ }[];
10
+ showLegend: boolean;
11
+ xAxisLabel?: string;
12
+ yAxisLabel?: string;
13
+ };
14
+ type TabularVisualizationResult = {
15
+ visualization?: TabularChartConfig;
16
+ error?: unknown;
17
+ };
18
+ export declare function requestsVisualization(text: string): boolean;
19
+ /** Build a chart only from an already-queried, bounded tabular result. */
20
+ export declare function createTabularVisualization(requestText: string | undefined, result: {
21
+ columns: string[];
22
+ rows: Record<string, unknown>[];
23
+ }): TabularChartConfig | undefined;
24
+ /**
25
+ * Keep the prose beside a rendered chart compact and deterministic. The chart
26
+ * already exposes every plotted row, so echoing those rows as assistant text
27
+ * is both noisy and a common source of provider-specific output failures.
28
+ */
29
+ export declare function formatTabularVisualizationAnswer(result: TabularVisualizationResult): string;
30
+ export {};
31
+ //# sourceMappingURL=tabular-visualization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabular-visualization.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/tabular-visualization.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAoBF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAI3D;AA+BD,0EAA0E;AAC1E,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAAE,GAC7D,kBAAkB,GAAG,SAAS,CAsDhC;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,0BAA0B,GAAG,MAAM,CA4B3F"}
@@ -0,0 +1,11 @@
1
+ import type { ToolCallRepairFunction } from 'ai';
2
+ type JsonObject = Record<string, unknown>;
3
+ /**
4
+ * Recover the specific valid-JSON shape produced when a model accidentally
5
+ * continues top-level tabular arguments inside a long filters array.
6
+ */
7
+ export declare function repairQueryTabularDataInput(value: unknown): JsonObject | null;
8
+ /** Repair only known, deterministic chat tool-call mistakes. */
9
+ export declare const repairChatToolCall: ToolCallRepairFunction<any>;
10
+ export {};
11
+ //# sourceMappingURL=tool-call-repair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-call-repair.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/tool-call-repair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,IAAI,CAAC;AAEjD,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAU1C;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAoD7E;AAED,gEAAgE;AAChE,eAAO,MAAM,kBAAkB,EAAE,sBAAsB,CAAC,GAAG,CAY1D,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Interpret the generic media-evidence verification protocol.
3
+ *
4
+ * `directlyEstablished` describes whether one observation states the answer.
5
+ * It is deliberately false for an answer established by a chronological trail,
6
+ * which is still answer-level evidence and must not be downgraded to a refusal.
7
+ */
8
+ export declare function mediaClaimNeedsCorroboration(value: unknown): boolean;
9
+ /** True when the evidence provider says the claim can be answered now. */
10
+ export declare function mediaClaimIsAnswerLevel(value: unknown): boolean;
11
+ /** Find an answer-level media claim even when it is nested in a search result. */
12
+ export declare function containsAnswerLevelMediaEvidence(value: unknown): boolean;
13
+ /** Extract only direct claims verified for the current question. */
14
+ export declare function collectQuestionMatchedDirectClaims(value: unknown, question: string): string[];
15
+ /**
16
+ * Last-resort visible text when a provider closes after tools without writing
17
+ * its answer. Only answer-level media results qualify; locators and
18
+ * needs-corroboration results must never be turned into claims here.
19
+ */
20
+ export declare function collectAnswerLevelMediaStatements(value: unknown): string[];
21
+ /**
22
+ * Collect the visibility protocol without trying to interpret the user's
23
+ * language. The reply model receives this separately from ranked snippets so
24
+ * a direct re-watch of one moment cannot hide the reconciled recurrence data.
25
+ */
26
+ export declare function collectObservedSubjectLedger(value: unknown): string[];
27
+ /**
28
+ * Render a source-position-to-recurrence answer when the local visual subject
29
+ * is described but not named. This protocol guard prevents a prose model from
30
+ * borrowing a proper name from another timestamp and attaching it to the
31
+ * requested moment.
32
+ */
33
+ export declare function formatLocatedObservedSubjectAnswer(value: unknown): string | undefined;
34
+ /**
35
+ * Render a repeated visual appearance directly from the evidence protocol.
36
+ * This is intentionally protocol-driven: a subject can be a person, animal,
37
+ * object, character, or anything else the visual index describes. It avoids
38
+ * asking a prose model to reinterpret explicit discrete moments as one
39
+ * continuous appearance or as an absence claim.
40
+ */
41
+ export declare function formatObservedAppearanceAnswer(value: unknown): string | undefined;
42
+ /** Render a final two-sided numeric outcome without waiting on a slow prose model. */
43
+ export declare function formatOutcomeMediaAnswer(value: unknown, investigation: VideoInvestigationDirective): string | undefined;
44
+ /** Use the strongest bounded source reading directly when it already settled the question. */
45
+ export declare function formatDirectObservationAnswer(value: unknown, question?: string): string | undefined;
46
+ /** Keep speech-only requests out of deterministic visual answer renderers. */
47
+ export declare function mediaEvidenceRequestsOnlySpeech(value: unknown): boolean;
48
+ /** Render a compact, source-grounded participant roster without relying on prose-model formatting. */
49
+ export declare function formatParticipantInventory(value: unknown, question: string): string | undefined;
50
+ /**
51
+ * Render a verified complete media inventory without putting hundreds of
52
+ * already-final source items through another model context window.
53
+ */
54
+ export declare function formatExhaustiveMediaAnswer(value: unknown, _question: string): string | undefined;
55
+ /** Guarantee a visible, normally-closing UI answer without delaying AI SDK lifecycle events. */
56
+ export declare function recoverEmptyUIMessageStream(fallbackText: string): () => TransformStream<any, any>;
57
+ /**
58
+ * Removing every tool for the final answer step (activeTools: [],
59
+ * toolChoice: 'none') isn't always enough signal on its own -- observed
60
+ * live with a reasoning-tagged model (Claude Sonnet 4.6) on a large,
61
+ * evidence-heavy video investigation: it burned a few output tokens and
62
+ * finished with no tool call and no text at all, leaving the turn looking
63
+ * answered (citations rendered from the tool result) but silently empty.
64
+ * An explicit nudge naming the moment ("you have every tool result now,
65
+ * answer") reliably produced a real answer where the bare absence of tools
66
+ * didn't -- reproduced and confirmed live before and after this fix.
67
+ */
68
+ export declare function withFinalAnswerNudge(messages: readonly any[]): any[];
69
+ /** Keep rendered tool outputs intact while bounding the next model call's evidence. */
70
+ export declare function compactToolContextForModel(messages: readonly any[]): any[];
71
+ import type { VideoInvestigationDirective } from '@larkup/core/video-knowledge/query-planner';
72
+ //# sourceMappingURL=tool-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-context.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/tool-context.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAmBpE;AAED,0EAA0E;AAC1E,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAgB/D;AAED,kFAAkF;AAClF,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAmBxE;AAmBD,oEAAoE;AACpE,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAuB7F;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CA+D1E;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAyDrE;AAED;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CA4KrF;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAgGjF;AAED,sFAAsF;AACtF,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,aAAa,EAAE,2BAA2B,GACzC,MAAM,GAAG,SAAS,CAwFpB;AAED,8FAA8F;AAC9F,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,SAAK,GAAG,MAAM,GAAG,SAAS,CAqE/F;AAED,8EAA8E;AAC9E,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA2BvE;AAED,sGAAsG;AACtG,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA0D/F;AAYD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA+IjG;AAED,gGAAgG;AAChG,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,MAAM,mCAwC/D;AAkLD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,CAapE;AAED,uFAAuF;AACvF,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,CAiB1E;AACD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Remove optional capabilities that are unavailable in the current runtime. */
2
+ export declare function executableTools<T extends Record<string, unknown>>(candidates: T): { [K in keyof T as T[K] extends null | undefined ? never : K]: NonNullable<T[K]>; };
3
+ //# sourceMappingURL=tool-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/tool-registry.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,GAGzE,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,KAAK,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE,CACxF"}
@@ -0,0 +1,33 @@
1
+ export type VideoEvidenceVerificationStatus = 'supported' | 'conflicted' | 'insufficient' | 'needs_inspection';
2
+ export interface IndexedVideoAnswerSignal {
3
+ modality: string;
4
+ text: string;
5
+ confidenceScore: number;
6
+ startSecs: number;
7
+ endSecs: number;
8
+ conflict?: boolean;
9
+ }
10
+ export declare const MAX_EXHAUSTIVE_EVIDENCE_ITEMS = 800;
11
+ export declare const MAX_EXHAUSTIVE_TABLE_ROWS = 10000;
12
+ /** Follow a tool-owned chronological cursor without relying on model tool use. */
13
+ export declare function collectExhaustiveVideoEvidencePages(execute: (input: Record<string, unknown>, options: {
14
+ toolCallId: string;
15
+ }) => Promise<unknown>, input: {
16
+ mediaAssetId: string;
17
+ query: string;
18
+ }, firstPage: unknown, toolCallId: string): Promise<unknown>;
19
+ /**
20
+ * Decide whether chat can answer from the immutable index before paying for a
21
+ * live source read. This gate is intentionally content-agnostic: it evaluates
22
+ * provenance, confidence, temporal coverage, and retrieval agreement rather
23
+ * than recognizing any particular kind of recording.
24
+ */
25
+ export declare function indexedVideoEvidenceIsSufficient(input: {
26
+ verificationStatus: VideoEvidenceVerificationStatus;
27
+ questionKinds: string[];
28
+ evidence: IndexedVideoAnswerSignal[];
29
+ focusSources?: string[];
30
+ durationSecs?: number;
31
+ hierarchyRanges?: number;
32
+ }): boolean;
33
+ //# sourceMappingURL=video-rag-routing.d.ts.map