@combycode/llm-sdk 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,6 +15,7 @@
15
15
  * LLMClient.complete. Either way the helper destroys its created client
16
16
  * before returning so callers don't leak. */
17
17
  import type { AgentTool } from '../agent/types';
18
+ import type { CacheConfig } from '../llm/types/request';
18
19
  import type { LLMClientConfig } from '../llm/client-config';
19
20
  import type { AudioOptions } from '../llm/types/audio';
20
21
  import type { ContentPart, Message } from '../llm/types/messages';
@@ -51,6 +52,12 @@ export interface CompleteOptions {
51
52
  /** Generation control. */
52
53
  maxTokens?: number;
53
54
  temperature?: number;
55
+ /** Top-k sampling. Emitted only where the wire accepts it (Anthropic, Google, xAI,
56
+ * OpenRouter) and dropped for OpenAI, which defines no top-k. */
57
+ topK?: number;
58
+ /** Best-effort deterministic sampling. Dropped on Anthropic, which has no seed.
59
+ * Determinism is never guaranteed. */
60
+ seed?: number;
54
61
  structured?: {
55
62
  schema: Record<string, unknown>;
56
63
  name?: string;
@@ -63,6 +70,13 @@ export interface CompleteOptions {
63
70
  /** Service tier for this call. Also settable as a `model:tier` suffix (e.g.
64
71
  * `anthropic/claude-opus-4.8:priority`); an explicit value here wins. */
65
72
  serviceTier?: ServiceTier;
73
+ /** Provider prompt caching: `'auto'`, `'off'`, or which segments to mark
74
+ * (`{ system: true, tools: true }`).
75
+ *
76
+ * It matters most exactly where this helper is convenient — a long system
77
+ * prompt or a large tool block, both of which sit at the front of the request
78
+ * and are the cheapest part to cache. */
79
+ cache?: CacheConfig;
66
80
  /** Optional engine to use. Falls back to coreRegistry default. */
67
81
  engine?: EngineHandle;
68
82
  /** Provider-specific request options (e.g. `{ openrouter: { models: [...] } }`). */
@@ -83,6 +97,11 @@ export interface CompleteResult<T = unknown> {
83
97
  * otherwise `undefined`. The generic on `complete<T>(...)` types this. */
84
98
  parsed?: T;
85
99
  response: CompletionResponse;
100
+ /** In-band provider failure. Some providers report a failed generation IN the
101
+ * response rather than by throwing (OpenAI Responses `status: 'failed'`, Google
102
+ * Interactions likewise), so a caller that only catches sees empty text and no
103
+ * exception — a failure indistinguishable from a successful empty answer. */
104
+ error?: CompletionResponse['error'];
86
105
  /** Fetch a hosted-tool output file (from `response.files`): bytes (`Blob`) +
87
106
  * `name` / `mimeType` / `size` — bound to the SAME model + key this call used. */
88
107
  retrieveFile(file: FileOutput): Promise<RetrievedFile>;