@mediamonks/canopy-cli 0.7.50 → 0.7.51

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 (33) hide show
  1. package/dist/{dev-BQ77vmCk.mjs → dev-DjK3Y8jb.mjs} +4 -4
  2. package/dist/dev-DkaQjBTp.mjs +2 -0
  3. package/dist/{dev-worker-BP-HGHYb.mjs → dev-worker-CDxgu7c1.mjs} +1 -1
  4. package/dist/docs/calling-projects.md +9 -0
  5. package/dist/docs/cli-dev.md +1 -1
  6. package/dist/docs/cli-files.md +57 -0
  7. package/dist/docs/cli.md +2 -0
  8. package/dist/docs/developers-architecture.md +5 -0
  9. package/dist/docs/index.json +10 -0
  10. package/dist/docs/outside-sign-in.md +79 -0
  11. package/dist/docs/platform-client-access.md +6 -0
  12. package/dist/docs/platform-project-data.md +7 -1
  13. package/dist/docs/sdk-auth.md +12 -9
  14. package/dist/docs/sdk-files.md +32 -0
  15. package/dist/docs/sdk-projects.md +2 -1
  16. package/dist/docs/staging.md +8 -0
  17. package/dist/{docs-Cd6VzYts.mjs → docs-CLgKBi8H.mjs} +1 -1
  18. package/dist/{feedback-BkrdL92o.mjs → feedback-B6tqJ3cd.mjs} +1 -1
  19. package/dist/files-B7toJRlj.mjs +69 -0
  20. package/dist/index.mjs +14 -12
  21. package/dist/{local-C6ggy2PQ.mjs → local-BmUmiOUN.mjs} +2 -2
  22. package/dist/{mcp-Bt9Z9kdf.mjs → mcp-CWtqUFE3.mjs} +1 -1
  23. package/dist/{package-Sir3152_.mjs → package-4SGn0Cy3.mjs} +1 -1
  24. package/dist/{project-template-DHWdVc6E.mjs → project-template-Bas1UN2O.mjs} +1 -0
  25. package/dist/project-template-Dti_Mmnb.mjs +2 -0
  26. package/dist/{projects-Z8ufQIBc.mjs → projects-BEBYhy6k.mjs} +1 -1
  27. package/dist/{skill-Bxc5E-wu.mjs → skill-CY_4eqOD.mjs} +1 -1
  28. package/dist/{src-DzU89gZN.mjs → src-DbqT3K2l.mjs} +25 -4
  29. package/dist/templates/worker/worker/index.ts +4 -0
  30. package/dist/{upgrade-DOpeMSWD.mjs → upgrade-Dxzb3e3r.mjs} +1 -1
  31. package/package.json +1 -1
  32. package/dist/dev-Z3bI5hgh.mjs +0 -2
  33. package/dist/project-template-ChFb7A_H.mjs +0 -2
@@ -2,7 +2,7 @@ import { c as projectDirArgs, d as resolveProject, m as tryReadCanopyJson, r as
2
2
  import { a as apiRequest, m as withContext, t as ApiError } from "./api-DmJrIsE7.mjs";
3
3
  import { r as reportErrors, t as formatDateTime } from "./ui-Ddw4d2Nn.mjs";
4
4
  import { r as readMigrationFiles } from "./migrations-BReMlGWP.mjs";
5
- import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER } from "./src-DzU89gZN.mjs";
5
+ import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER } from "./src-DbqT3K2l.mjs";
6
6
  import { a as parseAppRoleFlag } from "./roles-CUFRTp_R.mjs";
7
7
  import { n as writeDevServerRecord } from "./dev-server-file-Dk9pk4AR.mjs";
8
8
  import { createRequire } from "node:module";
@@ -107,7 +107,7 @@ async function workerPlugin(flags, slug, workerAttest, remoteUser, roles) {
107
107
  console.log(`note: canopy.json points "worker" at ${entry}, which does not exist — skipping.`);
108
108
  return;
109
109
  }
110
- const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-BP-HGHYb.mjs");
110
+ const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-CDxgu7c1.mjs");
111
111
  const secrets = readDevVars(flags.dir);
112
112
  const email = siteConfig().email;
