@burdenoff/fe-libs 2026.1009.2 → 2026.1010.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 (58) hide show
  1. package/dist/shared/assistant/appControls/grammar.js +48 -41
  2. package/dist/shared/assistant/appControls/languages.d.ts +2 -0
  3. package/dist/shared/assistant/appControls/languages.js +8 -5
  4. package/dist/shared/assistant/index.d.ts +18 -0
  5. package/dist/shared/assistant/localUiCommands.d.ts +33 -0
  6. package/dist/shared/assistant/localUiCommands.js +159 -88
  7. package/dist/shared/assistant/localeCommands/active.d.ts +19 -0
  8. package/dist/shared/assistant/localeCommands/active.js +25 -0
  9. package/dist/shared/assistant/localeCommands/assent.d.ts +25 -0
  10. package/dist/shared/assistant/localeCommands/assent.js +78 -0
  11. package/dist/shared/assistant/localeCommands/engine.d.ts +89 -0
  12. package/dist/shared/assistant/localeCommands/engine.js +351 -0
  13. package/dist/shared/assistant/localeCommands/evaluate.d.ts +77 -0
  14. package/dist/shared/assistant/localeCommands/evaluate.js +180 -0
  15. package/dist/shared/assistant/localeCommands/fold.d.ts +17 -0
  16. package/dist/shared/assistant/localeCommands/fold.js +66 -0
  17. package/dist/shared/assistant/localeCommands/frames.d.ts +23 -0
  18. package/dist/shared/assistant/localeCommands/frames.js +150 -0
  19. package/dist/shared/assistant/localeCommands/gate.d.ts +37 -0
  20. package/dist/shared/assistant/localeCommands/gate.js +137 -0
  21. package/dist/shared/assistant/localeCommands/languageNames.d.ts +11 -0
  22. package/dist/shared/assistant/localeCommands/languageNames.js +53 -0
  23. package/dist/shared/assistant/localeCommands/nameForms.d.ts +21 -0
  24. package/dist/shared/assistant/localeCommands/nameForms.js +44 -0
  25. package/dist/shared/assistant/localeCommands/normalise.d.ts +49 -0
  26. package/dist/shared/assistant/localeCommands/normalise.js +87 -0
  27. package/dist/shared/assistant/localeCommands/symbols.d.ts +8 -0
  28. package/dist/shared/assistant/localeCommands/symbols.js +6 -0
  29. package/dist/shared/assistant/localeCommands/tables/ar.d.ts +10 -0
  30. package/dist/shared/assistant/localeCommands/tables/ar.js +343 -0
  31. package/dist/shared/assistant/localeCommands/tables/en.d.ts +12 -0
  32. package/dist/shared/assistant/localeCommands/tables/en.js +28 -0
  33. package/dist/shared/assistant/localeCommands/tables/es.d.ts +7 -0
  34. package/dist/shared/assistant/localeCommands/tables/es.js +356 -0
  35. package/dist/shared/assistant/localeCommands/tables/hi.d.ts +9 -0
  36. package/dist/shared/assistant/localeCommands/tables/hi.js +495 -0
  37. package/dist/shared/assistant/localeCommands/tables/ta.d.ts +10 -0
  38. package/dist/shared/assistant/localeCommands/tables/ta.js +429 -0
  39. package/dist/shared/assistant/localeCommands/tables/zh.d.ts +9 -0
  40. package/dist/shared/assistant/localeCommands/tables/zh.js +402 -0
  41. package/dist/shared/assistant/localeCommands/types.d.ts +172 -0
  42. package/dist/shared/assistant/localeCommands/types.js +19 -0
  43. package/dist/shared/assistant/ui/AssistantChatArea.js +1340 -1330
  44. package/dist/shared/assistant/uiActions/linkContext.d.ts +20 -1
  45. package/dist/shared/assistant/uiActions/linkContext.js +39 -21
  46. package/dist/shared/assistant/uiActions/offerYesOnSurface.d.ts +6 -0
  47. package/dist/shared/assistant/uiActions/offerYesOnSurface.js +1 -1
  48. package/dist/shared/assistant/writeReplyBinder.d.ts +1 -1
  49. package/dist/shared/assistant/writeReplySend.d.ts +16 -0
  50. package/dist/shared/assistant/writeReplySend.js +23 -1
  51. package/dist/shared/graphql/client.d.ts +20 -0
  52. package/dist/shared/graphql/client.js +196 -191
  53. package/dist/shared/graphql/retryPolicy.d.ts +27 -0
  54. package/dist/shared/graphql/retryPolicy.js +10 -0
  55. package/dist/shared/utils/apollo.d.ts +6 -2
  56. package/dist/shared/utils/apollo.js +26 -25
  57. package/dist/shared-assistant.js +55 -37
  58. package/package.json +2 -2
