@anuma/sdk 6.5.0 → 6.6.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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  callPortalJsonCompletion,
3
3
  getLogger
4
- } from "./chunk-ILAWDQDE.mjs";
4
+ } from "./chunk-B5UPJRCU.mjs";
5
5
  import {
6
6
  BASE_URL,
7
7
  createClientConfig
@@ -6784,7 +6784,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
6784
6784
  subQueries = decomp.subQueries;
6785
6785
  }
6786
6786
  }
6787
- const { recall: recall2 } = await import("./recall-ISSI7RMD.mjs");
6787
+ const { recall: recall2 } = await import("./recall-EZIHN5VU.mjs");
6788
6788
  let recallDegraded = [];
6789
6789
  const result = await recall2(
6790
6790
  query,
@@ -45,6 +45,14 @@ function validateEndpointOverride(override) {
45
45
  return { valid: true, endpoint: trimmed.startsWith("/") ? trimmed : `/${trimmed}` };
46
46
  }
47
47
 
48
+ // src/lib/internalFlowMarker.ts
49
+ var INTERNAL_FLOW_MARKER = "Anuma internal first-party flow (not user chat).";
50
+ function withInternalFlowMarker(systemPrompt) {
51
+ if (systemPrompt.includes(INTERNAL_FLOW_MARKER)) return systemPrompt;
52
+ return `${INTERNAL_FLOW_MARKER}
53
+ ${systemPrompt}`;
54
+ }
55
+
48
56
  // src/lib/memory/portalLlm.ts
49
57
  function defaultBaseUrl() {
50
58
  return typeof process !== "undefined" && process.env?.ANUMA_PORTAL_BASE_URL || BASE_URL;
@@ -151,7 +159,12 @@ async function attemptPortalJson(req, endpoint) {
151
159
  const isAnthropic = req.model.startsWith("anthropic/");
152
160
  const prefill = isAnthropic ? "{" : "";
153
161
  const messages = [
154
- { role: "system", content: req.systemPrompt },
162
+ // Every caller of this helper is a first-party BACKGROUND op (fact extraction,
163
+ // topic sweep, consolidation, classifiers, graph traversal, query
164
+ // decomposition). Marking here — the one place they all funnel through — is what
165
+ // keeps the portal's detector reading them as genuine rather than markerless.
166
+ // See ../internalFlowMarker.
167
+ { role: "system", content: withInternalFlowMarker(req.systemPrompt) },
155
168
  { role: "user", content: req.userMessage }
156
169
  ];
157
170
  if (prefill) messages.push({ role: "assistant", content: prefill });
@@ -290,6 +303,8 @@ export {
290
303
  setLogger,
291
304
  getLogger,
292
305
  validateEndpointOverride,
306
+ INTERNAL_FLOW_MARKER,
307
+ withInternalFlowMarker,
293
308
  supportsResponseFormat,
294
309
  resolvePortalAuthHeaders,
295
310
  callPortalJsonCompletion,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getLogger
3
- } from "./chunk-ILAWDQDE.mjs";
3
+ } from "./chunk-B5UPJRCU.mjs";
4
4
 
5
5
  // src/lib/pii/patterns.ts
6
6
  function luhnCheck(digits) {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  notifyConsolidationFallback,
3
3
  resolvePiiRedactor
4
- } from "./chunk-VMI74IUX.mjs";
4
+ } from "./chunk-VOMDHMKH.mjs";
5
5
  import {
6
6
  callPortalJsonCompletion
7
- } from "./chunk-ILAWDQDE.mjs";
7
+ } from "./chunk-B5UPJRCU.mjs";
8
8
  import "./chunk-GYKJOWEO.mjs";
9
9
 
10
10
  // src/lib/memory/consolidate.ts
@@ -4564,6 +4564,20 @@ var init_endpointOverride = __esm({
4564
4564
  }
4565
4565
  });
4566
4566
 
4567
+ // src/lib/internalFlowMarker.ts
4568
+ function withInternalFlowMarker(systemPrompt) {
4569
+ if (systemPrompt.includes(INTERNAL_FLOW_MARKER)) return systemPrompt;
4570
+ return `${INTERNAL_FLOW_MARKER}
4571
+ ${systemPrompt}`;
4572
+ }
4573
+ var INTERNAL_FLOW_MARKER;
4574
+ var init_internalFlowMarker = __esm({
4575
+ "src/lib/internalFlowMarker.ts"() {
4576
+ "use strict";
4577
+ INTERNAL_FLOW_MARKER = "Anuma internal first-party flow (not user chat).";
4578
+ }
4579
+ });
4580
+
4567
4581
  // src/lib/db/entities/types.ts
