@sentry/junior 0.286.0 → 0.288.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 (78) hide show
  1. package/dist/{adapter-JQZaJ-B_.js → adapter-Cikcqdty.js} +1 -1
  2. package/dist/{admin-Dm2bimJ-.js → admin-BcSxHuTB.js} +2 -1
  3. package/dist/{agent-runner-DGCwOEyL.js → agent-runner-9MXyWUL8.js} +784 -368
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +9 -8
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +411 -65
  8. package/dist/{app-BKq0JzWx.d.ts → app-BUklJVBe.d.ts} +4 -2
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +555 -71
  11. package/dist/{assistant-reply-CAPafcUY.js → assistant-reply-mj47jMRV.js} +1 -1
  12. package/dist/{automation-B-jJN_gM.js → automation-DDXwHQs5.js} +4 -7
  13. package/dist/{background-compaction-queue-Btu2oab_.js → background-compaction-queue-CjllSPir.js} +161 -90
  14. package/dist/{briefs-UMeYehUe.js → briefs-DW9iuolG.js} +7 -5
  15. package/dist/{catalog-runtime-Bym8GVdh.js → catalog-runtime-B3gfH58M.js} +1 -1
  16. package/dist/cli/chat.js +14 -14
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +4 -4
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/config-CLJcyYEF.js +1762 -0
  24. package/dist/{connections-CQ7p0aNJ.js → connections-BtdJftow.js} +9 -9
  25. package/dist/{conversation-BusI2uzj.js → conversation-DhoqHtQ7.js} +30 -6
  26. package/dist/{conversation-pending-messages-DwehU0Fd.js → conversation-pending-messages-DHV0S4uF.js} +2 -5
  27. package/dist/{conversation-privacy-Cd_nZZBM.js → conversation-privacy-BPirIVlX.js} +1 -1
  28. package/dist/core-model-BTt5E5b0.js +182 -0
  29. package/dist/{credential-sync-DmiJi_At.js → credential-sync-Co8Q2xRW.js} +28 -20
  30. package/dist/{viewer-CH-ASQzh.js → db-Co7DTYYh.js} +62 -358
  31. package/dist/{db-C5zi4ecs.d.ts → db-zIs8-Ba3.d.ts} +6 -2
  32. package/dist/{executor-Dipi2Ixl.js → executor-m0kIN71Q.js} +102 -14
  33. package/dist/{media-B-BpXo41.js → history-IjdmO_r6.js} +8 -88
  34. package/dist/instrumentation.js +2 -2
  35. package/dist/{logging-CMFhLLj4.js → logging-DbD-dErY.js} +3 -2
  36. package/dist/media-BAHvgkok.js +85 -0
  37. package/dist/{message-D1xLljUF.js → message-DKTdTYm-.js} +10 -10
  38. package/dist/nitro.d.ts +1 -1
  39. package/dist/nitro.js +19 -41
  40. package/dist/{oauth-callback-server-DCAFIUQr.js → oauth-callback-server-CpbepSbp.js} +2 -2
  41. package/dist/{projection-CoeMNxJ4.js → projection-BViECfYu.js} +361 -746
  42. package/dist/{prompt-C9OQEfan.js → prompt-KT6MaDHN.js} +1 -1
  43. package/dist/{registry-u-sFYtx_.js → registry-D-Acyjhh.js} +1 -1
  44. package/dist/{reporting-window-B4TwyuJo.js → reporting-window-B3Ze-Qnt.js} +4 -1
  45. package/dist/{resolve-DYqgL3Eo.js → resolve-gkT2R66z.js} +3 -3
  46. package/dist/{result-CescSwAw.js → result-DHmCFEt8.js} +8 -8
  47. package/dist/{runner-Cr67a8TB.js → runner-DBKjGjH-.js} +8 -8
  48. package/dist/{sandbox-egress-signals-DLOazy5W.js → sandbox-egress-signals-9n8hqx29.js} +1 -1
  49. package/dist/{schedule-BTp__wrw.js → schedule-cP0AACm1.js} +11 -2
  50. package/dist/{schema-Ih60j59-.d.ts → schema-B_6aOcx5.d.ts} +159 -3
  51. package/dist/{schema-BUSi3sgv.js → schema-DxicIQbc.js} +79 -14
  52. package/dist/{service-account-CsKxktLk.js → service-account-Bi0HsY6w.js} +3 -3
  53. package/dist/{service-account-CGEqz9wG.js → service-account-CDlC9ssy.js} +3 -3
  54. package/dist/{session-stop-CGz5DByb.js → session-stop-BWOsuo8p.js} +62 -20
  55. package/dist/{skills-COCqf61f.js → skills-DO5K68Rq.js} +2 -2
  56. package/dist/spawn-BBqZDcPa.js +79 -0
  57. package/dist/{stop-GyFZkHuQ.js → stop-WC97cmHz.js} +832 -552
  58. package/dist/{store-D0-8plWp.js → store-ByR1Lr7e.js} +4 -16
  59. package/dist/{task-runner-xPuQmEot.js → task-runner-B-Ewf8TX.js} +30 -21
  60. package/dist/{turn-failure-response-BOviBdT-.js → turn-failure-response-CpdPoZSl.js} +25 -11
  61. package/dist/{validation-DZDKorGz.js → validation-B4sbIoES.js} +1 -1
  62. package/dist/{version-BTIz7fGi.js → version-D6lpuAgL.js} +1 -1
  63. package/dist/version.js +1 -1
  64. package/dist/viewer-CeP27tC3.js +337 -0
  65. package/dist/warmup-P_GJCL1c.js +767 -0
  66. package/dist/{work-C75_IM5e.js → work-DI7x1Slm.js} +32 -20
  67. package/dist/{worker-Dl47I729.js → worker-CYPTOT4j.js} +6 -7
  68. package/migrations/0088_conversation_unsubscribe.sql +1 -0
  69. package/migrations/0089_conversation_paused_status.sql +3 -0
  70. package/migrations/0090_guardian_review_time_index.sql +20 -0
  71. package/migrations/meta/0088_snapshot.json +4372 -0
  72. package/migrations/meta/0089_snapshot.json +4372 -0
  73. package/migrations/meta/0090_snapshot.json +4388 -0
  74. package/migrations/meta/_journal.json +21 -0
  75. package/package.json +5 -4
  76. package/dist/client-B0aAs7wC.js +0 -793
  77. package/dist/config-B9f9Lqo5.js +0 -579
  78. package/dist/spawn-C8F_iXWO.js +0 -42
