AkurAI Build
Menu

popagent

public

Latest change ac1b32888da9db0a129d0e91ff5cb4dac22c12f0 - Add workspace documentation RAG by AkurAI Build

export const MAX_AGENT_INSTRUCTIONS_CHARACTERS = 32_000;
export const DEFAULT_WORKSPACE_ID = "default";

export type ChatMessage = {
  id: string;
  role: string;
  parts: unknown[];
  metadata?: Record<string, unknown>;
  [key: string]: unknown;
};
export type AgentActivity = {
  turnId: string;
  runId: string;
  agentId: string;
  agentName: string;
  iteration: number;
  maxIterations: number | null;
  isFinal: boolean;
  finishReason: string;
  text: string;
  tools: string[];
};

export type AgentWorkspace = {
  id: string;
  name: string;
  repositoryPath: string;
  createdAt: string;
  updatedAt: string;
};

export type DocumentationPageSummary = {
  path: string;
  title: string;
  revision: string;
  size: number;
  updatedAt: string;
};
export type DocumentationPage = DocumentationPageSummary & { content: string };
export type DocumentationSearchResult = {
  workspaceId: string;
  workspaceName: string;
  path: string;
  title: string;
  heading?: string;
  excerpt: string;
  score: number;
};
export type DocumentationIndexStatus = {
  workspaceId: string;
  files: number;
  chunks: number;
  indexedAt: string | null;
  model: string;
  dimension: number;
  running: boolean;
};
export type DocumentationListResponse = { pages: DocumentationPageSummary[] };
export type DocumentationSearchResponse = { results: DocumentationSearchResult[] };

export type SessionSummary = {
  id: string;
  title: string;
  model: string;
  workspaceId: string;
  revision: number;
  archivedAt: string | null;
  createdAt: string;
  updatedAt: string;
};

export type Session<Message = ChatMessage> = SessionSummary & { messages: Message[] };
export const AGENT_TOOL_NAMES = [
  "getTime",
  "remember",
  "storeSecret",
  "recallSecret",
  "updateSecret",
  "webSearch",
  "searchDocumentation",
] as const;
export type AgentToolName = (typeof AGENT_TOOL_NAMES)[number];
export type AgentWorkspaceAccess = "read-write" | "read-only" | "none";
export type AgentBrowserAccess = "interactive" | "read-only" | "none";

export type AgentSettings = {
  id: string;
  name: string;
  description: string;
  instructions: string;
  workspaceAccess: AgentWorkspaceAccess;
  browserAccess: AgentBrowserAccess;
  delegationEnabled: boolean;
  tools: AgentToolName[];
  sourceUrls: string[];
  createdAt: string;
  updatedAt: string;
};

export type AgentSettingsInput = Pick<
  AgentSettings,
  | "name"
  | "description"
  | "instructions"
  | "workspaceAccess"
  | "browserAccess"
  | "delegationEnabled"
  | "tools"
>;

export type AgentSkill = {
  id: string;
  agentId: string;
  name: string;
  description: string;
  instructions: string;
  references: Record<string, string>;
  sourceUrls: string[];
  enabled: boolean;
  userInvocable: boolean;
  createdAt: string;
  updatedAt: string;
};

export type AgentSkillInput = Pick<
  AgentSkill,
  "name" | "description" | "instructions" | "references" | "enabled" | "userInvocable"
>;

export type ChannelDispatchMode = "every-message" | "mentions";
export type ChannelToolDisplay = "compact" | "timeline";

export type ChannelSettings = {
  enabled: boolean;
  channelName: string;
  dispatchMode: ChannelDispatchMode;
  contextMessages: number;
  streaming: boolean;
  toolDisplay: ChannelToolDisplay;
  updatedAt: string;
};

export type ChannelSettingsInput = Omit<ChannelSettings, "updatedAt">;

export type Channel = {
  id: string;
  name: string;
  createdAt: string;
  updatedAt: string;
};

export type ChannelMessage = {
  id: string;
  channelId: string;
  workspaceId: string;
  authorId: string;
  authorName: string;
  content: string;
  taskId: string | null;
  task: AgentTask | null;
  createdAt: string;
};

export type BrowserScope = "thread" | "shared";

export type BrowserSettings = {
  enabled: boolean;
  scope: BrowserScope;
  viewportWidth: number;
  viewportHeight: number;
  timeoutMs: number;
  maxSessions: number;
  idleTimeoutMs: number;
  screencastEnabled: boolean;
  screenshotsEnabled: boolean;
  multiTabEnabled: boolean;
  formsEnabled: boolean;
  dialogsEnabled: boolean;
  dragEnabled: boolean;
  evaluateEnabled: boolean;
  recordingEnabled: boolean;
  recordingRetentionDays: number;
  recordingMaxFiles: number;
  allowHosts: string[];
  denyHosts: string[];
  updatedAt: string;
};

export type BrowserSettingsInput = Omit<BrowserSettings, "updatedAt">;

export type BrowserSession = {
  id: string;
  threadId: string;
  access: "interactive" | "read-only";
  status: "active" | "closed" | "error";
  currentUrl: string | null;
  tabs: Array<{ id: string; url: string; title: string }>;
  activeTabIndex: number;
  createdAt: string;
  lastActivityAt: string;
};

