@loxtep/sdk 0.7.0 → 0.7.6

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 CHANGED
@@ -6,6 +6,69 @@ 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.6] - 2026-07-23
10
+
11
+ ### Added
12
+
13
+ - **`loxtep --version`** (also `-V` and `loxtep version`) prints the installed
14
+ `@loxtep/sdk` semver, e.g. `@loxtep/sdk 0.7.6`.
15
+
16
+ ## [0.7.5] - 2026-07-23
17
+
18
+ ### Changed
19
+
20
+ - **CLI help** (`loxtep --help`) reorganized under **MCP-aligned SDK facades**
21
+ (Session, Workspace, Build, Define, Review, Query, Observe, Context) instead
22
+ of a flat command list. Help text lives in `src/cli/help.ts`.
23
+
24
+ ## [0.7.4] - 2026-07-23
25
+
26
+ ### Changed
27
+
28
+ - **Documentation** defaults to **pnpm** (`pnpm add`, `pnpm exec loxtep`) instead of
29
+ npm/npx across README, getting started, quick reference, and SDK pairing.
30
+ - **New guide:** [`docs/code-first-cli.md`](./docs/code-first-cli.md) documents the
31
+ `loxtep init → attach → generate → test → deploy` workflow, when init is
32
+ required vs login-only programmatic use, and cross-links from getting started
33
+ and quick reference.
34
+ - CLI auth hints now reference `pnpm exec loxtep login` for consistency with docs.
35
+
36
+ ## [0.7.3] - 2026-07-23
37
+
38
+ ### Fixed
39
+
40
+ - **`loxtep login`** now saves credentials to **`./.loxtep/credentials.json`** in
41
+ the current working directory by default (not `~/.loxtep/credentials.json`).
42
+ Use `--global` for the home-directory path. Read resolution walks upward for
43
+ a local `credentials.json` before falling back to global.
44
+
45
+ ## [0.7.2] - 2026-07-23
46
+
47
+ ### Changed
48
+
49
+ - **Documentation** aligned with **v0.7.0+ MCP facade API**: README, getting
50
+ started, quick reference, event replay cookbook, and AGENTS guidance now use
51
+ `client.get_writer` / `client.get_reader` and facade paths
52
+ (`client.build.*`, `client.observe.*`, etc.) instead of removed flat
53
+ namespaces (`client.data_products`, `client.workflows`, …).
54
+ - **Module export docs** corrected: import from `@loxtep/sdk` (and
55
+ `@loxtep/sdk/errors` only for the errors subpath).
56
+
57
+ ## [0.7.1] - 2026-07-23
58
+
59
+ ### Security
60
+
61
+ - **js-yaml** upgraded to **4.3.0+** ([GHSA-52cp-r559-cp3m](https://github.com/advisories/GHSA-52cp-r559-cp3m) /
62
+ CVE-2026-59869): fixes quadratic CPU use from chained YAML merge-key (`<<:`) documents.
63
+
64
+ ### Changed
65
+
66
+ - **leo-sdk** bumped **7.1.12 → 7.1.21** (latest npm; lodash already at 4.18.x upstream).
67
+ - **Dependency overrides** (transitive hardening for npm consumers):
68
+ - `uuid` → **^11.1.0** (leo-sdk still declares 8.x)
69
+ - `fast-csv` → **^5.0.7** (drops deprecated `lodash.isequal`; leo-sdk still declares 4.x)
70
+ - `lodash` → **^4.18.0** (unchanged)
71
+
9
72
  ## [0.7.0] - 2026-07-23
10
73
 
11
74
  ### Breaking changes — MCP-aligned client facades
package/README.md CHANGED
@@ -1,15 +1,31 @@
1
1
  # Loxtep Node.js SDK
2
2
 
3
- Client for the Loxtep API, organized around one journey: **ingest define →
4
- deliver**. Install the SDK and get to your first event in five steps (below),
5
- then reach for the namespace that matches the stage you're in:
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
- - **Ingest** `triggers`, `connectors`, `workflows`, `data_products.get_writer`
8
- - **Define** `data_products`, `schemas`, `quality`, `catalog`, `discovery`,
9
- `domains`, `standards`, `data_contracts`, `thesaurus`, `procedures`
10
- - **Deliver** `data_products` (reader/stream/replay/query), `targets`
11
- - **Advanced / platform** `projects`, `templates`, `instances`, `observe`,
12
- `queues`, `metrics`
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` → `data_products.get_writer` / `get_reader` |
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
- npm install @loxtep/sdk
57
+ pnpm add @loxtep/sdk
42
58
  ```
43
59
 
44
60
  2. **Log in**
45
61
 
46
62
  ```bash
47
- npx loxtep login
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 `~/.loxtep/credentials.json` and refresh automatically.
67
+ Tokens are saved to `./.loxtep/credentials.json` (use `--global` for home dir).
52
68
 
53
- > **CI/headless:** Use `npx loxtep login --email you@co.com --password ...`
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.data_products.get_writer('shopify_gql_customer');
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.data_products.get_reader('shopify_gql_customer');
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. Note: `data_products.get_writer` and `get_reader` resolve
91
- stream config automatically — this is only needed for manual bus access.
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
- npm install @loxtep/sdk
118
+ pnpm add @loxtep/sdk
102
119
 
103
120
  # 2. Authenticate
104
- npx loxtep login
121
+ pnpm exec loxtep login
105
122
 
106
123
  # 3. Scaffold a project from a template
107
- npx loxtep init --template shopify-orders
124
+ pnpm exec loxtep init --template shopify-orders
108
125
 
109
126
  # 4. Bind to a runtime instance
110
- npx loxtep attach --instance prod
127
+ pnpm exec loxtep attach --instance prod
111
128
 
112
129
  # 5. Generate typed workspace constants
113
- npx loxtep generate
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
- npx loxtep test orders-enricher --event ./events/order-created.json
135
+ pnpm exec loxtep test orders-enricher --event ./events/order-created.json
119
136
 
120
137
  # 8. Deploy to the workflow engine
121
- npx loxtep deploy
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/authoring'
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`. Namespaces are grouped by the stage of the journey
150
- they serve, and labelled by *kind*: **Resource** (full CRUD), **Reference**
151
- (read-only), **Runtime** (live stream I/O).
152
-
153
- ### Ingest connect sources, write events
154
-
155
- - **triggers** *(Resource)* `get`, `list`, `create`, `update`, `delete`,
156
- `test` — ingest source bindings (external systems that feed a workflow)
157
- - **connectors** *(Resource)* `list`, `get`, `create`, `update`, `delete`,
158
- `test`, `get_oauth_url` org-level catalog of connectable system types
159
- - **workflows** *(Resource)* – `list`, `get`, `create`, `get_graph`, `deploy` —
160
- the ingestion transformation → export DAG
161
- - **data_products.get_writer(name)** *(Runtime)* – the write path for events
162
-
163
- ### Define — semantics, schema, quality, governance
164
-
165
- - **data_products** *(Resource + Runtime)* – `get`, `get_lexicon`, `list`,
166
- `search`, `query`, `list_tables`, `get_queue_info`, `get_reader_checkpoint`,
167
- `create`, `readiness`, `promote`, `get_usage_map`, `invalidate_cache`
168
- - **schemas** *(Reference)* `get`, `list`, `tag_pii_fields`
169
- - **quality** *(Resource)* – `list`, `get`, `create`
170
- - **catalog** *(Reference)* – `search`
171
- - **discovery** *(Reference)* – `search`, `get_evidence`, `get_lineage_impact`,
172
- `get_governance_flags`, `run`
173
- - **domains** *(Reference)* `list`, `get`
174
- - **standards** *(Reference)* – `list`, `get`
175
- - **data_contracts** *(Resource)* – `list`, `get`, `create`, `update`, `delete`
176
- - **thesaurus** *(Reference)* – `list_terms`, `resolve_canonical_key`,
177
- `append_synonym`
178
- - **procedures** *(Reference)* `list`
179
-
180
- ### Deliver consume and route data
181
-
182
- - **data_products** *(Runtime)* `get_reader`, `stream`, `replay`
183
- - **targets** *(Resource)* – `list`, `get`, `create`, `update`, `delete` —
184
- delivery sink bindings (webhook, API, export, DB sync, BI, event stream)
185
-
186
- ### Advanced / platform
187
-
188
- - **projects** *(Resource)* – `list`, `get`, `create`, `update`, `delete`,
189
- `apply_template`, `repository`
190
- - **templates** *(Reference)* `list`, `get`
191
- - **instances** *(Reference)* – `list`, `get`, `get_stream_config`
192
- - **observe** – `status`, `stream_config`
193
- - **queues** – `get_queue_metadata`, `get_reader_checkpoint`, `open_reader`,
194
- `open_writer`
195
- - **metrics** `log`, `get_reporter`
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.data_products.get_writer('name')` resolves the data product's
200
- queue, bot identity, and stream bus config automatically, then returns a
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.data_products.get_writer('shopify_gql_customer');
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.data_products.get_reader('name')` returns an async iterable over
210
- the data product's queue:
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.data_products.get_reader('shopify_gql_customer');
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 `queues.open_reader().read()`:
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
- - **Quick reference** – Single-page cheat sheet.
283
- - **Event replay cookbook** – Replay events from a data product or queue.
284
- - **MCP + SDK pairing** – One auth story, when MCP vs SDK.
285
- - **MCP SDK mapping** – Agent-oriented table.
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** – `npm run docs` (Typedoc).
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 also ships standalone modules for configuration, authentication,
352
- code generation, skill scoping, and workflow authoring. Import them directly
353
- from the relevant subpath.
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 { defineDataWorkflow, on, createToolbox, agent } from '@loxtep/sdk/authoring';
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
- | Export | Type | Description |
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
- ```typescript
446
- import { signRequest, LoxtepHttpClient } from '@loxtep/sdk/http';
447
- ```
397
+ **Config:** `loadConfig`, `loadConfigSync`, `saveConfig`, `parseStreamsPartial`,
398
+ `getConfigDir`, `getDefaultConfigPath`, `buildAuthServiceUrl`,
399
+ `buildPlatformRequestUrl`, `resolveAutoConfig`
448
400
 
449
- | Export | Type | Description |
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
- ### `checkpoint` module
455
-
456
- ```typescript
457
- import { createMemoryCheckpointStore } from '@loxtep/sdk/checkpoint';
458
- ```
404
+ **Codegen:** `loadWorkspaceContext`, `deriveKey`, `normalizeContext`, `emitArtifact`,
405
+ `writeArtifact`, `computeCounts`
459
406
 
460
- | Export | Type | Description |
461
- | --- | --- | --- |
462
- | `createMemoryCheckpointStore` | function | Create an in-memory checkpoint store for stream/replay resume. Suitable for tests or single-process use |
407
+ **Skills:** `checkScope`, `checkScopeByName`, `parseSkillYaml`, `loadSkillFromFile`,
408
+ `loadSkillsFromDirectory`, `validateSkillReferences`, `formatSkillValidationErrors`,
409
+ `SkillDefinitionSchema`
463
410
 
464
- ### Error classes
411
+ **Authoring:** `defineDataWorkflow`, `on`, `createToolbox`, `agent`,
412
+ `validateAgentOptions`, `compileModule`, `ActionTrace`, `AgentScopeError`,
413
+ `ToolboxOperationError`
465
414
 
466
- ```typescript
467
- import { AuthorizationError, ConflictError, ValidationError, DefinitionValidationError, SchemaValidationError, CheckpointError, parseHttpError } from '@loxtep/sdk/errors';
468
- ```
415
+ **HTTP:** `signRequest`, `LoxtepHttpClient`
469
416
 
470
- | Export | Type | Description |
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
- ### `DataProductResolver` class
419
+ **Streaming:** `mapStream`, `filterStream`
481
420
 
482
- ```typescript
483
- import { DataProductResolver } from '@loxtep/sdk/client';
484
- ```
421
+ **Errors** (from `@loxtep/sdk/errors`): `AuthorizationError`, `ConflictError`,
422
+ `ValidationError`, `DefinitionValidationError`, `SchemaValidationError`,
423
+ `CheckpointError`, `parseHttpError`
485
424
 
486
- | Export | Type | Description |
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 are stored at ~/.loxtep/credentials.json.
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 ~/.loxtep/credentials.json; or set LOXTEP_AUTH_TOKEN env var)
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 → ~/.loxtep/credentials.json (from loxtep login).
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 `<project>/.loxtep/credentials.json`
24
- * (requires a project found via `.loxtep/project.json`); `global` writes to
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;;;;OAIG;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,CAmIxE"}
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"}