@xenosystem/agent-sdk 0.8.12
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/LICENSE +15 -0
- package/README.md +511 -0
- package/dist/agents/index.cjs +17 -0
- package/dist/agents/index.d.cts +244 -0
- package/dist/agents/index.d.ts +244 -0
- package/dist/agents/index.js +17 -0
- package/dist/agents/metafile-cjs.json +1 -0
- package/dist/agents/metafile-esm.json +1 -0
- package/dist/artifacts/browser.cjs +1 -0
- package/dist/artifacts/browser.d.cts +8 -0
- package/dist/artifacts/browser.d.ts +8 -0
- package/dist/artifacts/browser.js +1 -0
- package/dist/artifacts/diff-artifact-C2tQZWcs.d.cts +354 -0
- package/dist/artifacts/diff-artifact-C2tQZWcs.d.ts +354 -0
- package/dist/artifacts/index.cjs +10 -0
- package/dist/artifacts/index.d.cts +588 -0
- package/dist/artifacts/index.d.ts +588 -0
- package/dist/artifacts/index.js +10 -0
- package/dist/artifacts/metafile-cjs.json +1 -0
- package/dist/artifacts/metafile-esm.json +1 -0
- package/dist/automation/index.cjs +438 -0
- package/dist/automation/index.d.cts +878 -0
- package/dist/automation/index.d.ts +878 -0
- package/dist/automation/index.js +438 -0
- package/dist/automation/metafile-cjs.json +1 -0
- package/dist/automation/metafile-esm.json +1 -0
- package/dist/control-plane/index.cjs +7 -0
- package/dist/control-plane/index.d.cts +403 -0
- package/dist/control-plane/index.d.ts +403 -0
- package/dist/control-plane/index.js +7 -0
- package/dist/control-plane/metafile-cjs.json +1 -0
- package/dist/control-plane/metafile-esm.json +1 -0
- package/dist/control-room/index.cjs +1 -0
- package/dist/control-room/index.d.cts +216 -0
- package/dist/control-room/index.d.ts +216 -0
- package/dist/control-room/index.js +1 -0
- package/dist/control-room/metafile-cjs.json +1 -0
- package/dist/control-room/metafile-esm.json +1 -0
- package/dist/electron/index.cjs +1476 -0
- package/dist/electron/index.d.cts +1583 -0
- package/dist/electron/index.d.ts +1583 -0
- package/dist/electron/index.js +1476 -0
- package/dist/electron/metafile-cjs.json +1 -0
- package/dist/electron/metafile-esm.json +1 -0
- package/dist/governance/index.cjs +33 -0
- package/dist/governance/index.d.cts +397 -0
- package/dist/governance/index.d.ts +397 -0
- package/dist/governance/index.js +33 -0
- package/dist/governance/metafile-cjs.json +1 -0
- package/dist/governance/metafile-esm.json +1 -0
- package/dist/hooks/index.cjs +9 -0
- package/dist/hooks/index.d.cts +198 -0
- package/dist/hooks/index.d.ts +198 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/metafile-cjs.json +1 -0
- package/dist/hooks/metafile-esm.json +1 -0
- package/dist/hosted/index.cjs +1 -0
- package/dist/hosted/index.d.cts +490 -0
- package/dist/hosted/index.d.ts +490 -0
- package/dist/hosted/index.js +1 -0
- package/dist/hosted/metafile-cjs.json +1 -0
- package/dist/hosted/metafile-esm.json +1 -0
- package/dist/index.cjs +2161 -0
- package/dist/index.d.cts +12259 -0
- package/dist/index.d.ts +12259 -0
- package/dist/index.js +2161 -0
- package/dist/intelligence/index.cjs +10 -0
- package/dist/intelligence/index.d.cts +220 -0
- package/dist/intelligence/index.d.ts +220 -0
- package/dist/intelligence/index.js +10 -0
- package/dist/intelligence/metafile-cjs.json +1 -0
- package/dist/intelligence/metafile-esm.json +1 -0
- package/dist/mcp/index.cjs +28 -0
- package/dist/mcp/index.d.cts +960 -0
- package/dist/mcp/index.d.ts +960 -0
- package/dist/mcp/index.js +28 -0
- package/dist/mcp/metafile-cjs.json +1 -0
- package/dist/mcp/metafile-esm.json +1 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/oracle/index.cjs +1 -0
- package/dist/oracle/index.d.cts +310 -0
- package/dist/oracle/index.d.ts +310 -0
- package/dist/oracle/index.js +1 -0
- package/dist/oracle/metafile-cjs.json +1 -0
- package/dist/oracle/metafile-esm.json +1 -0
- package/dist/providers/index.cjs +11 -0
- package/dist/providers/index.d.cts +462 -0
- package/dist/providers/index.d.ts +462 -0
- package/dist/providers/index.js +11 -0
- package/dist/providers/metafile-cjs.json +1 -0
- package/dist/providers/metafile-esm.json +1 -0
- package/dist/recipes/index.cjs +2 -0
- package/dist/recipes/index.d.cts +86 -0
- package/dist/recipes/index.d.ts +86 -0
- package/dist/recipes/index.js +2 -0
- package/dist/recipes/metafile-cjs.json +1 -0
- package/dist/recipes/metafile-esm.json +1 -0
- package/dist/research/index.cjs +3 -0
- package/dist/research/index.d.cts +285 -0
- package/dist/research/index.d.ts +285 -0
- package/dist/research/index.js +3 -0
- package/dist/research/metafile-cjs.json +1 -0
- package/dist/research/metafile-esm.json +1 -0
- package/dist/session/index.cjs +56 -0
- package/dist/session/index.d.cts +523 -0
- package/dist/session/index.d.ts +523 -0
- package/dist/session/index.js +56 -0
- package/dist/session/metafile-cjs.json +1 -0
- package/dist/session/metafile-esm.json +1 -0
- package/dist/sharing/index.cjs +4 -0
- package/dist/sharing/index.d.cts +272 -0
- package/dist/sharing/index.d.ts +272 -0
- package/dist/sharing/index.js +4 -0
- package/dist/sharing/metafile-cjs.json +1 -0
- package/dist/sharing/metafile-esm.json +1 -0
- package/dist/skills/index.cjs +6 -0
- package/dist/skills/index.d.cts +277 -0
- package/dist/skills/index.d.ts +277 -0
- package/dist/skills/index.js +6 -0
- package/dist/skills/metafile-cjs.json +1 -0
- package/dist/skills/metafile-esm.json +1 -0
- package/dist/soul/index.cjs +32 -0
- package/dist/soul/index.d.cts +138 -0
- package/dist/soul/index.d.ts +138 -0
- package/dist/soul/index.js +32 -0
- package/dist/soul/metafile-cjs.json +1 -0
- package/dist/soul/metafile-esm.json +1 -0
- package/dist/terminal/index.cjs +4 -0
- package/dist/terminal/index.d.cts +55 -0
- package/dist/terminal/index.d.ts +55 -0
- package/dist/terminal/index.js +4 -0
- package/dist/terminal/metafile-cjs.json +1 -0
- package/dist/terminal/metafile-esm.json +1 -0
- package/dist/ui/index.cjs +35 -0
- package/dist/ui/index.d.cts +298 -0
- package/dist/ui/index.d.ts +298 -0
- package/dist/ui/index.js +35 -0
- package/dist/ui/metafile-cjs.json +1 -0
- package/dist/ui/metafile-esm.json +1 -0
- package/dist/utils/index.cjs +23 -0
- package/dist/utils/index.d.cts +245 -0
- package/dist/utils/index.d.ts +245 -0
- package/dist/utils/index.js +23 -0
- package/dist/utils/metafile-cjs.json +1 -0
- package/dist/utils/metafile-esm.json +1 -0
- package/native/mxc/LICENSE.microsoft-mxc-sdk.md +21 -0
- package/native/mxc/README.md +25 -0
- package/native/mxc/bin/arm64/lxc-exec +0 -0
- package/native/mxc/bin/arm64/mxc-exec-mac +0 -0
- package/native/mxc/bin/arm64/wxc-exec.exe +0 -0
- package/native/mxc/bin/arm64/wxc-host-prep.exe +0 -0
- package/native/mxc/bin/x64/lxc-exec +0 -0
- package/native/mxc/bin/x64/wxc-exec.exe +0 -0
- package/native/mxc/bin/x64/wxc-host-prep.exe +0 -0
- package/native/mxc/package.json +58 -0
- package/ownership/CLEAN_ROOM_CONTRIBUTOR_GUIDE.md +63 -0
- package/ownership/audit.mjs +727 -0
- package/ownership/evidence/PROPRIETARY-COMMAND-1/implementation-record.md +77 -0
- package/ownership/evidence/PROPRIETARY-COMMAND-1/provenance-review.md +51 -0
- package/ownership/evidence/PROPRIETARY-MEDIA-1/implementation-record.md +131 -0
- package/ownership/evidence/PROPRIETARY-MEDIA-1/provenance-review.md +50 -0
- package/ownership/evidence/PROPRIETARY-PTY-1/implementation-record.md +86 -0
- package/ownership/evidence/PROPRIETARY-PTY-1/provenance-review.md +52 -0
- package/ownership/evidence/PROPRIETARY-RUNTIME-1/implementation-record.md +68 -0
- package/ownership/evidence/PROPRIETARY-RUNTIME-1/provenance-review.md +32 -0
- package/ownership/evidence/PROPRIETARY-TOOLCHAIN-1/implementation-record.md +53 -0
- package/ownership/evidence/PROPRIETARY-TOOLCHAIN-1/provenance-review.md +32 -0
- package/ownership/evidence/PROPRIETARY-UI-1/implementation-record.md +96 -0
- package/ownership/evidence/PROPRIETARY-UI-1/provenance-review.md +46 -0
- package/ownership/ownership-policy.json +232 -0
- package/ownership/ownership-policy.schema.json +192 -0
- package/ownership/templates/clean-room-implementation-record.md +70 -0
- package/ownership/templates/provenance-review.md +51 -0
- package/package.json +209 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var X=2,R=1,p=1;var re=/(?:^|[_-])(api[_-]?key|access[_-]?token|refresh[_-]?token|id[_-]?token|auth(?:orization)?|bearer|secret|password|passwd|credential|cookie|private[_-]?key|client[_-]?secret)(?:$|[_-])/i,te=/\b([A-Z][A-Z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|API_KEY|PRIVATE_KEY|CLIENT_SECRET)[A-Z0-9_]*)\s*=\s*([^\s"']+)/g,ne=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,oe=/\b(?:sk-[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9_]{20,}|github_pat_[A-Za-z0-9_]{20,}|xox[baprs]-[A-Za-z0-9-]{16,}|AKIA[0-9A-Z]{16})\b/g,ie=/-----BEGIN (?:RSA |EC |OPENSSH |)PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH |)PRIVATE KEY-----/g,se=/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,ae=/([?&#](?:access_token|refresh_token|token|key|secret|password|api[_-]?key|signature)=)[^&#\s]+/gi;function v(e,r={}){let t={options:{...r,redactEmails:r.redactEmails??!0,maxDepth:r.maxDepth??48,maxStringLength:r.maxStringLength??2e5,maxEvents:r.maxEvents??256},seen:new Set,events:[],byCategory:{},total:0};return{value:b(e,"$","",0,t),report:{schemaVersion:1,total:t.total,byCategory:t.byCategory,events:t.events,eventsTruncated:t.total>t.events.length}}}function l(e,r,t){e.total+=1,e.byCategory[t]=(e.byCategory[t]??0)+1,e.events.length<e.options.maxEvents&&e.events.push({path:r,category:t})}function b(e,r,t,n,o){if(re.test(t))return e!=null&&e!==""&&l(o,r,"secret-field"),e==null||e===""?null:"[redacted]";if(n>o.options.maxDepth)return l(o,r,"truncated"),"[redacted:depth-limit]";if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:String(e);if(typeof e=="bigint")return e.toString();if(typeof e=="string")return ce(e,r,o);if(e instanceof Date)return e.toISOString();if(e instanceof Uint8Array)return l(o,r,"binary"),`[redacted:binary:${e.byteLength}-bytes]`;if(Array.isArray(e)){if(o.seen.has(e))return l(o,r,"cycle"),"[redacted:cycle]";o.seen.add(e);let i=e.map((s,a)=>b(s,`${r}[${a}]`,"",n+1,o));return o.seen.delete(e),i}if(e&&typeof e=="object"){if(o.seen.has(e))return l(o,r,"cycle"),"[redacted:cycle]";o.seen.add(e);let i={};for(let[s,a]of Object.entries(e))i[s]=b(a,`${r}.${ue(s)}`,s,n+1,o);return o.seen.delete(e),i}return null}function ce(e,r,t){let n=e;return n=u(n,ie,"[redacted:private-key]",r,"private-key",t),n=u(n,ne,"$1[redacted]",r,"authorization",t),n=u(n,oe,"[redacted:credential]",r,"credential-pattern",t),n=u(n,te,"$1=[redacted]",r,"environment-secret",t),n=u(n,ae,"$1[redacted]",r,"url-secret",t),t.options.redactEmails&&(n=u(n,se,"[redacted:email]",r,"email",t)),n=P(n,t.options.workspaceRoot,"<workspace>",r,"workspace-path",t),n=P(n,t.options.homeDirectory,"<home>",r,"home-path",t),n.length>t.options.maxStringLength&&(l(t,r,"truncated"),n=`${n.slice(0,t.options.maxStringLength)}
|
|
2
|
+
[truncated]`),n}function u(e,r,t,n,o,i){r.lastIndex=0;let s=0,a=e.replace(r,(...c)=>(s+=1,t.includes("$1")?t.replace("$1",String(c[1]??"")):t));for(let c=0;c<s;c+=1)l(i,n,o);return r.lastIndex=0,a}function P(e,r,t,n,o,i){let s=r?.trim().replace(/[\\/]+$/,"");if(!s)return e;let a=new RegExp(de(s).replace(/[\\/]+/g,"[\\\\/]"),process.platform==="win32"?"gi":"g");return u(e,a,t,n,o,i)}function de(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ue(e){return e.replace(/[^A-Za-z0-9_-]/g,"_")}import{createHash as C,createPrivateKey as le,createPublicKey as _,generateKeyPairSync as fe,randomBytes as ge,randomUUID as O,sign as he,timingSafeEqual as pe,verify as ye}from"node:crypto";function g(e){return JSON.stringify(k(e,new Set))}function k(e,r){if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new TypeError("Artifact JSON cannot contain non-finite numbers");return e}if(r.has(e))throw new TypeError("Artifact JSON cannot contain cycles");if(r.add(e),Array.isArray(e)){let n=e.map(o=>k(o,r));return r.delete(e),n}let t={};for(let n of Object.keys(e).sort((o,i)=>o.localeCompare(i))){let o=e[n];if(o===void 0)throw new TypeError(`Artifact JSON property ${n} is undefined`);t[n]=k(o,r)}return r.delete(e),t}function h(e,r={}){for(let t of e){let n=t.codePointAt(0);if(n===127)return!0;if(!(n>31)&&!(n===9&&r.allowTab===!0)&&!((n===10||n===13)&&r.allowLineBreaks===!0))return!0}return!1}var me=10080*60*1e3,Se=365*24*60*60*1e3;function tr(){let{publicKey:e,privateKey:r}=fe("ed25519"),t=e.export({type:"spki",format:"pem"}).toString(),n=r.export({type:"pkcs8",format:"pem"}).toString();return{keyId:T(t),publicKeyPem:t,privateKeyPem:n}}function T(e){let r=_(e).export({type:"spki",format:"der"});return`ed25519:${C("sha256").update(r).digest("hex").slice(0,32)}`}function nr(e){let r=e.now??new Date,t=r.toISOString(),n=N(r,e.expiresAt,e.ttlMs),o=ge(32).toString("base64url"),i=v(e.content,e.redaction),s=e.visibility??"private";xe(s,e.workspaceId,e.teamId,e.allowedPrincipalIds);let a={schemaVersion:2,kind:"xeno-secure-share",shareId:d(e.shareId??`share_${O()}`,"shareId"),createdAt:t,expiresAt:n,issuer:$(e.issuer),session:D({...e.session,name:e.session.name??e.name}),access:{mode:"read-only",visibility:s,...e.workspaceId?{workspaceId:d(e.workspaceId,"workspaceId")}:{},...e.teamId?{teamId:d(e.teamId,"teamId")}:{},...e.allowedPrincipalIds?.length?{allowedPrincipalIds:m(e.allowedPrincipalIds,"allowedPrincipalIds")}:{},capabilityToken:{algorithm:"sha256",hash:L(o)}},content:i.value,references:J(e.references??[]),redaction:i.report};return{envelope:Ie(a,e.signingIdentity),capabilityToken:o,url:Re(e.baseUrl,a.shareId,o)}}function Ie(e,r){if(r.keyId!==T(r.publicKeyPem))throw new Error("Signing identity keyId does not match public key");let t=V(e,r);return{payload:e,signature:t}}function or(e,r={}){let t=[],n=!1,o=!1;if(e?.payload?.kind!=="xeno-secure-share"||e.payload.schemaVersion!==2)t.push("Unsupported secure-share envelope");else{let x=K(r.trustedPublicKeys,e.signature.keyId),A=x??(r.allowEmbeddedPublicKey===!1?void 0:e.signature.publicKeySpki);if(o=!!x,!A)t.push("No trusted or embedded issuer public key is available");else try{n=H(e.payload,e.signature,A),n||t.push("Share signature is invalid")}catch(w){t.push(w instanceof Error?w.message:String(w))}}let i=(r.now??new Date).getTime(),s=Date.parse(e?.payload?.expiresAt??""),c=r.revokedShareIds?.has(e?.payload?.shareId??"")??!1?"revoked":Number.isFinite(s)&&s<=i?"expired":"active";c==="revoked"&&t.push("Share has been revoked"),c==="expired"&&t.push("Share has expired");let f=we(e?.payload,r.capabilityToken);f||t.push("Capability token is missing or invalid");let I=Xe(e?.payload,r.principal);return I||t.push("Principal is outside the share audience"),{valid:n&&f&&I&&c==="active",integrityValid:n,issuerTrusted:o,capabilityValid:f,audienceAllowed:I,status:c,errors:t}}function ir(e){let r=e.now??new Date,t={schemaVersion:1,kind:"xeno-session-handoff",handoffId:d(e.handoffId??`handoff_${O()}`,"handoffId"),createdAt:r.toISOString(),expiresAt:N(r,e.expiresAt,e.ttlMs??1440*60*1e3),issuer:$(e.issuer),source:D(e.source),target:be(e.target),resume:ke(e.resume),authority:Ee(e.authority),references:J(e.references??[]),...e.shareId?{shareId:d(e.shareId,"shareId")}:{}};return{payload:t,signature:V(t,e.signingIdentity)}}function sr(e,r={}){let t=[];if(e?.payload?.kind!=="xeno-session-handoff"||e.payload.schemaVersion!==1)return{valid:!1,integrityValid:!1,issuerTrusted:!1,expired:!1,errors:["Unsupported handoff envelope"]};let n=K(r.trustedPublicKeys,e.signature.keyId),o=n??(r.allowEmbeddedPublicKey===!1?void 0:e.signature.publicKeySpki),i=!!n,s=!1;if(!o)t.push("No trusted or embedded issuer public key is available");else try{s=H(e.payload,e.signature,o),s||t.push("Handoff signature is invalid")}catch(c){t.push(c instanceof Error?c.message:String(c))}let a=Date.parse(e.payload.expiresAt)<=(r.now??new Date).getTime();return a&&t.push("Handoff has expired"),{valid:s&&!a,integrityValid:s,issuerTrusted:i,expired:a,errors:t}}function V(e,r){let t=g(e),n=he(null,Buffer.from(t),le(r.privateKeyPem)).toString("base64");return{algorithm:"ed25519",keyId:r.keyId,value:n,publicKeySpki:r.publicKeyPem}}function H(e,r,t){if(r.algorithm!=="ed25519")return!1;let n=Buffer.from(r.value,"base64");if(n.toString("base64")!==r.value)throw new Error("Signature is not canonical base64");return ye(null,Buffer.from(g(e)),_(t),n)}function we(e,r){if(!e||!r)return!1;let t=Buffer.from(e.access.capabilityToken.hash,"hex"),n=Buffer.from(L(r),"hex");return t.length===n.length&&pe(t,n)}function Xe(e,r){if(!e)return!1;let t=e.access;return t.allowedPrincipalIds?.length&&(!r?.id||!t.allowedPrincipalIds.includes(r.id))?!1:t.visibility==="workspace"?!!(r?.workspaceId&&r.workspaceId===t.workspaceId):t.visibility==="team"?!!(t.teamId&&r?.teamIds?.includes(t.teamId)):t.visibility==="private"?!!(r?.id&&r.id===e.issuer.id):t.visibility==="link"}function Re(e,r,t){let n=new URL(e??"xeno://share/");if(n.username||n.password)throw new Error("Share base URL cannot contain credentials");if(n.protocol!=="https:"&&n.protocol!=="xeno:")throw new Error("Share base URL must use https: or xeno:");return n.pathname=`${n.pathname.replace(/\/$/,"")}/${encodeURIComponent(r)}`,n.search="",n.hash=new URLSearchParams({access_token:t}).toString(),n.toString()}function N(e,r,t=me){let n=r?new Date(r):new Date(e.getTime()+t);if(!Number.isFinite(n.getTime()))throw new Error("expiresAt must be a valid timestamp");let o=n.getTime()-e.getTime();if(o<=0)throw new Error("expiresAt must be in the future");if(o>Se)throw new Error("Share and handoff expiry cannot exceed 365 days");return n.toISOString()}function $(e){return{id:d(e.id,"issuer.id"),...e.displayName?.trim()?{displayName:e.displayName.trim().slice(0,160)}:{},...e.workspaceId?{workspaceId:d(e.workspaceId,"issuer.workspaceId")}:{},...e.teamId?{teamId:d(e.teamId,"issuer.teamId")}:{}}}function D(e){let r={name:y(e.name,"session.name",200),surface:e.surface};for(let t of["sessionId","runId","hostedRunId","conversationId","parentSessionId","forkedFromSessionId","forkedAtEventId"])e[t]&&(r[t]=d(e[t],`session.${t}`));if(!r.sessionId&&!r.runId&&!r.hostedRunId&&!r.conversationId)throw new Error("Session identity requires sessionId, runId, hostedRunId, or conversationId");return e.git&&(r.git={...e.git.repositoryId?{repositoryId:d(e.git.repositoryId,"git.repositoryId")}:{},...e.git.remoteUrl?{remoteUrl:E(e.git.remoteUrl,"git.remoteUrl")}:{},...e.git.branch?{branch:y(e.git.branch,"git.branch",300)}:{},...e.git.commit?{commit:q(e.git.commit,"git.commit")}:{},...e.git.pullRequest?{pullRequest:{provider:e.git.pullRequest.provider,repository:y(e.git.pullRequest.repository,"git.pullRequest.repository",300),number:Ae(e.git.pullRequest.number,"git.pullRequest.number"),...e.git.pullRequest.url?{url:E(e.git.pullRequest.url,"git.pullRequest.url")}:{}}}:{}}),r}function J(e){let r=new Set;return e.map(t=>{let n=`${t.kind}:${t.id}`;if(r.has(n))throw new Error(`Duplicate share reference: ${n}`);return r.add(n),{kind:t.kind,id:d(t.id,"reference.id"),...t.title?.trim()?{title:t.title.trim().slice(0,300)}:{},...t.uri?{uri:E(t.uri,"reference.uri")}:{},...t.hash?{hash:q(t.hash,"reference.hash")}:{}}})}function be(e){return{surface:e.surface,...e.workspaceId?{workspaceId:d(e.workspaceId,"target.workspaceId")}:{},...e.teamId?{teamId:d(e.teamId,"target.teamId")}:{},...e.environmentId?{environmentId:d(e.environmentId,"target.environmentId")}:{},...e.repositoryId?{repositoryId:d(e.repositoryId,"target.repositoryId")}:{}}}function ke(e){let r={};for(let t of["sessionId","runId","hostedRunId","checkpointId","transcriptEventId"])e[t]&&(r[t]=d(e[t],`resume.${t}`));if(e.artifactIds?.length&&(r.artifactIds=m(e.artifactIds,"resume.artifactIds")),e.taskIds?.length&&(r.taskIds=m(e.taskIds,"resume.taskIds")),!Object.keys(r).length)throw new Error("Handoff resume point cannot be empty");return r}function Ee(e){return{filesystem:e.filesystem,network:e.network,externalActions:e.externalActions,secretRefs:m(e.secretRefs,"authority.secretRefs")}}function xe(e,r,t,n){if(e==="workspace"&&!r)throw new Error("workspace visibility requires workspaceId");if(e==="team"&&!t)throw new Error("team visibility requires teamId");if(e==="private"&&n?.length)throw new Error("private shares cannot add allowed principals; use link/workspace/team visibility")}function K(e,r){if(!e)return;let t=e;return typeof t.get=="function"?t.get(r):e[r]}function L(e){return C("sha256").update(e).digest("hex")}function m(e,r){return[...new Set(e.map(t=>d(t,r)))].sort()}function d(e,r){let t=e.trim();if(!t||t.length>500||h(t))throw new Error(`${r} is invalid`);return t}function q(e,r){let t=e.trim();if(!/^[A-Za-z0-9:+._-]{7,256}$/.test(t))throw new Error(`${r} is invalid`);return t}function y(e,r,t){let n=e.trim();if(!n||n.length>t||h(n,{allowTab:!0,allowLineBreaks:!0}))throw new Error(`${r} is invalid`);return n}function Ae(e,r){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`${r} must be a positive integer`);return e}function E(e,r){let t=y(e,r,2e3),n=new URL(t);if(n.username||n.password)throw new Error(`${r} cannot contain credentials`);if(!["https:","xeno:","artifact:","urn:"].includes(n.protocol))throw new Error(`${r} uses an unsupported scheme`);return n.toString()}import{createHash as W}from"node:crypto";import{chmod as $e,mkdir as Q,open as De,readFile as Je,rename as Ke,unlink as Le}from"node:fs/promises";import{dirname as qe,join as F,resolve as Me}from"node:path";import{mkdirSync as Pe,readFileSync as ve,rmSync as U,writeFileSync as Ce}from"node:fs";import{hostname as j}from"node:os";import{dirname as _e}from"node:path";function Oe(){return new Date().toISOString()}function Te(){return new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString()}function B(e){try{return JSON.parse(ve(e,"utf8"))}catch{return null}}function Ve(e){if(!e||e<=0)return!1;try{return process.kill(e,0),!0}catch{return!1}}function He(e){return e.hostname!==j()?!0:Ve(e.pid)}function M(e,r){Pe(_e(e),{recursive:!0}),Ce(e,JSON.stringify(r,null,2)+`
|
|
3
|
+
`,{encoding:"utf8",flag:"wx"})}function Ne(e,r){let t=B(e);t?.pid!==r.pid||t.hostname!==r.hostname||U(e,{force:!0})}function z(e,r,t){let n=Oe(),o={schemaVersion:1,name:r,pid:process.pid,hostname:j(),processStartedAt:Te(),version:t,acquiredAt:n,updatedAt:n};try{M(e,o)}catch(i){if(i.code!=="EEXIST")throw i;let a=B(e);if(a&&He(a))throw new Error(`${r} is already locked by PID ${a.pid} on ${a.hostname}.`);U(e,{force:!0}),M(e,o)}return{record:o,release:()=>{Ne(e,o)}}}var Z=class{directory;snapshotPath;lockPath;now;constructor(r){this.directory=Me(r.directory),this.snapshotPath=F(this.directory,"registry.json"),this.lockPath=F(this.directory,"registry.lock"),this.now=r.now??(()=>new Date)}async register(r,t="created"){return this.mutate(n=>{let o=n.records.find(s=>s.shareId===r.payload.shareId);if(o){if(S(o.envelope)!==S(r))throw new Error(`Share ${r.payload.shareId} already exists with different content`);return{snapshot:n,result:o}}let i={shareId:r.payload.shareId,envelope:r,status:Date.parse(r.payload.expiresAt)<=this.now().getTime()?"expired":"active",registeredAt:this.now().toISOString(),origin:t};return{snapshot:Y(n,[...n.records,i],this.now()),result:i}})}async revoke(r,t,n){return this.mutate(o=>{let i=o.records.findIndex(f=>f.shareId===r);if(i<0)throw new Error(`Share not found: ${r}`);let s=o.records[i];if(s.status==="revoked")return{snapshot:o,result:s};let a={...s,status:"revoked",revokedAt:this.now().toISOString(),revokedBy:G(t,"actor"),revocationReason:G(n,"reason")},c=[...o.records];return c[i]=a,{snapshot:Y(o,c,this.now()),result:a}})}async get(r){return(await this.load()).records.find(t=>t.shareId===r)??null}async list(){let r=this.now().getTime();return(await this.load()).records.map(t=>t.status==="active"&&Date.parse(t.envelope.payload.expiresAt)<=r?{...t,status:"expired"}:t).sort((t,n)=>n.registeredAt.localeCompare(t.registeredAt))}async revokedIds(){return new Set((await this.list()).filter(r=>r.status==="revoked").map(r=>r.shareId))}async load(){try{let r=await Je(this.snapshotPath,"utf8"),t=JSON.parse(r);return je(t),t}catch(r){if(r.code==="ENOENT")return Ue(this.now());throw r}}async mutate(r){await Q(this.directory,{recursive:!0,mode:448});let t=z(this.lockPath,"xeno secure-share registry","1");try{let n=await this.load(),{snapshot:o,result:i}=r(n);return o!==n&&await Be(this.snapshotPath,`${JSON.stringify(o,null,2)}
|
|
4
|
+
`),i}finally{t.release()}}};function Ue(e){return ee({schemaVersion:1,generation:0,updatedAt:e.toISOString(),records:[]})}function Y(e,r,t){return ee({schemaVersion:1,generation:e.generation+1,updatedAt:t.toISOString(),records:[...r].sort((n,o)=>n.shareId.localeCompare(o.shareId))})}function ee(e){return{...e,checksum:{algorithm:"sha256",value:W("sha256").update(S(e)).digest("hex")}}}function je(e){if(e.schemaVersion!==1||!Array.isArray(e.records))throw new Error("Invalid secure-share registry snapshot");let{checksum:r,...t}=e,n=W("sha256").update(S(t)).digest("hex");if(r?.algorithm!=="sha256"||r.value!==n)throw new Error("Secure-share registry checksum mismatch");let o=new Set;for(let i of e.records){if(i.shareId!==i.envelope?.payload?.shareId)throw new Error("Secure-share registry identity mismatch");if(o.has(i.shareId))throw new Error(`Duplicate secure-share registry record: ${i.shareId}`);o.add(i.shareId)}}async function Be(e,r){await Q(qe(e),{recursive:!0,mode:448});let t=`${e}.${process.pid}.${Date.now()}.tmp`,n;try{n=await De(t,"wx",384),await n.writeFile(r,"utf8"),await n.sync(),await n.close(),n=void 0,await Ke(t,e),await $e(e,384).catch(()=>{})}finally{n&&await n.close().catch(()=>{}),await Le(t).catch(()=>{})}}function S(e){return g(e)}function G(e,r){let t=e.trim();if(!t||t.length>500||h(t))throw new Error(`${r} is invalid`);return t}export{Z as FileXenoShareRegistry,R as XENO_HANDOFF_SCHEMA_VERSION,p as XENO_SHARE_REGISTRY_SCHEMA_VERSION,X as XENO_SHARE_SCHEMA_VERSION,nr as createXenoSecureShare,ir as createXenoSessionHandoff,tr as createXenoShareSigningIdentity,T as publicKeyFingerprint,v as redactXenoShareValue,Ie as signSharePayload,or as verifyXenoSecureShare,sr as verifyXenoSessionHandoff};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/sharing/types.ts":{"bytes":5339,"imports":[],"format":"esm"},"src/sharing/redaction.ts":{"bytes":6891,"imports":[],"format":"esm"},"src/artifacts/hash.ts":{"bytes":1530,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/utils/text-security.ts":{"bytes":833,"imports":[],"format":"esm"},"src/sharing/protocol.ts":{"bytes":19752,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"../artifacts/hash.js"},{"path":"src/utils/text-security.ts","kind":"import-statement","original":"../utils/text-security.js"},{"path":"src/sharing/redaction.ts","kind":"import-statement","original":"./redaction.js"},{"path":"src/sharing/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/control-plane/lock.ts":{"bytes":2591,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/sharing/file-registry.ts":{"bytes":7468,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"../artifacts/hash.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"../control-plane/lock.js"},{"path":"src/utils/text-security.ts","kind":"import-statement","original":"../utils/text-security.js"},{"path":"src/sharing/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/sharing/index.ts":{"bytes":131,"imports":[{"path":"src/sharing/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/sharing/redaction.ts","kind":"import-statement","original":"./redaction.js"},{"path":"src/sharing/protocol.ts","kind":"import-statement","original":"./protocol.js"},{"path":"src/sharing/file-registry.ts","kind":"import-statement","original":"./file-registry.js"}],"format":"esm"}},"outputs":{"dist/sharing/index.cjs":{"imports":[{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/sharing/index.ts","inputs":{"src/sharing/index.ts":{"bytesInOutput":413},"src/sharing/types.ts":{"bytesInOutput":16},"src/sharing/redaction.ts":{"bytesInOutput":3216},"src/sharing/protocol.ts":{"bytesInOutput":9109},"src/artifacts/hash.ts":{"bytesInOutput":559},"src/utils/text-security.ts":{"bytesInOutput":179},"src/sharing/file-registry.ts":{"bytesInOutput":3496},"src/control-plane/lock.ts":{"bytesInOutput":1055}},"bytes":18796}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/sharing/types.ts":{"bytes":5339,"imports":[],"format":"esm"},"src/sharing/redaction.ts":{"bytes":6891,"imports":[],"format":"esm"},"src/artifacts/hash.ts":{"bytes":1530,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/utils/text-security.ts":{"bytes":833,"imports":[],"format":"esm"},"src/sharing/protocol.ts":{"bytes":19752,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"../artifacts/hash.js"},{"path":"src/utils/text-security.ts","kind":"import-statement","original":"../utils/text-security.js"},{"path":"src/sharing/redaction.ts","kind":"import-statement","original":"./redaction.js"},{"path":"src/sharing/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/control-plane/lock.ts":{"bytes":2591,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/sharing/file-registry.ts":{"bytes":7468,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"../artifacts/hash.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"../control-plane/lock.js"},{"path":"src/utils/text-security.ts","kind":"import-statement","original":"../utils/text-security.js"},{"path":"src/sharing/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/sharing/index.ts":{"bytes":131,"imports":[{"path":"src/sharing/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/sharing/redaction.ts","kind":"import-statement","original":"./redaction.js"},{"path":"src/sharing/protocol.ts","kind":"import-statement","original":"./protocol.js"},{"path":"src/sharing/file-registry.ts","kind":"import-statement","original":"./file-registry.js"}],"format":"esm"}},"outputs":{"dist/sharing/index.js":{"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"exports":["FileXenoShareRegistry","XENO_HANDOFF_SCHEMA_VERSION","XENO_SHARE_REGISTRY_SCHEMA_VERSION","XENO_SHARE_SCHEMA_VERSION","createXenoSecureShare","createXenoSessionHandoff","createXenoShareSigningIdentity","publicKeyFingerprint","redactXenoShareValue","signSharePayload","verifyXenoSecureShare","verifyXenoSessionHandoff"],"entryPoint":"src/sharing/index.ts","inputs":{"src/sharing/types.ts":{"bytesInOutput":16},"src/sharing/index.ts":{"bytesInOutput":0},"src/sharing/redaction.ts":{"bytesInOutput":3216},"src/sharing/protocol.ts":{"bytesInOutput":9080},"src/artifacts/hash.ts":{"bytesInOutput":559},"src/utils/text-security.ts":{"bytesInOutput":179},"src/sharing/file-registry.ts":{"bytesInOutput":3486},"src/control-plane/lock.ts":{"bytesInOutput":1041}},"bytes":17947}}}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";var D=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var me=(e,n)=>{for(var t in n)D(e,t,{get:n[t],enumerable:!0})},fe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ue(n))!de.call(e,r)&&r!==t&&D(e,r,{get:()=>n[r],enumerable:!(o=ae(n,r))||o.enumerable});return e};var pe=e=>fe(D({},"__esModule",{value:!0}),e);var Be={};me(Be,{XENO_SKILL_SCHEMA_VERSION:()=>S,compileXenoSkillActivation:()=>Ae,createXenoSkillTool:()=>Ie,discoverXenoSkills:()=>he,findXenoSkill:()=>O,importLegacyXenoSkill:()=>we,invokeXenoSkill:()=>te,isToolAllowedByXenoSkillActivation:()=>De,loadXenoSkill:()=>_,renderXenoSkillCatalog:()=>Xe});module.exports=pe(Be);var S=2;var q=require("node:crypto"),f=require("node:fs"),d=require("node:path");function $(e){let n=ye(e);return{frontmatter:n.frontmatter,content:n.content.trim()}}function ye(e){let n=e.replace(/^\uFEFF/,"");if(!n.startsWith("---"))return{frontmatter:{},content:e};let t=n.search(/\r?\n/);if(t<0||n.slice(0,t).trim()!=="---")return{frontmatter:{},content:e};let o=n.slice(t+(n[t]==="\r"?2:1)),r=o.match(/(?:^|\r?\n)---[ \t]*(?:\r?\n|$)/);if(!r||r.index===void 0)throw new Error("YAML frontmatter is not closed.");let i=o.slice(0,r.index),c=r[0],m=r.index+c.length;return{frontmatter:K(i),content:o.slice(m)}}function K(e){let n={},t=e.split(/\r?\n/);for(let o=0;o<t.length;o+=1){let r=t[o];if(!r.trim()||r.trimStart().startsWith("#"))continue;if(/^\s/.test(r))throw new Error(`Unexpected indentation at line ${o+1}.`);let i=ke(r,o+1);if(i.key==="<<")throw new Error("YAML merge keys are not supported.");if(i.value!==""){n[i.key]=M(i.value,o+1);continue}let c=ge(t,o+1);n[i.key]=c.value,o=c.nextIndex-1}return n}function ge(e,n){let t=[],o=n;for(;o<e.length;o+=1){let i=e[o];if(!i.trim()){t.push(i);continue}if(!/^\s/.test(i))break;t.push(i.replace(/^ {2}/,""))}let r=t.filter(i=>i.trim()&&!i.trimStart().startsWith("#"));return r.length===0?{value:{},nextIndex:o}:r.every(i=>i.trimStart().startsWith("- "))?{value:r.map((i,c)=>M(i.trimStart().slice(2),n+c+1)),nextIndex:o}:{value:K(t.join(`
|
|
2
|
+
`)),nextIndex:o}}function ke(e,n){let t=e.indexOf(":");if(t<=0)throw new Error(`Invalid YAML line ${n}.`);let o=e.slice(0,t).trim(),r=e.slice(t+1).trim();if(!o)throw new Error(`Invalid YAML key at line ${n}.`);return{key:o,value:r}}function M(e,n){if(e==="")return"";if(e==="[]")return[];if(e==="{}")return{};if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="~")return null;if(/^-?\d+(?:\.\d+)?$/.test(e))return Number(e);if(e.startsWith('"'))return j(e,n);if(e.startsWith("'")){if(!e.endsWith("'"))throw new Error(`Unclosed quoted scalar at line ${n}.`);return e.slice(1,-1).replace(/''/g,"'")}if(e.startsWith("[")||e.startsWith("{"))return j(e,n);if(e.includes("[")||e.includes("]")||e.includes("{")||e.includes("}"))throw new Error(`Unsupported YAML scalar at line ${n}.`);return e}function j(e,n){try{return JSON.parse(e)}catch{throw new Error(`Invalid YAML scalar at line ${n}.`)}}var P=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,Se=2e3,V=2*1024*1024,z=2e3,Y=64*1024*1024;function he(e){let n={maxSkills:E(e.maxSkills,Se,1,2e4),maxSkillBytes:E(e.maxSkillBytes,V,1024,16777216),maxResourceFiles:E(e.maxResourceFiles,z,0,2e4),maxResourceBytes:E(e.maxResourceBytes,Y,0,536870912)},t=[],o=[],r=new Set;for(let s of e.roots){if(o.length>=n.maxSkills)break;let l=(0,d.resolve)(s.path),a;try{if(!(0,f.statSync)(l,{throwIfNoEntry:!1})?.isDirectory())continue;a=(0,f.readdirSync)(l,{withFileTypes:!0}).sort((p,y)=>p.name.localeCompare(y.name))}catch(p){t.push({severity:"warning",code:"SKILL_ROOT_UNREADABLE",message:`Unable to inspect skill root: ${F(p)}`,path:l});continue}for(let p of a){if(o.length>=n.maxSkills)break;let y=(0,d.join)(l,p.name);try{let g=(0,f.lstatSync)(y);if(g.isSymbolicLink()&&!s.followSymlinks){t.push({severity:"warning",code:"SKILL_SYMLINK_REJECTED",message:"Skill directory symlinks require an explicitly trusted discovery root",path:y});continue}let u=g.isSymbolicLink()?(0,f.realpathSync)(y):y;if(!(0,f.statSync)(u).isDirectory())continue;let k=(0,f.realpathSync)(u);if(r.has(k))continue;let w=W(k,s,n,t);if(!w)continue;r.add(k),o.push(w.descriptor)}catch(g){t.push({severity:"error",code:"SKILL_INVALID",message:F(g),path:y})}}}let i=new Map;for(let s of o){let l=i.get(s.key)??[];l.push(s),i.set(s.key,l)}let c=[],m=[];for(let[s,l]of[...i].sort(([a],[p])=>a.localeCompare(p))){let a=l.sort((u,k)=>k.precedence-u.precedence||u.entrypoint.localeCompare(k.entrypoint)),p=a[0]?.precedence,y=a.filter(u=>u.precedence===p);if(y.length>1&&new Set(y.map(u=>u.contentHash)).size>1){t.push({severity:"error",code:"SKILL_AMBIGUOUS",key:s,message:`Skill ${s} has conflicting definitions at precedence ${p}; qualify or remove one definition`});continue}let g=a[0];c.push(g),a.length>1&&m.push({key:s,selected:g,shadowed:a.slice(1)})}return c.sort((s,l)=>s.key.localeCompare(l.key)),{schemaVersion:2,generatedAt:(e.now?.()??new Date).toISOString(),catalogHash:b(h(c.map(Le))),skills:c,shadowed:m,diagnostics:t}}function _(e){if(e.source==="legacy"){let r=$((0,f.readFileSync)(e.entrypoint,"utf8")).content.trim();if(J(e,r)!==e.contentHash)throw new Error(`Skill ${e.key} changed after discovery; refresh the catalog before invoking it`);return{descriptor:structuredClone(e),instructions:r}}let n=[],t=W(e.directory,{path:(0,d.dirname)(e.directory),source:e.source,precedence:e.precedence,...e.namespace?{namespace:e.namespace}:{},followSymlinks:!1},{maxSkills:1,maxSkillBytes:Math.max(V,e.instructionBytes),maxResourceFiles:Math.max(z,e.resources.length),maxResourceBytes:Math.max(Y,e.resources.reduce((o,r)=>o+r.sizeBytes,0))},n);if(!t||n.some(o=>o.severity==="error"))throw new Error(`Unable to load skill ${e.key}: ${n.map(o=>o.message).join("; ")||"invalid skill"}`);if(t.descriptor.contentHash!==e.contentHash)throw new Error(`Skill ${e.key} changed after discovery; refresh the catalog before invoking it`);return{descriptor:structuredClone(e),instructions:t.instructions}}function we(e){let n=e.id.trim().toLowerCase();if(!P.test(n)||n.length>64)throw new Error(`Legacy skill name is invalid: ${e.id}`);let t=e.content.trim();if(!t)throw new Error("Legacy skill content cannot be empty");let o=e.path?(0,d.dirname)((0,d.resolve)(e.path)):process.cwd(),r={schemaVersion:2,key:e.namespace?`${e.namespace}:${n}`:n,name:n,description:e.description?.trim()||e.name?.trim()||`Imported legacy XENO skill ${n}`,source:"legacy",precedence:e.precedence??0,directory:o,entrypoint:e.path?(0,d.resolve)(e.path):(0,d.join)(o,`${n}.md`),...e.namespace?{namespace:e.namespace}:{},...e.version?{version:e.version}:{},metadata:{"xeno.imported-from":e.source??"legacy"},modelInvocable:e.modelInvocable??!0,userInvocable:e.userInvocable??!0,requestedPreapprovedTools:[...new Set(e.allowedTools??[])].sort(),toolPolicy:G(e.toolPolicy),externalActions:e.externalActions??"ask",contentHash:"",instructionBytes:Buffer.byteLength(t,"utf8"),resources:[]};return r.contentHash=J(r,t),{descriptor:r,instructions:t}}function Xe(e){let n=e.skills.filter(t=>t.modelInvocable);return n.length===0?"":["<available_skills>",...n.flatMap(t=>[" <skill>",` <name>${U(t.key)}</name>`,` <description>${U(t.description)}</description>`,` <hash>${t.contentHash}</hash>`," </skill>"]),"</available_skills>","Use the Skill tool to load full instructions only when a listed skill is relevant."].join(`
|
|
3
|
+
`)}function O(e,n){let t=n.trim().toLowerCase();if(!t)return;let o=e.skills.find(i=>i.key.toLowerCase()===t);if(o)return o;let r=e.skills.filter(i=>i.name.toLowerCase()===t);return r.length===1?r[0]:void 0}function W(e,n,t,o){let r=(0,d.join)(e,"SKILL.md"),i=(0,f.lstatSync)(r,{throwIfNoEntry:!1});if(!i)return;if(i.isSymbolicLink()||!i.isFile())throw new Error("SKILL.md must be a regular, non-symlink file");if(i.size>t.maxSkillBytes)throw new Error(`SKILL.md exceeds ${t.maxSkillBytes} bytes`);let c=(0,f.readFileSync)(r,"utf8"),m=$(c),s=m.frontmatter,l=H(s.name,"name"),a=H(s.description,"description");if(!P.test(l)||l.length>64)throw new Error(`Skill name does not match ${P.source} or exceeds 64 characters`);if(l!==(0,d.basename)(e))throw new Error(`Skill name ${l} must match its parent directory ${(0,d.basename)(e)}`);if(a.length>1024)throw new Error("Skill description exceeds 1024 characters");let p=T(s.license,"license"),y=T(s.compatibility,"compatibility");if(y&&y.length>500)throw new Error("Skill compatibility exceeds 500 characters");let g=be(s.metadata,"metadata"),u=L(s.xeno),k=R(s["allowed-tools"]??s.allowedTools),w=G({allow:R(u?.["allowed-tools"]??u?.allowedTools??L(u?.tools)?.allow),deny:R(u?.["denied-tools"]??u?.deniedTools??L(u?.tools)?.deny)}),ie=ve(u?.["external-actions"]??u?.externalActions),se=!(x(s["disable-model-invocation"])??!1)&&(x(u?.modelInvocable)??!0),le=x(s["user-invocable"])??x(u?.userInvocable)??!0,B=xe(e,r,t,o),A=m.content.trim();if(!A)throw new Error("SKILL.md instructions cannot be empty");let ce=b(h({raw:c,resources:B.map(N=>({path:N.relativePath,sha256:N.sha256}))})),X=n.namespace?.trim();return{descriptor:{schemaVersion:2,key:X?`${X}:${l}`:l,name:l,description:a,source:n.source,precedence:n.precedence,directory:e,entrypoint:r,...X?{namespace:X}:{},...g.version?{version:g.version}:{},...p?{license:p}:{},...y?{compatibility:y}:{},metadata:g,modelInvocable:se,userInvocable:le,requestedPreapprovedTools:k,toolPolicy:w,externalActions:ie,contentHash:ce,instructionBytes:Buffer.byteLength(A,"utf8"),resources:B},instructions:A}}function xe(e,n,t,o){let r=[],i=0,c=m=>{for(let s of(0,f.readdirSync)(m,{withFileTypes:!0}).sort((l,a)=>l.name.localeCompare(a.name))){let l=(0,d.join)(m,s.name);if(l===n)continue;let a=(0,f.lstatSync)(l);if(a.isSymbolicLink()){o.push({severity:"warning",code:"SKILL_SYMLINK_REJECTED",message:"Skill resource symlinks are not included",path:l});continue}if(a.isDirectory()){c(l);continue}if(!a.isFile())continue;if(r.length>=t.maxResourceFiles)throw new Error(`Skill resource count exceeds ${t.maxResourceFiles}`);if(i+=a.size,i>t.maxResourceBytes)throw new Error(`Skill resources exceed ${t.maxResourceBytes} bytes`);let p=(0,d.relative)(e,l).split(d.sep).join("/");r.push({relativePath:p,kind:Ee(p),sizeBytes:a.size,sha256:b((0,f.readFileSync)(l))})}};return c(e),r.sort((m,s)=>m.relativePath.localeCompare(s.relativePath))}function Ee(e){let n=e.split("/",1)[0]?.toLowerCase();return n==="scripts"?"script":n==="references"?"reference":n==="assets"?"asset":n==="templates"?"template":"other"}function Le(e){return{key:e.key,source:e.source,precedence:e.precedence,contentHash:e.contentHash,modelInvocable:e.modelInvocable,userInvocable:e.userInvocable}}function J(e,n){return b(h({key:e.key,description:e.description,instructions:n,requestedPreapprovedTools:e.requestedPreapprovedTools,toolPolicy:e.toolPolicy,externalActions:e.externalActions}))}function G(e){let n=[...new Set(e?.allow?.map(o=>o.trim()).filter(Boolean)??[])].sort(),t=[...new Set(e?.deny?.map(o=>o.trim()).filter(Boolean)??[])].sort();return{...n.length>0?{allow:n}:{},...t.length>0?{deny:t}:{}}}function R(e){return typeof e=="string"?[...new Set(e.split(/\s+/u).map(n=>n.trim()).filter(Boolean))].sort():Array.isArray(e)?[...new Set(e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean))].sort():[]}function be(e,n){if(e===void 0)return{};let t=L(e);if(!t)throw new Error(`${n} must be a string-to-string mapping`);let o={};for(let[r,i]of Object.entries(t)){if(typeof i!="string")throw new Error(`${n}.${r} must be a string`);o[r]=i}return o}function H(e,n){let t=T(e,n);if(!t)throw new Error(`Skill ${n} is required`);return t}function T(e,n){if(e===void 0)return;if(typeof e!="string")throw new Error(`Skill ${n} must be a string`);let t=e.trim();if(!t)throw new Error(`Skill ${n} cannot be empty`);return t}function L(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function x(e){return typeof e=="boolean"?e:void 0}function ve(e){return e==="deny"||e==="allow"||e==="ask"?e:"ask"}function E(e,n,t,o){if(e===void 0)return n;if(!Number.isInteger(e)||e<t||e>o)throw new Error(`Skill discovery limit must be an integer between ${t} and ${o}`);return e}function h(e){return Array.isArray(e)?`[${e.map(h).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).filter(([,n])=>n!==void 0).sort(([n],[t])=>n.localeCompare(t)).map(([n,t])=>`${JSON.stringify(n)}:${h(t)}`).join(",")}}`:JSON.stringify(e)??"null"}function b(e){return(0,q.createHash)("sha256").update(e).digest("hex")}function U(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function F(e){return e instanceof Error?e.message:String(e)}var ne=require("node:crypto");var Q=128*1024;function Ie(e){return{definition:{name:"Skill",description:"Load one available SKILL.md instruction body on demand. Use only a name from <available_skills>.",input_schema:{type:"object",properties:{name:{type:"string",description:"Exact skill key or unique skill name"},arguments:{type:"string",description:"Optional arguments supplied to the skill"}},required:["name"],additionalProperties:!1}},projectPolicyInput:n=>({observabilityInput:{name:typeof n.name=="string"?n.name:"",hasArguments:typeof n.arguments=="string"&&n.arguments.length>0},permissionInput:{name:typeof n.name=="string"?n.name:""},permissionPreview:`Load skill ${typeof n.name=="string"?n.name:""}`,approvalKey:`skill:${typeof n.name=="string"?n.name:"unknown"}`,riskLevel:"low"}),execute:async n=>{let t=typeof n.name=="string"?n.name.trim():"",o=typeof n.arguments=="string"?n.arguments.trim():"";if(!t)return ee("SKILL_INVALID_INPUT","Skill name is required");try{return{success:!0,output:(await te({...e,name:t,arguments:o,invocation:"model"})).output}}catch(r){return ee("SKILL_INVOCATION_DENIED",C(r))}}}}async function te(e){let n=e.getCatalog(),t=O(n,e.name);if(!t)throw new Error(`Skill not found or ambiguous: ${e.name}`);let o=e.arguments?.trim()??"",r={schemaVersion:2,recordedAt:(e.now?.()??new Date).toISOString(),skillKey:t.key,skillHash:t.contentHash,invocation:e.invocation,...o?{argumentsHash:Oe(o)}:{}};try{let i=await Re(t,e.invocation,e);if(i==="deny")throw await v(e,{...r,type:"skill-denied",reason:"Invocation policy denied the skill"}),new Error(`Skill ${t.key} is denied by the active policy`);if(i==="ask"&&(!e.ask||!await e.ask(t)))throw await v(e,{...r,type:"skill-denied",reason:"User did not approve skill invocation"}),new Error(`Skill ${t.key} requires approval`);let c=await(e.loadSkill??_)(t);if(c.descriptor.contentHash!==t.contentHash)throw new Error(`Skill ${t.key} loader returned a mismatched content hash`);let m=re(e.invocationPolicy),s=oe(t,o,m);await e.onActivate?.(structuredClone(s));let l=$e(c,s,{arguments:o,projectDirectory:typeof e.projectDirectory=="function"?e.projectDirectory():e.projectDirectory});if(Buffer.byteLength(l,"utf8")>Q)throw new Error(`Skill ${t.key} exceeds the ${Q}-byte invocation limit; move details into references/`);return await v(e,{...r,type:"skill-invoked"}),{loaded:c,activation:s,output:l}}catch(i){throw/denied by the active policy|requires approval/u.test(C(i))||await v(e,{...r,type:"skill-load-failed",reason:C(i)}),i}}function Ae(e,n="",t){return oe(e,n,t)}function oe(e,n,t){let o=Z(t?.allow),r=Z(e.toolPolicy.allow),i=[o,r].filter(s=>s!==void 0),c=i.length<=1?i[0]:void 0,m=[...new Set([...e.toolPolicy.deny??[],...t?.deny??[]])].sort();return{descriptor:structuredClone(e),arguments:n,toolAllowLayers:i,...c?{effectiveAllowedTools:c}:{},effectiveDeniedTools:m,externalActions:Pe(e.externalActions,t?.externalActions??"allow")}}function De(e,n){return I(n,e.effectiveDeniedTools)?!1:e.toolAllowLayers.every(t=>I(n,t))}function $e(e,n,t){let o=e.descriptor,r=e.instructions,i=/\$ARGUMENTS(?:\[\d+\])?|\$\d+/u.test(r),c=_e(t.arguments);r=r.replace(/\$ARGUMENTS\[(\d+)\]/gu,(s,l)=>c[Number.parseInt(l,10)]??"").replace(/\$(\d+)\b/gu,(s,l)=>c[Number.parseInt(l,10)]??"").replace(/\$ARGUMENTS\b/gu,t.arguments).replace(/\$\{(?:XENO|CLAUDE)_SKILL_DIR\}/gu,o.directory).replace(/\$\{(?:XENO|CLAUDE)_PROJECT_DIR\}/gu,t.projectDirectory??process.cwd()),t.arguments&&!i&&(r+=`
|
|
4
|
+
|
|
5
|
+
ARGUMENTS: ${t.arguments}`);let m=o.resources.length>0?["","Bundled resources (load only when needed; paths are relative to the skill directory):",...o.resources.map(s=>`- ${s.relativePath} (${s.kind}, ${s.sizeBytes} bytes, sha256:${s.sha256})`)]:[];return[`<xeno_skill key="${Ce(o.key)}" hash="${o.contentHash}">`,`Source: ${o.source}`,`External actions: ${n.externalActions}`,...n.toolAllowLayers.map((s,l)=>`Tool allow layer ${l+1}: ${s.join(", ")||"none"}`),...n.effectiveDeniedTools.length>0?[`Denied tools: ${n.effectiveDeniedTools.join(", ")}`]:[],o.requestedPreapprovedTools.length>0?`Requested pre-approvals (not authority grants): ${o.requestedPreapprovedTools.join(", ")}`:"Requested pre-approvals: none","",r,...m,"</xeno_skill>"].join(`
|
|
6
|
+
`)}async function Re(e,n,t){if(n==="model"&&!e.modelInvocable||n==="user"&&!e.userInvocable)return"deny";let o=re(t.invocationPolicy);return I(e.key,o?.deny??[])||o?.allow&&!I(e.key,o.allow)?"deny":t.authorize?t.authorize(e,n):"allow"}function re(e){return typeof e=="function"?e():e}function Pe(e,n){let t={deny:0,ask:1,allow:2};return t[e]<=t[n]?e:n}function Z(e){if(e)return[...new Set(e.map(n=>n.trim()).filter(Boolean))].sort()}function I(e,n){let t=e.toLowerCase();return n.some(o=>{let r=o.trim().toLowerCase();return r?new RegExp(`^${r.split("*").map(Te).join(".*")}$`,"u").test(t):!1})}function Te(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _e(e){return(e.match(/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/gu)??[]).map(t=>t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t)}async function v(e,n){await e.onAudit?.(n)}function ee(e,n){return{success:!1,output:n,error:n,errorCode:e}}function Oe(e){return(0,ne.createHash)("sha256").update(e).digest("hex")}function Ce(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function C(e){return e instanceof Error?e.message:String(e)}0&&(module.exports={XENO_SKILL_SCHEMA_VERSION,compileXenoSkillActivation,createXenoSkillTool,discoverXenoSkills,findXenoSkill,importLegacyXenoSkill,invokeXenoSkill,isToolAllowedByXenoSkillActivation,loadXenoSkill,renderXenoSkillCatalog});
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
interface ToolDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
input_schema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: Record<string, unknown>;
|
|
7
|
+
required?: string[];
|
|
8
|
+
additionalProperties?: boolean | Record<string, unknown>;
|
|
9
|
+
[keyword: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface ImageUrlBlock {
|
|
13
|
+
type: "image_url";
|
|
14
|
+
image_url: {
|
|
15
|
+
url: string;
|
|
16
|
+
detail?: "auto" | "low" | "high";
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
interface ResourceContentBlock {
|
|
20
|
+
type: "resource";
|
|
21
|
+
uri?: string;
|
|
22
|
+
mimeType?: string;
|
|
23
|
+
text?: string;
|
|
24
|
+
data?: string;
|
|
25
|
+
}
|
|
26
|
+
type ToolAssistantContentBlock = TextBlock | ImageUrlBlock | ResourceContentBlock;
|
|
27
|
+
type ToolOperationState = "registered" | "starting" | "running_foreground" | "running_background" | "waiting_for_input" | "stalled" | "verifying" | "completed" | "failed" | "timed_out" | "cancelled" | "orphaned";
|
|
28
|
+
type ToolCompletionPolicy = "await" | "observe" | "detach";
|
|
29
|
+
interface ExpectedOutputContract {
|
|
30
|
+
path: string;
|
|
31
|
+
kind?: "file" | "directory";
|
|
32
|
+
nonEmpty?: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface ToolEvidence {
|
|
35
|
+
id: string;
|
|
36
|
+
kind: "artifact" | "process" | "verification";
|
|
37
|
+
status: "pending" | "verified" | "failed";
|
|
38
|
+
path?: string;
|
|
39
|
+
observedAt: string;
|
|
40
|
+
operationId: string;
|
|
41
|
+
detail?: Record<string, string | number | boolean | null>;
|
|
42
|
+
}
|
|
43
|
+
interface ToolOperationSnapshot {
|
|
44
|
+
schemaVersion: 1;
|
|
45
|
+
operationId: string;
|
|
46
|
+
turnId: string;
|
|
47
|
+
generation: number;
|
|
48
|
+
toolCallId: string;
|
|
49
|
+
toolName: string;
|
|
50
|
+
ownerSessionId?: string;
|
|
51
|
+
state: ToolOperationState;
|
|
52
|
+
terminal: boolean;
|
|
53
|
+
presentation: "foreground" | "background";
|
|
54
|
+
completionPolicy: ToolCompletionPolicy;
|
|
55
|
+
promotable: boolean;
|
|
56
|
+
processId?: string;
|
|
57
|
+
taskId?: string;
|
|
58
|
+
pid?: number;
|
|
59
|
+
commandFingerprint?: string;
|
|
60
|
+
outputPath?: string;
|
|
61
|
+
startedAt: string;
|
|
62
|
+
lastActivityAt: string;
|
|
63
|
+
deadlineAt?: string;
|
|
64
|
+
elapsedMs: number;
|
|
65
|
+
idleMs: number;
|
|
66
|
+
outputBytes: number;
|
|
67
|
+
nextOffset: number;
|
|
68
|
+
exitCode?: number | null;
|
|
69
|
+
completionReason?: string;
|
|
70
|
+
suggestedNextAction?: string;
|
|
71
|
+
expectedOutputs?: ExpectedOutputContract[];
|
|
72
|
+
evidence?: ToolEvidence[];
|
|
73
|
+
}
|
|
74
|
+
interface ToolProgressUpdate {
|
|
75
|
+
activity?: "stdout" | "stderr" | "input" | "waiting_for_input" | "heartbeat" | "state";
|
|
76
|
+
message?: string;
|
|
77
|
+
bytes?: number;
|
|
78
|
+
outputBytes?: number;
|
|
79
|
+
nextOffset?: number;
|
|
80
|
+
}
|
|
81
|
+
interface ToolAuthorizationReceipt {
|
|
82
|
+
turnId: string;
|
|
83
|
+
toolCallId: string;
|
|
84
|
+
toolName: string;
|
|
85
|
+
iteration: number;
|
|
86
|
+
policy: {
|
|
87
|
+
allowed: true;
|
|
88
|
+
reason: string;
|
|
89
|
+
temporaryOverride: boolean;
|
|
90
|
+
};
|
|
91
|
+
permission: {
|
|
92
|
+
allowed: true;
|
|
93
|
+
reason: string;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
interface ToolResult {
|
|
97
|
+
success: boolean;
|
|
98
|
+
output: string;
|
|
99
|
+
error?: string;
|
|
100
|
+
errorCode?: string;
|
|
101
|
+
errorDetails?: Record<string, unknown>;
|
|
102
|
+
assistantContent?: ToolAssistantContentBlock[];
|
|
103
|
+
assistantOnlyContent?: ToolAssistantContentBlock[];
|
|
104
|
+
operation?: ToolOperationSnapshot;
|
|
105
|
+
evidence?: ToolEvidence[];
|
|
106
|
+
retryable?: boolean;
|
|
107
|
+
}
|
|
108
|
+
interface ToolExecutionContext {
|
|
109
|
+
signal?: AbortSignal;
|
|
110
|
+
operationId?: string;
|
|
111
|
+
reportProgress?: (event: ToolProgressUpdate) => void;
|
|
112
|
+
authorization?: ToolAuthorizationReceipt;
|
|
113
|
+
}
|
|
114
|
+
type ToolExecutor = (input: Record<string, unknown>, context?: ToolExecutionContext) => Promise<ToolResult>;
|
|
115
|
+
interface ToolPolicyProjection {
|
|
116
|
+
observabilityInput: Record<string, unknown>;
|
|
117
|
+
permissionInput: Record<string, unknown>;
|
|
118
|
+
permissionPreview?: string;
|
|
119
|
+
approvalKey?: string;
|
|
120
|
+
riskLevel?: "low" | "medium" | "high";
|
|
121
|
+
}
|
|
122
|
+
interface RegisteredTool {
|
|
123
|
+
definition: ToolDefinition;
|
|
124
|
+
execute: ToolExecutor;
|
|
125
|
+
projectPolicyInput?: (input: Record<string, unknown>) => ToolPolicyProjection | {
|
|
126
|
+
error: ToolResult;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
interface TextBlock {
|
|
130
|
+
type: "text";
|
|
131
|
+
text: string;
|
|
132
|
+
}
|
|
133
|
+
declare const XENO_SKILL_SCHEMA_VERSION: 2;
|
|
134
|
+
type XenoSkillSource = "managed" | "built-in" | "user" | "project" | "plugin" | "compatible" | "legacy";
|
|
135
|
+
type XenoSkillExternalActionPolicy = "deny" | "ask" | "allow";
|
|
136
|
+
type XenoSkillInvocationDecision = "allow" | "ask" | "deny";
|
|
137
|
+
interface XenoSkillDiscoveryRoot {
|
|
138
|
+
path: string;
|
|
139
|
+
source: XenoSkillSource;
|
|
140
|
+
precedence: number;
|
|
141
|
+
namespace?: string;
|
|
142
|
+
followSymlinks?: boolean;
|
|
143
|
+
}
|
|
144
|
+
interface XenoSkillResourceDescriptor {
|
|
145
|
+
relativePath: string;
|
|
146
|
+
kind: "script" | "reference" | "asset" | "template" | "other";
|
|
147
|
+
sizeBytes: number;
|
|
148
|
+
sha256: string;
|
|
149
|
+
}
|
|
150
|
+
interface XenoSkillToolPolicy {
|
|
151
|
+
allow?: string[];
|
|
152
|
+
deny?: string[];
|
|
153
|
+
}
|
|
154
|
+
interface XenoSkillDescriptor {
|
|
155
|
+
schemaVersion: typeof XENO_SKILL_SCHEMA_VERSION;
|
|
156
|
+
key: string;
|
|
157
|
+
name: string;
|
|
158
|
+
description: string;
|
|
159
|
+
source: XenoSkillSource;
|
|
160
|
+
precedence: number;
|
|
161
|
+
directory: string;
|
|
162
|
+
entrypoint: string;
|
|
163
|
+
namespace?: string;
|
|
164
|
+
version?: string;
|
|
165
|
+
license?: string;
|
|
166
|
+
compatibility?: string;
|
|
167
|
+
metadata: Record<string, string>;
|
|
168
|
+
modelInvocable: boolean;
|
|
169
|
+
userInvocable: boolean;
|
|
170
|
+
requestedPreapprovedTools: string[];
|
|
171
|
+
toolPolicy: XenoSkillToolPolicy;
|
|
172
|
+
externalActions: XenoSkillExternalActionPolicy;
|
|
173
|
+
contentHash: string;
|
|
174
|
+
instructionBytes: number;
|
|
175
|
+
resources: XenoSkillResourceDescriptor[];
|
|
176
|
+
}
|
|
177
|
+
interface XenoSkillDiagnostic {
|
|
178
|
+
severity: "warning" | "error";
|
|
179
|
+
code: "SKILL_ROOT_UNREADABLE" | "SKILL_INVALID" | "SKILL_SYMLINK_REJECTED" | "SKILL_RESOURCE_LIMIT" | "SKILL_AMBIGUOUS";
|
|
180
|
+
message: string;
|
|
181
|
+
path?: string;
|
|
182
|
+
key?: string;
|
|
183
|
+
}
|
|
184
|
+
interface XenoSkillShadowRecord {
|
|
185
|
+
key: string;
|
|
186
|
+
selected: XenoSkillDescriptor;
|
|
187
|
+
shadowed: XenoSkillDescriptor[];
|
|
188
|
+
}
|
|
189
|
+
interface XenoSkillCatalog {
|
|
190
|
+
schemaVersion: typeof XENO_SKILL_SCHEMA_VERSION;
|
|
191
|
+
generatedAt: string;
|
|
192
|
+
catalogHash: string;
|
|
193
|
+
skills: XenoSkillDescriptor[];
|
|
194
|
+
shadowed: XenoSkillShadowRecord[];
|
|
195
|
+
diagnostics: XenoSkillDiagnostic[];
|
|
196
|
+
}
|
|
197
|
+
interface XenoLoadedSkill {
|
|
198
|
+
descriptor: XenoSkillDescriptor;
|
|
199
|
+
instructions: string;
|
|
200
|
+
}
|
|
201
|
+
interface XenoSkillDiscoveryOptions {
|
|
202
|
+
roots: XenoSkillDiscoveryRoot[];
|
|
203
|
+
maxSkills?: number;
|
|
204
|
+
maxSkillBytes?: number;
|
|
205
|
+
maxResourceFiles?: number;
|
|
206
|
+
maxResourceBytes?: number;
|
|
207
|
+
now?: () => Date;
|
|
208
|
+
}
|
|
209
|
+
interface XenoSkillInvocationPolicy {
|
|
210
|
+
allow?: string[];
|
|
211
|
+
deny?: string[];
|
|
212
|
+
externalActions?: XenoSkillExternalActionPolicy;
|
|
213
|
+
}
|
|
214
|
+
interface XenoSkillActivation {
|
|
215
|
+
descriptor: XenoSkillDescriptor;
|
|
216
|
+
arguments: string;
|
|
217
|
+
toolAllowLayers: string[][];
|
|
218
|
+
effectiveAllowedTools?: string[];
|
|
219
|
+
effectiveDeniedTools: string[];
|
|
220
|
+
externalActions: XenoSkillExternalActionPolicy;
|
|
221
|
+
}
|
|
222
|
+
interface XenoSkillAuditEvent {
|
|
223
|
+
schemaVersion: typeof XENO_SKILL_SCHEMA_VERSION;
|
|
224
|
+
type: "skill-invoked" | "skill-denied" | "skill-load-failed";
|
|
225
|
+
recordedAt: string;
|
|
226
|
+
skillKey: string;
|
|
227
|
+
skillHash: string;
|
|
228
|
+
invocation: "model" | "user";
|
|
229
|
+
argumentsHash?: string;
|
|
230
|
+
reason?: string;
|
|
231
|
+
}
|
|
232
|
+
interface CreateXenoSkillToolOptions {
|
|
233
|
+
getCatalog: () => XenoSkillCatalog;
|
|
234
|
+
loadSkill?: (descriptor: XenoSkillDescriptor) => XenoLoadedSkill | Promise<XenoLoadedSkill>;
|
|
235
|
+
invocationPolicy?: XenoSkillInvocationPolicy | (() => XenoSkillInvocationPolicy | undefined);
|
|
236
|
+
authorize?: (descriptor: XenoSkillDescriptor, invocation: "model" | "user") => XenoSkillInvocationDecision | Promise<XenoSkillInvocationDecision>;
|
|
237
|
+
ask?: (descriptor: XenoSkillDescriptor) => Promise<boolean>;
|
|
238
|
+
onActivate?: (activation: XenoSkillActivation) => void | Promise<void>;
|
|
239
|
+
onAudit?: (event: XenoSkillAuditEvent) => void | Promise<void>;
|
|
240
|
+
now?: () => Date;
|
|
241
|
+
projectDirectory?: string | (() => string);
|
|
242
|
+
}
|
|
243
|
+
type XenoSkillTool = RegisteredTool;
|
|
244
|
+
interface LegacyXenoSkillInput {
|
|
245
|
+
id: string;
|
|
246
|
+
name?: string;
|
|
247
|
+
description?: string;
|
|
248
|
+
content: string;
|
|
249
|
+
path?: string;
|
|
250
|
+
source?: Extract<XenoSkillSource, "user" | "project" | "plugin" | "legacy">;
|
|
251
|
+
precedence?: number;
|
|
252
|
+
namespace?: string;
|
|
253
|
+
version?: string;
|
|
254
|
+
allowedTools?: string[];
|
|
255
|
+
modelInvocable?: boolean;
|
|
256
|
+
userInvocable?: boolean;
|
|
257
|
+
toolPolicy?: XenoSkillToolPolicy;
|
|
258
|
+
externalActions?: XenoSkillExternalActionPolicy;
|
|
259
|
+
}
|
|
260
|
+
declare function discoverXenoSkills(options: XenoSkillDiscoveryOptions): XenoSkillCatalog;
|
|
261
|
+
declare function loadXenoSkill(descriptor: XenoSkillDescriptor): XenoLoadedSkill;
|
|
262
|
+
declare function importLegacyXenoSkill(input: LegacyXenoSkillInput): XenoLoadedSkill;
|
|
263
|
+
declare function renderXenoSkillCatalog(catalog: XenoSkillCatalog): string;
|
|
264
|
+
declare function findXenoSkill(catalog: XenoSkillCatalog, reference: string): XenoSkillDescriptor | undefined;
|
|
265
|
+
declare function createXenoSkillTool(options: CreateXenoSkillToolOptions): XenoSkillTool;
|
|
266
|
+
declare function invokeXenoSkill(options: CreateXenoSkillToolOptions & {
|
|
267
|
+
name: string;
|
|
268
|
+
arguments?: string;
|
|
269
|
+
invocation: "model" | "user";
|
|
270
|
+
}): Promise<{
|
|
271
|
+
loaded: XenoLoadedSkill;
|
|
272
|
+
activation: XenoSkillActivation;
|
|
273
|
+
output: string;
|
|
274
|
+
}>;
|
|
275
|
+
declare function compileXenoSkillActivation(descriptor: XenoSkillDescriptor, argumentsValue?: string, outerPolicy?: XenoSkillInvocationPolicy): XenoSkillActivation;
|
|
276
|
+
declare function isToolAllowedByXenoSkillActivation(activation: XenoSkillActivation, toolName: string): boolean;
|
|
277
|
+
export { type CreateXenoSkillToolOptions, type LegacyXenoSkillInput, XENO_SKILL_SCHEMA_VERSION, type XenoLoadedSkill, type XenoSkillActivation, type XenoSkillAuditEvent, type XenoSkillCatalog, type XenoSkillDescriptor, type XenoSkillDiagnostic, type XenoSkillDiscoveryOptions, type XenoSkillDiscoveryRoot, type XenoSkillExternalActionPolicy, type XenoSkillInvocationDecision, type XenoSkillInvocationPolicy, type XenoSkillResourceDescriptor, type XenoSkillShadowRecord, type XenoSkillSource, type XenoSkillTool, type XenoSkillToolPolicy, compileXenoSkillActivation, createXenoSkillTool, discoverXenoSkills, findXenoSkill, importLegacyXenoSkill, invokeXenoSkill, isToolAllowedByXenoSkillActivation, loadXenoSkill, renderXenoSkillCatalog };
|