@npayload/sdk 5.1.0 → 6.0.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 (46) hide show
  1. package/dist/{chunk-TQFAYJEP.mjs → chunk-33VA5RSC.mjs} +1 -1
  2. package/dist/chunk-3FAIUX4A.mjs +1 -0
  3. package/dist/{chunk-ORT5FUFW.mjs → chunk-47FWIF2H.mjs} +1 -1
  4. package/dist/chunk-4HRWY6VL.mjs +1 -0
  5. package/dist/{chunk-GG7UQYUV.mjs → chunk-5L5EATJW.mjs} +1 -1
  6. package/dist/{chunk-6R2QLUWE.mjs → chunk-6WXPOKLY.mjs} +2 -2
  7. package/dist/chunk-7C63YJ2F.mjs +1 -0
  8. package/dist/{chunk-TUWFD3AZ.mjs → chunk-AM74KBVG.mjs} +1 -1
  9. package/dist/{chunk-CFM43QNN.mjs → chunk-BNGQVWMV.mjs} +4 -4
  10. package/dist/chunk-F455VQCQ.mjs +1 -0
  11. package/dist/{chunk-M7WGBUJ2.mjs → chunk-F6RREQEH.mjs} +1 -1
  12. package/dist/{chunk-X3CZMXOZ.mjs → chunk-FY32IC3I.mjs} +1 -1
  13. package/dist/chunk-GTEVGEFA.mjs +1 -0
  14. package/dist/{chunk-WOMYXKGW.mjs → chunk-IWWVVZC7.mjs} +3 -3
  15. package/dist/chunk-MNKWLZS2.mjs +1 -0
  16. package/dist/{chunk-ZDOLKWQD.mjs → chunk-MWLEDQSA.mjs} +1 -1
  17. package/dist/chunk-O2J73777.mjs +3 -0
  18. package/dist/{chunk-CDA75PLA.mjs → chunk-OMUKWD3N.mjs} +1 -1
  19. package/dist/chunk-Q3RG3NEU.mjs +1 -0
  20. package/dist/chunk-QQC6352X.mjs +6 -0
  21. package/dist/{chunk-UDLS46F5.mjs → chunk-SKJL2WB7.mjs} +1 -1
  22. package/dist/chunk-SRJTV2LW.mjs +1 -0
  23. package/dist/{chunk-HX6PH7C3.mjs → chunk-UV2R4VAS.mjs} +1 -1
  24. package/dist/{chunk-STS7CL74.mjs → chunk-UZ4TQPD3.mjs} +1 -1
  25. package/dist/{chunk-5R5L7GTT.mjs → chunk-W5UKL26F.mjs} +4 -4
  26. package/dist/chunk-WG5MUAXT.mjs +1 -0
  27. package/dist/{chunk-2WG7FETK.mjs → chunk-XOG6ZE4E.mjs} +1 -1
  28. package/dist/{chunk-IH2OLS7G.mjs → chunk-YZGGWQC5.mjs} +1 -1
  29. package/dist/cli/index.js +228 -228
  30. package/dist/cli/index.mjs +162 -162
  31. package/dist/index.d.mts +13 -2
  32. package/dist/index.d.ts +13 -2
  33. package/dist/index.js +1 -1
  34. package/dist/index.mjs +2 -2
  35. package/package.json +1 -1
  36. package/dist/chunk-2G46BKEC.mjs +0 -1
  37. package/dist/chunk-5SMWYS7Z.mjs +0 -1
  38. package/dist/chunk-7IFTQ52O.mjs +0 -1
  39. package/dist/chunk-7QTR5IWG.mjs +0 -1
  40. package/dist/chunk-AGDMCMF3.mjs +0 -1
  41. package/dist/chunk-C5EDDEPR.mjs +0 -1
  42. package/dist/chunk-K3YY77PG.mjs +0 -3
  43. package/dist/chunk-OA73YMB6.mjs +0 -6
  44. package/dist/chunk-ONTNXGOM.mjs +0 -1
  45. package/dist/chunk-R6DPWMZM.mjs +0 -1
  46. package/dist/chunk-YHUBO6K4.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{a as s,c as a}from"./chunk-OA73YMB6.mjs";import{a as c}from"./chunk-LJNU5QHZ.mjs";import{existsSync as u,readFileSync as f}from"fs";import{join as d}from"path";var i=class extends Error{static{c(this,"AuthError")}constructor(t){super(t),this.name="AuthError"}},l="Not authenticated. Run `npayload login` (interactive, stores in the OS keychain), or for CI / headless set NPAYLOAD_CLIENT_ID + NPAYLOAD_CLIENT_SECRET (or NPAYLOAD_TOKEN for a short-lived token). Run `npayload doctor` to check this host.";function h(){let n=process.cwd(),t=n;for(let o=0;o<5;o++){let r=d(t,".npayload.json");if(u(r))try{let p=JSON.parse(f(r,"utf8"));return t!==n&&process.stderr.write(`npayload: using app credentials from a parent directory (${r}). Run from the project root, or set NPAYLOAD_CLIENT_ID/NPAYLOAD_TOKEN, if this is not the app you intend.
1
+ import{a as s,c as a}from"./chunk-QQC6352X.mjs";import{a as c}from"./chunk-LJNU5QHZ.mjs";import{existsSync as u,readFileSync as f}from"fs";import{join as d}from"path";var i=class extends Error{static{c(this,"AuthError")}constructor(t){super(t),this.name="AuthError"}},l="Not authenticated. Run `npayload login` (interactive, stores in the OS keychain), or for CI / headless set NPAYLOAD_CLIENT_ID + NPAYLOAD_CLIENT_SECRET (or NPAYLOAD_TOKEN for a short-lived token). Run `npayload doctor` to check this host.";function h(){let n=process.cwd(),t=n;for(let o=0;o<5;o++){let r=d(t,".npayload.json");if(u(r))try{let p=JSON.parse(f(r,"utf8"));return t!==n&&process.stderr.write(`npayload: using app credentials from a parent directory (${r}). Run from the project root, or set NPAYLOAD_CLIENT_ID/NPAYLOAD_TOKEN, if this is not the app you intend.
2
2
  `),p}catch{return null}let e=d(t,"..");if(e===t)break;t=e}return null}c(h,"findProjectCredentials");async function v(){let n=process.env.NPAYLOAD_TOKEN?.trim()||void 0,t=process.env.NPAYLOAD_CLIENT_ID?.trim()||void 0,o=(process.env.NPAYLOAD_CLIENT_SECRET??process.env.NPAYLOAD_HMAC_SECRET)?.trim()||void 0;if(n)return{clientId:t??"",hmacSecret:o??"",accessToken:n,source:"env_token"};if(t&&o)return{clientId:t,hmacSecret:o,source:"env"};let r=h();if(r?.clientId&&r?.hmacSecret)return{clientId:r.clientId,hmacSecret:r.hmacSecret,source:"project",...r.dpopPrivateJwk!==void 0?{dpopPrivateJwk:r.dpopPrivateJwk}:{}};try{let e=await a();if(e?.clientId&&e?.hmacSecret)return{clientId:e.clientId,hmacSecret:e.hmacSecret,source:"keychain",...e.dpopPrivateJwk!==void 0?{dpopPrivateJwk:e.dpopPrivateJwk}:{}}}catch(e){throw e instanceof s?new i(`${e.message}
3
3
 
4
4
  ${l}`):e}throw new i(l)}c(v,"resolveCredentials");async function N(){try{return await v()}catch{return null}}c(N,"tryResolveCredentials");export{i as a,h as b,v as c,N as d};
@@ -0,0 +1 @@
1
+ import{d as a,e as b,f as c,g as d}from"./chunk-6WXPOKLY.mjs";import"./chunk-MDW42OG6.mjs";import"./chunk-5L5EATJW.mjs";import"./chunk-YZGGWQC5.mjs";import"./chunk-IWWVVZC7.mjs";import"./chunk-MWLEDQSA.mjs";import"./chunk-BNGQVWMV.mjs";import"./chunk-33VA5RSC.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-UV2R4VAS.mjs";import"./chunk-WG5MUAXT.mjs";import"./chunk-CJDCY2NH.mjs";import"./chunk-F6RREQEH.mjs";import"./chunk-XLK55DEY.mjs";import"./chunk-N6NIJISZ.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-QQC6352X.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{c as pullScopesIntoManifest,d as registerScopes,b as runScopesDiff,a as runScopesFix};
@@ -1 +1 @@
1
- import{a,b,c}from"./chunk-HX6PH7C3.mjs";import"./chunk-AGDMCMF3.mjs";import"./chunk-LJNU5QHZ.mjs";export{a as projectPermissions,b as projectPipesPermissions,c as projectPrimusPermissions};
1
+ import{a,b,c}from"./chunk-UV2R4VAS.mjs";import"./chunk-WG5MUAXT.mjs";import"./chunk-LJNU5QHZ.mjs";export{a as projectPermissions,b as projectPipesPermissions,c as projectPrimusPermissions};
@@ -0,0 +1 @@
1
+ import{a,b,c,d}from"./chunk-33VA5RSC.mjs";import"./chunk-QQC6352X.mjs";import"./chunk-LJNU5QHZ.mjs";export{a as AuthError,b as findProjectCredentials,c as resolveCredentials,d as tryResolveCredentials};
@@ -1 +1 @@
1
- import{b as a}from"./chunk-IH2OLS7G.mjs";import{a as l}from"./chunk-LJNU5QHZ.mjs";function t(e){return[...new Set(e)].sort()}l(t,"normalizeScopes");function f(e,r){let o=t(e),n=t(r);return o.length===n.length&&o.every((i,c)=>i===n[c])}l(f,"scopesEqual");function d(e,r,o){let n=new Set(e),i=new Set(r),c=new Set(o);return{base:t(e),manifest:t(r),remote:t(o),localAdded:t(r.filter(s=>!n.has(s))),localRemoved:t(e.filter(s=>!i.has(s))),remoteAdded:t(o.filter(s=>!n.has(s))),remoteRemoved:t(e.filter(s=>!c.has(s)))}}l(d,"diffAgainstBase");function p(e){let r=t(e.declared),o=e.resolution??"none",n=a(r,e.floor);if(n.length>0)return{kind:"floor-gap",gap:n};let i=t(e.remote.scopes),c=t(e.pullBase??e.remote.scopes);return e.remote.configDrift&&!f(r,i)?o==="accept-remote"?{kind:"accept-remote",grant:i,manifest:i}:o==="overwrite-remote"?{kind:"sync",grant:r}:{kind:"conflict",diff:d(c,r,i)}:{kind:"sync",grant:r}}l(p,"reconcileScopes");export{p as a};
1
+ import{b as a}from"./chunk-YZGGWQC5.mjs";import{a as l}from"./chunk-LJNU5QHZ.mjs";function t(e){return[...new Set(e)].sort()}l(t,"normalizeScopes");function f(e,r){let o=t(e),n=t(r);return o.length===n.length&&o.every((i,c)=>i===n[c])}l(f,"scopesEqual");function d(e,r,o){let n=new Set(e),i=new Set(r),c=new Set(o);return{base:t(e),manifest:t(r),remote:t(o),localAdded:t(r.filter(s=>!n.has(s))),localRemoved:t(e.filter(s=>!i.has(s))),remoteAdded:t(o.filter(s=>!n.has(s))),remoteRemoved:t(e.filter(s=>!c.has(s)))}}l(d,"diffAgainstBase");function p(e){let r=t(e.declared),o=e.resolution??"none",n=a(r,e.floor);if(n.length>0)return{kind:"floor-gap",gap:n};let i=t(e.remote.scopes),c=t(e.pullBase??e.remote.scopes);return e.remote.configDrift&&!f(r,i)?o==="accept-remote"?{kind:"accept-remote",grant:i,manifest:i}:o==="overwrite-remote"?{kind:"sync",grant:r}:{kind:"conflict",diff:d(c,r,i)}:{kind:"sync",grant:r}}l(p,"reconcileScopes");export{p as a};
@@ -1,4 +1,4 @@
1
- import{b as P,c as R}from"./chunk-MDW42OG6.mjs";import{a as b}from"./chunk-GG7UQYUV.mjs";import{a as y,b as G}from"./chunk-IH2OLS7G.mjs";import{g as x,k as g,l as h,o as m,p as w}from"./chunk-CFM43QNN.mjs";import{f as S}from"./chunk-N6NIJISZ.mjs";import{a as c}from"./chunk-LJNU5QHZ.mjs";import{readFileSync as _,writeFileSync as D}from"fs";import a from"chalk";import{existsSync as u,readFileSync as $,watch as j}from"fs";import{resolve as C,join as d}from"path";function L(o){if(o){let e=C(process.cwd(),o);return u(e)?[e]:[]}let t=[];for(let e of["events","primus","pipes"])for(let n of[d("npayload",`${e}.config.ts`),`${e}.config.ts`]){let r=d(process.cwd(),n);u(r)&&t.push(r)}return t}c(L,"findAllConfigs");function I(o,t){if(u(o))try{for(let e of $(o,"utf8").split(`
1
+ import{b as P,c as R}from"./chunk-MDW42OG6.mjs";import{a as b}from"./chunk-5L5EATJW.mjs";import{a as y,b as G}from"./chunk-YZGGWQC5.mjs";import{g as x,k as g,l as h,o as m,p as w}from"./chunk-BNGQVWMV.mjs";import{f as S}from"./chunk-N6NIJISZ.mjs";import{a as c}from"./chunk-LJNU5QHZ.mjs";import{readFileSync as _,writeFileSync as D}from"fs";import a from"chalk";import{existsSync as u,readFileSync as $,watch as j}from"fs";import{resolve as C,join as d}from"path";function L(o){if(o){let e=C(process.cwd(),o);return u(e)?[e]:[]}let t=[];for(let e of["events","primus","pipes"])for(let n of[d("npayload",`${e}.config.ts`),`${e}.config.ts`]){let r=d(process.cwd(),n);u(r)&&t.push(r)}return t}c(L,"findAllConfigs");function I(o,t){if(u(o))try{for(let e of $(o,"utf8").split(`
2
2
  `)){let n=e.trim();if(!n||n.startsWith("#"))continue;let r=n.indexOf("=");if(!(r===-1||n.slice(0,r).trim()!==t))return n.slice(r+1).trim().replace(/^["']|["']$/g,"")}}catch{}}c(I,"readEnvVar");function v(o){if(o)return o;let t=process.env.NPAYLOAD_APP_ID?.trim();if(t)return t;for(let e of[d(process.cwd(),".env"),d(process.cwd(),"npayload",".env")]){let n=I(e,"NPAYLOAD_APP_ID");if(n)return n}for(let e=process.cwd(),n=0;n<5;n++){let r=d(e,".npayload.json");if(u(r))try{let i=JSON.parse($(r,"utf8"));if(typeof i.appId=="string"&&i.appId.trim())return i.appId.trim()}catch{}let s=d(e,"..");if(s===e)break;e=s}}c(v,"resolveAppGid");function M(o,t,e=300,n){let r=null,s=c(()=>{r&&clearTimeout(r),r=setTimeout(()=>void t("change"),e)},"bump"),i=o.map(p=>j(p,s)),f=new Promise(p=>{process.on("SIGINT",()=>p())});return n===void 0?f:Promise.race([f,n.ended]).catch(p=>{r&&clearTimeout(r);for(let l of i)l.close();throw p})}c(M,"watchConfigs");function k(o,t){return{...o!==void 0?{cwd:o}:{},components:t}}c(k,"floorOptions");function A(o,t){let e=x(o);e.length!==0&&t?.(a.dim(` (declared component(s) not embeddable \u2014 they contribute no scope: ${e.join(", ")})
3
3
  `))}c(A,"reportInertComponents");async function F(o={}){let t=m(o.cwd),e=t?.path??w(o.cwd);if(!t||!e)throw new Error("no npayload.toml found \u2014 `np scopes fix` needs a manifest with an [access_scopes] block.");h(t.accessScopes);let n=o.floor??await y(k(o.cwd,t.embedComponents));A(t.embedComponents,o.log);let r=G(t.accessScopes,n),s=r.filter(l=>g(l)),i=r.filter(l=>!g(l));if(i.length>0&&o.log?.(a.dim(` (skipped ${i.length} non-catalog projection scope(s) \u2014 not declarable in [access_scopes]: ${i.join(", ")})
4
4
  `)),s.length===0)return o.log?.(a.dim(` [access_scopes] already covers the projected floor \u2014 nothing to add.
@@ -15,6 +15,6 @@ import{b as P,c as R}from"./chunk-MDW42OG6.mjs";import{a as b}from"./chunk-GG7UQ
15
15
  `));break;case"sync":i(a.green(`\u2713 [access_scopes] covers the floor and matches the remote grant (${s.grant.length} scope(s)).
16
16
  `));break;case"accept-remote":i(a.green(`\u2713 resolvable via --accept-remote.
17
17
  `));break}return s}c(T,"runScopesDiff");async function Z(o){let t=m(o.cwd),e=t?.path??w(o.cwd);if(!t||!e)return null;let n=o.appGid??v();if(!n)return null;let r=await o.readRemoteGrant(n);if(!r)return null;let s=[...new Set(r.scopes)].sort(),i=P(_(e,"utf8"),s);return D(e,i,"utf8"),o.log?.(a.green(`\u2713 pulled ${s.length} scope(s) from the remote grant into [access_scopes].
18
- `)),{written:s,path:e}}c(Z,"pullScopesIntoManifest");async function E(o){let{restoreSession:t}=await import("./chunk-7QTR5IWG.mjs"),e=await t();return e?e.getOacGrant(o):null}c(E,"sessionGrantReader");function ee(o){let t=o.command("scopes").description("Scopes-as-code: inspect and reconcile the manifest's [access_scopes] against the floor + the remote grant");t.command("diff").description("Show the floor gap + manifest\u21C4remote drift for [access_scopes]. Exit 0 in sync, 2 with a gap/conflict, 1 on error.").action(async()=>{try{let e=await T({readRemoteGrant:E});process.exit(e.kind==="sync"||e.kind==="accept-remote"?0:2)}catch(e){process.stderr.write(a.red(`${S(`scopes diff failed: ${e instanceof Error?e.message:String(e)}`,e)}
18
+ `)),{written:s,path:e}}c(Z,"pullScopesIntoManifest");async function E(o){let{restoreSession:t}=await import("./chunk-MNKWLZS2.mjs"),e=await t();return e?e.getOacGrant(o):null}c(E,"sessionGrantReader");function ee(o){let t=o.command("scopes").description("Scopes-as-code: inspect and reconcile the manifest's [access_scopes] against the floor + the remote grant");t.command("diff").description("Show the floor gap + manifest\u21C4remote drift for [access_scopes]. Exit 0 in sync, 2 with a gap/conflict, 1 on error.").action(async()=>{try{let e=await T({readRemoteGrant:E});process.exit(e.kind==="sync"||e.kind==="accept-remote"?0:2)}catch(e){process.stderr.write(a.red(`${S(`scopes diff failed: ${e instanceof Error?e.message:String(e)}`,e)}
19
19
  `)),process.exit(1)}}),t.command("fix").description("Append exactly the projected-floor gap to the manifest's [access_scopes] (idempotent)").action(async()=>{try{await F({log:c(e=>process.stdout.write(e),"log")}),process.exit(0)}catch(e){process.stderr.write(a.red(`scopes fix failed: ${e instanceof Error?e.message:String(e)}
20
20
  `)),process.exit(1)}})}c(ee,"registerScopes");export{L as a,v as b,M as c,F as d,T as e,Z as f,ee as g};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-MWLEDQSA.mjs";import"./chunk-BNGQVWMV.mjs";import"./chunk-33VA5RSC.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-UV2R4VAS.mjs";import"./chunk-WG5MUAXT.mjs";import"./chunk-CJDCY2NH.mjs";import"./chunk-F6RREQEH.mjs";import"./chunk-XLK55DEY.mjs";import"./chunk-N6NIJISZ.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-QQC6352X.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{a as projectAllPermissions};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-2WG7FETK.mjs";import"./chunk-HX6PH7C3.mjs";import"./chunk-AGDMCMF3.mjs";import"./chunk-LJNU5QHZ.mjs";export{e as checkPermissionsDrift,g as checkScopesDrift,a as permissionsContentHash,b as renderPermissionsModule,c as scopesFromConfig,d as writePermissionsModule,f as writeScopesModule};
1
+ import{a,b,c,d,e,f,g}from"./chunk-XOG6ZE4E.mjs";import"./chunk-UV2R4VAS.mjs";import"./chunk-WG5MUAXT.mjs";import"./chunk-LJNU5QHZ.mjs";export{e as checkPermissionsDrift,g as checkScopesDrift,a as permissionsContentHash,b as renderPermissionsModule,c as scopesFromConfig,d as writePermissionsModule,f as writeScopesModule};
@@ -1,4 +1,4 @@
1
- import{c as Le}from"./chunk-TQFAYJEP.mjs";import{a as qe}from"./chunk-4NWQCPI4.mjs";import{a as Ie,b as Ne,e as Ke}from"./chunk-CJDCY2NH.mjs";import{c as _e,f as De}from"./chunk-M7WGBUJ2.mjs";import{b as Me}from"./chunk-XLK55DEY.mjs";import{f as Be}from"./chunk-N6NIJISZ.mjs";import{a as Ge,f as Fe}from"./chunk-LCUELOEE.mjs";import{g as je,h as M}from"./chunk-AECDYMA2.mjs";import{a as Ce}from"./chunk-VZT7RCAC.mjs";import{a as ee,d as le,e as Te}from"./chunk-GGXNXM73.mjs";import{a as i}from"./chunk-LJNU5QHZ.mjs";import{pathToFileURL as Ee}from"url";import{createRequire as St}from"module";import{resolve as z,isAbsolute as Pn,join as H,dirname as kn}from"path";import{existsSync as Pe,mkdtempSync as Pt,mkdirSync as At,writeFileSync as xt,rmSync as $t,readFileSync as An}from"fs";import{createHash as Ot}from"crypto";import{tmpdir as Ct}from"os";import x from"chalk";function Ue(e){let n=e.env.NPAYLOAD_DPOP_JWK?.trim();if(n)try{return JSON.parse(n)}catch{throw new TypeError("NPAYLOAD_DPOP_JWK is set but is not a JSON Web Key. Set it to an ES256 private key, or unset it.")}let t=Ne(e.env);return t!==void 0?t:Ie(e.credentialKey)?e.credentialKey:void 0}i(Ue,"resolveCliDpopKey");var Je={agents:[{path:"skills",publicField:"skillGids",parent:"skills",wire:"gid",array:!0,label:"skills"}],skills:[{path:"definition.tools",publicField:"definition.tools",parent:"tools",wire:"name",array:!0,label:"tools"}],triggers:[{path:"agentGid",publicField:"agentGid",parent:"agents",wire:"gid",array:!1,label:"agent"},{path:"action.skillIds",publicField:"action.skillGids",parent:"skills",wire:"gid",array:!0,label:"skills"}]};function no(){return Object.keys(Je)}i(no,"relationResources");function Ye(e){return Je[e]??[]}i(Ye,"refSpecsForResource");function de(e,n){let t=e;for(let o of n.split(".")){if(t==null||typeof t!="object")return;t=t[o]}return t}i(de,"getAtPath");function to(e,n,t){let o=n.split("."),r=e;for(let c=0;c<o.length-1;c++){let a=o[c],s=r[a];(s==null||typeof s!="object"||Array.isArray(s))&&(r[a]={}),r=r[a]}r[o[o.length-1]]=t}i(to,"setAtPath");function pe(e){return e==null?null:typeof e=="string"?[e]:Array.isArray(e)&&e.every(n=>typeof n=="string")?e:null}i(pe,"refNames");function Ve(e,n){if(e.length!==n.length)return!1;let t=new Set(e);return n.every(o=>t.has(o))}i(Ve,"sameNameSet");function He(e,n){let t=new Map,o=e.get(n);if(o)for(let[r,c]of o)t.set(c,r);return t}i(He,"gidToNameFor");function ze(e,n,t){if(n.wire==="name")return{resolved:[...e],unresolved:null};let o=t.get(n.parent),r=[];for(let c of e){if(jn(c))return{resolved:r,unresolved:c};let a=o?.get(c);if(!a)return{resolved:r,unresolved:c};r.push(a)}return{resolved:r,unresolved:null}}i(ze,"resolveRefNames");function jn(e){return e.split("_").length===2&&/^[a-z]{2,4}_[A-Za-z0-9]*[0-9][A-Za-z0-9]*$/.test(e)}i(jn,"isGid");import{existsSync as st,readFileSync as it}from"fs";import{join as pn}from"path";import{existsSync as Mn,readFileSync as Bn}from"fs";import{isAbsolute as Gn,join as Qe,resolve as Fn}from"path";import{parse as qn}from"smol-toml";var In=/^[a-z][a-z0-9_-]*:(read|write|execute|admin)$/,We=/^[a-z][a-z0-9_-]*:[a-z][a-z0-9_-]*$/,q=class extends Error{static{i(this,"AccessScopeError")}scope;constructor(n,t){super(`npayload.toml [access_scopes]: ${t} \u2014 offending scope "${n}"`),this.name="AccessScopeError",this.scope=n}};function Nn(e){return In.test(e)?!0:We.test(e)&&le(e)}i(Nn,"isConcreteScope");function ue(e){for(let n of e){if(typeof n!="string"||n.trim()==="")throw new q(String(n),"every scope MUST be a non-empty string");if(n==="*")throw new q(n,"the literal wildcard `*` is forbidden (zero-wildcard invariant)");if(n.includes("*"))throw new q(n,"wildcard / `<namespace>:*` roll-up forms are forbidden (zero-wildcard invariant); declare each concrete <resource>:<action>");if(!Nn(n))throw new q(n,"must be a concrete `<resource>:<action>` scope where <action> is one of read|write|execute|admin, or a catalog-listed exception (none exist while audit:export is retired)")}}i(ue,"validateAccessScopes");function _n(e){return We.test(e)&&le(e)}i(_n,"isCatalogScope");function Dn(e){return Te(e)}i(Dn,"suggestCatalogScope");function io(e){ue(e);for(let n of e)if(!_n(n)){let t=Dn(n);throw new q(n,"is not in the npayload permission catalog"+(t?` \u2014 did you mean "${t}"?`:""))}}i(io,"validateAccessScopesCatalog");var Kn=Object.keys(ee).sort(),fe=class extends Error{static{i(this,"EmbedComponentError")}unknown;constructor(n){super(`npayload.toml [embed]: unknown component id(s) [${n.join(", ")}] \u2014 valid ids: [${Kn.join(", ")}]`),this.name="EmbedComponentError",this.unknown=n}};function Ze(e){return Object.prototype.hasOwnProperty.call(ee,e)}i(Ze,"isKnownComponentId");function Xe(e){let n=[];for(let t of e)(typeof t!="string"||t.trim()===""||!Ze(t))&&n.push(String(t));if(n.length>0)throw new fe(n)}i(Xe,"validateMountedComponents");function po(e){return e.filter(n=>Ze(n)&&ee[n].status!=="live")}i(po,"nonLiveComponents");var en=["development","production"],Ln=/^[a-z][a-z0-9-]{1,30}$/,D=class extends Error{static{i(this,"ManifestError")}block;constructor(n,t){super(`npayload.toml [${t}]: ${n}`),this.name="ManifestError",this.block=t}},Un="npayload.toml",Jn=new Set(["app","env","access_scopes","embed"]),Yn=new Set(["slug","name"]),Vn=new Set(["name","kind","deploy_branch"]),Hn=new Set(["scopes"]),zn=new Set(["components"]);function J(e,n,t){for(let o of Object.keys(e))if(!n.has(o)){let r=t===""?o:`${t}.${o}`;throw new D(`unknown key \`${r}\` \u2014 the manifest schema is strict (allowed here: ${[...n].join(", ")}); remove it or fix the typo`,t===""?o:t)}}i(J,"rejectUnknownKeys");function Y(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}i(Y,"asTable");function Wn(e,n,t){let o=e[n];if(typeof o!="string"||o.trim()==="")throw new D(`missing required string \`${n}\``,t);return o}i(Wn,"reqString");function ge(e,n){let t=e[n];return typeof t=="string"&&t.trim()!==""?t:void 0}i(ge,"optString");function me(e){return typeof e=="string"&&en.includes(e)}i(me,"isEnvironmentKind");function Zn(e){let n=qn(e);J(n,Jn,"");let t=Y(n.app);if(!t)throw new D("missing required table","app");J(t,Yn,"app");let o={slug:Wn(t,"slug","app")},r=ge(t,"name");r!==void 0&&(o.name=r);let c=Y(n.env);if(!c||Object.keys(c).length===0)throw new D('at least one `[env.<slug>]` section is required (e.g. `[env.sandbox]` with `kind = "development"`)',"env");let a=[];for(let[f,u]of Object.entries(c)){let m=`env.${f}`;if(!Ln.test(f))throw new D(`invalid environment slug \`${f}\` \u2014 use 2-31 chars, lowercase letter first, then lowercase letters, digits, or dashes`,m);let p=Y(u);if(!p)throw new D("must be a table (`[env.<slug>]` section)",m);J(p,Vn,m);let E=p.kind;if(!me(E))throw new D(`\`kind\` MUST be one of ${en.join(" | ")}, got ${JSON.stringify(E)} (env slug "${f}")`,m);let d={name:ge(p,"name")??f,slug:f,kind:E},k=ge(p,"deploy_branch");k!==void 0&&(d.deployBranch=k),a.push(d)}let s=Y(n.access_scopes);if(!s)throw new D("missing required table","access_scopes");J(s,Hn,"access_scopes");let l=s.scopes;if(l!==void 0&&!Array.isArray(l))throw new D("`scopes` must be an array of strings","access_scopes");let h=(l??[]).map(f=>String(f));ue(h);let g=Y(n.embed),y=[];if(g){J(g,zn,"embed");let f=g.components;if(f!==void 0&&!Array.isArray(f))throw new D("`components` must be an array of component ids","embed");y=(f??[]).map(u=>String(u)),Xe(y)}return{app:o,environments:a,accessScopes:h,embedComponents:y}}i(Zn,"parseManifest");function ne(e=process.cwd()){let n=Xn(e);if(!n)return null;let t=Zn(Bn(n,"utf8"));return t.path=n,t}i(ne,"loadManifest");function Xn(e=process.cwd()){let n=Gn(e)?e:Fn(process.cwd(),e);for(let t=0;t<6;t++){let o=Qe(n,Un);if(Mn(o))return o;let r=Qe(n,"..");if(r===n)break;n=r}return null}i(Xn,"findManifest");import{existsSync as nn,mkdirSync as tn,readFileSync as on,writeFileSync as rn}from"fs";import{isAbsolute as Qn,join as he,resolve as et}from"path";var nt=".npayload",tt="active-env.json",ot="environments.json";function te(e=process.cwd()){let n=Qn(e)?e:et(process.cwd(),e);return he(n,nt)}i(te,"stateDir");function sn(e=process.cwd()){return he(te(e),tt)}i(sn,"activeEnvPath");function an(e=process.cwd()){return he(te(e),ot)}i(an,"knownEnvsPath");function cn(e=process.cwd()){let n=sn(e);if(nn(n))try{let t=JSON.parse(on(n,"utf8"));return typeof t.slug=="string"&&t.slug.trim()!==""?t.slug:void 0}catch{return}}i(cn,"getActiveEnv");function Ro(e,n=process.cwd()){let t=te(n);tn(t,{recursive:!0}),rn(sn(n),JSON.stringify({slug:e},null,2)+`
1
+ import{c as Le}from"./chunk-33VA5RSC.mjs";import{a as qe}from"./chunk-4NWQCPI4.mjs";import{a as Ie,b as Ne,e as Ke}from"./chunk-CJDCY2NH.mjs";import{c as _e,f as De}from"./chunk-F6RREQEH.mjs";import{b as Me}from"./chunk-XLK55DEY.mjs";import{f as Be}from"./chunk-N6NIJISZ.mjs";import{a as Ge,f as Fe}from"./chunk-LCUELOEE.mjs";import{g as je,h as M}from"./chunk-AECDYMA2.mjs";import{a as Ce}from"./chunk-VZT7RCAC.mjs";import{a as ee,d as le,e as Te}from"./chunk-GGXNXM73.mjs";import{a as i}from"./chunk-LJNU5QHZ.mjs";import{pathToFileURL as Ee}from"url";import{createRequire as St}from"module";import{resolve as z,isAbsolute as Pn,join as H,dirname as kn}from"path";import{existsSync as Pe,mkdtempSync as Pt,mkdirSync as At,writeFileSync as xt,rmSync as $t,readFileSync as An}from"fs";import{createHash as Ot}from"crypto";import{tmpdir as Ct}from"os";import x from"chalk";function Ue(e){let n=e.env.NPAYLOAD_DPOP_JWK?.trim();if(n)try{return JSON.parse(n)}catch{throw new TypeError("NPAYLOAD_DPOP_JWK is set but is not a JSON Web Key. Set it to an ES256 private key, or unset it.")}let t=Ne(e.env);return t!==void 0?t:Ie(e.credentialKey)?e.credentialKey:void 0}i(Ue,"resolveCliDpopKey");var Je={agents:[{path:"skills",publicField:"skillGids",parent:"skills",wire:"gid",array:!0,label:"skills"}],skills:[{path:"definition.tools",publicField:"definition.tools",parent:"tools",wire:"name",array:!0,label:"tools"}],triggers:[{path:"agentGid",publicField:"agentGid",parent:"agents",wire:"gid",array:!1,label:"agent"},{path:"action.skillIds",publicField:"action.skillGids",parent:"skills",wire:"gid",array:!0,label:"skills"}]};function no(){return Object.keys(Je)}i(no,"relationResources");function Ye(e){return Je[e]??[]}i(Ye,"refSpecsForResource");function de(e,n){let t=e;for(let o of n.split(".")){if(t==null||typeof t!="object")return;t=t[o]}return t}i(de,"getAtPath");function to(e,n,t){let o=n.split("."),r=e;for(let c=0;c<o.length-1;c++){let a=o[c],s=r[a];(s==null||typeof s!="object"||Array.isArray(s))&&(r[a]={}),r=r[a]}r[o[o.length-1]]=t}i(to,"setAtPath");function pe(e){return e==null?null:typeof e=="string"?[e]:Array.isArray(e)&&e.every(n=>typeof n=="string")?e:null}i(pe,"refNames");function Ve(e,n){if(e.length!==n.length)return!1;let t=new Set(e);return n.every(o=>t.has(o))}i(Ve,"sameNameSet");function He(e,n){let t=new Map,o=e.get(n);if(o)for(let[r,c]of o)t.set(c,r);return t}i(He,"gidToNameFor");function ze(e,n,t){if(n.wire==="name")return{resolved:[...e],unresolved:null};let o=t.get(n.parent),r=[];for(let c of e){if(jn(c))return{resolved:r,unresolved:c};let a=o?.get(c);if(!a)return{resolved:r,unresolved:c};r.push(a)}return{resolved:r,unresolved:null}}i(ze,"resolveRefNames");function jn(e){return e.split("_").length===2&&/^[a-z]{2,4}_[A-Za-z0-9]*[0-9][A-Za-z0-9]*$/.test(e)}i(jn,"isGid");import{existsSync as st,readFileSync as it}from"fs";import{join as pn}from"path";import{existsSync as Mn,readFileSync as Bn}from"fs";import{isAbsolute as Gn,join as Qe,resolve as Fn}from"path";import{parse as qn}from"smol-toml";var In=/^[a-z][a-z0-9_-]*:(read|write|execute|admin)$/,We=/^[a-z][a-z0-9_-]*:[a-z][a-z0-9_-]*$/,q=class extends Error{static{i(this,"AccessScopeError")}scope;constructor(n,t){super(`npayload.toml [access_scopes]: ${t} \u2014 offending scope "${n}"`),this.name="AccessScopeError",this.scope=n}};function Nn(e){return In.test(e)?!0:We.test(e)&&le(e)}i(Nn,"isConcreteScope");function ue(e){for(let n of e){if(typeof n!="string"||n.trim()==="")throw new q(String(n),"every scope MUST be a non-empty string");if(n==="*")throw new q(n,"the literal wildcard `*` is forbidden (zero-wildcard invariant)");if(n.includes("*"))throw new q(n,"wildcard / `<namespace>:*` roll-up forms are forbidden (zero-wildcard invariant); declare each concrete <resource>:<action>");if(!Nn(n))throw new q(n,"must be a concrete `<resource>:<action>` scope where <action> is one of read|write|execute|admin, or a catalog-listed exception (none exist while audit:export is retired)")}}i(ue,"validateAccessScopes");function _n(e){return We.test(e)&&le(e)}i(_n,"isCatalogScope");function Dn(e){return Te(e)}i(Dn,"suggestCatalogScope");function io(e){ue(e);for(let n of e)if(!_n(n)){let t=Dn(n);throw new q(n,"is not in the npayload permission catalog"+(t?` \u2014 did you mean "${t}"?`:""))}}i(io,"validateAccessScopesCatalog");var Kn=Object.keys(ee).sort(),fe=class extends Error{static{i(this,"EmbedComponentError")}unknown;constructor(n){super(`npayload.toml [embed]: unknown component id(s) [${n.join(", ")}] \u2014 valid ids: [${Kn.join(", ")}]`),this.name="EmbedComponentError",this.unknown=n}};function Ze(e){return Object.prototype.hasOwnProperty.call(ee,e)}i(Ze,"isKnownComponentId");function Xe(e){let n=[];for(let t of e)(typeof t!="string"||t.trim()===""||!Ze(t))&&n.push(String(t));if(n.length>0)throw new fe(n)}i(Xe,"validateMountedComponents");function po(e){return e.filter(n=>Ze(n)&&ee[n].status!=="live")}i(po,"nonLiveComponents");var en=["development","production"],Ln=/^[a-z][a-z0-9-]{1,30}$/,D=class extends Error{static{i(this,"ManifestError")}block;constructor(n,t){super(`npayload.toml [${t}]: ${n}`),this.name="ManifestError",this.block=t}},Un="npayload.toml",Jn=new Set(["app","env","access_scopes","embed"]),Yn=new Set(["slug","name"]),Vn=new Set(["name","kind","deploy_branch"]),Hn=new Set(["scopes"]),zn=new Set(["components"]);function J(e,n,t){for(let o of Object.keys(e))if(!n.has(o)){let r=t===""?o:`${t}.${o}`;throw new D(`unknown key \`${r}\` \u2014 the manifest schema is strict (allowed here: ${[...n].join(", ")}); remove it or fix the typo`,t===""?o:t)}}i(J,"rejectUnknownKeys");function Y(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}i(Y,"asTable");function Wn(e,n,t){let o=e[n];if(typeof o!="string"||o.trim()==="")throw new D(`missing required string \`${n}\``,t);return o}i(Wn,"reqString");function ge(e,n){let t=e[n];return typeof t=="string"&&t.trim()!==""?t:void 0}i(ge,"optString");function me(e){return typeof e=="string"&&en.includes(e)}i(me,"isEnvironmentKind");function Zn(e){let n=qn(e);J(n,Jn,"");let t=Y(n.app);if(!t)throw new D("missing required table","app");J(t,Yn,"app");let o={slug:Wn(t,"slug","app")},r=ge(t,"name");r!==void 0&&(o.name=r);let c=Y(n.env);if(!c||Object.keys(c).length===0)throw new D('at least one `[env.<slug>]` section is required (e.g. `[env.sandbox]` with `kind = "development"`)',"env");let a=[];for(let[f,u]of Object.entries(c)){let m=`env.${f}`;if(!Ln.test(f))throw new D(`invalid environment slug \`${f}\` \u2014 use 2-31 chars, lowercase letter first, then lowercase letters, digits, or dashes`,m);let p=Y(u);if(!p)throw new D("must be a table (`[env.<slug>]` section)",m);J(p,Vn,m);let E=p.kind;if(!me(E))throw new D(`\`kind\` MUST be one of ${en.join(" | ")}, got ${JSON.stringify(E)} (env slug "${f}")`,m);let d={name:ge(p,"name")??f,slug:f,kind:E},k=ge(p,"deploy_branch");k!==void 0&&(d.deployBranch=k),a.push(d)}let s=Y(n.access_scopes);if(!s)throw new D("missing required table","access_scopes");J(s,Hn,"access_scopes");let l=s.scopes;if(l!==void 0&&!Array.isArray(l))throw new D("`scopes` must be an array of strings","access_scopes");let h=(l??[]).map(f=>String(f));ue(h);let g=Y(n.embed),y=[];if(g){J(g,zn,"embed");let f=g.components;if(f!==void 0&&!Array.isArray(f))throw new D("`components` must be an array of component ids","embed");y=(f??[]).map(u=>String(u)),Xe(y)}return{app:o,environments:a,accessScopes:h,embedComponents:y}}i(Zn,"parseManifest");function ne(e=process.cwd()){let n=Xn(e);if(!n)return null;let t=Zn(Bn(n,"utf8"));return t.path=n,t}i(ne,"loadManifest");function Xn(e=process.cwd()){let n=Gn(e)?e:Fn(process.cwd(),e);for(let t=0;t<6;t++){let o=Qe(n,Un);if(Mn(o))return o;let r=Qe(n,"..");if(r===n)break;n=r}return null}i(Xn,"findManifest");import{existsSync as nn,mkdirSync as tn,readFileSync as on,writeFileSync as rn}from"fs";import{isAbsolute as Qn,join as he,resolve as et}from"path";var nt=".npayload",tt="active-env.json",ot="environments.json";function te(e=process.cwd()){let n=Qn(e)?e:et(process.cwd(),e);return he(n,nt)}i(te,"stateDir");function sn(e=process.cwd()){return he(te(e),tt)}i(sn,"activeEnvPath");function an(e=process.cwd()){return he(te(e),ot)}i(an,"knownEnvsPath");function cn(e=process.cwd()){let n=sn(e);if(nn(n))try{let t=JSON.parse(on(n,"utf8"));return typeof t.slug=="string"&&t.slug.trim()!==""?t.slug:void 0}catch{return}}i(cn,"getActiveEnv");function Ro(e,n=process.cwd()){let t=te(n);tn(t,{recursive:!0}),rn(sn(n),JSON.stringify({slug:e},null,2)+`
2
2
  `,{mode:384})}i(Ro,"setActiveEnv");function ln(e=process.cwd()){let n=an(e);if(!nn(n))return[];try{let t=JSON.parse(on(n,"utf8"));return Array.isArray(t.environments)?t.environments:[]}catch{return[]}}i(ln,"getKnownEnvs");function So(e,n=process.cwd()){let t=te(n);tn(t,{recursive:!0}),rn(an(n),JSON.stringify({environments:e},null,2)+`
3
3
  `,{mode:384})}i(So,"saveKnownEnvs");var L=class extends Error{static{i(this,"EnvResolutionError")}constructor(n){super(n),this.name="EnvResolutionError"}};function rt(e){let n=e.explicitSlug??e.activeSlug;if(!n)throw new L("No target environment. Pass `--env <slug>` or set an active environment with `np env use <slug>`.");let t=e.environments.filter(o=>o.slug===n);if(t.length===0){let o=e.environments.map(r=>r.slug).join(", ")||"(none declared)";throw new L(`Unknown environment "${n}". Declared environments: ${o}.`)}if(t.length>1)throw new L(`Environment slug "${n}" is ambiguous \u2014 it matches ${t.length} environments. Fix the duplicate slug in npayload.toml.`);return t[0]}i(rt,"resolveTargetEnv");function dn(e={}){let n=e.explicitSlug?.trim();if(n)return n;let t=e.manifest!==void 0?e.manifest:ne(e.cwd),o=e.activeSlug!==void 0?e.activeSlug??void 0:cn(e.cwd),r=t?t.environments.map(s=>({slug:s.slug,kind:s.kind})):[],c=o?.trim();if(c)return t&&rt({activeSlug:c,environments:r}),c;if(!t)return;let a=t.environments.filter(s=>s.kind==="development");if(a.length===1)return a[0].slug;throw new L(t.environments.length===0?"npayload.toml declares no environments \u2014 add an [env.<slug>] section, or pass --env <slug> / set one with `np env use <slug>`.":`Cannot resolve a single target environment from npayload.toml (declared: ${t.environments.map(s=>s.slug).join(", ")}). Pass --env <slug> or set one with \`np env use <slug>\`.`)}i(dn,"resolveCliEnvSlug");function oe(e){return typeof e=="string"&&e.length>0?e:void 0}i(oe,"str");function at(e){let n=e.split(".");if(n.length<2)return{};try{let t=Buffer.from(n[1].replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf8");return JSON.parse(t)}catch{return{}}}i(at,"decodeJwtClaims");function ct(e){return oe(e["npayload/appId"])??oe(e.appId)??oe(e.app)??oe(e.app_id)}i(ct,"appIdFromClaims");function un(e=process.cwd()){for(let n=e,t=0;t<5;t++){let o=pn(n,".npayload.json");if(st(o))try{let c=JSON.parse(it(o,"utf8"));if(typeof c.appId=="string"&&c.appId.startsWith("app_"))return c.appId}catch{}let r=pn(n,"..");if(r===n)break;n=r}}i(un,"appIdFromProjectFile");var re=i(e=>!!e&&e.startsWith("app_"),"isAppGid");async function ye(e,n){if(n.app)return n.app;let t=process.env.NPAYLOAD_APP_ID?.trim()||void 0;if(re(t))return t;let o;try{let{token:r}=await e.auth.getAccessToken([]);o=ct(at(r))}catch(r){M(r),o=void 0}return o||(re(t)?t:un()??t)}i(ye,"resolveAppId");function lt(e={}){if(re(e.app)||e.app)return e.app;let n=process.env.NPAYLOAD_APP_ID?.trim()||void 0;return re(n)?n:un(e.cwd)??n}i(lt,"resolveAppIdLocal");function _o(e,n={}){let t=null;try{t=dn({...n.explicitEnv?{explicitSlug:n.explicitEnv}:{},...n.cwd?{cwd:n.cwd}:{}})??null}catch{t=null}return{org:e?.orgId?.()??null,app:lt(n.cwd?{cwd:n.cwd}:{})??null,env:t}}i(_o,"resolveWhoamiContext");function fn(e={}){let n=e.cwd,t=e.manifest!==void 0?e.manifest:ne(n);if(!t||t.environments.length===0){if(e.explicitSlug)throw new Error(`--env ${e.explicitSlug} requires a npayload.toml declaring [env.${e.explicitSlug}]. Run \`npayload init\` to scaffold one.`);return null}let o=t.environments.filter(s=>s.kind==="production");if(o.length===0)throw new Error('npayload.toml declares no production environment \u2014 add `[env.production]` with `kind = "production"`. `np deploy` targets production only.');if(o.length>1)throw new Error(`npayload.toml declares ${o.length} production environments (${o.map(s=>s.slug).join(", ")}) \u2014 exactly one is permitted.`);let r=o[0];if(e.explicitSlug&&e.explicitSlug!==r.slug)throw new Error(`np deploy targets the production environment ("${r.slug}") only \u2014 "${e.explicitSlug}" is not it. For development environments use \`np env use ${e.explicitSlug}\` + \`np push\`.`);let a=(e.knownEnvs!==void 0?e.knownEnvs:ln(n)).find(s=>s.slug===r.slug);return{slug:r.slug,kind:r.kind,...r.deployBranch?{deployBranch:r.deployBranch}:{},...a?.envId?{envId:a.envId}:{}}}i(fn,"resolveDeployEnv");var N=class extends Error{static{i(this,"CliUsageError")}exitCode=1;constructor(n){super(n),this.name="CliUsageError"}};function dt(e,n,t){switch(n){case"number":{let o=Number(e);if(Number.isNaN(o))throw new N(`--${t} expects a number, got "${e}"`);return o}case"boolean":{if(e==="true"||e==="")return!0;if(e==="false")return!1;throw new N(`--${t} expects true|false, got "${e}"`)}case"json":try{return JSON.parse(e)}catch{throw new N(`--${t} expects JSON, got "${e}"`)}default:return e}}i(dt,"coerceFlagValue");function pt(e){return e!=="GET"&&e!=="HEAD"}i(pt,"isMutatingMethod");function ut(e){return e.replace(/:([A-Za-z0-9_]+)/g,"{$1}")}i(ut,"kernelPathOf");function qo(e){let{row:n,positionals:t}=e,{["idempotency-key"]:o,...r}=e.flags;if(t.length!==n.pathParams.length)throw new N(`${n.commandPath.join(" ")} expects ${n.pathParams.length} argument(s) (${n.pathParams.map(f=>`<${f.key}>`).join(" ")}), got ${t.length}`);let c={};n.pathParams.forEach((f,u)=>{c[f.key]=t[u]});let a=n.flags.filter(f=>!f.optional&&!(f.name in r)).map(f=>`--${f.name}`);if(a.length>0)throw new N(`${n.commandPath.join(" ")} missing required flag(s): ${a.join(", ")}`);let s=new Map(n.flags.map(f=>[f.name,f])),l={};for(let[f,u]of Object.entries(r)){let m=s.get(f);if(!m)throw new N(`${n.commandPath.join(" ")} has no flag --${f}`);l[f]=dt(u,m.coerce,f)}let h=ut(n.pattern),g=n.method!=="GET"&&n.method!=="HEAD",y={method:n.method==="HEAD"?"GET":n.method,path:h,...Object.keys(c).length>0?{pathParams:c}:{},...n.scopes.length>0?{scope:n.scopes.join(" ")}:{}};if(g)Object.keys(l).length>0&&(y.body=l);else if(Object.keys(l).length>0){let f={};for(let[u,m]of Object.entries(l))f[u]=typeof m=="object"?JSON.stringify(m):m;y.query=f}return n.idempotent&&pt(n.method)&&(y.idempotencyKey=o!==void 0?o:e.newIdempotencyKey(),o!==void 0&&(y.idempotencyKeySupplied=!0)),y}i(qo,"buildKernelRequest");var ft={list:{method:"GET",path:"/v1/account/environments",scope:"account:read",idempotent:!0},create:{method:"POST",path:"/v1/account/environments",scope:"account:write",idempotent:!1},show:{method:"GET",path:"/v1/account/environments/{slug}",scope:"account:read",idempotent:!0},clone:{method:"POST",path:"/v1/account/environments/{slug}/clone",scope:"account:write",idempotent:!1},bind:{method:"POST",path:"/v1/account/environments/{slug}/bind",scope:"account:write",idempotent:!1}};function gn(e,n){let t=ft[e],o={method:t.method,path:t.path,scope:t.scope,envless:!0};if(e==="create"){let r=n;if(!r)throw new N("env create requires --name, --slug and --kind");if(!me(r.kind))throw new N(`env create: --kind MUST be one of development | production, got "${String(r.kind)}"`);o.body={name:r.name,slug:r.slug,kind:r.kind,...r.deployBranch?{deployBranch:r.deployBranch}:{}}}else if(e==="show"){let r=n;if(!r?.slug)throw new N("env show requires a <slug>");o.path=t.path.replace("{slug}",encodeURIComponent(r.slug))}else if(e==="clone"){let r=n;if(!r?.slug||!r.targetSlug)throw new N("env clone requires <source-slug> and <target-slug>");o.path=t.path.replace("{slug}",encodeURIComponent(r.slug)),o.body={targetSlug:r.targetSlug,...r.targetName?{targetName:r.targetName}:{},...r.withData?{mode:"config_and_data"}:{},...r.confirmation?{confirmation:r.confirmation}:{}}}else if(e==="bind"){let r=n;if(!r?.slug)throw new N("np deploy needs the production environment's slug");o.path=t.path.replace("{slug}",encodeURIComponent(r.slug))}return o}i(gn,"buildEnvRequest");function gt(e){if(e&&typeof e=="object"&&!Array.isArray(e)){let n=e,t=n.data;return t&&typeof t=="object"&&!Array.isArray(t)&&"bound"in t?t:n}return{}}i(gt,"asRecord");async function mn(e){let n=e.print??(()=>{}),t=gt(await e.send(gn("bind",{slug:e.slug}))),o={bound:t.bound===!0,created:t.created===!0,...typeof t.pool=="string"?{pool:t.pool}:{},...typeof t.cellId=="string"?{cellId:t.cellId}:{}};if(!o.bound)throw new Error(`production environment "${e.slug}" is not bound: nothing was deployed`);let r=o.cellId??"(cell id not returned)",c=o.pool?` (pool: ${o.pool})`:"";return n(o.created?`\u2192 production environment "${e.slug}" provisioned and bound to cell ${r}${c}`:`\u2192 production environment "${e.slug}" already bound to cell ${r}${c}`),o}i(mn,"bindProductionBeforeDeploy");import{execFileSync as mt}from"child_process";var se=class extends Error{static{i(this,"DeployBranchError")}expected;current;constructor(n,t,o){let r=t.join('" or "');super(`Refusing to deploy to environment "${n}" from branch "${o}". This environment deploys only from "${r}". Switch to "${r}" (or open a PR), or pass --allow-branch ${o} to deploy from this branch deliberately (CI).`),this.name="DeployBranchError",this.expected=t,this.current=o}};function ht(e){return e.deployBranch?[e.deployBranch]:["main","master"]}i(ht,"expectedDeployBranches");function yt(e,n){let t=ht(e),o=n??"(detached or not a git repository)";return n&&t.includes(n)?{ok:!0}:{ok:!1,expected:t,current:o}}i(yt,"checkDeployBranch");async function hn(e){let n=e.currentBranch!==void 0?e.currentBranch:vt(e.cwd),t=yt(e.env,n);if(t.ok)return;if(e.allowBranch!==void 0){if(n&&e.allowBranch===n)return;throw new se(e.env.slug,t.expected,t.current)}if((e.isTTY??!!process.stdin.isTTY)&&e.confirm){let r=`You are on branch "${t.current}" but environment "${e.env.slug}" deploys from "${t.expected.join('" or "')}". Deploy from "${t.current}" anyway?`;if(await e.confirm(r))return}throw new se(e.env.slug,t.expected,t.current)}i(hn,"enforceDeployBranchGuard");function vt(e=process.cwd()){try{let n=mt("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return n==="HEAD"||n===""?void 0:n}catch{return}}i(vt,"getCurrentBranch");import{createHash as wt}from"crypto";import{writeFileSync as bt}from"fs";function ve(e,n=0){if(!e||n>12)return"unknown";if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum.map(o=>JSON.stringify(o)).join(" | ");switch(Array.isArray(e.type)?e.type[0]:e.type){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";case"array":return`Array<${ve(e.items,n+1)}>`;case"object":{let o=e.properties??{},r=new Set(e.required??[]),c=Object.keys(o).sort();return c.length===0?"Record<string, unknown>":`{
4
4
  ${c.map(s=>{let l=r.has(s)?"":"?";return` ${JSON.stringify(s)}${l}: ${ve(o[s],n+1)};`}).join(`
@@ -47,10 +47,10 @@ export default defineEventsConfig;
47
47
  `)),process.exit(1)}})}i(Gr,"registerDeploy");async function Vt(e,n,t,o,r){let c=[],a=0,s=t.ops.list,l=t.ops.create;if(!s||!l)return c.push({resource:n,identity:"(singleton)",action:"noop",reason:"no list/upsert binding"}),{plan:c,applied:a};if(K(s.pattern).includes("appId")&&!r.appId)return c.push({resource:n,identity:"(singleton)",action:"noop",reason:"unresolved appId"}),{plan:c,applied:a};let h={};for(let m of K(s.pattern))m==="appId"&&r.appId&&(h.appId=r.appId);let g=await _(e,{method:s.method,path:G(s.pattern),...Object.keys(h).length?{pathParams:h}:{}},`${n}.get`);if(g&&typeof g=="object")for(let m of["data","settings",n]){let p=g[m];if(p&&typeof p=="object"&&!Array.isArray(p)){g=p;break}}let y={};for(let[m,p]of Object.entries(o))(!g||!Z(g[m],p))&&(y[m]=p);if(Object.keys(y).length===0)return c.push({resource:n,identity:"(singleton)",action:"noop",reason:"in sync"}),{plan:c,applied:a};let f=g?"update":"create";if(r.check)return c.push({resource:n,identity:"(singleton)",action:f}),{plan:c,applied:a};let u={};for(let m of K(l.pattern))m==="appId"&&r.appId&&(u.appId=r.appId);try{await _(e,{method:l.method,path:G(l.pattern),...Object.keys(u).length?{pathParams:u}:{},body:y},`${n}.upsert`),c.push({resource:n,identity:"(singleton)",action:f}),a++}catch(m){M(m);let p=m.message??String(m);if(/\b403\b|forbidden/i.test(p))c.push({resource:n,identity:"(singleton)",action:"noop",reason:"requires org-admin credential (admin-gated \u2014 manage via dashboard, or deploy with admin auth)"});else throw m}return{plan:c,applied:a}}i(Vt,"reconcileSingleton");async function Ht(e,n,t){let o=[],r=[],c=0,a=Object.keys(n);if(a.length===0)return{plans:o,applied:c,notes:r};a.length>1&&r.push(`teams: one team per environment is supported \u2014 reconciling "${a[0]}", skipping ${a.slice(1).join(", ")}.`);let s=a[0],l=n[s],h=pe(l.members)??[],g=typeof l.description=="string"?l.description:void 0,y=await _(e,{method:"GET",path:"/v1/primus/teams"},"teams.get"),f=y?.lead?.gid,u=(y?.specialists??[]).filter(d=>!!(d.gid&&d.name)),m=new Map;try{let d=await _(e,{method:"GET",path:"/v1/primus/agents"},"agents.list");for(let k of Oe(d?.data??d)){let R=typeof k.name=="string"?k.name:void 0,T=U(k);R&&T&&m.set(R,T)}}catch(d){M(d)}if(f){let d=(y?.lead?.name??"")!==s,k=g!==void 0&&(y?.lead?.description??void 0)!==g;d||k?t.check?o.push({resource:"teams",identity:s,action:"update"}):(await _(e,{method:"PATCH",path:"/v1/primus/teams/{teamId}",pathParams:{teamId:f},body:{...d?{name:s}:{},...k?{description:g}:{}}},"teams.update"),o.push({resource:"teams",identity:s,action:"update"}),c++):o.push({resource:"teams",identity:s,action:"noop",reason:"in sync"})}else if(t.check)o.push({resource:"teams",identity:s,action:"create"});else{let d=await _(e,{method:"POST",path:"/v1/primus/teams",body:{name:s,...g?{businessContext:g}:{}}},"teams.create");f=d?.gid??d?.lead?.gid,o.push({resource:"teams",identity:s,action:"create"}),c++}let p=new Set(u.map(d=>d.name));for(let d of h){if(p.has(d))continue;let k=m.get(d);if(!k){r.push(`teams "${s}": member "${d}" not found among agents \u2014 declare it in agents{} (or fix the name).`);continue}if(t.check){o.push({resource:"teams.member",identity:d,action:"create"});continue}try{await _(e,{method:"POST",path:"/v1/primus/teams/assign",body:{agentGid:k}},"teams.assignAgent"),o.push({resource:"teams.member",identity:d,action:"create"}),c++}catch(R){M(R),r.push(`teams "${s}": could not assign "${d}" (${R.message??"error"}).`)}}let E=new Set(h);for(let d of u)if(!E.has(d.name)){if(!t.prune){r.push(`teams "${s}": "${d.name}" is on the team but not declared \u2014 run with --prune to unassign it.`);continue}if(t.check){o.push({resource:"teams.member",identity:d.name,action:"delete"});continue}try{await _(e,{method:"POST",path:"/v1/primus/teams/unassign",body:{agentGid:d.gid}},"teams.unassignAgent"),o.push({resource:"teams.member",identity:d.name,action:"delete"}),c++}catch(k){M(k),r.push(`teams "${s}": could not unassign "${d.name}" (${k.message??"error"}).`)}}return{plans:o,applied:c,notes:r}}i(Ht,"reconcileTeams");async function zt(e,n,t,o,r,c){let a=await ke(t);if(!e.check){await Zt(a);let{resolveSecretRefs:p,loadSecretEnv:E}=await import("./chunk-BBHWYMQA.mjs"),d=E(t);a=p(a,d.env,d.searched)}let s=Nt(a,n.resources),l=n.name==="primus"?a.teams:void 0,h=!!l&&Object.keys(l).length>0;if(s.length===0&&!h){let p=`[${n.name}] no declared resources in ${t}`;return c(x.dim(p+`
48
48
  `)),{plans:[],applied:0,note:p}}let g=[...s,...h?["teams"]:[]];c(x.bold(`[${n.name}] ${e.check?"Plan":"Deploy"} \u2014 ${g.length} resource type(s): ${g.join(", ")}
49
49
  `));let y=new Map;for(let p of s)y.set(p,new Set(Object.keys(a[p]??{})));let f=new Map,u=[],m=0;for(let p of s){let E=n.resources[p];if(E?.singleton){let R=await Vt(o,p,E,a[p],{...r!==void 0?{appId:r}:{},registry:f,check:e.check??!1,prune:e.prune??!1,declaredParents:y});u.push(...R.plan),m+=R.applied;continue}let d=a[p],k=await Yt(o,p,E,d,{...r!==void 0?{appId:r}:{},registry:f,check:e.check??!1,prune:e.prune??!1,declaredParents:y});u.push(...k.plan),m+=k.applied}if(h&&l){let p=await Ht(o,l,{check:e.check??!1,prune:e.prune??!1});u.push(...p.plans),m+=p.applied;for(let E of p.notes)c(x.yellow(` \u26A0 ${E}
50
- `))}return{plans:u,applied:m}}i(zt,"reconcileProduct");async function Sn(e){let n=e.json?v=>{}:e.sink??(v=>void process.stdout.write(v));if(e.prune&&!e.check&&!e.yes){let v="--prune will DELETE every live resource not declared in the config.";if(!process.stdin.isTTY)throw new Error(`${v} Refusing without a TTY; pass --yes to proceed.`);let{createInterface:w}=await import("readline/promises"),b=w({input:process.stdin,output:process.stderr});try{let S=await b.question(`${v} Continue? [y/N] `);if(!/^y(es)?$/i.test(S.trim()))throw new Error("prune aborted by user")}finally{b.close()}}let t=e.resolvedEnv?.slug??(e.env?.trim()||"sandbox"),o=Date.now(),r=e.resolvedEnv?e.resolvedEnv.kind==="production":t==="production",c=t;n(bn(e.check?"plan":r?"deploy":"push",[c]));let a=[];if(e.config){let v=Pn(e.config)?e.config:z(process.cwd(),e.config),w=ie.find(b=>v.includes(`${b.name}.config`))??ie[0];a.push({product:w,configPath:v})}else for(let v of ie){let w=xn(v);w&&a.push({product:v,configPath:w})}if(a.length===0)return n(x.yellow("No <product>.config.ts found (events.config.ts / primus.config.ts). Run `npayload init`.\n")),{plan:[],applied:0,output:"No product config found."};let{assertScopesGate:s}=await import("./chunk-X3CZMXOZ.mjs"),l=await s({check:e.check??!1}),h={readOnly:e.check===!0},g=await Re(void 0,t,h),y=Ge(process.env.NPAYLOAD_PRIMUS_API_URL,"primusApiUrl"),f=y?await Re(y,t,h):g,u=await ye(g,e);if(!u)throw new Error("Could not resolve your app. Your credentials may be invalid or missing. Run `npayload doctor` to see which credential source is in use, then `npayload login` to re-provision (or set NPAYLOAD_APP_ID).");if(Se=void 0,!e.check&&a.length>0){let v=[];try{let{projectPermissions:w,projectPipesPermissions:b,projectPrimusPermissions:S}=await import("./chunk-ORT5FUFW.mjs"),{writeScopesModule:P}=await import("./chunk-TUWFD3AZ.mjs"),A=new Set;for(let{product:C,configPath:I}of a){let j=await ke(I),X=C.name==="events"?w(j):C.name==="pipes"?b(j):C.name==="primus"?S(j):[];for(let Q of X)A.add(Q)}let O=H(kn(a[0].configPath),"permissions.generated.ts");v=P([...A],O),n(x.dim(` permissions.generated.ts \u2014 ${v.length} per-object scope(s) across ${a.length} product(s)
50
+ `))}return{plans:u,applied:m}}i(zt,"reconcileProduct");async function Sn(e){let n=e.json?v=>{}:e.sink??(v=>void process.stdout.write(v));if(e.prune&&!e.check&&!e.yes){let v="--prune will DELETE every live resource not declared in the config.";if(!process.stdin.isTTY)throw new Error(`${v} Refusing without a TTY; pass --yes to proceed.`);let{createInterface:w}=await import("readline/promises"),b=w({input:process.stdin,output:process.stderr});try{let S=await b.question(`${v} Continue? [y/N] `);if(!/^y(es)?$/i.test(S.trim()))throw new Error("prune aborted by user")}finally{b.close()}}let t=e.resolvedEnv?.slug??(e.env?.trim()||"sandbox"),o=Date.now(),r=e.resolvedEnv?e.resolvedEnv.kind==="production":t==="production",c=t;n(bn(e.check?"plan":r?"deploy":"push",[c]));let a=[];if(e.config){let v=Pn(e.config)?e.config:z(process.cwd(),e.config),w=ie.find(b=>v.includes(`${b.name}.config`))??ie[0];a.push({product:w,configPath:v})}else for(let v of ie){let w=xn(v);w&&a.push({product:v,configPath:w})}if(a.length===0)return n(x.yellow("No <product>.config.ts found (events.config.ts / primus.config.ts). Run `npayload init`.\n")),{plan:[],applied:0,output:"No product config found."};let{assertScopesGate:s}=await import("./chunk-FY32IC3I.mjs"),l=await s({check:e.check??!1}),h={readOnly:e.check===!0},g=await Re(void 0,t,h),y=Ge(process.env.NPAYLOAD_PRIMUS_API_URL,"primusApiUrl"),f=y?await Re(y,t,h):g,u=await ye(g,e);if(!u)throw new Error("Could not resolve your app. Your credentials may be invalid or missing. Run `npayload doctor` to see which credential source is in use, then `npayload login` to re-provision (or set NPAYLOAD_APP_ID).");if(Se=void 0,!e.check&&a.length>0){let v=[];try{let{projectPermissions:w,projectPipesPermissions:b,projectPrimusPermissions:S}=await import("./chunk-47FWIF2H.mjs"),{writeScopesModule:P}=await import("./chunk-AM74KBVG.mjs"),A=new Set;for(let{product:C,configPath:I}of a){let j=await ke(I),X=C.name==="events"?w(j):C.name==="pipes"?b(j):C.name==="primus"?S(j):[];for(let Q of X)A.add(Q)}let O=H(kn(a[0].configPath),"permissions.generated.ts");v=P([...A],O),n(x.dim(` permissions.generated.ts \u2014 ${v.length} per-object scope(s) across ${a.length} product(s)
51
51
  `))}catch(w){n(x.yellow(` (permissions codegen skipped: ${w instanceof Error?w.message:String(w)})
52
- `))}if(l)try{let{runDeclaredGrantSync:w}=await import("./chunk-X3CZMXOZ.mjs"),{computeFloor:b}=await import("./chunk-R6DPWMZM.mjs"),{syncExactGrant:S}=await import("./chunk-UDLS46F5.mjs"),{setAccessScopes:P}=await import("./chunk-26BFOUGE.mjs"),A=await b({components:l.embedComponents}),O=e.acceptRemote?"accept-remote":e.overwriteRemote?"overwrite-remote":"none";await w({declared:l.accessScopes,floor:A,appGid:u,resolution:O,readRemoteGrant:i(async C=>{let{restoreSession:I}=await import("./chunk-7QTR5IWG.mjs"),j=await I();return j?j.getOacGrant(C):null},"readRemoteGrant"),syncGrant:i(async(C,I)=>{await S(I,C,n)},"syncGrant"),writeManifestScopes:i(C=>{l.path&&xt(l.path,P(An(l.path,"utf8"),C),"utf8")},"writeManifestScopes"),log:n})}catch(w){M(w);let{ScopeDriftError:b,ScopeFloorError:S}=await import("./chunk-X3CZMXOZ.mjs");if(w instanceof b||w instanceof S)throw w;n(x.yellow(` (declared-scope sync deferred: ${w instanceof Error?w.message:String(w)} \u2014 re-run after \`npayload login\`)
53
- `))}else{let{syncCredentialScopes:w}=await import("./chunk-UDLS46F5.mjs");await w(v,u,n)}}let m=i(async(v,w)=>{let b=[],S=[],P=0;for(let{product:A,configPath:O}of a){let C=A.name==="primus"?f:g,I=await zt(v,A,O,C,u,w);if(b.push(...I.plans),I.note&&S.push(I.note),P+=I.applied,A.name==="events"&&!v.check)try{let j=await ke(O),X=H(kn(O),"_generated");At(X,{recursive:!0});let Q=yn(j.eventTypes,H(X,"events.d.ts"));Q>0&&w(x.dim(` _generated/events.d.ts \u2014 ${Q} typed event payload(s)
52
+ `))}if(l)try{let{runDeclaredGrantSync:w}=await import("./chunk-FY32IC3I.mjs"),{computeFloor:b}=await import("./chunk-Q3RG3NEU.mjs"),{syncExactGrant:S}=await import("./chunk-SKJL2WB7.mjs"),{setAccessScopes:P}=await import("./chunk-26BFOUGE.mjs"),A=await b({components:l.embedComponents}),O=e.acceptRemote?"accept-remote":e.overwriteRemote?"overwrite-remote":"none";await w({declared:l.accessScopes,floor:A,appGid:u,resolution:O,readRemoteGrant:i(async C=>{let{restoreSession:I}=await import("./chunk-MNKWLZS2.mjs"),j=await I();return j?j.getOacGrant(C):null},"readRemoteGrant"),syncGrant:i(async(C,I)=>{await S(I,C,n)},"syncGrant"),writeManifestScopes:i(C=>{l.path&&xt(l.path,P(An(l.path,"utf8"),C),"utf8")},"writeManifestScopes"),log:n})}catch(w){M(w);let{ScopeDriftError:b,ScopeFloorError:S}=await import("./chunk-FY32IC3I.mjs");if(w instanceof b||w instanceof S)throw w;n(x.yellow(` (declared-scope sync deferred: ${w instanceof Error?w.message:String(w)} \u2014 re-run after \`npayload login\`)
53
+ `))}else{let{syncCredentialScopes:w}=await import("./chunk-SKJL2WB7.mjs");await w(v,u,n)}}let m=i(async(v,w)=>{let b=[],S=[],P=0;for(let{product:A,configPath:O}of a){let C=A.name==="primus"?f:g,I=await zt(v,A,O,C,u,w);if(b.push(...I.plans),I.note&&S.push(I.note),P+=I.applied,A.name==="events"&&!v.check)try{let j=await ke(O),X=H(kn(O),"_generated");At(X,{recursive:!0});let Q=yn(j.eventTypes,H(X,"events.d.ts"));Q>0&&w(x.dim(` _generated/events.d.ts \u2014 ${Q} typed event payload(s)
54
54
  `))}catch(j){w(x.yellow(` (typed-events codegen skipped: ${j instanceof Error?j.message:String(j)})
55
55
  `))}}return{plans:b,notes:S,applied:P}},"reconcileAll"),p,E=await Dt({plan:i(async()=>(p=await m({...e,check:!0},e.check?n:()=>{}),p.plans),"plan"),apply:i(async()=>e.check?p:await m(e,n),"apply")}),d=E.applied.plans,k=E.applied.notes,R=E.applied.applied;Wt(d,e.check??!1,n);let T;if(e.check){let v=d.filter(P=>P.action==="create").length,w=d.filter(P=>P.action==="update").length,b=d.filter(P=>P.action==="delete").length,S=$e(d).length;T=`Plan: ${v} to create, ${w} to update, ${b} to delete, ${d.length-v-w-b-S} unchanged${S?`, ${S} FAILED`:""}.`,n(x.bold(`
56
56
  ${T}
@@ -0,0 +1 @@
1
+ import{l as a,m as b}from"./chunk-W5UKL26F.mjs";import"./chunk-BNGQVWMV.mjs";import"./chunk-33VA5RSC.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-CJDCY2NH.mjs";import"./chunk-F6RREQEH.mjs";import"./chunk-XLK55DEY.mjs";import"./chunk-N6NIJISZ.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-QQC6352X.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{a as buildReport,b as registerDoctor};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-LJNU5QHZ.mjs";var t="4733cbf89a6b8a9c96c26de1b5df06bba969130890e64b8d404f8fe4ce6bca25";function s(n){return n}e(s,"defineEventsConfig");var r={channels:{identity:"slug",deps:[],refs:{},ops:{archive:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/archive",scopes:["channels:admin"],pathParams:{channelId:"channelGid"}},create:{convexFn:"",method:"POST",pattern:"/v1/apps/channels",scopes:["channels:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/apps/channels",scopes:["channels:read"]},pause:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/pause",scopes:["channels:write"],pathParams:{channelId:"channelGid"}},remove:{convexFn:"",method:"DELETE",pattern:"/v1/channels/:channelId",scopes:["channels:admin"],pathParams:{channelId:"channelGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/resume",scopes:["channels:write"],pathParams:{channelId:"channelGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/channels/:channelId",scopes:["channels:write"],pathParams:{channelId:"channelGid"},updatable:["complianceClass","nppMinQos","rateLimit","name","description","status","schema","settings","privacy","replication","compactionConfig","schemaValidation","platformConnectEnforcement","metadata","pii"]}}},consumerGroups:{identity:"name",deps:["channels"],refs:{channelGid:{parent:"channels",product:"events",wire:"gid",identity:"slug",array:!1,publicField:"channelGid"}},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelGid/consumer-groups",scopes:["consumer_groups:write"],pathParams:{channelGid:"channelGid"}},join:{convexFn:"",method:"POST",pattern:"/v1/consumer-groups/:consumerGroupGid/members",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"},updatable:["subscriptionGid"]},leave:{convexFn:"",method:"DELETE",pattern:"/v1/consumer-groups/:consumerGroupGid/members/:subscriptionGid",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid",subscriptionGid:"subscriptionGid"}},list:{convexFn:"",method:"GET",pattern:"/v1/channels/:channelGid/consumer-groups",scopes:["consumer_groups:read"],pathParams:{channelGid:"channelGid"}},pause:{convexFn:"",method:"POST",pattern:"/v1/consumer-groups/:consumerGroupGid/pause",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/consumer-groups/:consumerGroupGid/resume",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/consumer-groups/:consumerGroupGid",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"},updatable:["strategy","maxConcurrency"]}}},eventTypes:{identity:"name",deps:["channels"],refs:{channels:{parent:"channels",product:"events",wire:"gid",identity:"slug",array:!0,publicField:"channels"}},ops:{activate:{convexFn:"",method:"POST",pattern:"/v1/events/types/:eventTypeGid/activate",scopes:["catalogue:write"],pathParams:{eventTypeGid:"eventTypeGid"}},deprecate:{convexFn:"",method:"POST",pattern:"/v1/events/types/:eventTypeGid/deprecate",scopes:["catalogue:admin"],pathParams:{eventTypeGid:"eventTypeGid"},updatable:["message","sunsetDate"]},list:{convexFn:"",method:"GET",pattern:"/v1/apps/events/types",scopes:["catalogue:read"]},create:{convexFn:"",method:"POST",pattern:"/v1/apps/events/types",scopes:["catalogue:write"]},registerVersion:{convexFn:"",method:"POST",pattern:"/v1/events/types/:eventTypeGid/versions",scopes:["catalogue:write"],pathParams:{eventTypeGid:"eventTypeGid"},updatable:["version","schema","compatibility","changelog","publishedBy"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/events/types/:eventTypeGid",scopes:["catalogue:write"],pathParams:{eventTypeGid:"eventTypeGid"},updatable:["displayName","description","ownership","channels","tags","schema"]}}},exchanges:{identity:"name",deps:[],refs:{},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/exchanges",scopes:["exchanges:write"]},createBinding:{convexFn:"",method:"POST",pattern:"/v1/exchanges/:exchange_gid/bindings",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"},updatable:["channelGid","routingKey","headerRules"]},pause:{convexFn:"",method:"POST",pattern:"/v1/exchanges/:exchange_gid/disable",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/exchanges/:exchange_gid/enable",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"}},list:{convexFn:"",method:"GET",pattern:"/v1/exchanges",scopes:["exchanges:read"]},remove:{convexFn:"",method:"DELETE",pattern:"/v1/exchanges/:exchange_gid",scopes:["exchanges:admin"],pathParams:{exchange_gid:"exchangeGid"}},removeBinding:{convexFn:"",method:"DELETE",pattern:"/v1/exchange-bindings/:binding_gid",scopes:["exchanges:write"],pathParams:{binding_gid:"bindingGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/exchanges/:exchange_gid",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"},updatable:["config"]}}},subscriptions:{identity:"name",deps:["channels"],refs:{channelGid:{parent:"channels",product:"events",wire:"gid",identity:"slug",array:!1,publicField:"channelGid"}},ops:{archive:{convexFn:"",method:"POST",pattern:"/v1/subscriptions/:subscriptionId/archive",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"}},create:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/subscriptions",scopes:["subscriptions:write"],pathParams:{channelId:"channelGid"}},list:{convexFn:"",method:"GET",pattern:"/v1/channels/:channelId/subscriptions",scopes:["subscriptions:read"],pathParams:{channelId:"channelGid"}},pause:{convexFn:"",method:"POST",pattern:"/v1/subscriptions/:subscriptionId/pause",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"}},remove:{convexFn:"",method:"DELETE",pattern:"/v1/subscriptions/:subscriptionId",scopes:["subscriptions:admin"],pathParams:{subscriptionId:"subscriptionGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/subscriptions/:subscriptionId/resume",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/subscriptions/:subscriptionId",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"},updatable:["description","status","filter","endpoint","delivery","dlq","metadata","deliveryConfig","transformPipeId","transformTimeout","transformOnFailure"]}}}};var o="41cca5221cf2d3f14ebe43426ffadbc50816dfa8db8d6325205687a732db66dc";function c(n){return n}e(c,"definePrimusConfig");var p={agents:{identity:"slug",deps:["skills"],refs:{skills:{parent:"skills",product:"primus",wire:"gid",identity:"name",array:!0,publicField:"skills"}},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/agents",scopes:["agents:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/agents",scopes:["agents:read"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/agents/:agentId",scopes:["agents:write"],pathParams:{agentId:"agentGid"},updatable:["name","description","systemPrompt","personality","language","skills","enabledIntegrations","trustLevel","defaultModel","maxTurns","config"]}}},skills:{identity:"slug",deps:[],refs:{},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/skills",scopes:["skills:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/skills",scopes:["skills:read"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/skills/:skillId",scopes:["skills:write"],pathParams:{skillId:"skillGid"},updatable:["name","description","category","icon","executor","enabled","definition","limits"]}}},tools:{identity:"slug",deps:[],refs:{},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/tools",scopes:["tools:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/tools",scopes:["tools:read"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/tools/:toolId",scopes:["tools:write"],pathParams:{toolId:"toolGid"},updatable:["description","parameters","outputSchema","riskLevel","requiresApproval","endpoint","executor","timeout","category","secretRef","headers"]}}},triggers:{identity:"slug",deps:["agents"],refs:{agentGid:{parent:"agents",product:"primus",wire:"gid",identity:"slug",array:!1,publicField:"agentGid"}},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/triggers",scopes:["triggers:write"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/triggers/:triggerId",scopes:["triggers:write"],pathParams:{triggerId:"triggerGid"},updatable:["name","description","config","action","conditions","enabled"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/triggers",scopes:["triggers:read"]}}}};export{t as a,s as b,r as c,o as d,c as e,p as f};
1
+ import{a as e}from"./chunk-LJNU5QHZ.mjs";var t="dc3cb629dd49ea35025a10e40f58ee3165989ab7d43c13dff891a90efe5d1914";function s(n){return n}e(s,"defineEventsConfig");var r={channels:{identity:"slug",deps:[],refs:{},ops:{archive:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/archive",scopes:["channels:admin"],pathParams:{channelId:"channelGid"}},create:{convexFn:"",method:"POST",pattern:"/v1/apps/channels",scopes:["channels:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/apps/channels",scopes:["channels:read"]},pause:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/pause",scopes:["channels:write"],pathParams:{channelId:"channelGid"}},remove:{convexFn:"",method:"DELETE",pattern:"/v1/channels/:channelId",scopes:["channels:admin"],pathParams:{channelId:"channelGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/resume",scopes:["channels:write"],pathParams:{channelId:"channelGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/channels/:channelId",scopes:["channels:write"],pathParams:{channelId:"channelGid"},updatable:["complianceClass","nppMinQos","rateLimit","name","description","status","schema","settings","privacy","replication","compactionConfig","schemaValidation","platformConnectEnforcement","metadata","pii"]}}},consumerGroups:{identity:"name",deps:["channels"],refs:{channelGid:{parent:"channels",product:"events",wire:"gid",identity:"slug",array:!1,publicField:"channelGid"}},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelGid/consumer-groups",scopes:["consumer_groups:write"],pathParams:{channelGid:"channelGid"}},join:{convexFn:"",method:"POST",pattern:"/v1/consumer-groups/:consumerGroupGid/members",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"},updatable:["subscriptionGid"]},leave:{convexFn:"",method:"DELETE",pattern:"/v1/consumer-groups/:consumerGroupGid/members/:subscriptionGid",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid",subscriptionGid:"subscriptionGid"}},list:{convexFn:"",method:"GET",pattern:"/v1/channels/:channelGid/consumer-groups",scopes:["consumer_groups:read"],pathParams:{channelGid:"channelGid"}},pause:{convexFn:"",method:"POST",pattern:"/v1/consumer-groups/:consumerGroupGid/pause",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/consumer-groups/:consumerGroupGid/resume",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/consumer-groups/:consumerGroupGid",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"},updatable:["strategy","maxConcurrency"]}}},eventTypes:{identity:"name",deps:["channels"],refs:{channels:{parent:"channels",product:"events",wire:"gid",identity:"slug",array:!0,publicField:"channels"}},ops:{activate:{convexFn:"",method:"POST",pattern:"/v1/events/types/:eventTypeGid/activate",scopes:["catalogue:write"],pathParams:{eventTypeGid:"eventTypeGid"}},deprecate:{convexFn:"",method:"POST",pattern:"/v1/events/types/:eventTypeGid/deprecate",scopes:["catalogue:admin"],pathParams:{eventTypeGid:"eventTypeGid"},updatable:["message","sunsetDate"]},list:{convexFn:"",method:"GET",pattern:"/v1/apps/events/types",scopes:["catalogue:read"]},create:{convexFn:"",method:"POST",pattern:"/v1/apps/events/types",scopes:["catalogue:write"]},registerVersion:{convexFn:"",method:"POST",pattern:"/v1/events/types/:eventTypeGid/versions",scopes:["catalogue:write"],pathParams:{eventTypeGid:"eventTypeGid"},updatable:["version","schema","compatibility","changelog","publishedBy"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/events/types/:eventTypeGid",scopes:["catalogue:write"],pathParams:{eventTypeGid:"eventTypeGid"},updatable:["displayName","description","ownership","channels","tags","schema"]}}},exchanges:{identity:"name",deps:[],refs:{},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/exchanges",scopes:["exchanges:write"]},createBinding:{convexFn:"",method:"POST",pattern:"/v1/exchanges/:exchange_gid/bindings",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"},updatable:["channelGid","routingKey","headerRules"]},pause:{convexFn:"",method:"POST",pattern:"/v1/exchanges/:exchange_gid/disable",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/exchanges/:exchange_gid/enable",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"}},list:{convexFn:"",method:"GET",pattern:"/v1/exchanges",scopes:["exchanges:read"]},remove:{convexFn:"",method:"DELETE",pattern:"/v1/exchanges/:exchange_gid",scopes:["exchanges:admin"],pathParams:{exchange_gid:"exchangeGid"}},removeBinding:{convexFn:"",method:"DELETE",pattern:"/v1/exchange-bindings/:binding_gid",scopes:["exchanges:write"],pathParams:{binding_gid:"bindingGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/exchanges/:exchange_gid",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"},updatable:["config"]}}},subscriptions:{identity:"name",deps:["channels"],refs:{channelGid:{parent:"channels",product:"events",wire:"gid",identity:"slug",array:!1,publicField:"channelGid"}},ops:{archive:{convexFn:"",method:"POST",pattern:"/v1/subscriptions/:subscriptionId/archive",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"}},create:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/subscriptions",scopes:["subscriptions:write"],pathParams:{channelId:"channelGid"}},list:{convexFn:"",method:"GET",pattern:"/v1/channels/:channelId/subscriptions",scopes:["subscriptions:read"],pathParams:{channelId:"channelGid"}},pause:{convexFn:"",method:"POST",pattern:"/v1/subscriptions/:subscriptionId/pause",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"}},remove:{convexFn:"",method:"DELETE",pattern:"/v1/subscriptions/:subscriptionId",scopes:["subscriptions:admin"],pathParams:{subscriptionId:"subscriptionGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/subscriptions/:subscriptionId/resume",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/subscriptions/:subscriptionId",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"},updatable:["description","status","filter","endpoint","delivery","dlq","metadata","deliveryConfig","transformPipeId","transformTimeout","transformOnFailure"]}}}};var o="41cca5221cf2d3f14ebe43426ffadbc50816dfa8db8d6325205687a732db66dc";function c(n){return n}e(c,"definePrimusConfig");var p={agents:{identity:"slug",deps:["skills"],refs:{skills:{parent:"skills",product:"primus",wire:"gid",identity:"name",array:!0,publicField:"skills"}},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/agents",scopes:["agents:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/agents",scopes:["agents:read"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/agents/:agentId",scopes:["agents:write"],pathParams:{agentId:"agentGid"},updatable:["name","description","systemPrompt","personality","language","skills","enabledIntegrations","trustLevel","defaultModel","maxTurns","config"]}}},skills:{identity:"slug",deps:[],refs:{},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/skills",scopes:["skills:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/skills",scopes:["skills:read"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/skills/:skillId",scopes:["skills:write"],pathParams:{skillId:"skillGid"},updatable:["name","description","category","icon","executor","enabled","definition","limits"]}}},tools:{identity:"slug",deps:[],refs:{},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/tools",scopes:["tools:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/tools",scopes:["tools:read"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/tools/:toolId",scopes:["tools:write"],pathParams:{toolId:"toolGid"},updatable:["description","parameters","outputSchema","riskLevel","requiresApproval","endpoint","executor","timeout","category","secretRef","headers"]}}},triggers:{identity:"slug",deps:["agents"],refs:{agentGid:{parent:"agents",product:"primus",wire:"gid",identity:"slug",array:!1,publicField:"agentGid"}},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/triggers",scopes:["triggers:write"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/triggers/:triggerId",scopes:["triggers:write"],pathParams:{triggerId:"triggerGid"},updatable:["name","description","config","action","conditions","enabled"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/triggers",scopes:["triggers:read"]}}}};export{t as a,s as b,r as c,o as d,c as e,p as f};
@@ -1,4 +1,4 @@
1
- import{a as p}from"./chunk-GG7UQYUV.mjs";import{a as l,b as m}from"./chunk-IH2OLS7G.mjs";import"./chunk-WOMYXKGW.mjs";import"./chunk-ZDOLKWQD.mjs";import{l as i,o as c}from"./chunk-CFM43QNN.mjs";import"./chunk-TQFAYJEP.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-HX6PH7C3.mjs";import"./chunk-AGDMCMF3.mjs";import"./chunk-CJDCY2NH.mjs";import"./chunk-M7WGBUJ2.mjs";import"./chunk-XLK55DEY.mjs";import"./chunk-N6NIJISZ.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-OA73YMB6.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import{a as n}from"./chunk-LJNU5QHZ.mjs";var r=class extends Error{static{n(this,"ScopeFloorError")}gap;constructor(t){super(`npayload.toml [access_scopes] does not cover the required scope floor \u2014 ${t.length} scope(s) missing:
1
+ import{a as p}from"./chunk-5L5EATJW.mjs";import{a as l,b as m}from"./chunk-YZGGWQC5.mjs";import"./chunk-IWWVVZC7.mjs";import"./chunk-MWLEDQSA.mjs";import{l as i,o as c}from"./chunk-BNGQVWMV.mjs";import"./chunk-33VA5RSC.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-UV2R4VAS.mjs";import"./chunk-WG5MUAXT.mjs";import"./chunk-CJDCY2NH.mjs";import"./chunk-F6RREQEH.mjs";import"./chunk-XLK55DEY.mjs";import"./chunk-N6NIJISZ.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-QQC6352X.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import{a as n}from"./chunk-LJNU5QHZ.mjs";var r=class extends Error{static{n(this,"ScopeFloorError")}gap;constructor(t){super(`npayload.toml [access_scopes] does not cover the required scope floor \u2014 ${t.length} scope(s) missing:
2
2
  ${t.join(`
3
3
  `)}
4
4
  Run \`npayload scopes fix\` to append exactly these to the manifest.`),this.name="ScopeFloorError",this.gap=t}},s=class extends Error{static{n(this,"ScopeDriftError")}diff;constructor(t){super(`The remote grant has drifted from the manifest \u2014 refusing to overwrite it silently.
@@ -0,0 +1 @@
1
+ import{a,b,c,d}from"./chunk-UZ4TQPD3.mjs";import"./chunk-WG5MUAXT.mjs";import"./chunk-LJNU5QHZ.mjs";export{b as adminExtraCommands,d as loadExtraCommandRows,a as loadPrimusCliCommands,c as pipesExtraCommands};
@@ -1,5 +1,5 @@
1
- import{a as g}from"./chunk-4NWQCPI4.mjs";import{c as p,f}from"./chunk-M7WGBUJ2.mjs";import{h as d}from"./chunk-AECDYMA2.mjs";import{a as c}from"./chunk-LJNU5QHZ.mjs";import a from"chalk";function u(){let e=new Set;for(let t of[p,g,f])for(let o of Object.values(t))for(let n of Object.values(o.ops))for(let s of n.scopes??[])e.add(s);return e.add("account:read"),e.add("account:write"),[...e].sort()}c(u,"reconcileOpScopes");function m(e){return[...new Set([...e,...u()])].sort()}c(m,"computePushGrant");async function O(e,t,o){if(!t){o(a.dim(` (credential scopes not synced \u2014 no app id on this run)
2
- `));return}try{let{restoreSession:n}=await import("./chunk-7QTR5IWG.mjs"),s=await n();if(!s){o(a.dim(" (credential scopes not synced \u2014 run `npayload login` once to let push manage them)\n"));return}let r=m(e),l=(await s.provisionOac(null,t,!1,r)).allowedScopes?.length??r.length;o(a.dim(` credential scopes \u2014 synced to the config (${l} per-object scope(s))
1
+ import{a as g}from"./chunk-4NWQCPI4.mjs";import{c as p,f}from"./chunk-F6RREQEH.mjs";import{h as d}from"./chunk-AECDYMA2.mjs";import{a as c}from"./chunk-LJNU5QHZ.mjs";import a from"chalk";function u(){let e=new Set;for(let t of[p,g,f])for(let o of Object.values(t))for(let n of Object.values(o.ops))for(let s of n.scopes??[])e.add(s);return e.add("account:read"),e.add("account:write"),[...e].sort()}c(u,"reconcileOpScopes");function m(e){return[...new Set([...e,...u()])].sort()}c(m,"computePushGrant");async function O(e,t,o){if(!t){o(a.dim(` (credential scopes not synced \u2014 no app id on this run)
2
+ `));return}try{let{restoreSession:n}=await import("./chunk-MNKWLZS2.mjs"),s=await n();if(!s){o(a.dim(" (credential scopes not synced \u2014 run `npayload login` once to let push manage them)\n"));return}let r=m(e),l=(await s.provisionOac(null,t,!1,r)).allowedScopes?.length??r.length;o(a.dim(` credential scopes \u2014 synced to the config (${l} per-object scope(s))
3
3
  `))}catch(n){d(n);let s=n instanceof Error?n.message:String(n);o(a.yellow(` (credential scopes not synced: ${s} \u2014 config is applied; re-run \`npayload push\` after \`npayload login\`)
4
- `))}}c(O,"syncCredentialScopes");async function R(e,t,o=()=>{}){let n=[...new Set(e)].sort(),{restoreSession:s}=await import("./chunk-7QTR5IWG.mjs"),r=await s();if(!r)throw new Error("declared [access_scopes] sync needs the human management session \u2014 run `npayload login` (a machine credential can never widen its own grant).");let i=await r.provisionOac(null,t,!1,n),l=i.allowedScopes?.length??n.length;return o(a.dim(` credential scopes \u2014 grant set-equal to the manifest (${l} scope(s))
4
+ `))}}c(O,"syncCredentialScopes");async function R(e,t,o=()=>{}){let n=[...new Set(e)].sort(),{restoreSession:s}=await import("./chunk-MNKWLZS2.mjs"),r=await s();if(!r)throw new Error("declared [access_scopes] sync needs the human management session \u2014 run `npayload login` (a machine credential can never widen its own grant).");let i=await r.provisionOac(null,t,!1,n),l=i.allowedScopes?.length??n.length;return o(a.dim(` credential scopes \u2014 grant set-equal to the manifest (${l} scope(s))
5
5
  `)),{allowedScopes:i.allowedScopes??n}}c(R,"syncExactGrant");export{u as a,m as b,O as c,R as d};
@@ -0,0 +1 @@
1
+ import{i as a,j as b,k as c,l as d,m as e,n as f,o as g}from"./chunk-O2J73777.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-QQC6352X.mjs";import"./chunk-SRJTV2LW.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{a as CliDoorRefusal,c as CliSession,g as appCreateRefusalMessage,f as deviceLogin,b as readDoorRefusal,d as restoreSession,e as verificationPage};
@@ -1 +1 @@
1
- import{F as i,G as c}from"./chunk-CFM43QNN.mjs";import{a as e,b as n,c as t}from"./chunk-HX6PH7C3.mjs";import{a as o}from"./chunk-LJNU5QHZ.mjs";var a={events:e,pipes:n,primus:t};async function u(){let s=new Set;for(let[f,p]of Object.entries(a)){let r=i(f);if(!r)continue;let g=await c(r);for(let m of p(g))s.add(m)}return[...s].sort()}o(u,"projectAllPermissions");export{u as a};
1
+ import{F as i,G as c}from"./chunk-BNGQVWMV.mjs";import{a as e,b as n,c as t}from"./chunk-UV2R4VAS.mjs";import{a as o}from"./chunk-LJNU5QHZ.mjs";var a={events:e,pipes:n,primus:t};async function u(){let s=new Set;for(let[f,p]of Object.entries(a)){let r=i(f);if(!r)continue;let g=await c(r);for(let m of p(g))s.add(m)}return[...s].sort()}o(u,"projectAllPermissions");export{u as a};
@@ -0,0 +1,3 @@
1
+ import{e as m,g as x}from"./chunk-LCUELOEE.mjs";import{d as b,e as A,f as v}from"./chunk-QQC6352X.mjs";import{a as R}from"./chunk-SRJTV2LW.mjs";import{b as _,h as $}from"./chunk-AECDYMA2.mjs";import{ca as u}from"./chunk-VZT7RCAC.mjs";import{a as s}from"./chunk-LJNU5QHZ.mjs";import{hostname as V}from"os";import{SignJWT as W,importJWK as B}from"jose";import{readFileSync as L}from"fs";import{join as z,dirname as E}from"path";import{fileURLToPath as G}from"url";var S="@npayload/sdk",re=["@npayload/npayload"];function C(){try{let n=E(G(import.meta.url));for(let e=0;e<6;e++){try{let r=JSON.parse(L(z(n,"package.json"),"utf8"));if(r.name===S&&r.version)return r.version}catch{}let t=E(n);if(t===n)break;n=t}}catch{}return null}s(C,"resolveRuntimeVersion");function O(){return C()??R}s(O,"cliVersion");function oe(){let n=C();return n?`${S}@${n}`:S}s(oe,"installPinSpec");import{generateKeyPair as H,exportJWK as D,calculateJwkThumbprint as M}from"jose";async function j(){let{publicKey:n,privateKey:e}=await H("ES256",{extractable:!0}),t=await D(n),r=await D(e);return{kid:(await M(t,"sha256")).slice(0,12),alg:"ES256",publicJwk:t,privateJwk:r,createdAt:Date.now()}}s(j,"generateDpopKeypair");import I from"chalk";var p=class extends Error{static{s(this,"RevokedSessionError")}constructor(e="Your npayload CLI session was revoked."){super(e),this.name="RevokedSessionError"}};function pe(n){if(n instanceof p)return!0;let e=(n instanceof Error?n.message:String(n)).toLowerCase();return/fetch failed|econnrefused|etimedout|enotfound|eai_again|network|socket hang up|aborted|timed? ?out|and_error|dns/.test(e)?!1:/revoked|invalid_grant|unauthorized|session[_ ]?revoked|\b401\b/.test(e)}s(pe,"isRevokedError");function de(n={}){let e=n.write??(r=>void process.stderr.write(r)),t=n.exit??(r=>process.exit(r));e(`
2
+ `+I.red("\u2716 Your npayload CLI session was revoked.")+`
3
+ `),e(" "+I.yellow("\u2192")+" Run `npayload login` to re-authenticate.\n\n"),t(1)}s(de,"exitRevoked");var y=class extends Error{constructor(t,r,o){super(t);this.reason=r;this.httpStatus=o;this.name="CliDoorRefusal"}static{s(this,"CliDoorRefusal")}};function Pe(n){if(n===null||typeof n!="object")return;let e=n;if(!(e.name!=="CliDoorRefusal"||typeof e.httpStatus!="number"))return{reason:typeof e.reason=="string"?e.reason:void 0,httpStatus:e.httpStatus}}s(Pe,"readDoorRefusal");function U(n){return x(n).base}s(U,"authBase");function d(n,e){return _(m())(n,e)}s(d,"dial");function Y(){try{let n=V();return n?n.slice(0,80):void 0}catch{return}}s(Y,"safeHostname");function q(){let n=new Uint8Array(16);return crypto.getRandomValues(n),Array.from(n,e=>e.toString(16).padStart(2,"0")).join("")}s(q,"randomJti");function F(n){let e="";for(let t of n)e+=String.fromCharCode(t);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}s(F,"base64url");async function Z(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return F(new Uint8Array(e))}s(Z,"accessTokenHash");async function w(n,e,t,r){let o=await B(n.privateJwk,"ES256"),i=new URL(t),l={htm:e.toUpperCase(),htu:`${i.origin}${i.pathname}`,jti:q()};return r&&(l.ath=await Z(r)),new W(l).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:n.publicJwk}).setIssuedAt().sign(o)}s(w,"signDpopProof");var k=class{constructor(e,t,r,o){this.accessToken=e;this.refreshToken=t;this.keypair=r;this.base=o}static{s(this,"CliSession")}async call(e,t,r,o=!0,i=15e3){let l=`${this.base}/oauth/cli/${t}`,g=await w(this.keypair,e,l,this.accessToken),f=await d(l,{method:e,headers:{Authorization:`DPoP ${this.accessToken}`,DPoP:g,...r!==void 0?{"Content-Type":"application/json"}:{}},body:r!==void 0?JSON.stringify(r):void 0,signal:AbortSignal.timeout(i)});return f.status===401&&o&&await this.refresh()?this.call(e,t,r,!1,i):f}async refresh(){let e=`${this.base}/oauth/cli/refresh`,t=await w(this.keypair,"POST",e,this.refreshToken),r=await d(e,{method:"POST",headers:{Authorization:`DPoP ${this.refreshToken}`,DPoP:t},signal:AbortSignal.timeout(15e3)});if(!r.ok)return!1;let o=await r.json();return o.accessToken?(this.accessToken=o.accessToken,await b({accessToken:this.accessToken,refreshToken:this.refreshToken,dpopKeypair:this.keypair,storedAt:Date.now()}),!0):!1}async listOrgs(){let e=await this.call("GET","orgs");if(!e.ok)throw new Error(`Could not list organizations (${e.status}).`);return(await e.json()).orgs}async listApps(e){let t=await this.call("GET",`apps?orgId=${encodeURIComponent(e)}`);if(!t.ok)throw new Error(`Could not list apps (${t.status}).`);return(await t.json()).apps}async createApp(e,t){let r=await this.call("POST","apps",{orgId:e,...t});if(!r.ok){let o=await r.json().catch(()=>({}));throw new y(N(o.error,r.status,{slug:t.platformSlug}),o.error,r.status)}return await r.json()}async registerPlatform(e,t){let r=await this.call("POST","platforms",{orgId:e,slug:t.slug,...t.name!==void 0?{name:t.name}:{}});if(!r.ok){let o=await r.json().catch(()=>({}));throw new y(N(o.error,r.status,{slug:t.slug,door:"platforms"}),o.error,r.status)}return await r.json()}async provisionOac(e,t,r=!1,o){let i=await this.call("POST","oac",{...e?{orgId:e}:{},appGid:t,rotate:r,...o&&o.length>0?{requestedScopes:o}:{}});if(!i.ok)throw new Error(`Could not provision credentials (${i.status}).`);return await i.json()}async getOacGrant(e){let t;try{t=await this.call("GET",`oac?appGid=${encodeURIComponent(e)}`)}catch(o){return $(o),null}if(!t.ok)return null;let r=await t.json().catch(()=>({}));return{scopes:r.allowedScopes??[],configDrift:r.configDrift===!0}}async post(e,t,r=6e4){let o=await this.call("POST",e,t,!0,r);if(!o.ok){let i=await o.json().catch(()=>({}));throw new Error(i.message??i.error??`Request failed (${o.status}).`)}return await o.json()}async logout(){let e;try{let t=`${this.base}/oauth/cli/revoke`,r=await w(this.keypair,"POST",t,this.refreshToken);await d(t,{method:"POST",headers:{Authorization:`DPoP ${this.refreshToken}`,DPoP:r},signal:AbortSignal.timeout(8e3)})}catch(t){t instanceof u&&(e=t)}if(await v(),e!==void 0)throw e}async logoutAll(){let e;try{let t=`${this.base}/oauth/cli/revoke`,r=await w(this.keypair,"POST",t,this.refreshToken);await d(t,{method:"POST",headers:{Authorization:`DPoP ${this.refreshToken}`,DPoP:r,"Content-Type":"application/json"},body:JSON.stringify({all:!0}),signal:AbortSignal.timeout(8e3)})}catch(t){t instanceof u&&(e=t)}if(await v(),e!==void 0)throw e}sessionId(){try{let e=this.accessToken.split(".")[1];if(!e)return null;let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof t.sid=="string"?t.sid:null}catch{return null}}orgId(){try{let e=this.accessToken.split(".")[1];if(!e)return null;let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8")),r=t["npayload/orgId"]??t.orgId??t.org??t.org_id;return typeof r=="string"&&r.length>0?r:null}catch{return null}}async heartbeat(e){let t=await this.call("POST","heartbeat",{verb:e});if(t.status===401)throw new p;if(!t.ok)throw new Error(`heartbeat failed (${t.status})`)}async whoami(){let e=await this.call("GET","whoami");if(e.status===401)throw new p;if(!e.ok)throw new Error(`whoami failed (${e.status})`);let t=await e.json().catch(()=>({}));return{sid:typeof t.sid=="string"?t.sid:this.sessionId(),label:typeof t.label=="string"?t.label:null}}};async function _e(n){let e=await A();return e?new k(e.accessToken,e.refreshToken,e.dpopKeypair,U(n)):null}s(_e,"restoreSession");function Q(n){if(Array.isArray(n))return"a JSON array";if(n===null)return"JSON null";if(typeof n!="string")return`a JSON ${typeof n}, not a string`;if(n==="")return"an empty string";let e=/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(n)?.[1];return e===void 0?"a string with no scheme":/^https?$/i.test(e)?`an address under the ${e.toLowerCase()}: scheme with no // after it, or with no host`:`an address under the ${e.toLowerCase()}: scheme`}s(Q,"pageForm");function J(n,e){if(e!==void 0){if(typeof e=="string"&&/^https?:\/\//i.test(e))try{let t=new URL(e);if((t.protocol==="http:"||t.protocol==="https:")&&t.hostname!=="")return t.href}catch{}throw new u(`The device sign-in's answer names its ${n} as ${Q(e)}, not an absolute http(s) URL: the sign-in ends here, before anything is printed or opened.`)}}s(J,"verificationPage");async function $e(n){let e=U(n.authUrl);m().check(`${e}/oauth/cli/code`),n.onStart?.(e);let t=await j(),r;try{r=await d(`${e}/oauth/cli/code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dpop_jwk:t.publicJwk,hostname:Y(),os:process.platform,cli_version:O()}),signal:AbortSignal.timeout(15e3)})}catch(c){if(c instanceof u)throw c;let a=c instanceof Error?c.message:String(c);throw new Error(`Could not reach the npayload auth service at ${e} (${a}). Check your network connection, or set NPAYLOAD_AUTH_URL if your account uses another sign-in endpoint, then retry.`)}if(r.status===429)throw new Error("Too many sign-in attempts from this network. Please wait a minute and try again.");if(!r.ok)throw new Error(`Could not start login (${r.status}). Is the auth service reachable at ${e}?`);let o=await r.json(),i=J("verification_uri_complete",o.verification_uri_complete),l=J("verification_uri",o.verification_uri);if(i===void 0&&l===void 0)throw new u("The device sign-in's answer names no verification page, so there is nothing to print or open: the sign-in ends here.");m().checkPages(...[i,l].filter(c=>c!==void 0)),n.onPrompt({userCode:o.user_code,verificationUri:l??"",verificationUriComplete:i??"",expiresIn:o.expires_in});let g=(o.interval||5)*1e3,f=Date.now()+o.expires_in*1e3,T=!1,h=null,P=s(()=>{T=!0,h?.()},"onSigint");process.once("SIGINT",P);try{for(;Date.now()<f;){if(T||n.signal?.aborted)throw new Error("Login cancelled.");n.onPoll?.();let c=null;try{c=await d(`${e}/oauth/cli/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:o.device_code,dpop_jwk:t.publicJwk}),signal:AbortSignal.timeout(15e3)})}catch(a){if(a instanceof u)throw a;c=null}if(c){let a=await c.json().catch(()=>({}));if(c.ok&&a.access_token&&a.refresh_token)return await b({accessToken:a.access_token,refreshToken:a.refresh_token,dpopKeypair:t,storedAt:Date.now()}),new k(a.access_token,a.refresh_token,t,e);switch(a.error){case"authorization_pending":break;case"slow_down":g=(a.interval??g/1e3+5)*1e3;break;case"access_denied":throw new Error("Login was denied in the browser.");case"expired_token":throw new Error("The login code expired. Please run the command again.");default:if(!c.ok&&c.status>=500)throw new Error("The auth service returned an error. Please try again.")}}await new Promise(a=>{let K=setTimeout(()=>{h=null,a()},g);h=s(()=>{clearTimeout(K),h=null,a()},"wakeSleep")})}throw new Error("Login timed out. Please run the command again.")}finally{process.removeListener("SIGINT",P)}}s($e,"deviceLogin");function N(n,e,t={}){let r=t.slug??"this platform slug",o=t.organization??"your organization";switch(n){case"platform_not_registered":return`${r} is not registered to ${o} \u2014 register it as your own platform, or build on it as a standard connect app`;case"platform_claimed":return`${r} is operated by another organization \u2014 build on it as a standard connect app`;case"connect_write_required":return`registering ${r} needs an admin or owner of ${o}, or a member holding org:connect:write \u2014 ask an organization admin`;case"slug_taken":return"That slug is already taken.";case"reserved_slug":return"That slug is reserved. Choose another slug.";case"invalid_slug":return"That slug is not valid \u2014 lowercase alphanumeric with hyphens, no leading/trailing hyphens.";case"missing_tenancy_mode":return"The control plane requires a tenancy mode (none | tenanted) and this CLI did not send one \u2014 update npayload to the latest version.";case"invalid_tenancyMode":return'Tenancy mode must be exactly "none" or "tenanted".';case"feed_cannot_be_tenanted":return'A feed app cannot be tenanted \u2014 create it with tenancy "none".';case"invalid_appType":return"App type must be internal, connect, or feed.";case"invalid_subtype":return"Connect subtype must be device, mobile, or platform.";case"invalid_platform":return"Platform slug is not valid for this connect app.";case"missing_args":return"App name and slug are both required.";case"missing_tenancy_mode_flip_blocked":case"insufficient_scope":return`Your credential lacks the scope to create apps here (${n}).`;default:return t.door==="platforms"?`Could not register the platform (${n??"no reason given"}, HTTP ${e}).`:`Could not create app (${n??"no reason given"}, HTTP ${e}).`}}s(N,"appCreateRefusalMessage");export{S as a,re as b,C as c,O as d,oe as e,p as f,pe as g,de as h,y as i,Pe as j,k,_e as l,J as m,$e as n,N as o};
@@ -1 +1 @@
1
- import{F as a,G as b,H as c,I as d,J as e,K as f,L as g,M as h,N as i,O as j,P as k,Q as l,R as m,S as n,T as o,U as p,V as q,W as r,X as s,Y as t,Z as u,_ as v}from"./chunk-CFM43QNN.mjs";import"./chunk-TQFAYJEP.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-CJDCY2NH.mjs";import"./chunk-M7WGBUJ2.mjs";import"./chunk-XLK55DEY.mjs";import"./chunk-N6NIJISZ.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-OA73YMB6.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{c as READ_ONLY_SEND_BUDGET,h as assertPlanHasNoFailures,v as assertPushHasNoRawSecretHeaders,d as buildKernel,j as canonicalEntryOrder,k as canonicalPlan,o as changedFields,m as envFromCommandLine,g as failedRows,u as findConfig,a as findConfigForProduct,p as immutableDrift,q as isAlreadyExistsError,b as loadEventsConfig,f as planCreatePathParams,i as planThenApply,s as registerDeploy,e as resolveAppIdPublic,r as resolveExistingByIdentity,t as runDeploy,n as syncExitCode,l as yesFromCommandLine};
1
+ import{F as a,G as b,H as c,I as d,J as e,K as f,L as g,M as h,N as i,O as j,P as k,Q as l,R as m,S as n,T as o,U as p,V as q,W as r,X as s,Y as t,Z as u,_ as v}from"./chunk-BNGQVWMV.mjs";import"./chunk-33VA5RSC.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-CJDCY2NH.mjs";import"./chunk-F6RREQEH.mjs";import"./chunk-XLK55DEY.mjs";import"./chunk-N6NIJISZ.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-QQC6352X.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{c as READ_ONLY_SEND_BUDGET,h as assertPlanHasNoFailures,v as assertPushHasNoRawSecretHeaders,d as buildKernel,j as canonicalEntryOrder,k as canonicalPlan,o as changedFields,m as envFromCommandLine,g as failedRows,u as findConfig,a as findConfigForProduct,p as immutableDrift,q as isAlreadyExistsError,b as loadEventsConfig,f as planCreatePathParams,i as planThenApply,s as registerDeploy,e as resolveAppIdPublic,r as resolveExistingByIdentity,t as runDeploy,n as syncExitCode,l as yesFromCommandLine};
@@ -0,0 +1 @@
1
+ import{a,b,c}from"./chunk-YZGGWQC5.mjs";import"./chunk-IWWVVZC7.mjs";import"./chunk-MWLEDQSA.mjs";import"./chunk-BNGQVWMV.mjs";import"./chunk-33VA5RSC.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-UV2R4VAS.mjs";import"./chunk-WG5MUAXT.mjs";import"./chunk-CJDCY2NH.mjs";import"./chunk-F6RREQEH.mjs";import"./chunk-XLK55DEY.mjs";import"./chunk-N6NIJISZ.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-QQC6352X.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{a as computeFloor,c as coversFloor,b as floorGap};
@@ -0,0 +1,6 @@
1
+ import{a as i}from"./chunk-LJNU5QHZ.mjs";import{homedir as x}from"os";import{join as m}from"path";import{createHash as L}from"crypto";var o="npayload",v="default",C=process.env.NPAYLOAD_AUTH_HOME??m(x(),".npayload"),U=m(C,"credentials.json"),c=class extends Error{static{i(this,"KeychainUnavailableError")}cause;constructor(e){super(`The npayload CLI stores credentials in the OS keychain (macOS Keychain / Windows Credential Manager / Linux Secret Service), and it is not reachable here.
2
+ \u2022 On a desktop session: install/start a Secret Service (e.g. \`gnome-keyring\` or KWallet on Linux).
3
+ \u2022 Headless / CI / container: authenticate without a keychain by exporting machine credentials \u2014
4
+ export NPAYLOAD_CLIENT_ID=... NPAYLOAD_CLIENT_SECRET=... (or NPAYLOAD_TOKEN=<short-lived token>)
5
+ \u2022 Run \`npayload doctor\` to see exactly what is available on this host.
6
+ Plaintext credential files are intentionally NOT supported.`),this.name="KeychainUnavailableError",this.cause=e}};function g(t){return(t instanceof Error?t.message:String(t)).toLowerCase().includes("no matching entry")}i(g,"isNoEntryError");var u=null,h=null;async function O(){let t=await import("@napi-rs/keyring"),e=t.default??t;if(typeof e.AsyncEntry!="function")throw new Error("@napi-rs/keyring did not load an Entry class");return e}i(O,"loadRealKeyring");function T(t){return{async getPassword(e,n){try{return await new t.AsyncEntry(e,n).getPassword()??null}catch(r){if(g(r))return null;throw new c(r)}},async setPassword(e,n,r){try{await new t.AsyncEntry(e,n).setPassword(r)}catch(s){throw new c(s)}},async deletePassword(e,n){try{return await new t.AsyncEntry(e,n).deleteCredential()}catch(r){if(g(r))return!1;throw new c(r)}},async findCredentials(e){try{return await t.findCredentialsAsync(e)}catch(n){if(g(n))return[];throw new c(n)}}}}i(T,"adaptKeyring");async function l(){if(u)return u;let t;try{t=h?await h():await O()}catch(e){throw e instanceof c?e:new c(e)}return u=T(t),u}i(l,"loadKeytar");async function V(){try{return await(await l()).getPassword(o,"__probe__"),!0}catch{return!1}}i(V,"keychainAvailable");var P=1024,f=64,I="__npayload_part__/",y="npayloadParts",S=1;function A(){return process.platform==="win32"}i(A,"storesInParts");function p(t,e){return`${I}${t}/${e}`}i(p,"partAccount");function k(t,e){return L("sha256").update(JSON.stringify([t,e])).digest("hex")}i(k,"digestOf");function R(t){let e=[];for(let n=0;n<t.length;){let r=Math.min(n+P,t.length),s=t.charCodeAt(r-1);r<t.length&&s>=55296&&s<=56319&&(r-=1),e.push(t.slice(n,r)),n=r}return e}i(R,"splitValue");function N(t){let e;try{e=JSON.parse(t)}catch{return}if(e===null||typeof e!="object"||Array.isArray(e)||!(y in e))return;let n=e,{count:r,length:s,sha256:a}=n;return n[y]!==S||typeof r!="number"||!Number.isInteger(r)||r<1||r>f||typeof s!="number"||!Number.isInteger(s)||s<1||typeof a!="string"||!/^[0-9a-f]{64}$/.test(a)?null:{count:r,length:s,sha256:a}}i(N,"partsHeadOf");async function E(t,e){let n=await t.getPassword(o,e).catch(()=>null);return n?N(n)?.count??0:0}i(E,"knownParts");async function K(t,e,n,r){for(let s=n;s<=f;s+=1)if(!await t.deletePassword(o,p(e,s))&&s>r)return}i(K,"sweepParts");async function D(t,e,n){if(!A()){await t.setPassword(o,e,n);return}let r=n.length>P?R(n):[];if(r.length>f)throw new Error("These credentials are too large to save in the OS keychain.");let s=await E(t,e);for(let[d,_]of r.entries())await t.setPassword(o,p(e,d+1),_);await K(t,e,r.length+1,s);let a=r.length===0?n:JSON.stringify({[y]:S,count:r.length,length:n.length,sha256:k(e,n)});await t.setPassword(o,e,a)}i(D,"putValue");async function b(t,e){let n=await t.getPassword(o,e);if(!n)return null;let r=N(n);if(r===void 0)return n;if(r===null)return null;let s="";for(let a=1;a<=r.count;a+=1){let d=await t.getPassword(o,p(e,a));if(!d)return null;s+=d}return s.length===r.length&&k(e,s)===r.sha256?s:null}i(b,"getValue");async function M(t,e){A()&&await K(t,e,1,await E(t,e)),await t.deletePassword(o,e)}i(M,"removeValue");async function W(t=v){let e=await l(),n=await b(e,t);if(!n)return null;try{return JSON.parse(n)}catch{return null}}i(W,"getStoredCredentials");var w="__management__";async function Y(t){let e=await l();await D(e,w,JSON.stringify({...t,storedAt:t.storedAt||Date.now()}))}i(Y,"saveManagementSession");async function $(){let t=await l(),e=await b(t,w);if(!e)return null;try{return JSON.parse(e)}catch{return null}}i($,"getManagementSession");async function j(){let t=await l();await M(t,w)}i(j,"clearManagementSession");export{c as a,V as b,W as c,Y as d,$ as e,j as f};
@@ -1 +1 @@
1
- import{a,b,c,d}from"./chunk-WOMYXKGW.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-M7WGBUJ2.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{b as computePushGrant,a as reconcileOpScopes,c as syncCredentialScopes,d as syncExactGrant};
1
+ import{a,b,c,d}from"./chunk-IWWVVZC7.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-F6RREQEH.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{b as computePushGrant,a as reconcileOpScopes,c as syncCredentialScopes,d as syncExactGrant};
@@ -0,0 +1 @@
1
+ var e="6.0.0";var t=e,i="npayload",o=`${i}/${t}`;export{t as a,i as b,o as c};
@@ -1 +1 @@
1
- import{a as c}from"./chunk-AGDMCMF3.mjs";import{a as i}from"./chunk-LJNU5QHZ.mjs";function n(s){return!!s&&Object.keys(s).length>0}i(n,"nonEmpty");function a(){let s={};for(let e of c.commands)if(e.key.split(".")[0]==="events")for(let r of e.scopes??[]){let[d,t]=r.split(":");!d||!t||d!=="events"&&(s[d]??=new Set).add(t)}return s}i(a,"enforcedVerbsByResource");var g=a();function o(s,e){for(let r of g[e]??[])s.add(`${e}:${r}`)}i(o,"grantAll");function l(s){let e=new Set,r=s.channels??{},d=s.subscriptions??{};if(n(r)){for(let t of["channels","messages","scheduled","snapshots","consumer_groups","dlq","archive","time_travel","storage_policies"])o(e,t);for(let t of Object.values(r))t&&(t.type==="stream"&&o(e,"streams"),(t.retentionMode==="compacted"||t.retentionMode==="compacted_with_log")&&o(e,"kv"))}if(n(d))for(let t of["subscriptions","dlq","snapshots"])o(e,t);return n(s.eventTypes)&&o(e,"catalogue"),n(s.exchanges)&&o(e,"exchanges"),n(s.crossChannels)&&o(e,"cross_channels"),e.size>0&&o(e,"keys"),[...e].sort()}i(l,"projectPermissions");function p(s){let e=new Set;return n(s.workflows)&&(e.add("pipes:read"),e.add("pipes:write"),e.add("pipes:execute")),n(s.credentials)&&(e.add("credentials:read"),e.add("credentials:write")),[...e].sort()}i(p,"projectPipesPermissions");function f(s){let e=new Set;if(n(s.agents))for(let r of["agents:read","agents:write","executions:read","executions:execute","conversations:read","conversations:write","memory:read","memory:write"])e.add(r);return n(s.skills)&&(e.add("skills:read"),e.add("skills:write")),n(s.tools)&&(e.add("tools:read"),e.add("tools:write")),n(s.triggers)&&(e.add("triggers:read"),e.add("triggers:write")),n(s.teams)&&(e.add("teams:read"),e.add("teams:write"),e.add("agents:read")),[...e].sort()}i(f,"projectPrimusPermissions");export{l as a,p as b,f as c};
1
+ import{a as c}from"./chunk-WG5MUAXT.mjs";import{a as i}from"./chunk-LJNU5QHZ.mjs";function n(s){return!!s&&Object.keys(s).length>0}i(n,"nonEmpty");function a(){let s={};for(let e of c.commands)if(e.key.split(".")[0]==="events")for(let r of e.scopes??[]){let[d,t]=r.split(":");!d||!t||d!=="events"&&(s[d]??=new Set).add(t)}return s}i(a,"enforcedVerbsByResource");var g=a();function o(s,e){for(let r of g[e]??[])s.add(`${e}:${r}`)}i(o,"grantAll");function l(s){let e=new Set,r=s.channels??{},d=s.subscriptions??{};if(n(r)){for(let t of["channels","messages","scheduled","snapshots","consumer_groups","dlq","archive","time_travel","storage_policies"])o(e,t);for(let t of Object.values(r))t&&(t.type==="stream"&&o(e,"streams"),(t.retentionMode==="compacted"||t.retentionMode==="compacted_with_log")&&o(e,"kv"))}if(n(d))for(let t of["subscriptions","dlq","snapshots"])o(e,t);return n(s.eventTypes)&&o(e,"catalogue"),n(s.exchanges)&&o(e,"exchanges"),n(s.crossChannels)&&o(e,"cross_channels"),e.size>0&&o(e,"keys"),[...e].sort()}i(l,"projectPermissions");function p(s){let e=new Set;return n(s.workflows)&&(e.add("pipes:read"),e.add("pipes:write"),e.add("pipes:execute")),n(s.credentials)&&(e.add("credentials:read"),e.add("credentials:write")),[...e].sort()}i(p,"projectPipesPermissions");function f(s){let e=new Set;if(n(s.agents))for(let r of["agents:read","agents:write","executions:read","executions:execute","conversations:read","conversations:write","memory:read","memory:write"])e.add(r);return n(s.skills)&&(e.add("skills:read"),e.add("skills:write")),n(s.tools)&&(e.add("tools:read"),e.add("tools:write")),n(s.triggers)&&(e.add("triggers:read"),e.add("triggers:write")),n(s.teams)&&(e.add("teams:read"),e.add("teams:write"),e.add("agents:read")),[...e].sort()}i(f,"projectPrimusPermissions");export{l as a,p as b,f as c};