@treasuredata/tdx 0.2.8 → 0.3.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 (142) hide show
  1. package/README.md +23 -1625
  2. package/dist/build-info.json +2 -2
  3. package/dist/cli.js +1 -1
  4. package/dist/cli.js.map +1 -1
  5. package/dist/client/cdp-client.js +1 -1
  6. package/dist/client/http-client.js +1 -1
  7. package/dist/client/http-client.js.map +1 -1
  8. package/dist/client/llm-client.js +1 -1
  9. package/dist/client/rate-limiter.js +1 -1
  10. package/dist/client/td-client.d.ts +9 -1
  11. package/dist/client/td-client.d.ts.map +1 -1
  12. package/dist/client/td-client.js +1 -1
  13. package/dist/client/td-client.js.map +1 -1
  14. package/dist/client/trino-client.js +1 -1
  15. package/dist/client/workflow-client.js +1 -1
  16. package/dist/commands/activations.js +1 -1
  17. package/dist/commands/api-command.js +1 -1
  18. package/dist/commands/auth-command.d.ts +23 -0
  19. package/dist/commands/auth-command.d.ts.map +1 -0
  20. package/dist/commands/auth-command.js +1 -0
  21. package/dist/commands/auth-command.js.map +1 -0
  22. package/dist/commands/chat-command.js +1 -1
  23. package/dist/commands/claude-command.js +1 -1
  24. package/dist/commands/command.d.ts.map +1 -1
  25. package/dist/commands/command.js +1 -1
  26. package/dist/commands/command.js.map +1 -1
  27. package/dist/commands/context-command.js +1 -1
  28. package/dist/commands/databases.js +1 -1
  29. package/dist/commands/describe.js +1 -1
  30. package/dist/commands/job-command.js +1 -1
  31. package/dist/commands/llm-command.js +1 -1
  32. package/dist/commands/llm-proxy.js +1 -1
  33. package/dist/commands/parent-segment-command.js +1 -1
  34. package/dist/commands/profiles-command.js +1 -1
  35. package/dist/commands/query-command.js +1 -1
  36. package/dist/commands/segment-command.js +1 -1
  37. package/dist/commands/segment-create-command.js +1 -1
  38. package/dist/commands/segment-fields-command.js +1 -1
  39. package/dist/commands/segment-pwd-command.js +1 -1
  40. package/dist/commands/segment-update-command.js +1 -1
  41. package/dist/commands/segment-use-command.js +1 -1
  42. package/dist/commands/segments.js +1 -1
  43. package/dist/commands/show.js +1 -1
  44. package/dist/commands/tables.js +1 -1
  45. package/dist/commands/use-command.js +1 -1
  46. package/dist/commands/workflow-command.js +1 -1
  47. package/dist/core/auth.js +1 -1
  48. package/dist/core/config.d.ts +13 -2
  49. package/dist/core/config.d.ts.map +1 -1
  50. package/dist/core/config.js +1 -1
  51. package/dist/core/config.js.map +1 -1
  52. package/dist/core/global-context.js +1 -1
  53. package/dist/core/global-context.js.map +1 -1
  54. package/dist/core/profile.d.ts +8 -1
  55. package/dist/core/profile.d.ts.map +1 -1
  56. package/dist/core/profile.js +1 -1
  57. package/dist/core/profile.js.map +1 -1
  58. package/dist/core/project-config.js +1 -1
  59. package/dist/core/session.js +1 -1
  60. package/dist/index.js +1 -1
  61. package/dist/proxy/anthropic-adapter.d.ts.map +1 -1
  62. package/dist/proxy/anthropic-adapter.js +1 -1
  63. package/dist/proxy/anthropic-adapter.js.map +1 -1
  64. package/dist/proxy/server.d.ts.map +1 -1
  65. package/dist/proxy/server.js +1 -1
  66. package/dist/proxy/server.js.map +1 -1
  67. package/dist/proxy/session-cache.js +1 -1
  68. package/dist/sdk/api.d.ts +3 -0
  69. package/dist/sdk/api.d.ts.map +1 -1
  70. package/dist/sdk/api.js +1 -1
  71. package/dist/sdk/api.js.map +1 -1
  72. package/dist/sdk/database.d.ts +1 -0
  73. package/dist/sdk/database.d.ts.map +1 -1
  74. package/dist/sdk/database.js +1 -1
  75. package/dist/sdk/database.js.map +1 -1
  76. package/dist/sdk/errors.js +1 -1
  77. package/dist/sdk/index.d.ts +20 -6
  78. package/dist/sdk/index.d.ts.map +1 -1
  79. package/dist/sdk/index.js +1 -1
  80. package/dist/sdk/index.js.map +1 -1
  81. package/dist/sdk/job.d.ts +1 -0
  82. package/dist/sdk/job.d.ts.map +1 -1
  83. package/dist/sdk/job.js +1 -1
  84. package/dist/sdk/job.js.map +1 -1
  85. package/dist/sdk/llm.d.ts +1 -0
  86. package/dist/sdk/llm.d.ts.map +1 -1
  87. package/dist/sdk/llm.js +1 -1
  88. package/dist/sdk/llm.js.map +1 -1
  89. package/dist/sdk/query.d.ts +1 -0
  90. package/dist/sdk/query.d.ts.map +1 -1
  91. package/dist/sdk/query.js +1 -1
  92. package/dist/sdk/query.js.map +1 -1
  93. package/dist/sdk/segment.d.ts +1 -0
  94. package/dist/sdk/segment.d.ts.map +1 -1
  95. package/dist/sdk/segment.js +1 -1
  96. package/dist/sdk/segment.js.map +1 -1
  97. package/dist/sdk/table.d.ts +1 -0
  98. package/dist/sdk/table.d.ts.map +1 -1
  99. package/dist/sdk/table.js +1 -1
  100. package/dist/sdk/table.js.map +1 -1
  101. package/dist/sdk/workflow.d.ts +1 -0
  102. package/dist/sdk/workflow.d.ts.map +1 -1
  103. package/dist/sdk/workflow.js +1 -1
  104. package/dist/sdk/workflow.js.map +1 -1
  105. package/dist/types/endpoints.d.ts +12 -0
  106. package/dist/types/endpoints.d.ts.map +1 -1
  107. package/dist/types/endpoints.js +1 -1
  108. package/dist/types/endpoints.js.map +1 -1
  109. package/dist/types/index.d.ts +17 -0
  110. package/dist/types/index.d.ts.map +1 -1
  111. package/dist/types/index.js +1 -1
  112. package/dist/types/index.js.map +1 -1
  113. package/dist/utils/agent-ref-parser.js +1 -1
  114. package/dist/utils/chat-cache.js +1 -1
  115. package/dist/utils/colors.js +1 -1
  116. package/dist/utils/command-output.js +1 -1
  117. package/dist/utils/constants.js +1 -1
  118. package/dist/utils/file-permissions.js +1 -1
  119. package/dist/utils/format-detector.js +1 -1
  120. package/dist/utils/formatters.js +1 -1
  121. package/dist/utils/json-loader.js +1 -1
  122. package/dist/utils/model-aliases.js +1 -1
  123. package/dist/utils/option-validation.js +1 -1
  124. package/dist/utils/port.js +1 -1
  125. package/dist/utils/process.d.ts.map +1 -1
  126. package/dist/utils/process.js +1 -1
  127. package/dist/utils/process.js.map +1 -1
  128. package/dist/utils/prompt.js +1 -1
  129. package/dist/utils/segment-path-parser.js +1 -1
  130. package/dist/utils/segment-ref-parser.js +1 -1
  131. package/dist/utils/spinner.js +1 -1
  132. package/dist/utils/sql-parser.js +1 -1
  133. package/dist/utils/sse-parser.js +1 -1
  134. package/dist/utils/string-utils.js +1 -1
  135. package/dist/utils/table-ref-parser.js +1 -1
  136. package/dist/utils/tdx-logger.d.ts.map +1 -1
  137. package/dist/utils/tdx-logger.js +1 -1
  138. package/dist/utils/tdx-logger.js.map +1 -1
  139. package/dist/utils/tree-formatter.js +1 -1
  140. package/dist/utils/version-check.js +1 -1
  141. package/dist/utils/workflow-utils.js +1 -1
  142. package/package.json +11 -2
package/README.md CHANGED
@@ -1,1663 +1,62 @@
1
1
  # tdx - AI-Native CLI for Treasure Data
2
2
 
3
- > **Status:** 🚧 Under Active Development. SDK/CLI commands are subject to change (2025)
3
+ > **Status:** Under Active Development. SDK/CLI commands are subject to change (2025)
4
4
 
5
5
  A modern, AI-native command-line interface for Treasure Data, optimized for both human engineers and AI coding assistants.
6
6
 
