diff --git a/internal/acp/orchestrator.go b/internal/acp/orchestrator.go index e235a6e..d805f81 100644 --- a/internal/acp/orchestrator.go +++ b/internal/acp/orchestrator.go @@ -347,7 +347,7 @@ func openClawChatSendParams( } func openClawArtifactDeliveryRequired(params map[string]any) bool { - text := strings.ToLower(firstNonEmptyString(params, "taskPrompt", "prompt", "message")) + text := strings.ToLower(strings.Join(openClawArtifactDeliveryText(params), "\n")) if strings.TrimSpace(text) == "" { return false } @@ -383,6 +383,38 @@ func openClawArtifactDeliveryRequired(params map[string]any) bool { return false } +func openClawArtifactDeliveryText(raw any) []string { + switch value := raw.(type) { + case string: + if text := strings.TrimSpace(value); text != "" { + return []string{text} + } + case map[string]any: + texts := make([]string, 0, len(value)) + for key, item := range value { + switch strings.TrimSpace(key) { + case "taskPrompt", "prompt", "message": + texts = append(texts, openClawArtifactDeliveryText(item)...) + default: + if _, ok := item.(map[string]any); ok { + texts = append(texts, openClawArtifactDeliveryText(item)...) + } + if _, ok := item.([]any); ok { + texts = append(texts, openClawArtifactDeliveryText(item)...) + } + } + } + return texts + case []any: + texts := make([]string, 0, len(value)) + for _, item := range value { + texts = append(texts, openClawArtifactDeliveryText(item)...) + } + return texts + } + return nil +} + func withOpenClawArtifactDeliveryInstructions( message string, preparedArtifact *openClawPreparedArtifactScope, diff --git a/internal/acp/routing_test.go b/internal/acp/routing_test.go index 84e718a..eb6afd8 100644 --- a/internal/acp/routing_test.go +++ b/internal/acp/routing_test.go @@ -1079,6 +1079,19 @@ func TestOpenClawChatSendParamsAddsArtifactDeliveryInstructions(t *testing.T) { } } +func TestOpenClawArtifactDeliveryRequiredScansNestedParams(t *testing.T) { + params := map[string]any{ + "request": map[string]any{ + "params": map[string]any{ + "taskPrompt": "请在当前任务制品目录中真实生成一个文件", + }, + }, + } + if !openClawArtifactDeliveryRequired(params) { + t.Fatal("expected nested artifact delivery prompt to be detected") + } +} + func TestExecuteSessionTaskGatewayCollectsOpenClawEventArtifacts(t *testing.T) { gateway := newAcpFakeOpenClawGateway(t) gateway.artifactMode = "unknown"