4568
4582
  function normalizeEntityName(name) {
4569
4583
  return name.trim().toLowerCase();
@@ -6158,7 +6172,12 @@ async function attemptPortalJson(req, endpoint) {
6158
6172
  const isAnthropic = req.model.startsWith("anthropic/");
6159
6173
  const prefill = isAnthropic ? "{" : "";
6160
6174
  const messages = [
6161
- { role: "system", content: req.systemPrompt },
6175
+ // Every caller of this helper is a first-party BACKGROUND op (fact extraction,
6176
+ // topic sweep, consolidation, classifiers, graph traversal, query
6177
+ // decomposition). Marking here — the one place they all funnel through — is what
6178
+ // keeps the portal's detector reading them as genuine rather than markerless.
6179
+ // See ../internalFlowMarker.
6180
+ { role: "system", content: withInternalFlowMarker(req.systemPrompt) },
6162
6181
  { role: "user", content: req.userMessage }
6163
6182
  ];
6164
6183
  if (prefill) messages.push({ role: "assistant", content: prefill });
@@ -6296,6 +6315,7 @@ var init_portalLlm = __esm({
6296
6315
  "use strict";
6297
6316
  init_clientConfig();
6298
6317
  init_endpointOverride();
6318
+ init_internalFlowMarker();
6299
6319
  init_logger();
6300
6320
  RESPONSE_FORMAT_OK = /* @__PURE__ */ new Set(["openai", "inclusionai", "deepseek"]);
6301
6321
  RESPONSE_SCHEMA_OK = /* @__PURE__ */ new Set(["openai"]);
@@ -13995,6 +14015,7 @@ async function deleteConversationSummaryOp(ctx, conversationId) {
13995
14015
  }
13996
14016
 
13997
14017
  // src/lib/chat/summarize.ts
14018
+ init_internalFlowMarker();
13998
14019
  init_logger();
13999
14020
  var DEFAULT_SUMMARY_TOKEN_THRESHOLD = 4e3;
14000
14021
  var DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES = 4;
@@ -14187,7 +14208,17 @@ async function callSummarizationLlm(prompt, model, token, baseUrl) {
14187
14208
  body: JSON.stringify({
14188
14209
  model,
14189
14210
  stream: false,
14190
- messages: [{ role: "user", content: prompt }]
14211
+ // The marker rides a system message because this call has no other
14212
+ // provenance: it posts to the MAIN chat endpoint (not /utility/*), carries no
14213
+ // conversationId, and its prompt is neither the app's chat base prompt nor any
14214
+ // registered flow fingerprint — so without this it reads as markerless, i.e.
14215
+ // as a scripted abuser. Progressive summarization runs for every free-tier
14216
+ // long conversation, so at the PORTAL_DETECTION_REJECT_MARKERLESS flip it
14217
+ // would 403 and silently fall back to verbatim history (context bloat + cost).
14218
+ messages: [
14219
+ { role: "system", content: INTERNAL_FLOW_MARKER },
14220
+ { role: "user", content: prompt }
14221
+ ]
14191
14222
  }),
14192
14223
  signal: controller.signal
14193
14224
  });
@@ -17664,6 +17695,7 @@ init_reranker();
17664
17695
 
17665
17696
  // src/lib/memory/synthesizeProfile.ts
17666
17697
  init_operations3();
17698
+ init_internalFlowMarker();
17667
17699
  init_logger();
17668
17700
  init_constants();
17669
17701
  init_embeddings();
@@ -18025,7 +18057,10 @@ async function synthesizeFacet(facet, ctx, options, prior) {
18025
18057
  limit,
18026
18058
  types: ["fact"],
18027
18059
  maxTokens: DEFAULT_FACET_MAX_TOKENS,
18028
- systemPrompt: buildFacetSystemPrompt(facet),
18060
+ // Profile-facet synthesis is a background op, so it marks its own prompt.
18061
+ // reflect() itself must NOT mark — it also serves the user's own questions,
18062
+ // and that traffic is chat, not an internal flow. See ../internalFlowMarker.
18063
+ systemPrompt: withInternalFlowMarker(buildFacetSystemPrompt(facet)),
18029
18064
  responseSchema: facetResponseSchema(facet.key),
18030
18065
  memories
18031
18066
  });
@@ -130,7 +130,7 @@ import {
130
130
  upsertMessageOp,
131
131
  useEncryption,
132
132
  vaultMemoryToStored
133
- } from "./chunk-NCP3VGRX.mjs";
133
+ } from "./chunk-4M6W7QLZ.mjs";
134
134
  import {
135
135
  PII_PATTERNS,
136
136
  PiiRedactor,
@@ -138,8 +138,9 @@ import {
138
138
  isPiiRedactor,
139
139
  notifyConsolidationFallback,
140
140
  resolvePiiRedactor
141
- } from "./chunk-DT6QNRZL.mjs";
141
+ } from "./chunk-VOMDHMKH.mjs";
142
142
  import {
143
+ INTERNAL_FLOW_MARKER,
143
144
  callPortalJsonCompletion,
144
145
  consoleLogger,
145
146
  extractJsonCandidate,
@@ -148,8 +149,9 @@ import {
148
149
  resolvePortalAuthHeaders,
149
150
  setLogger,
150
151
  supportsResponseFormat,
151
- validateEndpointOverride
152
- } from "./chunk-ILAWDQDE.mjs";
152
+ validateEndpointOverride,
153
+ withInternalFlowMarker
154
+ } from "./chunk-B5UPJRCU.mjs";
153
155
  import {
154
156
  BASE_URL,
155
157
  MCP_R2_DOMAIN,
@@ -4789,7 +4791,17 @@ async function callSummarizationLlm(prompt, model, token, baseUrl) {
4789
4791
  body: JSON.stringify({
4790
4792
  model,
4791
4793
  stream: false,
4792
- messages: [{ role: "user", content: prompt }]
4794
+ // The marker rides a system message because this call has no other
4795
+ // provenance: it posts to the MAIN chat endpoint (not /utility/*), carries no
4796
+ // conversationId, and its prompt is neither the app's chat base prompt nor any
4797
+ // registered flow fingerprint — so without this it reads as markerless, i.e.
4798
+ // as a scripted abuser. Progressive summarization runs for every free-tier
4799
+ // long conversation, so at the PORTAL_DETECTION_REJECT_MARKERLESS flip it
4800
+ // would 403 and silently fall back to verbatim history (context bloat + cost).
4801
+ messages: [
4802
+ { role: "system", content: INTERNAL_FLOW_MARKER },
4803
+ { role: "user", content: prompt }
4804
+ ]
4793
4805
  }),
4794
4806
  signal: controller.signal
4795
4807
  });
@@ -6847,7 +6859,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
6847
6859
  content: m.content,
6848
6860
  similarity: m.similarity
6849
6861
  }));