@@ -1,97 +1,116 @@
1
- import { GATEWAYS as e, getGatewayUrl as t } from "../../shared-config.js";
2
- import { validateGatewayBaseUrl as n } from "./security.js";
3
- import { isWorkspaceTokenValidForContext as r } from "./workspaceToken.js";
4
- import { dispatchBackendErrorEvent as i, markConnectionHealthy as a } from "../utils/backendErrors.js";
5
- import { clearGraphqlFetchResponseCache as o, enqueueGraphQLFetch as s, ensureWorkspaceToken as c } from "./fetch.js";
6
- import { SSELink as l } from "./links/sse-link.js";
7
- import { onError as u } from "@apollo/client/link/error";
8
- import { RetryLink as d } from "@apollo/client/link/retry";
9
- import { setContext as f } from "@apollo/client/link/context";
10
- import { ApolloClient as p, ApolloLink as m, InMemoryCache as ee, Observable as h, from as te, split as ne } from "@apollo/client/core";
11
- import { getMainDefinition as g } from "@apollo/client/utilities";
12
- import { print as _ } from "graphql";
1
+ import { isOperationRetryable as e } from "./retryPolicy.js";
2
+ import { GATEWAYS as t, getGatewayUrl as n } from "../../shared-config.js";
3
+ import { validateGatewayBaseUrl as r } from "./security.js";
4
+ import { isWorkspaceTokenValidForContext as i } from "./workspaceToken.js";
5
+ import { dispatchBackendErrorEvent as a, markConnectionHealthy as o } from "../utils/backendErrors.js";
6
+ import { clearGraphqlFetchResponseCache as s, enqueueGraphQLFetch as c, ensureWorkspaceToken as l } from "./fetch.js";
7
+ import { SSELink as u } from "./links/sse-link.js";
8
+ import { onError as d } from "@apollo/client/link/error";
9
+ import { RetryLink as f } from "@apollo/client/link/retry";
10
+ import { setContext as p } from "@apollo/client/link/context";
11
+ import { ApolloClient as m, ApolloLink as h, InMemoryCache as ee, Observable as g, from as te, split as _ } from "@apollo/client/core";
12
+ import { getMainDefinition as v } from "@apollo/client/utilities";
13
+ import { print as y } from "graphql";
13
14
  //#region src/shared/graphql/client.ts
