feat: align AI configuration and task trunk concurrency with shared schema
This commit is contained in:
@@ -32,6 +32,30 @@ func testDataDir(t *testing.T) string {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if target == "providers.json" {
|
||||
var body map[string]any
|
||||
if err := json.Unmarshal(original, &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body["providers"] = append(body["providers"].([]any), map[string]any{"provider_id": "test-bailian", "provider_code": "ali_bailian", "name": "Example only", "api_endpoint": "https://example.invalid", "ws_endpoint": "wss://example.invalid", "api_key": "example-only-not-a-real-secret"})
|
||||
original, err = json.Marshal(body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if target == "tasks/task-full.json" {
|
||||
var body map[string]any
|
||||
if err := json.Unmarshal(original, &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a := body["agent"].(map[string]any)
|
||||
a["llm"].(map[string]any)["provider_ref"] = "ali_bailian"
|
||||
a["tts"].(map[string]any)["provider_ref"] = "ali_bailian"
|
||||
original, err = json.Marshal(body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(root, target), original, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func buildExecute(data dataset, eventID, taskID, callee string, now time.Time) (
|
||||
}
|
||||
var task configread.Task
|
||||
// The one-shot host capture arm is bound to one exact trunk before the MQ event is sent.
|
||||
if err := json.Unmarshal(body, &task); err != nil || task.DispatcherID != data.dispatcherID || task.TenantID != data.tenantID || task.TaskID != taskID || task.Status != "running" || len(task.AllowedTrunkIDs) != 1 {
|
||||
if err := json.Unmarshal(body, &task); err != nil || task.DispatcherID != data.dispatcherID || task.TenantID != data.tenantID || task.TaskID != taskID || task.Status != "running" || len(task.AllowedTrunks) != 1 || task.AllowedTrunks[0].Concurrency == 0 {
|
||||
return "", nil, errors.New("one-shot command requires a running task pinned to exactly one approved trunk")
|
||||
}
|
||||
command, err := json.Marshal(struct {
|
||||
|
||||
@@ -209,7 +209,7 @@ func publishAndAwait(ctx context.Context, brokerURL string, data dataset, eventI
|
||||
return oneShotResult{}, err
|
||||
}
|
||||
var task configread.Task
|
||||
if err := json.Unmarshal(data.tasks[taskID], &task); err != nil || len(task.AllowedTrunkIDs) != 1 {
|
||||
if err := json.Unmarshal(data.tasks[taskID], &task); err != nil || len(task.AllowedTrunks) != 1 {
|
||||
return oneShotResult{}, errors.New("one-shot result requires a single approved trunk")
|
||||
}
|
||||
consumer, err := openResultConsumer(brokerURL)
|
||||
@@ -222,5 +222,5 @@ func publishAndAwait(ctx context.Context, brokerURL string, data dataset, eventI
|
||||
if err := publishExecuteAt(publishCtx, brokerURL, data, eventID, taskID, callee, at); err != nil {
|
||||
return oneShotResult{}, err
|
||||
}
|
||||
return consumer.wait(ctx, resultPath, data.dispatcherID, data.tenantID, eventID, taskID, callee, task.AllowedTrunkIDs[0])
|
||||
return consumer.wait(ctx, resultPath, data.dispatcherID, data.tenantID, eventID, taskID, callee, task.AllowedTrunks[0].TrunkID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user