Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
import {
type EnvironmentId,
type OrchestrationShellSnapshot,
type OrchestrationThreadDetailSnapshot,
type ServerConfig,
type ThreadId,
} from "@akeru/contracts";
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
import type { ConnectionRegistration } from "../connection/catalog.ts";
import type { ConnectionTarget } from "../connection/model.ts";
export class ConnectionPersistenceError extends Schema.TaggedErrorClass<ConnectionPersistenceError>()(
"ConnectionPersistenceError",
{
operation: Schema.Literals([
"list-targets",
"register-connection",
"remove-connection",
"load-shell",
"save-shell",
"load-thread",
"save-thread",
"remove-thread",
"load-server-config",
"save-server-config",
"clear-environment",
]),
message: Schema.String,
},
) {}
export class ConnectionTargetStore extends Context.Service<
ConnectionTargetStore,
{
readonly list: Effect.Effect<ReadonlyArray<ConnectionTarget>, ConnectionPersistenceError>;
}
>()("@akeru/client-runtime/platform/persistence/ConnectionTargetStore") {}
export class ConnectionRegistrationStore extends Context.Service<
ConnectionRegistrationStore,
{
readonly register: (
registration: ConnectionRegistration,
) => Effect.Effect<void, ConnectionPersistenceError>;
readonly remove: (target: ConnectionTarget) => Effect.Effect<void, ConnectionPersistenceError>;
}
>()("@akeru/client-runtime/platform/persistence/ConnectionRegistrationStore") {}
export class EnvironmentCacheStore extends Context.Service<
EnvironmentCacheStore,
{
readonly loadShell: (
environmentId: EnvironmentId,
) => Effect.Effect<Option.Option<OrchestrationShellSnapshot>, ConnectionPersistenceError>;
readonly saveShell: (
environmentId: EnvironmentId,
snapshot: OrchestrationShellSnapshot,
) => Effect.Effect<void, ConnectionPersistenceError>;
readonly loadThread: (
environmentId: EnvironmentId,
threadId: ThreadId,
) => Effect.Effect<
Option.Option<OrchestrationThreadDetailSnapshot>,
ConnectionPersistenceError
>;
readonly saveThread: (
environmentId: EnvironmentId,
snapshot: OrchestrationThreadDetailSnapshot,
) => Effect.Effect<void, ConnectionPersistenceError>;
readonly removeThread: (
environmentId: EnvironmentId,
threadId: ThreadId,
) => Effect.Effect<void, ConnectionPersistenceError>;
/**
* The last complete server configuration. This deliberately includes provider
* metadata so offline task creation can still offer the models a user last saw.
*/
readonly loadServerConfig: (
environmentId: EnvironmentId,
) => Effect.Effect<Option.Option<ServerConfig>, ConnectionPersistenceError>;
readonly saveServerConfig: (
environmentId: EnvironmentId,
config: ServerConfig,
) => Effect.Effect<void, ConnectionPersistenceError>;
readonly clear: (
environmentId: EnvironmentId,
) => Effect.Effect<void, ConnectionPersistenceError>;
}
>()("@akeru/client-runtime/platform/persistence/EnvironmentCacheStore") {}
export class EnvironmentOwnedDataCleanup extends Context.Reference<{
readonly clear: (environmentId: EnvironmentId) => Effect.Effect<void>;
}>("@akeru/client-runtime/platform/persistence/EnvironmentOwnedDataCleanup", {
defaultValue: () => ({
clear: () => Effect.void,
}),
}) {}