@sentry/junior 0.84.1 → 0.86.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-TFPY6V3T.js → agent-hooks-NWOUB3UR.js} +7 -7
- package/dist/app.js +916 -363
- package/dist/chat/conversation-privacy.d.ts +12 -2
- package/dist/chat/conversations/sql/migrations.d.ts +1 -1
- package/dist/chat/conversations/sql/store.d.ts +9 -1
- package/dist/chat/conversations/store.d.ts +13 -0
- package/dist/chat/current-instruction.d.ts +6 -0
- package/dist/chat/ingress/message-changed.d.ts +2 -0
- package/dist/chat/respond-helpers.d.ts +1 -2
- package/dist/chat/respond.d.ts +7 -1
- package/dist/chat/runtime/reply-executor.d.ts +2 -10
- package/dist/chat/runtime/slack-runtime.d.ts +5 -4
- package/dist/chat/runtime/turn.d.ts +7 -0
- package/dist/chat/services/persist-retry.d.ts +2 -0
- package/dist/chat/services/turn-session-record.d.ts +31 -2
- package/dist/chat/slack/client.d.ts +33 -2
- package/dist/chat/slack/conversation-context.d.ts +15 -0
- package/dist/chat/state/turn-session.d.ts +9 -0
- package/dist/chat/task-execution/queue.d.ts +1 -1
- package/dist/chat/task-execution/slack-work.d.ts +10 -2
- package/dist/chat/task-execution/state.d.ts +44 -4
- package/dist/chat/task-execution/store.d.ts +21 -4
- package/dist/chat/task-execution/worker.d.ts +11 -4
- package/dist/chat/tools/slack/channel-access.d.ts +29 -0
- package/dist/chat/tools/slack/thread-read.d.ts +4 -1
- package/dist/{chunk-AL6ZFV7U.js → chunk-2NFV5FMB.js} +4 -4
- package/dist/{chunk-JK7376UT.js → chunk-37B2R2QJ.js} +17 -17
- package/dist/{chunk-QWKB6NJV.js → chunk-6I6HBOQM.js} +80 -15
- package/dist/{chunk-SBYMRDH7.js → chunk-6O5UI3RG.js} +1 -1
- package/dist/{chunk-CWMMGUWM.js → chunk-BRSQQRG6.js} +1 -1
- package/dist/{chunk-FPN7NYTE.js → chunk-ENPSU7L7.js} +165 -27
- package/dist/{chunk-T2YRJZ5A.js → chunk-FPHA6GCQ.js} +905 -711
- package/dist/{chunk-MJ4E2PK7.js → chunk-GB5DFM4D.js} +1 -1
- package/dist/{chunk-BAPRSWNW.js → chunk-GGD6WK6V.js} +124 -25
- package/dist/{chunk-SVFA43LT.js → chunk-JRXCSSSU.js} +19 -4
- package/dist/{chunk-DR75T7J3.js → chunk-L7OHKDOX.js} +9 -5
- package/dist/{chunk-LSG6PQF4.js → chunk-RIB3M6YA.js} +2 -2
- package/dist/{chunk-ALL7GG6U.js → chunk-ZU2ALUVQ.js} +45 -6
- package/dist/cli/chat.js +4 -4
- package/dist/cli/plugins.js +7 -7
- package/dist/cli/snapshot-warmup.js +4 -4
- package/dist/cli/upgrade.js +10 -7
- package/dist/{db-ELRCNB4A.js → db-SZVUU7RB.js} +4 -4
- package/dist/handlers/github-webhook/issue-comment.d.ts +3 -0
- package/dist/handlers/github-webhook/pull-request-review-comment.d.ts +3 -0
- package/dist/instrumentation.js +1 -1
- package/dist/nitro.js +4 -4
- package/dist/reporting/conversations.d.ts +2 -1
- package/dist/reporting.js +110 -34
- package/dist/{runner-2XU6QQND.js → runner-HEBRPNN2.js} +27 -13
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSlackBotToken
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZU2ALUVQ.js";
|
|
4
4
|
import {
|
|
5
5
|
isSlackConversationId,
|
|
6
6
|
isSlackTeamId,
|
|
@@ -11,7 +11,21 @@ import {
|
|
|
11
11
|
} from "./chunk-KF7522P3.js";
|
|
12
12
|
|
|
13
13
|
// src/chat/slack/client.ts
|
|
14
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
14
15
|
import { WebClient } from "@slack/web-api";
|
|
16
|
+
|
|
17
|
+
// src/chat/slack/workspace-context.ts
|
|
18
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
19
|
+
var workspaceTeamIdStorage = new AsyncLocalStorage();
|
|
20
|
+
function runWithWorkspaceTeamId(teamId, fn) {
|
|
21
|
+
if (!teamId) return fn();
|
|
22
|
+
return workspaceTeamIdStorage.run(teamId, fn);
|
|
23
|
+
}
|
|
24
|
+
function getWorkspaceTeamId() {
|
|
25
|
+
return workspaceTeamIdStorage.getStore();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/chat/slack/client.ts
|
|
15
29
|
var SlackActionError = class extends Error {
|
|
16
30
|
code;
|
|
17
31
|
apiError;
|
|
@@ -98,7 +112,39 @@ function parseSlackCanvasDetail(detail) {
|
|
|
98
112
|
}
|
|
99
113
|
return parsed;
|
|
100
114
|
}
|
|
101
|
-
var
|
|
115
|
+
var installationTokenStorage = new AsyncLocalStorage2();
|
|
116
|
+
var clientsByToken = /* @__PURE__ */ new Map();
|
|
117
|
+
function runWithSlackInstallationToken(token, fn) {
|
|
118
|
+
const trimmed = token.trim();
|
|
119
|
+
if (!trimmed) {
|
|
120
|
+
throw new SlackActionError(
|
|
121
|
+
"Slack installation token binding requires a non-empty token",
|
|
122
|
+
"missing_token"
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return installationTokenStorage.run({ token: trimmed }, fn);
|
|
126
|
+
}
|
|
127
|
+
function resolveSlackToken() {
|
|
128
|
+
const ambientToken = installationTokenStorage.getStore()?.token;
|
|
129
|
+
if (ambientToken) {
|
|
130
|
+
return ambientToken;
|
|
131
|
+
}
|
|
132
|
+
const envToken = getSlackBotToken();
|
|
133
|
+
if (envToken) {
|
|
134
|
+
return envToken;
|
|
135
|
+
}
|
|
136
|
+
const teamId = getWorkspaceTeamId();
|
|
137
|
+
if (teamId) {
|
|
138
|
+
throw new SlackActionError(
|
|
139
|
+
`Slack call is scoped to workspace ${teamId} but no installation token is bound and no default bot token is configured`,
|
|
140
|
+
"missing_token"
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
throw new SlackActionError(
|
|
144
|
+
"SLACK_BOT_TOKEN (or SLACK_BOT_USER_TOKEN) is required for Slack Web API actions in this service",
|
|
145
|
+
"missing_token"
|
|
146
|
+
);
|
|
147
|
+
}
|
|
102
148
|
function normalizeSlackConversationId(channelId) {
|
|
103
149
|
if (!channelId) return void 0;
|
|
104
150
|
const trimmed = channelId.trim();
|
|
@@ -110,16 +156,16 @@ function normalizeSlackConversationId(channelId) {
|
|
|
110
156
|
return parts[1]?.trim() || void 0;
|
|
111
157
|
}
|
|
112
158
|
function getClient() {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (!
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
);
|
|
159
|
+
const token = resolveSlackToken();
|
|
160
|
+
let cached = clientsByToken.get(token);
|
|
161
|
+
if (!cached) {
|
|
162
|
+
cached = new WebClient(token, {
|
|
163
|
+
retryConfig: { retries: 0 },
|
|
164
|
+
rejectRateLimitedCalls: true
|
|
165
|
+
});
|
|
166
|
+
clientsByToken.set(token, cached);
|
|
120
167
|
}
|
|
121
|
-
|
|
122
|
-
return client;
|
|
168
|
+
return cached;
|
|
123
169
|
}
|
|
124
170
|
function mapSlackError(error) {
|
|
125
171
|
if (error instanceof SlackActionError) {
|
|
@@ -186,8 +232,54 @@ function mapSlackError(error) {
|
|
|
186
232
|
function sleep(ms) {
|
|
187
233
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
188
234
|
}
|
|
235
|
+
var MAX_RETRY_DELAY_MS = 1e4;
|
|
236
|
+
var MAX_TOTAL_RETRY_DELAY_MS = 2e4;
|
|
237
|
+
var CONNECTION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
238
|
+
"ECONNREFUSED",
|
|
239
|
+
"ECONNRESET",
|
|
240
|
+
"ENOTFOUND",
|
|
241
|
+
"EAI_AGAIN"
|
|
242
|
+
]);
|
|
243
|
+
var TIMEOUT_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
244
|
+
"ETIMEDOUT",
|
|
245
|
+
"ECONNABORTED",
|
|
246
|
+
"ESOCKETTIMEDOUT"
|
|
247
|
+
]);
|
|
248
|
+
function findNetworkErrorCode(error, depth = 0) {
|
|
249
|
+
if (!error || typeof error !== "object" || depth > 4) {
|
|
250
|
+
return void 0;
|
|
251
|
+
}
|
|
252
|
+
const candidate = error;
|
|
253
|
+
if (typeof candidate.code === "string" && (CONNECTION_ERROR_CODES.has(candidate.code) || TIMEOUT_ERROR_CODES.has(candidate.code))) {
|
|
254
|
+
return candidate.code;
|
|
255
|
+
}
|
|
256
|
+
return findNetworkErrorCode(candidate.original, depth + 1) ?? findNetworkErrorCode(candidate.cause, depth + 1);
|
|
257
|
+
}
|
|
258
|
+
function hasSocketHangUpMessage(error) {
|
|
259
|
+
return error instanceof Error && error.message.toLowerCase().includes("socket hang up");
|
|
260
|
+
}
|
|
261
|
+
function classifySlackRetry(raw, mapped) {
|
|
262
|
+
if (mapped.code === "rate_limited") {
|
|
263
|
+
return "rate_limited";
|
|
264
|
+
}
|
|
265
|
+
if (mapped.statusCode !== void 0 && mapped.statusCode >= 500) {
|
|
266
|
+
return "server_error";
|
|
267
|
+
}
|
|
268
|
+
const networkCode = findNetworkErrorCode(raw);
|
|
269
|
+
if (networkCode && CONNECTION_ERROR_CODES.has(networkCode)) {
|
|
270
|
+
return "connection";
|
|
271
|
+
}
|
|
272
|
+
if (networkCode && TIMEOUT_ERROR_CODES.has(networkCode)) {
|
|
273
|
+
return "timeout";
|
|
274
|
+
}
|
|
275
|
+
if (hasSocketHangUpMessage(raw)) {
|
|
276
|
+
return "connection";
|
|
277
|
+
}
|
|
278
|
+
return "none";
|
|
279
|
+
}
|
|
189
280
|
async function withSlackRetries(task, maxAttempts = 3, context = {}) {
|
|
190
281
|
let attempt = 0;
|
|
282
|
+
let totalDelayMs = 0;
|
|
191
283
|
const action = context.action ?? "unknown";
|
|
192
284
|
while (attempt < maxAttempts) {
|
|
193
285
|
attempt += 1;
|
|
@@ -235,7 +327,9 @@ async function withSlackRetries(task, maxAttempts = 3, context = {}) {
|
|
|
235
327
|
);
|
|
236
328
|
} catch (error) {
|
|
237
329
|
const mapped = mapSlackError(error);
|
|
238
|
-
const
|
|
330
|
+
const retryClass = classifySlackRetry(error, mapped);
|
|
331
|
+
const isRetryable = retryClass === "rate_limited" || retryClass === "connection" || retryClass === "server_error" || retryClass === "timeout" && context.idempotent === true;
|
|
332
|
+
const remainingDelayBudgetMs = MAX_TOTAL_RETRY_DELAY_MS - totalDelayMs;
|
|
239
333
|
const baseLogAttributes = {
|
|
240
334
|
"app.slack.action": action,
|
|
241
335
|
"app.slack.error_code": mapped.code,
|
|
@@ -247,7 +341,7 @@ async function withSlackRetries(task, maxAttempts = 3, context = {}) {
|
|
|
247
341
|
...mapped.statusCode !== void 0 ? { "http.response.status_code": mapped.statusCode } : {},
|
|
248
342
|
...context.attributes ?? {}
|
|
249
343
|
};
|
|
250
|
-
if (!isRetryable || attempt >= maxAttempts) {
|
|
344
|
+
if (!isRetryable || attempt >= maxAttempts || remainingDelayBudgetMs <= 0) {
|
|
251
345
|
logWarn(
|
|
252
346
|
"slack_action_failed",
|
|
253
347
|
{},
|
|
@@ -264,13 +358,20 @@ async function withSlackRetries(task, maxAttempts = 3, context = {}) {
|
|
|
264
358
|
{},
|
|
265
359
|
{
|
|
266
360
|
...baseLogAttributes,
|
|
267
|
-
"app.slack.retry_attempt": attempt
|
|
361
|
+
"app.slack.retry_attempt": attempt,
|
|
362
|
+
"app.slack.retry_class": retryClass
|
|
268
363
|
},
|
|
269
364
|
"Retrying Slack action after transient failure"
|
|
270
365
|
);
|
|
271
|
-
const retryAfterMs =
|
|
366
|
+
const retryAfterMs = retryClass === "rate_limited" && mapped.retryAfterSeconds && mapped.retryAfterSeconds > 0 ? mapped.retryAfterSeconds * 1e3 : void 0;
|
|
272
367
|
const backoffMs = Math.min(2e3, 250 * 2 ** (attempt - 1));
|
|
273
|
-
|
|
368
|
+
const delayMs = Math.min(
|
|
369
|
+
retryAfterMs ?? backoffMs,
|
|
370
|
+
MAX_RETRY_DELAY_MS,
|
|
371
|
+
remainingDelayBudgetMs
|
|
372
|
+
);
|
|
373
|
+
totalDelayMs += delayMs;
|
|
374
|
+
await sleep(delayMs);
|
|
274
375
|
}
|
|
275
376
|
}
|
|
276
377
|
throw new SlackActionError(
|
|
@@ -296,27 +397,22 @@ function isConversationChannel(channelId) {
|
|
|
296
397
|
return normalized.startsWith("C") || normalized.startsWith("G");
|
|
297
398
|
}
|
|
298
399
|
async function getFilePermalink(fileId) {
|
|
299
|
-
const
|
|
400
|
+
const client = getClient();
|
|
300
401
|
const response = await withSlackRetries(
|
|
301
|
-
() =>
|
|
402
|
+
() => client.files.info({
|
|
302
403
|
file: fileId
|
|
303
404
|
}),
|
|
304
405
|
3,
|
|
305
406
|
{
|
|
306
407
|
action: "files.info",
|
|
408
|
+
idempotent: true,
|
|
307
409
|
spanAttributes: { "app.slack.file_id": fileId }
|
|
308
410
|
}
|
|
309
411
|
);
|
|
310
412
|
return response.file?.permalink;
|
|
311
413
|
}
|
|
312
414
|
async function downloadPrivateSlackFile(url) {
|
|
313
|
-
const token =
|
|
314
|
-
if (!token) {
|
|
315
|
-
throw new SlackActionError(
|
|
316
|
-
"SLACK_BOT_TOKEN (or SLACK_BOT_USER_TOKEN) is required for Slack file downloads in this service",
|
|
317
|
-
"missing_token"
|
|
318
|
-
);
|
|
319
|
-
}
|
|
415
|
+
const token = resolveSlackToken();
|
|
320
416
|
return withSpan(
|
|
321
417
|
"GET files.slack.com",
|
|
322
418
|
"http.client",
|
|
@@ -389,8 +485,11 @@ function destinationKey(destination) {
|
|
|
389
485
|
}
|
|
390
486
|
|
|
391
487
|
export {
|
|
488
|
+
runWithWorkspaceTeamId,
|
|
489
|
+
getWorkspaceTeamId,
|
|
392
490
|
SlackActionError,
|
|
393
491
|
getHeaderString,
|
|
492
|
+
runWithSlackInstallationToken,
|
|
394
493
|
normalizeSlackConversationId,
|
|
395
494
|
withSlackRetries,
|
|
396
495
|
getSlackClient,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getStateAdapter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GB5DFM4D.js";
|
|
4
4
|
import {
|
|
5
5
|
normalizeSlackConversationId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GGD6WK6V.js";
|
|
7
7
|
import {
|
|
8
8
|
parseSlackThreadId
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-L7OHKDOX.js";
|
|
10
10
|
import {
|
|
11
11
|
parseStoredSlackRequester
|
|
12
12
|
} from "./chunk-IXTBFABZ.js";
|
|
@@ -114,6 +114,18 @@ function toSlackEventChannelType(channelType) {
|
|
|
114
114
|
}
|
|
115
115
|
return void 0;
|
|
116
116
|
}
|
|
117
|
+
function conversationVisibilityFromSlackChannelType(channelType) {
|
|
118
|
+
if (!channelType) return void 0;
|
|
119
|
+
return channelType === "channel" ? "public" : "private";
|
|
120
|
+
}
|
|
121
|
+
function visibilityFromChannelIdPrefix(channelId) {
|
|
122
|
+
const normalized = normalizeSlackConversationId(channelId);
|
|
123
|
+
if (!normalized) return void 0;
|
|
124
|
+
if (normalized.startsWith("D") || normalized.startsWith("G")) {
|
|
125
|
+
return "private";
|
|
126
|
+
}
|
|
127
|
+
return void 0;
|
|
128
|
+
}
|
|
117
129
|
function resolveSlackChannelTypeFromMessage(message) {
|
|
118
130
|
const raw = message.raw;
|
|
119
131
|
if (!raw || typeof raw !== "object") {
|
|
@@ -126,9 +138,11 @@ function resolveSlackConversationContext(input) {
|
|
|
126
138
|
const type = typeFromSlackChannelType(input.channelType) ?? typeFromChannelId(input.channelId, input.channelName);
|
|
127
139
|
if (!type) return void 0;
|
|
128
140
|
const name = normalizeConversationName(type, input.channelName);
|
|
141
|
+
const visibility = conversationVisibilityFromSlackChannelType(input.channelType) ?? visibilityFromChannelIdPrefix(input.channelId);
|
|
129
142
|
return {
|
|
130
143
|
type,
|
|
131
|
-
...name ? { name } : {}
|
|
144
|
+
...name ? { name } : {},
|
|
145
|
+
...visibility ? { visibility } : {}
|
|
132
146
|
};
|
|
133
147
|
}
|
|
134
148
|
function resolveSlackConversationContextFromThreadId(input) {
|
|
@@ -264,6 +278,7 @@ export {
|
|
|
264
278
|
GET,
|
|
265
279
|
buildSentryConversationUrl,
|
|
266
280
|
buildSentryTraceUrl,
|
|
281
|
+
conversationVisibilityFromSlackChannelType,
|
|
267
282
|
resolveSlackChannelTypeFromMessage,
|
|
268
283
|
resolveSlackConversationContext,
|
|
269
284
|
resolveSlackConversationContextFromThreadId,
|
|
@@ -52,21 +52,25 @@ function resolveSlackChannelIdFromMessage(message) {
|
|
|
52
52
|
import { AsyncLocalStorage } from "async_hooks";
|
|
53
53
|
var SAFE_METADATA_KEY_LIMIT = 20;
|
|
54
54
|
var conversationPrivacyStorage = new AsyncLocalStorage();
|
|
55
|
-
function
|
|
55
|
+
function privateNarrowingFromChannelId(channelId) {
|
|
56
56
|
const normalized = channelId?.trim();
|
|
57
57
|
if (!normalized) return void 0;
|
|
58
|
-
return normalized.startsWith("
|
|
58
|
+
return normalized.startsWith("D") || normalized.startsWith("G") ? "private" : void 0;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function privateNarrowingFromConversationId(conversationId) {
|
|
61
61
|
if (!conversationId?.trim()) return void 0;
|
|
62
62
|
const slackThread = parseSlackThreadId(conversationId);
|
|
63
63
|
if (slackThread) {
|
|
64
|
-
return
|
|
64
|
+
return privateNarrowingFromChannelId(slackThread.channelId);
|
|
65
65
|
}
|
|
66
66
|
return "private";
|
|
67
67
|
}
|
|
68
68
|
function resolveConversationPrivacy(input) {
|
|
69
|
-
|
|
69
|
+
const narrowed = privateNarrowingFromChannelId(input.channelId) ?? privateNarrowingFromConversationId(input.conversationId);
|
|
70
|
+
if (narrowed === "private") {
|
|
71
|
+
return "private";
|
|
72
|
+
}
|
|
73
|
+
return input.visibility;
|
|
70
74
|
}
|
|
71
75
|
function canExposeConversationPayload(input) {
|
|
72
76
|
return resolveConversationPrivacy(input) === "public";
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-G3E7SCME.js";
|
|
4
4
|
import {
|
|
5
5
|
getStateAdapter
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GB5DFM4D.js";
|
|
7
7
|
import {
|
|
8
8
|
toOptionalTrimmed
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZU2ALUVQ.js";
|
|
10
10
|
import {
|
|
11
11
|
pluginCatalogRuntime
|
|
12
12
|
} from "./chunk-BQ3ITJA6.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getCurrentConversationPrivacy,
|
|
2
3
|
resolveConversationPrivacy,
|
|
3
4
|
toGenAiMessageMetadata,
|
|
4
5
|
toGenAiMessagesTraceAttributes,
|
|
5
6
|
toGenAiTextMetadata
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-L7OHKDOX.js";
|
|
7
8
|
import {
|
|
8
9
|
extractGenAiUsageAttributes,
|
|
9
10
|
logException,
|
|
@@ -13,6 +14,41 @@ import {
|
|
|
13
14
|
withSpan
|
|
14
15
|
} from "./chunk-KF7522P3.js";
|
|
15
16
|
|
|
17
|
+
// src/chat/xml.ts
|
|
18
|
+
function escapeXml(value) {
|
|
19
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/chat/current-instruction.ts
|
|
23
|
+
var CURRENT_INSTRUCTION_TAG = "current-instruction";
|
|
24
|
+
var CURRENT_INSTRUCTION_PATTERN = new RegExp(
|
|
25
|
+
`<${CURRENT_INSTRUCTION_TAG}>\\n([\\s\\S]*?)\\n</${CURRENT_INSTRUCTION_TAG}>`
|
|
26
|
+
);
|
|
27
|
+
var STANDALONE_CURRENT_INSTRUCTION_PATTERN = new RegExp(
|
|
28
|
+
`^<${CURRENT_INSTRUCTION_TAG}>\\n([\\s\\S]*?)\\n</${CURRENT_INSTRUCTION_TAG}>$`
|
|
29
|
+
);
|
|
30
|
+
function unescapeXml(value) {
|
|
31
|
+
return value.replaceAll(""", '"').replaceAll("'", "'").replaceAll(">", ">").replaceAll("<", "<").replaceAll("&", "&");
|
|
32
|
+
}
|
|
33
|
+
function renderCurrentInstruction(instruction) {
|
|
34
|
+
return [
|
|
35
|
+
`<${CURRENT_INSTRUCTION_TAG}>`,
|
|
36
|
+
escapeXml(instruction),
|
|
37
|
+
`</${CURRENT_INSTRUCTION_TAG}>`
|
|
38
|
+
].join("\n");
|
|
39
|
+
}
|
|
40
|
+
function extractCurrentInstructionBody(text) {
|
|
41
|
+
const match = text.match(STANDALONE_CURRENT_INSTRUCTION_PATTERN);
|
|
42
|
+
return match?.[1];
|
|
43
|
+
}
|
|
44
|
+
function unwrapCurrentInstruction(text) {
|
|
45
|
+
const match = text.match(CURRENT_INSTRUCTION_PATTERN);
|
|
46
|
+
if (!match) {
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
return unescapeXml(match[1]);
|
|
50
|
+
}
|
|
51
|
+
|
|
16
52
|
// src/chat/turn-context-tag.ts
|
|
17
53
|
var TURN_CONTEXT_TAG = "runtime-turn-context";
|
|
18
54
|
|
|
@@ -109,15 +145,14 @@ function renderThreadContextForPrompt(context) {
|
|
|
109
145
|
}
|
|
110
146
|
function buildUserTurnText(userInput, conversationContext) {
|
|
111
147
|
const trimmedContext = conversationContext?.trim();
|
|
148
|
+
const currentInstruction = renderCurrentInstruction(userInput);
|
|
112
149
|
if (!trimmedContext) {
|
|
113
|
-
return
|
|
150
|
+
return currentInstruction;
|
|
114
151
|
}
|
|
115
152
|
return [
|
|
116
153
|
renderThreadContextForPrompt(trimmedContext),
|
|
117
154
|
"",
|
|
118
|
-
|
|
119
|
-
userInput,
|
|
120
|
-
"</current-instruction>"
|
|
155
|
+
currentInstruction
|
|
121
156
|
].join("\n");
|
|
122
157
|
}
|
|
123
158
|
function encodeNonImageAttachmentForPrompt(attachment) {
|
|
@@ -344,7 +379,7 @@ async function completeText(params) {
|
|
|
344
379
|
const privacy = resolveConversationPrivacy({
|
|
345
380
|
channelId: typeof params.metadata?.channelId === "string" ? params.metadata.channelId : void 0,
|
|
346
381
|
conversationId: typeof params.metadata?.conversationId === "string" ? params.metadata.conversationId : typeof params.metadata?.threadId === "string" ? params.metadata.threadId : void 0
|
|
347
|
-
});
|
|
382
|
+
}) ?? getCurrentConversationPrivacy();
|
|
348
383
|
const effectivePrivacy = privacy ?? "private";
|
|
349
384
|
const messageAttributeMode = params.messageAttributeMode ?? (effectivePrivacy === "public" ? "content" : "metadata");
|
|
350
385
|
const requestMessagesAttribute = serializeGenAiAttribute(
|
|
@@ -857,6 +892,10 @@ function setSlackReactionConfig(overrides) {
|
|
|
857
892
|
|
|
858
893
|
export {
|
|
859
894
|
toOptionalTrimmed,
|
|
895
|
+
escapeXml,
|
|
896
|
+
renderCurrentInstruction,
|
|
897
|
+
extractCurrentInstructionBody,
|
|
898
|
+
unwrapCurrentInstruction,
|
|
860
899
|
TURN_CONTEXT_TAG,
|
|
861
900
|
getSessionIdentifiers,
|
|
862
901
|
isExecutionEscapeResponse,
|
package/dist/cli/chat.js
CHANGED
|
@@ -130,10 +130,10 @@ async function configureLocalChatPlugins(pluginSet) {
|
|
|
130
130
|
databaseModule
|
|
131
131
|
] = await Promise.all([
|
|
132
132
|
import("../plugins-PZMDS7AT.js"),
|
|
133
|
-
import("../agent-hooks-
|
|
133
|
+
import("../agent-hooks-NWOUB3UR.js"),
|
|
134
134
|
import("../catalog-runtime-XOD7YPRS.js"),
|
|
135
135
|
import("../validation-MBNJKWPQ.js"),
|
|
136
|
-
import("../db-
|
|
136
|
+
import("../db-SZVUU7RB.js")
|
|
137
137
|
]);
|
|
138
138
|
const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
|
|
139
139
|
const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
|
|
@@ -195,7 +195,7 @@ async function runPrompt(options, io, pluginSet) {
|
|
|
195
195
|
defaultStateAdapterForLocalChat();
|
|
196
196
|
await configureLocalChatPlugins(pluginSet);
|
|
197
197
|
const conversationId = newRunConversationId();
|
|
198
|
-
const { runLocalAgentTurn } = await import("../runner-
|
|
198
|
+
const { runLocalAgentTurn } = await import("../runner-HEBRPNN2.js");
|
|
199
199
|
const result = await runLocalAgentTurn(
|
|
200
200
|
{
|
|
201
201
|
conversationId,
|
|
@@ -219,7 +219,7 @@ async function runInteractive(io, pluginSet) {
|
|
|
219
219
|
defaultStateAdapterForLocalChat();
|
|
220
220
|
await configureLocalChatPlugins(pluginSet);
|
|
221
221
|
const conversationId = newRunConversationId();
|
|
222
|
-
const { runLocalAgentTurn } = await import("../runner-
|
|
222
|
+
const { runLocalAgentTurn } = await import("../runner-HEBRPNN2.js");
|
|
223
223
|
const rl = readline.createInterface({
|
|
224
224
|
input: io.input,
|
|
225
225
|
output: io.output,
|
package/dist/cli/plugins.js
CHANGED
|
@@ -10,18 +10,18 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
setPlugins,
|
|
12
12
|
validatePlugins
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-2NFV5FMB.js";
|
|
14
14
|
import {
|
|
15
15
|
createPluginLogger
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-BRSQQRG6.js";
|
|
17
17
|
import {
|
|
18
18
|
getDb
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-6I6HBOQM.js";
|
|
20
20
|
import "../chunk-G3E7SCME.js";
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
21
|
+
import "../chunk-GB5DFM4D.js";
|
|
22
|
+
import "../chunk-GGD6WK6V.js";
|
|
23
|
+
import "../chunk-ZU2ALUVQ.js";
|
|
24
|
+
import "../chunk-L7OHKDOX.js";
|
|
25
25
|
import {
|
|
26
26
|
loadAppPluginSet
|
|
27
27
|
} from "../chunk-Y2CM7HXH.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveRuntimeDependencySnapshot
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-RIB3M6YA.js";
|
|
4
4
|
import "../chunk-G3E7SCME.js";
|
|
5
5
|
import {
|
|
6
6
|
disconnectStateAdapter
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-GB5DFM4D.js";
|
|
8
|
+
import "../chunk-ZU2ALUVQ.js";
|
|
9
|
+
import "../chunk-L7OHKDOX.js";
|
|
10
10
|
import {
|
|
11
11
|
pluginCatalogRuntime
|
|
12
12
|
} from "../chunk-BQ3ITJA6.js";
|
package/dist/cli/upgrade.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
recordConversationActivity,
|
|
5
5
|
recordConversationExecution,
|
|
6
6
|
requestConversationWork
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-ENPSU7L7.js";
|
|
8
8
|
import {
|
|
9
9
|
JUNIOR_THREAD_STATE_TTL_MS,
|
|
10
10
|
coerceThreadConversationState
|
|
@@ -18,24 +18,24 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
createPluginLogger,
|
|
20
20
|
createPluginState
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-BRSQQRG6.js";
|
|
22
22
|
import {
|
|
23
23
|
createJuniorSqlExecutor,
|
|
24
24
|
createSqlStore,
|
|
25
25
|
getDb
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-6I6HBOQM.js";
|
|
27
27
|
import {
|
|
28
28
|
disconnectStateAdapter,
|
|
29
29
|
getConnectedStateContext
|
|
30
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-GB5DFM4D.js";
|
|
31
31
|
import {
|
|
32
32
|
parseDestination,
|
|
33
33
|
sameDestination
|
|
34
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-GGD6WK6V.js";
|
|
35
35
|
import {
|
|
36
36
|
getChatConfig
|
|
37
|
-
} from "../chunk-
|
|
38
|
-
import "../chunk-
|
|
37
|
+
} from "../chunk-ZU2ALUVQ.js";
|
|
38
|
+
import "../chunk-L7OHKDOX.js";
|
|
39
39
|
import {
|
|
40
40
|
loadAppPluginSet
|
|
41
41
|
} from "../chunk-Y2CM7HXH.js";
|
|
@@ -75,6 +75,9 @@ async function backfillToSql(args) {
|
|
|
75
75
|
function createStateConversationStore(state) {
|
|
76
76
|
return {
|
|
77
77
|
get: (args) => getConversation({ ...args, state }),
|
|
78
|
+
// Task-execution state has no destination records, so visibility is never
|
|
79
|
+
// source-confirmed here and cross-context reads fail closed to private.
|
|
80
|
+
getDestinationVisibility: async () => void 0,
|
|
78
81
|
recordActivity: (args) => recordConversationActivity({ ...args, state }),
|
|
79
82
|
recordExecution: (args) => recordConversationExecution({ ...args, state }),
|
|
80
83
|
listByActivity: (args) => listConversationsByActivity({ ...args, state })
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
closeDb,
|
|
3
3
|
getConversationStore,
|
|
4
4
|
getDb
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-6I6HBOQM.js";
|
|
6
|
+
import "./chunk-GGD6WK6V.js";
|
|
7
|
+
import "./chunk-ZU2ALUVQ.js";
|
|
8
|
+
import "./chunk-L7OHKDOX.js";
|
|
9
9
|
import "./chunk-IXTBFABZ.js";
|
|
10
10
|
import "./chunk-KF7522P3.js";
|
|
11
11
|
import "./chunk-FTMXFBDC.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IngestResourceEventInput } from "@/chat/resource-events/ingest";
|
|
2
|
+
/** Normalize GitHub `issue_comment` webhooks for PR-level comments. */
|
|
3
|
+
export declare function normalizeGitHubIssueCommentEvent(deliveryId: string, body: unknown): IngestResourceEventInput | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IngestResourceEventInput } from "@/chat/resource-events/ingest";
|
|
2
|
+
/** Normalize GitHub `pull_request_review_comment` webhooks for inline PR comments. */
|
|
3
|
+
export declare function normalizeGitHubPullRequestReviewCommentEvent(deliveryId: string, body: unknown): IngestResourceEventInput | undefined;
|
package/dist/instrumentation.js
CHANGED
package/dist/nitro.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveConversationWorkQueueTopic
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6O5UI3RG.js";
|
|
4
4
|
import {
|
|
5
5
|
PLUGIN_TASK_QUEUE_TOPIC
|
|
6
6
|
} from "./chunk-KNFROR7R.js";
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
pluginCatalogConfigFromPluginSet,
|
|
9
9
|
pluginRuntimeRegistrationsFromPluginSet
|
|
10
10
|
} from "./chunk-SG5WAA7H.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-GGD6WK6V.js";
|
|
12
|
+
import "./chunk-ZU2ALUVQ.js";
|
|
13
|
+
import "./chunk-L7OHKDOX.js";
|
|
14
14
|
import {
|
|
15
15
|
loadPluginSetFromModule,
|
|
16
16
|
resolvePluginModule
|
|
@@ -35,6 +35,7 @@ export interface ConversationSummaryReport {
|
|
|
35
35
|
requesterIdentity?: RequesterIdentity;
|
|
36
36
|
channel?: string;
|
|
37
37
|
channelName?: string;
|
|
38
|
+
channelNameRedacted?: boolean;
|
|
38
39
|
sentryTraceUrl?: string;
|
|
39
40
|
traceId?: string;
|
|
40
41
|
}
|
|
@@ -230,4 +231,4 @@ export declare function listRecentConversationSummaries(options?: {
|
|
|
230
231
|
/** Read one conversation transcript for reporting consumers. */
|
|
231
232
|
export declare function readConversationReport(conversationId: string, options?: ConversationReaderOptions): Promise<ConversationReport>;
|
|
232
233
|
/** Read one child-agent transcript through its parent conversation run. */
|
|
233
|
-
export declare function readConversationSubagentTranscriptReport(conversationId: string, runId: string, subagentId: string): Promise<ConversationSubagentTranscriptReport>;
|
|
234
|
+
export declare function readConversationSubagentTranscriptReport(conversationId: string, runId: string, subagentId: string, options?: ConversationReaderOptions): Promise<ConversationSubagentTranscriptReport>;
|