@vibecontrols/agent 2026.601.30
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 +22 -0
- package/README.md +558 -0
- package/dist/agent-config-85pskv43.js +2 -0
- package/dist/agent-ready-tracker-zp6p8e6f.js +2 -0
- package/dist/app-yvjadjmh.js +2 -0
- package/dist/bootstrap-workspace-zpm20zez.js +2 -0
- package/dist/bootstrap.service-pjmnpxha.js +2 -0
- package/dist/bridge-client-341r9rry.js +2 -0
- package/dist/cli.js +5 -0
- package/dist/daemon-profile-vas1vf2t.js +2 -0
- package/dist/esm-9fpye77x.js +2 -0
- package/dist/finalize-retry-handle-registry-vv241fsq.js +2 -0
- package/dist/finalize-retry-worker-xp1nhv3c.js +2 -0
- package/dist/gateway-client-43gzvj5s.js +2 -0
- package/dist/getMachineId-bsd-a56s0v8c.js +2 -0
- package/dist/getMachineId-darwin-w9k0yw9r.js +3 -0
- package/dist/getMachineId-linux-anh31jbf.js +2 -0
- package/dist/getMachineId-unsupported-5hv3pwca.js +2 -0
- package/dist/getMachineId-win-njb8tery.js +2 -0
- package/dist/highlights-8d9mgr01.js +2 -0
- package/dist/highlights-eq9cgrbb.scm +604 -0
- package/dist/highlights-ghv9g403.scm +205 -0
- package/dist/highlights-hk7bwhj4.scm +284 -0
- package/dist/highlights-jwvdxm9x.js +2 -0
- package/dist/highlights-qbx2vnme.js +2 -0
- package/dist/highlights-r3m83kn9.js +2 -0
- package/dist/highlights-r812a2qc.scm +150 -0
- package/dist/highlights-s7mqapt6.js +2 -0
- package/dist/highlights-x6tmsnaa.scm +115 -0
- package/dist/index-01qzsnwd.js +16 -0
- package/dist/index-0248afsn.js +3 -0
- package/dist/index-04n4qgvd.js +407 -0
- package/dist/index-0ckffygp.js +5 -0
- package/dist/index-0cn9bv8z.js +4 -0
- package/dist/index-1hnw0rhc.js +178 -0
- package/dist/index-1zw3kea7.js +10 -0
- package/dist/index-2gsarrbn.js +4 -0
- package/dist/index-2xs9cvjn.js +28 -0
- package/dist/index-3ys16efc.js +231 -0
- package/dist/index-4wgjx8bf.js +3 -0
- package/dist/index-52cp759f.js +3 -0
- package/dist/index-5mw3eshk.js +4 -0
- package/dist/index-678rwfc0.js +5 -0
- package/dist/index-6jq17k9s.js +7 -0
- package/dist/index-6jzsthh9.js +3 -0
- package/dist/index-6mprnf7p.js +9 -0
- package/dist/index-8kvc8ttn.js +15 -0
- package/dist/index-8sm0nkh8.js +3 -0
- package/dist/index-9bqd8veb.js +21 -0
- package/dist/index-b5dhmybd.js +4 -0
- package/dist/index-c58g96mb.js +26 -0
- package/dist/index-cs78wq6y.js +3 -0
- package/dist/index-d5ysy1yn.js +3 -0
- package/dist/index-dm6yjmgq.js +3 -0
- package/dist/index-e1bw1bwr.js +4 -0
- package/dist/index-ef95xr4z.js +9 -0
- package/dist/index-g2raeeh4.js +11 -0
- package/dist/index-g3ap3xpr.js +5 -0
- package/dist/index-g8zv1gta.js +17 -0
- package/dist/index-h8a8s8sn.js +3 -0
- package/dist/index-hrdamx5j.js +2 -0
- package/dist/index-jw1k4vbk.js +3 -0
- package/dist/index-mtm8cfyt.js +158 -0
- package/dist/index-mxc61yr1.js +3 -0
- package/dist/index-n7qyrdr1.js +3 -0
- package/dist/index-qfz9fy56.js +3 -0
- package/dist/index-rc79x8fw.js +3 -0
- package/dist/index-rdp5xq4r.js +15 -0
- package/dist/index-scsjyj4m.js +171 -0
- package/dist/index-ssjmzqcz.js +13 -0
- package/dist/index-tmrbs96r.js +11 -0
- package/dist/index-tp4y9jde.js +83 -0
- package/dist/index-v9fx5wab.js +83 -0
- package/dist/index-vdahdt49.js +2 -0
- package/dist/index-x1h8r7pr.js +3 -0
- package/dist/index-xjzmb1pn.js +3 -0
- package/dist/index-yrgm89r8.js +3 -0
- package/dist/index-yy1mm8zs.js +3 -0
- package/dist/index-z5a4yxzz.js +8 -0
- package/dist/index.js +5 -0
- package/dist/injections-73j83es3.scm +27 -0
- package/dist/injections-srewsjcz.js +2 -0
- package/dist/interactive-22ta89hc.js +2 -0
- package/dist/key.cmd-wgcq6kt8.js +2 -0
- package/dist/log-shipper-k24m8yw5.js +2 -0
- package/dist/path-utils-35re7qf9.js +2 -0
- package/dist/plugin-system-c916v9an.js +2 -0
- package/dist/postinstall-shim-fix.cjs +382 -0
- package/dist/prereqs-runner-ca4kt803.js +2 -0
- package/dist/preuninstall.cjs +254 -0
- package/dist/profile-mount-npcknw6v.js +2 -0
- package/dist/prune-stale-shims-nkx9vq5m.js +2 -0
- package/dist/register-core-qrawzyym.js +2 -0
- package/dist/secondary-profile-attach-db5cr3e1.js +2 -0
- package/dist/subprocess-g9sk1ep9.js +2 -0
- package/dist/telemetry-tnq47dcs.js +2 -0
- package/dist/tree-sitter-javascript-3h25c6bs.js +2 -0
- package/dist/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
- package/dist/tree-sitter-markdown-3nemcjhe.js +2 -0
- package/dist/tree-sitter-markdown-411r6y9b.wasm +0 -0
- package/dist/tree-sitter-markdown_inline-16ftwa53.js +2 -0
- package/dist/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
- package/dist/tree-sitter-typescript-f6mq6ze6.js +2 -0
- package/dist/tree-sitter-typescript-zxjzwt75.wasm +0 -0
- package/dist/tree-sitter-zig-e78zbjpm.wasm +0 -0
- package/dist/tree-sitter-zig-s2trkm2d.js +2 -0
- package/dist/tunnel-bootstrap-2kg79ng8.js +2 -0
- package/package.json +122 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
; Query from: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/99ddf573531c4dbe53f743ecbc1595af5eb1d32f/queries/markdown_inline/highlights.scm
|
|
2
|
+
; From MDeiml/tree-sitter-markdown
|
|
3
|
+
(code_span) @markup.raw @nospell
|
|
4
|
+
|
|
5
|
+
(emphasis) @markup.italic
|
|
6
|
+
|
|
7
|
+
(strong_emphasis) @markup.strong
|
|
8
|
+
|
|
9
|
+
(strikethrough) @markup.strikethrough
|
|
10
|
+
|
|
11
|
+
(shortcut_link
|
|
12
|
+
(link_text) @nospell)
|
|
13
|
+
|
|
14
|
+
[
|
|
15
|
+
(backslash_escape)
|
|
16
|
+
(hard_line_break)
|
|
17
|
+
] @string.escape
|
|
18
|
+
|
|
19
|
+
; Conceal codeblock and text style markers
|
|
20
|
+
([
|
|
21
|
+
(code_span_delimiter)
|
|
22
|
+
(emphasis_delimiter)
|
|
23
|
+
] @conceal
|
|
24
|
+
(#set! conceal ""))
|
|
25
|
+
|
|
26
|
+
; Inline links - style all parts
|
|
27
|
+
(inline_link
|
|
28
|
+
["[" "(" ")"] @markup.link)
|
|
29
|
+
|
|
30
|
+
(inline_link
|
|
31
|
+
"]" @markup.link.bracket.close)
|
|
32
|
+
|
|
33
|
+
; Conceal opening bracket
|
|
34
|
+
((inline_link
|
|
35
|
+
"[" @conceal)
|
|
36
|
+
(#set! conceal ""))
|
|
37
|
+
|
|
38
|
+
; Conceal closing bracket with space replacement
|
|
39
|
+
((inline_link
|
|
40
|
+
"]" @conceal)
|
|
41
|
+
(#set! conceal " "))
|
|
42
|
+
|
|
43
|
+
; Conceal image links
|
|
44
|
+
(image
|
|
45
|
+
[
|
|
46
|
+
"!"
|
|
47
|
+
"["
|
|
48
|
+
"]"
|
|
49
|
+
"("
|
|
50
|
+
(link_destination)
|
|
51
|
+
")"
|
|
52
|
+
] @markup.link
|
|
53
|
+
(#set! conceal ""))
|
|
54
|
+
|
|
55
|
+
; Conceal full reference links
|
|
56
|
+
(full_reference_link
|
|
57
|
+
[
|
|
58
|
+
"["
|
|
59
|
+
"]"
|
|
60
|
+
(link_label)
|
|
61
|
+
] @markup.link
|
|
62
|
+
(#set! conceal ""))
|
|
63
|
+
|
|
64
|
+
; Conceal collapsed reference links
|
|
65
|
+
(collapsed_reference_link
|
|
66
|
+
[
|
|
67
|
+
"["
|
|
68
|
+
"]"
|
|
69
|
+
] @markup.link
|
|
70
|
+
(#set! conceal ""))
|
|
71
|
+
|
|
72
|
+
; Conceal shortcut links
|
|
73
|
+
(shortcut_link
|
|
74
|
+
[
|
|
75
|
+
"["
|
|
76
|
+
"]"
|
|
77
|
+
] @markup.link
|
|
78
|
+
(#set! conceal ""))
|
|
79
|
+
|
|
80
|
+
[
|
|
81
|
+
(link_destination)
|
|
82
|
+
(uri_autolink)
|
|
83
|
+
] @markup.link.url @nospell
|
|
84
|
+
|
|
85
|
+
[
|
|
86
|
+
(link_label)
|
|
87
|
+
(link_text)
|
|
88
|
+
(link_title)
|
|
89
|
+
(image_description)
|
|
90
|
+
] @markup.link.label
|
|
91
|
+
|
|
92
|
+
; Replace common HTML entities.
|
|
93
|
+
((entity_reference) @character.special
|
|
94
|
+
(#eq? @character.special " ")
|
|
95
|
+
(#set! conceal ""))
|
|
96
|
+
|
|
97
|
+
((entity_reference) @character.special
|
|
98
|
+
(#eq? @character.special "<")
|
|
99
|
+
(#set! conceal "<"))
|
|
100
|
+
|
|
101
|
+
((entity_reference) @character.special
|
|
102
|
+
(#eq? @character.special ">")
|
|
103
|
+
(#set! conceal ">"))
|
|
104
|
+
|
|
105
|
+
((entity_reference) @character.special
|
|
106
|
+
(#eq? @character.special "&")
|
|
107
|
+
(#set! conceal "&"))
|
|
108
|
+
|
|
109
|
+
((entity_reference) @character.special
|
|
110
|
+
(#eq? @character.special """)
|
|
111
|
+
(#set! conceal "\""))
|
|
112
|
+
|
|
113
|
+
((entity_reference) @character.special
|
|
114
|
+
(#any-of? @character.special " " " ")
|
|
115
|
+
(#set! conceal " "))
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Sb as jY}from"./index-d5ysy1yn.js";import{Ub as WY}from"./index-04n4qgvd.js";import{Rc as zY,Sc as A,nd as P,pd as JY}from"./index-g2raeeh4.js";import{Kd as HY,Ld as wY,Nd as V}from"./index-9bqd8veb.js";import{Xd as p}from"./index-0cn9bv8z.js";import{randomBytes as M,createHmac as E,timingSafeEqual as vY}from"crypto";var R=600,n=600,g=M(32),K="p2.";function S(Y){if(!Y.startsWith("/"))return`/${Y}`;return Y.length>1&&Y.endsWith("/")?Y.slice(0,-1):Y}var UY=/^\/terminal\/[A-Za-z0-9_-]{1,128}(?:\/.*)?$/,XY=/^\/ui\/[a-z0-9-]{1,64}(?:\/.*)?$/,NY=/^\/plan\/[A-Za-z0-9_-]{1,128}(?:\/.*)?$/,bY=/^\/git(?:\/.*)?$/,OY="/ws/logs",LY=/^\/code-server(?:\/.*)?$/,CY=/^\/api\/plugins\/[a-z0-9-]{1,64}\/ui(?:\/.*)?$/;function s(Y){if(typeof Y!=="string"||Y.length===0)return!1;if(Y.includes("\x00")||Y.includes(`
|
|
3
|
+
`)||Y.includes("|"))return!1;if(Y.includes(".."))return!1;if(new Set(["/","/api","/api/agent","/api/plugins","/api/profiles","/health","/metrics","/ws","/api/ai","/api/logs"]).has(Y))return!1;if(UY.test(Y))return!0;if(XY.test(Y))return!0;if(NY.test(Y))return!0;if(bY.test(Y))return!0;if(Y===OY)return!0;if(LY.test(Y))return!0;if(CY.test(Y))return!0;return!1}var DY=new Set(["*","GET","HEAD","POST","PUT","PATCH","DELETE","OPTIONS"]);function KY(Y){if(!Y||Y.length===0)return["*"];let Z=new Set,$=[];for(let Q of Y){if(typeof Q!=="string")continue;let W=Q.toUpperCase();if(!DY.has(W))throw Error(`invalid method: ${Q}`);if(!Z.has(W))Z.add(W),$.push(W)}if($.length===0)return["*"];return $.sort()}function r(Y,Z){if(Y.includes("*"))return!0;return Y.includes(Z.toUpperCase())}var MY=/^[A-Za-z0-9_-]{1,128}$/;function SY(Y){return typeof Y==="string"&&MY.test(Y)}function x(Y,Z,$){return E("sha256",g).update(`${Y}
|
|
4
|
+
${Z}
|
|
5
|
+
${$}`).digest("hex")}var y=new Map;function kY(Y){for(let[Z,$]of y)if($<=Y)y.delete(Z)}function a(Y,Z){let $=Date.parse(Z);if(!Number.isFinite($))return;y.set(Y,$)}function i(Y){return kY(Date.now()),y.has(Y)}function h(Y,Z,$,Q){return E("sha256",g).update(`v2
|
|
6
|
+
${Y}
|
|
7
|
+
${Z}
|
|
8
|
+
${$}
|
|
9
|
+
${Q}`).digest("hex")}function T(Y){return Buffer.from(Y,"utf8").toString("base64").replace(/=+$/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function I(Y){try{let Z=Y.replace(/-/g,"+").replace(/_/g,"/"),$=Z.length%4===0?Z:Z+"=".repeat(4-Z.length%4);return Buffer.from($,"base64").toString("utf8")}catch{return null}}var d=16;function qY(Y){if(Y.length>d)throw Error(`pathPrefixes exceeds maximum count (${Y.length} > ${d})`);let Z=new Set,$=[];for(let Q of Y){if(!Q||typeof Q!=="string")continue;if(Q.includes("..")||Q.includes("\x00"))throw Error("invalid pathPrefix");let W=S(Q);if(!s(W))throw Error(`pathPrefix '${W}' is not an allowed iframe surface`);if(!Z.has(W))Z.add(W),$.push(W)}return $.sort()}function nY(Y,Z=R){if(!Y||typeof Y!=="string")throw Error("pathPrefix is required");if(Y.includes("..")||Y.includes("\x00"))throw Error("invalid pathPrefix");let $=Math.min(Math.max(1,Math.floor(Z||R)),n),Q=S(Y);if(!s(Q))throw Error(`pathPrefix '${Q}' is not an allowed iframe surface`);let W=new Date(Date.now()+$*1000).toISOString(),z=M(16).toString("hex"),J=x(Q,W,z);return{token:`${W}|${z}|${J}`,expiresAt:W}}function sY(Y,Z=R){if(!Y||!Array.isArray(Y.pathPrefixes)||Y.pathPrefixes.length===0)throw Error("pathPrefixes is required");let $=qY(Y.pathPrefixes);if($.length===0)throw Error("pathPrefixes is required");let Q=KY(Y.methods),W=Math.min(Math.max(1,Math.floor(Z||R)),n),z=new Date(Date.now()+W*1000).toISOString(),J=M(16).toString("hex"),j=T(JSON.stringify($)),G=T(JSON.stringify(Q)),H=`${K}${j}.${G}`,w=h(j,G,z,J);return{token:`${z}|${J}|${H}|${w}`,expiresAt:z}}function L(Y,Z){if(Y.length!==Z.length)return!1;try{return vY(Buffer.from(Y,"hex"),Buffer.from(Z,"hex"))}catch{return!1}}function _(Y,Z){let $=S(Z);return Y===$||Y.startsWith(`${$}/`)}function t(Y,Z,$="*"){return FY(Y,Z,$).ok}function FY(Y,Z,$="*"){if(!Y||typeof Y!=="string")return{ok:!1,reason:"missing"};let Q=Y.split("|");if(Q.length===3)return RY(Q,Z);if(Q.length===4)return yY(Q,Z,$);return{ok:!1,reason:"malformed"}}function RY(Y,Z){let[$,Q,W]=Y;if(!$||!Q||!W)return{ok:!1,reason:"malformed"};if(!C($))return{ok:!1,reason:"expired"};let z=Z.split("/").filter(Boolean),J=["/"],j="";for(let G of z)j+=`/${G}`,J.push(j);for(let G of J){let H=x(S(G),$,Q);if(L(H,W)){if(!_(Z,G))return{ok:!1,reason:"path_mismatch"};if(i(Q))return{ok:!1,reason:"replayed"};return a(Q,$),{ok:!0}}}return{ok:!1,reason:"bad_signature"}}function yY(Y,Z,$){let[Q,W,z,J]=Y;if(!Q||!W||!z||!J)return{ok:!1,reason:"malformed"};if(!z.startsWith(K))return{ok:!1,reason:"malformed"};if(!C(Q))return{ok:!1,reason:"expired"};let G=z.slice(K.length).split("."),H=G[0]??"",w=G[1]??T(JSON.stringify(["*"]));if(!H)return{ok:!1,reason:"malformed"};let N=h(H,w,Q,W);if(!L(N,J))return{ok:!1,reason:"bad_signature"};let F=I(H);if(F===null)return{ok:!1,reason:"malformed"};let b;try{b=JSON.parse(F)}catch{return{ok:!1,reason:"malformed"}}if(!Array.isArray(b))return{ok:!1,reason:"malformed"};let O=I(w),D=["*"];if(O!==null)try{let B=JSON.parse(O);if(Array.isArray(B)&&B.every((v)=>typeof v==="string"))D=B}catch{return{ok:!1,reason:"malformed"}}if($!=="*"&&!r(D,$))return{ok:!1,reason:"method_mismatch"};for(let B of b){if(typeof B!=="string")continue;if(_(Z,B)){if(i(W))return{ok:!1,reason:"replayed"};return a(W,Q),{ok:!0}}}return{ok:!1,reason:"path_mismatch"}}function rY(Y,Z,$="*"){if(!Y||typeof Y!=="string")return!1;let Q=Y.split("|");if(Q.length===3){let[W,z,J]=Q;if(!W||!z||!J)return!1;if(!C(W))return!1;let j=Z.split("/").filter(Boolean),G=["/"],H="";for(let w of j)H+=`/${w}`,G.push(H);for(let w of G){let N=x(S(w),W,z);if(L(N,J))return _(Z,w)}return!1}if(Q.length===4){let[W,z,J,j]=Q;if(!W||!z||!J||!j)return!1;if(!J.startsWith(K))return!1;if(!C(W))return!1;let H=J.slice(K.length).split("."),w=H[0]??"",N=H[1]??T(JSON.stringify(["*"]));if(!w)return!1;let F=h(w,N,W,z);if(!L(F,j))return!1;let b=I(w);if(b===null)return!1;let O;try{O=JSON.parse(b)}catch{return!1}if(!Array.isArray(O))return!1;let D=I(N),B=["*"];if(D!==null)try{let v=JSON.parse(D);if(Array.isArray(v)&&v.every((BY)=>typeof BY==="string"))B=v}catch{return!1}if($!=="*"&&!r(B,$))return!1;for(let v of O){if(typeof v!=="string")continue;if(_(Z,v))return!0}return!1}return!1}function C(Y){let Z=Date.parse(Y);return Number.isFinite(Z)&&Date.now()<Z}function c(Y,Z){let $=Y.headers.get("x-vibe-iframe-token")??Y.headers.get("X-Vibe-Iframe-Token");if($)return $;try{let Q=new URL(Y.url).searchParams.get("vt");if(Q)return Q}catch{}return null}var u="tc1|",l=600,TY=600;function e(Y,Z,$){return E("sha256",g).update(`tc1
|
|
10
|
+
${Y}
|
|
11
|
+
${Z}
|
|
12
|
+
${$}`).digest("hex")}function aY(Y,Z=l){if(!SY(Y))throw Error("invalid sid");let $=Math.min(Math.max(1,Math.floor(Z||l)||l),TY),Q=new Date(Date.now()+$*1000).toISOString(),W=M(16).toString("hex"),z=e(Y,Q,W);return{token:`${u}${Q}|${Y}|${W}|${z}`,expiresAt:Q}}function iY(Y,Z){if(!Y||typeof Y!=="string")return!1;if(!Y.startsWith(u))return!1;let Q=Y.slice(u.length).split("|");if(Q.length!==4)return!1;let[W,z,J,j]=Q;if(!W||!z||!J||!j)return!1;if(z!==Z)return!1;if(!C(W))return!1;let G=e(z,W,J);return L(G,j)}function IY(Y,Z){let $;if(Y instanceof Headers)$=Y.get("cookie")??Y.get("Cookie")??void 0;else $=Y.cookie??Y.Cookie??void 0;if(!$)return null;let Q=`vt_term_${Z}`;for(let W of $.split(";")){let z=W.indexOf("=");if(z===-1)continue;if(W.slice(0,z).trim()!==Q)continue;return W.slice(z+1).trim()||null}return null}function tY(Y,Z){return IY(Y.headers,Z)}var f="uc1|",m=600,_Y=600,EY=/^[a-z0-9-]{1,64}$/;function gY(Y){return typeof Y==="string"&&EY.test(Y)}function YY(Y,Z,$){return E("sha256",g).update(`uc1
|
|
13
|
+
${Y}
|
|
14
|
+
${Z}
|
|
15
|
+
${$}`).digest("hex")}function eY(Y,Z=m){if(!gY(Y))throw Error("invalid plugin name");let $=Math.min(Math.max(1,Math.floor(Z||m)||m),_Y),Q=new Date(Date.now()+$*1000).toISOString(),W=M(16).toString("hex"),z=YY(Y,Q,W);return{token:`${f}${Q}|${Y}|${W}|${z}`,expiresAt:Q}}function YZ(Y,Z){if(!Y||typeof Y!=="string")return!1;if(!Y.startsWith(f))return!1;let Q=Y.slice(f.length).split("|");if(Q.length!==4)return!1;let[W,z,J,j]=Q;if(!W||!z||!J||!j)return!1;if(z!==Z)return!1;if(!C(W))return!1;let G=YY(z,W,J);return L(G,j)}function AY(Y,Z){let $;if(Y instanceof Headers)$=Y.get("cookie")??Y.get("Cookie")??void 0;else $=Y.cookie??Y.Cookie??void 0;if(!$)return null;let Q=`vt_ui_${Z}`;for(let W of $.split(";")){let z=W.indexOf("=");if(z===-1)continue;if(W.slice(0,z).trim()!==Q)continue;return W.slice(z+1).trim()||null}return null}function ZZ(Y,Z){return AY(Y.headers,Z)}import{timingSafeEqual as PY}from"crypto";var lY=["/health","/ui","/code-server","/terminal","/plan","/git","/api/agent/status","/api/agent/version","/api/agent/identity","/api/agent/terminal-exchange","/api/agent/ui-exchange","/api/agent/ui-exchange-plugin","/metrics"];function ZY(Y,Z){if(!Z||Z==="/")return!1;let $=Z.endsWith("/")?Z.slice(0,-1):Z;return Y===$||Y.startsWith(`${$}/`)}function mY(Y){let Z=Y.replace(/^\/api\/profiles\/[^/]+/,"/api");return Z==="/api"?"/":Z}function uY(Y){let Z=/^\/api\/profiles\/([^/]+)(?:\/|$)/.exec(Y);if(!Z)return null;let $=Z[1];if(!$)return null;return $}function $Y(Y,Z){let $=[Y],Q=mY(Y);if(Q!==Y)$.push(Q);for(let W of $){if(lY.some((z)=>ZY(W,z)))return!0;if(Z.some((z)=>ZY(W,z)))return!0}return!1}function GY(){let Y=new Uint8Array(32);return crypto.getRandomValues(Y),`vcak_${Buffer.from(Y).toString("base64url")}`}var U=null;function VY(){return`${p()}:static-api-key`}async function BZ(){let Y=process.env.AGENT_API_KEY;if(Y)return U=Y,Y;let Z=VY(),$=await zY(Z);if($)return U=$,$;let Q=P({dir:V().dataDir})["static-api-key"];if(Q){try{await A(Z,Q)}catch(z){V().logger.warn("auth","could not persist legacy api key into secrets backend",{error:String(z)})}return U=Q,Q}let W=GY();return await A(Z,W),U=W,V().logger.info("auth","Generated and persisted new agent API key"),V().audit.emit("agent","apikey.minted",{profile:p(),via:"loadAgentApiKey"}),W}function k(){let Y=process.env.AGENT_API_KEY;if(Y)return Y;if(U!==null)return U;let Z=P()["static-api-key"];if(Z)return U=Z,Z;let $=GY();U=$;try{JY({"static-api-key":$},{dir:V().dataDir,scope:V().name})}catch{}return A(VY(),$).catch(()=>{}),$}function fY(Y){let Z=Y["x-agent-api-key"]??Y["X-Agent-Api-Key"];if(Z)return Z;let $=Y.authorization??Y.Authorization;if($?.startsWith("Bearer "))return $.slice(7);return null}function xY(Y){return!1}function hY(Y,Z){let $=fY(Object.fromEntries(Y.headers.entries()));if($)return $;if(!xY(Z))return null;try{let Q=new URL(Y.url).searchParams.get("apiKey");if(Q)return Q}catch{}return null}function q(Y,Z){let $=Buffer.from(Y),Q=Buffer.from(Z);if($.length!==Q.length)return!1;try{return PY($,Q)}catch{return!1}}function vZ(Y){if(!Y)return!1;return q(Y,k())}async function cY(Y,Z){if(!Y)return!1;let $=uY(Z);if($){let Q=wY.get($);if(Q){try{if(await Q.keyVault.match(Y))return!0}catch{}if($===V().name){try{if(await V().keyVault.match(Y))return!0}catch{}return q(Y,k())}return!1}}try{if(await V().keyVault.match(Y))return!0}catch{}if(q(Y,k()))return!0;if(oY(Y)!==null)return!0;return!1}function oY(Y){if(!Y)return null;if(q(Y,k()))return{name:"default",scopes:new Set(["admin"])};let Z=HY()??V(),$=P({dir:Z.dataDir}),Q=Date.now();for(let W of $.apiKeys??[]){if(!q(Y,W.key))continue;if(W.notBefore){let z=Date.parse(W.notBefore);if(Number.isFinite(z)&&Q<z)return null}if(W.expiresAt){let z=Date.parse(W.expiresAt);if(Number.isFinite(z)&&Q>=z)return null}return{name:W.name,scopes:new Set(W.scopes)}}return null}function UZ(Y,Z){if(!Y)return!1;if(Y.scopes.has("admin"))return!0;return Z.some(($)=>Y.scopes.has($))}var X=null;function o(Y,Z){try{V().audit.emit("auth",Y,Z)}catch{V().logger.warn("auth.audit",Y,Z)}}function pY(Y){let Z=new Set(Y());if(X===null)for(let $ of Z)o("plugin.public_path.declared",{path:$});else{for(let $ of Z)if(!X.has($))o("plugin.public_path.added",{path:$});for(let $ of X)if(!Z.has($))o("plugin.public_path.removed",{path:$})}return X=Z,Z}function XZ(){X=null}function QY(Y){if(!Y)return[];if(X===null)return[...pY(Y)];return[...X]}function NZ(Y){let Z=k();return V().logger.info("auth",`Agent API key: ${Z.substring(0,8)}****${Z.substring(Z.length-4)}`),new WY({name:"plugin/auth"}).decorate("apiKey",Z).derive(async({request:$,path:Q})=>{let W=QY(Y),z;if($Y(Q,W))z=!0;else if(jY($.headers))z=!0;else{let J=c($,Q);if(J&&t(J,Q,$.method))z=!0;else{let j=hY($,Q);z=await cY(j,Q)}}return{isAuthenticated:z}}).onBeforeHandle(({isAuthenticated:$,request:Q,path:W,set:z})=>{let J=QY(Y);if(!$&&!$Y(W,J)){if(c(Q,W))return z.status=401,{error:"invalid iframe token"};return z.status=401,{error:"Unauthorized",message:"Invalid or missing API key"}}}).as("global")}
|
|
16
|
+
export{SY as tb,nY as ub,sY as vb,t as wb,FY as xb,rY as yb,c as zb,aY as Ab,iY as Bb,IY as Cb,tY as Db,gY as Eb,eY as Fb,YZ as Gb,ZZ as Hb,BZ as Ib,k as Jb,fY as Kb,vZ as Lb,oY as Mb,UZ as Nb,XZ as Ob,NZ as Pb};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{K as I}from"./index-2gsarrbn.js";import{Qb as G,Rb as D}from"./index-d5ysy1yn.js";import{Nd as H}from"./index-9bqd8veb.js";var j="prereqs-runner",q="plugin-mgr",v={status:null,install:null,satisfied:!0,pendingSudo:[],noProtocol:!0};function w(z,F){if(!z.apiPrefix)return null;return`${(z.apiPrefix.startsWith("/")?z.apiPrefix:`/${z.apiPrefix}`).replace(/\/+$/,"")}/prereqs${F}`}async function M(z,F,J){let Q=z.handle;if(typeof Q!=="function")return null;let Y=new Request(`http://agent.local${F}`,{method:J,headers:{"x-vc-profile-rewrite":"1",[G]:D()}}),K=await Q.call(z,Y);if(K.status===404)return null;if(!K.ok){let $=await K.text().catch(()=>"");throw Error(`prereqs ${J} ${F} \u2192 ${K.status} ${$}`)}return await K.json()}async function A(z,F,J,Q,Y={}){let K=w(z,"/status"),$=w(z,"/install");if(!K||!$)return v;let W=null;try{W=await M(J,K,"GET")}catch(V){H().logger.warn(j,`${z.name}: prereqs/status call failed`,{error:String(V)})}if(W===null)return v;if(W.satisfied||Y.skipInstall)return await x(Q,F,z.version,{status:W,install:null}),{status:W,install:null,satisfied:W.satisfied,pendingSudo:[],noProtocol:!1};let X=null;try{X=await M(J,$,"POST")}catch(V){H().logger.warn(j,`${z.name}: prereqs/install call failed`,{error:String(V)})}let B=W;try{let V=await M(J,K,"GET");if(V)B=V}catch{}if(await x(Q,F,z.version,{status:B,install:X}),X&&X.installed.length>0){let V=new Map;for(let Z of z.prerequisites??[])V.set(Z.name,Z.kind);I(F,X.installed.map((Z)=>({name:Z,kind:V.get(Z)??"binary"})))}return{status:B,install:X,satisfied:B.satisfied,pendingSudo:X?.pendingSudo??[],noProtocol:!1}}async function x(z,F,J,Q){if(!z)return;let Y=JSON.stringify({lastInstallAt:new Date().toISOString(),lastInstallVersion:J,satisfied:Q.status?.satisfied??!1,missing:Q.status?.missing??[],pendingSudo:Q.install?.pendingSudo??[]});try{await z.setPluginState(q,`prereqs:${F}`,Y)}catch(K){H().logger.warn(j,"Failed to persist prereq state",{packageName:F,error:String(K)})}}async function L(z,F){if(!z)return null;try{let J=await z.getPluginState(q,`prereqs:${F}`);return J?JSON.parse(J):null}catch{return null}}
|
|
3
|
+
export{A as d,L as e};
|