mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 09:29:38 +02:00
refactor(ts): complete legacy host removal — drop fastify/commander/zod, delete MCP SDK server, remove ManagedRuntime facades
Finishes the remaining EFFECT_NATIVE_REWRITE_PLAN stages in one verified slice: - fastify, @fastify/websocket, commander, zod removed from all package manifests - legacy @modelcontextprotocol/sdk stdio server deleted; effect/unstable/ai McpServer is canonical - no ManagedRuntime or Effect.runPromise program facades remain in production source - gateway server/rpc-contract and client rpc/socket moved onto Effect v4 native http/rpc/socket layers Gates (force-run, no cache): check:tsgo, build, test (96 tests / 11 tasks) all green. Native-class inventory: zero blocking production classes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
a26463afc1
commit
cf12defcd8
30 changed files with 1506 additions and 456 deletions
|
|
@ -12,21 +12,13 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@effect/ai-anthropic": "4.0.0-beta.78",
|
||||
"@effect/ai-openai": "4.0.0-beta.78",
|
||||
"@effect/ai-openrouter": "4.0.0-beta.78",
|
||||
"@effect/atom-react": "4.0.0-beta.78",
|
||||
"@effect/openapi-generator": "4.0.0-beta.78",
|
||||
"@effect/opentelemetry": "4.0.0-beta.78",
|
||||
"@effect/platform-browser": "4.0.0-beta.78",
|
||||
"@effect/platform-bun": "4.0.0-beta.78",
|
||||
"@effect/platform-node": "4.0.0-beta.78",
|
||||
"@effect/platform-node-shared": "4.0.0-beta.78",
|
||||
"@effect/tsgo": "0.14.0",
|
||||
"@effect/vitest": "4.0.0-beta.78",
|
||||
"@mistralai/mistralai": "^1.0.0",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@qdrant/js-client-rest": "^1.13.0",
|
||||
"@trustgraph/base": "workspace:*",
|
||||
"@trustgraph/client": "workspace:*",
|
||||
"effect": "4.0.0-beta.78",
|
||||
"falkordb": "^5.0.0",
|
||||
"ollama": "^0.6.3",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { Clock, Effect, Exit, HashMap, HashSet, Option, Random, Scope, Synchroni
|
|||
import {
|
||||
loadMessagingRuntimeConfig,
|
||||
makeNatsBackend,
|
||||
makeNatsBackendScoped,
|
||||
makePubSubService,
|
||||
makeRequestResponseFactoryService,
|
||||
messagingDeliveryError,
|
||||
|
|
@ -401,3 +402,17 @@ export function makeDispatcherManager(config: GatewayConfig): DispatcherManager
|
|||
publishToTopic,
|
||||
};
|
||||
}
|
||||
|
||||
export const makeDispatcherManagerScoped = Effect.fn("makeDispatcherManagerScoped")(function* (
|
||||
config: GatewayConfig,
|
||||
) {
|
||||
if (config.pubsub !== undefined) {
|
||||
return makeDispatcherManager(config);
|
||||
}
|
||||
|
||||
const pubsub = yield* makeNatsBackendScoped(config.natsUrl ?? "nats://localhost:4222");
|
||||
return makeDispatcherManager({
|
||||
...config,
|
||||
pubsub,
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,34 +1 @@
|
|||
import { Schema as S } from "effect";
|
||||
import * as Rpc from "effect/unstable/rpc/Rpc";
|
||||
import * as RpcGroup from "effect/unstable/rpc/RpcGroup";
|
||||
|
||||
export class DispatchPayload extends S.Class<DispatchPayload>("DispatchPayload")({
|
||||
scope: S.Literals(["global", "flow"]),
|
||||
service: S.String,
|
||||
flow: S.optionalKey(S.String),
|
||||
request: S.Record(S.String, S.Unknown),
|
||||
}) {}
|
||||
|
||||
export class DispatchStreamChunk extends S.Class<DispatchStreamChunk>("DispatchStreamChunk")({
|
||||
response: S.Unknown,
|
||||
complete: S.Boolean,
|
||||
}) {}
|
||||
|
||||
export class DispatchError extends S.TaggedErrorClass<DispatchError>()("DispatchError", {
|
||||
message: S.String,
|
||||
}) {}
|
||||
|
||||
export class Dispatch extends Rpc.make("Dispatch", {
|
||||
payload: DispatchPayload,
|
||||
success: S.Unknown,
|
||||
error: DispatchError,
|
||||
}) {}
|
||||
|
||||
export class DispatchStream extends Rpc.make("DispatchStream", {
|
||||
payload: DispatchPayload,
|
||||
success: DispatchStreamChunk,
|
||||
error: DispatchError,
|
||||
stream: true,
|
||||
}) {}
|
||||
|
||||
export const TrustGraphRpcs = RpcGroup.make(Dispatch, DispatchStream);
|
||||
export * from "@trustgraph/client/rpc/contract";
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { NodeHttpServer, NodeRuntime } from "@effect/platform-node";
|
|||
import { Clock, Config, Effect, Exit, Layer, Random, Scope } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
import { HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
||||
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
||||
import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
|
||||
import {
|
||||
formatPrometheusMetrics,
|
||||
|
|
@ -19,7 +20,8 @@ import {
|
|||
toTgError,
|
||||
type PubSubBackend,
|
||||
} from "@trustgraph/base";
|
||||
import { makeDispatcherManager, type DispatcherManager } from "./dispatch/manager.js";
|
||||
import { GatewayWorkbenchHttpApi } from "@trustgraph/client/rpc/contract";
|
||||
import { makeDispatcherManagerScoped, type DispatcherManager } from "./dispatch/manager.js";
|
||||
import { makeGatewayRpcServer, type GatewayRpcServer } from "./rpc-server.js";
|
||||
|
||||
export interface GatewayConfig {
|
||||
|
|
@ -134,6 +136,22 @@ const workbenchDispatch = (
|
|||
),
|
||||
);
|
||||
|
||||
const gatewayWorkbenchHttpApiRoutes = (
|
||||
config: GatewayConfig,
|
||||
dispatcher: DispatcherManager,
|
||||
) => {
|
||||
const handlers = HttpApiBuilder.group(
|
||||
GatewayWorkbenchHttpApi,
|
||||
"workbench",
|
||||
(handlers) =>
|
||||
handlers.handleRaw("dispatch", () => workbenchDispatch(config, dispatcher)),
|
||||
);
|
||||
|
||||
return HttpApiBuilder.layer(GatewayWorkbenchHttpApi).pipe(
|
||||
Layer.provide(handlers),
|
||||
);
|
||||
};
|
||||
|
||||
const globalDispatch = (
|
||||
config: GatewayConfig,
|
||||
dispatcher: DispatcherManager,
|
||||
|
|
@ -240,7 +258,7 @@ export const makeGatewayRoutes = (
|
|||
rpcScope: Scope.Scope,
|
||||
) =>
|
||||
Layer.mergeAll(
|
||||
HttpRouter.add("POST", "/api/v1/workbench/dispatch", workbenchDispatch(config, dispatcher)),
|
||||
gatewayWorkbenchHttpApiRoutes(config, dispatcher),
|
||||
HttpRouter.add("POST", "/api/v1/:kind", globalDispatch(config, dispatcher)),
|
||||
HttpRouter.add("POST", "/api/v1/flow/:flow/service/:kind", flowDispatch(config, dispatcher)),
|
||||
HttpRouter.add("POST", "/api/v1/flow/:flow/load", flowLoad(config, dispatcher)),
|
||||
|
|
@ -251,7 +269,7 @@ export const makeGatewayRoutes = (
|
|||
export function createGateway(config: GatewayConfig) {
|
||||
return Layer.effectDiscard(
|
||||
Effect.scoped(Effect.gen(function* () {
|
||||
const dispatcher = makeDispatcherManager(config);
|
||||
const dispatcher = yield* makeDispatcherManagerScoped(config);
|
||||
yield* dispatcher.start.pipe(
|
||||
Effect.mapError((cause) => messagingLifecycleError("gateway", "dispatcher-start", cause)),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
"include": ["src"],
|
||||
"exclude": ["src/**/*.test.ts", "src/**/*.spec.ts"],
|
||||
"references": [
|
||||
{ "path": "../base" }
|
||||
{ "path": "../base" },
|
||||
{ "path": "../client" }
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue