Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

2.2 KB
Raw Blame
// API Key database item type (independent from schema)
export interface ApiKeyItem {
  accessedAt: Date;
  createdAt: Date;
  // Display name of the key's creator (workspace list view); null when unknown.
  creator?: string | null;
  enabled?: boolean | null;
  expiresAt?: Date | null;
  id: string;
  // Whether the current caller created this key. Only own keys carry the
  // decrypted plaintext `key`; other members' rows come back masked.
  isMine?: boolean;
  key: string;
  // A stale encrypted value must not make the whole list fail. When true,
  // callers can still manage or rotate the row but cannot reveal its secret.
  keyDecryptionFailed?: boolean;
  lastUsedAt?: Date | null;
  name: string;
  // Capability scopes. `null`/absent = full access (legacy keys), `['*']` =
  // explicit full access, otherwise a restricted scope list.
  scopes?: string[] | null;
  updatedAt: Date;
  userId: string;
}

export interface CreateApiKeyParams {
  expiresAt?: Date | null;
  name: string;
  scopes?: string[] | null;
}

export interface UpdateApiKeyParams {
  enabled?: boolean;
  expiresAt?: Date | null;
  name?: string;
  scopes?: string[] | null;
}

export type WorkspaceApiKeyMemberCreation = 'admins_only' | 'all_members';

/**
 * Who may connect, re-authorize, sync or remove the workspace's shared
 * connectors. Workspace owners and admins always can; `all_members` (the
 * default) lets every member co-maintain them. Reading or rewriting another
 * member's stored credentials stays with that creator and the workspace owner.
 */
export type WorkspaceConnectorMemberManage = 'admins_only' | 'all_members';

/**
 * Who may see and use a workspace connector (`user_connectors.visibility`),
 * mirroring devices / agents:
 * - `public` — shared with the workspace: every member sees it and every agent
 *   in the workspace may load it.
 * - `private` — the creator's own (私人): only the creator sees it, and only the
 *   creator's private agents load it.
 * Ignored for personal connectors (`workspace_id IS NULL`), which are
 * implicitly private to their owner.
 */
export const CONNECTOR_VISIBILITIES = ['private', 'public'] as const;
export type ConnectorVisibility = (typeof CONNECTOR_VISIBILITIES)[number];