Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(shared): types, api-types, constants from main

Gener69812f90db61
diff --git a/src/shared/src/api-types.ts b/src/shared/src/api-types.ts
new file mode 100644
index 000000000..645e3c96f
--- /dev/null
+++ b/src/shared/src/api-types.ts
@@ -0,0 +1,73 @@
+import type {
+ User,
+ Workspace,
+ Agent,
+ AgentRuntime,
+ Conversation,
+ Message,
+ AgentTask,
+ TaskMessage,
+ MachineToken,
+} from "./types";
+
+export interface ApiResponse<T> {
+ data: T;
+}
+
+export interface ApiListResponse<T> {
+ data: T[];
+ total?: number;
+}
+
+export interface ApiErrorResponse {
+ error: string;
+ code?: string;
+}
+
+export type GetUserResponse = ApiResponse<User>;
+export type ListWorkspacesResponse = ApiListResponse<Workspace>;
+export type GetWorkspaceResponse = ApiResponse<Workspace>;
+
+export type ListAgentsResponse = ApiListResponse<Agent>;
+export type GetAgentResponse = ApiResponse<Agent>;
+
+export type ListRuntimesResponse = ApiListResponse<AgentRuntime>;
+export type GetRuntimeResponse = ApiResponse<AgentRuntime>;
+
+export type ListConversationsResponse = ApiListResponse<Conversation>;
+export type GetConversationResponse = ApiResponse<Conversation>;
+
+export type ListMessagesResponse = ApiListResponse<Message>;
+
+export type ListTasksResponse = ApiListResponse<AgentTask>;
+export type GetTaskResponse = ApiResponse<AgentTask>;
+
+export type ListTaskMessagesResponse = ApiListResponse<TaskMessage>;
+
+export type ListMachineTokensResponse = ApiListResponse<MachineToken>;
+
+export interface CreateWorkspaceRequest {
+ name: string;
+}
+
+export interface UpdateAgentRequest {
+ name?: string;
+ description?: string;
+ instructions?: string;
+ runtime_config?: Record<string, unknown>;
+ max_concurrent_tasks?: number;
+}
+
+export interface SendMessageRequest {
+ content: string;
+}
+
+export interface CreateMachineTokenRequest {
+ name: string;
+}
+
+export interface CreateMachineTokenResponse {
+ token: string;
+ id: string;
+ name: string;
+}
diff --git a/src/shared/src/constants.ts b/src/shared/src/constants.ts
new file mode 100644
index 000000000..3ed192a35
--- /dev/null
+++ b/src/shared/src/constants.ts
@@ -0,0 +1,34 @@
+export const AgentStatus = {
+ ACTIVE: "active",
+ INACTIVE: "inactive",
+ ERROR: "error",
+} as const;
+
+export type AgentStatusType = (typeof AgentStatus)[keyof typeof AgentStatus];
+
+export const RuntimeStatus = {
+ ONLINE: "online",
+ OFFLINE: "offline",
+ ERROR: "error",
+} as const;
+
+export type RuntimeStatusType =
+ (typeof RuntimeStatus)[keyof typeof RuntimeStatus];
+
+export const TaskStatus = {
+ QUEUED: "queued",
+ DISPATCHED: "dispatched",
+ RUNNING: "running",
+ COMPLETED: "completed",
+ FAILED: "failed",
+ CANCELLED: "cancelled",
+} as const;
+
+export type TaskStatusType = (typeof TaskStatus)[keyof typeof TaskStatus];
+
+export const MessageRole = {
+ USER: "user",
+ ASSISTANT: "assistant",
+} as const;
+
+export type MessageRoleType = (typeof MessageRole)[keyof typeof MessageRole];
diff --git a/src/shared/src/types.ts b/src/shared/src/types.ts
new file mode 100644
index 000000000..f7640fd7e
--- /dev/null
+++ b/src/shared/src/types.ts
@@ -0,0 +1,121 @@
+export interface User {
+ id: string;
+ name: string;
+ email: string;
+ avatar_url: string | null;
+ created_at: string;
+ updated_at: string;
+}
+
+export interface Workspace {
+ id: string;
+ name: string;
+ slug: string;
+ created_at: string;
+ updated_at: string;
+}
+
+export interface Agent {
+ id: string;
+ workspace_id: string;
+ runtime_id: string;
+ name: string;
+ description: string;
+ instructions: string;
+ runtime_mode: string;
+ runtime_config: Record<string, unknown>;
+ status: string;
+ max_concurrent_tasks: number;
+ created_at: string;
+ updated_at: string;
+}
+
+export interface AgentRuntime {
+ id: string;
+ workspace_id: string;
+ daemon_id: string | null;
+ name: string;
+ runtime_mode: string;
+ provider: string;
+ status: string;
+ device_info: string;
+ metadata: Record<string, unknown>;
+ last_seen_at: string | null;
+ created_at: string;
+ updated_at: string;
+}
+
+export interface Conversation {
+ id: string;
+ agent_id: string;
+ title: string;
+ created_at: string;
+}
+
+export interface Message {
+ id: string;
+ conversation_id: string;
+ role: "user" | "assistant";
+ content: string;
+ task_id: string | null;
+ created_at: string;
+}
+
+/** @deprecated Use TaskApiSchema from schemas.ts for runtime validation. */
+export interface AgentTask {
+ id: string;
+ agent_id: string;
+ runtime_id: string;
+ conversation_id: string;
+ workspace_id: string;
+ prompt: string;
+ status: string;
+ priority: number;
+ dispatched_at: string | null;
+ started_at: string | null;
+ completed_at: string | null;
+ result: unknown;
+ error: string | null;
+ agent?: TaskAgentData;
+ created_at: string;
+ prior_session_id?: string;
+ prior_work_dir?: string;
+}
+
+export interface TaskAgentData {
+ id: string;
+ name: string;
+ instructions: string;
+}
+
+export interface TaskMessage {
+ id: string;
+ task_id: string;
+ seq: number;
+ type: string;
+ tool: string;
+ content: string;
+ input?: Record<string, unknown>;
+ output: string;
+}
+
+export interface MachineToken {
+ id: string;
+ name: string;
+ last_used_at: string | null;
+ created_at: string;
+}
+
+export interface LoginResponse {
+ token: string;
+ user: User;
+}
+
+export interface CreateAgentRequest {
+ name: string;
+ description?: string;
+ instructions?: string;
+ runtime_id: string;
+ runtime_config?: Record<string, unknown>;
+ max_concurrent_tasks?: number;
+}