@sentry/junior 0.258.0 → 0.260.0

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 (77) hide show
  1. package/dist/adapter-Dj5BTJRd.js +270 -0
  2. package/dist/{admin-My1SLGVO.js → admin-tzkZDqrH.js} +1 -1
  3. package/dist/{agent-hooks-BJ_5mlRH.js → agent-hooks-V4Hfc2tB.js} +711 -697
  4. package/dist/{agent-runner-DGsFQw72.js → agent-runner-DvTUyGTY.js} +751 -2508
  5. package/dist/api/schema.d.ts +239 -54
  6. package/dist/api/schema.js +4 -4
  7. package/dist/api.js +218 -57
  8. package/dist/{app-PX2H1PxU.d.ts → app-BsBUs3rF.d.ts} +6 -3
  9. package/dist/app.d.ts +2 -2
  10. package/dist/app.js +31 -31
  11. package/dist/{assistant-reply-H1M-91oF.js → assistant-reply-CEOMzsWy.js} +1 -1
  12. package/dist/{automation-DWBFBenG.js → automation-DrpcA-SX.js} +3 -0
  13. package/dist/{briefs-vYoK85rJ.js → briefs-BSCkyYqs.js} +4 -4
  14. package/dist/{catalog-runtime-BN4DVxco.js → catalog-runtime-Bpcs2b2L.js} +1 -1
  15. package/dist/cli/chat.d.ts +1 -1
  16. package/dist/cli/chat.js +16 -16
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +6 -2
  19. package/dist/cli/plugins.d.ts +1 -1
  20. package/dist/cli/plugins.js +4 -4
  21. package/dist/cli/run.d.ts +2 -1
  22. package/dist/cli/run.js +2 -1
  23. package/dist/cli/snapshot-create.js +4 -3
  24. package/dist/cli/upgrade.d.ts +1 -1
  25. package/dist/cli/upgrade.js +3 -3
  26. package/dist/{client-DbyHuMFU.js → client-JeyzRwsT.js} +57 -4
  27. package/dist/{config-_WO_AjCB.js → config-ULs6Zl9b.js} +5 -2
  28. package/dist/{connections-ag_1JOhB.js → connections-CZ7HhEmN.js} +174 -10
  29. package/dist/{conversation-DjN3mlog.js → conversation-CvuKJ3tA.js} +108 -155
  30. package/dist/{conversation-privacy-DHP_xnVj.js → conversation-privacy-BQSlZXgV.js} +1 -1
  31. package/dist/{credential-sync-B-CPX_ag.js → credential-sync-BKcv5rBe.js} +14 -177
  32. package/dist/{executor-RvG6kVe1.js → executor-BoGNVEDn.js} +3 -2
  33. package/dist/{images-C2J_bj2g.js → images-BBmDXQCB.js} +3 -3
  34. package/dist/instrumentation.js +2 -2
  35. package/dist/{job-queue-DVe37it2.js → job-queue-CbdVyaCo.js} +1 -1
  36. package/dist/{logging-DsHONhVm.js → logging-DSMmkHXG.js} +1 -1
  37. package/dist/{message-DyitL8no.js → message-zaj5gBbS.js} +3 -3
  38. package/dist/nitro.d.ts +2 -2
  39. package/dist/nitro.js +3 -3
  40. package/dist/{oauth-callback-server-CDby-pCn.js → oauth-callback-server-yYFG8Own.js} +2 -2
  41. package/dist/{plugins-B11Mfkmv.d.ts → plugins-B_0Cr0MO.d.ts} +5 -1
  42. package/dist/{profile-DpYjfKke.js → profile-ByWkAY7L.js} +24 -293
  43. package/dist/{prompt-xgpyMtg7.js → prompt-DeVax2qO.js} +1 -1
  44. package/dist/{registry-Du566MtJ.js → registry-BL-osYWN.js} +41 -2
  45. package/dist/{resolve-ClCIgh8E.js → resolve-HuPG2VMB.js} +9 -4
  46. package/dist/{result-BBbKA61B.js → result-DS7V4a3-.js} +9 -14
  47. package/dist/{runner-CCuqFSqx.js → runner-Cba_OfGl.js} +11 -11
  48. package/dist/{sandbox-egress-signals-DY1mbKF4.js → sandbox-egress-signals-C7NcPzea.js} +1 -1
  49. package/dist/{schema-DrMh3NtR.js → schema-OzL8Zw4H.js} +82 -3
  50. package/dist/service-account-DqwHhwJA.js +120 -0
  51. package/dist/service-account-Ko1Xs--F.js +661 -0
  52. package/dist/{session-stop-CIoFiwwe.js → session-stop-HfKx-pky.js} +180 -22
  53. package/dist/{skills-DyQBLIrK.js → skills-D6_bcAuW.js} +2 -2
  54. package/dist/{spawn-Dqfeo7XP.js → spawn-BWqK6EwM.js} +2 -2
  55. package/dist/{store-DJLwq4x8.js → store-DzRbd5VT.js} +6 -6
  56. package/dist/{task-queue-BzW4MaWU.js → task-queue-9LICOzcL.js} +3 -3
  57. package/dist/{task-runner-D3qJh4fK.js → task-runner-DGnd_B5X.js} +10 -10
  58. package/dist/{tasks-CEXKTASS.js → tasks-CjrS098O.js} +4928 -2389
  59. package/dist/thread-state-CqkYowEz.js +184 -0
  60. package/dist/{turn-failure-response-CWx7aNIh.js → turn-failure-response-BkKmGqFt.js} +8 -9
  61. package/dist/{turn-lifecycle-C9JFst7-.js → turn-lifecycle-DYv8IV6w.js} +1 -1
  62. package/dist/{turn-session-routing-CUxtfpr7.js → turn-session-routing-TaVhKmdz.js} +1 -1
  63. package/dist/{validation-BHRxa5G4.js → validation-BrXMYPyo.js} +1 -1
  64. package/dist/{version-C0U6rHg0.js → version-Ct049vav.js} +1 -1
  65. package/dist/version.js +1 -1
  66. package/dist/{viewer-CGvvRqKp.js → viewer-C-J0ewlH.js} +19 -10
  67. package/dist/{web-input-Keb5GRWj.js → web-input-C_xB3RXp.js} +41 -37
  68. package/dist/{work-DRcsJ3hV.js → work-D829Ue7k.js} +9 -10
  69. package/dist/{worker-Cjo-QqPq.js → worker-BRTYzlpk.js} +5 -5
  70. package/migrations/0061_workspace_vcpus.sql +1 -0
  71. package/migrations/meta/0061_snapshot.json +3471 -0
  72. package/migrations/meta/_journal.json +7 -0
  73. package/package.json +6 -6
  74. package/dist/experimental-BNK1l1jv.js +0 -49
  75. package/dist/oauth-authorization-djQn5Nhy.js +0 -97
  76. package/dist/pending-auth-D8J1uJUS.js +0 -442
  77. package/dist/thread-state-W3f6kAtz.js +0 -426
