grix-connector 4.2.5 → 4.2.7
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/adapter/claude/skill-scanner.js +2 -2
- package/dist/adapter/codewhale/codewhale-adapter.js +2 -2
- package/dist/adapter/deepseek-harness/dsh-provider-config.js +6 -6
- package/dist/adapter/deepseek-harness/index.js +1 -1
- package/dist/adapter/deepseek-harness/jsonrpc-adapter.js +2 -2
- package/dist/adapter/deepseek-harness/profile-runtime.js +2 -2
- package/dist/assets/dsh-bridge/{grix-dsh-bridge-4.2.5.tgz → grix-dsh-bridge-4.2.7.tgz} +0 -0
- package/dist/assets/dsh-bridge/manifest.json +4 -4
- package/dist/bridge/acp-toolbar-persist.js +1 -1
- package/dist/bridge/bridge.js +7 -7
- package/dist/bridge/event-queue.js +1 -1
- package/dist/core/aibot/client.js +2 -2
- package/dist/core/persistence/session-binding-store.js +2 -2
- package/dist/core/upgrade/upgrade-checker.js +1 -1
- package/dist/mcp/stream-http/security.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createHmac as
|
|
1
|
+
import{createHmac as H,randomUUID as T}from"node:crypto";import{EventEmitter as O}from"node:events";import{readFileSync as q}from"node:fs";import{createConnection as $}from"node:net";import{isDshBridgedGrixTool as z}from"./grix-tool-bridge.js";import{DshBridgeJsonRpcPeer as G,GRIX_DSH_PROTOCOL_MAX as C,GRIX_DSH_PROTOCOL_MIN as M}from"./profile-bridge-protocol.js";import{resolveDshProfileIdentity as U,selectDshBridgeEndpoint as L}from"./profile-resolver.js";import{DEFAULT_DSH_PRESETS as F,normalizeDshPresets as K,normalizeDshProviders as V,resolveDshAgentPreset as X,resolveDshProviderId as J}from"./toolbar-state.js";import{effectiveDshReasoningEffort as W}from"./types.js";const Z=T(),N=5e3,k=1e4,Q=6e4;class Y extends O{peer;sessionId;ownerId;onCursorAck;notificationsActive=!1;pendingNotifications=[];constructor(t,e,c,s){super(),this.peer=t,this.sessionId=e,this.ownerId=c,this.onCursorAck=s,t.on("notification",(o,a)=>{if(!this.notificationsActive){this.pendingNotifications.push({method:o,params:a});return}this.deliverNotification(o,a)}),t.on("protocolError",o=>this.emit("protocolError",o))}prompt(t,e){return this.peer.call("session/prompt",{sessionId:t.sessionId,ownerId:this.ownerId,contentBlocks:t.contentBlocks},e)}async shutdown(t){try{await this.peer.call("session/close",{sessionId:this.sessionId,ownerId:this.ownerId},m(t,5e3))}finally{this.peer.close()}}close(t){this.peer.close(t)}activateNotifications(){if(!this.notificationsActive){this.notificationsActive=!0;for(const t of this.pendingNotifications.splice(0))this.deliverNotification(t.method,t.params)}}call(t,e,c){const s=e&&typeof e=="object"?e:{};return this.peer.call(t,{sessionId:this.sessionId,ownerId:this.ownerId,...s},m(c,1e4))}async ack(t,e){if(!Number.isSafeInteger(t)||t<=0)throw Object.assign(new Error("Bridge ACK cursor must be a positive integer"),{code:"invalid_params"});const c=await this.peer.call("session/ack",{sessionId:this.sessionId,ownerId:this.ownerId,cursor:t},m(e,5e3));return await this.onCursorAck?.(t),c}cancel(t){return this.peer.call("session/cancel",{sessionId:this.sessionId,ownerId:this.ownerId},m(t,3e4))}setOptions(t,e){return this.peer.call("session/setOptions",{sessionId:this.sessionId,ownerId:this.ownerId,model:t.modelId,modeId:t.modeId},m(e,1e4))}deliverNotification(t,e){this.emit("notification",t,e)}}class ht{options;client=null;peer=null;socket=null;exitEmitter=new O;intentionalClose=!1;constructor(t){this.options=t}async start(){const t=U({dshHome:this.options.dshHome,profileName:this.options.profileName}),e=L(t);if(e.protocolMax<M||e.protocolMin>C)throw Object.assign(new Error(`Incompatible Grix DSH Bridge protocol ${e.protocolMin}-${e.protocolMax}`),{code:"bridge_incompatible"});const c=q(e.tokenPath,"utf8").trim();if(!c)throw Object.assign(new Error("DSH Bridge token file is empty"),{code:"auth_failed"});const s=await tt(e.address,this.options.connectTimeoutMs??N);this.socket=s;const o=new G(s,{maxFrameBytes:this.options.maxFrameBytes,capture:this.options.capture});this.peer=o,o.on("close",()=>{this.socket=null,this.peer=null,this.client=null,this.intentionalClose||this.exitEmitter.emit("exit")}),o.setRequestHandler(async(i,l)=>{const n=l&&typeof l=="object"?l:{};if(i==="interaction/requestApproval")return{outcome:await this.options.onApproval?.(n)??"unavailable"};if(i==="grix/tool-call"){if(!this.options.onToolInvoke)throw Object.assign(new Error("grix tools are not wired for this Connector session"),{code:"capability_unavailable"});const d=String(n.tool??"").trim(),b=n.args&&typeof n.args=="object"?n.args:{};if(!d)throw Object.assign(new Error("grix/tool-call requires a tool name"),{code:"invalid_params"});if(!z(d))throw Object.assign(new Error(`grix tool "${d}" is not exposed to DSH`),{code:"capability_unavailable"});const j=Number(n.timeoutMs)||void 0;return{ok:!0,value:await this.options.onToolInvoke(d,b,j)}}throw Object.assign(new Error(`Unsupported Bridge request: ${i}`),{code:"capability_unavailable"})});const a=T(),g=H("sha256",c).update(`${a}
|
|
2
2
|
${t.profileKey}
|
|
3
|
-
${e.instanceId}`).digest("hex"),
|
|
3
|
+
${e.instanceId}`).digest("hex"),I=AbortSignal.timeout(this.options.initializeTimeoutMs??this.options.connectTimeoutMs??N),r=await o.call("bridge/initialize",{protocol:{min:M,max:C},client:{name:"grix-connector",version:process.env.npm_package_version??"unknown",instanceId:Z},profileKey:t.profileKey,requestedRole:"controller",auth:{nonce:a,proof:g}},I),B=r.profile&&typeof r.profile=="object"?r.profile:{},S=String(B.dshVersion??"");if(S!==e.dshVersion)throw o.close(new Error("DSH Profile version changed between discovery and handshake")),Object.assign(new Error(`DSH Profile version mismatch: discovery=${e.dshVersion||"unknown"} handshake=${S||"unknown"}`),{code:"bridge_incompatible"});const R=r.capabilities&&typeof r.capabilities=="object"?r.capabilities:{},y=this.options.settings.skillIds??[],E=(this.options.settings.skillIdsExplicit===!0||y.length>0)&&R.sessionSkillAllowlist===!0,h=String(this.options.settings.providerId??"").trim();let u=[],_=!1;const x=this.options.catalogRefreshAttempts??8;for(let i=0;i<=x;i++){try{const l=AbortSignal.timeout(this.options.catalogTimeoutMs??k),n=await o.call("profile/listProviders",{},l),d=V(n.providers);if(_=!0,d.length>0&&(u=d),!h||u.some(b=>b.id===h))break}catch{break}i<x&&await new Promise(l=>setTimeout(l,150))}const w=_&&h&&!u.some(i=>i.id===h)?h:J(this.options.settings.providerId,u);let f;try{const i=AbortSignal.timeout(this.options.catalogTimeoutMs??k),l=await o.call("profile/listModels",{provider:w},i);f=Array.isArray(l.models)?l.models.filter(n=>!!n&&typeof n=="object"):[]}catch{}const P=(f??[]).some(i=>String(i.id??"")===this.options.settings.modelId)?this.options.settings.modelId:String(f?.[0]?.id??this.options.settings.modelId);let v=[...F];try{const i=AbortSignal.timeout(this.options.catalogTimeoutMs??k),l=await o.call("profile/listPresets",{},i),n=K(l.presets);n.length>0&&(v=n)}catch{}const A=X(this.options.settings.agentPreset,v);this.client=new Y(o,this.options.sessionId,this.options.ownerId,this.options.onCursorAck);try{const i=AbortSignal.timeout(this.options.sessionCreateTimeoutMs??Q);await o.call("session/create",{sessionId:this.options.sessionId,ownerId:this.options.ownerId,cwd:this.options.cwd,provider:w,model:P,reasoningEffort:W(this.options.settings),...w==="codex-app-server"?{}:{maxTokens:this.options.settings.maxTokens},modeId:this.options.settings.modeId,agentPreset:A,pluginIds:this.options.settings.pluginIds??[],...E?{skillIds:y,skillIdsExplicit:!0}:{},...E&&this.options.skillsDir?{skillsDir:this.options.skillsDir}:{},...this.options.pluginOverlayPath?{pluginOverlayPath:this.options.pluginOverlayPath}:{},systemPrompt:this.options.systemPrompt,resume:this.options.resumeSession===!0,lastAckCursor:this.options.lastAckCursor??0},i)}catch(i){throw this.client.close(i instanceof Error?i:new Error(String(i))),this.client=null,i}const D=r.serverInfo&&typeof r.serverInfo=="object"?r.serverInfo:{};return{serverInfo:{name:String(D.name??"grix-dsh-profile-bridge"),version:String(D.version??"unknown")},profile:r.profile,capabilities:r.capabilities,...f!==void 0?{models:f}:{},selectedModel:P,providers:u,selectedProvider:w,presets:v,selectedPreset:A}}async shutdown(){this.intentionalClose=!0;try{await this.client?.shutdown()}finally{this.peer?.close(),this.client=null,this.peer=null,this.socket=null}}async terminate(){this.intentionalClose=!0,this.peer?.close(new Error("DSH Profile Bridge connection terminated")),this.client=null,this.peer=null,this.socket=null}async cancel(t){await this.client?.cancel()}async hasBackgroundWork(){return!1}isConnected(){return!!this.client&&!!this.peer?.isOpen}onExit(t){return this.exitEmitter.on("exit",t),()=>this.exitEmitter.off("exit",t)}}function m(p,t){return p??AbortSignal.timeout(t)}function tt(p,t){return new Promise((e,c)=>{const s=$(p),o=setTimeout(()=>{a(),s.destroy(),c(Object.assign(new Error("Timed out connecting to DSH Profile Bridge"),{code:"bridge_connect_timeout"}))},t);o.unref?.();const a=()=>{clearTimeout(o),s.off("connect",g),s.off("error",I)},g=()=>{a(),s.setNoDelay(!0),e(s)},I=r=>{a(),c(Object.assign(r,{code:"bridge_connect_failed"}))};s.once("connect",g),s.once("error",I)})}export{k as BRIDGE_CATALOG_TIMEOUT_MS,N as BRIDGE_INITIALIZE_TIMEOUT_MS,Q as BRIDGE_SESSION_CREATE_TIMEOUT_MS,ht as DshProfileRuntime,Y as DshProfileRuntimeClient};
|
|
Binary file
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"bridgeVersion": "4.2.
|
|
4
|
-
"tarball": "grix-dsh-bridge-4.2.
|
|
3
|
+
"bridgeVersion": "4.2.7",
|
|
4
|
+
"tarball": "grix-dsh-bridge-4.2.7.tgz",
|
|
5
5
|
"size": 22490,
|
|
6
6
|
"unpackedSize": 89865,
|
|
7
|
-
"shasum": "
|
|
8
|
-
"integrity": "sha512-
|
|
7
|
+
"shasum": "13d8163f39412f799c1d7644f9ae4f33abf4b917",
|
|
8
|
+
"integrity": "sha512-aDoKYSNgPk2QUyXpceAPPnRx4dEIaN6EKdAiej4fMkPDhlYbYgoZVL5CTTCH6NTP+HaProfR3JiszPBxAEG99Q=="
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const s="acp-toolbar-persist";function
|
|
1
|
+
const s="acp-toolbar-persist";function d(e,o){return e.bindingStore.get(o)?.cwd?null:{status:"failed",errorCode:"binding_missing",errorMsg:"Session binding missing. Open a workspace first."}}async function u(e,o,i){const t=String(i??"").trim();if(!t)return{status:"failed",errorCode:"set_model_invalid",errorMsg:"model_id is required"};const l=d(e,o);if(l)return l;e.bindingStore.setAcpModelId(o,t),e.globalConfigStore?.set(e.agentName,{modelId:t});const a=!!e.acpAdapter?.isAlive();if(e.log.info(s,`set_model persisted: session=${o} model=${t} acpAlive=${a}`),!a)return{status:"ok",result:{outcome:"model_set_pending",modelId:t,model_id:t,sessionAlive:!1}};let r=!1;try{r=await e.acpAdapter.setModel(t)}catch(n){e.log.warn(s,`set_model RPC threw: session=${o} model=${t} err=${n instanceof Error?n.message:String(n)}`),r=!1}return r?{status:"ok",result:{outcome:"model_set",modelId:t,model_id:t,sessionAlive:!0,rpcOk:!0}}:(e.log.warn(s,`set_model RPC failed: session=${o} model=${t} (kept in binding)`),{status:"ok",result:{outcome:"model_set_pending",modelId:t,model_id:t,sessionAlive:!0,rpcOk:!1}})}async function m(e,o,i){const t=String(i??"").trim();if(!t)return{status:"failed",errorCode:"set_mode_invalid",errorMsg:"mode_id is required"};const l=d(e,o);if(l)return l;e.bindingStore.setAcpModeId(o,t),e.globalConfigStore?.set(e.agentName,{acpInitialMode:t});const a=!!e.acpAdapter?.isAlive();if(e.log.info(s,`set_mode persisted: session=${o} mode=${t} acpAlive=${a}`),!a)return{status:"ok",result:{outcome:"mode_set_pending",modeId:t,mode_id:t,sessionAlive:!1}};let r=!1;try{r=await e.acpAdapter.setMode(t)}catch(n){e.log.warn(s,`set_mode RPC threw: session=${o} mode=${t} err=${n instanceof Error?n.message:String(n)}`),r=!1}return r?{status:"ok",result:{outcome:"mode_set",modeId:t,mode_id:t,sessionAlive:!0,rpcOk:!0}}:(e.log.warn(s,`set_mode RPC failed: session=${o} mode=${t} (kept in binding)`),{status:"ok",result:{outcome:"mode_set_pending",modeId:t,mode_id:t,sessionAlive:!0,rpcOk:!1}})}function c(...e){for(const o of e){const i=String(o??"").trim();if(i)return i}}function g(e){const o=c(e.sessionBinding?.acpModeId,e.globalDefaults?.acpInitialMode,e.configInitialMode);return{initialModel:c(e.sessionBinding?.acpModelId,e.globalDefaults?.modelId),initialMode:o}}export{m as handleAcpSetMode,u as handleAcpSetModel,g as resolveAcpInitialDefaults};
|