mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 17:39:39 +02:00
chore(ts): consolidate effect native closeout
This commit is contained in:
parent
cd6c9107d7
commit
fab718dce8
21 changed files with 199 additions and 3533 deletions
|
|
@ -1 +1 @@
|
|||
{"exemptions":[],"baseline":[{"rule":"no-error-throw","path":"packages/workbench/src/main.tsx","count":1},{"rule":"no-native-sort","path":"packages/client/src/socket/trustgraph-socket.ts","count":2},{"rule":"no-native-sort","path":"packages/flow/src/config/service.ts","count":3},{"rule":"no-native-sort","path":"packages/flow/src/cores/service.ts","count":1},{"rule":"no-native-sort","path":"packages/flow/src/flow-manager/service.ts","count":1},{"rule":"no-native-sort","path":"packages/flow/src/librarian/service.ts","count":1},{"rule":"no-native-sort","path":"packages/flow/src/retrieval/graph-rag.ts","count":1},{"rule":"no-native-sort","path":"packages/mcp/src/server-effect.ts","count":1},{"rule":"no-native-sort","path":"packages/workbench/src/atoms/workbench.ts","count":2},{"rule":"no-native-sort","path":"packages/workbench/src/components/chat/explain-graph.tsx","count":1},{"rule":"no-native-sort","path":"packages/workbench/src/pages/graph.tsx","count":1},{"rule":"no-native-sort","path":"packages/workbench/src/qa/mock-api.ts","count":1},{"rule":"no-schema-suffix","path":"packages/base/src/schema/primitives.ts","count":1}]}
|
||||
{"exemptions":[{"rule":"no-error-throw","path":"packages/workbench/src/main.tsx","reason":"Host boundary: Workbench cannot render without the #root mount element."}],"baseline":[]}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
import { BunRuntime } from "@effect/platform-bun";
|
||||
import * as BunHttpClient from "@effect/platform-bun/BunHttpClient";
|
||||
import { DispatchInput, makeEffectRpcClient } from "@trustgraph/client";
|
||||
import { Config, Effect, Option as O, Schema as S } from "effect";
|
||||
import { HttpClient, HttpClientRequest } from "effect/unstable/http";
|
||||
|
||||
|
|
@ -19,17 +20,6 @@ const DEFAULT_LLM_MODEL = "qwen2.5:0.5b";
|
|||
const DEFAULT_FALKORDB_URL = "redis://localhost:6380";
|
||||
const DEFAULT_PIPELINE_WAIT = 20;
|
||||
|
||||
interface RpcSocket {
|
||||
close: () => void;
|
||||
makeRequest: <RequestType extends object, ResponseType>(
|
||||
service: string,
|
||||
request: RequestType,
|
||||
timeout?: number,
|
||||
retries?: number,
|
||||
flow?: string,
|
||||
) => Promise<ResponseType>;
|
||||
}
|
||||
|
||||
interface PipelineConfig {
|
||||
readonly gatewayUrl: string;
|
||||
readonly gatewaySecret: string | undefined;
|
||||
|
|
@ -299,33 +289,24 @@ const testTextCompletion = (config: PipelineConfig) => catchTest("Text completio
|
|||
}));
|
||||
|
||||
const testWebSocket = (config: PipelineConfig) => catchTest("Effect RPC WebSocket", Effect.gen(function* () {
|
||||
let socket: RpcSocket | undefined;
|
||||
return yield* Effect.gen(function* () {
|
||||
const { createTrustGraphSocket } = yield* Effect.tryPromise({
|
||||
try: () => import("../packages/client/src/socket/trustgraph-socket.js"),
|
||||
catch: (cause) => pipelineError("websocket.import", cause),
|
||||
});
|
||||
const gatewayWsUrl = config.gatewayUrl.replace(/^http/, "ws").replace(/\/$/, "");
|
||||
const response = yield* Effect.scoped(
|
||||
Effect.gen(function*() {
|
||||
const client = yield* makeEffectRpcClient(`${gatewayWsUrl}/api/v1/rpc`);
|
||||
return yield* client.dispatch(
|
||||
DispatchInput.make({
|
||||
scope: "global",
|
||||
service: "config",
|
||||
request: { operation: "list", keys: [] },
|
||||
}),
|
||||
{ timeoutMs: 5_000 },
|
||||
);
|
||||
}),
|
||||
).pipe(Effect.timeout("5 seconds"));
|
||||
|
||||
const gatewayWsUrl = config.gatewayUrl.replace(/^http/, "ws").replace(/\/$/, "");
|
||||
socket = createTrustGraphSocket(
|
||||
"pipeline",
|
||||
config.gatewaySecret,
|
||||
`${gatewayWsUrl}/api/v1/rpc`,
|
||||
);
|
||||
const response = yield* Effect.tryPromise({
|
||||
try: () =>
|
||||
socket?.makeRequest<Record<string, unknown>, Record<string, unknown>>(
|
||||
"config",
|
||||
{ operation: "list", keys: [] },
|
||||
5000,
|
||||
) ?? Promise.resolve({}),
|
||||
catch: (cause) => pipelineError("websocket.request", cause),
|
||||
}).pipe(Effect.timeout("5 seconds"));
|
||||
|
||||
log("websocket/rpc-response", response);
|
||||
pass("Effect RPC WebSocket round-trip works");
|
||||
return true;
|
||||
}).pipe(Effect.ensuring(Effect.sync(() => socket?.close())));
|
||||
log("websocket/rpc-response", response);
|
||||
pass("Effect RPC WebSocket round-trip works");
|
||||
return true;
|
||||
}));
|
||||
|
||||
// ─── Librarian Tests ──────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue