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 * as Schema from "effect/Schema";
import { NonNegativeInt, PositiveInt } from "../baseSchemas.ts";
import {
TrimmedNonEmptyStringSchema,
UnknownRecordSchema,
RuntimeSessionState,
RuntimeThreadState,
RuntimeSessionExitKind,
SessionStartedType,
SessionConfiguredType,
SessionStateChangedType,
SessionExitedType,
ThreadStartedType,
ThreadStateChangedType,
ThreadMetadataUpdatedType,
ThreadTokenUsageUpdatedType,
ThreadRealtimeStartedType,
ThreadRealtimeItemAddedType,
ThreadRealtimeAudioDeltaType,
ThreadRealtimeErrorType,
ThreadRealtimeClosedType,
AuthStatusType,
AccountUpdatedType,
AccountRateLimitsUpdatedType,
McpStatusUpdatedType,
McpOauthCompletedType,
ModelReroutedType,
ConfigWarningType,
DeprecationNoticeType,
FilesPersistedType,
ProviderRuntimeEventBase,
} from "./base.ts";
const SessionStartedPayload = Schema.Struct({
message: Schema.optional(TrimmedNonEmptyStringSchema),
resume: Schema.optional(Schema.Unknown),
});
export type SessionStartedPayload = typeof SessionStartedPayload.Type;
const SessionConfiguredPayload = Schema.Struct({
config: UnknownRecordSchema,
});
export type SessionConfiguredPayload = typeof SessionConfiguredPayload.Type;
const SessionStateChangedPayload = Schema.Struct({
state: RuntimeSessionState,
reason: Schema.optional(TrimmedNonEmptyStringSchema),
detail: Schema.optional(Schema.Unknown),
});
export type SessionStateChangedPayload = typeof SessionStateChangedPayload.Type;
const SessionExitedPayload = Schema.Struct({
reason: Schema.optional(TrimmedNonEmptyStringSchema),
recoverable: Schema.optional(Schema.Boolean),
exitKind: Schema.optional(RuntimeSessionExitKind),
});
export type SessionExitedPayload = typeof SessionExitedPayload.Type;
const ThreadStartedPayload = Schema.Struct({
providerThreadId: Schema.optional(TrimmedNonEmptyStringSchema),
});
export type ThreadStartedPayload = typeof ThreadStartedPayload.Type;
const ThreadStateChangedPayload = Schema.Struct({
state: RuntimeThreadState,
detail: Schema.optional(Schema.Unknown),
});
export type ThreadStateChangedPayload = typeof ThreadStateChangedPayload.Type;
const ThreadMetadataUpdatedPayload = Schema.Struct({
name: Schema.optional(TrimmedNonEmptyStringSchema),
metadata: Schema.optional(UnknownRecordSchema),
});
export type ThreadMetadataUpdatedPayload = typeof ThreadMetadataUpdatedPayload.Type;
export const ThreadTokenUsageSnapshot = Schema.Struct({
usedTokens: NonNegativeInt,
totalProcessedTokens: Schema.optional(NonNegativeInt),
maxTokens: Schema.optional(PositiveInt),
inputTokens: Schema.optional(NonNegativeInt),
cachedInputTokens: Schema.optional(NonNegativeInt),
cacheCreationTokens: Schema.optional(NonNegativeInt),
outputTokens: Schema.optional(NonNegativeInt),
reasoningOutputTokens: Schema.optional(NonNegativeInt),
lastUsedTokens: Schema.optional(NonNegativeInt),
lastInputTokens: Schema.optional(NonNegativeInt),
lastCachedInputTokens: Schema.optional(NonNegativeInt),
lastCacheCreationTokens: Schema.optional(NonNegativeInt),
lastOutputTokens: Schema.optional(NonNegativeInt),
lastReasoningOutputTokens: Schema.optional(NonNegativeInt),
toolUses: Schema.optional(NonNegativeInt),
durationMs: Schema.optional(NonNegativeInt),
compactsAutomatically: Schema.optional(Schema.Boolean),
autoCompactThreshold: Schema.optional(PositiveInt),
});
export type ThreadTokenUsageSnapshot = typeof ThreadTokenUsageSnapshot.Type;
const ThreadTokenUsageUpdatedPayload = Schema.Struct({
usage: ThreadTokenUsageSnapshot,
});
export type ThreadTokenUsageUpdatedPayload = typeof ThreadTokenUsageUpdatedPayload.Type;
const ThreadRealtimeStartedPayload = Schema.Struct({
realtimeSessionId: Schema.optional(TrimmedNonEmptyStringSchema),
});
export type ThreadRealtimeStartedPayload = typeof ThreadRealtimeStartedPayload.Type;
const ThreadRealtimeItemAddedPayload = Schema.Struct({
item: Schema.Unknown,
});
export type ThreadRealtimeItemAddedPayload = typeof ThreadRealtimeItemAddedPayload.Type;
const ThreadRealtimeAudioDeltaPayload = Schema.Struct({
audio: Schema.Unknown,
});
export type ThreadRealtimeAudioDeltaPayload = typeof ThreadRealtimeAudioDeltaPayload.Type;
const ThreadRealtimeErrorPayload = Schema.Struct({
message: TrimmedNonEmptyStringSchema,
});
export type ThreadRealtimeErrorPayload = typeof ThreadRealtimeErrorPayload.Type;
const ThreadRealtimeClosedPayload = Schema.Struct({
reason: Schema.optional(TrimmedNonEmptyStringSchema),
});
export type ThreadRealtimeClosedPayload = typeof ThreadRealtimeClosedPayload.Type;
const AuthStatusPayload = Schema.Struct({
isAuthenticating: Schema.optional(Schema.Boolean),
output: Schema.optional(Schema.Array(Schema.String)),
error: Schema.optional(TrimmedNonEmptyStringSchema),
});
export type AuthStatusPayload = typeof AuthStatusPayload.Type;
const AccountUpdatedPayload = Schema.Struct({
account: Schema.Unknown,
});
export type AccountUpdatedPayload = typeof AccountUpdatedPayload.Type;
const AccountRateLimitsUpdatedPayload = Schema.Struct({
rateLimits: Schema.Unknown,
});
export type AccountRateLimitsUpdatedPayload = typeof AccountRateLimitsUpdatedPayload.Type;
const McpStatusUpdatedPayload = Schema.Struct({
status: Schema.Unknown,
});
export type McpStatusUpdatedPayload = typeof McpStatusUpdatedPayload.Type;
const McpOauthCompletedPayload = Schema.Struct({
success: Schema.Boolean,
name: Schema.optional(TrimmedNonEmptyStringSchema),
error: Schema.optional(TrimmedNonEmptyStringSchema),
});
export type McpOauthCompletedPayload = typeof McpOauthCompletedPayload.Type;
const ModelReroutedPayload = Schema.Struct({
fromModel: TrimmedNonEmptyStringSchema,
toModel: TrimmedNonEmptyStringSchema,
reason: TrimmedNonEmptyStringSchema,
});
export type ModelReroutedPayload = typeof ModelReroutedPayload.Type;
const ConfigWarningPayload = Schema.Struct({
summary: TrimmedNonEmptyStringSchema,
details: Schema.optional(TrimmedNonEmptyStringSchema),
path: Schema.optional(TrimmedNonEmptyStringSchema),
range: Schema.optional(Schema.Unknown),
});
export type ConfigWarningPayload = typeof ConfigWarningPayload.Type;
const DeprecationNoticePayload = Schema.Struct({
summary: TrimmedNonEmptyStringSchema,
details: Schema.optional(TrimmedNonEmptyStringSchema),
});
export type DeprecationNoticePayload = typeof DeprecationNoticePayload.Type;
const FilesPersistedPayload = Schema.Struct({
files: Schema.Array(
Schema.Struct({
filename: TrimmedNonEmptyStringSchema,
fileId: TrimmedNonEmptyStringSchema,
}),
),
failed: Schema.optional(
Schema.Array(
Schema.Struct({
filename: TrimmedNonEmptyStringSchema,
error: TrimmedNonEmptyStringSchema,
}),
),
),
});
export type FilesPersistedPayload = typeof FilesPersistedPayload.Type;
export const ProviderRuntimeSessionStartedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: SessionStartedType,
payload: SessionStartedPayload,
});
export type ProviderRuntimeSessionStartedEvent = typeof ProviderRuntimeSessionStartedEvent.Type;
export const ProviderRuntimeSessionConfiguredEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: SessionConfiguredType,
payload: SessionConfiguredPayload,
});
export type ProviderRuntimeSessionConfiguredEvent =
typeof ProviderRuntimeSessionConfiguredEvent.Type;
export const ProviderRuntimeSessionStateChangedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: SessionStateChangedType,
payload: SessionStateChangedPayload,
});
export type ProviderRuntimeSessionStateChangedEvent =
typeof ProviderRuntimeSessionStateChangedEvent.Type;
export const ProviderRuntimeSessionExitedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: SessionExitedType,
payload: SessionExitedPayload,
});
export type ProviderRuntimeSessionExitedEvent = typeof ProviderRuntimeSessionExitedEvent.Type;
export const ProviderRuntimeThreadStartedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ThreadStartedType,
payload: ThreadStartedPayload,
});
export type ProviderRuntimeThreadStartedEvent = typeof ProviderRuntimeThreadStartedEvent.Type;
export const ProviderRuntimeThreadStateChangedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ThreadStateChangedType,
payload: ThreadStateChangedPayload,
});
export type ProviderRuntimeThreadStateChangedEvent =
typeof ProviderRuntimeThreadStateChangedEvent.Type;
export const ProviderRuntimeThreadMetadataUpdatedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ThreadMetadataUpdatedType,
payload: ThreadMetadataUpdatedPayload,
});
export type ProviderRuntimeThreadMetadataUpdatedEvent =
typeof ProviderRuntimeThreadMetadataUpdatedEvent.Type;
export const ProviderRuntimeThreadTokenUsageUpdatedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ThreadTokenUsageUpdatedType,
payload: ThreadTokenUsageUpdatedPayload,
});
export type ProviderRuntimeThreadTokenUsageUpdatedEvent =
typeof ProviderRuntimeThreadTokenUsageUpdatedEvent.Type;
export const ProviderRuntimeThreadRealtimeStartedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ThreadRealtimeStartedType,
payload: ThreadRealtimeStartedPayload,
});
export type ProviderRuntimeThreadRealtimeStartedEvent =
typeof ProviderRuntimeThreadRealtimeStartedEvent.Type;
export const ProviderRuntimeThreadRealtimeItemAddedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ThreadRealtimeItemAddedType,
payload: ThreadRealtimeItemAddedPayload,
});
export type ProviderRuntimeThreadRealtimeItemAddedEvent =
typeof ProviderRuntimeThreadRealtimeItemAddedEvent.Type;
export const ProviderRuntimeThreadRealtimeAudioDeltaEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ThreadRealtimeAudioDeltaType,
payload: ThreadRealtimeAudioDeltaPayload,
});
export type ProviderRuntimeThreadRealtimeAudioDeltaEvent =
typeof ProviderRuntimeThreadRealtimeAudioDeltaEvent.Type;
export const ProviderRuntimeThreadRealtimeErrorEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ThreadRealtimeErrorType,
payload: ThreadRealtimeErrorPayload,
});
export type ProviderRuntimeThreadRealtimeErrorEvent =
typeof ProviderRuntimeThreadRealtimeErrorEvent.Type;
export const ProviderRuntimeThreadRealtimeClosedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ThreadRealtimeClosedType,
payload: ThreadRealtimeClosedPayload,
});
export type ProviderRuntimeThreadRealtimeClosedEvent =
typeof ProviderRuntimeThreadRealtimeClosedEvent.Type;
export const ProviderRuntimeAuthStatusEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: AuthStatusType,
payload: AuthStatusPayload,
});
export type ProviderRuntimeAuthStatusEvent = typeof ProviderRuntimeAuthStatusEvent.Type;
export const ProviderRuntimeAccountUpdatedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: AccountUpdatedType,
payload: AccountUpdatedPayload,
});
export type ProviderRuntimeAccountUpdatedEvent = typeof ProviderRuntimeAccountUpdatedEvent.Type;
export const ProviderRuntimeAccountRateLimitsUpdatedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: AccountRateLimitsUpdatedType,
payload: AccountRateLimitsUpdatedPayload,
});
export type ProviderRuntimeAccountRateLimitsUpdatedEvent =
typeof ProviderRuntimeAccountRateLimitsUpdatedEvent.Type;
export const ProviderRuntimeMcpStatusUpdatedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: McpStatusUpdatedType,
payload: McpStatusUpdatedPayload,
});
export type ProviderRuntimeMcpStatusUpdatedEvent = typeof ProviderRuntimeMcpStatusUpdatedEvent.Type;
export const ProviderRuntimeMcpOauthCompletedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: McpOauthCompletedType,
payload: McpOauthCompletedPayload,
});
export type ProviderRuntimeMcpOauthCompletedEvent =
typeof ProviderRuntimeMcpOauthCompletedEvent.Type;
export const ProviderRuntimeModelReroutedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ModelReroutedType,
payload: ModelReroutedPayload,
});
export type ProviderRuntimeModelReroutedEvent = typeof ProviderRuntimeModelReroutedEvent.Type;
export const ProviderRuntimeConfigWarningEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: ConfigWarningType,
payload: ConfigWarningPayload,
});
export type ProviderRuntimeConfigWarningEvent = typeof ProviderRuntimeConfigWarningEvent.Type;
export const ProviderRuntimeDeprecationNoticeEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: DeprecationNoticeType,
payload: DeprecationNoticePayload,
});
export type ProviderRuntimeDeprecationNoticeEvent =
typeof ProviderRuntimeDeprecationNoticeEvent.Type;
export const ProviderRuntimeFilesPersistedEvent = Schema.Struct({
...ProviderRuntimeEventBase.fields,
type: FilesPersistedType,
payload: FilesPersistedPayload,
});
export type ProviderRuntimeFilesPersistedEvent = typeof ProviderRuntimeFilesPersistedEvent.Type;