@sentry/junior 0.297.0 → 0.299.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/{actor-6jsm_v96.js → actor-D2iXzvlN.js} +2 -1
- package/dist/{state-DFnmLmfn.js → adapter-AgCNqqsG.js} +49 -133
- package/dist/{admin-tmGIw4KS.js → admin-1VwEXztm.js} +2 -2
- package/dist/{agent-runner-CneTquAE.js → agent-runner-Ciet8_nn.js} +1067 -1353
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +8 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +125 -43
- package/dist/{app-BJojZ7HL.d.ts → app--ky-Eu33.d.ts} +6 -4
- package/dist/app.d.ts +1 -1
- package/dist/app.js +126 -299
- package/dist/{automation-BrP6ImrC.js → automation-M3RFJUBf.js} +1 -1
- package/dist/{background-compaction-queue-CwfJy3Cd.js → background-compaction-queue-CnimvRdk.js} +4 -4
- package/dist/{briefs-uFTuhMqA.js → briefs-CwzvgdCa.js} +4 -4
- package/dist/{catalog-runtime-0kuQqYL4.js → catalog-runtime-DaBaHY7u.js} +1 -1
- package/dist/cli/chat.js +17 -17
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +5 -5
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +4 -4
- package/dist/{config-Dj9M_nqB.js → config-CAXIpWQb.js} +80 -6
- package/dist/{connections-B96JUM5o.js → connections-Dy0hPdUq.js} +6 -6
- package/dist/continue-in-slack-DIOjFj76.js +176 -0
- package/dist/{conversation-CvcBU1z2.js → conversation-fCWD9Az3.js} +73 -13
- package/dist/{conversation-feed-BSMlGZnS.js → conversation-feed-BPK8vkkZ.js} +88 -3
- package/dist/{conversation-privacy-DI29jbZV.js → conversation-privacy-DUgtRkf8.js} +1 -1
- package/dist/{conversation-turn-CZWBr091.js → conversation-turn-DkJB6yMF.js} +85 -68
- package/dist/{credential-sync-Blhx4_xf.js → credential-sync-RX24Y8aY.js} +18 -18
- package/dist/{db-CrtyFRz7.d.ts → db-B07FtU9g.d.ts} +1 -1
- package/dist/{db-Br0tfAo7.js → db-COYOGzYS.js} +171 -12
- package/dist/{executor-BMPipFVA.js → executor-BWmAgSyi.js} +40 -11
- package/dist/{media-BepyEUNm.js → history-IjdmO_r6.js} +1 -85
- package/dist/instrumentation.js +2 -2
- package/dist/lineage-D-5jm_oj.js +37 -0
- package/dist/{logging-CQjlDQYX.js → logging-DPLEa8Bn.js} +1 -1
- package/dist/media-BAHvgkok.js +85 -0
- package/dist/{message-BOZEIuxy.js → message-BIHR1yRk.js} +9 -10
- package/dist/model-input-BPZYH8Nd.js +82 -0
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +17 -9
- package/dist/{oauth-callback-server-V_DuMuNX.js → oauth-callback-server-R7qvSzFG.js} +2 -2
- package/dist/{plugins-HYh_JOdw.js → plugins-CBW2Prb_.js} +1 -1
- package/dist/{projection-B08mfi0u.js → projection-DEdP1q6f.js} +261 -36
- package/dist/{prompt-BlutWLNt.js → prompt-4M98h_tC.js} +4 -4
- package/dist/{registry-BDWgCJDf.js → registry-BTKmKM-r.js} +3 -3
- package/dist/{resolve-2Z_o_SsI.js → resolve-B8hXNVZ3.js} +3 -3
- package/dist/{result-CAujiaci.js → result-g-XAaOj6.js} +158 -69
- package/dist/{runner-D2Chc02N.js → runner-BlPSA5A8.js} +9 -9
- package/dist/{sandbox-egress-signals-CFoJduFj.js → sandbox-egress-signals-Pai-MzEY.js} +1 -1
- package/dist/{schema-Bqa5NbcP.js → schema-BNnY_trV.js} +47 -7
- package/dist/{schema-Ce2XCS7O.d.ts → schema-DbuWR-DN.d.ts} +663 -346
- package/dist/{service-account-C9kRQEb_.js → service-account-9OLNQMyz.js} +4 -4
- package/dist/{service-account-CERfXEVU.js → service-account-BYGZ08DQ.js} +3 -3
- package/dist/session-stop-2XJrcNCy.js +3356 -0
- package/dist/{skills-B0m1nZ_j.js → skills-DpBQoeHV.js} +3 -3
- package/dist/slack-conversation-unfurl-BcDIWo67.js +370 -0
- package/dist/spawn-09GssFod.js +73 -0
- package/dist/state-Cufq0_rH.js +132 -0
- package/dist/{user-input-request-CXNIov9n.js → statuses-B8mUfghF.js} +30 -25
- package/dist/{stop-BCH9VNGf.js → stop-U7iUrR1g.js} +6011 -5773
- package/dist/{store-B59rOYbS.js → store-BHiaHCQu.js} +24 -4
- package/dist/{store-m5bmdmsP.js → store-CSgUTMdv.js} +10 -10
- package/dist/{task-queue-N0kuCknH.js → task-queue-bMNq0clp.js} +4 -4
- package/dist/{task-runner-COOwR8qm.js → task-runner-B__rxwxU.js} +10 -10
- package/dist/{thread-context-Cd44z_W5.js → thread-context-d0ceWbVT.js} +18 -18
- package/dist/{turn-session-routing-BlCtVFRN.js → turn-session-routing-BVZHBFCF.js} +5 -5
- package/dist/turn-user-message-BEw7acTP.js +355 -0
- package/dist/users-BK3dbxZL.js +424 -0
- package/dist/{validation-Ba2OcUse.js → validation-BDVJjO2E.js} +1 -1
- package/dist/{version-KNDzIAh6.js → version-DQgZoQ3D.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-BPpuN2f9.js → viewer-CAWfFo29.js} +25 -54
- package/dist/{warmup-Bskrwmk1.js → warmup-9ySPacF9.js} +1137 -143
- package/dist/{worker-B1skZlit.js → worker-D8jJO-WO.js} +8 -7
- package/migrations/0104_code_change_draft.sql +1 -0
- package/migrations/0105_attachment_uploads.sql +14 -0
- package/migrations/0106_conversation_agent_config.sql +1 -0
- package/migrations/meta/0104_snapshot.json +4516 -0
- package/migrations/meta/0105_snapshot.json +4611 -0
- package/migrations/meta/0106_snapshot.json +4617 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +4 -4
- package/dist/attempt-selection-ClP3MMPr.js +0 -61
- package/dist/locks-D-0h111u.js +0 -48
- package/dist/notification-gusCgdQ6.js +0 -1284
- package/dist/prompt-input-Dxn8cDC0.js +0 -1424
- package/dist/session-stop-B-I1rAS1.js +0 -181
- package/dist/spawn-CwMjRRtn.js +0 -80
- package/dist/turn-cancel-DDu8TOwt.js +0 -201
- package/dist/turn-user-message-ygLG3ylQ.js +0 -641
- package/dist/turn-wake-DmQec4AG.js +0 -161
- package/dist/{oauth-relay-CsfIazeF.js → oauth-relay-DRzq73b6.js} +1 -1
|
@@ -19,6 +19,7 @@ function slackMessageTsFromMs(ms) {
|
|
|
19
19
|
const slackChannelIdSchema = z.string().regex(/^[CDG][A-Z0-9]+$/).brand();
|
|
20
20
|
const slackTeamIdSchema = z.string().regex(/^T[A-Z0-9]+$/).brand();
|
|
21
21
|
const slackUserIdSchema = z.string().regex(/^[UW][A-Z0-9]+$/).brand();
|
|
22
|
+
const slackBotIdSchema = z.string().regex(/^B[A-Z0-9]+$/).brand();
|
|
22
23
|
const SLACK_CHANNEL_MENTION_RE = /^<#([CDG][A-Z0-9]+)(?:\|[^>]*)?>$/;
|
|
23
24
|
function slackChannelReferenceCandidate(value) {
|
|
24
25
|
const trimmed = value.trim();
|
|
@@ -205,4 +206,4 @@ function createSlackResumeActor(args) {
|
|
|
205
206
|
if (!actor || actor.platform !== "slack") throw new Error("Slack actor requires team and user ids");
|
|
206
207
|
return actor;
|
|
207
208
|
}
|
|
208
|
-
export {
|
|
209
|
+
export { slackUserIdSchema as _, isSlackUserId as a, slackMessageTsSchema as b, parseStoredSlackActor as c, parseSlackChannelReferenceId as d, parseSlackTeamId as f, slackTeamIdSchema as g, slackChannelIdSchema as h, isActorUserId as i, toStoredSlackActor as l, slackBotIdSchema as m, createSlackActor as n, isUserActor as o, parseSlackUserId as p, createSlackResumeActor as r, parseActorUserId as s, createActor as t, parseSlackChannelId as u, parseSlackMessageTs as v, slackMessageTsFromMs as y };
|
|
@@ -1,9 +1,53 @@
|
|
|
1
|
-
import { i as getChatConfig } from "./config-
|
|
2
|
-
import { h as logWarn } from "./logging-CQjlDQYX.js";
|
|
3
|
-
import { t as ACTIVE_LOCK_TTL_MS } from "./locks-D-0h111u.js";
|
|
4
|
-
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
1
|
+
import { i as getChatConfig } from "./config-CAXIpWQb.js";
|
|
5
2
|
import { createMemoryState } from "@chat-adapter/state-memory";
|
|
6
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 ttlMs = options.ttlMs ?? 9e4;
|
|
22
|
+
const startedAtMs = Date.now();
|
|
23
|
+
let lock;
|
|
24
|
+
while (true) {
|
|
25
|
+
lock = await state.acquireLock(key, ttlMs);
|
|
26
|
+
if (lock) break;
|
|
27
|
+
if (Date.now() - startedAtMs >= (options.waitMs ?? 0)) return { acquired: false };
|
|
28
|
+
await setTimeout(options.retryMs ?? 25, void 0, { ref: false });
|
|
29
|
+
}
|
|
30
|
+
const heartbeat = options.keepAlive ? setInterval(() => void state.extendLock(lock, ttlMs).catch(() => void 0), Math.max(1, Math.floor(ttlMs / 3))) : void 0;
|
|
31
|
+
heartbeat?.unref();
|
|
32
|
+
try {
|
|
33
|
+
return {
|
|
34
|
+
acquired: true,
|
|
35
|
+
value: await run(lock)
|
|
36
|
+
};
|
|
37
|
+
} finally {
|
|
38
|
+
if (heartbeat) clearInterval(heartbeat);
|
|
39
|
+
await state.releaseLock(lock);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Prove lock ownership immediately before a blind write.
|
|
44
|
+
*
|
|
45
|
+
* Whole-record mutations must stop if their lock expired rather than overwrite
|
|
46
|
+
* state committed by a newer owner.
|
|
47
|
+
*/
|
|
48
|
+
async function fenceLock(state, lock, ttlMs = MUTATION_LOCK_TTL_MS) {
|
|
49
|
+
if (!await state.extendLock(lock, ttlMs)) throw new Error(`Lock ownership was lost before write for ${lock.threadId}`);
|
|
50
|
+
}
|
|
7
51
|
// src/chat/state/adapter.ts
|
|
8
52
|
const ACTIVE_LOCK_HEARTBEAT_MS = 3e4;
|
|
9
53
|
const REDIS_STATE_KEY_PREFIX = "chat-sdk";
|
|
@@ -255,132 +299,4 @@ async function disconnectStateAdapter() {
|
|
|
255
299
|
redisStateAdapter = void 0;
|
|
256
300
|
}
|
|
257
301
|
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Encrypt secrets that Junior keeps at rest, such as provider credentials.
|
|
261
|
-
*
|
|
262
|
-
* AES-256-GCM with keys from `JUNIOR_ENCRYPTION_KEYS` (see `keyring.ts`).
|
|
263
|
-
* Each value is bound to a context, usually its storage key, and to its key
|
|
264
|
-
* id as additional authenticated data. A value copied to another key does not
|
|
265
|
-
* decrypt.
|
|
266
|
-
*
|
|
267
|
-
* New values use the active key. Any listed key decrypts. A value from a key
|
|
268
|
-
* that is not active reports `stale`, so its owner can save it again with the
|
|
269
|
-
* active key. A value that cannot be decrypted gives `UnreadableSecretError`:
|
|
270
|
-
* `unknown_key` when its key id is not listed, `invalid` when it is malformed,
|
|
271
|
-
* altered, or bound to another context.
|
|
272
|
-
*
|
|
273
|
-
* There is no per-value salt. The keys are random, not passwords, and each
|
|
274
|
-
* value has a random IV. The storage key in the AAD already names the
|
|
275
|
-
* identity that owns the value.
|
|
276
|
-
*
|
|
277
|
-
* Envelope: `jenc:v1:<keyId>:<iv>.<ciphertext>.<tag>` (base64url parts).
|
|
278
|
-
*/
|
|
279
|
-
const ENVELOPE_PREFIX = "jenc:v1:";
|
|
280
|
-
const ALGORITHM = "aes-256-gcm";
|
|
281
|
-
const IV_BYTES = 12;
|
|
282
|
-
const TAG_BYTES = 16;
|
|
283
|
-
/** A stored secret that cannot be decrypted with the configured keys. */
|
|
284
|
-
var UnreadableSecretError = class extends Error {
|
|
285
|
-
reason;
|
|
286
|
-
constructor(reason) {
|
|
287
|
-
super(reason === "unknown_key" ? "Stored secret was encrypted with a key that is not configured" : "Stored secret is malformed or failed authentication");
|
|
288
|
-
this.name = "UnreadableSecretError";
|
|
289
|
-
this.reason = reason;
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
function additionalData(keyId, context) {
|
|
293
|
-
return Buffer.from(`${ENVELOPE_PREFIX}${keyId}\0${context}`, "utf8");
|
|
294
|
-
}
|
|
295
|
-
/** Check whether a stored value is an encryption envelope. */
|
|
296
|
-
function isEncryptedSecret(value) {
|
|
297
|
-
return typeof value === "string" && value.startsWith(ENVELOPE_PREFIX);
|
|
298
|
-
}
|
|
299
|
-
/** Encrypt one secret with the active key and bind it to `context`. */
|
|
300
|
-
function encryptSecret(plaintext, context, keyring = getChatConfig().encryption) {
|
|
301
|
-
const { id, key } = keyring.active;
|
|
302
|
-
const iv = randomBytes(IV_BYTES);
|
|
303
|
-
const cipher = createCipheriv(ALGORITHM, key, iv, { authTagLength: TAG_BYTES });
|
|
304
|
-
cipher.setAAD(additionalData(id, context));
|
|
305
|
-
const parts = [
|
|
306
|
-
iv,
|
|
307
|
-
Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]),
|
|
308
|
-
cipher.getAuthTag()
|
|
309
|
-
].map((part) => part.toString("base64url"));
|
|
310
|
-
return `${ENVELOPE_PREFIX}${id}:${parts.join(".")}`;
|
|
311
|
-
}
|
|
312
|
-
/** Decrypt an `encryptSecret` envelope with the same `context`. */
|
|
313
|
-
function decryptSecret(envelope, context, keyring = getChatConfig().encryption) {
|
|
314
|
-
if (!isEncryptedSecret(envelope)) throw new Error("Stored secret is not an encryption envelope");
|
|
315
|
-
const [keyId, payload] = envelope.slice(8).split(":");
|
|
316
|
-
const [iv, ciphertext, tag] = (payload ?? "").split(".").map((part) => Buffer.from(part, "base64url"));
|
|
317
|
-
if (!keyId || !iv || iv.length !== IV_BYTES || !ciphertext || !tag || tag.length !== TAG_BYTES) throw new UnreadableSecretError("invalid");
|
|
318
|
-
const match = keyring.keys.find((candidate) => candidate.id === keyId);
|
|
319
|
-
if (!match) throw new UnreadableSecretError("unknown_key");
|
|
320
|
-
const decipher = createDecipheriv(ALGORITHM, match.key, iv, { authTagLength: TAG_BYTES });
|
|
321
|
-
decipher.setAAD(additionalData(keyId, context));
|
|
322
|
-
decipher.setAuthTag(tag);
|
|
323
|
-
let text;
|
|
324
|
-
try {
|
|
325
|
-
text = Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
|
|
326
|
-
} catch {
|
|
327
|
-
throw new UnreadableSecretError("invalid");
|
|
328
|
-
}
|
|
329
|
-
return {
|
|
330
|
-
stale: match.id !== keyring.active.id,
|
|
331
|
-
text
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
// src/chat/encryption/state.ts
|
|
335
|
-
/**
|
|
336
|
-
* Decrypt one stored envelope. The storage key is the encryption context.
|
|
337
|
-
* A value that cannot be decrypted, such as one from a key that is no longer
|
|
338
|
-
* configured or one that was altered, reads as missing. The owner then asks
|
|
339
|
-
* for the credential again and saves it with the active key.
|
|
340
|
-
*/
|
|
341
|
-
function decode(key, envelope) {
|
|
342
|
-
let decrypted;
|
|
343
|
-
try {
|
|
344
|
-
decrypted = decryptSecret(envelope, key);
|
|
345
|
-
} catch (error) {
|
|
346
|
-
if (!(error instanceof UnreadableSecretError)) throw error;
|
|
347
|
-
logWarn("encryption.secret_unreadable", { "error.type": error.reason });
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
return {
|
|
351
|
-
stale: decrypted.stale,
|
|
352
|
-
value: JSON.parse(decrypted.text)
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Wrap a state adapter so values are JSON-encoded and encrypted before they
|
|
357
|
-
* reach storage. Keys and TTLs stay readable. Use it for credentials and
|
|
358
|
-
* other secrets; delete, lock, and keep plain state on the base adapter.
|
|
359
|
-
*/
|
|
360
|
-
function createEncryptedState(state) {
|
|
361
|
-
return {
|
|
362
|
-
async get(key) {
|
|
363
|
-
const stored = await state.get(key);
|
|
364
|
-
if (!isEncryptedSecret(stored)) return void 0;
|
|
365
|
-
return decode(key, stored)?.value;
|
|
366
|
-
},
|
|
367
|
-
async set(key, value, ttlMs) {
|
|
368
|
-
await state.set(key, encryptSecret(JSON.stringify(value), key), ttlMs);
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Read a value and report whether it is stale: encrypted with a key that is
|
|
374
|
-
* not active, or saved before encryption. Long-lived owners save stale values
|
|
375
|
-
* again, so they move to the active key.
|
|
376
|
-
*/
|
|
377
|
-
async function readEncryptedState(state, key) {
|
|
378
|
-
const stored = await state.get(key);
|
|
379
|
-
if (stored === null || stored === void 0) return void 0;
|
|
380
|
-
if (!isEncryptedSecret(stored)) return {
|
|
381
|
-
stale: true,
|
|
382
|
-
value: stored
|
|
383
|
-
};
|
|
384
|
-
return decode(key, stored);
|
|
385
|
-
}
|
|
386
|
-
export { getStateAdapter as a, getDefaultRedisStateAdapterFor as i, readEncryptedState as n, getStateValues as o, disconnectStateAdapter as r, setStateValues as s, createEncryptedState as t };
|
|
302
|
+
export { setStateValues as a, fenceLock as c, getStateValues as i, withLock as l, getDefaultRedisStateAdapterFor as n, MUTATION_LOCK_TTL_MS as o, getStateAdapter as r, acquireActiveLock as s, disconnectStateAdapter as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as getDb } from "./db-
|
|
2
|
-
import { r as listAdminUsersFromSql, u as setUserAdminFromSql } from "./viewer-
|
|
1
|
+
import { o as getDb } from "./db-COYOGzYS.js";
|
|
2
|
+
import { r as listAdminUsersFromSql, u as setUserAdminFromSql } from "./viewer-CAWfFo29.js";
|
|
3
3
|
import { CLI_USAGE } from "./cli/run.js";
|
|
4
4
|
// src/cli/admin.ts
|
|
5
5
|
/**
|