Files
t3code/packages/contracts/src/applicationEvent.ts
T
Julius MarmingeandClaude Fable 5 d256570669 fix: repair rerere-damaged files and reconcile main's round-3 features with v2
Post-rebase reconciliation sweep:
- Sidebar: main's folded Sidebar.tsx/Sidebar.logic.ts adapted to v2 shells
  (latestRun/runtime naming, waiting status instead of monitoring), with
  subagent-thread filtering and main's pinned-reorder helpers re-exported
- Pinned drag reorder (#5581) ported into v2: thread.pin orderKey +
  thread.pin.reorder command, thread.pin-reordered event, Orchestrator fold,
  ProjectionStore/Maintenance, client-runtime commands and shell mapping
- Project favicon (#4849-era) and defaultThreadEnvMode flowed through v2
  contracts (OrchestrationProjectShell, application event payloads)
- ChatView: main's #5592 header props, pull-request right-panel surfaces,
  liveAgentCount badge (#5745) wired into the v2 panel layout
- enableAssistantStreaming -> enableLegacyTokenStreaming rename applied to
  v2 RunExecutionService and replay testkit
- Removed v1 zombies resurrected by the rebase (provider service/reaper/
  ingestion + v1 layer tests, server.test.ts, integration harness)
- routeTree: main's tree + branch's /settings/scheduled-tasks route
- Misc marker-sweep syntax repairs (rpc.ts, entities.ts, localApi.test.ts,
  rightPanelStore.test.ts, GitManager.test.ts, mobile model menu helpers)

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-14 11:23:51 +02:00

107 lines
4.2 KiB
TypeScript

import * as Schema from "effect/Schema";
import {
ApprovalRequestId,
CommandId,
EventId,
IsoDateTime,
NonNegativeInt,
ProjectId,
ProviderItemId,
TrimmedNonEmptyString,
} from "./baseSchemas.ts";
import { RepositoryIdentity, ThreadEnvMode } from "./environment.ts";
import { ModelSelection } from "./modelSelection.ts";
import type { OrchestrationV2StoredEvent } from "./orchestrationV2.ts";
import { ProjectScript } from "./project.ts";
/** Metadata retained by the shared application event source. */
export const ApplicationEventMetadata = Schema.Struct({
providerTurnId: Schema.optional(TrimmedNonEmptyString),
providerItemId: Schema.optional(ProviderItemId),
adapterKey: Schema.optional(TrimmedNonEmptyString),
requestId: Schema.optional(ApprovalRequestId),
ingestedAt: Schema.optional(IsoDateTime),
});
export type ApplicationEventMetadata = typeof ApplicationEventMetadata.Type;
export const ApplicationProjectCreatedPayload = Schema.Struct({
projectId: ProjectId,
title: TrimmedNonEmptyString,
workspaceRoot: TrimmedNonEmptyString,
repositoryIdentity: Schema.optional(Schema.NullOr(RepositoryIdentity)),
defaultModelSelection: Schema.NullOr(ModelSelection),
// Per-project override for where new threads start; optional so persisted
// events from older servers still decode.
defaultThreadEnvMode: Schema.optional(Schema.NullOr(ThreadEnvMode)),
// Optional so persisted events from older servers still decode.
faviconPath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
scripts: Schema.Array(ProjectScript),
createdAt: IsoDateTime,
updatedAt: IsoDateTime,
});
export type ApplicationProjectCreatedPayload = typeof ApplicationProjectCreatedPayload.Type;
export const ApplicationProjectMetaUpdatedPayload = Schema.Struct({
projectId: ProjectId,
title: Schema.optional(TrimmedNonEmptyString),
workspaceRoot: Schema.optional(TrimmedNonEmptyString),
repositoryIdentity: Schema.optional(Schema.NullOr(RepositoryIdentity)),
defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
// Absent = leave unchanged; null = clear the override.
defaultThreadEnvMode: Schema.optional(Schema.NullOr(ThreadEnvMode)),
faviconPath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
scripts: Schema.optional(Schema.Array(ProjectScript)),
updatedAt: IsoDateTime,
});
export type ApplicationProjectMetaUpdatedPayload = typeof ApplicationProjectMetaUpdatedPayload.Type;
export const ApplicationProjectDeletedPayload = Schema.Struct({
projectId: ProjectId,
deletedAt: IsoDateTime,
});
export type ApplicationProjectDeletedPayload = typeof ApplicationProjectDeletedPayload.Type;
const ApplicationProjectEventBaseFields = {
sequence: NonNegativeInt,
eventId: EventId,
aggregateKind: Schema.Literal("project"),
aggregateId: ProjectId,
occurredAt: IsoDateTime,
commandId: Schema.NullOr(CommandId),
causationEventId: Schema.NullOr(EventId),
correlationId: Schema.NullOr(CommandId),
metadata: ApplicationEventMetadata,
} as const;
export const ApplicationProjectCreatedEvent = Schema.Struct({
...ApplicationProjectEventBaseFields,
type: Schema.Literal("project.created"),
payload: ApplicationProjectCreatedPayload,
});
export type ApplicationProjectCreatedEvent = typeof ApplicationProjectCreatedEvent.Type;
export const ApplicationProjectMetaUpdatedEvent = Schema.Struct({
...ApplicationProjectEventBaseFields,
type: Schema.Literal("project.meta-updated"),
payload: ApplicationProjectMetaUpdatedPayload,
});
export type ApplicationProjectMetaUpdatedEvent = typeof ApplicationProjectMetaUpdatedEvent.Type;
export const ApplicationProjectDeletedEvent = Schema.Struct({
...ApplicationProjectEventBaseFields,
type: Schema.Literal("project.deleted"),
payload: ApplicationProjectDeletedPayload,
});
export type ApplicationProjectDeletedEvent = typeof ApplicationProjectDeletedEvent.Type;
export const ApplicationProjectEvent = Schema.Union([
ApplicationProjectCreatedEvent,
ApplicationProjectMetaUpdatedEvent,
ApplicationProjectDeletedEvent,
]);
export type ApplicationProjectEvent = typeof ApplicationProjectEvent.Type;
/** Events exposed by the retained application event source. */
export type ApplicationStoredEvent = ApplicationProjectEvent | OrchestrationV2StoredEvent;