@agent-native/core 0.164.15 → 0.164.18
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/corpus/README.md +1 -1
- package/corpus/templates/analytics/netlify.toml +4 -0
- package/corpus/templates/clips/actions/request-transcript.ts +10 -6
- package/corpus/templates/content/app/components/editor/BubbleToolbar.tsx +298 -3
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +3 -0
- package/corpus/templates/content/app/components/editor/extensions/NotionExtensions.tsx +18 -4
- package/corpus/templates/content/app/i18n-data.ts +160 -0
- package/corpus/templates/content/docs/solutions/2026-08-18-colored-text-highlighting-shape.md +693 -0
- package/corpus/templates/content/package.json +1 -0
- package/corpus/templates/content/shared/nfm.ts +14 -3
- package/corpus/templates/factory/AGENTS.md +24 -29
- package/corpus/templates/factory/actions/get-slack-feedback-context.ts +8 -28
- package/corpus/templates/factory/actions/get-triage-config.ts +1 -0
- package/corpus/templates/factory/actions/govern-agent-native-pull-request.ts +67 -59
- package/corpus/templates/factory/actions/list-triage-items.ts +6 -1
- package/corpus/templates/factory/actions/reconcile-triage-run.ts +7 -1
- package/corpus/templates/factory/actions/save-triage-config.ts +27 -7
- package/corpus/templates/factory/actions/start-builder-for-item.ts +113 -31
- package/corpus/templates/factory/actions/view-screen.ts +12 -0
- package/corpus/templates/factory/app/components/factory/FactorySettingsView.tsx +457 -0
- package/corpus/templates/factory/app/components/factory/FactoryWorkspaceActions.tsx +53 -0
- package/corpus/templates/factory/app/components/layout/Layout.tsx +2 -0
- package/corpus/templates/factory/app/components/layout/Sidebar.tsx +3 -1
- package/corpus/templates/factory/app/hooks/use-navigation-state.ts +10 -7
- package/corpus/templates/factory/app/i18n/en-US.ts +3 -0
- package/corpus/templates/factory/app/routes/agents.tsx +22 -1
- package/corpus/templates/factory/app/routes/factory-settings.tsx +34 -0
- package/corpus/templates/factory/app/routes/factory.tsx +33 -323
- package/corpus/templates/factory/server/connectors/slack.ts +62 -0
- package/corpus/templates/factory/server/db/schema.ts +1 -0
- package/corpus/templates/factory/server/lib/slack-feedback-prompt.ts +30 -0
- package/corpus/templates/factory/server/plugins/agent-chat.ts +9 -8
- package/corpus/templates/factory/server/plugins/factory-migrations.ts +7 -0
- package/corpus/templates/factory/server/plugins/factory-scheduler-job.ts +43 -25
- package/corpus/templates/factory/server/triage/ai-services-git.ts +2 -0
- package/corpus/templates/factory/server/triage/pr-monitor.ts +2 -1
- package/corpus/templates/factory/server/triage/pr-policy.ts +197 -19
- package/corpus/templates/factory/server/triage/review-skill-alignment.ts +127 -0
- package/corpus/templates/factory/server/triage/slack-client.ts +79 -6
- package/dist/client/MultiTabAssistantChat.js +28 -1
- package/dist/client/use-chat-threads.d.ts +1 -0
- package/dist/client/use-chat-threads.js +13 -3
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/integrations/plugin.js +18 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/resources/handlers.d.ts +2 -2
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/auth.js +2 -2
- package/dist/vite/client.js +2 -0
- package/package.json +1 -1
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@tiptap/core": "catalog:",
|
|
36
36
|
"@tiptap/extension-blockquote": "catalog:",
|
|
37
37
|
"@tiptap/extension-bubble-menu": "catalog:",
|
|
38
|
+
"@tiptap/extension-code": "3.30.1",
|
|
38
39
|
"@tiptap/extension-code-block-lowlight": "catalog:",
|
|
39
40
|
"@tiptap/extension-collaboration": "catalog:",
|
|
40
41
|
"@tiptap/extension-collaboration-caret": "catalog:",
|
|
@@ -363,8 +363,13 @@ function serializeInlineNode(node: PMNode): string {
|
|
|
363
363
|
const a = span?.attrs || {};
|
|
364
364
|
const underlined =
|
|
365
365
|
a.underline === "true" || a.underline === true || plainUnderline;
|
|
366
|
+
const foregroundColor =
|
|
367
|
+
isColor(a.color) && !a.color.endsWith("_bg") ? a.color : null;
|
|
368
|
+
const backgroundColor =
|
|
369
|
+
isColor(a.bgColor) && a.bgColor.endsWith("_bg") ? a.bgColor : null;
|
|
366
370
|
const attrStr = serializeAttrs([
|
|
367
|
-
["color",
|
|
371
|
+
["color", foregroundColor || backgroundColor],
|
|
372
|
+
["bg_color", foregroundColor ? backgroundColor : null],
|
|
368
373
|
["underline", underlined ? "true" : null],
|
|
369
374
|
]);
|
|
370
375
|
if (attrStr) out = `<span${attrStr}>${out}</span>`;
|
|
@@ -397,9 +402,15 @@ function addMark(nodes: PMNode[], mark: PMMark): void {
|
|
|
397
402
|
function mergeSpanMark(nodes: PMNode[], attrs: Record<string, string>): void {
|
|
398
403
|
const color = attrs.color;
|
|
399
404
|
const isBg = color ? color.endsWith("_bg") : false;
|
|
405
|
+
const explicitBackground = attrs.bg_color;
|
|
400
406
|
const spanAttrs: Record<string, any> = {
|
|
401
|
-
color: color && !isBg ? color : null,
|
|
402
|
-
bgColor:
|
|
407
|
+
color: isColor(color) && !isBg ? color : null,
|
|
408
|
+
bgColor:
|
|
409
|
+
isColor(explicitBackground) && explicitBackground.endsWith("_bg")
|
|
410
|
+
? explicitBackground
|
|
411
|
+
: isColor(color) && isBg
|
|
412
|
+
? color
|
|
413
|
+
: null,
|
|
403
414
|
underline: attrs.underline === "true" ? "true" : null,
|
|
404
415
|
href: attrs.href || null,
|
|
405
416
|
attrsJson: "{}",
|
|
@@ -21,21 +21,22 @@ decisions, feedback, agent runs, and provider audit records.
|
|
|
21
21
|
reconciliation is not success; preserve typed failure or
|
|
22
22
|
`reconciliation_required` state.
|
|
23
23
|
- Deduplicate by Factory item and rule/run identity, not provider comment ID.
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
API.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
- Slack clear bugs go through `start-builder-for-item` (👀 and a Slack user
|
|
25
|
+
mention for `/address-feedback`); never post Slack messages or `@handles`.
|
|
26
|
+
Group repeats into one Builder thread. GitHub/Sentry use the Builder run
|
|
27
|
+
API. Follow `review-latest-feedback` for full-thread evidence, existing
|
|
28
|
+
reaction and owner checks, answered-clarification priority, one-question
|
|
29
|
+
clarification limits, durable rechecks, and the required `@agent-native`
|
|
30
|
+
disposition after every actionable 👀. Clips, Design, and Content stay
|
|
31
|
+
owner-managed outside autonomous dispatch and PR governance.
|
|
32
|
+
- PR governance follows `review-prs`: verify BuilderIO membership and complete
|
|
33
|
+
diff/review/check evidence; skip drafts/current approvals and never approve
|
|
34
|
+
external authors. Keep ultra-scary security, auth, tenant-isolation,
|
|
35
|
+
secrets, data-loss, execution, payment, and deployment risks manual.
|
|
36
|
+
Verified members may pass ordinary uncertain checks or review feedback, but
|
|
37
|
+
record exact states and never call them clean. Apply the Alice/Content,
|
|
38
|
+
Nick/Slides, Enzo/Factory, Sid/Design, and docs-only exceptions only after
|
|
39
|
+
membership and the ultra-scary gate. Never auto-merge.
|
|
39
40
|
- Graph edits create immutable blueprint versions. AI proposes with `source=ai`;
|
|
40
41
|
a person reviews and publishes through the same action surface.
|
|
41
42
|
- Provider credentials belong to Dispatch/shared workspace integrations, never
|
|
@@ -45,10 +46,10 @@ decisions, feedback, agent runs, and provider audit records.
|
|
|
45
46
|
|
|
46
47
|
## Application state
|
|
47
48
|
|
|
48
|
-
- `navigation.view` is `factory
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
- `navigation.view` is `factory`, `agents`, or `factory-settings`.
|
|
50
|
+
Observation settings are workspace-scoped at `/factory-settings`.
|
|
51
|
+
`factoryId`, `factoryTab`, `factoryAuditRunId`, `factoryNodeId`, and
|
|
52
|
+
`factoryEdgeId` hold Factory context. Read `view-screen` first.
|
|
52
53
|
|
|
53
54
|
## Action contract
|
|
54
55
|
|
|
@@ -80,17 +81,11 @@ decisions, feedback, agent runs, and provider audit records.
|
|
|
80
81
|
| `import-agent` / `import-agent-pack` / `list-agent-pack` | Import profiles or agent packs. |
|
|
81
82
|
| `start-workspace-app-creation` | Promote an agent and its pack into an app handoff. |
|
|
82
83
|
|
|
83
|
-
Rules start in shadow mode; hard guards
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
automations are seeded. Use the visual editor for graph changes and agent chat
|
|
84
|
+
Rules start in shadow mode; hard guards apply. Organization automations use
|
|
85
|
+
stored prompts; external mutations require durable, idempotent runs and
|
|
86
|
+
provider confirmation. Use the visual editor for graph changes and agent chat
|
|
87
87
|
for proposals; persist complete graphs with `save-factory-graph`. Change rules
|
|
88
|
-
through triage
|
|
89
|
-
|
|
90
|
-
The Slack, GitHub, and Sentry pollers are bounded ingestion adapters for the
|
|
91
|
-
legacy default triage queue. They do not define the complete tool surface.
|
|
92
|
-
Interactive and scheduled agents may discover additional connected provider or
|
|
93
|
-
MCP tools through the shared workspace context.
|
|
88
|
+
through triage actions, never graph JSON.
|
|
94
89
|
|
|
95
90
|
## Source Changes
|
|
96
91
|
|
|
@@ -2,7 +2,6 @@ import { defineAction } from "@agent-native/core/action";
|
|
|
2
2
|
import { and, eq } from "drizzle-orm";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
|
-
import type { SlackMessage } from "../server/connectors/slack.js";
|
|
6
5
|
import { getDb } from "../server/db/index.js";
|
|
7
6
|
import { triageConfig, triageItems } from "../server/db/schema.js";
|
|
8
7
|
import {
|
|
@@ -12,8 +11,6 @@ import {
|
|
|
12
11
|
import { recordFactoryAudit } from "../server/triage/audit.js";
|
|
13
12
|
import { createSlackReader } from "../server/triage/slack-client.js";
|
|
14
13
|
|
|
15
|
-
const MAX_THREAD_PAGES = 5;
|
|
16
|
-
|
|
17
14
|
export default defineAction({
|
|
18
15
|
description:
|
|
19
16
|
"Read the bounded full Slack thread for one Factory feedback item. Use this before deciding whether a report is a clear bug; unreadable or truncated context is not a green light.",
|
|
@@ -46,31 +43,11 @@ export default defineAction({
|
|
|
46
43
|
const workspace =
|
|
47
44
|
config?.slackWorkspace === "secondary" ? "secondary" : "primary";
|
|
48
45
|
const slack = createSlackReader({ ownerEmail: userEmail, orgId });
|
|
49
|
-
const messages
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
workspace,
|
|
55
|
-
item.channelId,
|
|
56
|
-
item.threadTs,
|
|
57
|
-
100,
|
|
58
|
-
cursor,
|
|
59
|
-
);
|
|
60
|
-
messages.push(...result.messages);
|
|
61
|
-
if (result.has_more && !result.next_cursor) {
|
|
62
|
-
throw new Error(
|
|
63
|
-
"Slack thread pagination is incomplete because the provider omitted its next cursor.",
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
if (!result.has_more) {
|
|
67
|
-
hasMore = false;
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
hasMore = page === MAX_THREAD_PAGES - 1;
|
|
71
|
-
if (hasMore) break;
|
|
72
|
-
cursor = result.next_cursor;
|
|
73
|
-
}
|
|
46
|
+
const { messages, hasMore } = await slack.getCompleteThread(
|
|
47
|
+
workspace,
|
|
48
|
+
item.channelId,
|
|
49
|
+
item.threadTs,
|
|
50
|
+
);
|
|
74
51
|
|
|
75
52
|
await recordFactoryAudit(
|
|
76
53
|
context,
|
|
@@ -100,10 +77,13 @@ export default defineAction({
|
|
|
100
77
|
coverage: hasMore ? "partial" : "complete",
|
|
101
78
|
messages: messages.map((message) => ({
|
|
102
79
|
user: message.user ?? message.username ?? message.bot_id ?? null,
|
|
80
|
+
username: message.username ?? null,
|
|
81
|
+
botId: message.bot_id ?? null,
|
|
103
82
|
text: message.text,
|
|
104
83
|
ts: message.ts,
|
|
105
84
|
threadTs: message.thread_ts ?? item.threadTs,
|
|
106
85
|
replyCount: message.reply_count ?? 0,
|
|
86
|
+
reactions: message.reactions ?? [],
|
|
107
87
|
})),
|
|
108
88
|
};
|
|
109
89
|
},
|
|
@@ -24,7 +24,10 @@ import {
|
|
|
24
24
|
serializeTriageMetadata,
|
|
25
25
|
} from "../server/triage/metadata.js";
|
|
26
26
|
import { reconcileBabysitState } from "../server/triage/pr-babysit.js";
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
decidePullRequestGovernance,
|
|
29
|
+
hasCurrentPullRequestApproval,
|
|
30
|
+
} from "../server/triage/pr-policy.js";
|
|
28
31
|
|
|
29
32
|
function repositoryRef(value: string): { owner: string; repo: string } {
|
|
30
33
|
const match = /^([^/\s]+)\/([^/\s]+)$/.exec(value.trim());
|
|
@@ -103,7 +106,7 @@ async function hasVerifiedFactoryRun(input: {
|
|
|
103
106
|
|
|
104
107
|
export default defineAction({
|
|
105
108
|
description:
|
|
106
|
-
"Govern one agent-native pull request after fetching bounded GitHub and ai-services evidence. Auto-approve only
|
|
109
|
+
"Govern one agent-native pull request after fetching bounded GitHub and ai-services evidence. Auto-approve only under the current review-prs membership, owner, evidence, and ultra-scary gates. Never auto-merge. Clips, Design, and Content feedback remains owner-managed while their verified PR-owner exceptions still apply.",
|
|
107
110
|
schema: z.object({
|
|
108
111
|
repo: z.string().trim().min(1).max(256),
|
|
109
112
|
pullRequestNumber: z.number().int().positive(),
|
|
@@ -167,6 +170,24 @@ export default defineAction({
|
|
|
167
170
|
repository,
|
|
168
171
|
pullRequestNumber,
|
|
169
172
|
);
|
|
173
|
+
if (pullRequest.state !== "open" || pullRequest.draft) {
|
|
174
|
+
if (itemId) {
|
|
175
|
+
await getDb()
|
|
176
|
+
.update(triageItems)
|
|
177
|
+
.set({
|
|
178
|
+
status: "pr_observed",
|
|
179
|
+
updatedAt: new Date().toISOString(),
|
|
180
|
+
})
|
|
181
|
+
.where(and(eq(triageItems.id, itemId), eq(triageItems.orgId, orgId)));
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
ok: true,
|
|
185
|
+
action: "skipped",
|
|
186
|
+
reason: pullRequest.draft
|
|
187
|
+
? "Pull request is a draft and is excluded before evidence review."
|
|
188
|
+
: "Pull request is not open and is excluded before evidence review.",
|
|
189
|
+
};
|
|
190
|
+
}
|
|
170
191
|
const privateKey = await resolveConnectorSecret(
|
|
171
192
|
"BUILDER_PRIVATE_KEY",
|
|
172
193
|
userEmail,
|
|
@@ -186,6 +207,38 @@ export default defineAction({
|
|
|
186
207
|
`PR evidence is stale: GitHub reports ${pullRequest.headSha}, ai-services reports ${snapshot.headSha}.`,
|
|
187
208
|
);
|
|
188
209
|
}
|
|
210
|
+
if (hasCurrentPullRequestApproval(snapshot.reviews)) {
|
|
211
|
+
await recordFactoryAudit(
|
|
212
|
+
context,
|
|
213
|
+
{ userEmail, orgId },
|
|
214
|
+
{
|
|
215
|
+
action: "govern-agent-native-pull-request",
|
|
216
|
+
kind: "governance",
|
|
217
|
+
status: "skipped",
|
|
218
|
+
itemId: itemId ?? null,
|
|
219
|
+
source: "github",
|
|
220
|
+
sourceUrl: pullRequest.htmlUrl,
|
|
221
|
+
summary:
|
|
222
|
+
"Skipped the pull request because it already has a current non-dismissed approval.",
|
|
223
|
+
details: { repo, pullRequestNumber },
|
|
224
|
+
},
|
|
225
|
+
);
|
|
226
|
+
if (itemId) {
|
|
227
|
+
await getDb()
|
|
228
|
+
.update(triageItems)
|
|
229
|
+
.set({
|
|
230
|
+
status: "pr_observed",
|
|
231
|
+
updatedAt: new Date().toISOString(),
|
|
232
|
+
})
|
|
233
|
+
.where(and(eq(triageItems.id, itemId), eq(triageItems.orgId, orgId)));
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
ok: true,
|
|
237
|
+
action: "skipped",
|
|
238
|
+
reason:
|
|
239
|
+
"Pull request already has a current non-dismissed approval; no duplicate review was created.",
|
|
240
|
+
};
|
|
241
|
+
}
|
|
189
242
|
|
|
190
243
|
const checksPassed =
|
|
191
244
|
snapshot.coverage === "complete" &&
|
|
@@ -254,6 +307,7 @@ export default defineAction({
|
|
|
254
307
|
reviewFeedbackHandled,
|
|
255
308
|
autoApprove: governance.autoApprove,
|
|
256
309
|
autoMerge: governance.autoMerge,
|
|
310
|
+
ownerException: governance.ownerException,
|
|
257
311
|
ownerOwnedArea: governance.ownerOwnedArea ?? null,
|
|
258
312
|
guardResults: governance.guardResults,
|
|
259
313
|
},
|
|
@@ -341,7 +395,9 @@ export default defineAction({
|
|
|
341
395
|
const approval = await github.approvePullRequest(
|
|
342
396
|
repository,
|
|
343
397
|
pullRequestNumber,
|
|
344
|
-
|
|
398
|
+
governance.ownerException
|
|
399
|
+
? `Factory auto-approved under the verified ${governance.ownerException} owner exception; ordinary check and review states remain recorded.`
|
|
400
|
+
: "Factory auto-approved under verified BuilderIO membership; ordinary check and review states remain recorded.",
|
|
345
401
|
);
|
|
346
402
|
approvalUrl = approval.htmlUrl;
|
|
347
403
|
metadata.autoApprovedAt = new Date().toISOString();
|
|
@@ -361,61 +417,13 @@ export default defineAction({
|
|
|
361
417
|
await github.approvePullRequest(
|
|
362
418
|
repository,
|
|
363
419
|
pullRequestNumber,
|
|
364
|
-
|
|
420
|
+
governance.ownerException
|
|
421
|
+
? `Factory auto-approved under the verified ${governance.ownerException} owner exception; ordinary check and review states remain recorded.`
|
|
422
|
+
: "Factory auto-approved under verified BuilderIO membership; ordinary check and review states remain recorded.",
|
|
365
423
|
)
|
|
366
424
|
).htmlUrl;
|
|
367
425
|
}
|
|
368
426
|
|
|
369
|
-
if (!governance.autoMerge) {
|
|
370
|
-
await recordFactoryAudit(
|
|
371
|
-
context,
|
|
372
|
-
{ userEmail, orgId },
|
|
373
|
-
{
|
|
374
|
-
action: "govern-agent-native-pull-request",
|
|
375
|
-
kind: "external_action",
|
|
376
|
-
itemId: itemId ?? null,
|
|
377
|
-
source: "github",
|
|
378
|
-
sourceUrl: approvalUrl,
|
|
379
|
-
summary: "Approved the pull request after governance checks passed.",
|
|
380
|
-
details: { repo, pullRequestNumber, approvalUrl },
|
|
381
|
-
},
|
|
382
|
-
);
|
|
383
|
-
return {
|
|
384
|
-
ok: true,
|
|
385
|
-
action: "approved",
|
|
386
|
-
approvalUrl,
|
|
387
|
-
checksPassed,
|
|
388
|
-
reviewFeedbackHandled,
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
const merge = await github.mergePullRequest(
|
|
393
|
-
repository,
|
|
394
|
-
pullRequestNumber,
|
|
395
|
-
`Merge Factory bug fix #${pullRequestNumber}`,
|
|
396
|
-
snapshot.headSha,
|
|
397
|
-
);
|
|
398
|
-
if (itemId) {
|
|
399
|
-
const item = (
|
|
400
|
-
await getDb()
|
|
401
|
-
.select({ metadataJson: triageItems.metadataJson })
|
|
402
|
-
.from(triageItems)
|
|
403
|
-
.where(and(eq(triageItems.id, itemId), eq(triageItems.orgId, orgId)))
|
|
404
|
-
.limit(1)
|
|
405
|
-
)[0];
|
|
406
|
-
if (!item) throw new Error("Factory item disappeared after PR merge.");
|
|
407
|
-
const metadata = parseTriageMetadata(item.metadataJson);
|
|
408
|
-
metadata.autoMergedAt = new Date().toISOString();
|
|
409
|
-
metadata.mergeSha = merge.sha;
|
|
410
|
-
await getDb()
|
|
411
|
-
.update(triageItems)
|
|
412
|
-
.set({
|
|
413
|
-
metadataJson: serializeTriageMetadata(metadata),
|
|
414
|
-
status: "merged",
|
|
415
|
-
updatedAt: new Date().toISOString(),
|
|
416
|
-
})
|
|
417
|
-
.where(and(eq(triageItems.id, itemId), eq(triageItems.orgId, orgId)));
|
|
418
|
-
}
|
|
419
427
|
await recordFactoryAudit(
|
|
420
428
|
context,
|
|
421
429
|
{ userEmail, orgId },
|
|
@@ -424,16 +432,16 @@ export default defineAction({
|
|
|
424
432
|
kind: "external_action",
|
|
425
433
|
itemId: itemId ?? null,
|
|
426
434
|
source: "github",
|
|
427
|
-
sourceUrl:
|
|
428
|
-
summary:
|
|
429
|
-
|
|
435
|
+
sourceUrl: approvalUrl,
|
|
436
|
+
summary:
|
|
437
|
+
"Approved the pull request under the current review-prs policy.",
|
|
438
|
+
details: { repo, pullRequestNumber, approvalUrl },
|
|
430
439
|
},
|
|
431
440
|
);
|
|
432
441
|
return {
|
|
433
442
|
ok: true,
|
|
434
|
-
action: "
|
|
443
|
+
action: "approved",
|
|
435
444
|
approvalUrl,
|
|
436
|
-
mergeSha: merge.sha,
|
|
437
445
|
checksPassed,
|
|
438
446
|
reviewFeedbackHandled,
|
|
439
447
|
};
|
|
@@ -30,7 +30,12 @@ export default defineAction({
|
|
|
30
30
|
workspaceMemberIdentityFromContext(context),
|
|
31
31
|
);
|
|
32
32
|
const db = getDb();
|
|
33
|
-
const reviewStatuses =
|
|
33
|
+
const reviewStatuses =
|
|
34
|
+
source === "github"
|
|
35
|
+
? ["pr_observed"]
|
|
36
|
+
: source === "slack"
|
|
37
|
+
? ["received", "automation_started", "evidence_ready"]
|
|
38
|
+
: ["received"];
|
|
34
39
|
const items = await db
|
|
35
40
|
.select()
|
|
36
41
|
.from(triageItems)
|
|
@@ -20,7 +20,13 @@ import {
|
|
|
20
20
|
|
|
21
21
|
const reviewSchema = z.object({
|
|
22
22
|
author: z.string(),
|
|
23
|
-
state: z.enum([
|
|
23
|
+
state: z.enum([
|
|
24
|
+
"approved",
|
|
25
|
+
"changes_requested",
|
|
26
|
+
"commented",
|
|
27
|
+
"pending",
|
|
28
|
+
"dismissed",
|
|
29
|
+
]),
|
|
24
30
|
observedAt: z.string().datetime(),
|
|
25
31
|
});
|
|
26
32
|
const checkSchema = z.object({
|
|
@@ -13,11 +13,19 @@ const workspaceSchema = z.enum(["primary", "secondary"]);
|
|
|
13
13
|
|
|
14
14
|
export default defineAction({
|
|
15
15
|
description:
|
|
16
|
-
"Save Factory automation alert settings. Provider credentials live in shared workspace integrations;
|
|
16
|
+
"Save Factory observation and automation alert settings. Provider credentials live in shared workspace integrations; source routing metadata including the Builder Slack member id is stored on Factory config.",
|
|
17
17
|
schema: z.object({
|
|
18
18
|
slackWorkspace: workspaceSchema.optional(),
|
|
19
|
-
slackChannelId: z.string().trim().
|
|
19
|
+
slackChannelId: z.string().trim().max(128).optional(),
|
|
20
20
|
slackChannelName: z.string().trim().max(200).optional(),
|
|
21
|
+
builderSlackUserId: z
|
|
22
|
+
.string()
|
|
23
|
+
.trim()
|
|
24
|
+
.max(32)
|
|
25
|
+
.refine((value) => value === "" || /^[UW][A-Z0-9]+$/i.test(value), {
|
|
26
|
+
message: "Builder Slack member id must look like U01234567.",
|
|
27
|
+
})
|
|
28
|
+
.optional(),
|
|
21
29
|
pollingEnabled: z.boolean().optional(),
|
|
22
30
|
githubPollingEnabled: z.boolean().optional(),
|
|
23
31
|
sentryPollingEnabled: z.boolean().optional(),
|
|
@@ -26,7 +34,9 @@ export default defineAction({
|
|
|
26
34
|
sentryEnvironment: z.string().trim().max(200).optional(),
|
|
27
35
|
repository: z.string().trim().max(256).optional(),
|
|
28
36
|
automationFailureAlertsEnabled: z.boolean().optional(),
|
|
29
|
-
automationFailureAlertEmail: z
|
|
37
|
+
automationFailureAlertEmail: z
|
|
38
|
+
.union([z.string().trim().email(), z.literal("")])
|
|
39
|
+
.optional(),
|
|
30
40
|
}),
|
|
31
41
|
http: { method: "POST" },
|
|
32
42
|
run: async (
|
|
@@ -34,6 +44,7 @@ export default defineAction({
|
|
|
34
44
|
slackWorkspace,
|
|
35
45
|
slackChannelId,
|
|
36
46
|
slackChannelName,
|
|
47
|
+
builderSlackUserId,
|
|
37
48
|
pollingEnabled,
|
|
38
49
|
githubPollingEnabled,
|
|
39
50
|
sentryPollingEnabled,
|
|
@@ -72,6 +83,12 @@ export default defineAction({
|
|
|
72
83
|
slackChannelName,
|
|
73
84
|
existing?.slackChannelName,
|
|
74
85
|
);
|
|
86
|
+
const persistedBuilderSlackUserId = persistText(
|
|
87
|
+
builderSlackUserId === undefined
|
|
88
|
+
? undefined
|
|
89
|
+
: builderSlackUserId.toUpperCase(),
|
|
90
|
+
existing?.builderSlackUserId,
|
|
91
|
+
);
|
|
75
92
|
const persistedRepository = persistText(repository, existing?.repository);
|
|
76
93
|
const persistedSentryOrgSlug = persistText(
|
|
77
94
|
sentryOrgSlug,
|
|
@@ -109,10 +126,10 @@ export default defineAction({
|
|
|
109
126
|
: automationFailureAlertsEnabled
|
|
110
127
|
? 1
|
|
111
128
|
: 0;
|
|
112
|
-
const persistedAutomationFailureAlertEmail =
|
|
113
|
-
automationFailureAlertEmail
|
|
114
|
-
existing?.automationFailureAlertEmail
|
|
115
|
-
|
|
129
|
+
const persistedAutomationFailureAlertEmail = persistText(
|
|
130
|
+
automationFailureAlertEmail,
|
|
131
|
+
existing?.automationFailureAlertEmail,
|
|
132
|
+
);
|
|
116
133
|
await db
|
|
117
134
|
.insert(triageConfig)
|
|
118
135
|
.values({
|
|
@@ -120,6 +137,7 @@ export default defineAction({
|
|
|
120
137
|
slackWorkspace: persistedSlackWorkspace,
|
|
121
138
|
slackChannelId: persistedSlackChannelId,
|
|
122
139
|
slackChannelName: persistedSlackChannelName,
|
|
140
|
+
builderSlackUserId: persistedBuilderSlackUserId,
|
|
123
141
|
pollingEnabled: persistedPollingEnabled,
|
|
124
142
|
githubPollingEnabled: persistedGithubPollingEnabled,
|
|
125
143
|
sentryPollingEnabled: persistedSentryPollingEnabled,
|
|
@@ -140,6 +158,7 @@ export default defineAction({
|
|
|
140
158
|
slackWorkspace: persistedSlackWorkspace,
|
|
141
159
|
slackChannelId: persistedSlackChannelId,
|
|
142
160
|
slackChannelName: persistedSlackChannelName,
|
|
161
|
+
builderSlackUserId: persistedBuilderSlackUserId,
|
|
143
162
|
pollingEnabled: persistedPollingEnabled,
|
|
144
163
|
githubPollingEnabled: persistedGithubPollingEnabled,
|
|
145
164
|
sentryPollingEnabled: persistedSentryPollingEnabled,
|
|
@@ -160,6 +179,7 @@ export default defineAction({
|
|
|
160
179
|
githubPollingEnabled: persistedGithubPollingEnabled === 1,
|
|
161
180
|
sentryPollingEnabled: persistedSentryPollingEnabled === 1,
|
|
162
181
|
slackChannelId: persistedSlackChannelId,
|
|
182
|
+
builderSlackUserId: persistedBuilderSlackUserId,
|
|
163
183
|
automationFailureAlertsEnabled:
|
|
164
184
|
persistedAutomationFailureAlertsEnabled === 1,
|
|
165
185
|
automationFailureAlertEmail: persistedAutomationFailureAlertEmail,
|