@sentry/junior 0.67.3 → 0.69.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.
- package/dist/app.js +1465 -814
- package/dist/build/virtual-config.d.ts +2 -2
- package/dist/chat/agent-dispatch/heartbeat.d.ts +2 -2
- package/dist/chat/agent-dispatch/store.d.ts +4 -1
- package/dist/chat/agent-dispatch/types.d.ts +2 -4
- package/dist/chat/agent-dispatch/validation.d.ts +3 -2
- package/dist/chat/credentials/context.d.ts +49 -24
- package/dist/chat/credentials/user-token-store.d.ts +6 -0
- package/dist/chat/destination.d.ts +12 -0
- package/dist/chat/ingress/message-router.d.ts +1 -1
- package/dist/chat/mcp/auth-store.d.ts +2 -0
- package/dist/chat/mcp/oauth.d.ts +2 -0
- package/dist/chat/oauth-flow.d.ts +7 -0
- package/dist/chat/plugins/agent-hooks.d.ts +9 -9
- package/dist/chat/plugins/auth/auth-token-placeholder.d.ts +2 -2
- package/dist/chat/plugins/auth/oauth-request.d.ts +3 -1
- package/dist/chat/plugins/credential-hooks.d.ts +34 -0
- package/dist/chat/plugins/logging.d.ts +1 -1
- package/dist/chat/plugins/state.d.ts +1 -1
- package/dist/chat/plugins/types.d.ts +19 -23
- package/dist/chat/respond.d.ts +2 -0
- package/dist/chat/runtime/reply-executor.d.ts +3 -1
- package/dist/chat/runtime/slack-runtime.d.ts +8 -3
- package/dist/chat/sandbox/egress-credentials.d.ts +33 -0
- package/dist/chat/sandbox/egress-schemas.d.ts +105 -0
- package/dist/chat/sandbox/egress-session.d.ts +17 -17
- package/dist/chat/sandbox/sandbox.d.ts +3 -0
- package/dist/chat/sandbox/session.d.ts +1 -0
- package/dist/chat/services/mcp-auth-orchestration.d.ts +2 -0
- package/dist/chat/services/pending-auth.d.ts +2 -0
- package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -0
- package/dist/chat/services/provider-retry.d.ts +13 -4
- package/dist/chat/services/timeout-resume.d.ts +2 -0
- package/dist/chat/services/turn-session-record.d.ts +6 -0
- package/dist/chat/slack/attachment-fetchers.d.ts +11 -0
- package/dist/chat/slack/footer.d.ts +2 -7
- package/dist/chat/state/conversation.d.ts +1 -0
- package/dist/chat/state/turn-session.d.ts +4 -0
- package/dist/chat/task-execution/queue.d.ts +2 -0
- package/dist/chat/task-execution/store.d.ts +5 -0
- package/dist/chat/task-execution/vercel-callback.d.ts +4 -0
- package/dist/chat/task-execution/vercel-queue.d.ts +2 -0
- package/dist/chat/task-execution/worker.d.ts +4 -2
- package/dist/chat/tools/slack/context.d.ts +3 -0
- package/dist/chat/tools/types.d.ts +21 -2
- package/dist/chunk-76YMBKW7.js +326 -0
- package/dist/{chunk-PIVOJIUD.js → chunk-B5HKWWQB.js} +9 -5
- package/dist/chunk-BBXYXOJW.js +1858 -0
- package/dist/{chunk-V47RLIO2.js → chunk-GT67ZWZQ.js} +4 -4
- package/dist/{chunk-75UZ4JLC.js → chunk-IGLNC5H6.js} +21 -9
- package/dist/{chunk-EBVQXCD2.js → chunk-JS4HURDT.js} +362 -280
- package/dist/{chunk-UQQSW7QB.js → chunk-N3MORKTH.js} +74 -331
- package/dist/chunk-R62YWUNO.js +264 -0
- package/dist/{chunk-OIIXZOOC.js → chunk-UXG6TU2U.js} +311 -2015
- package/dist/cli/check.js +4 -4
- package/dist/cli/snapshot-warmup.js +5 -4
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +21 -19
- package/dist/plugins.d.ts +2 -2
- package/dist/reporting.d.ts +2 -2
- package/dist/reporting.js +13 -11
- package/package.json +6 -4
- package/dist/chat/plugins/auth/github-app-broker.d.ts +0 -4
- package/dist/chat/plugins/github-permissions.d.ts +0 -11
- package/dist/chat/queue/thread-message-dispatcher.d.ts +0 -33
- package/dist/chunk-KVZL5NZS.js +0 -519
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getChatConfig
|
|
3
|
+
} from "./chunk-JS4HURDT.js";
|
|
4
|
+
|
|
5
|
+
// src/chat/state/adapter.ts
|
|
6
|
+
import { createMemoryState } from "@chat-adapter/state-memory";
|
|
7
|
+
import { createRedisState } from "@chat-adapter/state-redis";
|
|
8
|
+
var ACTIVE_LOCK_TTL_MS = 9e4;
|
|
9
|
+
var ACTIVE_LOCK_HEARTBEAT_MS = 3e4;
|
|
10
|
+
var stateAdapter;
|
|
11
|
+
var redisStateAdapter;
|
|
12
|
+
function createPrefixedStateAdapter(base, prefix) {
|
|
13
|
+
const prefixed = (value) => `${prefix}:${value}`;
|
|
14
|
+
const unprefixed = (value) => value.startsWith(`${prefix}:`) ? value.slice(prefix.length + 1) : value;
|
|
15
|
+
const prefixLock = (lock) => ({
|
|
16
|
+
...lock,
|
|
17
|
+
threadId: prefixed(lock.threadId)
|
|
18
|
+
});
|
|
19
|
+
const unprefixLock = (lock) => ({
|
|
20
|
+
...lock,
|
|
21
|
+
threadId: unprefixed(lock.threadId)
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
appendToList: (key, value, options) => base.appendToList(prefixed(key), value, options),
|
|
25
|
+
connect: () => base.connect(),
|
|
26
|
+
disconnect: () => base.disconnect(),
|
|
27
|
+
subscribe: (threadId) => base.subscribe(prefixed(threadId)),
|
|
28
|
+
unsubscribe: (threadId) => base.unsubscribe(prefixed(threadId)),
|
|
29
|
+
isSubscribed: (threadId) => base.isSubscribed(prefixed(threadId)),
|
|
30
|
+
acquireLock: async (threadId, ttlMs) => {
|
|
31
|
+
const lock = await base.acquireLock(prefixed(threadId), ttlMs);
|
|
32
|
+
return lock ? unprefixLock(lock) : null;
|
|
33
|
+
},
|
|
34
|
+
releaseLock: (lock) => base.releaseLock(prefixLock(lock)),
|
|
35
|
+
extendLock: async (lock, ttlMs) => {
|
|
36
|
+
const prefixedLock = prefixLock(lock);
|
|
37
|
+
const extended = await base.extendLock(prefixedLock, ttlMs);
|
|
38
|
+
if (extended) {
|
|
39
|
+
lock.expiresAt = prefixedLock.expiresAt;
|
|
40
|
+
}
|
|
41
|
+
return extended;
|
|
42
|
+
},
|
|
43
|
+
forceReleaseLock: (threadId) => base.forceReleaseLock(prefixed(threadId)),
|
|
44
|
+
enqueue: (threadId, entry, maxSize) => base.enqueue(prefixed(threadId), entry, maxSize),
|
|
45
|
+
dequeue: (threadId) => base.dequeue(prefixed(threadId)),
|
|
46
|
+
queueDepth: (threadId) => base.queueDepth(prefixed(threadId)),
|
|
47
|
+
get: (key) => base.get(prefixed(key)),
|
|
48
|
+
getList: (key) => base.getList(prefixed(key)),
|
|
49
|
+
set: (key, value, ttlMs) => base.set(prefixed(key), value, ttlMs),
|
|
50
|
+
setIfNotExists: (key, value, ttlMs) => base.setIfNotExists(prefixed(key), value, ttlMs),
|
|
51
|
+
delete: (key) => base.delete(prefixed(key))
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function createQueuedStateAdapter(base, options) {
|
|
55
|
+
const heartbeats = /* @__PURE__ */ new Map();
|
|
56
|
+
const effectiveLockTtlMs = (ttlMs) => Math.max(ttlMs, ACTIVE_LOCK_TTL_MS);
|
|
57
|
+
const shouldHeartbeatLock = (ttlMs) => ttlMs <= ACTIVE_LOCK_TTL_MS;
|
|
58
|
+
const heartbeatKey = (lock) => `${lock.threadId}:${lock.token}`;
|
|
59
|
+
const stopHeartbeatByKey = (key) => {
|
|
60
|
+
const heartbeat = heartbeats.get(key);
|
|
61
|
+
if (!heartbeat) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
clearInterval(heartbeat.timer);
|
|
65
|
+
heartbeats.delete(key);
|
|
66
|
+
};
|
|
67
|
+
const stopHeartbeat = (lock) => {
|
|
68
|
+
stopHeartbeatByKey(heartbeatKey(lock));
|
|
69
|
+
};
|
|
70
|
+
const stopHeartbeatsForThread = (threadId) => {
|
|
71
|
+
for (const [key, heartbeat] of heartbeats) {
|
|
72
|
+
if (heartbeat.lock.threadId === threadId) {
|
|
73
|
+
stopHeartbeatByKey(key);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const stopAllHeartbeats = () => {
|
|
78
|
+
for (const key of heartbeats.keys()) {
|
|
79
|
+
stopHeartbeatByKey(key);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const runHeartbeat = async (key) => {
|
|
83
|
+
const heartbeat = heartbeats.get(key);
|
|
84
|
+
if (!heartbeat || heartbeat.inFlight) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
heartbeat.inFlight = true;
|
|
88
|
+
try {
|
|
89
|
+
if (Date.now() - heartbeat.startedAtMs >= options.activeLockMaxAgeMs) {
|
|
90
|
+
stopHeartbeatByKey(key);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const extended = await base.extendLock(heartbeat.lock, heartbeat.ttlMs);
|
|
94
|
+
if (!extended) {
|
|
95
|
+
stopHeartbeatByKey(key);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
heartbeat.lock.expiresAt = Date.now() + heartbeat.ttlMs;
|
|
99
|
+
} catch {
|
|
100
|
+
} finally {
|
|
101
|
+
const current = heartbeats.get(key);
|
|
102
|
+
if (current === heartbeat) {
|
|
103
|
+
current.inFlight = false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const startOrUpdateHeartbeat = (lock, ttlMs) => {
|
|
108
|
+
const key = heartbeatKey(lock);
|
|
109
|
+
const existing = heartbeats.get(key);
|
|
110
|
+
if (existing) {
|
|
111
|
+
existing.ttlMs = ttlMs;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const timer = setInterval(() => {
|
|
115
|
+
void runHeartbeat(key);
|
|
116
|
+
}, ACTIVE_LOCK_HEARTBEAT_MS);
|
|
117
|
+
timer.unref?.();
|
|
118
|
+
heartbeats.set(key, {
|
|
119
|
+
inFlight: false,
|
|
120
|
+
lock,
|
|
121
|
+
startedAtMs: Date.now(),
|
|
122
|
+
timer,
|
|
123
|
+
ttlMs
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
const acquireLock = async (threadId, ttlMs) => {
|
|
127
|
+
const effectiveTtlMs = effectiveLockTtlMs(ttlMs);
|
|
128
|
+
const lock = await base.acquireLock(threadId, effectiveTtlMs);
|
|
129
|
+
if (lock && shouldHeartbeatLock(ttlMs)) {
|
|
130
|
+
startOrUpdateHeartbeat(lock, effectiveTtlMs);
|
|
131
|
+
}
|
|
132
|
+
return lock;
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
appendToList: (key, value, options2) => base.appendToList(key, value, options2),
|
|
136
|
+
connect: () => base.connect(),
|
|
137
|
+
disconnect: async () => {
|
|
138
|
+
stopAllHeartbeats();
|
|
139
|
+
await base.disconnect();
|
|
140
|
+
},
|
|
141
|
+
subscribe: (threadId) => base.subscribe(threadId),
|
|
142
|
+
unsubscribe: (threadId) => base.unsubscribe(threadId),
|
|
143
|
+
isSubscribed: (threadId) => base.isSubscribed(threadId),
|
|
144
|
+
acquireLock,
|
|
145
|
+
releaseLock: async (lock) => {
|
|
146
|
+
stopHeartbeat(lock);
|
|
147
|
+
await base.releaseLock(lock);
|
|
148
|
+
},
|
|
149
|
+
extendLock: async (lock, ttlMs) => {
|
|
150
|
+
const effectiveTtlMs = effectiveLockTtlMs(ttlMs);
|
|
151
|
+
const extended = await base.extendLock(lock, effectiveTtlMs);
|
|
152
|
+
if (extended) {
|
|
153
|
+
lock.expiresAt = Date.now() + effectiveTtlMs;
|
|
154
|
+
if (shouldHeartbeatLock(ttlMs)) {
|
|
155
|
+
startOrUpdateHeartbeat(lock, effectiveTtlMs);
|
|
156
|
+
} else {
|
|
157
|
+
stopHeartbeat(lock);
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
stopHeartbeat(lock);
|
|
161
|
+
}
|
|
162
|
+
return extended;
|
|
163
|
+
},
|
|
164
|
+
forceReleaseLock: async (threadId) => {
|
|
165
|
+
stopHeartbeatsForThread(threadId);
|
|
166
|
+
await base.forceReleaseLock(threadId);
|
|
167
|
+
},
|
|
168
|
+
enqueue: (threadId, entry, maxSize) => base.enqueue(threadId, entry, maxSize),
|
|
169
|
+
dequeue: (threadId) => base.dequeue(threadId),
|
|
170
|
+
queueDepth: (threadId) => base.queueDepth(threadId),
|
|
171
|
+
get: (key) => base.get(key),
|
|
172
|
+
getList: (key) => base.getList(key),
|
|
173
|
+
set: (key, value, ttlMs) => base.set(key, value, ttlMs),
|
|
174
|
+
setIfNotExists: (key, value, ttlMs) => base.setIfNotExists(key, value, ttlMs),
|
|
175
|
+
delete: (key) => base.delete(key)
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function withOptionalPrefix(base, prefix) {
|
|
179
|
+
return prefix ? createPrefixedStateAdapter(base, prefix) : base;
|
|
180
|
+
}
|
|
181
|
+
function createStateAdapter() {
|
|
182
|
+
const config = getChatConfig();
|
|
183
|
+
const activeLockMaxAgeMs = config.bot.turnTimeoutMs + ACTIVE_LOCK_TTL_MS;
|
|
184
|
+
if (config.state.adapter === "memory") {
|
|
185
|
+
redisStateAdapter = void 0;
|
|
186
|
+
return createQueuedStateAdapter(
|
|
187
|
+
withOptionalPrefix(createMemoryState(), config.state.keyPrefix),
|
|
188
|
+
{ activeLockMaxAgeMs }
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
if (!config.state.redisUrl) {
|
|
192
|
+
throw new Error("REDIS_URL is required for durable Slack thread state");
|
|
193
|
+
}
|
|
194
|
+
const redisState = createRedisState({
|
|
195
|
+
url: config.state.redisUrl
|
|
196
|
+
});
|
|
197
|
+
redisStateAdapter = redisState;
|
|
198
|
+
return createQueuedStateAdapter(
|
|
199
|
+
withOptionalPrefix(redisState, config.state.keyPrefix),
|
|
200
|
+
{ activeLockMaxAgeMs }
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
function getOptionalRedisStateAdapter() {
|
|
204
|
+
getStateAdapter();
|
|
205
|
+
return redisStateAdapter;
|
|
206
|
+
}
|
|
207
|
+
async function getConnectedStateContext() {
|
|
208
|
+
const adapter = getStateAdapter();
|
|
209
|
+
await adapter.connect();
|
|
210
|
+
return {
|
|
211
|
+
redisStateAdapter: getOptionalRedisStateAdapter(),
|
|
212
|
+
stateAdapter: adapter
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function getStateAdapter() {
|
|
216
|
+
if (!stateAdapter) {
|
|
217
|
+
stateAdapter = createStateAdapter();
|
|
218
|
+
}
|
|
219
|
+
return stateAdapter;
|
|
220
|
+
}
|
|
221
|
+
async function disconnectStateAdapter() {
|
|
222
|
+
if (!stateAdapter) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
await stateAdapter.disconnect();
|
|
227
|
+
} finally {
|
|
228
|
+
stateAdapter = void 0;
|
|
229
|
+
redisStateAdapter = void 0;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/chat/sandbox/paths.ts
|
|
234
|
+
function normalizeWorkspaceRoot(input) {
|
|
235
|
+
const candidate = (input ?? "").trim();
|
|
236
|
+
if (!candidate) {
|
|
237
|
+
return "/vercel/sandbox";
|
|
238
|
+
}
|
|
239
|
+
const normalized = candidate.replace(/\/+$/, "");
|
|
240
|
+
return normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
241
|
+
}
|
|
242
|
+
var SANDBOX_WORKSPACE_ROOT = normalizeWorkspaceRoot(
|
|
243
|
+
process.env.VERCEL_SANDBOX_WORKSPACE_DIR
|
|
244
|
+
);
|
|
245
|
+
var SANDBOX_SKILLS_ROOT = `${SANDBOX_WORKSPACE_ROOT}/skills`;
|
|
246
|
+
var SANDBOX_DATA_ROOT = `${SANDBOX_WORKSPACE_ROOT}/data`;
|
|
247
|
+
function sandboxSkillDir(skillName) {
|
|
248
|
+
return `${SANDBOX_SKILLS_ROOT}/${skillName}`;
|
|
249
|
+
}
|
|
250
|
+
function sandboxSkillFile(skillName) {
|
|
251
|
+
return `${sandboxSkillDir(skillName)}/SKILL.md`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export {
|
|
255
|
+
ACTIVE_LOCK_TTL_MS,
|
|
256
|
+
getConnectedStateContext,
|
|
257
|
+
getStateAdapter,
|
|
258
|
+
disconnectStateAdapter,
|
|
259
|
+
SANDBOX_WORKSPACE_ROOT,
|
|
260
|
+
SANDBOX_SKILLS_ROOT,
|
|
261
|
+
SANDBOX_DATA_ROOT,
|
|
262
|
+
sandboxSkillDir,
|
|
263
|
+
sandboxSkillFile
|
|
264
|
+
};
|