@sentry/junior 0.138.0 → 0.139.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-SCR74Q3E.js → agent-hooks-MJXMD7JP.js} +10 -10
- package/dist/api/schema/task.d.ts +100 -1
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +9 -1
- package/dist/api.js +198 -54
- package/dist/app.js +288 -602
- package/dist/{catalog-runtime-IU3QF4GG.js → catalog-runtime-GCCFYPIK.js} +6 -6
- package/dist/chat/agent/request.d.ts +12 -2
- package/dist/chat/credentials/context.d.ts +14 -0
- package/dist/chat/resource-events/actor.d.ts +23 -0
- package/dist/chat/state/turn-session.d.ts +1 -3
- package/dist/chat/tasks/execution-stats.d.ts +34 -3
- package/dist/chat/tasks/read.d.ts +3 -1
- package/dist/{chunk-JNNJZURV.js → chunk-2ECYPYKP.js} +1 -1
- package/dist/chunk-3T2JAGRH.js +115 -0
- package/dist/{chunk-PB3CXNVL.js → chunk-4V4QIYJH.js} +1 -1
- package/dist/{chunk-FEUNPTGV.js → chunk-5GSZWRE2.js} +434 -12
- package/dist/{chunk-QS527AV5.js → chunk-6OHTDR4F.js} +1 -1
- package/dist/{chunk-TCS76X5D.js → chunk-6SU2DT27.js} +2 -2
- package/dist/{chunk-BYW4B4PR.js → chunk-75I3UBIL.js} +2 -2
- package/dist/{chunk-ZBSMCXKV.js → chunk-AEQISMMU.js} +7 -6
- package/dist/{chunk-KDCHVT25.js → chunk-C2N6MNO4.js} +9 -2
- package/dist/{chunk-KFRHRSCJ.js → chunk-CXH25EL4.js} +2 -2
- package/dist/{chunk-TDJCLNDH.js → chunk-DW4PMHNW.js} +3 -3
- package/dist/{chunk-A7WCHXZV.js → chunk-G52UXKGO.js} +4 -4
- package/dist/chunk-GI52BW74.js +207 -0
- package/dist/{chunk-ZXNTJJIE.js → chunk-GWQSZT4C.js} +2 -2
- package/dist/{chunk-EPBBYMNE.js → chunk-HUO3UTAQ.js} +1 -1
- package/dist/{chunk-5MXWHTCK.js → chunk-IIESAYDL.js} +6 -6
- package/dist/{chunk-YU5QUF67.js → chunk-J3S57AXY.js} +1 -1
- package/dist/{chunk-E5UYAIKJ.js → chunk-J6EJQCHY.js} +17 -19
- package/dist/{chunk-5LTJ4ITU.js → chunk-MQ5RYATN.js} +4 -4
- package/dist/{chunk-BOLJOV5T.js → chunk-MXTVUV3I.js} +1 -1
- package/dist/{chunk-FNLBTB4K.js → chunk-MXVD2BDS.js} +1 -1
- package/dist/{chunk-TUUDXEXU.js → chunk-PJW6U46K.js} +12 -15
- package/dist/{chunk-SIPKWSXK.js → chunk-QTBKPZDA.js} +3 -3
- package/dist/{chunk-77VDLF3Z.js → chunk-RUIXF3YQ.js} +10 -0
- package/dist/{chunk-SD3OFRWY.js → chunk-U27DSXKB.js} +6 -6
- package/dist/{chunk-C7ZVPO4Z.js → chunk-U7CMWQ7Z.js} +1 -1
- package/dist/{chunk-DCLLQGS6.js → chunk-UDBUS533.js} +8 -3
- package/dist/{chunk-HIWJWWMT.js → chunk-WQRX57EA.js} +3 -3
- package/dist/{chunk-LPVUNO2W.js → chunk-WZH4JV7R.js} +7 -7
- package/dist/{chunk-HCIVH3JS.js → chunk-YCTDA7BD.js} +28 -0
- package/dist/{chunk-VPZFVJND.js → chunk-YGZ2OLXL.js} +1 -1
- package/dist/{chunk-N7WARMC6.js → chunk-ZQCGQMF2.js} +7 -7
- package/dist/{chunk-RZIBSCYC.js → chunk-ZYQSPQYR.js} +25 -22
- package/dist/cli/chat.js +33 -33
- package/dist/cli/check.js +7 -7
- package/dist/cli/plugins.js +14 -14
- package/dist/cli/snapshot-create.js +10 -10
- package/dist/cli/upgrade.js +8 -8
- package/dist/db/schema/task-executions.d.ts +23 -2
- package/dist/db/schema.d.ts +20 -1
- package/dist/{db-UO2IWXGA.js → db-UXPPGHDF.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-MAQI43LX.js → oauth-callback-server-4ZYMD5UA.js} +22 -21
- package/dist/{runner-PIUQEXKE.js → runner-MZSEONRZ.js} +18 -16
- package/dist/{sandbox-egress-signals-A5HWIQH4.js → sandbox-egress-signals-EKPAVWQL.js} +2 -2
- package/dist/{skills-4ARJADHQ.js → skills-IMVPXSQ7.js} +7 -7
- package/dist/spawn-S5LSVOCE.js +38 -0
- package/dist/{validation-S3EE3HWL.js → validation-ZKCY2BVR.js} +7 -7
- package/dist/version.js +1 -1
- package/dist/{work-UARRUAW3.js → work-GG3XDYRX.js} +18 -18
- package/dist/{worker-DOCIRVD3.js → worker-23AUELCJ.js} +10 -10
- package/migrations/0022_task_execution_status.sql +3 -0
- package/migrations/meta/0022_snapshot.json +2186 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +5 -5
- package/dist/chunk-ELKW5FIB.js +0 -233
- package/dist/spawn-G2AWPMCT.js +0 -38
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pluginCatalogRuntime
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-6OHTDR4F.js";
|
|
4
|
+
import "./chunk-CXH25EL4.js";
|
|
5
|
+
import "./chunk-RUIXF3YQ.js";
|
|
6
6
|
import "./chunk-HZF5P5UN.js";
|
|
7
7
|
import "./chunk-F3B2YJ76.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-2ECYPYKP.js";
|
|
9
9
|
import "./chunk-6GWA276C.js";
|
|
10
10
|
import "./chunk-OOUNJNMR.js";
|
|
11
11
|
import "./chunk-H4HBKISO.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-C2N6MNO4.js";
|
|
13
|
+
import "./chunk-U7CMWQ7Z.js";
|
|
14
14
|
import "./chunk-MLKGABMK.js";
|
|
15
15
|
export {
|
|
16
16
|
pluginCatalogRuntime
|
|
@@ -75,10 +75,20 @@ export interface AgentRunInput {
|
|
|
75
75
|
piMessages?: PiMessage[];
|
|
76
76
|
conversationContext?: string;
|
|
77
77
|
}
|
|
78
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Identity and addressing for one run.
|
|
80
|
+
*
|
|
81
|
+
* Set `actor` first (who runs). Derive `credentialContext` with
|
|
82
|
+
* `credentialContextForActor(actor, subject?)` unless a caller already bound
|
|
83
|
+
* credentials (dispatch with delegated subject). They name the same principal
|
|
84
|
+
* except when a system actor carries `credentialContext.subject` for delegated
|
|
85
|
+
* user tokens.
|
|
86
|
+
*/
|
|
79
87
|
export interface AgentRunRouting {
|
|
80
|
-
|
|
88
|
+
/** Who this run executes as. Prefer always setting this. */
|
|
81
89
|
actor?: Actor;
|
|
90
|
+
/** Credential authority projected from actor (plus optional subject). */
|
|
91
|
+
credentialContext?: CredentialContext;
|
|
82
92
|
source: Source;
|
|
83
93
|
slackConversation?: SlackConversationContext;
|
|
84
94
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type Actor } from "@/chat/actor";
|
|
2
3
|
declare const credentialSubjectBindingSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
4
|
type: z.ZodLiteral<"slack-direct-conversation">;
|
|
4
5
|
teamId: z.ZodString;
|
|
@@ -100,6 +101,19 @@ export type CredentialSubjectBinding = z.output<typeof credentialSubjectBindingS
|
|
|
100
101
|
export type CredentialSystemActor = z.output<typeof credentialSystemActorSchema>;
|
|
101
102
|
export type CredentialSubject = z.output<typeof credentialSubjectSchema>;
|
|
102
103
|
export type CredentialContext = z.output<typeof credentialContextSchema>;
|
|
104
|
+
/**
|
|
105
|
+
* Build credential authority from the run actor.
|
|
106
|
+
*
|
|
107
|
+
* `actor` is the rich execution principal. This projects the credential stub
|
|
108
|
+
* tools/auth need from it:
|
|
109
|
+
* - user actor → `{ actor: { type: "user", userId } }`
|
|
110
|
+
* - system actor → `{ actor: systemActor, subject? }`
|
|
111
|
+
*
|
|
112
|
+
* They only diverge when a system run carries an explicit delegated `subject`
|
|
113
|
+
* (scheduled/event-task creator credentials). Callers should set `actor` first,
|
|
114
|
+
* then derive this — do not hand-build parallel shapes.
|
|
115
|
+
*/
|
|
116
|
+
export declare function credentialContextForActor(actor: Actor, subject?: CredentialSubject): CredentialContext;
|
|
103
117
|
/** Return the user whose OAuth token may satisfy this credential request. */
|
|
104
118
|
export declare function credentialUserSubjectId(context: CredentialContext): string | undefined;
|
|
105
119
|
/** Parse an untrusted credential context payload from sandbox egress state. */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Synthetic Slack author id stamped on resource-event mailbox messages. */
|
|
2
|
+
export declare const RESOURCE_EVENT_SLACK_AUTHOR_ID = "UJRNEVENT";
|
|
3
|
+
/** System execution actor for every resource-event turn. */
|
|
4
|
+
export declare const RESOURCE_EVENT_SYSTEM_ACTOR: {
|
|
5
|
+
readonly platform: "system";
|
|
6
|
+
readonly name: "resource-event";
|
|
7
|
+
};
|
|
8
|
+
/** Whether a durable conversation message is a resource-event turn input. */
|
|
9
|
+
export declare function isResourceEventConversationMessage(message: {
|
|
10
|
+
author?: {
|
|
11
|
+
userId?: string;
|
|
12
|
+
};
|
|
13
|
+
meta?: {
|
|
14
|
+
eventType?: string;
|
|
15
|
+
};
|
|
16
|
+
}): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether a Slack Message payload is a synthetic resource-event notification.
|
|
19
|
+
* Checks the raw `event_type` marker stamped at mailbox serialization.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isResourceEventSlackMessage(message: {
|
|
22
|
+
raw?: unknown;
|
|
23
|
+
}): boolean;
|
|
@@ -42,11 +42,9 @@ export interface AgentTurnSessionRecord {
|
|
|
42
42
|
* All distinct actors annotated on this run's committed instruction-authority
|
|
43
43
|
* messages, in first-seen order. Persisted as an attribution handle so a
|
|
44
44
|
* summary-only handoff cannot erase them. It never grants authority or
|
|
45
|
-
* replaces the singular execution actor.
|
|
45
|
+
* replaces the singular execution actor, which is rebuilt at resume.
|
|
46
46
|
*/
|
|
47
47
|
actors: Actor[];
|
|
48
|
-
/** The single actor this run executes as (credential binding, auth flows). */
|
|
49
|
-
actor?: Actor;
|
|
50
48
|
resumeReason?: AgentTurnResumeReason;
|
|
51
49
|
resumedFromSliceId?: number;
|
|
52
50
|
sessionId: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type TaskExecutionStatus } from "@/db/schema/task-executions";
|
|
1
2
|
export declare const TASK_EXECUTION_TYPES: readonly ["scheduled", "event"];
|
|
3
|
+
export declare const TASK_EXECUTION_STATUSES: readonly ["blocked", "completed", "failed"];
|
|
2
4
|
export type TaskExecutionType = (typeof TASK_EXECUTION_TYPES)[number];
|
|
3
5
|
export type TaskExecutionDay = {
|
|
4
6
|
date: string;
|
|
@@ -11,18 +13,47 @@ export type TaskExecutionSummary = {
|
|
|
11
13
|
runsLast7Days: number;
|
|
12
14
|
totalRuns: number;
|
|
13
15
|
};
|
|
14
|
-
|
|
16
|
+
export type TaskExecutionRecord = {
|
|
17
|
+
conversationId?: string;
|
|
18
|
+
executedAt: string;
|
|
19
|
+
executionId: string;
|
|
20
|
+
status: TaskExecutionStatus;
|
|
21
|
+
title?: string;
|
|
22
|
+
};
|
|
23
|
+
export type TaskExecutionStatusDay = {
|
|
24
|
+
blocked: number;
|
|
25
|
+
completed: number;
|
|
26
|
+
date: string;
|
|
27
|
+
failed: number;
|
|
28
|
+
};
|
|
29
|
+
/** Record one terminal task execution and its durable conversation when present. */
|
|
15
30
|
export declare function recordTaskExecution(type: TaskExecutionType, taskId: string, options: {
|
|
16
|
-
conversationId
|
|
31
|
+
conversationId?: string;
|
|
17
32
|
executionId: string;
|
|
18
33
|
namespace?: string;
|
|
19
34
|
nowMs?: number;
|
|
35
|
+
status?: TaskExecutionStatus;
|
|
20
36
|
}): Promise<void>;
|
|
21
37
|
/** Load usage analytics for all tasks of one type and namespace. */
|
|
22
38
|
export declare function readTaskExecutionSummaries(type: TaskExecutionType, namespace: string, options?: {
|
|
23
39
|
nowMs?: number;
|
|
24
40
|
}): Promise<Map<string, TaskExecutionSummary>>;
|
|
25
|
-
/** Load a fixed trailing window of
|
|
41
|
+
/** Load a fixed trailing window of completed executions stacked by task type. */
|
|
26
42
|
export declare function readTaskExecutionDays(dayCount?: number, options?: {
|
|
27
43
|
nowMs?: number;
|
|
28
44
|
}): Promise<TaskExecutionDay[]>;
|
|
45
|
+
/** Load newest-first executions for one task, with conversation titles when present. */
|
|
46
|
+
export declare function readTaskExecutions(args: {
|
|
47
|
+
kind: TaskExecutionType;
|
|
48
|
+
limit: number;
|
|
49
|
+
namespace?: string;
|
|
50
|
+
taskId: string;
|
|
51
|
+
}): Promise<TaskExecutionRecord[]>;
|
|
52
|
+
/** Load a fixed trailing window of terminal executions for one task by status. */
|
|
53
|
+
export declare function readTaskExecutionStatusDays(args: {
|
|
54
|
+
dayCount?: number;
|
|
55
|
+
kind: TaskExecutionType;
|
|
56
|
+
namespace?: string;
|
|
57
|
+
nowMs?: number;
|
|
58
|
+
taskId: string;
|
|
59
|
+
}): Promise<TaskExecutionStatusDay[]>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { User } from "@sentry/junior-plugin-api";
|
|
2
|
-
import type { TaskList } from "@/api/schema/task";
|
|
2
|
+
import type { TaskExecutionList, TaskList } from "@/api/schema/task";
|
|
3
3
|
/** Read viewer-owned and public-workspace tasks as one bounded newest-first projection. */
|
|
4
4
|
export declare function readViewerTasks(user: User): Promise<TaskList>;
|
|
5
5
|
export declare class ViewerTaskNotFoundError extends Error {
|
|
6
6
|
constructor();
|
|
7
7
|
}
|
|
8
|
+
/** Read one viewer-visible task and its newest terminal executions. */
|
|
9
|
+
export declare function readViewerTaskExecutions(user: User, kind: "scheduled" | "event", id: string): Promise<TaskExecutionList>;
|
|
8
10
|
/** Delete one viewer-owned scheduled or event task. */
|
|
9
11
|
export declare function deleteViewerTask(user: User, kind: "scheduled" | "event", id: string): Promise<void>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
healthReportSchema
|
|
3
|
+
} from "./chunk-UTL3MHPC.js";
|
|
4
|
+
import {
|
|
5
|
+
parseSlackThreadId
|
|
6
|
+
} from "./chunk-MXVD2BDS.js";
|
|
7
|
+
import {
|
|
8
|
+
normalizeSlackConversationId
|
|
9
|
+
} from "./chunk-6SU2DT27.js";
|
|
10
|
+
|
|
11
|
+
// src/handlers/health.ts
|
|
12
|
+
function readHealthReport() {
|
|
13
|
+
return healthReportSchema.parse({
|
|
14
|
+
status: "ok",
|
|
15
|
+
service: "junior",
|
|
16
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function GET() {
|
|
20
|
+
return Response.json(readHealthReport());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/chat/slack/conversation-context.ts
|
|
24
|
+
function normalizeConversationName(type, channelName) {
|
|
25
|
+
const trimmed = channelName?.trim();
|
|
26
|
+
if (!trimmed) return void 0;
|
|
27
|
+
if (type === "public_channel" || type === "private_channel" || type === "private_channel_or_group_dm") {
|
|
28
|
+
return trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
|
|
29
|
+
}
|
|
30
|
+
return trimmed;
|
|
31
|
+
}
|
|
32
|
+
function typeFromSlackChannelType(channelType) {
|
|
33
|
+
if (channelType === "channel") return "public_channel";
|
|
34
|
+
if (channelType === "group") return "private_channel";
|
|
35
|
+
if (channelType === "mpim") return "group_dm";
|
|
36
|
+
if (channelType === "im") return "direct_message";
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
function typeFromChannelId(channelId, channelName) {
|
|
40
|
+
const normalized = normalizeSlackConversationId(channelId);
|
|
41
|
+
if (!normalized) return void 0;
|
|
42
|
+
if (normalized.startsWith("C")) return "public_channel";
|
|
43
|
+
if (normalized.startsWith("D")) return "direct_message";
|
|
44
|
+
if (normalized.startsWith("G")) {
|
|
45
|
+
return channelName?.trim().startsWith("mpdm-") ? "group_dm" : "private_channel_or_group_dm";
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
function toSlackEventChannelType(channelType) {
|
|
50
|
+
if (channelType === "channel" || channelType === "group" || channelType === "mpim" || channelType === "im") {
|
|
51
|
+
return channelType;
|
|
52
|
+
}
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
function conversationVisibilityFromSlackChannelType(channelType) {
|
|
56
|
+
if (!channelType) return void 0;
|
|
57
|
+
return channelType === "channel" ? "public" : "private";
|
|
58
|
+
}
|
|
59
|
+
function resolveSlackChannelTypeFromMessage(message) {
|
|
60
|
+
const raw = message.raw;
|
|
61
|
+
if (!raw || typeof raw !== "object") {
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
const channelType = raw.channel_type;
|
|
65
|
+
return typeof channelType === "string" ? toSlackEventChannelType(channelType.trim()) : void 0;
|
|
66
|
+
}
|
|
67
|
+
function resolveSlackConversationContext(input) {
|
|
68
|
+
const type = typeFromSlackChannelType(input.channelType) ?? typeFromChannelId(input.channelId, input.channelName);
|
|
69
|
+
if (!type) return void 0;
|
|
70
|
+
const name = normalizeConversationName(type, input.channelName);
|
|
71
|
+
const visibility = conversationVisibilityFromSlackChannelType(
|
|
72
|
+
input.channelType
|
|
73
|
+
);
|
|
74
|
+
return {
|
|
75
|
+
type,
|
|
76
|
+
...name ? { name } : {},
|
|
77
|
+
...visibility ? { visibility } : {}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function resolveSlackConversationContextFromThreadId(input) {
|
|
81
|
+
const slackThread = parseSlackThreadId(input.threadId);
|
|
82
|
+
const context = resolveSlackConversationContext({
|
|
83
|
+
channelId: slackThread?.channelId,
|
|
84
|
+
channelName: input.channelName
|
|
85
|
+
});
|
|
86
|
+
if (!context || !input.visibility) {
|
|
87
|
+
return context;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
...context,
|
|
91
|
+
type: input.visibility === "private" && context.type === "public_channel" ? "private_channel" : context.type,
|
|
92
|
+
visibility: input.visibility
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function formatSlackConversationTypeLabel(type) {
|
|
96
|
+
if (type === "public_channel") return "Public Channel";
|
|
97
|
+
if (type === "private_channel") return "Private Channel";
|
|
98
|
+
if (type === "group_dm") return "Group DM";
|
|
99
|
+
if (type === "direct_message") return "Direct Message";
|
|
100
|
+
return "Private Channel or Group DM";
|
|
101
|
+
}
|
|
102
|
+
function formatSlackConversationRedactedLabel(context) {
|
|
103
|
+
if (!context) return void 0;
|
|
104
|
+
return formatSlackConversationTypeLabel(context.type);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
readHealthReport,
|
|
109
|
+
GET,
|
|
110
|
+
conversationVisibilityFromSlackChannelType,
|
|
111
|
+
resolveSlackChannelTypeFromMessage,
|
|
112
|
+
resolveSlackConversationContext,
|
|
113
|
+
resolveSlackConversationContextFromThreadId,
|
|
114
|
+
formatSlackConversationRedactedLabel
|
|
115
|
+
};
|