Retain the existing event-sourced application data plane for projects and shell state while making orchestration v2 the sole agent runtime. Adapt v2 events and receipts to the shared infrastructure and remove the v1 provider reactors.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import {
|
|
type EnvironmentId,
|
|
PreviewAutomationUnavailableError,
|
|
type ProviderInstanceId,
|
|
type ThreadId,
|
|
} from "@t3tools/contracts";
|
|
import * as Context from "effect/Context";
|
|
import * as Effect from "effect/Effect";
|
|
|
|
export type McpCapability = "preview" | "orchestration";
|
|
|
|
export interface McpInvocationScope {
|
|
readonly environmentId: EnvironmentId;
|
|
readonly threadId: ThreadId;
|
|
readonly providerSessionId: string;
|
|
readonly providerInstanceId: ProviderInstanceId;
|
|
readonly capabilities: ReadonlySet<McpCapability>;
|
|
readonly issuedAt: number;
|
|
}
|
|
|
|
export class McpInvocationContext extends Context.Service<
|
|
McpInvocationContext,
|
|
McpInvocationScope
|
|
>()("t3/mcp/McpInvocationContext") {}
|
|
|
|
export const requireMcpCapability = Effect.fn("mcp.requireCapability")(function* (
|
|
capability: "preview",
|
|
) {
|
|
const invocation = yield* McpInvocationContext;
|
|
if (!invocation.capabilities.has(capability)) {
|
|
return yield* new PreviewAutomationUnavailableError({
|
|
capability,
|
|
environmentId: invocation.environmentId,
|
|
threadId: invocation.threadId,
|
|
providerSessionId: invocation.providerSessionId,
|
|
providerInstanceId: invocation.providerInstanceId,
|
|
});
|
|
}
|
|
return invocation;
|
|
});
|