@north-light/sdk 0.3.882 → 0.3.885
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/resources/runs.d.ts +13 -0
- package/dist/resources/runs.js +10 -0
- package/dist/skill/northlight/SKILL.md +2 -2
- package/dist/testing/cloud.d.ts +1 -1
- package/dist/testing/cloud.js +21 -4
- package/dist/testing/run.d.ts +4 -0
- package/dist/testing/run.js +21 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
package/dist/resources/runs.d.ts
CHANGED
|
@@ -231,6 +231,19 @@ export declare class Runs {
|
|
|
231
231
|
cancel(runId: string, options?: RequestOptions & {
|
|
232
232
|
keepSchedules?: boolean;
|
|
233
233
|
}): Promise<RunObject>;
|
|
234
|
+
/** Stop one helper of the run (any descendant of the root, never the root; use `cancel` for that). The helper and its own helpers settle as `canceled`
|
|
235
|
+
* and `child.settled` fires; the run goes on. Throws `NotFoundError` (404) for a node that is not a descendant of the run. */
|
|
236
|
+
cancelNode(runId: string, nodeId: string, options?: RequestOptions): Promise<{
|
|
237
|
+
run_id: string;
|
|
238
|
+
node_id: string;
|
|
239
|
+
}>;
|
|
240
|
+
/** Kill one background job (`job.started`'s `job_id`) of any node in the run. Emits `job.ended` with reason `killed`.
|
|
241
|
+
* Throws `NotFoundError` (404) for a job that is not running or not a job of this run. */
|
|
242
|
+
killJob(runId: string, jobId: string, options?: RequestOptions): Promise<{
|
|
243
|
+
run_id: string;
|
|
244
|
+
node_id: string;
|
|
245
|
+
job_id: string;
|
|
246
|
+
}>;
|
|
234
247
|
/** Delete the run, running or not: the runtime stops its turns and sandboxes itself, so there is no need to
|
|
235
248
|
* `cancel` first. Deleting a run that is already gone throws `NotFoundError` (404).
|
|
236
249
|
* `uploads_pending` counts the run's released uploads storage has not yet confirmed deleted; the runtime retries those. */
|
package/dist/resources/runs.js
CHANGED
|
@@ -103,6 +103,16 @@ export class Runs {
|
|
|
103
103
|
const { keepSchedules, ...rest } = options;
|
|
104
104
|
return this.request('POST', `${runPath(runId)}/cancel`, keepSchedules === undefined ? {} : { keep_schedules: keepSchedules }, rest);
|
|
105
105
|
}
|
|
106
|
+
/** Stop one helper of the run (any descendant of the root, never the root; use `cancel` for that). The helper and its own helpers settle as `canceled`
|
|
107
|
+
* and `child.settled` fires; the run goes on. Throws `NotFoundError` (404) for a node that is not a descendant of the run. */
|
|
108
|
+
cancelNode(runId, nodeId, options) {
|
|
109
|
+
return this.request('POST', `${runPath(runId)}/nodes/${encodeURIComponent(nodeId)}/cancel`, {}, options);
|
|
110
|
+
}
|
|
111
|
+
/** Kill one background job (`job.started`'s `job_id`) of any node in the run. Emits `job.ended` with reason `killed`.
|
|
112
|
+
* Throws `NotFoundError` (404) for a job that is not running or not a job of this run. */
|
|
113
|
+
killJob(runId, jobId, options) {
|
|
114
|
+
return this.request('DELETE', `${runPath(runId)}/jobs/${encodeURIComponent(jobId)}`, undefined, options);
|
|
115
|
+
}
|
|
106
116
|
/** Delete the run, running or not: the runtime stops its turns and sandboxes itself, so there is no need to
|
|
107
117
|
* `cancel` first. Deleting a run that is already gone throws `NotFoundError` (404).
|
|
108
118
|
* `uploads_pending` counts the run's released uploads storage has not yet confirmed deleted; the runtime retries those. */
|
|
@@ -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.
|
|
5
|
+
sdk-version: "0.3.885"
|
|
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.
|
|
30
|
+
This skill is for SDK version `0.3.885`. 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/testing/cloud.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type SpaceOp } from './space.js';
|
|
|
7
7
|
import { type FakeRefusalCode, type FakeScope, type FakeUser, type Responder } from './users.js';
|
|
8
8
|
import { type FakeError } from './wire.js';
|
|
9
9
|
/** A runtime operation, named as the daemon's `OPERATIONS` table names it. */
|
|
10
|
-
export type FakeOp = 'grant.get' | 'run.start' | 'run.list' | 'run.get' | 'run.message' | 'run.events' | 'run.interrupt' | 'run.cancel' | 'run.delete' | 'run.rename' | 'question.get' | 'question.answer' | 'question.cancel' | 'question.history' | 'review.list' | 'review.get' | 'review.submit' | 'review.cancel' | 'discuss.ticket.get' | 'discuss.ticket.post' | 'discuss.review.get' | 'discuss.review.post' | 'trace.get' | 'memory.list' | 'memory.get' | 'provider.tools' | 'provider.call' | 'provider.machine' | 'profile.list' | 'exec' | SpaceOp;
|
|
10
|
+
export type FakeOp = 'grant.get' | 'run.start' | 'run.list' | 'run.get' | 'run.message' | 'run.events' | 'run.interrupt' | 'run.cancel' | 'run.cancel_node' | 'run.job.kill' | 'run.delete' | 'run.rename' | 'question.get' | 'question.answer' | 'question.cancel' | 'question.history' | 'review.list' | 'review.get' | 'review.submit' | 'review.cancel' | 'discuss.ticket.get' | 'discuss.ticket.post' | 'discuss.review.get' | 'discuss.review.post' | 'trace.get' | 'memory.list' | 'memory.get' | 'provider.tools' | 'provider.call' | 'provider.machine' | 'profile.list' | 'exec' | SpaceOp;
|
|
11
11
|
/** A directory operation. */
|
|
12
12
|
export type FakeDirectoryOp = 'directory.discovery' | 'directory.token' | 'directory.jwks';
|
|
13
13
|
/** What `intercept` / `failNext` / `gate` match: a runtime operation, `'*'` (every runtime operation), or a directory operation. */
|
package/dist/testing/cloud.js
CHANGED
|
@@ -25,6 +25,8 @@ const ROUTES = [
|
|
|
25
25
|
['GET', /^\/v1\/runs\/([^/]+)\/events$/, 'run.events'],
|
|
26
26
|
['POST', /^\/v1\/runs\/([^/]+)\/interrupt$/, 'run.interrupt'],
|
|
27
27
|
['POST', /^\/v1\/runs\/([^/]+)\/cancel$/, 'run.cancel'],
|
|
28
|
+
['POST', /^\/v1\/runs\/([^/]+)\/nodes\/([^/]+)\/cancel$/, 'run.cancel_node'],
|
|
29
|
+
['DELETE', /^\/v1\/runs\/([^/]+)\/jobs\/([^/]+)$/, 'run.job.kill'],
|
|
28
30
|
['POST', /^\/v1\/runs\/([^/]+)\/rename$/, 'run.rename'],
|
|
29
31
|
['GET', /^\/v1\/runs\/([^/]+)\/trace$/, 'trace.get'],
|
|
30
32
|
['GET', /^\/v1\/questions$/, 'question.history'],
|
|
@@ -60,7 +62,7 @@ const ROUTES = [
|
|
|
60
62
|
['GET', /^\/v1\/objects\/([^/]+)$/, 'object.get'],
|
|
61
63
|
];
|
|
62
64
|
const DIRECTORY_OPS = new Set(['directory.discovery', 'directory.token', 'directory.jwks']);
|
|
63
|
-
const RUN_OPS = new Set(['run.get', 'run.delete', 'run.message', 'run.events', 'run.interrupt', 'run.cancel', 'run.rename', 'trace.get']);
|
|
65
|
+
const RUN_OPS = new Set(['run.get', 'run.delete', 'run.message', 'run.events', 'run.interrupt', 'run.cancel', 'run.cancel_node', 'run.job.kill', 'run.rename', 'trace.get']);
|
|
64
66
|
const ACT_OPS = new Set(['run.start', 'run.message', 'exec']);
|
|
65
67
|
/** The runtime's live exec processes per app (`handlers/exec.ts`); one more is 429 `busy`. */
|
|
66
68
|
const MAX_LIVE_EXECS = 4;
|
|
@@ -627,6 +629,8 @@ export class FakeCloud {
|
|
|
627
629
|
const [, pattern, op] = route;
|
|
628
630
|
const segment = pattern.exec(url.pathname)?.[1];
|
|
629
631
|
const id = segment === undefined ? undefined : decodeURIComponent(segment);
|
|
632
|
+
const secondSegment = pattern.exec(url.pathname)?.[2];
|
|
633
|
+
const second = secondSegment === undefined ? undefined : decodeURIComponent(secondSegment);
|
|
630
634
|
let body = null;
|
|
631
635
|
let badJson = false;
|
|
632
636
|
if (request.method === 'POST' || request.method === 'PUT' || request.method === 'PATCH') {
|
|
@@ -683,7 +687,7 @@ export class FakeCloud {
|
|
|
683
687
|
call.status = 200;
|
|
684
688
|
return new Response(run.openStream(after, signal), { status: 200, headers: { 'content-type': 'text/event-stream', 'cache-control': 'no-cache', ...this.headers() } });
|
|
685
689
|
}
|
|
686
|
-
const result = await this.handle(op, user, id, url.searchParams, body, call.idempotencyKey, signal, claims);
|
|
690
|
+
const result = await this.handle(op, user, id, url.searchParams, body, call.idempotencyKey, signal, claims, second);
|
|
687
691
|
return answer(result.status, result.body);
|
|
688
692
|
}
|
|
689
693
|
catch (error) {
|
|
@@ -720,7 +724,7 @@ export class FakeCloud {
|
|
|
720
724
|
throw invalid('Idempotency-Key must be 1 to 255 characters');
|
|
721
725
|
return raw;
|
|
722
726
|
}
|
|
723
|
-
async handle(op, user, id, query, body, rawKey, signal, claims) {
|
|
727
|
+
async handle(op, user, id, query, body, rawKey, signal, claims, second) {
|
|
724
728
|
switch (op) {
|
|
725
729
|
case 'grant.get': return this.grantGet(user, query, signal, claims);
|
|
726
730
|
case 'run.start': return this.runStart(user, body, rawKey);
|
|
@@ -773,6 +777,19 @@ export class FakeCloud {
|
|
|
773
777
|
run.settle({ failure: 'canceled' });
|
|
774
778
|
return { status: 200, body: run.toObject() };
|
|
775
779
|
}
|
|
780
|
+
case 'run.cancel_node': {
|
|
781
|
+
const run = this.ownedRun(user, id);
|
|
782
|
+
if (!run.cancelNode(second))
|
|
783
|
+
throw notFound();
|
|
784
|
+
return { status: 200, body: { run_id: run.id, node_id: second } };
|
|
785
|
+
}
|
|
786
|
+
case 'run.job.kill': {
|
|
787
|
+
const run = this.ownedRun(user, id);
|
|
788
|
+
const nodeId = run.killJob(second);
|
|
789
|
+
if (nodeId === null)
|
|
790
|
+
throw notFound();
|
|
791
|
+
return { status: 200, body: { run_id: run.id, node_id: nodeId, job_id: second } };
|
|
792
|
+
}
|
|
776
793
|
case 'run.rename': {
|
|
777
794
|
const run = this.ownedRun(user, id);
|
|
778
795
|
const params = objectBody(body);
|
|
@@ -866,7 +883,7 @@ export class FakeCloud {
|
|
|
866
883
|
throw notFound('unknown operation');
|
|
867
884
|
}
|
|
868
885
|
}
|
|
869
|
-
async grantGet(user, query, signal, claims) {
|
|
886
|
+
async grantGet(user, query, signal, claims, second) {
|
|
870
887
|
const wait = waitSeconds(query);
|
|
871
888
|
const since = query.get('since');
|
|
872
889
|
if (since !== null && !/^[A-Za-z0-9_-]{1,64}$/.test(since))
|
package/dist/testing/run.d.ts
CHANGED
|
@@ -150,6 +150,10 @@ export declare class FakeRun {
|
|
|
150
150
|
idle(): void;
|
|
151
151
|
/** Record the run's ending and emit `node.settled`. */
|
|
152
152
|
settle(ending: FakeRunEnding): void;
|
|
153
|
+
/** `runs.cancelNode`: the child (one a `child.started` event named, not yet settled) settles `canceled`. Returns false for any other node. */
|
|
154
|
+
cancelNode(nodeId: string): boolean;
|
|
155
|
+
/** `runs.killJob`: a job a `job.started` event named and no `job.ended` closed ends `killed`. Returns the launching node, or null for any other job. */
|
|
156
|
+
killJob(jobId: string): string | null;
|
|
153
157
|
/** Open a question: a `waiting_on_user` event; the run waits on the user between turns. Returns its id. */
|
|
154
158
|
ask(question: FakeQuestion): string;
|
|
155
159
|
/** Delete the run as the runtime does: reads answer 404, streams close, its idempotency keys are dropped. */
|
package/dist/testing/run.js
CHANGED
|
@@ -204,6 +204,27 @@ export class FakeRun {
|
|
|
204
204
|
question.status = 'canceled';
|
|
205
205
|
this.append('node.settled', { outcome, usage: usage(), ...(this.hasResult ? { result: this.resultValue } : {}) });
|
|
206
206
|
}
|
|
207
|
+
/** `runs.cancelNode`: the child (one a `child.started` event named, not yet settled) settles `canceled`. Returns false for any other node. */
|
|
208
|
+
cancelNode(nodeId) {
|
|
209
|
+
this.assertLive();
|
|
210
|
+
const has = (type) => this.log.some((event) => event.type === type && event.child_node_id === nodeId);
|
|
211
|
+
if (!has('child.started'))
|
|
212
|
+
return false;
|
|
213
|
+
if (!has('child.settled')) {
|
|
214
|
+
const outcome = { node_id: nodeId, revision: 1, settled_at: nowIso(this.host.now()), structured_result: null, detail: null, final_report: null, kind: 'failure', reason: 'canceled', declined: null };
|
|
215
|
+
this.append('child.settled', { child_node_id: nodeId, outcome }, nodeId);
|
|
216
|
+
}
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
/** `runs.killJob`: a job a `job.started` event named and no `job.ended` closed ends `killed`. Returns the launching node, or null for any other job. */
|
|
220
|
+
killJob(jobId) {
|
|
221
|
+
this.assertLive();
|
|
222
|
+
const started = this.log.find((event) => event.type === 'job.started' && event.job_id === jobId);
|
|
223
|
+
if (!started || this.log.some((event) => event.type === 'job.ended' && event.job_id === jobId))
|
|
224
|
+
return null;
|
|
225
|
+
this.append('job.ended', { job_id: jobId, exit_code: null, reason: 'killed' }, started.node_id);
|
|
226
|
+
return started.node_id;
|
|
227
|
+
}
|
|
207
228
|
/** Open a question: a `waiting_on_user` event; the run waits on the user between turns. Returns its id. */
|
|
208
229
|
ask(question) {
|
|
209
230
|
this.assertLive();
|
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.
|
|
2
|
+
export declare const SDK_VERSION = "0.3.885";
|
|
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.
|
|
3
|
+
export const SDK_VERSION = '0.3.885';
|
|
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.
|
|
4
|
-
"crouterContract": "1.
|
|
3
|
+
"version": "0.3.885",
|
|
4
|
+
"crouterContract": "1.112",
|
|
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",
|
|
@@ -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.
|
|
54
|
-
"@north-light/identity": "0.3.
|
|
55
|
-
"@north-light/plugin": "0.3.
|
|
53
|
+
"@north-light/api": "0.3.885",
|
|
54
|
+
"@north-light/identity": "0.3.885",
|
|
55
|
+
"@north-light/plugin": "0.3.885",
|
|
56
56
|
"jose": "^6.2.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|