@superatomai/sdk-node 0.0.83-dsp → 0.0.85-dsp

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.js CHANGED
@@ -2001,6 +2001,7 @@ function canonicalPolicies(policies) {
2001
2001
  const norm = policies.map((p) => ({
2002
2002
  s: p.sourceId ?? "*",
2003
2003
  t: [...p.readableTables ?? []].sort(),
2004
+ x: JSON.stringify(p.exceptions ?? []),
2004
2005
  f: (p.rowFilters ?? []).map((f) => ({
2005
2006
  t: f.table ?? "*",
2006
2007
  c: f.column,
@@ -2677,6 +2678,38 @@ function accessFromConfig(config2) {
2677
2678
  allowedSources: scoped ? allowedSourcesFrom(scoped.allowedSources) : null
2678
2679
  };
2679
2680
  }
2681
+ function exceptionsFromConfig(raw) {
2682
+ if (!Array.isArray(raw)) return [];
2683
+ const str = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
2684
+ const out = [];
2685
+ for (const item of raw) {
2686
+ if (!item || typeof item !== "object") continue;
2687
+ const x = item;
2688
+ const name = typeof x.name === "string" && x.name ? x.name : void 0;
2689
+ if (!x.tables || typeof x.tables !== "object") continue;
2690
+ const visibleKeys = str(x.visibleKeys);
2691
+ const tables = {};
2692
+ for (const [table, spec] of Object.entries(x.tables)) {
2693
+ if (!table || !spec || typeof spec !== "object") continue;
2694
+ const s = spec;
2695
+ const link = str(s.link);
2696
+ const own = str(s.own);
2697
+ const columns = Array.isArray(s.columns) ? s.columns.filter((c) => typeof c === "string" && !!c) : [];
2698
+ let bad = null;
2699
+ if (!own && !link) bad = 'it has neither "link" nor "own"';
2700
+ else if (!own && columns.length === 0) bad = 'it lists no "columns"';
2701
+ else if (!own && !visibleKeys) bad = 'the exception has no "visibleKeys"';
2702
+ if (bad) {
2703
+ logger.warn(`[RequestIdentity] Exception "${name ?? "?"}": table "${table}" dropped because ${bad}.`);
2704
+ continue;
2705
+ }
2706
+ tables[table] = own ? { own } : { link, columns };
2707
+ }
2708
+ if (Object.keys(tables).length === 0) continue;
2709
+ out.push({ name, visibleKeys, tables });
2710
+ }
2711
+ return out;
2712
+ }
2680
2713
  function policiesFromConfig(config2) {
2681
2714
  const raw = scopedForm(config2)?.policies ?? config2;
2682
2715
  const entries = Array.isArray(raw) ? raw : [raw];
@@ -2702,6 +2735,7 @@ function policiesFromConfig(config2) {
2702
2735
  });
2703
2736
  }
2704
2737
  const readableTables = Array.isArray(e.readableTables) ? e.readableTables.filter((t) => typeof t === "string" && !!t) : [];
2738
+ const exceptions = exceptionsFromConfig(e.exceptions);
2705
2739
  if (rowFilters.length === 0 && readableTables.length === 0) continue;
2706
2740
  const label = typeof e.label === "string" && e.label.trim() ? e.label.trim() : void 0;
2707
2741
  if (!label && rowFilters.some((f) => !f.label) && !warnedUnlabelled) {
@@ -2714,7 +2748,8 @@ function policiesFromConfig(config2) {
2714
2748
  sourceId: typeof e.sourceId === "string" && e.sourceId ? e.sourceId : null,
2715
2749
  label,
2716
2750
  rowFilters,
2717
- readableTables
2751
+ readableTables,
2752
+ exceptions
2718
2753
  });
2719
2754
  }
2720
2755
  return out;
@@ -19690,6 +19725,7 @@ function promptContextFrom(raw) {
19690
19725
  if (source.filters && typeof source.filters === "object" && !Array.isArray(source.filters)) {
19691
19726
  context.filters = source.filters;
19692
19727
  }
19728
+ if (source.follow === true) context.follow = true;
19693
19729
  return Object.keys(context).length ? context : void 0;
19694
19730
  }
19695
19731
  var inFlightAborts = /* @__PURE__ */ new Map();
@@ -19872,7 +19908,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19872
19908
  };
19873
19909
  let userResponse;
19874
19910
  try {
19875
- const replayed = answerProvider && !attachments ? (await replayExactMatch({ prompt, collections, userId, threadId, streamCallback, method: "custom-exact-match", startTime: Date.now() }))?.response : void 0;
19911
+ const replayed = answerProvider && !attachments && !payload.context?.follow ? (await replayExactMatch({ prompt, collections, userId, threadId, streamCallback, method: "custom-exact-match", startTime: Date.now() }))?.response : void 0;
19876
19912
  userResponse = replayed ? replayed : answerProvider ? await answerProvider({
19877
19913
  prompt,
19878
19914
  components,
@@ -19917,6 +19953,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19917
19953
  if (Array.isArray(narration) && narration.length) uiBlock.setNarration(narration);
19918
19954
  uiBlock.setDurationMs(Date.now() - requestStartTime);
19919
19955
  const uiBlockId = existingUiBlockId;
19956
+ const recordable = !!userId && !userResponse?.data?.followed;
19920
19957
  const wasAborted = abortController.signal.aborted || !userResponse.success && Array.isArray(userResponse.errors) && userResponse.errors.includes("aborted");
19921
19958
  if (wasAborted) {
19922
19959
  thread.removeUIBlock(uiBlockId);
@@ -19926,7 +19963,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19926
19963
  }
19927
19964
  let savedConversationId2;
19928
19965
  let savedResponse2;
19929
- if (userId) {
19966
+ if (recordable) {
19930
19967
  const saveResult = await saveConversation({
19931
19968
  userId,
19932
19969
  userPrompt: prompt,
@@ -19945,7 +19982,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19945
19982
  savedResponse2 = saveResult.response;
19946
19983
  }
19947
19984
  }
19948
- if (userId) {
19985
+ if (recordable) {
19949
19986
  const latencyMs = Date.now() - requestStartTime;
19950
19987
  const turn = reported(userResponse);
19951
19988
  const model = turn.model || mainAgentModel || "unknown";
@@ -19995,7 +20032,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19995
20032
  }
19996
20033
  let savedConversationId2;
19997
20034
  let savedResponse2;
19998
- if (userId) {
20035
+ if (recordable) {
19999
20036
  const saveResult = await saveConversation({
20000
20037
  userId,
20001
20038
  userPrompt: prompt,
@@ -20017,7 +20054,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
20017
20054
  savedResponse2 = saveResult.response;
20018
20055
  }
20019
20056
  }
20020
- if (userId) {
20057
+ if (recordable) {
20021
20058
  const latencyMs = Date.now() - requestStartTime;
20022
20059
  const turn = reported(userResponse);
20023
20060
  const model = turn.model || mainAgentModel || "unknown";
@@ -20082,7 +20119,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
20082
20119
  logger.info(`Completed UIBlock: ${uiBlockId} in Thread: ${threadId}`);
20083
20120
  let savedConversationId;
20084
20121
  let savedResponse;
20085
- if (userId) {
20122
+ if (recordable) {
20086
20123
  const responseMethod = userResponse.data?.method || "";
20087
20124
  const semanticSimilarity = userResponse.data?.semanticSimilarity || 0;
20088
20125
  const isExactMatch = responseMethod.includes("semantic-match") && semanticSimilarity >= 0.99;
@@ -20121,7 +20158,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
20121
20158
  }
20122
20159
  }
20123
20160
  llmUsageLogger.logSessionSummary(prompt?.substring(0, 50));
20124
- if (userId) {
20161
+ if (recordable) {
20125
20162
  const latencyMs = Date.now() - requestStartTime;
20126
20163
  const turn = reported(userResponse);
20127
20164
  const model = turn.model || mainAgentModel || "unknown";
package/dist/index.mjs CHANGED
@@ -1889,6 +1889,7 @@ function canonicalPolicies(policies) {
1889
1889
  const norm = policies.map((p) => ({
1890
1890
  s: p.sourceId ?? "*",
1891
1891
  t: [...p.readableTables ?? []].sort(),
1892
+ x: JSON.stringify(p.exceptions ?? []),
1892
1893
  f: (p.rowFilters ?? []).map((f) => ({
1893
1894
  t: f.table ?? "*",
1894
1895
  c: f.column,
@@ -2565,6 +2566,38 @@ function accessFromConfig(config2) {
2565
2566
  allowedSources: scoped ? allowedSourcesFrom(scoped.allowedSources) : null
2566
2567
  };
2567
2568
  }
2569
+ function exceptionsFromConfig(raw) {
2570
+ if (!Array.isArray(raw)) return [];
2571
+ const str = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
2572
+ const out = [];
2573
+ for (const item of raw) {
2574
+ if (!item || typeof item !== "object") continue;
2575
+ const x = item;
2576
+ const name = typeof x.name === "string" && x.name ? x.name : void 0;
2577
+ if (!x.tables || typeof x.tables !== "object") continue;
2578
+ const visibleKeys = str(x.visibleKeys);
2579
+ const tables = {};
2580
+ for (const [table, spec] of Object.entries(x.tables)) {
2581
+ if (!table || !spec || typeof spec !== "object") continue;
2582
+ const s = spec;
2583
+ const link = str(s.link);
2584
+ const own = str(s.own);
2585
+ const columns = Array.isArray(s.columns) ? s.columns.filter((c) => typeof c === "string" && !!c) : [];
2586
+ let bad = null;
2587
+ if (!own && !link) bad = 'it has neither "link" nor "own"';
2588
+ else if (!own && columns.length === 0) bad = 'it lists no "columns"';
2589
+ else if (!own && !visibleKeys) bad = 'the exception has no "visibleKeys"';
2590
+ if (bad) {
2591
+ logger.warn(`[RequestIdentity] Exception "${name ?? "?"}": table "${table}" dropped because ${bad}.`);
2592
+ continue;
2593
+ }
2594
+ tables[table] = own ? { own } : { link, columns };
2595
+ }
2596
+ if (Object.keys(tables).length === 0) continue;
2597
+ out.push({ name, visibleKeys, tables });
2598
+ }
2599
+ return out;
2600
+ }
2568
2601
  function policiesFromConfig(config2) {
2569
2602
  const raw = scopedForm(config2)?.policies ?? config2;
2570
2603
  const entries = Array.isArray(raw) ? raw : [raw];
@@ -2590,6 +2623,7 @@ function policiesFromConfig(config2) {
2590
2623
  });
2591
2624
  }
2592
2625
  const readableTables = Array.isArray(e.readableTables) ? e.readableTables.filter((t) => typeof t === "string" && !!t) : [];
2626
+ const exceptions = exceptionsFromConfig(e.exceptions);
2593
2627
  if (rowFilters.length === 0 && readableTables.length === 0) continue;
2594
2628
  const label = typeof e.label === "string" && e.label.trim() ? e.label.trim() : void 0;
2595
2629
  if (!label && rowFilters.some((f) => !f.label) && !warnedUnlabelled) {
@@ -2602,7 +2636,8 @@ function policiesFromConfig(config2) {
2602
2636
  sourceId: typeof e.sourceId === "string" && e.sourceId ? e.sourceId : null,
2603
2637
  label,
2604
2638
  rowFilters,
2605
- readableTables
2639
+ readableTables,
2640
+ exceptions
2606
2641
  });
2607
2642
  }
2608
2643
  return out;
@@ -19578,6 +19613,7 @@ function promptContextFrom(raw) {
19578
19613
  if (source.filters && typeof source.filters === "object" && !Array.isArray(source.filters)) {
19579
19614
  context.filters = source.filters;
19580
19615
  }
19616
+ if (source.follow === true) context.follow = true;
19581
19617
  return Object.keys(context).length ? context : void 0;
19582
19618
  }
19583
19619
  var inFlightAborts = /* @__PURE__ */ new Map();
@@ -19760,7 +19796,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19760
19796
  };
19761
19797
  let userResponse;
19762
19798
  try {
19763
- const replayed = answerProvider && !attachments ? (await replayExactMatch({ prompt, collections, userId, threadId, streamCallback, method: "custom-exact-match", startTime: Date.now() }))?.response : void 0;
19799
+ const replayed = answerProvider && !attachments && !payload.context?.follow ? (await replayExactMatch({ prompt, collections, userId, threadId, streamCallback, method: "custom-exact-match", startTime: Date.now() }))?.response : void 0;
19764
19800
  userResponse = replayed ? replayed : answerProvider ? await answerProvider({
19765
19801
  prompt,
19766
19802
  components,
@@ -19805,6 +19841,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19805
19841
  if (Array.isArray(narration) && narration.length) uiBlock.setNarration(narration);
19806
19842
  uiBlock.setDurationMs(Date.now() - requestStartTime);
19807
19843
  const uiBlockId = existingUiBlockId;
19844
+ const recordable = !!userId && !userResponse?.data?.followed;
19808
19845
  const wasAborted = abortController.signal.aborted || !userResponse.success && Array.isArray(userResponse.errors) && userResponse.errors.includes("aborted");
19809
19846
  if (wasAborted) {
19810
19847
  thread.removeUIBlock(uiBlockId);
@@ -19814,7 +19851,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19814
19851
  }
19815
19852
  let savedConversationId2;
19816
19853
  let savedResponse2;
19817
- if (userId) {
19854
+ if (recordable) {
19818
19855
  const saveResult = await saveConversation({
19819
19856
  userId,
19820
19857
  userPrompt: prompt,
@@ -19833,7 +19870,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19833
19870
  savedResponse2 = saveResult.response;
19834
19871
  }
19835
19872
  }
19836
- if (userId) {
19873
+ if (recordable) {
19837
19874
  const latencyMs = Date.now() - requestStartTime;
19838
19875
  const turn = reported(userResponse);
19839
19876
  const model = turn.model || mainAgentModel || "unknown";
@@ -19883,7 +19920,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19883
19920
  }
19884
19921
  let savedConversationId2;
19885
19922
  let savedResponse2;
19886
- if (userId) {
19923
+ if (recordable) {
19887
19924
  const saveResult = await saveConversation({
19888
19925
  userId,
19889
19926
  userPrompt: prompt,
@@ -19905,7 +19942,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19905
19942
  savedResponse2 = saveResult.response;
19906
19943
  }
19907
19944
  }
19908
- if (userId) {
19945
+ if (recordable) {
19909
19946
  const latencyMs = Date.now() - requestStartTime;
19910
19947
  const turn = reported(userResponse);
19911
19948
  const model = turn.model || mainAgentModel || "unknown";
@@ -19970,7 +20007,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19970
20007
  logger.info(`Completed UIBlock: ${uiBlockId} in Thread: ${threadId}`);
19971
20008
  let savedConversationId;
19972
20009
  let savedResponse;
19973
- if (userId) {
20010
+ if (recordable) {
19974
20011
  const responseMethod = userResponse.data?.method || "";
19975
20012
  const semanticSimilarity = userResponse.data?.semanticSimilarity || 0;
19976
20013
  const isExactMatch = responseMethod.includes("semantic-match") && semanticSimilarity >= 0.99;
@@ -20009,7 +20046,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
20009
20046
  }
20010
20047
  }
20011
20048
  llmUsageLogger.logSessionSummary(prompt?.substring(0, 50));
20012
- if (userId) {
20049
+ if (recordable) {
20013
20050
  const latencyMs = Date.now() - requestStartTime;
20014
20051
  const turn = reported(userResponse);
20015
20052
  const model = turn.model || mainAgentModel || "unknown";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superatomai/sdk-node",
3
- "version": "0.0.83-dsp",
3
+ "version": "0.0.85-dsp",
4
4
  "description": "Node.js TypeScript SDK for Superatom",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",