Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "@t3tools/client-runtime/platform";
import type { EnvironmentId } from "@t3tools/contracts";
import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
import * as Crypto from "effect/Crypto";
import * as Digest from "effect/crypto/Digest";
import * as Effect from "effect/Effect";
import * as Base64 from "effect/encoding/Base64";
import * as Hex from "effect/encoding/Hex";
Expand Down Expand Up @@ -42,14 +42,14 @@ export const make = Effect.fn("desktop.connectionCompatibilityHintStore.make")(f
}) {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const crypto = yield* Crypto.Crypto;
const crypto = yield* Digest.Digest;
const filename = path.join(input.directory, "connection-compatibility-hints-v1.sqlite");
const keyFor = Effect.fn("desktop.connectionCompatibilityHintStore.key")(function* (
environmentId: EnvironmentId,
routeBinding: string,
) {
const encoded = yield* encodeKey([environmentId, routeBinding]);
return Hex.encode(yield* crypto.digest("SHA-256", new TextEncoder().encode(encoded)));
return Hex.encode(yield* crypto.digest(Digest.sha256, new TextEncoder().encode(encoded)));
});
const withDatabase = <A, E>(
operation: "read" | "write",
Expand Down
8 changes: 4 additions & 4 deletions apps/desktop/src/jones/previewCompanion/CompanionConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DesktopCompanionConfig, type DesktopCompanionConfigureInput } from "@t3tools/contracts";
import * as Context from "effect/Context";
import * as Crypto from "effect/Crypto";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
Expand Down Expand Up @@ -40,7 +40,7 @@ const make = Effect.gen(function* () {
);
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const crypto = yield* Crypto.Crypto;
const crypto = yield* SecureRandom.SecureRandom;
const identity = yield* DesktopAppIdentity.DesktopAppIdentity;
const directory = yield* identity.resolveUserDataPath.pipe(
Effect.mapError(() => new CompanionConfigError({ operation: "read" })),
Expand All @@ -57,7 +57,7 @@ const make = Effect.gen(function* () {
);
const write = Effect.fn("CompanionConfig.write")(
function* (config: DesktopCompanionConfig) {
const id = yield* crypto.randomUUIDv4();
const id = yield* crypto.uuidV4();
const temporary = `${target}.${id}.tmp`;
const encoded = yield* Schema.encodeEffect(Schema.fromJsonString(DesktopCompanionConfig))(
config,
Expand All @@ -79,7 +79,7 @@ const make = Effect.gen(function* () {
enabled: false,
environmentId: null,
hostId: yield* crypto
.randomUUIDv4()
.uuidV4()
.pipe(Effect.mapError(() => new CompanionConfigError({ operation: "identity" }))),
label: "Browser host",
browserOnly: productLocked,
Expand Down
6 changes: 3 additions & 3 deletions apps/mobile/src/features/workstreams/Controls.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { workstreamPageUrl } from "./gateway";
import { WorkstreamColorPicker } from "../../jones/workstreamAppearance/WorkstreamColorPicker";
import * as Crypto from "effect/Crypto";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Effect from "effect/Effect";
import { runtime } from "../../lib/runtime";
import { useEffect, useLayoutEffect, useRef, useState } from "react";
Expand Down Expand Up @@ -373,8 +373,8 @@ export function MobileWorkstreamControls({
generation={snapshot.data.binding.serverGeneration}
createCommandId={() =>
runtime.runPromise(
Crypto.Crypto.pipe(
Effect.flatMap((crypto) => crypto.randomUUIDv4()),
SecureRandom.SecureRandom.pipe(
Effect.flatMap((crypto) => crypto.uuidV4()),
Effect.map((id) => `t3-color-${id}`),
),
)
Expand Down
13 changes: 9 additions & 4 deletions apps/mobile/src/features/workstreams/useWorkstreams.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Digest from "effect/crypto/Digest";
import {
WorkstreamOperationsClient,
supportsWorkstreamOperations,
Expand Down Expand Up @@ -33,7 +34,7 @@ import {
type WorkstreamCommand,
type WorkstreamReceipt,
} from "@t3tools/contracts";
import * as Crypto from "effect/Crypto";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Effect from "effect/Effect";
import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
Expand Down Expand Up @@ -266,7 +267,9 @@ export function useMobileWorkstreams(threads: readonly WorkstreamThreadLike[]) {
),
},
() =>
runtime.runPromise(Crypto.Crypto.pipe(Effect.flatMap((crypto) => crypto.randomUUIDv4()))),
runtime.runPromise(
SecureRandom.SecureRandom.pipe(Effect.flatMap((crypto) => crypto.uuidV4())),
),
);
mobileOperationClients.set(connectionKey, client);
}
Expand Down Expand Up @@ -551,7 +554,9 @@ export function useMobileWorkstreams(threads: readonly WorkstreamThreadLike[]) {
Date.now,
(bytes) =>
runtime.runPromise(
Crypto.Crypto.pipe(Effect.flatMap((crypto) => crypto.digest("SHA-256", bytes))),
Digest.Digest.pipe(
Effect.flatMap((digest) => digest.digest(Digest.sha256, bytes)),
),
),
);
})().catch((cause: unknown) => {
Expand Down Expand Up @@ -848,7 +853,7 @@ export function useMobileWorkstreams(threads: readonly WorkstreamThreadLike[]) {
return await (async () => {
for (const action of actions) {
const command_id = await runtime.runPromise(
Crypto.Crypto.pipe(Effect.flatMap((crypto) => crypto.randomUUIDv4())),
SecureRandom.SecureRandom.pipe(Effect.flatMap((crypto) => crypto.uuidV4())),
);
assertCurrent(snapshot);
const command: WorkstreamCommand = {
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { typecheckTask } from "../../scripts/jones/tsrs/task-cache.ts";
import packageJson from "./package.json" with { type: "json" };
import * as NodeModule from "node:module";
import * as NodeURL from "node:url";
import { defineConfig, normalizePath } from "vite-plus";
Expand Down
10 changes: 5 additions & 5 deletions apps/server/src/environment/ServerEnvironment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("ServerEnvironmen
])("concurrent initializers recover a $name environment id file", ({ content }) =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const crypto = yield* Crypto.Crypto;
const crypto = yield* SecureRandom.SecureRandom;
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
prefix: "t3-server-environment-concurrent-test-",
});
Expand Down Expand Up @@ -425,17 +425,17 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("ServerEnvironmen
),
),
}),
Effect.provideService(Crypto.Crypto, {
Effect.provideService(SecureRandom.SecureRandom, {
...crypto,
randomUUIDv4: (() =>
uuidV4: (() =>
Effect.gen(function* () {
const id = yield* crypto.randomUUIDv4();
const id = yield* crypto.uuidV4();
if (--remaining === 0) {
yield* Deferred.succeed(bothGenerated, undefined);
}
yield* Deferred.await(bothGenerated);
return id;
})) as Crypto.Crypto["randomUUIDv4"],
})) as SecureRandom.SecureRandom["Service"]["uuidV4"],
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as HostProcess from "@t3tools/shared/HostProcess";
import * as CodexSchema from "effect-codex-app-server/schema";
import * as Crypto from "effect/Crypto";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
Expand Down Expand Up @@ -196,7 +196,7 @@ const scenario = (mode: "chain" | "all-unavailable") =>
Effect.provide(Codex.layerAppServerClientFactory),
);
const adapterDependencies = yield* Effect.context<
| Crypto.Crypto
| SecureRandom.SecureRandom
| FileSystem.FileSystem
| Path.Path
| IdAllocator.IdAllocatorV2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter"
import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
import * as CodexReplay from "effect-codex-app-server/replay";
import type { ServerNotification__CodexErrorInfo } from "effect-codex-app-server/schema";
import * as Crypto from "effect/Crypto";
import * as Digest from "effect/crypto/Digest";
import * as DateTime from "effect/DateTime";
import * as Deferred from "effect/Deferred";
import * as Effect from "effect/Effect";
Expand Down Expand Up @@ -359,7 +359,7 @@ const openHarness = Effect.fn("CodexFailoverEvidence.adapter.openHarness")(funct
settings: DEFAULT_CODEX_SETTINGS,
environment: {},
clientFactory: makeCodexReplayClientFactory({ transcript }),
crypto: yield* Crypto.Crypto,
digest: yield* Digest.Digest,
fileSystem,
idAllocator: yield* IdAllocator.IdAllocatorV2,
serverConfig,
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/jones/goals/GoalControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@t3tools/contracts";
import type { ProviderAdapterV2SessionRuntime } from "@t3tools/provider-core/server/ProviderAdapter";
import * as Context from "effect/Context";
import * as Crypto from "effect/Crypto";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
Expand Down Expand Up @@ -95,7 +95,7 @@ const make = Effect.gen(function* () {
const threads = yield* ThreadManagement.ThreadManagementService;
const sessions = yield* Effect.serviceOption(Sessions.ProviderSessionManagerV2);
const starts = yield* Effect.serviceOption(GoalStart.GoalStartDispatch);
const crypto = yield* Crypto.Crypto;
const crypto = yield* SecureRandom.SecureRandom;
const lock = yield* Semaphore.make(1);
const bindings = new Map<string, Binding>();
const execute = (scope: Invocation.McpInvocationScope, input: ThreadGoalInput) =>
Expand Down Expand Up @@ -184,7 +184,7 @@ const make = Effect.gen(function* () {
!sameBinding(binding.provider, provider)
) {
if (mutation) return answer("stale", "read_current_goal_before_mutation");
const token = yield* crypto.randomUUIDv4().pipe(Effect.orDie);
const token = yield* crypto.uuidV4().pipe(Effect.orDie);
const retain = binding !== undefined && sameConversation(binding, provider, runtime);
// Preserve rejected keys across an ownership change so durable command dedupe
// cannot attribute an old conversation's run to its replacement.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
} from "@t3tools/contracts";
import * as DateTime from "effect/DateTime";
import * as Layer from "effect/Layer";
import * as Crypto from "effect/Crypto";
import * as Digest from "effect/crypto/Digest";
import * as TestClock from "effect/testing/TestClock";
import * as AuthSessions from "../../persistence/AuthSessions.ts";
import { runMigrations } from "../../persistence/Migrations.ts";
Expand Down Expand Up @@ -662,7 +662,7 @@ const scenario = (mode: Mode) =>
const adapter = yield* CodexAdapterV2.makeCodexAdapterV2({
instanceId: binding.providerInstanceId,
settings,
crypto: yield* Crypto.Crypto,
digest: yield* Digest.Digest,
environment: {},
fileSystem: fs,
idAllocator: allocator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderS
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as CodexClient from "effect-codex-app-server/client";
import * as CodexReplay from "effect-codex-app-server/replay";
import * as Crypto from "effect/Crypto";
import * as Digest from "effect/crypto/Digest";
import * as DateTime from "effect/DateTime";
import * as Deferred from "effect/Deferred";
import * as Effect from "effect/Effect";
Expand Down Expand Up @@ -223,7 +223,7 @@ describe("Codex late subagent reader progress", () => {
instanceId: modelSelection.instanceId,
settings: yield* Schema.decodeEffect(CodexSettings)({}),
environment: {},
crypto: yield* Crypto.Crypto,
digest: yield* Digest.Digest,
fileSystem,
idAllocator: yield* IdAllocator.IdAllocatorV2,
serverConfig: yield* makeReplayServerConfig(scenario).pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderS
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as CodexClient from "effect-codex-app-server/client";
import * as CodexReplay from "effect-codex-app-server/replay";
import * as Crypto from "effect/Crypto";
import * as Digest from "effect/crypto/Digest";
import * as DateTime from "effect/DateTime";
import * as Deferred from "effect/Deferred";
import * as Effect from "effect/Effect";
Expand Down Expand Up @@ -399,7 +399,7 @@ describe("Codex pre-ACK item reader progress", () => {
instanceId: modelSelection.instanceId,
settings: yield* Schema.decodeEffect(CodexSettings)({}),
environment: {},
crypto: yield* Crypto.Crypto,
digest: yield* Digest.Digest,
fileSystem,
idAllocator: {
...idAllocator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ThreadId,
} from "@t3tools/contracts";
import * as HostProcess from "@t3tools/shared/HostProcess";
import * as Crypto from "effect/Crypto";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Deferred from "effect/Deferred";
import * as Effect from "effect/Effect";
import * as Fiber from "effect/Fiber";
Expand Down Expand Up @@ -415,11 +415,8 @@ const syntheticClient = OpenCode2Client.layer.pipe(
),
);
const syntheticCrypto = Layer.succeed(
Crypto.Crypto,
Crypto.make({
randomBytes: (size) => new Uint8Array(size),
digest: (_algorithm, bytes) => Effect.succeed(bytes),
}),
SecureRandom.SecureRandom,
SecureRandom.make((size) => new Uint8Array(size)),
);
const serverInput = { ...ownerInput, serverUrl: "", serverPassword: "", environment: {} };

Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/jones/terminal/ShellIdlePrompt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Crypto from "effect/Crypto";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Path from "effect/Path";
Expand Down Expand Up @@ -51,7 +51,7 @@ export class ShellIdlePrompt {
/** Child-local startup hooks preserve the user's files; unsupported shells never expire. */
export const makeShellIdlePromptIntegration = Effect.fn("terminal.makeShellIdlePromptIntegration")(
function* () {
const crypto = yield* Crypto.Crypto;
const crypto = yield* SecureRandom.SecureRandom;
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const directory = yield* fs.makeTempDirectoryScoped({ prefix: "jones-shell-idle-" });
Expand Down Expand Up @@ -109,7 +109,7 @@ preexec_functions+=(__jones_idle_busy)
env: NodeJS.ProcessEnv,
) {
if (shellName !== "bash" && shellName !== "zsh") return { env, tracker: undefined };
const token = yield* crypto.randomUUIDv4();
const token = yield* crypto.uuidV4();
const tracker = new ShellIdlePrompt(token);
if (shellName === "bash") {
// PS0 is emitted immediately before execution, including shell builtins.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { makeOwnerSelectionStore } from "./ownerSelectionStore.ts";
import { makeJonesTablePresence } from "../persistence/JonesTablePresence.ts";
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
import * as Crypto from "effect/Crypto";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Context from "effect/Context";
import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
Expand Down Expand Up @@ -84,8 +84,8 @@ const make = Effect.gen(function* () {
const transitions = yield* Switch.ProviderSwitchServiceV2;
const sql = yield* SqlClient.SqlClient;
const ownerSelections = makeOwnerSelectionStore(sql, makeJonesTablePresence(sql));
const crypto = yield* Crypto.Crypto;
const generationNamespace = yield* crypto.randomUUIDv4();
const crypto = yield* SecureRandom.SecureRandom;
const generationNamespace = yield* crypto.uuidV4();
let nextGeneration = 0;
const residentGenerations = new WeakMap<object, string>();
const revision = Effect.fn("ThreadSelfConfiguration.revision")(function* (threadId: ThreadId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type ThreadRequestObservation,
} from "@t3tools/contracts";
import * as Context from "effect/Context";
import * as Crypto from "effect/Crypto";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
import * as Fiber from "effect/Fiber";
Expand All @@ -32,7 +32,7 @@ export class DependencyReactor extends Context.Service<
>()("t3/jones/threadResultDependencies/DependencyReactor") {}
const make = Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient;
const crypto = yield* Crypto.Crypto;
const crypto = yield* SecureRandom.SecureRandom;
const store = makeDependencyStore(sql, makeJonesTablePresence(sql));
const changes = yield* Changes.DependencyChanges;
const watcher = yield* RequestWatch.RequestWatch;
Expand All @@ -42,12 +42,12 @@ const make = Effect.gen(function* () {
const running = new Map<string, { generation: number; fiber?: Fiber.Fiber<void> }>();
const mutate = makeCommit(sql, store, changes);
const wake = Effect.fn("DependencyReactor.wake")(function* (dependency: Dependency) {
const messageId = MessageId.make(yield* crypto.randomUUIDv4());
const messageId = MessageId.make(yield* crypto.uuidV4());
const value = notification(dependency);
yield* orchestrator
.dispatch({
type: "message.dispatch",
commandId: CommandId.make(yield* crypto.randomUUIDv4()),
commandId: CommandId.make(yield* crypto.uuidV4()),
messageId,
threadId: dependency.waiterThreadId,
text: `${value.summary}\n\n${value.detail}`,
Expand Down
Loading
Loading