@north-light/cli 0.3.659 → 0.3.660

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.
Files changed (42) hide show
  1. package/dist/api/client.d.ts +3 -0
  2. package/dist/api/client.js +1 -1
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/files.d.ts +20 -0
  6. package/dist/api/dto/run-events.d.ts +9 -1
  7. package/dist/api/routes.d.ts +2 -0
  8. package/dist/api/routes.js +1 -1
  9. package/dist/builtin-memory/northlight-apps/guides/files-and-documents.md +12 -6
  10. package/dist/clients/attach/viewer.js +1 -1
  11. package/dist/commands/push.js +6 -4
  12. package/dist/core/canvas/export-sqlite.js +1 -1
  13. package/dist/core/canvas/migrations.js +1 -1
  14. package/dist/core/canvas/person.js +3 -3
  15. package/dist/core/canvas/schema-pg/019-outbound-files.sql +26 -0
  16. package/dist/core/canvas/schema-version.d.ts +1 -1
  17. package/dist/core/canvas/schema-version.js +1 -1
  18. package/dist/core/grants/remove.js +1 -1
  19. package/dist/core/import/bundle/layout.d.ts +1 -1
  20. package/dist/core/import/bundle/layout.js +3 -3
  21. package/dist/core/import/load/bind.js +8 -8
  22. package/dist/core/providers/files.js +1 -1
  23. package/dist/core/runs/operations.js +4 -4
  24. package/dist/core/storage/download.d.ts +0 -1
  25. package/dist/core/storage/download.js +1 -1
  26. package/dist/core/storage/media-types.d.ts +1 -0
  27. package/dist/core/storage/media-types.js +1 -0
  28. package/dist/core/storage/shares.d.ts +15 -6
  29. package/dist/core/storage/shares.js +1 -1
  30. package/dist/core/storage/tables.d.ts +31 -1
  31. package/dist/core/storage/tables.js +4 -3
  32. package/dist/daemon/api/handlers/node-files.d.ts +2 -0
  33. package/dist/daemon/api/handlers/node-files.js +1 -0
  34. package/dist/daemon/api/handlers/transfer.d.ts +2 -2
  35. package/dist/daemon/api/handlers/transfer.js +1 -1
  36. package/dist/daemon/api/operations.js +1 -1
  37. package/dist/daemon/api/server.js +1 -1
  38. package/dist/daemon/reconcilers/ledger-storage.js +3 -3
  39. package/docs/apps/guides/files-and-documents.md +11 -6
  40. package/package.json +2 -2
  41. package/packages/crouter-identity/package.json +1 -1
  42. package/runtime.lock.json +13 -13
@@ -1,21 +1,26 @@
1
1
  ---
2
2
  title: Files and documents
3
- description: Download a file from a person's runtime with files.download, and read the person's public documents with memory.list and memory.get.
3
+ description: Download a file from a person's runtime with files.download, serve a file an agent handed to the person with files.link, and read the person's public documents with memory.list and memory.get.
4
4
  ---
5
5
 
6
6
  # Files and documents
7
7
 
8
8
  ## Download a file
9
9
 
10
- `runtime.files.download(path, options?)` returns the file's raw bytes as a Fetch `Response` (200, or 206 for a `range`) with `Content-Type`, `Content-Length` and `Content-Range`, so you can pipe its body on. `path` is an absolute path on the person's runtime that your app's grant lets it read. Options: `range` (one `Range` header value such as `bytes=0-0` or `bytes=-500`) and `signal`.
10
+ `runtime.files.download(path, options?)` returns the file's raw bytes as a Fetch `Response` (200, or 206 for a `range`) with `Content-Type`, `Content-Length` and `Content-Range`, so you can pipe its body on. `path` is an absolute path on the person's runtime that your app's grant lets it read. Options: `range` (one `Range` header value such as `bytes=0-0` or `bytes=-500`) and `signal`. A non-2xx answer is thrown as an `APIError`, never returned as bytes; a bad `range` is `416`. A cloud role refuses it with `permission_error`: use `files.link` there. What a path may reach depends on the grant: see [Scopes and grants](/docs/concepts/scopes-and-grants).
11
+
12
+ ## Receive a file an agent made
13
+
14
+ An agent gives the person a file with `crtr push file <path>`. The file is copied to storage and a `file.sent` event (`{file_id, name, media_type, size}`) appears in the run's event stream. Your app then serves it by `file_id`; the agent's own paths are never exposed, and only the app and person that own the run can reach the file.
15
+
16
+ `runtime.files.link(fileId, options?)` returns `{url, expires_at, name, media_type, size}`: a short-lived signed download URL. Redirect the person to it or fetch it from your server; call `link` again for a fresh one. A file of another app, another person, or a run your app may not read is `not_found`.
11
17
 
