@mediamonks/canopy-cli 0.7.47 → 0.7.48

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.
@@ -0,0 +1,101 @@
1
+ import { c as projectDirArgs, d as resolveProject } from "./site-BL5Ik-yj.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-DmJrIsE7.mjs";
3
+ import { r as reportErrors, t as formatDateTime } from "./ui-26ETk1n8.mjs";
4
+ import { defineCommand } from "citty";
5
+ //#region src/calls.ts
6
+ /**
7
+ * canopy calls — which other projects may call this project's backend
8
+ * (OpenSpec project-calls). A granted project's backend reaches this one's
9
+ * `/api` with `canopy.projects.fetch`, for every visitor and scheduled run it
10
+ * has; this project's own code then sees it as `env.CALLER.kind === "project"`
11
+ * and decides what it may do. Only the owner (or a platform admin) changes the
12
+ * list; owners, managers and editors can read it.
13
+ */
14
+ const FIXES = {
15
+ owner_only: "Only the project owner can decide which projects may call its backend — ask them to run this command or change it in the dashboard.",
16
+ unknown_project: "No project with that slug on this site (see `canopy projects`).",
17
+ invalid_caller: "A project can always call itself; it needs no grant."
18
+ };
19
+ function printGrants(grants, slug) {
20
+ if (grants.length === 0) {
21
+ console.log(`No other project may call ${slug}'s backend.`);
22
+ console.log("Allow one with `canopy calls allow <project>`.");
23
+ return;
24
+ }
25
+ console.log(`Projects that may call ${slug}'s backend:`);
26
+ for (const g of grants) {
27
+ const owner = g.owner ? `, owned by ${g.owner.name || g.owner.email}` : "";
28
+ const by = g.created_by ? ` by ${g.created_by.name}` : "";
29
+ console.log(` ${g.caller} (${g.name}${owner}) — allowed${by} ${formatDateTime(g.created_at)}`);
30
+ }
31
+ }
32
+ const callsCommand = defineCommand({
33
+ meta: {
34
+ name: "calls",
35
+ description: "Manage which other projects may call this project's backend"
36
+ },
37
+ subCommands: {
38
+ list: defineCommand({
39
+ meta: {
40
+ name: "list",
41
+ description: "List the projects allowed to call this backend"
42
+ },
43
+ args: { ...projectDirArgs },
44
+ run: reportErrors("calls list", async ({ args }) => {
45
+ const { slug } = resolveProject(args);
46
+ const { grants } = await apiRequest("GET", `/projects/${slug}/calls`);
47
+ printGrants(grants, slug);
48
+ })
49
+ }),
50
+ allow: defineCommand({
51
+ meta: {
52
+ name: "allow",
53
+ description: "Let another project's backend call this project's /api (owner only)"
54
+ },
55
+ args: {
56
+ caller: {
57
+ type: "positional",
58
+ description: "The calling project's slug",
59
+ required: true
60
+ },
61
+ ...projectDirArgs
62
+ },
63
+ run: reportErrors("calls allow", async ({ args }) => {
64
+ const { slug } = resolveProject(args);
65
+ const { caller } = await withContext(apiRequest("PUT", `/projects/${slug}/calls/${encodeURIComponent(args.caller)}`), {
66
+ action: `allow ${args.caller} to call ${slug}`,
67
+ fixes: FIXES
68
+ });
69
+ console.log(`${caller} may now call ${slug}'s backend, for any of its visitors and schedules.`);
70
+ console.log(`Your code sees those calls as env.CALLER.kind === "project" and decides what each may do.`);
71
+ })
72
+ }),
73
+ remove: defineCommand({
74
+ meta: {
75
+ name: "remove",
76
+ description: "Stop another project from calling this backend (owner only)"
77
+ },
78
+ args: {
79
+ caller: {
80
+ type: "positional",
81
+ description: "The calling project's slug",
82
+ required: true
83
+ },
84
+ ...projectDirArgs
85
+ },
86
+ run: reportErrors("calls remove", async ({ args }) => {
87
+ const { slug } = resolveProject(args);
88
+ const { caller } = await withContext(apiRequest("DELETE", `/projects/${slug}/calls/${encodeURIComponent(args.caller)}`), {
89
+ action: `stop ${args.caller} calling ${slug}`,
90
+ fixes: {
91
+ ...FIXES,
92
+ not_found: `${args.caller} was not allowed to call ${slug}.`
93
+ }
94
+ });
95
+ console.log(`${caller} can no longer call ${slug}'s backend. A call already under way may finish within five minutes.`);
96
+ })
97
+ })
98
+ }
99
+ });
100
+ //#endregion
101
+ export { callsCommand };
@@ -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-26ETk1n8.mjs";
4
4
  import { r as readMigrationFiles } from "./migrations-BReMlGWP.mjs";
