@sentry/junior 0.311.0 → 0.313.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 (120) hide show
  1. package/dist/{adapter-B1wujchl.js → adapter-CYAvJzZS.js} +1 -1
  2. package/dist/{adapter-context-G2M0y6rP.js → adapter-context-CVsHoVSf.js} +2 -2
  3. package/dist/{admin-DCiBhUT1.js → admin-Cyhb4TwZ.js} +1 -1
  4. package/dist/{agent-runner-BVHPUIc8.js → agent-runner-B5y9MsT-.js} +3487 -3493
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +6 -6
  7. package/dist/api.d.ts +2 -2
  8. package/dist/api.js +294 -311
  9. package/dist/{app-Cw5Vy6H6.d.ts → app-DA8-hCMj.d.ts} +2 -9
  10. package/dist/app.d.ts +1 -1
  11. package/dist/app.js +336 -604
  12. package/dist/{background-compaction-queue-CJDnWVOJ.js → background-compaction-queue-iZXadLV3.js} +60 -85
  13. package/dist/{catalog-runtime-DMY3VV-D.js → catalog-runtime-kkE3hvCX.js} +1 -1
  14. package/dist/channel-access-mt7K6dPh.js +221 -0
  15. package/dist/cli/chat.js +18 -19
  16. package/dist/cli/check.js +3 -3
  17. package/dist/cli/init.js +0 -1
  18. package/dist/cli/main.js +3 -7
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/run.d.ts +1 -2
  21. package/dist/cli/run.js +1 -2
  22. package/dist/cli/snapshot-create.js +5 -5
  23. package/dist/cli/upgrade.d.ts +1 -1
  24. package/dist/cli/upgrade.js +3 -3
  25. package/dist/{config-BrXDQefC.js → config-CWbwKj0j.js} +59 -27
  26. package/dist/{continue-in-slack-DNXSC9So.js → continue-in-slack-CxyFzdlF.js} +7 -8
  27. package/dist/{conversation-feed-DkinDu5o.js → conversation-feed-BEXLD3Me.js} +86 -21
  28. package/dist/{conversation-privacy-DxttrKb9.js → conversation-privacy-BrMiDN61.js} +1 -1
  29. package/dist/{conversation-turn-DWw7Xhdr.js → conversation-turn-B35eu0uz.js} +78 -56
  30. package/dist/{credential-sync-Bk8wGb8Y.js → credential-sync-DWTOEQrm.js} +15 -15
  31. package/dist/{projection-Cns7XwWa.js → credentialed-Dyv8b-lu.js} +16306 -20732
  32. package/dist/{db-7ETESH44.d.ts → db-DYGcXYl3.d.ts} +11 -6
  33. package/dist/{db-DTxzH7u5.js → db-PwSRzWWn.js} +181 -100
  34. package/dist/{executor-DqTiYj9S.js → executor-CgWyWfYz.js} +117 -99
  35. package/dist/{html-B9Sl4Axb.js → html-DidUcRhI.js} +6 -6
  36. package/dist/ingest-B0AggUEC.js +7931 -0
  37. package/dist/{install-Sg4ePfLl.js → install-2urLLXNt.js} +2 -2
  38. package/dist/instrumentation.js +3 -3
  39. package/dist/{lineage-BHAMpNKr.js → lineage-BXplQAVH.js} +2 -2
  40. package/dist/{stop-CYsfc0Ed.js → list-DyIyReSV.js} +709 -475
  41. package/dist/{logging-FjclQsXu.js → logging-DNt-qOIO.js} +1 -1
  42. package/dist/{schedule-BLJ476XQ.js → media-B0pZJ0bG.js} +1058 -11
  43. package/dist/{message-CJ7_RL50.js → message-Z5YKC-Af.js} +35 -28
  44. package/dist/{model-input-CMLh4Cwq.js → model-input-BhPJYdSV.js} +3 -3
  45. package/dist/nitro.d.ts +1 -1
  46. package/dist/nitro.js +4 -3
  47. package/dist/{oauth-callback-server-RVcbiDjL.js → oauth-callback-server-ByvDdcdY.js} +2 -2
  48. package/dist/{oauth-relay-Bu9kkaQu.js → oauth-relay-D-kK0yoN.js} +1 -1
  49. package/dist/{registry-BPwuOP2O.js → registry-POH4bZC4.js} +1 -1
  50. package/dist/reporting-window-C4dbzDiR.js +124 -0
  51. package/dist/request-deadline-BUiRYQYj.js +24 -0
  52. package/dist/{resolve-BK29bBry.js → resolve-CWtBNSKP.js} +3 -3
  53. package/dist/{runner-BcAE-cJm.js → runner-CsZ_VRxp.js} +14 -16
  54. package/dist/{sandbox-egress-signals-C-q0go5b.js → sandbox-egress-signals-FbCk1FkN.js} +1 -1
  55. package/dist/{schema-DYcJeV7d.d.ts → schema-DBf18QPS.d.ts} +2773 -3630
  56. package/dist/{schema-BLgSZXcL.js → schema-DojR2uCL.js} +106 -121
  57. package/dist/{service-account-iJoCtkHR.js → service-account-CDYb9hfX.js} +3 -3
  58. package/dist/{service-account-gN0zqf0S.js → service-account-o15pZWcJ.js} +5 -5
  59. package/dist/{skills-BoZ80epJ.js → skills-B0jP4whm.js} +2 -2
  60. package/dist/{slack-conversation-unfurl-CogYrITA.js → slack-conversation-unfurl-D26t9kBC.js} +9 -9
  61. package/dist/{spawn-Dk92r7mX.js → spawn-BjljgExZ.js} +14 -32
  62. package/dist/start-conversation-DbVujrwO.js +755 -0
  63. package/dist/{state-DH3Cmgp3.js → state-BTawTCme.js} +4 -4
  64. package/dist/statuses-BKwqCPhj.js +69 -0
  65. package/dist/store-CjXrp-Up.js +492 -0
  66. package/dist/task-queue-Cwlatjz3.js +90 -0
  67. package/dist/task-runner--Ke8KSMf.js +1432 -0
  68. package/dist/{thread-context-BW2BsQbH.js → thread-context-B8exINEe.js} +6 -7
  69. package/dist/turn-membership-DTR3SaKD.js +5859 -0
  70. package/dist/{validation-DrJd0nnq.js → validation-Ce0qbMlT.js} +1 -1
  71. package/dist/{task-queue-C_zldF5J.js → vercel-queue-q4z8w5QO.js} +93 -172
  72. package/dist/{version-CNKZ8owc.js → version-DFh4n9nr.js} +1 -1
  73. package/dist/version.js +1 -1
  74. package/dist/{warmup-BWdHew2H.js → warmup-D5hzqTcp.js} +4853 -13605
  75. package/dist/web-message-id-C6P83ans.js +10 -0
  76. package/dist/{worker-t9qpu_Zx.js → worker-CDg9Lbpg.js} +20 -7
  77. package/migrations/0143_todos.sql +14 -0
  78. package/migrations/0144_inbox_items.sql +32 -0
  79. package/migrations/0145_todo_changed_by_agent.sql +1 -0
  80. package/migrations/0146_inbox_item_subject_title_parts.sql +1 -0
  81. package/migrations/0147_inbox_snooze_wake_reason.sql +1 -0
  82. package/migrations/0148_authorization_request_index.sql +1 -0
  83. package/migrations/0149_conversation_metadata.sql +10 -0
  84. package/migrations/0150_conversation_metadata_fill.sql +39 -0
  85. package/migrations/0151_conversation_search_index.sql +1 -0
  86. package/migrations/0152_inbox_item_legacy_automation_keys.sql +21 -0
  87. package/migrations/0153_artifact_expiry.sql +1 -0
  88. package/migrations/0154_artifact_permanent_sha_index.sql +1 -0
  89. package/migrations/0155_artifact_drop_public_sha_index.sql +3 -0
  90. package/migrations/0156_conversation_kind_lead.sql +6 -0
  91. package/migrations/0157_conversation_lead_actor_index.sql +1 -0
  92. package/migrations/0158_keep_legacy_archive_columns.sql +5 -0
  93. package/migrations/0159_conversation_embeddings_fk_validate.sql +5 -0
  94. package/migrations/meta/0143_snapshot.json +6434 -0
  95. package/migrations/meta/0144_snapshot.json +6434 -0
  96. package/migrations/meta/0145_snapshot.json +6440 -0
  97. package/migrations/meta/0146_snapshot.json +6446 -0
  98. package/migrations/meta/0147_snapshot.json +6452 -0
  99. package/migrations/meta/0148_snapshot.json +6474 -0
  100. package/migrations/meta/0149_snapshot.json +6490 -0
  101. package/migrations/meta/0150_snapshot.json +6490 -0
  102. package/migrations/meta/0151_snapshot.json +6505 -0
  103. package/migrations/meta/0152_snapshot.json +6505 -0
  104. package/migrations/meta/0153_snapshot.json +6511 -0
  105. package/migrations/meta/0154_snapshot.json +6533 -0
  106. package/migrations/meta/0155_snapshot.json +6511 -0
  107. package/migrations/meta/0156_snapshot.json +6511 -0
  108. package/migrations/meta/0157_snapshot.json +6527 -0
  109. package/migrations/meta/0158_snapshot.json +6515 -0
  110. package/migrations/meta/0159_snapshot.json +6515 -0
  111. package/migrations/meta/_journal.json +120 -1
  112. package/package.json +6 -6
  113. package/skills/design-automation-skill/SKILL.md +108 -0
  114. package/dist/briefs-BDjnug6Y.js +0 -395
  115. package/dist/conversation-ca__NDQW.js +0 -1063
  116. package/dist/prompt-CDqcsDYC.js +0 -910
  117. package/dist/store-DmmMIrQi.js +0 -335
  118. package/dist/task-runner-C7oCJQIx.js +0 -294
  119. package/dist/turn-session-routing-Xh_2nSQe.js +0 -261
  120. package/dist/web-message-id-Ch5dPq-a.js +0 -306
