permdock 0.11.0 → 0.14.0

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 (84) hide show
  1. package/dist/a2a/index.js +1 -1
  2. package/dist/{adoption-scan-DKCOsfcF.js → adoption-scan-BGtwGfoH.js} +1 -1
  3. package/dist/agent/index.js +1 -1
  4. package/dist/ai-sdk/index.js +2 -2
  5. package/dist/{arazzo-CTH5iN--.js → arazzo-9uhbmKf5.js} +1 -1
  6. package/dist/{arazzo-BXaEhGHM.js → arazzo-Bol9OgF-.js} +1 -1
  7. package/dist/better-supabase/index.d.ts +19 -17
  8. package/dist/better-supabase/index.js +31 -16
  9. package/dist/better-supabase-83Gsetrv.js +56 -0
  10. package/dist/{casbin-BuTZnSPv.js → casbin-1PVgMHOR.js} +1 -1
  11. package/dist/{casbin-DTi6HSsl.js → casbin-CBXD5rFx.js} +1 -1
  12. package/dist/claude-agent/index.js +1 -1
  13. package/dist/cli/bin.js +1 -1
  14. package/dist/cli/index.js +2 -2
  15. package/dist/{cloud-DiAiYFRo.js → cloud-BfJVKpcN.js} +1 -1
  16. package/dist/{codemod-C1U8_Zu3.js → codemod-BXLd4K3j.js} +1 -1
  17. package/dist/{codemod-_q_ZI01S.js → codemod-DWfH-KHk.js} +2 -2
  18. package/dist/{collect-D9Tt0Bcx.js → collect-lZgCKMe_.js} +1 -1
  19. package/dist/{completion-DLTuCf53.js → completion-fJ19i8Jk.js} +1 -1
  20. package/dist/{config-CmydKZr2.js → config-BYSk3iKV.js} +1 -1
  21. package/dist/{config-BR23fL8m.js → config-ZZdtyQZy.js} +4 -1
  22. package/dist/{config-report-5AwptLr2.js → config-report-BpztJ3HP.js} +1 -1
  23. package/dist/{create-6EwRQlig.js → create-Coq5fIrq.js} +1 -1
  24. package/dist/{diff-BwR1JdP2.js → diff-CxtbOi2l.js} +1 -1
  25. package/dist/{diff-CQegtBAo.js → diff-DfmYaIhB.js} +1 -1
  26. package/dist/{doctor-DxyVeUEE.js → doctor-NxCr_hba.js} +2 -2
  27. package/dist/{doctor-ktitU5Dl.js → doctor-eNc7A_7I.js} +13 -47
  28. package/dist/eve/index.js +1 -1
  29. package/dist/{fixtures-A1_sp_tR.js → fixtures-Bm4_K1ke.js} +7 -9
  30. package/dist/{import-t1yqnCyG.js → import-efm6qPgx.js} +1 -1
  31. package/dist/{init-CY7THM2v.js → init-BtWY1L0J.js} +3 -3
  32. package/dist/{init-DFwylmiN.js → init-D6rpLPwM.js} +1 -1
  33. package/dist/{kernel-qv4cr9w8.js → kernel-BD8QuMnv.js} +9 -2
  34. package/dist/{login-C5XLYZSF.js → login-B8s6VI8Z.js} +3 -3
  35. package/dist/{login-B92-dZMK.js → login-cLflB63Z.js} +1 -1
  36. package/dist/{manifest-Cav1rjNQ.js → manifest-BWIR_EEB.js} +33 -33
  37. package/dist/mcp/index.d.ts +12 -3
  38. package/dist/mcp/index.js +60 -16
  39. package/dist/next/plugin.js +1 -1
  40. package/dist/openai/index.js +2 -2
  41. package/dist/{openapi-gMQQSzNn.js → openapi-CT55v3WD.js} +2 -2
  42. package/dist/{openapi-CuePQL4z.js → openapi-DDENzRbG.js} +1 -1
  43. package/dist/{output-CtyBwTNB.js → output-3iB3_Hfg.js} +1 -1
  44. package/dist/{powersync-CBcsEvdr.js → powersync-COjQTHRD.js} +2 -2
  45. package/dist/{powersync-CD8-Ypao.js → powersync-DVbskWD9.js} +126 -39
  46. package/dist/powersync-k8lUeC37.js +1 -0
  47. package/dist/pull-BY1METGf.js +1 -0
  48. package/dist/{pull-CAeaAioC.js → pull-Er4aBHlL.js} +1 -1
  49. package/dist/react-native/index.d.ts +7 -7
  50. package/dist/react-native/index.js +57 -16
  51. package/dist/{rls-CtRaRrn3.js → rls-DY3Fc18U.js} +30 -15
  52. package/dist/{rls-BYHN5bcJ.js → rls-DjjOHlKE.js} +1 -1
  53. package/dist/{run-B5nyNKe8.js → run-BlxXmaDS.js} +3 -3
  54. package/dist/run-DGSLvGty.js +1 -0
  55. package/dist/{scan-CvFWW_fU.js → scan-CR_xm71k.js} +1 -1
  56. package/dist/{schema-CQzIJdEd.js → schema-CnrIP94n.js} +1 -1
  57. package/dist/{skills-Bar7ZqwM.js → skills-CY-MY_Oj.js} +1 -1
  58. package/dist/{skills-BZc81VLt.js → skills-uzsVqEi9.js} +1 -1
  59. package/dist/supabase/index.js +1 -1
  60. package/dist/{supabase-CBEK6KEo.js → supabase-DYWnT800.js} +2 -2
  61. package/dist/{supabase-hook-CyuD9Wau.js → supabase-hook-HPgwYb9V.js} +2 -2
  62. package/dist/supabase-hook-qsewAVZY.js +1 -0
  63. package/dist/{supautils-C-_jqylY.js → supautils-DZ95xxW-.js} +3 -3
  64. package/dist/testing/core.js +1 -1
  65. package/dist/testing/fixtures/index.js +1 -1
  66. package/dist/testing/index.js +2 -2
  67. package/dist/unplugin/index.js +1 -1
  68. package/dist/usage-CH7oISI6.js +1 -0
  69. package/dist/{usage-heV5KOiU.js → usage-Dm2hn0pS.js} +1 -1
  70. package/dist/{usage-Y6xZUfE-.js → usage-WYRc7Kqg.js} +2 -2
  71. package/dist/{verify-6EauWrkP.js → verify-CHQgLrtS.js} +3 -3
  72. package/dist/watch-C44FtM79.js +1 -0
  73. package/dist/{watch-Bpci3hBY.js → watch-CTfSlIGD.js} +1 -1
  74. package/package.json +16 -16
  75. package/skills/permdock-credentials/references/tokens-keys-links.md +1 -1
  76. package/skills/permdock-wire/references/adapters.md +1 -1
  77. package/dist/powersync-6vgKevSi.js +0 -1
  78. package/dist/pull-DfJALUbS.js +0 -1
  79. package/dist/run-0vOholnN.js +0 -1
  80. package/dist/supabase-hook-CWvEpdCh.js +0 -1
  81. package/dist/usage-CNca1i1W.js +0 -1
  82. package/dist/watch-COuvly20.js +0 -1
  83. package/dist/{core-DzVINFbU.js → core-lxoANyai.js} +1 -1
  84. package/dist/{supabase-CC6rIri4.js → supabase-CDHMsDD0.js} +1 -1
