@sentry/junior 0.313.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 (108) hide show
  1. package/dist/{adapter-CYAvJzZS.js → adapter-JARQvoLw.js} +1 -2
  2. package/dist/{adapter-context-CVsHoVSf.js → adapter-context-B4BrJZuS.js} +2 -2
  3. package/dist/{admin-Cyhb4TwZ.js → admin-BXGAySz0.js} +1 -1
  4. package/dist/{agent-runner-B5y9MsT-.js → agent-runner-qZU5TR8i.js} +797 -118
  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 +334 -100
  11. package/dist/{app-DA8-hCMj.d.ts → app-D7tKnw9a.d.ts} +4 -21
  12. package/dist/app.d.ts +2 -2
  13. package/dist/app.js +80 -169
  14. package/dist/{background-compaction-queue-iZXadLV3.js → background-compaction-queue-C_uIBUvS.js} +6 -67
  15. package/dist/callback-C8SdXCwr.js +68 -0
  16. package/dist/{catalog-runtime-kkE3hvCX.js → catalog-runtime-BLKtnUL3.js} +1 -1
  17. package/dist/{channel-access-mt7K6dPh.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-CWbwKj0j.js → config-BIfHKNXN.js} +40 -35
  27. package/dist/{continue-in-slack-CxyFzdlF.js → continue-in-slack-fnmD2Ifb.js} +5 -7
  28. package/dist/{conversation-feed-BEXLD3Me.js → conversation-feed-DdFQuQDR.js} +1 -1
  29. package/dist/{logging-DNt-qOIO.js → conversation-privacy-DtZhI91r.js} +188 -2
  30. package/dist/{conversation-turn-B35eu0uz.js → conversation-turn-DScuDYmN.js} +418 -33
  31. package/dist/create-CrNt4Ewu.js +212 -0
  32. package/dist/{credential-sync-DWTOEQrm.js → credential-sync-CtqsGjj1.js} +14 -17
  33. package/dist/{credentialed-Dyv8b-lu.js → credentialed-dWRA3-oJ.js} +910 -426
  34. package/dist/{db-PwSRzWWn.js → db-BTmLKZrp.js} +2235 -38
  35. package/dist/{db-DYGcXYl3.d.ts → db-DcmzbA55.d.ts} +2 -2
  36. package/dist/{history-CYstOMKX.js → history-CneKY7_V.js} +19 -1
  37. package/dist/{html-DidUcRhI.js → html-B8rBt7F4.js} +5 -7
  38. package/dist/{install-2urLLXNt.js → install-OtFboxOM.js} +2 -2
  39. package/dist/instrumentation.js +2 -2
  40. package/dist/{lineage-BXplQAVH.js → lineage-EULJkGO1.js} +1 -2
  41. package/dist/{list-DyIyReSV.js → list-C5400AlJ.js} +235 -77
  42. package/dist/{turn-membership-DTR3SaKD.js → mailbox-turn-DL3Lvsm0.js} +4698 -587
  43. package/dist/markers-DUP8aBOp.js +323 -0
  44. package/dist/{media-B0pZJ0bG.js → media-FYM-Bl3H.js} +33 -8
  45. package/dist/{message-Z5YKC-Af.js → message-DuDelZFr.js} +16 -29
  46. package/dist/{model-input-BhPJYdSV.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-ByvDdcdY.js → oauth-callback-server-DX2fQ7Nq.js} +2 -2
  50. package/dist/{oauth-relay-D-kK0yoN.js → oauth-relay-PwPMdZJv.js} +1 -1
  51. package/dist/{plugins-Bkk0XRo2.js → plugins-BXMdNdyA.js} +1 -1
  52. package/dist/{registry-POH4bZC4.js → registry-D6kS6xYH.js} +1402 -64
  53. package/dist/{resolve-CWtBNSKP.js → resolve-D8CPJcNK.js} +3 -3
  54. package/dist/result-D090hxr5.js +402 -0
  55. package/dist/{runner-CsZ_VRxp.js → runner-BU7fgrm-.js} +7 -8
  56. package/dist/{sandbox-egress-signals-FbCk1FkN.js → sandbox-egress-signals-BUmVrsoG.js} +1 -1
  57. package/dist/{schema-DojR2uCL.js → schema-7gW9vBpJ.js} +90 -9
  58. package/dist/{schema-DBf18QPS.d.ts → schema-BB6E0wyV.d.ts} +138 -5
  59. package/dist/{service-account-CDYb9hfX.js → service-account-plA-uzIB.js} +6 -5
  60. package/dist/{skills-B0jP4whm.js → skills-CIosT6bS.js} +3 -3
  61. package/dist/{slack-conversation-unfurl-D26t9kBC.js → slack-conversation-unfurl-CBgZqth6.js} +8 -10
  62. package/dist/{spawn-BjljgExZ.js → spawn-DRjdzh3R.js} +9 -17
  63. package/dist/{start-conversation-DbVujrwO.js → start-conversation-a4NXH4X9.js} +12 -15
  64. package/dist/{store-CjXrp-Up.js → store-BuhF1QDm.js} +2 -4
  65. package/dist/{task-queue-Cwlatjz3.js → task-queue-CrRjFzOh.js} +5 -16
  66. package/dist/{task-runner--Ke8KSMf.js → task-runner-C-pXsgHM.js} +104 -50
  67. package/dist/{thread-context-B8exINEe.js → thread-context-CDX4dSZd.js} +8 -9
  68. package/dist/turn-session-routing-CZTRU8IY.js +116 -0
  69. package/dist/turn-wake-Bzq1Efrm.js +154 -0
  70. package/dist/user-customization-B27StpVQ.js +9 -0
  71. package/dist/{validation-Ce0qbMlT.js → validation-bTq88sya.js} +1 -1
  72. package/dist/{vercel-queue-q4z8w5QO.js → vercel-queue-nL0Hq3hr.js} +32 -147
  73. package/dist/{version-DFh4n9nr.js → version-DGUa1dZK.js} +1 -1
  74. package/dist/version.js +1 -1
  75. package/dist/{warmup-D5hzqTcp.js → warmup-CCOuIwAS.js} +639 -137
  76. package/dist/{worker-CDg9Lbpg.js → worker-AkZg7Dg1.js} +5 -6
  77. package/migrations/0160_money_micro_usd_repair.sql +99 -0
  78. package/migrations/0161_agent_config_backfill.sql +34 -0
  79. package/migrations/0162_inbox_item_deliveries.sql +15 -0
  80. package/migrations/0163_pg_trgm.sql +2 -0
  81. package/migrations/0164_search_indexes.sql +4 -0
  82. package/migrations/0165_drop_legacy_archive_columns.sql +4 -0
  83. package/migrations/0166_memory_prefix_index.sql +1 -0
  84. package/migrations/0167_todo_search_indexes.sql +2 -0
  85. package/migrations/0168_todo_inbox_items.sql +4 -0
  86. package/migrations/0169_drop_code_urls.sql +2 -0
  87. package/migrations/meta/0160_snapshot.json +6515 -0
  88. package/migrations/meta/0161_snapshot.json +6278 -0
  89. package/migrations/meta/0162_snapshot.json +6404 -0
  90. package/migrations/meta/0163_snapshot.json +6404 -0
  91. package/migrations/meta/0164_snapshot.json +6466 -0
  92. package/migrations/meta/0165_snapshot.json +6466 -0
  93. package/migrations/meta/0166_snapshot.json +6494 -0
  94. package/migrations/meta/0167_snapshot.json +6525 -0
  95. package/migrations/meta/0168_snapshot.json +6525 -0
  96. package/migrations/meta/0169_snapshot.json +6513 -0
  97. package/migrations/meta/_journal.json +70 -0
  98. package/package.json +9 -18
  99. package/skills/design-automation-skill/SKILL.md +2 -3
  100. package/dist/actor-BsBdxDXQ.js +0 -208
  101. package/dist/conversation-privacy-BrMiDN61.js +0 -189
  102. package/dist/executor-CgWyWfYz.js +0 -1858
  103. package/dist/fan-out-Cod-yEHG.js +0 -10
  104. package/dist/ingest-B0AggUEC.js +0 -7931
  105. package/dist/request-deadline-BUiRYQYj.js +0 -24
  106. package/dist/service-account-o15pZWcJ.js +0 -931
  107. package/dist/state-BTawTCme.js +0 -161
  108. package/dist/statuses-BKwqCPhj.js +0 -69