@@ -0,0 +1,755 @@
1
+ import { Eo as SlackActionError, Fo as readPrivateSlackFile, Lo as streamPrivateSlackFile, io as conversationWatch, wi as getDashboardConversationLink } from "./credentialed-Dyv8b-lu.js";
2
+ import { ht as bufferBody } from "./config-CWbwKj0j.js";
3
+ import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
4
+ import { o as getActiveTraceContext } from "./logging-DNt-qOIO.js";
5
+ import "./actor-BsBdxDXQ.js";
6
+ import { A as isTopLevelKind, Bn as sameDestination, Pn as conversationDetailTouch, Qt as resolveActorIdentityId, a as getConversationStore, dn as ToolInputError, nt as conversationKindSql, o as getDb, s as getSqlExecutor } from "./db-PwSRzWWn.js";
7
+ import { B as juniorAttachments, C as juniorConversationParticipants, H as juniorConversations, K as juniorUsers, U as juniorIdentities, n as isPostgresErrorCode, z as juniorAttachmentUploads } from "./executor-CgWyWfYz.js";
8
+ import { K as buildDeterministicTurnId, _ as appendAndEnqueueInboundMessage, g as appendAndEnqueueExclusiveInboundMessage } from "./turn-membership-DTR3SaKD.js";
9
+ import { i as isVisionImageMediaType, r as detectImageMediaType } from "./media-B0pZJ0bG.js";
10
+ import { t as getVercelConversationWorkQueue } from "./vercel-queue-q4z8w5QO.js";
11
+ import { a as recordUploadedAttachment, i as readLiveAttachment, n as fileFields, u as AttachmentSourceUnavailableError } from "./store-CjXrp-Up.js";
12
+ import { t as webMessageId } from "./web-message-id-C6P83ans.js";
13
+ import * as z from "zod";
14
+ import { createHash, randomUUID } from "node:crypto";
15
+ import { createWebSource, localDestinationSchema, subscribableResourceSchema } from "@sentry/junior-plugin-api";
16
+ import { and, asc, eq, gt, inArray, isNull, lte, sql } from "drizzle-orm";
17
+ import { alias } from "drizzle-orm/pg-core";
18
+ // src/chat/tool-support/structured-result.ts
19
+ const juniorToolContinuationSchema = z.object({
20
+ arguments: z.record(z.string(), z.unknown()),
21
+ reason: z.string().min(1).optional()
22
+ }).strict();
23
+ const juniorToolBoundContinuationSchema = juniorToolContinuationSchema.extend({ tool_name: z.string().min(1) });
24
+ /** Shared optional fields for canonical Junior tool outputs. */
25
+ const juniorToolOutputSchema = z.object({
26
+ target: z.string().min(1).optional(),
27
+ truncated: z.boolean().optional(),
28
+ /** True when this attempt did not finish before its time budget. */
29
+ timed_out: z.boolean().optional(),
30
+ continuation: juniorToolContinuationSchema.optional()
31
+ }).passthrough();
32
+ function sortJsonValue(value) {
33
+ if (Array.isArray(value)) return value.map(sortJsonValue);
34
+ if (!value || typeof value !== "object") return value;
35
+ return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => [key, sortJsonValue(item)]));
36
+ }
37
+ const continuationDetailsSchema = z.looseObject({ continuation: z.looseObject({}) });
38
+ /** Bind continuation metadata to the exposed runtime tool name. */
39
+ function injectContinuationToolName(details, toolName) {
40
+ const parsed = continuationDetailsSchema.safeParse(details);
41
+ if (!parsed.success) return details;
42
+ return {
43
+ ...parsed.data,
44
+ continuation: juniorToolBoundContinuationSchema.parse({
45
+ ...parsed.data.continuation,
46
+ tool_name: toolName
47
+ })
48
+ };
49
+ }
50
+ function makeStructuredToolOutput(details, options = {}) {
51
+ return {
52
+ content: [{
53
+ type: "text",
54
+ text: JSON.stringify(sortJsonValue(details))
55
+ }, ...options.content ?? []],
56
+ details
57
+ };
58
+ }
59
+ // src/chat/tool-support/zod-tool.ts
60
+ function isContentOnlyToolResult(value) {
61
+ return value !== null && typeof value === "object" && Array.isArray(value.content) && !("details" in value);
62
+ }
63
+ function isStructuredToolResultEnvelope(value) {
64
+ return value !== null && typeof value === "object" && Array.isArray(value.content) && "details" in value;
65
+ }
66
+ function parseToolContent(content) {
67
+ for (const item of content) if (!item || typeof item !== "object" || (item.type === "text" ? typeof item.text !== "string" : item.type === "image" ? typeof item.data !== "string" || typeof item.mimeType !== "string" : true)) throw new TypeError("zodTool() content must contain valid text or image items.");
68
+ return content;
69
+ }
70
+ function formatZodPath(path) {
71
+ return path.length > 0 ? path.map(String).join(".") : "root";
72
+ }
73
+ function formatToolInputError(error) {
74
+ return `Invalid tool arguments: ${error.issues.slice(0, 5).map((issue) => `${formatZodPath(issue.path)}: ${issue.message}`).join("; ") || "input did not match schema"}`;
75
+ }
76
+ /** Parse tool input with its Zod schema, as a model-repairable error on failure. */
77
+ function parseToolInput(schema, args) {
78
+ const result = schema.safeParse(args);
79
+ if (!result.success) throw new ToolInputError(formatToolInputError(result.error), { cause: result.error });
80
+ return result.data;
81
+ }
82
+ /** Declare the static definition of a Zod tool once, for the registry and its factory. */
83
+ function zodToolDefinition(definition) {
84
+ return definition;
85
+ }
86
+ function zodTool(definition) {
87
+ const { inputSchema, outputSchema, prepareArguments, execute, ...toolDef } = definition;
88
+ let modelInputSchema;
89
+ try {
90
+ modelInputSchema = z.toJSONSchema(inputSchema);
91
+ } catch (error) {
92
+ throw new TypeError("zodTool() inputSchema must be representable as JSON Schema.", { cause: error });
93
+ }
94
+ let modelOutputSchema;
95
+ if (outputSchema) try {
96
+ modelOutputSchema = z.toJSONSchema(outputSchema);
97
+ } catch (error) {
98
+ throw new TypeError("zodTool() outputSchema must be representable as JSON Schema.", { cause: error });
99
+ }
100
+ return {
101
+ ...toolDef,
102
+ inputSchema: modelInputSchema,
103
+ ...modelOutputSchema ? { outputSchema: modelOutputSchema } : void 0,
104
+ prepareArguments(args) {
105
+ return parseToolInput(inputSchema, prepareArguments ? prepareArguments(args) : args);
106
+ },
107
+ ...execute ? { async execute(input, options) {
108
+ const result = await execute(input, options);
109
+ if (!outputSchema) {
110
+ if (isContentOnlyToolResult(result)) return result;
111
+ throw new TypeError("zodTool() content-only tools must return { content } without details.");
112
+ }
113
+ if (isStructuredToolResultEnvelope(result)) return {
114
+ content: parseToolContent(result.content),
115
+ details: outputSchema.parse(result.details)
116
+ };
117
+ return outputSchema.parse(result);
118
+ } } : void 0
119
+ };
120
+ }
121
+ // src/chat/slack/attachments.ts
122
+ /** Save the vision summary for a stored Slack attachment. */
123
+ async function recordSlackAttachment(args) {
124
+ const db = args.db.db();
125
+ await db.with(conversationDetailTouch(db, [args.conversationId])).update(juniorAttachments).set({ visionSummary: args.visionSummary }).where(and(eq(juniorAttachments.id, args.attachmentId), eq(juniorAttachments.conversationId, args.conversationId), isNull(juniorAttachments.deleteRequestedAt)));
126
+ }
127
+ /** Read a saved vision summary for one live attachment. */
128
+ async function readAttachmentVisionSummary(args) {
129
+ const [row] = await args.db.db().select({ visionSummary: juniorAttachments.visionSummary }).from(juniorAttachments).where(and(eq(juniorAttachments.id, args.attachmentId), eq(juniorAttachments.conversationId, args.conversationId), isNull(juniorAttachments.deleteRequestedAt)));
130
+ return row?.visionSummary;
131
+ }
132
+ /** Match live conversation attachments to Slack file ids. */
133
+ async function matchSlackAttachments(args) {
134
+ if (args.providerIds.length === 0) return [];
135
+ return (await args.db.db().select({
136
+ id: juniorAttachments.id,
137
+ providerId: juniorAttachments.providerId,
138
+ bytes: juniorAttachments.bytes,
139
+ contentType: juniorAttachments.contentType,
140
+ storageKey: juniorAttachments.storageKey,
141
+ storageProvider: juniorAttachments.storageProvider,
142
+ title: juniorAttachments.title
143
+ }).from(juniorAttachments).where(and(eq(juniorAttachments.conversationId, args.conversationId), eq(juniorAttachments.provider, "slack"), inArray(juniorAttachments.providerId, args.providerIds), isNull(juniorAttachments.deleteRequestedAt)))).map((row) => {
144
+ const { bytes, contentType, filename } = fileFields(row);
145
+ const attachment = {
146
+ bytes,
147
+ contentType,
148
+ filename,
149
+ id: row.id,
150
+ providerId: row.providerId
151
+ };
152
+ return row.storageKey === null ? {
153
+ ...attachment,
154
+ pending: true
155
+ } : attachment;
156
+ });
157
+ }
158
+ /**
159
+ * Fingerprint the live Slack attachments that `matchSlackAttachments` can
160
+ * return for a Conversation. It changes when one is recorded, stored, or
161
+ * deleted, so a reader can tell that stored messages may now show other
162
+ * files, or a file that is no longer pending.
163
+ */
164
+ function slackAttachmentsVersionQuery(db, conversationId) {
165
+ return db.select({ version: sql`coalesce(md5(string_agg(concat(${juniorAttachments.id}, ':', ${juniorAttachments.storageKey} is null), ',' order by ${juniorAttachments.id})), '')` }).from(juniorAttachments).where(and(eq(juniorAttachments.conversationId, conversationId), eq(juniorAttachments.provider, "slack"), isNull(juniorAttachments.deleteRequestedAt)));
166
+ }
167
+ /** Read the Slack file identity retained by the Chat SDK. */
168
+ function getSlackFileId(attachment) {
169
+ const metadataId = attachment.fetchMetadata?.["fileId"];
170
+ if (metadataId) return metadataId;
171
+ return (attachment.url ?? attachment.fetchMetadata?.["url"] ?? "").match(/(?:^|[-/])(F[A-Z0-9]+)(?:[-/]|$)/)?.[1];
172
+ }
173
+ /**
174
+ * Look up a Slack file that Junior recorded without storing it yet.
175
+ *
176
+ * Uses the installation token that the caller binds: the Slack turn, or the
177
+ * dashboard route for the conversation's Slack team.
178
+ */
179
+ const readSlackAttachmentSource = async (source) => {
180
+ const unavailable = (cause) => new AttachmentSourceUnavailableError("The Slack file was deleted, or this app can no longer access it.", { cause });
181
+ if (source.provider !== "slack") throw unavailable();
182
+ const file = await readPrivateSlackFile(source.id);
183
+ if (!file) throw unavailable();
184
+ return {
185
+ bytes: file.bytes,
186
+ open: async () => {
187
+ try {
188
+ return await streamPrivateSlackFile(file.url);
189
+ } catch (error) {
190
+ if (error instanceof SlackActionError && (error.code === "not_found" || error.statusCode === 403)) throw unavailable(error);
191
+ throw error;
192
+ }
193
+ }
194
+ };
195
+ };
196
+ // src/chat/attachments/uploads.ts
197
+ const MINUTE_MS = 6e4;
198
+ /** Time that a browser has to write the bytes after it asks to upload. */
199
+ const UPLOAD_TARGET_TTL_MS = 15 * MINUTE_MS;
200
+ /** Time that a written upload can still join a Message. */
201
+ const UPLOAD_SEND_WINDOW_MS = 60 * MINUTE_MS;
202
+ /**
203
+ * Age at which cleanup deletes an upload that no Message used. It is much
204
+ * longer than the send window, so cleanup cannot race a send.
205
+ */
206
+ const UPLOAD_RETENTION_MS = 1440 * MINUTE_MS;
207
+ const UPLOAD_GC_BATCH_LIMIT = 200;
208
+ /** Leading bytes that image type detection reads. */
209
+ const SIGNATURE_BYTES = 16;
210
+ /** A Message refers to an upload that it cannot use. */
211
+ var AttachmentUploadError = class extends Error {
212
+ constructor(message) {
213
+ super(message);
214
+ this.name = "AttachmentUploadError";
215
+ }
216
+ };
217
+ /**
218
+ * Reserve one object key for a browser upload.
219
+ *
220
+ * Returns no target when the provider cannot sign browser writes. The caller
221
+ * then takes the bytes with `writeAttachmentUpload`.
222
+ */
223
+ async function createAttachmentUpload(args) {
224
+ const nowMs = args.nowMs ?? Date.now();
225
+ const id = randomUUID();
226
+ const storageKey = `conversations/${args.scope.conversationId}/uploads/${id}`;
227
+ await args.db.db().insert(juniorAttachmentUploads).values({
228
+ ...args.scope,
229
+ bytes: args.file.bytes,
230
+ contentType: args.file.contentType,
231
+ createdAt: new Date(nowMs),
232
+ filename: args.file.filename,
233
+ id,
234
+ storageKey,
235
+ storageProvider: args.storage.provider
236
+ });
237
+ const target = await args.storage.createUploadTarget?.({
238
+ bytes: args.file.bytes,
239
+ contentType: args.file.contentType,
240
+ expiresAtMs: nowMs + UPLOAD_TARGET_TTL_MS,
241
+ key: storageKey
242
+ });
243
+ return target ? {
244
+ id,
245
+ target
246
+ } : { id };
247
+ }
248
+ async function readUploadRows(args) {
249
+ return await args.db.db().select().from(juniorAttachmentUploads).where(and(inArray(juniorAttachmentUploads.id, [...args.uploadIds]), eq(juniorAttachmentUploads.conversationId, args.scope.conversationId), eq(juniorAttachmentUploads.idempotencyKey, args.scope.idempotencyKey), eq(juniorAttachmentUploads.userId, args.scope.userId), eq(juniorAttachmentUploads.storageProvider, args.storageProvider), gt(juniorAttachmentUploads.createdAt, /* @__PURE__ */ new Date(args.nowMs - UPLOAD_SEND_WINDOW_MS))));
250
+ }
251
+ /** Write upload bytes through the API, for providers without browser writes. */
252
+ async function writeAttachmentUpload(args) {
253
+ const nowMs = args.nowMs ?? Date.now();
254
+ const [row] = await args.db.db().select().from(juniorAttachmentUploads).where(and(eq(juniorAttachmentUploads.id, args.uploadId), eq(juniorAttachmentUploads.userId, args.userId), eq(juniorAttachmentUploads.storageProvider, args.storage.provider), gt(juniorAttachmentUploads.createdAt, /* @__PURE__ */ new Date(nowMs - UPLOAD_TARGET_TTL_MS))));
255
+ if (!row) throw new AttachmentUploadError("Upload not found.");
256
+ if (await readLiveAttachment({
257
+ attachmentId: row.id,
258
+ conversationId: row.conversationId,
259
+ db: args.db
260
+ })) throw new AttachmentUploadError("Upload was already sent.");
261
+ if (args.body.byteLength !== row.bytes) throw new AttachmentUploadError("Upload size does not match the file.");
262
+ await args.storage.put({
263
+ body: bufferBody(args.body),
264
+ bytes: row.bytes,
265
+ contentType: row.contentType,
266
+ key: row.storageKey
267
+ });
268
+ }
269
+ /** Read a whole object once for its size, digest, and leading bytes. */
270
+ async function inspectObject(body, maxBytes) {
271
+ const hash = createHash("sha256");
272
+ const head = [];
273
+ let headBytes = 0;
274
+ let bytes = 0;
275
+ const reader = body.getReader();
276
+ for (;;) {
277
+ const { done, value } = await reader.read();
278
+ if (done) break;
279
+ bytes += value.byteLength;
280
+ if (bytes > maxBytes) {
281
+ await reader.cancel();
282
+ return;
283
+ }
284
+ hash.update(value);
285
+ if (headBytes < SIGNATURE_BYTES) {
286
+ head.push(Buffer.from(value.subarray(0, SIGNATURE_BYTES - headBytes)));
287
+ headBytes += head.at(-1).byteLength;
288
+ }
289
+ }
290
+ return {
291
+ bytes,
292
+ head: Buffer.concat(head),
293
+ sha256: hash.digest("hex")
294
+ };
295
+ }
296
+ /**
297
+ * Pick the type to store from the file signature, not only the browser's
298
+ * guess from the file name. Models reject an image whose bytes do not match
299
+ * its type, so a file that only claims to be an image is stored as bytes.
300
+ */
301
+ function storedContentType(declared, head) {
302
+ const detected = detectImageMediaType(head);
303
+ if (detected) return detected;
304
+ return isVisionImageMediaType(declared) ? "application/octet-stream" : declared;
305
+ }
306
+ /**
307
+ * Check the uploads of one Message before the Message is accepted.
308
+ *
309
+ * Each upload must belong to the scope and be written in full at its
310
+ * declared size. Throws `AttachmentUploadError` for any upload that the
311
+ * Message cannot use.
312
+ */
313
+ async function verifyAttachmentUploads(args) {
314
+ if (args.uploadIds.length === 0) return [];
315
+ if (new Set(args.uploadIds).size !== args.uploadIds.length) throw new AttachmentUploadError("Attach each file once.");
316
+ const rows = await readUploadRows({
317
+ db: args.db,
318
+ nowMs: args.nowMs ?? Date.now(),
319
+ scope: args.scope,
320
+ storageProvider: args.storage.provider,
321
+ uploadIds: args.uploadIds
322
+ });
323
+ const byId = new Map(rows.map((row) => [row.id, row]));
324
+ return await Promise.all(args.uploadIds.map(async (uploadId) => {
325
+ const row = byId.get(uploadId);
326
+ if (!row) throw new AttachmentUploadError("Upload expired. Attach the file again.");
327
+ const recorded = await readLiveAttachment({
328
+ attachmentId: row.id,
329
+ conversationId: row.conversationId,
330
+ db: args.db
331
+ });
332
+ if (recorded) return {
333
+ attachment: {
334
+ bytes: recorded.bytes,
335
+ contentType: recorded.contentType,
336
+ filename: recorded.filename,
337
+ id: recorded.id
338
+ },
339
+ recorded: true
340
+ };
341
+ const body = await args.storage.get(row.storageKey);
342
+ const object = body ? await inspectObject(body, row.bytes) : void 0;
343
+ if (!object || object.bytes !== row.bytes) throw new AttachmentUploadError(`Upload of ${row.filename} is not complete. Attach it again.`);
344
+ return {
345
+ attachment: {
346
+ bytes: row.bytes,
347
+ contentType: storedContentType(row.contentType, object.head),
348
+ filename: row.filename,
349
+ id: row.id
350
+ },
351
+ recorded: false,
352
+ sha256: object.sha256,
353
+ storageKey: row.storageKey
354
+ };
355
+ }));
356
+ }
357
+ /** Record checked uploads as attachments of their Conversation. */
358
+ async function recordAttachmentUploads(args) {
359
+ await mapBounded(args.uploads.filter((upload) => !upload.recorded), (upload) => recordUploadedAttachment({
360
+ attachment: {
361
+ ...upload.attachment,
362
+ conversationId: args.conversationId,
363
+ sha256: upload.sha256,
364
+ storageKey: upload.storageKey
365
+ },
366
+ db: args.db,
367
+ nowMs: args.nowMs ?? Date.now(),
368
+ storage: args.storage
369
+ }));
370
+ return args.uploads.map((upload) => upload.attachment);
371
+ }
372
+ /**
373
+ * Delete old upload rows in one bounded batch.
374
+ *
375
+ * An upload that a Message recorded keeps its object: the attachment row owns
376
+ * it now. Other objects are deleted first, so a failed delete stays
377
+ * retryable.
378
+ */
379
+ async function collectAttachmentUploadGarbage(args) {
380
+ const rows = await args.db.db().select({
381
+ id: juniorAttachmentUploads.id,
382
+ recordedId: juniorAttachments.id,
383
+ storageKey: juniorAttachmentUploads.storageKey
384
+ }).from(juniorAttachmentUploads).leftJoin(juniorAttachments, eq(juniorAttachments.id, juniorAttachmentUploads.id)).where(and(eq(juniorAttachmentUploads.storageProvider, args.storage.provider), lte(juniorAttachmentUploads.createdAt, /* @__PURE__ */ new Date(args.nowMs - UPLOAD_RETENTION_MS)))).orderBy(asc(juniorAttachmentUploads.createdAt)).limit(UPLOAD_GC_BATCH_LIMIT);
385
+ if (rows.length === 0) return { deleted: 0 };
386
+ const unusedKeys = rows.filter((row) => row.recordedId === null).map((row) => row.storageKey);
387
+ await args.storage.delete(unusedKeys);
388
+ return { deleted: (await args.db.db().delete(juniorAttachmentUploads).where(inArray(juniorAttachmentUploads.id, rows.map((row) => row.id))).returning({ id: juniorAttachmentUploads.id })).length };
389
+ }
390
+ // src/chat/conversations/destination.ts
391
+ function requireLocalDestination(conversationId) {
392
+ const parsed = localDestinationSchema.safeParse({
393
+ platform: "local",
394
+ conversationId
395
+ });
396
+ if (!parsed.success) throw new Error(`Invalid local conversation id: ${conversationId}`);
397
+ return parsed.data;
398
+ }
399
+ /**
400
+ * Keep a stored Destination, or create the temporary local Destination.
401
+ *
402
+ * TODO(dcramer): Delete this module after Conversation and AgentRun use
403
+ * Location, and web and event Turns no longer need a local
404
+ * Destination.
405
+ */
406
+ function resolveConversationDestination(args) {
407
+ return args.existing ?? requireLocalDestination(args.conversationId);
408
+ }
409
+ // src/chat/conversations/web-input.ts
410
+ function normalizeEmail(email) {
411
+ return email.trim().toLowerCase();
412
+ }
413
+ function stableHex(...parts) {
414
+ return createHash("sha256").update(parts.join("\0")).digest("hex").slice(0, 24);
415
+ }
416
+ /**
417
+ * Build a durable Conversation id for one web Actor and create key.
418
+ *
419
+ * Retries with the same key must address the same Conversation before the
420
+ * mailbox Message id is derived.
421
+ */
422
+ function createConversationId(args) {
423
+ return `local:web:${stableHex(normalizeEmail(args.actorEmail), args.idempotencyKey)}`;
424
+ }
425
+ /** Return the stable Turn id for one mailbox Message. */
426
+ function conversationTurnIdForMessage(messageId) {
427
+ return buildDeterministicTurnId(messageId);
428
+ }
429
+ /**
430
+ * Store the dashboard participant in the current Conversation actor field.
431
+ *
432
+ * TODO(dcramer): Remove this StoredSlackActor conversion after Conversation
433
+ * actor storage accepts web Actors directly.
434
+ */
435
+ function storedActorFromWeb(actor) {
436
+ return {
437
+ ...actor.email ? { email: normalizeEmail(actor.email) } : void 0,
438
+ ...actor.fullName ? { fullName: actor.fullName } : void 0
439
+ };
440
+ }
441
+ /**
442
+ * Return whether a person can add a web Message to an existing
443
+ * Conversation: a dashboard Conversation, a Slack thread, or a Thread.
444
+ */
445
+ function acceptsWebMessages(conversation) {
446
+ if (!isTopLevelKind(conversation.kind)) return conversation.kind === "thread";
447
+ const { conversationId, destination } = conversation;
448
+ if (destination?.platform === "slack") return true;
449
+ return destination?.platform === "local" && conversationId.startsWith("local:web:");
450
+ }
451
+ /**
452
+ * Build the web Actor for one signed-in User. Junior is the web provider,
453
+ * so the provider-scoped Actor id is the User id.
454
+ */
455
+ function webActorFromUser(user, profile) {
456
+ return {
457
+ platform: "web",
458
+ userId: user.id,
459
+ email: normalizeEmail(user.email),
460
+ ...user.displayName ? { fullName: user.displayName } : void 0,
461
+ ...profile?.userName ? { userName: profile.userName } : void 0
462
+ };
463
+ }
464
+ /** Build one web mailbox entry. */
465
+ function buildWebInboundMessage(args) {
466
+ const text = args.message.trim();
467
+ if (!text && !args.attachments?.length) throw new Error("Web Message must not be empty");
468
+ if (!args.actor.email) throw new Error("Web Actor requires a verified email");
469
+ const nowMs = args.nowMs ?? Date.now();
470
+ const traceContext = getActiveTraceContext();
471
+ return {
472
+ conversationId: args.conversationId,
473
+ createdAtMs: args.createdAtMs ?? nowMs,
474
+ delivery: args.delivery ?? "defer",
475
+ ...args.destination ? { destination: args.destination } : void 0,
476
+ inboundMessageId: args.messageId,
477
+ input: {
478
+ authorId: args.actor.userId,
479
+ ...args.authorIdentityId ? { authorIdentityId: args.authorIdentityId } : void 0,
480
+ text,
481
+ ...args.attachments?.length ? { attachments: args.attachments } : void 0,
482
+ ...args.reviewItemChange ? { reviewItemChange: args.reviewItemChange } : void 0,
483
+ metadata: {
484
+ authorEmail: normalizeEmail(args.actor.email),
485
+ ...args.actor.fullName && { authorFullName: args.actor.fullName },
486
+ authorUserId: args.actor.userId,
487
+ ...args.actor.userName && { authorUserName: args.actor.userName },
488
+ kind: "api_turn",
489
+ messageId: args.messageId
490
+ }
491
+ },
492
+ receivedAtMs: nowMs,
493
+ source: "web",
494
+ ...traceContext ? { traceContext } : void 0
495
+ };
496
+ }
497
+ /**
498
+ * Record web activity and create a Conversation root when needed. Returns the
499
+ * Destination for the Message's work. A child's work keeps none, so its
500
+ * workers read the Conversation.
501
+ */
502
+ async function recordWebConversationActivity(args) {
503
+ const store = args.conversationStore ?? getConversationStore();
504
+ const existing = await store.get({ conversationId: args.conversationId });
505
+ const destination = resolveConversationDestination({
506
+ conversationId: args.conversationId,
507
+ existing: existing?.destination
508
+ });
509
+ const isNewRoot = !existing;
510
+ const visibility = args.rootVisibility === "private" ? "private" : "public";
511
+ const source = isNewRoot ? createWebSource(args.conversationId, visibility) : void 0;
512
+ await store.recordActivity({
513
+ conversationId: args.conversationId,
514
+ ...existing?.destination ? void 0 : { destination },
515
+ nowMs: args.nowMs,
516
+ actor: storedActorFromWeb(args.actor),
517
+ ...isNewRoot ? { source: "web" } : void 0,
518
+ ...source ? { sessionSource: source } : void 0,
519
+ ...isNewRoot && args.rootTitle ? { title: args.rootTitle } : void 0,
520
+ ...isNewRoot ? { visibility } : void 0,
521
+ ...isNewRoot && args.rootKind ? { kind: args.rootKind } : void 0
522
+ });
523
+ return existing && !isTopLevelKind(existing.kind) ? void 0 : destination;
524
+ }
525
+ /** Create a Conversation from web input and enqueue its first Message. */
526
+ async function createAndEnqueueConversation(input, options) {
527
+ if (!input.actor.email) throw new Error("Web Actor requires a verified email");
528
+ const conversationId = createConversationId({
529
+ actorEmail: input.actor.email,
530
+ idempotencyKey: input.idempotencyKey
531
+ });
532
+ return await appendAndEnqueueWebMessage({
533
+ actor: input.actor,
534
+ conversationId,
535
+ idempotencyKey: input.idempotencyKey,
536
+ message: input.message,
537
+ uploads: input.uploads,
538
+ ...input.title ? { rootTitle: input.title } : void 0,
539
+ rootVisibility: input.visibility === "private" ? "private" : "public"
540
+ }, options);
541
+ }
542
+ async function appendAndEnqueueWebMessage(input, options) {
543
+ const text = input.message.trim();
544
+ if (!text && !input.uploads?.length) throw new Error("Web Message must not be empty");
545
+ if (!input.actor.email) throw new Error("Web Actor requires a verified email");
546
+ const nowMs = options.nowMs ?? Date.now();
547
+ const messageId = await webMessageId({
548
+ conversationId: input.conversationId,
549
+ idempotencyKey: input.idempotencyKey
550
+ });
551
+ const destination = await recordWebConversationActivity({
552
+ actor: input.actor,
553
+ conversationId: input.conversationId,
554
+ conversationStore: options.conversationStore,
555
+ nowMs,
556
+ ...input.rootTitle && { rootTitle: input.rootTitle },
557
+ ...input.rootVisibility && { rootVisibility: input.rootVisibility }
558
+ });
559
+ let attachments = [];
560
+ if (input.uploads?.length) {
561
+ if (!options.attachmentStorage) throw new Error("Attachment storage is unavailable.");
562
+ attachments = await recordAttachmentUploads({
563
+ conversationId: input.conversationId,
564
+ db: getSqlExecutor(),
565
+ nowMs,
566
+ storage: options.attachmentStorage,
567
+ uploads: input.uploads
568
+ });
569
+ }
570
+ const enqueue = options.exclusive ? appendAndEnqueueExclusiveInboundMessage : appendAndEnqueueInboundMessage;
571
+ const authorIdentityId = await resolveActorIdentityId(getSqlExecutor(), input.actor);
572
+ const enqueueTo = (destination) => enqueue({
573
+ message: buildWebInboundMessage({
574
+ actor: input.actor,
575
+ authorIdentityId,
576
+ conversationId: input.conversationId,
577
+ delivery: input.delivery,
578
+ destination,
579
+ message: text,
580
+ attachments,
581
+ messageId,
582
+ nowMs,
583
+ ...input.reviewItemChange && { reviewItemChange: input.reviewItemChange }
584
+ }),
585
+ conversationStore: options.conversationStore,
586
+ nowMs,
587
+ queue: options.queue,
588
+ state: options.state
589
+ });
590
+ let result;
591
+ try {
592
+ result = await enqueueTo(destination);
593
+ } catch (error) {
594
+ if (!destination) throw error;
595
+ const stored = await (options.conversationStore ?? getConversationStore()).get({ conversationId: input.conversationId });
596
+ const current = resolveConversationDestination({
597
+ conversationId: input.conversationId,
598
+ existing: stored?.destination
599
+ });
600
+ if (sameDestination(current, destination)) throw error;
601
+ result = await enqueueTo(current);
602
+ }
603
+ const status = result.status === "appended" ? "accepted" : result.status;
604
+ return {
605
+ conversationId: input.conversationId,
606
+ messageId,
607
+ status
608
+ };
609
+ }
610
+ // src/chat/lead/conversation.ts
611
+ /**
612
+ * The Lead of one person: their private Conversation that finds, starts, and
613
+ * steers their other Conversations. Only web creates a Lead, so its root
614
+ * Actor is the web Identity of its User, and a unique index keeps one Lead
615
+ * for each Identity.
616
+ */
617
+ const UNIQUE_VIOLATION = "23505";
618
+ const LEAD_TITLE = "Lead";
619
+ async function findLead(identityId) {
620
+ const [row] = await getDb().select({ conversationId: juniorConversations.conversationId }).from(juniorConversations).where(and(eq(juniorConversations.kind, "lead"), eq(juniorConversations.actorIdentityId, identityId))).limit(1);
621
+ return row ? await getConversationStore().get({ conversationId: row.conversationId }) : void 0;
622
+ }
623
+ /** Return the Lead of one User, and create it on first use. */
624
+ async function getLeadConversation(user) {
625
+ const actor = webActorFromUser(user);
626
+ const identityId = await resolveActorIdentityId(getSqlExecutor(), actor);
627
+ if (!identityId) throw new Error("A Lead needs a web Identity");
628
+ const existing = await findLead(identityId);
629
+ if (existing) return existing;
630
+ try {
631
+ await recordWebConversationActivity({
632
+ actor,
633
+ conversationId: `local:web:${randomUUID()}`,
634
+ nowMs: Date.now(),
635
+ rootKind: "lead",
636
+ rootTitle: LEAD_TITLE,
637
+ rootVisibility: "private"
638
+ });
639
+ } catch (error) {
640
+ if (!isPostgresErrorCode(error, UNIQUE_VIOLATION)) throw error;
641
+ }
642
+ const created = await findLead(identityId);
643
+ if (!created) throw new Error("The Lead was not saved");
644
+ return created;
645
+ }
646
+ /**
647
+ * Return the User of a Lead: the person whose Conversations it steers.
648
+ * Returns nothing for a Conversation that is not a Lead.
649
+ */
650
+ async function readLeadUser(conversationId) {
651
+ const [row] = await getDb().select({
652
+ displayName: juniorUsers.displayName,
653
+ email: juniorUsers.primaryEmail,
654
+ id: juniorUsers.id
655
+ }).from(juniorConversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(eq(juniorConversations.conversationId, conversationId), eq(juniorConversations.kind, "lead"))).limit(1);
656
+ return row ? {
657
+ id: row.id,
658
+ email: row.email,
659
+ ...row.displayName ? { displayName: row.displayName } : void 0
660
+ } : void 0;
661
+ }
662
+ /**
663
+ * Return whether the person of a Lead is a Participant of one root
664
+ * Conversation. False when the sender is not a Lead, or when the target is
665
+ * not a root, such as an Automation run.
666
+ */
667
+ async function leadPersonParticipates(args) {
668
+ const target = alias(juniorConversations, "target");
669
+ const [row] = await getDb().select({ one: sql`1` }).from(juniorConversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).innerJoin(juniorConversationParticipants, and(eq(juniorConversationParticipants.userId, juniorIdentities.userId), eq(juniorConversationParticipants.rootConversationId, args.rootConversationId))).innerJoin(target, and(eq(target.conversationId, args.rootConversationId), eq(conversationKindSql(target), "root"))).where(and(eq(juniorConversations.conversationId, args.leadConversationId), eq(juniorConversations.kind, "lead"))).limit(1);
670
+ return row !== void 0;
671
+ }
672
+ // src/chat/lead/start-conversation.ts
673
+ /**
674
+ * Start one Conversation from a Lead. The new Conversation is a public web
675
+ * root of the Lead's person and runs as that person, like any root. The
676
+ * Lead's task is its first Message. The start is not reviewed. Action
677
+ * review judges the new root's own tool calls, as it does a child agent's.
678
+ */
679
+ /**
680
+ * Create the Conversation and enqueue the task as its first Message. Repeat
681
+ * calls with the same `messageKey` are safe.
682
+ */
683
+ async function startLeadConversation(args) {
684
+ const user = await readLeadUser(args.leadConversationId);
685
+ if (!user) throw new Error("Only a Lead can start a Conversation");
686
+ const idempotencyKey = `lead:${args.leadConversationId}:${args.messageKey}`;
687
+ const conversationId = createConversationId({
688
+ actorEmail: user.email,
689
+ idempotencyKey
690
+ });
691
+ await appendAndEnqueueWebMessage({
692
+ actor: webActorFromUser(user),
693
+ conversationId,
694
+ idempotencyKey,
695
+ message: args.task,
696
+ rootTitle: args.title,
697
+ rootVisibility: "public"
698
+ }, {
699
+ nowMs: Date.now(),
700
+ queue: args.queue
701
+ });
702
+ return { conversationId };
703
+ }
704
+ // src/chat/tools/start-conversation.ts
705
+ /** Static definition of `startConversation`, which only a Lead lists. */
706
+ const startConversationToolDefinition = zodToolDefinition({
707
+ description: [
708
+ "Start a new conversation that does one piece of the person's work. It is a public conversation of the person, and it starts at once.",
709
+ "Your task is its first message, and it runs as the person, so write the task as the person's request.",
710
+ "Use messageAgent instead for work that a conversation already does."
711
+ ].join(" "),
712
+ exposure: "modelOnly",
713
+ approvalMode: "auto",
714
+ annotations: {
715
+ destructiveHint: false,
716
+ idempotentHint: true,
717
+ openWorldHint: false,
718
+ readOnlyHint: false
719
+ },
720
+ inputSchema: z.object({
721
+ task: z.string().trim().min(1).describe("Self-contained brief for a peer who has not seen this conversation: the goal, the targets, the facts you know, the constraints, and what done means."),
722
+ title: z.string().trim().min(1).max(60).describe("Short display title of the new conversation.")
723
+ }).strict(),
724
+ outputSchema: juniorToolOutputSchema.extend({
725
+ conversation_id: z.string().min(1).describe("ID of the new conversation. Pass it to messageAgent to steer it."),
726
+ dashboard_url: z.string().url().optional().describe("Dashboard link of the new conversation."),
727
+ subscribable: subscribableResourceSchema.describe("Watch it with watchEvents only when the person asks to hear back.")
728
+ })
729
+ });
730
+ /** Create the tool that starts a Conversation from a Lead Turn. */
731
+ function createStartConversationTool(context) {
732
+ return zodTool({
733
+ ...startConversationToolDefinition,
734
+ execute: async (input, options) => {
735
+ if (!options.toolCallId || !context.turnId) throw new ToolInputError("startConversation requires an active Turn and tool call ID");
736
+ const { conversationId } = await startLeadConversation({
737
+ leadConversationId: context.conversationId,
738
+ messageKey: `${context.turnId}:${options.toolCallId}`,
739
+ queue: context.conversationWorkQueue ?? getVercelConversationWorkQueue(),
740
+ task: input.task,
741
+ title: input.title
742
+ });
743
+ const dashboardUrl = getDashboardConversationLink(conversationId);
744
+ return {
745
+ conversation_id: conversationId,
746
+ ...dashboardUrl ? { dashboard_url: dashboardUrl } : void 0,
747
+ subscribable: conversationWatch({
748
+ conversationId,
749
+ title: input.title
750
+ })
751
+ };
752
+ }
753
+ });
754
+ }
755
+ export { makeStructuredToolOutput as A, recordSlackAttachment as C, zodToolDefinition as D, zodTool as E, injectContinuationToolName as O, readSlackAttachmentSource as S, parseToolInput as T, verifyAttachmentUploads as _, readLeadUser as a, matchSlackAttachments as b, conversationTurnIdForMessage as c, recordWebConversationActivity as d, webActorFromUser as f, createAttachmentUpload as g, collectAttachmentUploadGarbage as h, leadPersonParticipates as i, juniorToolOutputSchema as k, createAndEnqueueConversation as l, AttachmentUploadError as m, startConversationToolDefinition as n, acceptsWebMessages as o, resolveConversationDestination as p, getLeadConversation as r, appendAndEnqueueWebMessage as s, createStartConversationTool as t, createConversationId as u, writeAttachmentUpload as v, slackAttachmentsVersionQuery as w, readAttachmentVisionSummary as x, getSlackFileId as y };