@silmaril-security/sdk 0.11.2 → 0.11.3

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.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as HookLabel, B as BlockResult, R as ReviewLevel } from './firewall-D8XAQ9gj.cjs';
2
- export { A as ALL_HOOKS, C as ClassificationMetadata, a as ClassifyBatchOptions, b as ClassifyEvent, c as ClassifyOptions, D as DEFAULT_HOOKS, d as DEFAULT_TIMEOUT_MS, F as FIREWALL_HOOK_TO_LABEL, e as Firewall, f as FirewallHook, g as FirewallMiddleware, h as FirewallMode, i as FirewallOptions, G as GovernanceAction, j as GovernanceContext, k as GovernanceDecision, l as GovernanceResource, m as GovernanceResourceKind, n as HARMFUL_OUTCOMES, o as HarmfulOutcome, I as INPUT_HOOKS, K as KnownHarmfulOutcome, p as KnownPrimaryOutcome, L as LangChainAdapterOptions, q as LangChainFirewallHandler, M as MiddlewareOptions, O as OUTCOME_DESCRIPTIONS, r as OUTPUT_HOOKS, s as Outcome, P as PRIMARY_OUTCOMES, t as Prediction, u as PrimaryOutcome, v as ProtectOptions, U as UnknownOutcome, w as isHarmfulOutcome, x as isPrimaryOutcome, y as normalizeHarmfulOutcome, z as normalizeHarmfulOutcomeMap, E as normalizePrimaryOutcome, J as prependHook, N as prependToolName, Q as resolveHooks } from './firewall-D8XAQ9gj.cjs';
1
+ import { H as HookLabel, B as BlockResult, R as ReviewLevel } from './firewall-BZ8kfq5c.cjs';
2
+ export { A as ALL_HOOKS, C as ClassificationMetadata, a as ClassifyBatchOptions, b as ClassifyEvent, c as ClassifyOptions, D as DEFAULT_HOOKS, d as DEFAULT_TIMEOUT_MS, F as FIREWALL_HOOK_TO_LABEL, e as Firewall, f as FirewallHook, g as FirewallMiddleware, h as FirewallMode, i as FirewallOptions, G as GovernanceAction, j as GovernanceContext, k as GovernanceDecision, l as GovernanceResource, m as GovernanceResourceKind, n as HARMFUL_OUTCOMES, o as HarmfulOutcome, I as INPUT_HOOKS, K as KnownHarmfulOutcome, p as KnownPrimaryOutcome, L as LangChainAdapterOptions, q as LangChainFirewallHandler, M as MiddlewareOptions, O as OUTCOME_DESCRIPTIONS, r as OUTPUT_HOOKS, s as Outcome, P as PRIMARY_OUTCOMES, t as Prediction, u as PrimaryOutcome, v as ProtectOptions, U as UnknownOutcome, w as isHarmfulOutcome, x as isPrimaryOutcome, y as normalizeHarmfulOutcome, z as normalizeHarmfulOutcomeMap, E as normalizePrimaryOutcome, J as prependHook, N as prependToolName, Q as resolveHooks } from './firewall-BZ8kfq5c.cjs';
3
3
 
4
4
  interface MalformedInputDetails {
5
5
  field?: string;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as HookLabel, B as BlockResult, R as ReviewLevel } from './firewall-D8XAQ9gj.js';
2
- export { A as ALL_HOOKS, C as ClassificationMetadata, a as ClassifyBatchOptions, b as ClassifyEvent, c as ClassifyOptions, D as DEFAULT_HOOKS, d as DEFAULT_TIMEOUT_MS, F as FIREWALL_HOOK_TO_LABEL, e as Firewall, f as FirewallHook, g as FirewallMiddleware, h as FirewallMode, i as FirewallOptions, G as GovernanceAction, j as GovernanceContext, k as GovernanceDecision, l as GovernanceResource, m as GovernanceResourceKind, n as HARMFUL_OUTCOMES, o as HarmfulOutcome, I as INPUT_HOOKS, K as KnownHarmfulOutcome, p as KnownPrimaryOutcome, L as LangChainAdapterOptions, q as LangChainFirewallHandler, M as MiddlewareOptions, O as OUTCOME_DESCRIPTIONS, r as OUTPUT_HOOKS, s as Outcome, P as PRIMARY_OUTCOMES, t as Prediction, u as PrimaryOutcome, v as ProtectOptions, U as UnknownOutcome, w as isHarmfulOutcome, x as isPrimaryOutcome, y as normalizeHarmfulOutcome, z as normalizeHarmfulOutcomeMap, E as normalizePrimaryOutcome, J as prependHook, N as prependToolName, Q as resolveHooks } from './firewall-D8XAQ9gj.js';
1
+ import { H as HookLabel, B as BlockResult, R as ReviewLevel } from './firewall-BZ8kfq5c.js';
2
+ export { A as ALL_HOOKS, C as ClassificationMetadata, a as ClassifyBatchOptions, b as ClassifyEvent, c as ClassifyOptions, D as DEFAULT_HOOKS, d as DEFAULT_TIMEOUT_MS, F as FIREWALL_HOOK_TO_LABEL, e as Firewall, f as FirewallHook, g as FirewallMiddleware, h as FirewallMode, i as FirewallOptions, G as GovernanceAction, j as GovernanceContext, k as GovernanceDecision, l as GovernanceResource, m as GovernanceResourceKind, n as HARMFUL_OUTCOMES, o as HarmfulOutcome, I as INPUT_HOOKS, K as KnownHarmfulOutcome, p as KnownPrimaryOutcome, L as LangChainAdapterOptions, q as LangChainFirewallHandler, M as MiddlewareOptions, O as OUTCOME_DESCRIPTIONS, r as OUTPUT_HOOKS, s as Outcome, P as PRIMARY_OUTCOMES, t as Prediction, u as PrimaryOutcome, v as ProtectOptions, U as UnknownOutcome, w as isHarmfulOutcome, x as isPrimaryOutcome, y as normalizeHarmfulOutcome, z as normalizeHarmfulOutcomeMap, E as normalizePrimaryOutcome, J as prependHook, N as prependToolName, Q as resolveHooks } from './firewall-BZ8kfq5c.js';
3
3
 
