MCPcopy Create free account
hub / github.com/clawbot7/cli-gateway / constructor

Method constructor

src/gateway/bindingRuntime.ts:44–283  ·  view source on GitHub ↗
(params: {
    db: Db;
    config: AppConfig;
    toolAuth: ToolAuth;
    sessionKey: string;
    bindingKey: string;
    workspaceRoot: string;
    agentCommand?: string;
    agentArgs?: string[];
    acpRpc?: import('../acp/stdio.js').StdioProcess;
  })

Source from the content-addressed store, hash-verified

42 private readonly agentArgs: string[];
43
44 constructor(params: {
45 db: Db;
46 config: AppConfig;
47 toolAuth: ToolAuth;
48 sessionKey: string;
49 bindingKey: string;
50 workspaceRoot: string;
51 agentCommand?: string;
52 agentArgs?: string[];
53 acpRpc?: import('../acp/stdio.js').StdioProcess;
54 }) {
55 this.db = params.db;
56 this.config = params.config;
57 this.toolAuth = params.toolAuth;
58 this.sessionKey = params.sessionKey;
59 this.bindingKey = params.bindingKey;
60 this.workspaceRoot = params.workspaceRoot;
61 this.agentCommand = params.agentCommand ?? this.config.acpAgentCommand;
62 this.agentArgs = params.agentArgs ?? this.config.acpAgentArgs;
63
64 this.client = new AcpClient({
65 db: this.db,
66 workspaceRoot: this.workspaceRoot,
67 agentCommand: this.agentCommand,
68 agentArgs: this.agentArgs,
69 toolAuth: this.toolAuth,
70 rpc: params.acpRpc,
71 events: {
72 onSessionUpdate: (run, _sessionId, update, eventSeq) => {
73 if (run.runId === this.currentRunId) {
74 this.currentRunLastSeq = Math.max(this.currentRunLastSeq, eventSeq);
75 }
76
77 this.enqueueSinkWrite(async () => {
78 if (run.runId !== this.currentRunId) return;
79
80 const sink = this.activeSink;
81 if (!sink) return;
82
83 if (update?.sessionUpdate === 'agent_message_chunk') {
84 const block = update?.content;
85 const text = block?.text ?? '';
86 if (!text) return;
87 if (sink.sendAgentText) {
88 await sink.sendAgentText(text);
89 } else {
90 await sink.sendText(text);
91 }
92 }
93
94 if (
95 update?.sessionUpdate === 'tool_call' ||
96 update?.sessionUpdate === 'tool_call_update'
97 ) {
98 const ui = this.buildToolUiEvent(update);
99 if (!ui) return;
100
101 if (this.shouldBreakTextStreamForToolUpdate(update, ui.toolCallId)) {

Callers

nothing calls this directly

Calls 13

enqueueSinkWriteMethod · 0.95
buildToolUiEventMethod · 0.95
renderJsonFunction · 0.85
toToolKindFunction · 0.85
formatPermissionRequestFunction · 0.85
listAllowPrefixRulesMethod · 0.80
grantOnceMethod · 0.80
respondPermissionMethod · 0.80
formatTextCodeBlockFunction · 0.70

Tested by

no test coverage detected