6850
- const { consolidateMemory: doConsolidate } = await import("./consolidate-3MEWQNM3.mjs");
6862
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-TWE6OSSZ.mjs");
6851
6863
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
6852
6864
  if (decision.action === "create") return null;
6853
6865
  if (decision.action === "supersede" && decision.content) {
@@ -8549,7 +8561,10 @@ async function synthesizeFacet(facet, ctx, options, prior) {
8549
8561
  limit,
8550
8562
  types: ["fact"],
8551
8563
  maxTokens: DEFAULT_FACET_MAX_TOKENS,
8552
- systemPrompt: buildFacetSystemPrompt(facet),
8564
+ // Profile-facet synthesis is a background op, so it marks its own prompt.
8565
+ // reflect() itself must NOT mark — it also serves the user's own questions,
8566
+ // and that traffic is chat, not an internal flow. See ../internalFlowMarker.
8567
+ systemPrompt: withInternalFlowMarker(buildFacetSystemPrompt(facet)),
8553
8568
  responseSchema: facetResponseSchema(facet.key),
8554
8569
  memories
8555
8570
  });
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-NCP3VGRX.mjs";
4
- import "./chunk-ILAWDQDE.mjs";
3
+ } from "./chunk-4M6W7QLZ.mjs";
4
+ import "./chunk-B5UPJRCU.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
7
7
  recall
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getLogger
3
- } from "./chunk-ILAWDQDE.mjs";
3
+ } from "./chunk-B5UPJRCU.mjs";
4
4
 
5
5
  // src/lib/pii/patterns.ts