7
+ **Documentation:** [https://tdx.treasuredata.com/](https://tdx.treasuredata.com/)
8
+
7
9
  ## Features
8
10
 
9
- - 🤖 **AI-Native Design**: Consistent JSON output, predictable error codes, structured responses
10
- - 🌍 **Multi-Site Support**: Easy switching between US, JP, EU, and AP regions
11
- - 🚀 **Modern Distribution**: Install via `npx` or `npm` without prior setup
12
- - **Fast & Efficient**: Built with TypeScript on Node.js 24+
11
+ - **AI-Native Design**: Consistent JSON output, predictable error codes, structured responses
12
+ - **Claude Code Integration**: Launch Claude Code with TD LLM API using `tdx claude`
13
+ - **Multi-Site Support**: Easy switching between US, JP, EU, and AP regions
14
+ - **Modern Distribution**: Install via `npx` or `npm` without prior setup
13
15
 
14
16
  ## Installation
15
17
 
16
18
  ```bash
17
- # Run directly with npx (no installation required)
18
- npx @treasuredata/tdx databases
19
-
20
- # Run latest version with npx
21
- npx @treasuredata/tdx@latest databases
22
-
23
- # Or install globally
19
+ # Install globally
24
20
  npm install -g @treasuredata/tdx
25
21
 
26
- # Alternative: Use with Bun
27
- bunx @treasuredata/tdx databases
28
-
29
- # Run latest version with bunx
30
- bunx @treasuredata/tdx@latest databases
22
+ # Or run directly with npx (no installation required)
23
+ npx @treasuredata/tdx databases
31
24
  ```
32
25
 
33
26
  ## Quick Start
34
27
 
35
- ### 1. Configure API Key
36
-
37
- Create `~/.config/tdx/.env`:
38
-
39
28
  ```bash
40
- # Single API key (recommended for most users)
41
- TD_API_KEY=your-api-key-here/...
29
+ # Set up authentication (interactive)
30
+ tdx auth setup
42
31
 
43
- # Or use site-specific keys if working with multiple sites
44
- # TD_API_KEY_US01=your-us-key-here/...
45
- # TD_API_KEY_JP01=your-jp-key-here/...
46
- ```
47
-
48
- Alternatively, set as environment variable:
49
- ```bash
50
- # Export for all commands in session
51
- export TD_API_KEY=your-api-key-here/...
52
-
53
- # Or set inline for a single command
54
- TD_API_KEY=your-api-key-here/... tdx databases
55
- ```
56
-
57
- ### 2. Run Commands
58
-
59
- ```bash
60
32
  # List databases
61
33
  tdx databases
62
34
 
63
- # List databases in Tokyo region
64
- tdx databases --site jp01
65
-
66
- # Show table contents
67
- tdx show sample_datasets.www_access --limit 10
68
-
69
35
  # Run a query
70
- tdx query "SELECT * FROM mytable LIMIT 10"
71
-
72
- # Get JSON output (two ways)
73
- tdx databases --json
74
- tdx databases --format json
75
-
76
- # Get JSON Lines output
77
- tdx query "SELECT * FROM users" --jsonl
36
+ tdx query "SELECT * FROM mydb.users LIMIT 10"
78
37
 
79
- # Get TSV output
80
- tdx query "SELECT * FROM users" --tsv
81
-
82
- # Get human-readable table output (default)
83
- tdx databases --format table
84
-
85
- # Chat with AI (simplified - uses default agent)
38
+ # Chat with AI
86
39
  tdx chat "Show me customer revenue trends"
87
40
 
88
- # Continue previous chat (default behavior)
89
- tdx chat "What about last month?"
90
-
91
- # Start a new chat session
92
- tdx chat --new "Tell me about data pipelines"
93
- ```
94
-
95
- ## Context Management
96
-
97
- `tdx` provides a unified context system to reduce repetitive flags across commands. Context is resolved from multiple sources with the following priority:
98
-
99
- 1. **CLI flags** (highest priority) - `--database`, `--site`, etc.
100
- 2. **Session context** - Shell-scoped overrides set with `tdx use`
101
- 3. **Project config** - Per-project defaults in `tdx.json`
102
- 4. **Profile config** - Account-specific settings in `~/.config/tdx/tdx.json` or project `tdx.json`
103
- 5. **Global config** - Fallback defaults in `~/.config/tdx/tdx.json`
104
-
105
- ### Profiles
106
-
107
- Profiles store long-lived account configurations for easy switching between environments:
108
-
109
- ```bash
110
- # List all profiles with details
111
- tdx profiles
112
-
113
- # Set session profile (shell-scoped)
114
- tdx use profile production
115
- ```
116
-
117
- **Profile Structure:**
118
-
119
- Profiles are defined in `tdx.json` files with a `profiles` object:
120
-
121
- ```json
122
- {
123
- "profiles": {
124
- "production": {
125
- "description": "Production environment for US region",
126
- "site": "us01",
127
- "database": "analytics",
128
- "llm_project": "DataAnalytics"
129
- },
130
- "dev": {
131
- "description": "Development and testing environment",
132
- "site": "jp01",
133
- "database": "dev_db"
134
- }
135
- }
136
- }
137
- ```
138
-
139
- **Profile Locations:**
140
- - **User-level**: `~/.config/tdx/tdx.json` - Shared across all projects
141
- - **Project-level**: `(project folder)/tdx.json` - Project-specific profiles
142
-
143
- **Credentials:**
144
- Store API keys separately from profiles:
145
- ```
146
- ~/.config/tdx/
147
- ├── tdx.json # User-level profiles
148
- ├── .env.production # Production credentials
149
- └── .env.dev # Development credentials
150
- ```
151
-
152
- **Example credential file** (`~/.config/tdx/.env.production`):
153
- ```
154
- TD_API_KEY=1234/abcdefg...
155
- ```
156
-
157
- **Profile Precedence:**
158
- 1. Project `tdx.json` profiles (local)
159
- 2. User `~/.config/tdx/tdx.json` profiles (user-level)
160
- 3. Directory-based profiles (deprecated)
161
-
162
- **Note:** The `description` field is optional but recommended for documenting what each profile is for.
163
-
164
- ### Session Context
165
-
166
- Set temporary overrides for the current shell session:
167
-
168
- ```bash
169
- # Set session database
170
- tdx use database mydb
171
-
172
- # Set session LLM project
173
- tdx use llm_project Analytics
174
-
175
- # View current context
176
- tdx context
177
-
178
- # Clear session context
179
- tdx context --clear
180
- ```
181
-
182
- **How Session Scope Works:**
183
-
184
- Sessions are automatically scoped to your current shell window. Each terminal window/tab has a unique process ID (PID), and `tdx` uses the parent process ID (PPID) to identify and isolate sessions. This means:
185
-
186
- - **Automatic isolation**: Each terminal window maintains its own independent session context
187
- - **No manual setup**: Sessions are created automatically when you run `tdx use` commands
188
- - **Persistent within shell**: Context persists across multiple commands in the same terminal
189
- - **Automatic cleanup**: Sessions expire after 24 hours or when the shell is closed
190
-
191
- **Example:**
192
- ```bash
193
- # Terminal Window 1
194
- tdx use database analytics
195
- tdx tables # Uses database: analytics
196
-
197
- # Terminal Window 2 (different PID)
198
- tdx tables # Uses default database (separate session)
199
- ```
200
-
201
- Session context persists until the shell is closed or explicitly cleared with `tdx context --clear`.
202
-
203
- **Note:** For advanced session sharing across multiple processes or shells, see [Session ID Option](#session-id-option) in the Advanced Options section.
204
-
205
- ### Project Config
206
-
207
- Store per-project defaults in `tdx.json` at your project root:
208
-
209
- ```json
210
- {
211
- "database": "customer_analytics",
212
- "parent_segment": "active_users",
213
- "llm_project": "CustomerInsights"
214
- }
215
- ```
216
-
217
- **Available Configuration Parameters:**
218
-
219
- | Parameter | Type | Description | Example |
220
- |-----------|------|-------------|---------|
221
- | `description` | string | Optional description of the configuration | `"Production environment"` |
222
- | `site` | string | TD site/region (us01, jp01, eu01, ap02) | `"us01"` |
223
- | `database` | string | Default database for queries and table commands | `"analytics"` |
224
- | `parent_segment` | string | Default parent segment for CDP commands | `"active_users"` |
225
- | `llm_project` | string | Default LLM project for agent commands | `"DataAnalytics"` |
226
-
227
- **Security Note:** Project configs should never contain API keys since they may be committed to version control. Use profiles or global `.env` files for credentials.
228
-
229
- ### View Context
230
-
231
- See the currently resolved context and where each value comes from:
232
-
233
- ```bash
234
- # Show current context
235
- tdx context
236
-
237
- # Show context with sources (debugging)
238
- tdx context --debug
239
- ```
240
-
241
- Example output:
242
- ```
243
- [context]
244
- site: us01 (global: ~/.config/tdx/tdx.json)
245
- database: analytics (session)
246
- llm_project: DataAnalytics (profile: production)
247
- profile: production (session)
248
-
249
- Configuration Files:
250
- Session: /Users/user/.config/tdx/sessions/12345.json ✓
251
- Global: /Users/user/.config/tdx/tdx.json ✓
252
- Project: /Users/user/projects/myproject/tdx.json ✓
253
- ```
254
-
255
- ## Available Commands
256
-
257
- ```bash
258
- tdx <command> [options] [arguments]
259
- ```
260
-
261
- ### Global Options
262
-
263
- Available for all commands:
264
-
265
- - `--site <site>`: TD site/region (us01, jp01, eu01, ap02) - default: us01
266
- - `--format <format>`: Output format (table, json, jsonl, tsv) - default: table
267
- - `--json`: Output in JSON format (shorthand for --format json)
268
- - `--jsonl`: Output in JSON Lines format (shorthand for --format jsonl)
269
- - `--tsv`: Output in TSV format (shorthand for --format tsv)
270
- - `--output <file>`: Save output to file
271
- - `--limit <rows>`: Maximum rows to display in table format - default: 40
272
- - `--color`: Force ANSI color output (overrides TTY detection)
273
- - `--no-color`: Disable ANSI color output (also respects NO_COLOR env var)
274
- - `-v, --verbose`: Enable verbose logging
275
- - `--timeout <seconds>`: Set operation timeout - default: 30
276
- - `--dry-run`: Preview operation without executing
277
- - `-y, --yes`: Skip confirmation prompts
278
-
279
- **Note:** Shorthand flags (--json, --jsonl, --tsv) are only applied when --format is not explicitly specified. If both are provided, --format is used.
280
-
281
- ### Interactive Table Navigation
282
-
283
- When viewing table output in an interactive terminal, `tdx` automatically pipes the output through `less` for easy navigation of large datasets. This allows you to:
284
-
285
- - View all rows without truncation (unlimited data display)
286
- - Scroll through wide tables without column truncation
287
- - Search and navigate efficiently
288
-
289
- **Keyboard shortcuts in less:**
290
-
291
- | Key | Action |
292
- |-----|--------|
293
- | `q` | Quit and return to terminal |
294
- | `↑` / `↓` | Scroll up/down one line |
295
- | `Space` / `Page Down` | Scroll down one page |
296
- | `b` / `Page Up` | Scroll up one page |
297
- | `←` / `→` | Scroll left/right (for wide tables) |
298
- | `/pattern` | Search forward for pattern |
299
- | `?pattern` | Search backward for pattern |
300
- | `n` | Repeat previous search forward |
301
- | `N` | Repeat previous search backward |
302
- | `g` | Go to first line |
303
- | `G` | Go to last line |
304
- | `h` | Show help |
305
-
306
- **Note:** Less pagination is automatically enabled for table format output in interactive terminals. It's disabled when:
307
- - Output is piped to another command
308
- - Output is saved to a file with `--output`
309
- - Using non-table formats (JSON, JSONL, TSV)
310
-
311
- ### Chat Commands (Quick AI Interaction)
312
-
313
- Simplified top-level command for chatting with LLM agents.
314
-
315
- | Command | Description | Example |
316
- |---------|-------------|---------|
317
- | `chat <message>` | Chat (continues last session by default) | `tdx chat "Analyze my data"` |
318
- | `chat <message> --agent <name>` | Chat with specific agent | `tdx chat "Hello" --agent "Data Analyst"` |
319
- | `chat <message> --model <name>` | Chat using specific model or alias (haiku, sonnet) | `tdx chat "Help" --model "haiku"` |
320
- | `chat <message> --temperature <n>` | Set temperature (0.0-2.0, default: 0.7) | `tdx chat "Be creative" --temperature 1.2` |
321
- | `chat <message> --new` | Start a new chat session | `tdx chat --new "Fresh conversation"` |
322
-
323
- **Examples**:
324
- ```bash
325
- # Simple chat (uses default agent with claude-4.5-haiku)
326
- tdx chat "Show me the top customers by revenue"
327
-
328
- # Continue previous conversation (default behavior)
329
- tdx chat "What about last quarter?"
330
-
331
- # Start a new conversation
332
- tdx chat --new "Tell me about data modeling best practices"
333
-
334
- # Use model aliases for quick access
335
- tdx chat "Quick question" --model "haiku" # Uses claude-4.5-haiku
336
- tdx chat "Analyze this" --model "sonnet" # Uses claude-4.5-sonnet
337
-
338
- # Use full model name
339
- tdx chat "Help me write SQL" --model "claude-4.5-opus"
340
-
341
- # Use specific agent by name (uses current project context)
342
- tdx llm use "MyProject"
343
- tdx chat "Analyze churn" --agent "Data Analyst"
344
-
345
- # Override project for agent lookup
346
- tdx chat "Hello" --agent "Analyst" --llm-project "OtherProject"
347
-
348
- # Adjust temperature
349
- tdx chat "Write a poem" --temperature 1.5
350
-
351
- # Verbose mode shows chat session ID
352
- tdx chat "Hello" --verbose
353
- ```
354
-
355
- **How it works**:
356
- - **Default behavior**: Continues last chat session automatically
357
- - **Session persistence**: Last chat ID saved to `.cache/tdx/last_chat_id`
358
- - **--new flag**: Starts a fresh chat session
359
- - **--agent**: Use specific agent by name (resolves using project context)
360
- - **--model**: Auto-creates/reuses agent per model (supports aliases: `haiku` → `claude-4.5-haiku`, `sonnet` → `claude-4.5-sonnet`)
361
- - **--temperature**: Controls randomness (0.7 default, lower=focused, higher=creative)
362
-
363
- ### Database Commands
364
-
365
- | Command | Description | Example |
366
- |---------|-------------|---------|
367
- | `databases` | List all databases | `tdx databases` |
368
- | | Filter by pattern (glob/wildcards) | `tdx databases "prod_*"` or `tdx databases "*_analytics"` |
369
-
370
- ### Table Commands
371
-
372
- All table commands use dot-separated patterns: `(database).(table)`
373
-
374
- | Command | Description | Example |
375
- |---------|-------------|---------|
376
- | `tables` | List all tables from all databases | `tdx tables` |
377
- | | List all tables from specific database | `tdx tables "mydb.*"` or `tdx tables --in mydb` |
378
- | | List tables from database (--database flag) | `tdx tables --database mydb` |
379
- | | Filter tables with pattern | `tdx tables "mydb.user_*"` |
380
- | | Database pattern with table | `tdx tables "prod_*.access_log"` |
381
- | | Wildcard database and table | `tdx tables "*.user*"` |
382
- | | All tables from all databases | `tdx tables "*.*"` |
383
- | `describe <table>` (alias: `desc`) | Show table schema | `tdx describe mydb.users` |
384
- | | Using --in or --database flag | `tdx describe users --in mydb` or `tdx describe users -d mydb` |
385
- | `show <table>` | Show table contents (SELECT * with limit) | `tdx show mydb.users` |
386
- | | With custom row limit | `tdx show mydb.users --limit 10` |
387
- | | With explicit catalog | `tdx show td.mydb.users --limit 5` |
388
- | | Using --in or --database flag | `tdx show users --in mydb` or `tdx show users -d mydb` |
389
-
390
- **Pattern syntax:**
391
- - Database wildcard: `"mydb.*"` → all tables from mydb (use this or `--database mydb`)
392
- - Database.table: `mydb.users` → specific table
393
- - Wildcards: `"*.users"`, `"prod_*.user*"` → pattern matching
394
- - Catalog: `"td.mydb.users"` → with catalog prefix
395
-
396
- **Table-specific options:**
397
- - `-d, --database <database>`: Specify database name when not included in pattern
398
- - `--in <database>`: Alias for `--database` (natural language style)
399
-
400
- **Alternative syntax for specifying database:**
401
-
402
- There are multiple ways to specify the database for table commands:
403
-
404
- ```bash
405
- # Using dot notation (recommended for patterns)
406
- tdx tables "mydb.*"
407
-
408
- # Using --in flag (natural language style, no quotes needed)
409
- tdx tables --in mydb
410
-
411
- # Using --database flag (or -d shorthand)
412
- tdx tables --database mydb
413
- tdx tables -d mydb
414
-
415
- # All three are equivalent for listing all tables from a database
416
-
417
- # Works with describe and show commands too
418
- tdx describe users --in mydb
419
- tdx show users --in mydb
420
-
421
- # List tables matching pattern from "mydb"
422
- tdx tables "user*" --in mydb
423
- ```
424
-
425
- **Note:** If the pattern already includes a database (e.g., `mydb.users`), the `--database` option is ignored:
426
-
427
- ```bash
428
- # Uses "mydb" from pattern, ignores --database option
429
- tdx tables mydb.users --database other
430
- # Result: Lists users table from mydb, not other
431
- ```
432
-
433
- ### Query Commands
434
-
435
- Usage: `tdx query [options] [sql]`
436
-
437
- | Option/Usage | Description | Example |
438
- |--------------|-------------|---------|
439
- | `<sql>` | Execute SQL query | `tdx query "SELECT * FROM table"` |
440
- | `-f, --file <path>` | Execute SQL from file | `tdx query -f query.sql` |
441
- | Multi-statement | Execute multiple statements (CLI or file) | `tdx query "SELECT 1; SELECT 2"` |
442
- | | Multi-statement from file | `tdx query -f setup-and-query.sql` |
443
-
444
- **Query-specific options**:
445
- - `-f, --file <path>`: Read SQL from file
446
- - `-d, --database <db>`: Database to query (default: information_schema)
447
- - `--in <db>`: Alias for `--database` (natural language style)
448
- - `--catalog <catalog>`: Trino catalog (default: td)
449
-
450
- **Examples**:
451
- ```bash
452
- # Query with --in flag
453
- tdx query "SELECT * FROM users" --in mydb
454
-
455
- # Equivalent to --database
456
- tdx query "SELECT * FROM users" --database mydb
457
- tdx query "SELECT * FROM users" -d mydb
458
- ```
459
-
460
- ### Job Commands
461
-
462
- Manage and execute Treasure Data jobs (queries).
463
-
464
- **List jobs**:
465
- ```bash
466
- # List jobs (default: 40 jobs)
467
- tdx jobs
468
-
469
- # List more jobs with --limit
470
- tdx jobs --limit 100
471
-
472
- # Filter by status
473
- tdx jobs --status running
474
- tdx jobs --status success
475
- tdx jobs --status error
476
- tdx jobs --status queued
477
-
478
- # Combine filters
479
- tdx jobs --status running --limit 50
480
-
481
- # Output as JSON
482
- tdx jobs --format json
483
- ```
484
-
485
- **Show job details**:
486
- ```bash
487
- # Show job details
488
- tdx job show <job-id>
489
-
490
- # Show job as JSON
491
- tdx job show <job-id> --format json
492
- ```
493
-
494
- **Kill a job**:
495
- ```bash
496
- # Kill a job (with confirmation)
497
- tdx job kill <job-id>
498
-
499
- # Skip confirmation prompt
500
- tdx job kill <job-id> --yes
501
- ```
502
-
503
- **Submit jobs**:
504
- ```bash
505
- # Submit Trino query (default)
506
- tdx job submit "SELECT * FROM mydb.table LIMIT 10"
507
-
508
- # Submit with specific database
509
- tdx job submit "SELECT * FROM table" --database mydb
510
-
511
- # Submit Hive query from file
512
- tdx job submit --job-type hive -f query.sql --database mydb
513
-
514
- # Submit without specifying database (uses information_schema by default)
515
- tdx job submit "SELECT 1"
516
- ```
517
-
518
- **Get job results**:
519
- ```bash
520
- # Get job results (table format)
521
- tdx job result <job-id>
522
-
523
- # Get results as JSON
524
- tdx job result <job-id> --format json
525
-
526
- # Save results to file
527
- tdx job result <job-id> --output results.json
528
-
529
- # Get results as TSV
530
- tdx job result <job-id> --format tsv
531
- ```
532
-
533
- **Job Command Options**:
534
- - `--job-type <type>`: Job type - `trino` (default) or `hive`
535
- - `-f, --file <path>`: Read query from file
536
- - `--database <name>`: Database name (default: `information_schema`)
537
- - `--status <status>`: Filter by job status - `queued`, `running`, `success`, or `error` (for `jobs` list)
538
- - `--limit <number>`: Maximum number of jobs to list (default: 40, for `jobs` list)
539
-
540
- ### Segment Commands (CDP)
541
-
542
- Usage: `tdx segment <subcommand> [options] [arguments]`
543
-
544
- CDP (Customer Data Platform) segment management for audiences and activations with file-system-like navigation.
545
-
546
- **Path Format:**
547
- - Parent segment: `"My Audience"`
548
- - Child segment: `"My Audience/High Value Users"`
549
- - Nested folders: `"My Audience/Marketing/Campaigns/Email Q1"`
550
- - Pattern matching: `"*DEMO"`, `"test*"`, `"*audience*"`
551
- - **Note**: Names are case-sensitive
552
-
553
- **Navigation Model:**
554
- - Set context: `tdx segment use <path>` - Navigate into a parent or folder
555
- - Show context: `tdx segment pwd` - Display current location
556
- - List contents: `tdx segments` - Show folders + segments in current context
557
- - All commands support both absolute paths and relative paths from context
558
-
559
- #### Navigation Commands
560
-
561
- | Command | Description | Example |
562
- |---------|-------------|---------|
563
- | `segment use <path>` | Set current context to parent or folder | `tdx segment use "My Audience/Marketing"` |
564
- | `segment pwd` | Show current context path | `tdx segment pwd` |
565
- | `segment use /` | Clear context (back to root) | `tdx segment use /` |
566
- | `segment use ..` | Navigate to parent folder | `tdx segment use ..` |
567
-
568
- #### Discovery Commands
569
-
570
- | Command | Description | Example |
571
- |---------|-------------|---------|
572
- | `segments` | List contents in current context (or all parents if no context) | `tdx segments` |
573
- | `segments <path>` | List folders + segments at specified path | `tdx segments "My Audience/Marketing"` |
574
- | `segments <pattern>` | List parents matching pattern (glob) | `tdx segments "*DEMO"` |
575
- | `segments -r` | List recursively (tree view) | `tdx segments -r` |
576
- | `segments <path> -r` | Recursive tree from path | `tdx segments "My Audience" -r` |
577
- | `segment describe <path>` | Show details (parent/folder/segment) | `tdx segment describe "My Audience/Marketing"` |
578
- | `segment show <path>` | Execute segment SQL query and show results | `tdx segment show "My Audience/Premium Users"` |
579
- | `segment sql <path>` | Get SQL query for segment | `tdx segment sql "My Audience/Marketing/Premium"` |
580
- | `segment fields <parent>` | List available fields for segmentation | `tdx segment fields "My Audience"` |
581
-
582
- #### Management Commands
583
-
584
- | Command | Description | Example |
585
- |---------|-------------|---------|
586
- | `segment parent create <name>` | Create new parent segment (audience) | `tdx segment parent create "Customer 360" --database mydb --table customers` |
587
- | `segment parent update <name>` | Update existing parent segment | `tdx segment parent update "Customer 360" --description "Updated"` |
588
- | `segment create <path>` | Create child segment with filtering (supports nested paths) | `tdx segment create "My Audience/Marketing/Premium" --rule-file rule.json` |
589
- | `segment update <path>` | Update child segment (supports nested paths) | `tdx segment update "My Audience/Marketing/Premium" --description "Updated"` |
590
- | `segment folder create <parent> <folder>` | Create segment folder | `tdx segment folder create "My Audience" "Q1 2024"` |
591
-
592
- #### Discovery Examples
593
-
594
- **Navigation Workflow:**
595
-
596
- ```bash
597
- # List all parent segments
598
- tdx segments
599
- # Output:
600
- # [parent segments]
601
- # 👥 My Audience (50K)
602
- # 👥 Sales Leads (12.5K)
603
-
604
- # Pattern matching for parents
605
- tdx segments "*DEMO"
606
- # Output:
607
- # [parent segments]
608
- # 👥 TREASUREBIKES DEMO (3.28K)
609
- # 👥 TEST DEMO (1.5K)
610
-
611
- # Navigate into a parent
612
- tdx segment use "My Audience"
613
-
614
- # List folders + segments in current context (unified view)
615
- tdx segments
616
- # Output:
617
- # [/My Audience]
618
- # 📁 Marketing
619
- # 📁 Sales
620
- # 🎯 Active Users (35K)
621
- # 🎯 All Users (50K)
622
-
623
- # Recursive tree view from current context
624
- tdx segments -r
625
- # Output:
626
- # [/My Audience]
627
- # 📁 Marketing
628
- # ├── 📁 Campaigns
629
- # │ ├── 🎯 Email Q1 (5.23K)
630
- # │ └── 🎯 Email Q2 (6.12K)
631
- # └── 🎯 Email Subscribers (15K)
632
- # 🎯 Active Users (35K)
633
-
634
- # Navigate to nested folder
635
- tdx segment use "My Audience/Marketing/Campaigns"
636
- tdx segment pwd
637
- # Output: My Audience/Marketing/Campaigns
638
-
639
- # List specific path without changing context
640
- tdx segments "My Audience/Marketing"
641
- tdx segments "My Audience" -r # Recursive from specific path
642
-
643
- # Show details using absolute paths
644
- tdx segment describe "My Audience/Marketing/Campaigns"
645
- tdx segment describe "My Audience/High Value Users"
646
-
647
- # Show details using relative paths (from context)
648
- tdx segment use "My Audience/Marketing"
649
- tdx segment describe "Campaigns" # Relative to Marketing
650
-
651
- # Execute queries with paths
652
- tdx segment show "My Audience/Premium Users" --limit 100
653
- tdx segment sql "My Audience/Marketing/Email Subscribers" > query.sql
654
-
655
- # List available fields for parent
656
- tdx segment fields "My Audience"
657
- ```
658
-
659
- #### Management Examples
660
-
661
- **Create Parent Segment (Audience):**
662
-
663
- ```bash
664
- # Create minimal parent segment
665
- tdx segment parent create "Customer 360" \
666
- --database customer_data \
667
- --table customers \
668
- --description "Complete customer view"
669
-
670
- # Create with attributes from file
671
- tdx segment parent create "Customer 360" \
672
- --database customer_data \
673
- --table customers \
674
- --attributes-file examples/parent-segment-attributes.json \
675
- --behaviors-file examples/parent-segment-behaviors.json
676
-
677
- # Create with scheduling
678
- tdx segment parent create "Customer 360" \
679
- --database customer_data \
680
- --table customers \
681
- --schedule-type daily \
682
- --schedule-option "03:00" \
683
- --timezone "America/Los_Angeles"
684
- ```
685
-
686
- **Update Parent Segment:**
687
-
688
- ```bash
689
- # Update description
690
- tdx segment parent update "Customer 360" \
691
- --description "Updated customer view"
692
-
693
- # Add new attributes
694
- tdx segment parent update "Customer 360" \
695
- --add-attributes-file new-attributes.json
696
-
697
- # Update schedule
698
- tdx segment parent update "Customer 360" \
699
- --schedule-type weekly \
700
- --schedule-option "0" # Sunday
701
- ```
702
-
703
- **Create Child Segment with Filtering:**
704
-
705
- ```bash
706
- # Create segment with simple rule (inline JSON)
707
- tdx segment create "My Audience/High Value" \
708
- --description "Customers with LTV > $1000" \
709
- --rule '{"type":"And","conditions":[{"type":"Value","leftValue":{"name":"Lifetime Value"},"operator":{"type":"Greater","rightValue":1000}}]}'
710
-
711
- # Create segment with complex rule (from file)
712
- tdx segment create "My Audience/High Value US" \
713
- --description "High value US customers" \
714
- --rule-file examples/segment-rule-complex.json
715
-
716
- # Create segment in folder
717
- tdx segment create "My Audience/Premium" \
718
- --rule-file examples/segment-rule-simple.json \
719
- --folder "Geographic Segments"
720
-
721
- # Create realtime segment
722
- tdx segment create "My Audience/Realtime Active" \
723
- --rule-file rule.json \
724
- --kind 1 # 0=batch, 1=realtime, 2=funnel_stage
725
- ```
726
-
727
- **Update Child Segment:**
728
-
729
- ```bash
730
- # Update segment name
731
- tdx segment update "My Audience/High Value" \
732
- --name "Super High Value"
733
-
734
- # Update segment rule
735
- tdx segment update "My Audience/High Value" \
736
- --description "Updated criteria" \
737
- --rule-file updated-rule.json
738
-
739
- # Move segment to folder
740
- tdx segment update "My Audience/High Value" \
741
- --folder "Premium Customers"
742
- ```
743
-
744
- **Create Folders:**
745
-
746
- ```bash
747
- # Create top-level folder
748
- tdx segment folder create "My Audience" "Q1 2024 Campaigns" \
749
- --description "Campaign segments for Q1"
750
-
751
- # Create nested folder
752
- tdx segment folder create "My Audience" "West Region" \
753
- --parent-folder "Geographic Segments"
754
- ```
755
-
756
- **Segment Rule Syntax:**
757
-
758
- See `examples/segment-rule-simple.json` and `examples/segment-rule-complex.json` for rule examples.
759
-
760
- Supported operators:
761
- - **Comparison**: Equal, NotEqual, Greater, GreaterEqual, Less, LessEqual
762
- - **Set**: In, NotIn
763
- - **Text**: Contains, StartsWith, EndsWith
764
- - **Pattern**: Regex
765
- - **Time**: TimeWithinPast
766
-
767
- Example rule structure:
768
- ```json
769
- {
770
- "type": "And",
771
- "conditions": [
772
- {
773
- "type": "Value",
774
- "leftValue": {"name": "Lifetime Value"},
775
- "operator": {"type": "Greater", "rightValue": 1000}
776
- },
777
- {
778
- "type": "Value",
779
- "leftValue": {"name": "Country"},
780
- "operator": {"type": "In", "rightValues": ["US", "UK", "CA"]}
781
- }
782
- ]
783
- }
784
- ```
785
-
786
- ### Activation Commands (CDP)
787
-
788
- Manage CDP activations (syndications) for segments.
789
-
790
- | Command | Description | Example |
791
- |---------|-------------|---------|
792
- | `activations <parent_name/child_name>` | List activations for a child segment | `tdx activations "My Audience/Premium Users"` |
793
-
794
- **Examples**:
795
- ```bash
796
- # List activations for a child segment (slash notation with names)
797
- tdx activations "My Audience/Premium Users"
798
-
799
- # Get activations as JSON
800
- tdx activations "My Audience/High Value Users" --format json
801
-
802
- # Using Tokyo region
803
- tdx activations "My Audience/Premium Users" --site jp01
804
- ```
805
-
806
- ### Workflow Commands
807
-
808
- Usage: `tdx workflow <subcommand>` (alias: `tdx wf`)
809
-
810
- Manage Treasure Data workflows powered by Digdag. Monitor execution sessions, view logs, and control workflow attempts.
811
-
812
- | Subcommand | Description | Example |
813
- |------------|-------------|---------|
814
- | `projects [pattern]` | List workflow projects (supports glob patterns) | `tdx wf projects` or `tdx wf projects "cdp_*"` |
815
- | `workflows [project]` (alias: `ls`) | List workflows (filter by project, supports globs) | `tdx wf workflows` or `tdx wf workflows "lda*"` |
816
- | `sessions [project]` | List workflow execution sessions | `tdx wf sessions` or `tdx wf sessions myproject` or `tdx wf sessions myproject.daily_etl` |
817
- | `attempts [project]` | List workflow attempts | `tdx wf attempts` or `tdx wf attempts myproject` or `tdx wf attempts myproject.workflow` |
818
- | `attempt <attempt-id>` | Show specific attempt details | `tdx wf attempt 67890` |
819
- | `tasks <attempt-id>` | Show tasks for an attempt | `tdx wf tasks 67890` |
820
- | `logs <attempt-id> <task-name>` | Show logs for a specific task | `tdx wf logs 67890 +step1` |
821
- | `kill <attempt-id>` | Kill a running attempt | `tdx wf kill 67890` |
822
- | `retry <session-id\|attempt-id>` | Retry a session or attempt | `tdx wf retry session:12345` or `tdx wf retry attempt:67890` |
823
- | `download <project-name> [output-dir]` | Download workflow project from TD console | `tdx wf download myproject` or `tdx wf download myproject ./workflows` |
824
- | `push [project-name-or-dir]` | Push workflow project to TD console (digdag-style) | `cd myproject && tdx wf push myproject` or `tdx wf push ./myproject` |
825
- | `delete <project-name-or-id>` | Delete workflow project from TD console | `tdx wf delete myproject` or `tdx wf delete 12345` |
826
-
827
- **Workflow-specific options:**
828
-
829
- For `sessions` command:
830
- - `--status <status>`: Filter by status (running, success, error, blocked, all)
831
- - `--from <timestamp>`: Start time filter (ISO 8601 format)
832
- - `--to <timestamp>`: End time filter (ISO 8601 format)
833
-
834
- For `attempts` command:
835
- - `--include-retried`: Include retried attempts in the output
836
-
837
- For `tasks` command:
838
- - `--include-subtasks`: Include subtasks in the output
839
-
840
- For `logs` command:
841
- - `--offset <number>`: Starting offset for logs (default: 0)
842
-
843
- For `download` command:
844
- - `--revision <revision>`: Download specific revision (default: latest)
845
-
846
- For `push` command:
847
- - `--name <name>`: Project name (default: directory name)
848
- - `--revision <revision>`: Revision name (default: timestamp)
849
- - `--skip-validation`: Skip validation of .dig files
850
-
851
- For `kill` command:
852
- - `--reason <text>`: Reason for killing the attempt
853
- - `-y, --yes`: Skip confirmation prompt
854
-
855
- For `retry` command:
856
- - `--from-task <task>`: Resume from specific task (session retry only)
857
- - `--resume-from <task>`: Resume from specific task (attempt retry only)
858
- - `--params <json>`: Override parameters (JSON string or @file.json)
859
- - `--force`: Force retry even if not failed (attempt retry only)
860
- - `-y, --yes`: Skip confirmation prompt
861
-
862
- **Examples**:
863
- ```bash
864
- # List all workflow projects
865
- tdx wf projects
866
-
867
- # Filter projects by pattern
868
- tdx wf projects "cdp_segment_*"
869
-
870
- # List all workflows
871
- tdx wf workflows
872
-
873
- # List workflows for a specific project
874
- tdx wf workflows myproject
875
-
876
- # Filter workflows by project pattern
877
- tdx wf workflows "lda*"
878
-
879
- # List all workflow sessions
880
- tdx wf sessions
881
-
882
- # List sessions for a specific project
883
- tdx wf sessions myproject
884
-
885
- # List sessions for specific workflow
886
- tdx wf sessions myproject.daily_etl
887
-
888
- # Filter sessions by status
889
- tdx wf sessions --status error
890
-
891
- # Filter sessions by time range
892
- tdx wf sessions --from "2025-01-01" --to "2025-01-31"
893
-
894
- # List all attempts
895
- tdx wf attempts
896
-
897
- # List attempts for a project
898
- tdx wf attempts myproject
899
-
900
- # List attempts for a workflow
901
- tdx wf attempts myproject.daily_etl
902
-
903
- # Include retried attempts
904
- tdx wf attempts --include-retried
905
-
906
- # Show specific attempt details
907
- tdx wf attempt 67890
908
-
909
- # Show tasks for an attempt
910
- tdx wf tasks 67890
911
-
912
- # Show tasks including subtasks
913
- tdx wf tasks 67890 --include-subtasks
914
-
915
- # View logs for a specific task
916
- tdx wf logs 67890 +step1
917
-
918
- # View logs with pagination
919
- tdx wf logs 67890 +step1 --offset 100 --limit 500
920
-
921
- # Kill a running attempt (with confirmation)
922
- tdx wf kill 67890
923
-
924
- # Kill with reason and skip confirmation
925
- tdx wf kill 67890 --reason "manual stop" -y
926
-
927
- # Retry entire session
928
- tdx wf retry session:12345
929
-
930
- # Retry session from specific task
931
- tdx wf retry session:12345 --from-task +step2
932
-
933
- # Retry attempt
934
- tdx wf retry attempt:67890
935
-
936
- # Retry attempt from specific task
937
- tdx wf retry attempt:67890 --resume-from +step2
938
-
939
- # Retry with parameter override
940
- tdx wf retry attempt:67890 --params '{"key":"value"}'
941
-
942
- # Retry with params from file
943
- tdx wf retry attempt:67890 --params @params.json
944
-
945
- # Force retry without confirmation
946
- tdx wf retry attempt:67890 --force -y
947
-
948
- # Download workflow project
949
- tdx wf download myproject
950
-
951
- # Download to specific directory
952
- tdx wf download myproject ./workflows
953
-
954
- # Download specific revision
955
- tdx wf download myproject --revision v1.0.0
956
-
957
- # Push workflow project (digdag-style: cd into project directory first)
958
- cd myproject
959
- tdx wf push myproject
960
-
961
- # Push with custom revision
962
- cd myproject
963
- tdx wf push myproject --revision v1.0.0
964
-
965
- # Push from parent directory with path
966
- tdx wf push ./myproject
967
-
968
- # Push with --name override
969
- cd myproject
970
- tdx wf push myproject --name production_workflow
971
-
972
- # Push from current directory without specifying name
973
- cd myproject
974
- tdx wf push
975
-
976
- # Push without validation
977
- cd myproject
978
- tdx wf push myproject --skip-validation
979
-
980
- # Delete workflow project (with confirmation)
981
- tdx wf delete myproject
982
-
983
- # Delete by project ID
984
- tdx wf delete 12345
985
-
986
- # Delete without confirmation
987
- tdx wf delete myproject -y
988
-
989
- # Get workflow data as JSON
990
- tdx wf sessions --format json --output sessions.json
991
- ```
992
-
993
- ### LLM Commands
994
-
995
- Usage: `tdx llm <subcommand>`
996
-
997
- Manage LLM projects, agents, and chat sessions with streaming support.
998
-
999
- | Command | Description | Example |
1000
- |---------|-------------|---------|
1001
- | `llm use <project>` | Set current project context | `tdx llm use "MyProject"` |
1002
- | `llm models` | List available LLM models | `tdx llm models` |
1003
- | `llm projects [pattern]` | List all projects (with wildcard support) | `tdx llm projects` or `tdx llm projects "data*"` |
1004
- | `llm project create <name>` | Create a new project | `tdx llm project create "MyProject"` |
1005
- | `llm project delete <name>` | Delete a project | `tdx llm project delete "MyProject"` |
1006
- | `llm agents [pattern]` | List agents in current project (with wildcard support) | `tdx llm agents` or `tdx llm agents "test*"` |
1007
- | `llm agent show <name>` | Show agent details | `tdx llm agent show "Data Analyst"` |
1008
- | `llm agent create <name>` | Create a new agent in current project | `tdx llm agent create "My Agent" --model <model>` |
1009
- | `llm agent update <name>` | Update an agent | `tdx llm agent update "Agent" --name "New Name"` |
1010
- | `llm agent delete <name>` | Delete an agent | `tdx llm agent delete "Agent"` |
1011
- | `llm history [chat-id]` | List chat sessions or show messages | `tdx llm history` or `tdx llm history chat456` |
1012
- | `llm proxy` | **[EXPERIMENTAL]** Start proxy server for Claude Code | `tdx llm proxy --port 4000` |
1013
- | `claude` | Launch Claude Code with integrated LLM proxy | `tdx claude` |
1014
-
1015
- **Project Resolution (Precedence Order):**
1016
-
1017
- Agent commands resolve projects in this order:
1018
- 1. `--llm-project` global option (highest priority)
1019
- 2. `tdx llm use <project>` context (session-only)
1020
- 3. Default project `tdx_default_<username>` (auto-created)
1021
-
1022
- **Command Options:**
1023
-
1024
- For `project create`:
1025
- - `--description <text>`: Project description
1026
-
1027
- For `agent create`:
1028
- - `--system-prompt <text>`: System prompt/instructions (default: empty)
1029
- - `--model <name>`: Model type or alias (default: claude-4.5-haiku)
1030
- - `--starter-message <text>`: Starter message for the agent
1031
- - `--max-tool-iterations <n>`: Maximum tool iterations (default: 4)
1032
- - `--temperature <n>`: Temperature 0.0-2.0 (default: 0.7)
1033
-
1034
- For `agent update`:
1035
- - `--name <text>`: New agent name
1036
- - `--prompt <text>`: New prompt/instructions
1037
- - `--description <text>`: New description
1038
- - `--starter-message <text>`: New starter message
1039
-
1040
- **Examples**:
1041
- ```bash
1042
- # List available models
1043
- tdx llm models
1044
-
1045
- # List all projects
1046
- tdx llm projects
1047
-
1048
- # List projects matching pattern (wildcards: * = any chars, ? = single char)
1049
- tdx llm projects "data*" # Projects starting with 'data'
1050
- tdx llm projects "*_prod" # Projects ending with '_prod'
1051
-
1052
- # Create a new project
1053
- tdx llm project create "MyProject" --description "My data analysis project"
1054
-
1055
- # Set current project context (session-only)
1056
- tdx llm use "MyProject"
1057
-
1058
- # Now all agent commands use "MyProject" by default:
1059
- tdx llm agents # List agents in MyProject
1060
- tdx llm agents "test*" # Filter agents by pattern
1061
- tdx llm agent show "Data Analyst" # Show agent from MyProject
1062
- tdx llm agent create "Analyst" --model gpt-5 # Create in MyProject
1063
- tdx llm agent update "Analyst" --name "Senior Analyst"
1064
- tdx llm agent delete "Analyst"
1065
-
1066
- # Override project with --llm-project option (highest priority)
1067
- tdx llm agents --llm-project "OtherProject"
1068
- tdx llm agent show "Agent" --llm-project "OtherProject"
1069
-
1070
- # Use default project (tdx_default_<username>) - no setup needed
1071
- tdx llm agents # Uses tdx_default_leo if no context set
1072
- tdx llm agent create "Bot" # Creates in default project
1073
-
1074
- # Complete workflow: Create custom agent and chat with it
1075
- tdx llm use "MyProject"
1076
- tdx llm agent create "SQL Expert" \
1077
- --system-prompt "You are an expert in SQL and data analysis. Help users write efficient queries." \
1078
- --model "claude-4.5-sonnet"
1079
-
1080
- # Now chat with your custom agent
1081
- tdx chat "Help me analyze customer churn" --agent "SQL Expert"
1082
- tdx chat "Show me the query for that" # Continues conversation
1083
-
1084
- # Delete project
1085
- tdx llm project delete "OldProject"
1086
-
1087
- # Chat history
1088
- tdx llm history # List recent chat sessions
1089
- tdx llm history chat456 # Show specific chat messages
1090
-
1091
- # JSON output
1092
- tdx llm agents --format json --output agents.json
1093
- ```
1094
-
1095
- ### Claude Code Integration
1096
-
1097
- The `tdx claude` command provides seamless integration with Claude Code by automatically:
1098
- 1. Creating/using a default project and agent (or using cached haiku/sonnet/opus agent)
1099
- 2. Finding an available port and starting an LLM proxy server in the background
1100
- 3. Generating `.claude/settings.local.json` configuration file
1101
- 4. Launching Claude Code with the proxy configured
1102
- 5. Stopping the proxy server when Claude Code exits
1103
-
1104
- **Quick Start:**
1105
-
1106
- ```bash
1107
- # Launch Claude Code with default settings (uses haiku model)
41
+ # Launch Claude Code with TD LLM
1108
42
  tdx claude
1109
-
1110
- # Use sonnet model instead
1111
- tdx claude --model sonnet
1112
-
1113
- # Use opus model
1114
- tdx claude --model opus
1115
-
1116
- # Enable debug/trace logging
1117
- tdx --debug claude
1118
- tdx --trace claude
1119
-
1120
- # Pass arbitrary options to Claude Code using '--' separator
1121
- # Continue previous session
1122
- tdx claude --model sonnet -- -c
1123
-
1124
- # Resume a specific session
1125
- tdx claude -- -r session-id-here
1126
-
1127
- # Combine tdx and Claude Code options
1128
- tdx claude --debug -- -c
1129
- ```
1130
-
1131
- **Requirements:**
1132
- - Claude Code CLI must be installed (https://claude.com/claude-code)
1133
- - The command will fail with a helpful error if Claude Code is not found
1134
-
1135
- **Debugging:**
1136
- - Logs are written to `~/.cache/tdx/logs/proxy.log`
1137
- - Use `--debug` for HTTP request/response logging
1138
- - Use `--trace` for ultra-verbose internal operation logging
1139
- - View logs in real-time: `tail -f ~/.cache/tdx/logs/proxy.log`
1140
-
1141
- **How It Works:**
1142
-
1143
- 1. Creates or reuses a default agent (e.g., `tdx_claude-4.5-haiku`) with the specified model
1144
- 2. Finds an available port starting from 4000 (tries 4001, 4002, etc. if occupied)
1145
- 3. Starts `tdx llm proxy` in the background on the found port
1146
- 4. Creates `.claude/settings.local.json` with:
1147
- ```json
1148
- {
1149
- "env": {
1150
- "ANTHROPIC_BASE_URL": "http://127.0.0.1:4000",
1151
- "ANTHROPIC_MODEL": "haiku"
1152
- }
1153
- }
1154
- ```
1155
- 5. Launches Claude Code CLI
1156
- 6. When Claude Code exits, automatically stops the proxy server
1157
-
1158
- **Options:**
1159
-
1160
- - `--model <name>`: Model to use (haiku, sonnet, opus) - default: haiku
1161
- - `--debug`: Enable debug mode (logs proxy request/response to stderr)
1162
-
1163
- **Model Selection:**
1164
-
1165
- The `--model` flag controls which TD agent is used:
1166
- - `haiku` → Uses/creates `tdx_claude-4.5-haiku` agent (fast, cost-effective)
1167
- - `sonnet` → Uses/creates `tdx_claude-4.5-sonnet` agent (balanced)
1168
- - `opus` → Uses/creates `tdx_claude-opus` agent (most capable)
1169
-
1170
- All agents are created in your default project (`tdx_default_<username>`) and cached for reuse.
1171
-
1172
- **Advantages over Manual Setup:**
1173
- - Zero configuration - just run `tdx claude` and start coding
1174
- - Automatic port management - finds available port automatically
1175
- - Automatic cleanup - stops proxy when Claude Code exits
1176
- - Smart agent caching - reuses agents across sessions
1177
-
1178
- #### LLM Proxy Server for Claude Code
1179
-
1180
- > **⚠️ EXPERIMENTAL FEATURE**: This proxy server is experimental and may have limitations. Please report issues at https://github.com/treasure-data/tdx/issues
1181
-
1182
- The `tdx llm proxy` command starts a local HTTP server that provides Anthropic-compatible API endpoints, allowing Claude Code and other AI coding assistants to use Treasure Data's LLM API as a backend.
1183
-
1184
- **Starting the Proxy:**
1185
-
1186
- ```bash
1187
- # Start proxy with default settings (port 4000)
1188
- tdx llm proxy
1189
-
1190
- # Specify custom port
1191
- tdx llm proxy --port 8000
1192
-
1193
- # Use specific project and agent
1194
- tdx llm proxy --project "MyProject" --agent "MyAgent"
1195
-
1196
- # Use context (set with 'tdx llm use')
1197
- tdx llm use "MyProject/MyAgent"
1198
- tdx llm proxy
1199
-
1200
- # Enable debug mode to see request/response JSON
1201
- tdx llm proxy --debug
1202
- ```
1203
-
1204
- **Claude Code Configuration:**
1205
-
1206
- Create a `.claude/settings.local.json` file in your project directory:
1207
-
1208
- ```json
1209
- {
1210
- "env": {
1211
- "ANTHROPIC_BASE_URL": "http://127.0.0.1:4000",
1212
- "ANTHROPIC_MODEL": "sonnet"
1213
- }
1214
- }
1215
- ```
1216
-
1217
- **Testing with Agent SDK:**
1218
-
1219
- You can also test the proxy using [Claude Agent SDK](https://docs.claude.com/en/docs/agent-sdk/typescript):
1220
-
1221
- ```bash
1222
- npm install @anthropic-ai/sdk
1223
- ```
1224
-
1225
- The SDK reads `.claude/settings.json` for `ANTHROPIC_BASE_URL` configuration.
1226
-
1227
- **How It Works:**
1228
-
1229
- 1. The proxy translates Anthropic Messages API calls to TD LLM API format
1230
- 2. Maintains conversation state across multiple requests
1231
- 3. Streams responses in real-time using Server-Sent Events (SSE)
1232
- 4. Maps model names (sonnet/haiku/opus) to TD models
1233
- 5. Supports tool calls via prompt engineering (see Tool Support below)
1234
-
1235
- **Proxy Options:**
1236
-
1237
- - `--port <number>`: Port to run the server on (default: 4000)
1238
- - `--project <name>`: LLM project name (uses context or default)
1239
- - `--agent <name>`: Agent name (uses context or default)
1240
- - `--debug`: Enable debug mode (logs request/response JSON to stderr)
1241
-
1242
- **Tool Support:**
1243
-
1244
- The proxy supports Anthropic-style tool calls via prompt engineering:
1245
-
1246
- 1. **Tool Definition Injection**: Tool definitions from the Anthropic request are converted into clear instructions and prepended to the user message
1247
- 2. **JSON-based Tool Calls**: The LLM is instructed to output tool calls as JSON: `{"tool_use":{"id":"toolu_xxx","name":"tool_name","input":{...}}}`
1248
- 3. **Automatic Detection**: The proxy parses the response stream to detect tool call JSON and converts it to proper Anthropic SSE events
1249
- 4. **Tool Results**: When the client sends tool results back, they're formatted and included in the next message to the LLM
1250
-
1251
- This approach works around the architectural differences between TD's server-driven tool system and Anthropic's client-driven model.
1252
-
1253
- **Known Limitations:**
1254
-
1255
- - Tool calls rely on prompt engineering (LLM must output correct JSON format)
1256
- - Non-streaming responses are not implemented
1257
- - Image inputs are not supported
1258
- - System prompt is prepended to first message only (not persisted in agent)
1259
- - TD's built-in tools (knowledge base, functions) are not directly accessible
1260
-
1261
- ## Advanced Query Features
1262
-
1263
- ### File Input
1264
-
1265
- Read SQL queries from files using the `-f` or `--file` option:
1266
-
1267
- ```bash
1268
- # Execute SQL from file
1269
- tdx query --file query.sql
1270
-
1271
- # Short form
1272
- tdx query -f query.sql
1273
-
1274
- # With options
1275
- tdx query -f query.sql --database mydb --format json --output results.json
1276
- ```
1277
-
1278
- ### Multi-Statement Execution
1279
-
1280
- Execute multiple SQL statements sequentially by separating them with semicolons. This works for both command-line input and file input:
1281
-
1282
- **From command line**:
1283
- ```bash
1284
- tdx query "SELECT COUNT(*) FROM users; SELECT COUNT(*) FROM orders"
1285
- ```
1286
-
1287
- **From file** (`setup-and-query.sql`):
1288
- ```sql
1289
- CREATE TABLE temp_users AS SELECT * FROM users WHERE active = true;
1290
- CREATE TABLE temp_orders AS SELECT * FROM orders WHERE user_id IN (SELECT id FROM temp_users);
1291
- SELECT COUNT(*) as order_count FROM temp_orders;
1292
- ```
1293
-
1294
- ```bash
1295
- tdx query -f setup-and-query.sql
1296
- ```
1297
-
1298
- **Output behavior**:
1299
- - Each statement executes sequentially with progress indication
1300
- - **Console output**: All results displayed as they complete
1301
- - **File output** (`--output results.txt`): All results appended to single file
1302
- - **Fail-fast**: Execution stops on first error
1303
-
1304
- **Example output**:
1305
- ```
1306
- ✔ Statement 1/3 - Query completed: Processed 1,000 rows in 2.3s
1307
- ┌────────────┐
1308
- │ user_count │
1309
- ├────────────┤
1310
- │ 1000 │
1311
- └────────────┘
1312
- ✔ Statement 2/3 - Query completed: Processed 5,000 rows in 3.1s
1313
- ┌─────────────┐
1314
- │ order_count │
1315
- ├─────────────┤
1316
- │ 5000 │
1317
- └─────────────┘
1318
- ✔ Statement 3/3 - Query completed: Processed 1 rows in 0.5s
1319
- ┌─────────────┐
1320
- │ order_count │
1321
- ├─────────────┤
1322
- │ 5000 │
1323
- └─────────────┘
1324
- ```
1325
-
1326
- **With `--output`** (file mode):
1327
- ```bash
1328
- tdx query -f statements.sql --output results.txt
1329
- ```
1330
- - Console shows only progress messages
1331
- - All results written to `results.txt` (appended sequentially)
1332
- - Message: "All results saved to results.txt"
1333
-
1334
- ## Output Formats
1335
-
1336
- tdx supports multiple output formats for query results and command outputs:
1337
-
1338
- ### Table Format (default)
1339
- Human-readable ASCII table with column types and row counts:
1340
- ```bash
1341
- tdx query "SELECT name, age FROM users LIMIT 2"
1342
- ```
1343
- ```
1344
- ┌───────┬─────┐
1345
- │ name │ age │
1346
- │ string│ int │
1347
- ├───────┼─────┤
1348
- │ Alice │ 25 │
1349
- │ Bob │ 30 │
1350
- ├───────┴─────┤
1351
- │ 2 rows │
1352
- └─────────────┘
1353
- ```
1354
-
1355
- ### JSON Format
1356
- Readable JSON array with newlines (no metadata):
1357
- ```bash
1358
- tdx query "SELECT name, age FROM users LIMIT 2" --format json
1359
- ```
1360
- ```json
1361
- [
1362
- {"name":"Alice","age":25},
1363
- {"name":"Bob","age":30}
1364
- ]
1365
- ```
1366
-
1367
- Each object is compact (single line) but separated by newlines for readability.
1368
-
1369
- Perfect for piping to `jq`:
1370
- ```bash
1371
- tdx query "SELECT * FROM users" --format json | jq '.[0]'
1372
- tdx query "SELECT * FROM users" --format json | jq 'length'
1373
43
  ```
1374
44
 
1375
- ### JSON Lines Format (jsonl)
1376
- One JSON object per line - ideal for streaming and line-by-line processing:
1377
- ```bash
1378
- tdx query "SELECT name, age FROM users LIMIT 2" --format jsonl
1379
- ```
1380
- ```
1381
- {"name":"Alice","age":25}
1382
- {"name":"Bob","age":30}
1383
- ```
45
+ ## Documentation
1384
46
 
1385
- Process line by line:
1386
- ```bash
1387
- tdx query "SELECT * FROM users" --format jsonl | while read line; do
1388
- echo "$line" | jq '.name'
1389
- done
1390
- ```
1391
-
1392
- ### TSV Format
1393
- Tab-separated values with header row:
1394
- ```bash
1395
- tdx query "SELECT name, age FROM users LIMIT 2" --format tsv
1396
- ```
1397
- ```
1398
- name age
1399
- Alice 25
1400
- Bob 30
1401
- ```
1402
-
1403
- ### Color Output
1404
-
1405
- `tdx` automatically adds ANSI colors to output in interactive terminals to improve readability:
1406
-
1407
- **Table format:**
1408
- - Table borders: Dark gray (dim)
1409
- - Column headers: Plain text (no color)
1410
- - Type row: Dim gray
1411
- - Data values: Plain text (no color)
1412
-
1413
- **JSON format:**
1414
- - Keys: Blue
1415
- - Strings: Green
1416
- - Numbers: Cyan
1417
- - Booleans: Yellow
1418
- - Null values: Dim
1419
-
1420
- **JSONL format:**
1421
- - Same color scheme as JSON format
1422
- - Compact one-line-per-object output with colors in interactive terminals
1423
-
1424
- **Automatic detection:**
1425
- - Colors are enabled automatically when output is to an interactive terminal (TTY)
1426
- - Colors are disabled automatically when:
1427
- - Output is piped to another command
1428
- - Output is saved to a file with `--output`
1429
- - Respects the `NO_COLOR` environment variable (see https://no-color.org/)
1430
-
1431
- **Manual control:**
1432
- ```bash
1433
- # Force colors on (even when piping or saving to file)
1434
- tdx databases --color
1435
- tdx databases --color --output results.txt
1436
-
1437
- # Disable colors (even in interactive terminal)
1438
- tdx databases --no-color
1439
-
1440
- # Disable colors via environment variable
1441
- NO_COLOR=1 tdx databases
1442
- ```
1443
-
1444
- **Priority order:**
1445
- 1. `--no-color` flag (highest priority)
1446
- 2. `--color` flag
1447
- 3. `NO_COLOR` environment variable
1448
- 4. TTY detection (automatic)
1449
-
1450
- ## Advanced Commands
1451
-
1452
- ### API Command (Raw HTTP Access)
1453
-
1454
- Make authenticated HTTP requests to any Treasure Data API endpoint (similar to `gh api` from GitHub CLI).
1455
-
1456
- **Usage:** `tdx api <endpoint> [options]`
1457
-
1458
- | Option | Description | Example |
1459
- |--------|-------------|---------|
1460
- | `<endpoint>` | API endpoint path (must start with /) | `/v3/database/list` |
1461
- | `-X, --method <method>` | HTTP method (GET, POST, PUT, DELETE, PATCH) | `-X POST` |
1462
- | `--data <json>` | Request body as JSON string | `--data '{"name":"mydb"}'` |
1463
- | `-f, --file <path>` | Read request body from file | `-f body.json` |
1464
- | `-H, --header <header>` | Custom header (repeatable) | `-H "X-Custom: value"` |
1465
- | `--type <api_type>` | API type (td, cdp, workflow, trino, llm) | `--type cdp` |
1466
-
1467
- **Examples:**
1468
-
1469
- ```bash
1470
- # GET request to TD API (default)
1471
- tdx api /v3/database/list
1472
-
1473
- # GET with path parameters
1474
- tdx api /v3/database/show/mydb
1475
- tdx api /v3/table/list/mydb
1476
- tdx api /v3/table/show/mydb/users
1477
-
1478
- # POST with inline JSON body (submit query)
1479
- tdx api -X POST --data '{"query":"SELECT 1"}' /v3/job/issue/hive/mydb
1480
-
1481
- # POST with data from file
1482
- tdx api -X POST -f query.json /v3/job/issue/hive/mydb
1483
-
1484
- # Custom headers
1485
- tdx api -H "X-Custom: value" -H "X-Another: test" /v3/database/list
1486
-
1487
- # CDP API endpoints (read-only)
1488
- tdx api /entities/parent_segments --type cdp
1489
- tdx api /audiences/12345/segments --type cdp
1490
- tdx api -X POST --data '{"format":"sql"}' /audiences/12345/segments/query --type cdp
1491
-
1492
- # Workflow API endpoints (read-only)
1493
- tdx api /api/workflows --type workflow
1494
- tdx api /api/projects --type workflow
1495
- tdx api /api/attempts --type workflow
1496
-
1497
- # Trino API endpoints (query submission - plain SQL, not JSON)
1498
- tdx api -X POST --data 'SELECT 1' /v1/statement --type trino
1499
-
1500
- # LLM API endpoints (read-only)
1501
- tdx api /v1/agents --type llm
1502
- tdx api /v1/models --type llm
1503
-
1504
- # Show HTTP response headers (with --verbose)
1505
- tdx api /v3/database/list --verbose
1506
-
1507
- # Save output to file
1508
- tdx api /v3/database/list --output databases.json
1509
-
1510
- # Combine --verbose with --output to see headers while saving
1511
- tdx api /v3/database/list --verbose --output databases.json
1512
- ```
1513
-
1514
- **API Types:**
1515
-
1516
- | Type | Base URL Pattern | Description |
1517
- |------|-----------------|-------------|
1518
- | `td` | `api.treasuredata.com` | TD REST API (databases, tables, jobs) |
1519
- | `cdp` | `api-cdp.treasuredata.com` | CDP API (audiences, segments, activations) |
1520
- | `workflow` | `api-workflow.treasuredata.com` | Workflow API (digdag) |
1521
- | `trino` | `api-presto.treasuredata.com` | Trino Query Engine API |
1522
- | `llm` | `llm-api.treasuredata.com` | LLM API (agents, chat) |
1523
-
1524
- **Notes:**
1525
- - All requests are automatically authenticated using your configured API key
1526
- - Request body from `--data` must be valid JSON
1527
- - `--data` and `--file` are mutually exclusive
1528
- - Custom headers override default authentication headers
1529
- - Response is output to stdout as JSON
1530
- - Use `--verbose` to show HTTP request/response details in stderr:
1531
- - Full target URL (shows site and API type)
1532
- - Request headers (non-sensitive: User-Agent, X-TD-Client, Content-Type, etc.)
1533
- - Response status and headers
1534
- - Sensitive headers (Authorization, Cookie, etc.) are hidden for security
1535
-
1536
- **Verbose Output Example:**
1537
- ```
1538
- > POST https://api.treasuredata.com/v3/job/issue/hive/mydb
1539
- > User-Agent: tdx/1.0.0 (darwin; node/24.0.0)
1540
- > X-TD-Client: tdx
1541
- > X-TD-Client-Version: 1.0.0
1542
- > Content-Type: application/json
1543
- >
1544
-
1545
- < HTTP/1.1 200
1546
- < content-type: application/json
1547
- < x-td-request-id: abc123
1548
-
1549
- {"job_id": "12345"}
1550
- ```
1551
-
1552
- ## Advanced Options
1553
-
1554
- ### Session ID Option
1555
-
1556
- By default, sessions are tied to the shell's process ID (PPID). You can explicitly specify a session ID using `--session` to share context across multiple processes or shells:
1557
-
1558
- **Usage:** `tdx --session <session-id> [command]`
1559
-
1560
- **Examples:**
1561
-
1562
- ```bash
1563
- # Process 1: Set session with explicit ID
1564
- tdx --session my-workflow use database analytics
1565
- tdx --session my-workflow use llm_project DataPipeline
1566
-
1567
- # Process 2: Reuse the same session
1568
- tdx --session my-workflow context
1569
- # Shows: Database: analytics, LLM Project: DataPipeline
1570
-
1571
- # Process 2: Run commands with shared context
1572
- tdx --session my-workflow tables
1573
- # Uses database: analytics
1574
-
1575
- # Clean up when done
1576
- tdx --session my-workflow use --clear
1577
- ```
1578
-
1579
- **Use Cases:**
1580
- - Sharing context between multiple terminal windows
1581
- - Maintaining consistent context in CI/CD pipelines
1582
- - Scripting scenarios where session persistence is needed
1583
-
1584
- **Note:** The `--session` option must be specified before the command name (e.g., `tdx --session id tables`, not `tdx tables --session id`).
1585
-
1586
- ## Architecture
1587
-
1588
- The `tdx` project is designed with a layered architecture that separates the CLI interface from the core SDK, allowing the TypeScript SDK to be used in multiple environments:
1589
-
1590
- ```mermaid
1591
- graph TD
1592
- subgraph "Client Environments"
1593
- NodeJS[Node.JS/CLI<br/>tdx commands]
1594
- Browser[Web Browser<br/>Client-side]
1595
- end
1596
-
1597
- subgraph "TDX SDK - TypeScript"
1598
- SDK[TDX SDK<br/>TypeScript/JavaScript API]
1599
- end
1600
-
1601
- subgraph "Treasure Data APIs"
1602
- TD[TD REST API<br/>Databases, Tables, Jobs]
1603
- Trino[Trino Streaming API<br/>Query Execution]
1604
- CDP[CDP API<br/>Segments, Activations]
1605
- end
1606
-
1607
- NodeJS --> SDK
1608
- Browser --> SDK
1609
-
1610
- SDK -->|HTTPS| TD
1611
- SDK -->|HTTPS| Trino
1612
- SDK -->|HTTPS| CDP
1613
-
1614
- style NodeJS fill:#d4f1d4
1615
- style Browser fill:#ffd4d4
1616
- style SDK fill:#fff5cc
1617
- style TD fill:#e8e8f0
1618
- style CDP fill:#e8e8f0
1619
- style Trino fill:#e8e8f0
1620
- ```
1621
-
1622
- ## TDX SDK
1623
-
1624
- **Usage Examples:**
1625
-
1626
- **Node.js:**
1627
- ```typescript
1628
- import { TDX, loadLocalSDKConfig } from '@treasuredata/tdx/sdk';
1629
-
1630
- // Load config from environment or pass API key directly
1631
- const config = loadLocalSDKConfig({
1632
- site: 'us01',
1633
- apiKey: 'your_key_id/your_key_secret' // Optional: omit to load from env
1634
- });
1635
- const tdx = new TDX(config);
1636
- const result = await tdx.query('SELECT * FROM users');
1637
- ```
1638
-
1639
- **Web Browser:**
1640
- ```html
1641
- <script type="module">
1642
- import { TDX } from 'https://unpkg.com/@treasuredata/tdx';
1643
- // Browser: Create config object directly (loadLocalSDKConfig requires file system)
1644
- const config = {
1645
- site: 'us01',
1646
- apiKey: 'your_key_id/your_key_secret',
1647
- verbose: false
1648
- };
1649
- const tdx = new TDX(config);
1650
- const result = await tdx.query('SELECT * FROM users');
1651
- </script>
1652
- ```
47
+ For detailed documentation, visit [https://tdx.treasuredata.com/](https://tdx.treasuredata.com/):
1653
48
 
49
+ - [Getting Started Guide](https://tdx.treasuredata.com/guide/)
50
+ - [Authentication](https://tdx.treasuredata.com/guide/authentication)
51
+ - [Commands Reference](https://tdx.treasuredata.com/commands/)
52
+ - [Claude Code Integration](https://tdx.treasuredata.com/commands/claude)
53
+ - [TD Skills for Claude Code](https://tdx.treasuredata.com/guide/td-skills)
1654
54
 
1655
55
  ## Requirements
1656
56
 
1657
- - **Node.js 22.0.0 or higher** (Node.js 24 Active LTS recommended for development)
57
+ - **Node.js 22.0.0 or higher** (Node.js 24 Active LTS recommended)
1658
58
  - TD API key with appropriate permissions
1659
59
 
1660
-
1661
60
  ## License
1662
61
 
1663
62
  Apache-2.0
@@ -1665,4 +64,3 @@ Apache-2.0
1665
64
  ## Contributing
1666
65
 
1667
66
  This project is maintained by the Treasure Data DevAI Unit.
1668
-