@sentry/junior 0.177.0 → 0.179.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 (102) hide show
  1. package/dist/{agent-hooks-IYHCN7CO.js → agent-hooks-32IDCLMW.js} +12 -12
  2. package/dist/api/conversations/archive.d.ts +5 -2
  3. package/dist/api/conversations/list.d.ts +0 -1
  4. package/dist/api/conversations/membership.d.ts +14 -0
  5. package/dist/api/conversations/projection.d.ts +2 -1
  6. package/dist/api/locations/detail.d.ts +1 -1
  7. package/dist/api/people/shared.d.ts +2 -2
  8. package/dist/api/schema/conversation.d.ts +4 -4
  9. package/dist/api/schema/location.d.ts +1 -1
  10. package/dist/api/schema/person.d.ts +1 -1
  11. package/dist/api/schema.js +1 -1
  12. package/dist/api.js +399 -287
  13. package/dist/app.js +573 -198
  14. package/dist/{catalog-runtime-2TD4CXSB.js → catalog-runtime-FBVA6WAQ.js} +5 -5
  15. package/dist/chat/agent/sandbox.d.ts +2 -0
  16. package/dist/chat/conversations/sql/participants.d.ts +1 -0
  17. package/dist/chat/conversations/store.d.ts +0 -1
  18. package/dist/chat/sandbox/errors.d.ts +4 -0
  19. package/dist/chat/sandbox/noninteractive-command.d.ts +1 -0
  20. package/dist/chat/sandbox/prepare-workspace.d.ts +27 -3
  21. package/dist/chat/sandbox/sandbox.d.ts +2 -0
  22. package/dist/chat/sandbox/session.d.ts +2 -0
  23. package/dist/chat/sandbox/snapshot/builder-sandbox.d.ts +5 -0
  24. package/dist/chat/sandbox/snapshot/install.d.ts +2 -2
  25. package/dist/chat/sandbox/snapshot/span.d.ts +3 -0
  26. package/dist/chat/sandbox/snapshot/store.d.ts +20 -17
  27. package/dist/chat/sandbox/snapshot/waiting-error.d.ts +15 -0
  28. package/dist/chat/sandbox/snapshot/workspace.d.ts +17 -0
  29. package/dist/chat/scheduled-tasks/personal.d.ts +5 -8
  30. package/dist/chat/scheduled-tasks/runs.d.ts +49 -0
  31. package/dist/chat/scheduled-tasks/schedule-intent.d.ts +1 -1
  32. package/dist/chat/scheduled-tasks/tasks.d.ts +27 -0
  33. package/dist/chat/scheduled-tasks/tool-support.d.ts +0 -4
  34. package/dist/chat/scheduled-tasks/tools/create.d.ts +1 -1
  35. package/dist/chat/scheduled-tasks/tools/update.d.ts +1 -1
  36. package/dist/chat/scheduled-tasks/types.d.ts +127 -78
  37. package/dist/chat/services/workspace-snapshot-wait.d.ts +27 -0
  38. package/dist/chat/workspaces/types.d.ts +1 -0
  39. package/dist/{chunk-CAWBLVBY.js → chunk-2HIPYNQI.js} +6 -6
  40. package/dist/{chunk-ZCYABD7N.js → chunk-3AFVR5UC.js} +5 -5
  41. package/dist/{chunk-PA7QDS7P.js → chunk-3I7XE3PA.js} +204 -100
  42. package/dist/{chunk-VGDOEKO2.js → chunk-3TM3FYLQ.js} +1 -1
  43. package/dist/{chunk-6NZRKJWU.js → chunk-4GWXAILB.js} +1 -1
  44. package/dist/{chunk-LFZODSAY.js → chunk-5IRROPA5.js} +4 -4
  45. package/dist/{chunk-N4YEVOEC.js → chunk-B6ECUSVX.js} +45 -276
  46. package/dist/{chunk-4TWDRU64.js → chunk-CJLBLELR.js} +5 -5
  47. package/dist/{chunk-3FWXQZJJ.js → chunk-FAS6AIMF.js} +1 -1
  48. package/dist/{chunk-I7PKGMKI.js → chunk-FIDMHAO6.js} +6 -6
  49. package/dist/{chunk-4SVAFAI2.js → chunk-FTGD2FBP.js} +1 -1
  50. package/dist/{chunk-LVL5NG5G.js → chunk-G2CAC4CV.js} +19 -19
  51. package/dist/{chunk-DLTP6TUJ.js → chunk-GENV6KF2.js} +2 -2
  52. package/dist/{chunk-FVVYHML7.js → chunk-GPLAT6H7.js} +6 -6
  53. package/dist/{chunk-7CVYXUOJ.js → chunk-HQNE5APD.js} +1 -1
  54. package/dist/{chunk-Q362TECJ.js → chunk-JMJNFEDC.js} +331 -2
  55. package/dist/{chunk-AFOFVEXP.js → chunk-JT4WMD3C.js} +124 -13
  56. package/dist/{chunk-7ZFESKJ2.js → chunk-KJLHIHFF.js} +9 -9
  57. package/dist/{chunk-QLLOX7JY.js → chunk-Q5B3WTGG.js} +8 -8
  58. package/dist/{chunk-DGGIKWYQ.js → chunk-R5NWWYIS.js} +1 -1
  59. package/dist/{chunk-WCQUKX74.js → chunk-R6U7N4FS.js} +14 -5
  60. package/dist/{chunk-WYO2HXY5.js → chunk-RTRBYSF3.js} +1 -1
  61. package/dist/{chunk-2IMQLZHS.js → chunk-RZRYOLCE.js} +1144 -136
  62. package/dist/{chunk-7B6NW4P7.js → chunk-SLGGOASN.js} +1 -1
  63. package/dist/{chunk-SNPQGTHJ.js → chunk-TIEKUH4Q.js} +1 -1
  64. package/dist/{chunk-ELEAIRTG.js → chunk-TKB25A3L.js} +2 -2
  65. package/dist/{chunk-UB5YB2ED.js → chunk-U4TKB6F6.js} +6 -6
  66. package/dist/{chunk-ORMJY4RG.js → chunk-UT6X7XN7.js} +1 -1
  67. package/dist/{chunk-LPMLAJYR.js → chunk-VP4OVRDD.js} +11 -17
  68. package/dist/{chunk-7PZDAXIK.js → chunk-XSPSCWLH.js} +1 -1
  69. package/dist/chunk-XZY6G5YZ.js +1088 -0
  70. package/dist/{chunk-J2EWL6GJ.js → chunk-YFNAMRGE.js} +1 -1
  71. package/dist/{chunk-6KGMMVHF.js → chunk-ZQMG3CL5.js} +2 -2
  72. package/dist/cli/chat.js +31 -30
  73. package/dist/cli/check.js +6 -6
  74. package/dist/cli/plugins.js +13 -13
  75. package/dist/cli/snapshot-create.js +10 -10
  76. package/dist/cli/upgrade.js +7 -7
  77. package/dist/db/schema/conversation-participants.d.ts +17 -0
  78. package/dist/db/schema/conversations.d.ts +629 -1
  79. package/dist/db/schema/scheduled-tasks.d.ts +29 -5
  80. package/dist/db/schema/snapshots.d.ts +1 -1
  81. package/dist/db/schema.d.ts +46 -5
  82. package/dist/{db-A3CB76US.js → db-EJAV7JL6.js} +7 -7
  83. package/dist/instrumentation.js +4 -4
  84. package/dist/nitro.js +2 -2
  85. package/dist/{oauth-callback-server-64QMI3IB.js → oauth-callback-server-GAVSUBTQ.js} +23 -23
  86. package/dist/{runner-EIAE2BGD.js → runner-34JL64JF.js} +15 -15
  87. package/dist/{skills-ZADWFKDG.js → skills-U545HALM.js} +6 -6
  88. package/dist/spawn-I2S4IDUQ.js +37 -0
  89. package/dist/{validation-4I6AF4CV.js → validation-EVXVGA44.js} +6 -6
  90. package/dist/version.js +1 -1
  91. package/dist/{work-BS6BZ66U.js → work-QOAUPDBU.js} +18 -18
  92. package/dist/worker-5GX2IKLZ.js +24 -0
  93. package/migrations/0033_workspace_snapshot_active_build.sql +1 -0
  94. package/migrations/0034_strong_randall.sql +31 -0
  95. package/migrations/meta/0033_snapshot.json +2914 -0
  96. package/migrations/meta/0034_snapshot.json +3038 -0
  97. package/migrations/meta/_journal.json +15 -1
  98. package/package.json +4 -4
  99. package/dist/chat/scheduled-tasks/store.d.ts +0 -78
  100. package/dist/chunk-4TRHPYTL.js +0 -1944
  101. package/dist/spawn-DVUOUFFC.js +0 -37
  102. package/dist/worker-RS5PWTCE.js +0 -24
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  appendAndEnqueueInboundMessage
3
- } from "./chunk-LFZODSAY.js";
3
+ } from "./chunk-5IRROPA5.js";
4
4
  import {
5
5
  ConversationTurnLifecycleService,
6
6
  getPersistedSandboxState,
7
7
  getPersistedThreadState,
8
8
  persistThreadStateById
9
- } from "./chunk-4TWDRU64.js";
9
+ } from "./chunk-CJLBLELR.js";
10
10
  import {
11
11
  AgentInvocationBusyError,
12
12
  AgentInvocationLimitError,
@@ -15,7 +15,7 @@ import {
15
15
  agentBindingSchema,
16
16
  agentInvocationSchema,
17
17
  createAgentInvocationSchema
18
- } from "./chunk-ZCYABD7N.js";
18
+ } from "./chunk-3AFVR5UC.js";
19
19
  import {
20
20
  TurnInputCommitLostError,
21
21
  failTurnRecord,
@@ -26,16 +26,16 @@ import {
26
26
  isTurnInputCommitLostError,
27
27
  openConversationProjection,
28
28
  saveTurnCheckpoint
29
- } from "./chunk-I7PKGMKI.js";
29
+ } from "./chunk-FIDMHAO6.js";
30
30
  import {
31
31
  getConversationEventStore,
32
32
  getConversationStore,
33
33
  getSqlExecutor
34
- } from "./chunk-LPMLAJYR.js";
34
+ } from "./chunk-VP4OVRDD.js";
35
35
  import {
36
36
  juniorAgentBindings,
37
37
  juniorAgentInvocations
38
- } from "./chunk-WCQUKX74.js";
38
+ } from "./chunk-R6U7N4FS.js";
39
39
 