6
6
  function luhnCheck(digits) {
@@ -45,6 +45,14 @@ function validateEndpointOverride(override) {
45
45
  return { valid: true, endpoint: trimmed.startsWith("/") ? trimmed : `/${trimmed}` };
46
46
  }
47
47
 
48
+ // src/lib/internalFlowMarker.ts
49
+ var INTERNAL_FLOW_MARKER = "Anuma internal first-party flow (not user chat).";
50
+ function withInternalFlowMarker(systemPrompt) {
51
+ if (systemPrompt.includes(INTERNAL_FLOW_MARKER)) return systemPrompt;
52
+ return `${INTERNAL_FLOW_MARKER}
53
+ ${systemPrompt}`;
54
+ }
55
+
48
56
  // src/lib/memory/portalLlm.ts
49
57
  function defaultBaseUrl() {
50
58
  return typeof process !== "undefined" && process.env?.ANUMA_PORTAL_BASE_URL || BASE_URL;
@@ -151,7 +159,12 @@ async function attemptPortalJson(req, endpoint) {
151
159
  const isAnthropic = req.model.startsWith("anthropic/");
152
160
  const prefill = isAnthropic ? "{" : "";
153
161
  const messages = [
154
- { role: "system", content: req.systemPrompt },
162
+ // Every caller of this helper is a first-party BACKGROUND op (fact extraction,
163
+ // topic sweep, consolidation, classifiers, graph traversal, query
164
+ // decomposition). Marking here — the one place they all funnel through — is what
165
+ // keeps the portal's detector reading them as genuine rather than markerless.
166
+ // See ../internalFlowMarker.
167
+ { role: "system", content: withInternalFlowMarker(req.systemPrompt) },
155
168
  { role: "user", content: req.userMessage }
156
169
  ];
157
170
  if (prefill) messages.push({ role: "assistant", content: prefill });
@@ -290,6 +303,8 @@ export {
290
303
  setLogger,
291
304
  getLogger,
292
305
  validateEndpointOverride,
306
+ INTERNAL_FLOW_MARKER,
307
+ withInternalFlowMarker,
293
308
  supportsResponseFormat,
294
309
  resolvePortalAuthHeaders,
295
310
  callPortalJsonCompletion,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  callPortalJsonCompletion,
3
3
  getLogger
4
- } from "./chunk-ILAWDQDE.mjs";
4
+ } from "./chunk-B5UPJRCU.mjs";
5
5
  import {
6
6
  BASE_URL,
7
7
  createClientConfig
@@ -7085,7 +7085,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
7085
7085
  subQueries = decomp.subQueries;
7086
7086
  }
7087
7087
  }
7088
- const { recall: recall2 } = await import("./recall-DQJINKEY.mjs");
7088
+ const { recall: recall2 } = await import("./recall-ROEK55FJ.mjs");
7089
7089
  let recallDegraded = [];
7090
7090
  const result = await recall2(
7091
7091
  query,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  notifyConsolidationFallback,
3
3
  resolvePiiRedactor
4
- } from "./chunk-DT6QNRZL.mjs";
4
+ } from "./chunk-2ARMO2NN.mjs";
5
5
  import {
6
6
  callPortalJsonCompletion
7
- } from "./chunk-ILAWDQDE.mjs";
7
+ } from "./chunk-B5UPJRCU.mjs";
8
8
  import "./chunk-GYKJOWEO.mjs";
9
9
 
10
10
  // src/lib/memory/consolidate.ts
@@ -4781,6 +4781,20 @@ var init_endpointOverride = __esm({
4781
4781
  }
4782
4782
  });
4783
4783
 
4784
+ // src/lib/internalFlowMarker.ts
4785
+ function withInternalFlowMarker(systemPrompt) {
4786
+ if (systemPrompt.includes(INTERNAL_FLOW_MARKER)) return systemPrompt;
4787
+ return `${INTERNAL_FLOW_MARKER}
4788
+ ${systemPrompt}`;
4789
+ }
4790
+ var INTERNAL_FLOW_MARKER;
4791
+ var init_internalFlowMarker = __esm({
4792
+ "src/lib/internalFlowMarker.ts"() {
4793
+ "use strict";
4794
+ INTERNAL_FLOW_MARKER = "Anuma internal first-party flow (not user chat).";
4795
+ }
4796
+ });
4797
+
4784
4798
  // src/lib/db/entities/types.ts
