@combycode/llm-sdk 1.7.0 → 2.0.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +430 -1
  2. package/MIGRATION.md +93 -0
  3. package/README.md +17 -2
  4. package/dist/agent/loop-config.d.ts +22 -0
  5. package/dist/agent/loop-step-state.d.ts +2 -0
  6. package/dist/agent/loop.d.ts +7 -0
  7. package/dist/agent/reflect-retry.d.ts +56 -0
  8. package/dist/agent/tool-key.d.ts +3 -0
  9. package/dist/helpers/mcp.d.ts +24 -2
  10. package/dist/helpers/provenance-types.d.ts +63 -0
  11. package/dist/helpers/provenance.d.ts +12 -0
  12. package/dist/helpers/transcribe.d.ts +35 -6
  13. package/dist/index.browser.js +2996 -707
  14. package/dist/index.d.ts +19 -7
  15. package/dist/index.js +2996 -707
  16. package/dist/llm/providers/anthropic/constants.d.ts +2 -0
  17. package/dist/llm/providers/openai/completions.d.ts +9 -0
  18. package/dist/llm/providers/openai/provenance.d.ts +26 -0
  19. package/dist/llm/providers/openai/responses.d.ts +4 -2
  20. package/dist/llm/providers/openai/transcription.d.ts +39 -2
  21. package/dist/llm/types/audio.d.ts +31 -0
  22. package/dist/llm/types/messages.d.ts +89 -1
  23. package/dist/llm/types/options.d.ts +15 -0
  24. package/dist/llm/types/request.d.ts +13 -1
  25. package/dist/llm/types/response.d.ts +31 -1
  26. package/dist/llm/types/stream.d.ts +14 -1
  27. package/dist/llm/types/tiers.d.ts +6 -6
  28. package/dist/network/queue-state-config.d.ts +5 -0
  29. package/dist/network/queue-state.d.ts +7 -0
  30. package/dist/network/types.d.ts +23 -0
  31. package/dist/plugins/context-guard/strategies/anchored.d.ts +47 -0
  32. package/dist/plugins/context-measurer/counter/hybrid.d.ts +4 -1
  33. package/dist/plugins/context-measurer/counter/tiktoken.d.ts +8 -1
  34. package/dist/plugins/mcp/base-transport.d.ts +16 -0
  35. package/dist/plugins/mcp/client.d.ts +144 -7
  36. package/dist/plugins/mcp/input-required.d.ts +35 -0
  37. package/dist/plugins/mcp/jsonrpc.d.ts +7 -0
  38. package/dist/plugins/mcp/oauth.d.ts +21 -1
  39. package/dist/plugins/mcp/protocol-version.d.ts +61 -0
  40. package/dist/plugins/mcp/result-cache.d.ts +31 -0
  41. package/dist/plugins/mcp/subscriptions.d.ts +69 -0
  42. package/dist/plugins/mcp/transport-http.d.ts +31 -0
  43. package/dist/plugins/mcp/transport-stdio.d.ts +2 -0
  44. package/dist/plugins/mcp/transport-ws.d.ts +11 -1
  45. package/dist/plugins/mcp/transport.d.ts +11 -0
  46. package/dist/plugins/mcp/types.d.ts +54 -2
  47. package/dist/plugins/telemetry/telemetry.d.ts +12 -0
  48. package/dist/util/http.d.ts +8 -0
  49. package/package.json +9 -6
