@sentry/junior 0.206.0 → 0.208.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-C9yuiZUF.js → agent-BfxfHsf1.js} +375 -346
- package/dist/{agent-hooks-DNjlz2A-.js → agent-hooks-CuGjLjmR.js} +224 -97
- package/dist/{agent-runner-E67lFrDG.js → agent-runner-Dz1PMKP0.js} +9 -9
- package/dist/api/schema.d.ts +39 -39
- package/dist/api/schema.js +2 -2
- package/dist/api.d.ts +1 -1
- package/dist/api.js +154 -154
- package/dist/{app-AxGmJHwK.d.ts → app-DfNrn_gS.d.ts} +2 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +185 -183
- package/dist/{auth-pause-state-MVZ6xvEK.js → auth-pause-state-Bjoh8wCy.js} +7 -7
- package/dist/{briefs-CvJFQvhJ.js → briefs-q_onrGmf.js} +3 -3
- package/dist/{catalog-runtime-TBR8n4e1.js → catalog-runtime-D8YUMNhb.js} +1 -1
- package/dist/{checkpoint-BY47jJCB.js → checkpoint-FKMcINix.js} +8 -8
- package/dist/cli/chat.js +13 -13
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +1 -1
- package/dist/cli/plugins.js +3 -3
- package/dist/cli/snapshot-create.js +3 -3
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-ceE7NtvC.js → client-bRyPqwAV.js} +4 -4
- package/dist/{config-CIE83sR2.js → config-EtF2uEaW.js} +6 -6
- package/dist/{context-B45_WqVX.js → context-Bplcgypl.js} +13 -13
- package/dist/{conversation-privacy-Auyq26XQ.js → conversation-privacy-whGaV2TG.js} +1 -1
- package/dist/{credential-sync-BO33aNQd.js → credential-sync-DM-EE1ey.js} +21 -21
- package/dist/{db-BeyXKJOI.d.ts → db-D74z7BZH.d.ts} +1 -1
- package/dist/{execution-stats-SiS2FLcv.js → execution-stats-C-f8zwMU.js} +77 -77
- package/dist/{executor-BfbYPW63.js → executor-BW5qp0jC.js} +43 -14
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-CyTc24Es.js → job-queue-BIHNIEIX.js} +1 -1
- package/dist/{logging-D37bayDc.js → logging-sNS84Yuu.js} +1 -1
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-BtfOeHTZ.js → oauth-callback-server-Co6D_yXP.js} +2 -2
- package/dist/{pending-auth-BPUzcs7n.js → pending-auth-CRJCt9Ux.js} +2 -2
- package/dist/{profile-CSixooTi.js → profile-BfLMVhWo.js} +4 -4
- package/dist/{prompt-3gqNY1Ka.js → prompt-x-0ZtTyb.js} +14 -14
- package/dist/{registry-DiR0-xRg.js → registry-Cyww_jnC.js} +2 -2
- package/dist/{resolve-Bn5q__9b.js → resolve-BApIFQXX.js} +2 -2
- package/dist/{runner-DFx3dIJH.js → runner-C9okx4GL.js} +10 -10
- package/dist/{sandbox-egress-signals-bwvjihxA.js → sandbox-egress-signals-BHfx0esj.js} +1 -1
- package/dist/{schema-8GXFfclK.js → schema-CwTeb-BF.js} +39 -39
- package/dist/{skills-BhM5qyCF.js → skills-DhL_wXEp.js} +2 -2
- package/dist/{spawn-Dk0PqdH6.js → spawn-msnzfE8_.js} +2 -2
- package/dist/{stats-DKRP4rsY.js → stats-Cq5w_Awk.js} +292 -268
- package/dist/{store-C5qxF2ac.d.ts → store-Det8MQ9g.d.ts} +1 -1
- package/dist/{task-queue-CdpTvu4R.js → task-queue-JfmWmpjS.js} +3 -3
- package/dist/{task-runner-alpjVSxQ.js → task-runner-Cm0gXoLH.js} +15 -15
- package/dist/{thread-state-CRK7aA41.js → thread-state-lw2QwQ-y.js} +5 -5
- package/dist/{turn-execution-XtyzIHog.js → turn-execution-C7K6lQp1.js} +3 -3
- package/dist/{turn-lifecycle-VbwZLfBv.js → turn-lifecycle-DVlJLwB0.js} +1 -1
- package/dist/{usage-D4A48Bdl.js → usage-BMuAlKIW.js} +2 -2
- package/dist/{validation-jn_46o4U.js → validation-BI-r3iQA.js} +1 -1
- package/dist/{version-DcfJxB4z.js → version-s6smK6lP.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{web-authorization-CsfLSfEs.js → web-authorization-C9MxPvXX.js} +1 -1
- package/dist/{web-input-BPp_sc7t.js → web-input-CwVlaLd0.js} +7 -109
- package/dist/{work-Di-ubSGg.js → work-BK0W1QAt.js} +9 -9
- package/dist/{worker-Cu_D5Mr8.js → worker-D-WWKHQD.js} +5 -5
- package/migrations/0041_automation_outcomes_backfill.sql +27 -0
- package/migrations/meta/0041_snapshot.json +3516 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +5 -5
package/dist/api.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { f as logWarn, u as logException } from "./logging-
|
|
2
|
-
import { _ as parseSlackMessageTs, h as parseSlackTeamId, p as parseSlackChannelId } from "./context-
|
|
3
|
-
import { $ as resolveViewerUser, Ct as
|
|
1
|
+
import { f as logWarn, u as logException } from "./logging-sNS84Yuu.js";
|
|
2
|
+
import { _ as parseSlackMessageTs, h as parseSlackTeamId, p as parseSlackChannelId } from "./context-Bplcgypl.js";
|
|
3
|
+
import { $ as resolveViewerUser, $t as parseSessionSource, Ct as conversationArchivedForEmail, D as SANDBOX_RUNTIME, Dt as conversationNotArchivedForEmail, Et as conversationHasParticipantUser, Ft as listConversationAnnotations, Gt as getDb, It as listConversationAnnotationsById, J as withSlackRetries, Kt as getSqlExecutor, Mt as readConversationEventPage, Nt as buildSentryConversationUrl, Ot as conversationNotArchivedForUser, S as WorkspaceValidationError, St as conversationArchiveTimes, Tt as conversationHasParticipantEmail, U as getSlackClient, Wt as getConversationStore, Z as findUserByEmail, Zt as locationFromRow, _ as deleteWorkspace, b as listWorkspaces, bt as createPluginLogger, en as resolveRootConversationId, et as updateViewerDisplayName, g as createWorkspace, j as workspaceRepoCheckoutPath, jt as readLatestConversationBrief, kt as viewerConversationMembership, u as getPlugins, v as getWorkspace, wt as conversationArchivedForUser, x as updateWorkspace, xt as readConversationAccessFromSql } from "./agent-hooks-CuGjLjmR.js";
|
|
4
4
|
import { n as juniorDestinations } from "./destinations-BeBiJeEM.js";
|
|
5
|
-
import { C as conversationReadColumns, E as juniorUsers, T as juniorIdentities, _ as juniorConversationEvents, b as juniorCodeChanges, g as juniorConversationBriefs, m as juniorConversationParticipants, o as juniorSchedulerTasks, v as juniorApiTokens, w as juniorConversations, x as juniorCodeRepositories } from "./executor-
|
|
5
|
+
import { C as conversationReadColumns, E as juniorUsers, T as juniorIdentities, _ as juniorConversationEvents, b as juniorCodeChanges, g as juniorConversationBriefs, m as juniorConversationParticipants, o as juniorSchedulerTasks, v as juniorApiTokens, w as juniorConversations, x as juniorCodeRepositories } from "./executor-BW5qp0jC.js";
|
|
6
6
|
import { D as createConversationBodySchema, O as createConversationMessageBodySchema, T as conversationStatsReportSchema, _ as conversationParamsSchema, a as cancelConversationPendingMessagesBodySchema, c as conversationAttachmentParamsSchema, d as conversationDetailReportSchema, g as conversationFeedSchema, h as conversationFeedQuerySchema, i as archiveConversationResponseSchema, m as conversationEventsQuerySchema, o as cancelConversationPendingMessagesResponseSchema, p as conversationEventPageSchema, r as archiveConversationBodySchema, t as acceptedConversationMessageSchema, u as conversationDetailQuerySchema, x as conversationPendingMessagesReportSchema } from "./conversation-AA4R1VUn.js";
|
|
7
|
-
import { a as hasAgentTurnUsage, i as agentTurnUsageSchema, s as fallbackShortTitle } from "./usage-
|
|
8
|
-
import { n as hash, t as create } from "./profile-
|
|
9
|
-
import { A as
|
|
10
|
-
import { t as getCachedSnapshot } from "./resolve-
|
|
7
|
+
import { a as hasAgentTurnUsage, i as agentTurnUsageSchema, s as fallbackShortTitle } from "./usage-BMuAlKIW.js";
|
|
8
|
+
import { n as hash, t as create } from "./profile-BfLMVhWo.js";
|
|
9
|
+
import { A as eventAutomationTriggerAvailable, F as effectiveTaskOutcomes, G as listDeletedEventAutomationsCreatedBy, H as eventAutomationBelongsToUser, J as listPublicEventAutomationsForTeams, K as listEventAutomationsCreatedBy, Tt as getConversation, V as deleteEventAutomation, W as getEventAutomation, X as getEventCatalog, _ as parseScheduledAutomationRow, c as parseSlackThreadId, ht as cancelHumanFacingPendingMessages, i as readLiveAttachment, m as listPublicScheduledAutomationsForTeams, n as readStats, p as isListedScheduledAutomation, v as readScheduledAutomation, y as saveScheduledAutomation } from "./stats-Cq5w_Awk.js";
|
|
10
|
+
import { t as getCachedSnapshot } from "./resolve-BApIFQXX.js";
|
|
11
11
|
import { t as getVercelConversationWorkQueue } from "./vercel-queue-DIkVcfK4.js";
|
|
12
12
|
import { c as runtimeInfoReportSchema, n as pluginOperationalReportFeedSchema, s as pluginsSchema, t as healthReportSchema, u as skillReportsSchema } from "./reporting-schema-DosTN__Q.js";
|
|
13
|
-
import {
|
|
14
|
-
import { a as
|
|
15
|
-
import { r as getWebAuthorization } from "./web-authorization-
|
|
16
|
-
import { $ as sumUtcHoursIntoSixHours, A as actorProfileReportSchema, C as createPersonalTokenBodySchema, D as personalTokenParamsSchema, F as locationDirectoryReportSchema, G as codePersonReportSchema, I as locationParamsSchema, J as HOUR_MS$1, L as activityDays$1, M as personalSpendReportSchema, O as revokePersonalTokenResponseSchema, P as locationDetailReportSchema, Q as startOfUtcHour, R as activityHours$1, T as personalTokenListSchema, W as codeOverviewReportSchema, X as fillUtcHours, Y as fillUtcDays, Z as fillUtcSixHours, _ as
|
|
13
|
+
import { a as webActorFromEmail, c as formatSlackConversationRedactedLabel, d as resolveSlackConversationContextFromThreadId, f as lookupSlackUser, g as readHealthReport, m as createVercelAttachmentStorage, p as legacyWebMailboxMetadataSchema, r as createAndEnqueueConversation, t as appendAndEnqueueWebMessage } from "./web-input-CwVlaLd0.js";
|
|
14
|
+
import { a as readAutomationExecutionStatusDays, c as readAutomationExecutions, d as conversationActiveDaysColumn, f as conversationAggregateColumns, i as readAutomationExecutionHours, l as readAutomationRuns, n as readAutomationExecutionByConversationId, o as readAutomationExecutionStatusHours, p as conversationRangeColumns, r as readAutomationExecutionDays, s as readAutomationExecutionSummaries, t as emptyAutomationRunWindows } from "./execution-stats-C-f8zwMU.js";
|
|
15
|
+
import { r as getWebAuthorization } from "./web-authorization-C9MxPvXX.js";
|
|
16
|
+
import { $ as sumUtcHoursIntoSixHours, A as actorProfileReportSchema, C as createPersonalTokenBodySchema, D as personalTokenParamsSchema, F as locationDirectoryReportSchema, G as codePersonReportSchema, I as locationParamsSchema, J as HOUR_MS$1, L as activityDays$1, M as personalSpendReportSchema, O as revokePersonalTokenResponseSchema, P as locationDetailReportSchema, Q as startOfUtcHour, R as activityHours$1, T as personalTokenListSchema, W as codeOverviewReportSchema, X as fillUtcHours, Y as fillUtcDays, Z as fillUtcSixHours, _ as automationRunListSchema, a as workspaceBodySchema, at as apiErrorSchema, et as trailingUtcDayWindow, g as automationParamsSchema, h as automationListSchema, i as deleteWorkspaceResponseSchema, it as utcHourKey, j as personParamsSchema, k as actorDirectoryReportSchema, l as workspaceSchema, m as automationListQuerySchema, n as statsReportSchema, nt as trailingUtcSixHourWindow, o as workspaceListSchema, q as DAY_MS$1, rt as utcDayKey, s as workspaceParamsSchema, tt as trailingUtcHourWindow, u as automationExecutionListSchema, w as createdPersonalTokenSchema, z as activitySixHours$1 } from "./schema-CwTeb-BF.js";
|
|
17
17
|
import { Hono } from "hono";
|
|
18
18
|
import path from "node:path";
|
|
19
19
|
import { z } from "zod";
|
|
@@ -1081,23 +1081,23 @@ async function readConversationFeed(options = {}) {
|
|
|
1081
1081
|
return conversationFeedSchema.parse(await readConversationFeedFromSql(options));
|
|
1082
1082
|
}
|
|
1083
1083
|
//#endregion
|
|
1084
|
-
//#region src/chat/scheduled-
|
|
1084
|
+
//#region src/chat/scheduled-automations/personal.ts
|
|
1085
1085
|
const cursorSchema = z.object({
|
|
1086
1086
|
createdAtMs: z.number().finite(),
|
|
1087
1087
|
id: z.string().min(1),
|
|
1088
1088
|
query: z.string().max(200).optional(),
|
|
1089
1089
|
version: z.literal(1)
|
|
1090
1090
|
}).strict();
|
|
1091
|
-
var
|
|
1091
|
+
var InvalidScheduledAutomationCursorError = class extends Error {
|
|
1092
1092
|
constructor() {
|
|
1093
|
-
super("Scheduled
|
|
1094
|
-
this.name = "
|
|
1093
|
+
super("Scheduled automation cursor is invalid.");
|
|
1094
|
+
this.name = "InvalidScheduledAutomationCursorError";
|
|
1095
1095
|
}
|
|
1096
1096
|
};
|
|
1097
|
-
var
|
|
1097
|
+
var PersonalScheduledAutomationNotFoundError = class extends Error {
|
|
1098
1098
|
constructor() {
|
|
1099
|
-
super("Scheduled
|
|
1100
|
-
this.name = "
|
|
1099
|
+
super("Scheduled automation was not found.");
|
|
1100
|
+
this.name = "PersonalScheduledAutomationNotFoundError";
|
|
1101
1101
|
}
|
|
1102
1102
|
};
|
|
1103
1103
|
function normalizeQuery(query) {
|
|
@@ -1107,13 +1107,13 @@ function decodeCursor(value, query) {
|
|
|
1107
1107
|
if (!value) return void 0;
|
|
1108
1108
|
try {
|
|
1109
1109
|
const parsed = cursorSchema.parse(JSON.parse(Buffer.from(value, "base64url").toString("utf8")));
|
|
1110
|
-
if (parsed.query !== query) throw new
|
|
1110
|
+
if (parsed.query !== query) throw new InvalidScheduledAutomationCursorError();
|
|
1111
1111
|
return {
|
|
1112
1112
|
createdAtMs: parsed.createdAtMs,
|
|
1113
1113
|
id: parsed.id
|
|
1114
1114
|
};
|
|
1115
1115
|
} catch {
|
|
1116
|
-
throw new
|
|
1116
|
+
throw new InvalidScheduledAutomationCursorError();
|
|
1117
1117
|
}
|
|
1118
1118
|
}
|
|
1119
1119
|
function encodeCursor(task, query) {
|
|
@@ -1124,12 +1124,12 @@ function encodeCursor(task, query) {
|
|
|
1124
1124
|
version: 1
|
|
1125
1125
|
}), "utf8").toString("base64url");
|
|
1126
1126
|
}
|
|
1127
|
-
/** Delete one scheduled
|
|
1128
|
-
async function
|
|
1127
|
+
/** Delete one scheduled automation created by the viewer. */
|
|
1128
|
+
async function deleteViewerScheduledAutomation(db, user, id, nowMs = Date.now()) {
|
|
1129
1129
|
const identityIds = new Set(user.identities.map((identity) => identity.id));
|
|
1130
|
-
const task = await
|
|
1131
|
-
if (!task || task.status === "deleted" || !identityIds.has(task.creatorIdentityId)) throw new
|
|
1132
|
-
await
|
|
1130
|
+
const task = await readScheduledAutomation(db, id);
|
|
1131
|
+
if (!task || task.status === "deleted" || !identityIds.has(task.creatorIdentityId)) throw new PersonalScheduledAutomationNotFoundError();
|
|
1132
|
+
await saveScheduledAutomation(db, {
|
|
1133
1133
|
...task,
|
|
1134
1134
|
nextRunAtMs: void 0,
|
|
1135
1135
|
runNowAtMs: void 0,
|
|
@@ -1137,16 +1137,16 @@ async function deleteViewerScheduledTask(db, user, id, nowMs = Date.now()) {
|
|
|
1137
1137
|
updatedAtMs: nowMs
|
|
1138
1138
|
});
|
|
1139
1139
|
}
|
|
1140
|
-
/** List scheduled
|
|
1141
|
-
async function
|
|
1140
|
+
/** List scheduled automations created by the viewer with a stable SQL cursor. */
|
|
1141
|
+
async function listViewerScheduledAutomations(db, user, input) {
|
|
1142
1142
|
const identityIds = user.identities.map((identity) => identity.id);
|
|
1143
|
-
if (identityIds.length === 0) return {
|
|
1143
|
+
if (identityIds.length === 0) return { automations: [] };
|
|
1144
1144
|
const query = normalizeQuery(input.query);
|
|
1145
1145
|
const cursor = decodeCursor(input.cursor, query);
|
|
1146
|
-
const
|
|
1146
|
+
const automations = [];
|
|
1147
1147
|
let before = cursor;
|
|
1148
1148
|
const fetchLimit = input.limit + 1;
|
|
1149
|
-
while (
|
|
1149
|
+
while (automations.length < fetchLimit) {
|
|
1150
1150
|
const cursorFilter = before ? or(lt(juniorSchedulerTasks.createdAtMs, before.createdAtMs), and(eq(juniorSchedulerTasks.createdAtMs, before.createdAtMs), lt(juniorSchedulerTasks.id, before.id))) : void 0;
|
|
1151
1151
|
const search = query ? sql`strpos(lower(coalesce(${juniorSchedulerTasks.title}, ${juniorSchedulerTasks.record}->'task'->>'text')), ${query}) > 0` : void 0;
|
|
1152
1152
|
const rows = await db.select({
|
|
@@ -1156,7 +1156,7 @@ async function listViewerScheduledTasks(db, user, input) {
|
|
|
1156
1156
|
record: juniorSchedulerTasks.record,
|
|
1157
1157
|
title: juniorSchedulerTasks.title
|
|
1158
1158
|
}).from(juniorSchedulerTasks).where(and(notInArray(juniorSchedulerTasks.status, ["deleted", "paused"]), inArray(juniorSchedulerTasks.creatorIdentityId, identityIds), cursorFilter, search)).orderBy(desc(juniorSchedulerTasks.createdAtMs), desc(juniorSchedulerTasks.id)).limit(fetchLimit);
|
|
1159
|
-
|
|
1159
|
+
automations.push(...rows.map(parseScheduledAutomationRow).filter(isListedScheduledAutomation));
|
|
1160
1160
|
if (rows.length < fetchLimit) break;
|
|
1161
1161
|
const last = rows.at(-1);
|
|
1162
1162
|
before = {
|
|
@@ -1164,14 +1164,14 @@ async function listViewerScheduledTasks(db, user, input) {
|
|
|
1164
1164
|
id: last.id
|
|
1165
1165
|
};
|
|
1166
1166
|
}
|
|
1167
|
-
const page =
|
|
1167
|
+
const page = automations.slice(0, input.limit);
|
|
1168
1168
|
return {
|
|
1169
|
-
|
|
1170
|
-
...
|
|
1169
|
+
automations: page,
|
|
1170
|
+
...automations.length > input.limit && page.length > 0 ? { nextCursor: encodeCursor(page.at(-1), query) } : void 0
|
|
1171
1171
|
};
|
|
1172
1172
|
}
|
|
1173
1173
|
//#endregion
|
|
1174
|
-
//#region src/chat/
|
|
1174
|
+
//#region src/chat/automations/read.ts
|
|
1175
1175
|
const TASK_LIST_LIMIT = 100;
|
|
1176
1176
|
const TASK_FETCH_LIMIT = 101;
|
|
1177
1177
|
const TASK_EXECUTION_LIST_LIMIT = 100;
|
|
@@ -1232,14 +1232,14 @@ function executionSummaryFields(stats) {
|
|
|
1232
1232
|
return {
|
|
1233
1233
|
...stats?.lastConversationId ? { lastConversationId: stats.lastConversationId } : void 0,
|
|
1234
1234
|
...stats?.lastExecutedAtMs ? { lastRunAt: new Date(stats.lastExecutedAtMs).toISOString() } : void 0,
|
|
1235
|
-
runs: stats?.runs ??
|
|
1235
|
+
runs: stats?.runs ?? emptyAutomationRunWindows(),
|
|
1236
1236
|
totalRuns: stats?.totalRuns ?? 0
|
|
1237
1237
|
};
|
|
1238
1238
|
}
|
|
1239
|
-
function
|
|
1240
|
-
if (task.status === "deleted") throw new Error("Deleted scheduled
|
|
1239
|
+
function scheduledAutomationSummary(task, ownedByViewer, destination, stats, createdByEmail) {
|
|
1240
|
+
if (task.status === "deleted") throw new Error("Deleted scheduled automations cannot enter the Automations view");
|
|
1241
1241
|
const nextRunAtMs = task.runNowAtMs ?? task.nextRunAtMs;
|
|
1242
|
-
const instruction = displayText(task.task.text, "Untitled scheduled
|
|
1242
|
+
const instruction = displayText(task.task.text, "Untitled scheduled automation");
|
|
1243
1243
|
return {
|
|
1244
1244
|
createdAt: new Date(task.createdAtMs).toISOString(),
|
|
1245
1245
|
createdBy: creatorLabel(task.createdBy),
|
|
@@ -1259,10 +1259,10 @@ function scheduledTaskSummary(task, ownedByViewer, destination, stats, createdBy
|
|
|
1259
1259
|
schedule: displayText(task.schedule.description, "Schedule unavailable"),
|
|
1260
1260
|
status: task.status,
|
|
1261
1261
|
outcomes: effectiveTaskOutcomes(task.outcomes, task.destination),
|
|
1262
|
-
title: taskDisplayTitle(task.title, instruction, "Untitled scheduled
|
|
1262
|
+
title: taskDisplayTitle(task.title, instruction, "Untitled scheduled automation")
|
|
1263
1263
|
};
|
|
1264
1264
|
}
|
|
1265
|
-
function
|
|
1265
|
+
function eventAutomationSummary(task, ownedByViewer, destination, stats, createdByEmail) {
|
|
1266
1266
|
const instruction = task.task.text;
|
|
1267
1267
|
return {
|
|
1268
1268
|
createdAt: new Date(task.createdAtMs).toISOString(),
|
|
@@ -1283,8 +1283,8 @@ function eventTaskSummary(task, ownedByViewer, destination, stats, createdByEmai
|
|
|
1283
1283
|
resource: `${task.trigger.label} · ${task.trigger.identifier}`,
|
|
1284
1284
|
source: task.trigger.namespace,
|
|
1285
1285
|
outcomes: effectiveTaskOutcomes(task.outcomes, task.destination),
|
|
1286
|
-
title: taskDisplayTitle(task.title, instruction, "Untitled event
|
|
1287
|
-
triggerAvailable:
|
|
1286
|
+
title: taskDisplayTitle(task.title, instruction, "Untitled event automation"),
|
|
1287
|
+
triggerAvailable: eventAutomationTriggerAvailable(task, getEventCatalog())
|
|
1288
1288
|
};
|
|
1289
1289
|
}
|
|
1290
1290
|
function viewerTeamIds(user) {
|
|
@@ -1295,7 +1295,7 @@ async function resolveViewerTaskCandidate(user, kind, id) {
|
|
|
1295
1295
|
const identityIds = new Set(user.identities.map((identity) => identity.id));
|
|
1296
1296
|
const teamIds = viewerTeamIds(user);
|
|
1297
1297
|
if (kind === "scheduled") {
|
|
1298
|
-
const task = await
|
|
1298
|
+
const task = await readScheduledAutomation(db, id);
|
|
1299
1299
|
if (!task || task.status === "deleted") return void 0;
|
|
1300
1300
|
const ownedByViewer = identityIds.has(task.creatorIdentityId);
|
|
1301
1301
|
const destination = (await destinationDetails([task.destination])).get(destinationKey(task.destination));
|
|
@@ -1308,9 +1308,9 @@ async function resolveViewerTaskCandidate(user, kind, id) {
|
|
|
1308
1308
|
task
|
|
1309
1309
|
};
|
|
1310
1310
|
}
|
|
1311
|
-
const task = await
|
|
1311
|
+
const task = await getEventAutomation(db, id);
|
|
1312
1312
|
if (!task || task.status === "deleted") return void 0;
|
|
1313
|
-
const ownedByViewer =
|
|
1313
|
+
const ownedByViewer = eventAutomationBelongsToUser(task, user);
|
|
1314
1314
|
const destination = (await destinationDetails([task.destination])).get(destinationKey(task.destination));
|
|
1315
1315
|
const publicToViewer = teamIds.includes(task.destination.teamId) && destination?.visibility === "public";
|
|
1316
1316
|
if (!ownedByViewer && !publicToViewer) return void 0;
|
|
@@ -1321,22 +1321,22 @@ async function resolveViewerTaskCandidate(user, kind, id) {
|
|
|
1321
1321
|
task
|
|
1322
1322
|
};
|
|
1323
1323
|
}
|
|
1324
|
-
async function
|
|
1324
|
+
async function automationSummaryForCandidate(candidate) {
|
|
1325
1325
|
const [destinations, creatorEmails, stats] = await Promise.all([
|
|
1326
1326
|
destinationDetails([candidate.task.destination]),
|
|
1327
1327
|
creatorProfileEmails([candidate]),
|
|
1328
|
-
|
|
1328
|
+
readAutomationExecutionSummaries(candidate.kind, "junior")
|
|
1329
1329
|
]);
|
|
1330
1330
|
const destination = destinations.get(destinationKey(candidate.task.destination)) ?? {
|
|
1331
1331
|
label: `Channel ${candidate.task.destination.channelId}`,
|
|
1332
1332
|
visibility: "private"
|
|
1333
1333
|
};
|
|
1334
1334
|
const createdByEmail = creatorEmails.get(creatorKey(candidate.task.destination.teamId, candidate.task.createdBy.slackUserId));
|
|
1335
|
-
if (candidate.kind === "scheduled") return
|
|
1336
|
-
return
|
|
1335
|
+
if (candidate.kind === "scheduled") return scheduledAutomationSummary(candidate.task, candidate.ownedByViewer, destination, stats.get(candidate.task.id), createdByEmail);
|
|
1336
|
+
return eventAutomationSummary(candidate.task, candidate.ownedByViewer, destination, stats.get(candidate.task.id), createdByEmail);
|
|
1337
1337
|
}
|
|
1338
|
-
/** Read viewer-owned and public-workspace
|
|
1339
|
-
function
|
|
1338
|
+
/** Read viewer-owned and public-workspace automations as one bounded newest-first projection. */
|
|
1339
|
+
function emptyAutomationExecutionDay(date) {
|
|
1340
1340
|
return {
|
|
1341
1341
|
costUsd: 0,
|
|
1342
1342
|
date,
|
|
@@ -1344,7 +1344,7 @@ function emptyTaskExecutionDay(date) {
|
|
|
1344
1344
|
scheduled: 0
|
|
1345
1345
|
};
|
|
1346
1346
|
}
|
|
1347
|
-
function
|
|
1347
|
+
function emptyAutomationExecutionStatusDay(date) {
|
|
1348
1348
|
return {
|
|
1349
1349
|
blocked: 0,
|
|
1350
1350
|
completed: 0,
|
|
@@ -1352,51 +1352,51 @@ function emptyTaskExecutionStatusDay(date) {
|
|
|
1352
1352
|
failed: 0
|
|
1353
1353
|
};
|
|
1354
1354
|
}
|
|
1355
|
-
function
|
|
1355
|
+
function automationExecutionSixHours(hours, nowMs = Date.now()) {
|
|
1356
1356
|
return sumUtcHoursIntoSixHours({
|
|
1357
|
-
empty:
|
|
1357
|
+
empty: emptyAutomationExecutionDay,
|
|
1358
1358
|
hours,
|
|
1359
1359
|
nowMs
|
|
1360
1360
|
});
|
|
1361
1361
|
}
|
|
1362
|
-
function
|
|
1362
|
+
function automationExecutionStatusSixHours(hours, nowMs = Date.now()) {
|
|
1363
1363
|
return sumUtcHoursIntoSixHours({
|
|
1364
|
-
empty:
|
|
1364
|
+
empty: emptyAutomationExecutionStatusDay,
|
|
1365
1365
|
hours,
|
|
1366
1366
|
nowMs
|
|
1367
1367
|
});
|
|
1368
1368
|
}
|
|
1369
|
-
/** List one viewer's scheduled and event
|
|
1370
|
-
async function
|
|
1369
|
+
/** List one viewer's scheduled and event automations, optionally filtered by title or instruction search. */
|
|
1370
|
+
async function readViewerAutomations(user, input = {}) {
|
|
1371
1371
|
const db = getDb();
|
|
1372
1372
|
const query = input.q?.trim().toLowerCase() || void 0;
|
|
1373
1373
|
const identityIds = new Set(user.identities.map((identity) => identity.id));
|
|
1374
1374
|
const teamIds = viewerTeamIds(user);
|
|
1375
|
-
const [scheduledPage, publicScheduled,
|
|
1376
|
-
|
|
1375
|
+
const [scheduledPage, publicScheduled, eventAutomations, publicEventAutomations] = await Promise.all([
|
|
1376
|
+
listViewerScheduledAutomations(db, user, {
|
|
1377
1377
|
limit: TASK_FETCH_LIMIT,
|
|
1378
1378
|
query
|
|
1379
1379
|
}),
|
|
1380
|
-
|
|
1380
|
+
listPublicScheduledAutomationsForTeams(db, teamIds, {
|
|
1381
1381
|
limit: TASK_FETCH_LIMIT,
|
|
1382
1382
|
query
|
|
1383
1383
|
}),
|
|
1384
|
-
|
|
1385
|
-
|
|
1384
|
+
listEventAutomationsCreatedBy(db, user, TASK_FETCH_LIMIT, query),
|
|
1385
|
+
listPublicEventAutomationsForTeams(db, teamIds, TASK_FETCH_LIMIT, query)
|
|
1386
1386
|
]);
|
|
1387
1387
|
const candidatesById = /* @__PURE__ */ new Map();
|
|
1388
1388
|
const publicScheduledIds = new Set(publicScheduled.map((task) => task.id));
|
|
1389
|
-
const
|
|
1390
|
-
for (const task of [...scheduledPage.
|
|
1389
|
+
const publicEventAutomationIds = new Set(publicEventAutomations.map((task) => task.id));
|
|
1390
|
+
for (const task of [...scheduledPage.automations, ...publicScheduled]) candidatesById.set(`scheduled:${task.id}`, {
|
|
1391
1391
|
kind: "scheduled",
|
|
1392
1392
|
ownedByViewer: identityIds.has(task.creatorIdentityId),
|
|
1393
1393
|
publicToViewer: publicScheduledIds.has(task.id),
|
|
1394
1394
|
task
|
|
1395
1395
|
});
|
|
1396
|
-
for (const task of [...
|
|
1396
|
+
for (const task of [...eventAutomations, ...publicEventAutomations]) candidatesById.set(`event:${task.id}`, {
|
|
1397
1397
|
kind: "event",
|
|
1398
|
-
ownedByViewer:
|
|
1399
|
-
publicToViewer:
|
|
1398
|
+
ownedByViewer: eventAutomationBelongsToUser(task, user),
|
|
1399
|
+
publicToViewer: publicEventAutomationIds.has(task.id),
|
|
1400
1400
|
task
|
|
1401
1401
|
});
|
|
1402
1402
|
const candidates = [...candidatesById.values()].sort((left, right) => right.task.createdAtMs - left.task.createdAtMs || right.task.id.localeCompare(left.task.id));
|
|
@@ -1407,30 +1407,30 @@ async function readViewerTasks(user, input = {}) {
|
|
|
1407
1407
|
const [destinations, creatorEmails] = await Promise.all([destinationDetails(selected.map(({ task }) => task.destination)), creatorProfileEmails(selected)]);
|
|
1408
1408
|
const visible = selected.filter((candidate) => candidate.ownedByViewer || destinations.get(destinationKey(candidate.task.destination))?.visibility === "public");
|
|
1409
1409
|
const [executionDays, executionHours, scheduledStats, eventStats] = await Promise.all([
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1410
|
+
readAutomationExecutionDays(),
|
|
1411
|
+
readAutomationExecutionHours(),
|
|
1412
|
+
readAutomationExecutionSummaries("scheduled", "junior"),
|
|
1413
|
+
readAutomationExecutionSummaries("event", "junior")
|
|
1414
1414
|
]);
|
|
1415
|
-
const
|
|
1415
|
+
const automations = visible.map((candidate) => {
|
|
1416
1416
|
const destination = destinations.get(destinationKey(candidate.task.destination)) ?? {
|
|
1417
1417
|
label: `Channel ${candidate.task.destination.channelId}`,
|
|
1418
1418
|
visibility: "private"
|
|
1419
1419
|
};
|
|
1420
1420
|
const createdByEmail = creatorEmails.get(creatorKey(candidate.task.destination.teamId, candidate.task.createdBy.slackUserId));
|
|
1421
|
-
if (candidate.kind === "scheduled") return
|
|
1422
|
-
return
|
|
1421
|
+
if (candidate.kind === "scheduled") return scheduledAutomationSummary(candidate.task, candidate.ownedByViewer, destination, scheduledStats.get(candidate.task.id), createdByEmail);
|
|
1422
|
+
return eventAutomationSummary(candidate.task, candidate.ownedByViewer, destination, eventStats.get(candidate.task.id), createdByEmail);
|
|
1423
1423
|
});
|
|
1424
1424
|
return {
|
|
1425
1425
|
executionDays,
|
|
1426
1426
|
executionHours,
|
|
1427
|
-
executionSixHours:
|
|
1428
|
-
|
|
1427
|
+
executionSixHours: automationExecutionSixHours(executionHours),
|
|
1428
|
+
automations,
|
|
1429
1429
|
truncated: ownedCandidates.length > TASK_LIST_LIMIT || publicCandidates.length > TASK_LIST_LIMIT
|
|
1430
1430
|
};
|
|
1431
1431
|
}
|
|
1432
|
-
/** Load deleted scheduled
|
|
1433
|
-
async function
|
|
1432
|
+
/** Load deleted scheduled automations the viewer still owns, newest first. */
|
|
1433
|
+
async function readDeletedOwnedScheduledAutomations(user) {
|
|
1434
1434
|
const identityIds = user.identities.map((identity) => identity.id);
|
|
1435
1435
|
if (identityIds.length === 0) return [];
|
|
1436
1436
|
return (await getDb().select({
|
|
@@ -1438,68 +1438,68 @@ async function readDeletedOwnedScheduledTasks(user) {
|
|
|
1438
1438
|
id: juniorSchedulerTasks.id,
|
|
1439
1439
|
record: juniorSchedulerTasks.record,
|
|
1440
1440
|
title: juniorSchedulerTasks.title
|
|
1441
|
-
}).from(juniorSchedulerTasks).where(and(eq(juniorSchedulerTasks.status, "deleted"), inArray(juniorSchedulerTasks.creatorIdentityId, identityIds))).orderBy(desc(juniorSchedulerTasks.createdAtMs), desc(juniorSchedulerTasks.id)).limit(TASK_EXECUTION_LIST_LIMIT)).map(
|
|
1441
|
+
}).from(juniorSchedulerTasks).where(and(eq(juniorSchedulerTasks.status, "deleted"), inArray(juniorSchedulerTasks.creatorIdentityId, identityIds))).orderBy(desc(juniorSchedulerTasks.createdAtMs), desc(juniorSchedulerTasks.id)).limit(TASK_EXECUTION_LIST_LIMIT)).map(parseScheduledAutomationRow).filter((task) => task?.status === "deleted");
|
|
1442
1442
|
}
|
|
1443
|
-
/** Load deleted event
|
|
1444
|
-
async function
|
|
1445
|
-
return await
|
|
1443
|
+
/** Load deleted event automations the viewer still owns, newest first. */
|
|
1444
|
+
async function readDeletedOwnedEventAutomations(user) {
|
|
1445
|
+
return await listDeletedEventAutomationsCreatedBy(getDb(), user, TASK_EXECUTION_LIST_LIMIT);
|
|
1446
1446
|
}
|
|
1447
|
-
function
|
|
1448
|
-
return
|
|
1447
|
+
function automationTitleForRun(run, automationTitles) {
|
|
1448
|
+
return automationTitles.get(`${run.kind}:${run.automationId}`) ?? run.title?.trim() ?? "Untitled task";
|
|
1449
1449
|
}
|
|
1450
|
-
function
|
|
1451
|
-
const key = `${args.kind}:${args.
|
|
1452
|
-
if (
|
|
1453
|
-
|
|
1454
|
-
|
|
1450
|
+
function addDeletedAutomationRun(args, automationTitles, automations) {
|
|
1451
|
+
const key = `${args.kind}:${args.automationId}`;
|
|
1452
|
+
if (automationTitles.has(key)) return;
|
|
1453
|
+
automationTitles.set(key, args.title);
|
|
1454
|
+
automations.push({
|
|
1455
1455
|
kind: args.kind,
|
|
1456
|
-
|
|
1456
|
+
automationId: args.automationId
|
|
1457
1457
|
});
|
|
1458
1458
|
}
|
|
1459
1459
|
/**
|
|
1460
|
-
* Read newest runs across live viewer-visible
|
|
1460
|
+
* Read newest runs across live viewer-visible automations and deleted automations the
|
|
1461
1461
|
* viewer owns. Deleted task rows stay available so history does not depend on
|
|
1462
1462
|
* conversation actor membership.
|
|
1463
1463
|
*/
|
|
1464
|
-
async function
|
|
1464
|
+
async function readViewerAutomationRuns(user) {
|
|
1465
1465
|
const [taskList, deletedScheduled, deletedEvent] = await Promise.all([
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1466
|
+
readViewerAutomations(user),
|
|
1467
|
+
readDeletedOwnedScheduledAutomations(user),
|
|
1468
|
+
readDeletedOwnedEventAutomations(user)
|
|
1469
1469
|
]);
|
|
1470
|
-
const
|
|
1471
|
-
const
|
|
1472
|
-
for (const task of taskList.
|
|
1473
|
-
|
|
1474
|
-
|
|
1470
|
+
const automationTitles = /* @__PURE__ */ new Map();
|
|
1471
|
+
const automations = [];
|
|
1472
|
+
for (const task of taskList.automations) {
|
|
1473
|
+
automationTitles.set(`${task.kind}:${task.id}`, task.title);
|
|
1474
|
+
automations.push({
|
|
1475
1475
|
kind: task.kind,
|
|
1476
|
-
|
|
1476
|
+
automationId: task.id
|
|
1477
1477
|
});
|
|
1478
1478
|
}
|
|
1479
1479
|
for (const task of deletedScheduled) {
|
|
1480
|
-
const instruction = displayText(task.task.text, "Untitled scheduled
|
|
1481
|
-
|
|
1480
|
+
const instruction = displayText(task.task.text, "Untitled scheduled automation");
|
|
1481
|
+
addDeletedAutomationRun({
|
|
1482
1482
|
kind: "scheduled",
|
|
1483
|
-
|
|
1484
|
-
title: taskDisplayTitle(task.title, instruction, "Untitled scheduled
|
|
1485
|
-
},
|
|
1483
|
+
automationId: task.id,
|
|
1484
|
+
title: taskDisplayTitle(task.title, instruction, "Untitled scheduled automation")
|
|
1485
|
+
}, automationTitles, automations);
|
|
1486
1486
|
}
|
|
1487
1487
|
for (const task of deletedEvent) {
|
|
1488
|
-
const instruction = displayText(task.task.text, "Untitled event
|
|
1489
|
-
|
|
1488
|
+
const instruction = displayText(task.task.text, "Untitled event automation");
|
|
1489
|
+
addDeletedAutomationRun({
|
|
1490
1490
|
kind: "event",
|
|
1491
|
-
|
|
1492
|
-
title: taskDisplayTitle(task.title, instruction, "Untitled event
|
|
1493
|
-
},
|
|
1491
|
+
automationId: task.id,
|
|
1492
|
+
title: taskDisplayTitle(task.title, instruction, "Untitled event automation")
|
|
1493
|
+
}, automationTitles, automations);
|
|
1494
1494
|
}
|
|
1495
|
-
const runs = await
|
|
1495
|
+
const runs = await readAutomationRuns({
|
|
1496
1496
|
limit: 101,
|
|
1497
|
-
|
|
1497
|
+
automations
|
|
1498
1498
|
});
|
|
1499
1499
|
return {
|
|
1500
1500
|
runs: runs.slice(0, TASK_EXECUTION_LIST_LIMIT).map((run) => ({
|
|
1501
1501
|
...run,
|
|
1502
|
-
|
|
1502
|
+
automationTitle: automationTitleForRun(run, automationTitles)
|
|
1503
1503
|
})),
|
|
1504
1504
|
truncated: runs.length > TASK_EXECUTION_LIST_LIMIT
|
|
1505
1505
|
};
|
|
@@ -1511,70 +1511,70 @@ var ViewerTaskNotFoundError = class extends Error {
|
|
|
1511
1511
|
}
|
|
1512
1512
|
};
|
|
1513
1513
|
/** Read one viewer-visible task and its newest terminal executions. */
|
|
1514
|
-
async function
|
|
1514
|
+
async function readViewerAutomationExecutions(user, kind, id) {
|
|
1515
1515
|
const candidate = await resolveViewerTaskCandidate(user, kind, id);
|
|
1516
1516
|
if (!candidate) throw new ViewerTaskNotFoundError();
|
|
1517
|
-
const [
|
|
1518
|
-
|
|
1519
|
-
|
|
1517
|
+
const [automation, executions, executionDays, executionHours] = await Promise.all([
|
|
1518
|
+
automationSummaryForCandidate(candidate),
|
|
1519
|
+
readAutomationExecutions({
|
|
1520
1520
|
kind,
|
|
1521
1521
|
limit: 101,
|
|
1522
|
-
|
|
1522
|
+
automationId: id
|
|
1523
1523
|
}),
|
|
1524
|
-
|
|
1524
|
+
readAutomationExecutionStatusDays({
|
|
1525
1525
|
kind,
|
|
1526
|
-
|
|
1526
|
+
automationId: id
|
|
1527
1527
|
}),
|
|
1528
|
-
|
|
1528
|
+
readAutomationExecutionStatusHours({
|
|
1529
1529
|
kind,
|
|
1530
|
-
|
|
1530
|
+
automationId: id
|
|
1531
1531
|
})
|
|
1532
1532
|
]);
|
|
1533
1533
|
return {
|
|
1534
1534
|
executionDays,
|
|
1535
1535
|
executionHours,
|
|
1536
|
-
executionSixHours:
|
|
1536
|
+
executionSixHours: automationExecutionStatusSixHours(executionHours),
|
|
1537
1537
|
executions: executions.slice(0, TASK_EXECUTION_LIST_LIMIT),
|
|
1538
|
-
|
|
1538
|
+
automation,
|
|
1539
1539
|
truncated: executions.length > TASK_EXECUTION_LIST_LIMIT
|
|
1540
1540
|
};
|
|
1541
1541
|
}
|
|
1542
1542
|
/** Resolve the source task for one conversation when a terminal execution links it. */
|
|
1543
1543
|
async function readConversationSourceTask(args) {
|
|
1544
|
-
const execution = await
|
|
1544
|
+
const execution = await readAutomationExecutionByConversationId({ conversationId: args.conversationId });
|
|
1545
1545
|
if (!execution) return void 0;
|
|
1546
1546
|
if (!args.viewer) return { kind: execution.kind };
|
|
1547
|
-
const candidate = await resolveViewerTaskCandidate(args.viewer, execution.kind, execution.
|
|
1547
|
+
const candidate = await resolveViewerTaskCandidate(args.viewer, execution.kind, execution.automationId);
|
|
1548
1548
|
if (!candidate) return { kind: execution.kind };
|
|
1549
1549
|
if (candidate.kind === "scheduled") {
|
|
1550
|
-
const instruction = displayText(candidate.task.task.text, "Untitled scheduled
|
|
1550
|
+
const instruction = displayText(candidate.task.task.text, "Untitled scheduled automation");
|
|
1551
1551
|
return {
|
|
1552
1552
|
id: candidate.task.id,
|
|
1553
1553
|
kind: "scheduled",
|
|
1554
1554
|
label: instruction,
|
|
1555
|
-
title: taskDisplayTitle(candidate.task.title, instruction, "Untitled scheduled
|
|
1555
|
+
title: taskDisplayTitle(candidate.task.title, instruction, "Untitled scheduled automation")
|
|
1556
1556
|
};
|
|
1557
1557
|
}
|
|
1558
|
-
const instruction = displayText(candidate.task.task.text, "Untitled event
|
|
1558
|
+
const instruction = displayText(candidate.task.task.text, "Untitled event automation");
|
|
1559
1559
|
return {
|
|
1560
1560
|
id: candidate.task.id,
|
|
1561
1561
|
kind: "event",
|
|
1562
1562
|
label: instruction,
|
|
1563
|
-
title: taskDisplayTitle(candidate.task.title, instruction, "Untitled event
|
|
1563
|
+
title: taskDisplayTitle(candidate.task.title, instruction, "Untitled event automation")
|
|
1564
1564
|
};
|
|
1565
1565
|
}
|
|
1566
|
-
/** Delete one viewer-owned scheduled or event
|
|
1566
|
+
/** Delete one viewer-owned scheduled or event automation. */
|
|
1567
1567
|
async function deleteViewerTask(user, kind, id) {
|
|
1568
1568
|
if (kind === "scheduled") try {
|
|
1569
|
-
await
|
|
1569
|
+
await deleteViewerScheduledAutomation(getDb(), user, id);
|
|
1570
1570
|
return;
|
|
1571
1571
|
} catch (error) {
|
|
1572
|
-
if (error instanceof
|
|
1572
|
+
if (error instanceof PersonalScheduledAutomationNotFoundError) throw new ViewerTaskNotFoundError();
|
|
1573
1573
|
throw error;
|
|
1574
1574
|
}
|
|
1575
|
-
const task = await
|
|
1576
|
-
if (!task || task.status === "deleted" || !
|
|
1577
|
-
await
|
|
1575
|
+
const task = await getEventAutomation(getDb(), id);
|
|
1576
|
+
if (!task || task.status === "deleted" || !eventAutomationBelongsToUser(task, user)) throw new ViewerTaskNotFoundError();
|
|
1577
|
+
await deleteEventAutomation(getDb(), id);
|
|
1578
1578
|
}
|
|
1579
1579
|
//#endregion
|
|
1580
1580
|
//#region src/api/conversations/detail.ts
|
|
@@ -3409,7 +3409,7 @@ async function readPeoplePluginReports(args) {
|
|
|
3409
3409
|
reports: [],
|
|
3410
3410
|
source: "plugins"
|
|
3411
3411
|
});
|
|
3412
|
-
const { getPluginProfileReports } = await import("./agent-hooks-
|
|
3412
|
+
const { getPluginProfileReports } = await import("./agent-hooks-CuGjLjmR.js").then((n) => n.t);
|
|
3413
3413
|
return pluginOperationalReportFeedSchema.parse({
|
|
3414
3414
|
generatedAt: new Date(nowMs).toISOString(),
|
|
3415
3415
|
reports: await getPluginProfileReports({
|
|
@@ -3857,30 +3857,30 @@ function createUserPageRoutes() {
|
|
|
3857
3857
|
return app;
|
|
3858
3858
|
}
|
|
3859
3859
|
//#endregion
|
|
3860
|
-
//#region src/api/
|
|
3860
|
+
//#region src/api/automations/routes.ts
|
|
3861
3861
|
/** Create authenticated native task list and action routes. */
|
|
3862
|
-
function
|
|
3862
|
+
function createAutomationRoutes() {
|
|
3863
3863
|
const app = new Hono();
|
|
3864
|
-
app.get("/", requireViewer, validateRequest("query",
|
|
3864
|
+
app.get("/", requireViewer, validateRequest("query", automationListQuerySchema, "Invalid task list query."), async (context) => {
|
|
3865
3865
|
const user = context.get("viewer");
|
|
3866
3866
|
const query = context.req.valid("query");
|
|
3867
|
-
return jsonResponse(
|
|
3867
|
+
return jsonResponse(automationListSchema, await readViewerAutomations(user, query));
|
|
3868
3868
|
});
|
|
3869
3869
|
app.get("/runs", requireViewer, async (context) => {
|
|
3870
3870
|
const user = context.get("viewer");
|
|
3871
|
-
return jsonResponse(
|
|
3871
|
+
return jsonResponse(automationRunListSchema, await readViewerAutomationRuns(user));
|
|
3872
3872
|
});
|
|
3873
|
-
app.get("/:kind/:id/executions", requireViewer, validateRequest("param",
|
|
3873
|
+
app.get("/:kind/:id/executions", requireViewer, validateRequest("param", automationParamsSchema, "Invalid task."), async (context) => {
|
|
3874
3874
|
const user = context.get("viewer");
|
|
3875
3875
|
const params = context.req.valid("param");
|
|
3876
3876
|
try {
|
|
3877
|
-
return jsonResponse(
|
|
3877
|
+
return jsonResponse(automationExecutionListSchema, await readViewerAutomationExecutions(user, params.kind, params.id));
|
|
3878
3878
|
} catch (error) {
|
|
3879
3879
|
if (error instanceof ViewerTaskNotFoundError) return jsonResponse(apiErrorSchema, { error: error.message }, { status: 404 });
|
|
3880
3880
|
throw error;
|
|
3881
3881
|
}
|
|
3882
3882
|
});
|
|
3883
|
-
app.delete("/:kind/:id", requireViewer, validateRequest("param",
|
|
3883
|
+
app.delete("/:kind/:id", requireViewer, validateRequest("param", automationParamsSchema, "Invalid task."), async (context) => {
|
|
3884
3884
|
const user = context.get("viewer");
|
|
3885
3885
|
const params = context.req.valid("param");
|
|
3886
3886
|
try {
|
|
@@ -4018,7 +4018,7 @@ function readDescriptionText(home) {
|
|
|
4018
4018
|
}
|
|
4019
4019
|
/** Read discovered skill names for authenticated runtime diagnostics. */
|
|
4020
4020
|
async function readSkillReports() {
|
|
4021
|
-
const { discoverSkills } = await import("./skills-
|
|
4021
|
+
const { discoverSkills } = await import("./skills-DhL_wXEp.js").then((n) => n.o);
|
|
4022
4022
|
const skills = await discoverSkills();
|
|
4023
4023
|
return skillReportsSchema.parse(skills.map((skill) => ({
|
|
4024
4024
|
name: skill.name,
|
|
@@ -4027,7 +4027,7 @@ async function readSkillReports() {
|
|
|
4027
4027
|
}
|
|
4028
4028
|
/** Read safe configured plugin metadata for authenticated runtime diagnostics. */
|
|
4029
4029
|
async function readPlugins() {
|
|
4030
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
4030
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-D8YUMNhb.js").then((n) => n.t);
|
|
4031
4031
|
return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
4032
4032
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
4033
4033
|
description: plugin.manifest.description,
|
|
@@ -4039,7 +4039,7 @@ async function readPlugins() {
|
|
|
4039
4039
|
async function readRuntimeInfoReport() {
|
|
4040
4040
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
4041
4041
|
import("./package-discovery-7a9YqLhE.js").then((n) => n.r),
|
|
4042
|
-
import("./catalog-runtime-
|
|
4042
|
+
import("./catalog-runtime-D8YUMNhb.js").then((n) => n.t),
|
|
4043
4043
|
readPlugins(),
|
|
4044
4044
|
readSkillReports()
|
|
4045
4045
|
]);
|
|
@@ -4056,7 +4056,7 @@ async function readRuntimeInfoReport() {
|
|
|
4056
4056
|
/** Read sanitized operational summaries contributed by plugins. */
|
|
4057
4057
|
async function readPluginOperationalReportFeed() {
|
|
4058
4058
|
const nowMs = Date.now();
|
|
4059
|
-
const { getPluginOperationalReports } = await import("./agent-hooks-
|
|
4059
|
+
const { getPluginOperationalReports } = await import("./agent-hooks-CuGjLjmR.js").then((n) => n.t);
|
|
4060
4060
|
return pluginOperationalReportFeedSchema.parse({
|
|
4061
4061
|
source: "plugins",
|
|
4062
4062
|
generatedAt: new Date(nowMs).toISOString(),
|
|
@@ -4080,7 +4080,7 @@ function createJuniorApi() {
|
|
|
4080
4080
|
app.route("/api/people", createPeopleRoutes());
|
|
4081
4081
|
app.route("/api/locations", createLocationRoutes());
|
|
4082
4082
|
app.route("/api/user-pages", createUserPageRoutes());
|
|
4083
|
-
app.route("/api/
|
|
4083
|
+
app.route("/api/automations", createAutomationRoutes());
|
|
4084
4084
|
app.route("/api/workspaces", createWorkspaceRoutes());
|
|
4085
4085
|
app.notFound(() => jsonResponse(apiErrorSchema, { error: "Resource not found." }, { status: 404 }));
|
|
4086
4086
|
app.onError((error, _context) => {
|