4785
4799
  function normalizeEntityName(name) {
4786
4800
  return name.trim().toLowerCase();
@@ -6459,7 +6473,12 @@ async function attemptPortalJson(req, endpoint) {
6459
6473
  const isAnthropic = req.model.startsWith("anthropic/");
6460
6474
  const prefill = isAnthropic ? "{" : "";
6461
6475
  const messages = [
6462
- { role: "system", content: req.systemPrompt },
6476
+ // Every caller of this helper is a first-party BACKGROUND op (fact extraction,
6477
+ // topic sweep, consolidation, classifiers, graph traversal, query
6478
+ // decomposition). Marking here — the one place they all funnel through — is what
6479
+ // keeps the portal's detector reading them as genuine rather than markerless.
6480
+ // See ../internalFlowMarker.
6481
+ { role: "system", content: withInternalFlowMarker(req.systemPrompt) },
6463
6482
  { role: "user", content: req.userMessage }
6464
6483
  ];
6465
6484
  if (prefill) messages.push({ role: "assistant", content: prefill });
@@ -6597,6 +6616,7 @@ var init_portalLlm = __esm({
6597
6616
  "use strict";
6598
6617
  init_clientConfig();
6599
6618
  init_endpointOverride();
6619
+ init_internalFlowMarker();
6600
6620
  init_logger();
6601
6621
  RESPONSE_FORMAT_OK = /* @__PURE__ */ new Set(["openai", "inclusionai", "deepseek"]);
6602
6622
  RESPONSE_SCHEMA_OK = /* @__PURE__ */ new Set(["openai"]);
@@ -14853,6 +14873,7 @@ async function deleteConversationSummaryOp(ctx, conversationId) {
14853
14873
  }
14854
14874
 
14855
14875
  // src/lib/chat/summarize.ts
14876
+ init_internalFlowMarker();
14856
14877
  init_logger();
14857
14878
  var DEFAULT_SUMMARY_TOKEN_THRESHOLD = 4e3;
14858
14879
  var DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES = 4;
@@ -15045,7 +15066,17 @@ async function callSummarizationLlm(prompt, model, token, baseUrl) {
15045
15066
  body: JSON.stringify({
15046
15067
  model,
15047
15068
  stream: false,
15048
- messages: [{ role: "user", content: prompt }]
15069
+ // The marker rides a system message because this call has no other
15070
+ // provenance: it posts to the MAIN chat endpoint (not /utility/*), carries no
15071
+ // conversationId, and its prompt is neither the app's chat base prompt nor any
15072
+ // registered flow fingerprint — so without this it reads as markerless, i.e.
15073
+ // as a scripted abuser. Progressive summarization runs for every free-tier
15074
+ // long conversation, so at the PORTAL_DETECTION_REJECT_MARKERLESS flip it
15075
+ // would 403 and silently fall back to verbatim history (context bloat + cost).
15076
+ messages: [
15077
+ { role: "system", content: INTERNAL_FLOW_MARKER },
15078
+ { role: "user", content: prompt }
15079
+ ]
15049
15080
  }),
15050
15081
  signal: controller.signal
15051
15082
  });
@@ -18981,6 +19012,7 @@ init_reranker();
18981
19012
 
18982
19013
  // src/lib/memory/synthesizeProfile.ts
18983
19014
  init_operations3();
19015
+ init_internalFlowMarker();
18984
19016
  init_logger();
18985
19017
  init_constants();
18986
19018
  init_embeddings();
@@ -19342,7 +19374,10 @@ async function synthesizeFacet(facet, ctx, options, prior) {
19342
19374
  limit,
19343
19375
  types: ["fact"],
19344
19376
  maxTokens: DEFAULT_FACET_MAX_TOKENS,
19345
- systemPrompt: buildFacetSystemPrompt(facet),
19377
+ // Profile-facet synthesis is a background op, so it marks its own prompt.
19378
+ // reflect() itself must NOT mark — it also serves the user's own questions,
19379
+ // and that traffic is chat, not an internal flow. See ../internalFlowMarker.
19380
+ systemPrompt: withInternalFlowMarker(buildFacetSystemPrompt(facet)),
19346
19381
  responseSchema: facetResponseSchema(facet.key),
19347
19382
  memories
19348
19383
  });
@@ -178,15 +178,16 @@ import {
178
178
  updateVaultMemoryOp,
179
179
  useEncryption,
180
180
  vaultMemoryToStored
181
- } from "./chunk-OB5HFCLB.mjs";
181
+ } from "./chunk-S6WPXD5N.mjs";
182
182
  import {
183
183
  PiiRedactor,
184
184
  createStreamingDeAnonymizer,
185
185
  isPiiRedactor,
186
186
  notifyConsolidationFallback,
187
187
  resolvePiiRedactor
188
- } from "./chunk-VMI74IUX.mjs";
188
+ } from "./chunk-2ARMO2NN.mjs";
189
189
  import {
190
+ INTERNAL_FLOW_MARKER,
190
191
  callPortalJsonCompletion,
191
192
  consoleLogger,
192
193
  extractJsonCandidate,
@@ -195,8 +196,9 @@ import {
195
196
  resolvePortalAuthHeaders,
196
197
  setLogger,
197
198
  supportsResponseFormat,
198
- validateEndpointOverride
199
- } from "./chunk-ILAWDQDE.mjs";
199
+ validateEndpointOverride,
200
+ withInternalFlowMarker
201
+ } from "./chunk-B5UPJRCU.mjs";
200
202
  import {
201
203
  BASE_URL,
202
204
  MCP_R2_DOMAIN,
@@ -5152,7 +5154,17 @@ async function callSummarizationLlm(prompt, model, token, baseUrl) {
5152
5154
  body: JSON.stringify({
5153
5155
  model,
5154
5156
  stream: false,
5155
- messages: [{ role: "user", content: prompt }]
5157
+ // The marker rides a system message because this call has no other
5158
+ // provenance: it posts to the MAIN chat endpoint (not /utility/*), carries no
5159
+ // conversationId, and its prompt is neither the app's chat base prompt nor any
5160
+ // registered flow fingerprint — so without this it reads as markerless, i.e.
5161
+ // as a scripted abuser. Progressive summarization runs for every free-tier
5162
+ // long conversation, so at the PORTAL_DETECTION_REJECT_MARKERLESS flip it
5163
+ // would 403 and silently fall back to verbatim history (context bloat + cost).
5164
+ messages: [
5165
+ { role: "system", content: INTERNAL_FLOW_MARKER },
5166
+ { role: "user", content: prompt }
5167
+ ]
5156
5168
  }),
5157
5169
  signal: controller.signal
5158
5170
  });
