@sentry/junior 0.312.0 → 0.314.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 (115) hide show
  1. package/dist/{adapter-iIq7ihf7.js → adapter-JARQvoLw.js} +1 -2
  2. package/dist/{adapter-context-BRjEWRy1.js → adapter-context-B4BrJZuS.js} +2 -2
  3. package/dist/{admin-DhInw5K9.js → admin-BXGAySz0.js} +1 -1
  4. package/dist/{agent-runner-C9iDurwX.js → agent-runner-qZU5TR8i.js} +865 -138
  5. package/dist/agent-update-cS7Z9mnG.js +26 -0
  6. package/dist/agent-update-delivery-CZ5M8RDa.js +85 -0
  7. package/dist/api/schema.d.ts +2 -2
  8. package/dist/api/schema.js +6 -6
  9. package/dist/api.d.ts +1 -1
  10. package/dist/api.js +340 -106
  11. package/dist/{app-DRFrC8Mw.d.ts → app-D7tKnw9a.d.ts} +4 -21
  12. package/dist/app.d.ts +2 -2
  13. package/dist/app.js +80 -171
  14. package/dist/{background-compaction-queue-DrKi7w3d.js → background-compaction-queue-C_uIBUvS.js} +6 -17
  15. package/dist/{callback-mFlTUWWx.js → callback-C8SdXCwr.js} +4 -11
  16. package/dist/{catalog-runtime-D7xapBAX.js → catalog-runtime-BLKtnUL3.js} +1 -1
  17. package/dist/{channel-access-CJGfNTdn.js → channel-access-BOL29BG3.js} +6 -6
  18. package/dist/child-message--2G3Ft26.js +19 -0
  19. package/dist/cli/chat.js +18 -21
  20. package/dist/cli/check.js +4 -4
  21. package/dist/cli/main.js +2 -2
  22. package/dist/cli/plugins.js +5 -5
  23. package/dist/cli/snapshot-create.js +5 -5
  24. package/dist/cli/upgrade.d.ts +1 -1
  25. package/dist/cli/upgrade.js +23 -4
  26. package/dist/{config-kXB2Y5tl.js → config-BIfHKNXN.js} +40 -35
  27. package/dist/{continue-in-slack-O6pV5004.js → continue-in-slack-fnmD2Ifb.js} +5 -7
  28. package/dist/{conversation-feed-uNOv_x68.js → conversation-feed-DdFQuQDR.js} +13 -2
  29. package/dist/{logging-dQ9ZRGQ8.js → conversation-privacy-DtZhI91r.js} +188 -2
  30. package/dist/{conversation-turn-CeLbHqdw.js → conversation-turn-DScuDYmN.js} +465 -62
  31. package/dist/create-CrNt4Ewu.js +212 -0
  32. package/dist/{credential-sync-I8VBGk05.js → credential-sync-CtqsGjj1.js} +14 -18
  33. package/dist/{credentialed-Cb6E2phL.js → credentialed-dWRA3-oJ.js} +911 -429
  34. package/dist/{db-LAyyX8tk.js → db-BTmLKZrp.js} +2245 -50
  35. package/dist/{db-BbC5stfa.d.ts → db-DcmzbA55.d.ts} +2 -2
  36. package/dist/{history-CYstOMKX.js → history-CneKY7_V.js} +19 -1
  37. package/dist/{html-BCZ3Xtb_.js → html-B8rBt7F4.js} +5 -7
  38. package/dist/{install-DCFJFkC0.js → install-OtFboxOM.js} +2 -2
  39. package/dist/instrumentation.js +2 -2
  40. package/dist/{lineage-B_m-4TJw.js → lineage-EULJkGO1.js} +1 -2
  41. package/dist/{list-CN2QA2R9.js → list-C5400AlJ.js} +284 -113
  42. package/dist/{thread-state-DhPndWi1.js → mailbox-turn-DL3Lvsm0.js} +4830 -485
  43. package/dist/markers-DUP8aBOp.js +323 -0
  44. package/dist/{media-CYm1QD8T.js → media-FYM-Bl3H.js} +42 -14
  45. package/dist/{message-DSXGj1hM.js → message-DuDelZFr.js} +16 -15
  46. package/dist/{model-input--TrP9hYV.js → model-input-0osF3pBS.js} +3 -3
  47. package/dist/nitro.d.ts +2 -4
  48. package/dist/nitro.js +340 -13
  49. package/dist/{oauth-callback-server-DHCZC6B4.js → oauth-callback-server-DX2fQ7Nq.js} +2 -2
  50. package/dist/{oauth-relay-pPMGnDZt.js → oauth-relay-PwPMdZJv.js} +1 -1
  51. package/dist/{plugins-Bkk0XRo2.js → plugins-BXMdNdyA.js} +1 -1
  52. package/dist/{registry-CZOzddwu.js → registry-D6kS6xYH.js} +1402 -64
  53. package/dist/{statuses-_cRJHXK7.js → reporting-window-C4dbzDiR.js} +1 -27
  54. package/dist/{resolve-cKOQ14Dh.js → resolve-D8CPJcNK.js} +3 -3
  55. package/dist/result-D090hxr5.js +402 -0
  56. package/dist/{runner-DBfUW44l.js → runner-BU7fgrm-.js} +7 -8
  57. package/dist/{sandbox-egress-signals-BVF_xAm1.js → sandbox-egress-signals-BUmVrsoG.js} +1 -1
  58. package/dist/{schema-Bk9Nm2E8.js → schema-7gW9vBpJ.js} +91 -10
  59. package/dist/{schema-BEHKxr4I.d.ts → schema-BB6E0wyV.d.ts} +2105 -2753
  60. package/dist/{service-account-CVYsFjty.js → service-account-plA-uzIB.js} +6 -5
  61. package/dist/{skills-VTnhAJWm.js → skills-CIosT6bS.js} +3 -3
  62. package/dist/{slack-conversation-unfurl-fuLnF1jE.js → slack-conversation-unfurl-CBgZqth6.js} +8 -10
  63. package/dist/spawn-DRjdzh3R.js +46 -0
  64. package/dist/{start-conversation-CEn2KH1A.js → start-conversation-a4NXH4X9.js} +13 -202
  65. package/dist/{store-DFZaN-Ix.js → store-BuhF1QDm.js} +2 -4
  66. package/dist/{task-queue-Cx4Lmjyk.js → task-queue-CrRjFzOh.js} +5 -16
  67. package/dist/{task-runner-CbTwFA6k.js → task-runner-C-pXsgHM.js} +105 -51
  68. package/dist/{thread-context-BkAZDTX2.js → thread-context-CDX4dSZd.js} +8 -10
  69. package/dist/turn-session-routing-CZTRU8IY.js +116 -0
  70. package/dist/turn-wake-Bzq1Efrm.js +154 -0
  71. package/dist/user-customization-B27StpVQ.js +9 -0
  72. package/dist/{validation-nIzMtAVJ.js → validation-bTq88sya.js} +1 -1
  73. package/dist/{vercel-queue-hW90XzbG.js → vercel-queue-nL0Hq3hr.js} +32 -147
  74. package/dist/{version-Brbtz4Qf.js → version-DGUa1dZK.js} +1 -1
  75. package/dist/version.js +1 -1
  76. package/dist/{warmup-BDA5myRK.js → warmup-CCOuIwAS.js} +831 -3254
  77. package/dist/{worker-D63RcaVD.js → worker-AkZg7Dg1.js} +5 -6
  78. package/migrations/0158_keep_legacy_archive_columns.sql +5 -0
  79. package/migrations/0159_conversation_embeddings_fk_validate.sql +5 -0
  80. package/migrations/0160_money_micro_usd_repair.sql +99 -0
  81. package/migrations/0161_agent_config_backfill.sql +34 -0
  82. package/migrations/0162_inbox_item_deliveries.sql +15 -0
  83. package/migrations/0163_pg_trgm.sql +2 -0
  84. package/migrations/0164_search_indexes.sql +4 -0
  85. package/migrations/0165_drop_legacy_archive_columns.sql +4 -0
  86. package/migrations/0166_memory_prefix_index.sql +1 -0
  87. package/migrations/0167_todo_search_indexes.sql +2 -0
  88. package/migrations/0168_todo_inbox_items.sql +4 -0
  89. package/migrations/0169_drop_code_urls.sql +2 -0
  90. package/migrations/meta/0158_snapshot.json +6515 -0
  91. package/migrations/meta/0159_snapshot.json +6515 -0
  92. package/migrations/meta/0160_snapshot.json +6515 -0
  93. package/migrations/meta/0161_snapshot.json +6278 -0
  94. package/migrations/meta/0162_snapshot.json +6404 -0
  95. package/migrations/meta/0163_snapshot.json +6404 -0
  96. package/migrations/meta/0164_snapshot.json +6466 -0
  97. package/migrations/meta/0165_snapshot.json +6466 -0
  98. package/migrations/meta/0166_snapshot.json +6494 -0
  99. package/migrations/meta/0167_snapshot.json +6525 -0
  100. package/migrations/meta/0168_snapshot.json +6525 -0
  101. package/migrations/meta/0169_snapshot.json +6513 -0
  102. package/migrations/meta/_journal.json +84 -0
  103. package/package.json +9 -18
  104. package/skills/design-automation-skill/SKILL.md +2 -3
  105. package/dist/actor-BsBdxDXQ.js +0 -208
  106. package/dist/child-message-DcsritGf.js +0 -179
  107. package/dist/conversation-privacy-L4ja1_W6.js +0 -189
  108. package/dist/executor-SCub-fAq.js +0 -1860
  109. package/dist/fan-out-Cod-yEHG.js +0 -10
  110. package/dist/ingest-BDf3D50j.js +0 -3836
  111. package/dist/result-DcvEOe1r.js +0 -574
  112. package/dist/result-event-type-BdIJuZxg.js +0 -48
  113. package/dist/service-account-Ts4ulcrV.js +0 -931
  114. package/dist/spawn-vxAarlX5.js +0 -73
  115. package/dist/state-C1P3_Ywk.js +0 -161
