@sentry/junior 0.265.0 → 0.267.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/{actor-tlxzqaRe.js → actor-DZSokpwj.js} +8 -1
- package/dist/{adapter-cUkPH3Om.js → adapter-BybMEezj.js} +2 -2
- package/dist/{admin-Cf0rDmWV.js → admin-DOs1_EiW.js} +1 -1
- package/dist/{agent-runner-C6MwHJEs.js → agent-runner-DgNATN4D.js} +874 -228
- package/dist/api/schema.d.ts +202 -23
- package/dist/api/schema.js +6 -5
- package/dist/api.d.ts +6 -1
- package/dist/api.js +130 -1205
- package/dist/{app-Csbi9dW7.d.ts → app-DAB3fzyp.d.ts} +21 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +1611 -353
- package/dist/{assistant-reply-UPA8vKlC.js → assistant-reply-CT7VcXQe.js} +1 -1
- package/dist/{automation-2RbKzpMT.js → automation-CmeFBSEh.js} +42 -14
- package/dist/{briefs-DRjx8kQ9.js → briefs-CWKjka7v.js} +5 -5
- package/dist/{catalog-runtime-D3qbJlYz.js → catalog-runtime-cMlAI5LY.js} +1 -1
- package/dist/cli/chat.js +15 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +0 -1
- 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 +3 -3
- package/dist/{client-DX34VNtH.js → client-BjgbMawj.js} +2 -2
- package/dist/{config-BayQ9hHH.js → config-CdB6yJj5.js} +32 -10
- package/dist/{connections-mpN5Lsnj.js → connections-RE_65jzK.js} +13 -12
- package/dist/{conversation-B0baEwoA.js → conversation-DSo310Ps.js} +14 -3
- package/dist/{conversation-privacy-frjQCJa9.js → conversation-privacy-BzgJC5k0.js} +1 -1
- package/dist/{credential-sync-CZmyDNdR.js → credential-sync-DhEGEpgq.js} +15 -15
- package/dist/{credentialed-C6pKlB1p.js → credentialed-CIGwoLU2.js} +2913 -1026
- package/dist/{db-BnRqQ7G5.d.ts → db-Bg-zC3r5.d.ts} +1 -1
- package/dist/{executor-CAr7xQr2.js → executor-VYrx_K4w.js} +7 -4
- package/dist/{history-AY8rs-FR.js → history-C84mlAwO.js} +2 -1
- package/dist/{images-B2yA3HWE.js → images-CecjXAAz.js} +3 -3
- package/dist/instrumentation.js +6 -2
- package/dist/{job-queue-Cjo6Yg_b.js → job-queue-C0BZSa7r.js} +128 -3
- package/dist/{web-input-Y6aXvmfa.js → list-1XQP-o6K.js} +1374 -71
- package/dist/{logging-D2QBriUo.js → logging-DuZ1A4ab.js} +11 -3
- package/dist/{message-C9ymnpBS.js → message-NKSbbnA6.js} +4 -4
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-BtMf3TPZ.js → oauth-callback-server-qAHLPtml.js} +2 -2
- package/dist/{prompt-CvaDdSX3.js → prompt-BW9jFsqZ.js} +1 -1
- package/dist/{registry-COTeZ2cV.js → registry-FQutO926.js} +2 -2
- package/dist/{resolve-g9PKz9pH.js → resolve-Bk4yeuHy.js} +3 -3
- package/dist/{result-COnC42GR.js → result-B9e9ATOU.js} +9 -9
- package/dist/{runner-BnTNS7x_.js → runner-C3S2ObH-.js} +11 -11
- package/dist/{sandbox-egress-signals-C_IIdLFk.js → sandbox-egress-signals-DqpGzzMB.js} +1 -1
- package/dist/{schema-D5Amlzkp.js → schema-X7Fj4fv1.js} +3 -2
- package/dist/{service-account-CwvToidT.js → service-account-BQasl-qq.js} +3 -3
- package/dist/{service-account-YdYftwV2.js → service-account-Do30HUNv.js} +3 -3
- package/dist/{session-stop-CpCUy1ZJ.js → session-stop-DkOjt46_.js} +45 -128
- package/dist/{skills-Bb2KaJ3m.js → skills-CQHrwfOa.js} +2 -2
- package/dist/{spawn-mbTcrLb3.js → spawn-BHuqN14f.js} +2 -2
- package/dist/{store-CqRnaZSq.js → store-6EetVP-m.js} +3 -3
- package/dist/{store-CG0VJyye.d.ts → store-B8CABbmR.d.ts} +10 -2
- package/dist/store-DvNZIsCr.js +295 -0
- package/dist/{task-queue-8XjDIORF.js → task-queue-B0DLgd2P.js} +10 -5
- package/dist/{task-runner-6mLmG6g_.js → task-runner-B-PD_JOj.js} +26 -14
- package/dist/{tasks-DGbrur6x.js → tasks-0ilmuCux.js} +1440 -46
- package/dist/{thread-state-D45lz-oC.js → thread-state-DRmdJ2QN.js} +5 -5
- package/dist/{turn-failure-response-CaEPLSBn.js → turn-failure-response-G11cs2gE.js} +9 -9
- package/dist/{turn-lifecycle-C35IyRGp.js → turn-lifecycle-OzLIwvi1.js} +2 -2
- package/dist/{turn-session-routing-BKx6rfVd.js → turn-session-routing-Dyut9l7Y.js} +1 -1
- package/dist/user-input-request-BDFBdF8r.js +116 -0
- package/dist/{validation-C0X3CX51.js → validation-CxEmt1id.js} +1 -1
- package/dist/{version-BPHgJwnm.js → version-Bapedn4A.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-B2wXNspU.js → viewer-DrN3oC2X.js} +22 -11
- package/dist/{work-DMbqK0kT.js → work-DUQoNcqP.js} +52 -51
- package/dist/{worker-B-rDJ3XN.js → worker-D1l4Ugk0.js} +30 -19
- package/migrations/0064_any_resource_event_triggers.sql +2 -0
- package/migrations/meta/0064_snapshot.json +3505 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +20 -5
- package/dist/store-DdT74Lvq.js +0 -1424
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { dt as persistConversationMessages, ur as createDurableLocationConfigurationService } from "./tasks-0ilmuCux.js";
|
|
2
|
+
import { B as isRecord, H as toOptionalString, V as toOptionalNumber } from "./logging-DuZ1A4ab.js";
|
|
3
|
+
import { p as getDb } from "./viewer-DrN3oC2X.js";
|
|
4
|
+
import { dn as JUNIOR_THREAD_STATE_TTL_MS } from "./credentialed-CIGwoLU2.js";
|
|
5
|
+
import { i as getStateAdapter } from "./adapter-BybMEezj.js";
|
|
6
6
|
// src/chat/state/conversation.ts
|
|
7
7
|
function defaultConversationState() {
|
|
8
8
|
return {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as getProviderErrorAttributes, g as findProviderError, m as ProviderError, v as getProviderErrorUserMessage } from "./client-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { D as parseAgentInvocationResultMessageId, J as markTurnClosed, Y as markTurnCompleted, c as getAgentInvocation, m as getAgentInvocationTurnId } from "./store-
|
|
9
|
-
import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-
|
|
1
|
+
import { $n as buildDeterministicTurnId, Rt as clearPendingAuth, ut as hydrateConversationMessages, wt as markConversationMessage } from "./tasks-0ilmuCux.js";
|
|
2
|
+
import { _ as getProviderErrorAttributes, g as findProviderError, m as ProviderError, v as getProviderErrorUserMessage } from "./client-BjgbMawj.js";
|
|
3
|
+
import { B as isRecord, t as buildTurnFailureResponse } from "./logging-DuZ1A4ab.js";
|
|
4
|
+
import { p as parseSlackMessageTs } from "./actor-DZSokpwj.js";
|
|
5
|
+
import { p as getDb, u as getConversationEventStore } from "./viewer-DrN3oC2X.js";
|
|
6
|
+
import { er as listConversationAnnotations } from "./credentialed-CIGwoLU2.js";
|
|
7
|
+
import { B as removedCardSchema, V as resolveMessageCards, z as readMessageCardRefs } from "./conversation-DSo310Ps.js";
|
|
8
|
+
import { D as parseAgentInvocationResultMessageId, J as markTurnClosed, Y as markTurnCompleted, c as getAgentInvocation, m as getAgentInvocationTurnId } from "./store-6EetVP-m.js";
|
|
9
|
+
import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-DRmdJ2QN.js";
|
|
10
10
|
// src/chat/conversations/pending-cards.ts
|
|
11
11
|
/**
|
|
12
12
|
* Add the cards that tool results selected since the last visible assistant
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { u as getConversationEventStore } from "./viewer-DrN3oC2X.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 {
|
|
@@ -19,7 +19,7 @@ var ConversationTurnLifecycleService = class {
|
|
|
19
19
|
}
|
|
20
20
|
}]);
|
|
21
21
|
}
|
|
22
|
-
/** Record
|
|
22
|
+
/** Record a completion that is not a failure once. */
|
|
23
23
|
async complete(input) {
|
|
24
24
|
await this.events.append(input.conversationId, [{
|
|
25
25
|
idempotencyKey: `turn:${input.turnId}:terminal`,
|
|
@@ -34,7 +34,7 @@ function slackSourceForDestination(args) {
|
|
|
34
34
|
* Reads parent Conversations when this Conversation has no Destination.
|
|
35
35
|
*/
|
|
36
36
|
async function resolveConversationRouting(args) {
|
|
37
|
-
const conversationStore = args.conversationStore ?? (await import("./viewer-
|
|
37
|
+
const conversationStore = args.conversationStore ?? (await import("./viewer-DrN3oC2X.js").then((n) => n.l)).getConversationStore();
|
|
38
38
|
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
39
39
|
let destination;
|
|
40
40
|
let source;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// src/chat/tools/runtime/user-input-request.ts
|
|
3
|
+
const USER_INPUT_LIMITS = {
|
|
4
|
+
maxButtonOptions: 5,
|
|
5
|
+
maxDescriptionChars: 200,
|
|
6
|
+
maxFields: 4,
|
|
7
|
+
maxLabelChars: 75,
|
|
8
|
+
maxOptions: 10,
|
|
9
|
+
maxTextChars: 3e3,
|
|
10
|
+
maxQuestionChars: 3e3,
|
|
11
|
+
minOptions: 2
|
|
12
|
+
};
|
|
13
|
+
const labelSchema = z.string().trim().min(1).max(USER_INPUT_LIMITS.maxLabelChars);
|
|
14
|
+
const descriptionSchema = z.string().trim().min(1).max(USER_INPUT_LIMITS.maxDescriptionChars).optional();
|
|
15
|
+
const optionSchema = z.object({
|
|
16
|
+
label: labelSchema.describe("Short choice text, such as `Accept` or `Decline`. The answer uses this exact text."),
|
|
17
|
+
description: descriptionSchema.describe("Optional short note about what this choice does.")
|
|
18
|
+
});
|
|
19
|
+
const fieldBase = {
|
|
20
|
+
id: z.string().regex(/^[a-z][a-z0-9_]{0,31}$/).describe("Stable key for this field, such as `approach`."),
|
|
21
|
+
label: labelSchema.describe("Short field name, such as `Approach`."),
|
|
22
|
+
description: descriptionSchema.describe("Optional short help text for this field.")
|
|
23
|
+
};
|
|
24
|
+
const optionsSchema = z.array(optionSchema).min(USER_INPUT_LIMITS.minOptions).max(USER_INPUT_LIMITS.maxOptions).describe("Choices in display order.");
|
|
25
|
+
const userInputFieldSchema = z.discriminatedUnion("kind", [
|
|
26
|
+
z.object({
|
|
27
|
+
...fieldBase,
|
|
28
|
+
kind: z.literal("choice").describe("The person picks one option."),
|
|
29
|
+
options: optionsSchema
|
|
30
|
+
}),
|
|
31
|
+
z.object({
|
|
32
|
+
...fieldBase,
|
|
33
|
+
kind: z.literal("multi_choice").describe("The person picks any number of options."),
|
|
34
|
+
options: optionsSchema
|
|
35
|
+
}),
|
|
36
|
+
z.object({
|
|
37
|
+
...fieldBase,
|
|
38
|
+
kind: z.literal("text").describe("The person types a short answer.")
|
|
39
|
+
})
|
|
40
|
+
]);
|
|
41
|
+
const userInputRequestSchema = z.object({
|
|
42
|
+
question: z.string().trim().min(1).max(USER_INPUT_LIMITS.maxQuestionChars).describe("The question, in markdown. Include the facts the person needs to decide."),
|
|
43
|
+
fields: z.array(userInputFieldSchema).min(1).max(USER_INPUT_LIMITS.maxFields).describe("What to ask, in display order. Use one `choice` field for a simple decision.")
|
|
44
|
+
}).superRefine((request, context) => {
|
|
45
|
+
const ids = /* @__PURE__ */ new Set();
|
|
46
|
+
for (const field of request.fields) {
|
|
47
|
+
if (ids.has(field.id)) context.addIssue({
|
|
48
|
+
code: "custom",
|
|
49
|
+
message: "Each field needs a different id."
|
|
50
|
+
});
|
|
51
|
+
ids.add(field.id);
|
|
52
|
+
if (field.kind === "text") continue;
|
|
53
|
+
const labels = field.options.map((option) => option.label.toLowerCase());
|
|
54
|
+
if (new Set(labels).size !== labels.length) context.addIssue({
|
|
55
|
+
code: "custom",
|
|
56
|
+
message: "Each choice of a field needs a different label."
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Return the single choice field of a request that a surface can show as
|
|
62
|
+
* one row of buttons, where one click is the whole answer.
|
|
63
|
+
*/
|
|
64
|
+
function buttonUserInputField(request) {
|
|
65
|
+
const [field, ...rest] = request.fields;
|
|
66
|
+
if (rest.length || field?.kind !== "choice") return void 0;
|
|
67
|
+
return field.options.length <= USER_INPUT_LIMITS.maxButtonOptions ? field : void 0;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Keep only answer values that match the request: known field ids, known
|
|
71
|
+
* option labels, one value for a `choice` field, and trimmed text.
|
|
72
|
+
*/
|
|
73
|
+
function normalizeUserInputAnswer(request, answer) {
|
|
74
|
+
const values = {};
|
|
75
|
+
for (const field of request.fields) {
|
|
76
|
+
const raw = (answer.values[field.id] ?? []).map((value) => value.trim()).filter(Boolean);
|
|
77
|
+
if (field.kind === "text") {
|
|
78
|
+
const text = raw.join("\n").slice(0, USER_INPUT_LIMITS.maxTextChars);
|
|
79
|
+
if (text) values[field.id] = [text];
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const picked = field.options.map((option) => option.label).filter((label) => raw.includes(label));
|
|
83
|
+
const kept = field.kind === "choice" ? picked.slice(0, 1) : picked;
|
|
84
|
+
if (kept.length) values[field.id] = kept;
|
|
85
|
+
}
|
|
86
|
+
const other = answer.other?.trim().slice(0, USER_INPUT_LIMITS.maxTextChars);
|
|
87
|
+
return {
|
|
88
|
+
requestId: answer.requestId,
|
|
89
|
+
values,
|
|
90
|
+
...other ? { other } : void 0
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Return true when an answer has no value and no free text. */
|
|
94
|
+
function isEmptyUserInputAnswer(answer) {
|
|
95
|
+
return !answer.other && Object.keys(answer.values).length === 0;
|
|
96
|
+
}
|
|
97
|
+
function answerLine(text) {
|
|
98
|
+
return text.split("\n").map((line) => line.trim()).filter(Boolean).join("\n");
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Write an answer as the text of the person's message. Slack and the web
|
|
102
|
+
* dashboard both send this text, so the model reads one format. The first
|
|
103
|
+
* line names the request, and each field starts its own line.
|
|
104
|
+
*/
|
|
105
|
+
function formatUserInputAnswer(request, answer) {
|
|
106
|
+
const normalized = normalizeUserInputAnswer(request, answer);
|
|
107
|
+
const lines = [`Answer to request ${normalized.requestId}:`];
|
|
108
|
+
for (const field of request.fields) {
|
|
109
|
+
const values = normalized.values[field.id];
|
|
110
|
+
const value = values?.length ? values.join(", ") : "(no answer)";
|
|
111
|
+
lines.push(answerLine(`${field.label} (${field.id}): ${value}`));
|
|
112
|
+
}
|
|
113
|
+
if (normalized.other) lines.push(answerLine(`Other: ${normalized.other}`));
|
|
114
|
+
return lines.join("\n");
|
|
115
|
+
}
|
|
116
|
+
export { normalizeUserInputAnswer as a, isEmptyUserInputAnswer as i, buttonUserInputField as n, userInputRequestSchema as o, formatUserInputAnswer as r, USER_INPUT_LIMITS as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
2
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-cMlAI5LY.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.267.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-Bapedn4A.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import { i as getChatConfig } from "./config-
|
|
3
|
-
import {
|
|
4
|
-
import { d as parseSlackTeamId, o as parseActorUserId, u as parseSlackChannelReferenceId } from "./actor-
|
|
2
|
+
import { i as getChatConfig } from "./config-CdB6yJj5.js";
|
|
3
|
+
import { L as GOOGLE_IDENTITY_PROVIDER, z as normalizeIdentityEmail } from "./logging-DuZ1A4ab.js";
|
|
4
|
+
import { c as toStoredSlackActor, d as parseSlackTeamId, o as parseActorUserId, u as parseSlackChannelReferenceId } from "./actor-DZSokpwj.js";
|
|
5
5
|
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-CxKldAeB.js";
|
|
6
|
-
import { _ as juniorConversationAnnotations, d as juniorConversationBindings, h as juniorConversationEvents, m as juniorConversationMetrics, p as CONVERSATION_METRICS, t as createJuniorSqlExecutor, u as juniorConversationParticipants } from "./executor-
|
|
7
|
-
import { c as newConversationEventSchema, h as usageSchema, l as encodeHistoryPayload, o as decodeStoredConversationEvent, r as conversationEventDataSchema, s as historyReplacementSchema } from "./history-
|
|
6
|
+
import { _ as juniorConversationAnnotations, d as juniorConversationBindings, h as juniorConversationEvents, m as juniorConversationMetrics, p as CONVERSATION_METRICS, t as createJuniorSqlExecutor, u as juniorConversationParticipants } from "./executor-VYrx_K4w.js";
|
|
7
|
+
import { c as newConversationEventSchema, h as usageSchema, l as encodeHistoryPayload, o as decodeStoredConversationEvent, r as conversationEventDataSchema, s as historyReplacementSchema } from "./history-C84mlAwO.js";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
9
9
|
import { and, asc, desc, eq, gt, gte, inArray, isNull, lt, lte, ne, or, sql } from "drizzle-orm";
|
|
10
10
|
import { destinationSchema, identitySchema, locationSchema, sourceSchema, userSchema } from "@sentry/junior-plugin-api";
|
|
@@ -476,6 +476,15 @@ function identityFromActor(actor) {
|
|
|
476
476
|
metadata: { platform: "web" }
|
|
477
477
|
};
|
|
478
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* Build the identity observation for one runtime actor with the same key the
|
|
481
|
+
* Conversation write path stores. Local and system actors have no user
|
|
482
|
+
* identity.
|
|
483
|
+
*/
|
|
484
|
+
function identityFromRuntimeActor(actor) {
|
|
485
|
+
if (actor.platform === "slack") return identityFromActor(toStoredSlackActor(actor));
|
|
486
|
+
if (actor.platform === "web") return identityFromActor(actor.email ? { email: actor.email } : void 0);
|
|
487
|
+
}
|
|
479
488
|
/** Build a system identity when a conversation has no user actor. */
|
|
480
489
|
function systemIdentityFromSource(source) {
|
|
481
490
|
if (source === "scheduler") return {
|
|
@@ -817,6 +826,8 @@ var SqlStore = class {
|
|
|
817
826
|
const incomingExecutionAt = args.execution.updatedAtMs ?? args.updatedAtMs;
|
|
818
827
|
const incomingIsFresh = incomingExecutionAt >= (existing?.execution.updatedAtMs ?? existing?.updatedAtMs ?? 0);
|
|
819
828
|
const execution = incomingIsFresh ? args.execution : existing?.execution ?? args.execution;
|
|
829
|
+
const actor = mergeActor(existing?.actor, args.actor);
|
|
830
|
+
const source = existing?.source ?? args.source;
|
|
820
831
|
await this.upsertConversation({ conversation: {
|
|
821
832
|
schemaVersion: 1,
|
|
822
833
|
conversationId: args.conversationId,
|
|
@@ -827,8 +838,8 @@ var SqlStore = class {
|
|
|
827
838
|
...existing?.location ? { location: existing.location } : void 0,
|
|
828
839
|
...args.channelName ? { channelName: args.channelName } : void 0,
|
|
829
840
|
...args.destination ? { destination: args.destination } : void 0,
|
|
830
|
-
...
|
|
831
|
-
...
|
|
841
|
+
...actor ? { actor } : void 0,
|
|
842
|
+
...source ? { source } : void 0,
|
|
832
843
|
...args.title ? { title: args.title } : void 0,
|
|
833
844
|
...args.visibility ? { visibility: args.visibility } : void 0,
|
|
834
845
|
execution
|
|
@@ -1630,12 +1641,12 @@ async function listAdminUsersFromSql(db) {
|
|
|
1630
1641
|
}
|
|
1631
1642
|
/** Resolve the stored identity and linked user for one runtime actor. */
|
|
1632
1643
|
async function readActorIdentityFromSql(db, actor) {
|
|
1633
|
-
|
|
1634
|
-
|
|
1644
|
+
const key = identityFromRuntimeActor(actor);
|
|
1645
|
+
if (!key) return void 0;
|
|
1635
1646
|
const row = (await db.select({
|
|
1636
1647
|
identity: juniorIdentities,
|
|
1637
1648
|
user: juniorUsers
|
|
1638
|
-
}).from(juniorIdentities).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(eq(juniorIdentities.kind, "user"), eq(juniorIdentities.provider,
|
|
1649
|
+
}).from(juniorIdentities).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(eq(juniorIdentities.kind, "user"), eq(juniorIdentities.provider, key.provider), eq(juniorIdentities.providerTenantId, key.providerTenantId ?? ""), eq(juniorIdentities.providerSubjectId, key.providerSubjectId))).limit(1))[0];
|
|
1639
1650
|
if (!row) return void 0;
|
|
1640
1651
|
return {
|
|
1641
1652
|
identity: identityFromRow(row.identity),
|
|
@@ -1662,4 +1673,4 @@ async function readIdentityByIdFromSql(db, identityId) {
|
|
|
1662
1673
|
async function readIdentityById(identityId) {
|
|
1663
1674
|
return await readIdentityByIdFromSql(getDb(), identityId);
|
|
1664
1675
|
}
|
|
1665
|
-
export {
|
|
1676
|
+
export { resolveRootConversationId as A, parseDestination as B, bindProviderConversation as C, agentTurnTotalTokens as D, agentTurnCostUsd as E, recordGoogleSignIn as F, sameDestination as H, saveUserTimezone as I, upsertIdentity as L, deleteProviderIdentityForUser as M, findUserByVerifiedEmails as N, agentTurnUsageSchema as O, readUserTimezone as P, upsertLinkedIdentity as R, identityFromActor as S, addAgentTurnUsage as T, requireSlackDestination as V, loadConversationSlackTenantIds as _, resolveViewerUser as a, locationFromRow as b, closeDb as c, getConversationMessageSearchStore as d, getConversationStore as f, withConversationEventLock as g, createSqlConversationEventStore as h, readIdentityById as i, deleteProviderIdentityForSlackUser as j, hasAgentTurnUsage as k, db_exports as l, getSqlExecutor as m, listAdminUsersFromSql as n, setUserAdminFromSql as o, getDb as p, readActorIdentity as r, updateViewerDisplayName as s, findUserByEmail as t, getConversationEventStore as u, createSqlStore as v, parseSessionSource as w, startLocationThread as x, withConversationMutationLock as y, createSlackDestination as z };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import { At as
|
|
3
|
-
import { n as botConfig } from "./config-
|
|
4
|
-
import {
|
|
5
|
-
import { m as sameActorIdentity, u as agentInstructionProvenance } from "./history-
|
|
6
|
-
import {
|
|
7
|
-
import { E as markAgentInvocationSteered, H as TurnInputCommitLostError, K as isTurnInputCommitLostError, L as agentTypeInstructions, O as reportReplacedAgentInvocation, R as agentTypeStartsWithParentHistory, S as markAgentInvocationMailboxAppended, T as markAgentInvocationRunning, W as getConversationTurnBoundaryError, _ as getLatestAgentInvocationForConversation, c as getAgentInvocation, f as getAgentInvocationMessageId, m as getAgentInvocationTurnId, n as completeAgentInvocation, r as createAgentInvocation, s as getActiveAgentInvocationForConversation, w as markAgentInvocationPaused, y as isTerminalAgentInvocation } from "./store-
|
|
8
|
-
import { n as getAssistantReplyText } from "./assistant-reply-
|
|
9
|
-
import {
|
|
10
|
-
import { r as appendAndEnqueueInboundMessage } from "./store-
|
|
11
|
-
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
12
|
-
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-
|
|
2
|
+
import { At as PluginCredentialFailureError, Kt as failTurnRecord, Ln as getTerminalAssistantMessages, Nn as isTurnExecutionLimitExceededError, Pt as AuthorizationFlowDisabledError, Q as openConversationProjection, Ut as saveTurnCheckpoint, Wt as abandonTurnRecord, qt as getTurnRecord } from "./tasks-0ilmuCux.js";
|
|
3
|
+
import { n as botConfig } from "./config-CdB6yJj5.js";
|
|
4
|
+
import { f as getConversationStore, u as getConversationEventStore } from "./viewer-DrN3oC2X.js";
|
|
5
|
+
import { m as sameActorIdentity, u as agentInstructionProvenance } from "./history-C84mlAwO.js";
|
|
6
|
+
import { Q as stopChildAgentsOf, ct as buildSteeringPiMessage, et as recordSubagentEnded, lt as withoutSavedSteeringMessages, pt as readBlockedReport, tt as recordSubagentStarted } from "./agent-runner-DgNATN4D.js";
|
|
7
|
+
import { E as markAgentInvocationSteered, H as TurnInputCommitLostError, K as isTurnInputCommitLostError, L as agentTypeInstructions, O as reportReplacedAgentInvocation, R as agentTypeStartsWithParentHistory, S as markAgentInvocationMailboxAppended, T as markAgentInvocationRunning, W as getConversationTurnBoundaryError, _ as getLatestAgentInvocationForConversation, c as getAgentInvocation, f as getAgentInvocationMessageId, m as getAgentInvocationTurnId, n as completeAgentInvocation, r as createAgentInvocation, s as getActiveAgentInvocationForConversation, w as markAgentInvocationPaused, y as isTerminalAgentInvocation } from "./store-6EetVP-m.js";
|
|
8
|
+
import { n as getAssistantReplyText } from "./assistant-reply-CT7VcXQe.js";
|
|
9
|
+
import { C as maybePostAutomatedTurnLimitNotice, T as resetAutomatedTurnLimit, w as recordFinishedTurnForAutomatedLimit } from "./session-stop-DkOjt46_.js";
|
|
10
|
+
import { r as appendAndEnqueueInboundMessage } from "./store-DvNZIsCr.js";
|
|
11
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-OzLIwvi1.js";
|
|
12
|
+
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-DRmdJ2QN.js";
|
|
13
13
|
import { isDeepStrictEqual } from "node:util";
|
|
14
14
|
import { z } from "zod";
|
|
15
15
|
// src/chat/runtime/turn-execution.ts
|
|
@@ -35,11 +35,16 @@ async function executeTurn(agentRunner, run, saveResult) {
|
|
|
35
35
|
}
|
|
36
36
|
if (outcome.status !== "completed") return outcome;
|
|
37
37
|
const saved = await saveResult(outcome.result);
|
|
38
|
+
await finishTurn(run.conversationId, run.turnId, saved);
|
|
39
|
+
return { status: "completed" };
|
|
40
|
+
}
|
|
41
|
+
/** Record the terminal lifecycle event of a Turn from its saved result. */
|
|
42
|
+
async function finishTurn(conversationId, turnId, saved) {
|
|
38
43
|
const lifecycle = new ConversationTurnLifecycleService(getConversationEventStore());
|
|
39
44
|
const common = {
|
|
40
|
-
conversationId
|
|
45
|
+
conversationId,
|
|
41
46
|
createdAtMs: saved.finishedAtMs ?? Date.now(),
|
|
42
|
-
turnId
|
|
47
|
+
turnId
|
|
43
48
|
};
|
|
44
49
|
if (saved.outcome === "failed") await lifecycle.fail({
|
|
45
50
|
...common,
|
|
@@ -51,7 +56,6 @@ async function executeTurn(agentRunner, run, saveResult) {
|
|
|
51
56
|
...common,
|
|
52
57
|
outcome: saved.outcome
|
|
53
58
|
});
|
|
54
|
-
return { status: "completed" };
|
|
55
59
|
}
|
|
56
60
|
// src/chat/agent-invocations/fork-history.ts
|
|
57
61
|
/**
|
|
@@ -234,32 +238,41 @@ function createAgentMessageSteeringDrain(context, running) {
|
|
|
234
238
|
return accepted;
|
|
235
239
|
};
|
|
236
240
|
}
|
|
237
|
-
/**
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
await abandonTurnRecord({
|
|
251
|
-
conversationId: common.conversationId,
|
|
252
|
-
errorMessage: "Turn cancelled",
|
|
253
|
-
turnId: common.turnId
|
|
254
|
-
});
|
|
255
|
-
await lifecycle.complete({
|
|
256
|
-
...common,
|
|
241
|
+
/**
|
|
242
|
+
* How a terminal agent invocation ends its child Turn. The live save and the
|
|
243
|
+
* recovery paths both use this, so a status cannot end the Turn two ways.
|
|
244
|
+
*/
|
|
245
|
+
function agentInvocationTurnEnd(terminal) {
|
|
246
|
+
const finishedAtMs = terminal.terminalAtMs;
|
|
247
|
+
switch (terminal.status) {
|
|
248
|
+
case "completed": return {
|
|
249
|
+
finishedAtMs,
|
|
250
|
+
outcome: terminal.result.trim() ? "success" : "no_reply"
|
|
251
|
+
};
|
|
252
|
+
case "stopped": return {
|
|
253
|
+
finishedAtMs,
|
|
257
254
|
outcome: "cancelled"
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
255
|
+
};
|
|
256
|
+
case "blocked": return {
|
|
257
|
+
finishedAtMs,
|
|
258
|
+
outcome: "blocked"
|
|
259
|
+
};
|
|
260
|
+
case "failed": return {
|
|
261
|
+
failureCode: "model_execution_failed",
|
|
262
|
+
finishedAtMs,
|
|
263
|
+
outcome: "failed"
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/** Project the terminal invocation into the idempotent turn lifecycle. */
|
|
268
|
+
async function persistTerminalLifecycle(terminal) {
|
|
269
|
+
const turnId = getAgentInvocationTurnId(terminal.invocationId);
|
|
270
|
+
if (terminal.status === "stopped") await abandonTurnRecord({
|
|
271
|
+
conversationId: terminal.childConversationId,
|
|
272
|
+
errorMessage: "Turn cancelled",
|
|
273
|
+
turnId
|
|
262
274
|
});
|
|
275
|
+
await finishTurn(terminal.childConversationId, turnId, agentInvocationTurnEnd(terminal));
|
|
263
276
|
}
|
|
264
277
|
/** Stop an invocation whose worker died, or project its terminal turn result. */
|
|
265
278
|
async function projectTerminalTurn(invocation) {
|
|
@@ -345,19 +358,7 @@ async function saveAgentInvocationResult(args) {
|
|
|
345
358
|
}
|
|
346
359
|
});
|
|
347
360
|
if (!terminal || !isTerminalAgentInvocation(terminal)) throw new Error(`Agent invocation did not finish for ${args.invocation.invocationId}`);
|
|
348
|
-
|
|
349
|
-
finishedAtMs: terminal.terminalAtMs,
|
|
350
|
-
outcome: terminal.result.trim() ? "success" : "no_reply"
|
|
351
|
-
};
|
|
352
|
-
if (terminal.status === "stopped") return {
|
|
353
|
-
finishedAtMs: terminal.terminalAtMs,
|
|
354
|
-
outcome: "cancelled"
|
|
355
|
-
};
|
|
356
|
-
return {
|
|
357
|
-
finishedAtMs: terminal.terminalAtMs,
|
|
358
|
-
failureCode: "model_execution_failed",
|
|
359
|
-
outcome: "failed"
|
|
360
|
-
};
|
|
361
|
+
return agentInvocationTurnEnd(terminal);
|
|
361
362
|
}
|
|
362
363
|
/**
|
|
363
364
|
* Read how many parents a child Conversation has and the root Conversation's
|
|
@@ -1,34 +1,45 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
|
10
|
-
processConversationWork: () => processConversationWork
|
|
11
|
-
});
|
|
12
|
-
const CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
|
|
13
|
-
const CONVERSATION_STOP_CHECK_INTERVAL_MS = 500;
|
|
14
|
-
function now(options) {
|
|
15
|
-
return options.nowMs?.() ?? Date.now();
|
|
16
|
-
}
|
|
2
|
+
import { fn as hasConversationStop, hn as isInvalidConversationRecordError, mn as isFinalAttempt } from "./tasks-0ilmuCux.js";
|
|
3
|
+
import { y as isProviderRetryError } from "./client-BjgbMawj.js";
|
|
4
|
+
import { i as getChatConfig } from "./config-CdB6yJj5.js";
|
|
5
|
+
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-DuZ1A4ab.js";
|
|
6
|
+
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-C0BZSa7r.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-DvNZIsCr.js";
|
|
8
|
+
// src/chat/task-execution/attempt-selection.ts
|
|
17
9
|
function selectContiguousTurnBatch(messages) {
|
|
18
10
|
const first = messages[0];
|
|
19
11
|
if (!first) return [];
|
|
20
12
|
const nextTurnIndex = messages.findIndex((message) => message.input.authorId !== first.input.authorId || message.source !== first.source);
|
|
21
13
|
return messages.slice(0, nextTurnIndex === -1 ? messages.length : nextTurnIndex);
|
|
22
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* True when an interrupt can start its own attempt.
|
|
17
|
+
*
|
|
18
|
+
* A steered web message must not start a second Turn while a yielded Turn
|
|
19
|
+
* waits to resume. It stays pending for that Turn's drain or the next attempt.
|
|
20
|
+
*/
|
|
21
|
+
function isAttemptInterrupt(message, work) {
|
|
22
|
+
return message.delivery === "interrupt" && !(work.execution.status === "paused" && message.source === "web");
|
|
23
|
+
}
|
|
23
24
|
/** Prioritize interrupts while keeping each attempt to one Actor and Source. */
|
|
24
25
|
function selectAttemptMessages(work) {
|
|
25
26
|
const messages = work.messages;
|
|
26
|
-
const interrupts = messages.filter((message) => message
|
|
27
|
+
const interrupts = messages.filter((message) => isAttemptInterrupt(message, work));
|
|
27
28
|
if (interrupts.length > 0) return selectContiguousTurnBatch(interrupts);
|
|
28
29
|
if (work.execution.status === "paused") return [];
|
|
29
30
|
const nonEventMessages = messages.filter((message) => message.source !== "event");
|
|
30
31
|
return selectContiguousTurnBatch(nonEventMessages.length > 0 ? nonEventMessages : messages);
|
|
31
32
|
}
|
|
33
|
+
// src/chat/task-execution/worker.ts
|
|
34
|
+
var worker_exports = /* @__PURE__ */ __exportAll({
|
|
35
|
+
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
|
36
|
+
processConversationWork: () => processConversationWork
|
|
37
|
+
});
|
|
38
|
+
const CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
|
|
39
|
+
const CONVERSATION_STOP_CHECK_INTERVAL_MS = 500;
|
|
40
|
+
function now(options) {
|
|
41
|
+
return options.nowMs?.() ?? Date.now();
|
|
42
|
+
}
|
|
32
43
|
function nudgeIdempotencyKey(reason, conversationId, nowMs) {
|
|
33
44
|
return `${reason}:${conversationId}:${nowMs}`;
|
|
34
45
|
}
|
|
@@ -248,7 +259,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
248
259
|
const softYieldDeadlineMs = startedAtMs + (options.softYieldAfterMs ?? getChatConfig().conversationWorkSoftYieldAfterMs);
|
|
249
260
|
let attemptMessageIds = [];
|
|
250
261
|
let attemptSelectedMessageIds = /* @__PURE__ */ new Set();
|
|
251
|
-
let
|
|
262
|
+
let attemptStartInterruptIds = /* @__PURE__ */ new Set();
|
|
252
263
|
let failedWithoutProgress = false;
|
|
253
264
|
let leaseLost = false;
|
|
254
265
|
const markLeaseLost = () => {
|
|
@@ -269,7 +280,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
269
280
|
leaseToken: lease.leaseToken,
|
|
270
281
|
conversationStore: options.conversationStore,
|
|
271
282
|
handle: async (messages) => {
|
|
272
|
-
const candidates = drainOptions?.deferred ? messages : messages.filter((message) => message.delivery === "interrupt" && (attemptSelectedMessageIds.has(message.inboundMessageId) || !
|
|
283
|
+
const candidates = drainOptions?.deferred ? messages : messages.filter((message) => message.delivery === "interrupt" && (attemptSelectedMessageIds.has(message.inboundMessageId) || !attemptStartInterruptIds.has(message.inboundMessageId)));
|
|
273
284
|
if (candidates.length === 0) return [];
|
|
274
285
|
return await handle(candidates) ?? candidates.map((message) => message.inboundMessageId);
|
|
275
286
|
},
|
|
@@ -337,7 +348,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
337
348
|
const attemptMessages = selectAttemptMessages(leasedWork);
|
|
338
349
|
const runId = leasedWork.execution.runId;
|
|
339
350
|
if (!runId) throw new Error(`Conversation run is missing for ${conversationId}`);
|
|
340
|
-
|
|
351
|
+
attemptStartInterruptIds = new Set(leasedWork.messages.filter((message) => isAttemptInterrupt(message, leasedWork)).map((message) => message.inboundMessageId));
|
|
341
352
|
if (hasRun && shouldYield()) {
|
|
342
353
|
if (resumePending) return await yieldWork();
|
|
343
354
|
break;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
ALTER TABLE "junior_automations" DROP CONSTRAINT "junior_automations_trigger_check";--> statement-breakpoint
|
|
2
|
+
ALTER TABLE "junior_automations" ADD CONSTRAINT "junior_automations_trigger_check" CHECK (("junior_automations"."kind" = 'scheduled' and "junior_automations"."namespace" is null and "junior_automations"."identifier" is null) or ("junior_automations"."kind" = 'event' and "junior_automations"."namespace" is not null and "junior_automations"."next_run_at_ms" is null and "junior_automations"."run_now_at_ms" is null and "junior_automations"."status" <> 'completed'));
|