@@ -7667,7 +7679,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
7667
7679
  content: m.content,
7668
7680
  similarity: m.similarity
7669
7681
  }));
7670
- const { consolidateMemory: doConsolidate } = await import("./consolidate-AMPKH6YJ.mjs");
7682
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-ZCGS7QUA.mjs");
7671
7683
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
7672
7684
  if (decision.action === "create") return null;
7673
7685
  if (decision.action === "supersede" && decision.content) {
@@ -9369,7 +9381,10 @@ async function synthesizeFacet(facet, ctx, options, prior) {
9369
9381
  limit,
9370
9382
  types: ["fact"],
9371
9383
  maxTokens: DEFAULT_FACET_MAX_TOKENS,
9372
- systemPrompt: buildFacetSystemPrompt(facet),
9384
+ // Profile-facet synthesis is a background op, so it marks its own prompt.
9385
+ // reflect() itself must NOT mark — it also serves the user's own questions,
9386
+ // and that traffic is chat, not an internal flow. See ../internalFlowMarker.
9387
+ systemPrompt: withInternalFlowMarker(buildFacetSystemPrompt(facet)),
9373
9388
  responseSchema: facetResponseSchema(facet.key),
9374
9389
  memories
9375
9390
  });
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-OB5HFCLB.mjs";
4
- import "./chunk-ILAWDQDE.mjs";
3
+ } from "./chunk-S6WPXD5N.mjs";
4
+ import "./chunk-B5UPJRCU.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
7
7
  recall
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getLogger
3
- } from "./chunk-OBDRKQQI.mjs";
3
+ } from "./chunk-VHWLLYKO.mjs";
4
4
 
5
5
  // src/lib/pii/patterns.ts
6
6
  function luhnCheck(digits) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  callPortalJsonCompletion,
3
3
  getLogger
4
- } from "./chunk-OBDRKQQI.mjs";
4
+ } from "./chunk-VHWLLYKO.mjs";
5
5
  import {
6
6
  BASE_URL,
7
7
  __commonJS,
@@ -20845,7 +20845,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
20845
20845
  subQueries = decomp.subQueries;
20846
20846
  }
20847
20847
  }
20848
- const { recall: recall2 } = await import("./recall-CZFWWOVF.mjs");
20848
+ const { recall: recall2 } = await import("./recall-CGDEW2LQ.mjs");
20849
20849
  let recallDegraded = [];