@@ -1,73 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { A as actorFromRun, j as toolInvocationDestination } from "./agent-runner-C9iDurwX.js";
3
- import { n as botConfig } from "./config-kXB2Y5tl.js";
4
- import { t as readConversationLineage } from "./lineage-B_m-4TJw.js";
5
- import { w as getConversationWorkState } from "./thread-state-DhPndWi1.js";
6
- import { Dt as getAgentInvocation, Jt as createAndEnqueueAgentInvocation, in as getAgentBinding, tn as AgentDepthLimitError } from "./warmup-BDA5myRK.js";
7
- import { c as getAgentInvocationId, f as getAgentInvocationMessageId, y as getUnnamedAgentConversationId } from "./child-message-DcsritGf.js";
8
- // src/chat/agent-invocations/spawn.ts
9
- var spawn_exports = /* @__PURE__ */ __exportAll({ bindSpawnAgent: () => bindSpawnAgent });
10
- /**
11
- * Count the parents of the Conversation that starts a child agent. A chain
12
- * that does not end at a root, such as a cycle, cannot start one.
13
- */
14
- async function assertCanStartChildAgent(conversationId, maxAgentDepth) {
15
- const lineage = await readConversationLineage(conversationId);
16
- const root = lineage[0];
17
- if (!root || root.parentConversationId || lineage.length - 1 > maxAgentDepth) throw new AgentDepthLimitError(maxAgentDepth);
18
- }
19
- /**
20
- * Return the child of a spawn that already ran without an agent invocation.
21
- * Its idempotency key keys the task in the child's mailbox. A spawn with an
22
- * agent invocation replays through that row instead.
23
- */
24
- async function findSpawnedChildAgent(args) {
25
- const invocationId = getAgentInvocationId(args.parentConversationId, args.idempotencyKey);
26
- if (await getAgentInvocation(invocationId)) return;
27
- const childConversationId = args.agentName ? (await getAgentBinding({
28
- name: args.agentName,
29
- parentConversationId: args.parentConversationId
30
- }))?.childConversationId : getUnnamedAgentConversationId(invocationId);
31
- if (!childConversationId) return;
32
- return (await getConversationWorkState({
33
- conversationId: childConversationId,
34
- state: args.state
35
- }))?.execution.inboundMessageIds.includes(getAgentInvocationMessageId(invocationId)) ? childConversationId : void 0;
36
- }
37
- /** Bind a Run's Actor and credentials to new Agent invocations. */
38
- function bindSpawnAgent(run, options) {
39
- const actor = actorFromRun(run);
40
- if (!actor) return;
41
- return async (input, call) => {
42
- call.signal?.throwIfAborted();
43
- await assertCanStartChildAgent(run.conversationId, options.maxAgentDepth ?? botConfig.maxAgentDepth);
44
- const idempotencyKey = `${run.turnId}:${call.toolCallId}`;
45
- const spawned = await findSpawnedChildAgent({
46
- ...input.name ? { agentName: input.name } : void 0,
47
- idempotencyKey,
48
- parentConversationId: run.conversationId,
49
- state: options.state
50
- });
51
- if (spawned) return { childConversationId: spawned };
52
- const queue = typeof options.queue === "function" ? options.queue() : options.queue;
53
- return { childConversationId: (await createAndEnqueueAgentInvocation({
54
- actor,
55
- ...input.name ? { agentName: input.name } : void 0,
56
- ...input.agentType ? { agentType: input.agentType } : void 0,
57
- ...input.fork ? { fork: true } : void 0,
58
- ...run.credentialContext ? { credentialContext: run.credentialContext } : void 0,
59
- destination: toolInvocationDestination(run),
60
- idempotencyKey,
61
- input: input.task,
62
- ...input.kind ? { kind: input.kind } : void 0,
63
- parentConversationId: run.conversationId,
64
- parentToolCallId: call.toolCallId,
65
- ...input.reasoningLevel ? { reasoningLevel: input.reasoningLevel } : void 0,
66
- ...input.title ? { title: input.title } : void 0
67
- }, {
68
- ...options,
69
- queue
70
- })).childConversationId };
71
- };
72
- }
73
- export { spawn_exports as n, bindSpawnAgent as t };
@@ -1,161 +0,0 @@
1
- import { r as getChatConfig } from "./config-kXB2Y5tl.js";
2
- import { h as logWarn } from "./logging-dQ9ZRGQ8.js";
3
- import { o as getDb } from "./db-LAyyX8tk.js";
4
- import { K as juniorUsers } from "./executor-SCub-fAq.js";
5
- import { createCipheriv, createDecipheriv, createHash, randomBytes } from "node:crypto";
6
- import { eq } from "drizzle-orm";
7
- // src/chat/conversations/legacy-web-actor-id.ts
8
- /**
9
- * Web Actor ids that Junior stored before web Actors used the User id.
10
- *
11
- * Mailbox input, web authorizations, and OAuth credentials saved before that
12
- * deploy still carry `dashboard:` and the first 24 hex characters of
13
- * sha256(email).
14
- *
15
- * TODO(dcramer): Delete with its callers after that input and those
16
- * authorizations expire and no `dashboard:` credential keys remain.
17
- */
18
- const USER_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
19
- /** Return the legacy web Actor id for one email. */
20
- function legacyWebActorUserId(email) {
21
- return `dashboard:${createHash("sha256").update(email.trim().toLowerCase()).digest("hex").slice(0, 24)}`;
22
- }
23
- /** Return every web Actor id that names this User, the User id first. */
24
- function webActorUserIds(user) {
25
- return [user.id, legacyWebActorUserId(user.email)];
26
- }
27
- /** Return the legacy web Actor id of a User id, when the User exists. */
28
- async function findLegacyWebActorUserId(userId) {
29
- if (!USER_ID_PATTERN.test(userId)) return void 0;
30
- const rows = await getDb().select({ email: juniorUsers.primaryEmailNormalized }).from(juniorUsers).where(eq(juniorUsers.id, userId)).limit(1);
31
- return rows[0] ? legacyWebActorUserId(rows[0].email) : void 0;
32
- }
33
- // src/chat/encryption/secret.ts
34
- /**
35
- * Encrypt secrets that Junior keeps at rest, such as provider credentials.
36
- *
37
- * AES-256-GCM with keys from `JUNIOR_ENCRYPTION_KEYS` (see `keyring.ts`).
38
- * Each value is bound to a context, usually its storage key, and to its key
39
- * id as additional authenticated data. A value copied to another key does not
40
- * decrypt.
41
- *
42
- * New values use the active key. Any listed key decrypts. A value from a key
43
- * that is not active reports `stale`, so its owner can save it again with the
44
- * active key. A value that cannot be decrypted gives `UnreadableSecretError`:
45
- * `unknown_key` when its key id is not listed, `invalid` when it is malformed,
46
- * altered, or bound to another context.
47
- *
48
- * There is no per-value salt. The keys are random, not passwords, and each
49
- * value has a random IV. The storage key in the AAD already names the
50
- * identity that owns the value.
51
- *
52
- * Envelope: `jenc:v1:<keyId>:<iv>.<ciphertext>.<tag>` (base64url parts).
53
- */
54
- const ENVELOPE_PREFIX = "jenc:v1:";
55
- const ALGORITHM = "aes-256-gcm";
56
- const IV_BYTES = 12;
57
- const TAG_BYTES = 16;
58
- /** A stored secret that cannot be decrypted with the configured keys. */
59
- var UnreadableSecretError = class extends Error {
60
- reason;
61
- constructor(reason) {
62
- super(reason === "unknown_key" ? "Stored secret was encrypted with a key that is not configured" : "Stored secret is malformed or failed authentication");
63
- this.name = "UnreadableSecretError";
64
- this.reason = reason;
65
- }
66
- };
67
- function additionalData(keyId, context) {
68
- return Buffer.from(`${ENVELOPE_PREFIX}${keyId}\0${context}`, "utf8");
69
- }
70
- /** Check whether a stored value is an encryption envelope. */
71
- function isEncryptedSecret(value) {
72
- return typeof value === "string" && value.startsWith(ENVELOPE_PREFIX);
73
- }
74
- /** Encrypt one secret with the active key and bind it to `context`. */
75
- function encryptSecret(plaintext, context, keyring = getChatConfig().encryption) {
76
- const { id, key } = keyring.active;
77
- const iv = randomBytes(IV_BYTES);
78
- const cipher = createCipheriv(ALGORITHM, key, iv, { authTagLength: TAG_BYTES });
79
- cipher.setAAD(additionalData(id, context));
80
- const parts = [
81
- iv,
82
- Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]),
83
- cipher.getAuthTag()
84
- ].map((part) => part.toString("base64url"));
85
- return `${ENVELOPE_PREFIX}${id}:${parts.join(".")}`;
86
- }
87
- /** Decrypt an `encryptSecret` envelope with the same `context`. */
88
- function decryptSecret(envelope, context, keyring = getChatConfig().encryption) {
89
- if (!isEncryptedSecret(envelope)) throw new Error("Stored secret is not an encryption envelope");
90
- const [keyId, payload] = envelope.slice(8).split(":");
91
- const [iv, ciphertext, tag] = (payload ?? "").split(".").map((part) => Buffer.from(part, "base64url"));
92
- if (!keyId || !iv || iv.length !== IV_BYTES || !ciphertext || !tag || tag.length !== TAG_BYTES) throw new UnreadableSecretError("invalid");
93
- const match = keyring.keys.find((candidate) => candidate.id === keyId);
94
- if (!match) throw new UnreadableSecretError("unknown_key");
95
- const decipher = createDecipheriv(ALGORITHM, match.key, iv, { authTagLength: TAG_BYTES });
96
- decipher.setAAD(additionalData(keyId, context));
97
- decipher.setAuthTag(tag);
98
- let text;
99
- try {
100
- text = Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
101
- } catch {
102
- throw new UnreadableSecretError("invalid");
103
- }
104
- return {
105
- stale: match.id !== keyring.active.id,
106
- text
107
- };
108
- }
109
- // src/chat/encryption/state.ts
110
- /**
111
- * Decrypt one stored envelope. The storage key is the encryption context.
112
- * A value that cannot be decrypted, such as one from a key that is no longer
113
- * configured or one that was altered, reads as missing. The owner then asks
114
- * for the credential again and saves it with the active key.
115
- */
116
- function decode(key, envelope) {
117
- let decrypted;
118
- try {
119
- decrypted = decryptSecret(envelope, key);
120
- } catch (error) {
121
- if (!(error instanceof UnreadableSecretError)) throw error;
122
- logWarn("encryption.secret.unreadable", { "error.type": error.reason });
123
- return;
124
- }
125
- return {
126
- stale: decrypted.stale,
127
- value: JSON.parse(decrypted.text)
128
- };
129
- }
130
- /**
131
- * Wrap a state adapter so values are JSON-encoded and encrypted before they
132
- * reach storage. Keys and TTLs stay readable. Use it for credentials and
133
- * other secrets; delete, lock, and keep plain state on the base adapter.
134
- */
135
- function createEncryptedState(state) {
136
- return {
137
- async get(key) {
138
- const stored = await state.get(key);
139
- if (!isEncryptedSecret(stored)) return void 0;
140
- return decode(key, stored)?.value;
141
- },
142
- async set(key, value, ttlMs) {
143
- await state.set(key, encryptSecret(JSON.stringify(value), key), ttlMs);
144
- }
145
- };
146
- }
147
- /**
148
- * Read a value and report whether it is stale: encrypted with a key that is
149
- * not active, or saved before encryption. Long-lived owners save stale values
150
- * again, so they move to the active key.
151
- */
152
- async function readEncryptedState(state, key) {
153
- const stored = await state.get(key);
154
- if (stored === null || stored === void 0) return void 0;
155
- if (!isEncryptedSecret(stored)) return {
156
- stale: true,
157
- value: stored
158
- };
159
- return decode(key, stored);
160
- }
161
- export { webActorUserIds as i, readEncryptedState as n, findLegacyWebActorUserId as r, createEncryptedState as t };