@@ -1,161 +0,0 @@
1
- import { r as getChatConfig } from "./config-CWbwKj0j.js";
2
- import { h as logWarn } from "./logging-DNt-qOIO.js";
3
- import { o as getDb } from "./db-PwSRzWWn.js";
4
- import { K as juniorUsers } from "./executor-CgWyWfYz.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 };
@@ -1,69 +0,0 @@
1
- import * as z from "zod";
2
- // src/chat/todos/types.ts
3
- /** Statuses of a To-do. `done` and `dropped` close it. */
4
- const TODO_STATUSES = [
5
- "open",
6
- "in_progress",
7
- "done",
8
- "dropped"
9
- ];
10
- /** Statuses of a To-do that is still work to do. */
11
- const OPEN_TODO_STATUSES = ["open", "in_progress"];
12
- /** Whether a To-do with this status is still work to do. */
13
- function isOpenTodoStatus(status) {
14
- return status === "open" || status === "in_progress";
15
- }
16
- /** Model-facing tool that changes the To-dos. */
17
- const UPDATE_TODOS_TOOL_NAME = "updateTodos";
18
- /** Assignee text for the list's own agent, in tool results and blocks. */
19
- const SELF_TODO_ASSIGNEE = "self";
20
- // src/api/schema/user-customization.ts
21
- /** Longest customization text one user can save. */
22
- const USER_CUSTOMIZATION_MAX_CHARS = 1e3;
23
- /** Saved customization text. An empty string means none. */
24
- const userCustomizationTextSchema = z.string().trim().max(USER_CUSTOMIZATION_MAX_CHARS);
25
- /** Request and response body for the viewer's customization. */
26
- const userCustomizationSchema = z.object({ customization: userCustomizationTextSchema }).strict();
27
- // src/chat/agent-invocations/result-event-type.ts
28
- /** Event namespace of the messages between a parent and its child agents. */
29
- const AGENT_INVOCATION_EVENT_NAMESPACE = "junior";
30
- const AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX = "agent_invocation.";
31
- /** Build the Event type of the parent message for one agent invocation result. */
32
- function agentInvocationResultEventType(status) {
33
- return `${AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX}${status}`;
34
- }
35
- /** True when an Event type names an agent invocation result. */
36
- function isAgentInvocationResultEventType(eventType) {
37
- return eventType.startsWith(AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX);
38
- }
39
- /** Event type of the `reply` that ends a child agent's Turn. */
40
- const AGENT_REPLY_EVENT_TYPE = "agent.reply";
41
- /** Event type of a message that a child agent sends to its parent. */
42
- const AGENT_MESSAGE_EVENT_TYPE = "agent.message";
43
- // src/chat/agent-invocations/statuses.ts
44
- const AGENT_INVOCATION_STATUSES = [
45
- "pending",
46
- "running",
47
- "paused",
48
- "blocked",
49
- "completed",
50
- "failed",
51
- "stopped"
52
- ];
53
- const AGENT_INVOCATION_MAILBOX_STATUSES = ["pending", "appended"];
54
- /**
55
- * Parent mailbox append state. Only terminal invocations have a value.
56
- * `replaced` means the child still had open work, so a later agent invocation
57
- * on the same child sends the result instead. `skipped` means a stop ended
58
- * the work, so the result is never used. `steered` means the agent invocation
59
- * that was running read the input as a steering message, so its result covers
60
- * this one.
61
- */
62
- const AGENT_INVOCATION_PARENT_MAILBOX_STATUSES = [
63
- "pending",
64
- "appended",
65
- "replaced",
66
- "skipped",
67
- "steered"
68
- ];
69
- export { AGENT_MESSAGE_EVENT_TYPE as a, isAgentInvocationResultEventType as c, userCustomizationTextSchema as d, OPEN_TODO_STATUSES as f, isOpenTodoStatus as g, UPDATE_TODOS_TOOL_NAME as h, AGENT_INVOCATION_EVENT_NAMESPACE as i, USER_CUSTOMIZATION_MAX_CHARS as l, TODO_STATUSES as m, AGENT_INVOCATION_PARENT_MAILBOX_STATUSES as n, AGENT_REPLY_EVENT_TYPE as o, SELF_TODO_ASSIGNEE as p, AGENT_INVOCATION_STATUSES as r, agentInvocationResultEventType as s, AGENT_INVOCATION_MAILBOX_STATUSES as t, userCustomizationSchema as u };