4
4
  interface MalformedInputDetails {
5
5
  field?: string;
package/dist/index.js CHANGED
@@ -1527,7 +1527,7 @@ function sanitizeText(text) {
1527
1527
  }
1528
1528
 
1529
1529
  // src/firewall.ts
1530
- var SDK_VERSION = "0.11.2";
1530
+ var SDK_VERSION = "0.11.3";
1531
1531
  var DEFAULT_TIMEOUT_MS = 1e4;
1532
1532
  var DEFAULT_MAX_RETRIES = 5;
1533
1533
  var MAX_BACKOFF_SECONDS = 30;
@@ -1855,7 +1855,7 @@ function createAttemptSignal(timeoutMs, callerSignal) {
1855
1855
  }
1856
1856
  function linkCaller(callerSignal, controller) {
1857
1857
  if (callerSignal === void 0) {
1858
- return { until: (work) => Promise.resolve(work), dispose: () => void 0 };
1858
+ return { until: (work) => Promise.resolve(work), run: (callback) => callback(), dispose: () => void 0 };
1859
1859
  }
1860
1860
  let onAbort = () => void 0;
1861
1861
  const cancelled = new Promise((_resolve, reject) => {
@@ -1868,6 +1868,14 @@ function linkCaller(callerSignal, controller) {
1868
1868
  callerSignal.addEventListener("abort", onAbort, { once: true });
1869
1869
  return {
1870
1870
  until: (work) => Promise.race([work, cancelled]),
1871
+ run: (callback) => {
1872
+ try {
1873
+ return callback();
1874
+ } catch (error) {
1875
+ callerSignal.throwIfAborted();
1876
+ throw error;
1877
+ }
1878
+ },
1871
1879
  dispose: () => callerSignal.removeEventListener("abort", onAbort)
1872
1880
  };
1873
1881
  }
@@ -1950,10 +1958,10 @@ var Firewall = class {
1950
1958
  if (observed !== void 0) {
1951
1959
  void this.background(text, observed);
1952
1960
  }
1953
- const result2 = await caller.until(operation(controller.signal));
1961
+ const result2 = await caller.until(caller.run(() => operation(controller.signal)));
1954
1962
  callerSignal?.throwIfAborted();
1955
1963
  if (observed !== void 0 && output !== void 0) {
1956
- const generated = output(result2);
1964
+ const generated = caller.run(() => output(result2));
1957
1965
  callerSignal?.throwIfAborted();
1958
1966
  void this.background(generated, outputRequest(observed));
1959
1967
  }
@@ -1975,7 +1983,7 @@ var Firewall = class {
1975
1983
  ]));
1976
1984
  callerSignal?.throwIfAborted();
1977
1985
  if (output !== void 0) {
1978
- const generated = output(result);
1986
+ const generated = caller.run(() => output(result));
1979
1987
  callerSignal?.throwIfAborted();
1980
1988
  await caller.until(this.pending.submit(
1981
1989
  () => this.enforce(generated, outputOptions),
@@ -1988,7 +1996,12 @@ var Firewall = class {
1988
1996
  caller.dispose();
1989
1997
  }
1990
1998
  }
1991
- /** Wait for classifications still running in the background. */
1999
+ /**
2000
+ * Wait for every check queued on this client, foreground or background.
2001
+ * `protect()` and the parallel or background checks of framework adapters are
2002
+ * queued. Direct `classify()` and `classifyBatch()` calls are not, and the
2003
+ * operation that `protect()` runs is not awaited.
2004
+ */
1992
2005
  flush() {
1993
2006
  return this.pending.drain();
1994
2007
  }