@sentry/junior 0.87.0 → 0.89.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 (61) hide show
  1. package/README.md +16 -5
  2. package/dist/{agent-hooks-NWOUB3UR.js → agent-hooks-RIJ5TSWP.js} +8 -8
  3. package/dist/api/people/list.d.ts +4 -0
  4. package/dist/api/people/list.js +83 -0
  5. package/dist/api/people/list.query.d.ts +4 -0
  6. package/dist/api/people/profile.d.ts +4 -0
  7. package/dist/api/people/profile.js +131 -0
  8. package/dist/api/people/profile.query.d.ts +4 -0
  9. package/dist/api/people/shared.d.ts +76 -0
  10. package/dist/api/people/types.d.ts +85 -0
  11. package/dist/app.js +43 -40
  12. package/dist/{catalog-runtime-XOD7YPRS.js → catalog-runtime-MW7XERSU.js} +3 -3
  13. package/dist/chat/conversations/sql/migrations.d.ts +1 -1
  14. package/dist/chat/conversations/sql/schema/identities.d.ts +54 -3
  15. package/dist/chat/conversations/sql/schema/users.d.ts +109 -0
  16. package/dist/chat/conversations/sql/schema.d.ts +164 -3
  17. package/dist/chat/conversations/sql/store.d.ts +0 -1
  18. package/dist/chat/identities/identity.d.ts +18 -0
  19. package/dist/chat/identities/sql.d.ts +4 -0
  20. package/dist/chat/runtime/processing-reaction.d.ts +2 -1
  21. package/dist/chat/runtime/slack-resume.d.ts +3 -2
  22. package/dist/chat/runtime/thread-context.d.ts +3 -1
  23. package/dist/chat/runtime/turn-user-message.d.ts +2 -1
  24. package/dist/chat/services/conversation-memory.d.ts +3 -1
  25. package/dist/chat/slack/message.d.ts +2 -1
  26. package/dist/chat/slack/outbound.d.ts +5 -4
  27. package/dist/chat/slack/timestamp.d.ts +6 -0
  28. package/dist/chat/sql/schema.d.ts +163 -3
  29. package/dist/chat/tools/slack/context.d.ts +2 -1
  30. package/dist/{chunk-ENPSU7L7.js → chunk-2DPZRS3B.js} +4 -4
  31. package/dist/{chunk-6I6HBOQM.js → chunk-4IXHIV37.js} +413 -157
  32. package/dist/{chunk-JRXCSSSU.js → chunk-6UPQ5GTJ.js} +3 -3
  33. package/dist/{chunk-64ACM6AP.js → chunk-7ES37H6U.js} +2 -2
  34. package/dist/{chunk-GGD6WK6V.js → chunk-AHLSXMOU.js} +2 -2
  35. package/dist/{chunk-2TAIGJPQ.js → chunk-C5NCV3OB.js} +1 -1
  36. package/dist/{chunk-6O5UI3RG.js → chunk-F22AM3OW.js} +1 -1
  37. package/dist/{chunk-BRSQQRG6.js → chunk-IATAYWFU.js} +2 -2
  38. package/dist/{chunk-BQ3ITJA6.js → chunk-KBFQXJL4.js} +2 -2
  39. package/dist/{chunk-ACJJJEGG.js → chunk-KBSLCOGE.js} +8 -8
  40. package/dist/{chunk-IXTBFABZ.js → chunk-KQKIA4CU.js} +1 -1
  41. package/dist/{chunk-B6FQPS7A.js → chunk-NYJLQI42.js} +22 -20
  42. package/dist/chunk-PBV4ZIVM.js +261 -0
  43. package/dist/{chunk-ZU2ALUVQ.js → chunk-S35CPNPT.js} +1 -1
  44. package/dist/{chunk-RIB3M6YA.js → chunk-V6XDCS3X.js} +4 -4
  45. package/dist/{chunk-KF7522P3.js → chunk-VMBZFPZM.js} +11 -1
  46. package/dist/{chunk-2NFV5FMB.js → chunk-XS6NLQPA.js} +21 -12
  47. package/dist/{chunk-GB5DFM4D.js → chunk-YPAE5RH3.js} +1 -1
  48. package/dist/cli/chat.js +6 -6
  49. package/dist/cli/check.js +4 -4
  50. package/dist/cli/init.js +30 -36
  51. package/dist/cli/plugins.js +11 -11
  52. package/dist/cli/snapshot-warmup.js +6 -6
  53. package/dist/cli/upgrade.js +12 -12
  54. package/dist/{db-SZVUU7RB.js → db-37HOGLI7.js} +5 -5
  55. package/dist/nitro.js +4 -4
  56. package/dist/reporting/conversations.d.ts +0 -56
  57. package/dist/reporting.d.ts +2 -8
  58. package/dist/reporting.js +14 -290
  59. package/dist/{runner-DMP3IQNM.js → runner-BCRF2FCI.js} +13 -13
  60. package/dist/{validation-MBNJKWPQ.js → validation-FMJO3L5P.js} +4 -4
  61. package/package.json +13 -5
