Skip to content

Commit 8861a14

Browse files
samsam
authored andcommitted
feat(server): let agents coordinate persistent peer threads
1 parent e1c94f7 commit 8861a14

8 files changed

Lines changed: 796 additions & 5 deletions

File tree

‎apps/server/src/mcp/McpHttpServer.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ import {
4141
DeviceStandardToolkit,
4242
} from "./toolkits/device/tools.ts";
4343

44+
import { ThreadsToolkitHandlersLive } from "./toolkits/threads/handlers.ts";
45+
import { ThreadsToolkit } from "./toolkits/threads/tools.ts";
46+
4447
const unauthorized = HttpServerResponse.jsonUnsafe(
4548
{
4649
error: "invalid_mcp_credential",
@@ -621,6 +624,10 @@ export const DeviceToolkitRegistrationLive = Layer.mergeAll(
621624
DeviceScreenshotRegistrationLive,
622625
);
623626

627+
export const ThreadsToolkitRegistrationLive = McpServer.toolkit(ThreadsToolkit).pipe(
628+
Layer.provide(ThreadsToolkitHandlersLive),
629+
);
630+
624631
const McpTransportLive = McpServer.layerHttp({
625632
name: "T3 Code",
626633
version: packageJson.version,
@@ -632,4 +639,5 @@ export const layer = Layer.mergeAll(
632639
PreviewToolkitRegistrationLive,
633640
PullRequestsToolkitRegistrationLive,
634641
DeviceToolkitRegistrationLive,
642+
ThreadsToolkitRegistrationLive,
635643
).pipe(Layer.provideMerge(McpTransportLive));

‎apps/server/src/mcp/McpInvocationContext.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import * as Context from "effect/Context";
99
import * as Effect from "effect/Effect";
1010

11-
export type McpCapability = "preview" | "device" | "pull-requests";
11+
export type McpCapability = "preview" | "device" | "pull-requests" | "threads";
1212

1313
export interface McpInvocationScope {
1414
readonly environmentId: EnvironmentId;

‎apps/server/src/mcp/McpSessionRegistry.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ it.effect("stores only a token hash, resolves the bearer token, and revokes by t
5555
}),
5656
);
5757

58-
it.effect("always grants pull-requests and gates browser and device access independently", () =>
58+
it.effect("grants thread and PR tools independently of browser and device access", () =>
5959
Effect.gen(function* () {
6060
const registry = yield* makeRegistry(() => 1_000);
6161
const withPreview = yield* registry.issue({
@@ -78,9 +78,9 @@ it.effect("always grants pull-requests and gates browser and device access indep
7878
.resolve(issued.config.authorizationHeader.replace(/^Bearer\s+/, ""))
7979
.pipe(Effect.map((scope) => [...(scope?.capabilities ?? [])].sort()));
8080

81-
expect(yield* capabilitiesOf(withPreview)).toEqual(["preview", "pull-requests"]);
82-
expect(yield* capabilitiesOf(withoutPreview)).toEqual(["pull-requests"]);
83-
expect(yield* capabilitiesOf(withDevice)).toEqual(["device", "pull-requests"]);
81+
expect(yield* capabilitiesOf(withPreview)).toEqual(["preview", "pull-requests", "threads"]);
82+
expect(yield* capabilitiesOf(withoutPreview)).toEqual(["pull-requests", "threads"]);
83+
expect(yield* capabilitiesOf(withDevice)).toEqual(["device", "pull-requests", "threads"]);
8484
}),
8585
);
8686

‎apps/server/src/mcp/McpSessionRegistry.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const makeWithOptions = Effect.fn("McpSessionRegistry.make")(function* (
131131
providerInstanceId: ProviderInstanceId.make(request.providerInstanceId),
132132
capabilities: new Set<McpInvocationContext.McpCapability>([
133133
"pull-requests",
134+
"threads",
134135
...request.capabilities,
135136
]),
136137
issuedAt,

0 commit comments

Comments
 (0)