@axiom-lattice/examples-deep_research 1.0.26 → 1.0.28

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 (34) hide show
  1. package/.env +6 -0
  2. package/.turbo/turbo-build.log +5 -5
  3. package/CHANGELOG.md +22 -0
  4. package/DATABASE_CONFIG_SETUP.md +290 -0
  5. package/dist/index.js +146 -22
  6. package/dist/index.js.map +1 -1
  7. package/package.json +5 -5
  8. package/src/agents/data_agent/skills/business-analytics/README.md +121 -0
  9. package/src/agents/data_agent/skills/business-analytics/SKILL.md +230 -0
  10. package/src/agents/data_agent/skills/business-analytics/examples.md +295 -0
  11. package/src/agents/data_agent/skills/business-analytics/reference.md +240 -0
  12. package/src/agents/data_agent/skills/business-analytics/resources/data/sample.json +66 -0
  13. package/src/agents/data_agent/skills/business-analytics/resources/prompts/analyze.txt +128 -0
  14. package/src/agents/data_agent/skills/business-analytics/resources/templates/report-template.md +260 -0
  15. package/src/agents/data_agent/skills/chart-markdown/SKILL.md +91 -0
  16. package/src/agents/data_agent/skills/chart-markdown/resources/best-practices/README.md +16 -0
  17. package/src/agents/data_agent/skills/chart-markdown/resources/best-practices/data-patterns.md +14 -0
  18. package/src/agents/data_agent/skills/chart-markdown/resources/best-practices/finance.md +7 -0
  19. package/src/agents/data_agent/skills/chart-markdown/resources/best-practices/formatting.md +14 -0
  20. package/src/agents/data_agent/skills/chart-markdown/resources/best-practices/hr-people.md +7 -0
  21. package/src/agents/data_agent/skills/chart-markdown/resources/best-practices/marketing-growth.md +7 -0
  22. package/src/agents/data_agent/skills/chart-markdown/resources/best-practices/operations-supply-chain.md +7 -0
  23. package/src/agents/data_agent/skills/chart-markdown/resources/best-practices/sales-retail.md +8 -0
  24. package/src/agents/data_agent/skills/chart-markdown/resources/examples.md +80 -0
  25. package/src/agents/data_agent/skills/financial-analysis/SKILL.md +268 -0
  26. package/src/agents/data_agent/skills/metrics-query/SKILL.md +296 -0
  27. package/src/agents/data_agent/skills/operations-analysis/SKILL.md +432 -0
  28. package/src/agents/data_agent/skills/sales-analysis/SKILL.md +350 -0
  29. package/src/agents/index.ts +1 -0
  30. package/src/agents/research_team/index.ts +93 -0
  31. package/src/index-with-auth.ts +122 -0
  32. package/src/index.ts +93 -3
  33. package/src/agents/data_agent/skills/sql-query/SKILL.md +0 -58
  34. package/src/agents/data_agent/skills/test/SKILL.md +0 -9