package/dist/app.js CHANGED
@@ -75,7 +75,7 @@ import {
75
75
  updateConversationStats,
76
76
  uploadFilesToThread,
77
77
  upsertConversationMessage
78
- } from "./chunk-B6FQPS7A.js";
78
+ } from "./chunk-NYJLQI42.js";
79
79
  import {
80
80
  CONVERSATION_WORK_CHECK_IN_INTERVAL_MS,
81
81
  CONVERSATION_WORK_STALE_ENQUEUE_MS,
@@ -99,17 +99,17 @@ import {
99
99
  requestConversationContinuation,
100
100
  requestConversationWork,
101
101
  startConversationWork
102
- } from "./chunk-ENPSU7L7.js";
102
+ } from "./chunk-2DPZRS3B.js";
103
103
  import {
104
104
  JUNIOR_THREAD_STATE_TTL_MS,
105
105
  coerceThreadConversationState
106
106
  } from "./chunk-66NX7MNW.js";
107
- import "./chunk-RIB3M6YA.js";
107
+ import "./chunk-V6XDCS3X.js";
108
108
  import {
109
109
  getVercelConversationWorkQueue,
110
110
  resolveConversationWorkQueueTopic,
111
111
  verifyConversationQueueMessage
112
- } from "./chunk-6O5UI3RG.js";
112
+ } from "./chunk-F22AM3OW.js";
113
113
  import {
114
114
  PLUGIN_TASK_QUEUE_TOPIC,
115
115
  createVercelQueueClient,
@@ -123,7 +123,7 @@ import {
123
123
  resolveSlackChannelTypeFromMessage,
124
124
  resolveSlackConversationContext,
125
125
  setConversationTitle
126
- } from "./chunk-JRXCSSSU.js";
126
+ } from "./chunk-6UPQ5GTJ.js";
127
127
  import {
128
128
  abandonAgentTurnSessionRecord,
129
129
  buildSlackOutputMessage,
@@ -137,11 +137,11 @@ import {
137
137
  recordAuthorizationCompleted,
138
138
  splitSlackReplyText,
139
139
  truncateStatusText
140
- } from "./chunk-ACJJJEGG.js";
140
+ } from "./chunk-KBSLCOGE.js";
141
141
  import {
142
142
  validatePluginEgressCredentialHooks,
143
143
  validatePluginRegistrations
144
- } from "./chunk-2TAIGJPQ.js";
144
+ } from "./chunk-C5NCV3OB.js";
145
145
  import {
146
146
  defineJuniorPlugins,
147
147
  pluginCatalogConfigFromEnv,
@@ -154,23 +154,24 @@ import {
154
154
  getPluginRoutes,
155
155
  getPluginSlackConversationLink,
156
156
  getPlugins,
157
+ parseSlackMessageTs,
157
158
  setPlugins,
158
159
  validatePlugins,
159
160
  verifySlackDirectCredentialSubject
160
- } from "./chunk-2NFV5FMB.js";
161
+ } from "./chunk-XS6NLQPA.js";
161
162
  import {
162
163
  createPluginLogger,
163
164
  createPluginState
164
- } from "./chunk-BRSQQRG6.js";
165
- import {
166
- getConversationStore,
167
- getDb
168
- } from "./chunk-6I6HBOQM.js";
165
+ } from "./chunk-IATAYWFU.js";
169
166
  import "./chunk-G3E7SCME.js";