40
40
  // src/chat/agent-invocations/work.ts
41
41
  import { z } from "zod";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-6GWA276C.js";
10
10
  import {
11
11
  getDeploymentTelemetryAttributes
12
- } from "./chunk-ORMJY4RG.js";
12
+ } from "./chunk-UT6X7XN7.js";
13
13
 
14
14
  // src/chat/logging.ts
15
15
  import path from "path";
@@ -1,6 +1,13 @@
1
+ import {
2
+ toOptionalTrimmed
3
+ } from "./chunk-GENV6KF2.js";
1
4
  import {
2
5
  pluginCatalogRuntime
3
- } from "./chunk-J2EWL6GJ.js";
6
+ } from "./chunk-YFNAMRGE.js";
7
+ import {
8
+ setSpanAttributes,
9
+ setSpanStatus
10
+ } from "./chunk-HQNE5APD.js";
4
11
 
5
12
  // src/chat/sandbox/paths.ts
6
13
  function normalizeWorkspaceRoot(input) {
@@ -93,7 +100,8 @@ async function runNonInteractiveCommand(sandbox, input) {
93
100
  ...buildNonInteractiveCommand(input),
94
101
  ...input.cwd ? { cwd: input.cwd } : {},
95
102
  ...input.signal ? { signal: input.signal } : {},
96
- ...input.sudo !== void 0 ? { sudo: input.sudo } : {}
103
+ ...input.sudo !== void 0 ? { sudo: input.sudo } : {},
104
+ ...input.timeoutMs !== void 0 ? { timeoutMs: input.timeoutMs } : {}
97
105
  };
98
106
  return await sandbox.runCommand(command);
99
107
  }
