@loxtep/sdk 0.7.1 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +157 -219
- package/dist/cli/commands/config-cmd.js +3 -3
- package/dist/cli/commands/login.d.ts +2 -3
- package/dist/cli/commands/login.d.ts.map +1 -1
- package/dist/cli/commands/login.js +11 -9
- package/dist/cli/commands/login.js.map +1 -1
- package/dist/cli/commands/logout.d.ts.map +1 -1
- package/dist/cli/commands/logout.js +1 -8
- package/dist/cli/commands/logout.js.map +1 -1
- package/dist/cli/create-cli-client.js +2 -2
- package/dist/cli/create-cli-client.js.map +1 -1
- package/dist/cli/credentials.d.ts +9 -10
- package/dist/cli/credentials.d.ts.map +1 -1
- package/dist/cli/credentials.js +41 -30
- package/dist/cli/credentials.js.map +1 -1
- package/dist/cli/help.d.ts +6 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +82 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +8 -91
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/version.d.ts +8 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +25 -0
- package/dist/cli/version.js.map +1 -0
- package/docs/code-first-cli.md +182 -0
- package/docs/event-replay-cookbook.md +31 -25
- package/docs/getting-started.md +32 -27
- package/docs/quick-reference.md +67 -105
- package/docs/sdk-pairing.md +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,62 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
and this project adheres to
|
|
7
7
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
+
## [0.7.7] - 2026-07-23
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **CLI help** no longer exposes internal MCP facade names (`loxtep_session`,
|
|
14
|
+
`client.build`, etc.). Commands are grouped under customer-facing headings
|
|
15
|
+
(Authentication, Workspace, Build & deploy, Governance, …).
|
|
16
|
+
|
|
17
|
+
## [0.7.6] - 2026-07-23
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **`loxtep --version`** (also `-V` and `loxtep version`) prints the installed
|
|
22
|
+
`@loxtep/sdk` semver, e.g. `@loxtep/sdk 0.7.6`.
|
|
23
|
+
|
|
24
|
+
## [0.7.5] - 2026-07-23
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **CLI help** (`loxtep --help`) reorganized under **MCP-aligned SDK facades**
|
|
29
|
+
(Session, Workspace, Build, Define, Review, Query, Observe, Context) instead
|
|
30
|
+
of a flat command list. Help text lives in `src/cli/help.ts`.
|
|
31
|
+
|
|
32
|
+
## [0.7.4] - 2026-07-23
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- **Documentation** defaults to **pnpm** (`pnpm add`, `pnpm exec loxtep`) instead of
|
|
37
|
+
npm/npx across README, getting started, quick reference, and SDK pairing.
|
|
38
|
+
- **New guide:** [`docs/code-first-cli.md`](./docs/code-first-cli.md) documents the
|
|
39
|
+
`loxtep init → attach → generate → test → deploy` workflow, when init is
|
|
40
|
+
required vs login-only programmatic use, and cross-links from getting started
|
|
41
|
+
and quick reference.
|
|
42
|
+
- CLI auth hints now reference `pnpm exec loxtep login` for consistency with docs.
|
|
43
|
+
|
|
44
|
+
## [0.7.3] - 2026-07-23
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- **`loxtep login`** now saves credentials to **`./.loxtep/credentials.json`** in
|
|
49
|
+
the current working directory by default (not `~/.loxtep/credentials.json`).
|
|
50
|
+
Use `--global` for the home-directory path. Read resolution walks upward for
|
|
51
|
+
a local `credentials.json` before falling back to global.
|
|
52
|
+
|
|
53
|
+
## [0.7.2] - 2026-07-23
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- **Documentation** aligned with **v0.7.0+ MCP facade API**: README, getting
|
|
58
|
+
started, quick reference, event replay cookbook, and AGENTS guidance now use
|
|
59
|
+
`client.get_writer` / `client.get_reader` and facade paths
|
|
60
|
+
(`client.build.*`, `client.observe.*`, etc.) instead of removed flat
|
|
61
|
+
namespaces (`client.data_products`, `client.workflows`, …).
|
|
62
|
+
- **Module export docs** corrected: import from `@loxtep/sdk` (and
|
|
63
|
+
`@loxtep/sdk/errors` only for the errors subpath).
|
|
64
|
+
|
|
9
65
|
## [0.7.1] - 2026-07-23
|
|
10
66
|
|
|
11
67
|
### Security
|
package/README.md
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
# Loxtep Node.js SDK
|
|
2
2
|
|
|
3
|
-
Client for the Loxtep API
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Client for the Loxtep API. Since **v0.7.0**, the public surface mirrors the
|
|
4
|
+
**10 hosted MCP tool facades** (no flat top-level namespaces like
|
|
5
|
+
`client.workflows` or `client.data_products`).
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
| MCP facade | SDK namespace | Examples |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `loxtep_session` | `client.session` | `get_current_user()` |
|
|
10
|
+
| `loxtep_connect` | `client.connect` | `.connectors.*`, `.templates.*` |
|
|
11
|
+
| `loxtep_workspace` | `client.workspace` | `.projects.*`, `.instances.*` |
|
|
12
|
+
| `loxtep_build` | `client.build` | `.workflows.*`, `.triggers.*`, `.data_products.*`, `.targets.*` |
|
|
13
|
+
| `loxtep_define` | `client.define` | `.schemas.*`, `.quality.*`, `.domains.*`, … |
|
|
14
|
+
| `loxtep_meaning` | `client.meaning` | `.thesaurus.*` |
|
|
15
|
+
| `loxtep_review` | `client.review` | `.approvals.*`, `.improvements.*` |
|
|
16
|
+
| `loxtep_query` | `client.query` | `.catalog.*`, `.discovery.*`, `.query()` |
|
|
17
|
+
| `loxtep_observe` | `client.observe` | `.stream_config()`, `.open_reader()` |
|
|
18
|
+
| `loxtep_context` | `client.context` | `.procedures.*`, `.activity.*`, … |
|
|
19
|
+
|
|
20
|
+
**Stream I/O** uses top-level helpers (not nested under a facade):
|
|
21
|
+
`await client.get_writer('data-product-name')` and
|
|
22
|
+
`await client.get_reader('data-product-name')`.
|
|
23
|
+
|
|
24
|
+
Full mapping table: [`docs/sdk-mcp-mapping.md`](./docs/sdk-mcp-mapping.md).
|
|
25
|
+
**Upgrading from 0.6.x:** replace `client.data_products` →
|
|
26
|
+
`client.build.data_products` (CRUD/stream/replay) or `client.get_writer` /
|
|
27
|
+
`client.get_reader` (recommended write/read path); `client.workflows` →
|
|
28
|
+
`client.build.workflows`; etc.
|
|
13
29
|
|
|
14
30
|
**Node.js 22+** is the supported runtime (`engines` in `package.json`). **Live**
|
|
15
31
|
queue/flow writes use the **Loxtep stream** data plane; configure stream bus
|
|
@@ -22,7 +38,7 @@ This SDK supports two developer workflows:
|
|
|
22
38
|
|
|
23
39
|
| Path | Use case | Entry point |
|
|
24
40
|
|------|----------|-------------|
|
|
25
|
-
| **Programmatic** | Write/read events from application code (microservices, lambdas, scripts) | `LoxtepClient` → `
|
|
41
|
+
| **Programmatic** | Write/read events from application code (microservices, lambdas, scripts) | `LoxtepClient` → `get_writer` / `get_reader` |
|
|
26
42
|
| **Code-first CLI** | Author workflows as TypeScript, test locally, deploy via CI | `loxtep init → attach → generate → test → deploy` |
|
|
27
43
|
|
|
28
44
|
There are also two additional paths that don't require this SDK:
|
|
@@ -38,19 +54,19 @@ All paths are documented in the [Loxtep Quickstart](https://docs.loxtep.io/quick
|
|
|
38
54
|
1. **Install**
|
|
39
55
|
|
|
40
56
|
```bash
|
|
41
|
-
|
|
57
|
+
pnpm add @loxtep/sdk
|
|
42
58
|
```
|
|
43
59
|
|
|
44
60
|
2. **Log in**
|
|
45
61
|
|
|
46
62
|
```bash
|
|
47
|
-
|
|
63
|
+
pnpm exec loxtep login
|
|
48
64
|
```
|
|
49
65
|
|
|
50
66
|
A browser window opens — sign in to Loxtep and you're authenticated.
|
|
51
|
-
Tokens are saved to
|
|
67
|
+
Tokens are saved to `./.loxtep/credentials.json` (use `--global` for home dir).
|
|
52
68
|
|
|
53
|
-
> **CI/headless:** Use `
|
|
69
|
+
> **CI/headless:** Use `pnpm exec loxtep login --email you@co.com --password ...`
|
|
54
70
|
> or set `LOXTEP_AUTH_TOKEN` in your environment.
|
|
55
71
|
|
|
56
72
|
3. **Create a client, write and read events**
|
|
@@ -63,8 +79,8 @@ All paths are documented in the [Loxtep Quickstart](https://docs.loxtep.io/quick
|
|
|
63
79
|
auth: { type: 'jwt', token: process.env.LOXTEP_AUTH_TOKEN! },
|
|
64
80
|
});
|
|
65
81
|
|
|
66
|
-
// Write events to a data product
|
|
67
|
-
const writer = await client.
|
|
82
|
+
// Write events to a data product (top-level — resolves deployment metadata)
|
|
83
|
+
const writer = await client.get_writer('shopify_gql_customer');
|
|
68
84
|
writer.write({
|
|
69
85
|
customer_id: '123',
|
|
70
86
|
name: 'Alice',
|
|
@@ -73,7 +89,7 @@ All paths are documented in the [Loxtep Quickstart](https://docs.loxtep.io/quick
|
|
|
73
89
|
await writer.close();
|
|
74
90
|
|
|
75
91
|
// Read events from a data product
|
|
76
|
-
const reader = await client.
|
|
92
|
+
const reader = await client.get_reader('shopify_gql_customer');
|
|
77
93
|
for await (const event of reader) {
|
|
78
94
|
console.log(event);
|
|
79
95
|
}
|
|
@@ -87,44 +103,45 @@ All paths are documented in the [Loxtep Quickstart](https://docs.loxtep.io/quick
|
|
|
87
103
|
`await client.observe.stream_config()` returns stream resource names
|
|
88
104
|
needed for the data plane. Merge into
|
|
89
105
|
`new LoxtepClient({ ...opts, streams: { ...partial } })` with your
|
|
90
|
-
JWT-backed client.
|
|
91
|
-
|
|
106
|
+
JWT-backed client. `get_writer` / `get_reader` resolve stream config
|
|
107
|
+
automatically — this step is only needed for manual bus access via
|
|
108
|
+
`client.observe.open_reader()`.
|
|
92
109
|
|
|
93
110
|
---
|
|
94
111
|
|
|
95
112
|
## Quick start — Code-first CLI (init → deploy)
|
|
96
113
|
|
|
97
|
-
For developers who author workflows as TypeScript and want the full local-dev-to-production lifecycle:
|
|
114
|
+
For developers who author workflows as TypeScript and want the full local-dev-to-production lifecycle, see the dedicated **[Code-first CLI guide](./docs/code-first-cli.md)**. Quick version:
|
|
98
115
|
|
|
99
116
|
```bash
|
|
100
117
|
# 1. Install
|
|
101
|
-
|
|
118
|
+
pnpm add @loxtep/sdk
|
|
102
119
|
|
|
103
120
|
# 2. Authenticate
|
|
104
|
-
|
|
121
|
+
pnpm exec loxtep login
|
|
105
122
|
|
|
106
123
|
# 3. Scaffold a project from a template
|
|
107
|
-
|
|
124
|
+
pnpm exec loxtep init --template shopify-orders
|
|
108
125
|
|
|
109
126
|
# 4. Bind to a runtime instance
|
|
110
|
-
|
|
127
|
+
pnpm exec loxtep attach --instance prod
|
|
111
128
|
|
|
112
129
|
# 5. Generate typed workspace constants
|
|
113
|
-
|
|
130
|
+
pnpm exec loxtep generate
|
|
114
131
|
|
|
115
132
|
# 6. Author a workflow (see authoring module docs below)
|
|
116
133
|
|
|
117
134
|
# 7. Test locally with a sample event
|
|
118
|
-
|
|
135
|
+
pnpm exec loxtep test orders-enricher --event ./events/order-created.json
|
|
119
136
|
|
|
120
137
|
# 8. Deploy to the workflow engine
|
|
121
|
-
|
|
138
|
+
pnpm exec loxtep deploy
|
|
122
139
|
```
|
|
123
140
|
|
|
124
141
|
The `generate` step produces `.loxtep/generated/index.ts` with typed constants for every data product, connector, domain, and queue in your workspace. Import them in your workflow modules for compile-time safety:
|
|
125
142
|
|
|
126
143
|
```ts
|
|
127
|
-
import { defineDataWorkflow, on } from '@loxtep/sdk
|
|
144
|
+
import { defineDataWorkflow, on } from '@loxtep/sdk'
|
|
128
145
|
import { workspace } from './.loxtep/generated'
|
|
129
146
|
|
|
130
147
|
export default defineDataWorkflow({
|
|
@@ -146,71 +163,76 @@ See `loxtep init --help`, `loxtep attach --help`, etc. for all flags. The full C
|
|
|
146
163
|
|
|
147
164
|
## API surface
|
|
148
165
|
|
|
149
|
-
Every method is `snake_case`.
|
|
150
|
-
|
|
151
|
-
(
|
|
152
|
-
|
|
153
|
-
###
|
|
154
|
-
|
|
155
|
-
-
|
|
156
|
-
|
|
157
|
-
-
|
|
158
|
-
`
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
-
|
|
166
|
-
`
|
|
167
|
-
`
|
|
168
|
-
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
-
|
|
179
|
-
|
|
180
|
-
###
|
|
181
|
-
|
|
182
|
-
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
-
|
|
166
|
+
Every method is `snake_case`. Use the **10 MCP-aligned facades** on
|
|
167
|
+
`LoxtepClient` (see table at the top). Nested APIs keep descriptive names
|
|
168
|
+
(`workflows`, `data_products`, `connectors`, …) under their facade.
|
|
169
|
+
|
|
170
|
+
### Top-level stream I/O (preferred)
|
|
171
|
+
|
|
172
|
+
- **`get_writer(name_or_id)`** — write path; resolves queue, bot, stream config
|
|
173
|
+
- **`get_reader(name_or_id)`** — async iterable read path
|
|
174
|
+
- **`LoxtepClient.fromWorkspace()`** — construct from `.loxtep/project.json` +
|
|
175
|
+
`~/.loxtep/credentials.json` (env overrides: `LOXTEP_API_URL`, `LOXTEP_TOKEN`, …)
|
|
176
|
+
|
|
177
|
+
### `client.build` (MCP: loxtep_build)
|
|
178
|
+
|
|
179
|
+
- **`.workflows`** — `list`, `get`, `create`, `get_graph`, `deploy`; low-level
|
|
180
|
+
`.get_writer(workflow_id, { bot_id, … })` escape hatch
|
|
181
|
+
- **`.triggers`** — `get`, `list`, `create`, `update`, `delete`, `test`
|
|
182
|
+
- **`.data_products`** — CRUD, `stream`, `replay`, `get_queue_info`,
|
|
183
|
+
`invalidate_cache`, … (for writes/reads by name, prefer top-level
|
|
184
|
+
`client.get_writer` / `get_reader`)
|
|
185
|
+
- **`.targets`** — delivery sink bindings (`list`, `get`, `create`, `update`, `delete`)
|
|
186
|
+
|
|
187
|
+
### `client.connect` (MCP: loxtep_connect)
|
|
188
|
+
|
|
189
|
+
- **`.connectors`** — org-level connector credentials
|
|
190
|
+
- **`.templates`** — starter templates (`list`, `get`, `apply_template` on projects)
|
|
191
|
+
|
|
192
|
+
### `client.workspace` (MCP: loxtep_workspace)
|
|
193
|
+
|
|
194
|
+
- **`.projects`** — `list`, `get`, `create`, `update`, `delete`, `apply_template`
|
|
195
|
+
- **`.instances`** — `list`, `get`, stream config helpers
|
|
196
|
+
|
|
197
|
+
### `client.define` (MCP: loxtep_define)
|
|
198
|
+
|
|
199
|
+
- **`.schemas`**, **`.quality`**, **`.standards`**, **`.data_contracts`**, **`.domains`**
|
|
200
|
+
|
|
201
|
+
### `client.query` (MCP: loxtep_query)
|
|
202
|
+
|
|
203
|
+
- **`.catalog`**, **`.discovery`**, **`.query()`**, **`.list_tables()`**, **`.search()`**
|
|
204
|
+
|
|
205
|
+
### `client.observe` (MCP: loxtep_observe)
|
|
206
|
+
|
|
207
|
+
- **`status()`**, **`stream_config()`**, **`open_reader()`**, **`open_writer()`**,
|
|
208
|
+
**`get_queue_metadata()`**, **`get_reader_checkpoint()`**
|
|
209
|
+
|
|
210
|
+
### Other facades
|
|
211
|
+
|
|
212
|
+
- **`client.session`** — `get_current_user`, `get_current_organization`, `logout`
|
|
213
|
+
- **`client.meaning`** — `.thesaurus.*`
|
|
214
|
+
- **`client.review`** — `.approvals.*`, `.improvements.*`
|
|
215
|
+
- **`client.context`** — `.procedures.*`, `.activity.*`, `.process_intelligence.*`
|
|
216
|
+
- **`client.metrics`** — `log`, `get_reporter` (stub until metrics wiring lands)
|
|
217
|
+
|
|
218
|
+
See [`docs/sdk-mcp-mapping.md`](./docs/sdk-mcp-mapping.md) for the full MCP ↔ SDK table.
|
|
196
219
|
|
|
197
220
|
## Data product writer and reader
|
|
198
221
|
|
|
199
|
-
`await client.
|
|
200
|
-
|
|
201
|
-
**FlowWriter**:
|
|
222
|
+
`await client.get_writer('name')` resolves the data product's queue, bot
|
|
223
|
+
identity, and stream bus config automatically, then returns a **FlowWriter**:
|
|
202
224
|
|
|
203
225
|
```ts
|
|
204
|
-
const writer = await client.
|
|
226
|
+
const writer = await client.get_writer('shopify_gql_customer');
|
|
205
227
|
writer.write({ customer_id: '123', name: 'Alice', email: 'alice@example.com' });
|
|
206
228
|
await writer.close();
|
|
207
229
|
```
|
|
208
230
|
|
|
209
|
-
`await client.
|
|
210
|
-
|
|
231
|
+
`await client.get_reader('name')` returns an async iterable over the data
|
|
232
|
+
product's queue:
|
|
211
233
|
|
|
212
234
|
```ts
|
|
213
|
-
const reader = await client.
|
|
235
|
+
const reader = await client.get_reader('shopify_gql_customer');
|
|
214
236
|
for await (const event of reader) {
|
|
215
237
|
console.log(event);
|
|
216
238
|
}
|
|
@@ -221,13 +243,13 @@ Options:
|
|
|
221
243
|
- **Writer**: `{ bot_id?, batch_size?, max_retries? }`
|
|
222
244
|
- **Reader**: `{ bot_id?, from?, batch_size? }`
|
|
223
245
|
|
|
224
|
-
Cache: call `client.data_products.invalidate_cache('name')` to force
|
|
246
|
+
Cache: call `client.build.data_products.invalidate_cache('name')` to force
|
|
225
247
|
re-resolution on the next call.
|
|
226
248
|
|
|
227
249
|
## Stream helpers
|
|
228
250
|
|
|
229
|
-
Use `mapStream` and `filterStream` with `data_products.stream()`,
|
|
230
|
-
`data_products.replay()`, or `
|
|
251
|
+
Use `mapStream` and `filterStream` with `client.build.data_products.stream()`,
|
|
252
|
+
`client.build.data_products.replay()`, or `client.observe.open_reader().read()`:
|
|
231
253
|
|
|
232
254
|
```ts
|
|
233
255
|
import { mapStream, filterStream } from '@loxtep/sdk';
|
|
@@ -257,10 +279,10 @@ const client = new LoxtepClient({
|
|
|
257
279
|
});
|
|
258
280
|
|
|
259
281
|
// List targets for a data product
|
|
260
|
-
const { items, pagination } = await client.targets.list('dp_abc123');
|
|
282
|
+
const { items, pagination } = await client.build.targets.list('dp_abc123');
|
|
261
283
|
|
|
262
284
|
// Create a webhook target
|
|
263
|
-
const webhook = await client.targets.create('dp_abc123', {
|
|
285
|
+
const webhook = await client.build.targets.create('dp_abc123', {
|
|
264
286
|
targetType: 'webhook',
|
|
265
287
|
name: 'Order notifications',
|
|
266
288
|
endpoint_url: 'https://example.com/webhooks/orders',
|
|
@@ -268,23 +290,24 @@ const webhook = await client.targets.create('dp_abc123', {
|
|
|
268
290
|
});
|
|
269
291
|
|
|
270
292
|
// Update a target
|
|
271
|
-
await client.targets.update('dp_abc123', webhook.consumption_id, {
|
|
293
|
+
await client.build.targets.update('dp_abc123', webhook.consumption_id, {
|
|
272
294
|
is_active: false,
|
|
273
295
|
});
|
|
274
296
|
|
|
275
297
|
// Delete a target
|
|
276
|
-
await client.targets.delete('dp_abc123', webhook.consumption_id);
|
|
298
|
+
await client.build.targets.delete('dp_abc123', webhook.consumption_id);
|
|
277
299
|
```
|
|
278
300
|
|
|
279
301
|
## Documentation
|
|
280
302
|
|
|
281
|
-
- **Getting started** – Zero to first event in under 5 minutes.
|
|
282
|
-
- **
|
|
283
|
-
- **
|
|
284
|
-
- **
|
|
285
|
-
- **MCP
|
|
303
|
+
- **[Getting started](./docs/getting-started.md)** – Zero to first event in under 5 minutes (programmatic; no init).
|
|
304
|
+
- **[Code-first CLI](./docs/code-first-cli.md)** – `loxtep init`, attach, generate, test, deploy.
|
|
305
|
+
- **[Quick reference](./docs/quick-reference.md)** – Single-page cheat sheet.
|
|
306
|
+
- **[Event replay cookbook](./docs/event-replay-cookbook.md)** – Replay events from a data product or queue.
|
|
307
|
+
- **[MCP + SDK pairing](./docs/sdk-pairing.md)** – One auth story, when MCP vs SDK.
|
|
308
|
+
- **[MCP → SDK mapping](./docs/sdk-mcp-mapping.md)** – Agent-oriented table.
|
|
286
309
|
- **Typed errors** – `import { … } from '@loxtep/sdk/errors'`.
|
|
287
|
-
- **API reference** – `
|
|
310
|
+
- **API reference** – `pnpm run docs` (Typedoc).
|
|
288
311
|
|
|
289
312
|
## CLI reference
|
|
290
313
|
|
|
@@ -348,141 +371,56 @@ loxtep metrics rate-limits
|
|
|
348
371
|
|
|
349
372
|
## Module exports
|
|
350
373
|
|
|
351
|
-
The SDK
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
### `config` module
|
|
356
|
-
|
|
357
|
-
```typescript
|
|
358
|
-
import { loadConfig, loadConfigSync, saveConfig } from '@loxtep/sdk/config';
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
| Export | Type | Description |
|
|
362
|
-
| --- | --- | --- |
|
|
363
|
-
| `loadConfig` | function | Load config from env vars and optional file (async). Precedence: env > file > defaults |
|
|
364
|
-
| `loadConfigSync` | function | Synchronous variant of `loadConfig` using `readFileSync` |
|
|
365
|
-
| `saveConfig` | function | Persist config (api_url, org/project/instance IDs) to file. No secrets written to disk |
|
|
366
|
-
| `parseStreamsPartial` | function | Extract a partial bus config from unknown JSON, keeping only valid stream resource keys |
|
|
367
|
-
| `getConfigDir` | function | Return the default config directory path (`~/.loxtep`) |
|
|
368
|
-
| `getDefaultConfigPath` | function | Return the default config file path (`~/.loxtep/config.json`) |
|
|
369
|
-
| `buildAuthServiceUrl` | function | Build the full URL for auth endpoints (`/auth/login`, `/auth/refresh`) with path prefix |
|
|
370
|
-
| `extendClientBaseUrl` | function | Extend `api_url` with a microservice path segment, avoiding duplication |
|
|
371
|
-
| `buildPlatformRequestUrl` | function | Build a full request URL for the shared control-plane host, handling microservice routing |
|
|
372
|
-
| `resolveAutoConfig` | function | Resolve configuration with full precedence: env > explicit > workspace files |
|
|
373
|
-
|
|
374
|
-
### `auth` module
|
|
375
|
-
|
|
376
|
-
```typescript
|
|
377
|
-
import { login, refresh, browserLogin, TokenManager } from '@loxtep/sdk/auth';
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
| Export | Type | Description |
|
|
381
|
-
| --- | --- | --- |
|
|
382
|
-
| `decodeJwtPayload` | function | Decode JWT payload to read `exp` (expiry) without verification. Client-side only |
|
|
383
|
-
| `login` | function | Authenticate with email/password via `POST /auth/login`. Returns access + refresh tokens |
|
|
384
|
-
| `refresh` | function | Refresh an access token via `POST /auth/refresh` |
|
|
385
|
-
| `browserLogin` | function | Run OAuth 2.1 browser-based login flow with a localhost callback server |
|
|
386
|
-
| `TokenManager` | class | In-memory token manager with auto-refresh support. No tokens persisted to disk |
|
|
387
|
-
| `LoginMfaRequiredError` | class | Error thrown when login returns 403 and the user must supply a TOTP code |
|
|
388
|
-
|
|
389
|
-
### `codegen` module
|
|
390
|
-
|
|
391
|
-
```typescript
|
|
392
|
-
import { loadWorkspaceContext, deriveKey, normalizeContext, emitArtifact, writeArtifact, computeCounts } from '@loxtep/sdk/codegen';
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
| Export | Type | Description |
|
|
396
|
-
| --- | --- | --- |
|
|
397
|
-
| `loadWorkspaceContext` | function | Fetch all workspace resources from the control plane and assemble a `WorkspaceContext` |
|
|
398
|
-
| `deriveKey` | function | Derive a deterministic, valid TypeScript identifier key from a resource name |
|
|
399
|
-
| `normalizeContext` | function | Transform raw `WorkspaceContext` into canonical `NormalizedContext` with stable keys and id-sorted ordering |
|
|
400
|
-
| `emitArtifact` | function | Render a `NormalizedContext` into a complete TypeScript source string with `as const` exports |
|
|
401
|
-
| `writeArtifact` | function | Atomic file write of the generated artifact; returns per-resource-type counts |
|
|
402
|
-
| `computeCounts` | function | Compute per-resource-type counts from a `NormalizedContext` |
|
|
403
|
-
|
|
404
|
-
### `skills` module
|
|
405
|
-
|
|
406
|
-
```typescript
|
|
407
|
-
import { checkScope, parseSkillYaml, loadSkillsFromDirectory } from '@loxtep/sdk/skills';
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
| Export | Type | Description |
|
|
411
|
-
| --- | --- | --- |
|
|
412
|
-
| `checkScope` | function | Fail-closed scope decision: check whether an operation on a resource is permitted by a skill |
|
|
413
|
-
| `checkScopeByName` | function | Resolve a skill by name from a map and check scope in one step |
|
|
414
|
-
| `parseSkillYaml` | function | Parse a YAML string into a validated `SkillDefinition` |
|
|
415
|
-
| `loadSkillFromFile` | function | Load a single skill definition from a `.yaml` file path |
|
|
416
|
-
| `loadSkillsFromDirectory` | function | Load all skill definitions from a `.loxtep/skills/` directory |
|
|
417
|
-
| `validateSkillReferences` | function | Validate all skill resource references against the loaded `WorkspaceContext` |
|
|
418
|
-
| `formatSkillValidationErrors` | function | Format skill validation errors into human-readable messages |
|
|
419
|
-
| `SkillDefinitionSchema` | object | Zod schema for validating skill definition YAML structure |
|
|
420
|
-
|
|
421
|
-
### `authoring` module
|
|
374
|
+
The SDK re-exports configuration, authentication, codegen, skill scoping,
|
|
375
|
+
workflow authoring, HTTP, checkpoint, and streaming helpers from the main
|
|
376
|
+
entry point. **`@loxtep/sdk/errors`** is the only additional published
|
|
377
|
+
subpath (see `package.json` `exports`).
|
|
422
378
|
|
|
423
379
|
```typescript
|
|
424
|
-
import {
|
|
380
|
+
import {
|
|
381
|
+
LoxtepClient,
|
|
382
|
+
loadConfig,
|
|
383
|
+
login,
|
|
384
|
+
defineDataWorkflow,
|
|
385
|
+
on,
|
|
386
|
+
checkScope,
|
|
387
|
+
signRequest,
|
|
388
|
+
createMemoryCheckpointStore,
|
|
389
|
+
DataProductResolver,
|
|
390
|
+
} from '@loxtep/sdk';
|
|
391
|
+
|
|
392
|
+
import { ValidationError, parseHttpError } from '@loxtep/sdk/errors';
|
|
425
393
|
```
|
|
426
394
|
|
|
427
|
-
|
|
428
|
-
| --- | --- | --- |
|
|
429
|
-
| `defineDataWorkflow` | function | Validate and return a `DataWorkflowModule` spec. Throws `ValidationError` on invalid input |
|
|
430
|
-
| `on` | object | Trigger builders: `queueEvent`, `connectorEvent`, `schedule`, `webhook` |
|
|
431
|
-
| `createToolbox` | function | Create a deterministic typed platform-call toolbox (no model in the loop) |
|
|
432
|
-
| `agent` | function | Agentic operation entry point with scope enforcement and action trace |
|
|
433
|
-
| `validateAgentOptions` | function | Validate agent options (prompt length, skills references) against available skills |
|
|
434
|
-
| `computeReachableScope` | function | Compute the union of all resource scopes from supplied skill definitions |
|
|
435
|
-
| `enforceAgentScope` | function | Check whether a resource access is within the merged scope of the agent's skills |
|
|
436
|
-
| `createScopeGuardedToolbox` | function | Create a scope-guarded proxy that enforces scope and records traces before every call |
|
|
437
|
-
| `compileModule` | function | Pure compiler: lower a `DataWorkflowModule` into `GraphPatchOp[]` for deployment |
|
|
438
|
-
| `computeRemovalSet` | function | Compute workflows present on instance but absent from project modules (for cleanup) |
|
|
439
|
-
| `ActionTrace` | class | Mutable action trace recorder with monotonically increasing sequence numbers |
|
|
440
|
-
| `AgentScopeError` | class | Error thrown when an agentic operation is blocked due to a scope violation |
|
|
441
|
-
| `ToolboxOperationError` | class | Error thrown when a toolbox operation fails (network, validation, or platform error) |
|
|
442
|
-
|
|
443
|
-
### `http` module
|
|
395
|
+
### Selected exports (import from `@loxtep/sdk` unless noted)
|
|
444
396
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
397
|
+
**Config:** `loadConfig`, `loadConfigSync`, `saveConfig`, `parseStreamsPartial`,
|
|
398
|
+
`getConfigDir`, `getDefaultConfigPath`, `buildAuthServiceUrl`,
|
|
399
|
+
`buildPlatformRequestUrl`, `resolveAutoConfig`
|
|
448
400
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
| `signRequest` | function | Sign an HTTP request with AWS SigV4 for API Gateway (`execute-api`). Returns headers including `Authorization` and `x-amz-*` |
|
|
452
|
-
| `LoxtepHttpClient` | class | HTTP client that signs requests with AWS SigV4 and attaches JWT. Provides `get`, `post`, `put`, `delete` helpers with retry on 5xx/network errors and typed Loxtep errors on 4xx |
|
|
401
|
+
**Auth:** `decodeJwtPayload`, `login`, `refresh`, `browserLogin`, `TokenManager`,
|
|
402
|
+
`LoginMfaRequiredError`
|
|
453
403
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
```typescript
|
|
457
|
-
import { createMemoryCheckpointStore } from '@loxtep/sdk/checkpoint';
|
|
458
|
-
```
|
|
404
|
+
**Codegen:** `loadWorkspaceContext`, `deriveKey`, `normalizeContext`, `emitArtifact`,
|
|
405
|
+
`writeArtifact`, `computeCounts`
|
|
459
406
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
407
|
+
**Skills:** `checkScope`, `checkScopeByName`, `parseSkillYaml`, `loadSkillFromFile`,
|
|
408
|
+
`loadSkillsFromDirectory`, `validateSkillReferences`, `formatSkillValidationErrors`,
|
|
409
|
+
`SkillDefinitionSchema`
|
|
463
410
|
|
|
464
|
-
|
|
411
|
+
**Authoring:** `defineDataWorkflow`, `on`, `createToolbox`, `agent`,
|
|
412
|
+
`validateAgentOptions`, `compileModule`, `ActionTrace`, `AgentScopeError`,
|
|
413
|
+
`ToolboxOperationError`
|
|
465
414
|
|
|
466
|
-
|
|
467
|
-
import { AuthorizationError, ConflictError, ValidationError, DefinitionValidationError, SchemaValidationError, CheckpointError, parseHttpError } from '@loxtep/sdk/errors';
|
|
468
|
-
```
|
|
415
|
+
**HTTP:** `signRequest`, `LoxtepHttpClient`
|
|
469
416
|
|
|
470
|
-
|
|
471
|
-
| --- | --- | --- |
|
|
472
|
-
| `AuthorizationError` | class | 403 — Insufficient permissions |
|
|
473
|
-
| `ConflictError` | class | 409 — Resource already exists or version conflict |
|
|
474
|
-
| `ValidationError` | class | 400 — Invalid input with optional `field_errors` array |
|
|
475
|
-
| `DefinitionValidationError` | class | 400 — Payload doesn't match data product definition (schema validation failures) |
|
|
476
|
-
| `SchemaValidationError` | class | Alias for `DefinitionValidationError` (backend terminology) |
|
|
477
|
-
| `CheckpointError` | class | 500 — Failed to save or load a stream checkpoint |
|
|
478
|
-
| `parseHttpError` | function | Map an HTTP status code and response body to the appropriate typed Loxtep error class |
|
|
417
|
+
**Checkpoint:** `createMemoryCheckpointStore`
|
|
479
418
|
|
|
480
|
-
|
|
419
|
+
**Streaming:** `mapStream`, `filterStream`
|
|
481
420
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
421
|
+
**Errors** (from `@loxtep/sdk/errors`): `AuthorizationError`, `ConflictError`,
|
|
422
|
+
`ValidationError`, `DefinitionValidationError`, `SchemaValidationError`,
|
|
423
|
+
`CheckpointError`, `parseHttpError`
|
|
485
424
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
| `DataProductResolver` | class | Resolves a data product name or UUID into full runtime configuration (queue name, bot_id, stream bus resources). Caches results in memory. Used internally by `client.data_products.get_writer`/`get_reader` |
|
|
425
|
+
**Resolver:** `DataProductResolver`, `AmbiguityError` — used internally by
|
|
426
|
+
`get_writer` / `get_reader`; import when building custom resolution logic.
|
|
@@ -316,10 +316,10 @@ export async function runConfigExportFromConnector(connectorId, options = {}) {
|
|
|
316
316
|
export async function runInit() {
|
|
317
317
|
console.log(`Loxtep CLI — setup checklist:
|
|
318
318
|
|
|
319
|
-
Config is stored at ~/.loxtep/config.json. Auth tokens
|
|
319
|
+
Config is stored at ~/.loxtep/config.json. Auth tokens default to ./.loxtep/credentials.json (use loxtep login --global for ~/.loxtep/credentials.json).
|
|
320
320
|
|
|
321
321
|
1. loxtep config set api_url <https://your-api-host> (host only; no trailing /app)
|
|
322
|
-
2. loxtep login (stores credentials at
|
|
322
|
+
2. loxtep login (stores credentials at ./.loxtep/credentials.json by default; or set LOXTEP_AUTH_TOKEN env var)
|
|
323
323
|
3. (Legacy only) loxtep config set api_path_prefix <one ms> if you must pin a single microservice base URL (LOXTEP_API_PATH_PREFIX); default is per-path platform routing
|
|
324
324
|
4. Optional: loxtep config set organization_id <uuid> | project_id <uuid> | instance_id <uuid> | region <aws-region>
|
|
325
325
|
(saved to ~/.loxtep/config.json; used as defaults for LoxtepClient constructor)
|
|
@@ -327,7 +327,7 @@ export async function runInit() {
|
|
|
327
327
|
6. From a connector: loxtep config export --from-connector <uuid>
|
|
328
328
|
From a data product: loxtep config export --from-data-product <uuid>
|
|
329
329
|
|
|
330
|
-
Auth precedence: LOXTEP_AUTH_TOKEN env var →
|
|
330
|
+
Auth precedence: LOXTEP_AUTH_TOKEN env var → ./.loxtep/credentials.json (walk up from cwd) → ~/.loxtep/credentials.json.
|
|
331
331
|
Docs: package docs/sdk-pairing.md and docs/sdk-control-vs-data-plane.md (npm pack path: node_modules/@loxtep/sdk/docs/...).
|
|
332
332
|
`);
|
|
333
333
|
}
|
|
@@ -20,9 +20,8 @@ export interface LoginOptions {
|
|
|
20
20
|
/** For tests: credentials file path to write. Takes precedence over --local/--global. */
|
|
21
21
|
credentialsPath?: string;
|
|
22
22
|
/**
|
|
23
|
-
* Force credentials scope: `local` writes to
|
|
24
|
-
* (
|
|
25
|
-
* `~/.loxtep/credentials.json`. Default: local when run inside a project, else global.
|
|
23
|
+
* Force credentials scope: `local` writes to `./.loxtep/credentials.json` under
|
|
24
|
+
* `cwd` (default); `global` writes to `~/.loxtep/credentials.json`.
|
|
26
25
|
*/
|
|
27
26
|
scope?: CredentialsScope;
|
|
28
27
|
/** Working directory used to resolve the project for local scoping (default: `process.cwd()`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/login.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yFAAyF;IACzF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/login.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yFAAyF;IACzF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,kGAAkG;IAClG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uFAAuF;IACvF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAuBD;;GAEG;AACH,wBAAsB,QAAQ,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqIxE"}
|