2
0

v3-agent-grants.yaml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-agent-grants.yaml
  2. post:
  3. summary: '签发 agent 写入授权'
  4. tags:
  5. - agent-grants
  6. operationId: post_api_v3_agent_grants
  7. description: |-
  8. 必须用人类的登录 token 调用(模型 token 403);模型必须归当前用户所有,当前用户
  9. 必须能编辑该 channel。授权 7 天有效,只能由指定的模型使用;撤销该模型的 token
  10. (token_version 自增)时一并失效。
  11. 模型写入时用自己的模型 token 登录,并带请求头 `X-Agent-Grant: <token>`;
  12. 写入的记录 editor 为授权人、co_editor 为模型,权限按授权人判断。
  13. 实现:`V3\AgentGrantController@store`
  14. security:
  15. -
  16. bearerAuth: []
  17. requestBody:
  18. required: true
  19. content:
  20. application/json:
  21. schema:
  22. type: object
  23. properties:
  24. ai_model:
  25. type: string
  26. description: '被授权的 AI 模型 uid'
  27. target_type:
  28. type: string
  29. description: 授权范围的类型
  30. enum:
  31. - channel
  32. target_id:
  33. type: string
  34. description: 'channel 的 uid'
  35. book:
  36. type: integer
  37. description: '限定 book,0 或不传表示不限'
  38. default: 0
  39. required:
  40. - ai_model
  41. - target_type
  42. - target_id
  43. responses:
  44. 200:
  45. description: 成功
  46. content:
  47. application/json:
  48. schema:
  49. type: object
  50. properties:
  51. data:
  52. type: object
  53. properties:
  54. token:
  55. type: string
  56. grantor:
  57. type: string
  58. ai_model:
  59. type: string
  60. target_type:
  61. type: string
  62. target_id:
  63. type: string
  64. book:
  65. type: integer
  66. expires_at:
  67. type: string
  68. 201:
  69. description: 签发成功
  70. content:
  71. application/json:
  72. schema:
  73. type: object
  74. properties:
  75. data:
  76. type: object
  77. properties:
  78. token:
  79. type: string
  80. grantor:
  81. type: string
  82. ai_model:
  83. type: string
  84. target_type:
  85. type: string
  86. target_id:
  87. type: string
  88. book:
  89. type: integer
  90. expires_at:
  91. type: string
  92. 401:
  93. $ref: '../../main.yaml#/components/responses/ProblemUnauthorized'
  94. 403:
  95. description: '用模型 token 调用、模型不归当前用户,或当前用户不能编辑该 channel'
  96. content:
  97. application/problem+json:
  98. schema:
  99. $ref: '../../main.yaml#/components/schemas/ProblemDetails'
  100. 422:
  101. $ref: '../../main.yaml#/components/responses/ProblemValidation'