feat(access): add guest chat ACL (#235)

This commit is contained in:
BBQ
2026-03-14 17:15:41 +08:00
committed by GitHub
parent c8728ffc2c
commit 839e63acda
86 changed files with 6886 additions and 2554 deletions
+670 -203
View File
@@ -182,6 +182,312 @@ const docTemplate = `{
}
}
},
"/bots/{bot_id}/access/channel_identities": {
"get": {
"description": "Search locally observed channel identity candidates for bot access control",
"tags": [
"bots"
],
"summary": "Search access channel identities",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Search query",
"name": "q",
"in": "query"
},
{
"type": "integer",
"description": "Max results",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/acl.ChannelIdentityCandidateListResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{bot_id}/access/channel_identities/{channel_identity_id}/conversations": {
"get": {
"description": "List previously observed conversation candidates for a channel identity under a bot",
"tags": [
"bots"
],
"summary": "List observed conversations for a channel identity",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Channel Identity ID",
"name": "channel_identity_id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/acl.ObservedConversationCandidateListResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{bot_id}/access/users": {
"get": {
"description": "Search user candidates for bot access control",
"tags": [
"bots"
],
"summary": "Search access users",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Search query",
"name": "q",
"in": "query"
},
{
"type": "integer",
"description": "Max results",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/acl.UserCandidateListResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{bot_id}/blacklist": {
"get": {
"description": "List guest deny rules for chat trigger",
"tags": [
"bots"
],
"summary": "List bot blacklist",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/acl.ListRulesResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
},
"put": {
"description": "Add a guest deny rule for chat trigger",
"tags": [
"bots"
],
"summary": "Upsert bot blacklist entry",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{
"description": "Blacklist payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/acl.UpsertRuleRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/acl.Rule"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{bot_id}/blacklist/{rule_id}": {
"delete": {
"description": "Delete a guest deny rule by rule ID",
"tags": [
"bots"
],
"summary": "Delete bot blacklist entry",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Rule ID",
"name": "rule_id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{bot_id}/cli/messages": {
"post": {
"description": "Post a user message (with optional attachments) through the local channel pipeline.",
@@ -4610,6 +4916,149 @@ const docTemplate = `{
}
}
},
"/bots/{bot_id}/whitelist": {
"get": {
"description": "List guest allow rules for chat trigger",
"tags": [
"bots"
],
"summary": "List bot whitelist",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/acl.ListRulesResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
},
"put": {
"description": "Add a guest allow rule for chat trigger",
"tags": [
"bots"
],
"summary": "Upsert bot whitelist entry",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{
"description": "Whitelist payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/acl.UpsertRuleRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/acl.Rule"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{bot_id}/whitelist/{rule_id}": {
"delete": {
"description": "Delete a guest allow rule by rule ID",
"tags": [
"bots"
],
"summary": "Delete bot whitelist entry",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Rule ID",
"name": "rule_id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{id}": {
"get": {
"description": "Get a bot by ID (owner/admin only)",
@@ -5189,167 +5638,6 @@ const docTemplate = `{
}
}
},
"/bots/{id}/members": {
"get": {
"description": "List members for a bot",
"tags": [
"bots"
],
"summary": "List bot members",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/bots.ListMembersResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
},
"put": {
"description": "Add or update bot member role",
"tags": [
"bots"
],
"summary": "Upsert bot member",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Member payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/bots.UpsertMemberRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/bots.BotMember"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{id}/members/{user_id}": {
"delete": {
"description": "Remove a member from a bot",
"tags": [
"bots"
],
"summary": "Delete bot member",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "User ID",
"name": "user_id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{id}/owner": {
"put": {
"description": "Transfer bot ownership to another human user",
@@ -8685,6 +8973,227 @@ const docTemplate = `{
}
}
},
"acl.ChannelIdentityCandidate": {
"type": "object",
"properties": {
"avatar_url": {
"type": "string"
},
"channel": {
"type": "string"
},
"channel_subject_id": {
"type": "string"
},
"display_name": {
"type": "string"
},
"id": {
"type": "string"
},
"linked_avatar_url": {
"type": "string"
},
"linked_display_name": {
"type": "string"
},
"linked_username": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"acl.ChannelIdentityCandidateListResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/acl.ChannelIdentityCandidate"
}
}
}
},
"acl.ListRulesResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/acl.Rule"
}
}
}
},
"acl.ObservedConversationCandidate": {
"type": "object",
"properties": {
"channel": {
"type": "string"
},
"conversation_id": {
"type": "string"
},
"conversation_name": {
"type": "string"
},
"conversation_type": {
"type": "string"
},
"last_observed_at": {
"type": "string"
},
"route_id": {
"type": "string"
},
"thread_id": {
"type": "string"
}
}
},
"acl.ObservedConversationCandidateListResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/acl.ObservedConversationCandidate"
}
}
}
},
"acl.Rule": {
"type": "object",
"properties": {
"action": {
"type": "string"
},
"bot_id": {
"type": "string"
},
"channel_identity_avatar_url": {
"type": "string"
},
"channel_identity_display_name": {
"type": "string"
},
"channel_identity_id": {
"type": "string"
},
"channel_subject_id": {
"type": "string"
},
"channel_type": {
"type": "string"
},
"created_at": {
"type": "string"
},
"effect": {
"type": "string"
},
"id": {
"type": "string"
},
"linked_user_avatar_url": {
"type": "string"
},
"linked_user_display_name": {
"type": "string"
},
"linked_user_id": {
"type": "string"
},
"linked_user_username": {
"type": "string"
},
"source_scope": {
"$ref": "#/definitions/acl.SourceScope"
},
"subject_kind": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"user_avatar_url": {
"type": "string"
},
"user_display_name": {
"type": "string"
},
"user_id": {
"type": "string"
},
"user_username": {
"type": "string"
}
}
},
"acl.SourceScope": {
"type": "object",
"properties": {
"channel": {
"type": "string"
},
"conversation_id": {
"type": "string"
},
"conversation_type": {
"type": "string"
},
"thread_id": {
"type": "string"
}
}
},
"acl.UpsertRuleRequest": {
"type": "object",
"properties": {
"channel_identity_id": {
"type": "string"
},
"source_scope": {
"$ref": "#/definitions/acl.SourceScope"
},
"user_id": {
"type": "string"
}
}
},
"acl.UserCandidate": {
"type": "object",
"properties": {
"avatar_url": {
"type": "string"
},
"display_name": {
"type": "string"
},
"email": {
"type": "string"
},
"id": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"acl.UserCandidateListResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/acl.UserCandidate"
}
}
}
},
"adapters.CDFPoint": {
"type": "object",
"properties": {
@@ -9049,9 +9558,6 @@ const docTemplate = `{
"bots.Bot": {
"type": "object",
"properties": {
"allow_guest": {
"type": "boolean"
},
"avatar_url": {
"type": "string"
},
@@ -9121,23 +9627,6 @@ const docTemplate = `{
}
}
},
"bots.BotMember": {
"type": "object",
"properties": {
"bot_id": {
"type": "string"
},
"created_at": {
"type": "string"
},
"role": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"bots.CreateBotRequest": {
"type": "object",
"properties": {
@@ -9181,17 +9670,6 @@ const docTemplate = `{
}
}
},
"bots.ListMembersResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/bots.BotMember"
}
}
}
},
"bots.TransferBotRequest": {
"type": "object",
"properties": {
@@ -9218,17 +9696,6 @@ const docTemplate = `{
}
}
},
"bots.UpsertMemberRequest": {
"type": "object",
"properties": {
"role": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"browsercontexts.BrowserContext": {
"type": "object",
"properties": {