@north-light/sdk 0.3.664 → 0.3.666
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 +3 -6
- package/dist/client.js +2 -28
- package/dist/index.d.ts +1 -1
- package/dist/oauth/index.d.ts +1 -1
- package/dist/oauth/index.js +2 -2
- package/dist/resources/files.d.ts +1 -19
- package/dist/resources/files.js +1 -15
- package/dist/resources/runs.d.ts +7 -1
- package/dist/resources/shares.d.ts +2 -4
- package/dist/skill/northlight/SKILL.md +2 -2
- package/dist/testing/run.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
package/dist/client.d.ts
CHANGED
|
@@ -74,15 +74,15 @@ export interface CrouterOptions {
|
|
|
74
74
|
}
|
|
75
75
|
/** The namespaces of `Crouter` that only the owner's own daemon serves. A person's app listener answers them `404 unknown operation`. */
|
|
76
76
|
export type OwnerOnly = 'spendLimits' | 'nodes' | 'bash' | 'canvas' | 'crons' | 'structuredRequests' | 'customObjects' | 'human' | 'models' | 'system' | 'auth';
|
|
77
|
-
/** What an app reaches on a person's runtime (the app listener): `Crouter` without the owner-daemon namespaces, `files.link`
|
|
77
|
+
/** What an app reaches on a person's runtime (the app listener): `Crouter` without the owner-daemon namespaces, `files.link`
|
|
78
78
|
* only, `profiles.list` only, `customObjects` register/publish/unregister and `canvas` watch/unwatch. `Crouter` is assignable to it, so a function that takes `AppClient` takes either. */
|
|
79
79
|
export type AppClient = Omit<Crouter, OwnerOnly | 'files' | 'profiles'> & {
|
|
80
80
|
/** Register, publish to and unregister the custom objects the app owns (`receive` and `ack` are owner-daemon only). */
|
|
81
81
|
readonly customObjects: Pick<CustomObjects, 'register' | 'publish' | 'unregister'>;
|
|
82
82
|
/** Link nodes to the app's objects: `watch` and `unwatch` with `watcher` (and `watcher_machine` for a node of another machine), under `crtr:objects:link:node`. */
|
|
83
83
|
readonly canvas: Pick<Canvas, 'watch' | 'unwatch'>;
|
|
84
|
-
/**
|
|
85
|
-
readonly files: Pick<Files, '
|
|
84
|
+
/** A download link for a file an agent handed over, by its id (`files.link`); the other `files` calls are owner-daemon only. */
|
|
85
|
+
readonly files: Pick<Files, 'link'>;
|
|
86
86
|
/** The profiles the app may start runs with (`profiles.list`); `ensure` and `retrieve` are owner-daemon only. */
|
|
87
87
|
readonly profiles: Pick<Crouter['profiles'], 'list'>;
|
|
88
88
|
};
|
|
@@ -191,9 +191,6 @@ export declare class Crouter {
|
|
|
191
191
|
/** Establish NDJSON through the JSON client's cold-socket/retry transport; leave the live body unread. */
|
|
192
192
|
private openCustomDeliveries;
|
|
193
193
|
private openRunEvents;
|
|
194
|
-
/** `GET /v1/files/download` as a raw fetch: bytes are not JSON, so it bypasses the JSON client but
|
|
195
|
-
* still goes through `call()`, which supplies the connection token and refreshes it once on a 401. */
|
|
196
|
-
private openDownload;
|
|
197
194
|
/** Sends one request to any daemon route, for routes the namespaces above do not wrap. */
|
|
198
195
|
request<T>(method: string, path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
199
196
|
private authStatus;
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
-
import { APIConnectionError,
|
|
2
|
+
import { APIConnectionError, AuthenticationError, CrouterError, mapError } from './errors.js';
|
|
3
3
|
import { Bash } from './resources/bash.js';
|
|
4
4
|
import { Canvas } from './resources/canvas.js';
|
|
5
5
|
import { Crons } from './resources/crons.js';
|
|
@@ -234,7 +234,7 @@ export class Crouter {
|
|
|
234
234
|
this.auth = {
|
|
235
235
|
status: (params, options) => this.authStatus(params, options),
|
|
236
236
|
};
|
|
237
|
-
this.files = new Files(request
|
|
237
|
+
this.files = new Files(request);
|
|
238
238
|
this.uploads = new Uploads(request);
|
|
239
239
|
this.attachments = new Attachments(request);
|
|
240
240
|
this.shares = new Shares(request);
|
|
@@ -278,32 +278,6 @@ export class Crouter {
|
|
|
278
278
|
...(after ? { 'Last-Event-ID': String(after) } : {}) }, signal,
|
|
279
279
|
}));
|
|
280
280
|
}
|
|
281
|
-
/** `GET /v1/files/download` as a raw fetch: bytes are not JSON, so it bypasses the JSON client but
|
|
282
|
-
* still goes through `call()`, which supplies the connection token and refreshes it once on a 401. */
|
|
283
|
-
async openDownload(path, options) {
|
|
284
|
-
const baseURL = this.baseURL;
|
|
285
|
-
if (!baseURL)
|
|
286
|
-
throw new CrouterError('File downloads require an app listener baseURL');
|
|
287
|
-
if (typeof path !== 'string' || path === '')
|
|
288
|
-
throw new TypeError('path is required');
|
|
289
|
-
const url = `${baseURL.replace(/\/$/, '')}/v1/files/download?${new URLSearchParams({ path })}`;
|
|
290
|
-
const response = await this.call(undefined, async () => {
|
|
291
|
-
try {
|
|
292
|
-
return await this.eventFetch(url, {
|
|
293
|
-
headers: { ...(this.bearerToken ? { Authorization: `Bearer ${this.bearerToken}` } : {}), ...(options.range ? { Range: options.range } : {}) },
|
|
294
|
-
...(options.signal ? { signal: options.signal } : {}),
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
catch (error) {
|
|
298
|
-
if (options.signal?.aborted)
|
|
299
|
-
throw new APIUserAbortError(0, 'request_aborted', 'download aborted by caller');
|
|
300
|
-
throw new APIConnectionError(0, 'connection_error', error instanceof Error ? error.message : String(error));
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
if (response.ok)
|
|
304
|
-
return response;
|
|
305
|
-
throw mapError(await responseError(response));
|
|
306
|
-
}
|
|
307
281
|
/** Sends one request to any daemon route, for routes the namespaces above do not wrap. */
|
|
308
282
|
request(method, path, body, options) {
|
|
309
283
|
return this.call(deadline(options), (options) => this.client.request(method, path, body, options), path !== '/v1/health');
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { RunEvent, RunEventListener, RunEventOf, RunEventType, RunStreamEnd
|
|
|
8
8
|
export { RunReply } from './resources/run-reply.js';
|
|
9
9
|
export type { RunReplyCollectOptions, RunReplyEnding, RunReplyEvent, RunReplyResult, SentRunMessage } from './resources/run-reply.js';
|
|
10
10
|
export type { AppProfile, RunActivity, RunDeleteResult, RunObject, RunParsedOutcome, RunParseOptions, RunParseParams, RunRecap, RunStartParams, RunStartResult, RunStatus, RunTrace } from './resources/runs.js';
|
|
11
|
-
export type {
|
|
11
|
+
export type { FileLink } from './resources/files.js';
|
|
12
12
|
export type { Upload, UploadCreateParams } from './resources/uploads.js';
|
|
13
13
|
export type { AttachmentLink } from './resources/attachments.js';
|
|
14
14
|
export type { Share, ShareCreated, ShareCreateParams } from './resources/shares.js';
|
package/dist/oauth/index.d.ts
CHANGED
|
@@ -110,7 +110,7 @@ declare const AppCrouter: new (options: CrouterOptions) => AppClient;
|
|
|
110
110
|
/** A runtime client on one person's stored connection (`oauth.client(userId)`): an `AppClient` that refreshes its
|
|
111
111
|
* token through the `OAuth2Client`'s store, plus whose connection it is and the runtime it calls. It offers only what
|
|
112
112
|
* the person's app listener serves. The owner-daemon namespaces (`nodes`, `crons`, …) are absent from its
|
|
113
|
-
* type and throw `CrouterError` if reached anyway; `files` is `
|
|
113
|
+
* type and throw `CrouterError` if reached anyway; `files` is `link` only, `profiles` is `list` only, `customObjects` is
|
|
114
114
|
* `register`, `publish` and `unregister`, and `canvas` is `watch` and `unwatch`.
|
|
115
115
|
* `request` still sends any route. */
|
|
116
116
|
export declare class ConnectedCrouter extends AppCrouter {
|
package/dist/oauth/index.js
CHANGED
|
@@ -70,7 +70,7 @@ const AppCrouter = Crouter;
|
|
|
70
70
|
/** A runtime client on one person's stored connection (`oauth.client(userId)`): an `AppClient` that refreshes its
|
|
71
71
|
* token through the `OAuth2Client`'s store, plus whose connection it is and the runtime it calls. It offers only what
|
|
72
72
|
* the person's app listener serves. The owner-daemon namespaces (`nodes`, `crons`, …) are absent from its
|
|
73
|
-
* type and throw `CrouterError` if reached anyway; `files` is `
|
|
73
|
+
* type and throw `CrouterError` if reached anyway; `files` is `link` only, `profiles` is `list` only, `customObjects` is
|
|
74
74
|
* `register`, `publish` and `unregister`, and `canvas` is `watch` and `unwatch`.
|
|
75
75
|
* `request` still sends any route. */
|
|
76
76
|
export class ConnectedCrouter extends AppCrouter {
|
|
@@ -88,7 +88,7 @@ export class ConnectedCrouter extends AppCrouter {
|
|
|
88
88
|
} });
|
|
89
89
|
}
|
|
90
90
|
const { files, profiles } = this;
|
|
91
|
-
Object.defineProperty(this, 'files', { value: {
|
|
91
|
+
Object.defineProperty(this, 'files', { value: { link: files.link.bind(files) } });
|
|
92
92
|
Object.defineProperty(this, 'profiles', { value: { list: profiles.list } });
|
|
93
93
|
const { customObjects, canvas } = this;
|
|
94
94
|
Object.defineProperty(this, 'customObjects', { value: { register: customObjects.register.bind(customObjects), publish: customObjects.publish.bind(customObjects), unregister: customObjects.unregister.bind(customObjects) } });
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { type FileEncoding, type FileListDTO, type FilePeekDTO, type FileWriteDTO } from '@north-light/api';
|
|
2
2
|
import type { RequestOptions } from '../types.js';
|
|
3
3
|
import type { Request } from './request.js';
|
|
4
|
-
/** Options for `files.download`. */
|
|
5
|
-
export interface FileDownloadOptions {
|
|
6
|
-
/** A single `Range` header value, e.g. `bytes=0-0` or `bytes=-500`; the answer is then 206 with `Content-Range`. */
|
|
7
|
-
range?: string;
|
|
8
|
-
/** Aborts the request and the body stream. */
|
|
9
|
-
signal?: AbortSignal;
|
|
10
|
-
}
|
|
11
|
-
/** Opens a raw download; the client supplies the bearer token and refresh. */
|
|
12
|
-
export type FileDownloadOpener = (path: string, options: FileDownloadOptions) => Promise<Response>;
|
|
13
4
|
/** A short-lived signed download link for a file an agent handed over with `crtr push file`. */
|
|
14
5
|
export interface FileLink {
|
|
15
6
|
/** Fetch this URL (no credentials needed) before `expires_at`. */
|
|
@@ -21,8 +12,7 @@ export interface FileLink {
|
|
|
21
12
|
}
|
|
22
13
|
export declare class Files {
|
|
23
14
|
private readonly request;
|
|
24
|
-
|
|
25
|
-
constructor(request: Request, openDownload?: FileDownloadOpener | undefined);
|
|
15
|
+
constructor(request: Request);
|
|
26
16
|
read(path: string, options?: {
|
|
27
17
|
encoding?: FileEncoding;
|
|
28
18
|
} & RequestOptions): Promise<FilePeekDTO>;
|
|
@@ -32,14 +22,6 @@ export declare class Files {
|
|
|
32
22
|
list(path: string, options?: {
|
|
33
23
|
limit?: number;
|
|
34
24
|
} & RequestOptions): Promise<FileListDTO>;
|
|
35
|
-
/**
|
|
36
|
-
* The raw bytes of a file the caller may read, by path (app listener only; refused on a cloud role). Answers the `Response`
|
|
37
|
-
* itself (200, or 206 for `range`) with `Content-Type`, `Content-Length`, and `Content-Range`,
|
|
38
|
-
* so its body can be piped on. A non-2xx answer is thrown as `APIError` — a bad range is
|
|
39
|
-
* 416 `invalid_request` with `param: 'range'` — and never returned as bytes. A body cut
|
|
40
|
-
* short mid-stream means the file could not be read to the end.
|
|
41
|
-
*/
|
|
42
|
-
download(path: string, options?: FileDownloadOptions): Promise<Response>;
|
|
43
25
|
/**
|
|
44
26
|
* A signed download link for a file an agent handed over (`crtr push file`, announced by a `file.sent` run event), by its `file_id`
|
|
45
27
|
* (app listener only). The link is short-lived; call again for a new one. A file of another app, another person, or a run the app may
|
package/dist/resources/files.js
CHANGED
|
@@ -3,10 +3,8 @@ import { pathSegment } from './identifiers.js';
|
|
|
3
3
|
import { withQuery } from './request.js';
|
|
4
4
|
export class Files {
|
|
5
5
|
request;
|
|
6
|
-
|
|
7
|
-
constructor(request, openDownload) {
|
|
6
|
+
constructor(request) {
|
|
8
7
|
this.request = request;
|
|
9
|
-
this.openDownload = openDownload;
|
|
10
8
|
}
|
|
11
9
|
read(path, options) {
|
|
12
10
|
const { encoding, ...requestOptions } = options ?? {};
|
|
@@ -20,18 +18,6 @@ export class Files {
|
|
|
20
18
|
const { limit, ...requestOptions } = options ?? {};
|
|
21
19
|
return this.request('GET', withQuery(routes.fileList(), { path, limit }), undefined, requestOptions);
|
|
22
20
|
}
|
|
23
|
-
/**
|
|
24
|
-
* The raw bytes of a file the caller may read, by path (app listener only; refused on a cloud role). Answers the `Response`
|
|
25
|
-
* itself (200, or 206 for `range`) with `Content-Type`, `Content-Length`, and `Content-Range`,
|
|
26
|
-
* so its body can be piped on. A non-2xx answer is thrown as `APIError` — a bad range is
|
|
27
|
-
* 416 `invalid_request` with `param: 'range'` — and never returned as bytes. A body cut
|
|
28
|
-
* short mid-stream means the file could not be read to the end.
|
|
29
|
-
*/
|
|
30
|
-
async download(path, options = {}) {
|
|
31
|
-
if (!this.openDownload)
|
|
32
|
-
throw new TypeError('files.download requires a Crouter client');
|
|
33
|
-
return this.openDownload(path, options);
|
|
34
|
-
}
|
|
35
21
|
/**
|
|
36
22
|
* A signed download link for a file an agent handed over (`crtr push file`, announced by a `file.sent` run event), by its `file_id`
|
|
37
23
|
* (app listener only). The link is short-lived; call again for a new one. A file of another app, another person, or a run the app may
|
package/dist/resources/runs.d.ts
CHANGED
|
@@ -86,6 +86,11 @@ export interface RunObject {
|
|
|
86
86
|
* `between_turns`. Poll `runs.get` for a progress badge instead of
|
|
87
87
|
* reading `runs.trace`. */
|
|
88
88
|
activity: RunActivity | null;
|
|
89
|
+
/** The repository (`owner/name`) and branch a cloud dev node works on; null for every node not running in a Blaxel sandbox. */
|
|
90
|
+
worktree: {
|
|
91
|
+
repository: string;
|
|
92
|
+
branch: string;
|
|
93
|
+
} | null;
|
|
89
94
|
}
|
|
90
95
|
/** `RunObject.recap`. */
|
|
91
96
|
export interface RunRecap {
|
|
@@ -101,7 +106,8 @@ export interface AppProfile {
|
|
|
101
106
|
name: string;
|
|
102
107
|
grantee: string;
|
|
103
108
|
default_kind: string;
|
|
104
|
-
default: boolean;
|
|
109
|
+
default: boolean; /** `owner/name` of a cloud dev profile's repositories; empty otherwise. */
|
|
110
|
+
repositories?: string[];
|
|
105
111
|
}
|
|
106
112
|
export interface RunDeleteResult {
|
|
107
113
|
run_id: string;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { RequestOptions } from '../types.js';
|
|
2
2
|
import type { Request } from './request.js';
|
|
3
|
-
/** `shares.create` input
|
|
3
|
+
/** `shares.create` input. */
|
|
4
4
|
export interface ShareCreateParams {
|
|
5
|
-
/** Absolute path of a file the caller may read (refused on a cloud role). Without `crtr:files:share`, only files in the caller's own app space. */
|
|
6
|
-
path?: string;
|
|
7
5
|
/** The `file_id` of a file an agent handed over with `crtr push file` (from its `file.sent` run event). */
|
|
8
|
-
file_id
|
|
6
|
+
file_id: string;
|
|
9
7
|
/** ISO 8601 time in the future; absent or null keeps the share until it is deleted. */
|
|
10
8
|
expires_at?: string | null;
|
|
11
9
|
}
|
|
@@ -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.666"
|
|
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.666`. 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/run.js
CHANGED
|
@@ -121,7 +121,7 @@ export class FakeRun {
|
|
|
121
121
|
...(this.turnError ? { last_turn_error: this.turnError } : {}),
|
|
122
122
|
usage: usage(), payer: 'user', scopes: this.scopes, metadata: this.metadata, created_at: this.createdAt,
|
|
123
123
|
...(this.settledAt ? { settled_at: this.settledAt } : {}),
|
|
124
|
-
latest_sequence: this.sequence, last_activity_at: this.lastActivityAt, activity: this.activity,
|
|
124
|
+
latest_sequence: this.sequence, last_activity_at: this.lastActivityAt, activity: this.activity, worktree: null,
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
// ---- scripting -------------------------------------------------------------------------------------------------
|
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.666";
|
|
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.666';
|
|
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.666",
|
|
4
|
+
"crouterContract": "1.56",
|
|
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.
|
|
48
|
-
"@north-light/identity": "0.3.
|
|
49
|
-
"@north-light/plugin": "0.3.
|
|
47
|
+
"@north-light/api": "0.3.666",
|
|
48
|
+
"@north-light/identity": "0.3.666",
|
|
49
|
+
"@north-light/plugin": "0.3.666",
|
|
50
50
|
"jose": "^6.2.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|