feat(sdk): typed errors, enums, and KB model config for the CLI

Adds the client-library surface the agent-first CLI builds on:
- named server error-code constants + typed *APIError from non-2xx responses,
- MessageSearchMode / AgentMode / KBSelectionMode and model type/source
  enumerators so the CLI validates flags against the server vocabulary,
- SetKBModelConfig for binding embedding/chat models to a knowledge base.
This commit is contained in:
nullkey
2026-06-26 20:40:59 +08:00
committed by lyingbug
parent eba9fe7e78
commit 8f36ea2229
9 changed files with 203 additions and 8 deletions
+1 -1
View File
@@ -441,7 +441,7 @@ func (c *Client) OpenKnowledgeFile(ctx context.Context, knowledgeID string) (str
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
body, _ := io.ReadAll(resp.Body)
_ = resp.Body.Close()
return "", nil, fmt.Errorf("HTTP error %d: %s", resp.StatusCode, string(body))
return "", nil, newAPIError(resp.StatusCode, body)
}
filename := filenameFromContentDisposition(resp.Header.Get("Content-Disposition"))
return filename, resp.Body, nil