@larkup/workspace-server 0.2.14 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-types/app/api/chat/route.d.ts.map +1 -1
- package/dist-types/lib/chat/tabular-query-plan.d.ts +3 -1
- package/dist-types/lib/chat/tabular-query-plan.d.ts.map +1 -1
- package/dist-types/lib/chat/tabular-visualization.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/app/api/chat/route.ts +2 -0
- package/src/lib/chat/tabular-query-plan.ts +22 -3
- package/src/lib/chat/tabular-visualization.ts +9 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/chat/route.ts"],"names":[],"mappings":"AAqHA,eAAO,MAAM,WAAW,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/chat/route.ts"],"names":[],"mappings":"AAqHA,eAAO,MAAM,WAAW,MAAM,CAAC;AAmuB/B,wBAAsB,IAAI,CAAC,GAAG,EAAE,OAAO,qBA69CtC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type TabularDataset, type TabularQueryRequest } from '@larkup/core/tabular-store';
|
|
2
2
|
export type InferredTabularPlan = {
|
|
3
3
|
request: TabularQueryRequest;
|
|
4
4
|
chartTitle?: string;
|
|
5
5
|
};
|
|
6
|
+
/** Preserve an explicit long-list size instead of relying on a model default. */
|
|
7
|
+
export declare function requestedTabularResultLimit(text: string): number | undefined;
|
|
6
8
|
/**
|
|
7
9
|
* Normalize a clear calendar request from the dataset schema. It never
|
|
8
10
|
* assumes business columns or domain names: a time series is derived only
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabular-query-plan.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/tabular-query-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"tabular-query-plan.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/tabular-query-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACzB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AA2EF,iFAAiF;AACjF,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ5E;AAwCD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CAuErB"}
|
|
@@ -1 +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,
|
|
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,CAU3D;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@larkup/workspace-server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -325,9 +325,9 @@
|
|
|
325
325
|
"zod": "^4.4.3",
|
|
326
326
|
"mammoth": "^1.12.0",
|
|
327
327
|
"@larkup/marketplace": "0.3.11",
|
|
328
|
-
"@larkup/sandbox": "0.1.8",
|
|
329
328
|
"@larkup/scraper": "0.2.2",
|
|
330
|
-
"@larkup/vector-stores": "0.1.27"
|
|
329
|
+
"@larkup/vector-stores": "0.1.27",
|
|
330
|
+
"@larkup/sandbox": "0.1.8"
|
|
331
331
|
},
|
|
332
332
|
"devDependencies": {
|
|
333
333
|
"typescript": "^7.0.2",
|
|
@@ -176,6 +176,8 @@ ${PERSONALIZED_RESPONSE_STYLE}
|
|
|
176
176
|
|
|
177
177
|
Keep the answer brief and direct: give the answer first, then only the essential context. Do not repeat tool output, dump rows, or add a table unless the user asks to see data. Use a short list only when it improves clarity.
|
|
178
178
|
|
|
179
|
+
When a tabular tool returns a requested long list, the structured table is the complete visible answer. Briefly state what it contains and its coverage; never stream the rows again as prose or Markdown.
|
|
180
|
+
|
|
179
181
|
When the user asks for an Excel, CSV, or PDF export, use createDataExport. Never claim that a file was created and never write a Markdown download link unless the tool returned a real file artifact.
|
|
180
182
|
|
|
181
183
|
When the user asks for every item and the media evidence marks its continuation as exhaustive, include every returned item in chronological order. In that case completeness overrides brevity; deduplicate wording but do not summarize items away.
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
MAX_TABULAR_RESULT_LIMIT,
|
|
3
|
+
type TabularDataset,
|
|
4
|
+
type TabularQueryRequest,
|
|
5
|
+
} from '@larkup/core/tabular-store';
|
|
2
6
|
|
|
3
7
|
export type InferredTabularPlan = {
|
|
4
8
|
request: TabularQueryRequest;
|
|
@@ -78,6 +82,17 @@ function requestedSortOrder(text: string) {
|
|
|
78
82
|
return undefined;
|
|
79
83
|
}
|
|
80
84
|
|
|
85
|
+
/** Preserve an explicit long-list size instead of relying on a model default. */
|
|
86
|
+
export function requestedTabularResultLimit(text: string): number | undefined {
|
|
87
|
+
const match = text.match(
|
|
88
|
+
/\b(?:top|first|last|show|list|return|give(?:\s+me)?|display)\s+(?:the\s+)?(\d{1,4})\b/iu,
|
|
89
|
+
);
|
|
90
|
+
if (!match) return undefined;
|
|
91
|
+
const requested = Number(match[1]);
|
|
92
|
+
if (!Number.isSafeInteger(requested) || requested < 1) return undefined;
|
|
93
|
+
return Math.min(requested, MAX_TABULAR_RESULT_LIMIT);
|
|
94
|
+
}
|
|
95
|
+
|
|
81
96
|
function normalizeAggregations(
|
|
82
97
|
dataset: TabularDataset,
|
|
83
98
|
request: TabularQueryRequest,
|
|
@@ -133,6 +148,7 @@ export function inferTabularPlan(
|
|
|
133
148
|
const measureColumns =
|
|
134
149
|
requestedMeasures.length > 0 ? requestedMeasures : numeric.length === 1 ? [numeric[0]] : [];
|
|
135
150
|
const year = text.match(/\b(20\d{2})\b/)?.[1];
|
|
151
|
+
const explicitLimit = requestedTabularResultLimit(text);
|
|
136
152
|
|
|
137
153
|
if (
|
|
138
154
|
dateColumn &&
|
|
@@ -184,12 +200,15 @@ export function inferTabularPlan(
|
|
|
184
200
|
...(sortOrder
|
|
185
201
|
? { sortBy: `${aggregations[0].op}_${aggregations[0].column}`, sortOrder }
|
|
186
202
|
: {}),
|
|
187
|
-
limit: Math.min(request.limit ?? 120, 120),
|
|
203
|
+
limit: explicitLimit ?? Math.min(request.limit ?? 120, 120),
|
|
188
204
|
},
|
|
189
205
|
};
|
|
190
206
|
}
|
|
191
207
|
|
|
192
208
|
return {
|
|
193
|
-
request:
|
|
209
|
+
request: {
|
|
210
|
+
...normalizeDistinctCountIntent(text, normalizeAggregations(dataset, request)),
|
|
211
|
+
...(explicitLimit ? { limit: explicitLimit } : {}),
|
|
212
|
+
},
|
|
194
213
|
};
|
|
195
214
|
}
|
|
@@ -35,9 +35,15 @@ function formatSeriesLabel(value: string) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export function requestsVisualization(text: string): boolean {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const explicitChart =
|
|
39
|
+
/\b(?:charts?|graphs?|plots?|visuali[sz](?:e|ation)|diagram|histogram|scatter\s*plot|trends?)\b/iu.test(
|
|
40
|
+
text,
|
|
41
|
+
);
|
|
42
|
+
const visualPresentation =
|
|
43
|
+
/\b(?:show|display|draw|render|create|make)\b.{0,40}\b(?:distribution|breakdown|trend|comparison)\b/iu.test(
|
|
44
|
+
text,
|
|
45
|
+
);
|
|
46
|
+
return explicitChart || visualPresentation;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
function normalizedTerms(value: string) {
|