@sentry/junior 0.91.0 → 0.92.1
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-MXAF7RQL.js → agent-hooks-KL7I3ZRC.js} +7 -7
- package/dist/api/people/list.d.ts +3 -3
- package/dist/api/people/list.js +15 -15
- package/dist/api/people/list.query.d.ts +2 -2
- package/dist/api/people/profile.d.ts +3 -3
- package/dist/api/people/profile.js +12 -12
- package/dist/api/people/profile.query.d.ts +2 -2
- package/dist/api/people/shared.d.ts +13 -13
- package/dist/api/people/types.d.ts +12 -12
- package/dist/api-reference.d.ts +1 -1
- package/dist/app.js +365 -265
- package/dist/{catalog-runtime-DXE6NXHT.js → catalog-runtime-NZHMSMYC.js} +2 -2
- package/dist/chat/actor.d.ts +75 -0
- package/dist/chat/agent/prompt.d.ts +2 -2
- package/dist/chat/agent/request.d.ts +13 -13
- package/dist/chat/agent/resume.d.ts +5 -4
- package/dist/chat/agent/tools.d.ts +4 -2
- package/dist/chat/capabilities/jr-rpc-command.d.ts +1 -1
- package/dist/chat/conversation-privacy.d.ts +11 -0
- package/dist/chat/conversations/sql/migrations.d.ts +1 -1
- package/dist/chat/conversations/sql/schema/conversations.d.ts +2 -19
- package/dist/chat/conversations/sql/schema.d.ts +2 -19
- package/dist/chat/conversations/sql/store.d.ts +3 -3
- package/dist/chat/conversations/store.d.ts +4 -4
- package/dist/chat/credentials/context.d.ts +4 -4
- package/dist/chat/logging.d.ts +2 -2
- package/dist/chat/no-reply.d.ts +1 -1
- package/dist/chat/oauth-flow.d.ts +1 -1
- package/dist/chat/pi/messages.d.ts +2 -2
- package/dist/chat/pi/transcript.d.ts +15 -0
- package/dist/chat/plugins/agent-hooks.d.ts +5 -3
- package/dist/chat/plugins/credential-hooks.d.ts +2 -8
- package/dist/chat/prompt.d.ts +3 -6
- package/dist/chat/runtime/reply-executor.d.ts +1 -1
- package/dist/chat/runtime/turn-input.d.ts +1 -1
- package/dist/chat/sandbox/egress/schemas.d.ts +2 -2
- package/dist/chat/sandbox/egress/session.d.ts +1 -1
- package/dist/chat/services/context-compaction.d.ts +1 -1
- package/dist/chat/services/conversation-memory.d.ts +1 -1
- package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
- package/dist/chat/services/message-actor-identity.d.ts +4 -4
- package/dist/chat/services/pending-auth.d.ts +2 -2
- package/dist/chat/services/plugin-auth-orchestration.d.ts +1 -1
- package/dist/chat/services/provider-default-config.d.ts +1 -1
- package/dist/chat/services/subscribed-decision.d.ts +1 -1
- package/dist/chat/services/turn-result.d.ts +1 -1
- package/dist/chat/services/turn-session-record.d.ts +11 -8
- package/dist/chat/services/turn-thinking-level.d.ts +1 -1
- package/dist/chat/slack/assistant-thread/title.d.ts +1 -1
- package/dist/chat/slack/tools/canvas/create.d.ts +41 -1
- package/dist/chat/slack/tools/canvas/edit.d.ts +60 -1
- package/dist/chat/slack/tools/canvas/read.d.ts +60 -1
- package/dist/chat/slack/tools/canvas/write.d.ts +41 -1
- package/dist/chat/slack/tools/channel-list-messages.d.ts +45 -1
- package/dist/chat/slack/tools/context.d.ts +3 -3
- package/dist/chat/slack/tools/list/add-items.d.ts +42 -1
- package/dist/chat/slack/tools/list/create.d.ts +40 -1
- package/dist/chat/slack/tools/list/get-items.d.ts +40 -1
- package/dist/chat/slack/tools/list/update-item.d.ts +46 -1
- package/dist/chat/slack/tools/message-add-reaction.d.ts +40 -1
- package/dist/chat/slack/tools/send-message.d.ts +45 -1
- package/dist/chat/slack/tools/thread-read.d.ts +44 -1
- package/dist/chat/slack/tools/user-lookup.d.ts +45 -1
- package/dist/chat/slack/user.d.ts +3 -3
- package/dist/chat/slack/vision-context.d.ts +2 -2
- package/dist/chat/sql/schema.d.ts +2 -19
- package/dist/chat/state/conversation-details.d.ts +4 -4
- package/dist/chat/state/conversation.d.ts +1 -1
- package/dist/chat/state/session-log.d.ts +140 -26
- package/dist/chat/state/turn-session.d.ts +18 -5
- package/dist/chat/task-execution/slack-work.d.ts +2 -2
- package/dist/chat/task-execution/state.d.ts +4 -4
- package/dist/chat/tool-support/zod-tool.d.ts +16 -4
- package/dist/chat/tools/advisor/tool.d.ts +41 -1
- package/dist/chat/tools/definition.d.ts +10 -0
- package/dist/chat/tools/execute-tool.d.ts +41 -1
- package/dist/chat/tools/resource-events.d.ts +124 -3
- package/dist/chat/tools/runtime/report-progress.d.ts +40 -1
- package/dist/chat/tools/sandbox/bash.d.ts +41 -1
- package/dist/chat/tools/sandbox/edit-file.d.ts +44 -1
- package/dist/chat/tools/sandbox/find-files.d.ts +42 -1
- package/dist/chat/tools/sandbox/grep.d.ts +46 -1
- package/dist/chat/tools/sandbox/list-dir.d.ts +41 -1
- package/dist/chat/tools/sandbox/read-file.d.ts +42 -1
- package/dist/chat/tools/sandbox/write-file.d.ts +41 -1
- package/dist/chat/tools/search-tools.d.ts +102 -1
- package/dist/chat/tools/skill/call-mcp-tool.d.ts +10 -1
- package/dist/chat/tools/skill/load-skill.d.ts +40 -1
- package/dist/chat/tools/skill/search-mcp-tools.d.ts +100 -1
- package/dist/chat/tools/system-time.d.ts +38 -1
- package/dist/chat/tools/types.d.ts +4 -4
- package/dist/chat/tools/web/fetch-tool.d.ts +41 -1
- package/dist/chat/tools/web/image-generate.d.ts +62 -1
- package/dist/chat/tools/web/search.d.ts +41 -1
- package/dist/{chunk-HXL2ZV74.js → chunk-3F54A3YM.js} +82 -11
- package/dist/{chunk-ZGDTBSQ7.js → chunk-56SIBIVF.js} +930 -660
- package/dist/{chunk-DACFZ5CI.js → chunk-7K3JALTQ.js} +18 -12
- package/dist/{chunk-IRRMABQD.js → chunk-APIVR44P.js} +10 -10
- package/dist/{chunk-XP7F4LYB.js → chunk-BTH37NCU.js} +4 -4
- package/dist/{chunk-5GBUZI6M.js → chunk-H7KUZAMZ.js} +4 -4
- package/dist/{chunk-PIB4EOW6.js → chunk-IWKVXO3F.js} +19 -72
- package/dist/{chunk-TYUXD3FN.js → chunk-MC4ZZE4Q.js} +1 -1
- package/dist/{chunk-2S7M37HY.js → chunk-NIFONS4W.js} +86 -47
- package/dist/{chunk-AOISHLSF.js → chunk-O6ZYIHFC.js} +143 -20
- package/dist/{chunk-GCWD2VHP.js → chunk-OQQU3SD6.js} +285 -124
- package/dist/{chunk-NW7AXDA5.js → chunk-OZJXGX4U.js} +2 -2
- package/dist/{chunk-KC42JAAQ.js → chunk-PFXC67GJ.js} +3 -3
- package/dist/{chunk-QCKGI74V.js → chunk-PGR4WGZW.js} +10 -10
- package/dist/{chunk-ZUK7BL63.js → chunk-S6QKIGRM.js} +66 -54
- package/dist/{chunk-IX76WFJV.js → chunk-TF5VLGA7.js} +10 -10
- package/dist/{chunk-AN2437E3.js → chunk-YTNPU7I2.js} +2 -2
- package/dist/{chunk-3MPOMK3K.js → chunk-YYBX2BD5.js} +61 -3
- package/dist/{chunk-ONFOWI2D.js → chunk-Z4FOYQXW.js} +16 -15
- package/dist/{chunk-RS6ANWVT.js → chunk-ZATRYQLR.js} +1 -1
- package/dist/cli/chat.js +20 -20
- package/dist/cli/check.js +3 -3
- package/dist/cli/plugins.js +9 -9
- package/dist/cli/snapshot-warmup.js +6 -6
- package/dist/cli/upgrade.js +9 -9
- package/dist/{db-CXI7PR5U.js → db-GCK43OO3.js} +4 -4
- package/dist/instrumentation.js +1 -1
- package/dist/reporting/conversations.d.ts +3 -3
- package/dist/reporting.d.ts +1 -1
- package/dist/reporting.js +48 -50
- package/dist/{runner-FKL3RAHA.js → runner-Y73GZ2VE.js} +20 -18
- package/dist/{validation-I7GD2YWS.js → validation-KYAWETI4.js} +3 -3
- package/package.json +6 -6
- package/dist/chat/requester.d.ts +0 -68
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPluginLogger,
|
|
3
3
|
createPluginState
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OZJXGX4U.js";
|
|
5
5
|
import {
|
|
6
6
|
SANDBOX_WORKSPACE_ROOT
|
|
7
7
|
} from "./chunk-G3E7SCME.js";
|
|
8
8
|
import {
|
|
9
9
|
getDb
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NIFONS4W.js";
|
|
11
11
|
import {
|
|
12
12
|
botConfig,
|
|
13
13
|
completeObject,
|
|
14
14
|
embedTexts,
|
|
15
15
|
getSlackBotToken
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-3F54A3YM.js";
|
|
17
17
|
import {
|
|
18
18
|
isActorUserId,
|
|
19
19
|
logInfo,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
setSpanAttributes,
|
|
23
23
|
setSpanStatus,
|
|
24
24
|
withSpan
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-S6QKIGRM.js";
|
|
26
26
|
import {
|
|
27
27
|
parseSlackChannelReferenceId,
|
|
28
28
|
parseSlackMessageTs,
|
|
@@ -90,7 +90,7 @@ function getSlackToolContext(context) {
|
|
|
90
90
|
return {
|
|
91
91
|
destination: context.destination,
|
|
92
92
|
source: context.source,
|
|
93
|
-
|
|
93
|
+
actor: context.actor?.platform === "slack" ? context.actor : void 0,
|
|
94
94
|
destinationChannelId,
|
|
95
95
|
messageTs: parseSlackMessageTs(context.source.messageTs),
|
|
96
96
|
sourceChannelId,
|
|
@@ -697,7 +697,7 @@ function invocationPluginContext(plugin, context) {
|
|
|
697
697
|
return {
|
|
698
698
|
...common,
|
|
699
699
|
destination: context.destination,
|
|
700
|
-
|
|
700
|
+
actor: context.actor?.platform === "slack" ? context.actor : void 0
|
|
701
701
|
};
|
|
702
702
|
}
|
|
703
703
|
if (context.destination.platform !== "local") {
|
|
@@ -708,7 +708,7 @@ function invocationPluginContext(plugin, context) {
|
|
|
708
708
|
return {
|
|
709
709
|
...common,
|
|
710
710
|
destination: context.destination,
|
|
711
|
-
|
|
711
|
+
actor: context.actor?.platform === "local" ? context.actor : void 0
|
|
712
712
|
};
|
|
713
713
|
}
|
|
714
714
|
function safeErrorMessage(error) {
|
|
@@ -907,7 +907,7 @@ function getPluginTools(context) {
|
|
|
907
907
|
const credentialSubject = slackToolContext ? createSlackDirectCredentialSubject({
|
|
908
908
|
channelId: slackToolContext.sourceChannelId,
|
|
909
909
|
teamId: slackToolContext.teamId,
|
|
910
|
-
userId: slackToolContext.
|
|
910
|
+
userId: slackToolContext.actor?.userId
|
|
911
911
|
}) : void 0;
|
|
912
912
|
const slackContext = slackToolContext ? {
|
|
913
913
|
channelCapabilities: resolveChannelCapabilities(
|
|
@@ -924,7 +924,7 @@ function getPluginTools(context) {
|
|
|
924
924
|
}
|
|
925
925
|
pluginContext = {
|
|
926
926
|
...basePluginContext(plugin),
|
|
927
|
-
|
|
927
|
+
actor: context.actor?.platform === "slack" ? context.actor : void 0,
|
|
928
928
|
conversationId: context.conversationId,
|
|
929
929
|
destination: context.destination,
|
|
930
930
|
slack: slackContext,
|
|
@@ -943,7 +943,7 @@ function getPluginTools(context) {
|
|
|
943
943
|
}
|
|
944
944
|
pluginContext = {
|
|
945
945
|
...basePluginContext(plugin),
|
|
946
|
-
|
|
946
|
+
actor: context.actor?.platform === "local" ? context.actor : void 0,
|
|
947
947
|
conversationId: context.conversationId,
|
|
948
948
|
destination: context.destination,
|
|
949
949
|
source: context.source,
|
|
@@ -974,6 +974,10 @@ function getPluginTools(context) {
|
|
|
974
974
|
name: localName,
|
|
975
975
|
plugin: pluginName
|
|
976
976
|
};
|
|
977
|
+
definition.source = {
|
|
978
|
+
id: pluginName,
|
|
979
|
+
description: plugin.manifest.description
|
|
980
|
+
};
|
|
977
981
|
definition.exposure = "deferred";
|
|
978
982
|
tools[name] = definition;
|
|
979
983
|
}
|
|
@@ -1355,7 +1359,7 @@ function createPluginHookRunner(input = {}) {
|
|
|
1355
1359
|
);
|
|
1356
1360
|
await hook({
|
|
1357
1361
|
...basePluginContext(plugin),
|
|
1358
|
-
|
|
1362
|
+
actor: input.actor,
|
|
1359
1363
|
sandbox: sandboxCapability
|
|
1360
1364
|
});
|
|
1361
1365
|
}
|
|
@@ -1363,6 +1367,7 @@ function createPluginHookRunner(input = {}) {
|
|
|
1363
1367
|
async beforeToolExecute(tool) {
|
|
1364
1368
|
let nextInput = { ...tool.input };
|
|
1365
1369
|
const env = normalizeEnv(nextInput.env);
|
|
1370
|
+
const actors = input.actors?.() ?? (input.actor ? [input.actor] : []);
|
|
1366
1371
|
for (const plugin of loaded) {
|
|
1367
1372
|
const pluginName = plugin.manifest.name;
|
|
1368
1373
|
const hook = plugin.hooks?.beforeToolExecute;
|
|
@@ -1373,7 +1378,8 @@ function createPluginHookRunner(input = {}) {
|
|
|
1373
1378
|
let denied;
|
|
1374
1379
|
await hook({
|
|
1375
1380
|
...basePluginContext(plugin),
|
|
1376
|
-
|
|
1381
|
+
actor: input.actor,
|
|
1382
|
+
actors,
|
|
1377
1383
|
tool: {
|
|
1378
1384
|
name: tool.name,
|
|
1379
1385
|
input: nextInput
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
juniorDestinations,
|
|
5
5
|
juniorIdentities,
|
|
6
6
|
juniorUsers
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NIFONS4W.js";
|
|
8
8
|
|
|
9
9
|
// src/api/people/shared.ts
|
|
10
10
|
import { and, asc, desc, eq, sql } from "drizzle-orm";
|
|
@@ -106,7 +106,7 @@ function summaryFromRow(row, nowMs) {
|
|
|
106
106
|
startedAt: row.createdAt.toISOString(),
|
|
107
107
|
status: statusFromRow(row, nowMs),
|
|
108
108
|
surface,
|
|
109
|
-
|
|
109
|
+
actorIdentity: {
|
|
110
110
|
email: row.email,
|
|
111
111
|
...row.fullName ? { fullName: row.fullName } : {},
|
|
112
112
|
slackUserId: row.providerSubjectId,
|
|
@@ -162,14 +162,14 @@ function addSignals(target, value) {
|
|
|
162
162
|
target.failed += value.failed ? 1 : 0;
|
|
163
163
|
target.hung += value.hung ? 1 : 0;
|
|
164
164
|
}
|
|
165
|
-
function identityWithEmail(
|
|
166
|
-
const email = normalizeEmail(
|
|
165
|
+
function identityWithEmail(actor) {
|
|
166
|
+
const email = normalizeEmail(actor?.email);
|
|
167
167
|
if (!email) return void 0;
|
|
168
168
|
return {
|
|
169
169
|
email,
|
|
170
|
-
...
|
|
171
|
-
...
|
|
172
|
-
...
|
|
170
|
+
...actor?.fullName ? { fullName: actor.fullName } : {},
|
|
171
|
+
...actor?.slackUserId ? { slackUserId: actor.slackUserId } : {},
|
|
172
|
+
...actor?.slackUserName ? { slackUserName: actor.slackUserName } : {}
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
function mergeIdentity(current, next) {
|
|
@@ -197,7 +197,7 @@ function statsItems(map) {
|
|
|
197
197
|
(left, right) => right.conversations - left.conversations || right.runs - left.runs || right.durationMs - left.durationMs || left.label.localeCompare(right.label)
|
|
198
198
|
);
|
|
199
199
|
}
|
|
200
|
-
async function
|
|
200
|
+
async function actorRows(options = {}, email) {
|
|
201
201
|
const normalizedEmail = normalizeEmail(email);
|
|
202
202
|
const rows = await (options.db ?? getDb()).select({
|
|
203
203
|
channelName: juniorConversations.channelName,
|
|
@@ -217,7 +217,7 @@ async function requesterRows(options = {}, email) {
|
|
|
217
217
|
updatedAt: juniorConversations.updatedAt
|
|
218
218
|
}).from(juniorConversations).innerJoin(
|
|
219
219
|
juniorIdentities,
|
|
220
|
-
eq(juniorIdentities.id, juniorConversations.
|
|
220
|
+
eq(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
221
221
|
).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).leftJoin(
|
|
222
222
|
juniorDestinations,
|
|
223
223
|
eq(juniorDestinations.id, juniorConversations.destinationId)
|
|
@@ -257,5 +257,5 @@ export {
|
|
|
257
257
|
mergeIdentity,
|
|
258
258
|
activityDays,
|
|
259
259
|
statsItems,
|
|
260
|
-
|
|
260
|
+
actorRows
|
|
261
261
|
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
logWarn,
|
|
4
4
|
parseActorUserId,
|
|
5
5
|
setSpanAttributes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S6QKIGRM.js";
|
|
7
7
|
import {
|
|
8
8
|
discoverInstalledPluginPackageContent,
|
|
9
9
|
normalizePluginPackageNames,
|
|
@@ -1093,8 +1093,8 @@ var credentialUserActorSchema = z2.object({
|
|
|
1093
1093
|
userId: exactActorIdSchema
|
|
1094
1094
|
}).strict();
|
|
1095
1095
|
var credentialSystemActorSchema = z2.object({
|
|
1096
|
-
|
|
1097
|
-
|
|
1096
|
+
platform: z2.literal("system"),
|
|
1097
|
+
name: exactActorIdSchema
|
|
1098
1098
|
}).strict();
|
|
1099
1099
|
var credentialSubjectSchema = z2.object({
|
|
1100
1100
|
type: z2.literal("user"),
|
|
@@ -1112,7 +1112,7 @@ var credentialContextSchema = z2.union([
|
|
|
1112
1112
|
}).strict()
|
|
1113
1113
|
]);
|
|
1114
1114
|
function credentialUserSubjectId(context) {
|
|
1115
|
-
if (context.actor
|
|
1115
|
+
if ("type" in context.actor) {
|
|
1116
1116
|
return context.actor.userId;
|
|
1117
1117
|
}
|
|
1118
1118
|
return "subject" in context ? context.subject?.userId : void 0;
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
} from "./chunk-G3E7SCME.js";
|
|
4
4
|
import {
|
|
5
5
|
getStateAdapter
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZATRYQLR.js";
|
|
7
7
|
import {
|
|
8
8
|
toOptionalTrimmed
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3F54A3YM.js";
|
|
10
10
|
import {
|
|
11
11
|
pluginCatalogRuntime
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BTH37NCU.js";
|
|
13
13
|
import {
|
|
14
14
|
withSpan
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-S6QKIGRM.js";
|
|
16
16
|
|
|
17
17
|
// src/chat/sandbox/runtime-dependency-snapshots.ts
|
|
18
18
|
import { createHash } from "crypto";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
escapeXml,
|
|
3
2
|
getInterruptionMarker
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OQQU3SD6.js";
|
|
5
4
|
import {
|
|
6
5
|
SANDBOX_DATA_ROOT,
|
|
7
6
|
SANDBOX_WORKSPACE_ROOT,
|
|
@@ -9,69 +8,19 @@ import {
|
|
|
9
8
|
} from "./chunk-G3E7SCME.js";
|
|
10
9
|
import {
|
|
11
10
|
TURN_CONTEXT_TAG,
|
|
12
|
-
botConfig
|
|
13
|
-
|
|
11
|
+
botConfig,
|
|
12
|
+
escapeXml
|
|
13
|
+
} from "./chunk-3F54A3YM.js";
|
|
14
14
|
import {
|
|
15
15
|
logInfo,
|
|
16
16
|
logWarn
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-S6QKIGRM.js";
|
|
18
18
|
import {
|
|
19
19
|
listReferenceFiles,
|
|
20
20
|
soulPathCandidates,
|
|
21
21
|
worldPathCandidates
|
|
22
22
|
} from "./chunk-6APU57E6.js";
|
|
23
23
|
|
|
24
|
-
// src/chat/current-instruction.ts
|
|
25
|
-
var CURRENT_INSTRUCTION_TAG = "current-instruction";
|
|
26
|
-
var CURRENT_INSTRUCTION_OPEN_PREFIX = `<${CURRENT_INSTRUCTION_TAG}`;
|
|
27
|
-
var CURRENT_INSTRUCTION_OPEN_BARE = `<${CURRENT_INSTRUCTION_TAG}>`;
|
|
28
|
-
var CURRENT_INSTRUCTION_OPEN_ATTR_PREFIX = `<${CURRENT_INSTRUCTION_TAG} `;
|
|
29
|
-
var CURRENT_INSTRUCTION_CLOSE = `
|
|
30
|
-
</${CURRENT_INSTRUCTION_TAG}>`;
|
|
31
|
-
function unescapeXml(value) {
|
|
32
|
-
return value.replaceAll(""", '"').replaceAll("'", "'").replaceAll(">", ">").replaceAll("<", "<").replaceAll("&", "&");
|
|
33
|
-
}
|
|
34
|
-
function isCurrentInstructionOpeningTag(value) {
|
|
35
|
-
return value === CURRENT_INSTRUCTION_OPEN_BARE || value.startsWith(CURRENT_INSTRUCTION_OPEN_ATTR_PREFIX) && value.endsWith(">");
|
|
36
|
-
}
|
|
37
|
-
function readCurrentInstructionBody(text) {
|
|
38
|
-
const start = text.indexOf(CURRENT_INSTRUCTION_OPEN_PREFIX);
|
|
39
|
-
if (start < 0) {
|
|
40
|
-
return void 0;
|
|
41
|
-
}
|
|
42
|
-
const openingEnd = text.indexOf(">\n", start);
|
|
43
|
-
if (openingEnd < 0) {
|
|
44
|
-
return void 0;
|
|
45
|
-
}
|
|
46
|
-
const openingTag = text.slice(start, openingEnd + 1);
|
|
47
|
-
if (!isCurrentInstructionOpeningTag(openingTag)) {
|
|
48
|
-
return void 0;
|
|
49
|
-
}
|
|
50
|
-
const bodyStart = openingEnd + 2;
|
|
51
|
-
const bodyEnd = text.indexOf(CURRENT_INSTRUCTION_CLOSE, bodyStart);
|
|
52
|
-
if (bodyEnd < bodyStart) {
|
|
53
|
-
return void 0;
|
|
54
|
-
}
|
|
55
|
-
return text.slice(bodyStart, bodyEnd);
|
|
56
|
-
}
|
|
57
|
-
function renderCurrentInstruction(instruction, attrs) {
|
|
58
|
-
const renderedAttrs = [
|
|
59
|
-
attrs?.authorId ? `author_id="${escapeXml(attrs.authorId)}"` : void 0,
|
|
60
|
-
attrs?.authorName ? `author_name="${escapeXml(attrs.authorName)}"` : void 0,
|
|
61
|
-
attrs?.slackTs ? `slack_ts="${escapeXml(attrs.slackTs)}"` : void 0
|
|
62
|
-
].filter((attr) => Boolean(attr)).join(" ");
|
|
63
|
-
const openingTag = renderedAttrs ? `<${CURRENT_INSTRUCTION_TAG} ${renderedAttrs}>` : `<${CURRENT_INSTRUCTION_TAG}>`;
|
|
64
|
-
return [
|
|
65
|
-
openingTag,
|
|
66
|
-
escapeXml(instruction),
|
|
67
|
-
`</${CURRENT_INSTRUCTION_TAG}>`
|
|
68
|
-
].join("\n");
|
|
69
|
-
}
|
|
70
|
-
function unwrapCurrentInstruction(text) {
|
|
71
|
-
const body = readCurrentInstructionBody(text);
|
|
72
|
-
return body === void 0 ? void 0 : unescapeXml(body);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
24
|
// src/chat/prompt.ts
|
|
76
25
|
import fs from "fs";
|
|
77
26
|
import path from "path";
|
|
@@ -598,12 +547,12 @@ function formatConfigurationValue(value) {
|
|
|
598
547
|
return escapeXml(String(value));
|
|
599
548
|
}
|
|
600
549
|
}
|
|
601
|
-
function
|
|
550
|
+
function renderActorBlock(fields) {
|
|
602
551
|
const lines = Object.entries(fields).filter(([, value]) => Boolean(value)).map(([key, value]) => `- ${key}: ${escapeXml(value)}`);
|
|
603
552
|
if (lines.length === 0) {
|
|
604
553
|
return null;
|
|
605
554
|
}
|
|
606
|
-
return ["<
|
|
555
|
+
return ["<actor>", ...lines, "</actor>"];
|
|
607
556
|
}
|
|
608
557
|
function renderTag(tag, lines) {
|
|
609
558
|
return [`<${tag}>`, ...lines, `</${tag}>`];
|
|
@@ -774,7 +723,7 @@ var EXECUTION_CONTRACT_RULES = [
|
|
|
774
723
|
];
|
|
775
724
|
var CONVERSATION_RULES = [
|
|
776
725
|
"- In thread follow-ups, answer from prior thread context; do not repeat resolved clarifying questions.",
|
|
777
|
-
"- Preserve attribution roles from thread context: the
|
|
726
|
+
"- Preserve attribution roles from thread context: the actor is the person asking now, which may differ from the original reporter or subject.",
|
|
778
727
|
"- Treat event notifications as subscribed conversation updates, not user-authored commands. Use their subscription intent to decide whether to reply, inspect, suggest, or stay brief.",
|
|
779
728
|
"- Runtime owns continuation and authorization notices; on resumed turns, answer with the final requested content only."
|
|
780
729
|
];
|
|
@@ -784,7 +733,7 @@ var SLACK_ACTION_RULES = [
|
|
|
784
733
|
"- sendMessage has no target argument; it always sends into the active Slack conversation/thread. For top-level channel posts, other channels, or named recipients, explain that this runtime can only send into the active conversation.",
|
|
785
734
|
"- sendMessage is not final-reply delivery. After using sendMessage, provide a brief normal final answer unless the user requested no further text.",
|
|
786
735
|
"- Ambient reaction requests target the current inbound message; do not ask for a message reference.",
|
|
787
|
-
`-
|
|
736
|
+
`- When no visible final thread reply is useful, make the final message exactly ${NO_REPLY_MARKER}.`
|
|
788
737
|
];
|
|
789
738
|
var SAFETY_RULES = [
|
|
790
739
|
"- Stay within the user's request and the runtime's available capabilities; do not pursue independent goals, persistence, replication, credential gathering, or access expansion.",
|
|
@@ -835,7 +784,7 @@ function buildOutputSection(platform) {
|
|
|
835
784
|
"- Use Slack-flavored Markdown: **bold** section labels, `code`, [text](url) links, bullet lists, and fenced code blocks. No hash-prefixed headings and no tables. When the answer primarily lists several URLs, show each URL bare instead of as a labeled link.",
|
|
836
785
|
"- Keep replies brief and scannable; use bullets or short code blocks when helpful, and one compact thread reply when it fits.",
|
|
837
786
|
"- When a research or document-style answer would benefit from continuation, multiple sections, or future reference value, create a Slack canvas and keep the thread reply to one or two short sentences plus the link; do not recap the canvas contents.",
|
|
838
|
-
"- End every turn with a final user-facing markdown response unless the Slack action rules allow a
|
|
787
|
+
"- End every turn with a final user-facing markdown response unless the Slack action rules allow a no-reply completion.",
|
|
839
788
|
"</output>"
|
|
840
789
|
].join("\n");
|
|
841
790
|
}
|
|
@@ -904,8 +853,8 @@ function buildDispatchSection(params) {
|
|
|
904
853
|
"- dispatch.delivery: the runtime delivers the final answer to the destination",
|
|
905
854
|
"- dispatch.delivery_rule: do not request or require a separate posting tool just to deliver the final answer",
|
|
906
855
|
...params.actor ? [
|
|
907
|
-
`- dispatch.actor.
|
|
908
|
-
`- dispatch.actor.
|
|
856
|
+
`- dispatch.actor.platform: ${escapeXml(params.actor.platform)}`,
|
|
857
|
+
`- dispatch.actor.name: ${escapeXml(params.actor.name)}`
|
|
909
858
|
] : [],
|
|
910
859
|
...params.plugin ? [`- dispatch.plugin: ${escapeXml(params.plugin)}`] : [],
|
|
911
860
|
...formatSourceLines(params.source),
|
|
@@ -924,13 +873,13 @@ function buildContextSection(params) {
|
|
|
924
873
|
])
|
|
925
874
|
);
|
|
926
875
|
}
|
|
927
|
-
const
|
|
928
|
-
full_name: params.
|
|
929
|
-
user_name: params.
|
|
930
|
-
user_id: params.
|
|
876
|
+
const actorLines = renderActorBlock({
|
|
877
|
+
full_name: params.actor?.fullName,
|
|
878
|
+
user_name: params.actor?.userName,
|
|
879
|
+
user_id: params.actor?.userId
|
|
931
880
|
});
|
|
932
|
-
if (
|
|
933
|
-
blocks.push(
|
|
881
|
+
if (actorLines) {
|
|
882
|
+
blocks.push(actorLines);
|
|
934
883
|
}
|
|
935
884
|
const dispatchLines = buildDispatchSection(params.dispatch);
|
|
936
885
|
if (dispatchLines) {
|
|
@@ -1053,7 +1002,7 @@ function buildTurnContextPrompt(params) {
|
|
|
1053
1002
|
}) : null,
|
|
1054
1003
|
pluginPromptContributions,
|
|
1055
1004
|
includeSessionContext ? buildContextSection({
|
|
1056
|
-
|
|
1005
|
+
actor: params.actor,
|
|
1057
1006
|
artifactState: params.artifactState,
|
|
1058
1007
|
configuration: params.configuration,
|
|
1059
1008
|
dispatch: params.dispatch,
|
|
@@ -1078,8 +1027,6 @@ export {
|
|
|
1078
1027
|
isNoReplyMarker,
|
|
1079
1028
|
containsNoReplyMarker,
|
|
1080
1029
|
stripNoReplyMarker,
|
|
1081
|
-
renderCurrentInstruction,
|
|
1082
|
-
unwrapCurrentInstruction,
|
|
1083
1030
|
truncateStatusText,
|
|
1084
1031
|
escapeSlackMrkdwnText,
|
|
1085
1032
|
formatSlackLink,
|