20850
20850
  const result = await recall2(
20851
20851
  query,
@@ -32,6 +32,14 @@ function validateEndpointOverride(override) {
32
32
  return { valid: true, endpoint: trimmed.startsWith("/") ? trimmed : `/${trimmed}` };
33
33
  }
34
34
 
35
+ // src/lib/internalFlowMarker.ts
36
+ var INTERNAL_FLOW_MARKER = "Anuma internal first-party flow (not user chat).";
37
+ function withInternalFlowMarker(systemPrompt) {
38
+ if (systemPrompt.includes(INTERNAL_FLOW_MARKER)) return systemPrompt;
39
+ return `${INTERNAL_FLOW_MARKER}
40
+ ${systemPrompt}`;
41
+ }
42
+
35
43
  // src/lib/memory/portalLlm.ts
36
44
  function defaultBaseUrl() {
37
45
  return typeof process !== "undefined" && process.env?.ANUMA_PORTAL_BASE_URL || BASE_URL;
@@ -138,7 +146,12 @@ async function attemptPortalJson(req, endpoint) {
138
146
  const isAnthropic = req.model.startsWith("anthropic/");
139
147
  const prefill = isAnthropic ? "{" : "";
140
148
  const messages = [
141
- { role: "system", content: req.systemPrompt },
149
+ // Every caller of this helper is a first-party BACKGROUND op (fact extraction,
150
+ // topic sweep, consolidation, classifiers, graph traversal, query
151
+ // decomposition). Marking here — the one place they all funnel through — is what
152
+ // keeps the portal's detector reading them as genuine rather than markerless.
153
+ // See ../internalFlowMarker.
154
+ { role: "system", content: withInternalFlowMarker(req.systemPrompt) },
142
155
  { role: "user", content: req.userMessage }
143
156
  ];
144
157
  if (prefill) messages.push({ role: "assistant", content: prefill });
@@ -273,6 +286,8 @@ function extractCompletionContent(body) {
273
286
 
274
287
  export {
275
288
  getLogger,
289
+ INTERNAL_FLOW_MARKER,
290
+ withInternalFlowMarker,
276
291
  validateEndpointOverride,
277
292
  supportsResponseFormat,
278
293
  resolvePortalAuthHeaders,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  notifyConsolidationFallback,
3
3
  resolvePiiRedactor
4
- } from "./chunk-KF4HV3QE.mjs";
4
+ } from "./chunk-CR5P3YIK.mjs";
5
5
  import {
6
6
  callPortalJsonCompletion
7
- } from "./chunk-OBDRKQQI.mjs";
7
+ } from "./chunk-VHWLLYKO.mjs";
8
8
  import "./chunk-3RPGXXPZ.mjs";
9
9
 
10
10
  // src/lib/memory/consolidate.ts
@@ -17118,6 +17118,20 @@ var init_clientConfig = __esm({
17118
17118
  }
17119
17119
  });
17120
17120
 
17121
+ // src/lib/internalFlowMarker.ts
17122
+ function withInternalFlowMarker(systemPrompt) {
17123
+ if (systemPrompt.includes(INTERNAL_FLOW_MARKER)) return systemPrompt;
17124
+ return `${INTERNAL_FLOW_MARKER}
17125
+ ${systemPrompt}`;
17126
+ }
17127
+ var INTERNAL_FLOW_MARKER;
17128
+ var init_internalFlowMarker = __esm({
17129
+ "src/lib/internalFlowMarker.ts"() {
17130
+ "use strict";
17131
+ INTERNAL_FLOW_MARKER = "Anuma internal first-party flow (not user chat).";
17132
+ }
17133
+ });
17134
+
17121
17135
  // src/lib/db/entities/types.ts
17122
17136
  function normalizeEntityName(name) {
17123
17137
  return name.trim().toLowerCase();
@@ -20647,7 +20661,12 @@ async function attemptPortalJson(req, endpoint) {
20647
20661
  const isAnthropic = req.model.startsWith("anthropic/");
20648
20662
  const prefill = isAnthropic ? "{" : "";
20649
20663
  const messages = [
20650
- { role: "system", content: req.systemPrompt },
20664
+ // Every caller of this helper is a first-party BACKGROUND op (fact extraction,
20665
+ // topic sweep, consolidation, classifiers, graph traversal, query
20666
+ // decomposition). Marking here — the one place they all funnel through — is what
20667
+ // keeps the portal's detector reading them as genuine rather than markerless.
20668
+ // See ../internalFlowMarker.
20669
+ { role: "system", content: withInternalFlowMarker(req.systemPrompt) },
20651
20670
  { role: "user", content: req.userMessage }
20652
20671
  ];
20653
20672
  if (prefill) messages.push({ role: "assistant", content: prefill });
@@ -20785,6 +20804,7 @@ var init_portalLlm = __esm({
20785
20804
  "use strict";
20786
20805
  init_clientConfig();
20787
20806
  init_endpointOverride();
20807
+ init_internalFlowMarker();
20788
20808
  init_logger();
20789
20809
  RESPONSE_FORMAT_OK = /* @__PURE__ */ new Set(["openai", "inclusionai", "deepseek"]);
20790
20810
  RESPONSE_SCHEMA_OK = /* @__PURE__ */ new Set(["openai"]);
@@ -26726,6 +26746,7 @@ init_types2();
26726
26746
 
26727
26747
  // src/lib/chat/summarize.ts
26728
26748
  init_clientConfig();
26749
+ init_internalFlowMarker();
26729
26750
  init_logger();
26730
26751
  var DEFAULT_SUMMARY_TOKEN_THRESHOLD = 4e3;
26731
26752
  var DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES = 4;
@@ -26918,7 +26939,17 @@ async function callSummarizationLlm(prompt, model, token, baseUrl) {
26918
26939
  body: JSON.stringify({
26919
26940
  model,
26920
26941
  stream: false,
26921
- messages: [{ role: "user", content: prompt }]
26942
+ // The marker rides a system message because this call has no other
26943
+ // provenance: it posts to the MAIN chat endpoint (not /utility/*), carries no
26944
+ // conversationId, and its prompt is neither the app's chat base prompt nor any
26945
+ // registered flow fingerprint — so without this it reads as markerless, i.e.
26946
+ // as a scripted abuser. Progressive summarization runs for every free-tier
26947
+ // long conversation, so at the PORTAL_DETECTION_REJECT_MARKERLESS flip it
26948
+ // would 403 and silently fall back to verbatim history (context bloat + cost).
26949
+ messages: [
26950
+ { role: "system", content: INTERNAL_FLOW_MARKER },
26951
+ { role: "user", content: prompt }
26952
+ ]
26922
26953
  }),
26923
26954
  signal: controller.signal
26924
26955
  });
@@ -30605,6 +30636,7 @@ init_reranker();
30605
30636
 
30606
30637
  // src/lib/memory/synthesizeProfile.ts
30607
30638
  init_operations3();
30639
+ init_internalFlowMarker();
30608
30640
  init_logger();
30609
30641
  init_constants();
30610
30642
  init_embeddings();
@@ -30966,7 +30998,10 @@ async function synthesizeFacet(facet, ctx, options, prior) {
30966
30998
  limit,
30967
30999
  types: ["fact"],
30968
31000
  maxTokens: DEFAULT_FACET_MAX_TOKENS,
30969
- systemPrompt: buildFacetSystemPrompt(facet),
31001
+ // Profile-facet synthesis is a background op, so it marks its own prompt.
31002
+ // reflect() itself must NOT mark — it also serves the user's own questions,
31003
+ // and that traffic is chat, not an internal flow. See ../internalFlowMarker.
31004
+ systemPrompt: withInternalFlowMarker(buildFacetSystemPrompt(facet)),
30970
31005
  responseSchema: facetResponseSchema(facet.key),
30971
31006
  memories
30972
31007
  });
@@ -141,20 +141,22 @@ import {
141
141
  updateVaultMemoryOp,
142
142
  upsertMessageOp,
143
143
  vaultMemoryToStored
144
- } from "./chunk-BZEAYCBV.mjs";
144
+ } from "./chunk-TD7SMY7C.mjs";
145
145
  import {
146
146
  createStreamingDeAnonymizer,
147
147
  notifyConsolidationFallback,
148
148
  resolvePiiRedactor
149
- } from "./chunk-KF4HV3QE.mjs";
149
+ } from "./chunk-CR5P3YIK.mjs";
150
150
  import {
151
+ INTERNAL_FLOW_MARKER,
151
152
  callPortalJsonCompletion,
152
153
  extractJsonCandidate,
153
154
  getLogger,
154
155
  resolvePortalAuthHeaders,
155
156
  supportsResponseFormat,
156
- validateEndpointOverride
157
- } from "./chunk-OBDRKQQI.mjs";
157
+ validateEndpointOverride,
158
+ withInternalFlowMarker
159
+ } from "./chunk-VHWLLYKO.mjs";
158
160
  import {
159
161
  BASE_URL,
160
162
  __commonJS,
@@ -3411,7 +3413,17 @@ async function callSummarizationLlm(prompt, model, token, baseUrl) {
3411
3413
  body: JSON.stringify({
3412
3414
  model,
3413
3415
  stream: false,
3414
- messages: [{ role: "user", content: prompt }]
3416
+ // The marker rides a system message because this call has no other
3417
+ // provenance: it posts to the MAIN chat endpoint (not /utility/*), carries no
3418
+ // conversationId, and its prompt is neither the app's chat base prompt nor any
3419
+ // registered flow fingerprint — so without this it reads as markerless, i.e.
3420
+ // as a scripted abuser. Progressive summarization runs for every free-tier
3421
+ // long conversation, so at the PORTAL_DETECTION_REJECT_MARKERLESS flip it
3422
+ // would 403 and silently fall back to verbatim history (context bloat + cost).
3423
+ messages: [
3424
+ { role: "system", content: INTERNAL_FLOW_MARKER },
3425
+ { role: "user", content: prompt }
3426
+ ]
3415
3427
  }),
3416
3428
  signal: controller.signal
3417
3429
  });