170
167
  import {
171
168
  acquireActiveLock,
172
169
  getStateAdapter
173
- } from "./chunk-GB5DFM4D.js";
170
+ } from "./chunk-YPAE5RH3.js";
171
+ import {
172
+ getConversationStore,
173
+ getDb
174
+ } from "./chunk-4IXHIV37.js";
174
175
  import {
175
176
  SlackActionError,
176
177
  createSlackDestination,
@@ -186,7 +187,7 @@ import {
186
187
  runWithSlackInstallationToken,
187
188
  runWithWorkspaceTeamId,
188
189
  sameDestination
189
- } from "./chunk-GGD6WK6V.js";
190
+ } from "./chunk-AHLSXMOU.js";
190
191
  import {
191
192
  FUNCTION_TIMEOUT_BUFFER_SECONDS,
192
193
  botConfig,
@@ -206,7 +207,7 @@ import {
206
207
  stripRuntimeTurnContext,
207
208
  trimTrailingAssistantMessages,
208
209
  unwrapCurrentInstruction
209
- } from "./chunk-ZU2ALUVQ.js";
210
+ } from "./chunk-S35CPNPT.js";
210
211
  import {
211
212
  parseSlackThreadId,
212
213
  resolveSlackChannelIdFromMessage,
@@ -214,13 +215,13 @@ import {
214
215
  } from "./chunk-L7OHKDOX.js";
215
216
  import {
216
217
  discoverSkills
217
- } from "./chunk-64ACM6AP.js";
218
+ } from "./chunk-7ES37H6U.js";
218
219
  import {
219
220
  buildOAuthTokenRequest,
220
221
  hasRequiredOAuthScope,
221
222
  parseOAuthTokenResponse,
222
223
  pluginCatalogRuntime
223
- } from "./chunk-BQ3ITJA6.js";
224
+ } from "./chunk-KBFQXJL4.js";
224
225
  import {
225
226
  createRequester,
226
227
  createSlackRequester,
@@ -228,7 +229,7 @@ import {
228
229
  isActorUserId,
229
230
  parseActorUserId,
230
231
  toStoredSlackRequester
231
- } from "./chunk-IXTBFABZ.js";
232
+ } from "./chunk-KQKIA4CU.js";
232
233
  import {
233
234
  homeDir
234
235
  } from "./chunk-6APU57E6.js";