@@ -69,6 +69,17 @@ export interface TelemetryAdapterOptions {
69
69
  maxEvents?: number;
70
70
  /** Service identity stamped on all exported telemetry. */
71
71
  resource?: TelemetryResource;
72
+ /** Whether provider error TEXT may be stored in telemetry. Default `true`
73
+ * (unchanged behaviour, and the same default as the OpenAI Agents SDK's
74
+ * `trace_include_sensitive_data`).
75
+ *
76
+ * A provider's `error.message` / `error.raw` can echo request content back —
77
+ * a moderation refusal quotes the prompt, a validation error names the offending
78
+ * field and value. URLs and headers are always redacted regardless; this switch
79
+ * governs the free-text payload. Set `false` when telemetry leaves your trust
80
+ * boundary (a shared collector, a vendor APM) and the message is replaced by a
81
+ * fixed `[redacted]` string while name/code/status are kept for triage. */
82
+ includeSensitiveData?: boolean;
72
83
  }
73
84
  export declare class TelemetryAdapter {
74
85
  readonly events: TelemetryEvent[];
@@ -80,6 +91,7 @@ export declare class TelemetryAdapter {
80
91
  private latSum;
81
92
  private readonly open;
82
93
  private readonly maxEvents;
94
+ private readonly includeSensitiveData;
83
95
  private readonly unsub;
84
96
  constructor(hooks: HookBus, opts?: TelemetryAdapterOptions);
85
97
  /** Stop tapping the bus. */
@@ -1,6 +1,14 @@
1
1
  /** Small HTTP header helpers shared across network + server layers. */
2
2
  /** Lowercase-keyed plain record from a WHATWG `Headers`. */
3
3
  export declare function headersToRecord(headers: Headers): Record<string, string>;
4
+ /** Case-insensitive header lookup. HTTP header names are case-insensitive
5
+ * (RFC 9110 §5.1) but a plain record is not, and the casing a server or fetch
6
+ * implementation actually sends varies — so read response headers through here
7
+ * instead of guessing casings at the call site. */
8
+ export declare function header(headers: Record<string, string>, name: string): string | undefined;
9
+ /** True when a request body cannot be replayed for a retry (the first attempt
10
+ * consumes it). FormData, strings and byte views are replayable; a stream is not. */
11
+ export declare function isStreamBody(body: unknown): boolean;
4
12
  /** Parse an integer header value, or null if absent / not a number. */
5
13
  export declare function parseIntHeader(headers: Record<string, string>, key: string): number | null;
6
14
  /** Combine multiple AbortSignals into one that aborts when any of them does. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combycode/llm-sdk",
3
- "version": "1.7.0",
3
+ "version": "2.0.0",
4
4
  "description": "Unified, pluggable AI SDK for accessing the LLMs of every major provider (Anthropic, OpenAI, Google, xAI, OpenRouter) through one API. Cross-environment: Node, Bun, and the browser.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,7 +23,8 @@
23
23
  "dist",
24
24
  "README.md",
25
25
  "CHANGELOG.md",
26
- "LICENSE"
26
+ "LICENSE",
27
+ "MIGRATION.md"
27
28
  ],
28
29
  "scripts": {
29
30
  "build": "bun run clean && bun run build:js && bun run build:types",
@@ -43,25 +44,27 @@
43
44
  "check": "biome check src tests",
44
45
  "check:fix": "biome check --write src tests"
45
46
  },
46
- "optionalDependencies": {
47
- "tiktoken": "^1.0.22"
48
- },
49
47
  "devDependencies": {
50
48
  "@biomejs/biome": "^2.4.13",
51
49
  "@types/bun": "latest",
52
50
  "esbuild": "0.28.1",
51
+ "tiktoken": "^1.0.22",
53
52
  "typescript": "^5.6.0"
54
53
  },
55
54
  "peerDependencies": {
55
+ "tiktoken": "^1.0.22",
56
56
  "typescript": ">=5.0"
57
57
  },
58
58
  "peerDependenciesMeta": {
59
59
  "typescript": {
60
60
  "optional": true
61
+ },
62
+ "tiktoken": {
63
+ "optional": true
61
64
  }
62
65
  },
63
66
  "engines": {
64
- "node": ">=18",
67
+ "node": ">=22",
65
68
  "bun": ">=1.1.0"
66
69
  },
67
70
  "repository": {