@outsidedata/dolex 0.1.12 → 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.
- package/dist/src/analysis/rules.d.ts.map +1 -1
- package/dist/src/analysis/rules.js +8 -2
- package/dist/src/analysis/rules.js.map +1 -1
- package/dist/src/connectors/csv.d.ts.map +1 -1
- package/dist/src/connectors/csv.js +31 -1
- package/dist/src/connectors/csv.js.map +1 -1
- package/dist/src/connectors/dsl-compiler.d.ts +4 -0
- package/dist/src/connectors/dsl-compiler.d.ts.map +1 -1
- package/dist/src/connectors/dsl-compiler.js +51 -18
- package/dist/src/connectors/dsl-compiler.js.map +1 -1
- package/dist/src/connectors/dsl-validator.js +6 -1
- package/dist/src/connectors/dsl-validator.js.map +1 -1
- package/dist/src/connectors/js-aggregation.d.ts.map +1 -1
- package/dist/src/connectors/js-aggregation.js +18 -12
- package/dist/src/connectors/js-aggregation.js.map +1 -1
- package/dist/src/mcp/index.js +63 -29
- package/dist/src/mcp/index.js.map +1 -1
- package/dist/src/mcp/spec-store.d.ts +2 -1
- package/dist/src/mcp/spec-store.d.ts.map +1 -1
- package/dist/src/mcp/spec-store.js +4 -2
- package/dist/src/mcp/spec-store.js.map +1 -1
- package/dist/src/mcp/tools/dsl-schemas.d.ts +52 -51
- package/dist/src/mcp/tools/dsl-schemas.d.ts.map +1 -1
- package/dist/src/mcp/tools/dsl-schemas.js +1 -1
- package/dist/src/mcp/tools/dsl-schemas.js.map +1 -1
- package/dist/src/mcp/tools/list-patterns.js +2 -2
- package/dist/src/mcp/tools/list-patterns.js.map +1 -1
- package/dist/src/mcp/tools/query-source.d.ts +16 -16
- package/dist/src/mcp/tools/refine.d.ts +124 -15
- package/dist/src/mcp/tools/refine.d.ts.map +1 -1
- package/dist/src/mcp/tools/refine.js +335 -253
- package/dist/src/mcp/tools/refine.js.map +1 -1
- package/dist/src/mcp/tools/shared.d.ts +15 -2
- package/dist/src/mcp/tools/shared.d.ts.map +1 -1
- package/dist/src/mcp/tools/shared.js +64 -6
- package/dist/src/mcp/tools/shared.js.map +1 -1
- package/dist/src/mcp/tools/visualize-from-source.d.ts +52 -76
- package/dist/src/mcp/tools/visualize-from-source.d.ts.map +1 -1
- package/dist/src/mcp/tools/visualize-from-source.js +20 -5
- package/dist/src/mcp/tools/visualize-from-source.js.map +1 -1
- package/dist/src/mcp/tools/visualize.d.ts +45 -100
- package/dist/src/mcp/tools/visualize.d.ts.map +1 -1
- package/dist/src/mcp/tools/visualize.js +19 -19
- package/dist/src/mcp/tools/visualize.js.map +1 -1
- package/dist/src/patterns/definitions/comparison/grouped-bar.js +5 -5
- package/dist/src/patterns/definitions/comparison/grouped-bar.js.map +1 -1
- package/dist/src/patterns/definitions/composition/waffle.d.ts.map +1 -1
- package/dist/src/patterns/definitions/composition/waffle.js +17 -3
- package/dist/src/patterns/definitions/composition/waffle.js.map +1 -1
- package/dist/src/patterns/definitions/distribution/strip-plot.d.ts.map +1 -1
- package/dist/src/patterns/definitions/distribution/strip-plot.js +12 -3
- package/dist/src/patterns/definitions/distribution/strip-plot.js.map +1 -1
- package/dist/src/patterns/definitions/time/sparkline-grid.js +2 -2
- package/dist/src/patterns/definitions/time/sparkline-grid.js.map +1 -1
- package/dist/src/patterns/selector.d.ts.map +1 -1
- package/dist/src/patterns/selector.js +46 -1
- package/dist/src/patterns/selector.js.map +1 -1
- package/dist/src/renderers/d3/comparison/bar.d.ts.map +1 -1
- package/dist/src/renderers/d3/comparison/bar.js +24 -1
- package/dist/src/renderers/d3/comparison/bar.js.map +1 -1
- package/dist/src/renderers/d3/comparison/grouped-bar.d.ts.map +1 -1
- package/dist/src/renderers/d3/comparison/grouped-bar.js +9 -4
- package/dist/src/renderers/d3/comparison/grouped-bar.js.map +1 -1
- package/dist/src/renderers/d3/composition/donut.d.ts.map +1 -1
- package/dist/src/renderers/d3/composition/donut.js +12 -0
- package/dist/src/renderers/d3/composition/donut.js.map +1 -1
- package/dist/src/renderers/d3/composition/stacked-bar.d.ts.map +1 -1
- package/dist/src/renderers/d3/composition/stacked-bar.js +4 -0
- package/dist/src/renderers/d3/composition/stacked-bar.js.map +1 -1
- package/dist/src/renderers/d3/composition/treemap.js +2 -1
- package/dist/src/renderers/d3/composition/treemap.js.map +1 -1
- package/dist/src/renderers/d3/distribution/beeswarm.d.ts.map +1 -1
- package/dist/src/renderers/d3/distribution/beeswarm.js +8 -0
- package/dist/src/renderers/d3/distribution/beeswarm.js.map +1 -1
- package/dist/src/renderers/d3/distribution/histogram.js +36 -2
- package/dist/src/renderers/d3/distribution/histogram.js.map +1 -1
- package/dist/src/renderers/d3/flow/funnel.d.ts.map +1 -1
- package/dist/src/renderers/d3/flow/funnel.js +4 -0
- package/dist/src/renderers/d3/flow/funnel.js.map +1 -1
- package/dist/src/renderers/d3/flow/sankey-layout.js +20 -3
- package/dist/src/renderers/d3/flow/sankey-layout.js.map +1 -1
- package/dist/src/renderers/d3/heatmap.d.ts.map +1 -1
- package/dist/src/renderers/d3/heatmap.js +18 -3
- package/dist/src/renderers/d3/heatmap.js.map +1 -1
- package/dist/src/renderers/d3/radar.d.ts.map +1 -1
- package/dist/src/renderers/d3/radar.js +3 -1
- package/dist/src/renderers/d3/radar.js.map +1 -1
- package/dist/src/renderers/d3/relationship.d.ts.map +1 -1
- package/dist/src/renderers/d3/relationship.js +29 -7
- package/dist/src/renderers/d3/relationship.js.map +1 -1
- package/dist/src/renderers/d3/shared.js +7 -7
- package/dist/src/renderers/d3/shared.js.map +1 -1
- package/dist/src/renderers/d3/time/area.js +21 -7
- package/dist/src/renderers/d3/time/area.js.map +1 -1
- package/dist/src/renderers/d3/time/calendar-heatmap.js +6 -0
- package/dist/src/renderers/d3/time/calendar-heatmap.js.map +1 -1
- package/dist/src/renderers/d3/time/horizon-chart.d.ts.map +1 -1
- package/dist/src/renderers/d3/time/horizon-chart.js +10 -0
- package/dist/src/renderers/d3/time/horizon-chart.js.map +1 -1
- package/dist/src/renderers/d3/time/line.d.ts.map +1 -1
- package/dist/src/renderers/d3/time/line.js +27 -7
- package/dist/src/renderers/d3/time/line.js.map +1 -1
- package/dist/src/renderers/d3/time/small-multiples.js +8 -0
- package/dist/src/renderers/d3/time/small-multiples.js.map +1 -1
- package/dist/src/renderers/d3/time/sparkline-grid.d.ts.map +1 -1
- package/dist/src/renderers/d3/time/sparkline-grid.js +5 -2
- package/dist/src/renderers/d3/time/sparkline-grid.js.map +1 -1
- package/dist/src/renderers/d3/time/stream-graph.js +6 -0
- package/dist/src/renderers/d3/time/stream-graph.js.map +1 -1
- package/dist/src/renderers/html/_generated/bundles.d.ts +39 -39
- package/dist/src/renderers/html/_generated/bundles.d.ts.map +1 -1
- package/dist/src/renderers/html/_generated/bundles.js +39 -39
- package/dist/src/renderers/html/_generated/bundles.js.map +1 -1
- package/dist/src/renderers/html/template.js +2 -2
- package/dist/src/renderers/html/template.js.map +1 -1
- package/dist/src/types.d.ts +30 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -1
- package/src/analysis/rules.ts +10 -2
- package/src/connectors/csv.ts +31 -1
- package/src/connectors/dsl-compiler.ts +56 -20
- package/src/connectors/dsl-validator.ts +6 -1
- package/src/connectors/js-aggregation.ts +16 -11
- package/src/mcp/index.ts +63 -29
- package/src/mcp/spec-store.ts +5 -1
- package/src/mcp/tools/dsl-schemas.ts +1 -1
- package/src/mcp/tools/list-patterns.ts +2 -2
- package/src/mcp/tools/refine.ts +333 -258
- package/src/mcp/tools/shared.ts +70 -7
- package/src/mcp/tools/visualize-from-source.ts +20 -5
- package/src/mcp/tools/visualize.ts +22 -22
- package/src/patterns/definitions/comparison/grouped-bar.ts +5 -5
- package/src/patterns/definitions/composition/waffle.ts +17 -3
- package/src/patterns/definitions/distribution/strip-plot.ts +12 -3
- package/src/patterns/definitions/time/sparkline-grid.ts +2 -2
- package/src/patterns/selector.ts +47 -1
- package/src/renderers/d3/comparison/bar.ts +24 -1
- package/src/renderers/d3/comparison/grouped-bar.ts +9 -4
- package/src/renderers/d3/composition/donut.ts +14 -0
- package/src/renderers/d3/composition/stacked-bar.ts +5 -0
- package/src/renderers/d3/composition/treemap.ts +2 -1
- package/src/renderers/d3/distribution/beeswarm.ts +12 -0
- package/src/renderers/d3/distribution/histogram.ts +44 -2
- package/src/renderers/d3/flow/funnel.ts +8 -0
- package/src/renderers/d3/flow/sankey-layout.ts +23 -3
- package/src/renderers/d3/heatmap.ts +20 -2
- package/src/renderers/d3/radar.ts +4 -1
- package/src/renderers/d3/relationship.ts +31 -6
- package/src/renderers/d3/shared.ts +7 -7
- package/src/renderers/d3/time/area.ts +22 -7
- package/src/renderers/d3/time/calendar-heatmap.ts +5 -0
- package/src/renderers/d3/time/horizon-chart.ts +11 -0
- package/src/renderers/d3/time/line.ts +24 -9
- package/src/renderers/d3/time/small-multiples.ts +6 -0
- package/src/renderers/d3/time/sparkline-grid.ts +5 -2
- package/src/renderers/d3/time/stream-graph.ts +5 -0
- package/src/renderers/html/_generated/bundles.ts +39 -39
- package/src/renderers/html/template.ts +2 -2
- package/src/types.ts +18 -2
- package/dist/src/mcp/tools/connect-data.d.ts +0 -14
- package/dist/src/mcp/tools/connect-data.d.ts.map +0 -1
- package/dist/src/mcp/tools/connect-data.js +0 -80
- package/dist/src/mcp/tools/connect-data.js.map +0 -1
- package/src/mcp/tools/connect-data.ts +0 -94
|
@@ -572,7 +572,7 @@ const MAX_EMBED_ROWS = 10_000;
|
|
|
572
572
|
|
|
573
573
|
export function buildHtml(spec: VisualizationSpec, renderFunctionBody: string): string {
|
|
574
574
|
const cappedSpec = capDataRows(spec);
|
|
575
|
-
const specJson = JSON.stringify(cappedSpec);
|
|
575
|
+
const specJson = JSON.stringify(cappedSpec).replace(/<\//g, '<\\/');
|
|
576
576
|
|
|
577
577
|
return `<!DOCTYPE html>
|
|
578
578
|
<html lang="en">
|
|
@@ -682,7 +682,7 @@ export function buildHtmlFromBundle(
|
|
|
682
682
|
options?: { extraScripts?: string[] }
|
|
683
683
|
): string {
|
|
684
684
|
const cappedSpec = capDataRows(spec);
|
|
685
|
-
const specJson = JSON.stringify(cappedSpec);
|
|
685
|
+
const specJson = JSON.stringify(cappedSpec).replace(/<\//g, '<\\/');
|
|
686
686
|
const extraScriptTags = (options?.extraScripts || [])
|
|
687
687
|
.map(src => `<script src="${src}"><\/script>`)
|
|
688
688
|
.join('\n');
|
package/src/types.ts
CHANGED
|
@@ -375,13 +375,29 @@ export interface VisualizeOutput {
|
|
|
375
375
|
|
|
376
376
|
export interface RefineInput {
|
|
377
377
|
specId: string;
|
|
378
|
-
|
|
379
|
-
|
|
378
|
+
sort?: { field?: string; direction: 'asc' | 'desc' } | null;
|
|
379
|
+
limit?: number;
|
|
380
|
+
filter?: Array<{ field: string; op?: string; values: (string | number)[] }>;
|
|
381
|
+
flip?: boolean;
|
|
382
|
+
title?: string;
|
|
383
|
+
subtitle?: string;
|
|
384
|
+
xLabel?: string;
|
|
385
|
+
yLabel?: string;
|
|
386
|
+
palette?: string;
|
|
387
|
+
highlight?: { values: (string | number)[]; color?: string | string[]; mutedColor?: string; mutedOpacity?: number } | null;
|
|
388
|
+
colorField?: string;
|
|
389
|
+
flowColorBy?: 'source' | 'target';
|
|
390
|
+
format?: string;
|
|
391
|
+
switchPattern?: string;
|
|
392
|
+
removeTable?: boolean;
|
|
393
|
+
layout?: 'rows' | 'columns';
|
|
394
|
+
hideColumns?: string[];
|
|
380
395
|
}
|
|
381
396
|
|
|
382
397
|
export interface RefineOutput {
|
|
383
398
|
spec: VisualizationSpec | CompoundVisualizationSpec;
|
|
384
399
|
changes: string[];
|
|
400
|
+
notes: string[];
|
|
385
401
|
}
|
|
386
402
|
|
|
387
403
|
// ─── COMPOUND VISUALIZATION TYPES ────────────────────────────────────────────
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
export declare const connectDataInputSchema: z.ZodObject<{
|
|
4
|
-
path: z.ZodOptional<z.ZodString>;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
path?: string | undefined;
|
|
7
|
-
}, {
|
|
8
|
-
path?: string | undefined;
|
|
9
|
-
}>;
|
|
10
|
-
export declare function handleConnectData(deps: {
|
|
11
|
-
sourceManager: any;
|
|
12
|
-
server: McpServer;
|
|
13
|
-
}): (args: z.infer<typeof connectDataInputSchema>, _extra: any) => Promise<import("./shared.js").McpResponse>;
|
|
14
|
-
//# sourceMappingURL=connect-data.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect-data.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/connect-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,eAAO,MAAM,sBAAsB;;;;;;EAEjC,CAAC;AAwBH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,aAAa,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,IAGjE,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,EAAE,QAAQ,GAAG,gDAyDxE"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import { errorResponse } from './shared.js';
|
|
5
|
-
import { handleAddSource, isSandboxPath } from './sources.js';
|
|
6
|
-
export const connectDataInputSchema = z.object({
|
|
7
|
-
path: z.string().optional().describe('File or directory path. If omitted, Dolex will ask the user directly.'),
|
|
8
|
-
});
|
|
9
|
-
function detectType(filePath) {
|
|
10
|
-
const stat = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
11
|
-
if (!stat)
|
|
12
|
-
return 'csv';
|
|
13
|
-
if (stat.isDirectory()) {
|
|
14
|
-
const files = fs.readdirSync(filePath);
|
|
15
|
-
if (files.some(f => f.endsWith('.sqlite') || f.endsWith('.db') || f.endsWith('.sqlite3')))
|
|
16
|
-
return 'sqlite';
|
|
17
|
-
return 'csv';
|
|
18
|
-
}
|
|
19
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
20
|
-
if (ext === '.sqlite' || ext === '.db' || ext === '.sqlite3')
|
|
21
|
-
return 'sqlite';
|
|
22
|
-
return 'csv';
|
|
23
|
-
}
|
|
24
|
-
function deriveName(filePath) {
|
|
25
|
-
const base = path.basename(filePath, path.extname(filePath));
|
|
26
|
-
return base
|
|
27
|
-
.replace(/[-_]/g, ' ')
|
|
28
|
-
.replace(/\b\w/g, c => c.toUpperCase());
|
|
29
|
-
}
|
|
30
|
-
export function handleConnectData(deps) {
|
|
31
|
-
const addSource = handleAddSource({ sourceManager: deps.sourceManager });
|
|
32
|
-
return async (args, _extra) => {
|
|
33
|
-
let filePath = args.path;
|
|
34
|
-
if (!filePath) {
|
|
35
|
-
try {
|
|
36
|
-
const result = await deps.server.server.elicitInput({
|
|
37
|
-
message: 'What data would you like to analyze?',
|
|
38
|
-
requestedSchema: {
|
|
39
|
-
type: 'object',
|
|
40
|
-
properties: {
|
|
41
|
-
path: {
|
|
42
|
-
type: 'string',
|
|
43
|
-
title: 'File or directory path',
|
|
44
|
-
description: 'e.g. /Users/you/Downloads/sales.csv or ~/data/my-project/',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
required: ['path'],
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
if (result.action !== 'accept' || !result.content?.path) {
|
|
51
|
-
return errorResponse('No path provided. To connect data, provide a file or directory path.');
|
|
52
|
-
}
|
|
53
|
-
filePath = result.content.path;
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
return errorResponse('This client does not support interactive input. '
|
|
57
|
-
+ 'Use add_source instead and pass the file path directly.');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
filePath = filePath.replace(/^~/, process.env.HOME || '');
|
|
61
|
-
if (isSandboxPath(filePath)) {
|
|
62
|
-
return errorResponse('This path looks like a cloud sandbox path, not a local filesystem path. '
|
|
63
|
-
+ 'Dolex runs on the user\'s machine and can access any local file — but not cloud sandbox uploads. '
|
|
64
|
-
+ 'Please provide the real local path.');
|
|
65
|
-
}
|
|
66
|
-
const stat = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
67
|
-
if (!stat) {
|
|
68
|
-
return errorResponse(`Path not found: ${filePath}`);
|
|
69
|
-
}
|
|
70
|
-
const type = detectType(filePath);
|
|
71
|
-
const name = deriveName(filePath);
|
|
72
|
-
return addSource({
|
|
73
|
-
name,
|
|
74
|
-
type,
|
|
75
|
-
config: { type, path: filePath },
|
|
76
|
-
detail: 'full',
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=connect-data.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect-data.js","sourceRoot":"","sources":["../../../../src/mcp/tools/connect-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uEAAuE,CAAC;CAC9G,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,QAAgB;IAClC,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,cAAc,EA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M,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QAElC,OAAO,SAAS,CAAC;YACf,IAAI;YACJ,IAAI;YACJ,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAS;YACvC,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
-
import { errorResponse } from './shared.js';
|
|
6
|
-
import { handleAddSource, isSandboxPath } from './sources.js';
|
|
7
|
-
|
|
8
|
-
export const connectDataInputSchema = z.object({
|
|
9
|
-
path: z.string().optional().describe('File or directory path. If omitted, Dolex will ask the user directly.'),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
function detectType(filePath: string): 'csv' | 'sqlite' {
|
|
13
|
-
const stat = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
14
|
-
if (!stat) return 'csv';
|
|
15
|
-
|
|
16
|
-
if (stat.isDirectory()) {
|
|
17
|
-
const files = fs.readdirSync(filePath);
|
|
18
|
-
if (files.some(f => f.endsWith('.sqlite') || f.endsWith('.db') || f.endsWith('.sqlite3'))) return 'sqlite';
|
|
19
|
-
return 'csv';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
23
|
-
if (ext === '.sqlite' || ext === '.db' || ext === '.sqlite3') return 'sqlite';
|
|
24
|
-
return 'csv';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function deriveName(filePath: string): string {
|
|
28
|
-
const base = path.basename(filePath, path.extname(filePath));
|
|
29
|
-
return base
|
|
30
|
-
.replace(/[-_]/g, ' ')
|
|
31
|
-
.replace(/\b\w/g, c => c.toUpperCase());
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function handleConnectData(deps: { sourceManager: any; server: McpServer }) {
|
|
35
|
-
const addSource = handleAddSource({ sourceManager: deps.sourceManager });
|
|
36
|
-
|
|
37
|
-
return async (args: z.infer<typeof connectDataInputSchema>, _extra: any) => {
|
|
38
|
-
let filePath = args.path;
|
|
39
|
-
|
|
40
|
-
if (!filePath) {
|
|
41
|
-
try {
|
|
42
|
-
const result = await deps.server.server.elicitInput({
|
|
43
|
-
message: 'What data would you like to analyze?',
|
|
44
|
-
requestedSchema: {
|
|
45
|
-
type: 'object' as const,
|
|
46
|
-
properties: {
|
|
47
|
-
path: {
|
|
48
|
-
type: 'string' as const,
|
|
49
|
-
title: 'File or directory path',
|
|
50
|
-
description: 'e.g. /Users/you/Downloads/sales.csv or ~/data/my-project/',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
required: ['path'],
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (result.action !== 'accept' || !result.content?.path) {
|
|
58
|
-
return errorResponse('No path provided. To connect data, provide a file or directory path.');
|
|
59
|
-
}
|
|
60
|
-
filePath = result.content.path as string;
|
|
61
|
-
} catch {
|
|
62
|
-
return errorResponse(
|
|
63
|
-
'This client does not support interactive input. '
|
|
64
|
-
+ 'Use add_source instead and pass the file path directly.'
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
filePath = filePath.replace(/^~/, process.env.HOME || '');
|
|
70
|
-
|
|
71
|
-
if (isSandboxPath(filePath)) {
|
|
72
|
-
return errorResponse(
|
|
73
|
-
'This path looks like a cloud sandbox path, not a local filesystem path. '
|
|
74
|
-
+ 'Dolex runs on the user\'s machine and can access any local file — but not cloud sandbox uploads. '
|
|
75
|
-
+ 'Please provide the real local path.'
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const stat = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
80
|
-
if (!stat) {
|
|
81
|
-
return errorResponse(`Path not found: ${filePath}`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const type = detectType(filePath);
|
|
85
|
-
const name = deriveName(filePath);
|
|
86
|
-
|
|
87
|
-
return addSource({
|
|
88
|
-
name,
|
|
89
|
-
type,
|
|
90
|
-
config: { type, path: filePath } as any,
|
|
91
|
-
detail: 'full',
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
}
|