@rulvar/anthropic 1.26.0 → 1.28.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.
package/dist/index.d.ts CHANGED
@@ -121,14 +121,9 @@ declare class IdMap {
121
121
  canonicalFor(wireId: string): CanonicalId;
122
122
  wireFor(canonicalId: CanonicalId): string;
123
123
  }
124
+ /** A raw Messages API content block, structurally typed. */
124
125
  type Block = Record<string, unknown>;
125
126
  /**
126
- * Returns a deep copy of the schema with the unsupported keywords
127
- * removed at SCHEMA positions only: a property literally named
128
- * "minimum" (a key inside `properties`) survives. The input is never
129
- * mutated; unrecognized keywords are copied through untouched.
130
- */
131
- /**
132
127
  * Builds Messages API params from a ChatRequest. cacheHint compiles into
133
128
  * cache_control breakpoints; beyond the provider cap of 4 the DEEPEST
134
129
  * breakpoints are kept and the shallowest dropped, deterministically.
@@ -186,4 +181,4 @@ declare function mapAnthropicStream(stream: AsyncIterable<AnthropicStreamEvent>,
186
181
  */
187
182
  declare function anthropicErrorToWire(error: unknown): WireError;
188
183
  //#endregion
189
- export { ANTHROPIC_MODELS, ANTHROPIC_PRICING, type AnthropicAdapterOptions, type AnthropicClientLike, type AnthropicModelInfo, type AnthropicSdkOptions, type AnthropicStreamEvent, DEFAULT_PAUSE_TURN_MAX_CONTINUATIONS, IdMap, type TurnMapping, anthropic, anthropicErrorToWire, anthropicModelInfo, buildAnthropicParams, mapAnthropicStream, mapStopReason, normalizeAnthropicUsage };
184
+ export { ANTHROPIC_MODELS, ANTHROPIC_PRICING, type AnthropicAdapterOptions, type AnthropicClientLike, type AnthropicModelInfo, type AnthropicSdkOptions, type AnthropicStreamEvent, type Block, DEFAULT_PAUSE_TURN_MAX_CONTINUATIONS, IdMap, type MappedStop, type TurnMapping, anthropic, anthropicErrorToWire, anthropicModelInfo, buildAnthropicParams, mapAnthropicStream, mapStopReason, normalizeAnthropicUsage };
package/dist/index.js CHANGED
@@ -766,6 +766,7 @@ function anthropic(options = {}) {
766
766
  stream: true
767
767
  }, signal === void 0 ? void 0 : { signal });
768
768
  } catch (thrown) {
769
+ if (signal?.aborted === true) return;
769
770
  yield {
770
771
  type: "error",
771
772
  error: anthropicErrorToWire(thrown)
@@ -791,7 +792,20 @@ function anthropic(options = {}) {
791
792
  };
792
793
  return;
793
794
  }
794
- if (!mapping.pauseTurn) return;
795
+ if (mapping.finished) return;
796
+ if (!mapping.pauseTurn) {
797
+ if (signal?.aborted === true) return;
798
+ yield {
799
+ type: "error",
800
+ error: {
801
+ code: "agent",
802
+ message: "Messages stream ended before message_stop; the read was truncated",
803
+ retryable: true,
804
+ data: { kind: "transport" }
805
+ }
806
+ };
807
+ return;
808
+ }
795
809
  carryRetained.push(...mapping.assistantContent.filter((block) => block.type === "thinking" || block.type === "redacted_thinking"));
796
810
  continuations += 1;
797
811
  if (continuations > pauseCap) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/anthropic",
3
- "version": "1.26.0",
3
+ "version": "1.28.0",
4
4
  "description": "Rulvar first-class provider adapter over @anthropic-ai/sdk.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@anthropic-ai/sdk": "^0.110.0",
26
- "@rulvar/core": "1.26.0"
26
+ "@rulvar/core": "1.28.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^22.20.0",
30
30
  "tsdown": "^0.22.3",
31
31
  "typescript": "~6.0.3",
32
- "@rulvar/testing": "1.26.0"
32
+ "@rulvar/testing": "1.28.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",