@zhama/tego-plugin-sdk 1.36.1 → 1.37.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 (99) hide show
  1. package/README.md +50 -3
  2. package/agent/RULES.md +123 -0
  3. package/agent/guides/access.md +39 -0
  4. package/agent/guides/backend.md +76 -0
  5. package/agent/guides/claw.md +18 -0
  6. package/agent/guides/desktop-web.md +48 -0
  7. package/agent/guides/frontend.md +83 -0
  8. package/agent/guides/host-api-versions.md +34 -0
  9. package/agent/guides/i18n.md +17 -0
  10. package/agent/guides/manifest.md +26 -0
  11. package/agent/guides/migrations.md +17 -0
  12. package/agent/guides/storage.md +18 -0
  13. package/agent/guides/testing.md +17 -0
  14. package/agent/guides/ui.md +22 -0
  15. package/agent/reference/plugin-sdk-api.md +561 -0
  16. package/bin/tego-plugin-pack.mjs +1 -1
  17. package/bin/tego-plugin.mjs +4 -2
  18. package/dist/chunk-2NTAWYCG.js +1 -0
  19. package/dist/chunk-2P6UEAPV.cjs +1 -0
  20. package/dist/chunk-45Y4CR4R.cjs +1 -0
  21. package/dist/{chunk-THMWRUAT.cjs → chunk-4LKRXDYY.cjs} +13 -12
  22. package/dist/{chunk-7XHF3YSK.js → chunk-56QOZQTY.js} +1 -1
  23. package/dist/{chunk-C2OCOPZQ.cjs → chunk-6HNG5OZI.cjs} +1 -1
  24. package/dist/chunk-DEGQDJF6.js +1 -0
  25. package/dist/chunk-EIVA5BR6.js +1 -0
  26. package/dist/chunk-FCYAAOHC.js +20 -0
  27. package/dist/chunk-HZ4YWRYX.cjs +5 -0
  28. package/dist/chunk-I5Z3ECC4.js +5 -0
  29. package/dist/chunk-INCA3GFW.js +1 -0
  30. package/dist/chunk-IVJECPGG.js +1 -0
  31. package/dist/chunk-MWMGJJ74.cjs +1 -0
  32. package/dist/chunk-N4SXZZPY.cjs +1 -0
  33. package/dist/chunk-SKNPNPJP.cjs +1 -0
  34. package/dist/dev.cjs +358 -0
  35. package/dist/dev.d.cts +144 -0
  36. package/dist/dev.d.ts +144 -0
  37. package/dist/dev.js +358 -0
  38. package/dist/doctor.cjs +8 -0
  39. package/dist/doctor.d.cts +62 -0
  40. package/dist/doctor.d.ts +62 -0
  41. package/dist/doctor.js +8 -0
  42. package/dist/frontend.d.cts +33 -1
  43. package/dist/frontend.d.ts +33 -1
  44. package/dist/hono.cjs +1 -0
  45. package/dist/hono.d.cts +84 -0
  46. package/dist/hono.d.ts +84 -0
  47. package/dist/hono.js +1 -0
  48. package/dist/index.cjs +1 -1
  49. package/dist/index.d.cts +8 -3
  50. package/dist/index.d.ts +8 -3
  51. package/dist/index.js +1 -1
  52. package/dist/{manifest-types-DQARCQJt.d.cts → manifest-types-CUTNfJTa.d.cts} +1 -1
  53. package/dist/{manifest-types-DQARCQJt.d.ts → manifest-types-CUTNfJTa.d.ts} +1 -1
  54. package/dist/manifest.cjs +1 -1
  55. package/dist/manifest.d.cts +55 -2
  56. package/dist/manifest.d.ts +55 -2
  57. package/dist/manifest.js +1 -1
  58. package/dist/migrations-sync.cjs +1 -0
  59. package/dist/migrations-sync.d.cts +20 -0
  60. package/dist/migrations-sync.d.ts +20 -0
  61. package/dist/migrations-sync.js +1 -0
  62. package/dist/pack.cjs +1 -1
  63. package/dist/pack.d.cts +8 -2
  64. package/dist/pack.d.ts +8 -2
  65. package/dist/pack.js +1 -1
  66. package/dist/publish.cjs +1 -1
  67. package/dist/publish.d.cts +1 -1
  68. package/dist/publish.d.ts +1 -1
  69. package/dist/publish.js +1 -1
  70. package/dist/react.cjs +1 -0
  71. package/dist/react.d.cts +101 -0
  72. package/dist/react.d.ts +101 -0
  73. package/dist/react.js +1 -0
  74. package/dist/scaffold.cjs +672 -17
  75. package/dist/scaffold.d.cts +42 -18
  76. package/dist/scaffold.d.ts +42 -18
  77. package/dist/scaffold.js +674 -19
  78. package/dist/server-runtime.cjs +1 -1
  79. package/dist/server-runtime.d.cts +27 -2
  80. package/dist/server-runtime.d.ts +27 -2
  81. package/dist/server-runtime.js +1 -1
  82. package/dist/testing.cjs +6 -2
  83. package/dist/testing.d.cts +19 -1
  84. package/dist/testing.d.ts +19 -1
  85. package/dist/testing.js +6 -2
  86. package/dist/verify-FF2RD2MV.cjs +1 -0
  87. package/dist/verify-W7ZTUCO4.js +1 -0
  88. package/dist/vite.cjs +1 -1
  89. package/dist/vite.d.cts +27 -1
  90. package/dist/vite.d.ts +27 -1
  91. package/dist/vite.js +1 -1
  92. package/package.json +37 -3
  93. package/dist/chunk-3KUOBGJN.js +0 -19
  94. package/dist/chunk-3WA3M347.cjs +0 -1
  95. package/dist/chunk-5CU33JVY.js +0 -1
  96. package/dist/chunk-7K37PVGV.js +0 -5
  97. package/dist/chunk-BTHXQWHT.js +0 -1
  98. package/dist/chunk-ROFUQLOZ.cjs +0 -1
  99. package/dist/chunk-W7C357A6.cjs +0 -5
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var u=Object.defineProperty;var c=(e,o)=>u(e,"name",{value:o,configurable:!0});import{readFileSync as d}from"node:fs";const i=process.argv.slice(2),a=i[0];if(a==="create"){const{createStandalonePlugin:e}=await import("../dist/scaffold.js"),o=i.indexOf("--dir");try{const r=e(d(0,"utf8"),{parent:o===-1?".":i[o+1]??".",cwd:process.cwd()});process.stdout.write(`${JSON.stringify(r)}
3
- `)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exitCode=1}process.exit()}a!=="publish"&&(console.error("usage: tego-plugin create [--dir <parent>] | tego-plugin publish [options]"),process.exit(2));const{publishPlugin:f}=await import("../dist/publish.js"),n=i.slice(1);function s(e){const o=n.indexOf(`--${e}`);return o===-1?void 0:n[o+1]}c(s,"flag");function v(e){const o=[];for(let r=0;r<n.length;r++)n[r]===`--${e}`&&o.push(n[r+1]);return o}c(v,"all");const l=s("server")??process.env.TEGO_SERVER_URL,p=s("token")??process.env.TEGO_ADMIN_TOKEN;(!l||!p)&&(console.error("\u2716 --server (TEGO_SERVER_URL) and --token (TEGO_ADMIN_TOKEN) are both required"),process.exit(2));const g=v("avatar").filter(Boolean),t={};s("category")&&(t.category=s("category")),s("homepage")&&(t.homepage=s("homepage")),s("icon")&&(t.icon=s("icon"));try{const e=await f({root:s("root")??process.cwd(),server:l,token:p,...g.length>0?{avatarIds:g}:{},...Object.keys(t).length>0?{meta:t}:{},approve:!n.includes("--no-approve"),install:!n.includes("--no-install")}),o=e.release.semanticVersion;console.log(`\u2705 ${e.release.pluginId}@${o} \u2014 release ${e.release.status}`)}catch(e){console.error(`\u2716 ${e instanceof Error?e.message:String(e)}`),process.exitCode=1}
2
+ var v=Object.defineProperty;var l=(r,o)=>v(r,"name",{value:o,configurable:!0});import{readFileSync as x}from"node:fs";const c=process.argv.slice(2),p=c[0];if(p==="create"){const{createStandalonePlugin:r}=await import("../dist/scaffold.js"),o=c.indexOf("--dir");try{const e=await r(x(0,"utf8"),{parent:o===-1?".":c[o+1]??".",cwd:process.cwd()});process.stdout.write(`${JSON.stringify(e)}
3
+ `)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}process.exit()}if(p==="migrations"){const{syncMigrations:r}=await import("../dist/migrations-sync.js"),o=c[1];o!=="sync"&&o!=="check"&&(console.error("usage: tego-plugin migrations sync|check"),process.exit(2));const e=await r({root:process.cwd(),check:o==="check"});for(const{from:s,to:t}of e.copied)console.log(`${s} -> ${t}`);for(const s of e.problems)console.error(`\u2716 ${s}`);e.problems.length===0&&e.copied.length===0&&console.log("\u2705 migrations are in sync"),process.exit(e.problems.length>0?1:0)}if(p==="doctor"){const{runDoctor:r,formatDoctorReport:o}=await import("../dist/doctor.js"),e=c.slice(1),s=e.indexOf("--files");try{const t=await r({root:process.cwd(),files:s===-1?void 0:(e[s+1]??"").split(",").filter(Boolean)});process.stdout.write(e.includes("--json")?`${JSON.stringify(t)}
4
+ `:`${o(t)}
5
+ `),process.exit(t.errors>0?1:0)}catch(t){console.error(`\u2716 ${t instanceof Error?t.message:String(t)}`),process.exit(2)}}if(p==="dev"){const{startDevServer:r}=await import("../dist/dev.js"),o=c.slice(1),e=l(a=>{const u=o.indexOf(`--${a}`);return u===-1?void 0:o[u+1]},"value"),s=e("port");s!==void 0&&!/^\d+$/.test(s)&&(console.error(`\u2716 --port must be a number, not ${s}`),process.exit(2));let t;try{t=await r({root:process.cwd(),port:s===void 0?void 0:Number(s),host:e("host"),backend:!o.includes("--no-backend"),target:e("target")==="desktop"?"desktop":"web",databaseUrl:process.env.DATABASE_URL||void 0})}catch(a){console.error(`\u2716 ${a instanceof Error?a.message:String(a)}`),process.exit(1)}let g=!1;const f=l(async()=>{g||(g=!0,setTimeout(()=>process.exit(0),5e3).unref(),await t.close().catch(()=>{}),process.exit(0))},"stop");process.once("SIGINT",f),process.once("SIGTERM",f),await new Promise(()=>{})}else p!=="publish"&&(console.error("usage: tego-plugin create [--dir <parent>] | tego-plugin dev [--port <n>] [--no-backend] | tego-plugin doctor [--json] | tego-plugin publish [options]"),process.exit(2));const{publishPlugin:b}=await import("../dist/publish.js"),i=c.slice(1);function n(r){const o=i.indexOf(`--${r}`);return o===-1?void 0:i[o+1]}l(n,"flag");function $(r){const o=[];for(let e=0;e<i.length;e++)i[e]===`--${r}`&&o.push(i[e+1]);return o}l($,"all");const m=n("server")??process.env.TEGO_SERVER_URL,h=n("token")??process.env.TEGO_ADMIN_TOKEN;(!m||!h)&&(console.error("\u2716 --server (TEGO_SERVER_URL) and --token (TEGO_ADMIN_TOKEN) are both required"),process.exit(2));const w=$("avatar").filter(Boolean),d={};n("category")&&(d.category=n("category")),n("homepage")&&(d.homepage=n("homepage")),n("icon")&&(d.icon=n("icon"));try{const r=await b({root:n("root")??process.cwd(),server:m,token:h,...w.length>0?{avatarIds:w}:{},...Object.keys(d).length>0?{meta:d}:{},approve:!i.includes("--no-approve"),install:!i.includes("--no-install")}),o=r.release.semanticVersion;console.log(`\u2705 ${r.release.pluginId}@${o} \u2014 release ${r.release.status}`)}catch(r){console.error(`\u2716 ${r instanceof Error?r.message:String(r)}`),process.exitCode=1}
@@ -0,0 +1 @@
1
+ var m=Object.defineProperty;var $=(o,s)=>m(o,"name",{value:s,configurable:!0});import{PLUGIN_SUPPORTED_LOCALES as N}from"./chunk-INCA3GFW.js";var g=/^([a-z]{2}(?:-[A-Za-z]{2,4})?)\.json$/,y=/^(\d{4,})_[A-Za-z0-9._-]+\.sql$/;function d(o,s="",n=new Set){if(typeof o!="object"||o===null||Array.isArray(o))return n.add(s),n;for(const[t,i]of Object.entries(o))d(i,s?`${s}.${t}`:t,n);return n}$(d,"flattenLocaleKeys");async function j(o,s){const n=[],t=[],i=new Map;for(const e of await o.list(s.i18nDirPath)){const r=g.exec(e);if(!r?.[1]){n.push(`Frontend i18n file "${s.i18nDirPath}/${e}" is not named "<locale>.json".`);continue}t.push(r[1])}if(!(s.nav.length>0||t.length>0))return{locales:t,bundles:i,errors:n};const p=N.filter(e=>!t.includes(e));p.length>0&&n.push(`Frontend part must ship a bundle for every supported locale in "${s.i18nDirPath}"; missing ${p.join(", ")}.`);const c=new Map;for(const e of t){const r=`${s.i18nDirPath}/${e}.json`,h=await o.readText(r);if(h===null)continue;let a;try{a=JSON.parse(h)}catch(u){n.push(`Frontend i18n file "${r}" is not valid JSON: ${u instanceof Error?u.message:"parse error"}`);continue}i.set(e,a),c.set(e,d(a))}const l=c.get("zh-CN");if(l){for(const[e,r]of c){if(e==="zh-CN")continue;const h=[...l].filter(u=>!r.has(u)).sort(),a=[...r].filter(u=>!l.has(u)).sort();h.length>0&&n.push(`Frontend i18n "${e}.json" is missing ${h.length} key(s) present in zh-CN.json: ${h.slice(0,5).join(", ")}${h.length>5?", ...":""}`),a.length>0&&n.push(`Frontend i18n "${e}.json" declares ${a.length} key(s) absent from zh-CN.json: ${a.slice(0,5).join(", ")}${a.length>5?", ...":""}`)}for(const e of s.nav)l.has(e.labelKey)||n.push(`Nav entry "${e.key}" points at i18n key "${e.labelKey}", which zh-CN.json does not define.`)}return{locales:t,bundles:i,errors:n}}$(j,"verifyFrontendLocales");async function b(o,s){const n=[],t=[],i=new Map;for(const f of await o.list(s)){const p=y.exec(f);if(!p?.[1]){n.push(`Migration "${s}/${f}" must be named "<ordinal>_<description>.sql", for example "0001_initial.sql".`);continue}const c=p[1],l=i.get(c);if(l){n.push(`Migrations "${l}" and "${f}" share ordinal ${c}, so their apply order would be ambiguous.`);continue}i.set(c,f),t.push(f)}return{migrations:t.sort(),errors:n}}$(b,"verifyMigrationNames");export{g as LOCALE_FILENAME_PATTERN,y as MIGRATION_FILENAME_PATTERN,d as flattenLocaleKeys,j as verifyFrontendLocales,b as verifyMigrationNames};
@@ -0,0 +1 @@
1
+ "use strict";var d=Object.defineProperty;var s=(t,e)=>d(t,"name",{value:e,configurable:!0});var PLUGIN_NAV_ICONS=["bar-chart","bell","bookmark","book-open","bot","briefcase","building","calendar","chart-pie","clipboard-list","clock","contact","credit-card","database","file-text","folder","globe","handshake","inbox","key","layers","layout-dashboard","library","link","list-todo","mail","map-pin","message-square","mic","package","phone","puzzle","receipt","search","settings","shield","shopping-cart","sliders","sparkles","star","table","tag","target","trending-up","truck","users","wallet","workflow","wrench","zap"],PLUGIN_NAV_ICON_FALLBACK="puzzle",PLUGIN_BACKEND_RUNTIMES=["node","python"],PLUGIN_BACKEND_PLATFORMS=["linux/amd64","linux/arm64"],PLUGIN_MANIFEST_FILENAME="tego.plugin.json",CLAW_MANIFEST_FILENAME="openclaw.plugin.json",PLUGIN_PART_DEFAULTS={frontend:{dir:"frontend",entry:"index.js",i18nDir:"i18n"},backend:{dir:"backend",runtime:"node",entry:{node:"index.js",python:"app.py"},migrationsDir:"migrations",healthPath:"/healthz"},claw:{dir:"claw"},publicFrontend:{dir:"public-frontend",entry:"index.html"}};function resolvePluginScope(t){return t.scope??(t.parts.claw?"avatar":"tenant")}s(resolvePluginScope,"resolvePluginScope");function resolvePluginDeclares(t){const e=t.declares??{};return{database:e.database??t.parts.backend!==void 0,storage:e.storage??!1,events:e.events??!1,notifications:e.notifications??!1}}s(resolvePluginDeclares,"resolvePluginDeclares");var PLUGIN_PART_NAMES=["frontend","backend","claw","publicFrontend"];function declaredPartNames(t){return PLUGIN_PART_NAMES.filter(e=>t.parts[e]!==void 0)}s(declaredPartNames,"declaredPartNames");function resolvePluginParts(t){const e={},n=t.parts.frontend;if(n){const i=n.dir??PLUGIN_PART_DEFAULTS.frontend.dir;e.frontend={dir:i,entryPath:`${i}/${n.entry??PLUGIN_PART_DEFAULTS.frontend.entry}`,i18nDirPath:`${i}/${n.i18nDir??PLUGIN_PART_DEFAULTS.frontend.i18nDir}`,nav:n.nav??[],...n.config?{config:n.config}:{}}}const r=t.parts.backend;if(r){const i=r.dir??PLUGIN_PART_DEFAULTS.backend.dir,l=r.runtime??PLUGIN_PART_DEFAULTS.backend.runtime;e.backend={dir:i,runtime:l,entryPath:`${i}/${r.entry??PLUGIN_PART_DEFAULTS.backend.entry[l]}`,platforms:l==="python"?[...r.platforms??PLUGIN_BACKEND_PLATFORMS]:[],egress:[...new Set(r.egress??[])].sort(),migrationsDirPath:`${i}/${r.migrationsDir??PLUGIN_PART_DEFAULTS.backend.migrationsDir}`,...r.compatibilityRepairs?{compatibilityRepairs:r.compatibilityRepairs}:{},healthPath:r.healthPath??PLUGIN_PART_DEFAULTS.backend.healthPath,limits:r.limits??{},publicRoutes:r.publicRoutes??[],...r.config?{config:r.config}:{}}}const a=t.parts.claw;if(a){const i=a.dir??PLUGIN_PART_DEFAULTS.claw.dir;e.claw={dir:i,manifestPath:`${i}/${CLAW_MANIFEST_FILENAME}`,...a.hooks?{hooks:a.hooks}:{}}}const o=t.parts.publicFrontend;if(o){const i=o.dir??PLUGIN_PART_DEFAULTS.publicFrontend.dir;e.publicFrontend={dir:i,entryPath:`${i}/${PLUGIN_PART_DEFAULTS.publicFrontend.entry}`}}return e}s(resolvePluginParts,"resolvePluginParts");var PLUGIN_PUBLIC_ROUTE_METHODS=["GET","POST","PUT","PATCH","DELETE"],PLUGIN_PUBLIC_API_PATH="/public/plugins/api",PLUGIN_PUBLIC_PAGES_PATH="/public/plugins/pages",PLUGIN_AVATAR_PUBLIC_API_PATH="/public/plugins/avatars/api",PLUGIN_AVATAR_PUBLIC_PAGES_PATH="/public/plugins/avatars/pages",PUBLIC_ROUTE_PATH_PATTERN=/^(?:\/(?:[A-Za-z0-9._~-]+|:[A-Za-z_][A-Za-z0-9_]*))+$/;function segments(t){return t.split("/").slice(1)}s(segments,"segments");function isParam(t){return t.startsWith(":")}s(isParam,"isParam");function formatPublicRoute(t){return`${t.method} ${t.path}`}s(formatPublicRoute,"formatPublicRoute");function publicRoutePathProblem(t){if(!PUBLIC_ROUTE_PATH_PATTERN.test(t))return'must be "/"-separated literal segments or ":name" parameters, e.g. "/public/inspections/:token"';const e=segments(t);if(e.some(r=>/^\.+$/.test(r)))return'must not contain "." or ".." segments';const n=e.filter(isParam);return new Set(n).size!==n.length?"must not repeat a parameter name":null}s(publicRoutePathProblem,"publicRoutePathProblem");function publicRoutesOverlap(t,e){if(t.method!==e.method)return!1;const n=segments(t.path),r=segments(e.path);return n.length!==r.length?!1:n.every((a,o)=>{const i=r[o];return isParam(a)||isParam(i)||a===i})}s(publicRoutesOverlap,"publicRoutesOverlap");function matchPublicRoute(t,e,n){const r=e.toUpperCase(),a=segments(n.startsWith("/")?n:`/${n}`);if(a.some(o=>o===""))return null;for(const o of t){if(o.method!==r)continue;const i=segments(o.path);if(i.length!==a.length)continue;const l={};if(i.every((c,P)=>{const p=a[P];return isParam(c)?(l[c.slice(1)]=p,!0):c===p}))return{route:formatPublicRoute(o),params:l}}return null}s(matchPublicRoute,"matchPublicRoute");function publicApiBaseFromPagePath(t){const e=t.indexOf(`${PLUGIN_AVATAR_PUBLIC_PAGES_PATH}/`);if(e!==-1){const i=t.slice(e+PLUGIN_AVATAR_PUBLIC_PAGES_PATH.length+1),[l,u,c]=i.split("/");return!l||!u||!c?null:`${t.slice(0,e)}${PLUGIN_AVATAR_PUBLIC_API_PATH}/${l}/${u}/${c}`}const n=t.indexOf(`${PLUGIN_PUBLIC_PAGES_PATH}/`);if(n===-1)return null;const r=t.slice(n+PLUGIN_PUBLIC_PAGES_PATH.length+1),[a,o]=r.split("/");return!a||!o?null:`${t.slice(0,n)}${PLUGIN_PUBLIC_API_PATH}/${a}/${o}`}s(publicApiBaseFromPagePath,"publicApiBaseFromPagePath"),exports.CLAW_MANIFEST_FILENAME=CLAW_MANIFEST_FILENAME,exports.PLUGIN_AVATAR_PUBLIC_API_PATH=PLUGIN_AVATAR_PUBLIC_API_PATH,exports.PLUGIN_AVATAR_PUBLIC_PAGES_PATH=PLUGIN_AVATAR_PUBLIC_PAGES_PATH,exports.PLUGIN_BACKEND_PLATFORMS=PLUGIN_BACKEND_PLATFORMS,exports.PLUGIN_BACKEND_RUNTIMES=PLUGIN_BACKEND_RUNTIMES,exports.PLUGIN_MANIFEST_FILENAME=PLUGIN_MANIFEST_FILENAME,exports.PLUGIN_NAV_ICONS=PLUGIN_NAV_ICONS,exports.PLUGIN_NAV_ICON_FALLBACK=PLUGIN_NAV_ICON_FALLBACK,exports.PLUGIN_PART_DEFAULTS=PLUGIN_PART_DEFAULTS,exports.PLUGIN_PART_NAMES=PLUGIN_PART_NAMES,exports.PLUGIN_PUBLIC_API_PATH=PLUGIN_PUBLIC_API_PATH,exports.PLUGIN_PUBLIC_PAGES_PATH=PLUGIN_PUBLIC_PAGES_PATH,exports.PLUGIN_PUBLIC_ROUTE_METHODS=PLUGIN_PUBLIC_ROUTE_METHODS,exports.declaredPartNames=declaredPartNames,exports.formatPublicRoute=formatPublicRoute,exports.matchPublicRoute=matchPublicRoute,exports.publicApiBaseFromPagePath=publicApiBaseFromPagePath,exports.publicRoutePathProblem=publicRoutePathProblem,exports.publicRoutesOverlap=publicRoutesOverlap,exports.resolvePluginDeclares=resolvePluginDeclares,exports.resolvePluginParts=resolvePluginParts,exports.resolvePluginScope=resolvePluginScope;
@@ -0,0 +1 @@
1
+ "use strict";var y=Object.defineProperty;var $=(o,s)=>y(o,"name",{value:s,configurable:!0});var chunkN4SXZZPY_cjs=require("./chunk-N4SXZZPY.cjs"),LOCALE_FILENAME_PATTERN=/^([a-z]{2}(?:-[A-Za-z]{2,4})?)\.json$/,MIGRATION_FILENAME_PATTERN=/^(\d{4,})_[A-Za-z0-9._-]+\.sql$/;function flattenLocaleKeys(o,s="",n=new Set){if(typeof o!="object"||o===null||Array.isArray(o))return n.add(s),n;for(const[t,i]of Object.entries(o))flattenLocaleKeys(i,s?`${s}.${t}`:t,n);return n}$(flattenLocaleKeys,"flattenLocaleKeys");async function verifyFrontendLocales(o,s){const n=[],t=[],i=new Map;for(const e of await o.list(s.i18nDirPath)){const r=LOCALE_FILENAME_PATTERN.exec(e);if(!r?.[1]){n.push(`Frontend i18n file "${s.i18nDirPath}/${e}" is not named "<locale>.json".`);continue}t.push(r[1])}if(!(s.nav.length>0||t.length>0))return{locales:t,bundles:i,errors:n};const p=chunkN4SXZZPY_cjs.PLUGIN_SUPPORTED_LOCALES.filter(e=>!t.includes(e));p.length>0&&n.push(`Frontend part must ship a bundle for every supported locale in "${s.i18nDirPath}"; missing ${p.join(", ")}.`);const c=new Map;for(const e of t){const r=`${s.i18nDirPath}/${e}.json`,h=await o.readText(r);if(h===null)continue;let a;try{a=JSON.parse(h)}catch(u){n.push(`Frontend i18n file "${r}" is not valid JSON: ${u instanceof Error?u.message:"parse error"}`);continue}i.set(e,a),c.set(e,flattenLocaleKeys(a))}const l=c.get("zh-CN");if(l){for(const[e,r]of c){if(e==="zh-CN")continue;const h=[...l].filter(u=>!r.has(u)).sort(),a=[...r].filter(u=>!l.has(u)).sort();h.length>0&&n.push(`Frontend i18n "${e}.json" is missing ${h.length} key(s) present in zh-CN.json: ${h.slice(0,5).join(", ")}${h.length>5?", ...":""}`),a.length>0&&n.push(`Frontend i18n "${e}.json" declares ${a.length} key(s) absent from zh-CN.json: ${a.slice(0,5).join(", ")}${a.length>5?", ...":""}`)}for(const e of s.nav)l.has(e.labelKey)||n.push(`Nav entry "${e.key}" points at i18n key "${e.labelKey}", which zh-CN.json does not define.`)}return{locales:t,bundles:i,errors:n}}$(verifyFrontendLocales,"verifyFrontendLocales");async function verifyMigrationNames(o,s){const n=[],t=[],i=new Map;for(const f of await o.list(s)){const p=MIGRATION_FILENAME_PATTERN.exec(f);if(!p?.[1]){n.push(`Migration "${s}/${f}" must be named "<ordinal>_<description>.sql", for example "0001_initial.sql".`);continue}const c=p[1],l=i.get(c);if(l){n.push(`Migrations "${l}" and "${f}" share ordinal ${c}, so their apply order would be ambiguous.`);continue}i.set(c,f),t.push(f)}return{migrations:t.sort(),errors:n}}$(verifyMigrationNames,"verifyMigrationNames"),exports.LOCALE_FILENAME_PATTERN=LOCALE_FILENAME_PATTERN,exports.MIGRATION_FILENAME_PATTERN=MIGRATION_FILENAME_PATTERN,exports.flattenLocaleKeys=flattenLocaleKeys,exports.verifyFrontendLocales=verifyFrontendLocales,exports.verifyMigrationNames=verifyMigrationNames;
@@ -1,19 +1,20 @@
1
- "use strict";var j=Object.defineProperty;var c=(e,n)=>j(e,"name",{value:n,configurable:!0});var chunkW7C357A6_cjs=require("./chunk-W7C357A6.cjs"),chunk3WA3M347_cjs=require("./chunk-3WA3M347.cjs"),chunkROFUQLOZ_cjs=require("./chunk-ROFUQLOZ.cjs"),crypto=require("crypto"),promises=require("fs/promises"),http=require("http"),path=require("path"),JSZip=require("jszip"),child_process=require("child_process"),util=require("util");function _interopDefault(e){return e&&e.__esModule?e:{default:e}}c(_interopDefault,"_interopDefault");var JSZip__default=_interopDefault(JSZip),AGENT_TEMPLATE_CONFIG_FILENAME="template.config.json",WORKSPACE_FILES={IDENTITY:"identityMd",SOUL:"soulMd",AGENTS:"agentsMd",TOOLS:"toolsMd",BOOTSTRAP:"bootstrapMd",HEARTBEAT:"heartbeatMd",USER:"userMd",MEMORY:"memoryMd"};async function buildAgentTemplate(e){const{agents:n,...i}=JSON.parse(await promises.readFile(path.join(e,AGENT_TEMPLATE_CONFIG_FILENAME),"utf8")),t=i.slug??e,a={...i.content,...await readRootFiles(path.join(e,"workspace"))},o=await readExtraFiles(path.join(e,"workspace"));if(o.length>0&&(a.workspaceFiles=o),n){if(n[0]?.id!=="main")throw new Error(`${t}: the first of "agents" must be main`);if(i.content?.agentList)throw new Error(`${t}: declare the team in "agents" or in "content.agentList", not both`);const r=n.slice(1),s=(await subdirectories(path.join(e,"experts"))).sort(),l=r.map(u=>u.id).sort();if(s.join()!==l.join())throw new Error(`${t}: experts/ holds [${s.join(", ")}] but "agents" declares [${l.join(", ")}]`);if(r.length>0){const u={};for(const d of r)u[d.id]=await readRootFiles(path.join(e,"experts",d.id));a.subAgentWorkspaces=u}a.agentList=n.map(({id:u,name:d,description:f,emoji:w})=>({id:u,name:d,...f?{description:f}:{},identity:{name:d,emoji:w},...u==="main"&&r.length>0?{subagents:{allowAgents:r.map(h=>h.id)}}:{}}))}return`${JSON.stringify({...i,content:a},null,2)}
1
+ "use strict";var j=Object.defineProperty;var c=(e,n)=>j(e,"name",{value:n,configurable:!0});var chunkHZ4YWRYX_cjs=require("./chunk-HZ4YWRYX.cjs"),chunkSKNPNPJP_cjs=require("./chunk-SKNPNPJP.cjs"),chunk2P6UEAPV_cjs=require("./chunk-2P6UEAPV.cjs"),crypto=require("crypto"),promises=require("fs/promises"),http=require("http"),path=require("path"),JSZip=require("jszip"),child_process=require("child_process"),util=require("util");function _interopDefault(e){return e&&e.__esModule?e:{default:e}}c(_interopDefault,"_interopDefault");var JSZip__default=_interopDefault(JSZip),AGENT_TEMPLATE_CONFIG_FILENAME="template.config.json",WORKSPACE_FILES={IDENTITY:"identityMd",SOUL:"soulMd",AGENTS:"agentsMd",TOOLS:"toolsMd",BOOTSTRAP:"bootstrapMd",HEARTBEAT:"heartbeatMd",USER:"userMd",MEMORY:"memoryMd"};async function buildAgentTemplate(e){const{agents:n,...i}=JSON.parse(await promises.readFile(path.join(e,AGENT_TEMPLATE_CONFIG_FILENAME),"utf8")),t=i.slug??e,a={...i.content,...await readRootFiles(path.join(e,"workspace"))},o=await readExtraFiles(path.join(e,"workspace"));if(o.length>0&&(a.workspaceFiles=o),n){if(n[0]?.id!=="main")throw new Error(`${t}: the first of "agents" must be main`);if(i.content?.agentList)throw new Error(`${t}: declare the team in "agents" or in "content.agentList", not both`);const r=n.slice(1),s=(await subdirectories(path.join(e,"experts"))).sort(),l=r.map(u=>u.id).sort();if(s.join()!==l.join())throw new Error(`${t}: experts/ holds [${s.join(", ")}] but "agents" declares [${l.join(", ")}]`);if(r.length>0){const u={};for(const f of r)u[f.id]=await readRootFiles(path.join(e,"experts",f.id));a.subAgentWorkspaces=u}a.agentList=n.map(({id:u,name:f,description:d,emoji:w})=>({id:u,name:f,...d?{description:d}:{},identity:{name:f,emoji:w},...u==="main"&&r.length>0?{subagents:{allowAgents:r.map(h=>h.id)}}:{}}))}return`${JSON.stringify({...i,content:a},null,2)}
2
2
  `}c(buildAgentTemplate,"buildAgentTemplate");async function readRootFiles(e){const n=new Set(await fileNames(e)),i={};for(const[t,a]of Object.entries(WORKSPACE_FILES)){const o=`${t}.md`;n.has(o)&&(i[a]=await readDocument(path.join(e,o)))}return i}c(readRootFiles,"readRootFiles");async function readExtraFiles(e){const n=new Set(Object.keys(WORKSPACE_FILES).map(t=>`${t}.md`)),i=(await walk(e)).map(t=>path.relative(e,t).split(path.sep).join("/")).filter(t=>!n.has(t)).sort();return Promise.all(i.map(async t=>({path:t,content:await readDocument(path.join(e,t)),...t.endsWith(".md")?{contentType:"text/markdown"}:{}})))}c(readExtraFiles,"readExtraFiles");async function readDocument(e){return(await promises.readFile(e,"utf8")).replace(/\n$/,"")}c(readDocument,"readDocument");async function walk(e){const n=await promises.readdir(e,{withFileTypes:!0}).catch(()=>[]),i=[];for(const t of n){if(t.name.startsWith("."))continue;const a=path.join(e,t.name);t.isDirectory()?i.push(...await walk(a)):t.isFile()&&i.push(a)}return i}c(walk,"walk");async function fileNames(e){return(await promises.readdir(e,{withFileTypes:!0}).catch(()=>[])).filter(i=>i.isFile()).map(i=>i.name)}c(fileNames,"fileNames");async function subdirectories(e){return(await promises.readdir(e,{withFileTypes:!0}).catch(()=>[])).filter(i=>i.isDirectory()&&!i.name.startsWith(".")).map(i=>i.name)}c(subdirectories,"subdirectories");var ACCESS_UI_PACKAGE="@tego/plugin-access-ui";async function readPluginLocales(e,n,i){const t=path.resolve(e,i),a=await promises.readdir(t).then(s=>s.filter(l=>l.endsWith(".json")).sort(),s=>{if(s.code==="ENOENT")return[];throw s}),o=new Map,r=n.access&&a.length>0?await accessUiLocaleDir(e):null;for(const s of a){const l=await promises.readFile(path.join(t,s),"utf8");if(!r){o.set(s,l);continue}o.set(s,mergeLocale(s,l,r,await readAccessLocale(r,s)))}return o}c(readPluginLocales,"readPluginLocales");async function accessUiLocaleDir(e){for(let n=path.resolve(e);;n=path.dirname(n)){const i=path.join(n,"node_modules",ACCESS_UI_PACKAGE);if(await promises.access(path.join(i,"package.json")).then(()=>!0,()=>!1))return path.join(i,"locales");if(path.dirname(n)===n)break}throw new Error(`The manifest declares access, so the frontend renders ${ACCESS_UI_PACKAGE} \u2014 add it to this plugin's dependencies.`)}c(accessUiLocaleDir,"accessUiLocaleDir");async function readAccessLocale(e,n){try{return await promises.readFile(path.join(e,n),"utf8")}catch{throw new Error(`${ACCESS_UI_PACKAGE} has no ${n}; the plugin ships that locale, so its access screens would show bare keys.`)}}c(readAccessLocale,"readAccessLocale");function mergeLocale(e,n,i,t){const a=JSON.parse(n),o=JSON.parse(t);for(const r of Object.keys(o))if(r in a)throw new Error(`Locale ${e} defines "${r}", which ${ACCESS_UI_PACKAGE} (${i}) owns \u2014 rename the plugin's key.`);return`${JSON.stringify({...a,...o},null,2)}
3
3
  `}c(mergeLocale,"mergeLocale");var run=util.promisify(child_process.execFile),SOURCE_DATE_EPOCH="315532800",DEFAULT_INCLUDE=["src","resources","migrations"],REQUIREMENTS_INPUT="requirements.in",SDK_DIST_NAME="tego-plugin-sdk",ARCH={"linux/amd64":"x86_64","linux/arm64":"aarch64"};function pipPlatformArgs(e){const n=ARCH[e],i=[`manylinux2014_${n}`];for(let t=17;t<=36;t++)i.push(`manylinux_2_${t}_${n}`);return n==="x86_64"&&i.push("manylinux2010_x86_64","manylinux1_x86_64"),i.flatMap(t=>["--platform",t])}c(pipPlatformArgs,"pipPlatformArgs");async function exists(e){try{return await promises.stat(e),!0}catch{return!1}}c(exists,"exists");async function findSdkProject(e,n){if(n)return path.resolve(e,n);let i=e;for(;;){const t=path.join(i,"packages","plugin-sdk-python");if(await exists(path.join(t,"pyproject.toml")))return t;const a=path.dirname(i);if(a===i)throw new Error("Cannot find packages/plugin-sdk-python above the plugin root; pass backend.python.sdkProject.");i=a}}c(findSdkProject,"findSdkProject");async function uv(e,n={}){try{await run("uv",e,{env:{...process.env,...n},maxBuffer:64*1024*1024})}catch(i){const t=i.stderr?.trim()||(i instanceof Error?i.message:String(i));throw i.code==="ENOENT"?new Error("`uv` is required to pack a python backend: https://docs.astral.sh/uv/"):new Error(`uv ${e[0]} failed:
4
- ${t}`)}}c(uv,"uv");async function buildSdkWheel(e,n){await uv(["build","--quiet","--wheel","--out-dir",n,e],{SOURCE_DATE_EPOCH})}c(buildSdkWheel,"buildSdkWheel");async function lockPythonBackend(e,n,i={}){const t=path.resolve(e,n.dir),a=path.join(t,REQUIREMENTS_INPUT);if(!await exists(a))throw new Error(`${n.dir}/${REQUIREMENTS_INPUT} not found`);const o=path.join(e,"build","python-sdk");await promises.rm(o,{recursive:!0,force:!0}),await buildSdkWheel(await findSdkProject(e,i.sdkProject),o);const r=path.join(t,chunk3WA3M347_cjs.PYTHON_LOCK_FILENAME),{major:s,minor:l}=chunk3WA3M347_cjs.PYTHON_RUNNER_VERSION;return await uv(["pip","compile","--quiet",a,"--output-file",r,"--generate-hashes","--no-header","--python-version",`${s}.${l}`,"--python-platform","x86_64-manylinux_2_36","--find-links",o,"--upgrade-package",SDK_DIST_NAME]),r}c(lockPythonBackend,"lockPythonBackend");async function sha256(e){return crypto.createHash("sha256").update(await promises.readFile(e)).digest("hex")}c(sha256,"sha256");async function vendorWheels(e){const{major:n,minor:i}=chunk3WA3M347_cjs.PYTHON_RUNNER_VERSION,t=path.join(e.scratch,"downloads");await promises.mkdir(t,{recursive:!0});for(const o of e.platforms)await uv(["tool","run","--from","pip","pip","download","--quiet","--no-deps","--prefer-binary","--require-hashes","--python-version",`${n}.${i}`,"--implementation","cp","--abi",`cp${n}${i}`,"--abi","abi3","--abi","none",...pipPlatformArgs(o),"--find-links",e.sdkDist,"--requirement",e.lockPath,"--dest",t]);const a=path.join(e.scratch,"built");for(const o of await promises.readdir(t))o.endsWith(".whl")||await uv(["build","--quiet","--wheel","--out-dir",a,path.join(t,o)],{SOURCE_DATE_EPOCH});await promises.mkdir(e.wheelsDir,{recursive:!0});for(const o of[t,a])if(await exists(o))for(const r of(await promises.readdir(o)).sort())r.endsWith(".whl")&&await promises.cp(path.join(o,r),path.join(e.wheelsDir,r))}c(vendorWheels,"vendorWheels");async function writePackagedLock(e,n,i){const{requirements:t}=chunk3WA3M347_cjs.parseRequirementsLock(e),a=new Map;for(const s of(await promises.readdir(n)).sort()){const l=chunk3WA3M347_cjs.parseWheelFilename(s);if(!l)continue;const u=`${l.name}==${l.version}`;a.set(u,[...a.get(u)??[],await sha256(path.join(n,s))])}const r=`${t.map(s=>{const l=a.get(`${s.name}==${s.version}`)??[];return[`${s.name}==${s.version}`,...l.map(u=>`--hash=sha256:${u}`)].join(" ")}).join(`
4
+ ${t}`)}}c(uv,"uv");async function buildSdkWheel(e,n){await uv(["build","--quiet","--wheel","--out-dir",n,e],{SOURCE_DATE_EPOCH})}c(buildSdkWheel,"buildSdkWheel");async function lockPythonBackend(e,n,i={}){const t=path.resolve(e,n.dir),a=path.join(t,REQUIREMENTS_INPUT);if(!await exists(a))throw new Error(`${n.dir}/${REQUIREMENTS_INPUT} not found`);const o=path.join(e,"build","python-sdk");await promises.rm(o,{recursive:!0,force:!0}),await buildSdkWheel(await findSdkProject(e,i.sdkProject),o);const r=path.join(t,chunkSKNPNPJP_cjs.PYTHON_LOCK_FILENAME),{major:s,minor:l}=chunkSKNPNPJP_cjs.PYTHON_RUNNER_VERSION;return await uv(["pip","compile","--quiet",a,"--output-file",r,"--generate-hashes","--no-header","--python-version",`${s}.${l}`,"--python-platform","x86_64-manylinux_2_36","--find-links",o,"--upgrade-package",SDK_DIST_NAME]),r}c(lockPythonBackend,"lockPythonBackend");async function sha256(e){return crypto.createHash("sha256").update(await promises.readFile(e)).digest("hex")}c(sha256,"sha256");async function vendorWheels(e){const{major:n,minor:i}=chunkSKNPNPJP_cjs.PYTHON_RUNNER_VERSION,t=path.join(e.scratch,"downloads");await promises.mkdir(t,{recursive:!0});for(const o of e.platforms)await uv(["tool","run","--from","pip","pip","download","--quiet","--no-deps","--prefer-binary","--require-hashes","--python-version",`${n}.${i}`,"--implementation","cp","--abi",`cp${n}${i}`,"--abi","abi3","--abi","none",...pipPlatformArgs(o),"--find-links",e.sdkDist,"--requirement",e.lockPath,"--dest",t]);const a=path.join(e.scratch,"built");for(const o of await promises.readdir(t))o.endsWith(".whl")||await uv(["build","--quiet","--wheel","--out-dir",a,path.join(t,o)],{SOURCE_DATE_EPOCH});await promises.mkdir(e.wheelsDir,{recursive:!0});for(const o of[t,a])if(await exists(o))for(const r of(await promises.readdir(o)).sort())r.endsWith(".whl")&&await promises.cp(path.join(o,r),path.join(e.wheelsDir,r))}c(vendorWheels,"vendorWheels");async function writePackagedLock(e,n,i){const{requirements:t}=chunkSKNPNPJP_cjs.parseRequirementsLock(e),a=new Map;for(const s of(await promises.readdir(n)).sort()){const l=chunkSKNPNPJP_cjs.parseWheelFilename(s);if(!l)continue;const u=`${l.name}==${l.version}`;a.set(u,[...a.get(u)??[],await sha256(path.join(n,s))])}const r=`${t.map(s=>{const l=a.get(`${s.name}==${s.version}`)??[];return[`${s.name}==${s.version}`,...l.map(u=>`--hash=sha256:${u}`)].join(" ")}).join(`
5
5
  `)}
6
- `;return await promises.writeFile(i,r,"utf8"),r}c(writePackagedLock,"writePackagedLock");async function stagePythonBackend(e){const{root:n,staging:i,part:t,options:a={},log:o}=e,r=path.resolve(n,t.dir),s=path.join(i,t.dir);await promises.mkdir(s,{recursive:!0});const l=path.resolve(n,t.entryPath);if(!await exists(l))throw new Error(`backend entry not found at ${l}`);await promises.cp(l,path.join(i,t.entryPath));for(const m of a.include??DEFAULT_INCLUDE){const p=path.join(r,m);await exists(p)&&await promises.cp(p,path.join(s,m),{recursive:!0,filter:c(y=>!/(^|\/)(__pycache__|\.pytest_cache|\.venv)(\/|$)|\.pyc$/.test(y),"filter")})}const u=path.resolve(n,t.migrationsDirPath);await exists(u)&&await promises.cp(u,path.join(i,t.migrationsDirPath),{recursive:!0});const d=path.join(r,chunk3WA3M347_cjs.PYTHON_LOCK_FILENAME);if(!await exists(d))throw new Error(`${t.dir}/${chunk3WA3M347_cjs.PYTHON_LOCK_FILENAME} not found; run \`tego-plugin-pack lock\``);const f=await promises.readFile(d,"utf8"),{errors:w,requirements:h}=chunk3WA3M347_cjs.parseRequirementsLock(f);if(w.length>0)throw new Error([`${t.dir}/${chunk3WA3M347_cjs.PYTHON_LOCK_FILENAME} is invalid:`,...w].join(`
7
- `));if(!h.some(m=>m.name===chunk3WA3M347_cjs.normalizePackageName(SDK_DIST_NAME)))throw new Error(`${t.dir}/${chunk3WA3M347_cjs.PYTHON_LOCK_FILENAME} must lock ${SDK_DIST_NAME}`);const g=path.join(n,"build","python-scratch");await promises.rm(g,{recursive:!0,force:!0});try{const m=path.join(g,"sdk");await buildSdkWheel(await findSdkProject(n,a.sdkProject),m);const p=path.join(s,chunk3WA3M347_cjs.PYTHON_WHEELS_DIR);o(` \u203A vendoring ${h.length} packages for ${t.platforms.join(", ")}`),await vendorWheels({lockPath:d,platforms:t.platforms,sdkDist:m,wheelsDir:p,scratch:g});const y=await writePackagedLock(f,p,path.join(s,chunk3WA3M347_cjs.PYTHON_LOCK_FILENAME)),E=await Promise.all((await promises.readdir(p)).map(async k=>({filename:k,sha256:await sha256(path.join(p,k))}))),v=chunk3WA3M347_cjs.checkPythonVendoring({lockText:y,wheels:E,platforms:t.platforms});if(v.length>0)throw new Error(["Python backend would not install in the runner:",...v].join(`
8
- `))}finally{await promises.rm(g,{recursive:!0,force:!0})}}c(stagePythonBackend,"stagePythonBackend");var BACKEND_EXTERNAL=["pg","node:*"],CLAW_EXTERNAL=["openclaw","openclaw/*","node:*"],ZIP_EPOCH=new Date(Date.UTC(1980,0,1));async function packPlugin(e){const n=path.resolve(e.root),i=e.log===null?()=>{}:e.log??(s=>console.log(s)),t=await readManifest(n),a=chunkROFUQLOZ_cjs.resolvePluginParts(t),o=path.resolve(n,e.outDir??"build"),r=path.join(o,"package");await promises.rm(r,{recursive:!0,force:!0}),await promises.mkdir(r,{recursive:!0});try{await promises.writeFile(path.join(r,chunkROFUQLOZ_cjs.PLUGIN_MANIFEST_FILENAME),`${JSON.stringify(t,null,2)}
9
- `,"utf8"),await stageAccessCatalog(n,r,t),a.frontend&&(i("\u203A building frontend"),await stageFrontend(n,r,t,a.frontend,e.frontend)),a.publicFrontend&&(i("\u203A building public pages"),await stagePublicFrontend(n,r,a.publicFrontend,e.publicFrontend)),a.backend?.runtime==="python"?(i("\u203A staging python backend"),await stagePythonBackend({root:n,staging:r,part:a.backend,...e.backend?.python?{options:e.backend.python}:{},log:i})):a.backend&&(i("\u203A building backend"),await stageBackend(n,r,a.backend,e.backend)),a.claw&&(i("\u203A building claw"),await stageClaw(n,r,a.claw,t,e.claw)),await writeAgentTemplates(n,t,i);for(const d of t.agentTemplates??[])for(const f of[d.entry,d.icon].filter(w=>!!w)){const w=path.resolve(n,f);await assertExists(w,`agent template asset ${f}`);const h=path.join(r,f);await promises.mkdir(path.dirname(h),{recursive:!0}),await promises.cp(w,h)}const s=path.join(o,e.fileName??`${t.id}-${t.version}.zip`),l=await zipDirectory(r,s),u=crypto.createHash("sha256").update(await promises.readFile(s)).digest("hex");return i(`\u2705 ${path.relative(n,s)} \u2014 ${formatBytes(l)}`),{file:s,bytes:l,sha256:u,manifest:t}}finally{await promises.rm(r,{recursive:!0,force:!0})}}c(packPlugin,"packPlugin");async function buildPluginTemplates(e){const n=path.resolve(e.root),i=e.log===null?()=>{}:e.log??(t=>console.log(t));return writeAgentTemplates(n,await readManifest(n),i)}c(buildPluginTemplates,"buildPluginTemplates");async function writeAgentTemplates(e,n,i){const t=[];for(const a of n.agentTemplates??[]){const o=path.resolve(e,a.entry),r=path.dirname(o);if(!await exists2(path.join(r,AGENT_TEMPLATE_CONFIG_FILENAME)))continue;const s=await buildAgentTemplate(r),{content:l}=JSON.parse(s);l?.usageGuide?.summary?.trim()||i(`\u26A0\uFE0F ${a.key}: missing content.usageGuide.summary (recommended for onboarding)`),await promises.readFile(o,"utf8").catch(()=>null)!==s&&(await promises.writeFile(o,s,"utf8"),i(`\u203A rebuilt ${a.entry}`),t.push(a.entry))}return t}c(writeAgentTemplates,"writeAgentTemplates");async function lockPlugin(e){const n=path.resolve(e.root),i=chunkROFUQLOZ_cjs.resolvePluginParts(await readManifest(n)).backend;if(i?.runtime!=="python")throw new Error("Only a python backend part has a lock to compile.");return lockPythonBackend(n,i,e.python)}c(lockPlugin,"lockPlugin");async function watchPluginFrontend(e){const n=path.resolve(e.root),i=e.log===null?()=>{}:e.log??(f=>console.log(f)),t=await readManifest(n),a=chunkROFUQLOZ_cjs.resolvePluginParts(t).frontend;if(!a)throw new Error(`${t.id} declares no frontend part to watch.`);const o=path.resolve(n,e.frontend?.buildDir??`${a.dir}/dist`),r=path.resolve(n,e.frontend?.viteConfig??`${a.dir}/vite.config.ts`);await assertExists(r,"frontend vite config");const s=e.port??DEFAULT_WATCH_PORT,l=serveBuildDir(o,s,()=>readPluginLocales(n,t,a.i18nDirPath)),{build:u}=await import("vite");return(await u({root:n,configFile:r,logLevel:"warn",...chunkW7C357A6_cjs.TEGO_PLUGIN_DEV_OVERRIDES,build:{...chunkW7C357A6_cjs.TEGO_PLUGIN_DEV_OVERRIDES.build,watch:{}}})).on("event",f=>{f.code==="END"&&(i(`\u21BB rebuilt \u2014 reloading ${l.clientCount()} page(s)`),l.notify())}),i([`Serving ${t.id} from http://localhost:${s}/${path.basename(a.entryPath)}`,"","Point the shell at it and restart its dev server:",` VITE_TEGO_LOCAL_PLUGINS=${t.id}=http://localhost:${s}/${path.basename(a.entryPath)}`,"","The release still has to be installed and enabled \u2014 this only replaces","where its bundle is fetched from. Ctrl-C to stop."].join(`
6
+ `;return await promises.writeFile(i,r,"utf8"),r}c(writePackagedLock,"writePackagedLock");async function stagePythonBackend(e){const{root:n,staging:i,part:t,options:a={},log:o}=e,r=path.resolve(n,t.dir),s=path.join(i,t.dir);await promises.mkdir(s,{recursive:!0});const l=path.resolve(n,t.entryPath);if(!await exists(l))throw new Error(`backend entry not found at ${l}`);await promises.cp(l,path.join(i,t.entryPath));for(const p of a.include??DEFAULT_INCLUDE){const m=path.join(r,p);await exists(m)&&await promises.cp(m,path.join(s,p),{recursive:!0,filter:c(y=>!/(^|\/)(__pycache__|\.pytest_cache|\.venv)(\/|$)|\.pyc$/.test(y),"filter")})}const u=path.resolve(n,t.migrationsDirPath);await exists(u)&&await promises.cp(u,path.join(i,t.migrationsDirPath),{recursive:!0});const f=path.join(r,chunkSKNPNPJP_cjs.PYTHON_LOCK_FILENAME);if(!await exists(f))throw new Error(`${t.dir}/${chunkSKNPNPJP_cjs.PYTHON_LOCK_FILENAME} not found; run \`tego-plugin-pack lock\``);const d=await promises.readFile(f,"utf8"),{errors:w,requirements:h}=chunkSKNPNPJP_cjs.parseRequirementsLock(d);if(w.length>0)throw new Error([`${t.dir}/${chunkSKNPNPJP_cjs.PYTHON_LOCK_FILENAME} is invalid:`,...w].join(`
7
+ `));if(!h.some(p=>p.name===chunkSKNPNPJP_cjs.normalizePackageName(SDK_DIST_NAME)))throw new Error(`${t.dir}/${chunkSKNPNPJP_cjs.PYTHON_LOCK_FILENAME} must lock ${SDK_DIST_NAME}`);const g=path.join(n,"build","python-scratch");await promises.rm(g,{recursive:!0,force:!0});try{const p=path.join(g,"sdk");await buildSdkWheel(await findSdkProject(n,a.sdkProject),p);const m=path.join(s,chunkSKNPNPJP_cjs.PYTHON_WHEELS_DIR);o(` \u203A vendoring ${h.length} packages for ${t.platforms.join(", ")}`),await vendorWheels({lockPath:f,platforms:t.platforms,sdkDist:p,wheelsDir:m,scratch:g});const y=await writePackagedLock(d,m,path.join(s,chunkSKNPNPJP_cjs.PYTHON_LOCK_FILENAME)),E=await Promise.all((await promises.readdir(m)).map(async k=>({filename:k,sha256:await sha256(path.join(m,k))}))),v=chunkSKNPNPJP_cjs.checkPythonVendoring({lockText:y,wheels:E,platforms:t.platforms});if(v.length>0)throw new Error(["Python backend would not install in the runner:",...v].join(`
8
+ `))}finally{await promises.rm(g,{recursive:!0,force:!0})}}c(stagePythonBackend,"stagePythonBackend");var BACKEND_EXTERNAL=["pg","node:*"],CLAW_EXTERNAL=["openclaw","openclaw/*","node:*"],ZIP_EPOCH=new Date(Date.UTC(1980,0,1));async function packPlugin(e){const n=path.resolve(e.root),i=e.log===null?()=>{}:e.log??(s=>console.log(s)),t=await readManifest(n),a=chunk2P6UEAPV_cjs.resolvePluginParts(t);if(e.doctor!==!1){const{runDoctor:s,UPLOAD_BLOCKING_RULES:l}=await import("./doctor.cjs"),u=await s({root:n}),f=u.findings.filter(d=>d.severity==="error"&&l.includes(d.rule));if(f.length>0)throw new Error(["Upload would refuse this package:",...f.map(d=>` ${d.rule} ${d.file?`${d.file}: `:""}${d.message}`)].join(`
9
+ `));u.findings.length>0&&i(`\u26A0 doctor: ${u.errors} error(s), ${u.warnings} warning(s) \u2014 run \`tego-plugin doctor\` for the list`)}const o=path.resolve(n,e.outDir??"build"),r=path.join(o,"package");await promises.rm(r,{recursive:!0,force:!0}),await promises.mkdir(r,{recursive:!0});try{await promises.writeFile(path.join(r,chunk2P6UEAPV_cjs.PLUGIN_MANIFEST_FILENAME),`${JSON.stringify(t,null,2)}
10
+ `,"utf8"),await stageAccessCatalog(n,r,t),a.frontend&&(i("\u203A building frontend"),await stageFrontend(n,r,t,a.frontend,e.frontend)),a.publicFrontend&&(i("\u203A building public pages"),await stagePublicFrontend(n,r,a.publicFrontend,e.publicFrontend)),a.backend?.runtime==="python"?(i("\u203A staging python backend"),await stagePythonBackend({root:n,staging:r,part:a.backend,...e.backend?.python?{options:e.backend.python}:{},log:i})):a.backend&&(i("\u203A building backend"),await stageBackend(n,r,a.backend,e.backend)),a.claw&&(i("\u203A building claw"),await stageClaw(n,r,a.claw,t,e.claw)),await writeAgentTemplates(n,t,i);for(const f of t.agentTemplates??[])for(const d of[f.entry,f.icon].filter(w=>!!w)){const w=path.resolve(n,d);await assertExists(w,`agent template asset ${d}`);const h=path.join(r,d);await promises.mkdir(path.dirname(h),{recursive:!0}),await promises.cp(w,h)}const s=path.join(o,e.fileName??`${t.id}-${t.version}.zip`),l=await zipDirectory(r,s),u=crypto.createHash("sha256").update(await promises.readFile(s)).digest("hex");return i(`\u2705 ${path.relative(n,s)} \u2014 ${formatBytes(l)}`),{file:s,bytes:l,sha256:u,manifest:t}}finally{await promises.rm(r,{recursive:!0,force:!0})}}c(packPlugin,"packPlugin");async function buildPluginTemplates(e){const n=path.resolve(e.root),i=e.log===null?()=>{}:e.log??(t=>console.log(t));return writeAgentTemplates(n,await readManifest(n),i)}c(buildPluginTemplates,"buildPluginTemplates");async function writeAgentTemplates(e,n,i){const t=[];for(const a of n.agentTemplates??[]){const o=path.resolve(e,a.entry),r=path.dirname(o);if(!await exists2(path.join(r,AGENT_TEMPLATE_CONFIG_FILENAME)))continue;const s=await buildAgentTemplate(r),{content:l}=JSON.parse(s);l?.usageGuide?.summary?.trim()||i(`\u26A0\uFE0F ${a.key}: missing content.usageGuide.summary (recommended for onboarding)`),await promises.readFile(o,"utf8").catch(()=>null)!==s&&(await promises.writeFile(o,s,"utf8"),i(`\u203A rebuilt ${a.entry}`),t.push(a.entry))}return t}c(writeAgentTemplates,"writeAgentTemplates");async function lockPlugin(e){const n=path.resolve(e.root),i=chunk2P6UEAPV_cjs.resolvePluginParts(await readManifest(n)).backend;if(i?.runtime!=="python")throw new Error("Only a python backend part has a lock to compile.");return lockPythonBackend(n,i,e.python)}c(lockPlugin,"lockPlugin");async function watchPluginFrontend(e){const n=path.resolve(e.root),i=e.log===null?()=>{}:e.log??(d=>console.log(d)),t=await readManifest(n),a=chunk2P6UEAPV_cjs.resolvePluginParts(t).frontend;if(!a)throw new Error(`${t.id} declares no frontend part to watch.`);const o=path.resolve(n,e.frontend?.buildDir??`${a.dir}/dist`),r=path.resolve(n,e.frontend?.viteConfig??`${a.dir}/vite.config.ts`);await assertExists(r,"frontend vite config");const s=e.port??DEFAULT_WATCH_PORT,l=serveBuildDir(o,s,()=>readPluginLocales(n,t,a.i18nDirPath)),{build:u}=await import("vite");return(await u({root:n,configFile:r,logLevel:"warn",...chunkHZ4YWRYX_cjs.TEGO_PLUGIN_DEV_OVERRIDES,build:{...chunkHZ4YWRYX_cjs.TEGO_PLUGIN_DEV_OVERRIDES.build,watch:{}}})).on("event",d=>{d.code==="END"&&(i(`\u21BB rebuilt \u2014 reloading ${l.clientCount()} page(s)`),l.notify())}),i([`Serving ${t.id} from http://localhost:${s}/${path.basename(a.entryPath)}`,"","Point the shell at it and restart its dev server:",` VITE_TEGO_LOCAL_PLUGINS=${t.id}=http://localhost:${s}/${path.basename(a.entryPath)}`,"","The release still has to be installed and enabled \u2014 this only replaces","where its bundle is fetched from. Ctrl-C to stop."].join(`
10
11
  `)),new Promise(()=>{})}c(watchPluginFrontend,"watchPluginFrontend");var DEFAULT_WATCH_PORT=5180,RELOAD_PATH="/__tego_plugin_reload",LOCALE_PATH_PREFIX="/i18n/";function serveBuildDir(e,n,i){const t=new Set;return http.createServer((o,r)=>{r.setHeader("Access-Control-Allow-Origin","*"),r.setHeader("Access-Control-Allow-Headers","*");const s=new URL(o.url??"/","http://localhost").pathname;if(s===RELOAD_PATH){r.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}),r.write(`: connected
11
12
 
12
- `),t.add(r),o.on("close",()=>t.delete(r));return}if(s.startsWith(LOCALE_PATH_PREFIX)){const u=s.slice(LOCALE_PATH_PREFIX.length);i().then(d=>{const f=d.get(u);if(f===void 0){r.writeHead(404).end();return}r.writeHead(200,{"Content-Type":contentTypeFor(u),"Cache-Control":"no-store"}),r.end(f)},d=>{r.writeHead(500,{"Content-Type":"text/plain; charset=utf-8"}).end(d instanceof Error?d.message:String(d))});return}const l=path.resolve(e,`.${s}`);if(!l.startsWith(e)){r.writeHead(403).end();return}promises.readFile(l).then(u=>{r.writeHead(200,{"Content-Type":contentTypeFor(l),"Cache-Control":"no-store"}),r.end(u)},()=>r.writeHead(404).end())}).listen(n,"127.0.0.1"),{notify:c(()=>{for(const o of t)o.write(`data: rebuilt
13
+ `),t.add(r),o.on("close",()=>t.delete(r));return}if(s.startsWith(LOCALE_PATH_PREFIX)){const u=s.slice(LOCALE_PATH_PREFIX.length);i().then(f=>{const d=f.get(u);if(d===void 0){r.writeHead(404).end();return}r.writeHead(200,{"Content-Type":contentTypeFor(u),"Cache-Control":"no-store"}),r.end(d)},f=>{r.writeHead(500,{"Content-Type":"text/plain; charset=utf-8"}).end(f instanceof Error?f.message:String(f))});return}const l=path.resolve(e,`.${s}`);if(!l.startsWith(e)){r.writeHead(403).end();return}promises.readFile(l).then(u=>{r.writeHead(200,{"Content-Type":contentTypeFor(l),"Cache-Control":"no-store"}),r.end(u)},()=>r.writeHead(404).end())}).listen(n,"127.0.0.1"),{notify:c(()=>{for(const o of t)o.write(`data: rebuilt
13
14
 
14
- `)},"notify"),clientCount:c(()=>t.size,"clientCount")}}c(serveBuildDir,"serveBuildDir");function contentTypeFor(e){return e.endsWith(".js")?"text/javascript; charset=utf-8":e.endsWith(".json")?"application/json; charset=utf-8":e.endsWith(".css")?"text/css; charset=utf-8":"application/octet-stream"}c(contentTypeFor,"contentTypeFor");async function readManifest(e){const n=path.join(e,chunkROFUQLOZ_cjs.PLUGIN_MANIFEST_FILENAME);let i;try{i=await promises.readFile(n,"utf8")}catch{throw new Error(`${chunkROFUQLOZ_cjs.PLUGIN_MANIFEST_FILENAME} not found at ${n}`)}const t=chunk3WA3M347_cjs.parseTegoPluginManifest(JSON.parse(i));if(!t.ok||!t.manifest)throw new Error([`${chunkROFUQLOZ_cjs.PLUGIN_MANIFEST_FILENAME} is invalid:`,...t.errors].join(`
15
- `));return t.manifest}c(readManifest,"readManifest");async function stageFrontend(e,n,i,t,a){const o=path.resolve(e,a?.viteConfig??`${t.dir}/vite.config.ts`);await assertExists(o,"frontend vite config");const{build:r}=await import("vite");await r({root:e,configFile:o,logLevel:"warn"});const s=path.resolve(e,a?.buildDir??`${t.dir}/dist`);await assertExists(path.join(s,path.basename(t.entryPath)),`frontend bundle (expected the vite build to write ${path.basename(t.entryPath)})`),await promises.mkdir(path.join(n,path.dirname(t.entryPath)),{recursive:!0}),await promises.cp(s,path.join(n,path.dirname(t.entryPath)),{recursive:!0});const l=await readPluginLocales(e,i,t.i18nDirPath);l.size>0&&await promises.mkdir(path.join(n,t.i18nDirPath),{recursive:!0});for(const[u,d]of l)await promises.writeFile(path.join(n,t.i18nDirPath,u),d,"utf8")}c(stageFrontend,"stageFrontend");async function stageAccessCatalog(e,n,i){const t=i.access?.catalog;if(!t)return;const a=path.resolve(e,t);await assertExists(a,`access catalog ${t}`);const o=await promises.readFile(a,"utf8"),r=chunk3WA3M347_cjs.checkPluginAccessCatalog(i,JSON.parse(o));if(!r.ok)throw new Error(["The access catalog is invalid:",...r.errors].join(`
15
+ `)},"notify"),clientCount:c(()=>t.size,"clientCount")}}c(serveBuildDir,"serveBuildDir");function contentTypeFor(e){return e.endsWith(".js")?"text/javascript; charset=utf-8":e.endsWith(".json")?"application/json; charset=utf-8":e.endsWith(".css")?"text/css; charset=utf-8":"application/octet-stream"}c(contentTypeFor,"contentTypeFor");async function readManifest(e){const n=path.join(e,chunk2P6UEAPV_cjs.PLUGIN_MANIFEST_FILENAME);let i;try{i=await promises.readFile(n,"utf8")}catch{throw new Error(`${chunk2P6UEAPV_cjs.PLUGIN_MANIFEST_FILENAME} not found at ${n}`)}const t=chunkSKNPNPJP_cjs.parseTegoPluginManifest(JSON.parse(i));if(!t.ok||!t.manifest)throw new Error([`${chunk2P6UEAPV_cjs.PLUGIN_MANIFEST_FILENAME} is invalid:`,...t.errors].join(`
16
+ `));return t.manifest}c(readManifest,"readManifest");async function stageFrontend(e,n,i,t,a){const o=path.resolve(e,a?.viteConfig??`${t.dir}/vite.config.ts`);await assertExists(o,"frontend vite config");const{build:r}=await import("vite");await r({root:e,configFile:o,logLevel:"warn"});const s=path.resolve(e,a?.buildDir??`${t.dir}/dist`);await assertExists(path.join(s,path.basename(t.entryPath)),`frontend bundle (expected the vite build to write ${path.basename(t.entryPath)})`),await promises.mkdir(path.join(n,path.dirname(t.entryPath)),{recursive:!0}),await promises.cp(s,path.join(n,path.dirname(t.entryPath)),{recursive:!0});const l=await readPluginLocales(e,i,t.i18nDirPath);l.size>0&&await promises.mkdir(path.join(n,t.i18nDirPath),{recursive:!0});for(const[u,f]of l)await promises.writeFile(path.join(n,t.i18nDirPath,u),f,"utf8")}c(stageFrontend,"stageFrontend");async function stageAccessCatalog(e,n,i){const t=i.access?.catalog;if(!t)return;const a=path.resolve(e,t);await assertExists(a,`access catalog ${t}`);const o=await promises.readFile(a,"utf8"),r=chunkSKNPNPJP_cjs.checkPluginAccessCatalog(i,JSON.parse(o));if(!r.ok)throw new Error(["The access catalog is invalid:",...r.errors].join(`
16
17
  `));await promises.mkdir(path.dirname(path.join(n,t)),{recursive:!0}),await promises.writeFile(path.join(n,t),o,"utf8")}c(stageAccessCatalog,"stageAccessCatalog");async function stagePublicFrontend(e,n,i,t){const a=path.resolve(e,t?.viteConfig??`${i.dir}/vite.config.ts`);await assertExists(a,"public pages vite config");const{build:o}=await import("vite");await o({root:path.resolve(e,i.dir),configFile:a,logLevel:"warn"});const r=path.resolve(e,t?.buildDir??`${i.dir}/dist`);await assertExists(path.join(r,path.basename(i.entryPath)),`public pages (expected the vite build to write ${path.basename(i.entryPath)})`),await promises.mkdir(path.join(n,i.dir),{recursive:!0}),await promises.cp(r,path.join(n,i.dir),{recursive:!0})}c(stagePublicFrontend,"stagePublicFrontend");async function stageBackend(e,n,i,t){await buildPluginBackend(i,{root:e,outDir:n,...t?.entry?{entry:t.entry}:{},...t?.external?{external:t.external}:{}})}c(stageBackend,"stageBackend");async function buildPluginBackend(e,n){const{root:i,outDir:t}=n,a=path.resolve(i,n.entry??`${e.dir}/src/index.ts`);await assertExists(a,"backend entry");const{build:o}=await import("esbuild");await o({entryPoints:[a],outfile:path.join(t,e.entryPath),bundle:!0,platform:"node",target:"node22",format:"esm",banner:{js:"import { createRequire as __tegoCreateRequire } from 'node:module'; const require = __tegoCreateRequire(import.meta.url);"},external:[...BACKEND_EXTERNAL,...n.external??[]],logLevel:"warning"});for(const s of e.compatibilityRepairs??[]){const l=`${e.dir}/${s.sqlFile}`;await assertExists(path.resolve(i,l),"schema repair"),await promises.mkdir(path.dirname(path.join(t,l)),{recursive:!0}),await promises.cp(path.resolve(i,l),path.join(t,l))}const r=path.resolve(i,e.migrationsDirPath);await exists2(r)&&await promises.cp(r,path.join(t,e.migrationsDirPath),{recursive:!0}),await promises.writeFile(path.join(t,e.dir,"package.json"),`${JSON.stringify({type:"module"},null,2)}
17
- `,"utf8")}c(buildPluginBackend,"buildPluginBackend");async function stageClaw(e,n,i,t,a){const o=path.resolve(e,a?.entry??`${i.dir}/src/index.ts`);await assertExists(o,"claw entry");const{build:r}=await import("esbuild");await r({entryPoints:[o],outfile:path.join(n,i.dir,"index.js"),bundle:!0,platform:"node",target:"node22",format:"esm",external:[...CLAW_EXTERNAL,...a?.external??[]],logLevel:"warning"});const s=path.resolve(e,i.manifestPath);await assertExists(s,chunkROFUQLOZ_cjs.CLAW_MANIFEST_FILENAME);const l=JSON.parse(await promises.readFile(s,"utf8"));await promises.writeFile(path.join(n,i.manifestPath),`${JSON.stringify({...l,version:t.version},null,2)}
18
- `,"utf8");const u=path.resolve(e,i.dir,"package.json"),d=await exists2(u)?JSON.parse(await promises.readFile(u,"utf8")):{name:t.id,private:!0,type:"module"};await promises.writeFile(path.join(n,i.dir,"package.json"),`${JSON.stringify({...d,version:t.version,openclaw:{extensions:["./index.js"]}},null,2)}
19
- `,"utf8");const f=path.resolve(e,a?.skillsDir??`${i.dir}/skills`);await exists2(f)&&await promises.cp(f,path.join(n,i.dir,"skills"),{recursive:!0})}c(stageClaw,"stageClaw");async function zipDirectory(e,n){const i=new JSZip__default.default;await addDirectory(i,e,"");const t=await i.generateAsync({type:"nodebuffer",compression:"DEFLATE",compressionOptions:{level:9}});return await promises.writeFile(n,t),t.byteLength}c(zipDirectory,"zipDirectory");async function addDirectory(e,n,i){const t=await promises.readdir(n,{withFileTypes:!0});t.sort((a,o)=>a.name.localeCompare(o.name));for(const a of t){const o=`${i}${a.name}`;a.isDirectory()?(e.file(`${o}/`,null,{dir:!0,date:ZIP_EPOCH}),await addDirectory(e,path.join(n,a.name),`${o}/`)):e.file(o,await promises.readFile(path.join(n,a.name)),{date:ZIP_EPOCH,createFolders:!1})}}c(addDirectory,"addDirectory");async function exists2(e){try{return await promises.stat(e),!0}catch{return!1}}c(exists2,"exists2");async function assertExists(e,n){if(!await exists2(e))throw new Error(`${n} not found at ${e}`)}c(assertExists,"assertExists");function formatBytes(e){return e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}c(formatBytes,"formatBytes"),exports.buildAgentTemplate=buildAgentTemplate,exports.buildPluginBackend=buildPluginBackend,exports.buildPluginTemplates=buildPluginTemplates,exports.lockPlugin=lockPlugin,exports.packPlugin=packPlugin,exports.watchPluginFrontend=watchPluginFrontend;
18
+ `,"utf8")}c(buildPluginBackend,"buildPluginBackend");async function stageClaw(e,n,i,t,a){const o=path.resolve(e,a?.entry??`${i.dir}/src/index.ts`);await assertExists(o,"claw entry");const{build:r}=await import("esbuild");await r({entryPoints:[o],outfile:path.join(n,i.dir,"index.js"),bundle:!0,platform:"node",target:"node22",format:"esm",external:[...CLAW_EXTERNAL,...a?.external??[]],logLevel:"warning"});const s=path.resolve(e,i.manifestPath);await assertExists(s,chunk2P6UEAPV_cjs.CLAW_MANIFEST_FILENAME);const l=JSON.parse(await promises.readFile(s,"utf8"));await promises.writeFile(path.join(n,i.manifestPath),`${JSON.stringify({...l,version:t.version},null,2)}
19
+ `,"utf8");const u=path.resolve(e,i.dir,"package.json"),f=await exists2(u)?JSON.parse(await promises.readFile(u,"utf8")):{name:t.id,private:!0,type:"module"};await promises.writeFile(path.join(n,i.dir,"package.json"),`${JSON.stringify({...f,version:t.version,openclaw:{extensions:["./index.js"]}},null,2)}
20
+ `,"utf8");const d=path.resolve(e,a?.skillsDir??`${i.dir}/skills`);await exists2(d)&&await promises.cp(d,path.join(n,i.dir,"skills"),{recursive:!0})}c(stageClaw,"stageClaw");async function zipDirectory(e,n){const i=new JSZip__default.default;await addDirectory(i,e,"");const t=await i.generateAsync({type:"nodebuffer",compression:"DEFLATE",compressionOptions:{level:9}});return await promises.writeFile(n,t),t.byteLength}c(zipDirectory,"zipDirectory");async function addDirectory(e,n,i){const t=await promises.readdir(n,{withFileTypes:!0});t.sort((a,o)=>a.name.localeCompare(o.name));for(const a of t){const o=`${i}${a.name}`;a.isDirectory()?(e.file(`${o}/`,null,{dir:!0,date:ZIP_EPOCH}),await addDirectory(e,path.join(n,a.name),`${o}/`)):e.file(o,await promises.readFile(path.join(n,a.name)),{date:ZIP_EPOCH,createFolders:!1})}}c(addDirectory,"addDirectory");async function exists2(e){try{return await promises.stat(e),!0}catch{return!1}}c(exists2,"exists2");async function assertExists(e,n){if(!await exists2(e))throw new Error(`${n} not found at ${e}`)}c(assertExists,"assertExists");function formatBytes(e){return e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}c(formatBytes,"formatBytes"),exports.buildAgentTemplate=buildAgentTemplate,exports.buildPluginBackend=buildPluginBackend,exports.buildPluginTemplates=buildPluginTemplates,exports.lockPlugin=lockPlugin,exports.packPlugin=packPlugin,exports.readManifest=readManifest,exports.readPluginLocales=readPluginLocales,exports.watchPluginFrontend=watchPluginFrontend;
@@ -1 +1 @@
1
- var $=Object.defineProperty;var i=(r,e)=>$(r,"name",{value:e,configurable:!0});function s(r){const e=/^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(r);if(!e)throw new Error(`Invalid semantic version: ${r}`);return{major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:e[4]?.split(".")??[]}}i(s,"parseSemanticVersion");function a(r,e){const u=s(r),t=s(e);for(const n of["major","minor","patch"])if(u[n]!==t[n])return u[n]-t[n];if(u.prerelease.length===0)return t.prerelease.length===0?0:1;if(t.prerelease.length===0)return-1;const l=Math.max(u.prerelease.length,t.prerelease.length);for(let n=0;n<l;n++){const o=u.prerelease[n],c=t.prerelease[n];if(o===void 0)return-1;if(c===void 0)return 1;if(o===c)continue;const m=/^\d+$/.test(o)?Number(o):null,f=/^\d+$/.test(c)?Number(c):null;return m!==null&&f!==null?m-f:m!==null?-1:f!==null?1:o.localeCompare(c)}return 0}i(a,"compareSkillSemanticVersions");var h="1.36.0",N=["react","react-dom","react-dom/client","react/jsx-runtime","@tego/ui","react-i18next","lucide-react","@tego/chat/plugin-surface"],p=/^\^(\d+)\.(\d+)\.(\d+)$/,d=/^(\d+)\.(\d+)\.(\d+)$/;function A(r){return p.test(r)||d.test(r)}i(A,"isValidHostApiRange");function E(r){const e=p.exec(r)??d.exec(r);if(!e)throw new Error(`Unsupported host API range "${r}". Use "^X.Y.Z" or "X.Y.Z".`);return`${e[1]}.${e[2]}.${e[3]}`}i(E,"hostApiRangeMinimum");function x(r,e,u){return r>0?`${r+1}.0.0`:e>0?`0.${e+1}.0`:`0.0.${u+1}`}i(x,"caretUpperBound");function b(r,e){if(d.exec(r))return a(e,r)===0;const t=p.exec(r);if(!t)throw new Error(`Unsupported host API range "${r}". Use "^X.Y.Z" or "X.Y.Z".`);s(e);const l=`${t[1]}.${t[2]}.${t[3]}`,n=x(Number(t[1]),Number(t[2]),Number(t[3]));return a(e,l)>=0&&a(e,n)<0}i(b,"satisfiesHostApiRange");export{h as HOST_API_VERSION,N as SHARED_MODULE_IDS,a as compareSkillSemanticVersions,E as hostApiRangeMinimum,A as isValidHostApiRange,s as parseSemanticVersion,b as satisfiesHostApiRange};
1
+ var $=Object.defineProperty;var i=(r,e)=>$(r,"name",{value:e,configurable:!0});function s(r){const e=/^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(r);if(!e)throw new Error(`Invalid semantic version: ${r}`);return{major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:e[4]?.split(".")??[]}}i(s,"parseSemanticVersion");function a(r,e){const u=s(r),t=s(e);for(const n of["major","minor","patch"])if(u[n]!==t[n])return u[n]-t[n];if(u.prerelease.length===0)return t.prerelease.length===0?0:1;if(t.prerelease.length===0)return-1;const l=Math.max(u.prerelease.length,t.prerelease.length);for(let n=0;n<l;n++){const o=u.prerelease[n],c=t.prerelease[n];if(o===void 0)return-1;if(c===void 0)return 1;if(o===c)continue;const m=/^\d+$/.test(o)?Number(o):null,f=/^\d+$/.test(c)?Number(c):null;return m!==null&&f!==null?m-f:m!==null?-1:f!==null?1:o.localeCompare(c)}return 0}i(a,"compareSkillSemanticVersions");var h="1.37.0",N=["react","react-dom","react-dom/client","react/jsx-runtime","@tego/ui","react-i18next","lucide-react","@tego/chat/plugin-surface"],p=/^\^(\d+)\.(\d+)\.(\d+)$/,d=/^(\d+)\.(\d+)\.(\d+)$/;function A(r){return p.test(r)||d.test(r)}i(A,"isValidHostApiRange");function E(r){const e=p.exec(r)??d.exec(r);if(!e)throw new Error(`Unsupported host API range "${r}". Use "^X.Y.Z" or "X.Y.Z".`);return`${e[1]}.${e[2]}.${e[3]}`}i(E,"hostApiRangeMinimum");function x(r,e,u){return r>0?`${r+1}.0.0`:e>0?`0.${e+1}.0`:`0.0.${u+1}`}i(x,"caretUpperBound");function b(r,e){if(d.exec(r))return a(e,r)===0;const t=p.exec(r);if(!t)throw new Error(`Unsupported host API range "${r}". Use "^X.Y.Z" or "X.Y.Z".`);s(e);const l=`${t[1]}.${t[2]}.${t[3]}`,n=x(Number(t[1]),Number(t[2]),Number(t[3]));return a(e,l)>=0&&a(e,n)<0}i(b,"satisfiesHostApiRange");export{h as HOST_API_VERSION,N as SHARED_MODULE_IDS,a as compareSkillSemanticVersions,E as hostApiRangeMinimum,A as isValidHostApiRange,s as parseSemanticVersion,b as satisfiesHostApiRange};
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var o=(r,e)=>p(r,"name",{value:e,configurable:!0});function parseSemanticVersion(r){const e=/^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(r);if(!e)throw new Error(`Invalid semantic version: ${r}`);return{major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:e[4]?.split(".")??[]}}o(parseSemanticVersion,"parseSemanticVersion");function compareSkillSemanticVersions(r,e){const i=parseSemanticVersion(r),t=parseSemanticVersion(e);for(const n of["major","minor","patch"])if(i[n]!==t[n])return i[n]-t[n];if(i.prerelease.length===0)return t.prerelease.length===0?0:1;if(t.prerelease.length===0)return-1;const c=Math.max(i.prerelease.length,t.prerelease.length);for(let n=0;n<c;n++){const s=i.prerelease[n],u=t.prerelease[n];if(s===void 0)return-1;if(u===void 0)return 1;if(s===u)continue;const a=/^\d+$/.test(s)?Number(s):null,l=/^\d+$/.test(u)?Number(u):null;return a!==null&&l!==null?a-l:a!==null?-1:l!==null?1:s.localeCompare(u)}return 0}o(compareSkillSemanticVersions,"compareSkillSemanticVersions");var HOST_API_VERSION="1.36.0",SHARED_MODULE_IDS=["react","react-dom","react-dom/client","react/jsx-runtime","@tego/ui","react-i18next","lucide-react","@tego/chat/plugin-surface"],CARET_RANGE_PATTERN=/^\^(\d+)\.(\d+)\.(\d+)$/,EXACT_VERSION_PATTERN=/^(\d+)\.(\d+)\.(\d+)$/;function isValidHostApiRange(r){return CARET_RANGE_PATTERN.test(r)||EXACT_VERSION_PATTERN.test(r)}o(isValidHostApiRange,"isValidHostApiRange");function hostApiRangeMinimum(r){const e=CARET_RANGE_PATTERN.exec(r)??EXACT_VERSION_PATTERN.exec(r);if(!e)throw new Error(`Unsupported host API range "${r}". Use "^X.Y.Z" or "X.Y.Z".`);return`${e[1]}.${e[2]}.${e[3]}`}o(hostApiRangeMinimum,"hostApiRangeMinimum");function caretUpperBound(r,e,i){return r>0?`${r+1}.0.0`:e>0?`0.${e+1}.0`:`0.0.${i+1}`}o(caretUpperBound,"caretUpperBound");function satisfiesHostApiRange(r,e){if(EXACT_VERSION_PATTERN.exec(r))return compareSkillSemanticVersions(e,r)===0;const t=CARET_RANGE_PATTERN.exec(r);if(!t)throw new Error(`Unsupported host API range "${r}". Use "^X.Y.Z" or "X.Y.Z".`);parseSemanticVersion(e);const c=`${t[1]}.${t[2]}.${t[3]}`,n=caretUpperBound(Number(t[1]),Number(t[2]),Number(t[3]));return compareSkillSemanticVersions(e,c)>=0&&compareSkillSemanticVersions(e,n)<0}o(satisfiesHostApiRange,"satisfiesHostApiRange"),exports.HOST_API_VERSION=HOST_API_VERSION,exports.SHARED_MODULE_IDS=SHARED_MODULE_IDS,exports.compareSkillSemanticVersions=compareSkillSemanticVersions,exports.hostApiRangeMinimum=hostApiRangeMinimum,exports.isValidHostApiRange=isValidHostApiRange,exports.parseSemanticVersion=parseSemanticVersion,exports.satisfiesHostApiRange=satisfiesHostApiRange;
1
+ "use strict";var p=Object.defineProperty;var o=(r,e)=>p(r,"name",{value:e,configurable:!0});function parseSemanticVersion(r){const e=/^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(r);if(!e)throw new Error(`Invalid semantic version: ${r}`);return{major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:e[4]?.split(".")??[]}}o(parseSemanticVersion,"parseSemanticVersion");function compareSkillSemanticVersions(r,e){const i=parseSemanticVersion(r),t=parseSemanticVersion(e);for(const n of["major","minor","patch"])if(i[n]!==t[n])return i[n]-t[n];if(i.prerelease.length===0)return t.prerelease.length===0?0:1;if(t.prerelease.length===0)return-1;const c=Math.max(i.prerelease.length,t.prerelease.length);for(let n=0;n<c;n++){const s=i.prerelease[n],u=t.prerelease[n];if(s===void 0)return-1;if(u===void 0)return 1;if(s===u)continue;const a=/^\d+$/.test(s)?Number(s):null,l=/^\d+$/.test(u)?Number(u):null;return a!==null&&l!==null?a-l:a!==null?-1:l!==null?1:s.localeCompare(u)}return 0}o(compareSkillSemanticVersions,"compareSkillSemanticVersions");var HOST_API_VERSION="1.37.0",SHARED_MODULE_IDS=["react","react-dom","react-dom/client","react/jsx-runtime","@tego/ui","react-i18next","lucide-react","@tego/chat/plugin-surface"],CARET_RANGE_PATTERN=/^\^(\d+)\.(\d+)\.(\d+)$/,EXACT_VERSION_PATTERN=/^(\d+)\.(\d+)\.(\d+)$/;function isValidHostApiRange(r){return CARET_RANGE_PATTERN.test(r)||EXACT_VERSION_PATTERN.test(r)}o(isValidHostApiRange,"isValidHostApiRange");function hostApiRangeMinimum(r){const e=CARET_RANGE_PATTERN.exec(r)??EXACT_VERSION_PATTERN.exec(r);if(!e)throw new Error(`Unsupported host API range "${r}". Use "^X.Y.Z" or "X.Y.Z".`);return`${e[1]}.${e[2]}.${e[3]}`}o(hostApiRangeMinimum,"hostApiRangeMinimum");function caretUpperBound(r,e,i){return r>0?`${r+1}.0.0`:e>0?`0.${e+1}.0`:`0.0.${i+1}`}o(caretUpperBound,"caretUpperBound");function satisfiesHostApiRange(r,e){if(EXACT_VERSION_PATTERN.exec(r))return compareSkillSemanticVersions(e,r)===0;const t=CARET_RANGE_PATTERN.exec(r);if(!t)throw new Error(`Unsupported host API range "${r}". Use "^X.Y.Z" or "X.Y.Z".`);parseSemanticVersion(e);const c=`${t[1]}.${t[2]}.${t[3]}`,n=caretUpperBound(Number(t[1]),Number(t[2]),Number(t[3]));return compareSkillSemanticVersions(e,c)>=0&&compareSkillSemanticVersions(e,n)<0}o(satisfiesHostApiRange,"satisfiesHostApiRange"),exports.HOST_API_VERSION=HOST_API_VERSION,exports.SHARED_MODULE_IDS=SHARED_MODULE_IDS,exports.compareSkillSemanticVersions=compareSkillSemanticVersions,exports.hostApiRangeMinimum=hostApiRangeMinimum,exports.isValidHostApiRange=isValidHostApiRange,exports.parseSemanticVersion=parseSemanticVersion,exports.satisfiesHostApiRange=satisfiesHostApiRange;
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var o=(i,t)=>p(i,"name",{value:t,configurable:!0});import{localizedTextToString as C}from"./chunk-INCA3GFW.js";var m=["frontend","backend","claw"],l="__OPENCLAW_REDACTED__",c={fieldCount:0,required:[],sensitive:[]};function v(i){if(!i)return c;const t=Object.keys(i.schema.properties),n=i.uiHints??{};return{fieldCount:t.length,required:(i.schema.required??[]).filter(e=>t.includes(e)),sensitive:t.filter(e=>n[e]?.sensitive===!0)}}o(v,"summarizeConfigDeclaration");function _(i){if(!i)return c;const t=i.configSchema;if(typeof t!="object"||t===null)return c;const n=t.properties,e=typeof n=="object"&&n!==null?Object.keys(n):[],r=t.required,s=Array.isArray(r)?r.filter(u=>typeof u=="string"&&e.includes(u)):[],f=i.uiHints,a=typeof f=="object"&&f!==null?f:{},d=e.filter(u=>a[u]?.sensitive===!0);return{fieldCount:e.length,required:s,sensitive:d}}o(_,"summarizeClawConfig");function b(i,t){const n={...i};for(const e of t)n[e]===void 0||n[e]===null||(n[e]=l);return n}o(b,"redactSecrets");function E(i,t,n){const e={...i};for(const r of n){if(e[r]!==l)continue;const s=t[r];if(s===void 0){delete e[r];continue}e[r]=s}return e}o(E,"restoreSecrets");function N(i,t){const n={...t};for(const[e,r]of Object.entries(i.properties??{}))n[e]===void 0&&r.default!==void 0&&(n[e]=r.default);return n}o(N,"applyConfigDefaults");function S(i,t,n,e){return t?.label?C(t.label,e):n?.title?n.title:i}o(S,"configFieldLabel");export{c as EMPTY_CONFIG_SECTION_SUMMARY,l as PLUGIN_CONFIG_SECRET_SENTINEL,m as PLUGIN_CONFIG_SECTIONS,N as applyConfigDefaults,S as configFieldLabel,b as redactSecrets,E as restoreSecrets,_ as summarizeClawConfig,v as summarizeConfigDeclaration};
@@ -0,0 +1 @@
1
+ var N=Object.defineProperty;var u=(o,t)=>N(o,"name",{value:t,configurable:!0});import{PLUGIN_NAV_ICONS as _,publicRoutePathProblem as E,PLUGIN_PUBLIC_ROUTE_METHODS as L,publicRoutesOverlap as H,formatPublicRoute as w,PLUGIN_PART_DEFAULTS as b}from"./chunk-IVJECPGG.js";import{pluginMenuPermission as O,MAX_PLUGIN_MENU_PERMISSION_LENGTH as P}from"./chunk-INCA3GFW.js";import{parseSemanticVersion as D,isValidHostApiRange as p,compareSkillSemanticVersions as m,hostApiRangeMinimum as h}from"./chunk-56QOZQTY.js";import{validateAccessCatalog as U}from"./chunk-VMCGDDGP.js";import{isIP as C}from"net";import{z as e}from"zod";function M(o,t){const a=`access.catalog (${o.access?.catalog??"?"})`,n=U(t);if(!n.ok)return{ok:!1,errors:n.issues.map(r=>`${a}: ${r.path}: ${r.message}`)};const s=new Set((o.parts.frontend?.nav??[]).map(r=>r.key)),i=Object.keys(n.catalog.menus).filter(r=>!s.has(r)).map(r=>`${a}: menus.${r}: no parts.frontend.nav entry has this key`);return i.length>0?{ok:!1,errors:i}:{ok:!0,catalog:n.catalog}}u(M,"checkPluginAccessCatalog");var v={major:3,minor:12},F=36,f="requirements.lock",G="wheels";function I(o){return o.toLowerCase().replace(/[-_.]+/g,"-")}u(I,"normalizePackageName");function S(o){const t=[],a=[],n=o.replace(/\\\r?\n/g," ").split(/\r?\n/).map(s=>s.replace(/(^|\s)#.*$/,"").trim()).filter(Boolean);for(const s of n){const[i="",...r]=s.split(/\s+/),c=/^([A-Za-z0-9][A-Za-z0-9._-]*)(?:\[[^\]]*\])?==([^\s;]+)$/.exec(i);if(!c||s.includes(";")){a.push(`${f}: "${s.slice(0,80)}" is not a pinned "name==version" requirement without markers`);continue}const l=[];for(const g of r){const x=/^--hash=sha256:([0-9a-f]{64})$/.exec(g);x?.[1]?l.push(x[1]):a.push(`${f}: unsupported option "${g.slice(0,40)}" on ${c[1]}`)}l.length===0&&a.push(`${f}: ${c[1]}==${c[2]} has no --hash; compile with --generate-hashes`),t.push({name:I(c[1]),version:c[2].toLowerCase(),hashes:l})}return{requirements:t,errors:a}}u(S,"parseRequirementsLock");function Z(o){if(!o.endsWith(".whl"))return null;const t=o.slice(0,-4).split("-");if(t.length!==5&&t.length!==6)return null;const[a,n]=t,[s,i,r]=t.slice(-3);return!a||!n||!s||!i||!r?null:{name:I(a),version:n.toLowerCase(),pythonTags:s.split("."),abiTags:i.split("."),platformTags:r.split(".")}}u(Z,"parseWheelFilename");function V(o){const{major:t,minor:a}=v,n=`${t}${a}`;return o.pythonTags.some(s=>{if(s===`py${t}`||s===`py${n}`||s===`cp${n}`)return!0;const i=/^cp3(\d+)$/.exec(s);return i?.[1]!==void 0&&Number(i[1])<=a&&o.abiTags.includes("abi3")})}u(V,"supportsInterpreter");function W(o,t){const a=t==="linux/amd64"?"x86_64":"aarch64";return o.platformTags.some(n=>{if(n==="any"||n===`manylinux2014_${a}`||a==="x86_64"&&/^manylinux(1|2010)_x86_64$/.test(n))return!0;const s=/^manylinux_2_(\d+)_(x86_64|aarch64)$/.exec(n);return s?.[2]===a&&Number(s[1])<=F})}u(W,"supportsPlatform");function B(o){if(o.lockText===null)return[`Python backend ships no ${f}. The runner installs offline from it with --require-hashes.`];const{requirements:t,errors:a}=S(o.lockText),n=o.wheels.map(s=>({...s,parsed:Z(s.filename)}));for(const s of n){if(!s.parsed){a.push(`"${s.filename}" is not a valid wheel filename`);continue}const i=t.find(r=>r.name===s.parsed.name&&r.version===s.parsed.version);i?i.hashes.includes(s.sha256)||a.push(`"${s.filename}" does not match any --hash locked for ${i.name}==${i.version}`):a.push(`"${s.filename}" is not in ${f}; ship only locked wheels`)}for(const s of t){const i=n.filter(r=>r.parsed?.name===s.name&&r.parsed.version===s.version&&V(r.parsed));for(const r of o.platforms)i.some(c=>W(c.parsed,r))||a.push(`No wheel for ${s.name}==${s.version} on ${r} (python ${v.major}.${v.minor})`)}return a}u(B,"checkPythonVendoring");var K=/^[a-z0-9][a-z0-9._-]*$/,T="directory.read",R="1.22.0",Y=128,Q=/^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/,d=e.string().min(1).max(256).regex(Q,"must be a relative path inside the package").refine(o=>!o.split("/").some(t=>t===".."||t==="."),{message:'must not contain "." or ".." segments'}),y=e.union([e.string().min(1),e.record(e.string().min(1),e.string().min(1))]),X=e.string().refine(o=>{try{return D(o),!0}catch{return!1}},{message:"must be a valid semantic version"}),k=e.string().min(1).max(64).regex(/^[a-z0-9][a-z0-9-]*$/,"must be lowercase alphanumeric with hyphens"),J=e.object({key:k,labelKey:e.string().min(1).max(200),icon:e.enum(_).optional(),order:e.number().int().min(0).max(1e4).optional(),path:e.string().regex(/^\/[A-Za-z0-9/_-]*$/,'must start with "/"').max(256).optional()}).strict(),A=e.string().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_]*$/,"must be a plain identifier: a letter followed by letters, digits or underscores"),ee=e.object({type:e.enum(["string","number","integer","boolean","array"]),title:e.string().min(1).max(200).optional(),description:e.string().min(1).max(1e3).optional(),default:e.unknown().optional(),enum:e.array(e.union([e.string().max(200),e.number()])).min(1).max(50).optional(),minLength:e.number().int().min(0).max(1e4).optional(),maxLength:e.number().int().min(1).max(1e4).optional(),pattern:e.string().min(1).max(500).optional(),format:e.enum(["uri","email"]).optional(),minimum:e.number().optional(),maximum:e.number().optional(),items:e.object({type:e.literal("string"),enum:e.array(e.string().max(200)).min(1).max(50).optional()}).strict().optional(),maxItems:e.number().int().min(1).max(200).optional()}).strict().superRefine((o,t)=>{o.type==="array"&&o.items===void 0&&t.addIssue({code:e.ZodIssueCode.custom,path:["items"],message:'an array field must declare { "type": "string" } items'}),o.type!=="array"&&o.items!==void 0&&t.addIssue({code:e.ZodIssueCode.custom,path:["items"],message:"only an array field may declare items"}),o.enum&&o.default!==void 0&&(o.enum.some(n=>Object.is(n,o.default))||t.addIssue({code:e.ZodIssueCode.custom,path:["default"],message:"must be one of the declared enum values"}))}),$=e.union([e.string().min(1).max(500),e.record(e.string().min(1),e.string().min(1).max(500))]),oe=e.object({label:$.optional(),help:$.optional(),placeholder:$.optional(),order:e.number().int().min(0).max(1e4).optional(),advanced:e.boolean().optional(),sensitive:e.boolean().optional()}).strict(),j=e.object({schema:e.object({type:e.literal("object"),properties:e.record(A,ee),required:e.array(A).max(50).optional(),additionalProperties:e.literal(!1).optional()}).strict(),uiHints:e.record(A,oe).optional()}).strict().superRefine((o,t)=>{const a=Object.keys(o.schema.properties);a.length>50&&t.addIssue({code:e.ZodIssueCode.custom,path:["schema","properties"],message:"a config section is limited to 50 fields"});for(const n of o.schema.required??[])a.includes(n)||t.addIssue({code:e.ZodIssueCode.custom,path:["schema","required"],message:`"${n}" is required but not declared in properties`});for(const n of Object.keys(o.uiHints??{}))a.includes(n)||t.addIssue({code:e.ZodIssueCode.custom,path:["uiHints",n],message:"no such field in the section schema"})}),te=e.object({dir:d.optional(),entry:d.optional(),i18nDir:d.optional(),icon:e.enum(_).optional(),nav:e.array(J).max(20).optional(),config:j.optional()}).strict().superRefine((o,t)=>{for(const[a,n]of Object.entries(o.config?.uiHints??{}))n.sensitive===!0&&t.addIssue({code:e.ZodIssueCode.custom,path:["config","uiHints",a,"sensitive"],message:"the frontend config section is delivered to the browser, so it cannot hold secrets \u2014 declare this field in the backend section instead"})}).refine(o=>{const t=(o.nav??[]).map(a=>a.key);return new Set(t).size===t.length},{message:"nav entries must have unique keys",path:["nav"]}),ae=e.object({memoryMb:e.number().int().min(64).max(4096).optional(),cpuMs:e.number().int().min(100).max(6e5).optional(),requestTimeoutMs:e.number().int().min(100).max(12e4).optional()}).strict(),q=/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z0-9-]{0,61}[a-z0-9]$/,se=e.string().max(259).refine(o=>{if(o==="*")return!0;const t=/^\[([0-9a-f:]+)\]:([1-9]\d{0,4})$/.exec(o);if(t)return C(t[1])===6&&Number(t[2])<=65535;const a=/^([^:]+)(?::([1-9]\d{0,4}))?$/.exec(o);if(!a)return!1;const[,n,s]=a;return s&&Number(s)>65535?!1:s&&C(n)===4||q.test(n)},"must be *, a lowercase hostname, hostname:port, or IP:port"),ne=e.object({method:e.enum(L),path:e.string().max(256).superRefine((o,t)=>{const a=E(o);a&&t.addIssue({code:e.ZodIssueCode.custom,message:a})})}).strict(),re=e.object({dir:d.optional(),runtime:e.enum(["node","python"]).optional(),entry:d.optional(),platforms:e.array(e.enum(["linux/amd64","linux/arm64"])).min(1).optional(),egress:e.array(se).max(20).refine(o=>!o.includes("*")||o.length===1,{message:"the * wildcard must be the only egress entry"}).optional(),migrationsDir:d.optional(),compatibilityRepairs:e.array(e.object({id:e.string().regex(/^[a-z][a-z0-9_-]{0,99}$/),sqlFile:d.refine(o=>o.startsWith("repairs/")&&o.endsWith(".sql"),"Use a SQL file under repairs/"),table:e.string().regex(/^[a-z][a-z0-9_]{0,62}$/),column:e.string().regex(/^[a-z][a-z0-9_]{0,62}$/),postgresType:e.enum(["integer","text","boolean","bigint","jsonb"])}).strict()).max(100).refine(o=>new Set(o.map(t=>t.id)).size===o.length,"Repair IDs must be unique").optional(),healthPath:e.string().regex(/^\/[A-Za-z0-9/_-]*$/,'must start with "/"').max(256).optional(),limits:ae.optional(),publicRoutes:e.array(ne).max(100).optional(),config:j.optional()}).strict().superRefine((o,t)=>{const a=o.publicRoutes??[];a.forEach((n,s)=>{const i=a.slice(0,s).find(r=>H(r,n));i&&t.addIssue({code:e.ZodIssueCode.custom,path:["publicRoutes",s],message:`"${w(n)}" can match the same requests as "${w(i)}"`})}),o.platforms&&(o.runtime??"node")!=="python"&&t.addIssue({code:e.ZodIssueCode.custom,path:["platforms"],message:'only applies to runtime "python"'})}),ie=e.object({dir:d.optional(),hooks:e.object({allowPromptInjection:e.boolean().optional(),allowConversationAccess:e.boolean().optional()}).strict().optional()}).strict();function ce(o,t){return t===o||t.startsWith(`${o}/`)}u(ce,"containsPath");var de=e.object({dir:d.optional()}).strict(),le=e.object({frontend:te.optional(),backend:re.optional(),claw:ie.optional(),publicFrontend:de.optional()}).strict().refine(o=>o.frontend!==void 0||o.backend!==void 0||o.claw!==void 0,{message:"a plugin must declare at least one of frontend, backend, claw"}).superRefine((o,t)=>{const a=[["frontend",o.frontend?.dir??b.frontend.dir],["backend",o.backend?.dir??b.backend.dir],["claw",o.claw?.dir??b.claw.dir],["publicFrontend",o.publicFrontend?.dir??b.publicFrontend.dir]].filter(([n])=>o[n]!==void 0);for(const[n,s]of a)for(const[i,r]of a)n!==i&&ce(s,r)&&t.addIssue({code:e.ZodIssueCode.custom,path:[i,"dir"],message:s===r?`must not be the same directory as the ${n} part ("${s}")`:`must not sit inside the ${n} part's directory ("${s}")`})}),ue=e.object({required:e.array(e.string().min(1).max(128)).max(50).optional()}).strict(),pe=e.object({database:e.boolean().optional(),storage:e.boolean().optional(),events:e.boolean().optional(),notifications:e.boolean().optional()}).strict(),z=e.object({manifestVersion:e.literal(1),id:e.string().max(Y).regex(K,"must be lowercase letters, digits, dot, underscore or hyphen, starting with a letter or digit"),version:X,displayName:y,description:y.optional(),author:e.string().max(200).optional(),homepage:e.string().url().max(500).optional(),icon:d.optional(),category:e.string().min(1).max(64).optional(),tags:e.array(e.string().min(1).max(64)).max(20).optional(),hostApiRange:e.string().refine(p,{message:'must be a caret range like "^1.2.0" or an exact "1.2.0"'}).optional(),scope:e.enum(["avatar","tenant"]),declares:pe.optional(),parts:le,permissions:ue.optional(),access:e.object({catalog:d}).strict().optional(),audit:e.object({tools:e.record(e.string().min(1).max(128),e.object({category:e.enum(["read","write","search","browse","exec","knowledge","memory","message","schedule","delegate","document","plugin"]).optional(),title:y.optional(),target:e.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).optional(),risk:e.enum(["low","medium","high"]).optional(),dataClasses:e.array(e.string().min(1).max(32)).max(10).optional()}).strict()).optional()}).strict().optional(),agentTemplates:e.array(e.object({key:k,entry:d,icon:d.optional()}).strict()).max(20).optional(),workDelegation:e.object({allowedAvatarRoles:e.array(e.string().min(1).max(100)).min(1).max(20),settingsRoute:e.string().regex(/^\/[A-Za-z0-9/_-]*$/,'must start with "/"').max(256).refine(o=>!o.startsWith("//"),"must be a plugin page").optional(),summary:y.refine(o=>(typeof o=="string"?[o]:Object.values(o)).every(t=>t.length<=120),"must be at most 120 characters in every locale").optional(),privacyPolicyUrl:e.string().url().max(2048).refine(o=>o.startsWith("https://"),"must be an https URL").optional(),conversationCapture:e.boolean().optional()}).strict().optional(),conversationRecordRoutes:e.array(e.object({entity:k,path:d,contextQuery:e.string().max(200).regex(/^[A-Za-z0-9_=&-]+$/).optional(),labelFields:e.array(e.string().regex(/^[A-Za-z][A-Za-z0-9_]*$/)).min(1).max(3).optional()}).strict()).max(30).optional(),agentReadiness:e.object({path:d}).strict().optional()}).strict().superRefine((o,t)=>{const a=new Set;for(const[c,l]of(o.agentTemplates??[]).entries())a.has(l.key)&&t.addIssue({code:e.ZodIssueCode.custom,path:["agentTemplates",c,"key"],message:"duplicate template key"}),a.add(l.key);const n=new Set;for(const[c,l]of(o.conversationRecordRoutes??[]).entries())n.has(l.entity)&&t.addIssue({code:e.ZodIssueCode.custom,path:["conversationRecordRoutes",c,"entity"],message:"duplicate conversation entity"}),n.add(l.entity);(o.parts.frontend!==void 0||o.parts.backend!==void 0)&&o.hostApiRange===void 0&&t.addIssue({code:e.ZodIssueCode.custom,path:["hostApiRange"],message:"required when a frontend or backend part is declared, so the host can refuse incompatible releases"});const i=o.parts.backend?.publicRoutes??[];if(o.parts.publicFrontend!==void 0&&i.length===0&&t.addIssue({code:e.ZodIssueCode.custom,path:["parts","publicFrontend"],message:"requires parts.backend.publicRoutes for the pages to call"}),o.parts.backend===void 0&&o.declares)for(const c of["database","storage","events"])o.declares[c]===!0&&t.addIssue({code:e.ZodIssueCode.custom,path:["declares",c],message:"requires a backend part"});o.permissions?.required?.includes("knowledge.manage")&&(!o.parts.backend||!o.hostApiRange||p(o.hostApiRange)&&m(h(o.hostApiRange),"1.23.0")<0)&&t.addIssue({code:e.ZodIssueCode.custom,path:["hostApiRange"],message:"knowledge.manage requires a backend and host API ^1.23.0 or later"}),o.permissions?.required?.includes("proactive.emit")&&(!o.parts.backend||!o.hostApiRange||p(o.hostApiRange)&&m(h(o.hostApiRange),"1.26.0")<0)&&t.addIssue({code:e.ZodIssueCode.custom,path:["hostApiRange"],message:"proactive.emit requires a backend and host API ^1.26.0 or later"}),o.permissions?.required?.includes("attention.request")&&(!o.parts.backend||!o.hostApiRange||p(o.hostApiRange)&&m(h(o.hostApiRange),"1.34.0")<0)&&t.addIssue({code:e.ZodIssueCode.custom,path:["hostApiRange"],message:"attention.request requires a backend and host API ^1.34.0 or later"}),o.permissions?.required?.includes("mail.send")&&(!o.parts.backend||!o.hostApiRange||p(o.hostApiRange)&&m(h(o.hostApiRange),"1.29.0")<0)&&t.addIssue({code:e.ZodIssueCode.custom,path:["hostApiRange"],message:"mail.send requires a backend and host API ^1.29.0 or later"}),o.agentReadiness!==void 0&&o.parts.backend===void 0&&t.addIssue({code:e.ZodIssueCode.custom,path:["agentReadiness"],message:"requires a backend part to answer it"}),(o.agentReadiness!==void 0||o.workDelegation?.settingsRoute!==void 0)&&(!o.hostApiRange||p(o.hostApiRange)&&m(h(o.hostApiRange),"1.30.0")<0)&&t.addIssue({code:e.ZodIssueCode.custom,path:["hostApiRange"],message:"agentReadiness and workDelegation.settingsRoute require host API ^1.30.0 or later"}),o.workDelegation!==void 0&&o.parts.backend===void 0&&t.addIssue({code:e.ZodIssueCode.custom,path:["workDelegation"],message:"requires a backend part to act on it"});const r=o.workDelegation;(r?.summary!==void 0||r?.privacyPolicyUrl!==void 0||r?.conversationCapture!==void 0)&&(!o.hostApiRange||p(o.hostApiRange)&&m(h(o.hostApiRange),"1.33.0")<0)&&t.addIssue({code:e.ZodIssueCode.custom,path:["hostApiRange"],message:"workDelegation.summary, privacyPolicyUrl and conversationCapture require host API ^1.33.0 or later"}),o.access!==void 0&&(o.parts.backend===void 0&&t.addIssue({code:e.ZodIssueCode.custom,path:["access"],message:"requires a backend part to enforce it"}),o.permissions?.required?.includes(T)||t.addIssue({code:e.ZodIssueCode.custom,path:["permissions","required"],message:`must include "${T}" when access is declared`}),o.hostApiRange!==void 0&&p(o.hostApiRange)&&m(h(o.hostApiRange),R)<0&&t.addIssue({code:e.ZodIssueCode.custom,path:["hostApiRange"],message:`access needs host API ${R} \u2014 declare "^${R}" or later`})),(o.parts.frontend?.nav??[]).forEach((c,l)=>{const g=O(o.id,c.key);g.length<=P||t.addIssue({code:e.ZodIssueCode.custom,path:["parts","frontend","nav",l,"key"],message:`together with the plugin id this derives "${g}" (${g.length} chars), over the ${P}-char limit \u2014 shorten the id or the key`})})});function me(o){return o.issues.map(t=>{const a=t.path.join(".");return a?`${a}: ${t.message}`:t.message})}u(me,"formatIssues");function he(o){const t=z.safeParse(o);return t.success?{ok:!0,manifest:t.data,errors:[]}:{ok:!1,errors:me(t.error)}}u(he,"parseTegoPluginManifest");export{f as PYTHON_LOCK_FILENAME,v as PYTHON_RUNNER_VERSION,G as PYTHON_WHEELS_DIR,M as checkPluginAccessCatalog,B as checkPythonVendoring,I as normalizePackageName,S as parseRequirementsLock,he as parseTegoPluginManifest,Z as parseWheelFilename,z as tegoPluginManifestSchema};
@@ -0,0 +1,20 @@
1
+ var dt=Object.defineProperty;var l=(t,n)=>dt(t,"name",{value:n,configurable:!0});import{TEGO_PLUGIN_DEV_OVERRIDES as U}from"./chunk-I5Z3ECC4.js";import{parseTegoPluginManifest as wt,checkPluginAccessCatalog as ht,PYTHON_LOCK_FILENAME as T,parseRequirementsLock as B,normalizePackageName as mt,PYTHON_WHEELS_DIR as pt,checkPythonVendoring as gt,PYTHON_RUNNER_VERSION as J,parseWheelFilename as yt}from"./chunk-EIVA5BR6.js";import{resolvePluginParts as R,PLUGIN_MANIFEST_FILENAME as C,CLAW_MANIFEST_FILENAME as $t}from"./chunk-IVJECPGG.js";import{createHash as q}from"crypto";import{readFile as m,readdir as k,access as kt,rm as D,mkdir as g,writeFile as b,cp as y,stat as G}from"fs/promises";import{createServer as bt}from"http";import{join as o,relative as K,sep as vt,resolve as d,dirname as v,basename as x}from"path";import Et from"jszip";import{execFile as Pt}from"child_process";import{promisify as _t}from"util";var V="template.config.json",Y={IDENTITY:"identityMd",SOUL:"soulMd",AGENTS:"agentsMd",TOOLS:"toolsMd",BOOTSTRAP:"bootstrapMd",HEARTBEAT:"heartbeatMd",USER:"userMd",MEMORY:"memoryMd"};async function z(t){const{agents:n,...a}=JSON.parse(await m(o(t,V),"utf8")),e=a.slug??t,i={...a.content,...await X(o(t,"workspace"))},s=await At(o(t,"workspace"));if(s.length>0&&(i.workspaceFiles=s),n){if(n[0]?.id!=="main")throw new Error(`${e}: the first of "agents" must be main`);if(a.content?.agentList)throw new Error(`${e}: declare the team in "agents" or in "content.agentList", not both`);const r=n.slice(1),c=(await xt(o(t,"experts"))).sort(),u=r.map(f=>f.id).sort();if(c.join()!==u.join())throw new Error(`${e}: experts/ holds [${c.join(", ")}] but "agents" declares [${u.join(", ")}]`);if(r.length>0){const f={};for(const h of r)f[h.id]=await X(o(t,"experts",h.id));i.subAgentWorkspaces=f}i.agentList=n.map(({id:f,name:h,description:w,emoji:$})=>({id:f,name:h,...w?{description:w}:{},identity:{name:h,emoji:$},...f==="main"&&r.length>0?{subagents:{allowAgents:r.map(E=>E.id)}}:{}}))}return`${JSON.stringify({...a,content:i},null,2)}
2
+ `}l(z,"buildAgentTemplate");async function X(t){const n=new Set(await Tt(t)),a={};for(const[e,i]of Object.entries(Y)){const s=`${e}.md`;n.has(s)&&(a[i]=await Z(o(t,s)))}return a}l(X,"readRootFiles");async function At(t){const n=new Set(Object.keys(Y).map(e=>`${e}.md`)),a=(await Q(t)).map(e=>K(t,e).split(vt).join("/")).filter(e=>!n.has(e)).sort();return Promise.all(a.map(async e=>({path:e,content:await Z(o(t,e)),...e.endsWith(".md")?{contentType:"text/markdown"}:{}})))}l(At,"readExtraFiles");async function Z(t){return(await m(t,"utf8")).replace(/\n$/,"")}l(Z,"readDocument");async function Q(t){const n=await k(t,{withFileTypes:!0}).catch(()=>[]),a=[];for(const e of n){if(e.name.startsWith("."))continue;const i=o(t,e.name);e.isDirectory()?a.push(...await Q(i)):e.isFile()&&a.push(i)}return a}l(Q,"walk");async function Tt(t){return(await k(t,{withFileTypes:!0}).catch(()=>[])).filter(a=>a.isFile()).map(a=>a.name)}l(Tt,"fileNames");async function xt(t){return(await k(t,{withFileTypes:!0}).catch(()=>[])).filter(a=>a.isDirectory()&&!a.name.startsWith(".")).map(a=>a.name)}l(xt,"subdirectories");var S="@tego/plugin-access-ui";async function M(t,n,a){const e=d(t,a),i=await k(e).then(c=>c.filter(u=>u.endsWith(".json")).sort(),c=>{if(c.code==="ENOENT")return[];throw c}),s=new Map,r=n.access&&i.length>0?await Dt(t):null;for(const c of i){const u=await m(o(e,c),"utf8");if(!r){s.set(c,u);continue}s.set(c,Lt(c,u,r,await Nt(r,c)))}return s}l(M,"readPluginLocales");async function Dt(t){for(let n=d(t);;n=v(n)){const a=o(n,"node_modules",S);if(await kt(o(a,"package.json")).then(()=>!0,()=>!1))return o(a,"locales");if(v(n)===n)break}throw new Error(`The manifest declares access, so the frontend renders ${S} \u2014 add it to this plugin's dependencies.`)}l(Dt,"accessUiLocaleDir");async function Nt(t,n){try{return await m(o(t,n),"utf8")}catch{throw new Error(`${S} has no ${n}; the plugin ships that locale, so its access screens would show bare keys.`)}}l(Nt,"readAccessLocale");function Lt(t,n,a,e){const i=JSON.parse(n),s=JSON.parse(e);for(const r of Object.keys(s))if(r in i)throw new Error(`Locale ${t} defines "${r}", which ${S} (${a}) owns \u2014 rename the plugin's key.`);return`${JSON.stringify({...i,...s},null,2)}
3
+ `}l(Lt,"mergeLocale");var Ot=_t(Pt),tt="315532800",Ct=["src","resources","migrations"],et="requirements.in",I="tego-plugin-sdk",St={"linux/amd64":"x86_64","linux/arm64":"aarch64"};function Ft(t){const n=St[t],a=[`manylinux2014_${n}`];for(let e=17;e<=36;e++)a.push(`manylinux_2_${e}_${n}`);return n==="x86_64"&&a.push("manylinux2010_x86_64","manylinux1_x86_64"),a.flatMap(e=>["--platform",e])}l(Ft,"pipPlatformArgs");async function A(t){try{return await G(t),!0}catch{return!1}}l(A,"exists");async function nt(t,n){if(n)return d(t,n);let a=t;for(;;){const e=o(a,"packages","plugin-sdk-python");if(await A(o(e,"pyproject.toml")))return e;const i=v(a);if(i===a)throw new Error("Cannot find packages/plugin-sdk-python above the plugin root; pass backend.python.sdkProject.");a=i}}l(nt,"findSdkProject");async function F(t,n={}){try{await Ot("uv",t,{env:{...process.env,...n},maxBuffer:64*1024*1024})}catch(a){const e=a.stderr?.trim()||(a instanceof Error?a.message:String(a));throw a.code==="ENOENT"?new Error("`uv` is required to pack a python backend: https://docs.astral.sh/uv/"):new Error(`uv ${t[0]} failed:
4
+ ${e}`)}}l(F,"uv");async function at(t,n){await F(["build","--quiet","--wheel","--out-dir",n,t],{SOURCE_DATE_EPOCH:tt})}l(at,"buildSdkWheel");async function jt(t,n,a={}){const e=d(t,n.dir),i=o(e,et);if(!await A(i))throw new Error(`${n.dir}/${et} not found`);const s=o(t,"build","python-sdk");await D(s,{recursive:!0,force:!0}),await at(await nt(t,a.sdkProject),s);const r=o(e,T),{major:c,minor:u}=J;return await F(["pip","compile","--quiet",i,"--output-file",r,"--generate-hashes","--no-header","--python-version",`${c}.${u}`,"--python-platform","x86_64-manylinux_2_36","--find-links",s,"--upgrade-package",I]),r}l(jt,"lockPythonBackend");async function it(t){return q("sha256").update(await m(t)).digest("hex")}l(it,"sha256");async function Rt(t){const{major:n,minor:a}=J,e=o(t.scratch,"downloads");await g(e,{recursive:!0});for(const s of t.platforms)await F(["tool","run","--from","pip","pip","download","--quiet","--no-deps","--prefer-binary","--require-hashes","--python-version",`${n}.${a}`,"--implementation","cp","--abi",`cp${n}${a}`,"--abi","abi3","--abi","none",...Ft(s),"--find-links",t.sdkDist,"--requirement",t.lockPath,"--dest",e]);const i=o(t.scratch,"built");for(const s of await k(e))s.endsWith(".whl")||await F(["build","--quiet","--wheel","--out-dir",i,o(e,s)],{SOURCE_DATE_EPOCH:tt});await g(t.wheelsDir,{recursive:!0});for(const s of[e,i])if(await A(s))for(const r of(await k(s)).sort())r.endsWith(".whl")&&await y(o(s,r),o(t.wheelsDir,r))}l(Rt,"vendorWheels");async function Mt(t,n,a){const{requirements:e}=B(t),i=new Map;for(const c of(await k(n)).sort()){const u=yt(c);if(!u)continue;const f=`${u.name}==${u.version}`;i.set(f,[...i.get(f)??[],await it(o(n,c))])}const r=`${e.map(c=>{const u=i.get(`${c.name}==${c.version}`)??[];return[`${c.name}==${c.version}`,...u.map(f=>`--hash=sha256:${f}`)].join(" ")}).join(`
5
+ `)}
6
+ `;return await b(a,r,"utf8"),r}l(Mt,"writePackagedLock");async function It(t){const{root:n,staging:a,part:e,options:i={},log:s}=t,r=d(n,e.dir),c=o(a,e.dir);await g(c,{recursive:!0});const u=d(n,e.entryPath);if(!await A(u))throw new Error(`backend entry not found at ${u}`);await y(u,o(a,e.entryPath));for(const P of i.include??Ct){const _=o(r,P);await A(_)&&await y(_,o(c,P),{recursive:!0,filter:l(j=>!/(^|\/)(__pycache__|\.pytest_cache|\.venv)(\/|$)|\.pyc$/.test(j),"filter")})}const f=d(n,e.migrationsDirPath);await A(f)&&await y(f,o(a,e.migrationsDirPath),{recursive:!0});const h=o(r,T);if(!await A(h))throw new Error(`${e.dir}/${T} not found; run \`tego-plugin-pack lock\``);const w=await m(h,"utf8"),{errors:$,requirements:E}=B(w);if($.length>0)throw new Error([`${e.dir}/${T} is invalid:`,...$].join(`
7
+ `));if(!E.some(P=>P.name===mt(I)))throw new Error(`${e.dir}/${T} must lock ${I}`);const O=o(n,"build","python-scratch");await D(O,{recursive:!0,force:!0});try{const P=o(O,"sdk");await at(await nt(n,i.sdkProject),P);const _=o(c,pt);s(` \u203A vendoring ${E.length} packages for ${e.platforms.join(", ")}`),await Rt({lockPath:h,platforms:e.platforms,sdkDist:P,wheelsDir:_,scratch:O});const j=await Mt(w,_,o(c,T)),ft=await Promise.all((await k(_)).map(async W=>({filename:W,sha256:await it(o(_,W))}))),H=gt({lockText:j,wheels:ft,platforms:e.platforms});if(H.length>0)throw new Error(["Python backend would not install in the runner:",...H].join(`
8
+ `))}finally{await D(O,{recursive:!0,force:!0})}}l(It,"stagePythonBackend");var Ht=["pg","node:*"],Wt=["openclaw","openclaw/*","node:*"],rt=new Date(Date.UTC(1980,0,1));async function Ut(t){const n=d(t.root),a=t.log===null?()=>{}:t.log??(c=>console.log(c)),e=await N(n),i=R(e);if(t.doctor!==!1){const{runDoctor:c,UPLOAD_BLOCKING_RULES:u}=await import("./doctor.js"),f=await c({root:n}),h=f.findings.filter(w=>w.severity==="error"&&u.includes(w.rule));if(h.length>0)throw new Error(["Upload would refuse this package:",...h.map(w=>` ${w.rule} ${w.file?`${w.file}: `:""}${w.message}`)].join(`
9
+ `));f.findings.length>0&&a(`\u26A0 doctor: ${f.errors} error(s), ${f.warnings} warning(s) \u2014 run \`tego-plugin doctor\` for the list`)}const s=d(n,t.outDir??"build"),r=o(s,"package");await D(r,{recursive:!0,force:!0}),await g(r,{recursive:!0});try{await b(o(r,C),`${JSON.stringify(e,null,2)}
10
+ `,"utf8"),await zt(n,r,e),i.frontend&&(a("\u203A building frontend"),await Yt(n,r,e,i.frontend,t.frontend)),i.publicFrontend&&(a("\u203A building public pages"),await Xt(n,r,i.publicFrontend,t.publicFrontend)),i.backend?.runtime==="python"?(a("\u203A staging python backend"),await It({root:n,staging:r,part:i.backend,...t.backend?.python?{options:t.backend.python}:{},log:a})):i.backend&&(a("\u203A building backend"),await Zt(n,r,i.backend,t.backend)),i.claw&&(a("\u203A building claw"),await Qt(n,r,i.claw,e,t.claw)),await ot(n,e,a);for(const h of e.agentTemplates??[])for(const w of[h.entry,h.icon].filter($=>!!$)){const $=d(n,w);await p($,`agent template asset ${w}`);const E=o(r,w);await g(v(E),{recursive:!0}),await y($,E)}const c=o(s,t.fileName??`${e.id}-${e.version}.zip`),u=await te(r,c),f=q("sha256").update(await m(c)).digest("hex");return a(`\u2705 ${K(n,c)} \u2014 ${ee(u)}`),{file:c,bytes:u,sha256:f,manifest:e}}finally{await D(r,{recursive:!0,force:!0})}}l(Ut,"packPlugin");async function Bt(t){const n=d(t.root),a=t.log===null?()=>{}:t.log??(e=>console.log(e));return ot(n,await N(n),a)}l(Bt,"buildPluginTemplates");async function ot(t,n,a){const e=[];for(const i of n.agentTemplates??[]){const s=d(t,i.entry),r=v(s);if(!await L(o(r,V)))continue;const c=await z(r),{content:u}=JSON.parse(c);u?.usageGuide?.summary?.trim()||a(`\u26A0\uFE0F ${i.key}: missing content.usageGuide.summary (recommended for onboarding)`),await m(s,"utf8").catch(()=>null)!==c&&(await b(s,c,"utf8"),a(`\u203A rebuilt ${i.entry}`),e.push(i.entry))}return e}l(ot,"writeAgentTemplates");async function Jt(t){const n=d(t.root),a=R(await N(n)).backend;if(a?.runtime!=="python")throw new Error("Only a python backend part has a lock to compile.");return jt(n,a,t.python)}l(Jt,"lockPlugin");async function qt(t){const n=d(t.root),a=t.log===null?()=>{}:t.log??(w=>console.log(w)),e=await N(n),i=R(e).frontend;if(!i)throw new Error(`${e.id} declares no frontend part to watch.`);const s=d(n,t.frontend?.buildDir??`${i.dir}/dist`),r=d(n,t.frontend?.viteConfig??`${i.dir}/vite.config.ts`);await p(r,"frontend vite config");const c=t.port??Gt,u=Vt(s,c,()=>M(n,e,i.i18nDirPath)),{build:f}=await import("vite");return(await f({root:n,configFile:r,logLevel:"warn",...U,build:{...U.build,watch:{}}})).on("event",w=>{w.code==="END"&&(a(`\u21BB rebuilt \u2014 reloading ${u.clientCount()} page(s)`),u.notify())}),a([`Serving ${e.id} from http://localhost:${c}/${x(i.entryPath)}`,"","Point the shell at it and restart its dev server:",` VITE_TEGO_LOCAL_PLUGINS=${e.id}=http://localhost:${c}/${x(i.entryPath)}`,"","The release still has to be installed and enabled \u2014 this only replaces","where its bundle is fetched from. Ctrl-C to stop."].join(`
11
+ `)),new Promise(()=>{})}l(qt,"watchPluginFrontend");var Gt=5180,Kt="/__tego_plugin_reload",st="/i18n/";function Vt(t,n,a){const e=new Set;return bt((s,r)=>{r.setHeader("Access-Control-Allow-Origin","*"),r.setHeader("Access-Control-Allow-Headers","*");const c=new URL(s.url??"/","http://localhost").pathname;if(c===Kt){r.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}),r.write(`: connected
12
+
13
+ `),e.add(r),s.on("close",()=>e.delete(r));return}if(c.startsWith(st)){const f=c.slice(st.length);a().then(h=>{const w=h.get(f);if(w===void 0){r.writeHead(404).end();return}r.writeHead(200,{"Content-Type":ct(f),"Cache-Control":"no-store"}),r.end(w)},h=>{r.writeHead(500,{"Content-Type":"text/plain; charset=utf-8"}).end(h instanceof Error?h.message:String(h))});return}const u=d(t,`.${c}`);if(!u.startsWith(t)){r.writeHead(403).end();return}m(u).then(f=>{r.writeHead(200,{"Content-Type":ct(u),"Cache-Control":"no-store"}),r.end(f)},()=>r.writeHead(404).end())}).listen(n,"127.0.0.1"),{notify:l(()=>{for(const s of e)s.write(`data: rebuilt
14
+
15
+ `)},"notify"),clientCount:l(()=>e.size,"clientCount")}}l(Vt,"serveBuildDir");function ct(t){return t.endsWith(".js")?"text/javascript; charset=utf-8":t.endsWith(".json")?"application/json; charset=utf-8":t.endsWith(".css")?"text/css; charset=utf-8":"application/octet-stream"}l(ct,"contentTypeFor");async function N(t){const n=o(t,C);let a;try{a=await m(n,"utf8")}catch{throw new Error(`${C} not found at ${n}`)}const e=wt(JSON.parse(a));if(!e.ok||!e.manifest)throw new Error([`${C} is invalid:`,...e.errors].join(`
16
+ `));return e.manifest}l(N,"readManifest");async function Yt(t,n,a,e,i){const s=d(t,i?.viteConfig??`${e.dir}/vite.config.ts`);await p(s,"frontend vite config");const{build:r}=await import("vite");await r({root:t,configFile:s,logLevel:"warn"});const c=d(t,i?.buildDir??`${e.dir}/dist`);await p(o(c,x(e.entryPath)),`frontend bundle (expected the vite build to write ${x(e.entryPath)})`),await g(o(n,v(e.entryPath)),{recursive:!0}),await y(c,o(n,v(e.entryPath)),{recursive:!0});const u=await M(t,a,e.i18nDirPath);u.size>0&&await g(o(n,e.i18nDirPath),{recursive:!0});for(const[f,h]of u)await b(o(n,e.i18nDirPath,f),h,"utf8")}l(Yt,"stageFrontend");async function zt(t,n,a){const e=a.access?.catalog;if(!e)return;const i=d(t,e);await p(i,`access catalog ${e}`);const s=await m(i,"utf8"),r=ht(a,JSON.parse(s));if(!r.ok)throw new Error(["The access catalog is invalid:",...r.errors].join(`
17
+ `));await g(v(o(n,e)),{recursive:!0}),await b(o(n,e),s,"utf8")}l(zt,"stageAccessCatalog");async function Xt(t,n,a,e){const i=d(t,e?.viteConfig??`${a.dir}/vite.config.ts`);await p(i,"public pages vite config");const{build:s}=await import("vite");await s({root:d(t,a.dir),configFile:i,logLevel:"warn"});const r=d(t,e?.buildDir??`${a.dir}/dist`);await p(o(r,x(a.entryPath)),`public pages (expected the vite build to write ${x(a.entryPath)})`),await g(o(n,a.dir),{recursive:!0}),await y(r,o(n,a.dir),{recursive:!0})}l(Xt,"stagePublicFrontend");async function Zt(t,n,a,e){await lt(a,{root:t,outDir:n,...e?.entry?{entry:e.entry}:{},...e?.external?{external:e.external}:{}})}l(Zt,"stageBackend");async function lt(t,n){const{root:a,outDir:e}=n,i=d(a,n.entry??`${t.dir}/src/index.ts`);await p(i,"backend entry");const{build:s}=await import("esbuild");await s({entryPoints:[i],outfile:o(e,t.entryPath),bundle:!0,platform:"node",target:"node22",format:"esm",banner:{js:"import { createRequire as __tegoCreateRequire } from 'node:module'; const require = __tegoCreateRequire(import.meta.url);"},external:[...Ht,...n.external??[]],logLevel:"warning"});for(const c of t.compatibilityRepairs??[]){const u=`${t.dir}/${c.sqlFile}`;await p(d(a,u),"schema repair"),await g(v(o(e,u)),{recursive:!0}),await y(d(a,u),o(e,u))}const r=d(a,t.migrationsDirPath);await L(r)&&await y(r,o(e,t.migrationsDirPath),{recursive:!0}),await b(o(e,t.dir,"package.json"),`${JSON.stringify({type:"module"},null,2)}
18
+ `,"utf8")}l(lt,"buildPluginBackend");async function Qt(t,n,a,e,i){const s=d(t,i?.entry??`${a.dir}/src/index.ts`);await p(s,"claw entry");const{build:r}=await import("esbuild");await r({entryPoints:[s],outfile:o(n,a.dir,"index.js"),bundle:!0,platform:"node",target:"node22",format:"esm",external:[...Wt,...i?.external??[]],logLevel:"warning"});const c=d(t,a.manifestPath);await p(c,$t);const u=JSON.parse(await m(c,"utf8"));await b(o(n,a.manifestPath),`${JSON.stringify({...u,version:e.version},null,2)}
19
+ `,"utf8");const f=d(t,a.dir,"package.json"),h=await L(f)?JSON.parse(await m(f,"utf8")):{name:e.id,private:!0,type:"module"};await b(o(n,a.dir,"package.json"),`${JSON.stringify({...h,version:e.version,openclaw:{extensions:["./index.js"]}},null,2)}
20
+ `,"utf8");const w=d(t,i?.skillsDir??`${a.dir}/skills`);await L(w)&&await y(w,o(n,a.dir,"skills"),{recursive:!0})}l(Qt,"stageClaw");async function te(t,n){const a=new Et;await ut(a,t,"");const e=await a.generateAsync({type:"nodebuffer",compression:"DEFLATE",compressionOptions:{level:9}});return await b(n,e),e.byteLength}l(te,"zipDirectory");async function ut(t,n,a){const e=await k(n,{withFileTypes:!0});e.sort((i,s)=>i.name.localeCompare(s.name));for(const i of e){const s=`${a}${i.name}`;i.isDirectory()?(t.file(`${s}/`,null,{dir:!0,date:rt}),await ut(t,o(n,i.name),`${s}/`)):t.file(s,await m(o(n,i.name)),{date:rt,createFolders:!1})}}l(ut,"addDirectory");async function L(t){try{return await G(t),!0}catch{return!1}}l(L,"exists2");async function p(t,n){if(!await L(t))throw new Error(`${n} not found at ${t}`)}l(p,"assertExists");function ee(t){return t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(2)} MB`}l(ee,"formatBytes");export{z as buildAgentTemplate,lt as buildPluginBackend,Bt as buildPluginTemplates,Jt as lockPlugin,Ut as packPlugin,N as readManifest,M as readPluginLocales,qt as watchPluginFrontend};
@@ -0,0 +1,5 @@
1
+ "use strict";var c=Object.defineProperty;var s=(e,t)=>c(e,"name",{value:t,configurable:!0});var chunk6HNG5OZI_cjs=require("./chunk-6HNG5OZI.cjs"),MagicString=require("magic-string"),module$1=require("module"),path=require("path");function _interopDefault(e){return e&&e.__esModule?e:{default:e}}s(_interopDefault,"_interopDefault");var MagicString__default=_interopDefault(MagicString);function scopeRootForm(e,t){if(!e.startsWith(`${t} `))return null;const n=e.slice(t.length+1),r=n.search(/(?<!\\)::/);return r<0?n+t:n.slice(0,r)+t+n.slice(r)}s(scopeRootForm,"scopeRootForm");function tegoPluginScopeRoot(e){const t=`.${e}`;return{postcssPlugin:"tego-plugin-scope-root",OnceExit(n){n.walkRules(r=>{const o=r.selectors.map(i=>scopeRootForm(i,t)).filter(i=>i!==null);o.length>0&&(r.selectors=[...r.selectors,...o])})}}}s(tegoPluginScopeRoot,"tegoPluginScopeRoot");var UI_PACKAGE="@tego/ui",UI_PRESET="@tego/ui/tailwind-preset",OPTIONAL_COMPONENT_PACKAGES=["@tego/plugin-access-ui"],COMPILED_CODE_GLOB="**/*.{js,cjs}";function tegoPluginTailwind({pluginId:e,root:t,content:n}){const r=module$1.createRequire(path.join(t,"vite.config.ts")),o=s(u=>path.join(path.dirname(r.resolve(u)),COMPILED_CODE_GLOB),"compiledCodeOf");let i;try{i=r(UI_PRESET)}catch(u){throw new Error(`tegoPluginTailwind: cannot resolve ${UI_PRESET} from ${t}; install ${UI_PACKAGE} in the plugin`,{cause:u})}const a=OPTIONAL_COMPONENT_PACKAGES.flatMap(u=>{try{return[o(u)]}catch{return[]}});return{presets:[i],content:[...n,o(UI_PACKAGE),...a],corePlugins:{preflight:!1},important:`.${e}`}}s(tegoPluginTailwind,"tegoPluginTailwind");var SHARED_MODULE_URL_PREFIX="tego-shared:",BROWSER_TARGET=["chrome87","firefox78","safari14","edge88"],TEGO_PLUGIN_DEV_OVERRIDES={mode:"development",build:{minify:!1,sourcemap:"inline"}};function inlineCss(e){return{name:"tego-plugin-inline-css",enforce:"post",generateBundle(t,n){const r=Object.entries(n).filter(([i,a])=>a.type==="asset"&&i.endsWith(".css")).map(([i,a])=>(delete n[i],String(a.source))).join(`
2
+ `);if(!r)return;const o=Object.values(n).find(i=>i.type==="chunk"&&i.isEntry);o?.type==="chunk"&&(o.code=`(function(){try{var s=document.createElement('style');s.setAttribute('data-tego-plugin',${JSON.stringify(e)});s.textContent=${JSON.stringify(r)};document.head.appendChild(s)}catch(e){}})();
3
+ ${o.code}`)}}}s(inlineCss,"inlineCss");function isolateChunkScope(){return{name:"tego-plugin-isolate-chunk-scope",renderChunk:{order:"post",handler(e){const t=new MagicString__default.default(e);return t.prepend(`(function(){
4
+ `),t.append(`
5
+ })();`),{code:t.toString(),map:t.generateMap({hires:!0})}}}}}s(isolateChunkScope,"isolateChunkScope");function tegoPluginFrontend(e){const t=Object.fromEntries(chunk6HNG5OZI_cjs.SHARED_MODULE_IDS.map(r=>[r,`${SHARED_MODULE_URL_PREFIX}${r}`])),n=e.development??!1;return{plugins:[inlineCss(e.pluginId??""),isolateChunkScope()],mode:n?TEGO_PLUGIN_DEV_OVERRIDES.mode:"production",esbuild:{jsx:"automatic",jsxDev:!1},build:{outDir:e.outDir??"dist",emptyOutDir:!0,target:BROWSER_TARGET,sourcemap:n?TEGO_PLUGIN_DEV_OVERRIDES.build.sourcemap:!1,minify:n?TEGO_PLUGIN_DEV_OVERRIDES.build.minify:!0,cssCodeSplit:!1,rollupOptions:{input:e.entry,external:[...chunk6HNG5OZI_cjs.SHARED_MODULE_IDS],output:{format:"system",paths:t,entryFileNames:"index.js",chunkFileNames:"[name]-[hash].js",assetFileNames:"[name]-[hash][extname]"},preserveEntrySignatures:"exports-only"}}}}s(tegoPluginFrontend,"tegoPluginFrontend"),exports.TEGO_PLUGIN_DEV_OVERRIDES=TEGO_PLUGIN_DEV_OVERRIDES,exports.scopeRootForm=scopeRootForm,exports.tegoPluginFrontend=tegoPluginFrontend,exports.tegoPluginScopeRoot=tegoPluginScopeRoot,exports.tegoPluginTailwind=tegoPluginTailwind;
@@ -0,0 +1,5 @@
1
+ var g=Object.defineProperty;var s=(t,e)=>g(t,"name",{value:e,configurable:!0});import{SHARED_MODULE_IDS as l}from"./chunk-56QOZQTY.js";import h from"magic-string";import{createRequire as E}from"module";import{join as p,dirname as O}from"path";function m(t,e){if(!t.startsWith(`${e} `))return null;const n=t.slice(e.length+1),r=n.search(/(?<!\\)::/);return r<0?n+e:n.slice(0,r)+e+n.slice(r)}s(m,"scopeRootForm");function y(t){const e=`.${t}`;return{postcssPlugin:"tego-plugin-scope-root",OnceExit(n){n.walkRules(r=>{const o=r.selectors.map(i=>m(i,e)).filter(i=>i!==null);o.length>0&&(r.selectors=[...r.selectors,...o])})}}}s(y,"tegoPluginScopeRoot");var d="@tego/ui",f="@tego/ui/tailwind-preset",v=["@tego/plugin-access-ui"],S="**/*.{js,cjs}";function _({pluginId:t,root:e,content:n}){const r=E(p(e,"vite.config.ts")),o=s(u=>p(O(r.resolve(u)),S),"compiledCodeOf");let i;try{i=r(f)}catch(u){throw new Error(`tegoPluginTailwind: cannot resolve ${f} from ${e}; install ${d} in the plugin`,{cause:u})}const a=v.flatMap(u=>{try{return[o(u)]}catch{return[]}});return{presets:[i],content:[...n,o(d),...a],corePlugins:{preflight:!1},important:`.${t}`}}s(_,"tegoPluginTailwind");var P="tego-shared:",R=["chrome87","firefox78","safari14","edge88"],c={mode:"development",build:{minify:!1,sourcemap:"inline"}};function D(t){return{name:"tego-plugin-inline-css",enforce:"post",generateBundle(e,n){const r=Object.entries(n).filter(([i,a])=>a.type==="asset"&&i.endsWith(".css")).map(([i,a])=>(delete n[i],String(a.source))).join(`
2
+ `);if(!r)return;const o=Object.values(n).find(i=>i.type==="chunk"&&i.isEntry);o?.type==="chunk"&&(o.code=`(function(){try{var s=document.createElement('style');s.setAttribute('data-tego-plugin',${JSON.stringify(t)});s.textContent=${JSON.stringify(r)};document.head.appendChild(s)}catch(e){}})();
3
+ ${o.code}`)}}}s(D,"inlineCss");function C(){return{name:"tego-plugin-isolate-chunk-scope",renderChunk:{order:"post",handler(t){const e=new h(t);return e.prepend(`(function(){
4
+ `),e.append(`
5
+ })();`),{code:e.toString(),map:e.generateMap({hires:!0})}}}}}s(C,"isolateChunkScope");function j(t){const e=Object.fromEntries(l.map(r=>[r,`${P}${r}`])),n=t.development??!1;return{plugins:[D(t.pluginId??""),C()],mode:n?c.mode:"production",esbuild:{jsx:"automatic",jsxDev:!1},build:{outDir:t.outDir??"dist",emptyOutDir:!0,target:R,sourcemap:n?c.build.sourcemap:!1,minify:n?c.build.minify:!0,cssCodeSplit:!1,rollupOptions:{input:t.entry,external:[...l],output:{format:"system",paths:e,entryFileNames:"index.js",chunkFileNames:"[name]-[hash].js",assetFileNames:"[name]-[hash][extname]"},preserveEntrySignatures:"exports-only"}}}}s(j,"tegoPluginFrontend");export{c as TEGO_PLUGIN_DEV_OVERRIDES,m as scopeRootForm,j as tegoPluginFrontend,y as tegoPluginScopeRoot,_ as tegoPluginTailwind};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var u=(n,i)=>p(n,"name",{value:i,configurable:!0});var f="/p",$="plugin-api",c=["zh-CN","zh-TW","en","ja","ko","de","es","fr","it","pt"];function t(n){return`plugin.${n}`}u(t,"pluginI18nNamespace");function s(n,i){return`${t(n)}:${i}`}u(s,"pluginI18nKey");function e(n,i){return`plugin-${n}-${i}`}u(e,"pluginMenuKey");var g=100;function o(n){return`${f}/${n}`}u(o,"pluginBasePath");function N(n,i){const r=o(n);return!i||i==="/"?r:`${r}${i}`}u(N,"pluginNavPath");function P(n,i="/"){const r=i.startsWith("/")?i:`/${i}`;return`${$}/${n}${r==="/"?"":r}`}u(P,"pluginApiPath");function _(n,i="zh-CN"){return typeof n=="string"?n:n[i]??n.en??Object.values(n)[0]??""}u(_,"localizedTextToString");function a(n,i){return`menu.${e(n,i)}`}u(a,"pluginMenuPermission");export{g as MAX_PLUGIN_MENU_PERMISSION_LENGTH,c as PLUGIN_SUPPORTED_LOCALES,_ as localizedTextToString,P as pluginApiPath,o as pluginBasePath,s as pluginI18nKey,t as pluginI18nNamespace,e as pluginMenuKey,a as pluginMenuPermission,N as pluginNavPath};
@@ -0,0 +1 @@
1
+ var k=Object.defineProperty;var s=(t,e)=>k(t,"name",{value:e,configurable:!0});var L=["bar-chart","bell","bookmark","book-open","bot","briefcase","building","calendar","chart-pie","clipboard-list","clock","contact","credit-card","database","file-text","folder","globe","handshake","inbox","key","layers","layout-dashboard","library","link","list-todo","mail","map-pin","message-square","mic","package","phone","puzzle","receipt","search","settings","shield","shopping-cart","sliders","sparkles","star","table","tag","target","trending-up","truck","users","wallet","workflow","wrench","zap"],N="puzzle",y=["node","python"],g=["linux/amd64","linux/arm64"],T="tego.plugin.json",_="openclaw.plugin.json",c={frontend:{dir:"frontend",entry:"index.js",i18nDir:"i18n"},backend:{dir:"backend",runtime:"node",entry:{node:"index.js",python:"app.py"},migrationsDir:"migrations",healthPath:"/healthz"},claw:{dir:"claw"},publicFrontend:{dir:"public-frontend",entry:"index.html"}};function U(t){return t.scope??(t.parts.claw?"avatar":"tenant")}s(U,"resolvePluginScope");function E(t){const e=t.declares??{};return{database:e.database??t.parts.backend!==void 0,storage:e.storage??!1,events:e.events??!1,notifications:e.notifications??!1}}s(E,"resolvePluginDeclares");var m=["frontend","backend","claw","publicFrontend"];function R(t){return m.filter(e=>t.parts[e]!==void 0)}s(R,"declaredPartNames");function w(t){const e={},r=t.parts.frontend;if(r){const i=r.dir??c.frontend.dir;e.frontend={dir:i,entryPath:`${i}/${r.entry??c.frontend.entry}`,i18nDirPath:`${i}/${r.i18nDir??c.frontend.i18nDir}`,nav:r.nav??[],...r.config?{config:r.config}:{}}}const n=t.parts.backend;if(n){const i=n.dir??c.backend.dir,l=n.runtime??c.backend.runtime;e.backend={dir:i,runtime:l,entryPath:`${i}/${n.entry??c.backend.entry[l]}`,platforms:l==="python"?[...n.platforms??g]:[],egress:[...new Set(n.egress??[])].sort(),migrationsDirPath:`${i}/${n.migrationsDir??c.backend.migrationsDir}`,...n.compatibilityRepairs?{compatibilityRepairs:n.compatibilityRepairs}:{},healthPath:n.healthPath??c.backend.healthPath,limits:n.limits??{},publicRoutes:n.publicRoutes??[],...n.config?{config:n.config}:{}}}const a=t.parts.claw;if(a){const i=a.dir??c.claw.dir;e.claw={dir:i,manifestPath:`${i}/${_}`,...a.hooks?{hooks:a.hooks}:{}}}const o=t.parts.publicFrontend;if(o){const i=o.dir??c.publicFrontend.dir;e.publicFrontend={dir:i,entryPath:`${i}/${c.publicFrontend.entry}`}}return e}s(w,"resolvePluginParts");var F=["GET","POST","PUT","PATCH","DELETE"],A="/public/plugins/api",P="/public/plugins/pages",v="/public/plugins/avatars/api",h="/public/plugins/avatars/pages",G=/^(?:\/(?:[A-Za-z0-9._~-]+|:[A-Za-z_][A-Za-z0-9_]*))+$/;function d(t){return t.split("/").slice(1)}s(d,"segments");function p(t){return t.startsWith(":")}s(p,"isParam");function I(t){return`${t.method} ${t.path}`}s(I,"formatPublicRoute");function C(t){if(!G.test(t))return'must be "/"-separated literal segments or ":name" parameters, e.g. "/public/inspections/:token"';const e=d(t);if(e.some(n=>/^\.+$/.test(n)))return'must not contain "." or ".." segments';const r=e.filter(p);return new Set(r).size!==r.length?"must not repeat a parameter name":null}s(C,"publicRoutePathProblem");function D(t,e){if(t.method!==e.method)return!1;const r=d(t.path),n=d(e.path);return r.length!==n.length?!1:r.every((a,o)=>{const i=n[o];return p(a)||p(i)||a===i})}s(D,"publicRoutesOverlap");function S(t,e,r){const n=e.toUpperCase(),a=d(r.startsWith("/")?r:`/${r}`);if(a.some(o=>o===""))return null;for(const o of t){if(o.method!==n)continue;const i=d(o.path);if(i.length!==a.length)continue;const l={};if(i.every((u,$)=>{const b=a[$];return p(u)?(l[u.slice(1)]=b,!0):u===b}))return{route:I(o),params:l}}return null}s(S,"matchPublicRoute");function x(t){const e=t.indexOf(`${h}/`);if(e!==-1){const i=t.slice(e+h.length+1),[l,f,u]=i.split("/");return!l||!f||!u?null:`${t.slice(0,e)}${v}/${l}/${f}/${u}`}const r=t.indexOf(`${P}/`);if(r===-1)return null;const n=t.slice(r+P.length+1),[a,o]=n.split("/");return!a||!o?null:`${t.slice(0,r)}${A}/${a}/${o}`}s(x,"publicApiBaseFromPagePath");export{_ as CLAW_MANIFEST_FILENAME,v as PLUGIN_AVATAR_PUBLIC_API_PATH,h as PLUGIN_AVATAR_PUBLIC_PAGES_PATH,g as PLUGIN_BACKEND_PLATFORMS,y as PLUGIN_BACKEND_RUNTIMES,T as PLUGIN_MANIFEST_FILENAME,L as PLUGIN_NAV_ICONS,N as PLUGIN_NAV_ICON_FALLBACK,c as PLUGIN_PART_DEFAULTS,m as PLUGIN_PART_NAMES,A as PLUGIN_PUBLIC_API_PATH,P as PLUGIN_PUBLIC_PAGES_PATH,F as PLUGIN_PUBLIC_ROUTE_METHODS,R as declaredPartNames,I as formatPublicRoute,S as matchPublicRoute,x as publicApiBaseFromPagePath,C as publicRoutePathProblem,D as publicRoutesOverlap,E as resolvePluginDeclares,w as resolvePluginParts,U as resolvePluginScope};
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var o=(n,t)=>a(n,"name",{value:t,configurable:!0});var chunkN4SXZZPY_cjs=require("./chunk-N4SXZZPY.cjs"),PLUGIN_CONFIG_SECTIONS=["frontend","backend","claw"],PLUGIN_CONFIG_SECRET_SENTINEL="__OPENCLAW_REDACTED__",EMPTY_CONFIG_SECTION_SUMMARY={fieldCount:0,required:[],sensitive:[]};function summarizeConfigDeclaration(n){if(!n)return EMPTY_CONFIG_SECTION_SUMMARY;const t=Object.keys(n.schema.properties),r=n.uiHints??{};return{fieldCount:t.length,required:(n.schema.required??[]).filter(e=>t.includes(e)),sensitive:t.filter(e=>r[e]?.sensitive===!0)}}o(summarizeConfigDeclaration,"summarizeConfigDeclaration");function summarizeClawConfig(n){if(!n)return EMPTY_CONFIG_SECTION_SUMMARY;const t=n.configSchema;if(typeof t!="object"||t===null)return EMPTY_CONFIG_SECTION_SUMMARY;const r=t.properties,e=typeof r=="object"&&r!==null?Object.keys(r):[],i=t.required,s=Array.isArray(i)?i.filter(u=>typeof u=="string"&&e.includes(u)):[],c=n.uiHints,f=typeof c=="object"&&c!==null?c:{},l=e.filter(u=>f[u]?.sensitive===!0);return{fieldCount:e.length,required:s,sensitive:l}}o(summarizeClawConfig,"summarizeClawConfig");function redactSecrets(n,t){const r={...n};for(const e of t)r[e]===void 0||r[e]===null||(r[e]=PLUGIN_CONFIG_SECRET_SENTINEL);return r}o(redactSecrets,"redactSecrets");function restoreSecrets(n,t,r){const e={...n};for(const i of r){if(e[i]!==PLUGIN_CONFIG_SECRET_SENTINEL)continue;const s=t[i];if(s===void 0){delete e[i];continue}e[i]=s}return e}o(restoreSecrets,"restoreSecrets");function applyConfigDefaults(n,t){const r={...t};for(const[e,i]of Object.entries(n.properties??{}))r[e]===void 0&&i.default!==void 0&&(r[e]=i.default);return r}o(applyConfigDefaults,"applyConfigDefaults");function configFieldLabel(n,t,r,e){return t?.label?chunkN4SXZZPY_cjs.localizedTextToString(t.label,e):r?.title?r.title:n}o(configFieldLabel,"configFieldLabel"),exports.EMPTY_CONFIG_SECTION_SUMMARY=EMPTY_CONFIG_SECTION_SUMMARY,exports.PLUGIN_CONFIG_SECRET_SENTINEL=PLUGIN_CONFIG_SECRET_SENTINEL,exports.PLUGIN_CONFIG_SECTIONS=PLUGIN_CONFIG_SECTIONS,exports.applyConfigDefaults=applyConfigDefaults,exports.configFieldLabel=configFieldLabel,exports.redactSecrets=redactSecrets,exports.restoreSecrets=restoreSecrets,exports.summarizeClawConfig=summarizeClawConfig,exports.summarizeConfigDeclaration=summarizeConfigDeclaration;
@@ -0,0 +1 @@
1
+ "use strict";var r=Object.defineProperty;var t=(n,e)=>r(n,"name",{value:e,configurable:!0});var PLUGIN_ROUTE_ROOT="/p",PLUGIN_API_ROOT="plugin-api",PLUGIN_SUPPORTED_LOCALES=["zh-CN","zh-TW","en","ja","ko","de","es","fr","it","pt"];function pluginI18nNamespace(n){return`plugin.${n}`}t(pluginI18nNamespace,"pluginI18nNamespace");function pluginI18nKey(n,e){return`${pluginI18nNamespace(n)}:${e}`}t(pluginI18nKey,"pluginI18nKey");function pluginMenuKey(n,e){return`plugin-${n}-${e}`}t(pluginMenuKey,"pluginMenuKey");var MAX_PLUGIN_MENU_PERMISSION_LENGTH=100;function pluginBasePath(n){return`${PLUGIN_ROUTE_ROOT}/${n}`}t(pluginBasePath,"pluginBasePath");function pluginNavPath(n,e){const i=pluginBasePath(n);return!e||e==="/"?i:`${i}${e}`}t(pluginNavPath,"pluginNavPath");function pluginApiPath(n,e="/"){const i=e.startsWith("/")?e:`/${e}`;return`${PLUGIN_API_ROOT}/${n}${i==="/"?"":i}`}t(pluginApiPath,"pluginApiPath");function localizedTextToString(n,e="zh-CN"){return typeof n=="string"?n:n[e]??n.en??Object.values(n)[0]??""}t(localizedTextToString,"localizedTextToString");function pluginMenuPermission(n,e){return`menu.${pluginMenuKey(n,e)}`}t(pluginMenuPermission,"pluginMenuPermission"),exports.MAX_PLUGIN_MENU_PERMISSION_LENGTH=MAX_PLUGIN_MENU_PERMISSION_LENGTH,exports.PLUGIN_SUPPORTED_LOCALES=PLUGIN_SUPPORTED_LOCALES,exports.localizedTextToString=localizedTextToString,exports.pluginApiPath=pluginApiPath,exports.pluginBasePath=pluginBasePath,exports.pluginI18nKey=pluginI18nKey,exports.pluginI18nNamespace=pluginI18nNamespace,exports.pluginMenuKey=pluginMenuKey,exports.pluginMenuPermission=pluginMenuPermission,exports.pluginNavPath=pluginNavPath;
@@ -0,0 +1 @@
1
+ "use strict";var p=Object.defineProperty;var l=(e,o)=>p(e,"name",{value:o,configurable:!0});var chunk2P6UEAPV_cjs=require("./chunk-2P6UEAPV.cjs"),chunkN4SXZZPY_cjs=require("./chunk-N4SXZZPY.cjs"),chunk6HNG5OZI_cjs=require("./chunk-6HNG5OZI.cjs"),chunkAJY7ZHXK_cjs=require("./chunk-AJY7ZHXK.cjs"),net=require("net"),zod=require("zod");function checkPluginAccessCatalog(e,o){const t=`access.catalog (${e.access?.catalog??"?"})`,s=chunkAJY7ZHXK_cjs.validateAccessCatalog(o);if(!s.ok)return{ok:!1,errors:s.issues.map(n=>`${t}: ${n.path}: ${n.message}`)};const a=new Set((e.parts.frontend?.nav??[]).map(n=>n.key)),i=Object.keys(s.catalog.menus).filter(n=>!a.has(n)).map(n=>`${t}: menus.${n}: no parts.frontend.nav entry has this key`);return i.length>0?{ok:!1,errors:i}:{ok:!0,catalog:s.catalog}}l(checkPluginAccessCatalog,"checkPluginAccessCatalog");var PYTHON_RUNNER_VERSION={major:3,minor:12},RUNNER_GLIBC_MINOR=36,PYTHON_LOCK_FILENAME="requirements.lock",PYTHON_WHEELS_DIR="wheels";function normalizePackageName(e){return e.toLowerCase().replace(/[-_.]+/g,"-")}l(normalizePackageName,"normalizePackageName");function parseRequirementsLock(e){const o=[],t=[],s=e.replace(/\\\r?\n/g," ").split(/\r?\n/).map(a=>a.replace(/(^|\s)#.*$/,"").trim()).filter(Boolean);for(const a of s){const[i="",...n]=a.split(/\s+/),r=/^([A-Za-z0-9][A-Za-z0-9._-]*)(?:\[[^\]]*\])?==([^\s;]+)$/.exec(i);if(!r||a.includes(";")){t.push(`${PYTHON_LOCK_FILENAME}: "${a.slice(0,80)}" is not a pinned "name==version" requirement without markers`);continue}const c=[];for(const d of n){const u=/^--hash=sha256:([0-9a-f]{64})$/.exec(d);u?.[1]?c.push(u[1]):t.push(`${PYTHON_LOCK_FILENAME}: unsupported option "${d.slice(0,40)}" on ${r[1]}`)}c.length===0&&t.push(`${PYTHON_LOCK_FILENAME}: ${r[1]}==${r[2]} has no --hash; compile with --generate-hashes`),o.push({name:normalizePackageName(r[1]),version:r[2].toLowerCase(),hashes:c})}return{requirements:o,errors:t}}l(parseRequirementsLock,"parseRequirementsLock");function parseWheelFilename(e){if(!e.endsWith(".whl"))return null;const o=e.slice(0,-4).split("-");if(o.length!==5&&o.length!==6)return null;const[t,s]=o,[a,i,n]=o.slice(-3);return!t||!s||!a||!i||!n?null:{name:normalizePackageName(t),version:s.toLowerCase(),pythonTags:a.split("."),abiTags:i.split("."),platformTags:n.split(".")}}l(parseWheelFilename,"parseWheelFilename");function supportsInterpreter(e){const{major:o,minor:t}=PYTHON_RUNNER_VERSION,s=`${o}${t}`;return e.pythonTags.some(a=>{if(a===`py${o}`||a===`py${s}`||a===`cp${s}`)return!0;const i=/^cp3(\d+)$/.exec(a);return i?.[1]!==void 0&&Number(i[1])<=t&&e.abiTags.includes("abi3")})}l(supportsInterpreter,"supportsInterpreter");function supportsPlatform(e,o){const t=o==="linux/amd64"?"x86_64":"aarch64";return e.platformTags.some(s=>{if(s==="any"||s===`manylinux2014_${t}`||t==="x86_64"&&/^manylinux(1|2010)_x86_64$/.test(s))return!0;const a=/^manylinux_2_(\d+)_(x86_64|aarch64)$/.exec(s);return a?.[2]===t&&Number(a[1])<=RUNNER_GLIBC_MINOR})}l(supportsPlatform,"supportsPlatform");function checkPythonVendoring(e){if(e.lockText===null)return[`Python backend ships no ${PYTHON_LOCK_FILENAME}. The runner installs offline from it with --require-hashes.`];const{requirements:o,errors:t}=parseRequirementsLock(e.lockText),s=e.wheels.map(a=>({...a,parsed:parseWheelFilename(a.filename)}));for(const a of s){if(!a.parsed){t.push(`"${a.filename}" is not a valid wheel filename`);continue}const i=o.find(n=>n.name===a.parsed.name&&n.version===a.parsed.version);i?i.hashes.includes(a.sha256)||t.push(`"${a.filename}" does not match any --hash locked for ${i.name}==${i.version}`):t.push(`"${a.filename}" is not in ${PYTHON_LOCK_FILENAME}; ship only locked wheels`)}for(const a of o){const i=s.filter(n=>n.parsed?.name===a.name&&n.parsed.version===a.version&&supportsInterpreter(n.parsed));for(const n of e.platforms)i.some(r=>supportsPlatform(r.parsed,n))||t.push(`No wheel for ${a.name}==${a.version} on ${n} (python ${PYTHON_RUNNER_VERSION.major}.${PYTHON_RUNNER_VERSION.minor})`)}return t}l(checkPythonVendoring,"checkPythonVendoring");var PLUGIN_ID_PATTERN=/^[a-z0-9][a-z0-9._-]*$/,DIRECTORY_READ="directory.read",ACCESS_HOST_API_VERSION="1.22.0",MAX_PLUGIN_ID_LENGTH=128,RELATIVE_PATH_PATTERN=/^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/,relativePathSchema=zod.z.string().min(1).max(256).regex(RELATIVE_PATH_PATTERN,"must be a relative path inside the package").refine(e=>!e.split("/").some(o=>o===".."||o==="."),{message:'must not contain "." or ".." segments'}),localizedTextSchema=zod.z.union([zod.z.string().min(1),zod.z.record(zod.z.string().min(1),zod.z.string().min(1))]),semanticVersionSchema=zod.z.string().refine(e=>{try{return chunk6HNG5OZI_cjs.parseSemanticVersion(e),!0}catch{return!1}},{message:"must be a valid semantic version"}),navKeySchema=zod.z.string().min(1).max(64).regex(/^[a-z0-9][a-z0-9-]*$/,"must be lowercase alphanumeric with hyphens"),navEntrySchema=zod.z.object({key:navKeySchema,labelKey:zod.z.string().min(1).max(200),icon:zod.z.enum(chunk2P6UEAPV_cjs.PLUGIN_NAV_ICONS).optional(),order:zod.z.number().int().min(0).max(1e4).optional(),path:zod.z.string().regex(/^\/[A-Za-z0-9/_-]*$/,'must start with "/"').max(256).optional()}).strict(),configPropertyNameSchema=zod.z.string().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_]*$/,"must be a plain identifier: a letter followed by letters, digits or underscores"),configFieldSchema=zod.z.object({type:zod.z.enum(["string","number","integer","boolean","array"]),title:zod.z.string().min(1).max(200).optional(),description:zod.z.string().min(1).max(1e3).optional(),default:zod.z.unknown().optional(),enum:zod.z.array(zod.z.union([zod.z.string().max(200),zod.z.number()])).min(1).max(50).optional(),minLength:zod.z.number().int().min(0).max(1e4).optional(),maxLength:zod.z.number().int().min(1).max(1e4).optional(),pattern:zod.z.string().min(1).max(500).optional(),format:zod.z.enum(["uri","email"]).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),items:zod.z.object({type:zod.z.literal("string"),enum:zod.z.array(zod.z.string().max(200)).min(1).max(50).optional()}).strict().optional(),maxItems:zod.z.number().int().min(1).max(200).optional()}).strict().superRefine((e,o)=>{e.type==="array"&&e.items===void 0&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["items"],message:'an array field must declare { "type": "string" } items'}),e.type!=="array"&&e.items!==void 0&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["items"],message:"only an array field may declare items"}),e.enum&&e.default!==void 0&&(e.enum.some(s=>Object.is(s,e.default))||o.addIssue({code:zod.z.ZodIssueCode.custom,path:["default"],message:"must be one of the declared enum values"}))}),localizedHintTextSchema=zod.z.union([zod.z.string().min(1).max(500),zod.z.record(zod.z.string().min(1),zod.z.string().min(1).max(500))]),configUiHintSchema=zod.z.object({label:localizedHintTextSchema.optional(),help:localizedHintTextSchema.optional(),placeholder:localizedHintTextSchema.optional(),order:zod.z.number().int().min(0).max(1e4).optional(),advanced:zod.z.boolean().optional(),sensitive:zod.z.boolean().optional()}).strict(),configDeclarationSchema=zod.z.object({schema:zod.z.object({type:zod.z.literal("object"),properties:zod.z.record(configPropertyNameSchema,configFieldSchema),required:zod.z.array(configPropertyNameSchema).max(50).optional(),additionalProperties:zod.z.literal(!1).optional()}).strict(),uiHints:zod.z.record(configPropertyNameSchema,configUiHintSchema).optional()}).strict().superRefine((e,o)=>{const t=Object.keys(e.schema.properties);t.length>50&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["schema","properties"],message:"a config section is limited to 50 fields"});for(const s of e.schema.required??[])t.includes(s)||o.addIssue({code:zod.z.ZodIssueCode.custom,path:["schema","required"],message:`"${s}" is required but not declared in properties`});for(const s of Object.keys(e.uiHints??{}))t.includes(s)||o.addIssue({code:zod.z.ZodIssueCode.custom,path:["uiHints",s],message:"no such field in the section schema"})}),frontendPartSchema=zod.z.object({dir:relativePathSchema.optional(),entry:relativePathSchema.optional(),i18nDir:relativePathSchema.optional(),icon:zod.z.enum(chunk2P6UEAPV_cjs.PLUGIN_NAV_ICONS).optional(),nav:zod.z.array(navEntrySchema).max(20).optional(),config:configDeclarationSchema.optional()}).strict().superRefine((e,o)=>{for(const[t,s]of Object.entries(e.config?.uiHints??{}))s.sensitive===!0&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["config","uiHints",t,"sensitive"],message:"the frontend config section is delivered to the browser, so it cannot hold secrets \u2014 declare this field in the backend section instead"})}).refine(e=>{const o=(e.nav??[]).map(t=>t.key);return new Set(o).size===o.length},{message:"nav entries must have unique keys",path:["nav"]}),backendLimitsSchema=zod.z.object({memoryMb:zod.z.number().int().min(64).max(4096).optional(),cpuMs:zod.z.number().int().min(100).max(6e5).optional(),requestTimeoutMs:zod.z.number().int().min(100).max(12e4).optional()}).strict(),EGRESS_HOST_PATTERN=/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z0-9-]{0,61}[a-z0-9]$/,egressHostSchema=zod.z.string().max(259).refine(e=>{if(e==="*")return!0;const o=/^\[([0-9a-f:]+)\]:([1-9]\d{0,4})$/.exec(e);if(o)return net.isIP(o[1])===6&&Number(o[2])<=65535;const t=/^([^:]+)(?::([1-9]\d{0,4}))?$/.exec(e);if(!t)return!1;const[,s,a]=t;return a&&Number(a)>65535?!1:a&&net.isIP(s)===4||EGRESS_HOST_PATTERN.test(s)},"must be *, a lowercase hostname, hostname:port, or IP:port"),publicRouteSchema=zod.z.object({method:zod.z.enum(chunk2P6UEAPV_cjs.PLUGIN_PUBLIC_ROUTE_METHODS),path:zod.z.string().max(256).superRefine((e,o)=>{const t=chunk2P6UEAPV_cjs.publicRoutePathProblem(e);t&&o.addIssue({code:zod.z.ZodIssueCode.custom,message:t})})}).strict(),backendPartSchema=zod.z.object({dir:relativePathSchema.optional(),runtime:zod.z.enum(["node","python"]).optional(),entry:relativePathSchema.optional(),platforms:zod.z.array(zod.z.enum(["linux/amd64","linux/arm64"])).min(1).optional(),egress:zod.z.array(egressHostSchema).max(20).refine(e=>!e.includes("*")||e.length===1,{message:"the * wildcard must be the only egress entry"}).optional(),migrationsDir:relativePathSchema.optional(),compatibilityRepairs:zod.z.array(zod.z.object({id:zod.z.string().regex(/^[a-z][a-z0-9_-]{0,99}$/),sqlFile:relativePathSchema.refine(e=>e.startsWith("repairs/")&&e.endsWith(".sql"),"Use a SQL file under repairs/"),table:zod.z.string().regex(/^[a-z][a-z0-9_]{0,62}$/),column:zod.z.string().regex(/^[a-z][a-z0-9_]{0,62}$/),postgresType:zod.z.enum(["integer","text","boolean","bigint","jsonb"])}).strict()).max(100).refine(e=>new Set(e.map(o=>o.id)).size===e.length,"Repair IDs must be unique").optional(),healthPath:zod.z.string().regex(/^\/[A-Za-z0-9/_-]*$/,'must start with "/"').max(256).optional(),limits:backendLimitsSchema.optional(),publicRoutes:zod.z.array(publicRouteSchema).max(100).optional(),config:configDeclarationSchema.optional()}).strict().superRefine((e,o)=>{const t=e.publicRoutes??[];t.forEach((s,a)=>{const i=t.slice(0,a).find(n=>chunk2P6UEAPV_cjs.publicRoutesOverlap(n,s));i&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["publicRoutes",a],message:`"${chunk2P6UEAPV_cjs.formatPublicRoute(s)}" can match the same requests as "${chunk2P6UEAPV_cjs.formatPublicRoute(i)}"`})}),e.platforms&&(e.runtime??"node")!=="python"&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["platforms"],message:'only applies to runtime "python"'})}),clawPartSchema=zod.z.object({dir:relativePathSchema.optional(),hooks:zod.z.object({allowPromptInjection:zod.z.boolean().optional(),allowConversationAccess:zod.z.boolean().optional()}).strict().optional()}).strict();function containsPath(e,o){return o===e||o.startsWith(`${e}/`)}l(containsPath,"containsPath");var publicFrontendPartSchema=zod.z.object({dir:relativePathSchema.optional()}).strict(),partsSchema=zod.z.object({frontend:frontendPartSchema.optional(),backend:backendPartSchema.optional(),claw:clawPartSchema.optional(),publicFrontend:publicFrontendPartSchema.optional()}).strict().refine(e=>e.frontend!==void 0||e.backend!==void 0||e.claw!==void 0,{message:"a plugin must declare at least one of frontend, backend, claw"}).superRefine((e,o)=>{const t=[["frontend",e.frontend?.dir??chunk2P6UEAPV_cjs.PLUGIN_PART_DEFAULTS.frontend.dir],["backend",e.backend?.dir??chunk2P6UEAPV_cjs.PLUGIN_PART_DEFAULTS.backend.dir],["claw",e.claw?.dir??chunk2P6UEAPV_cjs.PLUGIN_PART_DEFAULTS.claw.dir],["publicFrontend",e.publicFrontend?.dir??chunk2P6UEAPV_cjs.PLUGIN_PART_DEFAULTS.publicFrontend.dir]].filter(([s])=>e[s]!==void 0);for(const[s,a]of t)for(const[i,n]of t)s!==i&&containsPath(a,n)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:[i,"dir"],message:a===n?`must not be the same directory as the ${s} part ("${a}")`:`must not sit inside the ${s} part's directory ("${a}")`})}),permissionsSchema=zod.z.object({required:zod.z.array(zod.z.string().min(1).max(128)).max(50).optional()}).strict(),declaresSchema=zod.z.object({database:zod.z.boolean().optional(),storage:zod.z.boolean().optional(),events:zod.z.boolean().optional(),notifications:zod.z.boolean().optional()}).strict(),tegoPluginManifestSchema=zod.z.object({manifestVersion:zod.z.literal(1),id:zod.z.string().max(MAX_PLUGIN_ID_LENGTH).regex(PLUGIN_ID_PATTERN,"must be lowercase letters, digits, dot, underscore or hyphen, starting with a letter or digit"),version:semanticVersionSchema,displayName:localizedTextSchema,description:localizedTextSchema.optional(),author:zod.z.string().max(200).optional(),homepage:zod.z.string().url().max(500).optional(),icon:relativePathSchema.optional(),category:zod.z.string().min(1).max(64).optional(),tags:zod.z.array(zod.z.string().min(1).max(64)).max(20).optional(),hostApiRange:zod.z.string().refine(chunk6HNG5OZI_cjs.isValidHostApiRange,{message:'must be a caret range like "^1.2.0" or an exact "1.2.0"'}).optional(),scope:zod.z.enum(["avatar","tenant"]),declares:declaresSchema.optional(),parts:partsSchema,permissions:permissionsSchema.optional(),access:zod.z.object({catalog:relativePathSchema}).strict().optional(),audit:zod.z.object({tools:zod.z.record(zod.z.string().min(1).max(128),zod.z.object({category:zod.z.enum(["read","write","search","browse","exec","knowledge","memory","message","schedule","delegate","document","plugin"]).optional(),title:localizedTextSchema.optional(),target:zod.z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).optional(),risk:zod.z.enum(["low","medium","high"]).optional(),dataClasses:zod.z.array(zod.z.string().min(1).max(32)).max(10).optional()}).strict()).optional()}).strict().optional(),agentTemplates:zod.z.array(zod.z.object({key:navKeySchema,entry:relativePathSchema,icon:relativePathSchema.optional()}).strict()).max(20).optional(),workDelegation:zod.z.object({allowedAvatarRoles:zod.z.array(zod.z.string().min(1).max(100)).min(1).max(20),settingsRoute:zod.z.string().regex(/^\/[A-Za-z0-9/_-]*$/,'must start with "/"').max(256).refine(e=>!e.startsWith("//"),"must be a plugin page").optional(),summary:localizedTextSchema.refine(e=>(typeof e=="string"?[e]:Object.values(e)).every(o=>o.length<=120),"must be at most 120 characters in every locale").optional(),privacyPolicyUrl:zod.z.string().url().max(2048).refine(e=>e.startsWith("https://"),"must be an https URL").optional(),conversationCapture:zod.z.boolean().optional()}).strict().optional(),conversationRecordRoutes:zod.z.array(zod.z.object({entity:navKeySchema,path:relativePathSchema,contextQuery:zod.z.string().max(200).regex(/^[A-Za-z0-9_=&-]+$/).optional(),labelFields:zod.z.array(zod.z.string().regex(/^[A-Za-z][A-Za-z0-9_]*$/)).min(1).max(3).optional()}).strict()).max(30).optional(),agentReadiness:zod.z.object({path:relativePathSchema}).strict().optional()}).strict().superRefine((e,o)=>{const t=new Set;for(const[r,c]of(e.agentTemplates??[]).entries())t.has(c.key)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["agentTemplates",r,"key"],message:"duplicate template key"}),t.add(c.key);const s=new Set;for(const[r,c]of(e.conversationRecordRoutes??[]).entries())s.has(c.entity)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["conversationRecordRoutes",r,"entity"],message:"duplicate conversation entity"}),s.add(c.entity);(e.parts.frontend!==void 0||e.parts.backend!==void 0)&&e.hostApiRange===void 0&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["hostApiRange"],message:"required when a frontend or backend part is declared, so the host can refuse incompatible releases"});const i=e.parts.backend?.publicRoutes??[];if(e.parts.publicFrontend!==void 0&&i.length===0&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["parts","publicFrontend"],message:"requires parts.backend.publicRoutes for the pages to call"}),e.parts.backend===void 0&&e.declares)for(const r of["database","storage","events"])e.declares[r]===!0&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["declares",r],message:"requires a backend part"});e.permissions?.required?.includes("knowledge.manage")&&(!e.parts.backend||!e.hostApiRange||chunk6HNG5OZI_cjs.isValidHostApiRange(e.hostApiRange)&&chunk6HNG5OZI_cjs.compareSkillSemanticVersions(chunk6HNG5OZI_cjs.hostApiRangeMinimum(e.hostApiRange),"1.23.0")<0)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["hostApiRange"],message:"knowledge.manage requires a backend and host API ^1.23.0 or later"}),e.permissions?.required?.includes("proactive.emit")&&(!e.parts.backend||!e.hostApiRange||chunk6HNG5OZI_cjs.isValidHostApiRange(e.hostApiRange)&&chunk6HNG5OZI_cjs.compareSkillSemanticVersions(chunk6HNG5OZI_cjs.hostApiRangeMinimum(e.hostApiRange),"1.26.0")<0)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["hostApiRange"],message:"proactive.emit requires a backend and host API ^1.26.0 or later"}),e.permissions?.required?.includes("attention.request")&&(!e.parts.backend||!e.hostApiRange||chunk6HNG5OZI_cjs.isValidHostApiRange(e.hostApiRange)&&chunk6HNG5OZI_cjs.compareSkillSemanticVersions(chunk6HNG5OZI_cjs.hostApiRangeMinimum(e.hostApiRange),"1.34.0")<0)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["hostApiRange"],message:"attention.request requires a backend and host API ^1.34.0 or later"}),e.permissions?.required?.includes("mail.send")&&(!e.parts.backend||!e.hostApiRange||chunk6HNG5OZI_cjs.isValidHostApiRange(e.hostApiRange)&&chunk6HNG5OZI_cjs.compareSkillSemanticVersions(chunk6HNG5OZI_cjs.hostApiRangeMinimum(e.hostApiRange),"1.29.0")<0)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["hostApiRange"],message:"mail.send requires a backend and host API ^1.29.0 or later"}),e.agentReadiness!==void 0&&e.parts.backend===void 0&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["agentReadiness"],message:"requires a backend part to answer it"}),(e.agentReadiness!==void 0||e.workDelegation?.settingsRoute!==void 0)&&(!e.hostApiRange||chunk6HNG5OZI_cjs.isValidHostApiRange(e.hostApiRange)&&chunk6HNG5OZI_cjs.compareSkillSemanticVersions(chunk6HNG5OZI_cjs.hostApiRangeMinimum(e.hostApiRange),"1.30.0")<0)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["hostApiRange"],message:"agentReadiness and workDelegation.settingsRoute require host API ^1.30.0 or later"}),e.workDelegation!==void 0&&e.parts.backend===void 0&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["workDelegation"],message:"requires a backend part to act on it"});const n=e.workDelegation;(n?.summary!==void 0||n?.privacyPolicyUrl!==void 0||n?.conversationCapture!==void 0)&&(!e.hostApiRange||chunk6HNG5OZI_cjs.isValidHostApiRange(e.hostApiRange)&&chunk6HNG5OZI_cjs.compareSkillSemanticVersions(chunk6HNG5OZI_cjs.hostApiRangeMinimum(e.hostApiRange),"1.33.0")<0)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["hostApiRange"],message:"workDelegation.summary, privacyPolicyUrl and conversationCapture require host API ^1.33.0 or later"}),e.access!==void 0&&(e.parts.backend===void 0&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["access"],message:"requires a backend part to enforce it"}),e.permissions?.required?.includes(DIRECTORY_READ)||o.addIssue({code:zod.z.ZodIssueCode.custom,path:["permissions","required"],message:`must include "${DIRECTORY_READ}" when access is declared`}),e.hostApiRange!==void 0&&chunk6HNG5OZI_cjs.isValidHostApiRange(e.hostApiRange)&&chunk6HNG5OZI_cjs.compareSkillSemanticVersions(chunk6HNG5OZI_cjs.hostApiRangeMinimum(e.hostApiRange),ACCESS_HOST_API_VERSION)<0&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["hostApiRange"],message:`access needs host API ${ACCESS_HOST_API_VERSION} \u2014 declare "^${ACCESS_HOST_API_VERSION}" or later`})),(e.parts.frontend?.nav??[]).forEach((r,c)=>{const d=chunkN4SXZZPY_cjs.pluginMenuPermission(e.id,r.key);d.length<=chunkN4SXZZPY_cjs.MAX_PLUGIN_MENU_PERMISSION_LENGTH||o.addIssue({code:zod.z.ZodIssueCode.custom,path:["parts","frontend","nav",c,"key"],message:`together with the plugin id this derives "${d}" (${d.length} chars), over the ${chunkN4SXZZPY_cjs.MAX_PLUGIN_MENU_PERMISSION_LENGTH}-char limit \u2014 shorten the id or the key`})})});function formatIssues(e){return e.issues.map(o=>{const t=o.path.join(".");return t?`${t}: ${o.message}`:o.message})}l(formatIssues,"formatIssues");function parseTegoPluginManifest(e){const o=tegoPluginManifestSchema.safeParse(e);return o.success?{ok:!0,manifest:o.data,errors:[]}:{ok:!1,errors:formatIssues(o.error)}}l(parseTegoPluginManifest,"parseTegoPluginManifest"),exports.PYTHON_LOCK_FILENAME=PYTHON_LOCK_FILENAME,exports.PYTHON_RUNNER_VERSION=PYTHON_RUNNER_VERSION,exports.PYTHON_WHEELS_DIR=PYTHON_WHEELS_DIR,exports.checkPluginAccessCatalog=checkPluginAccessCatalog,exports.checkPythonVendoring=checkPythonVendoring,exports.normalizePackageName=normalizePackageName,exports.parseRequirementsLock=parseRequirementsLock,exports.parseTegoPluginManifest=parseTegoPluginManifest,exports.parseWheelFilename=parseWheelFilename,exports.tegoPluginManifestSchema=tegoPluginManifestSchema;