@ai-matrx/meet 0.7.8 → 0.7.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.d.cts CHANGED
@@ -1188,6 +1188,7 @@ declare const MEET_ANSWER_EVENTS: {
1188
1188
  };
1189
1189
  /** The `info` event carrying what the answer was built from. */
1190
1190
  declare const MEET_ANSWER_CONTEXT_EVENT = "meet_intelligence_context";
1191
+
1191
1192
  interface ServerRefusal {
1192
1193
  readonly reason: string;
1193
1194
  readonly remedy: string;
package/dist/index.d.ts CHANGED
@@ -1188,6 +1188,7 @@ declare const MEET_ANSWER_EVENTS: {
1188
1188
  };
1189
1189
  /** The `info` event carrying what the answer was built from. */
1190
1190
  declare const MEET_ANSWER_CONTEXT_EVENT = "meet_intelligence_context";
1191
+
1191
1192
  interface ServerRefusal {
1192
1193
  readonly reason: string;
1193
1194
  readonly remedy: string;
package/dist/index.js CHANGED
@@ -23,6 +23,20 @@ var MeetError = class extends Error {
23
23
  return this.code === "permission-denied" || this.code === "device-not-found" || this.code === "device-in-use" || this.code === "insecure-context";
24
24
  }
25
25
  };
26
+ var SERVER_FAILED_SENTENCE = "The server hit an unexpected problem and nothing was changed.";
27
+ function isRawServerText(value) {
28
+ const text3 = value.trim();
29
+ return /^internal server error\b/i.test(text3) || /^[A-Z][A-Za-z0-9]*(Error|Exception)$/.test(text3) || /^[a-z][a-z0-9]*(_[a-z0-9]+)+$/.test(text3);
30
+ }
31
+ function humanDatabaseSentence(message) {
32
+ const text3 = message.trim();
33
+ if (text3.length === 0 || isRawServerText(text3)) return null;
34
+ if (/permission denied for|violates|relation "|does not exist|syntax error|column "|jwt|pgrst|duplicate key|null value in/i.test(
35
+ text3
36
+ ))
37
+ return null;
38
+ return text3;
39
+ }
26
40
  var FORBIDDEN_CODES = /* @__PURE__ */ new Set(["42501", "PGRST301", "PGRST302"]);
27
41
  var NOT_FOUND_CODES = /* @__PURE__ */ new Set(["PGRST116", "PGRST205"]);
28
42
  var CONFLICT_CODES = /* @__PURE__ */ new Set(["23505", "40001", "55000"]);
@@ -50,8 +64,8 @@ function normalizeMeetError(error, operation) {
50
64
  if (code !== void 0 && FORBIDDEN_CODES.has(code)) {
51
65
  return new MeetError(
52
66
  "forbidden",
53
- `${operation}: denied by the database (${code}: ${message})`,
54
- "Authorization is RLS plus auth-checked RPCs (R5). Fix the policy or the caller's membership \u2014 never route around it with a service-role client in a browser.",
67
+ humanDatabaseSentence(message) ?? "You don't have access to do that in this meeting.",
68
+ "Ask the meeting's host to do it, or to give you access.",
55
69
  error
56
70
  );
57
71
  }
@@ -66,15 +80,16 @@ function normalizeMeetError(error, operation) {
66
80
  if (code !== void 0 && CONFLICT_CODES.has(code)) {
67
81
  return new MeetError(
68
82
  "conflict",
69
- `${operation}: unique violation (${code}: ${message})`,
70
- "A concurrent writer won. Re-read the meeting rather than retrying the insert \u2014 for a call invite this is the idempotency key doing its job.",
83
+ humanDatabaseSentence(message) ?? "This meeting changed a moment ago, so nothing was saved.",
84
+ "Reload to see the latest, then try again.",
71
85
  error
72
86
  );
73
87
  }
88
+ const hint = error?.hint;
74
89
  return new MeetError(
75
90
  "transport",
76
- `${operation}: ${message}`,
77
- "Transient transport failure. Reads retry once; a join failure surfaces to the room phase as `failed` with this message rather than hanging on a spinner.",
91
+ /failed to fetch|networkerror|load failed|network request failed/i.test(message) ? "The server could not be reached." : humanDatabaseSentence(message) ?? SERVER_FAILED_SENTENCE,
92
+ typeof hint === "string" && humanDatabaseSentence(hint) !== null ? hint.trim() : "Nothing was changed \u2014 retry in a moment; if it keeps happening, reload the page.",
78
93
  error
79
94
  );
80
95
  }
@@ -482,11 +497,6 @@ function readText(data) {
482
497
  }
483
498
  return "";
484
499
  }
485
- var SERVER_FAILED_SENTENCE = "The server hit an unexpected problem and nothing was changed.";
486
- function isRawServerText(value) {
487
- const text3 = value.trim();
488
- return /^internal server error\b/i.test(text3) || /^[A-Z][A-Za-z0-9]*(Error|Exception)$/.test(text3) || /^[a-z][a-z0-9]*(_[a-z0-9]+)+$/.test(text3);
489
- }
490
500
  async function refusalFromResponse(response, operation, fallbackRemedy) {
491
501
  let body = null;
492
502
  try {