@north-light/sdk 0.3.899 → 0.3.900

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.
@@ -271,6 +271,30 @@ export declare class OAuth2Client {
271
271
  * token request's: `invalid_client` is a 401 `unauthorized` naming the key, a directory 5xx or a 429 has `retryable` true.
272
272
  */
273
273
  directoryToken(rejected?: string): Promise<string>;
274
+ /**
275
+ * One request to the directory's `/v1` routes as the app itself (bearer `directoryToken()`): `/v1/account/*` (setup state,
276
+ * research result, payment and billing state), `/v1/provider`, `/v1/receipts`. A 401 re-mints the token once. Any directory
277
+ * answer resolves as `{status, body}` (`body` is the parsed JSON, or `undefined` when the answer is not JSON), so the caller
278
+ * decides what a 404 or 409 means; a transport failure, a directory token failure or the deadline (`timeoutMs`) throws.
279
+ * `query` is appended to `path`.
280
+ */
281
+ directoryRequest(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, options?: {
282
+ query?: Record<string, string>;
283
+ body?: unknown;
284
+ }): Promise<{
285
+ status: number;
286
+ body: unknown;
287
+ }>;
288
+ /** The directory's public marketplace listing (`GET /v1/marketplace/apps`, no token). Resolves as `{status, body}` like `directoryRequest`. */
289
+ marketplaceApps(): Promise<{
290
+ status: number;
291
+ body: unknown;
292
+ }>;
293
+ /** The app's own provider row (`GET /v1/provider`). Resolves as `{status, body}` like `directoryRequest`. */
294
+ provider(): Promise<{
295
+ status: number;
296
+ body: unknown;
297
+ }>;
274
298
  /**
275
299
  * Whether `userId` (`user:<id>`) is on the team that holds this app, and their role on it (`GET /v1/apps/self/members/:user_id`
276
300
  * as the app itself, bearer `directoryToken()`). For an app's own staff pages: the directory answers from its current
@@ -497,6 +497,46 @@ export class OAuth2Client {
497
497
  directoryToken(rejected) {
498
498
  return this.directoryApiTokens.get('directory', rejected).then((token) => token.accessToken);
499
499
  }
500
+ /**
501
+ * One request to the directory's `/v1` routes as the app itself (bearer `directoryToken()`): `/v1/account/*` (setup state,
502
+ * research result, payment and billing state), `/v1/provider`, `/v1/receipts`. A 401 re-mints the token once. Any directory
503
+ * answer resolves as `{status, body}` (`body` is the parsed JSON, or `undefined` when the answer is not JSON), so the caller
504
+ * decides what a 404 or 409 means; a transport failure, a directory token failure or the deadline (`timeoutMs`) throws.
505
+ * `query` is appended to `path`.
506
+ */
507
+ async directoryRequest(method, path, options = {}) {
508
+ if (!path.startsWith('/v1/'))
509
+ throw new CrouterError(`directoryRequest needs a /v1 path, got ${JSON.stringify(path)}`);
510
+ const url = new URL(`${this.issuer.replace(/\/$/, '')}${path}`);
511
+ for (const [key, value] of Object.entries(options.query ?? {}))
512
+ url.searchParams.set(key, value);
513
+ const deadlineAt = Date.now() + this.timeoutMs;
514
+ const ask = async (token) => this.bounded(url.toString(), {
515
+ method,
516
+ headers: { accept: 'application/json', authorization: `Bearer ${token}`, ...(options.body === undefined ? {} : { 'content-type': 'application/json' }) },
517
+ ...(options.body === undefined ? {} : { body: JSON.stringify(options.body) }),
518
+ }, deadlineAt, async (response) => ({ status: response.status, body: await response.json().catch(() => undefined) }));
519
+ const mint = async (rejected) => {
520
+ try {
521
+ return await withinDeadline(this.directoryToken(rejected), deadlineAt);
522
+ }
523
+ catch (error) {
524
+ throw error instanceof APIError ? mapError(error) : error;
525
+ }
526
+ };
527
+ const token = await mint();
528
+ const first = await ask(token);
529
+ return first.status === 401 ? ask(await mint(token)) : first;
530
+ }
531
+ /** The directory's public marketplace listing (`GET /v1/marketplace/apps`, no token). Resolves as `{status, body}` like `directoryRequest`. */
532
+ async marketplaceApps() {
533
+ const deadlineAt = Date.now() + this.timeoutMs;
534
+ return this.bounded(`${this.issuer.replace(/\/$/, '')}/v1/marketplace/apps`, { headers: { accept: 'application/json' } }, deadlineAt, async (response) => ({ status: response.status, body: await response.json().catch(() => undefined) }));
535
+ }
536
+ /** The app's own provider row (`GET /v1/provider`). Resolves as `{status, body}` like `directoryRequest`. */
537
+ provider() {
538
+ return this.directoryRequest('GET', '/v1/provider');
539
+ }
500
540
  /**
501
541
  * Whether `userId` (`user:<id>`) is on the team that holds this app, and their role on it (`GET /v1/apps/self/members/:user_id`
502
542
  * as the app itself, bearer `directoryToken()`). For an app's own staff pages: the directory answers from its current
@@ -202,6 +202,8 @@ export declare class Runs {
202
202
  status?: RunStatus;
203
203
  after?: string;
204
204
  limit?: number;
205
+ app?: string;
206
+ cron_id?: string;
205
207
  }, options?: RequestOptions): Promise<{
206
208
  runs: RunObject[];
207
209
  next: string | null;
@@ -211,6 +213,8 @@ export declare class Runs {
211
213
  listAll(filters?: {
212
214
  status?: RunStatus;
213
215
  limit?: number;
216
+ app?: string;
217
+ cron_id?: string;
214
218
  }, options?: RequestOptions): AsyncGenerator<RunObject, void, undefined>;
215
219
  /** Send a message to a run. `start_turn: true` (the default) answers it in its
216
220
  * turn. A running run reads it at its next step unless `steer: false` opts out
@@ -2,7 +2,7 @@
2
2
  name: northlight
3
3
  description: "Use when building, debugging or shipping an app that signs people in with Northlight, starts runs on their Northlight runtime, or calls Northlight providers (sms, search, integrations, context, device) with @north-light/sdk."
4
4
  metadata:
5
- sdk-version: "0.3.899"
5
+ sdk-version: "0.3.900"
6
6
  ---
7
7
 
8
8
  # Building a Northlight app
@@ -27,7 +27,7 @@ Never text a person first: Comms refuses a send to anyone who has not texted you
27
27
 
28
28
  ## First: check this skill matches the SDK
29
29
 
30
- This skill is for SDK version `0.3.899`. If the project has `node_modules/@north-light/sdk/package.json`, compare its `version` with that number. If they differ, run `npx @north-light/sdk skill` in the project, then read the rewritten `.agents/skills/northlight/SKILL.md` (or `.claude/skills/northlight/SKILL.md`) instead of this copy. It needs no account. A project that has no SDK yet starts with `npx @north-light/sdk@latest init <dir>`.
30
+ This skill is for SDK version `0.3.900`. If the project has `node_modules/@north-light/sdk/package.json`, compare its `version` with that number. If they differ, run `npx @north-light/sdk skill` in the project, then read the rewritten `.agents/skills/northlight/SKILL.md` (or `.claude/skills/northlight/SKILL.md`) instead of this copy. It needs no account. A project that has no SDK yet starts with `npx @north-light/sdk@latest init <dir>`.
31
31
 
32
32
  ## Where things run
33
33
 
package/dist/version.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** This SDK's release version. Informational only: compatibility is the contract level, not this number. */
2
- export declare const SDK_VERSION = "0.3.899";
2
+ export declare const SDK_VERSION = "0.3.900";
3
3
  /** The release sent in `Crouter-Minimum-Runtime-Version` on every request. It is frozen, so a runtime from before the
4
4
  * contract level existed (which only knows this header) refuses this SDK, while every later runtime accepts it. */
5
5
  export declare const LEGACY_FLOOR = "0.3.423";
package/dist/version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // SDK_VERSION is written by scripts/release-version.mjs on every release; do not edit by hand.
2
2
  /** This SDK's release version. Informational only: compatibility is the contract level, not this number. */
3
- export const SDK_VERSION = '0.3.899';
3
+ export const SDK_VERSION = '0.3.900';
4
4
  // LEGACY_FLOOR is written once by `scripts/contract.mjs release`, at the first release that carries the contract level
5
5
  // (the `0.0.0` placeholder is replaced there and never again); do not edit by hand.
6
6
  /** The release sent in `Crouter-Minimum-Runtime-Version` on every request. It is frozen, so a runtime from before the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/sdk",
3
- "version": "0.3.899",
3
+ "version": "0.3.900",
4
4
  "crouterContract": "1.119",
5
5
  "description": "Typed Node and browser client for running crouter agents through the crtrd /v1 API.",
6
6
  "type": "module",
@@ -50,9 +50,9 @@
50
50
  "prepublishOnly": "node -e \"if (process.env.npm_config_tag !== 'next') { console.error('@north-light/sdk publishes only with --tag next; scripts/promote-sdk.mjs is the only mover of latest.'); process.exit(1); }\""
51
51
  },
52
52
  "dependencies": {
53
- "@north-light/api": "0.3.899",
54
- "@north-light/identity": "0.3.899",
55
- "@north-light/plugin": "0.3.899",
53
+ "@north-light/api": "0.3.900",
54
+ "@north-light/identity": "0.3.900",
55
+ "@north-light/plugin": "0.3.900",
56
56
  "jose": "^6.2.1"
57
57
  },
58
58
  "peerDependencies": {