@@ -1,11 +1,13 @@
1
- import "./config-B9f9Lqo5.js";
2
- import { p as logException } from "./logging-CMFhLLj4.js";
1
+ import { _ as withScope } from "./sentry-BRTJqumy.js";
2
+ import "./config-CLJcyYEF.js";
3
+ import { p as logException } from "./logging-DbD-dErY.js";
3
4
  import { AsyncLocalStorage } from "node:async_hooks";
4
5
  import { sql } from "drizzle-orm";
5
6
  import { bigint, boolean, check, date, doublePrecision, foreignKey, index, integer, jsonb, pgTable, primaryKey, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
6
- import { Pool } from "@neondatabase/serverless";
7
+ import { Pool, neon } from "@neondatabase/serverless";
7
8
  import { drizzle } from "drizzle-orm/neon-serverless";
8
9
  import { migrate } from "drizzle-orm/neon-serverless/migrator";
10
+ import { Agent } from "undici";
9
11
  import pg from "pg";
10
12
  import { drizzle as drizzle$1 } from "drizzle-orm/node-postgres";
11
13
  import { migrate as migrate$1 } from "drizzle-orm/node-postgres/migrator";
@@ -53,7 +55,7 @@ const juniorUsers = pgTable("junior_users", {
53
55
  timezone: text("timezone"),
54
56
  /** Text the user saved to change how Junior replies to them. */
55
57
  customization: text("customization"),
56
- /** Phone notification hours. Null means the default schedule. */
58
+ /** Push notification hours. Null means the default schedule. */
57
59
  notificationSchedule: jsonb("notification_schedule").$type(),
58
60
  /** Junior-wide admin role. Only the `junior admin` CLI changes it. */
59
61
  isAdmin: boolean("is_admin").notNull().default(false),
@@ -275,6 +277,7 @@ const juniorConversationEvents = pgTable("junior_conversation_events", {
275
277
  index("junior_conversation_events_history_version_idx").on(table.conversationId, table.historyVersion, table.seq),
276
278
  index("junior_conversation_events_type_idx").on(table.conversationId, table.type, table.seq),
277
279
  index("junior_conversation_events_plugin_report_idx").on(sql`(${table.payload}->>'namespace')`, sql`(${table.payload}->>'name')`, table.createdAt).where(sql`${table.type} = 'structured_event'`),
280
+ index("junior_conversation_events_guardian_review_time_idx").on(table.createdAt).where(sql`${table.type} = 'guardian_action_reviewed'`),
278
281
  index("junior_conversation_events_plugin_conversation_idx").on(table.conversationId, sql`(${table.payload}->>'namespace')`, sql`(${table.payload}->>'name')`, table.seq).where(sql`${table.type} = 'structured_event'`),
279
282
  index("junior_conversation_events_actor_identity_idx").on(table.actorIdentityId, table.conversationId, table.seq),
280
283
  index("junior_conversation_events_author_idx").on(table.conversationId, table.actorIdentityId, table.seq).where(sql`${table.actorIdentityId} is not null`),
@@ -366,7 +369,8 @@ const juniorConversationBindings = pgTable("junior_conversation_bindings", {
366
369
  /**
367
370
  * Materialized personal-feed membership for one linked user on one root
368
371
  * conversation. Rows come from the root actor and from the authors of Turn
369
- * input messages. Thread context authors do not get a row.
372
+ * input messages. Thread context authors do not get a row. An unsubscribed
373
+ * row keeps access but leaves the active feed.
370
374
  */
371
375
  const juniorConversationParticipants = pgTable("junior_conversation_participants", {
372
376
  userId: text("user_id").notNull().references(() => juniorUsers.id),
@@ -384,7 +388,13 @@ const juniorConversationParticipants = pgTable("junior_conversation_participants
384
388
  * Per-conversation auto-archive choice for this user. Null uses the
385
389
  * user's `autoArchiveDefault`.
386
390
  */
387
- autoArchive: boolean("auto_archive")
391
+ autoArchive: boolean("auto_archive"),
392
+ /**
393
+ * Set when this user left the conversation. It stays out of their
394
+ * active feed until they mention Junior in it again, subscribe, or pin
395
+ * it. The row keeps its access, so it is not deleted.
396
+ */
397
+ unsubscribedAt: timestamptz("unsubscribed_at")
388
398
  }, (table) => [
389
399
  primaryKey({
390
400
  name: "junior_conversation_participants_user_root_pk",
@@ -750,13 +760,91 @@ const juniorSqlSchema = {
750
760
  juniorWorkspaces
751
761
  };
752
762
  // src/db/neon.ts
763
+ /**
764
+ * Sends a pool query over Neon's SQL-over-HTTP endpoint when no idle
765
+ * WebSocket client is free.
766
+ *
767
+ * pg-pool reuses the newest idle client, so light polling keeps one or two
768
+ * clients warm and the rest idle out. A parallel read batch then opens about
769
+ * eight WebSockets, each with a new Postgres session. An HTTP query reuses the
770
+ * proxy's cached backend connection, so the batch skips that handshake. The
771
+ * warm path stays on WebSocket. `connect()` and transactions are unchanged.
772
+ */
773
+ var OverflowPool = class extends Pool {
774
+ pendingAcquires = 0;
775
+ webSocketOnly = new AsyncLocalStorage();
776
+ sql;
777
+ dispatcher;
778
+ statementTimeoutMs;
779
+ constructor(args) {
780
+ super({
781
+ connectionString: args.connectionString,
782
+ max: 10,
783
+ idleTimeoutMillis: 6e4,
784
+ statement_timeout: args.statementTimeoutMs
785
+ });
786
+ this.sql = neon(args.connectionString, { fullResults: true });
787
+ this.dispatcher = args.dispatcher;
788
+ this.statementTimeoutMs = args.statementTimeoutMs;
789
+ }
790
+ query(input, values, callback) {
791
+ const query = typeof input === "string" ? { text: input } : input;
792
+ if (callback !== void 0 || typeof values === "function" || typeof query?.text !== "string" || "submit" in query) return super.query(input, values, callback);
793
+ const params = values ?? query.values ?? [];
794
+ if (this.webSocketOnly.getStore() || this.idleCount > this.pendingAcquires || this.totalCount === 0) return this.queryWebSocket(query, params);
795
+ return this.queryHttp(query, params);
796
+ }
797
+ /** Keep every pool query in `callback` on WebSocket. */
798
+ async onWebSocket(callback) {
799
+ return await this.webSocketOnly.run(true, callback);
800
+ }
801
+ async queryWebSocket(query, params) {
802
+ const client = await this.acquire();
803
+ try {
804
+ const result = await client.query({
805
+ ...query,
806
+ values: params
807
+ });
808
+ client.release();
809
+ return result;
810
+ } catch (error) {
811
+ client.release(error);
812
+ throw error;
813
+ }
814
+ }
815
+ acquire() {
816
+ this.pendingAcquires++;
817
+ return new Promise((resolve, reject) => {
818
+ this.connect((error, client) => {
819
+ this.pendingAcquires--;
820
+ if (client) resolve(client);
821
+ else reject(error);
822
+ });
823
+ });
824
+ }
825
+ async queryHttp(query, params) {
826
+ const fetchOptions = { dispatcher: this.dispatcher };
827
+ if (this.statementTimeoutMs) fetchOptions.signal = AbortSignal.timeout(this.statementTimeoutMs);
828
+ return await withScope(async (scope) => {
829
+ scope.setAttributes({ "app.db.transport": "http" });
830
+ return await this.sql.query(query.text, params, {
831
+ arrayMode: query.rowMode === "array",
832
+ fullResults: true,
833
+ types: query.types ?? this.options.types,
834
+ fetchOptions
835
+ });
836
+ });
837
+ }
838
+ };
753
839
  var NeonExecutor = class {
754
840
  transactionClient = new AsyncLocalStorage();
755
841
  savepointId = 0;
756
842
  isolatedQueryId = 0;
757
843
  pool;
758
- constructor(pool) {
844
+ dispatcher;
845
+ constructor(pool, dispatcher) {
759
846
  this.pool = pool;
847
+ this.dispatcher = dispatcher;
760
848
  }
761
849
  db() {
762
850
  return drizzle(this.queryClient(), { schema: juniorSqlSchema });
@@ -840,13 +928,14 @@ var NeonExecutor = class {
840
928
  const lockName = `junior:migrate:${migrationTable}`;
841
929
  try {
842
930
  await client.query("SELECT pg_advisory_lock(hashtext($1))", [lockName]);
843
- return await callback();
931
+ return await this.pool.onWebSocket(callback);
844
932
  } finally {
845
933
  client.release(true);
846
934
  }
847
935
  }
848
936
  async close() {
849
937
  await this.pool.end();
938
+ await this.dispatcher.close();
850
939
  }
851
940
  queryClient() {
852
941
  return this.transactionClient.getStore() ?? this.pool;
@@ -854,16 +943,15 @@ var NeonExecutor = class {
854
943
  };
855
944
  /** Create the shared Neon-backed Junior SQL executor. */
856
945
  function createNeonJuniorSqlExecutor(args) {
857
- const pool = new Pool({
858
- connectionString: args.connectionString,
859
- max: 10,
860
- idleTimeoutMillis: 6e4,
861
- statement_timeout: args.statementTimeoutMs
946
+ const dispatcher = new Agent({ allowH2: true });
947
+ const pool = new OverflowPool({
948
+ ...args,
949
+ dispatcher
862
950
  });
863
951
  pool.on("error", (error) => {
864
952
  logException(error, "db.pool.client.failed", { "app.db.driver": "neon" });
865
953
  });
866
- return new NeonExecutor(pool);
954
+ return new NeonExecutor(pool, dispatcher);
867
955
  }
868
956
  // src/db/postgres.ts
869
957
  const { Pool: Pool$1 } = pg;
@@ -37,8 +37,8 @@ function instructionProvenanceFor(actor) {
37
37
  }
38
38
  /**
39
39
  * Provenance of an instruction that an agent wrote, such as a parent agent
40
- * task in a child Conversation. It has no Actor, so it never counts as user
41
- * intent.
40
+ * task in a child Conversation. It has no Actor: it is user intent only for a
41
+ * Run whose instructions an agent writes.
42
42
  */
43
43
  const agentInstructionProvenance = { authority: "instruction" };
44
44
  /** Unattributed ambient-context provenance for non-instruction messages. */
@@ -177,6 +177,7 @@ const historyReplacementEventDataSchema = z.object({
177
177
  modelProfile: legacyModelProfileSchema,
178
178
  modelId: z.string().min(1),
179
179
  details: compactionDetailsSchema.optional(),
180
+ costUsd: z.number().finite().nonnegative().optional(),
180
181
  summary: z.string().min(1).optional(),
181
182
  replacementHistory: replacementHistorySchema
182
183
  }).strict();
@@ -414,7 +415,10 @@ const compactionRequestedEventDataSchema = z.object({
414
415
  modelProfile: legacyModelProfileSchema,
415
416
  modelId: z.string().min(1)
416
417
  }).strict();
417
- const compactionPreparedFields = compactionRequestedEventDataSchema.extend({ type: z.literal("compaction_prepared") });
418
+ const compactionPreparedFields = compactionRequestedEventDataSchema.extend({
419
+ type: z.literal("compaction_prepared"),
420
+ costUsd: z.number().finite().nonnegative().optional()
421
+ });
418
422
  const compactionPreparedEventDataSchema = z.discriminatedUnion("outcome", [compactionPreparedFields.extend({
419
423
  outcome: z.literal("ready"),
420
424
  summary: z.string().min(1)
@@ -551,88 +555,4 @@ const newConversationEventSchema = z.object({
551
555
  idempotencyKey: z.string().min(1).optional(),
552
556
  createdAtMs: z.number().finite()
553
557
  }).strict();
554
- // src/chat/attachments/media.ts
555
- const INPUT_IMAGE_TYPES = [
556
- "image/png",
557
- "image/jpeg",
558
- "image/gif",
559
- "image/webp"
560
- ];
561
- /** Video types that browsers play in a `<video>` element. */
562
- const INLINE_VIDEO_TYPES = ["video/mp4", "video/webm"];
563
- /** Leading bytes of each accepted image type. `null` matches any byte. */
564
- const IMAGE_SIGNATURES = [
565
- {
566
- mediaType: "image/png",
567
- bytes: [
568
- 137,
569
- 80,
570
- 78,
571
- 71,
572
- 13,
573
- 10,
574
- 26,
575
- 10
576
- ]
577
- },
578
- {
579
- mediaType: "image/jpeg",
580
- bytes: [
581
- 255,
582
- 216,
583
- 255
584
- ]
585
- },
586
- {
587
- mediaType: "image/gif",
588
- bytes: [
589
- 71,
590
- 73,
591
- 70,
592
- 56,
593
- 55,
594
- 97
595
- ]
596
- },
597
- {
598
- mediaType: "image/gif",
599
- bytes: [
600
- 71,
601
- 73,
602
- 70,
603
- 56,
604
- 57,
605
- 97
606
- ]
607
- },
608
- {
609
- mediaType: "image/webp",
610
- bytes: [
611
- 82,
612
- 73,
613
- 70,
614
- 70,
615
- null,
616
- null,
617
- null,
618
- null,
619
- 87,
620
- 69,
621
- 66,
622
- 80
623
- ]
624
- }
625
- ];
626
- /**
627
- * Detect an accepted image type from file bytes. Use this instead of a file
628
- * name or declared content type, which can be wrong.
629
- */
630
- function detectImageMediaType(data) {
631
- return IMAGE_SIGNATURES.find(({ bytes }) => data.length >= bytes.length && bytes.every((byte, index) => byte === null || data[index] === byte))?.mediaType;
632
- }
633
- /** Report whether a media type is a raster image accepted by vision models. */
634
- function isVisionImageMediaType(mediaType) {
635
- const normalized = mediaType.split(";", 1)[0]?.trim().toLowerCase();
636
- return normalized ? INPUT_IMAGE_TYPES.some((type) => type === normalized) : false;
637
- }
638
- export { instructionProvenanceFor as _, KNOWN_CONVERSATION_EVENT_TYPES as a, conversationTurnFailureCodeSchema as c, historyReplacementSchema as d, newConversationEventSchema as f, instructionActors as g, contextProvenance as h, isVisionImageMediaType as i, conversationTurnFailureReasonSchema as l, agentInstructionProvenance as m, INPUT_IMAGE_TYPES as n, agentHistoryItemSchema as o, encodeHistoryPayload as p, detectImageMediaType as r, conversationEventDataSchema as s, INLINE_VIDEO_TYPES as t, decodeStoredConversationEvent as u, sameActorIdentity as v, usageSchema as y };
558
+ export { conversationTurnFailureReasonSchema as a, newConversationEventSchema as c, contextProvenance as d, instructionActors as f, usageSchema as h, conversationTurnFailureCodeSchema as i, encodeHistoryPayload as l, sameActorIdentity as m, agentHistoryItemSchema as n, decodeStoredConversationEvent as o, instructionProvenanceFor as p, conversationEventDataSchema as r, historyReplacementSchema as s, KNOWN_CONVERSATION_EVENT_TYPES as t, agentInstructionProvenance as u };
@@ -1,6 +1,6 @@
1
1
  import { a as getClient, c as init, i as getActiveSpan, o as getGlobalScope, p as spanToJSON, s as getTraceData } from "./sentry-BRTJqumy.js";
2
- import { R as getDeploymentServiceVersion, z as getDeploymentTelemetryAttributes } from "./logging-CMFhLLj4.js";
3
- import { n as getCurrentConversationPrivacy } from "./conversation-privacy-Cd_nZZBM.js";
2
+ import { B as getDeploymentTelemetryAttributes, z as getDeploymentServiceVersion } from "./logging-DbD-dErY.js";
3
+ import { n as getCurrentConversationPrivacy } from "./conversation-privacy-BPirIVlX.js";
4
4
  import { n as redactSandboxEgressProxyPath } from "./proxy-path-BHYoKZdq.js";
5
5
  import { t as consumePrivateTraceResultMarker } from "./private-trace-result-CE7_lEdq.js";
6
6
  import { n as promoteHttpRouteName, r as routeNameMiddleware, t as nameRequestRoute } from "./sentry-route-name-BhwWnfqj.js";
@@ -1,5 +1,5 @@
1
1
  import { _ as withScope, d as setTag, f as setUser, h as startSpan, i as getActiveSpan, l as logger, n as captureMessage, p as spanToJSON, s as getTraceData, t as captureException } from "./sentry-BRTJqumy.js";
2
- import { t as JUNIOR_VERSION } from "./version-BTIz7fGi.js";
2
+ import { t as JUNIOR_VERSION } from "./version-D6lpuAgL.js";
3
3
  import path from "node:path";
4
4
  import { styleText } from "node:util";
5
5
  import { ConfigError, configureSync, getConfig, getLogger } from "@logtape/logtape";
@@ -117,6 +117,7 @@ const JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE = "17 * * * *";
117
117
  const JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE = "/api/internal/agent/continue";
118
118
  const JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE = "/api/internal/plugin/tasks";
119
119
  const JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE = "/api/internal/workspace/snapshots";
120
+ const JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE = "/api/internal/cache/warmups";
120
121
  const JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE = "/api/internal/context/compactions";
121
122
  const LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION = "api/internal/agent/continue.ts";
122
123
  const SERVICE_INSTANCE_ID = randomUUID();
@@ -1247,4 +1248,4 @@ function extractGenAiUsageAttributes(...sources) {
1247
1248
  ...cost?.total !== void 0 ? { "app.cost.total_usd": cost.total } : void 0
1248
1249
  };
1249
1250
  }
1250
- export { JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE as A, runWithLogAttributes as B, summarizeMessageText as C, JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE as D, withSpan as E, JUNIOR_RETENTION_ROUTE as F, toOptionalNumber as G, isNativeIdentityProvider as H, JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE as I, toOptionalString as K, LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION as L, JUNIOR_HEARTBEAT_ROUTE as M, JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE as N, JUNIOR_AUTO_ARCHIVE_ROUTE as O, JUNIOR_RETENTION_CRON_SCHEDULE as P, getDeploymentServiceVersion as R, setTags as S, withLogContext as T, normalizeIdentityEmail as U, GOOGLE_IDENTITY_PROVIDER as V, isRecord as W, runBestEffort as _, extractGenAiUsageSummary as a, setSpanAttributes as b, getLogContextAttributes as c, logAudit as d, logError as f, normalizeGenAiFinishReason as g, logWarn as h, extractGenAiUsageAttributes as i, JUNIOR_HEARTBEAT_CRON_SCHEDULE as j, JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE as k, getLogContextAttributesForSpan as l, logInfo as m, createChatSdkLogger as n, getActiveTraceContext as o, logException as p, createRequestContext as r, getActiveTraceId as s, buildTurnFailureResponse as t, getTracePropagationHeaders as u, serializeGenAiAttribute as v, withContext as w, setSpanStatus as x, setSentryUser as y, getDeploymentTelemetryAttributes as z };
1251
+ export { JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE as A, getDeploymentTelemetryAttributes as B, summarizeMessageText as C, JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE as D, withSpan as E, JUNIOR_RETENTION_CRON_SCHEDULE as F, normalizeIdentityEmail as G, runWithLogContext as H, JUNIOR_RETENTION_ROUTE as I, toOptionalString as J, isRecord as K, JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE as L, JUNIOR_HEARTBEAT_CRON_SCHEDULE as M, JUNIOR_HEARTBEAT_ROUTE as N, JUNIOR_AUTO_ARCHIVE_ROUTE as O, JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE as P, LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION as R, setTags as S, withLogContext as T, GOOGLE_IDENTITY_PROVIDER as U, runWithLogAttributes as V, isNativeIdentityProvider as W, runBestEffort as _, extractGenAiUsageSummary as a, setSpanAttributes as b, getLogContextAttributes as c, logAudit as d, logError as f, normalizeGenAiFinishReason as g, logWarn as h, extractGenAiUsageAttributes as i, JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE as j, JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE as k, getLogContextAttributesForSpan as l, logInfo as m, createChatSdkLogger as n, getActiveTraceContext as o, logException as p, toOptionalNumber as q, createRequestContext as r, getActiveTraceId as s, buildTurnFailureResponse as t, getTracePropagationHeaders as u, serializeGenAiAttribute as v, withContext as w, setSpanStatus as x, setSentryUser as y, getDeploymentServiceVersion as z };
@@ -0,0 +1,85 @@
1
+ // src/chat/attachments/media.ts
2
+ const INPUT_IMAGE_TYPES = [
3
+ "image/png",
4
+ "image/jpeg",
5
+ "image/gif",
6
+ "image/webp"
7
+ ];
8
+ /** Video types that browsers play in a `<video>` element. */
9
+ const INLINE_VIDEO_TYPES = ["video/mp4", "video/webm"];
10
+ /** Leading bytes of each accepted image type. `null` matches any byte. */
11
+ const IMAGE_SIGNATURES = [
12
+ {
13
+ mediaType: "image/png",
14
+ bytes: [
15
+ 137,
16
+ 80,
17
+ 78,
18
+ 71,
19
+ 13,
20
+ 10,
21
+ 26,
22
+ 10
23
+ ]
24
+ },
25
+ {
26
+ mediaType: "image/jpeg",
27
+ bytes: [
28
+ 255,
29
+ 216,
30
+ 255
31
+ ]
32
+ },
33
+ {
34
+ mediaType: "image/gif",
35
+ bytes: [
36
+ 71,
37
+ 73,
38
+ 70,
39
+ 56,
40
+ 55,
41
+ 97
42
+ ]
43
+ },
44
+ {
45
+ mediaType: "image/gif",
46
+ bytes: [
47
+ 71,
48
+ 73,
49
+ 70,
50
+ 56,
51
+ 57,
52
+ 97
53
+ ]
54
+ },
55
+ {
56
+ mediaType: "image/webp",
57
+ bytes: [
58
+ 82,
59
+ 73,
60
+ 70,
61
+ 70,
62
+ null,
63
+ null,
64
+ null,
65
+ null,
66
+ 87,
67
+ 69,
68
+ 66,
69
+ 80
70
+ ]
71
+ }
72
+ ];
73
+ /**
74
+ * Detect an accepted image type from file bytes. Use this instead of a file
75
+ * name or declared content type, which can be wrong.
76
+ */
77
+ function detectImageMediaType(data) {
78
+ return IMAGE_SIGNATURES.find(({ bytes }) => data.length >= bytes.length && bytes.every((byte, index) => byte === null || data[index] === byte))?.mediaType;
79
+ }
80
+ /** Report whether a media type is a raster image accepted by vision models. */
81
+ function isVisionImageMediaType(mediaType) {
82
+ const normalized = mediaType.split(";", 1)[0]?.trim().toLowerCase();
83
+ return normalized ? INPUT_IMAGE_TYPES.some((type) => type === normalized) : false;
84
+ }
85
+ export { isVisionImageMediaType as i, INPUT_IMAGE_TYPES as n, detectImageMediaType as r, INLINE_VIDEO_TYPES as t };
@@ -1,13 +1,13 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { Qa as canAccessConversation, eo as readConversationAccessFromSql, yn as renderUntrustedTag } from "./projection-CoeMNxJ4.js";
3
- import { n as botConfig } from "./config-B9f9Lqo5.js";
4
- import { S as getDb, V as SYSTEM_IDENTITY_ID, x as getConversationStore } from "./viewer-CH-ASQzh.js";
5
- import { Gt as actorFromRun, It as AgentMessagePausedError, Kt as toolInvocationDestination, Rt as AgentMessageTargetError } from "./agent-runner-DGCwOEyL.js";
6
- import { F as PARENT_AGENT_TARGET, v as getActiveAgentInvocationForConversation } from "./turn-failure-response-BOviBdT-.js";
7
- import { G as admitAutomatedTurn, S as EVENT_WAIT_MS, V as postAutomatedTurnLimitNoticeForConversation } from "./session-stop-CGz5DByb.js";
8
- import { r as appendAndEnqueueInboundMessage } from "./store-D0-8plWp.js";
9
- import { a as enqueueAgentInvocation, c as createAgentInvocationForMessage, u as findChildAgentConversationId } from "./work-C75_IM5e.js";
10
- import { r as enqueueAgentMessageToParent } from "./result-CescSwAw.js";
2
+ import { Ya as readConversationAccessFromSql, qa as canAccessConversation, wn as renderUntrustedTag } from "./projection-BViECfYu.js";
3
+ import { n as botConfig } from "./config-CLJcyYEF.js";
4
+ import { T as SYSTEM_IDENTITY_ID, a as getConversationStore, o as getDb } from "./db-Co7DTYYh.js";
5
+ import { $t as actorFromRun, Kt as AgentMessageTargetError, Wt as AgentMessagePausedError, en as toolInvocationDestination } from "./agent-runner-9MXyWUL8.js";
6
+ import { I as PARENT_AGENT_TARGET, v as getActiveAgentInvocationForConversation } from "./turn-failure-response-CpdPoZSl.js";
7
+ import { G as admitAutomatedTurn, S as EVENT_WAIT_MS, V as postAutomatedTurnLimitNoticeForConversation } from "./session-stop-BWOsuo8p.js";
8
+ import { r as appendAndEnqueueInboundMessage } from "./store-ByR1Lr7e.js";
9
+ import { a as enqueueAgentInvocation, c as createAgentInvocationForMessage, u as findChildAgentConversationId } from "./work-DI7x1Slm.js";
10
+ import { r as enqueueAgentMessageToParent } from "./result-DHmCFEt8.js";
11
11
  // src/chat/agent-invocations/top-level-message.ts
12
12
  const AGENT_MESSAGE_EVENT_NAMESPACE = "junior";
13
13
  /** Event type of a message from another top-level agent. */
@@ -15,7 +15,7 @@ const TOP_LEVEL_AGENT_MESSAGE_EVENT_TYPE = "agent.top_level_message";
15
15
  /**
16
16
  * Check that a top-level agent can message another top-level agent under
17
17
  * `policies/conversation-access.md`. A private Conversation is isolated, so
18
- * only public agents in the same provider tenant can message each other.
18
+ * only public agents can message each other.
19
19
  * Every target that the sender cannot reach gets the same error, so the
20
20
  * error does not show that a private Conversation exists.
21
21
  */
package/dist/nitro.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as JuniorDashboardOptions } from "./app-BKq0JzWx.js";
1
+ import { i as JuniorDashboardOptions } from "./app-BUklJVBe.js";
2
2
  import { n as JuniorPluginSet } from "./plugins-DtmjkTza.js";
3
3
  import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
4
4
  type SentryNitroConfig = Parameters<typeof withSentryConfig$1>[0];
package/dist/nitro.js CHANGED
@@ -1,6 +1,6 @@
1
- import { A as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_ROUTE, I as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_ROUTE, N as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_RETENTION_CRON_SCHEDULE, R as getDeploymentServiceVersion, j as JUNIOR_HEARTBEAT_CRON_SCHEDULE, k as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE } from "./logging-CMFhLLj4.js";
1
+ import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_CRON_SCHEDULE, I as JUNIOR_RETENTION_ROUTE, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_CRON_SCHEDULE, N as JUNIOR_HEARTBEAT_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE, z as getDeploymentServiceVersion } from "./logging-DbD-dErY.js";
2
2
  import { d as resolvePackageDir, t as discoverInstalledPluginPackageContent, u as isValidPackageName } from "./package-discovery-DJhGdS4c.js";
3
- import { a as PLUGIN_TASK_QUEUE_TOPIC, p as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, v as resolveConversationWorkQueueTopic } from "./background-compaction-queue-Btu2oab_.js";
3
+ import { S as CACHE_WARMUP_QUEUE_TOPIC, _ as resolveConversationWorkQueueTopic, a as PLUGIN_TASK_QUEUE_TOPIC, f as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, t as BACKGROUND_COMPACTION_QUEUE_TOPIC } from "./background-compaction-queue-CjllSPir.js";
4
4
  import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-HYh_JOdw.js";
5
5
  import { n as loadPluginSetFromModule, r as resolvePluginModule } from "./plugin-module-Cf5gVPWP.js";
6
6
  import path from "node:path";
@@ -239,46 +239,24 @@ function configureVercelDeployment(nitro, options) {
239
239
  nitro.options.vercel.functions ??= {};
240
240
  nitro.options.vercel.functions.maxDuration = defaultMaxDuration;
241
241
  nitro.options.vercel.functionRules ??= {};
242
- const existingRule = nitro.options.vercel.functionRules["/api/internal/agent/continue"] ?? {};
243
- const otherTriggers = (Array.isArray(existingRule.experimentalTriggers) ? existingRule.experimentalTriggers : []).filter((trigger) => trigger.type !== VERCEL_QUEUE_TRIGGER_TYPE);
244
- nitro.options.vercel.functionRules[JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE] = {
245
- ...existingRule,
246
- maxDuration: defaultMaxDuration,
247
- experimentalTriggers: [...otherTriggers, {
248
- type: VERCEL_QUEUE_TRIGGER_TYPE,
249
- topic: queueTopic
250
- }]
251
- };
252
- const existingPluginTaskRule = nitro.options.vercel.functionRules["/api/internal/plugin/tasks"] ?? {};
253
- const otherPluginTaskTriggers = (Array.isArray(existingPluginTaskRule.experimentalTriggers) ? existingPluginTaskRule.experimentalTriggers : []).filter((trigger) => trigger.type !== VERCEL_QUEUE_TRIGGER_TYPE);
254
- nitro.options.vercel.functionRules[JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE] = {
255
- ...existingPluginTaskRule,
256
- maxDuration: defaultMaxDuration,
257
- experimentalTriggers: [...otherPluginTaskTriggers, {
258
- type: VERCEL_QUEUE_TRIGGER_TYPE,
259
- topic: PLUGIN_TASK_QUEUE_TOPIC
260
- }]
261
- };
262
- const existingSnapshotJobRule = nitro.options.vercel.functionRules["/api/internal/workspace/snapshots"] ?? {};
263
- const otherSnapshotJobTriggers = (Array.isArray(existingSnapshotJobRule.experimentalTriggers) ? existingSnapshotJobRule.experimentalTriggers : []).filter((trigger) => trigger.type !== VERCEL_QUEUE_TRIGGER_TYPE);
264
- nitro.options.vercel.functionRules[JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE] = {
265
- ...existingSnapshotJobRule,
266
- maxDuration: defaultMaxDuration,
267
- experimentalTriggers: [...otherSnapshotJobTriggers, {
268
- type: VERCEL_QUEUE_TRIGGER_TYPE,
269
- topic: WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC
270
- }]
271
- };
272
- const existingCompactionRule = nitro.options.vercel.functionRules["/api/internal/context/compactions"] ?? {};
273
- const otherCompactionTriggers = (Array.isArray(existingCompactionRule.experimentalTriggers) ? existingCompactionRule.experimentalTriggers : []).filter((trigger) => trigger.type !== VERCEL_QUEUE_TRIGGER_TYPE);
274
- nitro.options.vercel.functionRules[JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE] = {
275
- ...existingCompactionRule,
276
- maxDuration: defaultMaxDuration,
277
- experimentalTriggers: [...otherCompactionTriggers, {
278
- type: VERCEL_QUEUE_TRIGGER_TYPE,
279
- topic: BACKGROUND_COMPACTION_QUEUE_TOPIC
280
- }]
242
+ const functionRules = nitro.options.vercel.functionRules;
243
+ const addQueueTrigger = (route, topic) => {
244
+ const existingRule = functionRules[route] ?? {};
245
+ const existingTriggers = Array.isArray(existingRule.experimentalTriggers) ? existingRule.experimentalTriggers : [];
246
+ functionRules[route] = {
247
+ ...existingRule,
248
+ maxDuration: defaultMaxDuration,
249
+ experimentalTriggers: [...existingTriggers.filter((trigger) => trigger.type !== VERCEL_QUEUE_TRIGGER_TYPE), {
250
+ type: VERCEL_QUEUE_TRIGGER_TYPE,
251
+ topic
252
+ }]
253
+ };
281
254
  };
255
+ addQueueTrigger(JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, queueTopic);
256
+ addQueueTrigger(JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, PLUGIN_TASK_QUEUE_TOPIC);
257
+ addQueueTrigger(JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC);
258
+ addQueueTrigger(JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE, CACHE_WARMUP_QUEUE_TOPIC);
259
+ addQueueTrigger(JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, BACKGROUND_COMPACTION_QUEUE_TOPIC);
282
260
  return defaultMaxDuration;
283
261
  }
284
262
  /** Nitro module that configures deployment wiring and copies app/plugin content into the Vercel build output. */
@@ -1,5 +1,5 @@
1
- import { In as createUserTokenStore } from "./projection-CoeMNxJ4.js";
2
- import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-DmiJi_At.js";
1
+ import { Dn as createUserTokenStore } from "./projection-BViECfYu.js";
2
+ import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-Co8Q2xRW.js";
3
3
  import { createServer } from "node:http";
4
4
  // src/chat/local/oauth-callback-server.ts
5
5
  const LOCAL_OAUTH_TIMEOUT_MS = 6e5;