@@ -0,0 +1,296 @@
1
+ ---
2
+ name: metrics-query
3
+ description: Query business metrics using the three-step workflow. Discover available metrics, understand metric definitions, and execute queries with proper filters and groupings.
4
+ metadata:
5
+ category: data_analysis
6
+ tools:
7
+ - query_metrics_list
8
+ - query_metric_definition
9
+ - query_semantic_metric_data
10
+ ---
11
+
12
+ ## Overview: The Three-Step Loop
13
+
14
+ 1. **query_metrics_list** → Discover what metrics exist
15
+ 2. **query_metric_definition** → Understand one metric before querying it
16
+ 3. **query_semantic_metric_data** → Execute the query with the right parameters
17
+
18
+ Repeat steps 2-3 for each metric the user asks about. Drill-down means running step 3 multiple times with progressively narrower filters.
19
+
20
+ ## Step 1 — Discover Available Metrics
21
+
22
+ **Tool**: `query_metrics_list`
23
+
24
+ **Parameters**:
25
+ - `serverKey` (required): Target semantic metrics server
26
+ - `datasourceIds` (optional): Array of datasource IDs to query. If not provided, uses all selected datasources.
27
+
28
+ **Response Fields**:
29
+ | Field | Description | Usage |
30
+ |-------|-------------|-------|
31
+ | metricName | Metric identifier | Pass to query_metric_definition and query_semantic_metric_data |
32
+ | domain | Metric category | Groups related metrics (e.g., sales_performance, pricing_and_margin) |
33
+ | shortDesc | One-line description | Present to user |
34
+ | displayName | Human-readable name | Display in results |
35
+
36
+ **When to Use**:
37
+ - User asks about metrics without specifying exact names
38
+ - Starting any metrics-related conversation
39
+ - Finding metrics by domain or keywords
40
+
41
+ **Next Step**: After finding relevant metrics, call `query_metric_definition` with the `metricName`.
42
+
43
+ ## Step 2 — Read the Metric Definition
44
+
45
+ **Tool**: `query_metric_definition`
46
+
47
+ **Parameters**:
48
+ - `serverKey` (required): Target semantic metrics server
49
+ - `metricName` (required): The name of the metric to get definition for
50
+ - `datasourceId` (optional): Specific datasource ID to search in. If not provided, searches all selected datasources.
51
+
52
+ This response is self-contained. Everything you need to write a correct query is here.
53
+
54
+ ### 2.1 Identify the Time Axis (defaultTimeContext)
55
+
56
+ The `defaultTimeContext` tells you the primary date field and exactly how to use it:
57
+
58
+ ```json
59
+ {
60
+ "timeDimension": "DocDate",
61
+ "label": "单据日期",
62
+ "granularity": "month",
63
+ "window": "current_month",
64
+ "supportedGrains": ["day", "week", "month", "year"]
65
+ }
66
+ ```
67
+
68
+ **Rules**:
69
+ - To filter by date: Copy the pattern and replace values
70
+ ```json
71
+ {"dimension": "DocDate", "operator": "BETWEEN", "values": ["2025-01-01", "2025-12-31"]}
72
+ ```
73
+ - To group by time: Use `"{timeDimension}__{grain}"` format (e.g., `"DocDate__month"`)
74
+
75
+ ### 2.2 Identify Available Dimensions (supportedDimensions)
76
+
77
+ `supportedDimensions` lists every axis available for GROUP BY and filtering. Each entry has:
78
+ - `dim_id`: Use this (NOT `field_name`) in filters and groupBy
79
+ - `field_name`: Human-readable field name
80
+ - `type`: `"categorical"` (strings) or `"datetime"` (dates)
81
+
82
+ **Categorical Dimensions**:
83
+ - Values are strings
84
+ - Use `IN` for multiple values, `EQ` / `NEQ` for single
85
+ - Example: `{"dimension": "org_region", "operator": "IN", "values": ["华东", "华南"]}`
86
+
87
+ **Datetime Dimensions**:
88
+ - Values are YYYY-MM-DD format
89
+ - Use `BETWEEN` for ranges, `GT` / `LT` for open-ended
90
+ - Group format: `"{dim_id}__{grain}"` where grain is lowercase: `day`, `week`, `month`, `year`
91
+ - Example groupBy: `["DocDate__month"]`
92
+
93
+ ### 2.3 Understand Result Polarity (aiAgentContext.polarity)
94
+
95
+ - `"positive"` — Higher value is better (e.g., order amount, delivery qty)
96
+ - `"negative"` — Lower value is better (e.g., discount rate, return amount)
97
+
98
+ Use this when summarizing results to the user (e.g., "the discount rate increased, which is a negative sign").
99
+
100
+ **Next Step**: Call `query_semantic_metric_data` with parameters derived from this definition.
101
+
102
+ ## Step 3 — Execute a Query
103
+
104
+ **Tool**: `query_semantic_metric_data`
105
+
106
+ **Parameters**:
107
+ - `serverKey` (required): Target semantic metrics server
108
+ - `datasourceId` (required): The data source ID to query metrics from
109
+ - `metrics` (required): Array of metric names to query (e.g., `["net_sales_amt", "gross_profit"]`)
110
+ - `groupBy` (optional): Array of dimensions to group by (e.g., `["DocDate__month", "org_region"]`)
111
+ - `filters` (optional): Array of filters to apply
112
+ - `orderBy` (optional): Array of sort specifications
113
+ - `limit` (optional): Maximum number of results (default: 1000)
114
+ - `debug` (optional): Set to `true` to receive executed SQL for verification
115
+
116
+ **Full Request Schema**:
117
+ ```json
118
+ {
119
+ "serverKey": "your_server",
120
+ "datasourceId": "1",
121
+ "metrics": ["metric_name"],
122
+ "groupBy": ["dim_id or DocDate__grain"],
123
+ "filters": [{"dimension": "dim_id", "operator": "OP", "values": ["..."]}],
124
+ "orderBy": [{"field": "field_name", "direction": "ASC|DESC"}],
125
+ "limit": 100,
126
+ "debug": false
127
+ }
128
+ ```
129
+
130
+ ### Filter Operator Reference
131
+
132
+ | Operator | Applies To | Values Array |
133
+ |----------|------------|--------------|
134
+ | BETWEEN | datetime, number | [min, max] (inclusive) |
135
+ | IN | categorical | ["v1", "v2", ...] |
136
+ | EQ | any | ["v"] |
137
+ | NEQ | any | ["v"] |
138
+ | GT / GTE | datetime, number | ["v"] |
139
+ | LT / LTE | datetime, number | ["v"] |
140
+ | LIKE | string | ["%pattern%"] |
141
+ | NOT_NULL | any | [] |
142
+
143
+ ## Workflow Patterns
144
+
145
+ ### Pattern A — Time Trend (most common first query)
146
+
147
+ **Goal**: Show how a metric changes over time within a period.
148
+
149
+ ```json
150
+ {
151
+ "serverKey": "your_server",
152
+ "datasourceId": "1",
153
+ "metrics": ["order_amt_tax_inc"],
154
+ "groupBy": ["DocDate__month"],
155
+ "filters": [{"dimension": "DocDate", "operator": "BETWEEN", "values": ["2025-01-01", "2025-12-31"]}],
156
+ "orderBy": [{"field": "DocDate__month", "direction": "ASC"}]
157
+ }
158
+ ```
159
+
160
+ Use `DocDate__week` or `DocDate__day` for shorter time windows.
161
+
162
+ ### Pattern B — Dimension Breakdown (who/what is top or bottom)
163
+
164
+ **Goal**: Rank performance across a categorical dimension in a fixed period.
165
+
166
+ ```json
167
+ {
168
+ "serverKey": "your_server",
169
+ "datasourceId": "1",
170
+ "metrics": ["order_amt_tax_inc"],
171
+ "groupBy": ["org_region"],
172
+ "filters": [{"dimension": "DocDate", "operator": "BETWEEN", "values": ["2025-01-01", "2025-03-31"]}],
173
+ "orderBy": [{"field": "value", "direction": "DESC"}],
174
+ "limit": 10
175
+ }
176
+ ```
177
+
178
+ Pick `dim_id` values from `supportedDimensions` in the detail response.
179
+
180
+ ### Pattern C — Drill Down (zoom into an anomaly)
181
+
182
+ **Goal**: After Pattern A reveals a bad month, find which segment caused it.
183
+
184
+ **Step 1**: Find the anomaly month using Pattern A
185
+
186
+ **Step 2**: Drill into that month by adding a categorical dimension:
187
+
188
+ ```json
189
+ {
190
+ "serverKey": "your_server",
191
+ "datasourceId": "1",
192
+ "metrics": ["order_amt_tax_inc"],
193
+ "groupBy": ["sales_person"],
194
+ "filters": [
195
+ {"dimension": "DocDate", "operator": "BETWEEN", "values": ["2025-06-01", "2025-06-30"]},
196
+ {"dimension": "org_region", "operator": "EQ", "values": ["华东"]}
197
+ ],
198
+ "orderBy": [{"field": "value", "direction": "ASC"}]
199
+ }
200
+ ```
201
+
202
+ **Step 3** (optional): Add a second groupBy dimension to cross-analyze:
203
+ ```json
204
+ {
205
+ "groupBy": ["sales_person", "product_category"],
206
+ ...
207
+ }
208
+ ```
209
+
210
+ ### Pattern D — Multi-Metric Comparison
211
+
212
+ **Goal**: Query two or more metrics in one call to compare them side-by-side.
213
+
214
+ ```json
215
+ {
216
+ "serverKey": "your_server",
217
+ "datasourceId": "1",
218
+ "metrics": ["order_amt_tax_inc", "net_sales_amt"],
219
+ "groupBy": ["DocDate__month"],
220
+ "filters": [{"dimension": "DocDate", "operator": "BETWEEN", "values": ["2025-01-01", "2025-12-31"]}],
221
+ "orderBy": [{"field": "DocDate__month", "direction": "ASC"}]
222
+ }
223
+ ```
224
+
225
+ The response contains one `results[]` entry per metric. Each entry has its own `rows[]` and `metricName` label.
226
+
227
+ ### Pattern E — Time × Dimension Cross-Analysis
228
+
229
+ **Goal**: See how a dimension behaves across time (e.g., monthly sales by region).
230
+
231
+ ```json
232
+ {
233
+ "serverKey": "your_server",
234
+ "datasourceId": "1",
235
+ "metrics": ["order_amt_tax_inc"],
236
+ "groupBy": ["DocDate__month", "org_region"],
237
+ "filters": [{"dimension": "DocDate", "operator": "BETWEEN", "values": ["2025-01-01", "2025-06-30"]}],
238
+ "orderBy": [
239
+ {"field": "DocDate__month", "direction": "ASC"},
240
+ {"field": "org_region", "direction": "ASC"}
241
+ ]
242
+ }
243
+ ```
244
+
245
+ ## Recommended Analysis Flow
246
+
247
+ ```
248
+ User question
249
+
250
+
251
+ Step 1: query_metrics_list — find matching metric(s)
252
+
253
+
254
+ Step 2: query_metric_definition — read defaultTimeContext + supportedDimensions
255
+
256
+
257
+ Step 3a: Pattern A (time trend) — get the big picture
258
+
259
+ ├─ anomaly found? ──► Step 3c: Pattern C (drill down)
260
+
261
+ ├─ user asks "who"? ──► Step 3b: Pattern B (dimension breakdown)
262
+
263
+ └─ user asks "compare X and Y"? ──► Step 3d: Pattern D (multi-metric)
264
+ ```
265
+
266
+ Always start broad (monthly trend over a year), then narrow (weekly in the problem month), then pinpoint (drill by dimension in the problem week).
267
+
268
+ ## Debug Mode
269
+
270
+ Set `"debug": true` to receive `executedSqls` in the response. Use this to verify that the generated SQL matches your intent before presenting results to the user.
271
+
272
+ ```json
273
+ {
274
+ ...,
275
+ "debug": true
276
+ }
277
+ ```
278
+
279
+ **Response**:
280
+ ```json
281
+ {
282
+ "results": [...],
283
+ "executedSqls": ["SELECT TO_NVARCHAR(\"DocDate\", 'YYYY-MM') AS \"DocDate__month\", SUM(\"GTotal\") AS \"value\" FROM MTC_VW_AI_ORDR WHERE ..."]
284
+ }
285
+ ```
286
+
287
+ ## Common Mistakes to Avoid
288
+
289
+ | Mistake | Correct Approach |
290
+ |---------|------------------|
291
+ | Using `field_name` (e.g., `"SlpName"`) in groupBy | Use `dim_id` (e.g., `"sales_person"`) |
292
+ | Writing `"DocDate__Month"` (capital M) | Always lowercase grain: `"DocDate__month"` |
293
+ | Omitting a date filter entirely | ALWAYS include at least one DocDate filter to avoid full-table scans |
294
+ | Querying a metric by an unsupported dimension | Only use `dim_id` values listed in the detail response |
295
+ | Putting a groupBy field in orderBy using its display name | `orderBy.field` must match exactly what's in `groupBy` |
296
+ | Using wrong operator for dimension type | categorical → IN/EQ, datetime → BETWEEN/GT/LT |