@rulvar/anthropic 1.137.0 → 1.138.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 (2) hide show
  1. package/dist/index.js +9 -1
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -842,7 +842,7 @@ function anthropic(options = {}) {
842
842
  afterId = page.has_more === true && typeof page.last_id === "string" ? page.last_id : void 0;
843
843
  } while (afterId !== void 0);
844
844
  },
845
- async *stream(req, signal) {
845
+ async *stream(req, signal, hooks) {
846
846
  const info = infoFor(req.model);
847
847
  const rawPauseCap = req.providerOptions?.anthropic?.pauseTurnMaxContinuations;
848
848
  if (rawPauseCap !== void 0 && (typeof rawPauseCap !== "number" || !Number.isSafeInteger(rawPauseCap) || rawPauseCap < 0)) throw new ConfigError(`pauseTurnMaxContinuations must be a nonnegative safe integer, got ${typeof rawPauseCap === "number" ? String(rawPauseCap) : typeof rawPauseCap === "string" ? `'${rawPauseCap}'` : JSON.stringify(rawPauseCap) ?? "a non-numeric value"}; an invalid cap never disarms the continuation bound, because every absorbed continuation is a paid wire request`);
@@ -924,6 +924,14 @@ function anthropic(options = {}) {
924
924
  };
925
925
  return;
926
926
  }
927
+ const denial = await hooks?.onContinuationSegment?.({ segment: continuations + 1 });
928
+ if (denial !== void 0) {
929
+ yield {
930
+ type: "error",
931
+ error: denial
932
+ };
933
+ return;
934
+ }
927
935
  const messages = params.messages;
928
936
  params = {
929
937
  ...params,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/anthropic",
3
- "version": "1.137.0",
3
+ "version": "1.138.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.115.0",
26
- "@rulvar/core": "1.137.0"
26
+ "@rulvar/core": "1.138.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^22.20.1",
30
30
  "tsdown": "^0.22.14",
31
31
  "typescript": "~6.0.3",
32
- "@rulvar/testing": "1.137.0"
32
+ "@rulvar/testing": "1.138.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",