### Install Dependencies and Pull Environment Variables Source: https://github.com/niapya/clawless/blob/main/README.md Installs project dependencies and pulls Vercel environment variables locally for development. Ensure you have Bun installed. ```bash cd your-clawless bun install # Pull Vercel environment variables locally, including AUTH_SECRET, USERNAME, PASSWORD, and KV, DB, Blob and Sandbox keys. bun vercel pull bun dev ``` -------------------------------- ### GET /api/skills Source: https://context7.com/niapya/clawless/llms.txt Lists all installed skills. ```APIDOC ## GET /api/skills ### Description Retrieves a list of all installed skills. ### Method GET ### Endpoint https://your-clawless.vercel.app/api/skills ``` -------------------------------- ### List Skills Source: https://context7.com/niapya/clawless/llms.txt Retrieve metadata for all installed skills. ```bash curl "https://your-clawless.vercel.app/api/skills" \ -H "Cookie: clawless-auth=" ``` ```json [ { "name": "code-review", "description": "代码审查助手", "source": "git", "gitURL": "https://github.com/example/skills.git", "files": ["SKILL.md", "prompts/review.md"] }, { "name": "translator", "description": "多语言翻译", "source": "manual", "files": ["SKILL.md"] } ] ``` -------------------------------- ### Get Configuration Source: https://context7.com/niapya/clawless/llms.txt Retrieves the full application configuration, including AI models, channels, and agent settings. ```bash # 获取当前配置 curl "https://your-clawless.vercel.app/api/config" \ -H "Cookie: clawless-auth=" # 响应示例 { "config": { "models": { "model": "openai/gpt-4", "embedding_model": "openai/text-embedding-3-small", "temperature": 0.7, "providers": { "openai": { "format": "openaicompatible", "base_url": "https://api.openai.com/v1" } } }, "channels": { "telegram": { "enabled": true, "bot_token": "xxx", "allowed_author_ids": ["user123"] } }, "agents": { "default": { "system_prompt": "你是一个有帮助的 AI 助手", "temperature": 0.7 } } }, "runtimeHealth": {...} } ``` -------------------------------- ### Get Skill Details Source: https://context7.com/niapya/clawless/llms.txt Retrieve details for a specific skill. ```bash curl "https://your-clawless.vercel.app/api/skills/my-skill" \ -H "Cookie: clawless-auth=" ``` ```json { "name": "my-skill", "description": "自定义技能", "source": "manual", "files": ["SKILL.md", "prompts/main.md"], "createdAt": "2024-01-01T00:00:00Z", "updatedAt": "2024-01-01T00:00:00Z" } ``` -------------------------------- ### GET /api/skills/{skillName} Source: https://context7.com/niapya/clawless/llms.txt Gets details for a specific skill. ```APIDOC ## GET /api/skills/{skillName} ### Description Retrieves metadata for a specific skill. ### Method GET ### Endpoint https://your-clawless.vercel.app/api/skills/{skillName} ### Path Parameters - **skillName** (string) - Required - Name of the skill ``` -------------------------------- ### GET /api/files Source: https://context7.com/niapya/clawless/llms.txt Retrieves a list of uploaded files with optional filtering and pagination. ```APIDOC ## GET /api/files ### Description Lists files uploaded to the system. ### Method GET ### Endpoint https://your-clawless.vercel.app/api/files ### Parameters #### Query Parameters - **limit** (integer) - Optional - Number of files to return - **sort** (string) - Optional - Sort order - **sessionId** (string) - Optional - Filter by session ID ### Response #### Success Response (200) - **files** (array) - List of file objects - **hasMore** (boolean) - Pagination indicator #### Response Example { "files": [ { "id": "file-123", "name": "document.pdf" } ], "hasMore": false } ``` -------------------------------- ### GET /api/memory/long-term Source: https://context7.com/niapya/clawless/llms.txt Searches or lists long-term memory entries. ```APIDOC ## GET /api/memory/long-term ### Description Searches memory using semantic/keyword queries or lists all memories. ### Method GET ### Endpoint https://your-clawless.vercel.app/api/memory/long-term ### Query Parameters - **query** (string) - Optional - Search query - **minConfidence** (number) - Optional - Confidence threshold - **pageSize** (number) - Optional - Page size - **page** (number) - Optional - Page number ``` -------------------------------- ### GET /api/schedules Source: https://context7.com/niapya/clawless/llms.txt Retrieves a list of all scheduled tasks, including daily and delayed tasks. ```APIDOC ## GET /api/schedules ### Description Fetches all scheduled tasks. ### Method GET ### Endpoint https://your-clawless.vercel.app/api/schedules ### Response #### Success Response (200) - **tasks** (array) - List of scheduled task objects #### Response Example { "tasks": [ { "id": "task-123", "type": "daily", "title": "每日摘要", "nextRunAt": "2024-01-02T01:00:00Z", "active": true } ] } ``` -------------------------------- ### Development and Deployment Commands Source: https://github.com/niapya/clawless/blob/main/AGENTS.md Common CLI commands for managing dependencies, database migrations, and deployment using Bun. ```bash bun install ``` ```bash bun run db:generate # 生成迁移 bun run db:push # 推送到数据库 ``` ```bash bun run dev # 访问 http://localhost:3000 ``` ```bash bun run check # 完整检查 ``` ```bash bun run build # 构建生产版本 bun run deploy # 部署到 Vercel ``` -------------------------------- ### Replace Configuration via PUT Source: https://context7.com/niapya/clawless/llms.txt Perform a full replacement of the system configuration. ```bash curl -X PUT "https://your-clawless.vercel.app/api/config/update" \ -H "Content-Type: application/json" \ -d '{ "models": { "model": "openai/gpt-4", "embedding_model": "openai/text-embedding-3-small", "temperature": 0.7, "providers": { "openai": { "format": "openaicompatible", "api_key": "sk-xxx", "base_url": "https://api.openai.com/v1" } } }, "channels": { "telegram": { "enabled": true, "bot_token": "your-bot-token", "allowed_author_ids": ["123456789"] } } }' ``` -------------------------------- ### Create Skill Manually Source: https://context7.com/niapya/clawless/llms.txt Create a new skill by providing file paths and content. ```bash curl -X POST "https://your-clawless.vercel.app/api/skills" \ -H "Content-Type: application/json" \ -H "Cookie: clawless-auth=" \ -d '{ "name": "my-skill", "description": "自定义技能", "files": [ { "path": "SKILL.md", "content": "# My Skill\n\n这是一个自定义技能的说明..." }, { "path": "prompts/main.md", "content": "## 系统提示词\n\n你是一个..." } ] }' ``` ```json { "name": "my-skill", "description": "自定义技能", "source": "manual", "files": ["SKILL.md", "prompts/main.md"], "createdAt": "2024-01-01T00:00:00Z" } ``` -------------------------------- ### Import Skill from Git Source: https://context7.com/niapya/clawless/llms.txt Asynchronously import skills from a Git repository. ```bash curl -X POST "https://your-clawless.vercel.app/api/skills/import" \ -H "Content-Type: application/json" \ -d '{ "gitURL": "https://github.com/example/ai-skills.git" }' ``` ```json { "jobId": "job-uuid-123", "status": "pending", "gitURL": "https://github.com/example/ai-skills.git" } ``` ```bash curl "https://your-clawless.vercel.app/api/skills/import?jobId=job-uuid-123" ``` ```json { "jobId": "job-uuid-123", "status": "syncing", "gitURL": "https://github.com/example/ai-skills.git" } ``` ```json { "jobId": "job-uuid-123", "status": "done", "gitURL": "https://github.com/example/ai-skills.git", "importedNames": ["skill-a", "skill-b"], "removedNames": [], "fileCount": 12, "finishedAt": 1704067200000 } ``` ```bash curl "https://your-clawless.vercel.app/api/skills/import" ``` -------------------------------- ### PUT /api/config/update Source: https://context7.com/niapya/clawless/llms.txt Completely replaces the system configuration. ```APIDOC ## PUT /api/config/update ### Description Completely replaces the system configuration. ### Method PUT ### Endpoint https://your-clawless.vercel.app/api/config/update ### Request Body - **models** (object) - Required - Model configuration - **channels** (object) - Required - Channel configuration ### Request Example { "models": { "model": "openai/gpt-4", "embedding_model": "openai/text-embedding-3-small", "temperature": 0.7, "providers": { "openai": { "format": "openaicompatible", "api_key": "sk-xxx", "base_url": "https://api.openai.com/v1" } } }, "channels": { "telegram": { "enabled": true, "bot_token": "your-bot-token", "allowed_author_ids": ["123456789"] } } } ``` -------------------------------- ### Project Directory Structure Source: https://github.com/niapya/clawless/blob/main/AGENTS.md The standard directory layout for the Next.js App Router project. ```text app/ # Next.js App Router ├── (auth)/ # 认证相关路由 ├── (chat)/ # 聊天相关路由 ├── (config)/ # 配置相关路由 ├── (memory)/ # 内存管理路由 ├── (skill)/ # 技能管理路由 └── layout.tsx # 根布局 components/ # React 可复用组件 ├── ui/ # shadcn/ui 原始组件 ├── auth/ # 认证组件 ├── config/ # 配置界面组件 └── *.tsx # 其他功能组件 lib/ # 工具函数与核心逻辑 ├── ai/ # AI SDK 封装 ├── auth/ # 认证逻辑 ├── blob/ # Blob 存储 ├── bot/ # Bot 适配器 ├── chat/ # 聊天逻辑 ├── db/ # 数据库操作 ├── kv/ # Redis 缓存 ├── sandbox/ # 沙箱执行 ├── workflow/ # 工作流调度 └── utils/ # 通用工具函数 types/ # TypeScript 类型定义 ├── config/ # 配置相关类型 ├── skills/ # 技能相关类型 └── *.ts # 其他类型 public/ # 静态资源 └── fonts/, images/ ``` -------------------------------- ### POST /api/skills/import Source: https://context7.com/niapya/clawless/llms.txt Imports a skill from a Git repository. ```APIDOC ## POST /api/skills/import ### Description Initiates an asynchronous import of a skill from a Git repository. ### Method POST ### Endpoint https://your-clawless.vercel.app/api/skills/import ### Request Body - **gitURL** (string) - Required - URL of the Git repository ``` -------------------------------- ### Subscribe to Workflow Stream Source: https://context7.com/niapya/clawless/llms.txt Establishes a connection to receive real-time streaming output from an active workflow. ```bash # 订阅工作流输出流 curl "https://your-clawless.vercel.app/api/ai/{runId}/stream" \ -H "Cookie: clawless-auth=" \ -H "Accept: text/event-stream" # 响应: Server-Sent Events 流 # data: {"type":"text-delta","delta":"Hello"} # data: {"type":"text-delta","delta":" World"} ``` -------------------------------- ### POST /api/skills Source: https://context7.com/niapya/clawless/llms.txt Manually creates a new skill. ```APIDOC ## POST /api/skills ### Description Creates a new skill by providing file content. ### Method POST ### Endpoint https://your-clawless.vercel.app/api/skills ### Request Body - **name** (string) - Required - Skill name - **description** (string) - Required - Skill description - **files** (array) - Required - List of file objects ``` -------------------------------- ### List Files Source: https://context7.com/niapya/clawless/llms.txt Retrieves a list of uploaded files with optional filtering by session ID. ```bash curl "https://your-clawless.vercel.app/api/files?limit=30&sort=desc" \ -H "Cookie: clawless-auth=" ``` ```bash curl "https://your-clawless.vercel.app/api/files?sessionId=session-123&limit=20" ``` -------------------------------- ### Update Configuration via PATCH Source: https://context7.com/niapya/clawless/llms.txt Perform a partial update of the system configuration. ```bash curl -X PATCH "https://your-clawless.vercel.app/api/config/update" \ -H "Content-Type: application/json" \ -H "Cookie: clawless-auth=" \ -d '{ "models": { "model": "anthropic/claude-3-5-sonnet-20241022", "temperature": 0.5 } }' ``` -------------------------------- ### Authenticate User Source: https://context7.com/niapya/clawless/llms.txt Logs in a user and returns an authentication cookie for subsequent requests. ```bash # 用户登录 curl -X POST "https://your-clawless.vercel.app/api/auth/login" \ -H "Content-Type: application/json" \ -d '{ "username": "admin", "password": "your-password" }' # 响应示例 { "ok": true, "redirectTo": "/" } # Set-Cookie: clawless-auth=; Path=/; HttpOnly; Secure; SameSite=Lax ``` -------------------------------- ### Slash Commands Source: https://context7.com/niapya/clawless/llms.txt List of available slash commands for chat interactions. ```bash /help # 显示帮助信息 /status # 显示当前会话状态 /new # 创建新会话 /session # 显示当前绑定的会话 /session # 切换到指定会话 /stop # 停止当前工作流 /compact # 请求上下文压缩 /approve # 批准待定的工具调用 /reject # 拒绝待定的工具调用 ``` -------------------------------- ### Search and List Long-Term Memory Source: https://context7.com/niapya/clawless/llms.txt Query memories using semantic search or list all existing entries. ```bash curl "https://your-clawless.vercel.app/api/memory/long-term?query=TypeScript%20开发偏好&minConfidence=0.7&pageSize=10" \ -H "Cookie: clawless-auth=" ``` ```json { "search": true, "page": 1, "pageSize": 10, "results": [ { "memoryId": "mem-123", "content": "用户偏好使用 TypeScript...", "confidence": 0.85, "matchType": "semantic" } ] } ``` ```bash curl "https://your-clawless.vercel.app/api/memory/long-term?page=1&pageSize=50" ``` ```json { "search": false, "page": 1, "pageSize": 50, "items": [...] } ``` -------------------------------- ### TypeScript Import Order Convention Source: https://github.com/niapya/clawless/blob/main/AGENTS.md Standardized import ordering for maintaining clean and readable codebases. ```typescript // 1. 外部库 import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useChat } from '@ai-sdk/react'; import { ofetch } from 'ofetch'; // 2. 内部组件与工具 import { ChatHeader } from '@/components/chat-header'; import { deriveSessionTitle } from '@/lib/chat/session-title'; import { type WorkflowDataPart } from '@/types/workflow'; // 3. 本地导入 import { Messages } from './messages'; ``` -------------------------------- ### Configure Telegram Webhook Source: https://context7.com/niapya/clawless/llms.txt Sets the webhook URL for Telegram bot integration. ```bash curl -X POST "https://api.telegram.org/bot/setWebhook" \ -H "Content-Type: application/json" \ -d '{ "url": "https://your-clawless.vercel.app/api/bot//telegram/callback", "secret_token": "" }' ``` -------------------------------- ### AppConfig Schema Source: https://context7.com/niapya/clawless/llms.txt TypeScript interface defining the application configuration structure. ```typescript interface AppConfig { models?: { model: string; // 格式: "provider/model-id" embedding_model?: string; // 格式: "provider/model-id" temperature?: number; // 0.0 - 2.0 context_limit?: number; // Token 上限 max_output_tokens?: number; // 输出 Token 上限 providers?: Record; }>; }; agents?: Record; channels?: { slack?: { enabled: boolean; bot_token?: string; signing_secret?: string; allowed_author_ids?: string[]; }; teams?: { enabled: boolean; app_id?: string; app_password?: string; allowed_author_ids?: string[]; }; gchat?: { enabled: boolean; project_id?: string; credentials_json?: string; allowed_author_ids?: string[]; }; telegram?: { enabled: boolean; bot_token?: string; secret_token?: string; bot_username?: string; allowed_author_ids?: string[]; }; }; autonomy?: { /* 自主权限配置 */ }; tools?: { /* 内置工具配置 */ }; mcp?: { /* MCP 远程服务器配置 */ }; } ``` -------------------------------- ### POST /api/memory/long-term Source: https://context7.com/niapya/clawless/llms.txt Creates a new long-term memory entry. ```APIDOC ## POST /api/memory/long-term ### Description Creates a new long-term memory entry and generates vector embeddings. ### Method POST ### Endpoint https://your-clawless.vercel.app/api/memory/long-term ### Request Body - **content** (string) - Required - The memory content ### Response #### Success Response (200) - **memory** (object) - Created memory object - **indexing** (object) - Indexing metadata ``` -------------------------------- ### Configuration Management API Source: https://context7.com/niapya/clawless/llms.txt Endpoints for retrieving and updating the application's configuration settings. ```APIDOC ## GET /api/config ### Description Retrieves the complete application configuration, including settings for AI models, channels, agents, and tools. ### Method GET ### Endpoint /api/config ### Parameters #### Request Headers - **Cookie** (string) - Required - Authentication cookie (`clawless-auth=`). ### Response #### Success Response (200) - **config** (object) - The application configuration object. - **models** (object) - AI model configurations. - **model** (string) - Default AI model. - **embedding_model** (string) - Default embedding model. - **temperature** (number) - Default temperature setting. - **providers** (object) - AI provider configurations. - **openai** (object) - OpenAI provider settings. - **format** (string) - API format compatibility. - **base_url** (string) - Base URL for the OpenAI API. - **channels** (object) - Channel integrations configuration. - **telegram** (object) - Telegram channel settings. - **enabled** (boolean) - Whether the Telegram channel is enabled. - **bot_token** (string) - The Telegram bot token. - **allowed_author_ids** (array) - List of allowed author IDs. - **agents** (object) - Agent configurations. - **default** (object) - Default agent settings. - **system_prompt** (string) - The system prompt for the default agent. - **temperature** (number) - Temperature setting for the default agent. - **runtimeHealth** (object) - Information about the runtime health of the application. #### Response Example ```json { "config": { "models": { "model": "openai/gpt-4", "embedding_model": "openai/text-embedding-3-small", "temperature": 0.7, "providers": { "openai": { "format": "openaicompatible", "base_url": "https://api.openai.com/v1" } } }, "channels": { "telegram": { "enabled": true, "bot_token": "xxx", "allowed_author_ids": ["user123"] } }, "agents": { "default": { "system_prompt": "你是一个有帮助的 AI 助手", "temperature": 0.7 } } }, "runtimeHealth": {...} } ``` ``` ```APIDOC ## PATCH /api/config or PUT /api/config ### Description Partially updates (PATCH) or completely replaces (PUT) the application configuration. ### Method PATCH or PUT ### Endpoint /api/config ### Parameters #### Request Body - **config** (object) - The configuration object to update or replace. Structure is the same as the response of `GET /api/config`. #### Request Headers - **Cookie** (string) - Required - Authentication cookie (`clawless-auth=`). - **Content-Type** (string) - Required - `application/json` for PUT, or `application/json-patch+json` for PATCH. ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the configuration update was successful. #### Response Example ```json { "ok": true } ``` ``` -------------------------------- ### Manage Sessions Source: https://context7.com/niapya/clawless/llms.txt Lists sessions or retrieves message history for a specific session with pagination support. ```bash # 列出所有会话 curl "https://your-clawless.vercel.app/api/sessions?limit=50&channel=web" \ -H "Cookie: clawless-auth=" # 响应 { "sessions": [ { "id": "session-123", "title": "Python 脚本编写", "channel": "web", "status": "active", "totalTokens": 2500, "createdAt": "2024-01-01T00:00:00Z" } ] } # 获取指定会话的消息(带分页) curl "https://your-clawless.vercel.app/api/sessions?id=session-123&limit=20&before=2024-01-01T12:00:00Z" # 响应 { "sessionId": "session-123", "messages": [...], "hasMore": true, "nextBefore": "2024-01-01T10:00:00Z" } ``` -------------------------------- ### Create Long-Term Memory Source: https://context7.com/niapya/clawless/llms.txt Create a new memory entry with automatic vector embedding generation. ```bash curl -X POST "https://your-clawless.vercel.app/api/memory/long-term" \ -H "Content-Type: application/json" \ -H "Cookie: clawless-auth=" \ -d '{ "content": "用户偏好使用 TypeScript 进行开发,喜欢函数式编程风格" }' ``` ```json { "memory": { "id": "mem-123", "content": "用户偏好使用 TypeScript 进行开发...", "createdAt": "2024-01-01T00:00:00Z", "updatedAt": "2024-01-01T00:00:00Z" }, "indexing": { "mode": "embedded", "embeddingModel": "openai/text-embedding-3-small", "embeddingDimensions": 1536, "warning": null } } ``` -------------------------------- ### List Scheduled Tasks Source: https://context7.com/niapya/clawless/llms.txt Retrieves a list of all scheduled tasks, including daily and delayed types. ```bash curl "https://your-clawless.vercel.app/api/schedules" \ -H "Cookie: clawless-auth=" ``` -------------------------------- ### Interact with Running Workflow Source: https://context7.com/niapya/clawless/llms.txt Sends user messages or control commands to an active workflow execution. ```bash # 发送用户消息 curl -X POST "https://your-clawless.vercel.app/api/ai/{runId}/message" \ -H "Content-Type: application/json" \ -d '{ "type": "user-message", "message": "继续执行下一步", "uiMessageId": "msg-789" }' # 发送控制命令 (compact/cancel) curl -X POST "https://your-clawless.vercel.app/api/ai/{runId}/message" \ -H "Content-Type: application/json" \ -d '{ "type": "control", "command": "compact", "reason": "上下文过长" }' # 响应 { "ok": true } ``` -------------------------------- ### PUT /api/schedules/{taskId} Source: https://context7.com/niapya/clawless/llms.txt Updates the configuration of an existing scheduled task. ```APIDOC ## PUT /api/schedules/{taskId} ### Description Updates a specific scheduled task by ID. ### Method PUT ### Endpoint https://your-clawless.vercel.app/api/schedules/{taskId} ### Parameters #### Path Parameters - **taskId** (string) - Required - The ID of the task to update #### Request Body - **type** (string) - Required - Task type (daily or delay) - **title** (string) - Optional - Task title - **prompt** (string) - Optional - Task prompt - **active** (boolean) - Optional - Task status ### Response #### Success Response (200) - **task** (object) - The updated task object #### Response Example { "task": { "id": "task-123", "type": "daily", "title": "每日报告" } } ``` -------------------------------- ### Delete Skill Source: https://context7.com/niapya/clawless/llms.txt Remove a skill and its associated files. ```bash curl -X DELETE "https://your-clawless.vercel.app/api/skills/my-skill" \ -H "Cookie: clawless-auth=" ``` -------------------------------- ### Manage AI Chat Messages Source: https://context7.com/niapya/clawless/llms.txt Handles sending new messages or regenerating existing ones using the main AI endpoint. ```bash # 发送新消息 curl -X POST "https://your-clawless.vercel.app/api/ai" \ -H "Content-Type: application/json" \ -H "Cookie: clawless-auth=" \ -d '{ "id": "session-uuid-here", "trigger": "submit-message", "messageId": "msg-uuid-here", "input": { "text": "你好,请帮我写一个 Python 脚本", "parts": [ { "type": "text", "text": "你好,请帮我写一个 Python 脚本" } ] } }' # 重新生成消息 curl -X POST "https://your-clawless.vercel.app/api/ai" \ -H "Content-Type: application/json" \ -d '{ "id": "session-uuid", "trigger": "regenerate-message", "messageId": "last-message-id" }' # 响应: Server-Sent Events 流 # Headers: x-session-id, x-workflow-run-id ``` -------------------------------- ### PATCH /api/config/update Source: https://context7.com/niapya/clawless/llms.txt Partially updates the system configuration, such as model settings. ```APIDOC ## PATCH /api/config/update ### Description Partially updates the system configuration. ### Method PATCH ### Endpoint https://your-clawless.vercel.app/api/config/update ### Request Body - **models** (object) - Optional - Configuration for models ### Request Example { "models": { "model": "anthropic/claude-3-5-sonnet-20241022", "temperature": 0.5 } } ``` -------------------------------- ### Update Scheduled Tasks Source: https://context7.com/niapya/clawless/llms.txt Updates the configuration for a specific task. Supports both delay and daily task types. ```bash curl -X PUT "https://your-clawless.vercel.app/api/schedules/{taskId}" \ -H "Content-Type: application/json" \ -H "Cookie: clawless-auth=" \ -d '{ "type": "delay", "title": "延迟提醒", "prompt": "提醒用户完成代码审查", "runAt": "2024-01-01T15:00:00Z", "active": true }' ``` ```bash curl -X PUT "https://your-clawless.vercel.app/api/schedules/{taskId}" \ -H "Content-Type: application/json" \ -d '{ "type": "daily", "title": "每日报告", "prompt": "生成并发送每日工作报告", "dailyTime": "18:00", "timezone": "Asia/Shanghai", "active": true }' ``` -------------------------------- ### Query Workflow Status Source: https://context7.com/niapya/clawless/llms.txt Retrieves the current status, session details, and token usage for a specific workflow run. ```bash # 获取运行状态 curl "https://your-clawless.vercel.app/api/ai/{runId}/status" \ -H "Cookie: clawless-auth=" # 响应示例 { "runId": "run-123", "sessionId": "session-456", "status": "running", "workflow": { "phase": "running", "lastRunId": "run-123", "startedAt": "2024-01-01T00:00:00Z" }, "session": { "id": "session-456", "channel": "web", "model": "openai/gpt-4", "totalTokens": 1500, "source": { "type": "web" } } } ``` -------------------------------- ### User Authentication API Source: https://context7.com/niapya/clawless/llms.txt Endpoints for user authentication, primarily for obtaining authentication tokens. ```APIDOC ## POST /api/auth/login ### Description Logs in a user by verifying username and password, returning an authentication cookie for subsequent requests. ### Method POST ### Endpoint /api/auth/login ### Parameters #### Request Body - **username** (string) - Required - The username for login. - **password** (string) - Required - The password for login. ### Request Example ```json { "username": "admin", "password": "your-password" } ``` ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the login was successful. - **redirectTo** (string) - The URL to redirect to after successful login. #### Response Example ```json { "ok": true, "redirectTo": "/" } ``` **Set-Cookie**: `clawless-auth=; Path=/; HttpOnly; Secure; SameSite=Lax` ``` -------------------------------- ### Session Management API Source: https://context7.com/niapya/clawless/llms.txt Endpoints for managing user sessions, including listing, retrieving messages, and deleting sessions. ```APIDOC ## GET /api/sessions ### Description Retrieves a list of sessions or the message history for a specific session. Supports pagination and channel filtering. ### Method GET ### Endpoint /api/sessions ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of sessions or messages to return. - **channel** (string) - Optional - Filters sessions by channel (e.g., "web"). - **id** (string) - Optional - Retrieves messages for a specific session ID. - **before** (string) - Optional - Retrieves messages before a specific timestamp (ISO 8601 format), used for pagination. #### Request Headers - **Cookie** (string) - Required - Authentication cookie (`clawless-auth=`). ### Response (List Sessions) #### Success Response (200) - **sessions** (array) - An array of session objects. - **id** (string) - The unique ID of the session. - **title** (string) - The title or summary of the session. - **channel** (string) - The communication channel. - **status** (string) - The current status of the session (e.g., "active"). - **totalTokens** (integer) - The total tokens used in the session. - **createdAt** (string) - The timestamp when the session was created. #### Response Example (List Sessions) ```json { "sessions": [ { "id": "session-123", "title": "Python 脚本编写", "channel": "web", "status": "active", "totalTokens": 2500, "createdAt": "2024-01-01T00:00:00Z" } ] } ``` ### Response (Get Session Messages) #### Success Response (200) - **sessionId** (string) - The ID of the session. - **messages** (array) - An array of message objects. - **hasMore** (boolean) - Indicates if there are more messages available. - **nextBefore** (string) - The timestamp to use for fetching the next page of messages. #### Response Example (Get Session Messages) ```json { "sessionId": "session-123", "messages": [...], "hasMore": true, "nextBefore": "2024-01-01T10:00:00Z" } ``` ``` ```APIDOC ## DELETE /api/sessions/{sessionId} ### Description Deletes a specific session, along with any associated workflows and sandbox processes. ### Method DELETE ### Endpoint /api/sessions/{sessionId} ### Parameters #### Path Parameters - **sessionId** (string) - Required - The ID of the session to delete. #### Request Headers - **Cookie** (string) - Required - Authentication cookie (`clawless-auth=`). ### Response #### Success Response (200) - **success** (boolean) - Indicates if the deletion was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Update Long-Term Memory Source: https://context7.com/niapya/clawless/llms.txt Update memory content and trigger re-embedding. ```bash curl -X PATCH "https://your-clawless.vercel.app/api/memory/long-term/{memoryId}" \ -H "Content-Type: application/json" \ -d '{ "content": "用户偏好使用 TypeScript 和 React 进行前端开发" }' ``` ```json { "memory": {...}, "indexing": {...} } ``` -------------------------------- ### DELETE /api/skills/{skillName} Source: https://context7.com/niapya/clawless/llms.txt Deletes a specific skill from the system. ```APIDOC ## DELETE /api/skills/{skillName} ### Description Deletes a specific skill by its name. ### Method DELETE ### Endpoint https://your-clawless.vercel.app/api/skills/{skillName} ### Parameters #### Path Parameters - **skillName** (string) - Required - The name of the skill to delete ### Response #### Success Response (200) - **success** (boolean) - Status of the operation - **name** (string) - Name of the deleted skill #### Response Example { "success": true, "name": "my-skill" } ``` -------------------------------- ### PATCH /api/memory/long-term/{memoryId} Source: https://context7.com/niapya/clawless/llms.txt Updates an existing memory entry. ```APIDOC ## PATCH /api/memory/long-term/{memoryId} ### Description Updates the content of a specific memory entry. ### Method PATCH ### Endpoint https://your-clawless.vercel.app/api/memory/long-term/{memoryId} ### Path Parameters - **memoryId** (string) - Required - ID of the memory to update ``` -------------------------------- ### Delete Session Source: https://context7.com/niapya/clawless/llms.txt Removes a session and terminates its associated workflow and sandbox. ```bash # 删除会话 curl -X DELETE "https://your-clawless.vercel.app/api/sessions/{sessionId}" \ -H "Cookie: clawless-auth=" # 响应 { "success": true } ``` -------------------------------- ### AI Chat API Source: https://context7.com/niapya/clawless/llms.txt Endpoints for interacting with the AI chat functionality, including sending messages, managing workflow status, and streaming responses. ```APIDOC ## POST /api/ai ### Description Main chat endpoint to send new messages, regenerate messages, or route messages. Returns a streaming response in UI Message Stream format. ### Method POST ### Endpoint /api/ai ### Parameters #### Request Body - **id** (string) - Required - The session ID. - **trigger** (string) - Required - The trigger for the action (e.g., "submit-message", "regenerate-message"). - **messageId** (string) - Required - The ID of the message to interact with. - **input** (object) - Required for "submit-message" trigger - Contains the user's input. - **text** (string) - Required - The text content of the message. - **parts** (array) - Required - An array of message parts. - **type** (string) - Required - The type of the part (e.g., "text"). - **text** (string) - Required - The text content of the part. ### Request Example ```json { "id": "session-uuid-here", "trigger": "submit-message", "messageId": "msg-uuid-here", "input": { "text": "你好,请帮我写一个 Python 脚本", "parts": [ { "type": "text", "text": "你好,请帮我写一个 Python 脚本" } ] } } ``` ### Response #### Success Response (200) Returns a Server-Sent Events (SSE) stream. **Headers**: `x-session-id`, `x-workflow-run-id` ``` ```APIDOC ## GET /api/ai/{runId}/status ### Description Retrieves the status information for a current workflow run, including session details, run status, and token usage. ### Method GET ### Endpoint /api/ai/{runId}/status ### Parameters #### Path Parameters - **runId** (string) - Required - The ID of the workflow run. #### Request Headers - **Cookie** (string) - Required - Authentication cookie (`clawless-auth=`). ### Response #### Success Response (200) - **runId** (string) - The ID of the workflow run. - **sessionId** (string) - The ID of the session. - **status** (string) - The current status of the run (e.g., "running"). - **workflow** (object) - Workflow-specific details. - **phase** (string) - The current phase of the workflow. - **lastRunId** (string) - The ID of the last workflow run. - **startedAt** (string) - The timestamp when the workflow started. - **session** (object) - Session-specific details. - **id** (string) - The ID of the session. - **channel** (string) - The communication channel used. - **model** (string) - The AI model being used. - **totalTokens** (integer) - The total number of tokens used. - **source** (object) - Information about the session source. - **type** (string) - The type of the source (e.g., "web"). #### Response Example ```json { "runId": "run-123", "sessionId": "session-456", "status": "running", "workflow": { "phase": "running", "lastRunId": "run-123", "startedAt": "2024-01-01T00:00:00Z" }, "session": { "id": "session-456", "channel": "web", "model": "openai/gpt-4", "totalTokens": 1500, "source": { "type": "web" } } } ``` ``` ```APIDOC ## GET /api/ai/{runId}/stream ### Description Subscribes to the real-time stream of output from an active workflow run. ### Method GET ### Endpoint /api/ai/{runId}/stream ### Parameters #### Path Parameters - **runId** (string) - Required - The ID of the workflow run. #### Request Headers - **Cookie** (string) - Required - Authentication cookie (`clawless-auth=`). - **Accept** (string) - Required - Must be `text/event-stream`. ### Response #### Success Response (200) Returns a Server-Sent Events (SSE) stream. **Example Stream Data**: ``` data: {"type":"text-delta","delta":"Hello"} data: {"type":"text-delta","delta":" World"} ``` ``` ```APIDOC ## POST /api/ai/{runId}/message ### Description Sends a user message, system message, or control command to an active workflow run. ### Method POST ### Endpoint /api/ai/{runId}/message ### Parameters #### Path Parameters - **runId** (string) - Required - The ID of the workflow run. #### Request Body - **type** (string) - Required - The type of message (e.g., "user-message", "control"). - **message** (string) - Required if type is "user-message" - The user's message content. - **uiMessageId** (string) - Required if type is "user-message" - The UI message ID. - **command** (string) - Required if type is "control" - The control command (e.g., "compact", "cancel"). - **reason** (string) - Optional - The reason for the control command. ### Request Example (User Message) ```json { "type": "user-message", "message": "继续执行下一步", "uiMessageId": "msg-789" } ``` ### Request Example (Control Command) ```json { "type": "control", "command": "compact", "reason": "上下文过长" } ``` ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the operation was successful. #### Response Example ```json { "ok": true } ``` ``` ```APIDOC ## POST /api/ai/{runId}/pause ### Description Pauses or cancels a running workflow. ### Method POST ### Endpoint /api/ai/{runId}/pause ### Parameters #### Path Parameters - **runId** (string) - Required - The ID of the workflow run to pause. #### Request Headers - **Cookie** (string) - Required - Authentication cookie (`clawless-auth=`). ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the operation was successful. - **sessionId** (string) - The ID of the session. - **runId** (string) - The ID of the workflow run that was paused. #### Response Example ```json { "ok": true, "sessionId": "session-456", "runId": "run-123" } ``` ``` -------------------------------- ### Pause Workflow Source: https://context7.com/niapya/clawless/llms.txt Stops an active workflow execution and cancels the current process. ```bash # 暂停/取消工作流 curl -X POST "https://your-clawless.vercel.app/api/ai/{runId}/pause" \ -H "Cookie: clawless-auth=" # 响应 { "ok": true, "sessionId": "session-456", "runId": "run-123" } ```