@@ -5,12 +5,14 @@ import { a as loadModule, s as pickNamed } from "./load-DjSU5KXO.js";
5
5
  import { existsSync } from "node:fs";
6
6
  import { resolve } from "node:path";
7
7
  //#region src/cli/fixtures.ts
8
- function asFixtures(value) {
8
+ function asFixtures(value, followed = false) {
9
9
  const list = Array.isArray(value) ? value : isRecord(value) && Array.isArray(value["fixtures"]) ? value["fixtures"] : void 0;
10
10
  if (list === void 0) throw configError("PermDock CLI: fixtures must be an array or { fixtures }");
11
11
  return list.map((item, index) => {
12
12
  if (!isRecord(item) || !isRecord(item["subject"]) || item["row"] === void 0) throw configError(`PermDock CLI: fixture ${index} needs subject and row`);
13
- if (typeof item["action"] !== "string") throw new TypeError(`PermDock CLI: fixture ${index} needs action`);
13
+ if (followed && item["table"] !== void 0) {
14
+ if (typeof item["table"] !== "string" || item["table"].length === 0 || item["action"] !== void 0 || item["expected"] !== "granted" && item["expected"] !== "denied") throw configError(`PermDock CLI: fixture ${index} needs table and expected (granted or denied), without action`);
15
+ } else if (typeof item["action"] !== "string") throw new TypeError(`PermDock CLI: fixture ${index} needs action`);
14
16
  if (typeof item["subject"]["id"] !== "string") throw new TypeError(`PermDock CLI: fixture ${index} subject needs id`);
15
17
  const memberships = item["subject"]["memberships"];
16
18
  if (memberships !== void 0 && !Array.isArray(memberships)) throw configError(`PermDock CLI: fixture ${index} subject.memberships must be an array`);
@@ -26,23 +28,19 @@ function asCustomRoles(value) {
26
28
  if (!Array.isArray(value["customRoles"])) throw new TypeError("PermDock CLI: fixtures customRoles must be an array");
27
29
  return value["customRoles"];
28
30
  }
29
- /**
30
- * A `.json` file or a module exporting `fixtures` (or default) and optionally
31
- * `customRoles`.
32
- */
33
- async function loadFixtures(cwd, path) {
31
+ async function loadFixtures(cwd, path, followed = false) {
34
32
  const abs = resolve(cwd, path);
35
33
  if (!existsSync(abs)) throw configError(`PermDock CLI: fixtures not found: ${path}`);
36
34
  if (abs.endsWith(".json")) {
37
35
  const parsed = readJsonFile(abs);
38
36
  return {
39
- fixtures: asFixtures(parsed),
37
+ fixtures: asFixtures(parsed, followed),
40
38
  customRoles: asCustomRoles(parsed)
41
39
  };
42
40
  }
43
41
  const mod = await loadModule(abs);
44
42
  return {
45
- fixtures: asFixtures(pickNamed(mod, ["fixtures", "default"])),
43
+ fixtures: asFixtures(pickNamed(mod, ["fixtures", "default"]), followed),
46
44
  customRoles: asCustomRoles(mod)
47
45
  };
48
46
  }
@@ -4,7 +4,7 @@ import { i as readJsonFile } from "./files-BSjrtIHw.js";
4
4
  import { t as applyFiles } from "./files-B3AA05f1.js";
5
5
  import { n as httpRequest } from "./http-DOL33cO0.js";
6
6
  import { i as schemaExpression, t as emitPermissionsModule } from "./generate-CezbCaTI.js";
7
- import { t as validateOpenapi } from "./schema-CQzIJdEd.js";
7
+ import { t as validateOpenapi } from "./schema-CnrIP94n.js";
8
8
  import { existsSync, readFileSync } from "node:fs";
9
9
  import { resolve } from "node:path";
10
10
  //#region ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/browser/dist/nodes/identity.js
@@ -48,7 +48,7 @@ const init = defineLeaf({
48
48
  ...forceFlag
49
49
  },
50
50
  async run(ctx, { flags }) {
51
- const [{ runInit }, { packageManagerOf }] = await Promise.all([import("./init-DFwylmiN.js"), import("./peer-C9LvBCcb.js")]);
51
+ const [{ runInit }, { packageManagerOf }] = await Promise.all([import("./init-D6rpLPwM.js"), import("./peer-C9LvBCcb.js")]);
52
52
  const agent = await packageManagerOf(ctx.cwd);
53
53
  const selection = {
54
54
  archetype: flags.archetype,
@@ -79,7 +79,7 @@ const presetDecode = defineLeaf({
79
79
  positionals: presetCode,
80
80
  flags: {},
81
81
  async run(_ctx, { args }) {
82
- const { runPreset } = await import("./init-DFwylmiN.js");
82
+ const { runPreset } = await import("./init-D6rpLPwM.js");
83
83
  return runPreset("decode", args["code"] ?? "");
84
84
  }
85
85
  });
@@ -87,7 +87,7 @@ const presetUrl = defineLeaf({
87
87
  positionals: presetCode,
88
88
  flags: {},
89
89
  async run(_ctx, { args }) {
90
- const { runPreset } = await import("./init-DFwylmiN.js");
90
+ const { runPreset } = await import("./init-D6rpLPwM.js");
91
91
  return runPreset("url", args["code"] ?? "");
92
92
  }
93
93
  });
@@ -1,6 +1,6 @@
1
1
  import { n as CliError } from "./errors-Vpu6rKHl.js";
2
2
  import { a as decodePreset, g as resolvePreset, i as presetFlags, n as generatePreset, o as encodePreset } from "./preset-BjLzeFpp.js";
3
- import { a as nonEmptyOr } from "./output-CtyBwTNB.js";
3
+ import { a as nonEmptyOr } from "./output-3iB3_Hfg.js";
4
4
  import { t as addLine } from "./peer-Q0fuZ6hx.js";
5
5
  import { t as applyFiles } from "./files-B3AA05f1.js";
6
6
  import { existsSync } from "node:fs";
@@ -228,6 +228,11 @@ function createAgentKernel(policy, given) {
228
228
  const boundary = options.boundary ?? "tool-args";
229
229
  const tools = options.tools ?? {};
230
230
  const run = async (binding, args, context, how) => {
231
+ const onError = (error) => {
232
+ try {
233
+ how.decideOptions.onError?.(error);
234
+ } catch {}
235
+ };
231
236
  let permdock;
232
237
  try {
233
238
  permdock = await instance(context);
@@ -252,7 +257,8 @@ function createAgentKernel(policy, given) {
252
257
  if (binding.data !== void 0) {
253
258
  try {
254
259
  data = await binding.data(args);
255
- } catch {
260
+ } catch (error) {
261
+ onError(error);
256
262
  return {
257
263
  ok: false,
258
264
  failure: "load-failed",
@@ -291,7 +297,8 @@ function createAgentKernel(policy, given) {
291
297
  raw,
292
298
  decision
293
299
  };
294
- } catch {
300
+ } catch (error) {
301
+ onError(error);
295
302
  return compact({
296
303
  ok: false,
297
304
  failure: "failed",
@@ -27,7 +27,7 @@ const login = defineLeaf({
27
27
  }
28
28
  },
29
29
  async run(ctx, { flags }) {
30
- const { runLogin } = await import("./login-B92-dZMK.js");
30
+ const { runLogin } = await import("./login-cLflB63Z.js");
31
31
  return runLogin({
32
32
  cwd: ctx.cwd,
33
33
  url: given(flags.url),
@@ -43,7 +43,7 @@ const login = defineLeaf({
43
43
  const logout = defineLeaf({
44
44
  flags: { ...urlFlag },
45
45
  async run(ctx, { flags }) {
46
- const { runLogout } = await import("./login-B92-dZMK.js");
46
+ const { runLogout } = await import("./login-cLflB63Z.js");
47
47
  return runLogout({
48
48
  url: given(flags.url),
49
49
  json: ctx.json,
@@ -55,7 +55,7 @@ const logout = defineLeaf({
55
55
  const whoami = defineLeaf({
56
56
  flags: { ...urlFlag },
57
57
  async run(ctx, { flags }) {
58
- const { runWhoami } = await import("./login-B92-dZMK.js");
58
+ const { runWhoami } = await import("./login-cLflB63Z.js");
59
59
  return runWhoami({
60
60
  url: given(flags.url),
61
61
  json: ctx.json,
@@ -3,7 +3,7 @@ import { n as CliError } from "./errors-Vpu6rKHl.js";
3
3
  import { i as postForm, r as parseToken, s as runDeviceFlow } from "./device-BwbJNmb2.js";
4
4
  import { i as writeCredentials, n as deleteCredentials, r as readCredentials, t as credentialsPath } from "./storage-C2bWdvJH.js";
5
5
  import { n as randomToken, t as pkce } from "./pkce-CnmmYqUZ.js";
6
- import { a as nonEmptyOr } from "./output-CtyBwTNB.js";
6
+ import { a as nonEmptyOr } from "./output-3iB3_Hfg.js";
7
7
  import { n as httpRequest } from "./http-DOL33cO0.js";
8
8
  import { c as READ_SCOPES, d as issuerMetadata, i as credentialsInsideRepository, l as cloudUrl, n as cliRuntime, r as credentialStorage, s as CLI_CLIENT_ID, t as CREDENTIAL_SERVICE } from "./auth--yPyZNgr.js";
9
9
  import { spawn } from "node:child_process";
@@ -30,20 +30,20 @@ const SECTIONS = [
30
30
  docs: "init",
31
31
  effects: ["files"],
32
32
  config: false,
33
- load: async () => (await import("./init-CY7THM2v.js")).init
33
+ load: async () => (await import("./init-BtWY1L0J.js")).init
34
34
  }),
35
35
  group("preset", "Decode a preset code, or print its permdock.com/create link", "preset", [leaf("decode", "Print what a preset code holds", {
36
36
  examples: ["permdock preset decode p1AQIDBAc"],
37
37
  docs: "preset",
38
38
  effects: [],
39
39
  config: false,
40
- load: async () => (await import("./init-CY7THM2v.js")).presetDecode
40
+ load: async () => (await import("./init-BtWY1L0J.js")).presetDecode
41
41
  }), leaf("url", "Print the permdock.com/create link that opens a code", {
42
42
  examples: ["permdock preset url p1AQIDBAc"],
43
43
  docs: "preset",
44
44
  effects: [],
45
45
  config: false,
46
- load: async () => (await import("./init-CY7THM2v.js")).presetUrl
46
+ load: async () => (await import("./init-BtWY1L0J.js")).presetUrl
47
47
  })]),
48
48
  group("skills", "Install, update or list the PermDock Agent Skills", "skills", [
49
49
  leaf("install", "Copy the Agent Skills into the agent folders", {
@@ -55,21 +55,21 @@ const SECTIONS = [
55
55
  docs: "skills",
56
56
  effects: ["files"],
57
57
  config: false,
58
- load: async () => (await import("./skills-BZc81VLt.js")).install
58
+ load: async () => (await import("./skills-uzsVqEi9.js")).install
59
59
  }),
60
60
  leaf("update", "Replace installed skills with this version's", {
61
61
  examples: ["permdock skills update"],
62
62
  docs: "skills",
63
63
  effects: ["files"],
64
64
  config: false,
65
- load: async () => (await import("./skills-BZc81VLt.js")).update
65
+ load: async () => (await import("./skills-uzsVqEi9.js")).update
66
66
  }),
67
67
  leaf("list", "List the skills and where each is installed", {
68
68
  examples: ["permdock skills list"],
69
69
  docs: "skills",
70
70
  effects: [],
71
71
  config: false,
72
- load: async () => (await import("./skills-BZc81VLt.js")).list
72
+ load: async () => (await import("./skills-uzsVqEi9.js")).list
73
73
  })
74
74
  ]),
75
75
  leaf("doctor", "Check a PermDock installation and print a fix for each finding", {
@@ -82,7 +82,7 @@ const SECTIONS = [
82
82
  effects: ["files"],
83
83
  config: true,
84
84
  findings: true,
85
- load: async () => (await import("./doctor-DxyVeUEE.js")).doctor
85
+ load: async () => (await import("./doctor-NxCr_hba.js")).doctor
86
86
  }),
87
87
  leaf("completion", "Print the shell completion script for bash, zsh or fish", {
88
88
  examples: ["permdock completion zsh > ~/.zfunc/_permdock", "eval \"$(permdock completion bash)\""],
@@ -90,7 +90,7 @@ const SECTIONS = [
90
90
  effects: [],
91
91
  config: false,
92
92
  shellOutput: true,
93
- load: async () => (await import("./completion-DLTuCf53.js")).completion
93
+ load: async () => (await import("./completion-fJ19i8Jk.js")).completion
94
94
  })
95
95
  ]
96
96
  },
@@ -106,7 +106,7 @@ const SECTIONS = [
106
106
  docs: "collect",
107
107
  effects: ["files"],
108
108
  config: true,
109
- load: async () => (await import("./collect-D9Tt0Bcx.js")).collect
109
+ load: async () => (await import("./collect-lZgCKMe_.js")).collect
110
110
  }),
111
111
  leaf("catalog", "Export the catalog as catalog JSON, JSON Schema or Markdown", {
112
112
  examples: ["permdock catalog --out permissions.catalog.json", "permdock catalog --kind markdown"],
@@ -132,14 +132,14 @@ const SECTIONS = [
132
132
  effects: [],
133
133
  config: true,
134
134
  findings: true,
135
- load: async () => (await import("./usage-heV5KOiU.js")).usage
135
+ load: async () => (await import("./usage-Dm2hn0pS.js")).usage
136
136
  }),
137
137
  leaf("diff", "Compare two policies or catalogs; exit 1 on a breaking change", {
138
138
  examples: ["permdock diff main.catalog.json permissions.catalog.json", "permdock diff ./old-policy.ts ./src/policy.ts --impact"],
139
139
  docs: "diff",
140
140
  effects: [],
141
141
  config: true,
142
- load: async () => (await import("./diff-BwR1JdP2.js")).diff
142
+ load: async () => (await import("./diff-CxtbOi2l.js")).diff
143
143
  }),
144
144
  leaf("config", "Check permdock.config.ts for unknown keys, or print the effective config", {
145
145
  examples: ["permdock config", "permdock config --print"],
@@ -147,7 +147,7 @@ const SECTIONS = [
147
147
  effects: [],
148
148
  config: true,
149
149
  findings: true,
150
- load: async () => (await import("./config-CmydKZr2.js")).config
150
+ load: async () => (await import("./config-BYSk3iKV.js")).config
151
151
  })
152
152
  ]
153
153
  },
@@ -164,14 +164,14 @@ const SECTIONS = [
164
164
  "network"
165
165
  ],
166
166
  config: true,
167
- load: async () => (await import("./rls-BYHN5bcJ.js")).generate
167
+ load: async () => (await import("./rls-DjjOHlKE.js")).generate
168
168
  }),
169
169
  leaf("import", "Turn existing RLS policies into a generated definition", {
170
170
  examples: ["permdock rls import --sql schema.sql --out src/permissions.generated.ts", "permdock rls import --db-url-stdin --out src/permissions.generated.ts"],
171
171
  docs: "rls",
172
172
  effects: ["files", "database:read"],
173
173
  config: true,
174
- load: async () => (await import("./rls-BYHN5bcJ.js")).importPolicies
174
+ load: async () => (await import("./rls-DjjOHlKE.js")).importPolicies
175
175
  }),
176
176
  leaf("verify", "Run the fixtures against the policies, or compare a live database", {
177
177
  examples: [
@@ -183,21 +183,21 @@ const SECTIONS = [
183
183
  effects: ["files", "database:read"],
184
184
  config: true,
185
185
  findings: true,
186
- load: async () => (await import("./rls-BYHN5bcJ.js")).verify
186
+ load: async () => (await import("./rls-DjjOHlKE.js")).verify
187
187
  }),
188
188
  leaf("migrate", "Rewrite hand-written policies onto the generated helpers", {
189
189
  examples: ["permdock rls migrate --sql supabase/migrations --dry-run", "permdock rls migrate --sql supabase/migrations"],
190
190
  docs: "rls",
191
191
  effects: ["rewrite", "files"],
192
192
  config: true,
193
- load: async () => (await import("./rls-BYHN5bcJ.js")).migrate
193
+ load: async () => (await import("./rls-DjjOHlKE.js")).migrate
194
194
  }),
195
195
  leaf("explain", "Show the tables, membership sources and triggers the SQL binds to", {
196
196
  examples: ["permdock rls explain", "permdock rls explain --db-url-stdin --json"],
197
197
  docs: "rls",
198
198
  effects: ["database:read"],
199
199
  config: true,
200
- load: async () => (await import("./rls-BYHN5bcJ.js")).explain
200
+ load: async () => (await import("./rls-DjjOHlKE.js")).explain
201
201
  })
202
202
  ]),
203
203
  group("supabase", "Generate the Supabase Custom Access Token Hook, or inspect its manifest", "supabase", [group("hook", "The Custom Access Token Hook", "supabase", [leaf("generate", "Compile the membership sources into the hook migration", {
@@ -205,26 +205,26 @@ const SECTIONS = [
205
205
  docs: "supabase",
206
206
  effects: ["files", "database:read"],
207
207
  config: true,
208
- load: async () => (await import("./supabase-CBEK6KEo.js")).hookGenerate
208
+ load: async () => (await import("./supabase-DYWnT800.js")).hookGenerate
209
209
  })]), leaf("inspect", "Print or write the hook and helper manifest", {
210
210
  examples: ["permdock supabase inspect", "permdock supabase inspect --out"],
211
211
  docs: "supabase",
212
212
  effects: ["files"],
213
213
  config: true,
214
- load: async () => (await import("./supabase-CBEK6KEo.js")).inspect
214
+ load: async () => (await import("./supabase-DYWnT800.js")).inspect
215
215
  })]),
216
216
  group("powersync", "Generate PowerSync Sync Streams from the policy, or verify them", "powersync", [leaf("generate", "Compile the read grants into sync-config.yaml", {
217
217
  examples: ["permdock powersync generate", "permdock powersync generate --check"],
218
218
  docs: "powersync",
219
219
  effects: ["files"],
220
220
  config: true,
221
- load: async () => (await import("./powersync-CBcsEvdr.js")).generate
221
+ load: async () => (await import("./powersync-COjQTHRD.js")).generate
222
222
  }), leaf("verify", "Fail on stale streams or a stream that syncs a denied row", {
223
223
  examples: ["permdock powersync verify", "permdock powersync verify --db-url-stdin"],
224
224
  docs: "powersync",
225
225
  effects: ["database:read"],
226
226
  config: true,
227
- load: async () => (await import("./powersync-CBcsEvdr.js")).verify
227
+ load: async () => (await import("./powersync-COjQTHRD.js")).verify
228
228
  })]),
229
229
  group("scim", "Generate the Postgres tables postgresDirectoryStore keeps a SCIM directory in", "scim", [leaf("generate", "Write the tenant-keyed users, groups and members tables", {
230
230
  examples: [
@@ -247,13 +247,13 @@ const SECTIONS = [
247
247
  docs: "openapi",
248
248
  effects: ["files"],
249
249
  config: true,
250
- load: async () => (await import("./openapi-gMQQSzNn.js")).emit
250
+ load: async () => (await import("./openapi-CT55v3WD.js")).emit
251
251
  }), leaf("import", "Turn an OpenAPI document into a generated definition", {
252
252
  examples: ["permdock openapi import --doc openapi.yaml --out src/permissions.generated.ts"],
253
253
  docs: "openapi",
254
254
  effects: ["files", "network"],
255
255
  config: false,
256
- load: async () => (await import("./openapi-gMQQSzNn.js")).importDocument
256
+ load: async () => (await import("./openapi-CT55v3WD.js")).importDocument
257
257
  })]),
258
258
  group("arazzo", "Check Arazzo workflows against the permissions", "arazzo", [leaf("check", "Resolve every Arazzo step to x-permdock-permissions", {
259
259
  examples: ["permdock arazzo check --doc arazzo.json --openapi openapi.json"],
@@ -261,7 +261,7 @@ const SECTIONS = [
261
261
  effects: [],
262
262
  config: true,
263
263
  findings: true,
264
- load: async () => (await import("./arazzo-BXaEhGHM.js")).check
264
+ load: async () => (await import("./arazzo-Bol9OgF-.js")).check
265
265
  })]),
266
266
  leaf("scan", "List authorization checks written without PermDock, to adopt it in an existing app", {
267
267
  examples: ["permdock scan", "permdock scan --src app,lib --pattern isBeta"],
@@ -269,7 +269,7 @@ const SECTIONS = [
269
269
  effects: [],
270
270
  config: true,
271
271
  findings: true,
272
- load: async () => (await import("./scan-CvFWW_fU.js")).scan
272
+ load: async () => (await import("./scan-CR_xm71k.js")).scan
273
273
  }),
274
274
  group("casl", "Import CASL rules into a generated module", "casl", [leaf("import", "Turn CASL rules per role into a permissions and policy module", {
275
275
  examples: ["permdock casl import --rules rules.json --out src/permissions.generated.ts"],
@@ -283,7 +283,7 @@ const SECTIONS = [
283
283
  docs: "casbin",
284
284
  effects: ["files"],
285
285
  config: false,
286
- load: async () => (await import("./casbin-BuTZnSPv.js")).casbinImport
286
+ load: async () => (await import("./casbin-1PVgMHOR.js")).casbinImport
287
287
  })])
288
288
  ]
289
289
  },
@@ -295,34 +295,34 @@ const SECTIONS = [
295
295
  docs: "login",
296
296
  effects: ["network", "files"],
297
297
  config: false,
298
- load: async () => (await import("./login-C5XLYZSF.js")).login
298
+ load: async () => (await import("./login-B8s6VI8Z.js")).login
299
299
  }),
300
300
  leaf("logout", "Revoke and delete the stored PermDock Cloud login", {
301
301
  examples: ["permdock logout"],
302
302
  docs: "login",
303
303
  effects: ["network", "files"],
304
304
  config: false,
305
- load: async () => (await import("./login-C5XLYZSF.js")).logout
305
+ load: async () => (await import("./login-B8s6VI8Z.js")).logout
306
306
  }),
307
307
  leaf("whoami", "Print the PermDock Cloud identity the CLI acts as", {
308
308
  examples: ["permdock whoami", "permdock whoami --json"],
309
309
  docs: "login",
310
310
  effects: [],
311
311
  config: false,
312
- load: async () => (await import("./login-C5XLYZSF.js")).whoami
312
+ load: async () => (await import("./login-B8s6VI8Z.js")).whoami
313
313
  }),
314
314
  group("cloud", "Publish to or pull from a PermDock Cloud project", "cloud", [leaf("push", "Publish the catalog, policy and manifest to a Cloud project", {
315
315
  examples: ["permdock cloud push --dry-run", "permdock cloud push --project prj_123"],
316
316
  docs: "cloud",
317
317
  effects: ["network", "cloud:write"],
318
318
  config: true,
319
- load: async () => (await import("./cloud-DiAiYFRo.js")).push
319
+ load: async () => (await import("./cloud-BfJVKpcN.js")).push
320
320
  }), leaf("pull", "Write a Cloud project's published catalog and manifest", {
321
321
  examples: ["permdock cloud pull --project prj_123"],
322
322
  docs: "cloud",
323
323
  effects: ["network", "files"],
324
324
  config: true,
325
- load: async () => (await import("./cloud-DiAiYFRo.js")).pull
325
+ load: async () => (await import("./cloud-BfJVKpcN.js")).pull
326
326
  })])
327
327
  ]
328
328
  },
@@ -333,7 +333,7 @@ const SECTIONS = [
333
333
  docs: "codemod",
334
334
  effects: ["rewrite"],
335
335
  config: false,
336
- load: async () => (await import("./codemod-_q_ZI01S.js")).codemod
336
+ load: async () => (await import("./codemod-DWfH-KHk.js")).codemod
337
337
  })]
338
338
  }
339
339
  ];
@@ -345,7 +345,7 @@ const COMPLETE_LEAF = leaf("__complete", "Print completion candidates for a part
345
345
  config: false,
346
346
  shellOutput: true,
347
347
  hidden: true,
348
- load: async () => (await import("./completion-DLTuCf53.js")).complete
348
+ load: async () => (await import("./completion-fJ19i8Jk.js")).complete
349
349
  });
350
350
  const ROOT = group("permdock", "Collect, export, diff and check the permissions a PermDock policy declares", "", [...SECTIONS.flatMap((section) => section.entries), COMPLETE_LEAF]);
351
351
  /** Each leaf with its path from the root, in manifest order. */
@@ -112,6 +112,15 @@ type McpProcedureEnforcement = {
112
112
  readonly permissionFor: (name: string) => Permission | undefined;
113
113
  readonly oauthScopesFor?: (name: string) => readonly string[] | undefined;
114
114
  };
115
+ /**
116
+ * Receives an error a check threw: a loader, `decide`, an approval input or a
117
+ * subject a list cannot build. The call still refuses; a sink that throws is
118
+ * ignored.
119
+ */
120
+ type McpOnError = (error: unknown, context: {
121
+ readonly permission: string | null;
122
+ readonly name: string;
123
+ }) => void;
115
124
  type McpPermDockOptions<TUser = unknown> = InstanceOptions & {
116
125
  /**
117
126
  * Receives the verified auth info, or `{}` on a transport without one
@@ -195,8 +204,8 @@ type McpPermDock = {
195
204
  * `permission`.
196
205
  */
197
206
  readonly protectServer: {
198
- (server: McpServer): GuardedMcpServer;
199
- (server: McpServer, options: McpProcedureEnforcement): ProcedureMcpServer;
207
+ (server: McpServer, onError?: McpOnError): GuardedMcpServer;
208
+ (server: McpServer, options: McpProcedureEnforcement, onError?: McpOnError): ProcedureMcpServer;
200
209
  };
201
210
  };
202
211
  //#endregion
@@ -290,4 +299,4 @@ type McpSubjectOptions = Pick<JwtSubjectOptions, "claims" | "groupRoles" | "sche
290
299
  */
291
300
  export declare function subjectFromMcp(authInfo: McpAuthInfo | undefined, options?: McpSubjectOptions): Subject<McpPrincipal>;
292
301
  //#endregion
293
- export type { DeniedText, DeniedTextEvent, GuardedMcpServer, McpAuthInfo, McpPermDock, McpPermDockOptions, McpPrincipal, McpProcedureEnforcement, McpProcedureToolConfig, McpPromptConfig, McpResourceConfig, McpResourceGuardOptions, McpResourceGuardResult, McpSubjectOptions, McpToolConfig, McpUiResourceConfig, ProcedureMcpServer, ProtectedResourceMetadataOptions };
302
+ export type { DeniedText, DeniedTextEvent, GuardedMcpServer, McpAuthInfo, McpOnError, McpPermDock, McpPermDockOptions, McpPrincipal, McpProcedureEnforcement, McpProcedureToolConfig, McpPromptConfig, McpResourceConfig, McpResourceGuardOptions, McpResourceGuardResult, McpSubjectOptions, McpToolConfig, McpUiResourceConfig, ProcedureMcpServer, ProtectedResourceMetadataOptions };
package/dist/mcp/index.js CHANGED
@@ -12,7 +12,7 @@ import { l as problemResponse, o as methodNotAllowed, r as bearerChallenge, u as
12
12
  import { t as clientNameOf } from "../clients-DYr3U86j.js";
13
13
  import { r as mapClaimsToSubject } from "../map-claims-C-nv08_n.js";
14
14
  import { r as instanceOptions } from "../build-instance-BWXqwQYU.js";
15
- import { i as refusalText, n as createAgentKernel } from "../kernel-qv4cr9w8.js";
15
+ import { i as refusalText, n as createAgentKernel } from "../kernel-BD8QuMnv.js";
16
16
  import { t as boundedMap } from "../lru-8q4WZjBV.js";
17
17
  import { t as delegationFrom } from "../delegation-input-FTxMK3ji.js";
18
18
  import { n as deniedToolRefusal, r as toolErrorResult, t as approvalToolRefusal } from "../tool-refusal-Qpjs_W6M.js";
@@ -211,6 +211,18 @@ function stepUpRefusal(stepUpAt, decision, permission, data, context, capabiliti
211
211
  });
212
212
  }
213
213
  //#endregion
214
+ //#region src/mcp/report.ts
215
+ /**
216
+ * Sends `error` to the `onError` sink. The check still refuses; a sink that
217
+ * throws is ignored (invariant 1).
218
+ */
219
+ function report(sink, error, context) {
220
+ if (sink === void 0) return;
221
+ try {
222
+ sink(error, context);
223
+ } catch {}
224
+ }
225
+ //#endregion
214
226
  //#region src/mcp/call-check.ts
215
227
  function reachOf(policy, permission, declared) {
216
228
  return declared === void 0 ? {
@@ -252,10 +264,16 @@ function credentialRefusal(checks, permission, reach, authInfo) {
252
264
  * The completion re-check of a long-running tool: the call must still be
253
265
  * allowed, or approved with the same token.
254
266
  */
255
- async function recheck(checks, binding, args, call, permission, approved, tool) {
267
+ async function recheck(checks, binding, args, call, permission, approved, tool, name) {
256
268
  const rechecked = await checks.kernel.check(binding, args, call, compact({
257
269
  simulate: true,
258
- tool
270
+ tool,
271
+ onError: (error) => {
272
+ report(checks.onError, error, {
273
+ permission: permission.key,
274
+ name
275
+ });
276
+ }
259
277
  }));
260
278
  if (!rechecked.ok) return {
261
279
  ok: false,
@@ -271,8 +289,14 @@ async function recheck(checks, binding, args, call, permission, approved, tool)
271
289
  } : plainRefusal(permission, `Denied: ${permission.key} was revoked before the call completed.`, {})
272
290
  };
273
291
  }
274
- async function decideCall(checks, permission, reach, args, load, context, handlerContext, capabilities, completion, tool) {
292
+ async function decideCall(checks, permission, reach, args, load, context, handlerContext, capabilities, completion, tool, name = tool ?? permission.key) {
275
293
  const authInfo = context.http?.authInfo;
294
+ const onError = (error) => {
295
+ report(checks.onError, error, {
296
+ permission: permission.key,
297
+ name
298
+ });
299
+ };
276
300
  const refused = credentialRefusal(checks, permission, reach, authInfo);
277
301
  if (refused !== void 0) return {
278
302
  ok: false,
@@ -283,10 +307,11 @@ async function decideCall(checks, permission, reach, args, load, context, handle
283
307
  data: load === void 0 ? void 0 : () => load()
284
308
  });
285
309
  const call = compact({ authInfo });
286
- if (completion !== void 0) return recheck(checks, binding, args, call, permission, completion.approved, tool);
310
+ if (completion !== void 0) return recheck(checks, binding, args, call, permission, completion.approved, tool, name);
287
311
  const checked = await checks.kernel.check(binding, args, call, compact({
288
312
  resumeToken: approvalTokenOf(context),
289
- tool
313
+ tool,
314
+ onError
290
315
  }));
291
316
  if (!checked.ok) return {
292
317
  ok: false,
@@ -316,7 +341,8 @@ async function decideCall(checks, permission, reach, args, load, context, handle
316
341
  inputRequired: await approvalInput(checks.options, decision, handlerContext, context, capabilities)
317
342
  })
318
343
  };
319
- } catch {
344
+ } catch (error) {
345
+ onError(error);
320
346
  return {
321
347
  ok: false,
322
348
  refusal: failedRefusal(permission, "failed")
@@ -326,8 +352,8 @@ async function decideCall(checks, permission, reach, args, load, context, handle
326
352
  }
327
353
  }
328
354
  /** `decideCall` with the refusal text replaced by `deniedText`'s. */
329
- async function checkCall(checks, permission, reach, args, load, context, handlerContext, capabilities, completion, tool) {
330
- const checked = await decideCall(checks, permission, reach, args, load, context, handlerContext, capabilities, completion, tool);
355
+ async function checkCall(checks, permission, reach, args, load, context, handlerContext, capabilities, completion, tool, name = tool ?? permission.key) {
356
+ const checked = await decideCall(checks, permission, reach, args, load, context, handlerContext, capabilities, completion, tool, name);
331
357
  const { deniedText } = checks.options;
332
358
  if (checked.ok || deniedText === void 0) return checked;
333
359
  const { refusal } = checked;
@@ -366,7 +392,11 @@ async function visible(checks, context, permissionOf, keys, declaredOf = () => v
366
392
  let permdock;
367
393
  try {
368
394
  permdock = await checks.kernel.instance(compact({ authInfo }));
369
- } catch {
395
+ } catch (error) {
396
+ for (const entry of guarded) report(checks.onError, error, {
397
+ permission: entry.permission.key,
398
+ name: entry.key
399
+ });
370
400
  return shown;
371
401
  }
372
402
  for (const entry of guarded) if ((!tools || actorMayCallTool(permdock.subject.actor, entry.key)) && permdock.mayUse(entry.permission)) shown.add(entry.key);
@@ -381,12 +411,13 @@ function guard(checks, permission, load, handler, dataArgs, onRefusal, extra = {
381
411
  const loader = load === void 0 ? void 0 : () => load(...args);
382
412
  const reach = extra.reach ?? reachOf(checks.policy, permission, void 0);
383
413
  const tool = extra.tool?.();
384
- const checked = await checkCall(checks, permission, reach, args, loader, context, raw, extra.capabilities, void 0, tool);
414
+ const name = extra.name?.() ?? tool ?? permission.key;
415
+ const checked = await checkCall(checks, permission, reach, args, loader, context, raw, extra.capabilities, void 0, tool, name);
385
416
  let result;
386
417
  if (checked.ok) {
387
418
  result = await handler(...params);
388
419
  if (extra.longRunning === true) {
389
- const again = await checkCall(checks, permission, reach, args, loader, context, raw, extra.capabilities, { approved: checked.approved }, tool);
420
+ const again = await checkCall(checks, permission, reach, args, loader, context, raw, extra.capabilities, { approved: checked.approved }, tool, name);
390
421
  if (!again.ok) result = onRefusal(again.refusal);
391
422
  }
392
423
  } else result = onRefusal(checked.refusal);
@@ -496,7 +527,8 @@ function protectServer(checks, server, enforcement) {
496
527
  longRunning,
497
528
  capabilities,
498
529
  reach,
499
- tool
530
+ tool,
531
+ name: tool
500
532
  });
501
533
  const originalTool = server.registerTool.bind(server);
502
534
  const toolPermissionOf = (name, config) => {
@@ -555,7 +587,10 @@ function protectServer(checks, server, enforcement) {
555
587
  const permission = requirePermission("prompt", name, config);
556
588
  const { permission: _permission, data, scopeChallenge, ...passthrough } = config;
557
589
  const load = data;
558
- const wrap = (callback) => guard(checks, permission, load, callback, (params) => params.length >= 2 ? [params[0]] : [void 0], throwRefusal, { capabilities });
590
+ const wrap = (callback) => guard(checks, permission, load, callback, (params) => params.length >= 2 ? [params[0]] : [void 0], throwRefusal, {
591
+ capabilities,
592
+ name: () => name
593
+ });
559
594
  const registered = originalPrompt(name, {
560
595
  ...passthrough,
561
596
  scopeChallenge: challengeFor(scopeChallenge, scopesReaching(checks.policy, permission), challengeScope(checks.policy, permission))
@@ -578,7 +613,10 @@ function protectServer(checks, server, enforcement) {
578
613
  const wrap = (callback) => (...params) => {
579
614
  const permission = permissionNow();
580
615
  if (permission === void 0) return Promise.reject(/* @__PURE__ */ new Error(`Denied: resource ${name} is linked to no guarded tool.`));
581
- return guard(checks, permission, load, callback, (args) => args.slice(0, -1), throwRefusal, { capabilities })(...params);
616
+ return guard(checks, permission, load, callback, (args) => args.slice(0, -1), throwRefusal, {
617
+ capabilities,
618
+ name: () => name
619
+ })(...params);
582
620
  };
583
621
  const registered = originalResource(name, uriOrTemplate, {
584
622
  ...passthrough,
@@ -680,7 +718,13 @@ function createPermDock(policy, given) {
680
718
  ...instanceOptions(options)
681
719
  }))
682
720
  };
683
- return { protectServer: ((server, enforcement) => protectServer(checks, server, enforcement)) };
721
+ return { protectServer: ((server, enforcement, onError) => {
722
+ const sink = typeof enforcement === "function" ? enforcement : onError;
723
+ return protectServer(sink === void 0 ? checks : {
724
+ ...checks,
725
+ onError: sink
726
+ }, server, typeof enforcement === "function" ? void 0 : enforcement);
727
+ }) };
684
728
  }
685
729
  //#endregion
686
730
  //#region src/mcp/resource-guard.ts
@@ -1,5 +1,5 @@
1
1
  import { a as describeError } from "../errors-Vpu6rKHl.js";
2
- import { n as createCollectScheduler, r as report, t as collectOnce } from "../watch-Bpci3hBY.js";
2
+ import { n as createCollectScheduler, r as report, t as collectOnce } from "../watch-CTfSlIGD.js";
3
3
  //#region src/cli/plugin.ts
4
4
  const PHASE_BUILD = "phase-production-build";
5
5
  const PHASE_DEV = "phase-development-server";