@yugenlab/vaayu 0.1.10 → 0.1.12

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 (53) hide show
  1. package/chunks/{agentic-tool-loop-2FZK72JO.js → agentic-tool-loop-NQESOBLC.js} +2 -2
  2. package/chunks/akasha-5C5Q6NMP.js +12 -0
  3. package/chunks/{chunk-JGI4SDWS.js → chunk-26K6DS6N.js} +7 -5
  4. package/chunks/chunk-5E3ZS5SW.js +529 -0
  5. package/chunks/{chunk-VJHNE47S.js → chunk-ARZCIITZ.js} +104 -94
  6. package/chunks/{chunk-PRXQW76U.js → chunk-EG37M4QL.js} +17 -6
  7. package/chunks/{chunk-HIYHTWFW.js → chunk-FEDPZOZ5.js} +572 -441
  8. package/chunks/{chunk-O4KV7TFP.js → chunk-GWYC7R2L.js} +38 -20
  9. package/chunks/chunk-H46F2Y6R.js +134 -0
  10. package/chunks/{chunk-M7THR63C.js → chunk-HXHDP2PZ.js} +78 -65
  11. package/chunks/chunk-KVQH4LE7.js +396 -0
  12. package/chunks/{chunk-TND3MU4Z.js → chunk-LJCT7UYP.js} +86 -68
  13. package/chunks/{chunk-OT4G2L46.js → chunk-M2RLX5LU.js} +229 -163
  14. package/chunks/{chunk-IGKYKEKT.js → chunk-NAQKA54E.js} +8 -2
  15. package/chunks/{chunk-77725AR7.js → chunk-PZ4AQ22L.js} +151 -57
  16. package/chunks/{chunk-C76USAC5.js → chunk-QFGAB4XD.js} +13 -5
  17. package/chunks/{chunk-MJ74G5RB.js → chunk-R273KC7J.js} +276 -3
  18. package/chunks/{chunk-JAWZ7ANC.js → chunk-RVKTGKFD.js} +12 -8
  19. package/chunks/{chunk-AGK3A7R7.js → chunk-TSOQ2CT3.js} +1430 -1173
  20. package/chunks/{chunk-YJRXLRTE.js → chunk-VEZ2DI2M.js} +24 -12
  21. package/chunks/{chunk-N22M7D4P.js → chunk-XP3NIH5F.js} +91 -98
  22. package/chunks/{chunk-6556EKOB.js → chunk-Y6IZH6FT.js} +42 -26
  23. package/chunks/{chunk-AS3DJFY3.js → chunk-YRTGGYJU.js} +45 -41
  24. package/chunks/{consolidation-indexer-VKQ6DNU3.js → consolidation-indexer-KPXORCJ4.js} +9 -9
  25. package/chunks/database-BX3LVYXS.js +11 -0
  26. package/chunks/{day-consolidation-BH3QU2SZ.js → day-consolidation-CR3TJFAL.js} +5 -5
  27. package/chunks/{src-Y3TGMINC.js → dist-ESCM3CP5.js} +31 -21
  28. package/chunks/graphrag-73XA7LBX.js +14 -0
  29. package/chunks/hierarchical-temporal-search-GHKVKNZ6.js +8 -0
  30. package/chunks/hybrid-search-OD756RDV.js +20 -0
  31. package/chunks/{memory-store-A6WOWLWC.js → memory-store-4GCBR2DZ.js} +4 -4
  32. package/chunks/periodic-consolidation-IINCHP6L.js +11 -0
  33. package/chunks/postgres-YLCUNVPQ.js +8 -0
  34. package/chunks/recall-64RROTUC.js +21 -0
  35. package/chunks/search-JVCDNTAJ.js +19 -0
  36. package/chunks/{session-store-3BRPGC6P.js → session-store-3EDQZEDS.js} +12 -6
  37. package/chunks/{sqlite-DHUQGPR5.js → sqlite-4N7YH2KK.js} +3 -3
  38. package/chunks/{src-6GVZTUH6.js → src-OPSDZEFI.js} +2 -2
  39. package/chunks/{suncalc-NOHGYHDU.js → suncalc-RM7URNUR.js} +2 -2
  40. package/chunks/{tree-RSHKDTCR.js → tree-FIUVGJ5J.js} +2 -2
  41. package/chunks/{vasana-engine-MU25OQ23.js → vasana-engine-W4PYWT5H.js} +5 -5
  42. package/gateway.js +38859 -30650
  43. package/package.json +1 -1
  44. package/pair-cli.js +2 -2
  45. package/chunks/chunk-U62ABYKD.js +0 -123
  46. package/chunks/chunk-UZ6OIVEC.js +0 -198
  47. package/chunks/graphrag-D7OXWAWD.js +0 -14
  48. package/chunks/hierarchical-temporal-search-PVHVA3NZ.js +0 -8
  49. package/chunks/hybrid-search-G2NAJKJ7.js +0 -20
  50. package/chunks/periodic-consolidation-LMYMNS4Q.js +0 -11
  51. package/chunks/postgres-WLH3D5HG.js +0 -8
  52. package/chunks/recall-ZNL4DJ2L.js +0 -21
  53. package/chunks/search-35JMSGUT.js +0 -19
