@ours.network/tg-connector 2.0.0 → 2.0.2

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 (2) hide show
  1. package/dist/connector.js +17 -14
  2. package/package.json +4 -4
package/dist/connector.js CHANGED
@@ -26208,7 +26208,7 @@ var L = 100 * 1024 * 1024;
26208
26208
  var K = { brokerUrl: "wss://broker1.ours.network", port: 3050, stateDir: E(T(), ".ours"), gcIntervalMs: 36e5, historyMaxBytes: L, apiVisibility: "owner", apiAuthMode: "legacy" };
26209
26209
  var $ = "daemon-token";
26210
26210
 
26211
- // node_modules/@ours.network/sdk/dist/chunk-XMDIJ6DK.js
26211
+ // node_modules/@ours.network/sdk/dist/chunk-HQL2UEEU.js
26212
26212
  import { homedir as Te } from "node:os";
26213
26213
  import { isAbsolute as Oe, join as Se, resolve as ue } from "node:path";
26214
26214
  import { randomBytes as W } from "node:crypto";
@@ -26387,7 +26387,7 @@ var F = class {
26387
26387
  if (!h.ok) throw new U(h.status);
26388
26388
  if (!h.body || !h.headers.get("content-type")?.startsWith("text/event-stream")) throw new Error("Invalid resource stream response");
26389
26389
  l = h.body.getReader(), i.addEventListener("abort", g, { once: true }), i.aborted && g();
26390
- let T2 = new TextDecoder("utf-8", { fatal: true }), v2 = "", b2 = 0, _ = false, R2, O2 = -1;
26390
+ let T2 = new TextDecoder("utf-8", { fatal: true }), v2 = "", b2 = 0, _ = false, A2, O2 = -1;
26391
26391
  for (; ; ) {
26392
26392
  let { value: ie, done: be } = await l.read();
26393
26393
  if (c(), be) throw new Error("Resource stream ended before disposal");
@@ -26401,16 +26401,16 @@ var F = class {
26401
26401
  let oe = j.split(/\r?\n/).filter((k) => k.startsWith("data:")).map((k) => k.slice(5).trimStart()).join(`
26402
26402
  `);
26403
26403
  if (!oe) continue;
26404
- let A2 = JSON.parse(oe);
26404
+ let R2 = JSON.parse(oe);
26405
26405
  if (c(), j.split(/\r?\n/).some((k) => k === "event: auth_required")) throw new U(401);
26406
- le(A2);
26407
- let K2 = A2.kind;
26406
+ le(R2);
26407
+ let K2 = R2.kind;
26408
26408
  if (!["ready", "committed", "coverage", "resync"].includes(K2)) throw new Error("Invalid resource frame kind");
26409
- if (R2 !== void 0 && (A2.producerGeneration !== R2 || A2.position < O2)) throw new Error("Resource stream continuity changed");
26410
- if (R2 = A2.producerGeneration, O2 = A2.position, K2 === "ready") _ = true, a(45e3);
26409
+ if (A2 !== void 0 && (R2.producerGeneration !== A2 || R2.position < O2)) throw new Error("Resource stream continuity changed");
26410
+ if (A2 = R2.producerGeneration, O2 = R2.position, K2 === "ready") _ = true, a(45e3);
26411
26411
  else if (_) a(45e3);
26412
26412
  else if (K2 !== "resync") throw new Error("Resource mutation before ready");
26413
- yield A2, c();
26413
+ yield R2, c();
26414
26414
  }
26415
26415
  if (Buffer.byteLength(v2) > 512 * 1024) throw new Error("Resource frame exceeds limit");
26416
26416
  }
@@ -26564,6 +26564,9 @@ var F = class {
26564
26564
  getHistorySummary(t) {
26565
26565
  return this.post("getHistorySummary", t);
26566
26566
  }
26567
+ getContactActivity() {
26568
+ return this.post("getContactActivity", {});
26569
+ }
26567
26570
  listFiles(t = {}) {
26568
26571
  return this.post("listFiles", t);
26569
26572
  }
@@ -26687,14 +26690,14 @@ var x = class extends Error {
26687
26690
  super(`Invalid gateway client profile: ${t}. Configure ~/.ours-client/profile.json with ours-install client; no local service fallback is permitted.`), this.name = "ClientProfileError";
26688
26691
  }
26689
26692
  };
26690
- function Re(e2 = process.env) {
26693
+ function Ae(e2 = process.env) {
26691
26694
  if (e2.OURS_CONFIG !== void 0) {
26692
26695
  if (!e2.OURS_CONFIG.trim()) throw new x("OURS_CONFIG must name a client profile");
26693
26696
  return ue(e2.OURS_CONFIG);
26694
26697
  }
26695
26698
  return Se(e2.HOME || Te(), ".ours-client", "profile.json");
26696
26699
  }
26697
- function Ae(e2) {
26700
+ function Re(e2) {
26698
26701
  let t = (o) => {
26699
26702
  throw new x(o);
26700
26703
  };
@@ -26717,13 +26720,13 @@ function Ae(e2) {
26717
26720
  return typeof n.expectedInstanceId != "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(n.expectedInstanceId) ? t("expectedInstanceId must be a lowercase UUID") : typeof n.credentialPath != "string" || !Oe(n.credentialPath) || ue(n.credentialPath) !== n.credentialPath ? t("credentialPath must be an absolute normalized path") : Object.freeze({ serverUrl: r, endpoint: i, expectedInstanceId: n.expectedInstanceId, credentialPath: n.credentialPath });
26718
26721
  }
26719
26722
  function pe(e2 = process.env) {
26720
- let t = Re(e2), n;
26723
+ let t = Ae(e2), n;
26721
26724
  try {
26722
26725
  n = JSON.parse(m(t).toString("utf8"));
26723
26726
  } catch {
26724
26727
  throw new x("selected profile is missing, invalid JSON or unsafe; require a 0700 directory and a 0600 regular file");
26725
26728
  }
26726
- let r = Ae(n);
26729
+ let r = Re(n);
26727
26730
  if (["OURS_PORT", "OURS_STATE_DIR", "OURS_API_TOKEN", "OURS_DAEMON_ID", "OURS_DAEMON_URL", "OURS_DAEMON_CREDENTIAL_PATH"].some((o) => e2[o]?.trim())) throw new x("remove legacy OURS_PORT/STATE_DIR/API_TOKEN/DAEMON_ID/DAEMON_URL/DAEMON_CREDENTIAL_PATH environment selectors");
26728
26731
  return Object.freeze({ ...r, configPath: t });
26729
26732
  }
@@ -26890,8 +26893,8 @@ async function Q(e2 = {}) {
26890
26893
  {
26891
26894
  let b2 = await globalThis.fetch(p(h, "/selection"), { signal: s ? AbortSignal.any([s, AbortSignal.timeout(5e3)]) : AbortSignal.timeout(5e3), redirect: "error" }), _ = await C(b2);
26892
26895
  if (!b2.ok || !_ || Object.keys(_).length !== 3 || Object.keys(_).some((O2) => !["schema", "instanceId", "capabilities"].includes(O2)) || _.schema !== 1 || _.instanceId !== a) throw new Error("Daemon instance selection metadata is absent, incompatible or mismatched");
26893
- let R2 = _.capabilities;
26894
- if (!Array.isArray(R2) || R2.some((O2) => typeof O2 != "string") || T2.some((O2) => !R2.includes(O2))) throw new Error("Daemon does not support the required capabilities; refusing local-mode fallback");
26896
+ let A2 = _.capabilities;
26897
+ if (!Array.isArray(A2) || A2.some((O2) => typeof O2 != "string") || T2.some((O2) => !A2.includes(O2))) throw new Error("Daemon does not support the required capabilities; refusing local-mode fallback");
26895
26898
  }
26896
26899
  let v2 = l === void 0 ? y2 : S(l);
26897
26900
  if (typeof v2 != "string" || !v2.trim()) throw new Error("Instance selection requires an explicit API token after daemon verification");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ours.network/tg-connector",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Bridge Telegram bots to ours.network agents \u2014 attaches to an already-running ours daemon and bridges one Telegram chat/topic to one agent per route. Run `ours-tg-connector add_new_connection`.",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-Apache-2.0",
@@ -37,15 +37,15 @@
37
37
  "test:v1-lifecycle": "node tests/v1-lifecycle.integration.mjs cli"
38
38
  },
39
39
  "dependencies": {
40
- "@ours.network/sdk": "5.0.0",
40
+ "@ours.network/sdk": "5.1.0",
41
41
  "undici": "^7.28.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@ours.network/cli": "4.0.0",
44
+ "@ours.network/cli": "4.0.1",
45
45
  "@types/node": "^20.14.0",
46
46
  "esbuild": "^0.24.2",
47
47
  "tsx": "^4.19.0",
48
48
  "typescript": "^5.5.4",
49
- "@ours.network/daemon": "5.0.0"
49
+ "@ours.network/daemon": "5.0.1"
50
50
  }
51
51
  }