@@ -247,7 +248,7 @@ import {
247
248
  setTags,
248
249
  withContext,
249
250
  withSpan
250
- } from "./chunk-KF7522P3.js";
251
+ } from "./chunk-VMBZFPZM.js";
251
252
  import {
252
253
  JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE,
253
254
  toOptionalString
@@ -1826,7 +1827,6 @@ function slackSerializedResourceEventMessage(input) {
1826
1827
  channel: input.channelId,
1827
1828
  event_type: "resource_event",
1828
1829
  thread_ts: input.threadTs,
1829
- ts: input.id,
1830
1830
  type: "message",
1831
1831
  user: "UJRNEVENT"
1832
1832
  },
@@ -3095,10 +3095,6 @@ async function GET2(request, waitUntil, options = {}) {
3095
3095
  import { THREAD_STATE_TTL_MS } from "chat";
3096
3096
 
3097
3097
  // src/chat/runtime/turn-user-message.ts
3098
- function normalizeSlackMessageTs(value) {
3099
- const trimmed = value?.trim();
3100
- return trimmed && /^\d+(?:\.\d+)?$/.test(trimmed) ? trimmed : void 0;
3101
- }
3102
3098
  function getTurnUserMessage(conversation, sessionId) {
3103
3099
  for (let index = conversation.messages.length - 1; index >= 0; index -= 1) {
3104
3100
  const message = conversation.messages[index];
@@ -3115,7 +3111,7 @@ function getTurnUserMessageId(conversation, sessionId) {
3115
3111
  return getTurnUserMessage(conversation, sessionId)?.id;
3116
3112
  }
3117
3113
  function getTurnUserSlackMessageTs(message) {
3118
- return normalizeSlackMessageTs(message?.meta?.slackTs) ?? normalizeSlackMessageTs(message?.id);
3114
+ return parseSlackMessageTs(message?.meta?.slackTs);
3119
3115
  }
3120
3116
  function getTurnUserReplyAttachmentContext(message) {
3121
3117
  const inboundAttachmentCount = message?.meta?.attachmentCount ?? 0;
@@ -3595,15 +3591,26 @@ function getMessageTs(message) {
3595
3591
  const directTs = toOptionalString(
3596
3592
  message.ts
3597
3593
  );
3598
- if (directTs) {
3599
- return directTs;
3594
+ const parsedDirectTs = parseSlackMessageTs(directTs);
3595
+ if (parsedDirectTs) {
3596
+ return parsedDirectTs;
3600
3597
  }
3601
3598
  const raw = message.raw;
3602
3599
  if (!raw || typeof raw !== "object") {
3603
3600
  return void 0;
3604
3601
  }
3605
3602
  const rawRecord = raw;
3606
- return toOptionalString(rawRecord.ts) ?? toOptionalString(rawRecord.event_ts) ?? toOptionalString(rawRecord.message?.ts);
3603
+ const candidates = [
3604
+ rawRecord.ts,
3605
+ rawRecord.message?.ts
3606
+ ];
3607
+ for (const candidate of candidates) {
3608
+ const ts = parseSlackMessageTs(candidate);
3609
+ if (ts) {
3610
+ return ts;
3611
+ }
3612
+ }
3613
+ return void 0;
3607
3614
  }
3608
3615
 
3609
3616
  // src/chat/runtime/processing-reaction.ts
@@ -9164,20 +9171,15 @@ import { THREAD_STATE_TTL_MS as THREAD_STATE_TTL_MS4 } from "chat";
9164
9171
  import { createSlackSource } from "@sentry/junior-plugin-api";
9165
9172
 
9166
9173
  // src/chat/slack/message.ts
9167
- function isSlackMessageTs(value) {
9168
- return /^\d+(?:\.\d+)?$/.test(value.trim());
9169
- }
9170
9174
  function getSlackMessageTs(message) {
9171
- if (isSlackMessageTs(message.id)) {
9172
- return message.id;
9175
+ const idTs = parseSlackMessageTs(message.id);
9176
+ if (idTs) {
9177
+ return idTs;
9173
9178
  }
9174
9179
  if (message.raw && typeof message.raw === "object") {
9175
- const ts = message.raw.ts;
9176
- if (typeof ts === "string" && ts.length > 0) {
9177
- return ts;
9178
- }
9180
+ return parseSlackMessageTs(message.raw.ts);
9179
9181
  }
9180
- return message.id;
9182
+ return void 0;
9181
9183
  }
9182
9184
 
9183
9185
  // src/chat/slack/assistant-thread/title.ts
@@ -10488,6 +10490,7 @@ function resolveMessageText(args) {
10488
10490
  }
10489
10491
  function toConversationMessage(args) {
10490
10492
  const actor = getMessageActorIdentity(args.entry);
10493
+ const slackTs = getSlackMessageTs(args.entry);
10491
10494
  const messageHasPotentialImageAttachment = hasPotentialImageAttachment(
10492
10495
  args.entry.attachments
10493
10496
  );
@@ -10508,7 +10511,7 @@ function toConversationMessage(args) {
10508
10511
  explicitMention: args.explicitMention,
10509
10512
  imageAttachmentCount: imageAttachmentCount > 0 ? imageAttachmentCount : void 0,
10510
10513
  imagesHydrated: !messageHasPotentialImageAttachment,
10511
- slackTs: getSlackMessageTs(args.entry)
10514
+ ...slackTs ? { slackTs } : {}
10512
10515
  }
10513
10516
  };
10514
10517
  }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-BQ3ITJA6.js";
4
- import "./chunk-IXTBFABZ.js";
3
+ } from "./chunk-KBFQXJL4.js";
4
+ import "./chunk-KQKIA4CU.js";
5
5
  import "./chunk-6APU57E6.js";
6
- import "./chunk-KF7522P3.js";
6
+ import "./chunk-VMBZFPZM.js";
7
7
  import "./chunk-FTMXFBDC.js";
8
8
  import "./chunk-3DA7X2U3.js";
9
9
  import "./chunk-MLKGABMK.js";
@@ -5,7 +5,7 @@ export interface Migration {
5
5
  id: string;
6
6
  statements: readonly string[];
7
7
  }
8
- export declare const migrations: readonly [Migration, Migration];
8
+ export declare const migrations: readonly [Migration, Migration, Migration];
9
9
  export { schema };
10
10
  /** Apply pending SQL schema migrations for queryable conversation records. */
11
11
  export declare function migrateSchema(executor: JuniorSqlMigrationExecutor, migrationList?: readonly Migration[]): Promise<void>;
@@ -1,4 +1,4 @@
1
- export type JuniorIdentityKind = "service" | "system" | "user";
1
+ import type { IdentityKind } from "@/chat/identities/identity";
2
2
  export declare const juniorIdentities: import("drizzle-orm/pg-core").PgTableWithColumns<{
3
3
  name: "junior_identities";
4
4
  schema: undefined;
@@ -25,7 +25,7 @@ export declare const juniorIdentities: import("drizzle-orm/pg-core").PgTableWith
25
25
  tableName: "junior_identities";
26
26
  dataType: "string";
27
27
  columnType: "PgText";
28
- data: JuniorIdentityKind;
28
+ data: IdentityKind;
29
29
  driverParam: string;
30
30
  notNull: true;
31
31
  hasDefault: false;
@@ -37,7 +37,7 @@ export declare const juniorIdentities: import("drizzle-orm/pg-core").PgTableWith
37
37
  identity: undefined;
38
38
  generated: undefined;
39
39
  }, {}, {
40
- $type: JuniorIdentityKind;
40
+ $type: IdentityKind;
41
41
  }>;
42
42
  provider: import("drizzle-orm/pg-core").PgColumn<{
43
43
  name: "provider";
@@ -209,6 +209,57 @@ export declare const juniorIdentities: import("drizzle-orm/pg-core").PgTableWith
209
209
  identity: undefined;
210
210
  generated: undefined;
211
211
  }, {}, {}>;
212
+ userId: import("drizzle-orm/pg-core").PgColumn<{
213
+ name: "user_id";
214
+ tableName: "junior_identities";
215
+ dataType: "string";
216
+ columnType: "PgText";
217
+ data: string;
218
+ driverParam: string;
219
+ notNull: false;
220
+ hasDefault: false;
221
+ isPrimaryKey: false;
222
+ isAutoincrement: false;
223
+ hasRuntimeDefault: false;
224
+ enumValues: [string, ...string[]];
225
+ baseColumn: never;
226
+ identity: undefined;
227
+ generated: undefined;
228
+ }, {}, {}>;
229
+ emailNormalized: import("drizzle-orm/pg-core").PgColumn<{
230
+ name: "email_normalized";
231
+ tableName: "junior_identities";
232
+ dataType: "string";
233
+ columnType: "PgText";
234
+ data: string;
235
+ driverParam: string;
236
+ notNull: false;
237
+ hasDefault: false;
238
+ isPrimaryKey: false;
239
+ isAutoincrement: false;
240
+ hasRuntimeDefault: false;
241
+ enumValues: [string, ...string[]];
242
+ baseColumn: never;
243
+ identity: undefined;
244
+ generated: undefined;
245
+ }, {}, {}>;
246
+ emailVerified: import("drizzle-orm/pg-core").PgColumn<{
247
+ name: "email_verified";
248
+ tableName: "junior_identities";
249
+ dataType: "boolean";
250
+ columnType: "PgBoolean";
251
+ data: boolean;
252
+ driverParam: boolean;
253
+ notNull: true;
254
+ hasDefault: true;
255
+ isPrimaryKey: false;
256
+ isAutoincrement: false;
257
+ hasRuntimeDefault: false;
258
+ enumValues: undefined;
259
+ baseColumn: never;
260
+ identity: undefined;
261
+ generated: undefined;
262
+ }, {}, {}>;
212
263
  };
213
264
  dialect: "pg";
214
265
  }>;
@@ -0,0 +1,109 @@
1
+ export declare const juniorUsers: import("drizzle-orm/pg-core").PgTableWithColumns<{
2
+ name: "junior_users";
3
+ schema: undefined;
4
+ columns: {
5
+ id: import("drizzle-orm/pg-core").PgColumn<{
6
+ name: "id";
7
+ tableName: "junior_users";
8
+ dataType: "string";
9
+ columnType: "PgText";
10
+ data: string;
11
+ driverParam: string;
12
+ notNull: true;
13
+ hasDefault: false;
14
+ isPrimaryKey: true;
15
+ isAutoincrement: false;
16
+ hasRuntimeDefault: false;
17
+ enumValues: [string, ...string[]];
18
+ baseColumn: never;
19
+ identity: undefined;
20
+ generated: undefined;
21
+ }, {}, {}>;
22
+ primaryEmail: import("drizzle-orm/pg-core").PgColumn<{
23
+ name: "primary_email";
24
+ tableName: "junior_users";
25
+ dataType: "string";
26
+ columnType: "PgText";
27
+ data: string;
28
+ driverParam: string;
29
+ notNull: true;
30
+ hasDefault: false;
31
+ isPrimaryKey: false;
32
+ isAutoincrement: false;
33
+ hasRuntimeDefault: false;
34
+ enumValues: [string, ...string[]];
35
+ baseColumn: never;
36
+ identity: undefined;
37
+ generated: undefined;
38
+ }, {}, {}>;
39
+ primaryEmailNormalized: import("drizzle-orm/pg-core").PgColumn<{
40
+ name: "primary_email_normalized";
41
+ tableName: "junior_users";
42
+ dataType: "string";
43
+ columnType: "PgText";
44
+ data: string;
45
+ driverParam: string;
46
+ notNull: true;
47
+ hasDefault: false;
48
+ isPrimaryKey: false;
49
+ isAutoincrement: false;
50
+ hasRuntimeDefault: false;
51
+ enumValues: [string, ...string[]];
52
+ baseColumn: never;
53
+ identity: undefined;
54
+ generated: undefined;
55
+ }, {}, {}>;
56
+ displayName: import("drizzle-orm/pg-core").PgColumn<{
57
+ name: "display_name";
58
+ tableName: "junior_users";
59
+ dataType: "string";
60
+ columnType: "PgText";
61
+ data: string;
62
+ driverParam: string;
63
+ notNull: false;
64
+ hasDefault: false;
65
+ isPrimaryKey: false;
66
+ isAutoincrement: false;
67
+ hasRuntimeDefault: false;
68
+ enumValues: [string, ...string[]];
69
+ baseColumn: never;
70
+ identity: undefined;
71
+ generated: undefined;
72
+ }, {}, {}>;
73
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
74
+ name: string;
75
+ tableName: "junior_users";
76
+ dataType: "date";
77
+ columnType: "PgTimestamp";
78
+ data: Date;
79
+ driverParam: string;
80
+ notNull: true;
81
+ hasDefault: false;
82
+ isPrimaryKey: false;
83
+ isAutoincrement: false;
84
+ hasRuntimeDefault: false;
85
+ enumValues: undefined;
86
+ baseColumn: never;
87
+ identity: undefined;
88
+ generated: undefined;
89
+ }, {}, {}>;
90
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
91
+ name: string;
92
+ tableName: "junior_users";
93
+ dataType: "date";
94
+ columnType: "PgTimestamp";
95
+ data: Date;
96
+ driverParam: string;
97
+ notNull: true;
98
+ hasDefault: false;
99
+ isPrimaryKey: false;
100
+ isAutoincrement: false;
101
+ hasRuntimeDefault: false;
102
+ enumValues: undefined;
103
+ baseColumn: never;
104
+ identity: undefined;
105
+ generated: undefined;
106
+ }, {}, {}>;
107
+ };
108
+ dialect: "pg";
109
+ }>;
@@ -2,7 +2,8 @@ import { juniorConversations } from "./schema/conversations";
2
2
  import { juniorDestinations } from "./schema/destinations";
3
3
  import { juniorIdentities } from "./schema/identities";
4
4
  import { juniorSchemaMigrations } from "./schema/migrations";
5
- export { juniorConversations, juniorDestinations, juniorIdentities, juniorSchemaMigrations, };
5
+ import { juniorUsers } from "./schema/users";
6
+ export { juniorConversations, juniorDestinations, juniorIdentities, juniorSchemaMigrations, juniorUsers, };
6
7
  export declare const schema: {
7
8
  juniorConversations: import("drizzle-orm/pg-core").PgTableWithColumns<{
8
9
  name: "junior_conversations";
@@ -662,7 +663,7 @@ export declare const schema: {
662
663
  tableName: "junior_identities";
663
664
  dataType: "string";
664
665
  columnType: "PgText";
665
- data: import("./schema/identities").JuniorIdentityKind;
666
+ data: import("../../identities/identity").IdentityKind;
666
667
  driverParam: string;
667
668
  notNull: true;
668
669
  hasDefault: false;
@@ -674,7 +675,7 @@ export declare const schema: {
674
675
  identity: undefined;
675
676
  generated: undefined;
676
677
  }, {}, {
677
- $type: import("./schema/identities").JuniorIdentityKind;
678
+ $type: import("../../identities/identity").IdentityKind;
678
679
  }>;
679
680
  provider: import("drizzle-orm/pg-core").PgColumn<{
680
681
  name: "provider";
@@ -846,6 +847,57 @@ export declare const schema: {
846
847
  identity: undefined;
847
848
  generated: undefined;
848
849
  }, {}, {}>;
850
+ userId: import("drizzle-orm/pg-core").PgColumn<{
851
+ name: "user_id";
852
+ tableName: "junior_identities";
853
+ dataType: "string";
854
+ columnType: "PgText";
855
+ data: string;
856
+ driverParam: string;
857
+ notNull: false;
858
+ hasDefault: false;
859
+ isPrimaryKey: false;
860
+ isAutoincrement: false;
861
+ hasRuntimeDefault: false;
862
+ enumValues: [string, ...string[]];
863
+ baseColumn: never;
864
+ identity: undefined;
865
+ generated: undefined;
866
+ }, {}, {}>;
867
+ emailNormalized: import("drizzle-orm/pg-core").PgColumn<{
868
+ name: "email_normalized";
869
+ tableName: "junior_identities";
870
+ dataType: "string";
871
+ columnType: "PgText";
872
+ data: string;
873
+ driverParam: string;
874
+ notNull: false;
875
+ hasDefault: false;
876
+ isPrimaryKey: false;
877
+ isAutoincrement: false;
878
+ hasRuntimeDefault: false;
879
+ enumValues: [string, ...string[]];
880
+ baseColumn: never;
881
+ identity: undefined;
882
+ generated: undefined;
883
+ }, {}, {}>;
884
+ emailVerified: import("drizzle-orm/pg-core").PgColumn<{
885
+ name: "email_verified";
886
+ tableName: "junior_identities";
887
+ dataType: "boolean";
888
+ columnType: "PgBoolean";
889
+ data: boolean;
890
+ driverParam: boolean;
891
+ notNull: true;
892
+ hasDefault: true;
893
+ isPrimaryKey: false;
894
+ isAutoincrement: false;
895
+ hasRuntimeDefault: false;
896
+ enumValues: undefined;
897
+ baseColumn: never;
898
+ identity: undefined;
899
+ generated: undefined;
900
+ }, {}, {}>;
849
901
  };
850
902
  dialect: "pg";
851
903
  }>;
@@ -907,4 +959,113 @@ export declare const schema: {
907
959
  };
908
960
  dialect: "pg";
909
961
  }>;
962
+ juniorUsers: import("drizzle-orm/pg-core").PgTableWithColumns<{
963
+ name: "junior_users";
964
+ schema: undefined;
965
+ columns: {
966
+ id: import("drizzle-orm/pg-core").PgColumn<{
967
+ name: "id";
968
+ tableName: "junior_users";
969
+ dataType: "string";
970
+ columnType: "PgText";
971
+ data: string;
972
+ driverParam: string;
973
+ notNull: true;
974
+ hasDefault: false;
975
+ isPrimaryKey: true;
976
+ isAutoincrement: false;
977
+ hasRuntimeDefault: false;
978
+ enumValues: [string, ...string[]];
979
+ baseColumn: never;
980
+ identity: undefined;
981
+ generated: undefined;
982
+ }, {}, {}>;
983
+ primaryEmail: import("drizzle-orm/pg-core").PgColumn<{
984
+ name: "primary_email";
985
+ tableName: "junior_users";
986
+ dataType: "string";
987
+ columnType: "PgText";
988
+ data: string;
989
+ driverParam: string;
990
+ notNull: true;
991
+ hasDefault: false;
992
+ isPrimaryKey: false;
993
+ isAutoincrement: false;
994
+ hasRuntimeDefault: false;
995
+ enumValues: [string, ...string[]];
996
+ baseColumn: never;
997
+ identity: undefined;
998
+ generated: undefined;
999
+ }, {}, {}>;
1000
+ primaryEmailNormalized: import("drizzle-orm/pg-core").PgColumn<{
1001
+ name: "primary_email_normalized";
1002
+ tableName: "junior_users";
1003
+ dataType: "string";
1004
+ columnType: "PgText";
1005
+ data: string;
1006
+ driverParam: string;
1007
+ notNull: true;
1008
+ hasDefault: false;
1009
+ isPrimaryKey: false;
1010
+ isAutoincrement: false;
1011
+ hasRuntimeDefault: false;
1012
+ enumValues: [string, ...string[]];
1013
+ baseColumn: never;
1014
+ identity: undefined;
1015
+ generated: undefined;
1016
+ }, {}, {}>;
1017
+ displayName: import("drizzle-orm/pg-core").PgColumn<{
1018
+ name: "display_name";
1019
+ tableName: "junior_users";
1020
+ dataType: "string";
1021
+ columnType: "PgText";
1022
+ data: string;
1023
+ driverParam: string;
1024
+ notNull: false;
1025
+ hasDefault: false;
1026
+ isPrimaryKey: false;
1027
+ isAutoincrement: false;
1028
+ hasRuntimeDefault: false;
1029
+ enumValues: [string, ...string[]];
1030
+ baseColumn: never;
1031
+ identity: undefined;
1032
+ generated: undefined;
1033
+ }, {}, {}>;
1034
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
1035
+ name: string;
1036
+ tableName: "junior_users";
1037
+ dataType: "date";
1038
+ columnType: "PgTimestamp";
1039
+ data: Date;
1040
+ driverParam: string;
1041
+ notNull: true;
1042
+ hasDefault: false;
1043
+ isPrimaryKey: false;
1044
+ isAutoincrement: false;
1045
+ hasRuntimeDefault: false;
1046
+ enumValues: undefined;
1047
+ baseColumn: never;
1048
+ identity: undefined;
1049
+ generated: undefined;
1050
+ }, {}, {}>;
1051
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
1052
+ name: string;
1053
+ tableName: "junior_users";
1054
+ dataType: "date";
1055
+ columnType: "PgTimestamp";
1056
+ data: Date;
1057
+ driverParam: string;
1058
+ notNull: true;
1059
+ hasDefault: false;
1060
+ isPrimaryKey: false;
1061
+ isAutoincrement: false;
1062
+ hasRuntimeDefault: false;
1063
+ enumValues: undefined;
1064
+ baseColumn: never;
1065
+ identity: undefined;
1066
+ generated: undefined;
1067
+ }, {}, {}>;
1068
+ };
1069
+ dialect: "pg";
1070
+ }>;
910
1071
  };
