@burdenoff/fe-libs 2026.929.1 → 2026.930.1

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.
@@ -16,35 +16,68 @@ function r(e) {
16
16
  }
17
17
  return r;
18
18
  }
19
- var i = 2e3, a = 5;
20
- function o(e) {
19
+ function i(e, t) {
20
+ return (e.sessionId === null || e.sessionId === t.sessionId) && (e.conversationId === null || e.conversationId === t.conversationId);
21
+ }
22
+ function a(e) {
23
+ let t = /* @__PURE__ */ new Map();
24
+ for (let n of e.messages) for (let i of r(n.metadata)) t.set(f(i), {
25
+ session: {
26
+ sandboxId: i.sandboxId,
27
+ sessionId: i.sessionId,
28
+ conversationId: e.id
29
+ },
30
+ issuing: !0
31
+ });
32
+ let n = e.backendSessionId;
33
+ if (n) for (let r = e.messages.length - 1; r >= 0; --r) {
34
+ let i = e.messages[r]?.metadata;
35
+ if (i?.sessionId !== n || typeof i.sandboxId != "string" || !i.sandboxId) continue;
36
+ let a = f({
37
+ sandboxId: i.sandboxId,
38
+ sessionId: n
39
+ }), o = t.get(a);
40
+ t.set(a, {
41
+ session: {
42
+ sandboxId: i.sandboxId,
43
+ sessionId: n,
44
+ conversationId: e.id
45
+ },
46
+ issuing: (o?.issuing ?? !1) || i.mode === "api-calls"
47
+ });
48
+ break;
49
+ }
50
+ return [...t.values()];
51
+ }
52
+ var o = 2e3, s = 5;
53
+ function c(e) {
21
54
  return e?.proposals === !0 && e.writeApprovalMode === "proposal-v1";
22
55
  }
23
- function s() {
56
+ function l() {
24
57
  let e = typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Math.random().toString(36).slice(2)}${Math.random().toString(36).slice(2)}`;
25
58
  return `wpr-${Date.now().toString(36)}-${e}`;
26
59
  }
27
- function c(n) {
60
+ function u(n) {
28
61
  return t(n) ? n : new e({
29
62
  status: 0,
30
63
  code: "UNKNOWN",
31
64
  message: n instanceof Error ? n.message : String(n)
32
65
  });
33
66
  }
34
- var l = {
67
+ var d = {
35
68
  set: (e, t) => setTimeout(e, t),
36
69
  clear: (e) => clearTimeout(e)
37
- }, u = (e) => `${e.sandboxId}\u0000${e.sessionId}`;
38
- function d(e, t) {
70
+ }, f = (e) => `${e.sandboxId}\u0000${e.sessionId}`;
71
+ function p(e, t) {
39
72
  return e ? {
40
73
  reason: e.reason === "turn" ? "turn" : t.reason,
41
74
  turnMessageId: t.turnMessageId ?? e.turnMessageId
42
75
  } : t;
43
76
  }
44
- function f(e) {
45
- let t = e.timers ?? l, n = e.pollMs ?? 2e3, r = e.maxPollFailures ?? 5, i = e.requestId ?? s, a = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Set(), p = !1, m = (t) => !p && o(e.capabilitiesOf(t.sandboxId)), h = (e) => m(e) && !f.has(e.sandboxId);
46
- function g(e) {
47
- let t = u(e), n = a.get(t);
77
+ function m(e) {
78
+ let t = e.timers ?? d, n = e.pollMs ?? 2e3, r = e.maxPollFailures ?? 5, a = e.requestId ?? l, o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), m = !1, h = (t) => !m && c(e.capabilitiesOf(t.sandboxId)), g = (e) => h(e) && !s.has(e.sandboxId);
79
+ function _(e) {
80
+ let t = f(e), n = o.get(t);
48
81
  return n ? n.session = e : (n = {
49
82
  session: e,
50
83
  since: null,
@@ -56,69 +89,72 @@ function f(e) {
56
89
  failures: 0,
57
90
  failureReported: !1,
58
91
  executing: /* @__PURE__ */ new Set()
59
- }, a.set(t, n)), n;
92
+ }, o.set(t, n)), n;
60
93
  }
61
- function _(e) {
94
+ function v(e) {
62
95
  e.hasTimer &&= (t.clear(e.timer), e.timer = null, !1);
63
96
  }
64
- function v(e, t) {
97
+ function y(e, t) {
65
98
  t.status === "executing" ? e.executing.add(t.proposalId) : e.executing.delete(t.proposalId);
66
99
  }
67
- function y(e) {
68
- p || e.hasTimer || e.running || e.queuedRun || e.executing.size === 0 || e.failures >= r || (e.hasTimer = !0, e.timer = t.set(() => {
69
- e.timer = null, e.hasTimer = !1, S(e.session, "poll");
100
+ function b(e) {
101
+ m || e.hasTimer || e.running || e.queuedRun || e.executing.size === 0 || e.failures >= r || (e.hasTimer = !0, e.timer = t.set(() => {
102
+ e.timer = null, e.hasTimer = !1, C(e.session, "poll");
70
103
  }, n));
71
104
  }
72
- function b(t, n) {
73
- p || (v(t, n), e.onView(t.session, n), y(t));
105
+ function x(t, n) {
106
+ m || (y(t, n), e.onView(t.session, n), b(t));
74
107
  }
75
- async function x(t, n) {
76
- if (_(t), !m(t.session)) return;
77
- let i = (async () => {
78
- let i;
108
+ async function S(t, n) {
109
+ if (v(t), !h(t.session)) return;
110
+ let a = e.actorOf?.() ?? null, o = (async () => {
111
+ let o;
79
112
  try {
80
- i = await e.client.list(t.session, {
113
+ o = await e.client.list(t.session, {
81
114
  status: "all",
82
115
  ...t.since === null ? {} : { since: t.since }
83
116
  });
84
117
  } catch (i) {
85
- if (p) return;
86
- t.failures += 1, (n.reason === "turn" || n.reason === "poll" && t.failures >= r) && !t.failureReported && (t.failureReported = !0, e.onError(t.session, c(i), "list"));
118
+ if (m) return;
119
+ t.failures += 1, (n.reason === "turn" || n.reason === "poll" && t.failures >= r) && !t.failureReported && (t.failureReported = !0, e.onError(t.session, u(i), "list"));
87
120
  return;
88
121
  }
89
- if (!p) {
90
- t.since = i.serverNow, t.failures = 0, t.failureReported = !1;
91
- for (let e of i.proposals) v(t, e);
92
- e.onList(t.session, i, n);
93
- }
122
+ if (m || a !== null && (e.actorOf?.() ?? null) !== a) return;
123
+ t.since = o.serverNow, t.failures = 0, t.failureReported = !1;
124
+ let s = o.proposals.filter((e) => i(e, t.session));
125
+ for (let e of s) y(t, e);
126
+ e.onList(t.session, s.length === o.proposals.length ? o : {
127
+ ...o,
128
+ proposals: s
129
+ }, n);
94
130
  })();
95
- t.running = i;
131
+ t.running = o;
96
132
  try {
97
- await i;
133
+ await o;
98
134
  } finally {
99
- t.running === i && (t.running = null), y(t);
135
+ t.running === o && (t.running = null), b(t);
100
136
  }
101
137
  }
102
- function S(e, t, n = {}) {
103
- if (!m(e)) return Promise.resolve();
104
- let r = g(e), i = {
138
+ function C(e, t, n = {}) {
139
+ if (!h(e)) return Promise.resolve();
140
+ let r = _(e), i = {
105
141
  reason: t,
106
142
  turnMessageId: n.turnMessageId ?? null
107
143
  };
108
- if (r.queuedRun) return r.queued = d(r.queued, i), r.queuedRun;
144
+ if (r.queuedRun) return r.queued = p(r.queued, i), r.queuedRun;
109
145
  if (r.running) {
110
146
  r.queued = i;
111
147
  let e = r.running.then(() => {
112
148
  let e = r.queued ?? i;
113
- return r.queued = null, r.queuedRun = null, x(r, e);
149
+ return r.queued = null, r.queuedRun = null, S(r, e);
114
150
  });
115
151
  return r.queuedRun = e, e;
116
152
  }
117
- return x(r, i);
153
+ return S(r, i);
118
154
  }
119
- async function C(t, n, r) {
120
- if (!h(t)) return;
121
- let a = g(t), o = !0;
155
+ async function w(t, n, r) {
156
+ if (!g(t)) return;
157
+ let i = _(t), o = !0;
122
158
  try {
123
159
  let s = await e.client.approve({
124
160
  ...t,
@@ -126,85 +162,85 @@ function f(e) {
126
162
  }, {
127
163
  payloadHash: n.payloadHash,
128
164
  surface: r,
129
- clientRequestId: i()
165
+ clientRequestId: a()
130
166
  });
131
- if (p) return;
132
- s.kind === "settled" ? (b(a, s.proposal), o = !1) : s.proposal ? b(a, s.proposal) : a.executing.add(n.proposalId);
167
+ if (m) return;
168
+ s.kind === "settled" ? (x(i, s.proposal), o = !1) : s.proposal ? x(i, s.proposal) : i.executing.add(n.proposalId);
133
169
  } catch (t) {
134
- if (p) return;
135
- let n = c(t);
136
- n.current && b(a, n.current), e.onError(a.session, n, "approve");
170
+ if (m) return;
171
+ let n = u(t);
172
+ n.current && x(i, n.current), e.onError(i.session, n, "approve");
137
173
  }
138
- o && await S(a.session, "refresh");
174
+ o && await C(i.session, "refresh");
139
175
  }
140
- async function w(t, n, r, a, o) {
141
- if (!h(t)) return;
142
- let s = g(t);
176
+ async function T(t, n, r, i, o) {
177
+ if (!g(t)) return;
178
+ let s = _(t);
143
179
  try {
144
- b(s, await e.client.decline({
180
+ x(s, await e.client.decline({
145
181
  ...t,
146
182
  proposalId: n.proposalId
147
183
  }, {
148
184
  reason: r,
149
- method: a,
185
+ method: i,
150
186
  ...o ? { surface: o } : {},
151
- clientRequestId: i()
187
+ clientRequestId: a()
152
188
  }));
153
189
  } catch (t) {
154
- if (p) return;
155
- let n = c(t);
156
- n.current && b(s, n.current), e.onError(s.session, n, "decline");
190
+ if (m) return;
191
+ let n = u(t);
192
+ n.current && x(s, n.current), e.onError(s.session, n, "decline");
157
193
  }
158
194
  }
159
- async function T(t, n, r) {
160
- if (!h(t) || n.status !== "pending") return;
161
- let a = g(t);
195
+ async function E(t, n, r) {
196
+ if (!g(t) || n.status !== "pending") return;
197
+ let i = _(t);
162
198
  try {
163
- b(a, await e.client.presented({
199
+ x(i, await e.client.presented({
164
200
  ...t,
165
201
  proposalId: n.proposalId
166
202
  }, {
167
203
  payloadHash: n.payloadHash,
168
204
  surface: r,
169
- clientRequestId: i()
205
+ clientRequestId: a()
170
206
  }));
171
207
  } catch (e) {
172
- if (p) return;
173
- let t = c(e);
174
- t.current && b(a, t.current);
208
+ if (m) return;
209
+ let t = u(e);
210
+ t.current && x(i, t.current);
175
211
  }
176
212
  }
177
- async function E(t, n, r, a = {}) {
178
- if (!m(t)) return !1;
179
- let o = g(t);
213
+ async function D(t, n, r, i = {}) {
214
+ if (!h(t)) return !1;
215
+ let o = _(t);
180
216
  try {
181
217
  await e.client.declineAll(t, {
182
218
  reason: n,
183
219
  method: r,
184
- clientRequestId: i()
220
+ clientRequestId: a()
185
221
  });
186
222
  } catch (t) {
187
- return p || a.report && e.onError(o.session, c(t), "decline"), !1;
223
+ return m || i.report && e.onError(o.session, u(t), "decline"), !1;
188
224
  }
189
- return p || a.refresh !== !1 && await S(o.session, "refresh"), !0;
225
+ return m || i.refresh !== !1 && await C(o.session, "refresh"), !0;
190
226
  }
191
227
  return {
192
- discover: S,
193
- approve: C,
194
- decline: w,
195
- presented: T,
196
- declineAll: E,
228
+ discover: C,
229
+ approve: w,
230
+ decline: T,
231
+ presented: E,
232
+ declineAll: D,
197
233
  retire: (e) => {
198
- f.add(e);
234
+ s.add(e);
199
235
  },
200
- isRetired: (e) => f.has(e),
201
- isPolling: (e) => !!a.get(u(e))?.hasTimer,
236
+ isRetired: (e) => s.has(e),
237
+ isPolling: (e) => !!o.get(f(e))?.hasTimer,
202
238
  dispose: () => {
203
- p = !0;
204
- for (let e of a.values()) _(e);
205
- a.clear();
239
+ m = !0;
240
+ for (let e of o.values()) v(e);
241
+ o.clear();
206
242
  }
207
243
  };
208
244
  }
209
245
  //#endregion
210
- export { a as WRITE_PROPOSAL_MAX_POLL_FAILURES, i as WRITE_PROPOSAL_POLL_MS, c as asWriteProposalError, f as createWriteProposalDiscovery, s as newWriteProposalRequestId, r as readWriteProposalRefs, o as writeProposalsEnabledFor };
246
+ export { s as WRITE_PROPOSAL_MAX_POLL_FAILURES, o as WRITE_PROPOSAL_POLL_MS, u as asWriteProposalError, m as createWriteProposalDiscovery, l as newWriteProposalRequestId, r as readWriteProposalRefs, i as writeProposalBelongsTo, a as writeProposalSessionsToReopen, c as writeProposalsEnabledFor };