公司管理 API

公司管理是 AIDC Control Plane 的第一组核心 API:先创建 Company,再创建部门、Agent Cell、服务器 Runtime、数据源、权限与审计链。所有后续资源都必须挂在 Company 下面,不能脱离公司边界单独存在。

// 核心判断

AIDC 的 Company 不是普通 CRM 客户记录,而是一个可运行、可隔离、可审计的企业部署单元。创建 Company 时,系统不是只写入一条数据库记录,而是启动一条部署链:身份与隔离边界、部署形态、Runtime、部门目录、权限基线、Action Log 与 smoke check。

资源关系

Company
├── Departments
│   ├── Root Directory
│   ├── Human Owner
│   ├── Permission Baseline
│   └── Department Agents
├── Runtime / Servers
│   ├── Provider: aidc-hosted | customer-cloud | on-prem
│   ├── Region
│   ├── Health
│   └── Power Actions: start | stop | restart
├── Data Sources
│   ├── Drive / Folder / OA / ERP / MES
│   ├── Sync Jobs
│   └── Ingestion Status
├── Agents
│   ├── Role
│   ├── Model Policy
│   ├── Tool Policy
│   └── Memory Policy
└── Action Log
    ├── Provisioning
    ├── Permission Change
    ├── Runtime Operation
    └── Audit Trail

API 命名原则

开发文档统一使用 companies 作为标准资源名。当前代码中已有一部分历史控制台接口使用 customers / cell,后续保留兼容,但新 API 与 CLI 语义应向 company 收敛。

名称用途状态
company新开发文档与未来公开 API 的标准资源名推荐
customer早期 dashboard / console 命名兼容保留
cellruntime 隔离单元 ID,可作为 company 的技术标识内部字段

1. 创建 Company

1.1 操作目标

创建一个新的 Company,并完成公司级 Control Plane 初始化。这一步对应 Console 里的「创建公司 · 置备隔离 Agent Cell」。

CreateCompany
→ ValidateCompanyKey
→ CreateCompanyProfile
→ SelectDeploymentForm
→ ProvisionRuntimeCell
→ BootstrapDirectories
→ BootstrapDepartments
→ WriteActionLog
→ RunSmokeCheck

1.2 细分操作

操作API 草案CLI 草案说明
创建公司基本档案POST /api/v1/control-plane/companiesaidc company create写入 company metadata,不含客户业务数据
检查 company key 是否可用GET /api/v1/control-plane/companies/{key}/availabilityaidc company check-key防止重复 key、非法字符、保留字
选择部署形态POST /companies/{key}/deployment-planaidc company set-deployment托管 / 客户云内 / 本地
开服务器 / 绑定 RuntimePOST /companies/{key}/serversaidc server create创建或登记运行节点
启动服务器POST /companies/{key}/servers/{serverId}/startaidc server start高风险操作,通常需要审批
查看服务器健康GET /companies/{key}/servers/{serverId}/healthaidc server healthsmoke test 和运维使用
初始化内置文件POST /companies/{key}/bootstrap/filesystemaidc company bootstrap-files同步 AGENT.md、权限矩阵、SOP 模板
初始化默认部门POST /companies/{key}/bootstrap/departmentsaidc company bootstrap-departments创建 C-suite 或客户定制部门
完成创建并签发POST /companies/{key}/provisioning/completeaidc company complete写 Action Log,进入 active / pending_review

1.3 HTTP Reference:创建 Company

POST /api/v1/control-plane/companies
Content-Type: application/json
Idempotency-Key: <uuid>

Request Body

{
  "nameZh": "<company-display-name-zh>",
  "nameEn": "<company-display-name-en>",
  "companyKey": "<company-key>",
  "industry": "manufacturing",
  "region": "ap-southeast-1",
  "deploymentForm": "aidc_hosted",
  "fdeOwner": "<fde-owner-id>",
  "humanOwner": {
    "name": "<owner-name>",
    "role": "<owner-role>"
  }
}

字段说明

字段类型必填说明
nameZhstring公司中文显示名,不应作为稳定 key 使用
nameEnstring公司英文显示名或标准名
companyKeystringURL / CLI / API 使用的稳定 key,只允许小写字母、数字和短横线
industrystring行业,用于模板推荐和默认部门建议
regionstring默认部署区域,例如 ap-southeast-1
deploymentFormenumaidc_hosted / customer_cloud / on_prem
fdeOwnerstring责任 FDE 或内部 owner ID
humanOwnerobject客户侧或 AIDC 侧的人类 owner

Response

