@devries-cameron20 / t3code-1 / commits / 22384ae977
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Adopt Effect JSON and DateTime idioms (#2559)

Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>

cursor[bot] committed May 6, 2026 at 10:36 UTC 22384ae977a362c547d6f57d4e3d92bbe55ee5db
3 files changed +38 -24
packages/effect-codex-app-server/src/protocol.test.ts
+8 -4
@@ -2,6 +2,7 @@ import * as Deferred from "effect/Deferred";
2 import * as Effect from "effect/Effect";
3 import * as Fiber from "effect/Fiber";
4 import * as Queue from "effect/Queue";
5 +import * as Schema from "effect/Schema";
6 import * as Stream from "effect/Stream";
7
8 import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -13,7 +14,10 @@ import { makeInMemoryStdio } from "./_internal/stdio.ts";
14
15 const encoder = new TextEncoder();
16
16 -const encodeJsonl = (value: unknown) => encoder.encode(`${JSON.stringify(value)}\n`);
17 +const encodeJsonl = (value: unknown) =>
18 + encoder.encode(`${Schema.encodeUnknownSync(Schema.UnknownFromJsonString)(value)}\n`);
19 +
20 +const decodeJson = Schema.decodeEffect(Schema.UnknownFromJsonString);
21
22 it.layer(NodeServices.layer)("effect-codex-app-server protocol", (it) => {
23 it.effect(
@@ -60,7 +64,7 @@ it.layer(NodeServices.layer)("effect-codex-app-server protocol", (it) => {
64 const pendingInitialize = yield* transport
65 .request("initialize", initializeParams)
66 .pipe(Effect.forkScoped);
63 - assert.deepEqual(JSON.parse(yield* Queue.take(output)), {
67 + assert.deepEqual(yield* decodeJson(yield* Queue.take(output)), {
68 id: 1,
69 method: "initialize",
70 params: initializeParams,
@@ -153,7 +157,7 @@ it.layer(NodeServices.layer)("effect-codex-app-server protocol", (it) => {
157 },
158 },
159 });
156 - assert.deepEqual(JSON.parse(yield* Queue.take(output)), {
160 + assert.deepEqual(yield* decodeJson(yield* Queue.take(output)), {
161 id: 77,
162 result: {
163 answers: {
@@ -168,7 +172,7 @@ it.layer(NodeServices.layer)("effect-codex-app-server protocol", (it) => {
172 78,
173 CodexError.CodexAppServerRequestError.methodNotFound("x/test"),
174 );
171 - assert.deepEqual(JSON.parse(yield* Queue.take(output)), {
175 + assert.deepEqual(yield* decodeJson(yield* Queue.take(output)), {
176 id: 78,
177 error: {
178 code: -32601,
packages/effect-codex-app-server/src/protocol.ts
+27 -18
@@ -83,17 +83,35 @@ function isIncomingResponse(value: unknown): value is typeof JsonRpcResponseEnve
83 return Schema.is(JsonRpcResponseEnvelope)(value);
84 }
85
86 +const encodeJsonString = Schema.encodeUnknownEffect(Schema.UnknownFromJsonString);
87 +const decodeJsonString = Schema.decodeUnknownEffect(Schema.UnknownFromJsonString);
88 +
89 const encodeWireMessage = (
90 message: Record<string, unknown>,
91 ): Effect.Effect<string, CodexError.CodexAppServerProtocolParseError> =>
89 - Effect.try({
90 - try: () => `${JSON.stringify(message)}\n`,
91 - catch: (cause) =>
92 - new CodexError.CodexAppServerProtocolParseError({
93 - detail: "Failed to encode Codex App Server message",
94 - cause,
95 - }),
96 - });
92 + encodeJsonString(message).pipe(
93 + Effect.map((encoded) => `${encoded}\n`),
94 + Effect.mapError(
95 + (cause) =>
96 + new CodexError.CodexAppServerProtocolParseError({
97 + detail: "Failed to encode Codex App Server message",
98 + cause,
99 + }),
100 + ),
101 + );
102 +
103 +const decodeWireMessage = (
104 + line: string,
105 +): Effect.Effect<unknown, CodexError.CodexAppServerProtocolParseError> =>
106 + decodeJsonString(line).pipe(
107 + Effect.mapError(
108 + (cause) =>
109 + new CodexError.CodexAppServerProtocolParseError({
110 + detail: "Failed to decode Codex App Server wire message",
111 + cause,
112 + }),
113 + ),
114 + );
115
116 const normalizeIncomingError = (error: unknown, detail: string): CodexError.CodexAppServerError =>
117 Schema.is(CodexError.CodexAppServerError)(error)
@@ -284,16 +302,7 @@ export const makeCodexAppServerPatchedProtocol = Effect.fn("makeCodexAppServerPa
302 stage: "raw",
303 payload: line,
304 }).pipe(
287 - Effect.flatMap(() =>
288 - Effect.try({
289 - try: () => JSON.parse(line),
290 - catch: (cause) =>
291 - new CodexError.CodexAppServerProtocolParseError({
292 - detail: "Failed to decode Codex App Server wire message",
293 - cause,
294 - }),
295 - }),
296 - ),
305 + Effect.flatMap(() => decodeWireMessage(line)),
306 Effect.tap((decoded) =>
307 logProtocol({
308 direction: "incoming",
scripts/notify-discord-release.ts
+3 -2
@@ -2,7 +2,7 @@
2
3 import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
4 import * as NodeServices from "@effect/platform-node/NodeServices";
5 -import { Config, Data, Effect, Layer, Logger, Schema } from "effect";
5 +import { Config, Data, DateTime, Effect, Layer, Logger, Schema } from "effect";
6 import { Argument, Command, Flag } from "effect/unstable/cli";
7 import {
8 FetchHttpClient,
@@ -201,6 +201,7 @@ export const notifyDiscordReleaseCommand = Command.make(
201 );
202
203 const webhookUrl = yield* DiscordWebhookUrl;
204 + const timestamp = DateTime.formatIso(yield* DateTime.now);
205 const payload = buildDiscordReleaseAnnouncement({
206 target,
207 roleId,
@@ -208,7 +209,7 @@ export const notifyDiscordReleaseCommand = Command.make(
209 version: releaseVersion,
210 tag,
211 releaseUrl,
211 - timestamp: new Date().toISOString(),
212 + timestamp,
213 });
214
215 yield* Effect.logInfo("discord release announcement payload built").pipe(