@chatpanel/gateway 0.39.11 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/chatpanel-gateway.js +4 -4
- package/package.json +2 -2
- package/src/recruiting.js +1 -1
- package/src/router.js +1 -1
- package/src/server.js +1 -1
package/bin/chatpanel-gateway.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
3
|
-
`)}process.argv.includes("--json")?console.log(JSON.stringify(
|
|
2
|
+
const o=process.argv[2],u={"--bridge":"chatpanel-bridge","--mcp-stdio":"chatpanel-bridge-mcp",mcp:"chatpanel-history-mcp","--extract-worker":"chatpanel-extract"};try{process.title=u[o]||"chatpanel-gateway"}catch{}try{if(o==="--extract-worker"){process.env.CHATPANEL_EXTRACT_WORKER_IMPORTED="1";const{runExtractWorker:e}=await import("../src/extract/worker.js");e()}else if(o==="--bridge")process.env.CHATPANEL_BRIDGE_EMBEDDED="1",process.argv.splice(2,1),await import("@chatpanel/bridge/src/server.js");else if(o==="--mcp-stdio")process.env.CHATPANEL_BRIDGE_EMBEDDED="1",await import("@chatpanel/bridge/src/server.js");else if(o==="mcp"){const{runMcpServer:e}=await import("../src/mcp.js");await e()}else if(o==="tools"||o==="call"){const{runMcpCli:e}=await import("../src/mcp-cli.js");process.exit(await e(process.argv.slice(2)))}else if(o==="policy"){const{loadPolicy:e,formatPolicy:s,PolicyLoadError:i}=await import("../src/policy.js");try{const r=await e();process.argv.includes("--json")?console.log(JSON.stringify(r?{...r,label:void 0}:null,null,2)):console.log(s(r))}catch(r){throw r instanceof i&&(console.error(`org policy: ${r.message}`),process.exit(78)),r}}else if(o==="--audit"){const{egressAudit:e,formatAudit:s}=await import("../src/egress.js"),{loadConfig:i}=await import("../src/config.js"),{readFileSync:r}=await import("node:fs"),{join:h}=await import("node:path"),l=await import("node:os"),c=i(),t=`http://127.0.0.1:${c.port||4320}`;let a=null,n=`no gateway running at ${t}`;try{const g=r(process.env.CHATPANEL_GATEWAY_TOKEN_PATH||h(l.homedir(),".chatpanel","gateway-token"),"utf8").trim(),p=await fetch(`${t}/audit`,{headers:{authorization:`Bearer ${g}`},signal:AbortSignal.timeout(2500)});if(p.ok)a=await p.json();else if(p.status===404){const d=await fetch(`${t}/health`,{signal:AbortSignal.timeout(2500)}).then(w=>w.json()).catch(()=>null);n=`the gateway running at ${t}${d?.version?` (${d.version})`:""} predates --audit (0.7.0) — restart it after updating`}else n=`the gateway at ${t} refused the audit (HTTP ${p.status}) — is ~/.chatpanel/gateway-token readable?`}catch{}if(!a){const{VERSION:g}=await import("../src/server.js");a={...e(c,{ledger:null,version:g}),observed:[]},console.log(`(${n}; showing what the current config allows)
|
|
3
|
+
`)}process.argv.includes("--json")?console.log(JSON.stringify(a,null,2)):console.log(s(a))}else if(o==="sandbox"){const{srtModuleUrl:e}=await import("../src/worker-sandbox.js");!process.env.CHATPANEL_SRT_MODULE&&e()&&(process.env.CHATPANEL_SRT_MODULE=e());const{runSandboxCli:s}=await import("@chatpanel/bridge/src/sandbox.js");process.exit(await s(process.argv.slice(3)))}else if(o==="pair"){const{loadConfig:e}=await import("../src/config.js"),{readFileSync:s}=await import("node:fs"),{join:i}=await import("node:path"),r=await import("node:os"),l=`http://127.0.0.1:${e().port||4320}`,c=process.env.CHATPANEL_GATEWAY_TOKEN_PATH||i(r.homedir(),".chatpanel","gateway-token");try{const t=s(c,"utf8").trim(),a=await fetch(`${l}/pair/code`,{method:"POST",headers:{authorization:`Bearer ${t}`},signal:AbortSignal.timeout(2500)}),n=await a.json().catch(()=>({}));if(a.status===404)throw new Error(`the gateway at ${l} predates pairing (0.9.0) — update and restart it`);if(!a.ok)throw new Error(n.error||`HTTP ${a.status}`);console.log(`Pairing code: ${n.display||n.code} (one use, expires in 5 minutes)`),console.log('Enter it in ChatPanel → Settings → Agent Tools → "Pairing code".')}catch(t){console.error(`could not get a pairing code from the gateway at ${l}: ${t?.message||t}${/ENOENT/.test(String(t?.message))?` (no token at ${c} — has the gateway started once?)`:""}`),process.exit(1)}}else if(o==="local"){const{localStatus:e,formatLocalStatus:s}=await import("../src/local-status.js");process.stdout.write(s(await e()))}else if(o==="connect"){const{connectAgents:e,formatConnect:s}=await import("../src/connect-agents.js"),i=process.argv.includes("--dry-run")||process.argv.includes("-n");process.stdout.write(s(e({dryRun:i}),{dryRun:i}))}else{const{start:e,VERSION:s}=await import("../src/server.js"),{installService:i,uninstallService:r,serviceReport:h,stopService:l,pathWithDir:c}=await import("../src/service.js");switch(o){case"--stop":l(),console.log("ChatPanel Gateway: stopped (auto-start is still registered; `--install` or a login starts it again).");break;case"--version":case"-v":console.log(s);break;case"--install":{const t=await i(),a=t.health;if(a.ok){const n=a.managedBy&&a.managedBy!=="gateway"?` — the ${a.managedBy} app's gateway is the one answering right now; this install takes over at the next login`:"";console.log(`ChatPanel Privacy Gateway v${a.version}: running at ${a.url}, starts at login${t.wsl?" (Windows login, through wsl.exe)":""}${n}.`)}else console.error(`ChatPanel Privacy Gateway: login auto-start is registered, but nothing answered at ${a.url} after 40 s.`),t.errLog&&console.error(` last of the error log:
|
|
4
4
|
${t.errLog.split(`
|
|
5
|
-
`).map(
|
|
6
|
-
`)}`),console.error(" `chatpanel-gateway --status` shows what is registered; running `chatpanel-gateway` in a terminal shows the start-up itself.");try{const{pruneForeignPrebuilds:
|
|
5
|
+
`).map(n=>` ${n}`).join(`
|
|
6
|
+
`)}`),console.error(" `chatpanel-gateway --status` shows what is registered; running `chatpanel-gateway` in a terminal shows the start-up itself.");try{const{pruneForeignPrebuilds:n,pruneLine:g}=await import("../src/prune-install.js"),p=g(n({log:d=>console.error(d)}));p&&console.log(p)}catch{}t.launcher==="powershell"&&console.log(" (VBScript is not installed here, so the login launcher is PowerShell — a console flashes for an instant at login.)"),t.path?.added?console.log(` Added ${t.path.dir} to your PATH — \`chatpanel-gateway\` works in a NEW terminal.`):t.path?.error?console.log(` Could not add ${t.path.dir} to your PATH (${t.path.error}) — add it yourself to run \`chatpanel-gateway\` by name.`):t.path?.dir&&t.wsl&&c(process.env.PATH||"",t.path.dir)!==null&&console.log(` Tip: add it to your PATH -> export PATH="${t.path.dir}:$PATH"`),a.ok||process.exit(1);break}case"--uninstall":r(),console.log("ChatPanel Privacy Gateway: removed login auto-start.");break;case"--status":console.log(await h());break;case void 0:await e();break;default:console.error(`unknown option: ${o}
|
|
7
7
|
Usage: chatpanel-gateway [mcp|tools list|tools schema <tool>|call <tool> '<json>'|local|connect|pair|policy|--audit|--install|--uninstall|--stop|--status|--version|--bridge]`),process.exit(2)}}}catch(e){console.error(`error: ${e.message}`),process.exit(1)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/gateway",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"description": "Local privacy gateway — redacts PII out of OpenAI/Anthropic API traffic before it reaches a model, then restores it in the reply. Point opencode, codex, aider, Claude Code, etc. at it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@anthropic-ai/sandbox-runtime": "^0.0.77",
|
|
25
25
|
"@chatpanel/bridge": "^0.20.1",
|
|
26
|
-
"@chatpanel/events": "^0.
|
|
26
|
+
"@chatpanel/events": "^0.190.0",
|
|
27
27
|
"@chatpanel/pii": "^0.11.0",
|
|
28
28
|
"@huggingface/transformers": "^4.2.0",
|
|
29
29
|
"defuddle": "^0.19.4",
|
package/src/recruiting.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{summarize as
|
|
1
|
+
import{summarize as h}from"./scorecard.js";import{applications as v,evaluatorPrompt as k,parseEvaluation as g,decide as M,recruitEvents as P,engineRows as S,MIN_FIT as A}from"./recruit.js";import{aggregateModelsAsync as E,listDestinations as F}from"./router.js";import{reachOfGatewayModel as D}from"@chatpanel/events/model-candidates.js";const N=new Set(["device","trusted","any"]);async function O(t,r,{jobKind:s=null,minCalls:n,timeoutMs:i=2500}={}){const l=await E(t,{timeoutMs:i}).catch(()=>({data:[]})),p=new Map(F(t).map(e=>[e.id,e])),c=(l.data||[]).map(e=>{const d=e.owned_by==="chatpanel-bridge",u=p.get(e.provider);return{id:e.id,model:e.id,kind:d?"bridge":"api",label:e.model?`${e.provider} · ${e.model}`:e.id,reach:D(e,u),capabilities:["tools"],available:e.configured===!1?!1:e.available!==!1}}),a=Object.fromEntries((r?.list?.({minCalls:n})||[]).map(e=>[e.key,e]));return S(c,{cards:a,minCalls:n,jobKind:s})}function R(t){const r=t?.get?.("agents")?.agents?.value;return(Array.isArray(r)?r:[]).filter(s=>s&&s.id&&s.enabled!==!1)}function q(t,r){const s={};for(const n of r){const i=t?.chains?.get?.(n.id);i?.length&&(s[n.id]=h(i))}return s}async function z(t,{cfg:r,prefsStore:s,scorecards:n,engines:i,reach:l="any",chatModel:p=null,now:c=Date.now()}={}){const a=R(s),e=await O(r,i),d=q(n,a),u=N.has(l)?l:"any",f=v(t,a,{summaries:d,rows:e,reach:u,chatModel:p,now:c});return{applications:f,prompt:k(t,f,a,{rows:e}),rows:e.map(o=>({key:o.key,label:o.label,reach:o.reach,quality:o.quality,costPer1k:o.costPer1k,latencyMs:o.latencyMs,available:o.available,observed:o.observed})),poolSize:a.length}}async function H(t,{cfg:r,prefsStore:s,scorecards:n,engines:i,record:l=null,reach:p="any",chatModel:c=null,evaluation:a=null,text:e=null,by:d="evaluator",minFit:u=A,now:f=Date.now()}={}){const{applications:o,prompt:b}=await z(t,{cfg:r,prefsStore:s,scorecards:n,engines:i,reach:p,chatModel:c,now:f});let y=null;e!=null?y=g(String(e),o):a&&typeof a=="object"&&(y=g(JSON.stringify({pick:a.pick,why:a.why,confidence:a.confidence,proposalName:a.proposal?.name,proposalPurpose:a.proposal?.purpose,proposalSkills:a.proposal?.skills,proposalGrants:a.proposal?.grants}),o));const m=M(t,o,{evaluation:y,minFit:u}),w=P(t,o,m,{by:m.by==="evaluator"?d:"fit",at:f,record:l});return{applications:o,evaluation:y,decision:m,events:w,prompt:b}}export{z as applicationsFor,R as poolFrom,H as recruitPass,O as rosterRows,q as summariesFrom};
|
package/src/router.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{secureFetch as
|
|
1
|
+
import{secureFetch as x}from"./secure-fetch.js";import{readBridgeToken as _,resolveBridgeUrl as S}from"./bridge.js";import{reachOfGatewayModel as M,agentModelReach as U}from"@chatpanel/events/model-candidates.js";const T=["codex","claude","opencode","pi","kiro","antigravity"];function b(t){const a=(Array.isArray(t.destinations)?t.destinations:[]).filter(Boolean),c=new Set(a.map(n=>n.id)),r=[...a.filter(n=>n.type==="agent"),...T.filter(n=>!c.has(n)).map(n=>({id:n,type:"agent",agent:n,models:[n]})),...a.filter(n=>n.type!=="agent")];return t.backend==="api"&&!a.some(n=>n.type==="api")&&(r.push({id:"openai",type:"api",protocol:"openai",baseUrl:t.upstreams?.openai?.baseUrl,models:[]}),r.push({id:"anthropic",type:"api",protocol:"anthropic",baseUrl:t.upstreams?.anthropic?.baseUrl,models:[]})),r}function H(t,a,c,{destination:r="",down:n=()=>!1}={}){const i=b(a),l=c==="anthropic",s=o=>(l?o.protocol==="anthropic":o.protocol!=="anthropic")&&!n(o);return r?i.find(o=>o.id===r)||null:t&&i.find(o=>Array.isArray(o.models)&&o.models.includes(t))||t&&i.find(o=>o.id===t||o.agent===t)||t&&t.includes("/")&&i.find(o=>o.type==="agent"&&(o.agent===t.slice(0,t.indexOf("/"))||o.id===t.slice(0,t.indexOf("/"))))||i.find(o=>a.backend==="bridge"?o.type==="agent":o.type==="api"&&s(o))||i.find(o=>(a.backend==="bridge"?o.type==="agent":o.type==="api")&&!n(o))||i.find(o=>!n(o))||null}function O(t){return t.type==="agent"?{api:"agent",endpoints:["/v1/chat/completions"]}:t.protocol==="anthropic"?{api:"anthropic",endpoints:["/v1/messages"]}:{api:"openai",endpoints:["/v1/chat/completions","/v1/responses"]}}const C=/^https?:\/\/(localhost|127\.0\.0\.1|\[::1\]|0\.0\.0\.0|[^/]*\.local)(:|\/|$)/i;function $(t){if(!t||t.type==="agent")return"";const a=String(t.baseUrl||"");return a?C.test(a)||t.apiKey||t.hasKey?"":`no API key is saved for ${t.id}`:"no endpoint URL is set for this provider"}function B(t){const a=[],c=new Set,r=(n,i,l)=>{if(!n||c.has(n))return;c.add(n);const s=O(l),o=$(l);a.push({id:n,object:"model",owned_by:i,...o?{configured:!1,reason:o}:{},provider:l.id,provider_type:l.type==="agent"?"agent":l.protocol==="anthropic"?"anthropic":"openai",api:s.api,endpoints:s.endpoints,reach:M({id:n,owned_by:i,provider_type:l.type==="agent"?"agent":"openai"},l)})};for(const n of b(t))if(n.type==="agent")for(const i of n.models?.length?n.models:[n.id])r(i,"chatpanel-bridge",n);else for(const i of n.models||[])r(i,n.id,n);return{object:"list",data:a}}async function K(t,a,c){const r=await S(t);if(!r||!a)return new Map;const n=_(t.bridge?.token),i=[...a.entries()].filter(([,s])=>s).map(([s])=>s),l=new Map;return await Promise.all(i.map(async s=>{try{const o=await fetch(`${r}/list-models`,{method:"POST",headers:{"content-type":"application/json",...n?{Authorization:`Bearer ${n}`}:{}},body:JSON.stringify({agent:s}),signal:AbortSignal.timeout(c)});if(!o.ok)return;const d=await o.json(),w=(Array.isArray(d?.models)?d.models:[]).map(e=>typeof e=="string"?e:e?.id||e?.name||"").map(e=>String(e).trim()).filter(Boolean);w.length&&l.set(s,w.slice(0,40))}catch{}})),l}async function N(t,a){const c=await S(t);if(!c)return null;try{const r=_(t.bridge?.token),n=await fetch(`${c}/health`,{headers:{Accept:"application/json",...r?{Authorization:`Bearer ${r}`}:{}},signal:AbortSignal.timeout(a)});if(!n.ok)return null;const i=await n.json();if(!Array.isArray(i?.agents))return null;const l=new Map(i.agents.map(s=>[s.id,!!s.available]));return l.noTools=new Set(i.agents.filter(s=>s.tools===!1).map(s=>s.id)),l}catch{return null}}const D=Number(process.env.CHATPANEL_MODELS_CACHE_MS)||6e4;let f={at:0,key:"",value:null,inflight:null};function E(t){try{return JSON.stringify([b(t).map(a=>[a.id,a.type,a.baseUrl,a.models]),t.bridge?.url||""])}catch{return String(Date.now())}}function F(){f={at:0,key:"",value:null,inflight:null}}async function G(t,{timeoutMs:a=4e3,fresh:c=!1,now:r=Date.now,serviceHealth:n=null}={}){const i=E(t),l=f.value&&f.key===i,s=!l||r()-f.at>D;if(l&&!c&&!s)return f.value;const o=()=>(f.inflight||(f.inflight=L(t,{timeoutMs:a,serviceHealth:n}).then(d=>(f={at:r(),key:i,value:d,inflight:null},d)).catch(d=>{throw f.inflight=null,d})),f.inflight);return l&&!c?(o().catch(()=>{}),f.value):o()}async function L(t,{timeoutMs:a=4e3,serviceHealth:c=null}={}){const r=B(t),n=new Set(r.data.map(e=>e.id)),i=c?await c():null,l=new Map(b(t).filter(e=>e.service).map(e=>[e.id,e.service])),s=e=>{if(l.get(e.owned_by)&&i){const y=i(e.owned_by);y!=="unknown"&&(e.available=y==="up");const p=typeof i.window=="function"?i.window(e.owned_by):null;p&&(e.context_window=p);const u=typeof i.card=="function"?i.card(e.owned_by):null;u&&(e.card=u)}return e};for(const e of r.data)s(e);const o=await N(t,a);if(o){r.data=r.data.filter(e=>e.owned_by!=="chatpanel-bridge"||o.get(e.id)!==!1);for(const e of r.data)e.owned_by==="chatpanel-bridge"&&(e.available=o.get(e.id)??!1,o.noTools?.has(e.id)&&(e.tools=!1))}const d=await K(t,o,a);for(const[e,h]of d){const y=r.data.find(p=>p.id===e);if(y)for(const p of h){const u=`${e}/${p}`;n.has(u)||(n.add(u),r.data.push({...y,id:u,model:p,available:!0,reach:U(p)}))}}const w=b(t).filter(e=>e.type==="api"&&e.baseUrl);return await Promise.all(w.map(async e=>{const h=new AbortController,y=setTimeout(()=>h.abort(),a);try{const p={"content-type":"application/json"};e.apiKey&&(e.protocol==="anthropic"?(p["x-api-key"]=e.apiKey,p["anthropic-version"]="2023-06-01"):p.authorization=`Bearer ${e.apiKey}`);const u=await x(`${e.baseUrl.replace(/\/$/,"")}/models`,{headers:p,signal:h.signal});if(!u.ok)return;const m=await u.json(),j=Array.isArray(m?.data)?m.data:Array.isArray(m?.models)?m.models:[];for(const v of j){const g=typeof v=="string"?v:v?.id;if(g&&!n.has(g)){n.add(g);const A=O(e),k=$(e);r.data.push(s({id:g,object:"model",owned_by:e.id,provider:e.id,provider_type:e.protocol==="anthropic"?"anthropic":"openai",api:A.api,endpoints:A.endpoints,...k?{configured:!1,reason:k}:{},reach:M({id:g,owned_by:e.id},e)}))}}}catch{}finally{clearTimeout(y)}})),r}export{B as aggregateModels,G as aggregateModelsAsync,b as listDestinations,F as resetModelsCache,H as resolveDestination};
|
package/src/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createServer as Ft}from"node:http";import{loadConfig as rt}from"./config.js";import{startEntitlementRefresh as Wt,maybeRevalidate as Kt}from"./entitlement-refresh.js";import{redactSegments as Oe,segment as je}from"./redact.js";import{pipeRestoredStream as Qt,pipeRestoredOpenAIStream as Zt,makeTokenRestorer as nt,restoreDeep as Yt}from"./stream.js";import{restoreText as Xt,gatedDictionary as qt,narrowSpecs as eo,makeToolHarness as to,placeholderToolNote as oo,placeholderNote as ro,assertEndpointUrl as no,capRunOptions as so,isPaired as ao}from"@chatpanel/pii";import{ensureGatewayToken as Re,currentGatewayToken as io,isAdminAuthorized as X,callerTrustOf as $e,setPinnedExtensionIds as lo,issuePairingCode as co,claimPairingCode as uo}from"./gateway-token.js";import{installEgressLedger as mo,egressAudit as po}from"./egress.js";import{initPolicy as ho,activePolicy as yo,applyPolicyToConfig as st,managedSummary as ke,PolicyLoadError as fo}from"./policy.js";import{routeAllowed as at,agentAllowed as go,egressAllowed as wo}from"@chatpanel/events/policy.js";import{resolveBridgeUrl as ye}from"./bridge.js";import{secureFetch as Pe}from"./secure-fetch.js";import{streamBridgeChat as it,readBridgeToken as de,openBridgeChat as bo}from"./bridge.js";import{createRelaySession as vo,getRelaySession as lt,endRelaySession as Se,pumpBridgeStream as ko,deliverToolResult as So,toolsToSpecs as To,wantsApprovals as xo,parseToolCallId as ct,touchRelaySession as Ie}from"./toolrelay.js";import{shaperFor as Le}from"./shape.js";import{startNer as _o,ensureNer as Ee,unionForThisMachine as Oo,skippedCompanions as $o}from"./ner.js";import{recommendDetector as dt}from"@chatpanel/pii/detector-router.js";import{installTimestampedConsole as Po}from"./log.js";import{saveBackupSecret as Eo,clearBackupSecret as Ao,loadBackupSecret as Je,hasBackupSecret as ut}from"./history-store.js";import{createMemoryStore as No}from"./memory-store.js";import{createPrefsStore as Bo}from"./prefs-store.js";import{createTeamStore as Do,loadOrCreateKey as ze}from"./team-store.js";import{createScorecardStore as Mo}from"./scorecard-store.js";import{createEngineLedgerStore as Co}from"./engine-ledger-store.js";import{createProjectStore as jo}from"./project-store.js";import{applicationsFor as Ro,recruitPass as Io}from"./recruiting.js";import{ensureBridge as Lo}from"./bridge-supervisor.js";import{checkForUpdate as Jo,updateStatus as zo,startUpdate as Go,updateJob as Ho}from"./update.js";import{createHistoryStore as Vo}from"./sqlite-store.js";import{createEventStore as Uo}from"./event-store.js";import{ingestCloudEvents as Fo,cursorOf as mt}from"./event-sync.js";import{eventStats as Wo,projectYear as Ko}from"./event-stats.js";import{toCloudEvent as Ge}from"./cloudevents.js";import{fusionsDocument as Qo,resolveFusionModel as Zo}from"./fusions.js";import{ingestBackups as He}from"./backup-ingest.js";import{toSearchRecord as Yo}from"@chatpanel/events/library.js";import{deriveBackupKey as Xo,openRecord as qo,keyCache as er,nodeCodec as tr}from"@chatpanel/events/backup-envelope.js";import or from"node:zlib";import*as E from"./ner-engine.js";import pt from"node:os";import{capabilitiesDocument as rr,handleDetect as nr}from"./capabilities.js";import{createExtractService as sr}from"./extract/service.js";import{workerSandbox as ar,disposeWorkerSandbox as ir}from"./worker-sandbox.js";import{createRuntime as lr}from"./runtime.js";import{createCapabilityProxy as cr}from"./capability-proxy.js";import{handleExtract as dr}from"./extract/handler.js";import{MAX_DOCUMENT_BYTES as ur}from"./extract-capability.js";import{createReader as mr}from"./retrieval/read.js";import{createSearcher as pr,toJinaSearch as hr,SEARCH_DEFAULTS as yr}from"./retrieval/search.js";import{createSearxng as fr}from"./retrieval/search-searxng.js";import{toJinaText as gr}from"./read-document.js";import*as A from"./stt-engine.js";import*as j from"./diarize-engine.js";import{providerOf as ht}from"./providers.js";import{createRemoteTranscriber as yt}from"./stt-remote.js";import{parseMultipart as wr,decodeAudioFile as br}from"./audio-file.js";import{MODEL_CATALOG as ft,isKnownModel as gt,isValidCustomModelId as wt,recommendFor as vr}from"./models.js";import{STT_MODEL_CATALOG as kr,isKnownSttModel as Sr,isValidCustomSttId as Tr,DEFAULT_STT_MODEL as Ae,STT_DTYPES as xr,isValidDtype as _r}from"./stt-models.js";import*as P from"./tts-engine.js";import{TTS_MODEL_CATALOG as bt,TTS_VOICES as Or,isKnownTtsModel as $r,isValidCustomTtsId as Pr,isKnownVoice as vt,isValidVoiceId as kt,DEFAULT_TTS_MODEL as St,DEFAULT_TTS_VOICE as ue,TTS_DTYPES as Er,isValidTtsDtype as Ar,MAX_TTS_CHARS as Tt,ttsModelHasCustomVoices as Nr,resolveDefaultModel as xt,POCKET_VOICES as Br,DEFAULT_POCKET_VOICE as Ne,isPocketVoice as Be,ttsModelEngine as De}from"./tts-models.js";import{ttsDestination as Dr,synthesizeRemote as Mr,isValidRemoteVoice as Cr}from"./tts-remote.js";import{rawOrtAvailable as Ve}from"./ort.js";import*as K from"./tts-voices.js";import{resolveTtsVoice as jr}from"./tts-voice-resolve.js";import{resolvePro as fe,checkQuota as Rr,consume as Ir,usage as Lr}from"./freegate.js";import{publicConfig as _t,applyConfigPatch as Jr,applyNerModelSelection as Ot,persistConfig as me,configPath as se,bridgeAgentOptions as $t,PERMISSION_MODES as zr,sandboxEnvFor as Gr}from"./configstore.js";import Pt from"node:path";import{resolveDestination as Et,aggregateModelsAsync as Hr,listDestinations as Vr}from"./router.js";import{makeAccessEvent as At}from"./observability.js";import{createPersistentAccessLog as Ur}from"./access-log-store.js";import{planQueries as Fr,multiSearch as Wr}from"./rrf.js";import*as Ue from"./openai.js";import*as Nt from"./responses.js";import*as Fe from"./anthropic.js";import{closeAndExit as Kr}from"./shutdown.js";const ee="0.
|
|
1
|
+
import{createServer as Ft}from"node:http";import{loadConfig as rt}from"./config.js";import{startEntitlementRefresh as Wt,maybeRevalidate as Kt}from"./entitlement-refresh.js";import{redactSegments as Oe,segment as je}from"./redact.js";import{pipeRestoredStream as Qt,pipeRestoredOpenAIStream as Zt,makeTokenRestorer as nt,restoreDeep as Yt}from"./stream.js";import{restoreText as Xt,gatedDictionary as qt,narrowSpecs as eo,makeToolHarness as to,placeholderToolNote as oo,placeholderNote as ro,assertEndpointUrl as no,capRunOptions as so,isPaired as ao}from"@chatpanel/pii";import{ensureGatewayToken as Re,currentGatewayToken as io,isAdminAuthorized as X,callerTrustOf as $e,setPinnedExtensionIds as lo,issuePairingCode as co,claimPairingCode as uo}from"./gateway-token.js";import{installEgressLedger as mo,egressAudit as po}from"./egress.js";import{initPolicy as ho,activePolicy as yo,applyPolicyToConfig as st,managedSummary as ke,PolicyLoadError as fo}from"./policy.js";import{routeAllowed as at,agentAllowed as go,egressAllowed as wo}from"@chatpanel/events/policy.js";import{resolveBridgeUrl as ye}from"./bridge.js";import{secureFetch as Pe}from"./secure-fetch.js";import{streamBridgeChat as it,readBridgeToken as de,openBridgeChat as bo}from"./bridge.js";import{createRelaySession as vo,getRelaySession as lt,endRelaySession as Se,pumpBridgeStream as ko,deliverToolResult as So,toolsToSpecs as To,wantsApprovals as xo,parseToolCallId as ct,touchRelaySession as Ie}from"./toolrelay.js";import{shaperFor as Le}from"./shape.js";import{startNer as _o,ensureNer as Ee,unionForThisMachine as Oo,skippedCompanions as $o}from"./ner.js";import{recommendDetector as dt}from"@chatpanel/pii/detector-router.js";import{installTimestampedConsole as Po}from"./log.js";import{saveBackupSecret as Eo,clearBackupSecret as Ao,loadBackupSecret as Je,hasBackupSecret as ut}from"./history-store.js";import{createMemoryStore as No}from"./memory-store.js";import{createPrefsStore as Bo}from"./prefs-store.js";import{createTeamStore as Do,loadOrCreateKey as ze}from"./team-store.js";import{createScorecardStore as Mo}from"./scorecard-store.js";import{createEngineLedgerStore as Co}from"./engine-ledger-store.js";import{createProjectStore as jo}from"./project-store.js";import{applicationsFor as Ro,recruitPass as Io}from"./recruiting.js";import{ensureBridge as Lo}from"./bridge-supervisor.js";import{checkForUpdate as Jo,updateStatus as zo,startUpdate as Go,updateJob as Ho}from"./update.js";import{createHistoryStore as Vo}from"./sqlite-store.js";import{createEventStore as Uo}from"./event-store.js";import{ingestCloudEvents as Fo,cursorOf as mt}from"./event-sync.js";import{eventStats as Wo,projectYear as Ko}from"./event-stats.js";import{toCloudEvent as Ge}from"./cloudevents.js";import{fusionsDocument as Qo,resolveFusionModel as Zo}from"./fusions.js";import{ingestBackups as He}from"./backup-ingest.js";import{toSearchRecord as Yo}from"@chatpanel/events/library.js";import{deriveBackupKey as Xo,openRecord as qo,keyCache as er,nodeCodec as tr}from"@chatpanel/events/backup-envelope.js";import or from"node:zlib";import*as E from"./ner-engine.js";import pt from"node:os";import{capabilitiesDocument as rr,handleDetect as nr}from"./capabilities.js";import{createExtractService as sr}from"./extract/service.js";import{workerSandbox as ar,disposeWorkerSandbox as ir}from"./worker-sandbox.js";import{createRuntime as lr}from"./runtime.js";import{createCapabilityProxy as cr}from"./capability-proxy.js";import{handleExtract as dr}from"./extract/handler.js";import{MAX_DOCUMENT_BYTES as ur}from"./extract-capability.js";import{createReader as mr}from"./retrieval/read.js";import{createSearcher as pr,toJinaSearch as hr,SEARCH_DEFAULTS as yr}from"./retrieval/search.js";import{createSearxng as fr}from"./retrieval/search-searxng.js";import{toJinaText as gr}from"./read-document.js";import*as A from"./stt-engine.js";import*as j from"./diarize-engine.js";import{providerOf as ht}from"./providers.js";import{createRemoteTranscriber as yt}from"./stt-remote.js";import{parseMultipart as wr,decodeAudioFile as br}from"./audio-file.js";import{MODEL_CATALOG as ft,isKnownModel as gt,isValidCustomModelId as wt,recommendFor as vr}from"./models.js";import{STT_MODEL_CATALOG as kr,isKnownSttModel as Sr,isValidCustomSttId as Tr,DEFAULT_STT_MODEL as Ae,STT_DTYPES as xr,isValidDtype as _r}from"./stt-models.js";import*as P from"./tts-engine.js";import{TTS_MODEL_CATALOG as bt,TTS_VOICES as Or,isKnownTtsModel as $r,isValidCustomTtsId as Pr,isKnownVoice as vt,isValidVoiceId as kt,DEFAULT_TTS_MODEL as St,DEFAULT_TTS_VOICE as ue,TTS_DTYPES as Er,isValidTtsDtype as Ar,MAX_TTS_CHARS as Tt,ttsModelHasCustomVoices as Nr,resolveDefaultModel as xt,POCKET_VOICES as Br,DEFAULT_POCKET_VOICE as Ne,isPocketVoice as Be,ttsModelEngine as De}from"./tts-models.js";import{ttsDestination as Dr,synthesizeRemote as Mr,isValidRemoteVoice as Cr}from"./tts-remote.js";import{rawOrtAvailable as Ve}from"./ort.js";import*as K from"./tts-voices.js";import{resolveTtsVoice as jr}from"./tts-voice-resolve.js";import{resolvePro as fe,checkQuota as Rr,consume as Ir,usage as Lr}from"./freegate.js";import{publicConfig as _t,applyConfigPatch as Jr,applyNerModelSelection as Ot,persistConfig as me,configPath as se,bridgeAgentOptions as $t,PERMISSION_MODES as zr,sandboxEnvFor as Gr}from"./configstore.js";import Pt from"node:path";import{resolveDestination as Et,aggregateModelsAsync as Hr,listDestinations as Vr}from"./router.js";import{makeAccessEvent as At}from"./observability.js";import{createPersistentAccessLog as Ur}from"./access-log-store.js";import{planQueries as Fr,multiSearch as Wr}from"./rrf.js";import*as Ue from"./openai.js";import*as Nt from"./responses.js";import*as Fe from"./anthropic.js";import{closeAndExit as Kr}from"./shutdown.js";const ee="0.40.0",N=await Vo(),ae=new Set;function Me({ids:t=[]}={}){const c=N.lossless;if(!c||!ae.size)return;const d=JSON.stringify({newest:c.newest,size:c.size,ids:t.slice(0,50),at:Date.now()});for(const m of ae)try{m.write(`event: records
|
|
2
2
|
data: ${d}
|
|
3
3
|
|
|
4
4
|
`)}catch{ae.delete(m)}}setInterval(()=>{for(const t of ae)try{t.write(`: ping
|