Skip to content

Commit 147095c

Browse files
fix(server): the server loads again from its entry
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent aee9bbf commit 147095c

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

‎apps/server/src/peer/PeerForwarding.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
OrchestratorMcpThreadInterruptResult,
77
OrchestratorMcpThreadReadInput,
88
OrchestratorMcpThreadReadResult,
9+
OrchestratorMcpThreadSendInput,
10+
OrchestratorMcpThreadSendResult,
911
OrchestratorMcpThreadWaitInput,
1012
OrchestratorMcpThreadWaitResult,
1113
} from "@t3tools/contracts";
@@ -61,6 +63,12 @@ export class PeerForwarding extends Context.Service<
6163
environmentId: EnvironmentId,
6264
input: OrchestratorMcpThreadReadInput,
6365
) => Effect.Effect<OrchestratorMcpThreadReadResult, OrchestratorMcpFailure>;
66+
/** `t3_thread_send` there. Refused while linked environments are off. */
67+
readonly sendToThread: (
68+
scope: Scope,
69+
environmentId: EnvironmentId,
70+
input: OrchestratorMcpThreadSendInput,
71+
) => Effect.Effect<OrchestratorMcpThreadSendResult, OrchestratorMcpFailure>;
6472
/** `t3_thread_interrupt` there. */
6573
readonly interruptThread: (
6674
scope: Scope,
@@ -223,6 +231,19 @@ const make = Effect.gen(function* () {
223231
return Effect.andThen(requireEnabled, forwarded);
224232
};
225233

234+
const sendToThread: PeerForwarding["Service"]["sendToThread"] = (scope, environmentId, input) =>
235+
Effect.andThen(
236+
requireEnabled,
237+
forward<OrchestratorMcpThreadSendResult>(
238+
scope,
239+
"t3_thread_send",
240+
OrchestratorMcpThreadSendInput,
241+
OrchestratorMcpThreadSendResult,
242+
environmentId,
243+
input,
244+
),
245+
);
246+
226247
/**
227248
* The next step for an agent whose machine is not linked: without it, an
228249
* empty list reads as a dead end and agents go looking elsewhere.
@@ -258,6 +279,7 @@ const make = Effect.gen(function* () {
258279
return PeerForwarding.of({
259280
call,
260281
readThread,
282+
sendToThread,
261283
interruptThread,
262284
waitForThread,
263285
links: listLinks,

‎apps/server/src/peer/RemoteDelegation.ts‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import { assertNotLinked } from "../mcp/linkOrigin.ts";
3737
import { requestIdentity } from "../mcp/requestIdentity.ts";
3838
import { readCaller, unavailable } from "../mcp/threadAccess.ts";
3939
import { ProjectToolkit } from "../mcp/toolkits/project/tools.ts";
40-
import { OrchestratorToolkit } from "../mcp/toolkits/orchestrator/tools.ts";
4140
import {
4241
resolveInteractionMode,
4342
resolveRuntimeMode,
@@ -861,12 +860,7 @@ const make = Effect.gen(function* () {
861860
const original = parent?.subagents.find((task) => task.origin === "app_owned");
862861
const remote = original?.remoteChild;
863862
if (remote === undefined || caller === undefined || parent === undefined) {
864-
return yield* forwarding.call(
865-
scope,
866-
OrchestratorToolkit.tools.t3_thread_send,
867-
input.environmentId,
868-
input,
869-
);
863+
return yield* forwarding.sendToThread(scope, input.environmentId, input);
870864
}
871865
const key = input.clientRequestId ?? (yield* random.uuidV4());
872866
const commandId = CommandId.make(
@@ -901,15 +895,10 @@ const make = Effect.gen(function* () {
901895
message: "This clientRequestId already belongs to another delegated follow-up.",
902896
});
903897
}
904-
const sent = yield* forwarding.call(
905-
scope,
906-
OrchestratorToolkit.tools.t3_thread_send,
907-
input.environmentId,
908-
{
909-
...input,
910-
clientRequestId: key,
911-
},
912-
);
898+
const sent = yield* forwarding.sendToThread(scope, input.environmentId, {
899+
...input,
900+
clientRequestId: key,
901+
});
913902
const existing = parent.subagents.find(
914903
(task) =>
915904
task.result === null &&

0 commit comments

Comments
 (0)