@sentry/junior 0.280.0 → 0.282.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/{adapter-DVN3iwf9.js → adapter-BAqo7eOH.js} +1 -1
- package/dist/{admin-Q_UI--9W.js → admin-DbWpMHh6.js} +1 -1
- package/dist/{agent-runner-_PYLv4Qo.js → agent-runner-h4CDcnDV.js} +1001 -981
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +5 -5
- package/dist/api.d.ts +1 -1
- package/dist/api.js +39 -33
- package/dist/{app-CL2zzzE0.d.ts → app-B-0wwAxr.d.ts} +2 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +42 -34
- package/dist/{assistant-reply-DbebsAxi.js → assistant-reply-4Wvo95-N.js} +1 -1
- package/dist/{automation-CPqRFjIa.js → automation-sIsmIXH7.js} +1 -1
- package/dist/{background-compaction-queue-B9lmh8Ml.js → background-compaction-queue-CoWqScCC.js} +2 -2
- package/dist/{briefs-Dej7V0Bz.js → briefs-CMiotFo9.js} +4 -8
- package/dist/{catalog-runtime-DpN0sWQ6.js → catalog-runtime-Cpje_Uic.js} +1 -1
- package/dist/cli/chat.js +14 -14
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +74 -7
- package/dist/{client-h2A2ZPzY.js → client-BHgCXeaF.js} +2 -2
- package/dist/{config-CusBFORe.js → config-DBdBimZ9.js} +1 -1
- package/dist/{connections-C4h6mGha.js → connections-DjY72_uF.js} +10 -10
- package/dist/{conversation-DExTZw8B.js → conversation-DNtcULyX.js} +29 -8
- package/dist/{conversation-pending-messages-Dgz6hrJs.js → conversation-pending-messages-LlFnr9-m.js} +10 -2
- package/dist/{conversation-privacy-2cm6OpNg.js → conversation-privacy-DiDh9KE4.js} +1 -1
- package/dist/{credential-sync-DK06Jgt-.js → credential-sync-DUrQwccr.js} +13 -13
- package/dist/{db-Dsvk1Tp1.d.ts → db-hQsoB16L.d.ts} +2 -1
- package/dist/{executor-Cmr0J8W3.js → executor-CGqJCxgR.js} +14 -3
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-CGnh65_X.js → logging-DapIaJAi.js} +1 -1
- package/dist/{message-RpAnqHPY.js → message-BjN5sKad.js} +9 -9
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -11
- package/dist/{oauth-callback-server-BBnhVKuX.js → oauth-callback-server-DVHKrjJP.js} +2 -2
- package/dist/{projection-C1MghKyI.js → projection-ii_OYu6z.js} +78 -30
- package/dist/{prompt-BcHg-BMy.js → prompt-DI6KCtwb.js} +5 -26
- package/dist/{registry-DR7DjX9H.js → registry-DpjG3yS-.js} +1 -1
- package/dist/{resolve-0Ful4oDv.js → resolve-iMW9Dgo2.js} +3 -3
- package/dist/{result-Dd9kCuQ-.js → result-BrlvfyIj.js} +9 -9
- package/dist/{runner-yiY8gUUu.js → runner-Bg9mr2pB.js} +11 -11
- package/dist/{sandbox-egress-signals-BzQVHCMz.js → sandbox-egress-signals-Bd3lb_Wd.js} +1 -1
- package/dist/{schema-C5pEgfHc.js → schema-BN34Jy-U.js} +3 -3
- package/dist/{schema-BkMmF552.d.ts → schema-CsqJzkP5.d.ts} +68 -9
- package/dist/{service-account-Cu7HFLZQ.js → service-account-Bd1348kw.js} +3 -3
- package/dist/{service-account-PIMpWZHF.js → service-account-Dfl9Pitm.js} +3 -3
- package/dist/{session-stop-CDEMsNtv.js → session-stop-CVEEx_YD.js} +12 -12
- package/dist/{skills-B2xIoe0f.js → skills-DqUUuf4L.js} +2 -2
- package/dist/{spawn-C0DySQRV.js → spawn-e7rQs14T.js} +2 -2
- package/dist/{stop-Dj5-nrAo.js → stop-DtpBUUJq.js} +353 -135
- package/dist/{store-Dlio-o6u.js → store-nETG4KVg.js} +4 -4
- package/dist/{store-QzOfDwKA.js → store-nu3Xx08K.js} +3 -3
- package/dist/{task-queue-Cp1V_XW3.js → task-queue-CYje8WKs.js} +3 -3
- package/dist/{task-runner-CQkkUj3o.js → task-runner-CwegN45x.js} +6 -6
- package/dist/{thread-state-Bn87cfzE.js → thread-state-BDaMl9yd.js} +4 -4
- package/dist/{turn-failure-response-CQebxByj.js → turn-failure-response-CV06tN_R.js} +7 -7
- package/dist/{turn-lifecycle-CJJsOhXB.js → turn-lifecycle-CF2N7ud5.js} +1 -1
- package/dist/{turn-session-routing-bmG330Cf.js → turn-session-routing-BIJGJjVh.js} +9 -9
- package/dist/{validation-D1wcf7hp.js → validation-DXvxEEjq.js} +1 -1
- package/dist/{version-BeHSXUK6.js → version-CzEk1KBX.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-BZ0Hp5Nb.js → viewer-C2PztlYX.js} +22 -8
- package/dist/{work-BTcCIbWu.js → work-BM_L0Pv9.js} +10 -10
- package/dist/{worker-D3fDK6zc.js → worker-2no53G60.js} +6 -6
- package/migrations/0062_plugin_report_index.sql +3 -3
- package/migrations/0078_plugin_conversation_index.sql +3 -3
- package/migrations/0079_conversation_event_author_index.sql +3 -3
- package/migrations/0080_conversation_event_latest_message_indexes.sql +27 -0
- package/migrations/meta/0080_snapshot.json +4265 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { g as TURN_REASONING_LEVELS } from "./config-
|
|
2
|
-
import { C as getSqlExecutor, x as getConversationStore } from "./viewer-
|
|
3
|
-
import { h as juniorAgentInvocations, m as juniorAgentBindings } from "./executor-
|
|
4
|
-
import { p as credentialContextSchema } from "./registry-
|
|
1
|
+
import { g as TURN_REASONING_LEVELS } from "./config-DBdBimZ9.js";
|
|
2
|
+
import { C as getSqlExecutor, x as getConversationStore } from "./viewer-C2PztlYX.js";
|
|
3
|
+
import { h as juniorAgentInvocations, m as juniorAgentBindings } from "./executor-CGqJCxgR.js";
|
|
4
|
+
import { p as credentialContextSchema } from "./registry-DpjG3yS-.js";
|
|
5
5
|
import { S as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, x as AGENT_INVOCATION_MAILBOX_STATUSES } from "./reporting-window-B-QP9zX1.js";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import * as z from "zod";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { At as requestAnotherSlice$1, Dt as recordConversationRetry$1, Et as recordAttemptFailure$1, Mt as startConversationWork$1, Nt as steerWebPendingMessages$1, Ot as releaseConversationWork$1, Pt as stopConversationWork$1, Tt as markConversationWorkEnqueued$1, _t as drainConversationMailbox$1, ct as appendInboundMessage, dt as checkInConversationWork$1, ft as clearConsumedConversationWake$1, gt as deadLetterAttempt$1, ht as completeConversationWork$1, jt as requestConversationWork$1, kt as removeActiveConversation$1, lt as beginConversationResume$1, mt as completeConversationStop$1, ot as ackMessages$1, pt as clearExpiredConversationLease$1, st as appendExclusiveInboundMessage, ut as cancelHumanFacingPendingMessages$1, vt as getConversation$1, wt as listActiveConversationIds$1, yt as getConversationWorkState$1 } from "./projection-
|
|
2
|
-
import { x as getConversationStore } from "./viewer-
|
|
3
|
-
import "./background-compaction-queue-
|
|
1
|
+
import { At as requestAnotherSlice$1, Dt as recordConversationRetry$1, Et as recordAttemptFailure$1, Mt as startConversationWork$1, Nt as steerWebPendingMessages$1, Ot as releaseConversationWork$1, Pt as stopConversationWork$1, Tt as markConversationWorkEnqueued$1, _t as drainConversationMailbox$1, ct as appendInboundMessage, dt as checkInConversationWork$1, ft as clearConsumedConversationWake$1, gt as deadLetterAttempt$1, ht as completeConversationWork$1, jt as requestConversationWork$1, kt as removeActiveConversation$1, lt as beginConversationResume$1, mt as completeConversationStop$1, ot as ackMessages$1, pt as clearExpiredConversationLease$1, st as appendExclusiveInboundMessage, ut as cancelHumanFacingPendingMessages$1, vt as getConversation$1, wt as listActiveConversationIds$1, yt as getConversationWorkState$1 } from "./projection-ii_OYu6z.js";
|
|
2
|
+
import { x as getConversationStore } from "./viewer-C2PztlYX.js";
|
|
3
|
+
import "./background-compaction-queue-CoWqScCC.js";
|
|
4
4
|
// src/chat/task-execution/store.ts
|
|
5
5
|
function metadataStore(options) {
|
|
6
6
|
return options.conversationStore ?? getConversationStore();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as logWarn } from "./logging-
|
|
2
|
-
import { _ as runWithTurnRequestDeadline, f as QUEUE_SIGNATURE_MAX_AGE_MS, h as getQueueProvider, m as verifyQueueMessage, p as signQueueMessage } from "./background-compaction-queue-
|
|
1
|
+
import { h as logWarn } from "./logging-DapIaJAi.js";
|
|
2
|
+
import { _ as runWithTurnRequestDeadline, f as QUEUE_SIGNATURE_MAX_AGE_MS, h as getQueueProvider, m as verifyQueueMessage, p as signQueueMessage } from "./background-compaction-queue-CoWqScCC.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import * as z from "zod";
|
|
5
5
|
// src/chat/queue/callback.ts
|
|
@@ -110,7 +110,7 @@ function pluginTaskCallback() {
|
|
|
110
110
|
maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
|
|
111
111
|
onRejected: logPluginTaskQueueMessageRejected,
|
|
112
112
|
run: async (message) => {
|
|
113
|
-
const { processPluginTask } = await import("./task-runner-
|
|
113
|
+
const { processPluginTask } = await import("./task-runner-CwegN45x.js").then((n) => n.r);
|
|
114
114
|
await processPluginTask(message);
|
|
115
115
|
},
|
|
116
116
|
topic: PLUGIN_TASK_QUEUE_TOPIC,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { Aa as createPluginLogger, Bn as coreTaskRegistrations, Gr as createPluginState, Gt as getPiMessageRole, Ln as getPlugins,
|
|
2
|
+
import { Aa as createPluginLogger, Bn as coreTaskRegistrations, Gr as createPluginState, Gt as getPiMessageRole, Ln as getPlugins, Wa as createPluginConversationEvents, Xt as instructionTextForProjection, en as isToolResultError, ga as createPluginModel, ha as createPluginEmbedder, in as stripRuntimeTurnContext, ka as createPluginModelCostRecorder, mo as createPluginCache, nn as normalizeToolNameFromResult, tn as isToolResultMessage, tt as getTurnRecord, v as hydrateConversationMessages } from "./projection-ii_OYu6z.js";
|
|
3
3
|
import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
|
|
4
|
-
import { S as getDb, i as readActorIdentity, x as getConversationStore } from "./viewer-
|
|
4
|
+
import { S as getDb, i as readActorIdentity, x as getConversationStore } from "./viewer-C2PztlYX.js";
|
|
5
5
|
import { _ as sameActorIdentity } from "./media-Dq9_svfQ.js";
|
|
6
|
-
import { r as getStateAdapter } from "./adapter-
|
|
7
|
-
import { t as resolveConversationRouting, u as getDispatchRecord } from "./turn-session-routing-
|
|
8
|
-
import { o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-
|
|
9
|
-
import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-
|
|
6
|
+
import { r as getStateAdapter } from "./adapter-BAqo7eOH.js";
|
|
7
|
+
import { t as resolveConversationRouting, u as getDispatchRecord } from "./turn-session-routing-BIJGJjVh.js";
|
|
8
|
+
import { o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-BDaMl9yd.js";
|
|
9
|
+
import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-CYje8WKs.js";
|
|
10
10
|
import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
|
|
11
11
|
// src/chat/plugins/task-runner.ts
|
|
12
12
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Rr as JUNIOR_THREAD_STATE_TTL_MS,
|
|
2
|
-
import { G as toOptionalNumber, K as toOptionalString, W as isRecord } from "./logging-
|
|
3
|
-
import { S as getDb } from "./viewer-
|
|
4
|
-
import { r as getStateAdapter } from "./adapter-
|
|
1
|
+
import { Rr as JUNIOR_THREAD_STATE_TTL_MS, ho as createDurableLocationConfigurationService, y as persistConversationMessages } from "./projection-ii_OYu6z.js";
|
|
2
|
+
import { G as toOptionalNumber, K as toOptionalString, W as isRecord } from "./logging-DapIaJAi.js";
|
|
3
|
+
import { S as getDb } from "./viewer-C2PztlYX.js";
|
|
4
|
+
import { r as getStateAdapter } from "./adapter-BAqo7eOH.js";
|
|
5
5
|
// src/chat/state/conversation.ts
|
|
6
6
|
function defaultConversationState() {
|
|
7
7
|
return {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { K as clearPendingAuth, M as markConversationMessage,
|
|
2
|
-
import { b as getProviderErrorUserMessage, g as ProviderError, v as findProviderError, y as getProviderErrorAttributes } from "./client-
|
|
3
|
-
import { W as isRecord, t as buildTurnFailureResponse } from "./logging-
|
|
1
|
+
import { K as clearPendingAuth, M as markConversationMessage, lo as listConversationAnnotations, un as buildDeterministicTurnId, v as hydrateConversationMessages } from "./projection-ii_OYu6z.js";
|
|
2
|
+
import { b as getProviderErrorUserMessage, g as ProviderError, v as findProviderError, y as getProviderErrorAttributes } from "./client-BHgCXeaF.js";
|
|
3
|
+
import { W as isRecord, t as buildTurnFailureResponse } from "./logging-DapIaJAi.js";
|
|
4
4
|
import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
|
|
5
|
-
import { S as getDb, y as getConversationEventStore } from "./viewer-
|
|
6
|
-
import { M as readMessageCardRefs, N as removedCardSchema, P as resolveMessageCards } from "./conversation-
|
|
7
|
-
import { O as parseAgentInvocationResultMessageId, Q as markTurnCompleted, Z as markTurnClosed, c as getAgentInvocation, m as getAgentInvocationTurnId } from "./store-
|
|
8
|
-
import { a as persistThreadStateById, o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-
|
|
5
|
+
import { S as getDb, y as getConversationEventStore } from "./viewer-C2PztlYX.js";
|
|
6
|
+
import { M as readMessageCardRefs, N as removedCardSchema, P as resolveMessageCards } from "./conversation-DNtcULyX.js";
|
|
7
|
+
import { O as parseAgentInvocationResultMessageId, Q as markTurnCompleted, Z as markTurnClosed, c as getAgentInvocation, m as getAgentInvocationTurnId } from "./store-nETG4KVg.js";
|
|
8
|
+
import { a as persistThreadStateById, o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-BDaMl9yd.js";
|
|
9
9
|
// src/chat/conversations/pending-cards.ts
|
|
10
10
|
/**
|
|
11
11
|
* Add the cards that tool results selected since the last visible assistant
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { y as getConversationEventStore } from "./viewer-
|
|
1
|
+
import { y as getConversationEventStore } from "./viewer-C2PztlYX.js";
|
|
2
2
|
// src/chat/conversations/turn-lifecycle.ts
|
|
3
3
|
/** Persist correlated turn lifecycle facts with retry-safe terminal exclusion. */
|
|
4
4
|
var ConversationTurnLifecycleService = class {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Ei as openSlackDirectMessage, Hr as getDashboardTaskLink, Rr as JUNIOR_THREAD_STATE_TTL_MS, Wr as ToolInputError, _i as escapeSlackMrkdwnText, ki as postSlackMessage, vi as formatSlackLink, w as fallbackShortTitle } from "./projection-
|
|
2
|
-
import { n as botConfig } from "./config-
|
|
3
|
-
import { _ as runBestEffort, h as logWarn } from "./logging-
|
|
4
|
-
import { Q as agentTurnTotalTokens, S as getDb, Z as agentTurnCostUsd } from "./viewer-
|
|
5
|
-
import {
|
|
6
|
-
import { h as credentialSubjectSchema } from "./registry-
|
|
7
|
-
import { r as getStateAdapter } from "./adapter-
|
|
8
|
-
import { O as eventAutomationSchema, S as automationVersionSchema, j as scheduledAutomationSchema } from "./automation-
|
|
1
|
+
import { Ei as openSlackDirectMessage, Hr as getDashboardTaskLink, Rr as JUNIOR_THREAD_STATE_TTL_MS, Wr as ToolInputError, _i as escapeSlackMrkdwnText, ki as postSlackMessage, vi as formatSlackLink, w as fallbackShortTitle } from "./projection-ii_OYu6z.js";
|
|
2
|
+
import { n as botConfig } from "./config-DBdBimZ9.js";
|
|
3
|
+
import { _ as runBestEffort, h as logWarn } from "./logging-DapIaJAi.js";
|
|
4
|
+
import { Q as agentTurnTotalTokens, S as getDb, Z as agentTurnCostUsd } from "./viewer-C2PztlYX.js";
|
|
5
|
+
import { A as juniorConversations, d as juniorAutomations, l as juniorAutomationRuns, u as juniorAutomationVersions } from "./executor-CGqJCxgR.js";
|
|
6
|
+
import { h as credentialSubjectSchema } from "./registry-DpjG3yS-.js";
|
|
7
|
+
import { r as getStateAdapter } from "./adapter-BAqo7eOH.js";
|
|
8
|
+
import { O as eventAutomationSchema, S as automationVersionSchema, j as scheduledAutomationSchema } from "./automation-sIsmIXH7.js";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import * as z from "zod";
|
|
11
11
|
import { and, asc, count, desc, eq, gte, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
|
|
@@ -1583,7 +1583,7 @@ function slackSourceForDestination(args) {
|
|
|
1583
1583
|
* Reads parent Conversations when this Conversation has no Destination.
|
|
1584
1584
|
*/
|
|
1585
1585
|
async function resolveConversationRouting(args) {
|
|
1586
|
-
const conversationStore = args.conversationStore ?? (await import("./viewer-
|
|
1586
|
+
const conversationStore = args.conversationStore ?? (await import("./viewer-C2PztlYX.js").then((n) => n.v)).getConversationStore();
|
|
1587
1587
|
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
1588
1588
|
let destination;
|
|
1589
1589
|
let source;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
2
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-Cpje_Uic.js";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
4
|
// src/chat/plugins/validation.ts
|
|
5
5
|
var validation_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.282.0";
|
|
3
3
|
// src/version.ts
|
|
4
4
|
/** Installed Junior package version, or `unknown` when package metadata is unavailable. */
|
|
5
5
|
const JUNIOR_VERSION = typeof version === "string" && version.trim() ? version : "unknown";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as JUNIOR_VERSION } from "./version-
|
|
1
|
+
export { t as JUNIOR_VERSION } from "./version-CzEk1KBX.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { i as getChatConfig } from "./config-
|
|
3
|
-
import { U as normalizeIdentityEmail, V as GOOGLE_IDENTITY_PROVIDER, h as logWarn } from "./logging-
|
|
2
|
+
import { i as getChatConfig } from "./config-DBdBimZ9.js";
|
|
3
|
+
import { U as normalizeIdentityEmail, V as GOOGLE_IDENTITY_PROVIDER, h as logWarn } from "./logging-DapIaJAi.js";
|
|
4
4
|
import { a as isSlackUserId, d as parseSlackChannelReferenceId, f as parseSlackTeamId, s as parseActorUserId } from "./actor-6jsm_v96.js";
|
|
5
|
-
import { A as
|
|
5
|
+
import { A as juniorConversations, C as juniorConversationEvents, M as juniorUsers, N as juniorDestinations, T as juniorConversationAnnotations, _ as juniorConversationParticipants, b as CONVERSATION_METRICS, j as juniorIdentities, k as conversationReadColumns, t as createJuniorSqlExecutor, v as juniorConversationBindings, x as juniorConversationMetrics } from "./executor-CGqJCxgR.js";
|
|
6
6
|
import { d as newConversationEventSchema, f as encodeHistoryPayload, l as decodeStoredConversationEvent, n as detectImageMediaType, o as conversationEventDataSchema, u as historyReplacementSchema, v as usageSchema } from "./media-Dq9_svfQ.js";
|
|
7
7
|
import { a as withLock } from "./locks-D-0h111u.js";
|
|
8
8
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -494,7 +494,8 @@ async function deleteProviderIdentityForUser(executor, userId, provider, provide
|
|
|
494
494
|
}
|
|
495
495
|
/**
|
|
496
496
|
* Save one Google sign-in. Link the Google identity to the user of its
|
|
497
|
-
* verified email, and set its sign-in time.
|
|
497
|
+
* verified email, and set its sign-in time. Return the previous sign-in
|
|
498
|
+
* time, if any.
|
|
498
499
|
*/
|
|
499
500
|
async function recordGoogleSignIn(executor, account, nowMs = Date.now()) {
|
|
500
501
|
const stored = await upsertIdentity(executor, {
|
|
@@ -506,8 +507,9 @@ async function recordGoogleSignIn(executor, account, nowMs = Date.now()) {
|
|
|
506
507
|
displayName: account.displayName,
|
|
507
508
|
avatarUrl: account.avatarUrl ?? null
|
|
508
509
|
}, nowMs);
|
|
510
|
+
const [previous] = await executor.db().select({ signedInAt: juniorIdentities.signedInAt }).from(juniorIdentities).where(eq(juniorIdentities.id, stored.id)).limit(1);
|
|
509
511
|
await executor.db().update(juniorIdentities).set({ signedInAt: dateFromMs$1(nowMs) }).where(eq(juniorIdentities.id, stored.id));
|
|
510
|
-
return
|
|
512
|
+
return previous?.signedInAt?.getTime();
|
|
511
513
|
}
|
|
512
514
|
// src/chat/identities/actor.ts
|
|
513
515
|
/**
|
|
@@ -1955,7 +1957,9 @@ function identityFromRow(row) {
|
|
|
1955
1957
|
});
|
|
1956
1958
|
}
|
|
1957
1959
|
async function readUserById(db, userRow) {
|
|
1958
|
-
|
|
1960
|
+
return userFromRows(userRow, await db.select().from(juniorIdentities).where(and(eq(juniorIdentities.userId, userRow.id), eq(juniorIdentities.kind, "user"))).orderBy(asc(juniorIdentities.provider), asc(juniorIdentities.providerTenantId), asc(juniorIdentities.providerSubjectId)));
|
|
1961
|
+
}
|
|
1962
|
+
function userFromRows(userRow, identityRows) {
|
|
1959
1963
|
return userSchema.parse({
|
|
1960
1964
|
email: userRow.primaryEmail,
|
|
1961
1965
|
id: userRow.id,
|
|
@@ -1964,10 +1968,21 @@ async function readUserById(db, userRow) {
|
|
|
1964
1968
|
...userRow.isAdmin ? { isAdmin: true } : void 0
|
|
1965
1969
|
});
|
|
1966
1970
|
}
|
|
1971
|
+
async function readUserByNormalizedEmail(db, normalizedEmail) {
|
|
1972
|
+
const rows = await db.select({
|
|
1973
|
+
user: juniorUsers,
|
|
1974
|
+
identity: juniorIdentities
|
|
1975
|
+
}).from(juniorUsers).leftJoin(juniorIdentities, and(eq(juniorIdentities.userId, juniorUsers.id), eq(juniorIdentities.kind, "user"))).where(eq(juniorUsers.primaryEmailNormalized, normalizedEmail)).orderBy(asc(juniorIdentities.provider), asc(juniorIdentities.providerTenantId), asc(juniorIdentities.providerSubjectId));
|
|
1976
|
+
const userRow = rows[0]?.user;
|
|
1977
|
+
if (!userRow) return void 0;
|
|
1978
|
+
return userFromRows(userRow, rows.flatMap((row) => row.identity ? [row.identity] : []));
|
|
1979
|
+
}
|
|
1967
1980
|
/** Resolve or create the canonical user for one verified viewer email. */
|
|
1968
1981
|
async function resolveViewerUserFromSql(db, email) {
|
|
1969
1982
|
const normalizedEmail = normalizeIdentityEmail(email);
|
|
1970
1983
|
if (!normalizedEmail) return void 0;
|
|
1984
|
+
const existing = await readUserByNormalizedEmail(db, normalizedEmail);
|
|
1985
|
+
if (existing) return existing;
|
|
1971
1986
|
const now = /* @__PURE__ */ new Date();
|
|
1972
1987
|
const userRow = (await db.insert(juniorUsers).values({
|
|
1973
1988
|
id: randomUUID(),
|
|
@@ -1987,8 +2002,7 @@ async function resolveViewerUser(email) {
|
|
|
1987
2002
|
async function findUserByEmailFromSql(db, email) {
|
|
1988
2003
|
const normalizedEmail = normalizeIdentityEmail(email);
|
|
1989
2004
|
if (!normalizedEmail) return void 0;
|
|
1990
|
-
|
|
1991
|
-
return userRow ? await readUserById(db, userRow) : void 0;
|
|
2005
|
+
return await readUserByNormalizedEmail(db, normalizedEmail);
|
|
1992
2006
|
}
|
|
1993
2007
|
/** Read one existing canonical user by verified email without creating a row. */
|
|
1994
2008
|
async function findUserByEmail(email) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { H as AuthorizationFlowDisabledError, Kt as getTerminalAssistantMessages, Q as abandonTurnRecord,
|
|
2
|
-
import { n as botConfig } from "./config-
|
|
3
|
-
import { F as SYSTEM_IDENTITY_ID, x as getConversationStore, y as getConversationEventStore } from "./viewer-
|
|
1
|
+
import { $a as loadForkHistory, H as AuthorizationFlowDisabledError, Kt as getTerminalAssistantMessages, Q as abandonTurnRecord, R as PluginCredentialFailureError, Vt as isTurnExecutionLimitExceededError, Z as saveTurnCheckpoint, et as failTurnRecord, s as openConversationProjection, tt as getTurnRecord } from "./projection-ii_OYu6z.js";
|
|
2
|
+
import { n as botConfig } from "./config-DBdBimZ9.js";
|
|
3
|
+
import { F as SYSTEM_IDENTITY_ID, x as getConversationStore, y as getConversationEventStore } from "./viewer-C2PztlYX.js";
|
|
4
4
|
import { _ as sameActorIdentity, p as agentInstructionProvenance } from "./media-Dq9_svfQ.js";
|
|
5
|
-
import { At as withoutSavedSteeringMessages, It as readBlockedReport, St as recordSubagentStarted, kt as buildSteeringPiMessage, xt as recordSubagentEnded, yt as stopChildAgentsOf } from "./agent-runner-
|
|
6
|
-
import { B as agentTypeInstructions, C as markAgentInvocationMailboxAppended, D as markAgentInvocationSteered, E as markAgentInvocationRunning, G as TurnInputCommitLostError, T as markAgentInvocationPaused, V as agentTypeStartsWithParentHistory, Y as isTurnInputCommitLostError, _ as getLatestAgentInvocationForConversation, b as listAgentInvocationsForConversation, c as getAgentInvocation, f as getAgentInvocationMessageId, i as createAgentInvocation, k as reportReplacedAgentInvocation, m as getAgentInvocationTurnId, n as NON_TERMINAL_AGENT_INVOCATION_STATUSES, q as getConversationTurnBoundaryError, r as completeAgentInvocation, s as getActiveAgentInvocationForConversation, t as ACTIVE_AGENT_INVOCATION_STATUSES, y as isTerminalAgentInvocation } from "./store-
|
|
7
|
-
import { n as getAssistantReplyText } from "./assistant-reply-
|
|
8
|
-
import { E as maybePostAutomatedTurnLimitNotice, M as recordFinishedTurnForAutomatedLimit, N as resetAutomatedTurnLimit } from "./session-stop-
|
|
9
|
-
import { r as appendAndEnqueueInboundMessage } from "./store-
|
|
10
|
-
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
11
|
-
import { a as persistThreadStateById, n as getPersistedSandboxState, r as getPersistedThreadState } from "./thread-state-
|
|
5
|
+
import { At as withoutSavedSteeringMessages, It as readBlockedReport, St as recordSubagentStarted, kt as buildSteeringPiMessage, xt as recordSubagentEnded, yt as stopChildAgentsOf } from "./agent-runner-h4CDcnDV.js";
|
|
6
|
+
import { B as agentTypeInstructions, C as markAgentInvocationMailboxAppended, D as markAgentInvocationSteered, E as markAgentInvocationRunning, G as TurnInputCommitLostError, T as markAgentInvocationPaused, V as agentTypeStartsWithParentHistory, Y as isTurnInputCommitLostError, _ as getLatestAgentInvocationForConversation, b as listAgentInvocationsForConversation, c as getAgentInvocation, f as getAgentInvocationMessageId, i as createAgentInvocation, k as reportReplacedAgentInvocation, m as getAgentInvocationTurnId, n as NON_TERMINAL_AGENT_INVOCATION_STATUSES, q as getConversationTurnBoundaryError, r as completeAgentInvocation, s as getActiveAgentInvocationForConversation, t as ACTIVE_AGENT_INVOCATION_STATUSES, y as isTerminalAgentInvocation } from "./store-nETG4KVg.js";
|
|
7
|
+
import { n as getAssistantReplyText } from "./assistant-reply-4Wvo95-N.js";
|
|
8
|
+
import { E as maybePostAutomatedTurnLimitNotice, M as recordFinishedTurnForAutomatedLimit, N as resetAutomatedTurnLimit } from "./session-stop-CVEEx_YD.js";
|
|
9
|
+
import { r as appendAndEnqueueInboundMessage } from "./store-nu3Xx08K.js";
|
|
10
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-CF2N7ud5.js";
|
|
11
|
+
import { a as persistThreadStateById, n as getPersistedSandboxState, r as getPersistedThreadState } from "./thread-state-BDaMl9yd.js";
|
|
12
12
|
import { isDeepStrictEqual } from "node:util";
|
|
13
13
|
import * as z from "zod";
|
|
14
14
|
// src/chat/runtime/turn-execution.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { Ct as isInvalidConversationRecordError, St as isFinalAttempt, bt as hasConversationStop } from "./projection-
|
|
3
|
-
import { x as isProviderRetryError } from "./client-
|
|
4
|
-
import { i as getChatConfig } from "./config-
|
|
5
|
-
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-
|
|
6
|
-
import { g as getTurnRequestDeadline, v as ConversationQueueMessageRejectedError } from "./background-compaction-queue-
|
|
7
|
-
import { C as requestAnotherSlice, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-
|
|
2
|
+
import { Ct as isInvalidConversationRecordError, St as isFinalAttempt, bt as hasConversationStop } from "./projection-ii_OYu6z.js";
|
|
3
|
+
import { x as isProviderRetryError } from "./client-BHgCXeaF.js";
|
|
4
|
+
import { i as getChatConfig } from "./config-DBdBimZ9.js";
|
|
5
|
+
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-DapIaJAi.js";
|
|
6
|
+
import { g as getTurnRequestDeadline, v as ConversationQueueMessageRejectedError } from "./background-compaction-queue-CoWqScCC.js";
|
|
7
|
+
import { C as requestAnotherSlice, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-nu3Xx08K.js";
|
|
8
8
|
// src/chat/task-execution/attempt-selection.ts
|
|
9
9
|
function selectContiguousTurnBatch(messages) {
|
|
10
10
|
const first = messages[0];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
--
|
|
2
|
-
--
|
|
3
|
-
-- pg_get_indexdef, pg_index.indisvalid, and pg_index.indisready.
|
|
1
|
+
-- Before this migration runs, junior upgrade builds the marked index with
|
|
2
|
+
-- CREATE INDEX CONCURRENTLY, so the build below does not block writes.
|
|
4
3
|
DO $$
|
|
5
4
|
BEGIN
|
|
6
5
|
-- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
|
|
7
6
|
IF to_regclass('junior_conversation_events_plugin_report_idx') IS NULL THEN
|
|
7
|
+
-- junior:concurrent-index
|
|
8
8
|
CREATE INDEX "junior_conversation_events_plugin_report_idx" ON "junior_conversation_events" USING btree (("payload"->>'namespace'),("payload"->>'name'),"created_at") WHERE "junior_conversation_events"."type" = 'structured_event';
|
|
9
9
|
END IF;
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
--
|
|
2
|
-
--
|
|
3
|
-
-- pg_get_indexdef, pg_index.indisvalid, and pg_index.indisready.
|
|
1
|
+
-- Before this migration runs, junior upgrade builds the marked index with
|
|
2
|
+
-- CREATE INDEX CONCURRENTLY, so the build below does not block writes.
|
|
4
3
|
DO $$
|
|
5
4
|
BEGIN
|
|
6
5
|
-- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
|
|
7
6
|
IF to_regclass('junior_conversation_events_plugin_conversation_idx') IS NULL THEN
|
|
7
|
+
-- junior:concurrent-index
|
|
8
8
|
CREATE INDEX "junior_conversation_events_plugin_conversation_idx" ON "junior_conversation_events" USING btree ("conversation_id",("payload"->>'namespace'),("payload"->>'name'),"seq") WHERE "junior_conversation_events"."type" = 'structured_event';
|
|
9
9
|
END IF;
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
--
|
|
2
|
-
--
|
|
3
|
-
-- pg_get_indexdef, pg_index.indisvalid, and pg_index.indisready.
|
|
1
|
+
-- Before this migration runs, junior upgrade builds the marked index with
|
|
2
|
+
-- CREATE INDEX CONCURRENTLY, so the build below does not block writes.
|
|
4
3
|
DO $$
|
|
5
4
|
BEGIN
|
|
6
5
|
-- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
|
|
7
6
|
IF to_regclass('junior_conversation_events_author_idx') IS NULL THEN
|
|
7
|
+
-- junior:concurrent-index
|
|
8
8
|
CREATE INDEX "junior_conversation_events_author_idx" ON "junior_conversation_events" USING btree ("conversation_id","actor_identity_id","seq") WHERE "junior_conversation_events"."actor_identity_id" is not null;
|
|
9
9
|
END IF;
|
|
10
10
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-- Before this migration runs, junior upgrade builds the marked indexes with
|
|
2
|
+
-- CREATE INDEX CONCURRENTLY, so the builds below do not block writes.
|
|
3
|
+
DO $$
|
|
4
|
+
BEGIN
|
|
5
|
+
-- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
|
|
6
|
+
IF to_regclass('junior_conversation_events_message_role_idx') IS NULL THEN
|
|
7
|
+
-- junior:concurrent-index
|
|
8
|
+
CREATE INDEX "junior_conversation_events_message_role_idx" ON "junior_conversation_events" USING btree ("conversation_id",("payload"->>'role'),"created_at","seq") WHERE "junior_conversation_events"."type" = 'message';
|
|
9
|
+
END IF;
|
|
10
|
+
IF to_regclass('junior_conversation_events_user_message_time_idx') IS NULL THEN
|
|
11
|
+
-- junior:concurrent-index
|
|
12
|
+
CREATE INDEX "junior_conversation_events_user_message_time_idx" ON "junior_conversation_events" USING btree ("conversation_id","created_at","seq") WHERE "junior_conversation_events"."type" = 'user_message' and ("junior_conversation_events"."payload"->'provenance'->>'authority') = 'instruction' and ("junior_conversation_events"."payload"->'provenance'->'actor'->>'platform') in ('slack', 'local', 'web');
|
|
13
|
+
END IF;
|
|
14
|
+
|
|
15
|
+
-- A failed concurrent build can leave an index that exists but cannot be used.
|
|
16
|
+
IF (
|
|
17
|
+
SELECT count(*) FROM pg_index
|
|
18
|
+
WHERE indexrelid IN (
|
|
19
|
+
'junior_conversation_events_message_role_idx'::regclass,
|
|
20
|
+
'junior_conversation_events_user_message_time_idx'::regclass
|
|
21
|
+
)
|
|
22
|
+
AND indrelid = 'junior_conversation_events'::regclass
|
|
23
|
+
AND indisvalid AND indisready
|
|
24
|
+
) <> 2 THEN
|
|
25
|
+
RAISE EXCEPTION 'The conversation event latest message indexes are not valid and ready. Repair the concurrent builds before running junior upgrade.';
|
|
26
|
+
END IF;
|
|
27
|
+
END $$;
|