@zhama/tego-plugin-sdk 1.37.1 → 1.40.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.
- package/README.md +48 -9
- package/agent/RULES.md +34 -11
- package/agent/guides/agent-templates.md +51 -0
- package/agent/guides/backend.md +8 -0
- package/agent/guides/host-api-versions.md +3 -0
- package/agent/reference/plugin-sdk-api.md +1 -0
- package/agent/rules.json +500 -0
- package/agent/skills/add-agent-template/SKILL.md +19 -0
- package/agent/skills/add-claw-tool/SKILL.md +21 -0
- package/agent/skills/add-i18n-strings/SKILL.md +19 -0
- package/agent/skills/add-migration/SKILL.md +22 -0
- package/agent/skills/add-route-with-access/SKILL.md +30 -0
- package/agent/skills/add-screen/SKILL.md +27 -0
- package/bin/tego-plugin.mjs +7 -3
- package/dist/access.d.cts +1 -0
- package/dist/access.d.ts +1 -0
- package/dist/{chunk-EIVA5BR6.js → chunk-2KXEYXM2.js} +1 -1
- package/dist/{chunk-I5Z3ECC4.js → chunk-44LPR67H.js} +1 -1
- package/dist/chunk-66LDWN4T.cjs +1 -0
- package/dist/{chunk-HZ4YWRYX.cjs → chunk-6EKQMOYT.cjs} +2 -2
- package/dist/{chunk-SKNPNPJP.cjs → chunk-H6GXDFLP.cjs} +1 -1
- package/dist/{chunk-6HNG5OZI.cjs → chunk-IOZFHJ4F.cjs} +1 -1
- package/dist/chunk-JV2G2Z33.js +1 -0
- package/dist/{chunk-4LKRXDYY.cjs → chunk-QQOUNXLC.cjs} +8 -8
- package/dist/{chunk-FCYAAOHC.js → chunk-UZBWS5AR.js} +2 -2
- package/dist/{chunk-56QOZQTY.js → chunk-XOXUS4VI.js} +1 -1
- package/dist/decision-card-IF2c4wvM.d.cts +161 -0
- package/dist/decision-card-IF2c4wvM.d.ts +161 -0
- package/dist/dev.cjs +8 -3
- package/dist/dev.d.cts +33 -2
- package/dist/dev.d.ts +33 -2
- package/dist/dev.js +13 -8
- package/dist/doctor.cjs +15 -8
- package/dist/doctor.d.cts +99 -2
- package/dist/doctor.d.ts +99 -2
- package/dist/doctor.js +15 -8
- package/dist/eslint.cjs +1 -0
- package/dist/eslint.d.cts +29 -0
- package/dist/eslint.d.ts +29 -0
- package/dist/eslint.js +1 -0
- package/dist/hono.d.cts +1 -0
- package/dist/hono.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +1 -1
- package/dist/manifest.cjs +1 -1
- package/dist/manifest.js +1 -1
- package/dist/pack.cjs +1 -1
- package/dist/pack.d.cts +5 -0
- package/dist/pack.d.ts +5 -0
- package/dist/pack.js +1 -1
- package/dist/publish.cjs +1 -1
- package/dist/publish.js +1 -1
- package/dist/scaffold.cjs +53 -8
- package/dist/scaffold.js +59 -14
- package/dist/server-runtime.cjs +1 -1
- package/dist/server-runtime.d.cts +1 -0
- package/dist/server-runtime.d.ts +1 -0
- package/dist/server-runtime.js +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +25 -0
- package/dist/server.d.ts +25 -0
- package/dist/server.js +1 -1
- package/dist/testing.d.cts +1 -0
- package/dist/testing.d.ts +1 -0
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/package.json +8 -1
- /package/dist/{chunk-QKSPPMVN.js → chunk-CDJQ7OPA.js} +0 -0
- /package/dist/{chunk-BN6TGHSB.cjs → chunk-SR5V7ZC2.cjs} +0 -0
package/bin/tego-plugin.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var v=Object.defineProperty;var
|
|
3
|
-
`)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}process.exit()}if(
|
|
2
|
+
var v=Object.defineProperty;var f=(s,o)=>v(s,"name",{value:o,configurable:!0});import{readFileSync as $}from"node:fs";const l=process.argv.slice(2),d=l[0];if(d==="create"){const{createStandalonePlugin:s}=await import("../dist/scaffold.js"),o=l.indexOf("--dir");try{const e=await s($(0,"utf8"),{parent:o===-1?".":l[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(d==="migrations"){const{syncMigrations:s}=await import("../dist/migrations-sync.js"),o=l[1];o!=="sync"&&o!=="check"&&(console.error("usage: tego-plugin migrations sync|check"),process.exit(2));const e=await s({root:process.cwd(),check:o==="check"});for(const{from:r,to:t}of e.copied)console.log(`${r} -> ${t}`);for(const r of e.problems)console.error(`\u2716 ${r}`);e.problems.length===0&&e.copied.length===0&&console.log("\u2705 migrations are in sync"),process.exit(e.problems.length>0?1:0)}if(d==="doctor"){const{runDoctor:s,formatDoctorReport:o}=await import("../dist/doctor.js"),e=l.slice(1),r=e.indexOf("--files");try{const t=await s({root:process.cwd(),files:r===-1?void 0:(e[r+1]??"").split(",").filter(Boolean)});process.stdout.write(e.includes("--json")?`${JSON.stringify(t)}
|
|
4
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(
|
|
5
|
+
`),process.exit(t.errors>0?1:0)}catch(t){console.error(`\u2716 ${t instanceof Error?t.message:String(t)}`),process.exit(2)}}if(d==="check"){const{runChecks:s,formatCheckReport:o,DEFAULT_CHECK_STEPS:e}=await import("../dist/doctor.js"),r=l.slice(1),t=f(i=>{const a=r.indexOf(`--${i}`);return a===-1?void 0:(r[a+1]??"").split(",").filter(Boolean)},"list"),n=t("steps")??[...e,...r.includes("--build")?["build"]:[]],g=["doctor","lint","type-check","test","build"],m=n.filter(i=>!g.includes(i));m.length>0&&(console.error(`\u2716 unknown step(s): ${m.join(", ")}; use ${g.join(", ")}`),process.exit(2));try{const i=t("files"),a=await s({root:process.cwd(),steps:n,...i?{files:i}:{}});process.stdout.write(r.includes("--json")?`${JSON.stringify(a)}
|
|
6
|
+
`:`${o(a)}
|
|
7
|
+
`),process.exit(a.passed?0:1)}catch(i){console.error(`\u2716 ${i instanceof Error?i.message:String(i)}`),process.exit(2)}}if(d==="rules"){const{ruleCatalog:s}=await import("../dist/doctor.js"),{resolvePluginParts:o}=await import("../dist/index.js");let e={};try{const t=JSON.parse($("tego.plugin.json","utf8")),n=o(t);e={frontend:n.frontend?.dir,backend:n.backend?.dir,claw:n.claw?.dir}}catch{}const r=s(e);if(l.includes("--json"))process.stdout.write(`${JSON.stringify(r)}
|
|
8
|
+
`);else for(const t of r.rules)process.stdout.write(`${t.id} ${t.severity.padEnd(7)} ${t.title} (${t.guide}; ${t.appliesTo.join(", ")||"whole plugin"})
|
|
9
|
+
`);process.exit(0)}if(d==="dev"){const{startDevServer:s}=await import("../dist/dev.js"),o=l.slice(1),e=f(c=>{const h=o.indexOf(`--${c}`);return h===-1?void 0:o[h+1]},"value"),r=e("port");r!==void 0&&!/^\d+$/.test(r)&&(console.error(`\u2716 --port must be a number, not ${r}`),process.exit(2));const t=o.find(c=>c==="--inspect"||c.startsWith("--inspect=")),n=t===void 0?process.env.TEGO_DEV_INSPECT||void 0:t.slice(10)||"default";let g;if(n!==void 0){n!=="default"&&!/^\d+$/.test(n)&&(console.error(`\u2716 --inspect takes a port number, not ${n}`),process.exit(2));const{DEFAULT_INSPECT_PORT:c}=await import("../dist/dev.js");g=n==="default"?c:Number(n)}let m;try{m=await s({root:process.cwd(),port:r===void 0?void 0:Number(r),host:e("host"),backend:!o.includes("--no-backend"),target:e("target")==="desktop"?"desktop":"web",databaseUrl:process.env.DATABASE_URL||void 0,inspect:g})}catch(c){console.error(`\u2716 ${c instanceof Error?c.message:String(c)}`),process.exit(1)}let i=!1;const a=f(async()=>{i||(i=!0,setTimeout(()=>process.exit(0),5e3).unref(),await m.close().catch(()=>{}),process.exit(0))},"stop");process.once("SIGINT",a),process.once("SIGTERM",a),await new Promise(()=>{})}else d!=="publish"&&(console.error("usage: tego-plugin create [--dir <parent>] | tego-plugin dev [--port <n>] [--inspect[=<port>]] [--no-backend] | tego-plugin doctor [--json] | tego-plugin publish [options]"),process.exit(2));const{publishPlugin:k}=await import("../dist/publish.js"),u=l.slice(1);function p(s){const o=u.indexOf(`--${s}`);return o===-1?void 0:u[o+1]}f(p,"flag");function y(s){const o=[];for(let e=0;e<u.length;e++)u[e]===`--${s}`&&o.push(u[e+1]);return o}f(y,"all");const x=p("server")??process.env.TEGO_SERVER_URL,b=p("token")??process.env.TEGO_ADMIN_TOKEN;(!x||!b)&&(console.error("\u2716 --server (TEGO_SERVER_URL) and --token (TEGO_ADMIN_TOKEN) are both required"),process.exit(2));const E=y("avatar").filter(Boolean),w={};p("category")&&(w.category=p("category")),p("homepage")&&(w.homepage=p("homepage")),p("icon")&&(w.icon=p("icon"));try{const s=await k({root:p("root")??process.cwd(),server:x,token:b,...E.length>0?{avatarIds:E}:{},...Object.keys(w).length>0?{meta:w}:{},approve:!u.includes("--no-approve"),install:!u.includes("--no-install")}),o=s.release.semanticVersion;console.log(`\u2705 ${s.release.pluginId}@${o} \u2014 release ${s.release.status}`)}catch(s){console.error(`\u2716 ${s instanceof Error?s.message:String(s)}`),process.exitCode=1}
|
package/dist/access.d.cts
CHANGED
|
@@ -4,6 +4,7 @@ import { PluginUserContext } from './frontend.cjs';
|
|
|
4
4
|
import { PluginHostApi } from './server.cjs';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
export { expandImplications, mergeGrant, scopeRank } from './access-implications.cjs';
|
|
7
|
+
import './decision-card-IF2c4wvM.cjs';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* The pure core of the decision engine: given who the caller is and what the
|
package/dist/access.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { PluginUserContext } from './frontend.js';
|
|
|
4
4
|
import { PluginHostApi } from './server.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
export { expandImplications, mergeGrant, scopeRank } from './access-implications.js';
|
|
7
|
+
import './decision-card-IF2c4wvM.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* The pure core of the decision engine: given who the caller is and what the
|
|
@@ -1 +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};
|
|
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 f}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-XOXUS4VI.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,b="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(`${b}: "${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(`${b}: unsupported option "${g.slice(0,40)}" on ${c[1]}`)}l.length===0&&a.push(`${b}: ${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 ${b}. 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 ${b}; 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._-]*$/,q="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(),T=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:T.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(),j=/^(?=.{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||j.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:T.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??f.frontend.dir],["backend",o.backend?.dir??f.backend.dir],["claw",o.claw?.dir??f.claw.dir],["publicFrontend",o.publicFrontend?.dir??f.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("messages.latest_user")&&(!o.parts.backend||!o.hostApiRange||p(o.hostApiRange)&&m(h(o.hostApiRange),"1.39.0")<0)&&t.addIssue({code:e.ZodIssueCode.custom,path:["hostApiRange"],message:"messages.latest_user requires a backend and host API ^1.39.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(q)||t.addIssue({code:e.ZodIssueCode.custom,path:["permissions","required"],message:`must include "${q}" 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{b 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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var g=Object.defineProperty;var s=(t,e)=>g(t,"name",{value:e,configurable:!0});import{SHARED_MODULE_IDS as l}from"./chunk-
|
|
1
|
+
var g=Object.defineProperty;var s=(t,e)=>g(t,"name",{value:e,configurable:!0});import{SHARED_MODULE_IDS as l}from"./chunk-XOXUS4VI.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
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
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
4
|
`),e.append(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var i=(e,u)=>s(e,"name",{value:u,configurable:!0});var decisionCardPath=i(e=>`/decision-intents/${encodeURIComponent(e)}`,"decisionCardPath");function isDecisionCardBlock(e){if(!e||typeof e!="object")return!1;const u=e;return u.type==="plugin-decision"&&typeof u.pluginId=="string"&&u.pluginId.length>0&&typeof u.intentId=="string"&&u.intentId.length>0}i(isDecisionCardBlock,"isDecisionCardBlock");var DECISION_CARD_FALLBACKS=["\u770B\u4E0D\u5230\u5361\u7247\uFF1F\u8BF7\u66F4\u65B0\u5E94\u7528\uFF0C\u6216\u5230\u7F51\u9875\u5904\u7406\u3002","\u770B\u4E0D\u5230\u5361\u7247\uFF1F\u8ACB\u66F4\u65B0\u61C9\u7528\u7A0B\u5F0F\uFF0C\u6216\u5230\u7DB2\u9801\u8655\u7406\u3002","Can't see a card? Update the app or use the web page.","\u30AB\u30FC\u30C9\u304C\u8868\u793A\u3055\u308C\u306A\u3044\u5834\u5408\u306F\u3001\u30A2\u30D7\u30EA\u3092\u66F4\u65B0\u3059\u308B\u304B Web \u3067\u51E6\u7406\u3057\u3066\u304F\u3060\u3055\u3044\u3002","\uCE74\uB4DC\uAC00 \uBCF4\uC774\uC9C0 \uC54A\uB098\uC694? \uC571\uC744 \uC5C5\uB370\uC774\uD2B8\uD558\uAC70\uB098 \uC6F9\uC5D0\uC11C \uCC98\uB9AC\uD558\uC138\uC694.","Keine Karte zu sehen? Aktualisiere die App oder nutze die Webseite.","Pas de carte visible ? Mettez \xE0 jour l\u2019application ou passez par le web.","\xBFNo ves una tarjeta? Actualiza la app o usa la web.","Non vedi una scheda? Aggiorna l\u2019app o usa il web.","N\xE3o v\xEA um cart\xE3o? Atualize o app ou use a web."];function stripDecisionCardFallback(e){const u=e.trimEnd();for(const t of DECISION_CARD_FALLBACKS)if(u.endsWith(t))return u.slice(0,u.length-t.length).trimEnd();return e}i(stripDecisionCardFallback,"stripDecisionCardFallback");function splitDecisionCardBlocks(e){const u=[],t=[];for(const n of e)isDecisionCardBlock(n)?u.push(n):t.push(n);return{decisions:u,rest:t}}i(splitDecisionCardBlocks,"splitDecisionCardBlocks"),exports.DECISION_CARD_FALLBACKS=DECISION_CARD_FALLBACKS,exports.decisionCardPath=decisionCardPath,exports.isDecisionCardBlock=isDecisionCardBlock,exports.splitDecisionCardBlocks=splitDecisionCardBlocks,exports.stripDecisionCardFallback=stripDecisionCardFallback;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var s=(e,t)=>c(e,"name",{value:t,configurable:!0});var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var s=(e,t)=>c(e,"name",{value:t,configurable:!0});var chunkIOZFHJ4F_cjs=require("./chunk-IOZFHJ4F.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
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
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
4
|
`),t.append(`
|
|
5
|
-
})();`),{code:t.toString(),map:t.generateMap({hires:!0})}}}}}s(isolateChunkScope,"isolateChunkScope");function tegoPluginFrontend(e){const t=Object.fromEntries(
|
|
5
|
+
})();`),{code:t.toString(),map:t.generateMap({hires:!0})}}}}}s(isolateChunkScope,"isolateChunkScope");function tegoPluginFrontend(e){const t=Object.fromEntries(chunkIOZFHJ4F_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:[...chunkIOZFHJ4F_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;
|
|
@@ -1 +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;
|
|
1
|
+
"use strict";var p=Object.defineProperty;var d=(e,o)=>p(e,"name",{value:o,configurable:!0});var chunk2P6UEAPV_cjs=require("./chunk-2P6UEAPV.cjs"),chunkN4SXZZPY_cjs=require("./chunk-N4SXZZPY.cjs"),chunkIOZFHJ4F_cjs=require("./chunk-IOZFHJ4F.cjs"),chunkAJY7ZHXK_cjs=require("./chunk-AJY7ZHXK.cjs"),net=require("net"),zod=require("zod");function checkPluginAccessCatalog(e,o){const t=`access.catalog (${e.access?.catalog??"?"})`,a=chunkAJY7ZHXK_cjs.validateAccessCatalog(o);if(!a.ok)return{ok:!1,errors:a.issues.map(n=>`${t}: ${n.path}: ${n.message}`)};const s=new Set((e.parts.frontend?.nav??[]).map(n=>n.key)),i=Object.keys(a.catalog.menus).filter(n=>!s.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:a.catalog}}d(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,"-")}d(normalizePackageName,"normalizePackageName");function parseRequirementsLock(e){const o=[],t=[],a=e.replace(/\\\r?\n/g," ").split(/\r?\n/).map(s=>s.replace(/(^|\s)#.*$/,"").trim()).filter(Boolean);for(const s of a){const[i="",...n]=s.split(/\s+/),r=/^([A-Za-z0-9][A-Za-z0-9._-]*)(?:\[[^\]]*\])?==([^\s;]+)$/.exec(i);if(!r||s.includes(";")){t.push(`${PYTHON_LOCK_FILENAME}: "${s.slice(0,80)}" is not a pinned "name==version" requirement without markers`);continue}const c=[];for(const l of n){const u=/^--hash=sha256:([0-9a-f]{64})$/.exec(l);u?.[1]?c.push(u[1]):t.push(`${PYTHON_LOCK_FILENAME}: unsupported option "${l.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}}d(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,a]=o,[s,i,n]=o.slice(-3);return!t||!a||!s||!i||!n?null:{name:normalizePackageName(t),version:a.toLowerCase(),pythonTags:s.split("."),abiTags:i.split("."),platformTags:n.split(".")}}d(parseWheelFilename,"parseWheelFilename");function supportsInterpreter(e){const{major:o,minor:t}=PYTHON_RUNNER_VERSION,a=`${o}${t}`;return e.pythonTags.some(s=>{if(s===`py${o}`||s===`py${a}`||s===`cp${a}`)return!0;const i=/^cp3(\d+)$/.exec(s);return i?.[1]!==void 0&&Number(i[1])<=t&&e.abiTags.includes("abi3")})}d(supportsInterpreter,"supportsInterpreter");function supportsPlatform(e,o){const t=o==="linux/amd64"?"x86_64":"aarch64";return e.platformTags.some(a=>{if(a==="any"||a===`manylinux2014_${t}`||t==="x86_64"&&/^manylinux(1|2010)_x86_64$/.test(a))return!0;const s=/^manylinux_2_(\d+)_(x86_64|aarch64)$/.exec(a);return s?.[2]===t&&Number(s[1])<=RUNNER_GLIBC_MINOR})}d(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),a=e.wheels.map(s=>({...s,parsed:parseWheelFilename(s.filename)}));for(const s of a){if(!s.parsed){t.push(`"${s.filename}" is not a valid wheel filename`);continue}const i=o.find(n=>n.name===s.parsed.name&&n.version===s.parsed.version);i?i.hashes.includes(s.sha256)||t.push(`"${s.filename}" does not match any --hash locked for ${i.name}==${i.version}`):t.push(`"${s.filename}" is not in ${PYTHON_LOCK_FILENAME}; ship only locked wheels`)}for(const s of o){const i=a.filter(n=>n.parsed?.name===s.name&&n.parsed.version===s.version&&supportsInterpreter(n.parsed));for(const n of e.platforms)i.some(r=>supportsPlatform(r.parsed,n))||t.push(`No wheel for ${s.name}==${s.version} on ${n} (python ${PYTHON_RUNNER_VERSION.major}.${PYTHON_RUNNER_VERSION.minor})`)}return t}d(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 chunkIOZFHJ4F_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(a=>Object.is(a,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 a of e.schema.required??[])t.includes(a)||o.addIssue({code:zod.z.ZodIssueCode.custom,path:["schema","required"],message:`"${a}" is required but not declared in properties`});for(const a of Object.keys(e.uiHints??{}))t.includes(a)||o.addIssue({code:zod.z.ZodIssueCode.custom,path:["uiHints",a],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,a]of Object.entries(e.config?.uiHints??{}))a.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[,a,s]=t;return s&&Number(s)>65535?!1:s&&net.isIP(a)===4||EGRESS_HOST_PATTERN.test(a)},"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((a,s)=>{const i=t.slice(0,s).find(n=>chunk2P6UEAPV_cjs.publicRoutesOverlap(n,a));i&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["publicRoutes",s],message:`"${chunk2P6UEAPV_cjs.formatPublicRoute(a)}" 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}/`)}d(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(([a])=>e[a]!==void 0);for(const[a,s]of t)for(const[i,n]of t)a!==i&&containsPath(s,n)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:[i,"dir"],message:s===n?`must not be the same directory as the ${a} part ("${s}")`:`must not sit inside the ${a} part's directory ("${s}")`})}),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(chunkIOZFHJ4F_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 a=new Set;for(const[r,c]of(e.conversationRecordRoutes??[]).entries())a.has(c.entity)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["conversationRecordRoutes",r,"entity"],message:"duplicate conversation entity"}),a.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||chunkIOZFHJ4F_cjs.isValidHostApiRange(e.hostApiRange)&&chunkIOZFHJ4F_cjs.compareSkillSemanticVersions(chunkIOZFHJ4F_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||chunkIOZFHJ4F_cjs.isValidHostApiRange(e.hostApiRange)&&chunkIOZFHJ4F_cjs.compareSkillSemanticVersions(chunkIOZFHJ4F_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||chunkIOZFHJ4F_cjs.isValidHostApiRange(e.hostApiRange)&&chunkIOZFHJ4F_cjs.compareSkillSemanticVersions(chunkIOZFHJ4F_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("messages.latest_user")&&(!e.parts.backend||!e.hostApiRange||chunkIOZFHJ4F_cjs.isValidHostApiRange(e.hostApiRange)&&chunkIOZFHJ4F_cjs.compareSkillSemanticVersions(chunkIOZFHJ4F_cjs.hostApiRangeMinimum(e.hostApiRange),"1.39.0")<0)&&o.addIssue({code:zod.z.ZodIssueCode.custom,path:["hostApiRange"],message:"messages.latest_user requires a backend and host API ^1.39.0 or later"}),e.permissions?.required?.includes("mail.send")&&(!e.parts.backend||!e.hostApiRange||chunkIOZFHJ4F_cjs.isValidHostApiRange(e.hostApiRange)&&chunkIOZFHJ4F_cjs.compareSkillSemanticVersions(chunkIOZFHJ4F_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||chunkIOZFHJ4F_cjs.isValidHostApiRange(e.hostApiRange)&&chunkIOZFHJ4F_cjs.compareSkillSemanticVersions(chunkIOZFHJ4F_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||chunkIOZFHJ4F_cjs.isValidHostApiRange(e.hostApiRange)&&chunkIOZFHJ4F_cjs.compareSkillSemanticVersions(chunkIOZFHJ4F_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&&chunkIOZFHJ4F_cjs.isValidHostApiRange(e.hostApiRange)&&chunkIOZFHJ4F_cjs.compareSkillSemanticVersions(chunkIOZFHJ4F_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 l=chunkN4SXZZPY_cjs.pluginMenuPermission(e.id,r.key);l.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 "${l}" (${l.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})}d(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)}}d(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;
|
|
@@ -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.
|
|
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.40.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 C=Object.defineProperty;var n=(e,u)=>C(e,"name",{value:u,configurable:!0});var a=n(e=>`/decision-intents/${encodeURIComponent(e)}`,"decisionCardPath");function o(e){if(!e||typeof e!="object")return!1;const u=e;return u.type==="plugin-decision"&&typeof u.pluginId=="string"&&u.pluginId.length>0&&typeof u.intentId=="string"&&u.intentId.length>0}n(o,"isDecisionCardBlock");var s=["\u770B\u4E0D\u5230\u5361\u7247\uFF1F\u8BF7\u66F4\u65B0\u5E94\u7528\uFF0C\u6216\u5230\u7F51\u9875\u5904\u7406\u3002","\u770B\u4E0D\u5230\u5361\u7247\uFF1F\u8ACB\u66F4\u65B0\u61C9\u7528\u7A0B\u5F0F\uFF0C\u6216\u5230\u7DB2\u9801\u8655\u7406\u3002","Can't see a card? Update the app or use the web page.","\u30AB\u30FC\u30C9\u304C\u8868\u793A\u3055\u308C\u306A\u3044\u5834\u5408\u306F\u3001\u30A2\u30D7\u30EA\u3092\u66F4\u65B0\u3059\u308B\u304B Web \u3067\u51E6\u7406\u3057\u3066\u304F\u3060\u3055\u3044\u3002","\uCE74\uB4DC\uAC00 \uBCF4\uC774\uC9C0 \uC54A\uB098\uC694? \uC571\uC744 \uC5C5\uB370\uC774\uD2B8\uD558\uAC70\uB098 \uC6F9\uC5D0\uC11C \uCC98\uB9AC\uD558\uC138\uC694.","Keine Karte zu sehen? Aktualisiere die App oder nutze die Webseite.","Pas de carte visible ? Mettez \xE0 jour l\u2019application ou passez par le web.","\xBFNo ves una tarjeta? Actualiza la app o usa la web.","Non vedi una scheda? Aggiorna l\u2019app o usa il web.","N\xE3o v\xEA um cart\xE3o? Atualize o app ou use a web."];function r(e){const u=e.trimEnd();for(const t of s)if(u.endsWith(t))return u.slice(0,u.length-t.length).trimEnd();return e}n(r,"stripDecisionCardFallback");function c(e){const u=[],t=[];for(const i of e)o(i)?u.push(i):t.push(i);return{decisions:u,rest:t}}n(c,"splitDecisionCardBlocks");export{s as DECISION_CARD_FALLBACKS,a as decisionCardPath,o as isDecisionCardBlock,c as splitDecisionCardBlocks,r as stripDecisionCardFallback};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var c=(e,n)=>j(e,"name",{value:n,configurable:!0});var
|
|
1
|
+
"use strict";var j=Object.defineProperty;var c=(e,n)=>j(e,"name",{value:n,configurable:!0});var chunk6EKQMOYT_cjs=require("./chunk-6EKQMOYT.cjs"),chunkH6GXDFLP_cjs=require("./chunk-H6GXDFLP.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,
|
|
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,chunkH6GXDFLP_cjs.PYTHON_LOCK_FILENAME),{major:s,minor:l}=chunkH6GXDFLP_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}=chunkH6GXDFLP_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}=chunkH6GXDFLP_cjs.parseRequirementsLock(e),a=new Map;for(const s of(await promises.readdir(n)).sort()){const l=chunkH6GXDFLP_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 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,
|
|
7
|
-
`));if(!h.some(p=>p.name===
|
|
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,chunkH6GXDFLP_cjs.PYTHON_LOCK_FILENAME);if(!await exists(f))throw new Error(`${t.dir}/${chunkH6GXDFLP_cjs.PYTHON_LOCK_FILENAME} not found; run \`tego-plugin-pack lock\``);const d=await promises.readFile(f,"utf8"),{errors:w,requirements:h}=chunkH6GXDFLP_cjs.parseRequirementsLock(d);if(w.length>0)throw new Error([`${t.dir}/${chunkH6GXDFLP_cjs.PYTHON_LOCK_FILENAME} is invalid:`,...w].join(`
|
|
7
|
+
`));if(!h.some(p=>p.name===chunkH6GXDFLP_cjs.normalizePackageName(SDK_DIST_NAME)))throw new Error(`${t.dir}/${chunkH6GXDFLP_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,chunkH6GXDFLP_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,chunkH6GXDFLP_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=chunkH6GXDFLP_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
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
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",...
|
|
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",...chunk6EKQMOYT_cjs.TEGO_PLUGIN_DEV_OVERRIDES,build:{...chunk6EKQMOYT_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(`
|
|
11
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
|
|
12
12
|
|
|
13
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
|
|
14
14
|
|
|
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=
|
|
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=
|
|
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)}
|
|
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=chunkH6GXDFLP_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=chunkH6GXDFLP_cjs.checkPluginAccessCatalog(i,JSON.parse(o));if(!r.ok)throw new Error(["The access catalog is invalid:",...r.errors].join(`
|
|
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??[]],sourcemap:n.sourcemap?"inline":!1,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)}
|
|
18
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
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
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,4 +1,4 @@
|
|
|
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-
|
|
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-44LPR67H.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-2KXEYXM2.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
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
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
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(`
|
|
@@ -14,7 +14,7 @@ ${e}`)}}l(F,"uv");async function at(t,n){await F(["build","--quiet","--wheel","-
|
|
|
14
14
|
|
|
15
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
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)}
|
|
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??[]],sourcemap:n.sourcemap?"inline":!1,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
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
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
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};
|
|
@@ -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.
|
|
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.40.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};
|