blade-code 0.10.24 → 0.10.26
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/dist/blade.js +2 -2
- package/dist/chunk-01n8k1jj.js +1 -0
- package/dist/{chunk-1gkpjhts.js → chunk-0q4jbbm5.js} +1 -1
- package/dist/{chunk-9c3jjbgd.js → chunk-1g5h4zv6.js} +1 -1
- package/dist/{chunk-xzdpdwhz.js → chunk-1hzj6s0f.js} +2 -2
- package/dist/chunk-1mh2285d.js +200 -0
- package/dist/{chunk-26zhy301.js → chunk-20kg90zt.js} +2 -2
- package/dist/{chunk-18n15nn8.js → chunk-35d5gdgw.js} +1 -1
- package/dist/{chunk-f8zz4se0.js → chunk-46yg6dfr.js} +2 -2
- package/dist/{chunk-f4ksxskk.js → chunk-4aem0m2n.js} +1 -1
- package/dist/chunk-58tpe6nx.js +44 -0
- package/dist/{chunk-phzy5kqq.js → chunk-58yqrbey.js} +1 -1
- package/dist/{chunk-5xph8r1k.js → chunk-5mtryjjc.js} +1 -1
- package/dist/chunk-5yr2c8gz.js +25 -0
- package/dist/chunk-6axhk4r7.js +2 -0
- package/dist/chunk-6k74z0eb.js +2 -0
- package/dist/{chunk-yac1ga9w.js → chunk-6srz3q5d.js} +1 -1
- package/dist/{chunk-d2kzet1k.js → chunk-7jv8thn1.js} +2 -2
- package/dist/{chunk-3fkj59nv.js → chunk-89gswfb2.js} +1 -1
- package/dist/{chunk-w56y2pvk.js → chunk-8htfb5zn.js} +2 -2
- package/dist/{chunk-hpmxmkzc.js → chunk-9ka0bdry.js} +1 -1
- package/dist/{chunk-m13jrgp9.js → chunk-a4cyec1y.js} +2 -2
- package/dist/chunk-aa28p37g.js +2 -0
- package/dist/chunk-acf5v2fv.js +2 -0
- package/dist/chunk-b5fegjt7.js +6 -0
- package/dist/chunk-bbjtt28z.js +1 -0
- package/dist/{chunk-6vfe3409.js → chunk-ct2x59pr.js} +1 -1
- package/dist/chunk-d9jz1edf.js +100 -0
- package/dist/chunk-dxgzyy09.js +1 -0
- package/dist/{chunk-j8ggq1z4.js → chunk-ebffhjma.js} +2 -2
- package/dist/{chunk-bp886b8j.js → chunk-edyxa2jw.js} +1 -1
- package/dist/{chunk-k2b95m2p.js → chunk-eqa706gn.js} +2 -2
- package/dist/chunk-f88wkyfm.js +1 -0
- package/dist/{chunk-aw8s1sej.js → chunk-fbc5zfq7.js} +1 -1
- package/dist/chunk-fkwqgqsw.js +1 -0
- package/dist/{chunk-m27w377p.js → chunk-fnt1z0y8.js} +1 -1
- package/dist/chunk-gahvpbbs.js +1 -0
- package/dist/{chunk-57q5wn4g.js → chunk-gn37wxwg.js} +1 -1
- package/dist/chunk-h2npwqz9.js +10 -0
- package/dist/{chunk-c674mmtj.js → chunk-jt55ct49.js} +2 -2
- package/dist/{chunk-xjqcc0nt.js → chunk-k99rbzqw.js} +1 -1
- package/dist/{chunk-wjqctwyr.js → chunk-kskg7crs.js} +26 -41
- package/dist/{chunk-p1dp2xgq.js → chunk-kvd5nexw.js} +1 -1
- package/dist/chunk-kwe0a3xw.js +1 -0
- package/dist/chunk-m7x4ya6m.js +1 -0
- package/dist/chunk-mqsxghqb.js +1 -0
- package/dist/chunk-nar8qz5t.js +1 -0
- package/dist/{chunk-5sw8j9ae.js → chunk-nt6xmzk0.js} +1 -1
- package/dist/chunk-p6nhdbdw.js +116 -0
- package/dist/{chunk-67ekta7b.js → chunk-pja0tttq.js} +1 -1
- package/dist/{chunk-my2jwz6y.js → chunk-px3t1rxa.js} +2 -2
- package/dist/chunk-pyfag66h.js +1 -0
- package/dist/chunk-q1papzdc.js +1 -0
- package/dist/{chunk-pccn8ndq.js → chunk-r46ws0q8.js} +2 -2
- package/dist/{chunk-bw7vknjr.js → chunk-rgafk34p.js} +1 -1
- package/dist/chunk-rth3jfdq.js +2 -0
- package/dist/{chunk-nqpcwa0k.js → chunk-rtktz9v1.js} +233 -231
- package/dist/{chunk-s14wmzm3.js → chunk-s1khjfye.js} +2 -2
- package/dist/{chunk-vns8g2rv.js → chunk-sprjrvn6.js} +1 -1
- package/dist/chunk-ss449b56.js +1 -0
- package/dist/{chunk-yaxapgbm.js → chunk-tg1mf1tf.js} +1 -1
- package/dist/{chunk-x6tns9d8.js → chunk-tnrrnzzv.js} +1 -1
- package/dist/chunk-v508x7cg.js +0 -0
- package/dist/chunk-vc2c8wkx.js +2 -0
- package/dist/chunk-vp50e95n.js +3 -0
- package/dist/chunk-wg8p9g0z.js +1 -0
- package/dist/chunk-xkb48pvz.js +1 -0
- package/dist/{chunk-t327cwnb.js → chunk-xp44jtsd.js} +1 -1
- package/dist/chunk-y2en7qvs.js +6 -0
- package/dist/{chunk-86zsjamb.js → chunk-zs9mwd17.js} +3 -3
- package/dist/web/assets/{ChatView-CCxjYDmJ.js → ChatView-Crna6-ID.js} +2 -2
- package/dist/web/assets/{CodeBlockHighlighter-D9MqsrZP.js → CodeBlockHighlighter-coWjWCyT.js} +1 -1
- package/dist/web/assets/{FilePreview-Cn5HOlPw.js → FilePreview-BKcCbpvz.js} +2 -2
- package/dist/web/assets/{MarkdownRenderer-ALTOCdfi.js → MarkdownRenderer-BqV1nvf1.js} +3 -3
- package/dist/web/assets/{SettingsModal-Dk69F1bS.js → SettingsModal-BOMswk9P.js} +2 -2
- package/dist/web/assets/{TaskSwitcher-DRZZocE1.js → TaskSwitcher-BEW2DhW3.js} +1 -1
- package/dist/web/assets/{TerminalPanel-ByAqKZ47.js → TerminalPanel-BXzypTz6.js} +1 -1
- package/dist/web/assets/index-DqXKkjcp.js +11 -0
- package/dist/web/index.html +1 -1
- package/package.json +2 -1
- package/dist/chunk-014rwj5b.js +0 -1
- package/dist/chunk-0568ndm9.js +0 -200
- package/dist/chunk-1pkca2km.js +0 -3
- package/dist/chunk-2wpnzjme.js +0 -1
- package/dist/chunk-3ak60ndt.js +0 -1
- package/dist/chunk-3qmwt188.js +0 -100
- package/dist/chunk-4a02yjg9.js +0 -2
- package/dist/chunk-6pb6zs96.js +0 -2
- package/dist/chunk-7dqc10sc.js +0 -1
- package/dist/chunk-ag07wwer.js +0 -2
- package/dist/chunk-bpz0g8ej.js +0 -2
- package/dist/chunk-bvwq5wth.js +0 -6
- package/dist/chunk-c29y2s8g.js +0 -2
- package/dist/chunk-d70mtcp4.js +0 -1
- package/dist/chunk-e71qm105.js +0 -1
- package/dist/chunk-edqtngzr.js +0 -44
- package/dist/chunk-f0mt91sr.js +0 -1
- package/dist/chunk-gwe547ww.js +0 -1
- package/dist/chunk-m486vmtn.js +0 -1
- package/dist/chunk-n00mknme.js +0 -25
- package/dist/chunk-n54tp9wr.js +0 -1
- package/dist/chunk-pq7tk058.js +0 -6
- package/dist/chunk-q5sewfn5.js +0 -1
- package/dist/chunk-qg87zezq.js +0 -1
- package/dist/chunk-r14bz8va.js +0 -1
- package/dist/chunk-rtkhyp1g.js +0 -1
- package/dist/chunk-s4mqw4wa.js +0 -116
- package/dist/chunk-sgnjekfb.js +0 -1
- package/dist/chunk-tetxqw28.js +0 -1
- package/dist/chunk-vmzf4nvh.js +0 -2
- package/dist/chunk-zm3zn23k.js +0 -10
- package/dist/web/assets/index-CRCirUK7.js +0 -11
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{f as Q,g as R,h as T,i as W}from"./chunk-vp50e95n.js";import"./chunk-gn37wxwg.js";import"./chunk-edyxa2jw.js";import"./chunk-1g5h4zv6.js";import"./chunk-58yqrbey.js";import"./chunk-rtktz9v1.js";import"./chunk-tg1mf1tf.js";import"./chunk-89gswfb2.js";import"./chunk-1mh2285d.js";import"./chunk-4dnvydyv.js";import"./chunk-d9jz1edf.js";import"./chunk-p6nhdbdw.js";import"./chunk-ebffhjma.js";import{cd as M}from"./chunk-5yr2c8gz.js";import"./chunk-v508x7cg.js";import"./chunk-k99rbzqw.js";import"./chunk-46yg6dfr.js";import"./chunk-1hzj6s0f.js";import"./chunk-fnt1z0y8.js";import"./chunk-7jv8thn1.js";import"./chunk-kskg7crs.js";import"./chunk-5mtryjjc.js";import"./chunk-nt6xmzk0.js";import"./chunk-35d5gdgw.js";import"./chunk-zs9mwd17.js";import"./chunk-rth3jfdq.js";import"./chunk-58tpe6nx.js";import"./chunk-6axhk4r7.js";import"./chunk-9ka0bdry.js";import"./chunk-vc2c8wkx.js";import"./chunk-kvd5nexw.js";import"./chunk-8htfb5zn.js";import"./chunk-jt55ct49.js";import"./chunk-0q4jbbm5.js";import{Jf as J}from"./chunk-acf5v2fv.js";import"./chunk-r46ws0q8.js";import"./chunk-tnrrnzzv.js";import"./chunk-s1khjfye.js";import"./chunk-sprjrvn6.js";import b from"chalk";import H from"open";var $=`
|
|
2
|
+
____ _ _
|
|
3
|
+
| __ )| | __ _ __| | ___
|
|
4
|
+
| _ \\| |/ _\` |/ _\` |/ _ \\
|
|
5
|
+
| |_) | | (_| | (_| | __/
|
|
6
|
+
|____/|_|\\__,_|\\__,_|\\___|
|
|
7
|
+
`,E={command:"web",describe:"Start Blade server and open web interface",builder:Q,handler:async(X)=>{let F=R(X);if(await M(),!process.env.BLADE_SERVER_PASSWORD)console.log(b.yellow("[WARN] BLADE_SERVER_PASSWORD is not set; server is unsecured.")),console.log(b.gray(` Set this environment variable to enable Basic Auth.
|
|
8
|
+
`));let C=await W.listenAsync(F);if(console.log(b.cyan($)),console.log(b.gray(` v${J()}
|
|
9
|
+
`)),F.hostname==="0.0.0.0"){let q=`http://localhost:${C.port}`;console.log(b.blue.bold(" Local access: "),b.white(q));let Y=T();for(let Z of Y)console.log(b.blue.bold(" Network access: "),b.white(`http://${Z}:${C.port}`));H(q).catch(()=>{})}else{let q=C.url.toString();console.log(b.blue.bold(" Web interface: "),b.white(q)),H(q).catch(()=>{})}console.log(""),console.log(b.gray(` Press Ctrl+C to stop the server.
|
|
10
|
+
`)),await new Promise(()=>{}),await C.stop()}};export{E as webCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Df as N,Gf as M}from"./chunk-0q4jbbm5.js";import{Yf as H}from"./chunk-s1khjfye.js";import{createModels as _,createProvider as Y,envApiKeyAuth as x,getSupportedThinkingLevels as E}from"@earendil-works/pi-ai";import{anthropicMessagesApi as F}from"@earendil-works/pi-ai/api/anthropic-messages.lazy";import{openAICompletionsApi as U}from"@earendil-works/pi-ai/api/openai-completions.lazy";import{builtinProviders as P}from"@earendil-works/pi-ai/providers/all";var K=/^[a-z][a-z0-9._-]{0,63}$/,z=/^[A-Z_][A-Z0-9_]*$/,s=new Set(["openai-completions","anthropic-messages"]);function B(u){return typeof u==="string"&&s.has(u)}function X(u,$){let h=`modelProviders.${u}`,b=[];if(!K.test(u))b.push(`${h}: id must match ${K.source}`);if(!$.name?.trim())b.push(`${h}: name must not be empty`);if(!B($.wireApi))b.push(`${h}: wireApi must be openai-completions or anthropic-messages`);try{let w=new URL($.baseUrl);if(!["http:","https:"].includes(w.protocol))b.push(`${h}: baseUrl must be an absolute HTTP(S) URL`)}catch{b.push(`${h}: baseUrl must be an absolute HTTP(S) URL`)}if($.apiKeyEnv!==void 0&&!z.test($.apiKeyEnv))b.push(`${h}: apiKeyEnv must be a valid environment variable name`);if("apiKey"in $)b.push(`${h}: API keys must be stored separately in auth.json`);return b}function J(u,$){let h=$.trim().replace(/\/+$/,"");if(u==="anthropic-messages"&&/\/v1$/i.test(h))return h.slice(0,-3);return h}import{promises as Z}from"node:fs";import j from"node:path";import{Mutex as R}from"async-mutex";import T from"write-file-atomic";class Q{filePath;mutex=new R;constructor(u=j.join(H(),"auth.json")){this.filePath=u}async read(u){return(await this.readAll())[u]}async list(){let u=await this.readAll();return Object.entries(u).map(([$,h])=>({providerId:$,type:h.type}))}async modify(u,$){return this.mutex.runExclusive(async()=>{let h=await this.readAll(),b=h[u],w=await $(b);if(w===void 0)return b;return h[u]=w,await this.writeAll(h),w})}async delete(u){await this.mutex.runExclusive(async()=>{let $=await this.readAll();if(!(u in $))return;delete $[u],await this.writeAll($)})}async readAll(){try{let u=await Z.readFile(this.filePath,"utf8"),$=JSON.parse(u);return $&&typeof $==="object"&&!Array.isArray($)?$:{}}catch(u){if(u.code==="ENOENT")return{};throw u}}async writeAll(u){let $=j.dirname(this.filePath);await Z.mkdir($,{recursive:!0,mode:448}),await Z.chmod($,448),await T(this.filePath,`${JSON.stringify(u,null,2)}
|
|
2
2
|
`,{mode:384}),await Z.chmod(this.filePath,384)}}var q="openai-compatible",G="anthropic-compatible",D="https://api.openai.com/v1",V="https://api.anthropic.com",A=128000,C=32768,t={input:0,output:0,cacheRead:0,cacheWrite:0},f=["openai","anthropic","deepseek","google","moonshotai","moonshotai-cn","zai","zai-coding-cn"];class L{credentials;models;compatibleModels=new Map;anthropicCompatibleModels=new Map;customProviderConfigs=new Map;customProviderModels=new Map;reservedProviderIds=new Set;constructor(u=new Q){this.credentials=u,this.models=_({credentials:u});for(let $ of P())this.models.setProvider($);this.installOpenAICompatibleProvider(),this.installAnthropicCompatibleProvider();for(let $ of this.models.getProviders())this.reservedProviderIds.add($.id)}async listProviders(){return Promise.all(this.models.getProviders().map(async(u)=>{let $=u.getModels(),h=this.customProviderConfigs.get(u.id),b=this.getFactoryWireApi(u.id);return{id:u.id,name:u.name,modelCount:$.length,defaultBaseUrl:u.baseUrl??$[0]?.baseUrl,supportsApiKey:Boolean(u.auth.apiKey),supportsOAuth:Boolean(u.auth.oauth),configured:b?!1:Boolean(await this.models.checkAuth(u.id)),custom:Boolean(h),factoryWireApi:b,wireApi:h?.wireApi,apiKeyEnv:h?.apiKeyEnv}}))}listModels(u){return this.models.getModels(u).map(($)=>this.toCatalogEntry($))}getModel(u,$){let h=this.models.getModel(u,$);if(!h&&u===q)this.registerOpenAICompatibleModel($),h=this.models.getModel(u,$);if(!h&&u===G)this.registerAnthropicCompatibleModel($),h=this.models.getModel(u,$);if(!h&&this.customProviderConfigs.has(u))this.registerCustomProviderModel(u,$),h=this.models.getModel(u,$);if(!h)throw Error(`Unknown pi-ai model: ${u}/${$}`);return h}resolveConfig(u){let $=this.getModel(u.provider,u.model),h=u.overrides;return{...$,...h?.baseUrl?{baseUrl:J($.api,h.baseUrl)}:{},...h?.maxOutputTokens?{maxTokens:h.maxOutputTokens}:{}}}async setApiKey(u,$){this.requireProvider(u),await this.credentials.modify(u,async()=>({type:"api_key",key:$}))}async clearCredential(u){this.requireProvider(u),await this.credentials.delete(u)}async isConfigured(u){return this.requireProvider(u),Boolean(await this.models.checkAuth(u))}isReservedProviderId(u){return this.reservedProviderIds.has(u)}configureModelProviders(u,$){for(let h of this.customProviderConfigs.keys())this.models.deleteProvider(h);this.customProviderConfigs.clear(),this.customProviderModels.clear();for(let[h,b]of Object.entries(u)){let w=$.filter((k)=>k.provider===h).map((k)=>k.model);this.registerModelProvider(h,b,w)}}registerModelProvider(u,$,h=[]){if(this.isReservedProviderId(u))throw Error(`modelProviders.${u}: built-in provider ids cannot be overridden`);let b=X(u,$);if(b.length>0)throw Error(b.join("; "));let w={...$,name:$.name.trim(),baseUrl:J($.wireApi,$.baseUrl),...$.apiKeyEnv?{apiKeyEnv:$.apiKeyEnv.trim()}:{}};this.customProviderConfigs.set(u,w);let k=new Map;for(let y of new Set(h)){let W=y.trim();if(!W)continue;k.set(W,this.createCompatibleModel(u,W,w.wireApi,w.baseUrl))}this.customProviderModels.set(u,k),this.installCustomProvider(u)}unregisterModelProvider(u){if(!this.customProviderConfigs.has(u))return;this.customProviderConfigs.delete(u),this.customProviderModels.delete(u),this.models.deleteProvider(u)}requireProvider(u){if(!this.models.getProvider(u))throw Error(`Unknown pi-ai provider: ${u}`)}registerOpenAICompatibleModel(u){let $=u.trim();if(!$)throw Error("OpenAI-compatible model ID must not be empty");if(this.compatibleModels.has($))return;let h=this.createCompatibleModel(q,$,"openai-completions",D);this.compatibleModels.set($,h),this.installOpenAICompatibleProvider()}registerAnthropicCompatibleModel(u){let $=u.trim();if(!$)throw Error("Anthropic-compatible model ID must not be empty");if(this.anthropicCompatibleModels.has($))return;let h=this.createCompatibleModel(G,$,"anthropic-messages",V);this.anthropicCompatibleModels.set($,h),this.installAnthropicCompatibleProvider()}registerCustomProviderModel(u,$){let h=$.trim();if(!h)throw Error("Custom provider model ID must not be empty");let b=this.customProviderConfigs.get(u),w=this.customProviderModels.get(u);if(!b||!w||w.has(h))return;w.set(h,this.createCompatibleModel(u,h,b.wireApi,b.baseUrl)),this.installCustomProvider(u)}createCompatibleModel(u,$,h,b){let w=this.models.getModels().filter((y)=>y.provider!==u&&!this.customProviderConfigs.has(y.provider)&&y.id===$),k=f.flatMap((y)=>w.filter((W)=>W.provider===y))[0]??w[0];return{id:$,name:k?.name??$,api:h,provider:u,baseUrl:b,reasoning:k?.reasoning??!1,input:k?[...k.input]:["text"],cost:{...t},contextWindow:k?.contextWindow??A,maxTokens:k?.maxTokens??C,...k?.thinkingLevelMap?{thinkingLevelMap:{...k.thinkingLevelMap}}:{}}}installOpenAICompatibleProvider(){this.models.setProvider(Y({id:q,name:"Custom OpenAI Endpoint",baseUrl:D,auth:{apiKey:x("OpenAI-compatible API key",["OPENAI_COMPATIBLE_API_KEY","BLADE_API_KEY"])},models:[...this.compatibleModels.values()],api:U()}))}installAnthropicCompatibleProvider(){this.models.setProvider(Y({id:G,name:"Custom Anthropic Endpoint",baseUrl:V,auth:{apiKey:x("Anthropic-compatible API key",["ANTHROPIC_API_KEY","BLADE_API_KEY"])},models:[...this.anthropicCompatibleModels.values()],api:F()}))}installCustomProvider(u){let $=this.customProviderConfigs.get(u),h=this.customProviderModels.get(u);if(!$||!h)return;let b=$.apiKeyEnv?[$.apiKeyEnv]:[];this.models.setProvider(Y({id:u,name:$.name,baseUrl:$.baseUrl,auth:{apiKey:x(`${$.name} API key`,b)},models:[...h.values()],api:$.wireApi==="anthropic-messages"?F():U()}))}getFactoryWireApi(u){if(u===q)return"openai-completions";if(u===G)return"anthropic-messages";return}toCatalogEntry(u){return{id:u.id,name:u.name,provider:u.provider,api:u.api,baseUrl:u.baseUrl,reasoning:u.reasoning,supportedReasoningEfforts:E(u),supportedServiceTiers:M(u),supportedResponseVerbosities:N(u),input:[...u.input],contextWindow:u.contextWindow,maxTokens:u.maxTokens,cost:{...u.cost}}}}var S;function hu(){return S??=new L,S}
|
|
3
|
-
export{K as
|
|
3
|
+
export{K as xf,X as yf,J as zf,L as Af,hu as Bf};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{nanoid as q}from"nanoid";var u=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function B(j="session",m=21){if(!u.test(j))throw Error(`Invalid session ID prefix: ${j}`);return`${j}-${q(m)}`}
|
|
2
|
-
export{B as
|
|
2
|
+
export{B as nd};
|