@north-light/sdk 0.3.784 → 0.3.786

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/dist/client.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type CheckDTO } from '@north-light/api';
2
2
  import { Canvas } from './resources/canvas.js';
3
+ import { Crons } from './resources/crons.js';
3
4
  import { Docs } from './resources/docs.js';
4
5
  import { Charges } from './resources/charges.js';
5
6
  import { Environments } from './resources/environments.js';
@@ -92,6 +93,8 @@ export declare class Crouter {
92
93
  readonly memory: Memory;
93
94
  /** Write, read and edit documents the calling app owns (`docs.write`, `docs.edit`, `docs.get`): for example one app-owned `preference` with a `boot` rule that carries the app's agent instructions. */
94
95
  readonly docs: Docs;
96
+ /** Schedule, list, pause, resume, run and delete the cron jobs the calling app's grant owns (`crtr:schedule` to change one). */
97
+ readonly crons: Crons;
95
98
  /** Register the app's permission schema (app listener only). */
96
99
  readonly schemas: Schemas;
97
100
  /** Write, replace and list the relation facts of the app's own schema (app listener only). */
package/dist/client.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { APIError, CrtrClient, CONTRACT_HEADER, CONTRACT_LEVEL, MINIMUM_RUNTIME_VERSION_HEADER, REQUIRED_CONTRACT_HEADER, RUNTIME_VERSION_HEADER, contractSatisfies, routes, } from '@north-light/api';
2
2
  import { CrouterError, mapError } from './errors.js';
3
3
  import { Canvas } from './resources/canvas.js';
4
+ import { Crons } from './resources/crons.js';
4
5
  import { Docs } from './resources/docs.js';
5
6
  import { Charges } from './resources/charges.js';
6
7
  import { Environments } from './resources/environments.js';
@@ -52,6 +53,8 @@ export class Crouter {
52
53
  memory;
53
54
  /** Write, read and edit documents the calling app owns (`docs.write`, `docs.edit`, `docs.get`): for example one app-owned `preference` with a `boot` rule that carries the app's agent instructions. */
54
55
  docs;
56
+ /** Schedule, list, pause, resume, run and delete the cron jobs the calling app's grant owns (`crtr:schedule` to change one). */
57
+ crons;
55
58
  /** Register the app's permission schema (app listener only). */
56
59
  schemas;
57
60
  /** Write, replace and list the relation facts of the app's own schema (app listener only). */
@@ -168,6 +171,7 @@ export class Crouter {
168
171
  this.questions = new Questions(request);
169
172
  this.memory = new Memory(request);
170
173
  this.docs = new Docs(request);
174
+ this.crons = new Crons(request);
171
175
  this.schemas = new Schemas(request);
172
176
  this.relations = new Relations(request);
173
177
  this.charges = new Charges(request);
@@ -0,0 +1,28 @@
1
+ import { type ArmCronRequest, type CronDTO, type CronRunDTO, type CronShowDTO } from '@north-light/api';
2
+ import type { RequestOptions } from '../types.js';
3
+ import type { Request } from './request.js';
4
+ /** `crons.create` input: the arm request without the fields the runtime derives from the calling app's grant. */
5
+ export type CronCreateParams = Omit<ArmCronRequest, 'profile' | 'scope'>;
6
+ /** `crons.list` input. */
7
+ export interface CronListParams {
8
+ /** Only the crons this node armed. */
9
+ created_by?: string;
10
+ }
11
+ /** The scheduled jobs the calling app's grant owns (app listener). An app never sees or changes another app's crons. */
12
+ export declare class Crons {
13
+ private readonly request;
14
+ constructor(request: Request);
15
+ private path;
16
+ /** Arm one cron. Never retried: a retry could arm a second one. */
17
+ create(params: CronCreateParams, options?: RequestOptions): Promise<CronDTO>;
18
+ list(params?: CronListParams, options?: RequestOptions): Promise<CronDTO[]>;
19
+ /** One cron with its run history (`runs`, newest first). */
20
+ retrieve(cronId: string, options?: RequestOptions): Promise<CronShowDTO>;
21
+ /** Stop firing; config and history stay. */
22
+ pause(cronId: string, options?: RequestOptions): Promise<CronDTO>;
23
+ resume(cronId: string, options?: RequestOptions): Promise<CronDTO>;
24
+ /** Fire now, out of band; resolves with the settled run once the process closes. Does not advance the schedule. Never retried. */
25
+ run(cronId: string, options?: RequestOptions): Promise<CronRunDTO>;
26
+ /** Cancel the cron (idempotent). */
27
+ delete(cronId: string, options?: RequestOptions): Promise<void>;
28
+ }
@@ -0,0 +1,39 @@
1
+ import { routes } from '@north-light/api';
2
+ import { pathSegment } from './identifiers.js';
3
+ /** The scheduled jobs the calling app's grant owns (app listener). An app never sees or changes another app's crons. */
4
+ export class Crons {
5
+ request;
6
+ constructor(request) {
7
+ this.request = request;
8
+ }
9
+ path(cronId) {
10
+ return routes.cron(encodeURIComponent(pathSegment(cronId, 'cron id')));
11
+ }
12
+ /** Arm one cron. Never retried: a retry could arm a second one. */
13
+ create(params, options = {}) {
14
+ return this.request('POST', routes.crons(), params, { ...options, maxRetries: 0 });
15
+ }
16
+ list(params = {}, options) {
17
+ const search = params.created_by === undefined ? '' : `?created_by=${encodeURIComponent(params.created_by)}`;
18
+ return this.request('GET', `${routes.crons()}${search}`, undefined, options);
19
+ }
20
+ /** One cron with its run history (`runs`, newest first). */
21
+ retrieve(cronId, options) {
22
+ return this.request('GET', this.path(cronId), undefined, options);
23
+ }
24
+ /** Stop firing; config and history stay. */
25
+ pause(cronId, options) {
26
+ return this.request('POST', routes.cronPause(encodeURIComponent(pathSegment(cronId, 'cron id'))), {}, options);
27
+ }
28
+ resume(cronId, options) {
29
+ return this.request('POST', routes.cronResume(encodeURIComponent(pathSegment(cronId, 'cron id'))), {}, options);
30
+ }
31
+ /** Fire now, out of band; resolves with the settled run once the process closes. Does not advance the schedule. Never retried. */
32
+ run(cronId, options = {}) {
33
+ return this.request('POST', routes.cronRun(encodeURIComponent(pathSegment(cronId, 'cron id'))), {}, { ...options, maxRetries: 0 });
34
+ }
35
+ /** Cancel the cron (idempotent). */
36
+ async delete(cronId, options) {
37
+ await this.request('DELETE', this.path(cronId), undefined, options);
38
+ }
39
+ }
@@ -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.784"
5
+ sdk-version: "0.3.786"
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.784`. 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.786`. 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.784";
2
+ export declare const SDK_VERSION = "0.3.786";
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.784';
3
+ export const SDK_VERSION = '0.3.786';
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@north-light/sdk",
3
- "version": "0.3.784",
4
- "crouterContract": "1.86",
3
+ "version": "0.3.786",
4
+ "crouterContract": "1.87",
5
5
  "description": "Typed Node and browser client for running crouter agents through the crtrd /v1 API.",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -44,9 +44,9 @@
44
44
  "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); }\""
45
45
  },
46
46
  "dependencies": {
47
- "@north-light/api": "0.3.784",
48
- "@north-light/identity": "0.3.784",
49
- "@north-light/plugin": "0.3.784",
47
+ "@north-light/api": "0.3.786",
48
+ "@north-light/identity": "0.3.786",
49
+ "@north-light/plugin": "0.3.786",
50
50
  "jose": "^6.2.1"
51
51
  },
52
52
  "peerDependencies": {