@yejiming/dsh-data-agent 0.0.13 → 0.1.1

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 (38) hide show
  1. package/README.en.md +46 -8
  2. package/README.md +46 -8
  3. package/conformance/dsh-ecosystem/inventory.json +26 -3
  4. package/conformance/dsh-ecosystem/restrictions.json +2 -2
  5. package/cordis.patch.yml +6 -3
  6. package/dsh-plugin.json +9 -4
  7. package/lib/catalog-DEJqOXRo.js +1944 -0
  8. package/lib/catalog-identity-CVftmvQL.js +96 -0
  9. package/lib/client.js +2214 -106
  10. package/lib/client.js.map +1 -1
  11. package/lib/command-CzzSPmag.js +1719 -0
  12. package/lib/command.js +2 -2
  13. package/lib/{connections-CHY4uB6z.js → connections-CFXOZTHZ.js} +223 -9
  14. package/lib/index.js +366 -16
  15. package/lib/routes.js +257 -4
  16. package/lib/{tool-ZTOS4B33.js → tool-DNkywSph.js} +364 -3
  17. package/lib/tool.js +1 -1
  18. package/lib/types/catalog-adapters.d.ts +52 -0
  19. package/lib/types/catalog-ai.d.ts +49 -0
  20. package/lib/types/catalog-command.d.ts +28 -0
  21. package/lib/types/catalog-identity.d.ts +23 -0
  22. package/lib/types/catalog-storage.d.ts +265 -0
  23. package/lib/types/catalog-tools.d.ts +5 -0
  24. package/lib/types/catalog-tui.d.ts +18 -0
  25. package/lib/types/catalog-types.d.ts +1376 -0
  26. package/lib/types/catalog.d.ts +59 -0
  27. package/lib/types/client/CatalogPanel.d.ts +15 -0
  28. package/lib/types/client/catalog-client.d.ts +57 -0
  29. package/lib/types/client/locales.d.ts +242 -0
  30. package/lib/types/command.d.ts +14 -3
  31. package/lib/types/connections.d.ts +9 -0
  32. package/lib/types/defaults.d.ts +22 -0
  33. package/lib/types/index.d.ts +42 -5
  34. package/lib/types/tui-connection-form.d.ts +11 -5
  35. package/package.json +4 -2
  36. package/preset/data-agent/agent.cordis.yml +9 -1
  37. package/lib/command-utC5MHd9.js +0 -916
  38. package/lib/defaults-Cngd8Tf8.js +0 -131
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Dialect-aware technical metadata adapters. Every statement is package-owned,
3
+ * read-only, bounded by the shared connection runner, and returns normalized
4
+ * observations rather than CLI text.
5
+ */
6
+ import type { DataAgentConnections, DatabaseConnection, DatabaseType } from './connections.ts';
7
+ import type { CatalogObservation, CatalogRelation, CatalogScope } from './catalog-types.ts';
8
+ export interface CatalogAdapterOptions {
9
+ maxTextChars: number;
10
+ schemaConcurrency: number;
11
+ assetConcurrency: number;
12
+ }
13
+ export interface CatalogAdapterContext {
14
+ connections: DataAgentConnections;
15
+ connection: DatabaseConnection;
16
+ sessionId: string;
17
+ sourceId: string;
18
+ runId: string;
19
+ scope: CatalogScope;
20
+ signal: AbortSignal;
21
+ options: CatalogAdapterOptions;
22
+ onProgress?(kind: 'schema' | 'relation' | 'field'): void;
23
+ }
24
+ export interface CatalogAdapterResult {
25
+ observations: CatalogObservation[];
26
+ relations: CatalogRelation[];
27
+ coverageComplete: boolean;
28
+ unavailableScopes: string[];
29
+ }
30
+ export interface CatalogAdapter {
31
+ readonly type: DatabaseType;
32
+ readonly capabilities: Readonly<Record<string, 'supported' | 'unsupported' | 'unavailable'>>;
33
+ scan(context: CatalogAdapterContext): Promise<CatalogAdapterResult>;
34
+ }
35
+ interface RawMetadataRow {
36
+ rowKind: 'relation' | 'column' | 'primary_key' | 'foreign_key' | 'index';
37
+ schema: string;
38
+ relation: string;
39
+ relationType: string;
40
+ relationComment: string;
41
+ column: string;
42
+ dataType: string;
43
+ nullable: string;
44
+ columnComment: string;
45
+ ordinal: string;
46
+ }
47
+ /** Registry contains an explicit adapter entry for every supported dialect. */
48
+ export declare function createCatalogAdapterRegistry(): Readonly<Record<DatabaseType, CatalogAdapter>>;
49
+ /** Pure SQL constructor used by fixture tests; values are SQL literals, never identifiers. */
50
+ export declare function buildCatalogMetadataSql(type: Exclude<DatabaseType, 'hive' | 'impala'>, database: string, schema: string, table?: string): string;
51
+ export declare function parseCatalogMetadataRows(type: DatabaseType, stdout: string): RawMetadataRow[];
52
+ export {};
@@ -0,0 +1,49 @@
1
+ /** DSH-native AI enrichment for table and field business-meaning candidates. */
2
+ import type { AgentRegistry } from '@deepseek-ai/dsh-agent';
3
+ import { type LlmCallConfig, type LlmRuntime } from '@deepseek-ai/dsh-llm';
4
+ export interface CatalogModelSelection {
5
+ provider: string;
6
+ model: string;
7
+ reasoningEffort?: LlmCallConfig['reasoningEffort'];
8
+ }
9
+ export interface CatalogMeaningFieldInput {
10
+ assetId: string;
11
+ name: string;
12
+ dataType?: string;
13
+ nullable?: boolean;
14
+ comment?: string;
15
+ keyKinds: string[];
16
+ }
17
+ export interface CatalogMeaningTableInput {
18
+ assetId: string;
19
+ schema: string;
20
+ name: string;
21
+ objectType: 'table' | 'view';
22
+ comment?: string;
23
+ fields: CatalogMeaningFieldInput[];
24
+ relations: Array<{
25
+ kind: string;
26
+ name?: string;
27
+ fromAssetId: string;
28
+ toAssetId?: string;
29
+ columnAssetIds: string[];
30
+ referencedColumnAssetIds?: string[];
31
+ }>;
32
+ }
33
+ export interface CatalogMeaningModelResult {
34
+ table: {
35
+ assetId: string;
36
+ meaning: string;
37
+ };
38
+ fields: Array<{
39
+ assetId: string;
40
+ meaning: string;
41
+ }>;
42
+ }
43
+ export interface CatalogMeaningGenerator {
44
+ capture(sessionId: string): CatalogModelSelection;
45
+ generate(selection: CatalogModelSelection, input: CatalogMeaningTableInput, signal: AbortSignal): Promise<CatalogMeaningModelResult>;
46
+ }
47
+ /** Resolve the exact current session model once, then use the host's configured LLM adapters and credentials. */
48
+ export declare function createDshCatalogMeaningGenerator(agents: AgentRegistry, llm: LlmRuntime): CatalogMeaningGenerator;
49
+ export declare function validateModelResult(raw: string, input: CatalogMeaningTableInput): CatalogMeaningModelResult;
@@ -0,0 +1,28 @@
1
+ /** Preset-scoped `/catalog` human command adapter. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import type { CommandInvocation, CommandResult } from '@deepseek-ai/dsh-commands';
4
+ import type { CatalogScope } from './catalog-types.ts';
5
+ export declare const CATALOG_COMMAND_USAGE: string;
6
+ export type CatalogCommandAction = {
7
+ kind: 'scan';
8
+ scope?: CatalogScope;
9
+ } | {
10
+ kind: 'status';
11
+ runId?: string;
12
+ } | {
13
+ kind: 'cancel';
14
+ runId?: string;
15
+ } | {
16
+ kind: 'diff';
17
+ fromRunId?: string;
18
+ toRunId?: string;
19
+ } | {
20
+ kind: 'view';
21
+ };
22
+ export interface CatalogCommandPresentation {
23
+ watch(run: Awaited<ReturnType<Context['dataAgentCatalogScanner']['start']>>): void;
24
+ open(sessionId: string): boolean;
25
+ }
26
+ export declare function registerCatalogCommand(ctx: Context, presentation?: CatalogCommandPresentation): () => void;
27
+ export declare function executeCatalogCommand(ctx: Context, invocation: CommandInvocation, presentation?: CatalogCommandPresentation): Promise<CommandResult>;
28
+ export declare function parseCatalogAction(rawInput: string): CatalogCommandAction;
@@ -0,0 +1,23 @@
1
+ /** Deterministic identity, normalization, and fingerprint helpers. */
2
+ import type { DatabaseType } from './database-types.ts';
3
+ import type { CatalogIdentity, CatalogTechnicalPayload } from './catalog-types.ts';
4
+ /** Strip unsafe controls, normalize Unicode, and enforce one explicit bound. */
5
+ export declare function normalizeCatalogText(value: string, maxChars: number): {
6
+ value: string;
7
+ truncated: boolean;
8
+ };
9
+ /** Normalize an observed identifier according to the dialect's identity rules. */
10
+ export declare function normalizeCatalogIdentifier(type: DatabaseType, value: string): string;
11
+ /** v1 source identity is deliberately the stable connection profile id. */
12
+ export declare function catalogSourceId(profileId: string): string;
13
+ /** Build canonical structured identity without parsing display paths. */
14
+ export declare function canonicalCatalogIdentity(type: DatabaseType, identity: CatalogIdentity): CatalogIdentity;
15
+ /** Stable opaque asset id derived only from structured identity components. */
16
+ export declare function catalogAssetId(type: DatabaseType, identity: CatalogIdentity): string;
17
+ export declare function catalogSemanticId(sourceId: string, kind: 'term' | 'metric', name: string): string;
18
+ /** Technical fingerprint excludes run-specific provenance and display-only truncation facts. */
19
+ export declare function catalogTechnicalFingerprint(payload: CatalogTechnicalPayload, status?: string): string;
20
+ /** Deterministic JSON encoding for hashes and cursor order keys. */
21
+ export declare function stableJson(value: unknown): string;
22
+ export declare function catalogRevisionId(assetId: string, revision: number): string;
23
+ export declare function catalogSemanticRevisionId(semanticId: string, version: number): string;
@@ -0,0 +1,265 @@
1
+ /** Durable versioned Catalog storage-domain and persistence adapter. */
2
+ import { type Domain } from '@deepseek-ai/dsh-storage-domain';
3
+ import { type CatalogAssetHead, type CatalogAssetRevision, type CatalogIndexRecord, type CatalogIndexState, type CatalogObservation, type CatalogRelation, type CatalogRun, type CatalogSemanticEntry, type CatalogSemanticRevision, type CatalogSource } from './catalog-types.ts';
4
+ export declare const CATALOG_STORAGE_DOMAIN = "data_agent_catalog";
5
+ export declare const CATALOG_STORAGE_VERSION = 1;
6
+ /** Strict schemas reject secret-shaped or raw-result fields at the durable boundary. */
7
+ export declare const catalogStorageSpec: {
8
+ name: string;
9
+ version: number;
10
+ tables: {
11
+ sources: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
12
+ id: string;
13
+ profileId: string;
14
+ type: "mysql" | "postgres" | "sqlite" | "oracle" | "hive" | "impala" | "clickhouse" | "doris" | "sqlserver";
15
+ name: string;
16
+ database: string;
17
+ credentialConfigured: boolean;
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ host?: string | undefined;
21
+ lastFullScanAt?: string | undefined;
22
+ lastPartialScanAt?: string | undefined;
23
+ }>;
24
+ scan_runs: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
25
+ id: string;
26
+ sourceId: string;
27
+ sessionId: string;
28
+ scope: {
29
+ kind: "source";
30
+ } | {
31
+ kind: "schema";
32
+ schema: string;
33
+ } | {
34
+ kind: "table";
35
+ schema: string;
36
+ table: string;
37
+ };
38
+ status: "queued" | "running" | "applying" | "succeeded" | "failed" | "cancelled" | "interrupted";
39
+ coverageComplete: boolean;
40
+ progress: {
41
+ schemas: number;
42
+ relations: number;
43
+ fields: number;
44
+ assets: number;
45
+ };
46
+ createdAt: string;
47
+ startedAt?: string | undefined;
48
+ completedAt?: string | undefined;
49
+ error?: string | undefined;
50
+ enrichment?: {
51
+ status: "queued" | "running" | "succeeded" | "failed" | "cancelled" | "partial";
52
+ provider: string;
53
+ model: string;
54
+ tablesTotal: number;
55
+ tablesCompleted: number;
56
+ tablesFailed: number;
57
+ candidatesGenerated: number;
58
+ reasoningEffort?: string | undefined;
59
+ startedAt?: string | undefined;
60
+ completedAt?: string | undefined;
61
+ error?: string | undefined;
62
+ } | undefined;
63
+ }>;
64
+ observations: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
65
+ runId: string;
66
+ sourceId: string;
67
+ assetId: string;
68
+ status: "observed" | "missing" | "unavailable";
69
+ fingerprint: string;
70
+ observedAt: string;
71
+ payload: {
72
+ identity: {
73
+ sourceId: string;
74
+ database: string;
75
+ schema: string;
76
+ kind: "table" | "schema" | "view" | "column" | "primary_key" | "foreign_key" | "index";
77
+ name: string;
78
+ relation?: string | undefined;
79
+ };
80
+ name: string;
81
+ path: string;
82
+ provenance: {
83
+ source: "database";
84
+ dialect: "mysql" | "postgres" | "sqlite" | "oracle" | "hive" | "impala" | "clickhouse" | "doris" | "sqlserver";
85
+ runId: string;
86
+ };
87
+ parentId?: string | undefined;
88
+ objectType?: "table" | "view" | undefined;
89
+ dataType?: string | undefined;
90
+ nullable?: boolean | undefined;
91
+ ordinal?: number | undefined;
92
+ comment?: string | undefined;
93
+ referencedAssetIds?: string[] | undefined;
94
+ attributes?: Record<string, string | number | boolean | null> | undefined;
95
+ capabilities?: Record<string, "unavailable" | "supported" | "unsupported"> | undefined;
96
+ truncatedFields?: string[] | undefined;
97
+ };
98
+ }>;
99
+ asset_revisions: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
100
+ id: string;
101
+ assetId: string;
102
+ sourceId: string;
103
+ runId: string;
104
+ revision: number;
105
+ status: "observed" | "missing" | "unavailable";
106
+ fingerprint: string;
107
+ observedAt: string;
108
+ changeSummary: string[];
109
+ payload: {
110
+ identity: {
111
+ sourceId: string;
112
+ database: string;
113
+ schema: string;
114
+ kind: "table" | "schema" | "view" | "column" | "primary_key" | "foreign_key" | "index";
115
+ name: string;
116
+ relation?: string | undefined;
117
+ };
118
+ name: string;
119
+ path: string;
120
+ provenance: {
121
+ source: "database";
122
+ dialect: "mysql" | "postgres" | "sqlite" | "oracle" | "hive" | "impala" | "clickhouse" | "doris" | "sqlserver";
123
+ runId: string;
124
+ };
125
+ parentId?: string | undefined;
126
+ objectType?: "table" | "view" | undefined;
127
+ dataType?: string | undefined;
128
+ nullable?: boolean | undefined;
129
+ ordinal?: number | undefined;
130
+ comment?: string | undefined;
131
+ referencedAssetIds?: string[] | undefined;
132
+ attributes?: Record<string, string | number | boolean | null> | undefined;
133
+ capabilities?: Record<string, "unavailable" | "supported" | "unsupported"> | undefined;
134
+ truncatedFields?: string[] | undefined;
135
+ };
136
+ previousRevisionId?: string | undefined;
137
+ }>;
138
+ asset_heads: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
139
+ assetId: string;
140
+ sourceId: string;
141
+ revisionIds: string[];
142
+ firstSeenAt: string;
143
+ lastSeenAt: string;
144
+ }>;
145
+ relations: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
146
+ id: string;
147
+ sourceId: string;
148
+ runId: string;
149
+ kind: "primary_key" | "foreign_key" | "index" | "parent";
150
+ fromAssetId: string;
151
+ columnAssetIds: string[];
152
+ observedAt: string;
153
+ toAssetId?: string | undefined;
154
+ name?: string | undefined;
155
+ referencedColumnAssetIds?: string[] | undefined;
156
+ }>;
157
+ semantic_entries: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
158
+ id: string;
159
+ sourceId: string;
160
+ kind: "metric" | "meaning" | "term";
161
+ currentVersion: number;
162
+ createdAt: string;
163
+ updatedAt: string;
164
+ }>;
165
+ semantic_revisions: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
166
+ id: string;
167
+ semanticId: string;
168
+ sourceId: string;
169
+ version: number;
170
+ createdAt: string;
171
+ definition: {
172
+ name: string;
173
+ aliases: string[];
174
+ description: string;
175
+ sourceAssetIds: string[];
176
+ status: "inferred" | "verified" | "needs_review" | "retired";
177
+ kind: "term";
178
+ owner?: string | undefined;
179
+ validFrom?: string | undefined;
180
+ validTo?: string | undefined;
181
+ revisionNote?: string | undefined;
182
+ verifiedAt?: string | undefined;
183
+ needsReviewReason?: string | undefined;
184
+ triggerRunId?: string | undefined;
185
+ } | {
186
+ formula: string;
187
+ grain: string;
188
+ filters: string[];
189
+ exclusions: string[];
190
+ name: string;
191
+ aliases: string[];
192
+ description: string;
193
+ sourceAssetIds: string[];
194
+ status: "inferred" | "verified" | "needs_review" | "retired";
195
+ kind: "metric";
196
+ timeFieldAssetId?: string | undefined;
197
+ owner?: string | undefined;
198
+ validFrom?: string | undefined;
199
+ validTo?: string | undefined;
200
+ revisionNote?: string | undefined;
201
+ verifiedAt?: string | undefined;
202
+ needsReviewReason?: string | undefined;
203
+ triggerRunId?: string | undefined;
204
+ } | {
205
+ targetAssetId: string;
206
+ targetKind: "table" | "view" | "column";
207
+ generatedBy: {
208
+ kind: "ai";
209
+ provider: string;
210
+ model: string;
211
+ runId: string;
212
+ };
213
+ name: string;
214
+ aliases: string[];
215
+ description: string;
216
+ sourceAssetIds: string[];
217
+ status: "inferred" | "verified" | "needs_review" | "retired";
218
+ kind: "meaning";
219
+ owner?: string | undefined;
220
+ validFrom?: string | undefined;
221
+ validTo?: string | undefined;
222
+ revisionNote?: string | undefined;
223
+ verifiedAt?: string | undefined;
224
+ needsReviewReason?: string | undefined;
225
+ triggerRunId?: string | undefined;
226
+ };
227
+ }>;
228
+ search_index: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, CatalogIndexRecord>;
229
+ index_state: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, CatalogIndexState>;
230
+ };
231
+ };
232
+ export type CatalogStorageDomain = Domain<typeof catalogStorageSpec>;
233
+ export interface CatalogPersistence {
234
+ getSource(id: string): CatalogSource | undefined;
235
+ listSources(): CatalogSource[];
236
+ putSource(source: CatalogSource): Promise<void>;
237
+ getRun(id: string): CatalogRun | undefined;
238
+ listRuns(sourceId?: string): CatalogRun[];
239
+ putRun(run: CatalogRun): Promise<void>;
240
+ putObservation(observation: CatalogObservation): Promise<void>;
241
+ listObservations(runId: string): CatalogObservation[];
242
+ deleteObservations(runId: string): Promise<void>;
243
+ getAssetHead(assetId: string): CatalogAssetHead | undefined;
244
+ listAssetHeads(sourceId?: string): CatalogAssetHead[];
245
+ putAssetHead(head: CatalogAssetHead): Promise<void>;
246
+ getAssetRevision(id: string): CatalogAssetRevision | undefined;
247
+ listAssetRevisions(assetId?: string): CatalogAssetRevision[];
248
+ putAssetRevision(revision: CatalogAssetRevision): Promise<void>;
249
+ listRelations(sourceId?: string): CatalogRelation[];
250
+ putRelation(relation: CatalogRelation): Promise<void>;
251
+ getSemanticEntry(id: string): CatalogSemanticEntry | undefined;
252
+ listSemanticEntries(sourceId?: string): CatalogSemanticEntry[];
253
+ putSemanticEntry(entry: CatalogSemanticEntry): Promise<void>;
254
+ getSemanticRevision(id: string): CatalogSemanticRevision | undefined;
255
+ listSemanticRevisions(semanticId?: string): CatalogSemanticRevision[];
256
+ putSemanticRevision(revision: CatalogSemanticRevision): Promise<void>;
257
+ listIndex(sourceId?: string): CatalogIndexRecord[];
258
+ putIndex(record: CatalogIndexRecord): Promise<void>;
259
+ clearIndex(sourceId?: string): Promise<void>;
260
+ getIndexState(): CatalogIndexState | undefined;
261
+ putIndexState(state: CatalogIndexState): Promise<void>;
262
+ }
263
+ export declare function createDomainCatalogPersistence(domain: CatalogStorageDomain): CatalogPersistence;
264
+ /** In-memory adapter used when Catalog persistence is explicitly disabled and by focused tests. */
265
+ export declare function createMemoryCatalogPersistence(): CatalogPersistence;
@@ -0,0 +1,5 @@
1
+ /** Read-only Catalog model tools. No scan or review service is injected here. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import { type JsonValue } from '@deepseek-ai/dsh-tools';
4
+ export declare function applyCatalogTools(ctx: Context): void;
5
+ export declare function sanitizeToolValue(value: unknown): JsonValue;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Optional dsh-tui presentation adapter for Catalog progress and read-only
3
+ * browsing. It only consumes the public `tuiStatus`/`tuiScenes` service
4
+ * shapes and deliberately has no runtime import from dsh-tui or React.
5
+ */
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import type { CatalogCommandPresentation } from './catalog-command.ts';
8
+ import type { CatalogAssetDetail, CatalogRun } from './catalog-types.ts';
9
+ export interface CatalogTuiAdapter extends CatalogCommandPresentation {
10
+ dispose(): void;
11
+ }
12
+ /** Create an adapter only from public optional services exposed by dsh-tui. */
13
+ export declare function createCatalogTuiAdapter(ctx: Context): CatalogTuiAdapter;
14
+ /** One bounded status-line projection shared by the adapter and tests. */
15
+ export declare function formatCatalogTuiStatus(run: CatalogRun): string;
16
+ export declare function isCatalogRunSettled(run: CatalogRun): boolean;
17
+ /** Text projection for the independently scrollable right pane. */
18
+ export declare function buildCatalogTuiDetailLines(detail: CatalogAssetDetail): string[];