@@ -0,0 +1,270 @@
1
+ import { i as getChatConfig } from "./config-ULs6Zl9b.js";
2
+ import { createMemoryState } from "@chat-adapter/state-memory";
3
+ import { createRedisState } from "@chat-adapter/state-redis";
4
+ import { setTimeout } from "node:timers/promises";
5
+ // src/chat/state/locks.ts
6
+ const ACTIVE_LOCK_TTL_MS = 9e4;
7
+ const MUTATION_LOCK_TTL_MS = 1e4;
8
+ /**
9
+ * Acquire a lock for long-running work that the queued state adapter should
10
+ * keep alive while the owning invocation is still making progress.
11
+ */
12
+ async function acquireActiveLock(state, threadId) {
13
+ return await state.acquireLock(threadId, ACTIVE_LOCK_TTL_MS);
14
+ }
15
+ /**
16
+ * Run work under one lock, optionally waiting for the current owner.
17
+ * `keepAlive` is for multi-store mutations that must retain ownership until all
18
+ * side effects finish; callers should still fence each blind write.
19
+ */
20
+ async function withLock(state, key, run, options = {}) {
21
+ const startedAtMs = Date.now();
22
+ let lock;
23
+ while (true) {
24
+ lock = await state.acquireLock(key, options.ttlMs ?? 9e4);
25
+ if (lock) break;
26
+ if (Date.now() - startedAtMs >= (options.waitMs ?? 0)) return { acquired: false };
27
+ await setTimeout(options.retryMs ?? 25, void 0, { ref: false });
28
+ }
29
+ const ttlMs = options.ttlMs ?? 9e4;
30
+ const heartbeat = options.keepAlive ? setInterval(() => {
31
+ state.extendLock(lock, ttlMs);
32
+ }, Math.max(1, Math.floor(ttlMs / 3))) : void 0;
33
+ heartbeat?.unref();
34
+ try {
35
+ return {
36
+ acquired: true,
37
+ value: await run(lock)
38
+ };
39
+ } finally {
40
+ if (heartbeat) clearInterval(heartbeat);
41
+ await state.releaseLock(lock);
42
+ }
43
+ }
44
+ /**
45
+ * Prove lock ownership immediately before a blind write.
46
+ *
47
+ * Whole-record mutations must stop if their lock expired rather than overwrite
48
+ * state committed by a newer owner.
49
+ */
50
+ async function fenceLock(state, lock, ttlMs = MUTATION_LOCK_TTL_MS) {
51
+ if (!await state.extendLock(lock, ttlMs)) throw new Error(`Lock ownership was lost before write for ${lock.threadId}`);
52
+ }
53
+ // src/chat/state/adapter.ts
54
+ const ACTIVE_LOCK_HEARTBEAT_MS = 3e4;
55
+ let stateAdapter;
56
+ let redisStateAdapter;
57
+ /** Lazily connect state operations, including queued-adapter lock heartbeats. */
58
+ function createConnectingStateAdapter(base) {
59
+ const connected = async (operation) => {
60
+ await base.connect();
61
+ return await operation();
62
+ };
63
+ return {
64
+ appendToList: (key, value, options) => connected(() => base.appendToList(key, value, options)),
65
+ connect: () => base.connect(),
66
+ disconnect: () => base.disconnect(),
67
+ subscribe: (threadId) => connected(() => base.subscribe(threadId)),
68
+ unsubscribe: (threadId) => connected(() => base.unsubscribe(threadId)),
69
+ isSubscribed: (threadId) => connected(() => base.isSubscribed(threadId)),
70
+ acquireLock: (threadId, ttlMs) => connected(() => base.acquireLock(threadId, ttlMs)),
71
+ releaseLock: (lock) => connected(() => base.releaseLock(lock)),
72
+ extendLock: (lock, ttlMs) => connected(() => base.extendLock(lock, ttlMs)),
73
+ forceReleaseLock: (threadId) => connected(() => base.forceReleaseLock(threadId)),
74
+ enqueue: (threadId, entry, maxSize) => connected(() => base.enqueue(threadId, entry, maxSize)),
75
+ dequeue: (threadId) => connected(() => base.dequeue(threadId)),
76
+ queueDepth: (threadId) => connected(() => base.queueDepth(threadId)),
77
+ get: (key) => connected(() => base.get(key)),
78
+ getList: (key) => connected(() => base.getList(key)),
79
+ set: (key, value, ttlMs) => connected(() => base.set(key, value, ttlMs)),
80
+ setIfNotExists: (key, value, ttlMs) => connected(() => base.setIfNotExists(key, value, ttlMs)),
81
+ delete: (key) => connected(() => base.delete(key))
82
+ };
83
+ }
84
+ function createPrefixedStateAdapter(base, prefix) {
85
+ const prefixed = (value) => `${prefix}:${value}`;
86
+ const unprefixed = (value) => value.startsWith(`${prefix}:`) ? value.slice(prefix.length + 1) : value;
87
+ const prefixLock = (lock) => ({
88
+ ...lock,
89
+ threadId: prefixed(lock.threadId)
90
+ });
91
+ const unprefixLock = (lock) => ({
92
+ ...lock,
93
+ threadId: unprefixed(lock.threadId)
94
+ });
95
+ return {
96
+ appendToList: (key, value, options) => base.appendToList(prefixed(key), value, options),
97
+ connect: () => base.connect(),
98
+ disconnect: () => base.disconnect(),
99
+ subscribe: (threadId) => base.subscribe(prefixed(threadId)),
100
+ unsubscribe: (threadId) => base.unsubscribe(prefixed(threadId)),
101
+ isSubscribed: (threadId) => base.isSubscribed(prefixed(threadId)),
102
+ acquireLock: async (threadId, ttlMs) => {
103
+ const lock = await base.acquireLock(prefixed(threadId), ttlMs);
104
+ return lock ? unprefixLock(lock) : null;
105
+ },
106
+ releaseLock: (lock) => base.releaseLock(prefixLock(lock)),
107
+ extendLock: async (lock, ttlMs) => {
108
+ const prefixedLock = prefixLock(lock);
109
+ const extended = await base.extendLock(prefixedLock, ttlMs);
110
+ if (extended) lock.expiresAt = prefixedLock.expiresAt;
111
+ return extended;
112
+ },
113
+ forceReleaseLock: (threadId) => base.forceReleaseLock(prefixed(threadId)),
114
+ enqueue: (threadId, entry, maxSize) => base.enqueue(prefixed(threadId), entry, maxSize),
115
+ dequeue: (threadId) => base.dequeue(prefixed(threadId)),
116
+ queueDepth: (threadId) => base.queueDepth(prefixed(threadId)),
117
+ get: (key) => base.get(prefixed(key)),
118
+ getList: (key) => base.getList(prefixed(key)),
119
+ set: (key, value, ttlMs) => base.set(prefixed(key), value, ttlMs),
120
+ setIfNotExists: (key, value, ttlMs) => base.setIfNotExists(prefixed(key), value, ttlMs),
121
+ delete: (key) => base.delete(prefixed(key))
122
+ };
123
+ }
124
+ function createQueuedStateAdapter(base, options) {
125
+ const heartbeats = /* @__PURE__ */ new Map();
126
+ const shouldHeartbeatLock = (ttlMs) => ttlMs === ACTIVE_LOCK_TTL_MS;
127
+ const heartbeatKey = (lock) => `${lock.threadId}:${lock.token}`;
128
+ const stopHeartbeatByKey = (key) => {
129
+ const heartbeat = heartbeats.get(key);
130
+ if (!heartbeat) return;
131
+ clearInterval(heartbeat.timer);
132
+ heartbeats.delete(key);
133
+ };
134
+ const stopHeartbeat = (lock) => {
135
+ stopHeartbeatByKey(heartbeatKey(lock));
136
+ };
137
+ const stopHeartbeatsForThread = (threadId) => {
138
+ for (const [key, heartbeat] of heartbeats) if (heartbeat.lock.threadId === threadId) stopHeartbeatByKey(key);
139
+ };
140
+ const stopAllHeartbeats = () => {
141
+ for (const key of heartbeats.keys()) stopHeartbeatByKey(key);
142
+ };
143
+ const runHeartbeat = async (key) => {
144
+ const heartbeat = heartbeats.get(key);
145
+ if (!heartbeat || heartbeat.inFlight) return;
146
+ heartbeat.inFlight = true;
147
+ try {
148
+ if (Date.now() - heartbeat.startedAtMs >= options.activeLockMaxAgeMs) {
149
+ stopHeartbeatByKey(key);
150
+ return;
151
+ }
152
+ if (!await base.extendLock(heartbeat.lock, heartbeat.ttlMs)) {
153
+ stopHeartbeatByKey(key);
154
+ return;
155
+ }
156
+ heartbeat.lock.expiresAt = Date.now() + heartbeat.ttlMs;
157
+ } catch {} finally {
158
+ const current = heartbeats.get(key);
159
+ if (current === heartbeat) current.inFlight = false;
160
+ }
161
+ };
162
+ const startOrUpdateHeartbeat = (lock, ttlMs) => {
163
+ const key = heartbeatKey(lock);
164
+ const existing = heartbeats.get(key);
165
+ if (existing) {
166
+ existing.ttlMs = ttlMs;
167
+ return;
168
+ }
169
+ const timer = setInterval(() => {
170
+ runHeartbeat(key);
171
+ }, ACTIVE_LOCK_HEARTBEAT_MS);
172
+ timer.unref?.();
173
+ heartbeats.set(key, {
174
+ inFlight: false,
175
+ lock,
176
+ startedAtMs: Date.now(),
177
+ timer,
178
+ ttlMs
179
+ });
180
+ };
181
+ const acquireLock = async (threadId, ttlMs) => {
182
+ const lock = await base.acquireLock(threadId, ttlMs);
183
+ if (lock && shouldHeartbeatLock(ttlMs)) startOrUpdateHeartbeat(lock, ttlMs);
184
+ return lock;
185
+ };
186
+ return {
187
+ appendToList: (key, value, options) => base.appendToList(key, value, options),
188
+ connect: () => base.connect(),
189
+ disconnect: async () => {
190
+ stopAllHeartbeats();
191
+ await base.disconnect();
192
+ },
193
+ subscribe: (threadId) => base.subscribe(threadId),
194
+ unsubscribe: (threadId) => base.unsubscribe(threadId),
195
+ isSubscribed: (threadId) => base.isSubscribed(threadId),
196
+ acquireLock,
197
+ releaseLock: async (lock) => {
198
+ stopHeartbeat(lock);
199
+ await base.releaseLock(lock);
200
+ },
201
+ extendLock: async (lock, ttlMs) => {
202
+ const extended = await base.extendLock(lock, ttlMs);
203
+ if (extended) {
204
+ lock.expiresAt = Date.now() + ttlMs;
205
+ if (shouldHeartbeatLock(ttlMs)) startOrUpdateHeartbeat(lock, ttlMs);
206
+ else stopHeartbeat(lock);
207
+ } else stopHeartbeat(lock);
208
+ return extended;
209
+ },
210
+ forceReleaseLock: async (threadId) => {
211
+ stopHeartbeatsForThread(threadId);
212
+ await base.forceReleaseLock(threadId);
213
+ },
214
+ enqueue: (threadId, entry, maxSize) => base.enqueue(threadId, entry, maxSize),
215
+ dequeue: (threadId) => base.dequeue(threadId),
216
+ queueDepth: (threadId) => base.queueDepth(threadId),
217
+ get: (key) => base.get(key),
218
+ getList: (key) => base.getList(key),
219
+ set: (key, value, ttlMs) => base.set(key, value, ttlMs),
220
+ setIfNotExists: (key, value, ttlMs) => base.setIfNotExists(key, value, ttlMs),
221
+ delete: (key) => base.delete(key)
222
+ };
223
+ }
224
+ function withOptionalPrefix(base, prefix) {
225
+ return prefix ? createPrefixedStateAdapter(base, prefix) : base;
226
+ }
227
+ function createStateAdapter() {
228
+ const config = getChatConfig();
229
+ const activeLockMaxAgeMs = config.bot.turnTimeoutMs + ACTIVE_LOCK_TTL_MS;
230
+ if (config.state.adapter === "memory") {
231
+ redisStateAdapter = void 0;
232
+ return createQueuedStateAdapter(createConnectingStateAdapter(withOptionalPrefix(createMemoryState(), config.state.keyPrefix)), { activeLockMaxAgeMs });
233
+ }
234
+ if (!config.state.redisUrl) throw new Error("REDIS_URL is required for durable Slack thread state");
235
+ const redisState = createRedisState({ url: config.state.redisUrl });
236
+ redisStateAdapter = redisState;
237
+ return createQueuedStateAdapter(createConnectingStateAdapter(withOptionalPrefix(redisState, config.state.keyPrefix)), { activeLockMaxAgeMs });
238
+ }
239
+ function getOptionalRedisStateAdapter() {
240
+ getStateAdapter();
241
+ return redisStateAdapter;
242
+ }
243
+ async function getConnectedStateContext() {
244
+ const adapter = getStateAdapter();
245
+ await adapter.connect();
246
+ return {
247
+ redisStateAdapter: getOptionalRedisStateAdapter(),
248
+ stateAdapter: adapter
249
+ };
250
+ }
251
+ /** Return the Redis adapter only when the caller is using the default state adapter. */
252
+ async function getDefaultRedisStateAdapterFor(adapter) {
253
+ if (adapter !== stateAdapter) return;
254
+ const context = await getConnectedStateContext();
255
+ return context.stateAdapter === adapter ? context.redisStateAdapter : void 0;
256
+ }
257
+ function getStateAdapter() {
258
+ if (!stateAdapter) stateAdapter = createStateAdapter();
259
+ return stateAdapter;
260
+ }
261
+ async function disconnectStateAdapter() {
262
+ if (!stateAdapter) return;
263
+ try {
264
+ await stateAdapter.disconnect();
265
+ } finally {
266
+ stateAdapter = void 0;
267
+ redisStateAdapter = void 0;
268
+ }
269
+ }
270
+ export { acquireActiveLock as a, MUTATION_LOCK_TTL_MS as i, getDefaultRedisStateAdapterFor as n, fenceLock as o, getStateAdapter as r, withLock as s, disconnectStateAdapter as t };
@@ -1,4 +1,4 @@
1
- import { a as setUserAdminFromSql, d as getDb, n as listAdminUsersFromSql } from "./viewer-CGvvRqKp.js";
1
+ import { a as setUserAdminFromSql, d as getDb, n as listAdminUsersFromSql } from "./viewer-C-J0ewlH.js";
2
2
  import { CLI_USAGE } from "./cli/run.js";
3
3
  // src/cli/admin.ts
4
4
  /**