@subcortex-ai/sdk 0.3.7 → 0.3.9

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
@@ -1035,7 +1035,7 @@ ${connectedPeople.map((p) => {
1035
1035
  agent_id: "sdk",
1036
1036
  tenant_id: this.tenantId,
1037
1037
  candidates,
1038
- ...input.sessionId ? { context: { sessionId: input.sessionId } } : {}
1038
+ ...input.sessionId ? { context: { session_id: input.sessionId } } : {}
1039
1039
  });
1040
1040
  return { success: true };
1041
1041
  }
@@ -1535,7 +1535,12 @@ var IntakeNamespace = class {
1535
1535
  provenance: c.provenance,
1536
1536
  person_name: c.personName
1537
1537
  })),
1538
- context: input.context
1538
+ context: input.context ? {
1539
+ topic: input.context.topic,
1540
+ emotional_state: input.context.emotionalState,
1541
+ session_id: input.context.sessionId,
1542
+ excerpt: input.context.excerpt
1543
+ } : void 0
1539
1544
  });
1540
1545
  }
1541
1546
  /** Get pending intake results for an agent. */
@@ -1974,16 +1979,25 @@ function toContextXml(user, options = {}) {
1974
1979
  if (knowledge.length > 0) {
1975
1980
  lines.push(` <knowledge count="${knowledge.length}">`);
1976
1981
  for (const mem of knowledge) {
1982
+ if (mem.predicate.startsWith("signal:")) {
1983
+ const sigType = mem.predicate.slice(7);
1984
+ const val = mem.value;
1985
+ const content = typeof val === "object" && val?.content ? String(val.content) : formatValue(mem.value);
1986
+ const intensity = typeof val === "object" && val?.intensity ? Number(val.intensity) : mem.confidence;
1987
+ const about = typeof val === "object" && val?.aboutSubject ? ` about="${esc(String(val.aboutSubject))}"` : "";
1988
+ lines.push(` <signal type="${esc(sigType)}" intensity="${fmtConf(intensity)}"${about}>${esc(content)}</signal>`);
1989
+ continue;
1990
+ }
1977
1991
  const memSignals = findSignalsForFact(mem, signalsByAbout);
1978
1992
  if (memSignals.length > 0) {
1979
1993
  lines.push(` <fact predicate="${esc(mem.predicate)}" confidence="${fmtConf(mem.confidence)}">`);
1980
- lines.push(` ${esc(String(mem.value))}`);
1994
+ lines.push(` ${esc(formatValue(mem.value))}`);
1981
1995
  for (const sig of memSignals) {
1982
1996
  lines.push(` ${renderSignal(sig)}`);
1983
1997
  }
1984
1998
  lines.push(` </fact>`);
1985
1999
  } else {
1986
- lines.push(` <fact predicate="${esc(mem.predicate)}" confidence="${fmtConf(mem.confidence)}">${esc(String(mem.value))}</fact>`);
2000
+ lines.push(` <fact predicate="${esc(mem.predicate)}" confidence="${fmtConf(mem.confidence)}">${esc(formatValue(mem.value))}</fact>`);
1987
2001
  }
1988
2002
  }
1989
2003
  lines.push(` </knowledge>`);
@@ -2025,6 +2039,12 @@ function findSignalsForFact(fact, signalsByAbout) {
2025
2039
  }
2026
2040
  return results;
2027
2041
  }
2042
+ function formatValue(v) {
2043
+ if (v === null || v === void 0) return "";
2044
+ if (typeof v === "string") return v;
2045
+ if (typeof v === "object" && "content" in v) return String(v.content);
2046
+ return JSON.stringify(v);
2047
+ }
2028
2048
  function fmtConf(n) {
2029
2049
  return n.toFixed(2);
2030
2050
  }