feat: add configurable Bailian AI cell call runtime

This commit is contained in:
2026-09-14 23:10:39 +08:00
parent 9bade94ada
commit 5dd69b8779
36 changed files with 6455 additions and 30 deletions
+145
View File
@@ -0,0 +1,145 @@
openapi: 3.1.0
info:
title: agent-call immutable AI configuration API
version: 1.0.0
description: >-
Internal configuration publication/read surface. The call.execute business
command remains RabbitMQ-only; secrets, URLs, and provider credentials are
resolved by the execution environment and never enter MQ messages.
servers:
- url: /
paths:
/internal/v1/ai/agent-versions:
post:
operationId: publishAgentVersion
security:
- aiConfigPublish: []
parameters:
- $ref: '#/components/parameters/TenantId'
- $ref: '#/components/parameters/RequestId'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AgentVersionPublishRequest'
responses:
'200':
description: Identical immutable content already exists
content:
application/json:
schema:
$ref: '#/components/schemas/AgentVersionReceipt'
'201':
description: Immutable version published
content:
application/json:
schema:
$ref: '#/components/schemas/AgentVersionReceipt'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'409':
description: Existing version has different content
/internal/v1/ai/agent-versions/{agent_version_id}:
get:
operationId: getAgentVersion
security:
- aiConfigRead: []
parameters:
- $ref: '#/components/parameters/TenantId'
- $ref: '#/components/parameters/RequestId'
- name: agent_version_id
in: path
required: true
schema:
type: string
pattern: '^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$'
responses:
'200':
description: Trusted immutable snapshot
content:
application/json:
schema:
$ref: '#/components/schemas/AgentVersion'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
description: Agent version not found
components:
parameters:
TenantId:
name: X-Tenant-Id
in: header
required: true
schema: {type: string, minLength: 1}
RequestId:
name: X-Request-Id
in: header
required: true
schema: {type: string, minLength: 1, maxLength: 128}
securitySchemes:
aiConfigPublish:
type: http
scheme: bearer
bearerFormat: JWT
description: >-
Requires scope ai.config.publish and the AI-config issuer/audience.
aiConfigRead:
type: http
scheme: bearer
bearerFormat: JWT
description: >-
Requires scope ai.config.read and the AI-config issuer/audience.
schemas:
AgentVersionPublishRequest:
type: object
additionalProperties: false
required: [agent_version_id, config]
properties:
agent_version_id:
type: string
pattern: '^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$'
config:
$ref: 'ai-config.schema.json'
AgentVersionReceipt:
type: object
required: [tenant_id, agent_version_id, status, immutable, content_sha256]
properties:
tenant_id: {type: string}
agent_version_id: {type: string}
status: {enum: [published, reused]}
immutable: {const: true}
content_sha256: {type: string, pattern: '^[a-f0-9]{64}$'}
AgentVersion:
allOf:
- $ref: '#/components/schemas/AgentVersionReceipt'
- type: object
required: [config]
properties:
config:
$ref: 'ai-config.schema.json'
created_at: {type: string, format: date-time}
published_at: {type: string, format: date-time}
created_by: {type: string}
Error:
type: object
required: [error]
properties:
error: {type: string}
message: {type: string}
responses:
BadRequest:
description: Invalid configuration
content:
application/json:
schema: {$ref: '#/components/schemas/Error'}
Unauthorized:
description: Missing or invalid AI-config token
Forbidden:
description: Token lacks the AI-config permission
+101
View File
@@ -0,0 +1,101 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://agent-call.local/contracts/ai-config.schema.json",
"title": "Immutable AI agent version",
"type": "object",
"additionalProperties": false,
"required": ["agent_version_id", "immutable", "llm", "prompt", "tts", "asr", "conversation"],
"properties": {
"agent_version_id": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"},
"immutable": {"const": true},
"llm": {
"type": "object",
"additionalProperties": false,
"required": ["provider_ref", "model"],
"properties": {
"provider_ref": {"type": "string", "minLength": 1, "maxLength": 128},
"credential_ref": {"type": "string", "minLength": 1, "maxLength": 128},
"model": {"type": "string", "minLength": 1, "maxLength": 128},
"temperature": {"type": "number", "minimum": 0, "maximum": 2},
"max_tokens": {"type": "integer", "minimum": 1},
"timeout_ms": {"type": "integer", "minimum": 1}
}
},
"prompt": {
"type": "object",
"additionalProperties": false,
"required": ["text", "allowed_variables"],
"properties": {
"text": {"type": "string", "minLength": 1, "maxLength": 32768},
"allowed_variables": {
"type": "array",
"maxItems": 32,
"items": {"type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"}
},
"max_bytes": {"type": "integer", "minimum": 1, "maximum": 32768}
}
},
"tts": {
"type": "object",
"additionalProperties": false,
"required": ["provider_ref", "model", "voice", "format"],
"properties": {
"provider_ref": {"type": "string", "minLength": 1, "maxLength": 128},
"credential_ref": {"type": "string", "minLength": 1, "maxLength": 128},
"model": {"type": "string", "minLength": 1, "maxLength": 128},
"voice": {"type": "string", "minLength": 1, "maxLength": 128},
"speed": {"type": "number", "minimum": 0.25, "maximum": 3},
"timeout_ms": {"type": "integer", "minimum": 1},
"format": {
"type": "object",
"additionalProperties": false,
"required": ["encoding", "sample_rate_hz", "channels"],
"properties": {
"encoding": {"enum": ["pcm_s16le", "pcma"]},
"sample_rate_hz": {"type": "integer", "minimum": 8000, "maximum": 48000},
"channels": {"const": 1}
}
}
}
},
"asr": {
"type": "object",
"additionalProperties": false,
"required": ["provider_ref", "language", "input"],
"properties": {
"provider_ref": {"type": "string", "minLength": 1, "maxLength": 128},
"credential_ref": {"type": "string", "minLength": 1, "maxLength": 128},
"model": {"type": "string", "minLength": 1, "maxLength": 128},
"language": {"type": "string", "minLength": 1, "maxLength": 32},
"interim": {"type": "boolean"},
"timeout_ms": {"type": "integer", "minimum": 1},
"input": {
"type": "object",
"additionalProperties": false,
"required": ["encoding", "sample_rate_hz", "channels", "sample_width_bytes"],
"properties": {
"encoding": {"const": "pcm_s16le"},
"sample_rate_hz": {"type": "integer", "minimum": 8000, "maximum": 48000},
"channels": {"const": 1},
"sample_width_bytes": {"const": 2}
}
}
}
},
"conversation": {
"type": "object",
"additionalProperties": false,
"required": ["opening", "allow_interrupt", "silence_timeout_ms", "max_duration_ms", "max_turns", "sentence_max_chars", "max_pending_audio_chunks"],
"properties": {
"opening": {"type": "string", "maxLength": 32768},
"allow_interrupt": {"type": "boolean"},
"silence_timeout_ms": {"type": "integer", "minimum": 1},
"max_duration_ms": {"type": "integer", "minimum": 1, "maximum": 3600000},
"max_turns": {"type": "integer", "minimum": 1, "maximum": 1000},
"sentence_max_chars": {"type": "integer", "minimum": 1},
"max_pending_audio_chunks": {"type": "integer", "minimum": 1}
}
},
"metadata": {"type": "object", "additionalProperties": true}
}
}
@@ -0,0 +1,49 @@
{
"agent_version_id": "agent_v1",
"immutable": true,
"llm": {
"provider_ref": "mock",
"model": "mock-chat-v1",
"temperature": 0.2,
"max_tokens": 256,
"timeout_ms": 5000
},
"prompt": {
"text": "You are a concise telephone assistant. Answer the caller's last statement.",
"allowed_variables": [],
"max_bytes": 32768
},
"tts": {
"provider_ref": "mock",
"model": "mock-tts-v1",
"voice": "mock-neutral",
"speed": 1.0,
"format": {
"encoding": "pcm_s16le",
"sample_rate_hz": 16000,
"channels": 1
},
"timeout_ms": 5000
},
"asr": {
"provider_ref": "mock",
"language": "zh-CN",
"input": {
"encoding": "pcm_s16le",
"sample_rate_hz": 16000,
"channels": 1,
"sample_width_bytes": 2
},
"interim": true,
"timeout_ms": 5000
},
"conversation": {
"opening": "",
"allow_interrupt": true,
"silence_timeout_ms": 3000,
"max_duration_ms": 120000,
"max_turns": 20,
"sentence_max_chars": 80,
"max_pending_audio_chunks": 32
}
}