{
  "ok": true,
  "data": {
    "company": {
      "id": "cmp_01...",
      "companyKey": "<company-key>",
      "cellId": "cell-<company-key>-<suffix>",
      "nameZh": "<company-display-name-zh>",
      "nameEn": "<company-display-name-en>",
      "status": "provisioning",
      "deploymentForm": "aidc_hosted",
      "region": "ap-southeast-1",
      "adl": "ADL-1"
    },
    "nextActions": [
      "create_runtime_server",
      "bootstrap_departments",
      "run_smoke_check"
    ]
  },
  "meta": {
    "version": "v1",
    "requestId": "req_...",
    "generatedAt": "<iso-8601-timestamp>"
  }
}

CLI:创建 Company

aidc company create \
  --name "<company-display-name>" \
  --name-zh "<company-display-name-zh>" \
  --key <company-key> \
  --industry manufacturing \
  --region ap-southeast-1 \
  --deployment aidc-hosted \
  --fde-owner <fde-owner-id>

2. 开服务器 / Runtime

创建 Company 后,必须为 Company 绑定 Runtime。Runtime 可以是 AIDC 托管、客户云内或本地私有化。服务器操作属于运维动作,必须通过 service 与 provider adapter,不能在 route 层直接调用云资源。

创建服务器

POST /api/v1/control-plane/companies/{companyKey}/servers
{
  "serverId": "primary",
  "provider": "aws",
  "region": "ap-southeast-1",
  "runtimeKind": "control-plane-worker",
  "instanceType": "t3.medium",
  "networkProfile": "private-cell"
}

服务器操作

操作MethodPath风险审批
列出服务器GET/companies/{key}/serverslow不需要
查看详情GET/companies/{key}/servers/{serverId}low不需要
健康检查GET/companies/{key}/servers/{serverId}/healthlow不需要
启动POST/companies/{key}/servers/{serverId}/starthigh需要/按策略
停止POST/companies/{key}/servers/{serverId}/stophigh需要
重启POST/companies/{key}/servers/{serverId}/restarthigh需要

CLI 草案

aidc server create --company <company-key> --server primary --provider aws --region ap-southeast-1
aidc server health --company <company-key> --server primary
aidc server start --company <company-key> --server primary --reason "initial provisioning"
aidc server restart --company <company-key> --server primary --reason "runtime upgrade"

安全边界

3. 创建 Department

Department 不是普通标签,而是 AIDC 的权限、目录、Agent Cell 和业务责任边界。一个 Department 至少应该包含 name、charter、rootDir、humanOwner、sensitivityBaseline、defaultPermissionPolicy、可选 Agent Cell 与 Action Log entry。

细分操作

操作API 草案CLI 草案说明
创建部门POST /companies/{key}/departmentsaidc department create创建部门 metadata
查看部门GET /companies/{key}/departments/{departmentId}aidc department get查看目录、owner、状态
修改部门PATCH /companies/{key}/departments/{departmentId}aidc department update修改 charter / owner / baseline
设置目录边界PUT /companies/{key}/departments/{departmentId}/root-directoryaidc department set-root绑定文件系统目录
设置 ownerPUT /companies/{key}/departments/{departmentId}/owneraidc department set-owner人类 owner 必填
设置敏感基线PUT /companies/{key}/departments/{departmentId}/sensitivityaidc department set-baselineinternal / confidential / restricted
初始化部门 AgentPOST /companies/{key}/departments/{departmentId}/agent-cellaidc department init-agent可选,创建部门 Agent Cell
禁用 / 归档部门POST /companies/{key}/departments/{departmentId}/archiveaidc department archive不物理删除,保留审计

HTTP Reference:创建 Department

POST /api/v1/control-plane/companies/{companyKey}/departments
Content-Type: application/json
Idempotency-Key: <uuid>

Request Body

{
  "name": "<department-display-name>",
  "departmentKey": "<department-key>",
  "charter": "<department-charter>",
  "rootDir": "/<department-root>/",
  "owner": "<owner-role-or-id>",
  "baseline": "internal",
  "createAgentCell": true
}

CLI:创建 Department

aidc department create \
  --company <company-key> \
  --name "<department-display-name>" \
  --key <department-key> \
  --charter "<department-charter>" \
  --root-dir /<department-root>/ \
  --owner <owner-role-or-id> \
  --baseline internal \
  --init-agent-cell

部门创建后的默认动作

  1. 写入 Department profile;
  2. 创建或绑定 root directory;
  3. 设置默认权限基线;
  4. 如果 createAgentCell=true,创建部门 Agent Cell;
  5. 生成部门级 AGENT.md 或 Agent profile;
  6. 写入 Action Log;
  7. 返回下一步建议。

部门敏感级别

baseline说明默认访问策略
public可公开展示的资料可读,仍需审计
internal默认内部资料公司内授权可读
confidential财务、人事、合同等敏感资料default-deny,需要显式授权
restricted高敏或受监管资料仅 owner / 指定 Agent 可访问

4. 管理 Company