@@ -380,6 +388,313 @@ function sleep(ms, signal) {
380
388
  });
381
389
  }
382
390
 
391
+ // src/chat/sandbox/credentials.ts
392
+ function getVercelSandboxCredentials() {
393
+ const token = toOptionalTrimmed(process.env.VERCEL_TOKEN);
394
+ const teamId = toOptionalTrimmed(process.env.VERCEL_TEAM_ID);
395
+ const projectId = toOptionalTrimmed(process.env.VERCEL_PROJECT_ID);
396
+ if (token && teamId && projectId) {
397
+ return { token, teamId, projectId };
398
+ }
399
+ return void 0;
400
+ }
401
+
402
+ // src/chat/sandbox/snapshot/waiting-error.ts
403
+ var WorkspaceSnapshotWaitingError = class extends Error {
404
+ code = "workspace_snapshot_waiting";
405
+ workspaceName;
406
+ constructor(workspaceName) {
407
+ super(
408
+ `Workspace ${workspaceName} snapshot is still building; yielded for requeue`
409
+ );
410
+ this.name = "WorkspaceSnapshotWaitingError";
411
+ this.workspaceName = workspaceName;
412
+ }
413
+ };
414
+ function isWorkspaceSnapshotWaitingResult(details) {
415
+ if (!details || typeof details !== "object" || Array.isArray(details)) {
416
+ return false;
417
+ }
418
+ const record = details;
419
+ return record.timed_out === true && record.waiting === "workspace_snapshot" && typeof record.workspace?.name === "string" && record.workspace.name.length > 0;
420
+ }
421
+ function workspaceNameFromWaitingResult(details) {
422
+ if (!isWorkspaceSnapshotWaitingResult(details)) return void 0;
423
+ const name = details.workspace?.name;
424
+ return typeof name === "string" ? name : void 0;
425
+ }
426
+ function isWorkspaceSnapshotWaitingError(error) {
427
+ const seen = /* @__PURE__ */ new Set();
428
+ let current = error;
429
+ while (current && !seen.has(current)) {
430
+ if (current instanceof WorkspaceSnapshotWaitingError) return true;
431
+ if (current instanceof Error && (current.name === "WorkspaceSnapshotWaitingError" || current.code === "workspace_snapshot_waiting")) {
432
+ return true;
433
+ }
434
+ seen.add(current);
435
+ current = typeof current === "object" ? current.cause : void 0;
436
+ }
437
+ return false;
438
+ }
439
+
440
+ // src/chat/sandbox/http-error-details.ts
441
+ var DEFAULT_PREVIEW_LIMIT = 512;
442
+ function toTrimmedString(value, maxChars) {
443
+ if (typeof value !== "string") {
444
+ return void 0;
445
+ }
446
+ const normalized = value.trim();
447
+ if (!normalized) {
448
+ return void 0;
449
+ }
450
+ return normalized.length > maxChars ? `${normalized.slice(0, maxChars)}\u2026` : normalized;
451
+ }
452
+ function extractHttpErrorDetails(error, options = {}) {
453
+ const prefix = options.attributePrefix ?? "app.http_error";
454
+ const previewLimit = options.previewLimit ?? DEFAULT_PREVIEW_LIMIT;
455
+ const normalizedError = error instanceof Error ? error : new Error(String(error));
456
+ const err = error ?? {};
457
+ const attributes = {
458
+ "error.type": normalizedError.name || "Error",
459
+ "exception.message": toTrimmedString(normalizedError.message, previewLimit) ?? "HTTP error"
460
+ };
461
+ const response = err.response;
462
+ const statusCode = typeof response?.status === "number" ? response.status : void 0;
463
+ const statusText = toTrimmedString(response?.statusText, previewLimit);
464
+ const responseUrl = toTrimmedString(response?.url, previewLimit);
465
+ const responseText = toTrimmedString(err.text, previewLimit);
466
+ const responseJson = toTrimmedString(
467
+ err.json && typeof err.json === "object" ? JSON.stringify(err.json) : void 0,
468
+ previewLimit
469
+ );
470
+ const contentType = toTrimmedString(
471
+ response?.headers?.get?.("content-type"),
472
+ previewLimit
473
+ );
474
+ const requestIdHeader = toTrimmedString(
475
+ response?.headers?.get?.("x-request-id"),
476
+ previewLimit
477
+ );
478
+ const vercelIdHeader = toTrimmedString(
479
+ response?.headers?.get?.("x-vercel-id"),
480
+ previewLimit
481
+ );
482
+ const requestId = requestIdHeader ?? vercelIdHeader;
483
+ if (statusCode !== void 0) {
484
+ attributes["http.response.status_code"] = statusCode;
485
+ }
486
+ if (statusText) {
487
+ attributes[`${prefix}.status_text`] = statusText;
488
+ }
489
+ if (responseUrl) {
490
+ attributes["url.full"] = responseUrl;
491
+ }
492
+ if (contentType) {
493
+ attributes["http.response.header.content-type"] = [contentType];
494
+ }
495
+ if (requestIdHeader) {
496
+ attributes["http.response.header.x-request-id"] = [requestIdHeader];
497
+ }
498
+ if (vercelIdHeader) {
499
+ attributes["http.response.header.x-vercel-id"] = [vercelIdHeader];
500
+ }
501
+ if (responseText) {
502
+ attributes[`${prefix}.response_text_preview`] = responseText;
503
+ attributes[`${prefix}.response_text_length`] = responseText.length;
504
+ }
505
+ if (responseJson) {
506
+ attributes[`${prefix}.response_json_preview`] = responseJson;
507
+ }
508
+ const summaryParts = [];
509
+ if (statusCode !== void 0) {
510
+ summaryParts.push(`status=${statusCode}`);
511
+ }
512
+ if (statusText) {
513
+ summaryParts.push(`statusText=${statusText}`);
514
+ }
515
+ if (responseUrl) {
516
+ summaryParts.push(`url=${responseUrl}`);
517
+ }
518
+ if (requestId) {
519
+ summaryParts.push(`requestId=${requestId}`);
520
+ }
521
+ for (const field of options.extraFields ?? []) {
522
+ const value = toTrimmedString(err[field.sourceKey], previewLimit);
523
+ if (!value) {
524
+ continue;
525
+ }
526
+ attributes[`${prefix}.${field.attributeKey}`] = value;
527
+ summaryParts.push(`${field.summaryKey ?? field.attributeKey}=${value}`);
528
+ }
529
+ if (responseJson) {
530
+ summaryParts.push(`json=${responseJson}`);
531
+ } else if (responseText) {
532
+ summaryParts.push(`text=${responseText}`);
533
+ }
534
+ const searchableText = `${normalizedError.message} ${responseText ?? ""} ${responseJson ?? ""}`.toLowerCase();
535
+ return {
536
+ attributes,
537
+ summary: summaryParts.join(", "),
538
+ searchableText
539
+ };
540
+ }
541
+
542
+ // src/chat/sandbox/errors.ts
543
+ var SANDBOX_ERROR_FIELDS = [
544
+ {
545
+ sourceKey: "sandboxId",
546
+ attributeKey: "sandbox_id",
547
+ summaryKey: "sandboxId"
548
+ }
549
+ ];
550
+ function getSandboxErrorDetails(error) {
551
+ return extractHttpErrorDetails(error, {
552
+ attributePrefix: "app.sandbox.api_error",
553
+ extraFields: [...SANDBOX_ERROR_FIELDS]
554
+ });
555
+ }
556
+ function findInErrorChain(error, predicate) {
557
+ const seen = /* @__PURE__ */ new Set();
558
+ let current = error;
559
+ while (current && !seen.has(current)) {
560
+ if (predicate(current)) {
561
+ return true;
562
+ }
563
+ seen.add(current);
564
+ current = typeof current === "object" ? current.cause : void 0;
565
+ }
566
+ return false;
567
+ }
568
+ function isRecord(value) {
569
+ return typeof value === "object" && value !== null;
570
+ }
571
+ function isInvalidSandboxSessionError(error) {
572
+ if (!isRecord(error)) {
573
+ return false;
574
+ }
575
+ if (isRecord(error.json) && error.json.invalidToken === true) {
576
+ return true;
577
+ }
578
+ const response = error.response;
579
+ return isRecord(response) && response.status === 403 && typeof response.url === "string" && response.url.includes("/sandboxes/sessions");
580
+ }
581
+ function getFirstErrorMessage(error) {
582
+ const seen = /* @__PURE__ */ new Set();
583
+ let current = error;
584
+ while (current && !seen.has(current)) {
585
+ if (current instanceof Error) {
586
+ const message = current.message.trim();
587
+ if (message) {
588
+ return message;
589
+ }
590
+ }
591
+ seen.add(current);
592
+ current = typeof current === "object" ? current.cause : void 0;
593
+ }
594
+ return void 0;
595
+ }
596
+ function isAlreadyExistsError(error) {
597
+ const details = getSandboxErrorDetails(error);
598
+ return details.searchableText.includes("already exists") || details.searchableText.includes("file exists") || details.searchableText.includes("eexist");
599
+ }
600
+ function isSandboxUnavailableError(error) {
601
+ return findInErrorChain(error, (candidate) => {
602
+ if (isInvalidSandboxSessionError(candidate)) {
603
+ return true;
604
+ }
605
+ const details = getSandboxErrorDetails(candidate);
606
+ const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
607
+ return searchable.includes("sandbox_stopped") || searchable.includes("status=410") || searchable.includes("status code 410") || searchable.includes("no longer available") || searchable.includes("stream was closed and is not accepting commands");
608
+ });
609
+ }
610
+ function isSandboxMissingError(error) {
611
+ return findInErrorChain(error, (candidate) => {
612
+ const details = getSandboxErrorDetails(candidate);
613
+ const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
614
+ return searchable.includes("status=404") || searchable.includes("status code 404") || searchable.includes("snapshot_not_found");
615
+ });
616
+ }
617
+ function isSnapshottingError(error) {
618
+ return findInErrorChain(error, (candidate) => {
619
+ const details = getSandboxErrorDetails(candidate);
620
+ const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
621
+ return searchable.includes("sandbox_snapshotting") || searchable.includes("creating a snapshot") || searchable.includes("stopped shortly");
622
+ });
623
+ }
624
+ function isAbortError(error) {
625
+ return findInErrorChain(error, (candidate) => {
626
+ if (typeof DOMException !== "undefined" && candidate instanceof DOMException) {
627
+ return candidate.name === "AbortError";
628
+ }
629
+ if (!(candidate instanceof Error)) return false;
630
+ if (candidate.name === "AbortError") return true;
631
+ const message = candidate.message.toLowerCase();
632
+ return message === "api turn cancelled" || message === "api turn canceled" || message.startsWith("executeagentrun timed out after");
633
+ });
634
+ }
635
+ function isSandboxApiTransientError(error) {
636
+ return findInErrorChain(error, (candidate) => {
637
+ const details = getSandboxErrorDetails(candidate);
638
+ const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
639
+ if (searchable.includes("internal_server_error") || searchable.includes("status=500") || searchable.includes("status code 500") || searchable.includes("status=502") || searchable.includes("status code 502") || searchable.includes("status=503") || searchable.includes("status code 503") || searchable.includes("status=504") || searchable.includes("status code 504")) {
640
+ return true;
641
+ }
642
+ if (!isRecord(candidate)) return false;
643
+ const response = candidate.response;
644
+ return isRecord(response) && typeof response.status === "number" && response.status >= 500 && response.status < 600;
645
+ });
646
+ }
647
+ function isSandboxCommandStreamInterruptedError(error) {
648
+ return findInErrorChain(error, (candidate) => {
649
+ if (!(candidate instanceof Error)) {
650
+ return false;
651
+ }
652
+ return candidate.name === "StreamError" && candidate.message.toLowerCase().includes("stream ended before command finished");
653
+ });
654
+ }
655
+ function wrapSandboxSetupError(error) {
656
+ if (isWorkspaceSnapshotWaitingError(error)) {
657
+ return error instanceof Error ? error : new Error(String(error));
658
+ }
659
+ try {
660
+ const details = getSandboxErrorDetails(error);
661
+ if (details.summary) {
662
+ return new Error(`sandbox setup failed (${details.summary})`, {
663
+ cause: error
664
+ });
665
+ }
666
+ } catch {
667
+ }
668
+ let causeMessage;
669
+ try {
670
+ causeMessage = getFirstErrorMessage(error);
671
+ } catch (cause) {
672
+ causeMessage = cause instanceof Error ? cause.message : void 0;
673
+ }
674
+ if (causeMessage && causeMessage.trim() && causeMessage !== "sandbox setup failed") {
675
+ const oneLine = causeMessage.replace(/\s+/g, " ").trim();
676
+ return new Error(`sandbox setup failed (${oneLine})`, { cause: error });
677
+ }
678
+ return new Error("sandbox setup failed", { cause: error });
679
+ }
680
+ function throwSandboxOperationError(action, error, includeMissingPath = false) {
681
+ const details = getSandboxErrorDetails(error);
682
+ setSpanAttributes({
683
+ ...details.attributes,
684
+ ...includeMissingPath ? {
685
+ "app.sandbox.api_error.missing_path": details.searchableText.includes("no such file") || details.searchableText.includes("enoent")
686
+ } : {},
687
+ "app.sandbox.success": false
688
+ });
689
+ setSpanStatus("error");
690
+ throw new Error(
691
+ details.summary ? `${action} failed (${details.summary})` : `${action} failed`,
692
+ {
693
+ cause: error
694
+ }
695
+ );
696
+ }
697
+
383
698
  export {
384
699
  SANDBOX_WORKSPACE_ROOT,
385
700
  SANDBOX_REPOS_ROOT,
@@ -388,10 +703,24 @@ export {
388
703
  sandboxSkillDir,
389
704
  sandboxSkillFile,
390
705
  sandboxSkillPathResolution,
706
+ WorkspaceSnapshotWaitingError,
707
+ isWorkspaceSnapshotWaitingResult,
708
+ workspaceNameFromWaitingResult,
709
+ isWorkspaceSnapshotWaitingError,
391
710
  sleep,
392
711
  buildCommandScript,
393
712
  buildNonInteractiveShellScript,
394
713
  runNonInteractiveCommand,
714
+ getVercelSandboxCredentials,
715
+ isAlreadyExistsError,
716
+ isSandboxUnavailableError,
717
+ isSandboxMissingError,
718
+ isSnapshottingError,
719
+ isAbortError,
720
+ isSandboxApiTransientError,
721
+ isSandboxCommandStreamInterruptedError,
722
+ wrapSandboxSetupError,
723
+ throwSandboxOperationError,
395
724
  ensureDockerDaemon,
396
725
  create,
397
726
  hash,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createWebAuthorization,
3
3
  deleteWebAuthorization
4
- } from "./chunk-4SVAFAI2.js";
4
+ } from "./chunk-FTGD2FBP.js";
5
5
  import {
6
6
  appendAndEnqueueInboundMessage
7
- } from "./chunk-LFZODSAY.js";
7
+ } from "./chunk-5IRROPA5.js";
8
8
  import {
9
9
  buildDeliveredTurnStatePatch,
10
10
  completeAuthPauseTurn,
@@ -12,20 +12,20 @@ import {
12
12
  getTurnUserMessage,
13
13
  processPluginTask,
14
14
  scheduleSessionCompletedPluginTasks
15
- } from "./chunk-7ZFESKJ2.js";
15
+ } from "./chunk-KJLHIHFF.js";
16
16
  import {
17
17
  ConversationTurnLifecycleService,
18
18
  coerceThreadConversationState,
19
19
  getPersistedSandboxState,
20
20
  getPersistedThreadState,
21
21
  persistThreadStateById
22
- } from "./chunk-4TWDRU64.js";
22
+ } from "./chunk-CJLBLELR.js";
23
23
  import {
24
24
  healthReportSchema
25
25
  } from "./chunk-UTL3MHPC.js";
26
26
  import {
27
27
  parseSlackThreadId
28
- } from "./chunk-3FWXQZJJ.js";
28
+ } from "./chunk-FAS6AIMF.js";
29
29
  import {
30
30
  TurnInputCommitLostError,
31
31
  abandonTurnRecord,
@@ -49,31 +49,31 @@ import {
49
49
  saveTurnCheckpoint,
50
50
  startActiveTurn,
51
51
  upsertConversationMessage
52
- } from "./chunk-I7PKGMKI.js";
52
+ } from "./chunk-FIDMHAO6.js";
53
53
  import {
54
54
  normalizeSlackConversationId
55
- } from "./chunk-PA7QDS7P.js";
55
+ } from "./chunk-3I7XE3PA.js";
56
56
  import {
57
57
  getConversationEventStore,
58
58
  getConversationStore,
59
59
  getDb
60
- } from "./chunk-LPMLAJYR.js";
60
+ } from "./chunk-VP4OVRDD.js";
61
61
  import {
62
62
  juniorApiTokens,
63
63
  juniorConversationParticipants,
64
64
  juniorConversations,
65
65
  juniorIdentities,
66
66
  juniorUsers
67
- } from "./chunk-WCQUKX74.js";
67
+ } from "./chunk-R6U7N4FS.js";
68
68
  import {
69
69
  getSlackBotToken
70
- } from "./chunk-DLTP6TUJ.js";
70
+ } from "./chunk-GENV6KF2.js";
71
71
  import {
72
72
  juniorDestinations
73
73
  } from "./chunk-VFUK3X5B.js";