14
- var v = {
15
+ var b = {
15
16
  consecutiveFailures: 0,
16
17
  lastFailureTime: 0,
17
18
  isOpen: !1,
18
19
  openCount: 0,
19
20
  nextRetryTime: 0
20
- }, y = 20, b = 5e3, x = 3e4;
21
- function re() {
22
- if (v.consecutiveFailures++, v.lastFailureTime = Date.now(), !v.isOpen && v.consecutiveFailures >= y) {
23
- v.isOpen = !0, v.openCount++;
24
- let e = Math.min(b * 2 ** (v.openCount - 1), x);
25
- v.nextRetryTime = Date.now() + e;
21
+ }, x = 20, S = 5e3, C = 3e4;
22
+ function ne() {
23
+ if (b.consecutiveFailures++, b.lastFailureTime = Date.now(), !b.isOpen && b.consecutiveFailures >= x) {
24
+ b.isOpen = !0, b.openCount++;
25
+ let e = Math.min(S * 2 ** (b.openCount - 1), C);
26
+ b.nextRetryTime = Date.now() + e;
26
27
  }
27
- return v.isOpen;
28
+ return b.isOpen;
29
+ }
30
+ function w() {
31
+ b.consecutiveFailures = 0, b.isOpen = !1, b.openCount = 0, b.nextRetryTime = 0, o();
28
32
  }
29
- function S() {
30
- v.consecutiveFailures = 0, v.isOpen = !1, v.openCount = 0, v.nextRetryTime = 0, a();
33
+ function re() {
34
+ return !(!b.isOpen || Date.now() >= b.nextRetryTime);
31
35
  }
32
- function C() {
33
- return !(!v.isOpen || Date.now() >= v.nextRetryTime);
36
+ function T(t, n, r) {
37
+ if (r || !t) return !1;
38
+ let i = t.message?.toLowerCase?.() ?? "";
39
+ return !(i.includes("401") || i.includes("403") || i.includes("unauthorized") || i.includes("forbidden") || i.includes("unauthenticated") || !e(n));
34
40
  }
35
- var w = /(?:\b40[13]\b|status code 40[13]|unauthori[sz]ed|unauthenticated|forbidden|invalid email or password)/i;
36
- function T(e) {
41
+ function ie({ maxAttempts: e, delay: t }) {
42
+ return new f({
43
+ delay: t ?? {
44
+ initial: 1e3,
45
+ max: 8e3,
46
+ jitter: !0
47
+ },
48
+ attempts: {
49
+ max: e,
50
+ retryIf: (e, t) => T(e, t, re())
51
+ }
52
+ });
53
+ }
54
+ var E = /(?:\b40[13]\b|status code 40[13]|unauthori[sz]ed|unauthenticated|forbidden|invalid email or password)/i;
55
+ function D(e) {
37
56
  return typeof e == "number" && Number.isInteger(e) ? e : typeof e == "string" && /^\d{3}$/.test(e) ? Number(e) : null;
38
57
  }
39
- function ie(e) {
58
+ function ae(e) {
40
59
  let t = /* @__PURE__ */ new Set(), n = (e, r) => {
41
60
  if (r > 3 || e == null || t.has(e)) return !1;
42
- if (typeof e == "string") return w.test(e);
61
+ if (typeof e == "string") return E.test(e);
43
62
  if (typeof e != "object") return !1;
44
63
  t.add(e);
45
- let i = e, a = T(i.status) ?? T(i.statusCode) ?? T(i.response?.status);
64
+ let i = e, a = D(i.status) ?? D(i.statusCode) ?? D(i.response?.status);
46
65
  if (a === 401 || a === 403) return !0;
47
66
  let o = i.message;
48
- return typeof o == "string" && w.test(o) ? !0 : n(i.cause, r + 1);
67
+ return typeof o == "string" && E.test(o) ? !0 : n(i.cause, r + 1);
49
68
  };
50
69
  return n(e, 0);
51
70
  }
52
- function ae(e) {
71
+ function oe(e) {
53
72
  if (!e || typeof e != "object") return null;
54
73
  let t = e, n = t.workspaceId || t.input?.workspaceId;
55
74
  return typeof n == "string" && n.trim() ? n : null;
56
75
  }
57
- function oe(e) {
76
+ function se(e) {
58
77
  if (!e || typeof e != "object") return null;
59
78
  let t = e.projectId;
60
79
  return typeof t == "string" && t.trim() ? t : null;
61
80
  }
62
- function se(e) {
63
- let t = g(e);
81
+ function ce(e) {
82
+ let t = v(e);
64
83
  return t.kind === "OperationDefinition" && t.operation === "mutation";
65
84
  }
66
- function ce(e) {
85
+ function le(e) {
67
86
  let t = e.errors;
68
87
  return Array.isArray(t) && t.length > 0;
69
88
  }
70
- function E(e) {
89
+ function O(e) {
71
90
  let t = e.headers;
72
91
  if (!t || typeof t != "object" || Array.isArray(t)) return {};
73
92
  let n = {};
74
93
  for (let [e, r] of Object.entries(t)) typeof r == "string" && (n[e] = r);
75
94
  return n;
76
95
  }
77
- function D(e) {
96
+ function k(e) {
78
97
  let t = e.fetchOptions;
79
98
  if (!t || typeof t != "object" || !("signal" in t)) return;
80
99
  let n = t.signal;
81
100
  return n instanceof AbortSignal ? n : void 0;
82
101
  }
83
- function le({ uri: e, batchMax: t, batchInterval: n }) {
84
- return new m((r) => new h((i) => {
85
- let a = r.getContext(), o = { query: _(r.query) };
102
+ function ue({ uri: e, batchMax: t, batchInterval: n }) {
103
+ return new h((r) => new g((i) => {
104
+ let a = r.getContext(), o = { query: y(r.query) };
86
105
  r.operationName && (o.operationName = r.operationName);
87
- let c = r.variables ?? {}, l = r.extensions ?? {};
88
- Object.keys(c).length > 0 && (o.variables = c), Object.keys(l).length > 0 && (o.extensions = l);
106
+ let s = r.variables ?? {}, l = r.extensions ?? {};
107
+ Object.keys(s).length > 0 && (o.variables = s), Object.keys(l).length > 0 && (o.extensions = l);
89
108
  let u = !1;
90
- return s(e, {
109
+ return c(e, {
91
110
  "content-type": "application/json",
92
111
  "Apollo-Require-Preflight": "true",
93
- ...E(a)
94
- }, o, D(a), {
112
+ ...O(a)
113
+ }, o, k(a), {
95
114
  batchMax: t,
96
115
  batchInterval: n
97
116
  }).then((e) => {
@@ -103,136 +122,122 @@ function le({ uri: e, batchMax: t, batchInterval: n }) {
103
122
  };
104
123
  }));
105
124
  }
106
- function O(a) {
107
- let { gateway: s, baseUrl: _, authToken: y, workspaceToken: b, locale: x, geography: w, organizationId: T, productId: E, productSlug: D, workspaceId: O, projectId: k, tenantId: A, cache: j, enableSubscriptions: M = !1, sseUrl: N, onAuthError: P, onRefreshToken: F, onNetworkError: I, onNetworkStatusChange: L, onMutationSuccess: R, maxRetryAttempts: ue = 3, batchMax: de = 10, batchInterval: fe, debug: z = !1 } = a, B = null, V = null, pe = (e) => {
108
- V ||= setTimeout(() => {
109
- V = null, B && B.refetchQueries({ include: "active" }).catch((t) => {
110
- z && console.warn("[GraphQL] Active query refresh failed after mutation:", {
111
- gateway: s,
125
+ function A(e) {
126
+ let { gateway: o, baseUrl: c, authToken: f, workspaceToken: y, locale: x, geography: S, organizationId: C, productId: T, productSlug: E, workspaceId: D, projectId: O, tenantId: k, cache: A, enableSubscriptions: j = !1, sseUrl: M, onAuthError: N, onRefreshToken: P, onNetworkError: F, onNetworkStatusChange: I, onMutationSuccess: L, maxRetryAttempts: de = 3, batchMax: fe = 10, batchInterval: pe, debug: R = !1 } = e, z = null, B = null, me = (e) => {
127
+ B ||= setTimeout(() => {
128
+ B = null, z && z.refetchQueries({ include: "active" }).catch((t) => {
129
+ R && console.warn("[GraphQL] Active query refresh failed after mutation:", {
130
+ gateway: o,
112
131
  operationName: e,
113
132
  error: t
114
133
  });
115
134
  });
116
135
  }, 0);
117
- }, H = e[s], U = n(t(_, s)), W = le({
118
- uri: U,
119
- batchMax: de,
120
- batchInterval: fe
121
- }), G = f((e, t) => {
122
- let n = t.headers ?? {}, r = typeof y == "function" ? y() : y;
136
+ }, V = t[o], H = r(n(c, o)), he = ue({
137
+ uri: H,
138
+ batchMax: fe,
139
+ batchInterval: pe
140
+ }), U = p((e, t) => {
141
+ let n = t.headers ?? {}, r = typeof f == "function" ? f() : f;
123
142
  return { headers: {
124
143
  ...n,
125
144
  ...r ? { authorization: `Bearer ${r}` } : {}
126
145
  } };
127
- }), K = f((e, t) => {
146
+ }), W = p((e, t) => {
128
147
  let n = t.headers ?? {}, r = typeof x == "function" ? x() : x;
129
148
  return { headers: {
130
149
  ...n,
131
150
  ...r ? { "accept-language": r } : {}
132
151
  } };
133
- }), q = f((e, t) => {
134
- let n = t.headers ?? {}, r = typeof w == "function" ? w() : null;
152
+ }), G = p((e, t) => {
153
+ let n = t.headers ?? {}, r = typeof S == "function" ? S() : null;
135
154
  return { headers: {
136
155
  ...n,
137
156
  ...r?.country ? { "x-geo-country": r.country } : {},
138
157
  ...r?.currency ? { "x-geo-currency": r.currency } : {},
139
158
  ...r?.timezone ? { "x-geo-timezone": r.timezone } : {}
140
159
  } };
141
- }), J = f((e, t) => {
142
- let n = t.headers ?? {}, r = typeof T == "function" ? T() : T;
160
+ }), K = p((e, t) => {
161
+ let n = t.headers ?? {}, r = typeof C == "function" ? C() : C;
143
162
  return { headers: {
144
163
  ...n,
145
164
  ...r ? { "x-org-id": r } : {}
146
165
  } };
147
- }), me = f((e, t) => {
148
- let n = t.headers ?? {}, r = typeof E == "function" ? E() : E, i = typeof D == "function" ? D() : D;
166
+ }), q = p((e, t) => {
167
+ let n = t.headers ?? {}, r = typeof T == "function" ? T() : T, i = typeof E == "function" ? E() : E;
149
168
  return { headers: {
150
169
  ...n,
151
170
  ...r ? { "x-product-id": r } : {},
152
171
  ...i ? { "x-product-slug": i } : {}
153
172
  } };
154
- }), he = f((e, t) => {
155
- let n = t.headers ?? {}, r = (typeof O == "function" ? O() : O) || ae(e.variables);
173
+ }), J = p((e, t) => {
174
+ let n = t.headers ?? {}, r = (typeof D == "function" ? D() : D) || oe(e.variables);
156
175
  return { headers: {
157
176
  ...n,
158
177
  ...r ? { "x-workspace-id": r } : {}
159
178
  } };
160
- }), ge = f((e, t) => {
161
- let n = t.headers ?? {}, r = (typeof k == "function" ? k() : k) || oe(e.variables);
179
+ }), Y = p((e, t) => {
180
+ let n = t.headers ?? {}, r = (typeof O == "function" ? O() : O) || se(e.variables);
162
181
  return { headers: {
163
182
  ...n,
164
183
  ...r ? { "x-project-id": r } : {}
165
184
  } };
166
- }), Y = f((e, t) => {
167
- let n = t.headers ?? {}, r = typeof A == "function" ? A() : A;
185
+ }), ge = p((e, t) => {
186
+ let n = t.headers ?? {}, r = typeof k == "function" ? k() : k;
168
187
  return { headers: {
169
188
  ...n,
170
189
  ...r ? { "x-tenant-id": r } : {}
171
190
  } };
172
- }), _e = f(async (e, n) => {
173
- let i = n.headers ?? {}, a = n.requiredWorkspaceAuth === !0;
174
- if (s === "global" && !a) return { headers: i };
175
- let o = typeof y == "function" ? y() : y, l = typeof b == "function" ? b() : b, u = typeof O == "function" ? O() : O, d = typeof T == "function" ? T() : T, f = typeof A == "function" ? A() : A, p = typeof k == "function" ? k() : k, m = r(l, {
191
+ }), X = p(async (e, t) => {
192
+ let r = t.headers ?? {}, a = t.requiredWorkspaceAuth === !0;
193
+ if (o === "global" && !a) return { headers: r };
194
+ let s = typeof f == "function" ? f() : f, c = typeof y == "function" ? y() : y, u = typeof D == "function" ? D() : D, d = typeof C == "function" ? C() : C, p = typeof k == "function" ? k() : k, m = typeof O == "function" ? O() : O, h = i(c, {
176
195
  workspaceId: u,
177
196
  organizationId: d,
178
- tenantId: f,
179
- projectId: p
180
- }) ? l : null;
181
- if (a && n.requiredWorkspaceId && n.requiredWorkspaceId !== u) throw Error("The active workspace changed; retry the request");
197
+ tenantId: p,
198
+ projectId: m
199
+ }) ? c : null;
200
+ if (a && t.requiredWorkspaceId && t.requiredWorkspaceId !== u) throw Error("The active workspace changed; retry the request");
182
201
  if (a && !u) throw Error("Workspace authentication requires an active workspace");
183
- if (!m && (s === "workspace" || a)) try {
184
- let n = typeof y == "function" ? y() : y;
185
- if (n) {
186
- let i = await Promise.race([c({
187
- url: s === "workspace" ? U : t(void 0, "workspace"),
188
- authToken: n,
202
+ if (!h && (o === "workspace" || a)) try {
203
+ let t = typeof f == "function" ? f() : f;
204
+ if (t) {
205
+ let r = await Promise.race([l({
206
+ url: o === "workspace" ? H : n(void 0, "workspace"),
207
+ authToken: t,
189
208
  workspaceId: u ?? void 0,
190
209
  organizationId: d ?? void 0,
191
- projectId: p ?? void 0,
210
+ projectId: m ?? void 0,
192
211
  currentQuery: e.operationName ?? ""
193
212
  }), new Promise((e) => setTimeout(() => e(null), 4e3))]);
194
- r(i, {
213
+ i(r, {
195
214
  workspaceId: u,
196
215
  organizationId: d,
197
- tenantId: f,
198
- projectId: p
199
- }) && (m = i);
216
+ tenantId: p,
217
+ projectId: m
218
+ }) && (h = r);
200
219
  }
201
220
  } catch {}
202
221
  if (a) {
203
- if (!m) throw Error("Workspace authentication is unavailable; retry the request");
204
- if (o !== (typeof y == "function" ? y() : y) || u !== (typeof O == "function" ? O() : O) || d !== (typeof T == "function" ? T() : T) || p !== (typeof k == "function" ? k() : k) || f !== (typeof A == "function" ? A() : A)) throw Error("The active workspace changed; retry the request");
222
+ if (!h) throw Error("Workspace authentication is unavailable; retry the request");
223
+ if (s !== (typeof f == "function" ? f() : f) || u !== (typeof D == "function" ? D() : D) || d !== (typeof C == "function" ? C() : C) || m !== (typeof O == "function" ? O() : O) || p !== (typeof k == "function" ? k() : k)) throw Error("The active workspace changed; retry the request");
205
224
  }
206
225
  return { headers: {
207
- ...i,
208
- ...m ? { "x-workspace-authorization": `Bearer ${m}` } : {}
226
+ ...r,
227
+ ...h ? { "x-workspace-authorization": `Bearer ${h}` } : {}
209
228
  } };
210
- }), ve = new d({
211
- delay: {
212
- initial: 1e3,
213
- max: 8e3,
214
- jitter: !0
215
- },
216
- attempts: {
217
- max: ue,
218
- retryIf: (e) => {
219
- if (C() || !e) return !1;
220
- let t = e.message?.toLowerCase?.() ?? "";
221
- return !(t.includes("401") || t.includes("403") || t.includes("unauthorized") || t.includes("forbidden") || t.includes("unauthenticated"));
222
- }
223
- }
224
- }), ye = new m((e, t) => {
225
- if (C()) {
226
- z && console.warn("[CircuitBreaker] Circuit is open, blocking request:", e.operationName);
227
- let t = Math.max(0, Math.ceil((v.nextRetryTime - Date.now()) / 1e3)), n = /* @__PURE__ */ Error(`Network circuit breaker is open — backend appears unreachable. Retrying in ${t} seconds.`);
228
- return I?.(n), new h((e) => {
229
+ }), _e = ie({ maxAttempts: de }), ve = new h((e, t) => {
230
+ if (re()) {
231
+ R && console.warn("[CircuitBreaker] Circuit is open, blocking request:", e.operationName);
232
+ let t = Math.max(0, Math.ceil((b.nextRetryTime - Date.now()) / 1e3)), n = /* @__PURE__ */ Error(`Network circuit breaker is open — backend appears unreachable. Retrying in ${t} seconds.`);
233
+ return F?.(n), new g((e) => {
229
234
  e.error(n);
230
235
  });
231
236
  }
232
- return new h((n) => {
237
+ return new g((n) => {
233
238
  let r = t(e).subscribe({
234
239
  next: (e) => {
235
- S(), v.consecutiveFailures === 0 && L?.(!1), n.next(e);
240
+ w(), b.consecutiveFailures === 0 && I?.(!1), n.next(e);
236
241
  },
237
242
  error: (e) => {
238
243
  n.error(e);
@@ -245,16 +250,16 @@ function O(a) {
245
250
  r.unsubscribe();
246
251
  };
247
252
  });
248
- }), X = !1, Z = [];
249
- function Q(e) {
250
- Z.forEach(({ resolve: t }) => t(e)), Z = [];
253
+ }), Z = !1, Q = [];
254
+ function $(e) {
255
+ Q.forEach(({ resolve: t }) => t(e)), Q = [];
251
256
  }
252
- let be = u(({ error: e, operation: t, forward: n }) => {
257
+ let ye = d(({ error: e, operation: t, forward: n }) => {
253
258
  let r = e.errors;
254
259
  if (r) {
255
- let a = r.some((e) => e.extensions?.code === "UNAUTHENTICATED" || e.message.includes("Unauthorized") || e.message.includes("Unauthenticated"));
256
- for (let e of r) z && console.error("[GraphQL Error]:", e.message);
257
- a && F || i({ errors: r }, { operationName: t.operationName });
260
+ let i = r.some((e) => e.extensions?.code === "UNAUTHENTICATED" || e.message.includes("Unauthorized") || e.message.includes("Unauthenticated"));
261
+ for (let e of r) R && console.error("[GraphQL Error]:", e.message);
262
+ i && P || a({ errors: r }, { operationName: t.operationName });
258
263
  let o = new Set(["STORAGE_QUOTA_EXCEEDED", "RESOURCE_CAP_EXCEEDED"]);
259
264
  for (let e of r) {
260
265
  let t = e.extensions?.code;
@@ -263,65 +268,65 @@ function O(a) {
263
268
  break;
264
269
  }
265
270
  }
266
- if (a && F) return new h((r) => {
271
+ if (i && P) return new g((r) => {
267
272
  (async () => {
268
- if (X) if (await new Promise((e) => {
269
- Z.push({ resolve: e });
273
+ if (Z) if (await new Promise((e) => {
274
+ Q.push({ resolve: e });
270
275
  })) {
271
276
  let e = n(t).subscribe(r);
272
277
  return () => e.unsubscribe();
273
- } else return P?.(), r.error(e), () => {};
274
- X = !0;
278
+ } else return N?.(), r.error(e), () => {};
279
+ Z = !0;
275
280
  try {
276
- let i = await F();
277
- if (X = !1, i) {
278
- Q(!0);
281
+ let i = await P();
282
+ if (Z = !1, i) {
283
+ $(!0);
279
284
  let e = n(t).subscribe(r);
280
285
  return () => e.unsubscribe();
281
- } else return Q(!1), P?.(), r.error(e), () => {};
286
+ } else return $(!1), N?.(), r.error(e), () => {};
282
287
  } catch {
283
- return X = !1, Q(!1), P?.(), r.error(e), () => {};
288
+ return Z = !1, $(!1), N?.(), r.error(e), () => {};
284
289
  }
285
290
  })();
286
291
  });
287
- a && P?.(), S();
292
+ i && N?.(), w();
288
293
  } else {
289
- if (z && console.error("[Network Error]:", e), ie(e)) {
290
- S(), e instanceof Error && i(e, {
294
+ if (R && console.error("[Network Error]:", e), ae(e)) {
295
+ w(), e instanceof Error && a(e, {
291
296
  operationName: t.operationName,
292
297
  fallbackMessage: "Your session is no longer valid. Please sign in again."
293
298
  });
294
299
  return;
295
300
  }
296
- if (re() && L?.(!0), e instanceof Error) I?.(e), i(e, {
301
+ if (ne() && I?.(!0), e instanceof Error) F?.(e), a(e, {
297
302
  operationName: t.operationName,
298
303
  fallbackMessage: "We could not reach the server. Please check your connection and try again."
299
304
  });
300
305
  else {
301
306
  let n = Error(String(e));
302
- I?.(n), i(n, {
307
+ F?.(n), a(n, {
303
308
  operationName: t.operationName,
304
309
  fallbackMessage: "We could not reach the server. Please check your connection and try again."
305
310
  });
306
311
  }
307
312
  }
308
- }), xe = new m((e, t) => {
309
- let n = se(e.query), r = n && e.getContext().autoRefreshAfterMutation !== !1 && e.getContext().skipMutationAutoRefresh !== !0;
310
- return new h((i) => {
313
+ }), be = new h((e, t) => {
314
+ let n = ce(e.query), r = n && e.getContext().autoRefreshAfterMutation !== !1 && e.getContext().skipMutationAutoRefresh !== !0;
315
+ return new g((i) => {
311
316
  let a = t(e).subscribe({
312
317
  next: (t) => {
313
- if (i.next(t), ce(t) || (n && o(), !r)) return;
318
+ if (i.next(t), le(t) || (n && s(), !r)) return;
314
319
  let a = e.operationName || "anonymous mutation";
315
- R ? Promise.resolve(R({
316
- gateway: s,
320
+ L ? Promise.resolve(L({
321
+ gateway: o,
317
322
  operationName: a
318
323
  })).catch((e) => {
319
- z && console.warn("[GraphQL] Mutation refresh callback failed:", {
320
- gateway: s,
324
+ R && console.warn("[GraphQL] Mutation refresh callback failed:", {
325
+ gateway: o,
321
326
  operationName: a,
322
327
  error: e
323
328
  });
324
- }) : pe(a);
329
+ }) : me(a);
325
330
  },
326
331
  error: (e) => {
327
332
  i.error(e);
@@ -334,51 +339,51 @@ function O(a) {
334
339
  a.unsubscribe();
335
340
  };
336
341
  });
337
- }), $ = te([
342
+ }), xe = te([
343
+ _e,
338
344
  ve,
339
345
  ye,
340
346
  be,
341
- xe,
342
- G,
343
- _e,
344
- J,
345
- me,
346
- he,
347
- ge,
348
- Y,
347
+ U,
348
+ X,
349
349
  K,
350
350
  q,
351
- ne(({ query: e }) => {
352
- let t = g(e);
351
+ J,
352
+ Y,
353
+ ge,
354
+ W,
355
+ G,
356
+ _(({ query: e }) => {
357
+ let t = v(e);
353
358
  return t.kind === "OperationDefinition" && t.operation === "subscription";
354
- }, new m((e) => new h((t) => {
359
+ }, new h((e) => new g((t) => {
355
360
  t.error(/* @__PURE__ */ Error(`[graphql] Refusing to send subscription "${e.operationName ?? "anonymous"}" over the batched HTTP transport — this gateway client was created without enableSubscriptions/SSE. Enable subscriptions on this client so it routes over SSE.`));
356
- })), W)
361
+ })), he)
357
362
  ]);
358
- if (M) {
359
- let e = H.sse, t = N || (e ? n(_ || H.defaultBaseUrl) + e : void 0);
360
- t && ($ = te([
363
+ if (j) {
364
+ let e = V.sse, t = M || (e ? r(c || V.defaultBaseUrl) + e : void 0);
365
+ t && (xe = te([
366
+ _e,
361
367
  ve,
362
368
  ye,
363
369
  be,
364
- xe,
365
- G,
366
- _e,
367
- J,
368
- me,
369
- he,
370
- ge,
371
- Y,
370
+ U,
371
+ X,
372
372
  K,
373
373
  q,
374
- ne(({ query: e }) => {
375
- let t = g(e);
374
+ J,
375
+ Y,
376
+ ge,
377
+ W,
378
+ G,
379
+ _(({ query: e }) => {
380
+ let t = v(e);
376
381
  return t.kind === "OperationDefinition" && t.operation === "subscription";
377
- }, new l({
382
+ }, new u({
378
383
  url: t,
379
384
  headers: {},
380
- debug: z
381
- }), W)
385
+ debug: R
386
+ }), he)
382
387
  ]));
383
388
  }
384
389
  let Se = new ee({ typePolicies: {
@@ -416,9 +421,9 @@ function O(a) {
416
421
  VibecontrolsAgent: { keyFields: ["id"] },
417
422
  Query: { fields: { vibes: { keyArgs: ["filter"] } } }
418
423
  } });
419
- return B = new p({
420
- link: $,
421
- cache: j ?? Se,
424
+ return z = new m({
425
+ link: xe,
426
+ cache: A ?? Se,
422
427
  defaultOptions: {
423
428
  watchQuery: {
424
429
  fetchPolicy: "cache-and-network",
@@ -430,19 +435,19 @@ function O(a) {
430
435
  },
431
436
  mutate: { errorPolicy: "all" }
432
437
  }
433
- }), B;
438
+ }), z;
434
439
  }
435
- var k = null, A = null;
436
- function j(e) {
440
+ var j = null, M = null;
441
+ function N(e) {
437
442
  let { workspaceBaseUrl: t, globalBaseUrl: n, authToken: r, enableSubscriptions: i = !1, onAuthError: a, debug: o = !1 } = e;
438
- k = O({
443
+ j = A({
439
444
  gateway: "workspace",
440
445
  baseUrl: t,
441
446
  authToken: r,
442
447
  enableSubscriptions: i,
443
448
  onAuthError: a,
444
449
  debug: o
445
- }), A = O({
450
+ }), M = A({
446
451
  gateway: "global",
447
452
  baseUrl: n,
448
453
  authToken: r,
@@ -450,16 +455,16 @@ function j(e) {
450
455
  debug: o
451
456
  });
452
457
  }
453
- function M() {
454
- if (!k) throw Error("Workspace client not initialized. Call initializeAppClients first.");
455
- return k;
458
+ function P() {
459
+ if (!j) throw Error("Workspace client not initialized. Call initializeAppClients first.");
460
+ return j;
456
461
  }
457
- function N() {
458
- if (!A) throw Error("Global client not initialized. Call initializeAppClients first.");
459
- return A;
462
+ function F() {
463
+ if (!M) throw Error("Global client not initialized. Call initializeAppClients first.");
464
+ return M;
460
465
  }
461
- function P() {
462
- k &&= (k.clearStore(), null), A &&= (A.clearStore(), null);
466
+ function I() {
467
+ j &&= (j.clearStore(), null), M &&= (M.clearStore(), null);
463
468
  }
464
469
  //#endregion
465
- export { O as createGraphQLClient, N as getGlobalClient, M as getWorkspaceClient, j as initializeAppClients, P as resetAppClients };
470
+ export { A as createGraphQLClient, F as getGlobalClient, P as getWorkspaceClient, N as initializeAppClients, I as resetAppClients };
@@ -0,0 +1,27 @@
1
+ import { DocumentNode } from 'graphql';
2
+ /**
3
+ * Operation-context key that explicitly opts a MUTATION in to automatic
4
+ * transport-level retries. Nothing opts in today.
5
+ *
6
+ * A mutation can change server state even when the response never arrives
7
+ * (a 504 / dropped connection is ambiguous: the write may have committed).
8
+ * Replaying it blindly can duplicate or silently re-apply the write, so the
9
+ * shared retry links never retry mutations unless the caller sets
10
+ * `context: { retryMutation: true }` AND guarantees the mutation is idempotent
11
+ * (for example a keyed upsert). Callers that need recovery from an ambiguous
12
+ * failure should reconcile explicitly (read the state back) instead.
13
+ */
14
+ export declare const RETRY_MUTATION_CONTEXT_KEY = "retryMutation";
15
+ /** The minimal operation surface the retry policy needs (ApolloLink.Operation fits). */
16
+ export interface RetryPolicyOperation {
17
+ query: DocumentNode;
18
+ getContext: () => Record<string, unknown>;
19
+ }
20
+ /** True when any operation definition in the document is a mutation. */
21
+ export declare function isMutationOperation(operation: Pick<RetryPolicyOperation, 'query'>): boolean;
22
+ /**
23
+ * Whether the transport may replay this operation after a failure. Queries and
24
+ * subscriptions are replayable; mutations only with an explicit
25
+ * `retryMutation: true` context opt-in.
26
+ */
27
+ export declare function isOperationRetryable(operation: RetryPolicyOperation | undefined): boolean;
@@ -0,0 +1,10 @@
1
+ //#region src/shared/graphql/retryPolicy.ts
2
+ var e = "retryMutation";
3
+ function t(e) {
4
+ return e.query.definitions.some((e) => e.kind === "OperationDefinition" && e.operation === "mutation");
5
+ }
6
+ function n(n) {
7
+ return !n || !t(n) ? !0 : n.getContext()[e] === !0;
8
+ }
9
+ //#endregion
10
+ export { n as isOperationRetryable };