[codex] Enforce canonical Node namespace imports (#3238)
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
db27502aff
commit
2fa37ec183
71 files changed
+1205
-952
No files matched your search
@@ -1,7 +1,7 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as NodePath from "node:path";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import type {
|
||||
@@ -395,7 +395,7 @@ describe("ClaudeAdapterLive", () => {
|
||||
});
|
||||
|
||||
const createInput = harness.getLastCreateQueryInput();
|
||||
assert.equal(createInput?.options.env?.HOME, path.join(os.homedir(), ".claude-work"));
|
||||
assert.equal(createInput?.options.env?.HOME, NodePath.join(NodeOS.homedir(), ".claude-work"));
|
||||
}).pipe(
|
||||
Effect.provideService(Random.Random, makeDeterministicRandomService()),
|
||||
Effect.provide(harness.layer),
|
||||
@@ -649,7 +649,7 @@ describe("ClaudeAdapterLive", () => {
|
||||
});
|
||||
|
||||
it.effect("embeds image attachments in Claude user messages", () => {
|
||||
const baseDir = mkdtempSync(path.join(os.tmpdir(), "claude-attachments-"));
|
||||
const baseDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "claude-attachments-"));
|
||||
const harness = makeHarness({
|
||||
cwd: "/tmp/project-claude-attachments",
|
||||
baseDir,
|
||||
@@ -657,7 +657,7 @@ describe("ClaudeAdapterLive", () => {
|
||||
return Effect.gen(function* () {
|
||||
yield* Effect.addFinalizer(() =>
|
||||
Effect.sync(() =>
|
||||
rmSync(baseDir, {
|
||||
NodeFS.rmSync(baseDir, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
}),
|
||||
@@ -674,9 +674,9 @@ describe("ClaudeAdapterLive", () => {
|
||||
mimeType: "image/png",
|
||||
sizeBytes: 4,
|
||||
};
|
||||
const attachmentPath = path.join(attachmentsDir, attachmentRelativePath(attachment));
|
||||
mkdirSync(path.dirname(attachmentPath), { recursive: true });
|
||||
writeFileSync(attachmentPath, Uint8Array.from([1, 2, 3, 4]));
|
||||
const attachmentPath = NodePath.join(attachmentsDir, attachmentRelativePath(attachment));
|
||||
NodeFS.mkdirSync(NodePath.dirname(attachmentPath), { recursive: true });
|
||||
NodeFS.writeFileSync(attachmentPath, Uint8Array.from([1, 2, 3, 4]));
|
||||
|
||||
const session = yield* adapter.startSession({
|
||||
threadId: THREAD_ID,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import * as NodeAssert from "node:assert/strict";
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as NodePath from "node:path";
|
||||
import {
|
||||
ApprovalRequestId,
|
||||
CodexSettings,
|
||||
@@ -250,8 +250,8 @@ validationLayer("CodexAdapterLive validation", (it) => {
|
||||
})
|
||||
.pipe(Effect.result);
|
||||
|
||||
assert.equal(result._tag, "Failure");
|
||||
assert.deepStrictEqual(
|
||||
NodeAssert.equal(result._tag, "Failure");
|
||||
NodeAssert.deepStrictEqual(
|
||||
result.failure,
|
||||
new ProviderAdapterValidationError({
|
||||
provider: ProviderDriverKind.make("codex"),
|
||||
@@ -259,7 +259,7 @@ validationLayer("CodexAdapterLive validation", (it) => {
|
||||
issue: "Expected provider 'codex' but received 'claudeAgent'.",
|
||||
}),
|
||||
);
|
||||
assert.equal(validationRuntimeFactory.factory.mock.calls.length, 0);
|
||||
NodeAssert.equal(validationRuntimeFactory.factory.mock.calls.length, 0);
|
||||
}),
|
||||
);
|
||||
it.effect("maps codex model options before starting a session", () =>
|
||||
@@ -276,7 +276,7 @@ validationLayer("CodexAdapterLive validation", (it) => {
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(validationRuntimeFactory.factory.mock.calls[0]?.[0], {
|
||||
NodeAssert.deepStrictEqual(validationRuntimeFactory.factory.mock.calls[0]?.[0], {
|
||||
binaryPath: "codex",
|
||||
cwd: process.cwd(),
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -319,10 +319,10 @@ sessionErrorLayer("CodexAdapterLive session errors", (it) => {
|
||||
})
|
||||
.pipe(Effect.result);
|
||||
|
||||
assert.equal(result._tag, "Failure");
|
||||
assert.equal(result.failure._tag, "ProviderAdapterSessionNotFoundError");
|
||||
assert.equal(result.failure.provider, "codex");
|
||||
assert.equal(result.failure.threadId, "sess-missing");
|
||||
NodeAssert.equal(result._tag, "Failure");
|
||||
NodeAssert.equal(result.failure._tag, "ProviderAdapterSessionNotFoundError");
|
||||
NodeAssert.equal(result.failure.provider, "codex");
|
||||
NodeAssert.equal(result.failure.threadId, "sess-missing");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -335,7 +335,7 @@ sessionErrorLayer("CodexAdapterLive session errors", (it) => {
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
const runtime = sessionRuntimeFactory.lastRuntime;
|
||||
assert.ok(runtime);
|
||||
NodeAssert.ok(runtime);
|
||||
runtime.sendTurnImpl.mockClear();
|
||||
|
||||
yield* Effect.ignore(
|
||||
@@ -350,7 +350,7 @@ sessionErrorLayer("CodexAdapterLive session errors", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(runtime.sendTurnImpl.mock.calls[0]?.[0], {
|
||||
NodeAssert.deepStrictEqual(runtime.sendTurnImpl.mock.calls[0]?.[0], {
|
||||
input: "hello",
|
||||
model: "gpt-5.3-codex",
|
||||
effort: "high",
|
||||
@@ -386,7 +386,7 @@ sessionErrorLayer("CodexAdapterLive session errors", (it) => {
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
const runtime = customRuntimeFactory.lastRuntime;
|
||||
assert.ok(runtime);
|
||||
NodeAssert.ok(runtime);
|
||||
runtime.sendTurnImpl.mockClear();
|
||||
|
||||
yield* Effect.ignore(
|
||||
@@ -405,7 +405,7 @@ sessionErrorLayer("CodexAdapterLive session errors", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(runtime.sendTurnImpl.mock.calls[0]?.[0], {
|
||||
NodeAssert.deepStrictEqual(runtime.sendTurnImpl.mock.calls[0]?.[0], {
|
||||
input: "hello",
|
||||
model: "gpt-5.3-codex",
|
||||
effort: "high",
|
||||
@@ -442,7 +442,7 @@ function startLifecycleRuntime() {
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
const runtime = lifecycleRuntimeFactory.lastRuntime;
|
||||
assert.ok(runtime);
|
||||
NodeAssert.ok(runtime);
|
||||
return { adapter, runtime };
|
||||
});
|
||||
}
|
||||
@@ -477,17 +477,17 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
yield* runtime.emit(event);
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "item.completed");
|
||||
NodeAssert.equal(firstEvent.value.type, "item.completed");
|
||||
if (firstEvent.value.type !== "item.completed") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.itemId, "msg_1");
|
||||
assert.equal(firstEvent.value.turnId, "turn-1");
|
||||
assert.equal(firstEvent.value.payload.itemType, "assistant_message");
|
||||
NodeAssert.equal(firstEvent.value.itemId, "msg_1");
|
||||
NodeAssert.equal(firstEvent.value.turnId, "turn-1");
|
||||
NodeAssert.equal(firstEvent.value.payload.itemType, "assistant_message");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -524,13 +524,13 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
});
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some" || firstEvent.value.type !== "item.completed") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.payload.itemType, "mcp_tool_call");
|
||||
assert.equal(firstEvent.value.payload.title, "t3-code · preview_status");
|
||||
assert.deepStrictEqual(firstEvent.value.payload.data, {
|
||||
NodeAssert.equal(firstEvent.value.payload.itemType, "mcp_tool_call");
|
||||
NodeAssert.equal(firstEvent.value.payload.title, "t3-code · preview_status");
|
||||
NodeAssert.deepStrictEqual(firstEvent.value.payload.data, {
|
||||
completedAtMs: 1_778_000_000_000,
|
||||
threadId: "thread-1",
|
||||
turnId: "turn-1",
|
||||
@@ -578,16 +578,16 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
yield* runtime.emit(event);
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "turn.proposed.completed");
|
||||
NodeAssert.equal(firstEvent.value.type, "turn.proposed.completed");
|
||||
if (firstEvent.value.type !== "turn.proposed.completed") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.turnId, "turn-1");
|
||||
assert.equal(firstEvent.value.payload.planMarkdown, "## Final plan\n\n- one\n- two");
|
||||
NodeAssert.equal(firstEvent.value.turnId, "turn-1");
|
||||
NodeAssert.equal(firstEvent.value.payload.planMarkdown, "## Final plan\n\n- one\n- two");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -615,16 +615,16 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "turn.proposed.delta");
|
||||
NodeAssert.equal(firstEvent.value.type, "turn.proposed.delta");
|
||||
if (firstEvent.value.type !== "turn.proposed.delta") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.turnId, "turn-1");
|
||||
assert.equal(firstEvent.value.payload.delta, "## Final plan");
|
||||
NodeAssert.equal(firstEvent.value.turnId, "turn-1");
|
||||
NodeAssert.equal(firstEvent.value.payload.delta, "## Final plan");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -646,16 +646,16 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
yield* runtime.emit(event);
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "session.exited");
|
||||
NodeAssert.equal(firstEvent.value.type, "session.exited");
|
||||
if (firstEvent.value.type !== "session.exited") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.threadId, "thread-1");
|
||||
assert.equal(firstEvent.value.payload.reason, "Session stopped");
|
||||
NodeAssert.equal(firstEvent.value.threadId, "thread-1");
|
||||
NodeAssert.equal(firstEvent.value.payload.reason, "Session stopped");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -684,16 +684,16 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "runtime.warning");
|
||||
NodeAssert.equal(firstEvent.value.type, "runtime.warning");
|
||||
if (firstEvent.value.type !== "runtime.warning") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.turnId, "turn-1");
|
||||
assert.equal(firstEvent.value.payload.message, "Reconnecting... 2/5");
|
||||
NodeAssert.equal(firstEvent.value.turnId, "turn-1");
|
||||
NodeAssert.equal(firstEvent.value.payload.message, "Reconnecting... 2/5");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -715,16 +715,16 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "runtime.warning");
|
||||
NodeAssert.equal(firstEvent.value.type, "runtime.warning");
|
||||
if (firstEvent.value.type !== "runtime.warning") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.turnId, "turn-1");
|
||||
assert.equal(
|
||||
NodeAssert.equal(firstEvent.value.turnId, "turn-1");
|
||||
NodeAssert.equal(
|
||||
firstEvent.value.payload.message,
|
||||
"The filename or extension is too long. (os error 206)",
|
||||
);
|
||||
@@ -752,16 +752,16 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "thread.realtime.started");
|
||||
NodeAssert.equal(firstEvent.value.type, "thread.realtime.started");
|
||||
if (firstEvent.value.type !== "thread.realtime.started") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.threadId, "thread-1");
|
||||
assert.equal(firstEvent.value.payload.realtimeSessionId, "realtime-session-1");
|
||||
NodeAssert.equal(firstEvent.value.threadId, "thread-1");
|
||||
NodeAssert.equal(firstEvent.value.payload.realtimeSessionId, "realtime-session-1");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -784,17 +784,17 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "runtime.error");
|
||||
NodeAssert.equal(firstEvent.value.type, "runtime.error");
|
||||
if (firstEvent.value.type !== "runtime.error") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.turnId, "turn-1");
|
||||
assert.equal(firstEvent.value.payload.class, "provider_error");
|
||||
assert.equal(
|
||||
NodeAssert.equal(firstEvent.value.turnId, "turn-1");
|
||||
NodeAssert.equal(firstEvent.value.payload.class, "provider_error");
|
||||
NodeAssert.equal(
|
||||
firstEvent.value.payload.message,
|
||||
"2026-03-31T18:14:06.833399Z ERROR codex_api::endpoint::responses_websocket: failed to connect to websocket: HTTP error: 503 Service Unavailable, url: wss://chatgpt.com/backend-api/codex/responses",
|
||||
);
|
||||
@@ -824,15 +824,15 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
yield* runtime.emit(event);
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "request.resolved");
|
||||
NodeAssert.equal(firstEvent.value.type, "request.resolved");
|
||||
if (firstEvent.value.type !== "request.resolved") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.payload.requestType, "command_execution_approval");
|
||||
NodeAssert.equal(firstEvent.value.payload.requestType, "command_execution_approval");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -859,15 +859,15 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
yield* runtime.emit(event);
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "request.resolved");
|
||||
NodeAssert.equal(firstEvent.value.type, "request.resolved");
|
||||
if (firstEvent.value.type !== "request.resolved") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.payload.requestType, "file_read_approval");
|
||||
NodeAssert.equal(firstEvent.value.payload.requestType, "file_read_approval");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -895,15 +895,15 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
yield* runtime.emit(event);
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "user-input.resolved");
|
||||
NodeAssert.equal(firstEvent.value.type, "user-input.resolved");
|
||||
if (firstEvent.value.type !== "user-input.resolved") {
|
||||
return;
|
||||
}
|
||||
assert.deepEqual(firstEvent.value.payload.answers, {
|
||||
NodeAssert.deepEqual(firstEvent.value.payload.answers, {
|
||||
scope: [],
|
||||
});
|
||||
}),
|
||||
@@ -934,20 +934,20 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
yield* runtime.emit(event);
|
||||
const events = Array.from(yield* Fiber.join(eventsFiber));
|
||||
|
||||
assert.equal(events.length, 2);
|
||||
NodeAssert.equal(events.length, 2);
|
||||
|
||||
const firstEvent = events[0];
|
||||
const secondEvent = events[1];
|
||||
|
||||
assert.equal(firstEvent?.type, "session.state.changed");
|
||||
NodeAssert.equal(firstEvent?.type, "session.state.changed");
|
||||
if (firstEvent?.type === "session.state.changed") {
|
||||
assert.equal(firstEvent.payload.state, "error");
|
||||
assert.equal(firstEvent.payload.reason, "Sandbox setup failed");
|
||||
NodeAssert.equal(firstEvent.payload.state, "error");
|
||||
NodeAssert.equal(firstEvent.payload.reason, "Sandbox setup failed");
|
||||
}
|
||||
|
||||
assert.equal(secondEvent?.type, "runtime.warning");
|
||||
NodeAssert.equal(secondEvent?.type, "runtime.warning");
|
||||
if (secondEvent?.type === "runtime.warning") {
|
||||
assert.equal(secondEvent.payload.message, "Sandbox setup failed");
|
||||
NodeAssert.equal(secondEvent.payload.message, "Sandbox setup failed");
|
||||
}
|
||||
}),
|
||||
);
|
||||
@@ -1006,17 +1006,17 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
} satisfies ProviderEvent);
|
||||
|
||||
const events = Array.from(yield* Fiber.join(eventsFiber));
|
||||
assert.equal(events[0]?.type, "user-input.requested");
|
||||
NodeAssert.equal(events[0]?.type, "user-input.requested");
|
||||
if (events[0]?.type === "user-input.requested") {
|
||||
assert.equal(events[0].requestId, "req-user-input-1");
|
||||
assert.equal(events[0].payload.questions[0]?.id, "sandbox_mode");
|
||||
assert.equal(events[0].payload.questions[0]?.multiSelect, false);
|
||||
NodeAssert.equal(events[0].requestId, "req-user-input-1");
|
||||
NodeAssert.equal(events[0].payload.questions[0]?.id, "sandbox_mode");
|
||||
NodeAssert.equal(events[0].payload.questions[0]?.multiSelect, false);
|
||||
}
|
||||
|
||||
assert.equal(events[1]?.type, "user-input.resolved");
|
||||
NodeAssert.equal(events[1]?.type, "user-input.resolved");
|
||||
if (events[1]?.type === "user-input.resolved") {
|
||||
assert.equal(events[1].requestId, "req-user-input-1");
|
||||
assert.deepEqual(events[1].payload.answers, {
|
||||
NodeAssert.equal(events[1].requestId, "req-user-input-1");
|
||||
NodeAssert.deepEqual(events[1].payload.answers, {
|
||||
sandbox_mode: "workspace-write",
|
||||
});
|
||||
}
|
||||
@@ -1060,16 +1060,16 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
} satisfies ProviderEvent);
|
||||
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "thread.token-usage.updated");
|
||||
NodeAssert.equal(firstEvent.value.type, "thread.token-usage.updated");
|
||||
if (firstEvent.value.type !== "thread.token-usage.updated") {
|
||||
return;
|
||||
}
|
||||
|
||||
assert.deepEqual(firstEvent.value.payload.usage, {
|
||||
NodeAssert.deepEqual(firstEvent.value.payload.usage, {
|
||||
usedTokens: 126,
|
||||
totalProcessedTokens: 11_839,
|
||||
maxTokens: 258_400,
|
||||
@@ -1119,15 +1119,15 @@ scopedLifecycleLayer("CodexAdapterLive scoped lifecycle", (it) => {
|
||||
});
|
||||
|
||||
const runtime = scopedLifecycleRuntimeFactory.lastRuntime;
|
||||
assert.ok(runtime);
|
||||
NodeAssert.ok(runtime);
|
||||
|
||||
yield* adapter.stopSession(asThreadId("thread-stop"));
|
||||
|
||||
assert.equal(runtime.closeImpl.mock.calls.length, 1);
|
||||
assert.deepStrictEqual(scopedLifecycleRuntimeFactory.releasedThreadIds, [
|
||||
NodeAssert.equal(runtime.closeImpl.mock.calls.length, 1);
|
||||
NodeAssert.deepStrictEqual(scopedLifecycleRuntimeFactory.releasedThreadIds, [
|
||||
asThreadId("thread-stop"),
|
||||
]);
|
||||
assert.equal(yield* adapter.hasSession(asThreadId("thread-stop")), false);
|
||||
NodeAssert.equal(yield* adapter.hasSession(asThreadId("thread-stop")), false);
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -1164,20 +1164,22 @@ scopedFailureLayer("CodexAdapterLive scoped startup failure", (it) => {
|
||||
})
|
||||
.pipe(Effect.result);
|
||||
|
||||
assert.equal(result._tag, "Failure");
|
||||
assert.equal(result.failure._tag, "ProviderAdapterProcessError");
|
||||
assert.deepStrictEqual(scopedFailureRuntimeFactory.releasedThreadIds, [
|
||||
NodeAssert.equal(result._tag, "Failure");
|
||||
NodeAssert.equal(result.failure._tag, "ProviderAdapterProcessError");
|
||||
NodeAssert.deepStrictEqual(scopedFailureRuntimeFactory.releasedThreadIds, [
|
||||
asThreadId("thread-fail"),
|
||||
]);
|
||||
assert.equal(yield* adapter.hasSession(asThreadId("thread-fail")), false);
|
||||
NodeAssert.equal(yield* adapter.hasSession(asThreadId("thread-fail")), false);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it.effect("flushes managed native logs when the adapter layer shuts down", () =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-codex-adapter-native-log-"));
|
||||
const basePath = path.join(tempDir, "provider-native.ndjson");
|
||||
const tempDir = NodeFS.mkdtempSync(
|
||||
NodePath.join(NodeOS.tmpdir(), "t3-codex-adapter-native-log-"),
|
||||
);
|
||||
const basePath = NodePath.join(tempDir, "provider-native.ndjson");
|
||||
const runtimeFactory = makeRuntimeFactory();
|
||||
const scope = yield* Scope.make("sequential");
|
||||
let scopeClosed = false;
|
||||
@@ -1208,7 +1210,7 @@ it.effect("flushes managed native logs when the adapter layer shuts down", () =>
|
||||
});
|
||||
|
||||
const runtime = runtimeFactory.lastRuntime;
|
||||
assert.ok(runtime);
|
||||
NodeAssert.ok(runtime);
|
||||
|
||||
const firstEventFiber = yield* Stream.runHead(adapter.streamEvents).pipe(Effect.forkChild);
|
||||
yield* runtime.emit({
|
||||
@@ -1225,15 +1227,15 @@ it.effect("flushes managed native logs when the adapter layer shuts down", () =>
|
||||
yield* Scope.close(scope, Exit.void);
|
||||
scopeClosed = true;
|
||||
|
||||
const threadLogPath = path.join(tempDir, "thread-logger.log");
|
||||
assert.equal(fs.existsSync(threadLogPath), true);
|
||||
const contents = fs.readFileSync(threadLogPath, "utf8");
|
||||
assert.match(contents, /NTIVE: .*"message":"native flush test"/);
|
||||
const threadLogPath = NodePath.join(tempDir, "thread-logger.log");
|
||||
NodeAssert.equal(NodeFS.existsSync(threadLogPath), true);
|
||||
const contents = NodeFS.readFileSync(threadLogPath, "utf8");
|
||||
NodeAssert.match(contents, /NTIVE: .*"message":"native flush test"/);
|
||||
} finally {
|
||||
if (!scopeClosed) {
|
||||
yield* Scope.close(scope, Exit.void);
|
||||
}
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
NodeFS.rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
}),
|
||||
);
|
||||
@@ -1,4 +1,4 @@
|
||||
import assert from "node:assert/strict";
|
||||
import * as NodeAssert from "node:assert/strict";
|
||||
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Schema from "effect/Schema";
|
||||
@@ -55,7 +55,7 @@ describe("buildTurnStartParams", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(params, {
|
||||
NodeAssert.deepStrictEqual(params, {
|
||||
threadId: "provider-thread-1",
|
||||
approvalPolicy: "never",
|
||||
sandboxPolicy: {
|
||||
@@ -97,7 +97,7 @@ describe("buildTurnStartParams", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(params, {
|
||||
NodeAssert.deepStrictEqual(params, {
|
||||
threadId: "provider-thread-1",
|
||||
approvalPolicy: "on-request",
|
||||
sandboxPolicy: {
|
||||
@@ -134,7 +134,7 @@ describe("buildTurnStartParams", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(params, {
|
||||
NodeAssert.deepStrictEqual(params, {
|
||||
threadId: "provider-thread-1",
|
||||
approvalPolicy: "untrusted",
|
||||
sandboxPolicy: {
|
||||
@@ -156,19 +156,19 @@ describe("T3 browser developer instructions", () => {
|
||||
CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
]) {
|
||||
assert.match(instructions, /t3-code/);
|
||||
assert.match(instructions, /preview_status/);
|
||||
assert.match(instructions, /preview_open/);
|
||||
assert.match(instructions, /Do not switch to global browser skills/);
|
||||
NodeAssert.match(instructions, /t3-code/);
|
||||
NodeAssert.match(instructions, /preview_status/);
|
||||
NodeAssert.match(instructions, /preview_open/);
|
||||
NodeAssert.match(instructions, /Do not switch to global browser skills/);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("hasConfiguredMcpServer", () => {
|
||||
it("detects inline Codex MCP configuration arguments", () => {
|
||||
assert.equal(hasConfiguredMcpServer(undefined), false);
|
||||
assert.equal(hasConfiguredMcpServer(["--model", "gpt-5.4"]), false);
|
||||
assert.equal(
|
||||
NodeAssert.equal(hasConfiguredMcpServer(undefined), false);
|
||||
NodeAssert.equal(hasConfiguredMcpServer(["--model", "gpt-5.4"]), false);
|
||||
NodeAssert.equal(
|
||||
hasConfiguredMcpServer(["-c", 'mcp_servers.t3-code.url="http://127.0.0.1/mcp"']),
|
||||
true,
|
||||
);
|
||||
@@ -177,7 +177,7 @@ describe("hasConfiguredMcpServer", () => {
|
||||
|
||||
describe("isRecoverableThreadResumeError", () => {
|
||||
it("matches missing thread errors", () => {
|
||||
assert.equal(
|
||||
NodeAssert.equal(
|
||||
isRecoverableThreadResumeError(
|
||||
new CodexErrors.CodexAppServerRequestError({
|
||||
code: -32603,
|
||||
@@ -189,7 +189,7 @@ describe("isRecoverableThreadResumeError", () => {
|
||||
});
|
||||
|
||||
it("ignores non-recoverable resume errors", () => {
|
||||
assert.equal(
|
||||
NodeAssert.equal(
|
||||
isRecoverableThreadResumeError(
|
||||
new CodexErrors.CodexAppServerRequestError({
|
||||
code: -32603,
|
||||
@@ -201,7 +201,7 @@ describe("isRecoverableThreadResumeError", () => {
|
||||
});
|
||||
|
||||
it("ignores unrelated missing-resource errors that do not mention threads", () => {
|
||||
assert.equal(
|
||||
NodeAssert.equal(
|
||||
isRecoverableThreadResumeError(
|
||||
new CodexErrors.CodexAppServerRequestError({
|
||||
code: -32603,
|
||||
@@ -210,7 +210,7 @@ describe("isRecoverableThreadResumeError", () => {
|
||||
),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
NodeAssert.equal(
|
||||
isRecoverableThreadResumeError(
|
||||
new CodexErrors.CodexAppServerRequestError({
|
||||
code: -32603,
|
||||
@@ -256,8 +256,8 @@ describe("openCodexThread", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
assert.equal(opened.thread.id, "fresh-thread");
|
||||
assert.deepStrictEqual(
|
||||
NodeAssert.equal(opened.thread.id, "fresh-thread");
|
||||
NodeAssert.deepStrictEqual(
|
||||
calls.map((call) => call.method),
|
||||
["thread/resume", "thread/start"],
|
||||
);
|
||||
@@ -283,7 +283,7 @@ describe("openCodexThread", () => {
|
||||
},
|
||||
};
|
||||
|
||||
await assert.rejects(
|
||||
await NodeAssert.rejects(
|
||||
Effect.runPromise(
|
||||
openCodexThread({
|
||||
client,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import * as path from "node:path";
|
||||
import * as os from "node:os";
|
||||
import { chmod, mkdtemp, readFile, writeFile } from "node:fs/promises";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import * as NodePath from "node:path";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as NodeFSP from "node:fs/promises";
|
||||
import * as NodeURL from "node:url";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
@@ -36,8 +36,8 @@ class CursorAdapter extends Context.Service<CursorAdapter, CursorAdapterShape>()
|
||||
"t3/provider/Layers/CursorAdapter.test/CursorAdapter",
|
||||
) {}
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const mockAgentPath = path.join(__dirname, "../../../scripts/acp-mock-agent.ts");
|
||||
const __dirname = NodePath.dirname(NodeURL.fileURLToPath(import.meta.url));
|
||||
const mockAgentPath = NodePath.join(__dirname, "../../../scripts/acp-mock-agent.ts");
|
||||
const mockAgentCommand = "node";
|
||||
const mockAgentArgs = [mockAgentPath] as const;
|
||||
|
||||
@@ -45,8 +45,8 @@ async function makeMockAgentWrapper(
|
||||
extraEnv?: Record<string, string>,
|
||||
options?: { initialDelaySeconds?: number },
|
||||
) {
|
||||
const dir = await mkdtemp(path.join(os.tmpdir(), "cursor-acp-mock-"));
|
||||
const wrapperPath = path.join(dir, "fake-agent.sh");
|
||||
const dir = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-acp-mock-"));
|
||||
const wrapperPath = NodePath.join(dir, "fake-agent.sh");
|
||||
const envExports = Object.entries(extraEnv ?? {})
|
||||
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
||||
.join("\n");
|
||||
@@ -55,8 +55,8 @@ ${envExports}
|
||||
${options?.initialDelaySeconds ? `sleep ${JSON.stringify(String(options.initialDelaySeconds))}` : ""}
|
||||
exec ${JSON.stringify(mockAgentCommand)} ${mockAgentArgs.map((arg) => JSON.stringify(arg)).join(" ")} "$@"
|
||||
`;
|
||||
await writeFile(wrapperPath, script, "utf8");
|
||||
await chmod(wrapperPath, 0o755);
|
||||
await NodeFSP.writeFile(wrapperPath, script, "utf8");
|
||||
await NodeFSP.chmod(wrapperPath, 0o755);
|
||||
return wrapperPath;
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ async function makeProbeWrapper(
|
||||
argvLogPath: string,
|
||||
extraEnv?: Record<string, string>,
|
||||
) {
|
||||
const dir = await mkdtemp(path.join(os.tmpdir(), "cursor-acp-probe-"));
|
||||
const wrapperPath = path.join(dir, "fake-agent.sh");
|
||||
const dir = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-acp-probe-"));
|
||||
const wrapperPath = NodePath.join(dir, "fake-agent.sh");
|
||||
const envExports = Object.entries(extraEnv ?? {})
|
||||
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
||||
.join("\n");
|
||||
@@ -77,13 +77,13 @@ export T3_ACP_REQUEST_LOG_PATH=${JSON.stringify(requestLogPath)}
|
||||
${envExports}
|
||||
exec ${JSON.stringify(mockAgentCommand)} ${mockAgentArgs.map((arg) => JSON.stringify(arg)).join(" ")} "$@"
|
||||
`;
|
||||
await writeFile(wrapperPath, script, "utf8");
|
||||
await chmod(wrapperPath, 0o755);
|
||||
await NodeFSP.writeFile(wrapperPath, script, "utf8");
|
||||
await NodeFSP.chmod(wrapperPath, 0o755);
|
||||
return wrapperPath;
|
||||
}
|
||||
|
||||
async function readArgvLog(filePath: string) {
|
||||
const raw = await readFile(filePath, "utf8");
|
||||
const raw = await NodeFSP.readFile(filePath, "utf8");
|
||||
return raw
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
@@ -92,7 +92,7 @@ async function readArgvLog(filePath: string) {
|
||||
}
|
||||
|
||||
async function readJsonLines(filePath: string) {
|
||||
const raw = await readFile(filePath, "utf8");
|
||||
const raw = await NodeFSP.readFile(filePath, "utf8");
|
||||
return raw
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
@@ -103,7 +103,7 @@ async function readJsonLines(filePath: string) {
|
||||
async function waitForFileContent(filePath: string, attempts = 40) {
|
||||
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
||||
try {
|
||||
const raw = await readFile(filePath, "utf8");
|
||||
const raw = await NodeFSP.readFile(filePath, "utf8");
|
||||
if (raw.trim().length > 0) {
|
||||
return raw;
|
||||
}
|
||||
@@ -315,9 +315,9 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
const settings = yield* ServerSettingsService;
|
||||
const threadId = ThreadId.make("cursor-stop-session-close");
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
mkdtemp(path.join(os.tmpdir(), "cursor-adapter-exit-log-")),
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-adapter-exit-log-")),
|
||||
);
|
||||
const exitLogPath = path.join(tempDir, "exit.log");
|
||||
const exitLogPath = NodePath.join(tempDir, "exit.log");
|
||||
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeMockAgentWrapper({
|
||||
@@ -349,9 +349,9 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
const settings = yield* ServerSettingsService;
|
||||
const threadId = ThreadId.make("cursor-concurrent-start-session");
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
mkdtemp(path.join(os.tmpdir(), "cursor-adapter-concurrent-exit-log-")),
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-adapter-concurrent-exit-log-")),
|
||||
);
|
||||
const exitLogPath = path.join(tempDir, "exit.log");
|
||||
const exitLogPath = NodePath.join(tempDir, "exit.log");
|
||||
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeMockAgentWrapper(
|
||||
@@ -414,10 +414,12 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const serverSettings = yield* ServerSettingsService;
|
||||
const threadId = ThreadId.make("cursor-plan-mode-probe");
|
||||
const tempDir = yield* Effect.promise(() => mkdtemp(path.join(os.tmpdir(), "cursor-acp-")));
|
||||
const requestLogPath = path.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = path.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => writeFile(requestLogPath, "", "utf8"));
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-acp-")),
|
||||
);
|
||||
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = NodePath.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => NodeFSP.writeFile(requestLogPath, "", "utf8"));
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeProbeWrapper(requestLogPath, argvLogPath),
|
||||
);
|
||||
@@ -470,10 +472,12 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const serverSettings = yield* ServerSettingsService;
|
||||
const threadId = ThreadId.make("cursor-initial-config-probe");
|
||||
const tempDir = yield* Effect.promise(() => mkdtemp(path.join(os.tmpdir(), "cursor-acp-")));
|
||||
const requestLogPath = path.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = path.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => writeFile(requestLogPath, "", "utf8"));
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-acp-")),
|
||||
);
|
||||
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = NodePath.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => NodeFSP.writeFile(requestLogPath, "", "utf8"));
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeProbeWrapper(requestLogPath, argvLogPath),
|
||||
);
|
||||
@@ -713,10 +717,12 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
const runtimeEvents: Array<ProviderRuntimeEvent> = [];
|
||||
const settledEventTypes = new Set<string>();
|
||||
const settledEventsReady = yield* Deferred.make<void>();
|
||||
const tempDir = yield* Effect.promise(() => mkdtemp(path.join(os.tmpdir(), "cursor-acp-")));
|
||||
const requestLogPath = path.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = path.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => writeFile(requestLogPath, "", "utf8"));
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-acp-")),
|
||||
);
|
||||
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = NodePath.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => NodeFSP.writeFile(requestLogPath, "", "utf8"));
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeProbeWrapper(requestLogPath, argvLogPath, { T3_ACP_EMIT_TOOL_CALLS: "1" }),
|
||||
);
|
||||
@@ -931,10 +937,12 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const serverSettings = yield* ServerSettingsService;
|
||||
const threadId = ThreadId.make("cursor-cancel-probe");
|
||||
const tempDir = yield* Effect.promise(() => mkdtemp(path.join(os.tmpdir(), "cursor-acp-")));
|
||||
const requestLogPath = path.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = path.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => writeFile(requestLogPath, "", "utf8"));
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-acp-")),
|
||||
);
|
||||
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = NodePath.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => NodeFSP.writeFile(requestLogPath, "", "utf8"));
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeProbeWrapper(requestLogPath, argvLogPath, { T3_ACP_EMIT_TOOL_CALLS: "1" }),
|
||||
);
|
||||
@@ -1192,10 +1200,12 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const serverSettings = yield* ServerSettingsService;
|
||||
const threadId = ThreadId.make("cursor-model-switch");
|
||||
const tempDir = yield* Effect.promise(() => mkdtemp(path.join(os.tmpdir(), "cursor-acp-")));
|
||||
const requestLogPath = path.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = path.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => writeFile(requestLogPath, "", "utf8"));
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-acp-")),
|
||||
);
|
||||
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = NodePath.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => NodeFSP.writeFile(requestLogPath, "", "utf8"));
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeProbeWrapper(requestLogPath, argvLogPath),
|
||||
);
|
||||
@@ -1255,10 +1265,12 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const serverSettings = yield* ServerSettingsService;
|
||||
const threadId = ThreadId.make("cursor-fast-mode-reset");
|
||||
const tempDir = yield* Effect.promise(() => mkdtemp(path.join(os.tmpdir(), "cursor-acp-")));
|
||||
const requestLogPath = path.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = path.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => writeFile(requestLogPath, "", "utf8"));
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-acp-")),
|
||||
);
|
||||
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = NodePath.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => NodeFSP.writeFile(requestLogPath, "", "utf8"));
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeProbeWrapper(requestLogPath, argvLogPath),
|
||||
);
|
||||
@@ -1339,10 +1351,12 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const serverSettings = yield* ServerSettingsService;
|
||||
const threadId = ThreadId.make("cursor-fast-mode-custom-instance");
|
||||
const tempDir = yield* Effect.promise(() => mkdtemp(path.join(os.tmpdir(), "cursor-acp-")));
|
||||
const requestLogPath = path.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = path.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => writeFile(requestLogPath, "", "utf8"));
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "cursor-acp-")),
|
||||
);
|
||||
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
|
||||
const argvLogPath = NodePath.join(tempDir, "argv.txt");
|
||||
yield* Effect.promise(() => NodeFSP.writeFile(requestLogPath, "", "utf8"));
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeProbeWrapper(requestLogPath, argvLogPath),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as NodeOs from "node:os";
|
||||
import * as NodeOS from "node:os";
|
||||
import type {
|
||||
CursorSettings,
|
||||
ModelCapabilities,
|
||||
@@ -746,7 +746,7 @@ function isCursorAboutJsonFormatUnsupported(result: CommandResult): boolean {
|
||||
const readCursorCliConfigChannel = Effect.fn("readCursorCliConfigChannel")(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const configPath = path.join(NodeOs.homedir(), ".cursor", "cli-config.json");
|
||||
const configPath = path.join(NodeOS.homedir(), ".cursor", "cli-config.json");
|
||||
const raw = yield* fileSystem.readFileString(configPath).pipe(Effect.orElseSucceed(() => ""));
|
||||
return parseCursorCliConfigChannel(raw);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as NodePath from "node:path";
|
||||
|
||||
import { ThreadId } from "@t3tools/contracts";
|
||||
import { assert, describe, it } from "@effect/vitest";
|
||||
@@ -31,8 +31,8 @@ function parseLogLine(line: string) {
|
||||
describe("EventNdjsonLogger", () => {
|
||||
it.effect("writes effect-style lines to thread-scoped files", () =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-provider-log-"));
|
||||
const basePath = path.join(tempDir, "provider-native.ndjson");
|
||||
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-provider-log-"));
|
||||
const basePath = NodePath.join(tempDir, "provider-native.ndjson");
|
||||
|
||||
try {
|
||||
const logger = yield* makeEventNdjsonLogger(basePath, { stream: "native" });
|
||||
@@ -51,13 +51,13 @@ describe("EventNdjsonLogger", () => {
|
||||
);
|
||||
yield* logger.close();
|
||||
|
||||
const threadOnePath = path.join(tempDir, "thread-1.log");
|
||||
const threadTwoPath = path.join(tempDir, "thread-2.log");
|
||||
assert.equal(fs.existsSync(threadOnePath), true);
|
||||
assert.equal(fs.existsSync(threadTwoPath), true);
|
||||
const threadOnePath = NodePath.join(tempDir, "thread-1.log");
|
||||
const threadTwoPath = NodePath.join(tempDir, "thread-2.log");
|
||||
assert.equal(NodeFS.existsSync(threadOnePath), true);
|
||||
assert.equal(NodeFS.existsSync(threadTwoPath), true);
|
||||
|
||||
const first = parseLogLine(fs.readFileSync(threadOnePath, "utf8").trim());
|
||||
const second = parseLogLine(fs.readFileSync(threadTwoPath, "utf8").trim());
|
||||
const first = parseLogLine(NodeFS.readFileSync(threadOnePath, "utf8").trim());
|
||||
const second = parseLogLine(NodeFS.readFileSync(threadTwoPath, "utf8").trim());
|
||||
|
||||
assert.equal(Number.isNaN(Date.parse(first.observedAt)), false);
|
||||
assert.equal(first.stream, "NTIVE");
|
||||
@@ -70,7 +70,7 @@ describe("EventNdjsonLogger", () => {
|
||||
'{"type":"turn.completed","threadId":"provider-thread-2","id":"evt-2"}',
|
||||
);
|
||||
} finally {
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
NodeFS.rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
}),
|
||||
);
|
||||
@@ -79,8 +79,8 @@ describe("EventNdjsonLogger", () => {
|
||||
"falls back to a global segment when orchestration thread id is missing or invalid",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-provider-log-"));
|
||||
const basePath = path.join(tempDir, "provider-canonical.ndjson");
|
||||
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-provider-log-"));
|
||||
const basePath = NodePath.join(tempDir, "provider-canonical.ndjson");
|
||||
|
||||
try {
|
||||
const logger = yield* makeEventNdjsonLogger(basePath, { stream: "orchestration" });
|
||||
@@ -93,10 +93,9 @@ describe("EventNdjsonLogger", () => {
|
||||
yield* logger.write({ id: "evt-invalid-thread" }, "!!!" as unknown as ThreadId);
|
||||
yield* logger.close();
|
||||
|
||||
const globalPath = path.join(tempDir, "_global.log");
|
||||
assert.equal(fs.existsSync(globalPath), true);
|
||||
const lines = fs
|
||||
.readFileSync(globalPath, "utf8")
|
||||
const globalPath = NodePath.join(tempDir, "_global.log");
|
||||
assert.equal(NodeFS.existsSync(globalPath), true);
|
||||
const lines = NodeFS.readFileSync(globalPath, "utf8")
|
||||
.trim()
|
||||
.split("\n")
|
||||
.map((line) => parseLogLine(line));
|
||||
@@ -108,15 +107,15 @@ describe("EventNdjsonLogger", () => {
|
||||
assert.equal(lines[1]?.stream, "CANON");
|
||||
assert.equal(lines[1]?.payload, '{"id":"evt-invalid-thread"}');
|
||||
} finally {
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
NodeFS.rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("serializes concurrent first writes for the same segment", () =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-provider-log-"));
|
||||
const basePath = path.join(tempDir, "provider-canonical.ndjson");
|
||||
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-provider-log-"));
|
||||
const basePath = NodePath.join(tempDir, "provider-canonical.ndjson");
|
||||
|
||||
try {
|
||||
const logger = yield* makeEventNdjsonLogger(basePath, {
|
||||
@@ -137,10 +136,9 @@ describe("EventNdjsonLogger", () => {
|
||||
);
|
||||
yield* logger.close();
|
||||
|
||||
const globalPath = path.join(tempDir, "_global.log");
|
||||
assert.equal(fs.existsSync(globalPath), true);
|
||||
const lines = fs
|
||||
.readFileSync(globalPath, "utf8")
|
||||
const globalPath = NodePath.join(tempDir, "_global.log");
|
||||
assert.equal(NodeFS.existsSync(globalPath), true);
|
||||
const lines = NodeFS.readFileSync(globalPath, "utf8")
|
||||
.trim()
|
||||
.split("\n")
|
||||
.map((line) => parseLogLine(line));
|
||||
@@ -151,15 +149,15 @@ describe("EventNdjsonLogger", () => {
|
||||
'{"id":"evt-concurrent-2"}',
|
||||
]);
|
||||
} finally {
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
NodeFS.rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("rotates per-thread files when max size is exceeded", () =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-provider-log-"));
|
||||
const basePath = path.join(tempDir, "provider-native.ndjson");
|
||||
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-provider-log-"));
|
||||
const basePath = NodePath.join(tempDir, "provider-native.ndjson");
|
||||
|
||||
try {
|
||||
const logger = yield* makeEventNdjsonLogger(basePath, {
|
||||
@@ -185,8 +183,7 @@ describe("EventNdjsonLogger", () => {
|
||||
yield* logger.close();
|
||||
|
||||
const fileStem = "thread-rotate.log";
|
||||
const matchingFiles = fs
|
||||
.readdirSync(tempDir)
|
||||
const matchingFiles = NodeFS.readdirSync(tempDir)
|
||||
.filter((entry) => entry === fileStem || entry.startsWith(`${fileStem}.`))
|
||||
.toSorted();
|
||||
|
||||
@@ -203,7 +200,7 @@ describe("EventNdjsonLogger", () => {
|
||||
false,
|
||||
);
|
||||
} finally {
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
NodeFS.rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* single effect-style text line in a thread-scoped file. Failures are
|
||||
* downgraded to warnings so provider runtime behavior is unaffected.
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodePath from "node:path";
|
||||
|
||||
import type { ThreadId } from "@t3tools/contracts";
|
||||
import { RotatingFileSink } from "@t3tools/shared/logging";
|
||||
@@ -178,7 +178,7 @@ export const makeEventNdjsonLogger = Effect.fn("makeEventNdjsonLogger")(function
|
||||
|
||||
const directoryReady = yield* Effect.sync(() => {
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
||||
NodeFS.mkdirSync(NodePath.dirname(filePath), { recursive: true });
|
||||
return true;
|
||||
} catch (error) {
|
||||
return { ok: false as const, error };
|
||||
@@ -211,7 +211,7 @@ export const makeEventNdjsonLogger = Effect.fn("makeEventNdjsonLogger")(function
|
||||
}
|
||||
|
||||
return makeThreadWriter({
|
||||
filePath: path.join(path.dirname(filePath), `${threadSegment}.log`),
|
||||
filePath: NodePath.join(NodePath.dirname(filePath), `${threadSegment}.log`),
|
||||
maxBytes,
|
||||
maxFiles,
|
||||
batchWindowMs,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import * as path from "node:path";
|
||||
import * as os from "node:os";
|
||||
import { chmod, mkdtemp, readFile, writeFile } from "node:fs/promises";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import * as NodePath from "node:path";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as NodeFSP from "node:fs/promises";
|
||||
import * as NodeURL from "node:url";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
@@ -26,13 +26,13 @@ import { ServerConfig } from "../../config.ts";
|
||||
import { makeGrokAdapter } from "./GrokAdapter.ts";
|
||||
const decodeGrokSettings = Schema.decodeSync(GrokSettings);
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const mockAgentPath = path.join(__dirname, "../../../scripts/acp-mock-agent.ts");
|
||||
const __dirname = NodePath.dirname(NodeURL.fileURLToPath(import.meta.url));
|
||||
const mockAgentPath = NodePath.join(__dirname, "../../../scripts/acp-mock-agent.ts");
|
||||
const mockAgentCommand = process.execPath;
|
||||
|
||||
async function makeMockGrokWrapper(extraEnv?: Record<string, string>) {
|
||||
const dir = await mkdtemp(path.join(os.tmpdir(), "grok-acp-mock-"));
|
||||
const wrapperPath = path.join(dir, "fake-grok.sh");
|
||||
const dir = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "grok-acp-mock-"));
|
||||
const wrapperPath = NodePath.join(dir, "fake-grok.sh");
|
||||
const envExports = Object.entries(extraEnv ?? {})
|
||||
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
||||
.join("\n");
|
||||
@@ -40,8 +40,8 @@ async function makeMockGrokWrapper(extraEnv?: Record<string, string>) {
|
||||
${envExports}
|
||||
exec ${JSON.stringify(mockAgentCommand)} ${JSON.stringify(mockAgentPath)} "$@"
|
||||
`;
|
||||
await writeFile(wrapperPath, script, "utf8");
|
||||
await chmod(wrapperPath, 0o755);
|
||||
await NodeFSP.writeFile(wrapperPath, script, "utf8");
|
||||
await NodeFSP.chmod(wrapperPath, 0o755);
|
||||
return wrapperPath;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ function waitForFileContent(filePath: string, attempts = 40): Effect.Effect<stri
|
||||
if (remainingAttempts <= 0) {
|
||||
return yield* Effect.die(new Error(`Timed out waiting for file content at ${filePath}`));
|
||||
}
|
||||
const raw = yield* Effect.tryPromise(() => readFile(filePath, "utf8")).pipe(
|
||||
const raw = yield* Effect.tryPromise(() => NodeFSP.readFile(filePath, "utf8")).pipe(
|
||||
Effect.orElseSucceed(() => ""),
|
||||
);
|
||||
if (raw.trim().length > 0) {
|
||||
@@ -64,7 +64,7 @@ function waitForFileContent(filePath: string, attempts = 40): Effect.Effect<stri
|
||||
}
|
||||
|
||||
async function readJsonLines(filePath: string) {
|
||||
const raw = await readFile(filePath, "utf8");
|
||||
const raw = await NodeFSP.readFile(filePath, "utf8");
|
||||
return raw
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
@@ -149,9 +149,9 @@ it.layer(grokAdapterTestLayer)("GrokAdapterLive", (it) => {
|
||||
Effect.gen(function* () {
|
||||
const threadId = ThreadId.make("grok-stop-session-close");
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
mkdtemp(path.join(os.tmpdir(), "grok-adapter-exit-log-")),
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "grok-adapter-exit-log-")),
|
||||
);
|
||||
const exitLogPath = path.join(tempDir, "exit.log");
|
||||
const exitLogPath = NodePath.join(tempDir, "exit.log");
|
||||
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeMockGrokWrapper({
|
||||
@@ -227,8 +227,10 @@ it.layer(grokAdapterTestLayer)("GrokAdapterLive", (it) => {
|
||||
it.effect("responds to ACP approvals using provider-supplied option ids", () =>
|
||||
Effect.gen(function* () {
|
||||
const threadId = ThreadId.make("grok-custom-approval-option-id");
|
||||
const tempDir = yield* Effect.promise(() => mkdtemp(path.join(os.tmpdir(), "grok-acp-")));
|
||||
const requestLogPath = path.join(tempDir, "requests.ndjson");
|
||||
const tempDir = yield* Effect.promise(() =>
|
||||
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "grok-acp-")),
|
||||
);
|
||||
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
|
||||
const wrapperPath = yield* Effect.promise(() =>
|
||||
makeMockGrokWrapper({
|
||||
T3_ACP_REQUEST_LOG_PATH: requestLogPath,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import assert from "node:assert/strict";
|
||||
import * as NodeAssert from "node:assert/strict";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it } from "@effect/vitest";
|
||||
import * as Context from "effect/Context";
|
||||
@@ -238,11 +238,11 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
assert.equal(session.provider, "opencode");
|
||||
assert.equal(session.threadId, "thread-opencode");
|
||||
assert.deepEqual(runtimeMock.state.startCalls, []);
|
||||
assert.deepEqual(runtimeMock.state.sessionCreateUrls, ["http://127.0.0.1:9999"]);
|
||||
assert.deepEqual(runtimeMock.state.authHeaders, [
|
||||
NodeAssert.equal(session.provider, "opencode");
|
||||
NodeAssert.equal(session.threadId, "thread-opencode");
|
||||
NodeAssert.deepEqual(runtimeMock.state.startCalls, []);
|
||||
NodeAssert.deepEqual(runtimeMock.state.sessionCreateUrls, ["http://127.0.0.1:9999"]);
|
||||
NodeAssert.deepEqual(runtimeMock.state.authHeaders, [
|
||||
`Basic ${btoa("opencode:secret-password")}`,
|
||||
]);
|
||||
}),
|
||||
@@ -259,8 +259,8 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
|
||||
yield* adapter.stopSession(asThreadId("thread-opencode"));
|
||||
|
||||
assert.deepEqual(runtimeMock.state.startCalls, []);
|
||||
assert.deepEqual(
|
||||
NodeAssert.deepEqual(runtimeMock.state.startCalls, []);
|
||||
NodeAssert.deepEqual(
|
||||
runtimeMock.state.abortCalls.includes("http://127.0.0.1:9999/session"),
|
||||
true,
|
||||
);
|
||||
@@ -286,7 +286,7 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
yield* adapter.stopSession(threadId);
|
||||
|
||||
const events = Array.from(yield* Fiber.join(eventsFiber).pipe(Effect.timeout("1 second")));
|
||||
assert.deepEqual(
|
||||
NodeAssert.deepEqual(
|
||||
events.map((event) => event.type),
|
||||
["session.started", "thread.started", "session.exited"],
|
||||
);
|
||||
@@ -316,11 +316,11 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
yield* Effect.exit(adapter.stopAll());
|
||||
const sessions = yield* adapter.listSessions();
|
||||
|
||||
assert.deepEqual(runtimeMock.state.closeCalls, [
|
||||
NodeAssert.deepEqual(runtimeMock.state.closeCalls, [
|
||||
"http://127.0.0.1:9999",
|
||||
"http://127.0.0.1:9999",
|
||||
]);
|
||||
assert.deepEqual(sessions, []);
|
||||
NodeAssert.deepEqual(sessions, []);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -348,7 +348,7 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
scopeClosed = true;
|
||||
|
||||
const exit = yield* Fiber.await(eventsFiber).pipe(Effect.timeout("1 second"));
|
||||
assert.equal(Exit.hasInterrupts(exit), true);
|
||||
NodeAssert.equal(Exit.hasInterrupts(exit), true);
|
||||
} finally {
|
||||
if (!scopeClosed) {
|
||||
yield* Scope.close(scope, Exit.void).pipe(Effect.ignore);
|
||||
@@ -379,19 +379,19 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
.pipe(Effect.flip);
|
||||
const sessions = yield* adapter.listSessions();
|
||||
|
||||
assert.equal(error._tag, "ProviderAdapterRequestError");
|
||||
NodeAssert.equal(error._tag, "ProviderAdapterRequestError");
|
||||
if (error._tag !== "ProviderAdapterRequestError") {
|
||||
throw new Error("Unexpected error type");
|
||||
}
|
||||
assert.equal(error.detail, "prompt failed");
|
||||
assert.equal(
|
||||
NodeAssert.equal(error.detail, "prompt failed");
|
||||
NodeAssert.equal(
|
||||
error.message,
|
||||
"Provider adapter request failed (opencode) for session.promptAsync: prompt failed",
|
||||
);
|
||||
assert.equal(sessions.length, 1);
|
||||
assert.equal(sessions[0]?.status, "ready");
|
||||
assert.equal(sessions[0]?.activeTurnId, undefined);
|
||||
assert.equal(sessions[0]?.lastError, "prompt failed");
|
||||
NodeAssert.equal(sessions.length, 1);
|
||||
NodeAssert.equal(sessions[0]?.status, "ready");
|
||||
NodeAssert.equal(sessions[0]?.activeTurnId, undefined);
|
||||
NodeAssert.equal(sessions[0]?.lastError, "prompt failed");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -424,13 +424,13 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
model: "openai/gpt-5",
|
||||
},
|
||||
});
|
||||
assert.equal(String(steeredTurn.turnId), String(turn.turnId));
|
||||
NodeAssert.equal(String(steeredTurn.turnId), String(turn.turnId));
|
||||
|
||||
const sessions = yield* adapter.listSessions();
|
||||
const session = sessions.find((entry) => entry.threadId === threadId);
|
||||
assert.equal(session?.status, "running");
|
||||
assert.equal(String(session?.activeTurnId), String(turn.turnId));
|
||||
assert.equal(runtimeMock.state.promptCalls.length, 2);
|
||||
NodeAssert.equal(session?.status, "running");
|
||||
NodeAssert.equal(String(session?.activeTurnId), String(turn.turnId));
|
||||
NodeAssert.equal(runtimeMock.state.promptCalls.length, 2);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -466,11 +466,11 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
.pipe(Effect.flip);
|
||||
|
||||
// The original turn keeps running — only the steer prompt failed.
|
||||
assert.equal(error._tag, "ProviderAdapterRequestError");
|
||||
NodeAssert.equal(error._tag, "ProviderAdapterRequestError");
|
||||
const sessions = yield* adapter.listSessions();
|
||||
const session = sessions.find((entry) => entry.threadId === threadId);
|
||||
assert.equal(session?.status, "running");
|
||||
assert.equal(String(session?.activeTurnId), String(turn.turnId));
|
||||
NodeAssert.equal(session?.status, "running");
|
||||
NodeAssert.equal(String(session?.activeTurnId), String(turn.turnId));
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -508,7 +508,7 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
),
|
||||
});
|
||||
|
||||
assert.deepEqual(runtimeMock.state.promptCalls.at(-1), {
|
||||
NodeAssert.deepEqual(runtimeMock.state.promptCalls.at(-1), {
|
||||
sessionID: "http://127.0.0.1:9999/session",
|
||||
model: {
|
||||
providerID: "anthropic",
|
||||
@@ -552,7 +552,7 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
input: "Fix it",
|
||||
});
|
||||
|
||||
assert.deepEqual(runtimeMock.state.promptCalls.at(-1), {
|
||||
NodeAssert.deepEqual(runtimeMock.state.promptCalls.at(-1), {
|
||||
sessionID: "http://127.0.0.1:9999/session",
|
||||
model: {
|
||||
providerID: "anthropic",
|
||||
@@ -596,15 +596,15 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
})
|
||||
.pipe(Effect.flip);
|
||||
|
||||
assert.equal(error._tag, "ProviderAdapterValidationError");
|
||||
NodeAssert.equal(error._tag, "ProviderAdapterValidationError");
|
||||
if (error._tag !== "ProviderAdapterValidationError") {
|
||||
throw new Error("Unexpected error type");
|
||||
}
|
||||
assert.equal(
|
||||
NodeAssert.equal(
|
||||
error.issue,
|
||||
"OpenCode model selection is bound to instance 'opencode', expected 'opencode_zen'.",
|
||||
);
|
||||
assert.deepEqual(runtimeMock.state.promptCalls, []);
|
||||
NodeAssert.deepEqual(runtimeMock.state.promptCalls, []);
|
||||
}).pipe(Effect.provide(adapterLayer));
|
||||
});
|
||||
|
||||
@@ -631,10 +631,10 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
|
||||
const snapshot = yield* adapter.rollbackThread(threadId, 2);
|
||||
|
||||
assert.deepEqual(runtimeMock.state.revertCalls, [
|
||||
NodeAssert.deepEqual(runtimeMock.state.revertCalls, [
|
||||
{ sessionID: "http://127.0.0.1:9999/session" },
|
||||
]);
|
||||
assert.deepEqual(snapshot.turns, []);
|
||||
NodeAssert.deepEqual(snapshot.turns, []);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -644,11 +644,11 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
const overlapDelta = appendOpenCodeAssistantTextDelta(firstUpdate.latestText, "lo world");
|
||||
const secondUpdate = mergeOpenCodeAssistantText(overlapDelta.nextText, "Hellolo world");
|
||||
|
||||
assert.deepEqual(
|
||||
NodeAssert.deepEqual(
|
||||
[firstUpdate.deltaToEmit, overlapDelta.deltaToEmit, secondUpdate.deltaToEmit],
|
||||
["Hello", "lo world", ""],
|
||||
);
|
||||
assert.equal(secondUpdate.latestText, "Hellolo world");
|
||||
NodeAssert.equal(secondUpdate.latestText, "Hellolo world");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -721,14 +721,14 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
|
||||
const events = Array.from(yield* Fiber.join(eventsFiber).pipe(Effect.timeout("1 second")));
|
||||
const deltas = events.filter((event) => event.type === "content.delta");
|
||||
assert.deepEqual(
|
||||
NodeAssert.deepEqual(
|
||||
deltas.map((event) => (event.type === "content.delta" ? event.payload.delta : "")),
|
||||
["A B", "Bonus"],
|
||||
);
|
||||
assert.equal(events.at(-1)?.type, "item.completed");
|
||||
NodeAssert.equal(events.at(-1)?.type, "item.completed");
|
||||
const completed = events.at(-1);
|
||||
if (completed?.type === "item.completed") {
|
||||
assert.equal(completed.payload.detail, "A BBonus");
|
||||
NodeAssert.equal(completed.payload.detail, "A BBonus");
|
||||
}
|
||||
}),
|
||||
);
|
||||
@@ -820,27 +820,27 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
return started;
|
||||
}).pipe(Effect.provide(adapterLayer));
|
||||
|
||||
assert.equal(session.threadId, "thread-native-log");
|
||||
assert.equal(nativeEvents.length, 1);
|
||||
assert.equal(
|
||||
NodeAssert.equal(session.threadId, "thread-native-log");
|
||||
NodeAssert.equal(nativeEvents.length, 1);
|
||||
NodeAssert.equal(
|
||||
nativeEvents.some((record) => record.event?.provider === "opencode"),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
NodeAssert.equal(
|
||||
nativeEvents.some(
|
||||
(record) => record.event?.providerThreadId === "http://127.0.0.1:9999/session",
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
NodeAssert.equal(
|
||||
nativeEvents.some((record) => record.event?.threadId === "thread-native-log"),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
NodeAssert.equal(
|
||||
nativeEvents.some((record) => record.event?.type === "message.updated"),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
NodeAssert.equal(
|
||||
nativeThreadIds.every((threadId) => threadId === "thread-native-log"),
|
||||
true,
|
||||
);
|
||||
@@ -911,9 +911,9 @@ it.layer(OpenCodeAdapterTestLayer)("OpenCodeAdapterLive", (it) => {
|
||||
};
|
||||
}).pipe(Effect.provide(adapterLayer));
|
||||
|
||||
assert.equal(sessions.length, 1);
|
||||
assert.equal(sessions[0]?.threadId, "thread-native-log-failure");
|
||||
assert.deepEqual(closeCallsDuringRun, []);
|
||||
NodeAssert.equal(sessions.length, 1);
|
||||
NodeAssert.equal(sessions[0]?.threadId, "thread-native-log-failure");
|
||||
NodeAssert.deepEqual(closeCallsDuringRun, []);
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import assert from "node:assert/strict";
|
||||
import * as NodeAssert from "node:assert/strict";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it } from "@effect/vitest";
|
||||
@@ -122,9 +122,12 @@ it.layer(testLayer)("checkOpenCodeProviderStatus", (it) => {
|
||||
runtimeMock.state.runVersionError = new Error("spawn opencode ENOENT");
|
||||
const snapshot = yield* checkOpenCodeProviderStatus(makeOpenCodeSettings(), process.cwd());
|
||||
|
||||
assert.equal(snapshot.status, "error");
|
||||
assert.equal(snapshot.installed, false);
|
||||
assert.equal(snapshot.message, "OpenCode CLI (`opencode`) is not installed or not on PATH.");
|
||||
NodeAssert.equal(snapshot.status, "error");
|
||||
NodeAssert.equal(snapshot.installed, false);
|
||||
NodeAssert.equal(
|
||||
snapshot.message,
|
||||
"OpenCode CLI (`opencode`) is not installed or not on PATH.",
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -133,9 +136,9 @@ it.layer(testLayer)("checkOpenCodeProviderStatus", (it) => {
|
||||
runtimeMock.state.runVersionError = new Error("An error occurred in Effect.tryPromise");
|
||||
const snapshot = yield* checkOpenCodeProviderStatus(makeOpenCodeSettings(), process.cwd());
|
||||
|
||||
assert.equal(snapshot.status, "error");
|
||||
assert.equal(snapshot.installed, true);
|
||||
assert.equal(snapshot.message, "Failed to execute OpenCode CLI health check.");
|
||||
NodeAssert.equal(snapshot.status, "error");
|
||||
NodeAssert.equal(snapshot.installed, true);
|
||||
NodeAssert.equal(snapshot.message, "Failed to execute OpenCode CLI health check.");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -174,20 +177,20 @@ it.layer(testLayer)("checkOpenCodeProviderStatus", (it) => {
|
||||
const snapshot = yield* checkOpenCodeProviderStatus(makeOpenCodeSettings(), process.cwd());
|
||||
const model = snapshot.models.find((entry) => entry.slug === "openai/gpt-5.4");
|
||||
|
||||
assert.ok(model);
|
||||
NodeAssert.ok(model);
|
||||
const variantDescriptor = model.capabilities?.optionDescriptors?.find(
|
||||
(descriptor) => descriptor.id === "variant" && descriptor.type === "select",
|
||||
);
|
||||
assert.ok(variantDescriptor && variantDescriptor.type === "select");
|
||||
assert.equal(
|
||||
NodeAssert.ok(variantDescriptor && variantDescriptor.type === "select");
|
||||
NodeAssert.equal(
|
||||
variantDescriptor.options.find((option) => option.isDefault === true)?.id,
|
||||
"medium",
|
||||
);
|
||||
const agentDescriptor = model.capabilities?.optionDescriptors?.find(
|
||||
(descriptor) => descriptor.id === "agent" && descriptor.type === "select",
|
||||
);
|
||||
assert.ok(agentDescriptor && agentDescriptor.type === "select");
|
||||
assert.equal(
|
||||
NodeAssert.ok(agentDescriptor && agentDescriptor.type === "select");
|
||||
NodeAssert.equal(
|
||||
agentDescriptor.options.find((option) => option.isDefault === true)?.id,
|
||||
"build",
|
||||
);
|
||||
@@ -198,7 +201,7 @@ it.layer(testLayer)("checkOpenCodeProviderStatus", (it) => {
|
||||
Effect.gen(function* () {
|
||||
yield* checkOpenCodeProviderStatus(makeOpenCodeSettings(), process.cwd());
|
||||
|
||||
assert.equal(runtimeMock.state.closeCalls, 1);
|
||||
NodeAssert.equal(runtimeMock.state.closeCalls, 1);
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -215,9 +218,9 @@ it.layer(testLayer)("checkOpenCodeProviderStatus with configured server URL", (i
|
||||
process.cwd(),
|
||||
);
|
||||
|
||||
assert.equal(snapshot.status, "error");
|
||||
assert.equal(snapshot.installed, true);
|
||||
assert.equal(
|
||||
NodeAssert.equal(snapshot.status, "error");
|
||||
NodeAssert.equal(snapshot.installed, true);
|
||||
NodeAssert.equal(
|
||||
snapshot.message,
|
||||
"OpenCode server rejected authentication. Check the server URL and password.",
|
||||
);
|
||||
@@ -237,9 +240,9 @@ it.layer(testLayer)("checkOpenCodeProviderStatus with configured server URL", (i
|
||||
process.cwd(),
|
||||
);
|
||||
|
||||
assert.equal(snapshot.status, "error");
|
||||
assert.equal(snapshot.installed, true);
|
||||
assert.equal(
|
||||
NodeAssert.equal(snapshot.status, "error");
|
||||
NodeAssert.equal(snapshot.installed, true);
|
||||
NodeAssert.equal(
|
||||
snapshot.message,
|
||||
"Couldn't reach the configured OpenCode server at http://127.0.0.1:9999. Check that the server is running and the URL is correct.",
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as NodePath from "node:path";
|
||||
|
||||
import type {
|
||||
ProviderApprovalDecision,
|
||||
@@ -644,8 +644,8 @@ it.effect("ProviderServiceLive writes canonical events to the emitting thread se
|
||||
|
||||
it.effect("ProviderServiceLive keeps persisted resumable sessions on startup", () =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-provider-service-"));
|
||||
const dbPath = path.join(tempDir, "orchestration.sqlite");
|
||||
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-provider-service-"));
|
||||
const dbPath = NodePath.join(tempDir, "orchestration.sqlite");
|
||||
|
||||
const codex = makeFakeCodexAdapter();
|
||||
const registry = makeAdapterRegistryMock({
|
||||
@@ -706,7 +706,7 @@ it.effect("ProviderServiceLive keeps persisted resumable sessions on startup", (
|
||||
}).pipe(Effect.provide(persistenceLayer));
|
||||
assert.equal(legacyTableRows.length, 0);
|
||||
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
NodeFS.rmSync(tempDir, { recursive: true, force: true });
|
||||
}).pipe(Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
|
||||
@@ -714,8 +714,10 @@ it.effect(
|
||||
"ProviderServiceLive restores rollback routing after restart using persisted thread mapping",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-provider-service-restart-"));
|
||||
const dbPath = path.join(tempDir, "orchestration.sqlite");
|
||||
const tempDir = NodeFS.mkdtempSync(
|
||||
NodePath.join(NodeOS.tmpdir(), "t3-provider-service-restart-"),
|
||||
);
|
||||
const dbPath = NodePath.join(tempDir, "orchestration.sqlite");
|
||||
const persistenceLayer = makeSqlitePersistenceLive(dbPath);
|
||||
const runtimeRepositoryLayer = ProviderSessionRuntime.layer.pipe(
|
||||
Layer.provide(persistenceLayer),
|
||||
@@ -834,7 +836,7 @@ it.effect(
|
||||
assert.equal(typeof rollbackCall?.[0], "string");
|
||||
assert.equal(rollbackCall?.[1], 1);
|
||||
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
NodeFS.rmSync(tempDir, { recursive: true, force: true });
|
||||
}).pipe(Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
|
||||
@@ -1283,8 +1285,10 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
|
||||
it.effect("reuses persisted resume cursor when startSession is called after a restart", () =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-provider-service-start-"));
|
||||
const dbPath = path.join(tempDir, "orchestration.sqlite");
|
||||
const tempDir = NodeFS.mkdtempSync(
|
||||
NodePath.join(NodeOS.tmpdir(), "t3-provider-service-start-"),
|
||||
);
|
||||
const dbPath = NodePath.join(tempDir, "orchestration.sqlite");
|
||||
const persistenceLayer = makeSqlitePersistenceLive(dbPath);
|
||||
const runtimeRepositoryLayer = ProviderSessionRuntime.layer.pipe(
|
||||
Layer.provide(persistenceLayer),
|
||||
@@ -1379,7 +1383,7 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
assert.equal(startPayload.threadId, initial.threadId);
|
||||
}
|
||||
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
NodeFS.rmSync(tempDir, { recursive: true, force: true });
|
||||
}).pipe(Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
|
||||
@@ -1387,8 +1391,10 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
"reuses persisted cwd when startSession resumes a claude session without cwd input",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-provider-service-cwd-"));
|
||||
const dbPath = path.join(tempDir, "orchestration.sqlite");
|
||||
const tempDir = NodeFS.mkdtempSync(
|
||||
NodePath.join(NodeOS.tmpdir(), "t3-provider-service-cwd-"),
|
||||
);
|
||||
const dbPath = NodePath.join(tempDir, "orchestration.sqlite");
|
||||
const persistenceLayer = makeSqlitePersistenceLive(dbPath);
|
||||
const runtimeRepositoryLayer = ProviderSessionRuntime.layer.pipe(
|
||||
Layer.provide(persistenceLayer),
|
||||
@@ -1477,7 +1483,7 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
assert.equal(startPayload.threadId, initial.threadId);
|
||||
}
|
||||
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
NodeFS.rmSync(tempDir, { recursive: true, force: true });
|
||||
}).pipe(Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as NodePath from "node:path";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { ProviderDriverKind, ThreadId } from "@t3tools/contracts";
|
||||
@@ -229,8 +229,8 @@ it.layer(makeDirectoryLayer(SqlitePersistenceMemory))("ProviderSessionDirectoryL
|
||||
|
||||
it("rehydrates persisted mappings across layer restart", () =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-provider-directory-"));
|
||||
const dbPath = path.join(tempDir, "orchestration.sqlite");
|
||||
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-provider-directory-"));
|
||||
const dbPath = NodePath.join(tempDir, "orchestration.sqlite");
|
||||
const directoryLayer = makeDirectoryLayer(makeSqlitePersistenceLive(dbPath));
|
||||
|
||||
const threadId = ThreadId.make("thread-restart");
|
||||
@@ -266,6 +266,6 @@ it.layer(makeDirectoryLayer(SqlitePersistenceMemory))("ProviderSessionDirectoryL
|
||||
assert.equal(legacyTableRows.length, 0);
|
||||
}).pipe(Effect.provide(directoryLayer));
|
||||
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
NodeFS.rmSync(tempDir, { recursive: true, force: true });
|
||||
}));
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import * as path from "node:path";
|
||||
import * as os from "node:os";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
||||
import * as NodePath from "node:path";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as NodeURL from "node:url";
|
||||
import * as NodeFS from "node:fs";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it } from "@effect/vitest";
|
||||
@@ -13,8 +13,8 @@ import { describe, expect } from "vite-plus/test";
|
||||
import * as AcpSessionRuntime from "./AcpSessionRuntime.ts";
|
||||
import type * as EffectAcpProtocol from "effect-acp/protocol";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const mockAgentPath = path.join(__dirname, "../../../scripts/acp-mock-agent.ts");
|
||||
const __dirname = NodePath.dirname(NodeURL.fileURLToPath(import.meta.url));
|
||||
const mockAgentPath = NodePath.join(__dirname, "../../../scripts/acp-mock-agent.ts");
|
||||
const mockAgentCommand = "node";
|
||||
const mockAgentArgs = [mockAgentPath];
|
||||
|
||||
@@ -347,8 +347,8 @@ describe("AcpSessionRuntime", () => {
|
||||
});
|
||||
|
||||
it.effect("rejects invalid config option values before sending session/set_config_option", () => {
|
||||
const tempDir = mkdtempSync(path.join(os.tmpdir(), "acp-runtime-"));
|
||||
const requestLogPath = path.join(tempDir, "requests.ndjson");
|
||||
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "acp-runtime-"));
|
||||
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
|
||||
return Effect.gen(function* () {
|
||||
const runtime = yield* AcpSessionRuntime.AcpSessionRuntime;
|
||||
yield* runtime.start();
|
||||
@@ -363,7 +363,7 @@ describe("AcpSessionRuntime", () => {
|
||||
expect(error.message).toContain("composer-2[fast=true]");
|
||||
}
|
||||
|
||||
const recordedRequests = readFileSync(requestLogPath, "utf8")
|
||||
const recordedRequests = NodeFS.readFileSync(requestLogPath, "utf8")
|
||||
.trim()
|
||||
.split("\n")
|
||||
.filter((line) => line.length > 0)
|
||||
@@ -392,7 +392,7 @@ describe("AcpSessionRuntime", () => {
|
||||
),
|
||||
Effect.scoped,
|
||||
Effect.provide(NodeServices.layer),
|
||||
Effect.ensuring(Effect.sync(() => rmSync(tempDir, { recursive: true, force: true }))),
|
||||
Effect.ensuring(Effect.sync(() => NodeFS.rmSync(tempDir, { recursive: true, force: true }))),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { pathToFileURL } from "node:url";
|
||||
import * as NodeURL from "node:url";
|
||||
|
||||
import type { ChatAttachment, ProviderApprovalDecision, RuntimeMode } from "@t3tools/contracts";
|
||||
import {
|
||||
@@ -206,7 +206,7 @@ export function toOpenCodeFileParts(input: {
|
||||
type: "file",
|
||||
mime: attachment.mimeType,
|
||||
filename: attachment.name,
|
||||
url: pathToFileURL(attachmentPath).href,
|
||||
url: NodeURL.pathToFileURL(attachmentPath).href,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import { expect, it } from "@effect/vitest";
|
||||
import { chmodSync, mkdirSync, symlinkSync, writeFileSync } from "node:fs";
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import * as NodeOS from "node:os";
|
||||
import path from "node:path";
|
||||
import * as NodePath from "node:path";
|
||||
import { ProviderDriverKind, ProviderInstanceId, type ServerProvider } from "@t3tools/contracts";
|
||||
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
@@ -25,7 +25,7 @@ const driver = (value: string) => ProviderDriverKind.make(value);
|
||||
const makeTempDir = (name: string) =>
|
||||
Crypto.Crypto.pipe(
|
||||
Effect.flatMap((crypto) => crypto.randomUUIDv4),
|
||||
Effect.map((id) => path.join(NodeOS.tmpdir(), `${name}-${id}`)),
|
||||
Effect.map((id) => NodePath.join(NodeOS.tmpdir(), `${name}-${id}`)),
|
||||
);
|
||||
const isNativeTestCommandPath =
|
||||
(expectedPathSegment: string) =>
|
||||
@@ -203,11 +203,11 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = yield* makeTempDir("t3-vite-plus-capabilities");
|
||||
const vitePlusBinDir = path.join(tempDir, ".vite-plus", "bin");
|
||||
mkdirSync(vitePlusBinDir, { recursive: true });
|
||||
const packageToolPath = path.join(vitePlusBinDir, "package-tool");
|
||||
writeFileSync(packageToolPath, "#!/bin/sh\n");
|
||||
chmodSync(packageToolPath, 0o755);
|
||||
const vitePlusBinDir = NodePath.join(tempDir, ".vite-plus", "bin");
|
||||
NodeFS.mkdirSync(vitePlusBinDir, { recursive: true });
|
||||
const packageToolPath = NodePath.join(vitePlusBinDir, "package-tool");
|
||||
NodeFS.writeFileSync(packageToolPath, "#!/bin/sh\n");
|
||||
NodeFS.chmodSync(packageToolPath, 0o755);
|
||||
|
||||
const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
|
||||
packageToolUpdate,
|
||||
@@ -240,9 +240,9 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = yield* makeTempDir("t3-bun-capabilities");
|
||||
const bunBinDir = path.join(tempDir, ".bun", "bin");
|
||||
mkdirSync(bunBinDir, { recursive: true });
|
||||
writeFileSync(path.join(bunBinDir, "native-package-tool.exe"), "MZ");
|
||||
const bunBinDir = NodePath.join(tempDir, ".bun", "bin");
|
||||
NodeFS.mkdirSync(bunBinDir, { recursive: true });
|
||||
NodeFS.writeFileSync(NodePath.join(bunBinDir, "native-package-tool.exe"), "MZ");
|
||||
|
||||
const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
|
||||
nativePackageToolUpdate,
|
||||
@@ -276,11 +276,11 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = yield* makeTempDir("t3-pnpm-capabilities");
|
||||
const pnpmHomeDir = path.join(tempDir, ".local", "share", "pnpm");
|
||||
mkdirSync(pnpmHomeDir, { recursive: true });
|
||||
const scopedPackageToolPath = path.join(pnpmHomeDir, "scoped-package-tool");
|
||||
writeFileSync(scopedPackageToolPath, "#!/bin/sh\n");
|
||||
chmodSync(scopedPackageToolPath, 0o755);
|
||||
const pnpmHomeDir = NodePath.join(tempDir, ".local", "share", "pnpm");
|
||||
NodeFS.mkdirSync(pnpmHomeDir, { recursive: true });
|
||||
const scopedPackageToolPath = NodePath.join(pnpmHomeDir, "scoped-package-tool");
|
||||
NodeFS.writeFileSync(scopedPackageToolPath, "#!/bin/sh\n");
|
||||
NodeFS.chmodSync(scopedPackageToolPath, 0o755);
|
||||
|
||||
const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
|
||||
scopedPackageToolUpdate,
|
||||
@@ -336,11 +336,11 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = yield* makeTempDir("t3-native-package-tool-native-capabilities");
|
||||
const nativeBinDir = path.join(tempDir, ".local", "bin");
|
||||
mkdirSync(nativeBinDir, { recursive: true });
|
||||
const nativePackageToolPath = path.join(nativeBinDir, "native-package-tool");
|
||||
writeFileSync(nativePackageToolPath, "#!/bin/sh\n");
|
||||
chmodSync(nativePackageToolPath, 0o755);
|
||||
const nativeBinDir = NodePath.join(tempDir, ".local", "bin");
|
||||
NodeFS.mkdirSync(nativeBinDir, { recursive: true });
|
||||
const nativePackageToolPath = NodePath.join(nativeBinDir, "native-package-tool");
|
||||
NodeFS.writeFileSync(nativePackageToolPath, "#!/bin/sh\n");
|
||||
NodeFS.chmodSync(nativePackageToolPath, 0o755);
|
||||
|
||||
const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
|
||||
nativePackageToolUpdate,
|
||||
@@ -373,11 +373,11 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = yield* makeTempDir("t3-scoped-package-tool-native-capabilities");
|
||||
const nativeBinDir = path.join(tempDir, ".scoped-package-tool", "bin");
|
||||
mkdirSync(nativeBinDir, { recursive: true });
|
||||
const scopedPackageToolPath = path.join(nativeBinDir, "scoped-package-tool");
|
||||
writeFileSync(scopedPackageToolPath, "#!/bin/sh\n");
|
||||
chmodSync(scopedPackageToolPath, 0o755);
|
||||
const nativeBinDir = NodePath.join(tempDir, ".scoped-package-tool", "bin");
|
||||
NodeFS.mkdirSync(nativeBinDir, { recursive: true });
|
||||
const scopedPackageToolPath = NodePath.join(nativeBinDir, "scoped-package-tool");
|
||||
NodeFS.writeFileSync(scopedPackageToolPath, "#!/bin/sh\n");
|
||||
NodeFS.chmodSync(scopedPackageToolPath, 0o755);
|
||||
|
||||
const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
|
||||
scopedPackageToolUpdate,
|
||||
@@ -454,8 +454,8 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
it.effect("keeps npm updates for binaries symlinked into npm's global node_modules tree", () =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = yield* makeTempDir("t3-npm-capabilities");
|
||||
const binDir = path.join(tempDir, "bin");
|
||||
const packageBinDir = path.join(
|
||||
const binDir = NodePath.join(tempDir, "bin");
|
||||
const packageBinDir = NodePath.join(
|
||||
tempDir,
|
||||
"lib",
|
||||
"node_modules",
|
||||
@@ -463,13 +463,13 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
"package-tool",
|
||||
"bin",
|
||||
);
|
||||
mkdirSync(binDir, { recursive: true });
|
||||
mkdirSync(packageBinDir, { recursive: true });
|
||||
const packageBinPath = path.join(packageBinDir, "package-tool.js");
|
||||
const symlinkPath = path.join(binDir, "package-tool");
|
||||
writeFileSync(packageBinPath, "#!/usr/bin/env node\n");
|
||||
chmodSync(packageBinPath, 0o755);
|
||||
symlinkSync(packageBinPath, symlinkPath);
|
||||
NodeFS.mkdirSync(binDir, { recursive: true });
|
||||
NodeFS.mkdirSync(packageBinDir, { recursive: true });
|
||||
const packageBinPath = NodePath.join(packageBinDir, "package-tool.js");
|
||||
const symlinkPath = NodePath.join(binDir, "package-tool");
|
||||
NodeFS.writeFileSync(packageBinPath, "#!/usr/bin/env node\n");
|
||||
NodeFS.chmodSync(packageBinPath, 0o755);
|
||||
NodeFS.symlinkSync(packageBinPath, symlinkPath);
|
||||
|
||||
const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(packageToolUpdate, {
|
||||
binaryPath: symlinkPath,
|
||||
@@ -497,8 +497,8 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
it.effect("uses Effect FileSystem realPath when detecting pnpm global symlinks", () =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = yield* makeTempDir("t3-pnpm-realpath-capabilities");
|
||||
const binDir = path.join(tempDir, "bin");
|
||||
const packageBinDir = path.join(
|
||||
const binDir = NodePath.join(tempDir, "bin");
|
||||
const packageBinDir = NodePath.join(
|
||||
tempDir,
|
||||
".local",
|
||||
"share",
|
||||
@@ -510,13 +510,13 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
"package-tool",
|
||||
"bin",
|
||||
);
|
||||
mkdirSync(binDir, { recursive: true });
|
||||
mkdirSync(packageBinDir, { recursive: true });
|
||||
const packageBinPath = path.join(packageBinDir, "package-tool.js");
|
||||
const symlinkPath = path.join(binDir, "package-tool");
|
||||
writeFileSync(packageBinPath, "#!/usr/bin/env node\n");
|
||||
chmodSync(packageBinPath, 0o755);
|
||||
symlinkSync(packageBinPath, symlinkPath);
|
||||
NodeFS.mkdirSync(binDir, { recursive: true });
|
||||
NodeFS.mkdirSync(packageBinDir, { recursive: true });
|
||||
const packageBinPath = NodePath.join(packageBinDir, "package-tool.js");
|
||||
const symlinkPath = NodePath.join(binDir, "package-tool");
|
||||
NodeFS.writeFileSync(packageBinPath, "#!/usr/bin/env node\n");
|
||||
NodeFS.chmodSync(packageBinPath, 0o755);
|
||||
NodeFS.symlinkSync(packageBinPath, symlinkPath);
|
||||
|
||||
const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(packageToolUpdate, {
|
||||
binaryPath: symlinkPath,
|
||||
|
||||
Reference in new issue
Block a user