12
18
  ```ts
13
- const response = await runtime.files.download('/apps/<your client id>/files/report.pdf');
14
- res.setHeader('content-type', response.headers.get('content-type') ?? 'application/octet-stream');
15
- await pipeline(Readable.fromWeb(response.body!), res);
19
+ const {url, name} = await runtime.files.link(event.file_id);
20
+ res.redirect(url);
16
21
  ```
17
22
 
18
- A non-2xx answer is thrown as an `APIError`, never returned as bytes. A bad `range` is `416`, `invalid_request` with `param: 'range'`. A body cut short mid-stream means the file could not be read to the end. What a path may reach depends on the grant: see [Scopes and grants](/docs/concepts/scopes-and-grants). The client your app gets from `oauth.client(userId)` exposes only `download` from `files`; reading, writing and listing are not available to apps.
23
+ `runtime.shares.create({file_id, expires_at?})` makes a public share link from the same file instead. `shares.create({path, expires_at?})` shares a file by path (refused on a cloud role); pass exactly one of `path` or `file_id`. The client your app gets from `oauth.client(userId)` exposes only `download` and `link` from `files`; reading, writing and listing are not available to apps.
19
24
 
20
25
  ## Read the person's public documents
21
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.659",
3
+ "version": "0.3.660",
4
4
  "description": "crtr — agent runtime with memory, plugins, and marketplaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -149,7 +149,7 @@
149
149
  },
150
150
  "license": "UNLICENSED",
151
151
  "dependencies": {
152
- "@north-light/identity": "0.3.659",
152
+ "@north-light/identity": "0.3.660",
153
153
  "@earendil-works/chord": "1.5.2",
154
154
  "@earendil-works/pi-agent-core": "1.5.2",
155
155
  "@earendil-works/pi-ai": "1.5.2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/identity",
3
- "version": "0.3.659",
3
+ "version": "0.3.660",
4
4
  "description": "Northlight access-token verification and scope rules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/runtime.lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.659",
3
+ "version": "0.3.660",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.659",
9
+ "version": "0.3.660",
10
10
  "hasInstallScript": true,
11
11
  "license": "UNLICENSED",
12
12
  "workspaces": [
@@ -28,7 +28,7 @@
28
28
  "@milkdown/preset-gfm": "^7.22.3",
29
29
  "@milkdown/prose": "^7.22.3",
30
30
  "@milkdown/utils": "^7.22.3",
31
- "@north-light/identity": "0.3.659",
31
+ "@north-light/identity": "0.3.660",
32
32
  "cron-parser": "^5.6.0",
33
33
  "esbuild": "0.28.2",
34
34
  "jose": "^6.2.12",
@@ -10666,17 +10666,17 @@
10666
10666
  },
10667
10667
  "packages/crouter-api": {
10668
10668
  "name": "@north-light/api",
10669
- "version": "0.3.659",
10669
+ "version": "0.3.660",
10670
10670
  "license": "UNLICENSED"
10671
10671
  },
10672
10672
  "packages/crouter-env-docker": {
10673
10673
  "name": "@north-light/env-docker",
10674
- "version": "0.3.659",
10674
+ "version": "0.3.660",
10675
10675
  "license": "UNLICENSED"
10676
10676
  },
10677
10677
  "packages/crouter-identity": {
10678
10678
  "name": "@north-light/identity",
10679
- "version": "0.3.659",
10679
+ "version": "0.3.660",
10680
10680
  "license": "UNLICENSED",
10681
10681
  "dependencies": {
10682
10682
  "jose": "^6.2.1"
@@ -10684,21 +10684,21 @@
10684
10684
  },
10685
10685
  "packages/crouter-plugin": {
10686
10686
  "name": "@north-light/plugin",
10687
- "version": "0.3.659",
10687
+ "version": "0.3.660",
10688
10688
  "license": "UNLICENSED",
10689
10689
  "dependencies": {
10690
- "@north-light/api": "0.3.659",
10691
- "@north-light/identity": "0.3.659"
10690
+ "@north-light/api": "0.3.660",
10691
+ "@north-light/identity": "0.3.660"
10692
10692
  }
10693
10693
  },
10694
10694
  "packages/crouter-sdk": {
10695
10695
  "name": "@north-light/sdk",
10696
- "version": "0.3.659",
10696
+ "version": "0.3.660",
10697
10697
  "license": "UNLICENSED",
10698
10698
  "dependencies": {
10699
- "@north-light/api": "0.3.659",
10700
- "@north-light/identity": "0.3.659",
10701
- "@north-light/plugin": "0.3.659",
10699
+ "@north-light/api": "0.3.660",
10700
+ "@north-light/identity": "0.3.660",
10701
+ "@north-light/plugin": "0.3.660",
10702
10702
  "jose": "^6.2.1"
10703
10703
  },
10704
10704
  "bin": {