@sentry/junior 0.122.1 → 0.123.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-65WXVKKX.js → agent-hooks-7JCABN73.js} +7 -7
- package/dist/api/conversations/detail.d.ts +55 -0
- package/dist/api/conversations/event-list.d.ts +55 -0
- package/dist/api/conversations/events.d.ts +1 -1
- package/dist/api/conversations/stats.d.ts +15 -0
- package/dist/api/schema/conversation.d.ts +260 -0
- package/dist/api/schema.d.ts +1 -1
- package/dist/api/schema.js +1 -1
- package/dist/api.js +134 -20
- package/dist/app.js +32 -19
- package/dist/{catalog-runtime-VNNMSKCB.js → catalog-runtime-SZAS6EVH.js} +5 -5
- package/dist/chat/agent/action-confirmation-retry.d.ts +6 -0
- package/dist/chat/agent/tools.d.ts +12 -0
- package/dist/chat/config.d.ts +1 -0
- package/dist/chat/conversations/history.d.ts +91 -1
- package/dist/chat/conversations/projection.d.ts +11 -0
- package/dist/chat/conversations/provenance.d.ts +2 -0
- package/dist/chat/mcp/tool-manager.d.ts +1 -1
- package/dist/chat/pi/client.d.ts +6 -0
- package/dist/chat/pi/sdk.d.ts +1 -1
- package/dist/chat/pi/transcript.d.ts +2 -0
- package/dist/chat/plugins/agent-hooks.d.ts +2 -0
- package/dist/chat/plugins/conversation-events.d.ts +15 -0
- package/dist/chat/services/guardian-action-policy.d.ts +12 -0
- package/dist/chat/services/guardian-action-review.d.ts +9 -0
- package/dist/chat/tool-support/action-review-evidence.d.ts +4 -0
- package/dist/chat/tool-support/action-review-history.d.ts +117 -0
- package/dist/chat/tool-support/action-review.d.ts +142 -0
- package/dist/chat/tool-support/pi-tool-adapter.d.ts +2 -1
- package/dist/chat/tool-support/skill/mcp-tool-summary.d.ts +1 -6
- package/dist/chat/tool-support/zod-tool.d.ts +1 -0
- package/dist/chat/tools/definition.d.ts +23 -1
- package/dist/chat/tools/query-conversation-events.d.ts +1 -1
- package/dist/chat/tools/search-tools.d.ts +0 -20
- package/dist/chat/tools/skill/search-mcp-tools.d.ts +0 -20
- package/dist/{chunk-MSDKKTRG.js → chunk-2DZD6HX2.js} +4 -4
- package/dist/{chunk-3KYLHUVC.js → chunk-3S2K7SYY.js} +1449 -591
- package/dist/{chunk-IEE5CSAP.js → chunk-5EUADEG3.js} +1 -1
- package/dist/{chunk-VLRECFIC.js → chunk-5P4QBMTY.js} +11 -11
- package/dist/{chunk-LZ4XXS76.js → chunk-7YOBVIHY.js} +3 -2
- package/dist/{chunk-HGREP4UX.js → chunk-A3TUEGKH.js} +1 -1
- package/dist/{chunk-XBYNPBPQ.js → chunk-DAMUPWYR.js} +2 -2
- package/dist/{chunk-GPQLJDT5.js → chunk-DQQCWMA2.js} +17 -19
- package/dist/{chunk-M7KAZXTE.js → chunk-DVPWU77W.js} +30 -2
- package/dist/{chunk-TI7SYDD4.js → chunk-JCJN6TPV.js} +55 -4
- package/dist/{chunk-O2ULQJWR.js → chunk-JMUPEYKC.js} +47 -1
- package/dist/{chunk-4JPJTFUH.js → chunk-JPG43UG7.js} +1 -1
- package/dist/{chunk-BXT63TNS.js → chunk-K5DCMBUV.js} +33 -4
- package/dist/{chunk-PXPBBOIU.js → chunk-LEQXDCWK.js} +1 -1
- package/dist/{chunk-73TQBD5S.js → chunk-QKYO7ZNS.js} +1 -1
- package/dist/{chunk-U5PRRZMZ.js → chunk-RQ6BLJJD.js} +7 -7
- package/dist/chunk-THYOK2SL.js +55 -0
- package/dist/{chunk-PYS4QZAF.js → chunk-VTWLP6YS.js} +1 -1
- package/dist/{chunk-4ZV2GNHX.js → chunk-XLPETJXX.js} +1 -1
- package/dist/{chunk-QE33ATQW.js → chunk-ZO4TL4OK.js} +19 -11
- package/dist/{chunk-WFJ2EG4E.js → chunk-ZOOZ25BO.js} +1 -1
- package/dist/cli/chat.js +21 -21
- package/dist/cli/check.js +6 -6
- package/dist/cli/init.js +2 -1
- package/dist/cli/plugins.js +10 -10
- package/dist/cli/snapshot-create.js +8 -8
- package/dist/cli/upgrade.js +5 -5
- package/dist/{db-36HXKAKH.js → db-XKB2CHDW.js} +5 -5
- package/dist/instrumentation.js +2 -2
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-UKOO7KKP.js → oauth-callback-server-EVMACH4G.js} +15 -14
- package/dist/{runner-M66KMCQ7.js → runner-BVHV5Y6L.js} +10 -9
- package/dist/{skills-TTXTVFOG.js → skills-QTI6GGJ4.js} +6 -6
- package/dist/{validation-TGASRGNN.js → validation-SCQUYIUU.js} +6 -6
- package/dist/version.js +1 -1
- package/package.json +8 -7
- package/dist/chat/tool-support/schema-summary.d.ts +0 -2
package/dist/api.js
CHANGED
|
@@ -24,15 +24,18 @@ import {
|
|
|
24
24
|
personalTokenParamsSchema,
|
|
25
25
|
revokePersonalTokenResponseSchema,
|
|
26
26
|
statsReportSchema
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-JMUPEYKC.js";
|
|
28
28
|
import {
|
|
29
29
|
formatSlackConversationRedactedLabel,
|
|
30
30
|
readHealthReport,
|
|
31
31
|
resolveSlackConversationContextFromThreadId
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-LEQXDCWK.js";
|
|
33
33
|
import {
|
|
34
34
|
buildSentryConversationUrl
|
|
35
35
|
} from "./chunk-4CODA7P5.js";
|
|
36
|
+
import {
|
|
37
|
+
renderPluginConversationEvent
|
|
38
|
+
} from "./chunk-THYOK2SL.js";
|
|
36
39
|
import {
|
|
37
40
|
healthReportSchema,
|
|
38
41
|
pluginOperationalReportFeedSchema,
|
|
@@ -42,7 +45,7 @@ import {
|
|
|
42
45
|
} from "./chunk-PE44LDDQ.js";
|
|
43
46
|
import {
|
|
44
47
|
readStats
|
|
45
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-5EUADEG3.js";
|
|
46
49
|
import {
|
|
47
50
|
agentTurnUsageSchema,
|
|
48
51
|
hasAgentTurnUsage
|
|
@@ -53,12 +56,12 @@ import {
|
|
|
53
56
|
getPlugins,
|
|
54
57
|
listConversationAnnotations,
|
|
55
58
|
readViewerActors
|
|
56
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-ZO4TL4OK.js";
|
|
57
60
|
import {
|
|
58
61
|
decodeStoredConversationEvent,
|
|
59
62
|
getDb,
|
|
60
63
|
getSqlExecutor
|
|
61
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-DVPWU77W.js";
|
|
62
65
|
import {
|
|
63
66
|
juniorApiTokens,
|
|
64
67
|
juniorConversationEvents,
|
|
@@ -66,8 +69,8 @@ import {
|
|
|
66
69
|
juniorIdentities,
|
|
67
70
|
juniorUsers
|
|
68
71
|
} from "./chunk-GCGJGSQL.js";
|
|
69
|
-
import "./chunk-
|
|
70
|
-
import "./chunk-
|
|
72
|
+
import "./chunk-ZOOZ25BO.js";
|
|
73
|
+
import "./chunk-JCJN6TPV.js";
|
|
71
74
|
import {
|
|
72
75
|
juniorDestinations
|
|
73
76
|
} from "./chunk-VFUK3X5B.js";
|
|
@@ -76,12 +79,12 @@ import {
|
|
|
76
79
|
parseSlackThreadId
|
|
77
80
|
} from "./chunk-S7G34U75.js";
|
|
78
81
|
import "./chunk-HZF5P5UN.js";
|
|
79
|
-
import "./chunk-
|
|
82
|
+
import "./chunk-JPG43UG7.js";
|
|
80
83
|
import "./chunk-OB42YVAE.js";
|
|
81
84
|
import "./chunk-F3B2YJ76.js";
|
|
82
85
|
import "./chunk-6GWA276C.js";
|
|
83
|
-
import "./chunk-
|
|
84
|
-
import "./chunk-
|
|
86
|
+
import "./chunk-VTWLP6YS.js";
|
|
87
|
+
import "./chunk-7YOBVIHY.js";
|
|
85
88
|
import "./chunk-MLKGABMK.js";
|
|
86
89
|
|
|
87
90
|
// src/api.ts
|
|
@@ -360,8 +363,10 @@ var conversationReportSourceEventTypes = [
|
|
|
360
363
|
"assistant_message",
|
|
361
364
|
"tool_result",
|
|
362
365
|
"tool_execution_started",
|
|
366
|
+
"guardian_action_reviewed",
|
|
363
367
|
"turn_started",
|
|
364
368
|
"turn_context",
|
|
369
|
+
"plugin_event",
|
|
365
370
|
"turn_routed",
|
|
366
371
|
"turn_completed",
|
|
367
372
|
"turn_failed",
|
|
@@ -403,6 +408,11 @@ var reportingMediaPartSchema = z2.object({
|
|
|
403
408
|
type: z2.enum(["image", "audio"]),
|
|
404
409
|
mimeType: z2.string().min(1).optional()
|
|
405
410
|
}).passthrough();
|
|
411
|
+
var reportingMessageAuthorSchema = z2.object({
|
|
412
|
+
fullName: z2.string().min(1).optional(),
|
|
413
|
+
userId: z2.string().min(1).optional(),
|
|
414
|
+
userName: z2.string().min(1).optional()
|
|
415
|
+
}).passthrough();
|
|
406
416
|
function sanitizeModelContentPart(value) {
|
|
407
417
|
const text = reportingTextPartSchema.safeParse(value);
|
|
408
418
|
if (text.success) return { type: "text", text: text.data.text };
|
|
@@ -420,6 +430,17 @@ function modelVisibleToolOutput(content) {
|
|
|
420
430
|
const only = sanitized[0];
|
|
421
431
|
return only.type === "text" ? only.text : only;
|
|
422
432
|
}
|
|
433
|
+
function reportMessageActorIdentity(data) {
|
|
434
|
+
if (data.role !== "user") return void 0;
|
|
435
|
+
const author = reportingMessageAuthorSchema.safeParse(data.meta?.author);
|
|
436
|
+
if (!author.success) return void 0;
|
|
437
|
+
const actorIdentity = {
|
|
438
|
+
...author.data.fullName ? { fullName: author.data.fullName } : {},
|
|
439
|
+
...author.data.userId ? { slackUserId: author.data.userId } : {},
|
|
440
|
+
...author.data.userName ? { slackUserName: author.data.userName } : {}
|
|
441
|
+
};
|
|
442
|
+
return Object.keys(actorIdentity).length > 0 ? actorIdentity : void 0;
|
|
443
|
+
}
|
|
423
444
|
function reportToolCalls(args) {
|
|
424
445
|
const message2 = reportingAssistantMessageSchema.safeParse(args.message);
|
|
425
446
|
if (!message2.success) return void 0;
|
|
@@ -514,15 +535,31 @@ function conversationReportToolResultIds(events) {
|
|
|
514
535
|
}
|
|
515
536
|
function reportEventData(args) {
|
|
516
537
|
const { data } = args;
|
|
538
|
+
if (data.type === "plugin_event") {
|
|
539
|
+
if (!args.canExposePayload) return void 0;
|
|
540
|
+
const presentation = renderPluginConversationEvent(data);
|
|
541
|
+
if (!presentation) return void 0;
|
|
542
|
+
return {
|
|
543
|
+
type: "plugin_event",
|
|
544
|
+
namespace: data.namespace,
|
|
545
|
+
name: data.name,
|
|
546
|
+
version: data.version,
|
|
547
|
+
turnId: data.turnId,
|
|
548
|
+
presentation
|
|
549
|
+
};
|
|
550
|
+
}
|
|
517
551
|
switch (data.type) {
|
|
518
|
-
case "message":
|
|
552
|
+
case "message": {
|
|
553
|
+
const actorIdentity = args.canExposePayload ? reportMessageActorIdentity(data) : void 0;
|
|
519
554
|
return {
|
|
520
555
|
type: "message",
|
|
521
556
|
messageId: data.messageId,
|
|
522
557
|
role: data.role,
|
|
558
|
+
...actorIdentity ? { actorIdentity } : {},
|
|
523
559
|
...typeof data.meta?.eventType === "string" ? { eventType: data.meta.eventType } : {},
|
|
524
560
|
...args.canExposePayload ? { text: data.text } : { redacted: true }
|
|
525
561
|
};
|
|
562
|
+
}
|
|
526
563
|
case "message_handled":
|
|
527
564
|
return {
|
|
528
565
|
type: "message_handled",
|
|
@@ -556,6 +593,16 @@ function reportEventData(args) {
|
|
|
556
593
|
...data.confidence !== void 0 ? { confidence: data.confidence } : {},
|
|
557
594
|
source: data.source
|
|
558
595
|
};
|
|
596
|
+
case "guardian_action_reviewed":
|
|
597
|
+
return {
|
|
598
|
+
type: "guardian_action_reviewed",
|
|
599
|
+
turnId: data.turnId,
|
|
600
|
+
toolCallId: data.toolCallId,
|
|
601
|
+
toolName: data.toolName,
|
|
602
|
+
decision: data.decision,
|
|
603
|
+
riskLevel: data.riskLevel,
|
|
604
|
+
userAuthorization: data.userAuthorization
|
|
605
|
+
};
|
|
559
606
|
case "turn_completed":
|
|
560
607
|
return {
|
|
561
608
|
type: "turn_lifecycle",
|
|
@@ -1589,6 +1636,46 @@ function metricDays(rows, endMs) {
|
|
|
1589
1636
|
}
|
|
1590
1637
|
return days;
|
|
1591
1638
|
}
|
|
1639
|
+
function guardianStats(rows, endMs) {
|
|
1640
|
+
const byDate = new Map(rows.map((row) => [row.date, row]));
|
|
1641
|
+
const end = new Date(endMs);
|
|
1642
|
+
end.setUTCHours(0, 0, 0, 0);
|
|
1643
|
+
const start = new Date(end);
|
|
1644
|
+
start.setUTCDate(start.getUTCDate() - (WINDOW_DAYS - 1));
|
|
1645
|
+
const metricDays2 = [];
|
|
1646
|
+
let allow = 0;
|
|
1647
|
+
let ask = 0;
|
|
1648
|
+
let deny = 0;
|
|
1649
|
+
let requests = 0;
|
|
1650
|
+
let costUsd;
|
|
1651
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
|
|
1652
|
+
const date = cursor.toISOString().slice(0, 10);
|
|
1653
|
+
const row = byDate.get(date);
|
|
1654
|
+
allow += row?.allow ?? 0;
|
|
1655
|
+
ask += row?.ask ?? 0;
|
|
1656
|
+
deny += row?.deny ?? 0;
|
|
1657
|
+
requests += row?.requests ?? 0;
|
|
1658
|
+
if (row?.costUsd !== null && row?.costUsd !== void 0) {
|
|
1659
|
+
costUsd = addUsd(costUsd, row.costUsd);
|
|
1660
|
+
}
|
|
1661
|
+
metricDays2.push({
|
|
1662
|
+
allow: row?.allow ?? 0,
|
|
1663
|
+
ask: row?.ask ?? 0,
|
|
1664
|
+
date,
|
|
1665
|
+
deny: row?.deny ?? 0,
|
|
1666
|
+
requests: row?.requests ?? 0,
|
|
1667
|
+
...row?.costUsd !== null && row?.costUsd !== void 0 ? { costUsd: row.costUsd } : {}
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
return {
|
|
1671
|
+
allow,
|
|
1672
|
+
ask,
|
|
1673
|
+
deny,
|
|
1674
|
+
metricDays: metricDays2,
|
|
1675
|
+
requests,
|
|
1676
|
+
...costUsd !== void 0 ? { costUsd } : {}
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1592
1679
|
async function aggregateStats(db, start, end) {
|
|
1593
1680
|
const where = statsWhere(start, end);
|
|
1594
1681
|
const activityDate = sql5`TO_CHAR(
|
|
@@ -1668,14 +1755,40 @@ async function aggregateStats(db, start, end) {
|
|
|
1668
1755
|
]);
|
|
1669
1756
|
return { actorRows, locationRows, metricRows, totals: totalsRows[0] };
|
|
1670
1757
|
}
|
|
1758
|
+
async function aggregateGuardianStats(db, start, end) {
|
|
1759
|
+
const date = sql5`TO_CHAR(
|
|
1760
|
+
${juniorConversationEvents.createdAt} AT TIME ZONE 'UTC',
|
|
1761
|
+
'YYYY-MM-DD'
|
|
1762
|
+
)`;
|
|
1763
|
+
const decision = sql5`${juniorConversationEvents.payload}->>'decision'`;
|
|
1764
|
+
const cost2 = sql5`CASE
|
|
1765
|
+
WHEN jsonb_typeof(${juniorConversationEvents.payload}->'costUsd') = 'number'
|
|
1766
|
+
THEN (${juniorConversationEvents.payload}->>'costUsd')::double precision
|
|
1767
|
+
ELSE NULL
|
|
1768
|
+
END`;
|
|
1769
|
+
return await db.select({
|
|
1770
|
+
allow: sql5`COUNT(*) FILTER (WHERE ${decision} = 'allow')::integer`,
|
|
1771
|
+
ask: sql5`COUNT(*) FILTER (WHERE ${decision} = 'ask')::integer`,
|
|
1772
|
+
costUsd: sql5`SUM(${cost2})::double precision`,
|
|
1773
|
+
date,
|
|
1774
|
+
deny: sql5`COUNT(*) FILTER (WHERE ${decision} = 'deny')::integer`,
|
|
1775
|
+
requests: sql5`COUNT(*)::integer`
|
|
1776
|
+
}).from(juniorConversationEvents).where(
|
|
1777
|
+
and6(
|
|
1778
|
+
eq7(juniorConversationEvents.type, "guardian_action_reviewed"),
|
|
1779
|
+
gte(juniorConversationEvents.createdAt, start),
|
|
1780
|
+
lte(juniorConversationEvents.createdAt, end)
|
|
1781
|
+
)
|
|
1782
|
+
).groupBy(date);
|
|
1783
|
+
}
|
|
1671
1784
|
async function readConversationStatsFromSql() {
|
|
1672
1785
|
const nowMs = Date.now();
|
|
1673
1786
|
const { end, start } = statsWindow(nowMs);
|
|
1674
|
-
const
|
|
1675
|
-
|
|
1676
|
-
start,
|
|
1677
|
-
end
|
|
1678
|
-
);
|
|
1787
|
+
const db = getDb();
|
|
1788
|
+
const [{ actorRows, locationRows, metricRows, totals }, guardianRows] = await Promise.all([
|
|
1789
|
+
aggregateStats(db, start, end),
|
|
1790
|
+
aggregateGuardianStats(db, start, end)
|
|
1791
|
+
]);
|
|
1679
1792
|
const actors = /* @__PURE__ */ new Map();
|
|
1680
1793
|
const locations = /* @__PURE__ */ new Map();
|
|
1681
1794
|
for (const row of actorRows) {
|
|
@@ -1690,6 +1803,7 @@ async function readConversationStatsFromSql() {
|
|
|
1690
1803
|
durationMs: totals?.durationMs ?? 0,
|
|
1691
1804
|
failed: totals?.failed ?? 0,
|
|
1692
1805
|
generatedAt: new Date(nowMs).toISOString(),
|
|
1806
|
+
guardian: guardianStats(guardianRows, nowMs),
|
|
1693
1807
|
metricDays: metricDays(metricRows, nowMs),
|
|
1694
1808
|
locations: statsItems(locations),
|
|
1695
1809
|
actors: statsItems(actors),
|
|
@@ -1740,7 +1854,7 @@ function readDescriptionText(home) {
|
|
|
1740
1854
|
}
|
|
1741
1855
|
}
|
|
1742
1856
|
async function readSkillReports() {
|
|
1743
|
-
const { discoverSkills } = await import("./skills-
|
|
1857
|
+
const { discoverSkills } = await import("./skills-QTI6GGJ4.js");
|
|
1744
1858
|
const skills = await discoverSkills();
|
|
1745
1859
|
return skillReportsSchema.parse(
|
|
1746
1860
|
skills.map((skill) => ({
|
|
@@ -1750,7 +1864,7 @@ async function readSkillReports() {
|
|
|
1750
1864
|
);
|
|
1751
1865
|
}
|
|
1752
1866
|
async function readPlugins() {
|
|
1753
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
1867
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-SZAS6EVH.js");
|
|
1754
1868
|
return pluginsSchema.parse(
|
|
1755
1869
|
pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
1756
1870
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
@@ -1763,7 +1877,7 @@ async function readPlugins() {
|
|
|
1763
1877
|
async function readRuntimeInfoReport() {
|
|
1764
1878
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
1765
1879
|
import("./discovery-GUFTFBTL.js"),
|
|
1766
|
-
import("./catalog-runtime-
|
|
1880
|
+
import("./catalog-runtime-SZAS6EVH.js"),
|
|
1767
1881
|
readPlugins(),
|
|
1768
1882
|
readSkillReports()
|
|
1769
1883
|
]);
|
|
@@ -1779,7 +1893,7 @@ async function readRuntimeInfoReport() {
|
|
|
1779
1893
|
}
|
|
1780
1894
|
async function readPluginOperationalReportFeed() {
|
|
1781
1895
|
const nowMs = Date.now();
|
|
1782
|
-
const { getPluginOperationalReports } = await import("./agent-hooks-
|
|
1896
|
+
const { getPluginOperationalReports } = await import("./agent-hooks-7JCABN73.js");
|
|
1783
1897
|
return pluginOperationalReportFeedSchema.parse({
|
|
1784
1898
|
source: "plugins",
|
|
1785
1899
|
generatedAt: new Date(nowMs).toISOString(),
|
package/dist/app.js
CHANGED
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
startConversationWork,
|
|
51
51
|
startSlackProcessingReaction,
|
|
52
52
|
stripLeadingBotMention
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-5P4QBMTY.js";
|
|
54
54
|
import "./chunk-FA6POGLH.js";
|
|
55
55
|
import {
|
|
56
56
|
ConversationTurnLifecycleService,
|
|
@@ -65,14 +65,15 @@ import {
|
|
|
65
65
|
processPluginTask,
|
|
66
66
|
requireTurnFailureEventId,
|
|
67
67
|
scheduleSessionCompletedPluginTasks
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-DQQCWMA2.js";
|
|
69
69
|
import {
|
|
70
70
|
GET,
|
|
71
71
|
conversationVisibilityFromSlackChannelType,
|
|
72
72
|
resolveSlackChannelTypeFromMessage,
|
|
73
73
|
resolveSlackConversationContext
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-LEQXDCWK.js";
|
|
75
75
|
import "./chunk-4CODA7P5.js";
|
|
76
|
+
import "./chunk-THYOK2SL.js";
|
|
76
77
|
import "./chunk-PE44LDDQ.js";
|
|
77
78
|
import {
|
|
78
79
|
ConversationQueueMessageRejectedError,
|
|
@@ -90,7 +91,7 @@ import {
|
|
|
90
91
|
import {
|
|
91
92
|
validatePluginEgressCredentialHooks,
|
|
92
93
|
validatePluginRegistrations
|
|
93
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-A3TUEGKH.js";
|
|
94
95
|
import {
|
|
95
96
|
defineJuniorPlugins,
|
|
96
97
|
pluginCatalogConfigFromEnv,
|
|
@@ -123,7 +124,7 @@ import {
|
|
|
123
124
|
setConfigDefaults,
|
|
124
125
|
shouldEmitDevAgentTrace,
|
|
125
126
|
shouldPropagateSandboxEgressTrace
|
|
126
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-3S2K7SYY.js";
|
|
127
128
|
import "./chunk-DIB4GX3G.js";
|
|
128
129
|
import {
|
|
129
130
|
RetryableDeliveryError,
|
|
@@ -134,7 +135,7 @@ import {
|
|
|
134
135
|
formatProviderLabel,
|
|
135
136
|
postSlackMessage,
|
|
136
137
|
startOAuthFlow
|
|
137
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-RQ6BLJJD.js";
|
|
138
139
|
import {
|
|
139
140
|
ConversationTurnBoundaryError,
|
|
140
141
|
CooperativeTurnYieldError,
|
|
@@ -190,10 +191,10 @@ import {
|
|
|
190
191
|
trimTrailingAssistantMessages,
|
|
191
192
|
updateConversationStats,
|
|
192
193
|
upsertConversationMessage
|
|
193
|
-
} from "./chunk-
|
|
194
|
+
} from "./chunk-K5DCMBUV.js";
|
|
194
195
|
import "./chunk-HDSDCEPK.js";
|
|
195
|
-
import "./chunk-
|
|
196
|
-
import "./chunk-
|
|
196
|
+
import "./chunk-2DZD6HX2.js";
|
|
197
|
+
import "./chunk-5EUADEG3.js";
|
|
197
198
|
import "./chunk-MU6HHZEN.js";
|
|
198
199
|
import "./chunk-PDO5BLNM.js";
|
|
199
200
|
import "./chunk-UIE3R5XU.js";
|
|
@@ -218,7 +219,7 @@ import {
|
|
|
218
219
|
validatePlugins,
|
|
219
220
|
verifyScheduledTaskCredentialSubject,
|
|
220
221
|
verifySlackDirectCredentialSubject
|
|
221
|
-
} from "./chunk-
|
|
222
|
+
} from "./chunk-ZO4TL4OK.js";
|
|
222
223
|
import {
|
|
223
224
|
contextProvenance,
|
|
224
225
|
createSlackDestination,
|
|
@@ -229,7 +230,7 @@ import {
|
|
|
229
230
|
instructionProvenanceFor,
|
|
230
231
|
requireSlackDestination,
|
|
231
232
|
withConversationEventLock
|
|
232
|
-
} from "./chunk-
|
|
233
|
+
} from "./chunk-DVPWU77W.js";
|
|
233
234
|
import {
|
|
234
235
|
juniorConversationEvents,
|
|
235
236
|
juniorConversations
|
|
@@ -238,7 +239,7 @@ import {
|
|
|
238
239
|
acquireActiveLock,
|
|
239
240
|
getStateAdapter,
|
|
240
241
|
sleep
|
|
241
|
-
} from "./chunk-
|
|
242
|
+
} from "./chunk-ZOOZ25BO.js";
|
|
242
243
|
import {
|
|
243
244
|
STANDARD_MODEL_PROFILE,
|
|
244
245
|
botConfig,
|
|
@@ -256,18 +257,18 @@ import {
|
|
|
256
257
|
modelIdForProfile,
|
|
257
258
|
setSlackReactionConfig,
|
|
258
259
|
standardModelId
|
|
259
|
-
} from "./chunk-
|
|
260
|
+
} from "./chunk-JCJN6TPV.js";
|
|
260
261
|
import {
|
|
261
262
|
juniorDestinations
|
|
262
263
|
} from "./chunk-VFUK3X5B.js";
|
|
263
264
|
import {
|
|
264
265
|
parseSlackThreadId
|
|
265
266
|
} from "./chunk-S7G34U75.js";
|
|
266
|
-
import "./chunk-
|
|
267
|
+
import "./chunk-DAMUPWYR.js";
|
|
267
268
|
import {
|
|
268
269
|
pluginCatalogRuntime
|
|
269
|
-
} from "./chunk-
|
|
270
|
-
import "./chunk-
|
|
270
|
+
} from "./chunk-QKYO7ZNS.js";
|
|
271
|
+
import "./chunk-XLPETJXX.js";
|
|
271
272
|
import {
|
|
272
273
|
credentialSubjectSchema
|
|
273
274
|
} from "./chunk-W3U3YQYI.js";
|
|
@@ -294,7 +295,7 @@ import {
|
|
|
294
295
|
withContext,
|
|
295
296
|
withLogContext,
|
|
296
297
|
withSpan
|
|
297
|
-
} from "./chunk-
|
|
298
|
+
} from "./chunk-JPG43UG7.js";
|
|
298
299
|
import {
|
|
299
300
|
toOptionalString
|
|
300
301
|
} from "./chunk-OB42YVAE.js";
|
|
@@ -309,10 +310,10 @@ import "./chunk-OOUNJNMR.js";
|
|
|
309
310
|
import "./chunk-H4HBKISO.js";
|
|
310
311
|
import {
|
|
311
312
|
JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE
|
|
312
|
-
} from "./chunk-
|
|
313
|
+
} from "./chunk-VTWLP6YS.js";
|
|
313
314
|
import {
|
|
314
315
|
JUNIOR_VERSION
|
|
315
|
-
} from "./chunk-
|
|
316
|
+
} from "./chunk-7YOBVIHY.js";
|
|
316
317
|
import "./chunk-MLKGABMK.js";
|
|
317
318
|
|
|
318
319
|
// src/app.ts
|
|
@@ -4586,6 +4587,7 @@ var ROUTER_CLASSIFIER_MAX_TOKENS = 240;
|
|
|
4586
4587
|
var LEADING_SLACK_MENTION_RE = /^\s*<@([A-Z0-9]+)(?:\|([^>]+))?>[\s,:-]*/i;
|
|
4587
4588
|
var LEADING_NAMED_MENTION_RE = /^\s*@([a-z0-9._-]+)\b[\s,:-]*/i;
|
|
4588
4589
|
var TRANSCRIPT_MESSAGE_LINE_RE = /^\[(assistant|system|user)\]\s+([^:]+):\s+([\s\S]+)$/i;
|
|
4590
|
+
var FORCED_THREAD_OPTOUT_RE = /^!stop(?:\s|$)/i;
|
|
4589
4591
|
var THREAD_OPTOUT_PATTERNS = [
|
|
4590
4592
|
/\bstop (?:watching|replying|participating)\b/i,
|
|
4591
4593
|
/\bstay out\b/i,
|
|
@@ -4629,6 +4631,9 @@ function detectLeadingOtherPartyAddress(rawText, text, botUserName) {
|
|
|
4629
4631
|
}
|
|
4630
4632
|
return `named_mention:${directedName}`;
|
|
4631
4633
|
}
|
|
4634
|
+
function isForcedThreadOptOutCommand(rawText, text) {
|
|
4635
|
+
return FORCED_THREAD_OPTOUT_RE.test(rawText.trim()) || FORCED_THREAD_OPTOUT_RE.test(text.trim());
|
|
4636
|
+
}
|
|
4632
4637
|
function isThreadOptOutInstruction(rawText, text) {
|
|
4633
4638
|
return THREAD_OPTOUT_PATTERNS.some(
|
|
4634
4639
|
(pattern) => pattern.test(rawText) || pattern.test(text)
|
|
@@ -4788,6 +4793,14 @@ function buildRouterSystemPrompt(botUserName) {
|
|
|
4788
4793
|
async function decideSubscribedThreadReply(args) {
|
|
4789
4794
|
const text = args.input.text.trim();
|
|
4790
4795
|
const rawText = args.input.rawText.trim();
|
|
4796
|
+
if (isForcedThreadOptOutCommand(rawText, text)) {
|
|
4797
|
+
return {
|
|
4798
|
+
shouldReply: false,
|
|
4799
|
+
shouldUnsubscribe: true,
|
|
4800
|
+
reason: "thread_opt_out" /* ThreadOptOut */,
|
|
4801
|
+
reasonDetail: "forced !stop command"
|
|
4802
|
+
};
|
|
4803
|
+
}
|
|
4791
4804
|
const preflightDecision = getSubscribedReplyPreflightDecision({
|
|
4792
4805
|
botUserName: args.botUserName,
|
|
4793
4806
|
rawText,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pluginCatalogRuntime
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-QKYO7ZNS.js";
|
|
4
|
+
import "./chunk-XLPETJXX.js";
|
|
5
5
|
import "./chunk-W3U3YQYI.js";
|
|
6
6
|
import "./chunk-HZF5P5UN.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-JPG43UG7.js";
|
|
8
8
|
import "./chunk-OB42YVAE.js";
|
|
9
9
|
import "./chunk-F3B2YJ76.js";
|
|
10
10
|
import "./chunk-6GWA276C.js";
|
|
11
11
|
import "./chunk-OOUNJNMR.js";
|
|
12
12
|
import "./chunk-H4HBKISO.js";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-VTWLP6YS.js";
|
|
14
|
+
import "./chunk-7YOBVIHY.js";
|
|
15
15
|
import "./chunk-MLKGABMK.js";
|
|
16
16
|
export {
|
|
17
17
|
pluginCatalogRuntime
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PiMessage } from "@/chat/pi/messages";
|
|
2
|
+
/**
|
|
3
|
+
* Return the durable tool-result boundary for one additional agent
|
|
4
|
+
* continuation when an ask rejection has no destination-visible reply.
|
|
5
|
+
*/
|
|
6
|
+
export declare function actionConfirmationRetryMessages(messages: readonly PiMessage[]): PiMessage[] | undefined;
|
|
@@ -33,6 +33,12 @@ interface ToolWiringArgs {
|
|
|
33
33
|
currentActor?: Actor;
|
|
34
34
|
/** Live projection of the run's committed instruction-authority actors so far. */
|
|
35
35
|
currentActors?: () => Actor[];
|
|
36
|
+
/** Live Pi transcript used to give Guardian bounded action context. */
|
|
37
|
+
currentAgentMessages: () => PiMessage[];
|
|
38
|
+
/** Durable transcript for this turn only, used to restore rejection state. */
|
|
39
|
+
currentTurnMessages: readonly PiMessage[];
|
|
40
|
+
/** Live same-actor instructions that authorize the pending action. */
|
|
41
|
+
currentUserIntent: () => string;
|
|
36
42
|
artifactStatePatch: Partial<ThreadArtifactsState>;
|
|
37
43
|
availableSkills: SkillMetadata[];
|
|
38
44
|
configurationValues: Record<string, unknown>;
|
|
@@ -43,6 +49,7 @@ interface ToolWiringArgs {
|
|
|
43
49
|
generatedFiles: FileUpload[];
|
|
44
50
|
invokedSkill: SkillMetadata | null;
|
|
45
51
|
observers: AgentRunObservers;
|
|
52
|
+
onFatalToolError(error: Error): void;
|
|
46
53
|
onSandboxRefChanged: (sandboxRef: SandboxRef) => void;
|
|
47
54
|
policy: AgentRunPolicy;
|
|
48
55
|
preAgentPromptMessages: () => PiMessage[];
|
|
@@ -68,6 +75,11 @@ export interface ToolWiring {
|
|
|
68
75
|
getPendingAuthPause: () => AuthorizationPauseError | undefined;
|
|
69
76
|
mcpToolManager: McpToolManager;
|
|
70
77
|
pluginHooks: PluginHookRunner;
|
|
78
|
+
/** Project core-owned review state into one durable Pi tool result. */
|
|
79
|
+
projectActionReviewResult<TResult extends {
|
|
80
|
+
details?: unknown;
|
|
81
|
+
isError?: boolean;
|
|
82
|
+
}>(toolCallId: string, result: TResult): TResult;
|
|
71
83
|
getSandboxRef: () => SandboxRef | undefined;
|
|
72
84
|
close(): Promise<void>;
|
|
73
85
|
toolGuidance: Array<{
|
package/dist/chat/config.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface BotConfig {
|
|
|
12
12
|
crossActorMidRunMode: CrossActorMidRunMode;
|
|
13
13
|
embeddingModelId: string;
|
|
14
14
|
fastModelId: string;
|
|
15
|
+
guardianModelId: string;
|
|
15
16
|
imageGenerationModelId: string;
|
|
16
17
|
loadingMessages: string[];
|
|
17
18
|
profiles: Readonly<Record<string, ExecutionProfileConfig>>;
|
|
@@ -223,6 +223,29 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
|
|
|
223
223
|
type: z.ZodLiteral<"tool_execution_started">;
|
|
224
224
|
toolCallId: z.ZodString;
|
|
225
225
|
toolName: z.ZodString;
|
|
226
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
227
|
+
type: z.ZodLiteral<"guardian_action_reviewed">;
|
|
228
|
+
turnId: z.ZodString;
|
|
229
|
+
toolCallId: z.ZodString;
|
|
230
|
+
toolName: z.ZodString;
|
|
231
|
+
costUsd: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
decision: z.ZodEnum<{
|
|
233
|
+
allow: "allow";
|
|
234
|
+
ask: "ask";
|
|
235
|
+
deny: "deny";
|
|
236
|
+
}>;
|
|
237
|
+
riskLevel: z.ZodEnum<{
|
|
238
|
+
low: "low";
|
|
239
|
+
medium: "medium";
|
|
240
|
+
high: "high";
|
|
241
|
+
critical: "critical";
|
|
242
|
+
}>;
|
|
243
|
+
userAuthorization: z.ZodEnum<{
|
|
244
|
+
unknown: "unknown";
|
|
245
|
+
low: "low";
|
|
246
|
+
medium: "medium";
|
|
247
|
+
high: "high";
|
|
248
|
+
}>;
|
|
226
249
|
}, z.core.$strict>, z.ZodObject<{
|
|
227
250
|
type: z.ZodLiteral<"message_handled">;
|
|
228
251
|
messageId: z.ZodString;
|
|
@@ -252,6 +275,13 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
|
|
|
252
275
|
kind: z.ZodString;
|
|
253
276
|
version: z.ZodNumber;
|
|
254
277
|
content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
278
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
279
|
+
type: z.ZodLiteral<"plugin_event">;
|
|
280
|
+
namespace: z.ZodString;
|
|
281
|
+
name: z.ZodString;
|
|
282
|
+
version: z.ZodNumber;
|
|
283
|
+
turnId: z.ZodString;
|
|
284
|
+
content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
255
285
|
}, z.core.$strict>, z.ZodObject<{
|
|
256
286
|
type: z.ZodLiteral<"turn_routed">;
|
|
257
287
|
turnId: z.ZodString;
|
|
@@ -392,7 +422,7 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
|
|
|
392
422
|
/** One durable conversation event's validated data. */
|
|
393
423
|
export type ConversationEventData = z.output<typeof conversationEventDataSchema>;
|
|
394
424
|
/** Event type names recognized by current readers and observational queries. */
|
|
395
|
-
export declare const KNOWN_CONVERSATION_EVENT_TYPES: readonly ["message", "message_updated", "user_message", "assistant_message", "tool_result", "mcp_provider_connected", "authorization_requested", "authorization_completed", "tool_execution_started", "message_handled", "messages_summarized", "turn_started", "turn_context", "turn_routed", "turn_completed", "turn_failed", "subagent_started", "subagent_ended", "handoff", "compaction"];
|
|
425
|
+
export declare const KNOWN_CONVERSATION_EVENT_TYPES: readonly ["message", "message_updated", "user_message", "assistant_message", "tool_result", "mcp_provider_connected", "authorization_requested", "authorization_completed", "tool_execution_started", "guardian_action_reviewed", "message_handled", "messages_summarized", "turn_started", "turn_context", "plugin_event", "turn_routed", "turn_completed", "turn_failed", "subagent_started", "subagent_ended", "handoff", "compaction"];
|
|
396
426
|
/** One known durable conversation event type name. */
|
|
397
427
|
export type KnownConversationEventType = (typeof KNOWN_CONVERSATION_EVENT_TYPES)[number];
|
|
398
428
|
declare const unknownConversationEventDataSchema: z.ZodObject<{
|
|
@@ -475,6 +505,29 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
475
505
|
type: z.ZodLiteral<"tool_execution_started">;
|
|
476
506
|
toolCallId: z.ZodString;
|
|
477
507
|
toolName: z.ZodString;
|
|
508
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
509
|
+
type: z.ZodLiteral<"guardian_action_reviewed">;
|
|
510
|
+
turnId: z.ZodString;
|
|
511
|
+
toolCallId: z.ZodString;
|
|
512
|
+
toolName: z.ZodString;
|
|
513
|
+
costUsd: z.ZodOptional<z.ZodNumber>;
|
|
514
|
+
decision: z.ZodEnum<{
|
|
515
|
+
allow: "allow";
|
|
516
|
+
ask: "ask";
|
|
517
|
+
deny: "deny";
|
|
518
|
+
}>;
|
|
519
|
+
riskLevel: z.ZodEnum<{
|
|
520
|
+
low: "low";
|
|
521
|
+
medium: "medium";
|
|
522
|
+
high: "high";
|
|
523
|
+
critical: "critical";
|
|
524
|
+
}>;
|
|
525
|
+
userAuthorization: z.ZodEnum<{
|
|
526
|
+
unknown: "unknown";
|
|
527
|
+
low: "low";
|
|
528
|
+
medium: "medium";
|
|
529
|
+
high: "high";
|
|
530
|
+
}>;
|
|
478
531
|
}, z.core.$strict>, z.ZodObject<{
|
|
479
532
|
type: z.ZodLiteral<"message_handled">;
|
|
480
533
|
messageId: z.ZodString;
|
|
@@ -504,6 +557,13 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
504
557
|
kind: z.ZodString;
|
|
505
558
|
version: z.ZodNumber;
|
|
506
559
|
content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
560
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
561
|
+
type: z.ZodLiteral<"plugin_event">;
|
|
562
|
+
namespace: z.ZodString;
|
|
563
|
+
name: z.ZodString;
|
|
564
|
+
version: z.ZodNumber;
|
|
565
|
+
turnId: z.ZodString;
|
|
566
|
+
content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
507
567
|
}, z.core.$strict>, z.ZodObject<{
|
|
508
568
|
type: z.ZodLiteral<"turn_routed">;
|
|
509
569
|
turnId: z.ZodString;
|
|
@@ -750,6 +810,29 @@ export declare const newConversationEventSchema: z.ZodObject<{
|
|
|
750
810
|
type: z.ZodLiteral<"tool_execution_started">;
|
|
751
811
|
toolCallId: z.ZodString;
|
|
752
812
|
toolName: z.ZodString;
|
|
813
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
814
|
+
type: z.ZodLiteral<"guardian_action_reviewed">;
|
|
815
|
+
turnId: z.ZodString;
|
|
816
|
+
toolCallId: z.ZodString;
|
|
817
|
+
toolName: z.ZodString;
|
|
818
|
+
costUsd: z.ZodOptional<z.ZodNumber>;
|
|
819
|
+
decision: z.ZodEnum<{
|
|
820
|
+
allow: "allow";
|
|
821
|
+
ask: "ask";
|
|
822
|
+
deny: "deny";
|
|
823
|
+
}>;
|
|
824
|
+
riskLevel: z.ZodEnum<{
|
|
825
|
+
low: "low";
|
|
826
|
+
medium: "medium";
|
|
827
|
+
high: "high";
|
|
828
|
+
critical: "critical";
|
|
829
|
+
}>;
|
|
830
|
+
userAuthorization: z.ZodEnum<{
|
|
831
|
+
unknown: "unknown";
|
|
832
|
+
low: "low";
|
|
833
|
+
medium: "medium";
|
|
834
|
+
high: "high";
|
|
835
|
+
}>;
|
|
753
836
|
}, z.core.$strict>, z.ZodObject<{
|
|
754
837
|
type: z.ZodLiteral<"message_handled">;
|
|
755
838
|
messageId: z.ZodString;
|
|
@@ -779,6 +862,13 @@ export declare const newConversationEventSchema: z.ZodObject<{
|
|
|
779
862
|
kind: z.ZodString;
|
|
780
863
|
version: z.ZodNumber;
|
|
781
864
|
content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
865
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
866
|
+
type: z.ZodLiteral<"plugin_event">;
|
|
867
|
+
namespace: z.ZodString;
|
|
868
|
+
name: z.ZodString;
|
|
869
|
+
version: z.ZodNumber;
|
|
870
|
+
turnId: z.ZodString;
|
|
871
|
+
content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
782
872
|
}, z.core.$strict>, z.ZodObject<{
|
|
783
873
|
type: z.ZodLiteral<"turn_routed">;
|
|
784
874
|
turnId: z.ZodString;
|