管理 Company 是创建后的持续运营 API:查看状态、修改公司信息、管理部署、管理服务器、管理部门、查看审计、暂停或归档公司。

细分操作

操作API 草案CLI 草案说明
列出公司GET /companiesaidc company listConsole 首页 / admin 使用
查看公司详情GET /companies/{key}aidc company get返回 profile + runtime summary
更新公司信息PATCH /companies/{key}aidc company update名称、行业、owner、FDE
查看部署状态GET /companies/{key}/provisioningaidc company statusprovisioning / active / suspended
查看公司健康GET /companies/{key}/healthaidc company health汇总 server / agent / data source
查看 usageGET /companies/{key}/usageaidc company usagetoken、cost、runtime usage
查看 Action LogGET /companies/{key}/action-logaidc company logs审计链
暂停公司POST /companies/{key}/suspendaidc company suspend高风险,保留数据,暂停 runtime
恢复公司POST /companies/{key}/resumeaidc company resume高风险,恢复 runtime
归档公司POST /companies/{key}/archiveaidc company archive不物理删除,进入只读
删除公司DELETE /companies/{key}不建议默认开放极高风险,需要单独审批和备份

Company 状态机

provisioning
  → pending_review
  → active
  → degraded
  → suspended
  → archived
状态说明允许动作
provisioning正在创建公司和基础资源update / bootstrap / health
pending_review待 FDE 或 owner 复核approve / reject / update
active正常运行all normal operations
degraded部分服务异常health / restart / repair
suspended暂停运行,数据保留resume / export / audit
archived只读归档read / export / audit

查看 Company 详情

GET /api/v1/control-plane/companies/{companyKey}
{
  "ok": true,
  "data": {
    "company": {
      "companyKey": "<company-key>",
      "cellId": "cell-<company-key>-<suffix>",
      "status": "active",
      "adl": "ADL-2",
      "industry": "manufacturing",
      "region": "ap-southeast-1",
      "deploymentForm": "aidc_hosted"
    },
    "summary": {
      "departments": 10,
      "agents": 12,
      "servers": 2,
      "dataSources": 8,
      "pendingApprovals": 1,
      "health": "healthy"
    }
  }
}

暂停 Company

POST /api/v1/control-plane/companies/{companyKey}/suspend
Content-Type: application/json
{
  "reason": "<suspension-reason>",
  "requestedBy": "<requester-id>",
  "keepData": true,
  "stopRuntime": true
}

5. 错误码草案

codeHTTP可重试说明
company_key_invalid400key 不符合命名规则
company_already_exists409companyKey 已存在
company_not_found404公司不存在
department_not_found404部门不存在
server_not_found404serverId 不存在
server_provider_not_configured501provider adapter 未配置
approval_required403高风险动作缺少审批
operation_conflict409可稍后重试已有同类 operation 在执行
runtime_unhealthy503可重试Runtime 不健康,需先修复

6. 幂等策略

所有创建类 API 必须支持 Idempotency-Key。生产 SDK / CLI 默认必须自动生成。

场景行为
同 key、同 body返回第一次创建结果
同 key、不同 body返回 idempotency_conflict
无 key开发环境可允许;生产 SDK / CLI 默认必须生成

7. 审计要求

Company Management 的所有写操作都要写入 Action Log。

操作Action Type风险审批
创建公司CreateCompany / DeployAgentCellhighpending
创建部门CreateDepartmentlownot_required
修改 ownerUpdateCompanyOwnermediumrequired
开服务器StartServerhighrequired
停服务器StopServerhighrequired
修改权限基线UpdatePermissionPolicyhighrequired
暂停公司SuspendCompanyhighrequired
归档公司ArchiveCompanyhighrequired
{
  "actor": "<actor-id>",
  "actorType": "human",
  "actionType": "CreateCompany",
  "targetRef": "company:<company-key>",
  "riskLevel": "high",
  "approvalStatus": "pending",
  "result": "partial",
  "evidence": "cell created; server pending",
  "createdAt": "<iso-8601-timestamp>"
}

8. 当前实现状态

能力当前状态说明
Console 创建公司已有 UI / Server ActioncreateCompanyAction 已能写入 company 与 ActionLog
Console 创建部门已有 UI / Server ActioncreateDepartmentAction 已能写入 department 与 ActionLog
v1 list customers已有 API当前命名是 customers,需要后续收敛到 companies
v1 server list/detail/health已有 API读 metadata,provider seam 已留出
v1 server start/stop/restart路由已搭好provider 未配置时安全返回 not configured
Company canonical API待实现建议新增 /api/v1/control-plane/companies
Department canonical API待实现建议新增 /api/v1/control-plane/companies/{key}/departments
AIDC CLI待设计 / 实现本文先定义命令形态

9. 记住几句