@@ -53,7 +53,6 @@ export declare class SqlStore implements ConversationStore {
53
53
  private readConversationRow;
54
54
  /** Upsert the conversation row while preserving previously discovered nullable metadata fields. */
55
55
  private upsertConversation;
56
- private upsertIdentity;
57
56
  private upsertDestination;
58
57
  }
59
58
  /** Create a SQL-backed conversation store. */
@@ -0,0 +1,18 @@
1
+ export type IdentityKind = "service" | "system" | "user";
2
+ export interface IdentityUpsert {
3
+ displayName?: string;
4
+ email?: string;
5
+ emailVerified?: boolean;
6
+ handle?: string;
7
+ kind: IdentityKind;
8
+ metadata?: Record<string, unknown>;
9
+ provider: string;
10
+ providerSubjectId: string;
11
+ providerTenantId?: string;
12
+ }
13
+ export interface StoredIdentity {
14
+ id: string;
15
+ userId?: string;
16
+ }
17
+ /** Canonicalize email addresses for identity lookup and linking. */
18
+ export declare function normalizeIdentityEmail(email: string | undefined): string | undefined;
@@ -0,0 +1,4 @@
1
+ import type { JuniorSqlDatabase } from "@/chat/sql/db";
2
+ import { type IdentityUpsert, type StoredIdentity } from "./identity";
3
+ /** Persist one provider identity observation and link verified emails to users. */
4
+ export declare function upsertIdentity(executor: JuniorSqlDatabase, identity: IdentityUpsert, nowMs?: number): Promise<StoredIdentity>;