mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-05 03:12:10 +02:00
saving
This commit is contained in:
parent
9e9307a2aa
commit
e26caa0b12
123 changed files with 3478 additions and 10078 deletions
28
ts/packages/cli/src/commands/util.ts
Normal file
28
ts/packages/cli/src/commands/util.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Shared CLI utilities.
|
||||
*/
|
||||
|
||||
import type { Command } from "commander";
|
||||
import { SocketManager } from "@trustgraph/mcp";
|
||||
|
||||
export interface CliOpts {
|
||||
gateway: string;
|
||||
token?: string;
|
||||
flow: string;
|
||||
}
|
||||
|
||||
export function getOpts(cmd: Command): CliOpts {
|
||||
// Walk up to root command to get global options
|
||||
let root = cmd;
|
||||
while (root.parent) root = root.parent;
|
||||
return root.opts() as CliOpts;
|
||||
}
|
||||
|
||||
export async function createSocket(opts: CliOpts): Promise<SocketManager> {
|
||||
const socket = new SocketManager({
|
||||
gatewayUrl: opts.gateway,
|
||||
token: opts.token,
|
||||
});
|
||||
await socket.connect();
|
||||
return socket;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue