@sentry/junior 0.185.0 → 0.187.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.
- package/dist/{agent-hooks-NGZQLL5O.js → agent-hooks-XVAE2554.js} +11 -11
- package/dist/api/schema/conversation.d.ts +8 -0
- package/dist/api/schema.js +1 -1
- package/dist/api.js +44 -36
- package/dist/app.js +1079 -264
- package/dist/{catalog-runtime-AAEAO2RL.js → catalog-runtime-DWFAC562.js} +4 -4
- package/dist/chat/agent/types.d.ts +16 -13
- package/dist/chat/api-turns/{accepted-reply.d.ts → assistant-message.d.ts} +3 -2
- package/dist/chat/api-turns/cancellation.d.ts +0 -1
- package/dist/chat/api-turns/mailbox-input.d.ts +4 -0
- package/dist/chat/api-turns/routing.d.ts +23 -7
- package/dist/chat/api-turns/work.d.ts +2 -2
- package/dist/chat/conversations/location.d.ts +2 -2
- package/dist/chat/conversations/store.d.ts +13 -0
- package/dist/chat/conversations/turn-lifecycle.d.ts +2 -0
- package/dist/chat/providers/slack/runtime.d.ts +0 -2
- package/dist/chat/providers/slack/turn.d.ts +0 -2
- package/dist/chat/resource-events/actor.d.ts +14 -2
- package/dist/chat/resource-events/app-publisher.d.ts +18 -0
- package/dist/chat/resource-events/catalog.d.ts +19 -0
- package/dist/chat/resource-events/ingest.d.ts +0 -1
- package/dist/chat/resource-events/notification.d.ts +28 -3
- package/dist/chat/resource-events/runtime-catalog.d.ts +7 -2
- package/dist/chat/resource-events/store.d.ts +1 -13
- package/dist/chat/resource-events/workspace.d.ts +7 -3
- package/dist/chat/sandbox/egress/credentials.d.ts +5 -4
- package/dist/chat/sandbox/egress/session.d.ts +9 -9
- package/dist/chat/sandbox/errors.d.ts +1 -1
- package/dist/chat/sandbox/ref.d.ts +1 -1
- package/dist/chat/sandbox/snapshot/events.d.ts +8 -1
- package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -1
- package/dist/chat/sentry-links.d.ts +2 -0
- package/dist/chat/services/turn-session-routing.d.ts +23 -7
- package/dist/chat/task-execution/slack-resource-event.d.ts +47 -0
- package/dist/chat/task-execution/slack-work.d.ts +0 -21
- package/dist/chat/task-input.d.ts +22 -0
- package/dist/chat/tools/event-tasks.d.ts +1 -1
- package/dist/chat/tools/resource-events.d.ts +1 -1
- package/dist/{chunk-Y5G23T2D.js → chunk-27T5HZHO.js} +91 -7
- package/dist/{chunk-TVVAMOLS.js → chunk-2VUDJGB6.js} +2 -2
- package/dist/{chunk-X7NCJQAA.js → chunk-4A2R3AQB.js} +1 -1
- package/dist/{chunk-MWOH6CIK.js → chunk-4YD3DET6.js} +278 -116
- package/dist/{chunk-INQHUE72.js → chunk-6FGN7ZEG.js} +6 -2
- package/dist/{chunk-ZKKGFUWM.js → chunk-6FKNNUSN.js} +6 -6
- package/dist/{chunk-OMQ2J6F6.js → chunk-6YCIYOVA.js} +1 -1
- package/dist/{chunk-7GAP2XG4.js → chunk-7LRRVMPH.js} +1 -1
- package/dist/{chunk-4HA36IWS.js → chunk-BITZUBPJ.js} +8 -8
- package/dist/{chunk-QCT4226Q.js → chunk-D3GDGREI.js} +3 -3
- package/dist/{chunk-WLKWN4CD.js → chunk-D5BWM37G.js} +8 -5
- package/dist/{chunk-VH4IU3UC.js → chunk-DUE4EUNL.js} +19 -45
- package/dist/{chunk-DAPC2HTM.js → chunk-EIWYZXSM.js} +5 -5
- package/dist/{chunk-LVK4WJKM.js → chunk-HXR3FHTE.js} +13 -3
- package/dist/{chunk-UUULGCKK.js → chunk-ITLYUKGZ.js} +14 -4
- package/dist/{chunk-FTVMXDNN.js → chunk-JCRXXEMC.js} +1 -1
- package/dist/{chunk-EJYP3NQ4.js → chunk-JZPDYKRG.js} +37 -3
- package/dist/{chunk-HJPC32TQ.js → chunk-KRYJ5VOD.js} +20 -14
- package/dist/{chunk-QZKHHG3B.js → chunk-MUPPP7A7.js} +436 -283
- package/dist/{chunk-D63IUQQE.js → chunk-NIKLTFBP.js} +12 -9
- package/dist/{chunk-U4CTAVWN.js → chunk-NU775DLU.js} +2 -2
- package/dist/{chunk-W7GCLNIV.js → chunk-OM4SFFJK.js} +3 -3
- package/dist/{chunk-X2SS6BF7.js → chunk-P2VU5JNH.js} +32 -36
- package/dist/{chunk-4K25ODAO.js → chunk-PFAZSRGR.js} +3 -1
- package/dist/{chunk-EIJCPJOY.js → chunk-Q6OCUQ7W.js} +1 -1
- package/dist/{chunk-GJTIZQGJ.js → chunk-QH3I7ZOK.js} +1 -1
- package/dist/{chunk-4S47VHJR.js → chunk-STF4GSK4.js} +3 -3
- package/dist/{chunk-C6TS47CQ.js → chunk-TQHCZXN7.js} +11 -5
- package/dist/{chunk-ZIF2S464.js → chunk-U3KMII5Y.js} +1 -1
- package/dist/{chunk-6DOAUXLD.js → chunk-U5POFCKM.js} +753 -1718
- package/dist/{chunk-PNYJOEVV.js → chunk-U6ZQHRIP.js} +1 -1
- package/dist/{chunk-LRI5IRGY.js → chunk-URZ7UD4P.js} +2 -2
- package/dist/{chunk-6Q7YZLCL.js → chunk-VC343WHM.js} +9 -1
- package/dist/{chunk-ABAX75GG.js → chunk-WKIS4VRK.js} +17 -3
- package/dist/{chunk-FFHXG2FX.js → chunk-WL3R2KTS.js} +11 -29
- package/dist/{chunk-EWEH2PJW.js → chunk-WRDW3A3D.js} +5 -5
- package/dist/{chunk-7MHNIGHP.js → chunk-X5SXFVZT.js} +1 -1
- package/dist/{chunk-ATUWN6Z3.js → chunk-Z6OHCDXP.js} +2 -2
- package/dist/cli/chat.js +33 -33
- package/dist/cli/check.js +5 -5
- package/dist/cli/plugins.js +12 -12
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +6 -6
- package/dist/{db-TRJ77FAU.js → db-FBHAWVXU.js} +6 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +6 -6
- package/dist/{oauth-callback-server-XD5SV3MS.js → oauth-callback-server-5HS5ULC6.js} +28 -28
- package/dist/{runner-KFX7NG6D.js → runner-46W6NV6B.js} +19 -19
- package/dist/{skills-J2AH26CW.js → skills-TG3QC4B6.js} +5 -5
- package/dist/spawn-Y6YWBIJS.js +41 -0
- package/dist/task-runner-YSGBPN4U.js +34 -0
- package/dist/{validation-O5J4VOPF.js → validation-GMRIDBC5.js} +5 -5
- package/dist/version.js +1 -1
- package/dist/{work-ECPQTG3U.js → work-W4ULBJTU.js} +21 -21
- package/dist/{worker-RS3DXUDO.js → worker-M6NVACS2.js} +10 -10
- package/package.json +4 -4
- package/dist/spawn-VU3CSRI6.js +0 -41
- package/dist/task-runner-5JG3VIIY.js +0 -34
|
@@ -5,19 +5,19 @@ import {
|
|
|
5
5
|
isDmChannel,
|
|
6
6
|
normalizeSlackConversationId,
|
|
7
7
|
withSlackRetries
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-DUE4EUNL.js";
|
|
9
9
|
import {
|
|
10
10
|
parseDestination
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-WKIS4VRK.js";
|
|
12
12
|
import {
|
|
13
13
|
getStateAdapter
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-U6ZQHRIP.js";
|
|
15
15
|
import {
|
|
16
16
|
normalizeSlackEmojiName
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-URZ7UD4P.js";
|
|
18
18
|
import {
|
|
19
19
|
pluginCatalogRuntime
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-QH3I7ZOK.js";
|
|
21
21
|
import {
|
|
22
22
|
parseSlackMessageTs,
|
|
23
23
|
parseSlackUserId
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
isRecord,
|
|
27
27
|
logInfo,
|
|
28
28
|
logWarn
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-6YCIYOVA.js";
|
|
30
30
|
|
|
31
31
|
// src/chat/slack/outbound.ts
|
|
32
32
|
var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveBaseUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6FKNNUSN.js";
|
|
4
4
|
import {
|
|
5
5
|
createPluginLogger,
|
|
6
6
|
getPlugins,
|
|
7
7
|
getSlackClient,
|
|
8
8
|
withSlackRetries
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DUE4EUNL.js";
|
|
10
10
|
import {
|
|
11
11
|
getDb,
|
|
12
12
|
parseDestination
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WKIS4VRK.js";
|
|
14
14
|
import {
|
|
15
15
|
sleep
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JZPDYKRG.js";
|
|
17
17
|
import {
|
|
18
18
|
acquireActiveLock,
|
|
19
19
|
getStateAdapter
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-U6ZQHRIP.js";
|
|
21
21
|
import {
|
|
22
22
|
pluginCatalogRuntime
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-QH3I7ZOK.js";
|
|
24
24
|
import {
|
|
25
25
|
fetchWithBoundedOAuthErrorBodies
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-X5SXFVZT.js";
|
|
27
27
|
import {
|
|
28
28
|
isRecord
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-6YCIYOVA.js";
|
|
30
30
|
|
|
31
31
|
// src/chat/capabilities/router.ts
|
|
32
32
|
var ProviderCredentialRouter = class {
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
isStale,
|
|
7
7
|
runNonInteractiveCommand,
|
|
8
8
|
sleep
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JZPDYKRG.js";
|
|
10
10
|
import {
|
|
11
11
|
getStateAdapter
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-U6ZQHRIP.js";
|
|
13
13
|
import {
|
|
14
14
|
setSpanAttributes,
|
|
15
15
|
withSpan
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6YCIYOVA.js";
|
|
17
17
|
|
|
18
18
|
// src/chat/sandbox/resources.ts
|
|
19
19
|
var configuredResources;
|
|
@@ -9,18 +9,18 @@ import {
|
|
|
9
9
|
getSqlExecutor,
|
|
10
10
|
sanitizePostgresJson,
|
|
11
11
|
withConversationEventLock
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WKIS4VRK.js";
|
|
13
13
|
import {
|
|
14
14
|
SANDBOX_REPOS_ROOT,
|
|
15
15
|
SANDBOX_WORKSPACE_ROOT,
|
|
16
16
|
sleep
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-JZPDYKRG.js";
|
|
18
18
|
import {
|
|
19
19
|
MUTATION_LOCK_TTL_MS,
|
|
20
20
|
fenceLock,
|
|
21
21
|
getStateAdapter,
|
|
22
22
|
withLock
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-U6ZQHRIP.js";
|
|
24
24
|
import {
|
|
25
25
|
agentHistoryItemSchema,
|
|
26
26
|
contextProvenance,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
escapeXml,
|
|
34
34
|
resolveGatewayModel,
|
|
35
35
|
unwrapCurrentInstruction
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-URZ7UD4P.js";
|
|
37
37
|
import {
|
|
38
38
|
parseSlackMessageTs,
|
|
39
39
|
toStoredSlackActor
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
logException,
|
|
44
44
|
logWarn,
|
|
45
45
|
setSpanAttributes
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-6YCIYOVA.js";
|
|
47
47
|
|
|
48
48
|
// src/chat/turn-context-tag.ts
|
|
49
49
|
var TURN_CONTEXT_TAG = "runtime-turn-context";
|
|
@@ -2308,6 +2308,9 @@ async function recordConversationActivityMetadata(args) {
|
|
|
2308
2308
|
});
|
|
2309
2309
|
const isChild = Boolean(conversation?.lineage);
|
|
2310
2310
|
const destination = isChild ? void 0 : args.destination;
|
|
2311
|
+
if (!isChild && !destination && !conversation) {
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
2311
2314
|
const activitySource = isChild ? "internal" : args.source?.platform === "web" ? "web" : destination?.platform === "local" ? "local" : destination ? args.summary.surface : void 0;
|
|
2312
2315
|
await conversationStore.recordActivity({
|
|
2313
2316
|
activityAtMs: args.summary.updatedAtMs,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getConversationEventStore,
|
|
6
6
|
getDb,
|
|
7
7
|
getSqlExecutor
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WKIS4VRK.js";
|
|
9
9
|
import {
|
|
10
10
|
juniorCodeChanges,
|
|
11
11
|
juniorCodeRepositories,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
juniorUsers,
|
|
17
17
|
juniorWorkspaceRepos,
|
|
18
18
|
juniorWorkspaces
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-HXR3FHTE.js";
|
|
20
20
|
import {
|
|
21
21
|
SANDBOX_WORKSPACE_ROOT,
|
|
22
22
|
getVercelSandboxCredentials,
|
|
@@ -24,16 +24,16 @@ import {
|
|
|
24
24
|
isSandboxMissingError,
|
|
25
25
|
runNonInteractiveCommand,
|
|
26
26
|
sleep
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-JZPDYKRG.js";
|
|
28
28
|
import {
|
|
29
29
|
getStateAdapter
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-U6ZQHRIP.js";
|
|
31
31
|
import {
|
|
32
32
|
botConfig,
|
|
33
33
|
completeObject,
|
|
34
34
|
embedTexts,
|
|
35
35
|
getSlackBotToken
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-URZ7UD4P.js";
|
|
37
37
|
import {
|
|
38
38
|
defaultModelId
|
|
39
39
|
} from "./chunk-D4YV5TDV.js";
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
setSpanAttributes,
|
|
53
53
|
setSpanStatus,
|
|
54
54
|
withSpan
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-6YCIYOVA.js";
|
|
56
56
|
|
|
57
57
|
// src/chat/plugins/agent-hooks.ts
|
|
58
58
|
import {
|
|
@@ -473,14 +473,13 @@ function getDashboardTaskLink(taskId) {
|
|
|
473
473
|
// src/chat/resource-events/store.ts
|
|
474
474
|
import { createHash as createHash2 } from "crypto";
|
|
475
475
|
import {
|
|
476
|
-
destinationSchema,
|
|
477
476
|
resourceEventMatchSchema,
|
|
478
477
|
resourceEventMatches,
|
|
479
478
|
resourceEventTypeSchema,
|
|
480
479
|
stableResourceEventMatchKey
|
|
481
480
|
} from "@sentry/junior-plugin-api";
|
|
482
481
|
import { z as z2 } from "zod";
|
|
483
|
-
var RESOURCE_EVENT_PREFIX = "junior:resource_event_subscription:
|
|
482
|
+
var RESOURCE_EVENT_PREFIX = "junior:resource_event_subscription:v5";
|
|
484
483
|
var INDEX_LOCK_TTL_MS = 1e4;
|
|
485
484
|
var SUBSCRIPTION_LOCK_TTL_MS = 1e4;
|
|
486
485
|
var SUBSCRIPTION_LOCK_WAIT_MS = 1e4;
|
|
@@ -491,7 +490,6 @@ var subscriptionIdIndexSchema = z2.array(z2.string().min(1));
|
|
|
491
490
|
var subscriptionSchema = z2.object({
|
|
492
491
|
conversationId: z2.string().min(1),
|
|
493
492
|
createdAtMs: z2.number().finite(),
|
|
494
|
-
destination: destinationSchema,
|
|
495
493
|
events: z2.array(resourceEventTypeSchema).min(1),
|
|
496
494
|
expiresAtMs: z2.number().finite(),
|
|
497
495
|
id: z2.string().min(1),
|
|
@@ -513,14 +511,8 @@ function subscriptionKey(id) {
|
|
|
513
511
|
function subscriptionLockKey(id) {
|
|
514
512
|
return `${RESOURCE_EVENT_PREFIX}:lock:${id}`;
|
|
515
513
|
}
|
|
516
|
-
function resourceIndexKey(
|
|
517
|
-
return `${RESOURCE_EVENT_PREFIX}:resource:${digest(`${
|
|
518
|
-
}
|
|
519
|
-
function subscriptionTeamId(destination) {
|
|
520
|
-
if (destination.platform !== "slack") {
|
|
521
|
-
throw new Error("Resource event subscriptions require a Slack destination");
|
|
522
|
-
}
|
|
523
|
-
return destination.teamId;
|
|
514
|
+
function resourceIndexKey(namespace, identifier) {
|
|
515
|
+
return `${RESOURCE_EVENT_PREFIX}:resource:${digest(`${namespace}\0${identifier}`)}`;
|
|
524
516
|
}
|
|
525
517
|
function conversationIndexKey(conversationId) {
|
|
526
518
|
return `${RESOURCE_EVENT_PREFIX}:conversation:${digest(conversationId)}`;
|
|
@@ -606,7 +598,7 @@ async function readSubscriptionIdIndex(state, key) {
|
|
|
606
598
|
function buildSubscriptionId(input) {
|
|
607
599
|
const eventKey = [...new Set(input.events)].sort().join("\0");
|
|
608
600
|
const matchKey = stableResourceEventMatchKey(input.match);
|
|
609
|
-
const material = matchKey ? `${input.
|
|
601
|
+
const material = matchKey ? `${input.namespace}\0${input.identifier}\0${input.conversationId}\0${eventKey}\0${matchKey}` : `${input.namespace}\0${input.identifier}\0${input.conversationId}\0${eventKey}`;
|
|
610
602
|
return `resub_${digest(material)}`;
|
|
611
603
|
}
|
|
612
604
|
async function withIndexLock(state, key, callback) {
|
|
@@ -658,7 +650,7 @@ function activeAt(subscription, nowMs) {
|
|
|
658
650
|
return subscription.status === "active" && subscription.expiresAtMs > nowMs;
|
|
659
651
|
}
|
|
660
652
|
function matchesEvent(subscription, input) {
|
|
661
|
-
return subscription.namespace === input.namespace && subscription.identifier === input.identifier &&
|
|
653
|
+
return subscription.namespace === input.namespace && subscription.identifier === input.identifier && subscription.events.includes(input.eventType) && activeAt(subscription, input.nowMs) && resourceEventMatches(subscription.match, input.data);
|
|
662
654
|
}
|
|
663
655
|
async function createResourceEventSubscription(input, options = {}) {
|
|
664
656
|
const state = options.state ?? getStateAdapter();
|
|
@@ -679,13 +671,11 @@ async function createResourceEventSubscription(input, options = {}) {
|
|
|
679
671
|
events,
|
|
680
672
|
match,
|
|
681
673
|
namespace: input.namespace,
|
|
682
|
-
identifier: input.identifier
|
|
683
|
-
teamId: subscriptionTeamId(input.destination)
|
|
674
|
+
identifier: input.identifier
|
|
684
675
|
});
|
|
685
676
|
const record = {
|
|
686
677
|
conversationId: input.conversationId,
|
|
687
678
|
createdAtMs: nowMs,
|
|
688
|
-
destination: input.destination,
|
|
689
679
|
events,
|
|
690
680
|
expiresAtMs: input.expiresAtMs,
|
|
691
681
|
id,
|
|
@@ -706,11 +696,7 @@ async function createResourceEventSubscription(input, options = {}) {
|
|
|
706
696
|
);
|
|
707
697
|
await addToIndex(
|
|
708
698
|
state,
|
|
709
|
-
resourceIndexKey(
|
|
710
|
-
subscriptionTeamId(parsed.destination),
|
|
711
|
-
input.namespace,
|
|
712
|
-
input.identifier
|
|
713
|
-
),
|
|
699
|
+
resourceIndexKey(input.namespace, input.identifier),
|
|
714
700
|
id,
|
|
715
701
|
nowMs
|
|
716
702
|
);
|
|
@@ -762,11 +748,7 @@ async function cancelResourceEventSubscription(input) {
|
|
|
762
748
|
);
|
|
763
749
|
await removeFromIndex(
|
|
764
750
|
state,
|
|
765
|
-
resourceIndexKey(
|
|
766
|
-
subscriptionTeamId(current.destination),
|
|
767
|
-
current.namespace,
|
|
768
|
-
current.identifier
|
|
769
|
-
),
|
|
751
|
+
resourceIndexKey(current.namespace, current.identifier),
|
|
770
752
|
input.id,
|
|
771
753
|
nowMs
|
|
772
754
|
);
|
|
@@ -805,7 +787,7 @@ async function collectResourceEventMatchKeys(input) {
|
|
|
805
787
|
for (const identifier of identifiers) {
|
|
806
788
|
const ids = await readSubscriptionIdIndex(
|
|
807
789
|
state,
|
|
808
|
-
resourceIndexKey(input.
|
|
790
|
+
resourceIndexKey(input.namespace, identifier)
|
|
809
791
|
);
|
|
810
792
|
const records = await Promise.all(
|
|
811
793
|
ids.map(
|
|
@@ -816,7 +798,6 @@ async function collectResourceEventMatchKeys(input) {
|
|
|
816
798
|
if (!record) continue;
|
|
817
799
|
if (record.namespace !== input.namespace) continue;
|
|
818
800
|
if (record.identifier !== identifier) continue;
|
|
819
|
-
if (subscriptionTeamId(record.destination) !== input.teamId) continue;
|
|
820
801
|
if (!activeAt(record, nowMs)) continue;
|
|
821
802
|
if (!record.events.some((eventType) => eventTypes.has(eventType))) continue;
|
|
822
803
|
for (const key of Object.keys(record.match ?? {})) {
|
|
@@ -832,7 +813,7 @@ async function findMatchingResourceEventSubscriptions(input) {
|
|
|
832
813
|
const nowMs = input.nowMs ?? Date.now();
|
|
833
814
|
const ids = await readSubscriptionIdIndex(
|
|
834
815
|
state,
|
|
835
|
-
resourceIndexKey(input.
|
|
816
|
+
resourceIndexKey(input.namespace, input.identifier)
|
|
836
817
|
);
|
|
837
818
|
const records = await Promise.all(
|
|
838
819
|
ids.map(
|
|
@@ -845,8 +826,7 @@ async function findMatchingResourceEventSubscriptions(input) {
|
|
|
845
826
|
eventType: input.eventType,
|
|
846
827
|
nowMs,
|
|
847
828
|
namespace: input.namespace,
|
|
848
|
-
identifier: input.identifier
|
|
849
|
-
teamId: input.teamId
|
|
829
|
+
identifier: input.identifier
|
|
850
830
|
})
|
|
851
831
|
);
|
|
852
832
|
}
|
|
@@ -866,8 +846,7 @@ async function deliverResourceEventSubscription(input) {
|
|
|
866
846
|
eventType: input.eventType,
|
|
867
847
|
nowMs,
|
|
868
848
|
namespace: input.namespace,
|
|
869
|
-
identifier: input.identifier
|
|
870
|
-
teamId: input.teamId
|
|
849
|
+
identifier: input.identifier
|
|
871
850
|
})) {
|
|
872
851
|
return false;
|
|
873
852
|
}
|
|
@@ -891,11 +870,7 @@ async function deliverResourceEventSubscription(input) {
|
|
|
891
870
|
);
|
|
892
871
|
await removeFromIndex(
|
|
893
872
|
state,
|
|
894
|
-
resourceIndexKey(
|
|
895
|
-
subscriptionTeamId(current.destination),
|
|
896
|
-
current.namespace,
|
|
897
|
-
current.identifier
|
|
898
|
-
),
|
|
873
|
+
resourceIndexKey(current.namespace, current.identifier),
|
|
899
874
|
current.id,
|
|
900
875
|
nowMs
|
|
901
876
|
);
|
|
@@ -2711,7 +2686,6 @@ function getPluginTools(context, sandbox = createSandboxCapability(context.works
|
|
|
2711
2686
|
}
|
|
2712
2687
|
const subscription = await createResourceEventSubscription({
|
|
2713
2688
|
conversationId: context.conversationId,
|
|
2714
|
-
destination: context.destination,
|
|
2715
2689
|
events: input.events,
|
|
2716
2690
|
expiresAtMs: Date.now() + RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS,
|
|
2717
2691
|
intent: input.intent,
|
|
@@ -2,29 +2,29 @@ import {
|
|
|
2
2
|
coerceThreadConversationState,
|
|
3
3
|
getPersistedThreadState,
|
|
4
4
|
persistThreadStateById
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-27T5HZHO.js";
|
|
6
6
|
import {
|
|
7
7
|
buildDeterministicTurnId,
|
|
8
8
|
clearPendingAuth,
|
|
9
9
|
markTurnClosed,
|
|
10
10
|
markTurnCompleted
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NU775DLU.js";
|
|
12
12
|
import {
|
|
13
13
|
hydrateConversationMessages,
|
|
14
14
|
markConversationMessage
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-D5BWM37G.js";
|
|
16
16
|
import {
|
|
17
17
|
ProviderError,
|
|
18
18
|
findProviderError,
|
|
19
19
|
getProviderErrorAttributes,
|
|
20
20
|
getProviderErrorUserMessage
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-URZ7UD4P.js";
|
|
22
22
|
import {
|
|
23
23
|
parseSlackMessageTs
|
|
24
24
|
} from "./chunk-N7TMSOZH.js";
|
|
25
25
|
import {
|
|
26
26
|
buildTurnFailureResponse
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-6YCIYOVA.js";
|
|
28
28
|
|
|
29
29
|
// src/chat/runtime/delivered-turn-state.ts
|
|
30
30
|
function buildDeliveredTurnStatePatch(args) {
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-VFUK3X5B.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_SQL_STATEMENT_TIMEOUT_MS
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-URZ7UD4P.js";
|
|
8
8
|
|
|
9
9
|
// src/db/neon.ts
|
|
10
10
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -137,13 +137,19 @@ var juniorConversations = pgTable4(
|
|
|
137
137
|
schemaVersion: integer2("schema_version").notNull().default(1),
|
|
138
138
|
source: text4("source").$type(),
|
|
139
139
|
/** Structured session Source locator; set-once on the conversation root. */
|
|
140
|
+
// TODO(dcramer): Remove source_json after every stored Conversation has a
|
|
141
|
+
// complete Location and all readers use it for provider context.
|
|
140
142
|
sessionSource: jsonb2("source_json").$type(),
|
|
141
143
|
originType: text4("origin_type"),
|
|
142
144
|
originId: text4("origin_id"),
|
|
143
145
|
originRunId: text4("origin_run_id"),
|
|
146
|
+
// TODO(dcramer): Rename destination_id to location_id after all deployed
|
|
147
|
+
// readers and writers use the singular Conversation Location contract.
|
|
144
148
|
destinationId: text4("destination_id").references(
|
|
145
149
|
() => juniorDestinations.id
|
|
146
150
|
),
|
|
151
|
+
// TODO(dcramer): Drop destination_json after every row uses location_id and
|
|
152
|
+
// no supported worker writes the legacy JSON value.
|
|
147
153
|
destination: jsonb2("destination_json").$type(),
|
|
148
154
|
actorIdentityId: text4("actor_identity_id").references(
|
|
149
155
|
() => juniorIdentities.id
|
|
@@ -422,6 +428,8 @@ var juniorConversationBindings = pgTable10(
|
|
|
422
428
|
conversationId: text10("conversation_id").notNull().references(() => juniorConversations.conversationId),
|
|
423
429
|
provider: text10("provider").notNull(),
|
|
424
430
|
providerTenantId: text10("provider_tenant_id").notNull().default(""),
|
|
431
|
+
// TODO(dcramer): Rename provider_destination_id with the Location SQL
|
|
432
|
+
// migration. It identifies the provider place that contains the thread.
|
|
425
433
|
providerDestinationId: text10("provider_destination_id").notNull(),
|
|
426
434
|
providerConversationId: text10("provider_conversation_id").notNull(),
|
|
427
435
|
createdAt: timestamptz("created_at").notNull()
|
|
@@ -660,7 +668,8 @@ var juniorSchedulerTasks = pgTable17(
|
|
|
660
668
|
{
|
|
661
669
|
id: text17("id").primaryKey(),
|
|
662
670
|
teamId: text17("team_id").notNull(),
|
|
663
|
-
// TODO(
|
|
671
|
+
// TODO(dcramer): Remove after v0.127.x runtimes are unsupported and no
|
|
672
|
+
// supported runtime writes this column.
|
|
664
673
|
creatorSlackUserId: text17("creator_slack_user_id"),
|
|
665
674
|
creatorIdentityId: text17("creator_identity_id"),
|
|
666
675
|
status: text17("status").notNull(),
|
|
@@ -672,7 +681,8 @@ var juniorSchedulerTasks = pgTable17(
|
|
|
672
681
|
record: jsonb7("record").$type().notNull()
|
|
673
682
|
},
|
|
674
683
|
(table) => [
|
|
675
|
-
// TODO(
|
|
684
|
+
// TODO(dcramer): Remove after no supported runtime reads or writes the
|
|
685
|
+
// legacy creatorSlackUserId column.
|
|
676
686
|
index13("junior_scheduler_tasks_creator_idx").on(table.teamId, table.creatorSlackUserId, table.createdAtMs, table.id).where(sql6`${table.status} <> 'deleted'`),
|
|
677
687
|
index13("junior_scheduler_tasks_creator_identity_idx").on(table.creatorIdentityId, table.createdAtMs, table.id).where(
|
|
678
688
|
sql6`${table.status} <> 'deleted' AND ${table.creatorIdentityId} IS NOT NULL`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getStateAdapter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-U6ZQHRIP.js";
|
|
4
4
|
import {
|
|
5
5
|
getClient
|
|
6
6
|
} from "./chunk-PEQXYSSE.js";
|
|
@@ -61,7 +61,7 @@ function buildSentryWebBaseUrl(dsn) {
|
|
|
61
61
|
const path = dsn.path ? `/${dsn.path}` : "";
|
|
62
62
|
return `${dsn.protocol}://${dsn.host}${port}${path}`;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function buildSentryOrgPath(args) {
|
|
65
65
|
const client = getClient();
|
|
66
66
|
const dsn = client?.getDsn();
|
|
67
67
|
if (!dsn?.host || !dsn.projectId) {
|
|
@@ -71,18 +71,28 @@ function buildSentryConversationUrl(conversationId) {
|
|
|
71
71
|
if (!orgSlug) {
|
|
72
72
|
return void 0;
|
|
73
73
|
}
|
|
74
|
-
const encodedId = encodeURIComponent(conversationId);
|
|
75
74
|
const params = new URLSearchParams();
|
|
76
75
|
params.set("project", dsn.projectId);
|
|
77
|
-
const path =
|
|
76
|
+
const path = `${args.path}?${params.toString()}`;
|
|
78
77
|
if (isSentrySaasDsnHost(dsn.host)) {
|
|
79
78
|
return `https://${orgSlug}.sentry.io/${path}`;
|
|
80
79
|
}
|
|
81
80
|
return `${buildSentryWebBaseUrl(dsn)}/organizations/${orgSlug}/${path}`;
|
|
82
81
|
}
|
|
82
|
+
function buildSentryConversationUrl(conversationId) {
|
|
83
|
+
return buildSentryOrgPath({
|
|
84
|
+
path: `explore/conversations/${encodeURIComponent(conversationId)}/`
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function buildSentryEventUrl(eventId) {
|
|
88
|
+
return buildSentryOrgPath({
|
|
89
|
+
path: `events/${encodeURIComponent(eventId)}/`
|
|
90
|
+
});
|
|
91
|
+
}
|
|
83
92
|
|
|
84
93
|
export {
|
|
85
94
|
buildSentryConversationUrl,
|
|
95
|
+
buildSentryEventUrl,
|
|
86
96
|
createWebAuthorization,
|
|
87
97
|
getWebAuthorization,
|
|
88
98
|
deleteWebAuthorization
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
toOptionalTrimmed
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-URZ7UD4P.js";
|
|
4
4
|
import {
|
|
5
5
|
pluginCatalogRuntime
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QH3I7ZOK.js";
|
|
7
7
|
import {
|
|
8
8
|
setSpanAttributes,
|
|
9
9
|
setSpanStatus
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6YCIYOVA.js";
|
|
11
11
|
|
|
12
12
|
// src/chat/sandbox/paths.ts
|
|
13
13
|
function normalizeWorkspaceRoot(input) {
|
|
@@ -399,6 +399,32 @@ function getVercelSandboxCredentials() {
|
|
|
399
399
|
return void 0;
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
+
// src/chat/sandbox/snapshot/not-ready-error.ts
|
|
403
|
+
var WorkspaceSnapshotNotReadyError = class extends Error {
|
|
404
|
+
workspaceName;
|
|
405
|
+
constructor(workspaceName) {
|
|
406
|
+
super(`Workspace ${workspaceName} snapshot is not ready`);
|
|
407
|
+
this.name = "WorkspaceSnapshotNotReadyError";
|
|
408
|
+
this.workspaceName = workspaceName;
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
function getWorkspaceSnapshotNotReadyError(error) {
|
|
412
|
+
const seen = /* @__PURE__ */ new Set();
|
|
413
|
+
let current = error;
|
|
414
|
+
while (current instanceof Error && !seen.has(current)) {
|
|
415
|
+
if (current instanceof WorkspaceSnapshotNotReadyError) return current;
|
|
416
|
+
seen.add(current);
|
|
417
|
+
current = current.cause;
|
|
418
|
+
}
|
|
419
|
+
return void 0;
|
|
420
|
+
}
|
|
421
|
+
function isWorkspaceSnapshotNotReadyError(error) {
|
|
422
|
+
return getWorkspaceSnapshotNotReadyError(error) !== void 0;
|
|
423
|
+
}
|
|
424
|
+
function workspaceSnapshotNotReadyUserMessage(error) {
|
|
425
|
+
return `The ${error.workspaceName} workspace is still preparing its sandbox. Wait for that preparation to finish, then try again.`;
|
|
426
|
+
}
|
|
427
|
+
|
|
402
428
|
// src/chat/sandbox/http-error-details.ts
|
|
403
429
|
var DEFAULT_PREVIEW_LIMIT = 512;
|
|
404
430
|
function toTrimmedString(value, maxChars) {
|
|
@@ -615,6 +641,10 @@ function isSandboxCommandStreamInterruptedError(error) {
|
|
|
615
641
|
});
|
|
616
642
|
}
|
|
617
643
|
function wrapSandboxSetupError(error) {
|
|
644
|
+
const notReady = getWorkspaceSnapshotNotReadyError(error);
|
|
645
|
+
if (notReady) {
|
|
646
|
+
return notReady;
|
|
647
|
+
}
|
|
618
648
|
try {
|
|
619
649
|
const details = getSandboxErrorDetails(error);
|
|
620
650
|
if (details.summary) {
|
|
@@ -667,6 +697,10 @@ export {
|
|
|
667
697
|
buildNonInteractiveShellScript,
|
|
668
698
|
runNonInteractiveCommand,
|
|
669
699
|
getVercelSandboxCredentials,
|
|
700
|
+
WorkspaceSnapshotNotReadyError,
|
|
701
|
+
getWorkspaceSnapshotNotReadyError,
|
|
702
|
+
isWorkspaceSnapshotNotReadyError,
|
|
703
|
+
workspaceSnapshotNotReadyUserMessage,
|
|
670
704
|
isAlreadyExistsError,
|
|
671
705
|
isSandboxUnavailableError,
|
|
672
706
|
isSandboxMissingError,
|