@@ -5681,7 +5693,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
5681
5693
  content: m.content,
5682
5694
  similarity: m.similarity
5683
5695
  }));
5684
- const { consolidateMemory: doConsolidate } = await import("./consolidate-I6TOH7CB.mjs");
5696
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-FWYK5KXB.mjs");
5685
5697
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
5686
5698
  if (decision.action === "create") return null;
5687
5699
  if (decision.action === "supersede" && decision.content) {
@@ -7383,7 +7395,10 @@ async function synthesizeFacet(facet, ctx, options, prior) {
7383
7395
  limit,
7384
7396
  types: ["fact"],
7385
7397
  maxTokens: DEFAULT_FACET_MAX_TOKENS,
7386
- systemPrompt: buildFacetSystemPrompt(facet),
7398
+ // Profile-facet synthesis is a background op, so it marks its own prompt.
7399
+ // reflect() itself must NOT mark — it also serves the user's own questions,
7400
+ // and that traffic is chat, not an internal flow. See ../internalFlowMarker.
7401
+ systemPrompt: withInternalFlowMarker(buildFacetSystemPrompt(facet)),
7387
7402
  responseSchema: facetResponseSchema(facet.key),
7388
7403
  memories
7389
7404
  });
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-BZEAYCBV.mjs";
4
- import "./chunk-OBDRKQQI.mjs";
3
+ } from "./chunk-TD7SMY7C.mjs";
4
+ import "./chunk-VHWLLYKO.mjs";
5
5
  import "./chunk-3RPGXXPZ.mjs";
6
6
  export {
7
7
  recall
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "6.5.0",
3
+ "version": "6.6.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",