5
- import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER } from "./src-8vxOBOxW.mjs";
5
+ import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER } from "./src-DzU89gZN.mjs";
6
6
  import { a as parseAppRoleFlag } from "./roles-S2D9Id0W.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-CcYwQjxz.mjs");
110
+ const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-BP-HGHYb.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-C9Bi9f3y.mjs");
328
+ const { fetchProjectDump } = await import("./local-DRcoiNcy.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-C9Bi9f3y.mjs");
345
+ const { createSandbox } = await import("./local-DRcoiNcy.mjs");
346
346
  const sandbox = await createSandbox({
347
347
  slug,
348
348
  persistDir: join(flags.dir, ".canopy", "local"),
@@ -385,7 +385,8 @@ async function devLocal(flags, slug) {
385
385
  ...remoteEntry && {
386
386
  "/_api/data/v1/ai": remoteEntry,
387
387
  "/_api/data/v1/services": remoteEntry,
388
- "/_api/data/v1/google": remoteEntry
388
+ "/_api/data/v1/google": remoteEntry,
389
+ "/_api/data/v1/calls": remoteEntry
389
390
  },
390
391
  "/_api": {
391
392
  target: `http://127.0.0.1:${apiAddress.port}`,
@@ -1,4 +1,4 @@
1
- import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER, r as redactCanopyCredentials, t as CALLER_HEADER } from "./src-8vxOBOxW.mjs";
1
+ import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER, r as redactCanopyCredentials, t as CALLER_HEADER } from "./src-DzU89gZN.mjs";
2
2
  import { readFileSync } from "node:fs";
3
3
  import { relative, resolve, sep } from "node:path";
4
4
  //#region src/dev-worker.ts
@@ -0,0 +1,2 @@
1
+ import { n as devCommand } from "./dev-BE48xClT.mjs";
2
+ export { devCommand };
@@ -0,0 +1,99 @@
1
+ ---
2
+ title: Calling another project
3
+ description: Let one project's backend call another project's API, and tell who is calling.
4
+ ---
5
+
6
+ Sometimes two projects belong together without being one project: an asset
7
+ library that several campaign sites read from, or a shared service that a few
8
+ tools use. One project's backend can call another project's API. The owner of
9
+ the project being called decides who may, and its code sees who did.
10
+
11
+ There are no keys or tokens to manage. Canopy proves who is calling on every
12
+ call.
13
+
14
+ ## 1. Allow the calling project
15
+
16
+ In the project that will be called (say `asset-library`), its owner allows
17
+ the project that will call it:
18
+
19
+ ```bash
20
+ canopy calls allow campaign-site
21
+ ```
22
+
23
+ Or use **Incoming calls** on the project's Backend tab. Only the owner can
24
+ change this list; managers and editors can see it.
25
+
26
+ One allow covers both channels of each project and every path under `/api`.
27
+ It also covers every visitor of the calling project and its scheduled runs,
28
+ so your backend decides what each caller may see (step 3).
29
+
30
+ A project can always call itself without being allowed.
31
+
32
+ ## 2. Make the call
33
+
34
+ In the calling project's backend:
35
+
36
+ ```ts
37
+ import { createCanopy } from "@mediamonks/canopy";
38
+
39
+ const canopy = createCanopy({ fetch: env.CANOPY.fetch.bind(env.CANOPY) });
40
+
41
+ const res = await canopy.projects.fetch("asset-library", "/api/assets?tag=summer");
42
+ if (!res.ok) throw new Error(`asset-library said ${res.status}`);
43
+ const assets = await res.json();
44
+ ```
45
+
46
+ `projects.fetch` works like `fetch`: pass a method, headers and a body as
47
+ usual. It calls the live channel unless you pass `{ channel: "staging" }`.
48
+ The other project needs no entry on your [outbound hosts](https://docs.canopy.website/platform/egress).
49
+
50
+ You get the other project's response back as it is. When Canopy refuses the
51
+ call, you get a JSON error instead:
52
+
53
+ | Error | What happened |
54
+ | --------------------- | ----------------------------------------------------------------- |
55
+ | `call_not_granted` | That project hasn't allowed yours, or there is no such project. |
56
+ | `invalid_call_path` | The path isn't under `/api`. Calls never reach a project's pages. |
57
+ | `call_depth_exceeded` | Projects called each other more than four times in a row. |
58
+ | `no_backend` | That project has no backend on that channel. |
59
+
60
+ Calls only work from backend code, and from `canopy dev`, where they go to the
61
+ deployed project as your project.
62
+
63
+ ## 3. See who called
64
+
65
+ In the project being called, `env.CALLER` tells you a call came from another
66
+ project:
67
+
68
+ ```ts
69
+ import type { CanopyCaller, CanopyProjectCaller } from "@mediamonks/canopy";
70
+
71
+ app.get("/api/assets", (c) => {
72
+ const caller = c.env.CALLER as CanopyCaller | CanopyProjectCaller | null;
73
+ if (caller?.kind === "project") {
74
+ // caller.project: "campaign-site", caller.channel: "live"
75
+ // caller.actingFor: the visitor behind the call, or null for a scheduled run
76
+ }
77
+ // …
78
+ });
79
+ ```
80
+
81
+ - `project` and `name` are the calling project; `channel` is which of its
82
+ channels called.
83
+ - `actingFor` is the person whose visit caused the call, with their
84
+ [app roles](https://docs.canopy.website/guides/roles) on _your_ project. They don't need to be a member
85
+ of it. It is `null` when nobody was behind the call, such as a scheduled run.
86
+ - `env.USER` is `null` on these calls, and your backend's own `canopy.db` and
87
+ other calls act as your project.
88
+
89
+ If your project calls another one while handling a call, that next project
90
+ sees your project, acting for nobody.
91
+
92
+ ## Taking it back
93
+
94
+ ```bash
95
+ canopy calls remove campaign-site
96
+ ```
97
+
98
+ New calls are refused within a few seconds. A call that had already started
99
+ may still finish within five minutes.
@@ -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": "calling-projects",
62
+ "title": "Calling another project",
63
+ "summary": "Let one project's backend call another project's API, and tell who is calling."
64
+ },
60
65
  {
61
66
  "slug": "data",
62
67
  "title": "Working with project data",
@@ -64,6 +64,10 @@ app.get("/api/me", (c) => {
64
64
  run. `env.USER` is the Monk-only form: the signed-in Monk, or `null` for a
65
65
  client-password visitor.
66
66
 
67
+ When another project's backend calls yours, `env.CALLER.kind` is `"project"`
68
+ and it names that project and the visitor it acts for. See
69
+ [Calling another project](https://docs.canopy.website/guides/calling-projects).
70
+
67
71
  A client-password visitor has no email address and is named `"Client"`. Its
68
72
  `id` changes with every password unlock, so don't key data on it that has to
69
73
  last.
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-BksVeJZB.mjs";
1
+ import { t as version } from "./package-Df9caKjj.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-BksVeJZB.mjs";
1
+ import { t as version } from "./package-Df9caKjj.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-26ETk1n8.mjs";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "./package-BksVeJZB.mjs";
2
+ import { t as version } from "./package-Df9caKjj.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";
@@ -71,7 +71,7 @@ const main = defineCommand({
71
71
  projects: () => import("./projects-CnU3194_.mjs").then((m) => m.projectsCommand),
72
72
  delete: () => import("./projects-CnU3194_.mjs").then((m) => m.deleteCommand),
73
73
  rename: () => import("./rename-BWvERJgA.mjs").then((m) => m.renameCommand),
74
- dev: () => import("./dev-BvVlq9np.mjs").then((m) => m.devCommand),
74
+ dev: () => import("./dev-z2KvqkF9.mjs").then((m) => m.devCommand),
75
75
  deploy: () => import("./deploy-BnRQusjJ.mjs").then((m) => m.deployCommand),
76
76
  promote: () => import("./deploy-BnRQusjJ.mjs").then((m) => m.promoteCommand),
77
77
  staging: () => import("./staging-Dn8kH9cK.mjs").then((m) => m.stagingCommand),
@@ -79,21 +79,22 @@ const main = defineCommand({
79
79
  download: () => import("./deploy-BnRQusjJ.mjs").then((m) => m.downloadCommand),
80
80
  token: () => import("./token-DMCj88A-.mjs").then((m) => m.tokenCommand),
81
81
  egress: () => import("./egress-BM4EpLBh.mjs").then((m) => m.egressCommand),
82
+ calls: () => import("./calls-DhkVJ32C.mjs").then((m) => m.callsCommand),
82
83
  secrets: () => import("./secrets-BIn2RPoe.mjs").then((m) => m.secretsCommand),
83
84
  roles: () => import("./roles-CrYf_8wk.mjs").then((m) => m.rolesCommand),
84
85
  members: () => import("./roles-CrYf_8wk.mjs").then((m) => m.membersCommand),
85
86
  schedule: () => import("./schedule-DvHSSzfR.mjs").then((m) => m.scheduleCommand),
86
- feedback: () => import("./feedback-C6kiYRro.mjs").then((m) => m.feedbackCommand),
87
+ feedback: () => import("./feedback-CAM-DJH9.mjs").then((m) => m.feedbackCommand),
87
88
  db: () => import("./db-DpCMc0uz.mjs").then((m) => m.dbCommand),
88
89
  usage: () => import("./usage-Bpz5B1N1.mjs").then((m) => m.usageCommand),
89
90
  ai: () => import("./ai-CWPQiUft.mjs").then((m) => m.aiCommand),
90
91
  open: () => import("./open-DcQSdfx5.mjs").then((m) => m.openCommand),
91
92
  browse: () => import("./browse-BPLWhoFI.mjs").then((m) => m.browseCommand),
92
- docs: () => import("./docs-D5gmZRJk.mjs").then((m) => m.docsCommand),
93
- skill: () => import("./skill-Bz39NhTN.mjs").then((m) => m.skillCommand),
94
- upgrade: () => import("./upgrade-BjDaghNf.mjs").then((m) => m.upgradeCommand),
93
+ docs: () => import("./docs-BZquSJej.mjs").then((m) => m.docsCommand),
94
+ skill: () => import("./skill-BtL5ANQO.mjs").then((m) => m.skillCommand),
95
+ upgrade: () => import("./upgrade-DrEk3nqk.mjs").then((m) => m.upgradeCommand),
95
96
  logs: () => import("./logs-dZMPTJLu.mjs").then((m) => m.logsCommand),
96
- mcp: () => import("./mcp-DuCxfb85.mjs").then((m) => m.mcpCommand),
97
+ mcp: () => import("./mcp-q9wWZ2yk.mjs").then((m) => m.mcpCommand),
97
98
  repo: () => import("./repo-C7AXDtFZ.mjs").then((m) => m.repoCommand),
98
99
  template: () => import("./project-template-Dw11151p.mjs").then((m) => m.templateCommand),
99
100
  audience: () => import("./audience-B68YZBGy.mjs").then((m) => m.audienceCommand)
@@ -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-8vxOBOxW.mjs";
3
- import { a as rewriteApiPath } from "./dev-BmKeIdMi.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-BE48xClT.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-BksVeJZB.mjs";
1
+ import { t as version } from "./package-Df9caKjj.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.47";
2
+ var version = "0.7.48";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-BksVeJZB.mjs";
1
+ import { t as version } from "./package-Df9caKjj.mjs";
2
2
  import { r as reportErrors } from "./ui-26ETk1n8.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { cpSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
@@ -835,23 +835,6 @@ function realtimeRouter(config) {
835
835
  }
836
836
  //#endregion
837
837
  //#region ../data-plane/src/worker-request.ts
838
- /**
839
- * How a project's backend addresses the platform — the one definition.
840
- *
841
- * Three hosts run project workers and each builds this request itself: the
842
- * Workers-for-Platforms shim (packages/data-plane/src/worker-shim.ts), the Node
843
- * runtime (apps/project-runtime/src/canopy-fetch.ts), and `canopy dev`
844
- * (packages/cli/src/dev-worker.ts). They had three copies of the header
845
- * shaping, and the two that hold a worker token had two copies of the
846
- * credential rule — which is exactly how the Google project grant came to
847
- * work on one target and not the other.
848
- *
849
- * The shim cannot import this: it ships as a standalone module uploaded
850
- * beside the user bundle, so it may only import `./bundle.mjs`. It keeps a
851
- * transcription, and `wfp-shim.test.ts` runs it against the table in
852
- * `worker-request.cases.ts` alongside this implementation, so the two cannot
853
- * drift silently.
854
- */
855
838
  /** Gateway-stamped identity, for the worker's own `env.USER` / `env.CALLER` — never relayed. */
856
839
  const IDENTITY_STAMP_HEADERS = [
857
840
  "x-canopy-user-sub",
@@ -861,7 +844,15 @@ const IDENTITY_STAMP_HEADERS = [
861
844
  "x-canopy-identity-id",
862
845
  "x-canopy-identity-email",
863
846
  "x-canopy-identity-name",
864
- "x-canopy-identity-roles"
847
+ "x-canopy-identity-roles",
848
+ "x-canopy-identity-project",
849
+ "x-canopy-identity-channel",
850
+ "x-canopy-acting-kind",
851
+ "x-canopy-acting-id",
852
+ "x-canopy-acting-email",
853
+ "x-canopy-acting-name",
854
+ "x-canopy-acting-agent",
855
+ "x-canopy-acting-roles"
865
856
  ];
866
857
  /**
867
858
  * Header carrying the project's worker token as runtime-origin proof (docs/35).
@@ -962,6 +953,14 @@ const IDENTITY_STAMP_HEADERS = [
962
953
  "x-canopy-identity-email",
963
954
  "x-canopy-identity-name",
964
955
  "x-canopy-identity-roles",
956
+ "x-canopy-identity-project",
957
+ "x-canopy-identity-channel",
958
+ "x-canopy-acting-kind",
959
+ "x-canopy-acting-id",
960
+ "x-canopy-acting-email",
961
+ "x-canopy-acting-name",
962
+ "x-canopy-acting-agent",
963
+ "x-canopy-acting-roles",
965
964
  ];
966
965
 
967
966
  // App roles (project-roles) — transcribed from rolesFromHeaders in
@@ -991,9 +990,45 @@ function userFromHeaders(headers) {
991
990
  // env.CALLER (worker-caller-identity) — transcribed from
992
991
  // project-runtime/src/user.ts: everyone the wall let through, client-password
993
992
  // visitors included, from headers older shims never read.
993
+ // A call from another project (project-calls) — transcribed from
994
+ // projectCallerFromHeaders in project-runtime/src/user.ts.
995
+ function projectCallerFromHeaders(headers, id) {
996
+ const project = (headers.get("x-canopy-identity-project") || "").trim();
997
+ const channel = (headers.get("x-canopy-identity-channel") || "").trim();
998
+ if (!project || (channel !== "live" && channel !== "staging")) return null;
999
+ const actingKind = (headers.get("x-canopy-acting-kind") || "").trim();
1000
+ const actingId = (headers.get("x-canopy-acting-id") || "").trim();
1001
+ const actingFor =
1002
+ (actingKind === "monk" || actingKind === "external") && actingId
1003
+ ? {
1004
+ kind: actingKind,
1005
+ id: actingId,
1006
+ email: (headers.get("x-canopy-acting-email") || "").trim(),
1007
+ name: (headers.get("x-canopy-acting-name") || "").trim(),
1008
+ agent: headers.get("x-canopy-acting-agent") === "1",
1009
+ roles: (headers.get("x-canopy-acting-roles") || "")
1010
+ .split(",")
1011
+ .map((r) => r.trim())
1012
+ .filter(Boolean),
1013
+ }
1014
+ : null;
1015
+ return {
1016
+ kind: "project",
1017
+ id,
1018
+ project,
1019
+ channel,
1020
+ name: (headers.get("x-canopy-identity-name") || "").trim() || project,
1021
+ email: "",
1022
+ agent: false,
1023
+ roles: [],
1024
+ actingFor,
1025
+ };
1026
+ }
1027
+
994
1028
  function callerFromHeaders(headers) {
995
1029
  const kind = (headers.get("x-canopy-identity-kind") || "").trim();
996
1030
  const id = (headers.get("x-canopy-identity-id") || "").trim();
1031
+ if (kind === "project" && id) return projectCallerFromHeaders(headers, id);
997
1032
  if ((kind !== "monk" && kind !== "external") || !id) return null;
998
1033
  const roles = rolesFromHeaders(headers);
999
1034
  return {
@@ -1130,6 +1165,10 @@ function createCanopyFetch(apiUrl, inboundHeaders, upstream) {
1130
1165
  const traceparent = inboundHeaders.get("traceparent");
1131
1166
  if (traceparent) headers.set("traceparent", traceparent);
1132
1167
  else headers.delete("traceparent");
1168
+ // Call depth (project-calls): from the request that woke the worker only.
1169
+ const callDepth = inboundHeaders.get("x-canopy-call-depth");
1170
+ if (callDepth) headers.set("x-canopy-call-depth", callDepth);
1171
+ else headers.delete("x-canopy-call-depth");
1133
1172
 
1134
1173
  const method = (input instanceof Request ? input.method : init && init.method) || "GET";
1135
1174
  const body = input instanceof Request ? input.body : init && init.body;
@@ -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-Bz39NhTN.mjs");
115
+ const { skillInstalled } = await import("./skill-BtL5ANQO.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.47",
3
+ "version": "0.7.48",
4
4
  "description": "Canopy CLI — create, develop and deploy Canopy projects.",
5
5
  "bin": {
6
6
  "canopy": "./dist/index.mjs"
@@ -22,8 +22,8 @@
22
22
  "esbuild": "^0.28.1",
23
23
  "hono": "^4.8.0",
24
24
  "vite-server": "npm:vite@^7",
25
- "@mediamonks/canopy": "0.0.13",
26
- "@mediamonks/canopy-data-plane": "0.0.4"
25
+ "@mediamonks/canopy-data-plane": "0.0.4",
26
+ "@mediamonks/canopy": "0.0.14"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^26.1.1",
@@ -1,2 +0,0 @@
1
- import { n as devCommand } from "./dev-BmKeIdMi.mjs";
2
- export { devCommand };