@@ -2,7 +2,7 @@ import {
2
2
  __commonJS,
3
3
  __require,
4
4
  __toESM
5
- } from "./chunk-IGKYKEKT.js";
5
+ } from "./chunk-NAQKA54E.js";
6
6
 
7
7
  // ../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js
8
8
  var require_can_promise = __commonJS({
@@ -5802,15 +5802,288 @@ var TwitterAdapter = class {
5802
5802
  }
5803
5803
  };
5804
5804
 
5805
+ // packages/channels/src/tring.ts
5806
+ import { execSync } from "node:child_process";
5807
+ import { randomUUID } from "node:crypto";
5808
+ var TRING_PLATFORM_ALIASES = {
5809
+ whispr: "signal"
5810
+ };
5811
+ var normalizeTringPlatform = (value) => {
5812
+ const normalized = value.trim().toLowerCase();
5813
+ if (normalized in TRING_PLATFORM_ALIASES) return TRING_PLATFORM_ALIASES[normalized];
5814
+ if (normalized === "whatsapp" || normalized === "telegram" || normalized === "signal") {
5815
+ return normalized;
5816
+ }
5817
+ return void 0;
5818
+ };
5819
+ var TringAdapter = class _TringAdapter {
5820
+ id = "tring";
5821
+ options;
5822
+ onMessage;
5823
+ timer;
5824
+ isPolling = false;
5825
+ unsupportedPollPlatforms = /* @__PURE__ */ new Set();
5826
+ /** Per-platform cursor token returned by Tring message list/poll. */
5827
+ lastCursor = /* @__PURE__ */ new Map();
5828
+ /** Per-platform fallback lower bound in unix seconds when cursor is unavailable. */
5829
+ lastSince = /* @__PURE__ */ new Map();
5830
+ /** Recent message identities for local de-duplication when daemon lacks `since`. */
5831
+ recentMessageKeys = /* @__PURE__ */ new Map();
5832
+ constructor(options, onMessage) {
5833
+ const normalizedPlatforms = options.platforms.map((platform) => normalizeTringPlatform(platform)).filter((platform) => Boolean(platform)).filter((platform, index, list) => list.indexOf(platform) === index);
5834
+ this.options = {
5835
+ ...options,
5836
+ platforms: normalizedPlatforms
5837
+ };
5838
+ this.onMessage = onMessage;
5839
+ }
5840
+ /** Start the adapter: verify daemon health, optionally spawn it, begin polling. */
5841
+ async start() {
5842
+ if (this.timer) return;
5843
+ const healthy = await this.health();
5844
+ if (!healthy && this.options.autoStartDaemon) {
5845
+ const bin = this.options.tringBin ?? _TringAdapter.detectTringBin();
5846
+ if (bin) {
5847
+ try {
5848
+ execSync(`${bin} daemon start`, { stdio: "ignore", timeout: 5e3 });
5849
+ } catch {
5850
+ }
5851
+ }
5852
+ }
5853
+ this.timer = setInterval(() => {
5854
+ void this.pollOnce();
5855
+ }, this.options.pollIntervalMs);
5856
+ }
5857
+ /** Stop polling. Does NOT kill the daemon. */
5858
+ stop() {
5859
+ if (this.timer) {
5860
+ clearInterval(this.timer);
5861
+ this.timer = void 0;
5862
+ }
5863
+ }
5864
+ /**
5865
+ * Send a text message through the Tring daemon.
5866
+ * @param platform Target platform (whatsapp, telegram, signal).
5867
+ * @param chatId Destination chat identifier.
5868
+ * @param text Message body.
5869
+ */
5870
+ async sendMessage(platform, chatId, text) {
5871
+ const canonical = normalizeTringPlatform(platform);
5872
+ if (!canonical) {
5873
+ throw new Error(`unsupported tring platform: ${platform}`);
5874
+ }
5875
+ await this.rpc("message.send", { platform: canonical, chat_id: chatId, text });
5876
+ }
5877
+ /** Check daemon health. Returns `true` if the daemon is reachable and healthy. */
5878
+ async health() {
5879
+ try {
5880
+ const res = await this.rpc("platform.health", {});
5881
+ return res?.ok === true;
5882
+ } catch {
5883
+ return false;
5884
+ }
5885
+ }
5886
+ /**
5887
+ * Auto-detect the tring CLI binary on the local system.
5888
+ * Searches common install paths.
5889
+ */
5890
+ static detectTringBin() {
5891
+ const paths = [
5892
+ "tring",
5893
+ `${process.env["HOME"] ?? ""}/.local/bin/tring`,
5894
+ "/usr/local/bin/tring"
5895
+ ];
5896
+ for (const p of paths) {
5897
+ try {
5898
+ execSync(`which ${p}`, { stdio: "ignore" });
5899
+ return p;
5900
+ } catch {
5901
+ }
5902
+ }
5903
+ return void 0;
5904
+ }
5905
+ // ── Private ──────────────────────────────────────────────────────────
5906
+ /** Poll all configured platforms once for new messages. */
5907
+ async pollOnce() {
5908
+ if (this.isPolling) return;
5909
+ this.isPolling = true;
5910
+ try {
5911
+ for (const platform of this.options.platforms) {
5912
+ const params = {
5913
+ platform,
5914
+ direction: "incoming"
5915
+ };
5916
+ const cursor = this.lastCursor.get(platform);
5917
+ const since = this.lastSince.get(platform);
5918
+ if (cursor) {
5919
+ params["cursor"] = cursor;
5920
+ } else if (since && since > 0) {
5921
+ params["since"] = since;
5922
+ }
5923
+ let res;
5924
+ if (this.unsupportedPollPlatforms.has(platform)) {
5925
+ res = await this.rpc("message.list", params);
5926
+ } else {
5927
+ const pollRes = await this.rpc("message.poll", params);
5928
+ if (pollRes.ok) {
5929
+ res = pollRes;
5930
+ } else if (this.shouldFallbackToList(pollRes.error)) {
5931
+ this.unsupportedPollPlatforms.add(platform);
5932
+ res = await this.rpc("message.list", params);
5933
+ } else {
5934
+ res = pollRes;
5935
+ }
5936
+ }
5937
+ const { messages, cursor: nextCursor } = this.extractMessages(res?.data);
5938
+ if (nextCursor) this.lastCursor.set(platform, nextCursor);
5939
+ this.pruneRecentMessageKeys();
5940
+ let maxSeenSince = since ?? 0;
5941
+ for (const raw of messages) {
5942
+ if (this.isDuplicate(platform, raw)) continue;
5943
+ if (this.options.allowedChats?.length) {
5944
+ if (!this.options.allowedChats.includes(raw.chat_id)) continue;
5945
+ }
5946
+ const normalized = this.normalize(platform, raw);
5947
+ if (normalized) {
5948
+ await this.onMessage(normalized);
5949
+ }
5950
+ const ts = this.toUnixSeconds(raw.timestamp);
5951
+ if (ts > maxSeenSince) maxSeenSince = ts;
5952
+ }
5953
+ if (maxSeenSince > 0) this.lastSince.set(platform, maxSeenSince);
5954
+ }
5955
+ } finally {
5956
+ this.isPolling = false;
5957
+ }
5958
+ }
5959
+ /** Normalize a Tring raw message into a NormalizedMessage. */
5960
+ normalize(platform, raw) {
5961
+ const normalizedPlatform = normalizeTringPlatform(raw.platform ?? platform);
5962
+ if (!normalizedPlatform) return null;
5963
+ const body = raw.body_text ?? raw.body;
5964
+ if (!body) return null;
5965
+ const userId = raw.user_id ?? raw.sender_id ?? raw.chat_id;
5966
+ const channel = normalizedPlatform;
5967
+ return {
5968
+ channel,
5969
+ chatId: raw.chat_id,
5970
+ userId,
5971
+ chatType: raw.chat_type ?? "dm",
5972
+ threadId: raw.thread_id,
5973
+ text: body,
5974
+ time: this.toIsoTimestamp(raw.timestamp),
5975
+ raw
5976
+ };
5977
+ }
5978
+ /** Extract messages/cursor from both legacy (`data: []`) and current payloads. */
5979
+ extractMessages(data) {
5980
+ if (Array.isArray(data)) return { messages: data };
5981
+ if (!data) return { messages: [] };
5982
+ return {
5983
+ messages: Array.isArray(data.messages) ? data.messages : [],
5984
+ cursor: typeof data.cursor === "string" && data.cursor.length > 0 ? data.cursor : void 0
5985
+ };
5986
+ }
5987
+ /** Convert epoch seconds/milliseconds into ISO timestamp. */
5988
+ toIsoTimestamp(value) {
5989
+ const millis = value > 1e10 ? value : value * 1e3;
5990
+ return new Date(millis).toISOString();
5991
+ }
5992
+ /** Convert epoch seconds/milliseconds to unix seconds. */
5993
+ toUnixSeconds(value) {
5994
+ return value > 1e10 ? Math.floor(value / 1e3) : value;
5995
+ }
5996
+ /** Prune dedupe cache to avoid unbounded growth. */
5997
+ pruneRecentMessageKeys() {
5998
+ const cutoff = Date.now() - 10 * 6e4;
5999
+ for (const [key, seenAt] of this.recentMessageKeys.entries()) {
6000
+ if (seenAt < cutoff) this.recentMessageKeys.delete(key);
6001
+ }
6002
+ }
6003
+ /** Return true when this inbound record was already observed in recent polls. */
6004
+ isDuplicate(platform, raw) {
6005
+ const identity = raw.platform_message_id || raw.id || `${raw.chat_id}:${raw.sender_id ?? raw.user_id ?? ""}:${raw.timestamp}:${raw.body ?? ""}`;
6006
+ const key = `${platform}:${identity}`;
6007
+ const now = Date.now();
6008
+ if (this.recentMessageKeys.has(key)) return true;
6009
+ this.recentMessageKeys.set(key, now);
6010
+ return false;
6011
+ }
6012
+ shouldFallbackToList(error) {
6013
+ if (!error) return false;
6014
+ const code = this.extractErrorCode(error);
6015
+ if (!code) return false;
6016
+ return code.includes("PLATFORM_FEATURE_UNSUPPORTED") || code.includes("METHOD_NOT_FOUND") || code.includes("INVALID_ARGUMENT") || code.includes("NOT_FOUND");
6017
+ }
6018
+ extractErrorCode(error) {
6019
+ if (typeof error === "string") return error;
6020
+ return error.code;
6021
+ }
6022
+ /**
6023
+ * Inline JSON-RPC client. Posts a command to the Tring daemon.
6024
+ * Retries once on connection failure after a 1 second delay.
6025
+ */
6026
+ async rpc(command, params) {
6027
+ const url = `${this.options.daemonUrl}/rpc`;
6028
+ const body = JSON.stringify({
6029
+ request_id: randomUUID(),
6030
+ command,
6031
+ params
6032
+ });
6033
+ const headers = { "content-type": "application/json" };
6034
+ const attempt = async () => {
6035
+ const res = await fetch(url, { method: "POST", headers, body });
6036
+ const contentType = res.headers.get("content-type")?.toLowerCase() ?? "";
6037
+ const payloadText = await res.text();
6038
+ const preview = payloadText.length > 512 ? `${payloadText.slice(0, 512)}...` : payloadText;
6039
+ if (!res.ok) {
6040
+ return {
6041
+ ok: false,
6042
+ error: `http_${res.status}_${res.statusText}: ${preview}`
6043
+ };
6044
+ }
6045
+ if (!contentType.includes("application/json")) {
6046
+ return {
6047
+ ok: false,
6048
+ error: `non_json_response_${contentType || "unknown"}: ${preview}`
6049
+ };
6050
+ }
6051
+ try {
6052
+ return JSON.parse(payloadText);
6053
+ } catch (parseError) {
6054
+ return {
6055
+ ok: false,
6056
+ error: `json_parse_failed_${parseError instanceof Error ? parseError.message : String(parseError)}: ${preview}`
6057
+ };
6058
+ }
6059
+ };
6060
+ try {
6061
+ return await attempt();
6062
+ } catch (firstError) {
6063
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
6064
+ try {
6065
+ return await attempt();
6066
+ } catch (retryError) {
6067
+ console.warn("[vaayu] tring rpc failed", {
6068
+ command,
6069
+ message: retryError instanceof Error ? retryError.message : String(retryError)
6070
+ });
6071
+ return { ok: false, error: "connection_failed" };
6072
+ }
6073
+ }
6074
+ }
6075
+ };
6076
+
5805
6077
  export {
6078
+ require_lib,
5806
6079
  TelegramAdapter,
5807
6080
  WhatsAppAdapter,
5808
6081
  IMessageAdapter,
5809
6082
  TwitterAdapter,
6083
+ TringAdapter,
5810
6084
  generateMantra,
5811
6085
  validateMantra,
5812
- require_lib,
5813
6086
  renderPairDisplay,
5814
6087
  renderPairStatus
5815
6088
  };
5816
- //# sourceMappingURL=chunk-MJ74G5RB.js.map
6089
+ //# sourceMappingURL=chunk-R273KC7J.js.map
@@ -1,4 +1,4 @@
1
- // ../chitragupta/packages/smriti/src/graphrag-scoring.ts
1
+ // ../chitragupta/packages/smriti/dist/graphrag-scoring.js
2
2
  var ALPHA = 0.6;
3
3
  var BETA = 0.25;
4
4
  var GAMMA = 0.15;
@@ -39,7 +39,8 @@ var STOP_WORDS = /* @__PURE__ */ new Set([
39
39
  "no"
40
40
  ]);
41
41
  function cosineSimilarity(a, b) {
42
- if (a.length !== b.length) return 0;
42
+ if (a.length !== b.length)
43
+ return 0;
43
44
  let dotProduct = 0;
44
45
  let normA = 0;
45
46
  let normB = 0;
@@ -49,11 +50,12 @@ function cosineSimilarity(a, b) {
49
50
  normB += b[i] * b[i];
50
51
  }
51
52
  const denominator = Math.sqrt(normA) * Math.sqrt(normB);
52
- if (denominator === 0) return 0;
53
+ if (denominator === 0)
54
+ return 0;
53
55
  return dotProduct / denominator;
54
56
  }
55
57
  function estimateTokens(text) {
56
- return Math.ceil(text.length / 4);
58
+ return Math.ceil(text.length / 3.7);
57
59
  }
58
60
  function tokenize(text) {
59
61
  return text.toLowerCase().replace(/[^a-z0-9\s]/g, " ").split(/\s+/).filter((t) => t.length >= 2 && !STOP_WORDS.has(t));
@@ -61,7 +63,8 @@ function tokenize(text) {
61
63
  function textMatchScore(query, docText) {
62
64
  const queryTokens = tokenize(query);
63
65
  const docTokens = tokenize(docText);
64
- if (queryTokens.length === 0 || docTokens.length === 0) return 0;
66
+ if (queryTokens.length === 0 || docTokens.length === 0)
67
+ return 0;
65
68
  const docTf = /* @__PURE__ */ new Map();
66
69
  for (const token of docTokens) {
67
70
  docTf.set(token, (docTf.get(token) ?? 0) + 1);
@@ -81,7 +84,7 @@ function textMatchScore(query, docText) {
81
84
  return Math.min(score, 1);
82
85
  }
83
86
 
84
- // ../chitragupta/packages/smriti/src/embedding-service.ts
87
+ // ../chitragupta/packages/smriti/dist/embedding-service.js
85
88
  var FALLBACK_DIM = 384;
86
89
  var DEFAULT_MAX_CACHE = 5e3;
87
90
  var MAX_CACHE_CEILING = 2e4;
@@ -155,7 +158,8 @@ var EmbeddingService = class {
155
158
  async getEmbedding(text) {
156
159
  const cacheKey = fnv1aHash(text);
157
160
  const cached = this.cache.get(cacheKey);
158
- if (cached) return cached;
161
+ if (cached)
162
+ return cached;
159
163
  let vector;
160
164
  if (this.provider) {
161
165
  if (this.providerAvailable === null) {
@@ -205,4 +209,4 @@ export {
205
209
  fallbackEmbedding,
206
210
  EmbeddingService
207
211
  };
208
- //# sourceMappingURL=chunk-JAWZ7ANC.js.map
212
+ //# sourceMappingURL=chunk-RVKTGKFD.js.map