export type MemorySettings = {
  autoCompact: boolean;
  observationTokens: number;
  reflectionTokens: number;
  recentMessagePercent: number;
  bufferOnIdle: boolean;
  updatedAt: string;
};

export type MemorySettingsInput = Omit<MemorySettings, "updatedAt">;

export type AgentRuntimeSettings = {
  defaultModel: string;
  supervisorMaxSteps: number;
  specialistMaxSteps: number;
  toolConcurrency: number;
  delegationContextMessages: number;
  delegationResultCharacters: number;
  maxProcessorRetries: number;
  finalResponseFeedback: string;
  delegationFailureFeedback: string;
  delegationResultTruncationMarker: string;
  taskConcurrency: number;
  taskPollIntervalMs: number;
  taskTimeoutMs: number;
  taskStaleAfterMs: number;
  updatedAt: string;
};

export type AgentRuntimeSettingsInput = Omit<AgentRuntimeSettings, "updatedAt">;

export type MemoryRecord = {
  id: string;
  resourceId: string;
  sessionId: string;
  kind: "fact" | "episode";
  key: string | null;
  content: string;
  importance: number;
  accessCount: number;
  createdAt: string;
  updatedAt: string;
  lastAccessedAt: string;
};

export type AgentTaskStatus = "queued" | "running" | "cancelling" | "completed" | "failed" | "cancelled";

export type AgentTask = {
  id: string;
  sessionId: string | null;
  scheduleId: string | null;
  workspaceId: string;
  prompt: string;
  model: string;
  status: AgentTaskStatus;
  output: string | null;
  error: string | null;
  stepsCompleted: number;
  progress: string | null;
  recoveryCount: number;
  createdAt: string;
  startedAt: string | null;
  completedAt: string | null;
};

export type AgentTaskProgress = Pick<AgentTask, "stepsCompleted" | "progress">;

export type AgentSchedule = {
  id: string;
  sessionId: string | null;
  workspaceId: string;
  name: string;
  prompt: string;
  model: string;
  cron: string;
  timezone: string;
  enabled: boolean;
  nextRunAt: string | null;
  lastRunAt: string | null;
  createdAt: string;
  updatedAt: string;
};

export type HookRunStatus =
  | "passed"
  | "modified"
  | "denied"
  | "continued"
  | "failed-open"
  | "failed-closed";

export type HookAuditRun = {
  id: string;
  eventId: string;
  sessionId: string;
  turnId: string | null;
  toolCallId: string | null;
  eventName: string;
  handlerId: string;
  startedAt: string;
  completedAt: string;
  durationMs: number;
  status: HookRunStatus;
  reason: string | null;
  error: string | null;
};

export type ModelCatalog = {
  models: string[];
  contextWindows: Record<string, number>;
};

export type ModelCatalogResponse = ModelCatalog & { defaultModel: string };

export type ChannelListResponse = { channels: Channel[] };
export type ChannelMessageListResponse = { messages: ChannelMessage[] };
export type WorkspaceListResponse = { workspaces: AgentWorkspace[] };
export type AgentListResponse = { agents: AgentSettings[] };
export type AgentSkillListResponse = { skills: AgentSkill[] };
export type MemoryListResponse = { memories: MemoryRecord[] };
export type TaskListResponse = { tasks: AgentTask[] };
export type ScheduleListResponse = { schedules: AgentSchedule[] };
export type SessionListResponse = { sessions: SessionSummary[] };
export type HookRunListResponse = { runs: HookAuditRun[] };

export type ObservabilityTraceSummary = {
  traceId: string;
  name: string;
  entityName: string | null;
  status: "success" | "error" | "running";
  startedAt: string;
  endedAt: string | null;
  durationMs: number | null;
  tags: string[];
  metadata: Record<string, unknown>;
};

export type ObservabilityTraceSpan = ObservabilityTraceSummary & {
  spanId: string;
  parentSpanId: string | null;
  spanType: string;
  input: unknown;
  output: unknown;
  error: unknown;
};

export type ObservabilityOverviewResponse = {
  from: string;
  to: string;
  runs: number;
  errors: number;
  errorRate: number;
  p95LatencyMs: number | null;
  inputTokens: number;
  outputTokens: number;
};

export type ObservabilityTraceListResponse = {
  traces: ObservabilityTraceSummary[];
  page: number;
  perPage: number;
  total: number;
  hasMore: boolean;
};

export type ObservabilityTraceResponse = { traceId: string; spans: ObservabilityTraceSpan[] };

export type ObservabilityLog = {
  id: string | null;
  timestamp: string;
  level: "debug" | "info" | "warn" | "error" | "fatal";
  message: string;
  traceId: string | null;
  spanId: string | null;
  entityName: string | null;
  data: Record<string, unknown>;
};

export type ObservabilityLogListResponse = {
  logs: ObservabilityLog[];
  page: number;
  perPage: number;
  total: number;
  hasMore: boolean;
};

export type ObservabilityHealthResponse = {
  status: "ok" | "error";
  checkedAt: string;
  error?: string;
};