74
74
  import {
75
75
  canExposeConversationPayload
76
- } from "./chunk-7PZDAXIK.js";
76
+ } from "./chunk-XSPSCWLH.js";
77
77
  import {
78
78
  credentialContextForActor
79
79
  } from "./chunk-CGA4ERJ5.js";
@@ -82,7 +82,7 @@ import {
82
82
  logWarn,
83
83
  setTags,
84
84
  withLogContext
85
- } from "./chunk-7CVYXUOJ.js";
85
+ } from "./chunk-HQNE5APD.js";
86
86
 
87
87
  // src/handlers/health.ts
88
88
  function readHealthReport() {
@@ -1025,7 +1025,15 @@ import { eq as eq3, inArray as inArray2 } from "drizzle-orm";
1025
1025
  import { alias } from "drizzle-orm/pg-core";
1026
1026
 
1027
1027
  // src/api/conversations/membership.ts
1028
- import { and as and2, eq as eq2, exists, inArray, or } from "drizzle-orm";
1028
+ import {
1029
+ and as and2,
1030
+ eq as eq2,
1031
+ exists,
1032
+ inArray,
1033
+ isNotNull,
1034
+ notExists,
1035
+ or
1036
+ } from "drizzle-orm";
1029
1037
  function conversationHasParticipantUser(userId) {
1030
1038
  const participant = getDb().select({
1031
1039
  rootConversationId: juniorConversationParticipants.rootConversationId
@@ -1057,12 +1065,110 @@ function conversationHasParticipantEmail(email) {
1057
1065
  );
1058
1066
  return exists(participant);
1059
1067
  }
1068
+ function conversationArchivedForUser(userId) {
1069
+ const archive = getDb().select({
1070
+ rootConversationId: juniorConversationParticipants.rootConversationId
1071
+ }).from(juniorConversationParticipants).where(
1072
+ and2(
1073
+ eq2(
1074
+ juniorConversationParticipants.rootConversationId,
1075
+ juniorConversations.conversationId
1076
+ ),
1077
+ eq2(juniorConversationParticipants.userId, userId),
1078
+ isNotNull(juniorConversationParticipants.archivedAt)
1079
+ )
1080
+ );
1081
+ return exists(archive);
1082
+ }
1083
+ function conversationNotArchivedForUser(userId) {
1084
+ const archive = getDb().select({
1085
+ rootConversationId: juniorConversationParticipants.rootConversationId
1086
+ }).from(juniorConversationParticipants).where(
1087
+ and2(
1088
+ eq2(
1089
+ juniorConversationParticipants.rootConversationId,
1090
+ juniorConversations.conversationId
1091
+ ),
1092
+ eq2(juniorConversationParticipants.userId, userId),
1093
+ isNotNull(juniorConversationParticipants.archivedAt)
1094
+ )
1095
+ );
1096
+ return notExists(archive);
1097
+ }
1098
+ function conversationArchivedForEmail(email) {
1099
+ const archive = getDb().select({
1100
+ rootConversationId: juniorConversationParticipants.rootConversationId
1101
+ }).from(juniorConversationParticipants).innerJoin(
1102
+ juniorUsers,
1103
+ eq2(juniorUsers.id, juniorConversationParticipants.userId)
1104
+ ).where(
1105
+ and2(
1106
+ eq2(
1107
+ juniorConversationParticipants.rootConversationId,
1108
+ juniorConversations.conversationId
1109
+ ),
1110
+ eq2(juniorUsers.primaryEmailNormalized, email),
1111
+ isNotNull(juniorConversationParticipants.archivedAt)
1112
+ )
1113
+ );
1114
+ return exists(archive);
1115
+ }
1116
+ function conversationNotArchivedForEmail(email) {
1117
+ const archive = getDb().select({
1118
+ rootConversationId: juniorConversationParticipants.rootConversationId
1119
+ }).from(juniorConversationParticipants).innerJoin(
1120
+ juniorUsers,
1121
+ eq2(juniorUsers.id, juniorConversationParticipants.userId)
1122
+ ).where(
1123
+ and2(
1124
+ eq2(
1125
+ juniorConversationParticipants.rootConversationId,
1126
+ juniorConversations.conversationId
1127
+ ),
1128
+ eq2(juniorUsers.primaryEmailNormalized, email),
1129
+ isNotNull(juniorConversationParticipants.archivedAt)
1130
+ )
1131
+ );
1132
+ return notExists(archive);
1133
+ }
1060
1134
  function viewerConversationMembership(args) {
1061
1135
  if (args.actorMatch && args.participantMatch) {
1062
1136
  return or(args.actorMatch, args.participantMatch);
1063
1137
  }
1064
1138
  return args.actorMatch ?? args.participantMatch;
1065
1139
  }
1140
+ async function conversationArchiveTimes(db, conversationIds, subject) {
1141
+ if (!subject || conversationIds.length === 0) return /* @__PURE__ */ new Map();
1142
+ const query = db.select({
1143
+ archivedAt: juniorConversationParticipants.archivedAt,
1144
+ rootConversationId: juniorConversationParticipants.rootConversationId
1145
+ }).from(juniorConversationParticipants);
1146
+ const rows = "userId" in subject ? await query.where(
1147
+ and2(
1148
+ eq2(juniorConversationParticipants.userId, subject.userId),
1149
+ inArray(juniorConversationParticipants.rootConversationId, [
1150
+ ...conversationIds
1151
+ ]),
1152
+ isNotNull(juniorConversationParticipants.archivedAt)
1153
+ )
1154
+ ) : await query.innerJoin(
1155
+ juniorUsers,
1156
+ eq2(juniorUsers.id, juniorConversationParticipants.userId)
1157
+ ).where(
1158
+ and2(
1159
+ eq2(juniorUsers.primaryEmailNormalized, subject.email),
1160
+ inArray(juniorConversationParticipants.rootConversationId, [
1161
+ ...conversationIds
1162
+ ]),
1163
+ isNotNull(juniorConversationParticipants.archivedAt)
1164
+ )
1165
+ );
1166
+ return new Map(
1167
+ rows.flatMap(
1168
+ (row) => row.archivedAt ? [[row.rootConversationId, row.archivedAt.getTime()]] : []
1169
+ )
1170
+ );
1171
+ }
1066
1172
  async function conversationIdsWithParticipantUser(db, conversationIds, userId) {
1067
1173
  if (conversationIds.length === 0) {
1068
1174
  return /* @__PURE__ */ new Set();
@@ -1335,7 +1441,12 @@ export {
1335
1441
  routeApiTurnWork,
1336
1442
  conversationHasParticipantUser,
1337
1443
  conversationHasParticipantEmail,
1444
+ conversationArchivedForUser,
1445
+ conversationNotArchivedForUser,
1446
+ conversationArchivedForEmail,
1447
+ conversationNotArchivedForEmail,
1338
1448
  viewerConversationMembership,
1449
+ conversationArchiveTimes,
1339
1450
  readConversationAccessFromSql,
1340
1451
  createPersonalToken,
1341
1452
  listPersonalTokens,