113
113
  const found = await remoteUser?.() ?? (email ? {
@@ -325,7 +325,7 @@ async function devRemote(flags, slug) {
325
325
  async function devLocal(flags, slug) {
326
326
  let dump;
327
327
  if (flags.pull) {
328
- const { fetchProjectDump } = await import("./local-C6ggy2PQ.mjs");
328
+ const { fetchProjectDump } = await import("./local-BmUmiOUN.mjs");
329
329
  console.log(`Pulling a fresh export of ${slug}${flags.staging ? " [staging]" : ""}…`);
330
330
  dump = await fetchProjectDump(slug, flags.staging ? "staging" : "live");
331
331
  }
@@ -342,7 +342,7 @@ async function devLocal(flags, slug) {
342
342
  }
343
343
  const workerAttest = randomBytes(24).toString("base64url");
344
344
  const devRoles = await resolveDevRoles(slug, flags.asRoles);
345
- const { createSandbox } = await import("./local-C6ggy2PQ.mjs");
345
+ const { createSandbox } = await import("./local-BmUmiOUN.mjs");
346
346
  const sandbox = await createSandbox({
347
347
  slug,
348
348
  persistDir: join(flags.dir, ".canopy", "local"),
@@ -0,0 +1,2 @@
1
+ import { n as devCommand } from "./dev-DjK3Y8jb.mjs";
2
+ export { devCommand };
@@ -1,4 +1,4 @@
1
- import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER, r as redactCanopyCredentials, t as CALLER_HEADER } from "./src-DzU89gZN.mjs";
1
+ import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER, r as redactCanopyCredentials, t as CALLER_HEADER } from "./src-DbqT3K2l.mjs";
2
2
  import { readFileSync } from "node:fs";
3
3
  import { relative, resolve, sep } from "node:path";
4
4
  //#region src/dev-worker.ts
@@ -48,6 +48,15 @@ const assets = await res.json();
48
48
  and a body as usual. It calls the live channel unless you pass `{ channel: "staging" }`.
49
49
  The other project needs no entry on your [outbound hosts](https://docs.canopy.website/platform/egress).
50
50
 
51
+ To keep a staged backend off the other project's live data, call the channel
52
+ you are on yourself. `env.CANOPY_CHANNEL` tells you which one that is:
53
+
54
+ ```ts
55
+ const res = await canopy.projects.fetch("asset-library", "/api/assets", {
56
+ channel: env.CANOPY_CHANNEL, // "live" or "staging"
57
+ });
58
+ ```
59
+
51
60
  You get the other project's response back as it is. When Canopy refuses the
52
61
  call, you get a JSON error instead:
53
62
 
@@ -40,7 +40,7 @@ With the lock in place, `--local` runs on an embedded SQLite engine instead —
40
40
 
41
41
  **Your backend worker.** If `canopy.json` names a `worker` entry (the worker scaffold does), `canopy dev` serves it too: requests to `/api/*` go to your worker, everything else to the SPA — the same split the platform makes once you deploy. There's no build step; save the file and the next request runs the new code.
42
42
 
43
- Your worker gets the same `env` it gets in production: `env.CANOPY.fetch` for the SDK, `env.DB` and `env.BLOB` for raw database and file access, `env.CALLER` and `env.USER` for whoever is calling, `env.PROJECT_SLUG`. They all follow the mode you're in — live project data by default, your sandbox under `--local`. Two differences worth knowing: `env.CALLER` and `env.USER` are you (the account you logged in with), since there's no company login in front of a local server, and a write through `env.DB` reports no row count locally.
43
+ Your worker gets the same `env` it gets in production: `env.CANOPY.fetch` for the SDK, `env.DB` and `env.BLOB` for raw database and file access, `env.CALLER` and `env.USER` for whoever is calling, `env.PROJECT_SLUG`, and `env.CANOPY_CHANNEL` (`"staging"` with `--staging`, otherwise `"live"`). They all follow the mode you're in — live project data by default, your sandbox under `--local`. Two differences worth knowing: `env.CALLER` and `env.USER` are you (the account you logged in with), since there's no company login in front of a local server, and a write through `env.DB` reports no row count locally.
44
44
 
45
45
  To tick a schedule by hand, post its name to the same path the platform uses:
46
46
 
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: canopy files
3
+ description: Show or set what the app's own pages may do with the project's files.
4
+ ---
5
+
6
+ `canopy files` works with the project's file storage, the files your app keeps
7
+ with [`canopy.blob`](https://docs.canopy.website/sdk/files). Today it has one subcommand, `access`.
8
+
9
+ ## Usage
10
+
11
+ ```bash
12
+ canopy files access [--project <slug>]
13
+ canopy files access full|readonly|off [--project <slug>]
14
+ ```
15
+
16
+ The project comes from `canopy.json` in the current directory, or from
17
+ `--project <slug>`. The global `--profile <site>` / `CANOPY_PROFILE` picks the
18
+ site.
19
+
20
+ ### canopy files access
21
+
22
+ Without a level, it prints the project's browser file access and what it
23
+ means. With a level, it sets it and prints the result:
24
+
25
+ - `full` — pages can list, download, upload and delete files. The default.
26
+ - `readonly` — pages can list and download files and make download links;
27
+ uploads and deletes from a page are refused.
28
+ - `off` — pages cannot touch files at all.
29
+
30
+ Your worker, the CLI and the dashboard keep full access at every level, and
31
+ download links the worker makes keep working. The level is separate from the
32
+ database's (`canopy db access`) and applies to the live and staging channels
33
+ alike. A change signs out visitors who came in with the
34
+ [client password](https://docs.canopy.website/platform/client-access), so they pick up the new level when
35
+ they sign in again. You need to be an editor on the project to read or change
36
+ it.
37
+
38
+ When client access is on and the level isn't `off`, the output warns that
39
+ visitors who know the password can reach the files too.
40
+
41
+ An unknown level exits non-zero and names the accepted ones.
42
+
43
+ ## Examples
44
+
45
+ ```bash
46
+ # See the current level
47
+ canopy files access
48
+
49
+ # Make files read-only for pages, before moving uploads into the worker
50
+ canopy files access readonly
51
+
52
+ # Only the worker (and the links it hands out) may touch files
53
+ canopy files access off --project people-dashboard
54
+ ```
55
+
56
+ The SDK side, including the worker-issued link pattern, is in
57
+ [Files](https://docs.canopy.website/sdk/files#who-can-call-this-from-the-browser).
package/dist/docs/cli.md CHANGED
@@ -58,6 +58,8 @@ has a full page per command.
58
58
  - `canopy db snapshots` — list stored snapshots.
59
59
  - `canopy db restore [file]` — replace ALL project data from a `.sql` file or
60
60
  `--snapshot <key>`. `--yes` skips the confirmation. **Destructive.**
61
+ - `canopy files access [full|readonly|off]` — what the app's own pages may do
62
+ with its files. See [canopy files](https://docs.canopy.website/cli/files).
61
63
  - `canopy usage` — AI spend and storage for the project (same data as the
62
64
  dashboard Usage tab). `--project <slug>` / `--json` for agents.
63
65
  - `canopy ai models` — the AI models and `auto/*` aliases this site offers,
@@ -90,6 +90,11 @@ else is still static serving. A few things to know:
90
90
  ask the platform instead: `await canopy.auth.user()` through the `CANOPY`
91
91
  binding (below) answers for every visitor.
92
92
 
93
+ - **The backend knows its channel.** `c.env.CANOPY_CHANNEL` is `"live"` or
94
+ `"staging"`: which [channel](https://docs.canopy.website/guides/staging) this copy of the backend
95
+ serves. It is set on every request and in scheduled runs, so there's no
96
+ need to read it from the hostname.
97
+
93
98
  - **Platform access goes through the same SDK**, via the `CANOPY` service
94
99
  binding — same budgets, same data isolation as the browser:
95
100
 
@@ -57,6 +57,11 @@
57
57
  "title": "Roles and permissions",
58
58
  "summary": "Give people different powers inside your app with app roles, and check them where it counts."
59
59
  },
60
+ {
61
+ "slug": "outside-sign-in",
62
+ "title": "Sharing a project with people outside Monks",
63
+ "summary": "Invite a client contact by email and they get their own sign-in to your project. No shared password, and you can take one person's access away on its own."
64
+ },
60
65
  {
61
66
  "slug": "calling-projects",
62
67
  "title": "Calling another project",
@@ -336,6 +341,11 @@
336
341
  "title": "canopy db",
337
342
  "summary": "Pull, snapshot, list, restore, and migrate a project's database from the terminal."
338
343
  },
344
+ {
345
+ "slug": "cli-files",
346
+ "title": "canopy files",
347
+ "summary": "Show or set what the app's own pages may do with the project's files."
348
+ },
339
349
  {
340
350
  "slug": "cli-logs",
341
351
  "title": "canopy logs",
@@ -0,0 +1,79 @@
1
+ ---
2
+ title: Sharing a project with people outside Monks
3
+ description: Invite a client contact by email and they get their own sign-in to your project. No shared password, and you can take one person's access away on its own.
4
+ ---
5
+
6
+ Anyone who manages a project's members can add someone from outside Monks by
7
+ their email address. They get an invitation email, sign in with that address,
8
+ and from then on open your app as themselves. Each person has their own
9
+ sign-in, so you can see who is who, give one person an app role, and remove
10
+ one person without touching anyone else.
11
+
12
+ > **Note:** This has to be switched on for the site. If the Members card doesn't mention outside invitations,
13
+ > ask the platform team.
14
+
15
+ ## Inviting someone
16
+
17
+ On the project's **Settings** tab, in the **Members** card, type the person's
18
+ full email address and add them. People outside Monks are always added as
19
+ **viewers**: they can open the app and nothing that manages it. You can give
20
+ them [app roles](https://docs.canopy.website/guides/roles) like anyone else.
21
+
22
+ The owner, managers and platform admins can invite outsiders. Each invitation
23
+ is recorded under the person who sent it.
24
+
25
+ They get an email naming the project and who added them, with a link to it.
26
+ If the email didn't go out, the Members card says so and lets you send it
27
+ again. The card marks outside members and invitations so you can tell them
28
+ apart from colleagues.
29
+
30
+ ## What they see
31
+
32
+ When they open the project's link, the sign-in page offers **Not at Monks?
33
+ Sign in with email**. They type their address and get an email with a link and
34
+ a 6-digit code. Either one signs them in:
35
+
36
+ - the **link** works on any device, after they click **Continue**;
37
+ - the **code** works in the browser where they asked for it.
38
+
39
+ Both expire after 15 minutes and work once. The first time, they're asked for
40
+ their name.
41
+
42
+ Once in, they use your app like any viewer. They can't open the Canopy
43
+ dashboard, use the CLI, file feedback through the widget, or open any other
44
+ project unless it was shared with them too. If they follow a link to a project
45
+ that isn't shared with them, they see a page saying so, with nothing about
46
+ that project on it.
47
+
48
+ Only people who were invited to that project get a sign-in email. Anyone else
49
+ who types an address sees the same "check your email" page and nothing is sent.
50
+
51
+ ## How long a sign-in lasts
52
+
53
+ A sign-in lasts 7 days from the last time they used it, and at most 30 days in
54
+ total. It survives closing the browser and restarting the computer. After that
55
+ they sign in with email again. Signing out (`auth.logout()` in your app, or the
56
+ sign-out link) ends it on that browser only.
57
+
58
+ ## In your code
59
+
60
+ To your app, an outside member is an `external` caller with a real email and an
61
+ id that stays the same every time they sign in. `auth.user()` and
62
+ `env.CALLER` both carry them; `env.USER` stays `null`, as it is for everyone
63
+ outside Monks. They get the project's default app role plus any you assigned.
64
+ See [Auth](https://docs.canopy.website/sdk/auth).
65
+
66
+ ## Removing someone
67
+
68
+ Remove them from the **Members** card like anyone else. Their access to the
69
+ project ends on their next page load. A platform admin can also sign an outside
70
+ account out everywhere, or remove it from every project at once, from the
71
+ admin **Users** page.
72
+
73
+ ## Compared with client passwords
74
+
75
+ A [client password](https://docs.canopy.website/platform/client-access) is one shared secret for one
76
+ project, good for a quick preview. Outside members are better when the same
77
+ people come back, use several of your tools, or need their own roles. A project
78
+ can use both: an outside member of a password-protected project gets in with
79
+ their own sign-in and doesn't need the password.
@@ -42,6 +42,11 @@ access off entirely, remove the password from the same card, or switch the
42
42
  mode back to Monks only; either way, visitors are back to Monks-only
43
43
  immediately, unlocked browsers included.
44
44
 
45
+ If the same people keep coming back, or need their own app roles, invite them
46
+ by email instead: each gets their own sign-in, and you can remove one person
47
+ without changing anything for the rest. See
48
+ [Sharing a project with people outside Monks](https://docs.canopy.website/guides/outside-sign-in).
49
+
45
50
  > **Warning:** A shared password is deliberately lightweight protection — right for work-in-progress previews,
46
51
  > wrong for anything sensitive. Anyone who has it can view the app and share it further, so rotate
47
52
  > it when a review round ends.
@@ -71,4 +76,5 @@ name them `private_…` so only the worker can reach them, or set browser
71
76
  access to read only or off. See
72
77
  [Who can call this from the browser](https://docs.canopy.website/sdk/database#who-can-call-this-from-the-browser).
73
78
 
79
+ - [Sharing with people outside Monks](https://docs.canopy.website/guides/outside-sign-in) — Invite client contacts by email so each gets their own sign-in.
74
80
  - [Members & access](https://docs.canopy.website/platform/members-and-access) — Who can view and who can manage a project, and how to tighten it.
@@ -31,7 +31,13 @@ by design. The explorer is fixed to the channel (live or staging) you opened
31
31
  it from; to look at the other one, go back to the Data tab and switch there.
32
32
 
33
33
  The **Files** tab next to it lists the project's blob storage — the uploads
34
- and files your app has saved.
34
+ and files your app has saved. Its **Browser access** card sets what the app's
35
+ own pages may do with those files: upload and delete (the default), read only,
36
+ or off. Your worker and this dashboard always keep full access, and download
37
+ links the worker makes keep working at every level. It is separate from the
38
+ Data tab's browser access for the database; see
39
+ [Files](https://docs.canopy.website/sdk/files#who-can-call-this-from-the-browser) for how pages and the
40
+ worker split the work.
35
41
 
36
42
  ## Snapshots and restores
37
43
 
@@ -20,15 +20,17 @@ const user = await canopy.auth.user();
20
20
 
21
21
  | Field | Type | Meaning |
22
22
  | ------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
23
- | `id` | `string` | Stable subject from OneLogin — safe to key user data on. |
24
- | `email` | `string` | The user's email address. |
23
+ | `id` | `string` | Stable id — safe to key user data on, except for a client-password visitor (see below). |
24
+ | `email` | `string` | The user's email address; empty for a client-password visitor. |
25
25
  | `name` | `string` | Display name. |
26
- | `kind` | `"monk" \| "external"` | `"monk"` = signed in through OneLogin; `"external"` = a visitor who got in with the project's client password instead. |
26
+ | `kind` | `"monk" \| "external"` | `"monk"` = signed in through OneLogin; `"external"` = someone outside Monks, signed in by email or with the client password. |
27
27
  | `roles` | `string[]` | The project's [app roles](https://docs.canopy.website/guides/roles) this person has: the default role first, then their own. Empty when the project has none. |
28
28
 
29
- `kind: "external"` sessions come from client-password access — clients viewing
30
- a shared project without a Monks account. Branch on it when externals should
31
- see a trimmed-down experience:
29
+ `kind: "external"` is someone outside Monks: a person you
30
+ [invited by email](https://docs.canopy.website/guides/outside-sign-in), who has their own email and an
31
+ `id` that stays the same every time they sign in, or a visitor who got in with
32
+ the project's [client password](https://docs.canopy.website/platform/client-access). Branch on it when
33
+ externals should see a trimmed-down experience:
32
34
 
33
35
  ```ts
34
36
  const user = await canopy.auth.user();
@@ -61,8 +63,8 @@ app.get("/api/me", (c) => {
61
63
  ```
62
64
 
63
65
  `env.CALLER` is `null` only when nobody called, such as during a scheduled
64
- run. `env.USER` is the Monk-only form: the signed-in Monk, or `null` for a
65
- client-password visitor.
66
+ run. `env.USER` is the Monk-only form: the signed-in Monk, or `null` for
67
+ anyone outside Monks.
66
68
 
67
69
  When another project's backend calls yours, `env.CALLER.kind` is `"project"`
68
70
  and it names that project and the visitor it acts for. See
@@ -70,7 +72,8 @@ and it names that project and the visitor it acts for. See
70
72
 
71
73
  A client-password visitor has no email address and is named `"Client"`. Its
72
74
  `id` changes with every password unlock, so don't key data on it that has to
73
- last.
75
+ last. Someone outside Monks who [signed in by email](https://docs.canopy.website/guides/outside-sign-in)
76
+ carries their email, the name they gave, and an `id` that stays the same.
74
77
 
75
78
  This is the place to check app roles, because a visitor can't change what
76
79
  your worker sees:
@@ -79,6 +79,38 @@ const avatars = await canopy.blob.list("avatars/");
79
79
  await canopy.blob.delete("notes.txt");
80
80
  ```
81
81
 
82
+ ## Who can call this from the browser
83
+
84
+ Everything above works from a page as well as from your worker, so an upload
85
+ form needs no backend at all. Once your worker manages files that pages must
86
+ not change, set **Browser access** on the project's **Files** tab in the
87
+ dashboard (or with [`canopy files access`](https://docs.canopy.website/cli/files)):
88
+
89
+ - **Upload and delete** is the default and how every project starts. Pages can
90
+ do everything on this page.
91
+ - **Read only** lets pages list and download files and make download links
92
+ with `getUrl()`. `put()` and `delete()` from a page are refused, so changes
93
+ have to come from the worker.
94
+ - **Off** means pages cannot touch files at all.
95
+
96
+ This is separate from the database's [browser access](https://docs.canopy.website/sdk/database#who-can-call-this-from-the-browser),
97
+ so you can lock one and not the other. Your worker, the CLI and the
98
+ dashboard's Files tab keep full access whatever you pick, and so does plain
99
+ `canopy dev`, where your browser shares the dev server's token.
100
+
101
+ Download links keep working at every level, because the link itself is the
102
+ permission. That makes **Off** workable for files a page should still show:
103
+ the page asks a worker route, the worker decides whether this visitor may see
104
+ the file, and answers with a short-lived link from `getUrl()`.
105
+
106
+ Everyone who opens the app gets the same rule: colleagues signed in with
107
+ OneLogin and, if you turned on [client access](https://docs.canopy.website/platform/client-access),
108
+ visitors with the password. Read only protects your files from being changed,
109
+ not from being seen.
110
+
111
+ A refused call throws a `CanopyError` with status 403, `code`
112
+ `browser_blob_access` and a one-line explanation that names the setting.
113
+
82
114
  ## Example: upload from a file input
83
115
 
84
116
  ```tsx
@@ -39,7 +39,8 @@ await canopy.projects.fetch("asset-library", "/api/assets", {
39
39
  - `path` — a path under its `/api`, with a query string if you need one.
40
40
  Anything else is refused before it is sent.
41
41
  - `init` — optional. The usual fetch options (`method`, `headers`, `body`, …)
42
- plus `channel`: `"live"` (the default) or `"staging"`.
42
+ plus `channel`: `"live"` (the default) or `"staging"`. Pass
43
+ `env.CANOPY_CHANNEL` to call the same channel your backend runs on.
43
44
 
44
45
  **Returns** a `Response`: the other project's answer as it is. It doesn't
45
46
  throw on an error status, so check `res.ok` like any fetch.
@@ -78,6 +78,14 @@ Shared with live: members, secrets, the client password, schedules (they run
78
78
  against live only), and the AI budget — staging traffic counts against the
79
79
  same cap.
80
80
 
81
+ ## Knowing which channel you're on
82
+
83
+ Your backend can tell which channel it runs on: `env.CANOPY_CHANNEL` is
84
+ `"live"` or `"staging"`. Use it for a staging banner, or to keep a staged
85
+ backend away from live data in other projects it calls (see
86
+ [Calling other projects](https://docs.canopy.website/guides/calling-projects)). Under `canopy dev` it is
87
+ `"staging"` with `--staging` and `"live"` otherwise.
88
+
81
89
  ## Developing against staging data
82
90
 
83
91
  Remote dev can point at the staging database instead of live — useful while a
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-Sir3152_.mjs";
1
+ import { t as version } from "./package-4SGn0Cy3.mjs";
2
2
  import { r as siteConfig } from "./site-BL5Ik-yj.mjs";
3
3
  import { i as latestKnownVersion, r as compareSemver } from "./version-check-CcsA1QjI.mjs";
4
4
  import { n as agentHeaders } from "./api-DmJrIsE7.mjs";
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-Sir3152_.mjs";
1
+ import { t as version } from "./package-4SGn0Cy3.mjs";
2
2
  import { c as projectDirArgs, d as resolveProject, h as tryResolveProject, m as tryReadCanopyJson, r as siteConfig } from "./site-BL5Ik-yj.mjs";
3
3
  import { a as apiRequest, c as credentials, i as apiDownload, o as apiUpload, s as commonHeaders } from "./api-DmJrIsE7.mjs";
4
4
  import { r as reportErrors, t as formatDateTime } from "./ui-Ddw4d2Nn.mjs";
@@ -0,0 +1,69 @@
1
+ import { d as resolveProject, l as projectFlagArgs } from "./site-BL5Ik-yj.mjs";
2
+ import { a as apiRequest } from "./api-DmJrIsE7.mjs";
3
+ import { r as reportErrors } from "./ui-Ddw4d2Nn.mjs";
4
+ import { defineCommand } from "citty";
5
+ //#region src/files.ts
6
+ /**
7
+ * `canopy files` — the project's file storage (canopy.blob).
8
+ *
9
+ * access show or set what the app's pages may do with its files
10
+ * (OpenSpec browser-blob-access)
11
+ */
12
+ const BLOB_LEVELS = [
13
+ "full",
14
+ "readonly",
15
+ "off"
16
+ ];
17
+ const LEVEL_MEANING = {
18
+ full: "pages can list, download, upload and delete files",
19
+ readonly: "pages can list and download files and make download links; uploads and deletes are refused",
20
+ off: "pages cannot touch files — only the worker, the CLI and the download links the worker makes can"
21
+ };
22
+ /** The level as a word, or null for anything else (case and spaces forgiven). */
23
+ function parseLevel(raw) {
24
+ const wanted = raw.trim().toLowerCase();
25
+ return BLOB_LEVELS.includes(wanted) ? wanted : null;
26
+ }
27
+ function describeAccess(slug, access) {
28
+ const lines = [`${slug}: browser file access is ${access.level} — ${LEVEL_MEANING[access.level]}.`];
29
+ if (access.clientAccess && access.level !== "off") lines.push("", ` ! Client access is on: visitors who know the password can ${access.level === "full" ? "download, upload and delete" : "download"} these files from their browser.`, " Move writes into the worker and run `canopy files access off` to keep them worker-only.");
30
+ return lines;
31
+ }
32
+ const filesCommand = defineCommand({
33
+ meta: {
34
+ name: "files",
35
+ description: "File storage tools: access"
36
+ },
37
+ subCommands: { access: defineCommand({
38
+ meta: {
39
+ name: "access",
40
+ description: "Show or set what the app's own pages may do with its files (full | readonly | off)"
41
+ },
42
+ args: {
43
+ ...projectFlagArgs,
44
+ level: {
45
+ type: "positional",
46
+ description: "full | readonly | off (omit to show)",
47
+ required: false
48
+ }
49
+ },
50
+ run: reportErrors("files access", async ({ args }) => {
51
+ const { slug } = resolveProject(args);
52
+ const print = (access) => {
53
+ for (const line of describeAccess(slug, access)) console.log(line);
54
+ };
55
+ if (!args.level?.trim()) {
56
+ print(await apiRequest("GET", `/projects/${slug}/blob-access`));
57
+ return;
58
+ }
59
+ const level = parseLevel(args.level);
60
+ if (!level) {
61
+ console.error(`unknown level "${args.level.trim()}" — expected full, readonly or off.`);
62
+ process.exit(1);
63
+ }
64
+ print(await apiRequest("PUT", `/projects/${slug}/blob-access`, { level }));
65
+ })
66
+ }) }
67
+ });
68
+ //#endregion
69
+ export { filesCommand };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "./package-Sir3152_.mjs";
2
+ import { t as version } from "./package-4SGn0Cy3.mjs";
3
3
  import { i as siteHeaderLine, n as setInvocationProfile } from "./site-BL5Ik-yj.mjs";
4
4
  import { a as notifyOfUpdate, o as runRefresh } from "./version-check-CcsA1QjI.mjs";
5
5
  import { defineCommand, runMain } from "citty";
@@ -15,6 +15,7 @@ import { defineCommand, runMain } from "citty";
15
15
  * deploy build & deploy assets (+ worker) [phase 1/2]
16
16
  * token create|list|revoke deploy tokens for CI [phase 2]
17
17
  * db pull|snapshot|restore [phase 2]
18
+ * files access what the app's pages may do with its files
18
19
  * logs [--follow] read the project's worker logs [phase 2]
19
20
  * usage AI spend + storage for a project [phase 1]
20
21
  * ai models the site's AI models and auto/* aliases
@@ -66,12 +67,12 @@ const main = defineCommand({
66
67
  login: () => import("./login-DrMr99-A.mjs").then((m) => m.loginCommand),
67
68
  whoami: () => import("./login-DrMr99-A.mjs").then((m) => m.whoamiCommand),
68
69
  logout: () => import("./login-DrMr99-A.mjs").then((m) => m.logoutCommand),
69
- create: () => import("./projects-Z8ufQIBc.mjs").then((m) => m.createCommand),
70
- init: () => import("./projects-Z8ufQIBc.mjs").then((m) => m.initCommand),
71
- projects: () => import("./projects-Z8ufQIBc.mjs").then((m) => m.projectsCommand),
72
- delete: () => import("./projects-Z8ufQIBc.mjs").then((m) => m.deleteCommand),
70
+ create: () => import("./projects-BEBYhy6k.mjs").then((m) => m.createCommand),
71
+ init: () => import("./projects-BEBYhy6k.mjs").then((m) => m.initCommand),
72
+ projects: () => import("./projects-BEBYhy6k.mjs").then((m) => m.projectsCommand),
73
+ delete: () => import("./projects-BEBYhy6k.mjs").then((m) => m.deleteCommand),
73
74
  rename: () => import("./rename-PIJmdzHk.mjs").then((m) => m.renameCommand),
74
- dev: () => import("./dev-Z3bI5hgh.mjs").then((m) => m.devCommand),
75
+ dev: () => import("./dev-DkaQjBTp.mjs").then((m) => m.devCommand),
75
76
  deploy: () => import("./deploy-D8OZyhH8.mjs").then((m) => m.deployCommand),
76
77
  promote: () => import("./deploy-D8OZyhH8.mjs").then((m) => m.promoteCommand),
77
78
  staging: () => import("./staging-B9sjqvfh.mjs").then((m) => m.stagingCommand),
@@ -84,19 +85,20 @@ const main = defineCommand({
84
85
  roles: () => import("./roles-CXY226VM.mjs").then((m) => m.rolesCommand),
85
86
  members: () => import("./roles-CXY226VM.mjs").then((m) => m.membersCommand),
86
87
  schedule: () => import("./schedule-DJsclUxC.mjs").then((m) => m.scheduleCommand),
87
- feedback: () => import("./feedback-BkrdL92o.mjs").then((m) => m.feedbackCommand),
88
+ feedback: () => import("./feedback-B6tqJ3cd.mjs").then((m) => m.feedbackCommand),
88
89
  db: () => import("./db-D5SXZrp5.mjs").then((m) => m.dbCommand),
90
+ files: () => import("./files-B7toJRlj.mjs").then((m) => m.filesCommand),
89
91
  usage: () => import("./usage-VMT75MZ4.mjs").then((m) => m.usageCommand),
90
92
  ai: () => import("./ai-BjnuSjmw.mjs").then((m) => m.aiCommand),
91
93
  open: () => import("./open-6ev_6m0p.mjs").then((m) => m.openCommand),
92
94
  browse: () => import("./browse-BPLWhoFI.mjs").then((m) => m.browseCommand),
93
- docs: () => import("./docs-Cd6VzYts.mjs").then((m) => m.docsCommand),
94
- skill: () => import("./skill-Bxc5E-wu.mjs").then((m) => m.skillCommand),
95
- upgrade: () => import("./upgrade-DOpeMSWD.mjs").then((m) => m.upgradeCommand),
95
+ docs: () => import("./docs-CLgKBi8H.mjs").then((m) => m.docsCommand),
96
+ skill: () => import("./skill-CY_4eqOD.mjs").then((m) => m.skillCommand),
97
+ upgrade: () => import("./upgrade-Dxzb3e3r.mjs").then((m) => m.upgradeCommand),
96
98
  logs: () => import("./logs-DJWrL6ja.mjs").then((m) => m.logsCommand),
97
- mcp: () => import("./mcp-Bt9Z9kdf.mjs").then((m) => m.mcpCommand),
99
+ mcp: () => import("./mcp-CWtqUFE3.mjs").then((m) => m.mcpCommand),
98
100
  repo: () => import("./repo-CGTFmIWM.mjs").then((m) => m.repoCommand),
99
- template: () => import("./project-template-ChFb7A_H.mjs").then((m) => m.templateCommand),
101
+ template: () => import("./project-template-Dti_Mmnb.mjs").then((m) => m.templateCommand),
100
102
  audience: () => import("./audience-BSvOEbco.mjs").then((m) => m.audienceCommand)
101
103
  }
102
104
  });
@@ -1,6 +1,6 @@
1
1
  import { r as apiDataRequest } from "./api-DmJrIsE7.mjs";
2
- import { a as realtimeRouter, c as META_COLUMNS, l as blobRouter, n as WORKER_ATTEST_HEADER, o as dbRouter, s as hasPrivateNames } from "./src-DzU89gZN.mjs";
3
- import { a as rewriteApiPath } from "./dev-BQ77vmCk.mjs";
2
+ import { a as realtimeRouter, c as META_COLUMNS, l as blobRouter, n as WORKER_ATTEST_HEADER, o as dbRouter, s as hasPrivateNames } from "./src-DbqT3K2l.mjs";
3
+ import { a as rewriteApiPath } from "./dev-DjK3Y8jb.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join, relative, sep } from "node:path";
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-Sir3152_.mjs";
1
+ import { t as version } from "./package-4SGn0Cy3.mjs";
2
2
  import { h as tryResolveProject, p as stagingUrl, r as siteConfig, u as projectUrl } from "./site-BL5Ik-yj.mjs";
3
3
  import { a as apiRequest, f as noticeRenamesOnly, l as currentSlug, t as ApiError } from "./api-DmJrIsE7.mjs";
4
4
  import { t as liveDevServer } from "./dev-server-file-Dk9pk4AR.mjs";
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.7.50";
2
+ var version = "0.7.51";
3
3
  //#endregion
4
4
  export { version as t };
@@ -22,6 +22,7 @@ function describeCopy(copy) {
22
22
  !copy.csp_enabled && "Content-Security-Policy off",
23
23
  copy.allow_framing && "other sites may frame the app",
24
24
  copy.browser_db_access !== "full" && `browser database access: ${copy.browser_db_access}`,
25
+ copy.browser_blob_access && copy.browser_blob_access !== "full" && `browser file access: ${copy.browser_blob_access}`,
25
26
  !copy.feedback_widget && "feedback widget hidden"
26
27
  ].filter(Boolean);
27
28
  if (loosened.length) lines.push(`Page settings: ${loosened.join("; ")}.`);
@@ -0,0 +1,2 @@
1
+ import { a as templateCommand } from "./project-template-Bas1UN2O.mjs";
2
+ export { templateCommand };
@@ -1,7 +1,7 @@
1
1
  import { m as tryReadCanopyJson, r as siteConfig, u as projectUrl } from "./site-BL5Ik-yj.mjs";
2
2
  import { a as apiRequest, m as withContext } from "./api-DmJrIsE7.mjs";
3
3
  import { a as spinner$1, i as requireTty, o as unwrap, r as reportErrors } from "./ui-Ddw4d2Nn.mjs";
4
- import { i as nextSteps, n as describeCopy, r as fetchTemplate, t as TEMPLATE_FIXES } from "./project-template-DHWdVc6E.mjs";
4
+ import { i as nextSteps, n as describeCopy, r as fetchTemplate, t as TEMPLATE_FIXES } from "./project-template-Bas1UN2O.mjs";
5
5
  import { a as offerRepoOnCreate, i as githubOrigin, n as cloneProjectRepo } from "./repo-Dry87b9d.mjs";
6
6
  import { defineCommand } from "citty";
7
7
  import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-Sir3152_.mjs";
1
+ import { t as version } from "./package-4SGn0Cy3.mjs";
2
2
  import { r as reportErrors } from "./ui-Ddw4d2Nn.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { cpSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
@@ -97,6 +97,8 @@ function blobRouter(config) {
97
97
  const { store } = resolved;
98
98
  const key = safeBlobKey(c.req.param("key"));
99
99
  if (!key) return c.json({ error: "invalid_key" }, 400);
100
+ const refused = await config.guard?.(c, "put");
101
+ if (refused) return refused;
100
102
  if (Number(c.req.header("content-length") ?? 0) > MAX_BLOB_BYTES) return c.json({
101
103
  error: "blob_too_large",
102
104
  maxBytes: MAX_BLOB_BYTES
@@ -121,6 +123,8 @@ function blobRouter(config) {
121
123
  const { store } = resolved;
122
124
  const prefix = c.req.query("prefix") ?? "";
123
125
  if (prefix.length > 512 || prefix.includes("\0")) return c.json({ error: "invalid_prefix" }, 400);
126
+ const refused = await config.guard?.(c, "list");
127
+ if (refused) return refused;
124
128
  const base = store.prefix;
125
129
  const objects = [];
126
130
  let cursor;
@@ -146,6 +150,8 @@ function blobRouter(config) {
146
150
  const { slug, store } = resolved;
147
151
  const key = safeBlobKey(c.req.param("key"));
148
152
  if (!key) return c.json({ error: "invalid_key" }, 400);
153
+ const refused = await config.guard?.(c, "url");
154
+ if (refused) return refused;
149
155
  const ttl = requestedTtl(c.req.query("expiresIn"));
150
156
  if (ttl === null) return c.json({
151
157
  error: "invalid_expires_in",
@@ -165,6 +171,8 @@ function blobRouter(config) {
165
171
  const { store } = resolved;
166
172
  const key = safeBlobKey(c.req.param("key"));
167
173
  if (!key) return c.json({ error: "invalid_key" }, 400);
174
+ const refused = await config.guard?.(c, "get");
175
+ if (refused) return refused;
168
176
  const object = await store.bucket.get(store.prefix + key);
169
177
  if (!object) return c.json({ error: "not_found" }, 404);
170
178
  return new Response(object.body, { headers: {
@@ -178,6 +186,8 @@ function blobRouter(config) {
178
186
  const { store } = resolved;
179
187
  const key = safeBlobKey(c.req.param("key"));
180
188
  if (!key) return c.json({ error: "invalid_key" }, 400);
189
+ const refused = await config.guard?.(c, "delete");
190
+ if (refused) return refused;
181
191
  const fullKey = store.prefix + key;
182
192
  const existed = await store.bucket.head(fullKey) !== null;
183
193
  await store.bucket.delete(fullKey);
@@ -873,11 +883,16 @@ const AGENT_CREDENTIAL_HEADER = "x-canopy-agent-credential";
873
883
  * only the gateway may set it — it strips client copies on every dispatch.
874
884
  */
875
885
  const CALLER_HEADER = "x-canopy-caller";
876
- /** Cookies that authenticate to Canopy itself — the monk session and the client-page session. */
886
+ /**
887
+ * Cookies that authenticate to Canopy itself — the monk session, the
888
+ * client-page session, an agent's browse session and an outside account's
889
+ * session (outside-sign-in).
890
+ */
877
891
  const CANOPY_COOKIE_NAMES = /* @__PURE__ */ new Set([
878
892
  "canopy_session",
879
893
  "canopy_client",
880
- "canopy_agent"
894
+ "canopy_agent",
895
+ "canopy_outside_session"
881
896
  ]);
882
897
  /**
883
898
  * Strip Canopy's own credentials from a request before untrusted project code
@@ -891,7 +906,8 @@ const CANOPY_COOKIE_NAMES = /* @__PURE__ */ new Set([
891
906
  *
892
907
  * Redaction is surgical on purpose: an app's own cookies and its own
893
908
  * Authorization scheme survive, because those belong to the app. Only
894
- * `canopy_session` / `canopy_client` / `canopy_agent` and a `cnpy_` bearer are removed.
909
+ * `canopy_session` / `canopy_client` / `canopy_agent` / `canopy_outside_session` and a
910
+ * `cnpy_` bearer are removed.
895
911
  *
896
912
  * `env.CANOPY.fetch` still authenticates as the visitor — the host passes it
897
913
  * the unredacted headers — so nothing about the platform-facing behaviour
@@ -1089,7 +1105,12 @@ function isControlPlanePath(raw) {
1089
1105
  }
1090
1106
 
1091
1107
  // Canopy's own cookies — platform credentials, never tenant-readable (R-01).
1092
- const CANOPY_COOKIE_NAMES = ["canopy_session", "canopy_client", "canopy_agent"];
1108
+ const CANOPY_COOKIE_NAMES = [
1109
+ "canopy_session",
1110
+ "canopy_client",
1111
+ "canopy_agent",
1112
+ "canopy_outside_session",
1113
+ ];
1093
1114
 
1094
1115
  // Strip Canopy's credentials from the request the bundle gets — a
1095
1116
  // transcription of redactCanopyCredentials in @mediamonks/canopy-data-plane,
@@ -21,6 +21,10 @@ interface Env {
21
21
  USER: { sub: string; email: string; name: string } | null;
22
22
  // This project's slug.
23
23
  PROJECT_SLUG: string;
24
+ // Which channel this backend serves: "live", or "staging" for a
25
+ // `canopy deploy --staging` copy. Pass it as projects.fetch's `channel` to
26
+ // keep a staged backend off other projects' live data.
27
+ CANOPY_CHANNEL: "live" | "staging";
24
28
  // Raw handles, below the SDK, if you ever need them:
25
29
  // DB — this project's database: `dialect` plus
26
30
  // `query(text, params) => { rows, rowCount }`
@@ -112,7 +112,7 @@ const upgradeCommand = defineCommand({
112
112
  const spec = `${PACKAGE_NAME}@${args.version ?? "latest"}`;
113
113
  const command = pmCommand(pm);
114
114
  const cmd = installArgs(pm, spec);
115
- const { skillInstalled } = await import("./skill-Bxc5E-wu.mjs");
115
+ const { skillInstalled } = await import("./skill-CY_4eqOD.mjs");
116
116
  const { homedir } = await import("node:os");
117
117
  const refreshGlobal = skillInstalled(homedir());
118
118
  const refreshRepo = process.cwd() !== homedir() && skillInstalled(process.cwd());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediamonks/canopy-cli",
3
- "version": "0.7.50",
3
+ "version": "0.7.51",
4
4
  "description": "Canopy CLI — create, develop and deploy Canopy projects.",
5
5
  "bin": {
6
6
  "canopy": "./dist/index.mjs"
@@ -1,2 +0,0 @@
1
- import { n as devCommand } from "./dev-BQ77vmCk.mjs";
2
- export { devCommand };
@@ -1,2 +0,0 @@
1
- import { a as templateCommand } from "./project-template-DHWdVc6E.mjs";
2
- export { templateCommand };