@ever-works/ever-email-router-plugin 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -2
- package/dist/index.cjs +2177 -0
- package/dist/index.d.cts +66 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.js +2165 -0
- package/package.json +82 -5
package/dist/index.js
ADDED
|
@@ -0,0 +1,2165 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual, createHash } from 'crypto';
|
|
2
|
+
import PostalMime from 'postal-mime';
|
|
3
|
+
|
|
4
|
+
// src/ever-email-router-plugin.ts
|
|
5
|
+
var PROBLEM_CODES = [
|
|
6
|
+
"validation_failed",
|
|
7
|
+
"not_found",
|
|
8
|
+
"unauthorized",
|
|
9
|
+
"forbidden_role",
|
|
10
|
+
"forbidden_scope",
|
|
11
|
+
"ambiguous_credentials",
|
|
12
|
+
"credential_revoked",
|
|
13
|
+
"instance_disconnected",
|
|
14
|
+
"instance_pending_approval",
|
|
15
|
+
"not_connection_owner",
|
|
16
|
+
"integration_disabled",
|
|
17
|
+
"integration_revoked",
|
|
18
|
+
"subject_unknown",
|
|
19
|
+
"link_not_found",
|
|
20
|
+
"oidc_client_exists",
|
|
21
|
+
"redirect_uri_invalid",
|
|
22
|
+
"denied_by_policy",
|
|
23
|
+
"integration_not_available",
|
|
24
|
+
"entitlement_required",
|
|
25
|
+
"tier_required",
|
|
26
|
+
"limit_exceeded",
|
|
27
|
+
"rate_limited",
|
|
28
|
+
"idempotency_mismatch",
|
|
29
|
+
"idempotency_in_progress",
|
|
30
|
+
"stale_version",
|
|
31
|
+
"module_disabled",
|
|
32
|
+
"handle_taken",
|
|
33
|
+
"handle_reserved",
|
|
34
|
+
"handle_retired",
|
|
35
|
+
"handle_invalid",
|
|
36
|
+
"handle_held",
|
|
37
|
+
"handle_held_by_you",
|
|
38
|
+
"code_invalid",
|
|
39
|
+
"code_expired",
|
|
40
|
+
"product_mismatch",
|
|
41
|
+
"product_not_supported",
|
|
42
|
+
"key_mismatch",
|
|
43
|
+
"signature_invalid",
|
|
44
|
+
"unlinked_org",
|
|
45
|
+
"schema_violation",
|
|
46
|
+
"mirror_owned_field",
|
|
47
|
+
"illegal_transition",
|
|
48
|
+
"already_exists",
|
|
49
|
+
"already_completed",
|
|
50
|
+
"legal_basis_required",
|
|
51
|
+
"receipt_final",
|
|
52
|
+
"billing_active",
|
|
53
|
+
"sso_required",
|
|
54
|
+
"reauth_required",
|
|
55
|
+
"session_required",
|
|
56
|
+
"step_up_required",
|
|
57
|
+
"session_bound",
|
|
58
|
+
"authorization_pending",
|
|
59
|
+
"slow_down",
|
|
60
|
+
"expired_token",
|
|
61
|
+
"already_connected",
|
|
62
|
+
"already_linked",
|
|
63
|
+
"already_claimed",
|
|
64
|
+
"claim_locked",
|
|
65
|
+
"invalid_client",
|
|
66
|
+
"public_jwk_invalid",
|
|
67
|
+
"identifier_claimed",
|
|
68
|
+
"salt_version_unknown",
|
|
69
|
+
"salt_version_retired",
|
|
70
|
+
"hashes_invalid",
|
|
71
|
+
"lookup_key_required",
|
|
72
|
+
"required_component",
|
|
73
|
+
"resync_required",
|
|
74
|
+
"last_owner",
|
|
75
|
+
"last_auth_method",
|
|
76
|
+
"instances_linked",
|
|
77
|
+
"install_in_progress",
|
|
78
|
+
"slug_reserved",
|
|
79
|
+
"checklist_incomplete",
|
|
80
|
+
"scope_version_outdated",
|
|
81
|
+
"method_not_allowed",
|
|
82
|
+
"payload_too_large",
|
|
83
|
+
"unsupported_media_type",
|
|
84
|
+
"gone",
|
|
85
|
+
"unavailable",
|
|
86
|
+
"upstream",
|
|
87
|
+
"database_absent",
|
|
88
|
+
"database_unreachable",
|
|
89
|
+
"topic_private",
|
|
90
|
+
"realtime_disabled",
|
|
91
|
+
"topic_forbidden",
|
|
92
|
+
"topic_invalid",
|
|
93
|
+
"realtime_busy",
|
|
94
|
+
"too_many_streams",
|
|
95
|
+
"keys_unavailable",
|
|
96
|
+
"internal_error"
|
|
97
|
+
];
|
|
98
|
+
new Set(PROBLEM_CODES);
|
|
99
|
+
|
|
100
|
+
// ../../contracts/dist/index.js
|
|
101
|
+
var USER_SELECTABLE_WORK_KINDS = [
|
|
102
|
+
"website",
|
|
103
|
+
"landing-page",
|
|
104
|
+
"blog",
|
|
105
|
+
"directory",
|
|
106
|
+
"awesome-repo",
|
|
107
|
+
"repo",
|
|
108
|
+
"app"
|
|
109
|
+
];
|
|
110
|
+
var WORK_KINDS = [...USER_SELECTABLE_WORK_KINDS, "company", "campaign", "project", "default"];
|
|
111
|
+
new Set(WORK_KINDS);
|
|
112
|
+
var GOAL_KINDS = ["metric", "delivery"];
|
|
113
|
+
new Set(GOAL_KINDS);
|
|
114
|
+
var RECORD_VISIBILITIES = ["private", "team", "organization"];
|
|
115
|
+
new Set(RECORD_VISIBILITIES);
|
|
116
|
+
var RECORD_LIST_VIEWS = ["mine", "shared", "organization"];
|
|
117
|
+
new Set(RECORD_LIST_VIEWS);
|
|
118
|
+
var VERSION = "1.0.0";
|
|
119
|
+
var GTM_SKILLS = [
|
|
120
|
+
// ── research ────────────────────────────────────────────────────────
|
|
121
|
+
{
|
|
122
|
+
slug: "lead-research",
|
|
123
|
+
title: "Lead research",
|
|
124
|
+
description: "Build a candidate lead list from seed criteria and public sources, recording a supporting source for every contact.",
|
|
125
|
+
stage: "research",
|
|
126
|
+
tags: ["gtm", "sales", "research"],
|
|
127
|
+
version: VERSION,
|
|
128
|
+
inputs: [
|
|
129
|
+
{ key: "icp", description: "Ideal-customer description: segment, size, geography, role titles." },
|
|
130
|
+
{ key: "seed_sources", description: "Seed lists, domains, or saved searches to start from." },
|
|
131
|
+
{ key: "max_leads", description: "Hard cap on how many candidates this run may collect." }
|
|
132
|
+
],
|
|
133
|
+
outputs: [
|
|
134
|
+
{ key: "contacts", description: "Candidate contacts with name, company, title, and a source reference." }
|
|
135
|
+
],
|
|
136
|
+
allowedTools: ["search", "content-extractor"],
|
|
137
|
+
body: [
|
|
138
|
+
"Build a candidate lead list from the supplied criteria and seed sources.",
|
|
139
|
+
"",
|
|
140
|
+
"## Rules",
|
|
141
|
+
"- NEVER invent a contact detail. An email address, phone number, or title is recorded only",
|
|
142
|
+
" when a source supports it; otherwise leave the field empty.",
|
|
143
|
+
"- Record `source` on every contact \u2014 the URL or seed list the entry came from. A contact",
|
|
144
|
+
" without a source is not a lead, it is a guess.",
|
|
145
|
+
"- Respect `max_leads` exactly. Stop collecting when the cap is reached and say how many",
|
|
146
|
+
" candidates were left unexamined.",
|
|
147
|
+
"- De-duplicate by email when present, otherwise by (company, name).",
|
|
148
|
+
"- Exclude anyone who has asked not to be contacted, and any source that forbids collection.",
|
|
149
|
+
"",
|
|
150
|
+
"## Output",
|
|
151
|
+
"Write `contacts`. Each entry carries `name`, and any of `email`, `company`, `title`,",
|
|
152
|
+
"`source`, `notes` that a source supports. Report the counts examined, kept, and dropped,",
|
|
153
|
+
"with the reason for each drop category."
|
|
154
|
+
].join("\n")
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
slug: "competitor-watch",
|
|
158
|
+
title: "Competitor watch",
|
|
159
|
+
description: "Monitor a watchlist of companies across public sources and emit dated, source-linked change signals.",
|
|
160
|
+
stage: "research",
|
|
161
|
+
tags: ["gtm", "marketing", "research"],
|
|
162
|
+
version: VERSION,
|
|
163
|
+
inputs: [
|
|
164
|
+
{ key: "watchlist", description: "Companies to monitor: name, website, public repositories." },
|
|
165
|
+
{ key: "focus_areas", description: "What to watch: pricing, features, positioning, hiring." },
|
|
166
|
+
{ key: "since", description: "Only report changes observed after this date." }
|
|
167
|
+
],
|
|
168
|
+
outputs: [{ key: "signals", description: "Dated observations with a source URL and the focus area they hit." }],
|
|
169
|
+
allowedTools: ["search", "content-extractor"],
|
|
170
|
+
body: [
|
|
171
|
+
"Monitor the watchlist across public sources and report what changed.",
|
|
172
|
+
"",
|
|
173
|
+
"## Rules",
|
|
174
|
+
"- Public sources only: published pages, public announcements, public repositories.",
|
|
175
|
+
"- Every signal carries a source URL and an observation date. No date or no URL means the",
|
|
176
|
+
" signal is not reportable.",
|
|
177
|
+
"- Separate FACT (what the source says) from ANALYSIS (what you infer). Never blend them in",
|
|
178
|
+
" the same sentence.",
|
|
179
|
+
"- Report only changes since `since`. If a focus area produced nothing, say so explicitly \u2014",
|
|
180
|
+
" an empty period is a finding, not a gap to fill.",
|
|
181
|
+
"- Do not speculate about unannounced plans, internal metrics, or private information.",
|
|
182
|
+
"",
|
|
183
|
+
"## Output",
|
|
184
|
+
"Write `signals`. Each entry carries `title`, `url`, `publishedDate`, the focus area, and a",
|
|
185
|
+
"one-line factual summary."
|
|
186
|
+
].join("\n")
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
slug: "news-signal-detection",
|
|
190
|
+
title: "News signal detection",
|
|
191
|
+
description: "Scan configured topics for newsworthy events and rank them by relevance to the campaign, discarding noise.",
|
|
192
|
+
stage: "research",
|
|
193
|
+
tags: ["gtm", "marketing", "research"],
|
|
194
|
+
version: VERSION,
|
|
195
|
+
inputs: [
|
|
196
|
+
{ key: "topics", description: "Topics, keywords, or accounts to scan." },
|
|
197
|
+
{ key: "lookback_days", description: "How far back the scan reaches." },
|
|
198
|
+
{ key: "relevance_threshold", description: "Minimum relevance (0-1) an item must clear to be kept." }
|
|
199
|
+
],
|
|
200
|
+
outputs: [{ key: "signals", description: "Relevance-ranked news items with source URL and publish date." }],
|
|
201
|
+
allowedTools: ["search", "content-extractor"],
|
|
202
|
+
body: [
|
|
203
|
+
"Scan the configured topics and keep only what is genuinely newsworthy for this campaign.",
|
|
204
|
+
"",
|
|
205
|
+
"## Rules",
|
|
206
|
+
"- Score each candidate 0-1 for relevance to the campaign brief and drop anything below",
|
|
207
|
+
" `relevance_threshold`. State the score and the one-line reason for every item you keep.",
|
|
208
|
+
"- Prefer primary sources over aggregators; when both exist, link the primary.",
|
|
209
|
+
"- Collapse duplicate coverage of the same event into one signal with the best source.",
|
|
210
|
+
"- Nothing older than `lookback_days`. Undated items are dropped, not guessed at.",
|
|
211
|
+
"- Never restate a headline as fact when the source hedges it \u2014 carry the hedge through.",
|
|
212
|
+
"",
|
|
213
|
+
"## Output",
|
|
214
|
+
"Write `signals` ordered by descending relevance, each with `title`, `url`, `publishedDate`,",
|
|
215
|
+
"the relevance score, and the reason it matters here."
|
|
216
|
+
].join("\n")
|
|
217
|
+
},
|
|
218
|
+
// ── qualify ─────────────────────────────────────────────────────────
|
|
219
|
+
{
|
|
220
|
+
slug: "lead-scoring",
|
|
221
|
+
title: "Lead scoring",
|
|
222
|
+
description: "Score contacts 0-100 against a declarative weight table and attach an explainable reason per point awarded.",
|
|
223
|
+
stage: "qualify",
|
|
224
|
+
tags: ["gtm", "sales", "scoring"],
|
|
225
|
+
version: VERSION,
|
|
226
|
+
inputs: [
|
|
227
|
+
{ key: "contacts", description: "Candidate contacts to score." },
|
|
228
|
+
{ key: "score_weights", description: "Weight table: signal name \u2192 points awarded." }
|
|
229
|
+
],
|
|
230
|
+
outputs: [
|
|
231
|
+
{ key: "scored_contacts", description: "Contacts with `score` (0-100) and `scoreReasons` per contact." }
|
|
232
|
+
],
|
|
233
|
+
allowedTools: [],
|
|
234
|
+
body: [
|
|
235
|
+
"Score every contact against the supplied weight table.",
|
|
236
|
+
"",
|
|
237
|
+
"## Rules",
|
|
238
|
+
"- The weight table is the whole model. Award points ONLY for signals it names; never invent",
|
|
239
|
+
" a bonus, and never award points for a signal the contact data does not actually support.",
|
|
240
|
+
"- Clamp the final score to 0-100. Record one `scoreReasons` line per point awarded, in the",
|
|
241
|
+
" form `<signal> +<points>`, so any score can be re-derived by hand.",
|
|
242
|
+
"- A missing field is worth zero points, never an assumed value.",
|
|
243
|
+
"- Scoring is deterministic: the same contact and the same weight table must always produce",
|
|
244
|
+
" the same score. Do not break ties with judgement calls \u2014 leave ties tied.",
|
|
245
|
+
"",
|
|
246
|
+
"## Output",
|
|
247
|
+
"Write `scored_contacts` sorted by descending score, then report the score distribution and",
|
|
248
|
+
"the three signals that moved the list most."
|
|
249
|
+
].join("\n")
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
slug: "risk-filter",
|
|
253
|
+
title: "Risk filter",
|
|
254
|
+
description: "Flag low-quality or unsafe contacts against a risk weight table and exclude those at or above the threshold.",
|
|
255
|
+
stage: "qualify",
|
|
256
|
+
tags: ["gtm", "sales", "safety"],
|
|
257
|
+
version: VERSION,
|
|
258
|
+
inputs: [
|
|
259
|
+
{ key: "scored_contacts", description: "Contacts already carrying a priority score." },
|
|
260
|
+
{ key: "risk_weights", description: "Risk weight table: risk signal \u2192 points." },
|
|
261
|
+
{ key: "risk_threshold", description: "Risk score at or above which a contact is excluded." }
|
|
262
|
+
],
|
|
263
|
+
outputs: [
|
|
264
|
+
{
|
|
265
|
+
key: "scored_contacts",
|
|
266
|
+
description: "The same contacts, now carrying `riskScore`, `riskReasons`, and an excluded flag."
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
allowedTools: [],
|
|
270
|
+
body: [
|
|
271
|
+
"Assess each scored contact for risk and mark \u2014 never silently delete \u2014 the excluded ones.",
|
|
272
|
+
"",
|
|
273
|
+
"## Rules",
|
|
274
|
+
"- Apply the risk weight table exactly as given; record one `riskReasons` line per point.",
|
|
275
|
+
"- Contacts at or above `risk_threshold` are EXCLUDED from outbound, but they stay in the",
|
|
276
|
+
" data set with their reasons attached so a human can overturn the call.",
|
|
277
|
+
'- Never drop a contact without a recorded reason. "Looked wrong" is not a reason.',
|
|
278
|
+
"- Risk is about deliverability and safety (unverifiable identity, throwaway domains,",
|
|
279
|
+
" do-not-contact signals) \u2014 it is not a second opinion on fit. Fit is `lead-scoring`.",
|
|
280
|
+
"",
|
|
281
|
+
"## Output",
|
|
282
|
+
"Write the enriched `scored_contacts` and report how many were excluded, grouped by the",
|
|
283
|
+
"dominant risk reason."
|
|
284
|
+
].join("\n")
|
|
285
|
+
},
|
|
286
|
+
// ── draft ───────────────────────────────────────────────────────────
|
|
287
|
+
{
|
|
288
|
+
slug: "outreach-personalization",
|
|
289
|
+
title: "Outreach personalization",
|
|
290
|
+
description: "Write one 80-120 word personalized outbound draft per qualified contact, grounded only in known facts.",
|
|
291
|
+
stage: "draft",
|
|
292
|
+
tags: ["gtm", "sales", "writing"],
|
|
293
|
+
version: VERSION,
|
|
294
|
+
inputs: [
|
|
295
|
+
{ key: "scored_contacts", description: "Qualified, non-excluded contacts to write for." },
|
|
296
|
+
{ key: "campaign_brief", description: "Offer, proof points, and the single ask." },
|
|
297
|
+
{ key: "tone", description: "Configured tone for the campaign." }
|
|
298
|
+
],
|
|
299
|
+
outputs: [{ key: "drafts", description: "One draft per contact with `ref`, `channel`, `subject`, `body`." }],
|
|
300
|
+
allowedTools: [],
|
|
301
|
+
body: [
|
|
302
|
+
"Write one outbound draft per qualified contact.",
|
|
303
|
+
"",
|
|
304
|
+
"## Rules",
|
|
305
|
+
"- HARD CONSTRAINT: drafts only. Nothing is sent, scheduled, or queued for delivery here.",
|
|
306
|
+
'- 80-120 words in the body. One ask. No multi-part asks, no "quick question" openers that',
|
|
307
|
+
" the rest of the message contradicts.",
|
|
308
|
+
"- Personalize ONLY from fields and signals actually present on the contact. If there is no",
|
|
309
|
+
" personalization material, write the generic version and say so \u2014 a fabricated detail is",
|
|
310
|
+
" worse than a generic opener.",
|
|
311
|
+
"- Write a subject line only for channels that carry one.",
|
|
312
|
+
"- No invented metrics, customer names, or mutual connections. Ever.",
|
|
313
|
+
"",
|
|
314
|
+
"## Output",
|
|
315
|
+
"Write `drafts`, ordered by descending contact score so the review gate sees the best",
|
|
316
|
+
"candidates first. Each draft carries a stable `ref` used later by review and the action log."
|
|
317
|
+
].join("\n")
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
slug: "newsletter-drafting",
|
|
321
|
+
title: "Newsletter drafting",
|
|
322
|
+
description: "Turn briefs, notes, and collected signals into a scannable newsletter issue with one clear call to action.",
|
|
323
|
+
stage: "draft",
|
|
324
|
+
tags: ["gtm", "marketing", "content", "writing"],
|
|
325
|
+
version: VERSION,
|
|
326
|
+
inputs: [
|
|
327
|
+
{ key: "campaign_brief", description: "Issue theme, audience, and the call to action." },
|
|
328
|
+
{ key: "signals", description: "Collected source material for the issue." },
|
|
329
|
+
{ key: "tone", description: "Configured editorial tone." }
|
|
330
|
+
],
|
|
331
|
+
outputs: [{ key: "drafts", description: "A single newsletter draft: subject line plus sectioned body." }],
|
|
332
|
+
allowedTools: ["content-extractor"],
|
|
333
|
+
body: [
|
|
334
|
+
"Draft one newsletter issue from the brief and the collected material.",
|
|
335
|
+
"",
|
|
336
|
+
"## Rules",
|
|
337
|
+
"- Draft-first: the issue is produced for human review. Never send or schedule it.",
|
|
338
|
+
"- Structure: subject line, one-sentence hook, 3-5 short sections, one call to action.",
|
|
339
|
+
" Scannable beats comprehensive.",
|
|
340
|
+
"- Every claim traces to the brief, the knowledge base, or a supplied signal. Link the",
|
|
341
|
+
" source when the section rests on one.",
|
|
342
|
+
"- Never invent metrics, quotes, or customer names.",
|
|
343
|
+
"- When the source material is thin, say so and list what extra input would raise quality",
|
|
344
|
+
" rather than padding the issue.",
|
|
345
|
+
"",
|
|
346
|
+
"## Output",
|
|
347
|
+
"Write `drafts` with a single entry: `subject` plus the sectioned `body`."
|
|
348
|
+
].join("\n")
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
slug: "social-scheduling",
|
|
352
|
+
title: "Social scheduling",
|
|
353
|
+
description: "Plan a channel-fit social calendar and stage each post for review, respecting cadence and angle variety.",
|
|
354
|
+
stage: "draft",
|
|
355
|
+
tags: ["gtm", "marketing", "social", "writing"],
|
|
356
|
+
version: VERSION,
|
|
357
|
+
inputs: [
|
|
358
|
+
{ key: "campaign_brief", description: "Campaign themes, channels, and cadence." },
|
|
359
|
+
{ key: "signals", description: "Source material and trends to build posts from." },
|
|
360
|
+
{ key: "cadence", description: "Posts per channel per period." }
|
|
361
|
+
],
|
|
362
|
+
outputs: [
|
|
363
|
+
{ key: "drafts", description: "Channel-fit post drafts, each with its planned slot in the calendar." }
|
|
364
|
+
],
|
|
365
|
+
allowedTools: [],
|
|
366
|
+
body: [
|
|
367
|
+
"Plan the social calendar for the cadence window and draft each post.",
|
|
368
|
+
"",
|
|
369
|
+
"## Rules",
|
|
370
|
+
"- Draft-first: posts are STAGED for review. Never publish, never schedule to a live channel.",
|
|
371
|
+
"- Fit each draft to its channel: length, hashtag conventions, and link placement differ and",
|
|
372
|
+
" a cross-posted body is a tell.",
|
|
373
|
+
"- Do not repeat the same angle inside one cadence window. Track the angle per slot and vary",
|
|
374
|
+
" it deliberately.",
|
|
375
|
+
"- Build only from the brief, the content Works, and supplied signals. Never invent product",
|
|
376
|
+
" claims or engagement numbers.",
|
|
377
|
+
"- Respect `cadence` exactly \u2014 proposing more slots than the operator configured is not",
|
|
378
|
+
" ambition, it is a spam risk.",
|
|
379
|
+
"",
|
|
380
|
+
"## Output",
|
|
381
|
+
"Write `drafts` with the planned slot (channel + relative day) on each entry, plus a compact",
|
|
382
|
+
"calendar view of the window."
|
|
383
|
+
].join("\n")
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
slug: "digest-compilation",
|
|
387
|
+
title: "Digest compilation",
|
|
388
|
+
description: "Compile collected signals into a recurring digest that separates facts from analysis and highlights change.",
|
|
389
|
+
stage: "draft",
|
|
390
|
+
tags: ["gtm", "marketing", "reporting", "writing"],
|
|
391
|
+
version: VERSION,
|
|
392
|
+
inputs: [
|
|
393
|
+
{ key: "signals", description: "Signals collected this period." },
|
|
394
|
+
{ key: "previous_digest", description: "The prior issue, used to compute what changed." },
|
|
395
|
+
{ key: "focus_areas", description: "Sections the digest must cover." }
|
|
396
|
+
],
|
|
397
|
+
outputs: [{ key: "drafts", description: "A digest draft: sections, change highlights, and a trend view." }],
|
|
398
|
+
allowedTools: [],
|
|
399
|
+
body: [
|
|
400
|
+
"Compile the period digest from the collected signals.",
|
|
401
|
+
"",
|
|
402
|
+
"## Rules",
|
|
403
|
+
"- One section per focus area, in the configured order, every issue. A stable shape is what",
|
|
404
|
+
" makes a recurring digest readable.",
|
|
405
|
+
"- Every section splits FACTS (sourced, dated, linked) from ANALYSIS (your interpretation),",
|
|
406
|
+
" under those labels.",
|
|
407
|
+
"- Lead with what CHANGED since `previous_digest`. Unchanged areas get one line, not a",
|
|
408
|
+
" restatement of last issue.",
|
|
409
|
+
"- No fabrication and no padding: if a focus area produced no signal this period, write",
|
|
410
|
+
" exactly that.",
|
|
411
|
+
"- Close with a short trend view over the recent periods \u2014 direction, not prophecy.",
|
|
412
|
+
"",
|
|
413
|
+
"## Output",
|
|
414
|
+
"Write `drafts` with a single digest entry for review."
|
|
415
|
+
].join("\n")
|
|
416
|
+
},
|
|
417
|
+
// ── act ─────────────────────────────────────────────────────────────
|
|
418
|
+
{
|
|
419
|
+
slug: "crm-sync-hygiene",
|
|
420
|
+
title: "CRM sync hygiene",
|
|
421
|
+
description: "Prepare reviewed records for a customer-record sync: normalized fields, no duplicates, no destructive overwrites.",
|
|
422
|
+
stage: "act",
|
|
423
|
+
tags: ["gtm", "sales", "operations"],
|
|
424
|
+
version: VERSION,
|
|
425
|
+
inputs: [
|
|
426
|
+
{ key: "approved_drafts", description: "Records cleared by the review gate." },
|
|
427
|
+
{ key: "field_map", description: "Local field \u2192 destination field mapping." }
|
|
428
|
+
],
|
|
429
|
+
outputs: [
|
|
430
|
+
{ key: "action_log", description: "Prepared record writes with the field diff and the reason for each." }
|
|
431
|
+
],
|
|
432
|
+
allowedTools: ["connector"],
|
|
433
|
+
body: [
|
|
434
|
+
"Prepare reviewed records for the destination system without losing data.",
|
|
435
|
+
"",
|
|
436
|
+
"## Rules",
|
|
437
|
+
"- Only records that passed the review gate are eligible. Nothing else, no exceptions.",
|
|
438
|
+
"- NEVER overwrite a populated destination field with an empty local value. Blank does not",
|
|
439
|
+
' mean "clear it", it means "we do not know".',
|
|
440
|
+
"- Match before you create: search by the destination key (email, then domain + name) and",
|
|
441
|
+
" update the existing record rather than minting a duplicate.",
|
|
442
|
+
"- Normalize on the way out \u2014 casing, phone format, domain form \u2014 per `field_map`.",
|
|
443
|
+
"- Record every intended write in `action_log` with its field-level diff BEFORE it is",
|
|
444
|
+
" applied, so the change is auditable and reversible.",
|
|
445
|
+
"",
|
|
446
|
+
"## Output",
|
|
447
|
+
"Write `action_log` with one entry per record, status `prepared` or `skipped`, and the",
|
|
448
|
+
"reason for every skip."
|
|
449
|
+
].join("\n")
|
|
450
|
+
},
|
|
451
|
+
// ── follow-up ───────────────────────────────────────────────────────
|
|
452
|
+
{
|
|
453
|
+
slug: "follow-up-cadence",
|
|
454
|
+
title: "Follow-up cadence",
|
|
455
|
+
description: "Schedule timed re-engagement for quiet threads, with strict caps and an unconditional stop on any reply.",
|
|
456
|
+
stage: "follow-up",
|
|
457
|
+
tags: ["gtm", "sales", "cadence"],
|
|
458
|
+
version: VERSION,
|
|
459
|
+
inputs: [
|
|
460
|
+
{ key: "action_log", description: "What was prepared, for whom, and when." },
|
|
461
|
+
{ key: "reply_state", description: "Which threads have received a reply." },
|
|
462
|
+
{ key: "cadence", description: "Follow-up spacing and the maximum number of touches." }
|
|
463
|
+
],
|
|
464
|
+
outputs: [
|
|
465
|
+
{ key: "follow_up_queue", description: "Queued follow-ups with a due offset and the rationale for each." }
|
|
466
|
+
],
|
|
467
|
+
allowedTools: [],
|
|
468
|
+
body: [
|
|
469
|
+
"Queue follow-ups for threads that have gone quiet.",
|
|
470
|
+
"",
|
|
471
|
+
"## Rules",
|
|
472
|
+
"- HARD STOP on any reply, bounce, or opt-out: that thread leaves the cadence immediately and",
|
|
473
|
+
" permanently. This overrides every other rule here.",
|
|
474
|
+
"- Never exceed the configured maximum touches per contact, and never shorten the configured",
|
|
475
|
+
" spacing to fit more in.",
|
|
476
|
+
"- Each follow-up must add something \u2014 a new angle, a new proof point, a genuine deadline.",
|
|
477
|
+
' "Bumping this to the top of your inbox" is not a follow-up.',
|
|
478
|
+
"- Follow-ups are drafts like any other outbound: they re-enter the review gate before",
|
|
479
|
+
" anything is prepared for delivery.",
|
|
480
|
+
"",
|
|
481
|
+
"## Output",
|
|
482
|
+
"Write `follow_up_queue` with `draftRef`, `channel`, `dueAfterDays`, and the rationale."
|
|
483
|
+
].join("\n")
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
slug: "reply-detection",
|
|
487
|
+
title: "Reply detection",
|
|
488
|
+
description: "Classify inbound replies into interested / not-now / decline / opt-out and route each to the right next step.",
|
|
489
|
+
stage: "follow-up",
|
|
490
|
+
tags: ["gtm", "sales", "classification"],
|
|
491
|
+
version: VERSION,
|
|
492
|
+
inputs: [
|
|
493
|
+
{ key: "inbound_messages", description: "Replies received against prepared outbound." },
|
|
494
|
+
{ key: "action_log", description: "The outbound each reply responds to." }
|
|
495
|
+
],
|
|
496
|
+
outputs: [
|
|
497
|
+
{ key: "reply_state", description: "Per-thread classification, confidence, and the routing decision." }
|
|
498
|
+
],
|
|
499
|
+
allowedTools: ["connector"],
|
|
500
|
+
body: [
|
|
501
|
+
"Classify each inbound reply and decide what happens to its thread.",
|
|
502
|
+
"",
|
|
503
|
+
"## Classes",
|
|
504
|
+
"`interested` \xB7 `not_now` \xB7 `decline` \xB7 `opt_out` \xB7 `auto_reply` \xB7 `unclear`",
|
|
505
|
+
"",
|
|
506
|
+
"## Rules",
|
|
507
|
+
"- `opt_out` and `decline` stop the cadence permanently. When in doubt between `opt_out` and",
|
|
508
|
+
" anything else, choose `opt_out` \u2014 the cost of a wrong stop is far below the cost of a",
|
|
509
|
+
" wrong send.",
|
|
510
|
+
"- `auto_reply` (out-of-office, autoresponder) does NOT count as a reply for cadence",
|
|
511
|
+
" purposes, but it does update the contact record if it names a new owner.",
|
|
512
|
+
"- Use `unclear` rather than guessing; unclear threads route to a human, they do not route",
|
|
513
|
+
" to the next touch.",
|
|
514
|
+
"- Record a confidence value and the phrase that drove the classification.",
|
|
515
|
+
"",
|
|
516
|
+
"## Output",
|
|
517
|
+
"Write `reply_state` with the class, confidence, evidence phrase, and routing decision per",
|
|
518
|
+
"thread."
|
|
519
|
+
].join("\n")
|
|
520
|
+
},
|
|
521
|
+
// ── enrich ──────────────────────────────────────────────────────────
|
|
522
|
+
{
|
|
523
|
+
slug: "contact-enrichment",
|
|
524
|
+
title: "Contact enrichment",
|
|
525
|
+
description: "Backfill missing contact and account fields from verifiable sources, recording the evidence for each fill.",
|
|
526
|
+
stage: "enrich",
|
|
527
|
+
tags: ["gtm", "sales", "data"],
|
|
528
|
+
version: VERSION,
|
|
529
|
+
inputs: [
|
|
530
|
+
{ key: "contacts", description: "Contacts with gaps to fill." },
|
|
531
|
+
{ key: "enrichment_fields", description: "Which fields this run is allowed to fill." }
|
|
532
|
+
],
|
|
533
|
+
outputs: [
|
|
534
|
+
{ key: "enriched_contacts", description: "Contacts with filled fields and a source note per filled field." }
|
|
535
|
+
],
|
|
536
|
+
allowedTools: ["search", "content-extractor", "connector"],
|
|
537
|
+
body: [
|
|
538
|
+
"Fill the requested gaps on each contact \u2014 and only those gaps.",
|
|
539
|
+
"",
|
|
540
|
+
"## Rules",
|
|
541
|
+
"- Evidence-bound: a field is filled ONLY when a source supports it, and the source goes in",
|
|
542
|
+
" the contact notes alongside the value. No source, no fill.",
|
|
543
|
+
"- NEVER guess or pattern-generate an email address. Constructing `first.last@domain` because",
|
|
544
|
+
" it usually works is fabrication, and it is the single most damaging thing this Skill can do.",
|
|
545
|
+
"- Never overwrite an existing non-empty value. Enrichment fills gaps; corrections are a",
|
|
546
|
+
" human decision.",
|
|
547
|
+
"- Only touch fields named in `enrichment_fields`.",
|
|
548
|
+
"- When two sources disagree, leave the field empty and flag the conflict.",
|
|
549
|
+
"",
|
|
550
|
+
"## Output",
|
|
551
|
+
"Write `enriched_contacts` and report fill rate per field plus every conflict flagged."
|
|
552
|
+
].join("\n")
|
|
553
|
+
},
|
|
554
|
+
// ── measure ─────────────────────────────────────────────────────────
|
|
555
|
+
{
|
|
556
|
+
slug: "seo-audit",
|
|
557
|
+
title: "Search-visibility audit",
|
|
558
|
+
description: "Audit a site or content Work for search visibility and return a prioritized, evidence-cited fix list.",
|
|
559
|
+
stage: "measure",
|
|
560
|
+
tags: ["gtm", "marketing", "seo", "audit"],
|
|
561
|
+
version: VERSION,
|
|
562
|
+
inputs: [
|
|
563
|
+
{ key: "pages", description: "Pages or posts in scope, with their current metadata and headings." },
|
|
564
|
+
{ key: "target_keywords", description: "Keywords or topics the Work is meant to rank for." },
|
|
565
|
+
{ key: "previous_audit", description: "The prior audit, used to report movement and regressions." }
|
|
566
|
+
],
|
|
567
|
+
outputs: [
|
|
568
|
+
{ key: "campaign_report", description: "Prioritized findings with page reference, impact, and fix." }
|
|
569
|
+
],
|
|
570
|
+
allowedTools: ["content-extractor", "search"],
|
|
571
|
+
body: [
|
|
572
|
+
"Audit the in-scope pages for search visibility and propose fixes.",
|
|
573
|
+
"",
|
|
574
|
+
"## What to check",
|
|
575
|
+
"Title and description metadata \xB7 heading structure and hierarchy \xB7 internal linking and",
|
|
576
|
+
"orphan pages \xB7 keyword coverage against `target_keywords` and the gaps between them \xB7",
|
|
577
|
+
"duplicate or thin content \xB7 canonical and indexability signals.",
|
|
578
|
+
"",
|
|
579
|
+
"## Rules",
|
|
580
|
+
"- Every finding cites the specific page or setting it applies to and states the expected",
|
|
581
|
+
" impact. A finding without a page reference is an opinion.",
|
|
582
|
+
"- Return a prioritized top 5-10, quick wins first \u2014 not an exhaustive dump.",
|
|
583
|
+
"- Propose changes as reviewable edits or tasks. Never modify published pages directly.",
|
|
584
|
+
"- When `previous_audit` is present, report movement honestly, INCLUDING regressions. A",
|
|
585
|
+
" clean report that hides a regression is worse than no report.",
|
|
586
|
+
"- No traffic or ranking projections. Estimate effort and impact qualitatively instead.",
|
|
587
|
+
"",
|
|
588
|
+
"## Output",
|
|
589
|
+
"Write `campaign_report` with the prioritized findings and the movement summary."
|
|
590
|
+
].join("\n")
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
slug: "campaign-reporting",
|
|
594
|
+
title: "Campaign reporting",
|
|
595
|
+
description: "Summarize a campaign period into counted totals, honest insights, and concrete hints for the next cycle.",
|
|
596
|
+
stage: "measure",
|
|
597
|
+
tags: ["gtm", "reporting"],
|
|
598
|
+
version: VERSION,
|
|
599
|
+
inputs: [
|
|
600
|
+
{ key: "action_log", description: "What the campaign prepared and skipped." },
|
|
601
|
+
{ key: "reply_state", description: "How recipients responded." },
|
|
602
|
+
{ key: "scored_contacts", description: "The qualified population the period worked from." }
|
|
603
|
+
],
|
|
604
|
+
outputs: [{ key: "campaign_report", description: "Totals, insights, and next-cycle variant hints." }],
|
|
605
|
+
allowedTools: [],
|
|
606
|
+
body: [
|
|
607
|
+
"Report the campaign period and close the loop into the next one.",
|
|
608
|
+
"",
|
|
609
|
+
"## Rules",
|
|
610
|
+
"- Totals are COUNTED from the supplied data, never estimated: contacts, qualified, excluded,",
|
|
611
|
+
" drafts, approved, prepared, follow-ups queued.",
|
|
612
|
+
"- State the denominator on every rate. A percentage without its base is not a metric.",
|
|
613
|
+
"- Below roughly 30 observations, report counts and refuse to draw a conclusion \u2014 small",
|
|
614
|
+
" samples produce confident nonsense.",
|
|
615
|
+
"- Insights must be falsifiable and tied to a number in the totals.",
|
|
616
|
+
"- End with `nextVariantHints`: concrete, testable changes for the next draft cycle, one per",
|
|
617
|
+
" line. This is the loop closing \u2014 a report that ends at description wasted the period.",
|
|
618
|
+
"",
|
|
619
|
+
"## Output",
|
|
620
|
+
"Write `campaign_report` with `summary`, `totals`, `insights`, and `nextVariantHints`."
|
|
621
|
+
].join("\n")
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
slug: "engagement-analysis",
|
|
625
|
+
title: "Engagement analysis",
|
|
626
|
+
description: "Compare engagement across variants, channels, and segments, and say which differences are real.",
|
|
627
|
+
stage: "measure",
|
|
628
|
+
tags: ["gtm", "marketing", "reporting"],
|
|
629
|
+
version: VERSION,
|
|
630
|
+
inputs: [
|
|
631
|
+
{ key: "engagement_events", description: "Per-item engagement observations for the period." },
|
|
632
|
+
{ key: "drafts", description: "The variants the events belong to." },
|
|
633
|
+
{ key: "comparison_window", description: "Prior period to compare against." }
|
|
634
|
+
],
|
|
635
|
+
outputs: [
|
|
636
|
+
{ key: "campaign_report", description: "Per-variant and per-segment engagement with a confidence call." }
|
|
637
|
+
],
|
|
638
|
+
allowedTools: ["metrics"],
|
|
639
|
+
body: [
|
|
640
|
+
"Analyze engagement and report what actually differs.",
|
|
641
|
+
"",
|
|
642
|
+
"## Rules",
|
|
643
|
+
"- Compare like with like: same channel, same audience segment, comparable send window.",
|
|
644
|
+
" Cross-channel comparisons need an explicit caveat.",
|
|
645
|
+
"- Report absolute counts alongside every rate.",
|
|
646
|
+
"- Say plainly when a difference is within noise. Declaring a winner on a handful of",
|
|
647
|
+
" observations is the most common way this analysis misleads a campaign for months.",
|
|
648
|
+
"- Separate what changed (observation) from why (hypothesis), and label hypotheses as such.",
|
|
649
|
+
"- Surface the losing variants too \u2014 a variant that consistently underperforms is the",
|
|
650
|
+
" cheapest thing to stop doing.",
|
|
651
|
+
"",
|
|
652
|
+
"## Output",
|
|
653
|
+
"Write `campaign_report` with the per-variant table, the segment breakdown, and an explicit",
|
|
654
|
+
"confidence statement per comparison."
|
|
655
|
+
].join("\n")
|
|
656
|
+
}
|
|
657
|
+
];
|
|
658
|
+
GTM_SKILLS.map((skill) => skill.slug);
|
|
659
|
+
new Map(
|
|
660
|
+
GTM_SKILLS.map((skill) => [skill.slug, skill])
|
|
661
|
+
);
|
|
662
|
+
var FLEET_AGENT_CREDENTIAL_FAMILIES = [
|
|
663
|
+
{
|
|
664
|
+
cli: "claude-code",
|
|
665
|
+
// CLAUDE_CODE_OAUTH_TOKEN (a Claude plan) before ANTHROPIC_API_KEY
|
|
666
|
+
// (per-token Console billing) — deliberately the REVERSE of the CLI's
|
|
667
|
+
// own precedence, so the cheaper credential wins rather than the one
|
|
668
|
+
// that silently spends money.
|
|
669
|
+
envNames: ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY"]
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
cli: "codex",
|
|
673
|
+
// CODEX_ACCESS_TOKEN draws the ChatGPT workspace entitlement;
|
|
674
|
+
// OPENAI_API_KEY is per-token platform billing.
|
|
675
|
+
envNames: ["CODEX_ACCESS_TOKEN", "OPENAI_API_KEY"]
|
|
676
|
+
}
|
|
677
|
+
];
|
|
678
|
+
FLEET_AGENT_CREDENTIAL_FAMILIES.flatMap(
|
|
679
|
+
(family) => family.envNames
|
|
680
|
+
);
|
|
681
|
+
var FLEET_LINK_FRAME_KINDS = {
|
|
682
|
+
/** Raw bytes: terminal output/input, log lines, file chunks. */
|
|
683
|
+
DATA: 1,
|
|
684
|
+
/** `[cols u16][rows u16]`. */
|
|
685
|
+
RESIZE: 2,
|
|
686
|
+
/** `[code i32]`. */
|
|
687
|
+
EXIT: 3,
|
|
688
|
+
/** UTF-8 JSON control message. */
|
|
689
|
+
JSON: 10,
|
|
690
|
+
/** UTF-8 reason code. */
|
|
691
|
+
CLOSE: 11,
|
|
692
|
+
/** A full picture (the existing computer-frame encoding). */
|
|
693
|
+
FRAME: 20,
|
|
694
|
+
/** A pointer / key / text event (the existing computer input encoding). */
|
|
695
|
+
INPUT: 21,
|
|
696
|
+
/** Changed tiles `[w][h][count]{x,y,w,h,len,jpeg}`. */
|
|
697
|
+
TILES: 23,
|
|
698
|
+
/** `[bytes u32]` credit. */
|
|
699
|
+
ACK: 30,
|
|
700
|
+
/** End of a stream. */
|
|
701
|
+
END: 31,
|
|
702
|
+
/** UTF-8 text ≤ 256 KiB, pasted into a desktop. */
|
|
703
|
+
CLIP: 40
|
|
704
|
+
};
|
|
705
|
+
new Set(Object.values(FLEET_LINK_FRAME_KINDS));
|
|
706
|
+
var FLEET_LINK_CONTROL_TYPES = [
|
|
707
|
+
"link.hello",
|
|
708
|
+
"link.ready",
|
|
709
|
+
"link.ping",
|
|
710
|
+
"link.pong",
|
|
711
|
+
"link.pause",
|
|
712
|
+
"link.resume",
|
|
713
|
+
"link.drain",
|
|
714
|
+
"channel.open",
|
|
715
|
+
"channel.ready",
|
|
716
|
+
"channel.refused",
|
|
717
|
+
"channel.close",
|
|
718
|
+
"operation.progress",
|
|
719
|
+
"operation.done",
|
|
720
|
+
"operation.cancel"
|
|
721
|
+
];
|
|
722
|
+
var FLEET_CREDENTIAL_FILE_PATTERNS = [
|
|
723
|
+
".env",
|
|
724
|
+
".env.*",
|
|
725
|
+
"*.pem",
|
|
726
|
+
"*.key",
|
|
727
|
+
"*.p12",
|
|
728
|
+
"*.pfx",
|
|
729
|
+
"*.jks",
|
|
730
|
+
"*.keystore",
|
|
731
|
+
"*.kdbx",
|
|
732
|
+
"id_rsa*",
|
|
733
|
+
"id_dsa*",
|
|
734
|
+
"id_ecdsa*",
|
|
735
|
+
"id_ed25519*",
|
|
736
|
+
"*.ppk",
|
|
737
|
+
".netrc",
|
|
738
|
+
".npmrc",
|
|
739
|
+
".pypirc",
|
|
740
|
+
"credentials",
|
|
741
|
+
"credentials.json",
|
|
742
|
+
"service-account*.json",
|
|
743
|
+
".aws/credentials",
|
|
744
|
+
"*.gpg",
|
|
745
|
+
"*.asc",
|
|
746
|
+
".docker/config.json",
|
|
747
|
+
"kubeconfig",
|
|
748
|
+
".kube/config"
|
|
749
|
+
];
|
|
750
|
+
function globToRegExp(glob) {
|
|
751
|
+
const escaped = glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
752
|
+
return new RegExp(`^${escaped}$`, "i");
|
|
753
|
+
}
|
|
754
|
+
FLEET_CREDENTIAL_FILE_PATTERNS.filter((pattern) => !pattern.includes("/")).map(
|
|
755
|
+
globToRegExp
|
|
756
|
+
);
|
|
757
|
+
FLEET_CREDENTIAL_FILE_PATTERNS.filter((pattern) => pattern.includes("/")).map(
|
|
758
|
+
(pattern) => ({ segments: pattern.split("/").length, matcher: globToRegExp(pattern) })
|
|
759
|
+
);
|
|
760
|
+
new Set(FLEET_LINK_CONTROL_TYPES);
|
|
761
|
+
new TextEncoder();
|
|
762
|
+
var FLEET_RUN_TOKEN_ROUTES = Object.freeze([
|
|
763
|
+
// Works — reads, plus the settings update (its merge / check / command
|
|
764
|
+
// fields are refused for run tokens by the Works controller).
|
|
765
|
+
{ method: "GET", pathPattern: "/api/works" },
|
|
766
|
+
{ method: "GET", pathPattern: "/api/works/{id}" },
|
|
767
|
+
{ method: "PUT", pathPattern: "/api/works/{id}" },
|
|
768
|
+
{ method: "GET", pathPattern: "/api/works/{id}/config" },
|
|
769
|
+
{ method: "GET", pathPattern: "/api/works/{id}/items" },
|
|
770
|
+
{ method: "GET", pathPattern: "/api/works/{id}/categories-tags" },
|
|
771
|
+
{ method: "GET", pathPattern: "/api/works/{id}/history" },
|
|
772
|
+
{ method: "GET", pathPattern: "/api/works/{id}/generator-form" },
|
|
773
|
+
{ method: "GET", pathPattern: "/api/works/{id}/schedule" },
|
|
774
|
+
{ method: "GET", pathPattern: "/api/works/{id}/comparisons" },
|
|
775
|
+
{ method: "GET", pathPattern: "/api/works/{id}/comparisons/{slug}" },
|
|
776
|
+
// Knowledge Base (`apps/mcp/src/tools/kb`). A document a run token writes
|
|
777
|
+
// lands `proposed` (review-gated), see the KB controller. No unlock.
|
|
778
|
+
{ method: "GET", pathPattern: "/api/works/{id}/kb/documents" },
|
|
779
|
+
{ method: "POST", pathPattern: "/api/works/{id}/kb/documents" },
|
|
780
|
+
{ method: "GET", pathPattern: "/api/works/{id}/kb/documents/{docIdOrPath}" },
|
|
781
|
+
{ method: "PATCH", pathPattern: "/api/works/{id}/kb/documents/{docId}" },
|
|
782
|
+
{ method: "POST", pathPattern: "/api/works/{id}/kb/documents/{docId}/lock" },
|
|
783
|
+
// Deploy — reads and the capability check only.
|
|
784
|
+
{ method: "GET", pathPattern: "/api/deploy/works/{id}/domains" },
|
|
785
|
+
{ method: "GET", pathPattern: "/api/deploy/providers" },
|
|
786
|
+
{ method: "POST", pathPattern: "/api/deploy/works/{id}/check" },
|
|
787
|
+
// Plugins — read only.
|
|
788
|
+
{ method: "GET", pathPattern: "/api/plugins" },
|
|
789
|
+
{ method: "GET", pathPattern: "/api/plugins/{pluginId}" },
|
|
790
|
+
// Missions — reads, plus pause (the safe direction).
|
|
791
|
+
{ method: "GET", pathPattern: "/api/me/missions" },
|
|
792
|
+
{ method: "GET", pathPattern: "/api/me/missions/{id}" },
|
|
793
|
+
{ method: "GET", pathPattern: "/api/me/missions/{id}/budget" },
|
|
794
|
+
{ method: "GET", pathPattern: "/api/me/missions/{id}/works" },
|
|
795
|
+
{ method: "POST", pathPattern: "/api/me/missions/{id}/pause" },
|
|
796
|
+
// Ideas — reads, plus filing a new Idea (a proposal a person builds).
|
|
797
|
+
{ method: "POST", pathPattern: "/api/me/work-proposals" },
|
|
798
|
+
{ method: "GET", pathPattern: "/api/me/work-proposals" },
|
|
799
|
+
{ method: "GET", pathPattern: "/api/me/work-proposals/status" },
|
|
800
|
+
{ method: "GET", pathPattern: "/api/me/work-proposals/preferences" },
|
|
801
|
+
{ method: "GET", pathPattern: "/api/me/work-proposals/{id}" },
|
|
802
|
+
{ method: "GET", pathPattern: "/api/me/work-proposals/{id}/budget" },
|
|
803
|
+
// Account-wide usage.
|
|
804
|
+
{ method: "GET", pathPattern: "/api/me/usage/account-wide" },
|
|
805
|
+
// Tasks — reads and collaboration writes. Create / update / transition /
|
|
806
|
+
// assign / chat carry body refusals for run tokens in the Tasks
|
|
807
|
+
// controller (no checks, no schedule, no force, no dispatch, no @agent).
|
|
808
|
+
{ method: "GET", pathPattern: "/api/tasks" },
|
|
809
|
+
{ method: "POST", pathPattern: "/api/tasks" },
|
|
810
|
+
{ method: "GET", pathPattern: "/api/tasks/{id}" },
|
|
811
|
+
{ method: "PATCH", pathPattern: "/api/tasks/{id}" },
|
|
812
|
+
{ method: "GET", pathPattern: "/api/tasks/{id}/subtasks" },
|
|
813
|
+
{ method: "GET", pathPattern: "/api/tasks/{id}/activity" },
|
|
814
|
+
{ method: "POST", pathPattern: "/api/tasks/{id}/transition" },
|
|
815
|
+
{ method: "GET", pathPattern: "/api/tasks/{id}/run-candidates" },
|
|
816
|
+
{ method: "GET", pathPattern: "/api/tasks/{id}/pr-status" },
|
|
817
|
+
{ method: "GET", pathPattern: "/api/tasks/{id}/diff" },
|
|
818
|
+
{ method: "POST", pathPattern: "/api/tasks/{id}/assignees" },
|
|
819
|
+
{ method: "POST", pathPattern: "/api/tasks/{id}/reviewers" },
|
|
820
|
+
{ method: "POST", pathPattern: "/api/tasks/{id}/approvers" },
|
|
821
|
+
{ method: "POST", pathPattern: "/api/tasks/{id}/relations" },
|
|
822
|
+
{ method: "GET", pathPattern: "/api/tasks/{id}/escalations" },
|
|
823
|
+
{ method: "GET", pathPattern: "/api/tasks/{id}/chat" },
|
|
824
|
+
{ method: "POST", pathPattern: "/api/tasks/{id}/chat" },
|
|
825
|
+
{ method: "GET", pathPattern: "/api/tasks/{id}/spend" },
|
|
826
|
+
// Inbox — read only (no reply, no archive / delete / mark-read).
|
|
827
|
+
{ method: "GET", pathPattern: "/api/inbox" },
|
|
828
|
+
{ method: "GET", pathPattern: "/api/inbox/unread-count" },
|
|
829
|
+
{ method: "GET", pathPattern: "/api/inbox/{id}" },
|
|
830
|
+
// Goals — reads, a draft create, field-limited update, pause, and the
|
|
831
|
+
// ASKING side of the definition of done (propose, never approve).
|
|
832
|
+
{ method: "GET", pathPattern: "/api/me/goals" },
|
|
833
|
+
{ method: "POST", pathPattern: "/api/me/goals" },
|
|
834
|
+
{ method: "GET", pathPattern: "/api/me/goals/{id}" },
|
|
835
|
+
{ method: "PATCH", pathPattern: "/api/me/goals/{id}" },
|
|
836
|
+
{ method: "GET", pathPattern: "/api/me/goals/{id}/samples" },
|
|
837
|
+
{ method: "POST", pathPattern: "/api/me/goals/{id}/pause" },
|
|
838
|
+
{ method: "POST", pathPattern: "/api/me/goals/{id}/dod/propose" },
|
|
839
|
+
// Fleet — reads only.
|
|
840
|
+
{ method: "GET", pathPattern: "/api/fleet/nodes" },
|
|
841
|
+
{ method: "GET", pathPattern: "/api/fleet/nodes/{id}" },
|
|
842
|
+
{ method: "GET", pathPattern: "/api/fleet/runner-status" },
|
|
843
|
+
{ method: "GET", pathPattern: "/api/fleet/execution-preferences" },
|
|
844
|
+
{ method: "GET", pathPattern: "/api/fleet/agents/{agentId}/node-affinity" },
|
|
845
|
+
// Session git & actions (FL-06 FR-18): an Agent session asks the platform to
|
|
846
|
+
// open or update the pull request of ITS OWN checkout. The route refuses a
|
|
847
|
+
// checkout that is not the token's session's, and the Agent's "may open pull
|
|
848
|
+
// requests" permission applies; it never merges anything.
|
|
849
|
+
{ method: "GET", pathPattern: "/api/fleet/checkouts/{id}/pull-request" },
|
|
850
|
+
{ method: "POST", pathPattern: "/api/fleet/checkouts/{id}/pull-request" },
|
|
851
|
+
// Agents — reads, plus cancel and pause (the safe direction).
|
|
852
|
+
{ method: "GET", pathPattern: "/api/agents" },
|
|
853
|
+
{ method: "GET", pathPattern: "/api/agents/{id}" },
|
|
854
|
+
{ method: "GET", pathPattern: "/api/agents/{id}/runs" },
|
|
855
|
+
{ method: "GET", pathPattern: "/api/agents/{id}/runs/{runId}" },
|
|
856
|
+
{ method: "POST", pathPattern: "/api/agents/{id}/runs/{runId}/cancel" },
|
|
857
|
+
{ method: "POST", pathPattern: "/api/agents/{id}/pause" },
|
|
858
|
+
{ method: "GET", pathPattern: "/api/agents/{id}/budget" },
|
|
859
|
+
// Agent Plugins — read only (installing a package installs instructions).
|
|
860
|
+
{ method: "GET", pathPattern: "/api/agent-plugins" },
|
|
861
|
+
{ method: "GET", pathPattern: "/api/agent-plugins/findings" },
|
|
862
|
+
{ method: "GET", pathPattern: "/api/agent-plugins/catalog" },
|
|
863
|
+
{ method: "GET", pathPattern: "/api/agent-plugins/updates" }
|
|
864
|
+
]);
|
|
865
|
+
function splitSegments(normalizedPath) {
|
|
866
|
+
return normalizedPath.split("/").filter((segment) => segment.length > 0);
|
|
867
|
+
}
|
|
868
|
+
FLEET_RUN_TOKEN_ROUTES.map((route) => ({
|
|
869
|
+
method: route.method.toUpperCase(),
|
|
870
|
+
shape: splitSegments(route.pathPattern).map((part) => /^\{[^}]+\}$/.test(part) ? "*" : part.toLowerCase())
|
|
871
|
+
}));
|
|
872
|
+
function row(input) {
|
|
873
|
+
const rest = input.name.slice("fleet_".length);
|
|
874
|
+
const cut = rest.indexOf("_");
|
|
875
|
+
const family = cut === -1 ? rest : rest.slice(0, cut);
|
|
876
|
+
const verb = cut === -1 ? "" : rest.slice(cut + 1);
|
|
877
|
+
return Object.freeze({ ...input, family, verb });
|
|
878
|
+
}
|
|
879
|
+
function read(name, permissionFamily, owner, flag, status, extra = {}) {
|
|
880
|
+
return row({
|
|
881
|
+
name,
|
|
882
|
+
readOnly: true,
|
|
883
|
+
category: "read.internal",
|
|
884
|
+
permissionFamily,
|
|
885
|
+
owner,
|
|
886
|
+
phase: "P1",
|
|
887
|
+
flag,
|
|
888
|
+
status,
|
|
889
|
+
...extra
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
function act(name, permissionFamily, owner, flag, status, annotation, extra = {}) {
|
|
893
|
+
return row({ name, permissionFamily, owner, phase: "P2", flag, status, ...annotation, ...extra });
|
|
894
|
+
}
|
|
895
|
+
var plain = (category, destructive = false) => ({
|
|
896
|
+
destructive,
|
|
897
|
+
confirmationClass: "plain",
|
|
898
|
+
category
|
|
899
|
+
});
|
|
900
|
+
var confirm = (category, destructive = true) => ({
|
|
901
|
+
destructive,
|
|
902
|
+
confirmationClass: "confirm",
|
|
903
|
+
category
|
|
904
|
+
});
|
|
905
|
+
var typed = (category) => ({
|
|
906
|
+
destructive: true,
|
|
907
|
+
confirmationClass: "confirm-destructive",
|
|
908
|
+
category
|
|
909
|
+
});
|
|
910
|
+
var GET = (path) => ({ method: "GET", path });
|
|
911
|
+
var POST = (path) => ({ method: "POST", path });
|
|
912
|
+
var PATCH = (path) => ({ method: "PATCH", path });
|
|
913
|
+
var DELETE = (path) => ({ method: "DELETE", path });
|
|
914
|
+
var FLEET_TOOL_CATALOGUE = Object.freeze([
|
|
915
|
+
// ── status (FL-19) ──
|
|
916
|
+
read("fleet_status", "view", "FL-19", "FLEET_ENABLED", "live", {
|
|
917
|
+
route: GET("/api/fleet/status"),
|
|
918
|
+
cli: "fleet status"
|
|
919
|
+
}),
|
|
920
|
+
// ── nodes (FL-19, FL-03, FL-15) ──
|
|
921
|
+
read("fleet_nodes_list", "view", "FL-19", "FLEET_ENABLED", "live", {
|
|
922
|
+
route: GET("/api/fleet/nodes"),
|
|
923
|
+
cli: "fleet nodes list"
|
|
924
|
+
}),
|
|
925
|
+
read("fleet_nodes_get", "view", "FL-19", "FLEET_ENABLED", "live", {
|
|
926
|
+
route: GET("/api/fleet/nodes/{id}"),
|
|
927
|
+
cli: "fleet nodes get"
|
|
928
|
+
}),
|
|
929
|
+
read("fleet_nodes_health", "view", "FL-03", "FLEET_ENABLED", "live", {
|
|
930
|
+
route: GET("/api/fleet/nodes/{id}/health"),
|
|
931
|
+
cli: "fleet nodes health"
|
|
932
|
+
}),
|
|
933
|
+
read("fleet_nodes_needs_a_look", "view", "FL-03", "FLEET_ENABLED", "live", {
|
|
934
|
+
route: GET("/api/fleet/nodes/{id}/needs-a-look"),
|
|
935
|
+
cli: "fleet nodes needs-a-look"
|
|
936
|
+
}),
|
|
937
|
+
read("fleet_nodes_git_identity_get", "view", "FL-15", "FLEET_CHECKOUTS_ENABLED", "live", {
|
|
938
|
+
route: GET("/api/fleet/nodes/{id}/git/identity"),
|
|
939
|
+
cli: "fleet nodes git-identity"
|
|
940
|
+
}),
|
|
941
|
+
act("fleet_nodes_wake", "machines", "FL-03", "FLEET_ENABLED", "live", plain("machine.admin"), {
|
|
942
|
+
route: POST("/api/fleet/nodes/{id}/wake"),
|
|
943
|
+
cli: "fleet nodes wake"
|
|
944
|
+
}),
|
|
945
|
+
act(
|
|
946
|
+
"fleet_nodes_git_identity_set",
|
|
947
|
+
"commands",
|
|
948
|
+
"FL-15",
|
|
949
|
+
"FLEET_CHECKOUTS_ENABLED",
|
|
950
|
+
"live",
|
|
951
|
+
confirm("machine.admin", false),
|
|
952
|
+
{ route: POST("/api/fleet/nodes/{id}/git/identity"), cli: "fleet nodes git-identity --set" }
|
|
953
|
+
),
|
|
954
|
+
// ── sessions (FL-04, FL-05, FL-06) ──
|
|
955
|
+
read("fleet_sessions_list", "sessions", "FL-04", "FLEET_SESSIONS_ENABLED", "live", {
|
|
956
|
+
route: GET("/api/fleet/sessions"),
|
|
957
|
+
cli: "fleet sessions list"
|
|
958
|
+
}),
|
|
959
|
+
read("fleet_sessions_read", "sessions", "FL-04", "FLEET_SESSIONS_ENABLED", "live", {
|
|
960
|
+
route: GET("/api/fleet/sessions/{id}"),
|
|
961
|
+
cli: "fleet sessions read"
|
|
962
|
+
}),
|
|
963
|
+
read("fleet_sessions_question", "sessions", "FL-05", "FLEET_SESSIONS_ENABLED", "live", {
|
|
964
|
+
route: GET("/api/fleet/sessions/{id}"),
|
|
965
|
+
cli: "fleet sessions question"
|
|
966
|
+
}),
|
|
967
|
+
read("fleet_sessions_actions_list", "sessions", "FL-06", "FLEET_SESSIONS_ENABLED", "planned", {
|
|
968
|
+
route: GET("/api/fleet/sessions/{id}/actions"),
|
|
969
|
+
cli: "fleet sessions actions"
|
|
970
|
+
}),
|
|
971
|
+
act("fleet_sessions_start", "sessions", "FL-04", "FLEET_SESSIONS_ENABLED", "live", plain("machine.run"), {
|
|
972
|
+
route: POST("/api/fleet/nodes/{id}/sessions"),
|
|
973
|
+
cli: "fleet sessions start"
|
|
974
|
+
}),
|
|
975
|
+
act("fleet_sessions_send", "sessions", "FL-04", "FLEET_SESSIONS_ENABLED", "live", plain("machine.run")),
|
|
976
|
+
act("fleet_sessions_answer", "sessions", "FL-05", "FLEET_SESSIONS_ENABLED", "live", confirm("machine.run", false), {
|
|
977
|
+
route: POST("/api/fleet/sessions/{id}/answer"),
|
|
978
|
+
cli: "fleet sessions answer",
|
|
979
|
+
confirmationNote: "questions only; a permission prompt is answered by a person (CONTRACTS R-32)"
|
|
980
|
+
}),
|
|
981
|
+
act("fleet_sessions_rename", "sessions", "FL-04", "FLEET_SESSIONS_ENABLED", "live", plain("write.internal"), {
|
|
982
|
+
route: PATCH("/api/fleet/sessions/{id}"),
|
|
983
|
+
cli: "fleet sessions rename"
|
|
984
|
+
}),
|
|
985
|
+
act("fleet_sessions_end", "sessions", "FL-04", "FLEET_SESSIONS_ENABLED", "live", confirm("machine.run"), {
|
|
986
|
+
route: POST("/api/fleet/sessions/{id}/end"),
|
|
987
|
+
cli: "fleet sessions end"
|
|
988
|
+
}),
|
|
989
|
+
act("fleet_sessions_action", "sessions", "FL-06", "FLEET_SESSIONS_ENABLED", "planned", plain("machine.run"), {
|
|
990
|
+
route: POST("/api/fleet/sessions/{id}/actions"),
|
|
991
|
+
cli: "fleet sessions action"
|
|
992
|
+
}),
|
|
993
|
+
// ── desktop (FL-07, FL-11 paste) ──
|
|
994
|
+
read("fleet_desktop_screenshot", "desktop", "FL-07", "FLEET_DESKTOP_ENABLED", "planned", {
|
|
995
|
+
route: GET("/api/fleet/nodes/{id}/desktop/screenshot"),
|
|
996
|
+
cli: "fleet desktop screenshot"
|
|
997
|
+
}),
|
|
998
|
+
read("fleet_desktop_displays", "desktop", "FL-07", "FLEET_DESKTOP_ENABLED", "live", {
|
|
999
|
+
route: GET("/api/fleet/nodes/{id}/desktop/displays"),
|
|
1000
|
+
cli: "fleet desktop displays"
|
|
1001
|
+
}),
|
|
1002
|
+
read("fleet_desktop_recordings_list", "desktop", "FL-07", "FLEET_DESKTOP_ENABLED", "planned", {
|
|
1003
|
+
route: GET("/api/fleet/nodes/{id}/desktop/recordings"),
|
|
1004
|
+
cli: "fleet desktop recordings"
|
|
1005
|
+
}),
|
|
1006
|
+
act("fleet_desktop_input", "desktop", "FL-07", "FLEET_DESKTOP_ENABLED", "planned", plain("machine.admin", true), {
|
|
1007
|
+
route: POST("/api/fleet/nodes/{id}/desktop/input"),
|
|
1008
|
+
cli: "fleet desktop input"
|
|
1009
|
+
}),
|
|
1010
|
+
act("fleet_desktop_set_display", "desktop", "FL-07", "FLEET_DESKTOP_ENABLED", "planned", plain("machine.admin"), {
|
|
1011
|
+
route: POST("/api/fleet/nodes/{id}/desktop/displays"),
|
|
1012
|
+
cli: "fleet desktop set-display"
|
|
1013
|
+
}),
|
|
1014
|
+
act("fleet_desktop_display_add", "desktop", "FL-07", "FLEET_DESKTOP_ENABLED", "planned", confirm("machine.admin"), {
|
|
1015
|
+
phase: "P3",
|
|
1016
|
+
route: POST("/api/fleet/nodes/{id}/desktop/displays/virtual"),
|
|
1017
|
+
cli: "fleet desktop display-add"
|
|
1018
|
+
}),
|
|
1019
|
+
act(
|
|
1020
|
+
"fleet_desktop_display_remove",
|
|
1021
|
+
"desktop",
|
|
1022
|
+
"FL-07",
|
|
1023
|
+
"FLEET_DESKTOP_ENABLED",
|
|
1024
|
+
"planned",
|
|
1025
|
+
confirm("machine.admin"),
|
|
1026
|
+
{
|
|
1027
|
+
phase: "P3",
|
|
1028
|
+
route: DELETE("/api/fleet/nodes/{id}/desktop/displays/virtual/{displayId}"),
|
|
1029
|
+
cli: "fleet desktop display-remove"
|
|
1030
|
+
}
|
|
1031
|
+
),
|
|
1032
|
+
act(
|
|
1033
|
+
"fleet_desktop_paste",
|
|
1034
|
+
"desktop",
|
|
1035
|
+
"FL-11",
|
|
1036
|
+
"FLEET_MACHINE_FACTS_ENABLED",
|
|
1037
|
+
"planned",
|
|
1038
|
+
plain("machine.admin", true),
|
|
1039
|
+
{
|
|
1040
|
+
route: POST("/api/fleet/nodes/{id}/desktop/paste"),
|
|
1041
|
+
cli: "fleet desktop paste",
|
|
1042
|
+
confirmationNote: "denied unless a tool grant allows it (AW-15)"
|
|
1043
|
+
}
|
|
1044
|
+
),
|
|
1045
|
+
// ── logs (FL-08) ──
|
|
1046
|
+
read("fleet_logs_sources", "logs", "FL-08", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1047
|
+
route: GET("/api/fleet/nodes/{id}/logs/sources"),
|
|
1048
|
+
cli: "fleet logs sources"
|
|
1049
|
+
}),
|
|
1050
|
+
read("fleet_logs_read", "logs", "FL-08", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1051
|
+
route: POST("/api/fleet/nodes/{id}/logs/read"),
|
|
1052
|
+
cli: "fleet logs read"
|
|
1053
|
+
}),
|
|
1054
|
+
// ── services (FL-09) ──
|
|
1055
|
+
read("fleet_services_list", "services", "FL-09", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1056
|
+
route: GET("/api/fleet/nodes/{id}/services"),
|
|
1057
|
+
cli: "fleet services list"
|
|
1058
|
+
}),
|
|
1059
|
+
act("fleet_services_action", "services", "FL-09", "FLEET_MACHINE_FACTS_ENABLED", "live", confirm("machine.admin"), {
|
|
1060
|
+
route: POST("/api/fleet/nodes/{id}/services/{name}/{action}"),
|
|
1061
|
+
cli: "fleet services action",
|
|
1062
|
+
waitable: true,
|
|
1063
|
+
confirmationNote: "confirm; blast-radius when the node warns it could cut the machine off"
|
|
1064
|
+
}),
|
|
1065
|
+
// ── processes (FL-09) ──
|
|
1066
|
+
read("fleet_processes_list", "processes", "FL-09", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1067
|
+
route: GET("/api/fleet/nodes/{id}/processes"),
|
|
1068
|
+
cli: "fleet processes list"
|
|
1069
|
+
}),
|
|
1070
|
+
act(
|
|
1071
|
+
"fleet_processes_signal",
|
|
1072
|
+
"processes",
|
|
1073
|
+
"FL-09",
|
|
1074
|
+
"FLEET_MACHINE_FACTS_ENABLED",
|
|
1075
|
+
"live",
|
|
1076
|
+
confirm("machine.admin"),
|
|
1077
|
+
{ route: POST("/api/fleet/nodes/{id}/processes/{pid}/signal"), cli: "fleet processes signal" }
|
|
1078
|
+
),
|
|
1079
|
+
// ── docker (FL-09) ──
|
|
1080
|
+
read("fleet_docker_containers_list", "docker", "FL-09", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1081
|
+
route: GET("/api/fleet/nodes/{id}/docker/containers"),
|
|
1082
|
+
cli: "fleet docker containers"
|
|
1083
|
+
}),
|
|
1084
|
+
read("fleet_docker_images_list", "docker", "FL-09", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1085
|
+
route: GET("/api/fleet/nodes/{id}/docker/images"),
|
|
1086
|
+
cli: "fleet docker images"
|
|
1087
|
+
}),
|
|
1088
|
+
read("fleet_docker_compose_list", "docker", "FL-09", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1089
|
+
route: GET("/api/fleet/nodes/{id}/docker/compose"),
|
|
1090
|
+
cli: "fleet docker compose"
|
|
1091
|
+
}),
|
|
1092
|
+
read("fleet_docker_compose_describe", "docker", "FL-09", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1093
|
+
cli: "fleet docker compose-describe"
|
|
1094
|
+
}),
|
|
1095
|
+
act(
|
|
1096
|
+
"fleet_docker_container_action",
|
|
1097
|
+
"docker",
|
|
1098
|
+
"FL-09",
|
|
1099
|
+
"FLEET_MACHINE_FACTS_ENABLED",
|
|
1100
|
+
"live",
|
|
1101
|
+
confirm("machine.admin"),
|
|
1102
|
+
{
|
|
1103
|
+
route: POST("/api/fleet/nodes/{id}/docker/containers/{cid}/{action}"),
|
|
1104
|
+
cli: "fleet docker container",
|
|
1105
|
+
waitable: true,
|
|
1106
|
+
confirmationNote: "confirm; remove is confirm-destructive"
|
|
1107
|
+
}
|
|
1108
|
+
),
|
|
1109
|
+
act("fleet_docker_run", "docker", "FL-09", "FLEET_MACHINE_FACTS_ENABLED", "live", confirm("machine.admin", false), {
|
|
1110
|
+
route: POST("/api/fleet/nodes/{id}/docker/containers"),
|
|
1111
|
+
cli: "fleet docker run",
|
|
1112
|
+
waitable: true,
|
|
1113
|
+
alwaysHeld: true,
|
|
1114
|
+
confirmationNote: "an Agent proposes a run; a person types any secret values"
|
|
1115
|
+
}),
|
|
1116
|
+
act(
|
|
1117
|
+
"fleet_docker_image_action",
|
|
1118
|
+
"docker",
|
|
1119
|
+
"FL-09",
|
|
1120
|
+
"FLEET_MACHINE_FACTS_ENABLED",
|
|
1121
|
+
"live",
|
|
1122
|
+
confirm("machine.admin"),
|
|
1123
|
+
{
|
|
1124
|
+
route: POST("/api/fleet/nodes/{id}/docker/images/{iid}/{action}"),
|
|
1125
|
+
cli: "fleet docker image",
|
|
1126
|
+
waitable: true,
|
|
1127
|
+
confirmationNote: "pull is plain and not destructive; remove and prune confirm"
|
|
1128
|
+
}
|
|
1129
|
+
),
|
|
1130
|
+
act(
|
|
1131
|
+
"fleet_docker_compose_action",
|
|
1132
|
+
"docker",
|
|
1133
|
+
"FL-09",
|
|
1134
|
+
"FLEET_MACHINE_FACTS_ENABLED",
|
|
1135
|
+
"live",
|
|
1136
|
+
confirm("machine.admin"),
|
|
1137
|
+
{
|
|
1138
|
+
route: POST("/api/fleet/nodes/{id}/docker/compose/{project}/{action}"),
|
|
1139
|
+
cli: "fleet docker compose-action",
|
|
1140
|
+
waitable: true,
|
|
1141
|
+
confirmationNote: "destructive for down"
|
|
1142
|
+
}
|
|
1143
|
+
),
|
|
1144
|
+
act("fleet_docker_exec", "docker", "FL-09", "FLEET_MACHINE_FACTS_ENABLED", "planned", plain("machine.run"), {
|
|
1145
|
+
phase: "P3",
|
|
1146
|
+
cli: "fleet docker exec"
|
|
1147
|
+
}),
|
|
1148
|
+
// ── ports (FL-10) ──
|
|
1149
|
+
read("fleet_ports_list", "view", "FL-10", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1150
|
+
route: GET("/api/fleet/nodes/{id}/ports"),
|
|
1151
|
+
cli: "fleet ports list"
|
|
1152
|
+
}),
|
|
1153
|
+
act("fleet_ports_open", "ports", "FL-10", "FLEET_MACHINE_FACTS_ENABLED", "live", plain("machine.run"), {
|
|
1154
|
+
route: POST("/api/fleet/nodes/{id}/ports/{port}/open"),
|
|
1155
|
+
cli: "fleet ports open"
|
|
1156
|
+
}),
|
|
1157
|
+
act("fleet_ports_preview_open", "ports", "FL-10", "FLEET_PORT_TUNNEL_ENABLED", "live", plain("machine.run"), {
|
|
1158
|
+
route: POST("/api/fleet/nodes/{id}/ports/{port}/preview"),
|
|
1159
|
+
cli: "fleet ports preview"
|
|
1160
|
+
}),
|
|
1161
|
+
act("fleet_ports_preview_close", "ports", "FL-10", "FLEET_PORT_TUNNEL_ENABLED", "live", plain("machine.run"), {
|
|
1162
|
+
route: DELETE("/api/fleet/nodes/{id}/ports/{port}/preview"),
|
|
1163
|
+
cli: "fleet ports preview-close"
|
|
1164
|
+
}),
|
|
1165
|
+
// ── files (FL-11) ──
|
|
1166
|
+
// P1 (FL-11 lane log decision 15): the roots read joins the family, and the list's route is the
|
|
1167
|
+
// one FL-11 built (`…/files/list` — `…/files` is the family's prefix, not a route).
|
|
1168
|
+
read("fleet_files_roots", "files", "FL-11", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1169
|
+
route: GET("/api/fleet/nodes/{id}/files/roots"),
|
|
1170
|
+
cli: "fleet files roots"
|
|
1171
|
+
}),
|
|
1172
|
+
read("fleet_files_list", "files", "FL-11", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1173
|
+
route: GET("/api/fleet/nodes/{id}/files/list"),
|
|
1174
|
+
cli: "fleet files list"
|
|
1175
|
+
}),
|
|
1176
|
+
read("fleet_files_stat", "files", "FL-11", "FLEET_MACHINE_FACTS_ENABLED", "live", {
|
|
1177
|
+
route: GET("/api/fleet/nodes/{id}/files/stat"),
|
|
1178
|
+
cli: "fleet files stat"
|
|
1179
|
+
}),
|
|
1180
|
+
read("fleet_files_read", "files", "FL-11", "FLEET_MACHINE_FACTS_ENABLED", "planned", {
|
|
1181
|
+
route: GET("/api/fleet/nodes/{id}/files/download"),
|
|
1182
|
+
cli: "fleet files get"
|
|
1183
|
+
}),
|
|
1184
|
+
act("fleet_files_write", "files", "FL-11", "FLEET_MACHINE_FACTS_ENABLED", "planned", confirm("machine.admin"), {
|
|
1185
|
+
route: POST("/api/fleet/nodes/{id}/files/upload"),
|
|
1186
|
+
cli: "fleet files put"
|
|
1187
|
+
}),
|
|
1188
|
+
act("fleet_files_copy", "files", "FL-11", "FLEET_MACHINE_FACTS_ENABLED", "live", confirm("machine.admin"), {
|
|
1189
|
+
route: POST("/api/fleet/nodes/{id}/files/copy"),
|
|
1190
|
+
cli: "fleet files cp",
|
|
1191
|
+
// FL-11 P2 (lane log decision 18): an Agent's copy is held for a person, like its delete.
|
|
1192
|
+
alwaysHeld: true
|
|
1193
|
+
}),
|
|
1194
|
+
act("fleet_files_delete", "files", "FL-11", "FLEET_MACHINE_FACTS_ENABLED", "live", typed("write.destructive"), {
|
|
1195
|
+
route: POST("/api/fleet/nodes/{id}/files/delete"),
|
|
1196
|
+
cli: "fleet files rm",
|
|
1197
|
+
alwaysHeld: true
|
|
1198
|
+
}),
|
|
1199
|
+
// ── commands (FL-12) ──
|
|
1200
|
+
read("fleet_commands_list", "commands", "FL-12", "FLEET_COMMANDS_ENABLED", "live", {
|
|
1201
|
+
route: GET("/api/fleet/commands"),
|
|
1202
|
+
cli: "fleet commands list"
|
|
1203
|
+
}),
|
|
1204
|
+
read("fleet_commands_get", "commands", "FL-12", "FLEET_COMMANDS_ENABLED", "live", {
|
|
1205
|
+
route: GET("/api/fleet/commands/{id}"),
|
|
1206
|
+
cli: "fleet commands get"
|
|
1207
|
+
}),
|
|
1208
|
+
act("fleet_commands_run", "commands", "FL-12", "FLEET_COMMANDS_ENABLED", "live", confirm("machine.run"), {
|
|
1209
|
+
route: POST("/api/fleet/commands"),
|
|
1210
|
+
cli: "fleet commands run",
|
|
1211
|
+
alwaysHeld: true
|
|
1212
|
+
}),
|
|
1213
|
+
act("fleet_commands_cancel", "commands", "FL-12", "FLEET_COMMANDS_ENABLED", "live", plain("machine.run"), {
|
|
1214
|
+
route: POST("/api/fleet/commands/{id}/cancel"),
|
|
1215
|
+
cli: "fleet commands cancel"
|
|
1216
|
+
}),
|
|
1217
|
+
// ── schedules (FL-13 P2: live — `apps/api/src/fleet/schedules/fleet-schedules.controller.ts`) ──
|
|
1218
|
+
read("fleet_schedules_list", "schedules", "FL-13", "FLEET_COMMANDS_ENABLED", "live", {
|
|
1219
|
+
route: GET("/api/fleet/schedules"),
|
|
1220
|
+
cli: "fleet schedules list"
|
|
1221
|
+
}),
|
|
1222
|
+
read("fleet_schedules_get", "schedules", "FL-13", "FLEET_COMMANDS_ENABLED", "live", {
|
|
1223
|
+
route: GET("/api/fleet/schedules/{id}"),
|
|
1224
|
+
cli: "fleet schedules get"
|
|
1225
|
+
}),
|
|
1226
|
+
read("fleet_schedules_runs", "schedules", "FL-13", "FLEET_COMMANDS_ENABLED", "live", {
|
|
1227
|
+
route: GET("/api/fleet/schedules/{id}/runs"),
|
|
1228
|
+
cli: "fleet schedules runs"
|
|
1229
|
+
}),
|
|
1230
|
+
act("fleet_schedules_create", "schedules", "FL-13", "FLEET_COMMANDS_ENABLED", "live", confirm("agent.fanout"), {
|
|
1231
|
+
route: POST("/api/fleet/schedules"),
|
|
1232
|
+
cli: "fleet schedules create"
|
|
1233
|
+
}),
|
|
1234
|
+
act("fleet_schedules_update", "schedules", "FL-13", "FLEET_COMMANDS_ENABLED", "live", confirm("agent.fanout"), {
|
|
1235
|
+
route: PATCH("/api/fleet/schedules/{id}"),
|
|
1236
|
+
cli: "fleet schedules update"
|
|
1237
|
+
}),
|
|
1238
|
+
act(
|
|
1239
|
+
"fleet_schedules_delete",
|
|
1240
|
+
"schedules",
|
|
1241
|
+
"FL-13",
|
|
1242
|
+
"FLEET_COMMANDS_ENABLED",
|
|
1243
|
+
"live",
|
|
1244
|
+
confirm("write.destructive"),
|
|
1245
|
+
{ route: DELETE("/api/fleet/schedules/{id}"), cli: "fleet schedules delete" }
|
|
1246
|
+
),
|
|
1247
|
+
act("fleet_schedules_run", "schedules", "FL-13", "FLEET_COMMANDS_ENABLED", "live", confirm("machine.run"), {
|
|
1248
|
+
route: POST("/api/fleet/schedules/{id}/run"),
|
|
1249
|
+
cli: "fleet schedules run"
|
|
1250
|
+
}),
|
|
1251
|
+
act("fleet_schedules_pause", "schedules", "FL-13", "FLEET_COMMANDS_ENABLED", "live", plain("agent.fanout"), {
|
|
1252
|
+
route: POST("/api/fleet/schedules/{id}/pause"),
|
|
1253
|
+
cli: "fleet schedules pause"
|
|
1254
|
+
}),
|
|
1255
|
+
act("fleet_schedules_resume", "schedules", "FL-13", "FLEET_COMMANDS_ENABLED", "live", plain("agent.fanout"), {
|
|
1256
|
+
route: POST("/api/fleet/schedules/{id}/resume"),
|
|
1257
|
+
cli: "fleet schedules resume"
|
|
1258
|
+
}),
|
|
1259
|
+
// ── checkouts (FL-14, FL-06) ──
|
|
1260
|
+
read("fleet_checkouts_list", "checkouts", "FL-14", "FLEET_CHECKOUTS_ENABLED", "live", {
|
|
1261
|
+
route: GET("/api/fleet/checkouts"),
|
|
1262
|
+
cli: "fleet checkouts list"
|
|
1263
|
+
}),
|
|
1264
|
+
read("fleet_checkouts_get", "checkouts", "FL-14", "FLEET_CHECKOUTS_ENABLED", "live", {
|
|
1265
|
+
route: GET("/api/fleet/checkouts/{id}"),
|
|
1266
|
+
cli: "fleet checkouts get"
|
|
1267
|
+
}),
|
|
1268
|
+
read("fleet_checkouts_changes", "checkouts", "FL-06", "FLEET_CHECKOUTS_ENABLED", "planned", {
|
|
1269
|
+
route: GET("/api/fleet/checkouts/{id}/changes"),
|
|
1270
|
+
cli: "fleet checkouts changes"
|
|
1271
|
+
}),
|
|
1272
|
+
read("fleet_checkouts_pull_request_get", "checkouts", "FL-06", "FLEET_CHECKOUTS_ENABLED", "planned", {
|
|
1273
|
+
route: GET("/api/fleet/checkouts/{id}/pull-request")
|
|
1274
|
+
}),
|
|
1275
|
+
act("fleet_checkouts_create", "checkouts", "FL-14", "FLEET_CHECKOUTS_ENABLED", "live", plain("machine.run"), {
|
|
1276
|
+
route: POST("/api/fleet/checkouts"),
|
|
1277
|
+
cli: "fleet checkouts create",
|
|
1278
|
+
waitable: true
|
|
1279
|
+
}),
|
|
1280
|
+
act("fleet_checkouts_sync", "checkouts", "FL-14", "FLEET_CHECKOUTS_ENABLED", "live", plain("machine.run"), {
|
|
1281
|
+
route: POST("/api/fleet/checkouts/{id}/sync"),
|
|
1282
|
+
cli: "fleet checkouts sync",
|
|
1283
|
+
waitable: true,
|
|
1284
|
+
confirmationNote: "plain for fetch; confirm for pull and push"
|
|
1285
|
+
}),
|
|
1286
|
+
act(
|
|
1287
|
+
"fleet_checkouts_archive",
|
|
1288
|
+
"checkouts",
|
|
1289
|
+
"FL-14",
|
|
1290
|
+
"FLEET_CHECKOUTS_ENABLED",
|
|
1291
|
+
"live",
|
|
1292
|
+
confirm("machine.run", false),
|
|
1293
|
+
{ route: POST("/api/fleet/checkouts/{id}/archive"), cli: "fleet checkouts archive" }
|
|
1294
|
+
),
|
|
1295
|
+
act(
|
|
1296
|
+
"fleet_checkouts_delete",
|
|
1297
|
+
"checkouts",
|
|
1298
|
+
"FL-14",
|
|
1299
|
+
"FLEET_CHECKOUTS_ENABLED",
|
|
1300
|
+
"live",
|
|
1301
|
+
confirm("write.destructive"),
|
|
1302
|
+
{
|
|
1303
|
+
route: DELETE("/api/fleet/checkouts/{id}"),
|
|
1304
|
+
cli: "fleet checkouts delete",
|
|
1305
|
+
confirmationNote: "confirm; confirm-destructive when it has uncommitted changes"
|
|
1306
|
+
}
|
|
1307
|
+
),
|
|
1308
|
+
act(
|
|
1309
|
+
"fleet_checkouts_open_pull_request",
|
|
1310
|
+
"checkouts",
|
|
1311
|
+
"FL-06",
|
|
1312
|
+
"FLEET_CHECKOUTS_ENABLED",
|
|
1313
|
+
"planned",
|
|
1314
|
+
plain("publish.external"),
|
|
1315
|
+
{ route: POST("/api/fleet/checkouts/{id}/pull-request"), cli: "fleet checkouts pull-request" }
|
|
1316
|
+
),
|
|
1317
|
+
// ── tasks (FL-15) ── the hand-off itself is `fleet_sessions_start` with `taskId`
|
|
1318
|
+
read("fleet_tasks_handoff_options", "sessions", "FL-15", "FLEET_CHECKOUTS_ENABLED", "live", {
|
|
1319
|
+
route: GET("/api/fleet/tasks/{taskId}/handoff-options"),
|
|
1320
|
+
cli: "fleet tasks handoff-options"
|
|
1321
|
+
}),
|
|
1322
|
+
// ── virtual (FL-16) ── P1 shipped: Containers. A create, a stop and a destroy are held for
|
|
1323
|
+
// the owner's approval by the Agent tools (`agent-fleet-virtual-tools.ts`).
|
|
1324
|
+
read("fleet_virtual_list", "view", "FL-16", "FLEET_VIRTUAL_ENABLED", "live", {
|
|
1325
|
+
phase: "P3",
|
|
1326
|
+
route: GET("/api/fleet/nodes/{id}/virtual"),
|
|
1327
|
+
cli: "fleet virtual list"
|
|
1328
|
+
}),
|
|
1329
|
+
read("fleet_virtual_options", "view", "FL-16", "FLEET_VIRTUAL_ENABLED", "live", {
|
|
1330
|
+
phase: "P3",
|
|
1331
|
+
route: GET("/api/fleet/nodes/{id}/virtual/options"),
|
|
1332
|
+
cli: "fleet virtual options"
|
|
1333
|
+
}),
|
|
1334
|
+
act("fleet_virtual_create", "machines", "FL-16", "FLEET_VIRTUAL_ENABLED", "live", confirm("machine.admin"), {
|
|
1335
|
+
phase: "P3",
|
|
1336
|
+
route: POST("/api/fleet/nodes/{id}/virtual"),
|
|
1337
|
+
cli: "fleet virtual create",
|
|
1338
|
+
waitable: true,
|
|
1339
|
+
alwaysHeld: true
|
|
1340
|
+
}),
|
|
1341
|
+
act("fleet_virtual_power", "machines", "FL-16", "FLEET_VIRTUAL_ENABLED", "live", confirm("machine.admin"), {
|
|
1342
|
+
phase: "P3",
|
|
1343
|
+
route: POST("/api/fleet/nodes/{id}/virtual/{childId}/power"),
|
|
1344
|
+
cli: "fleet virtual power",
|
|
1345
|
+
waitable: true,
|
|
1346
|
+
confirmationNote: "plain to start; confirm to stop (an Agent's stop is held for the owner)"
|
|
1347
|
+
}),
|
|
1348
|
+
act("fleet_virtual_destroy", "machines", "FL-16", "FLEET_VIRTUAL_ENABLED", "live", typed("write.destructive"), {
|
|
1349
|
+
phase: "P3",
|
|
1350
|
+
route: POST("/api/fleet/nodes/{id}/virtual/{childId}/destroy"),
|
|
1351
|
+
cli: "fleet virtual destroy",
|
|
1352
|
+
waitable: true,
|
|
1353
|
+
alwaysHeld: true
|
|
1354
|
+
}),
|
|
1355
|
+
// ── cloud (FL-17) ── P1 shipped providers, create, power, destroy, usage; P2 the idle policy
|
|
1356
|
+
// (`PUT` answers the same as `PATCH`). A create, a power change and a destroy are held for the
|
|
1357
|
+
// owner's approval by the Agent tools (`agent-fleet-cloud-tools.ts`).
|
|
1358
|
+
read("fleet_cloud_list", "view", "FL-17", "FLEET_CLOUD_ENABLED", "live", {
|
|
1359
|
+
phase: "P3",
|
|
1360
|
+
route: GET("/api/fleet/cloud"),
|
|
1361
|
+
cli: "fleet cloud list"
|
|
1362
|
+
}),
|
|
1363
|
+
read("fleet_cloud_options", "view", "FL-17", "FLEET_CLOUD_ENABLED", "live", {
|
|
1364
|
+
phase: "P3",
|
|
1365
|
+
route: GET("/api/fleet/providers/{plugin}/options"),
|
|
1366
|
+
cli: "fleet cloud options"
|
|
1367
|
+
}),
|
|
1368
|
+
read("fleet_cloud_usage", "view", "FL-17", "FLEET_CLOUD_ENABLED", "live", {
|
|
1369
|
+
phase: "P3",
|
|
1370
|
+
route: GET("/api/fleet/cloud/usage"),
|
|
1371
|
+
cli: "fleet cloud usage"
|
|
1372
|
+
}),
|
|
1373
|
+
act("fleet_cloud_create", "machines", "FL-17", "FLEET_CLOUD_ENABLED", "live", confirm("spend.metered"), {
|
|
1374
|
+
phase: "P3",
|
|
1375
|
+
route: POST("/api/fleet/cloud"),
|
|
1376
|
+
cli: "fleet cloud create",
|
|
1377
|
+
waitable: true,
|
|
1378
|
+
alwaysHeld: true,
|
|
1379
|
+
confirmationNote: "confirm with the price (acknowledgedPriceCents); also machine.admin"
|
|
1380
|
+
}),
|
|
1381
|
+
act("fleet_cloud_power", "machines", "FL-17", "FLEET_CLOUD_ENABLED", "live", confirm("machine.admin"), {
|
|
1382
|
+
phase: "P3",
|
|
1383
|
+
route: POST("/api/fleet/cloud/{id}/power"),
|
|
1384
|
+
cli: "fleet cloud power",
|
|
1385
|
+
waitable: true,
|
|
1386
|
+
alwaysHeld: true
|
|
1387
|
+
}),
|
|
1388
|
+
act("fleet_cloud_destroy", "machines", "FL-17", "FLEET_CLOUD_ENABLED", "live", typed("write.destructive"), {
|
|
1389
|
+
phase: "P3",
|
|
1390
|
+
// FL-17 plan §5 — `DELETE /api/fleet/cloud/{id}` answers the same (an alias).
|
|
1391
|
+
route: POST("/api/fleet/cloud/{id}/destroy"),
|
|
1392
|
+
cli: "fleet cloud destroy",
|
|
1393
|
+
waitable: true,
|
|
1394
|
+
alwaysHeld: true
|
|
1395
|
+
}),
|
|
1396
|
+
act("fleet_cloud_idle_policy", "machines", "FL-17", "FLEET_CLOUD_ENABLED", "live", plain("machine.admin"), {
|
|
1397
|
+
phase: "P3",
|
|
1398
|
+
route: PATCH("/api/fleet/cloud/{id}/idle-policy"),
|
|
1399
|
+
cli: "fleet cloud idle-policy"
|
|
1400
|
+
}),
|
|
1401
|
+
// ── runners (FL-18) ── P1 shipped: list, install, start / stop / restart, remove. An install, a
|
|
1402
|
+
// stop, a restart and a remove asked by an Agent are held for the owner's approval
|
|
1403
|
+
// (`agent-fleet-runners-tools.ts`). P2: the Actions jobs read and Cancel workflow run (always held for an Agent).
|
|
1404
|
+
read("fleet_runners_list", "view", "FL-18", "FLEET_ACTIONS_RUNNERS_ENABLED", "live", {
|
|
1405
|
+
phase: "P3",
|
|
1406
|
+
route: GET("/api/fleet/nodes/{id}/runners"),
|
|
1407
|
+
cli: "fleet runners list"
|
|
1408
|
+
}),
|
|
1409
|
+
read("fleet_runners_jobs", "view", "FL-18", "FLEET_ACTIONS_RUNNERS_ENABLED", "live", {
|
|
1410
|
+
phase: "P3",
|
|
1411
|
+
route: GET("/api/fleet/runners/jobs"),
|
|
1412
|
+
cli: "fleet runners jobs"
|
|
1413
|
+
}),
|
|
1414
|
+
act(
|
|
1415
|
+
"fleet_runners_install",
|
|
1416
|
+
"machines",
|
|
1417
|
+
"FL-18",
|
|
1418
|
+
"FLEET_ACTIONS_RUNNERS_ENABLED",
|
|
1419
|
+
"live",
|
|
1420
|
+
confirm("machine.admin"),
|
|
1421
|
+
{
|
|
1422
|
+
phase: "P3",
|
|
1423
|
+
route: POST("/api/fleet/nodes/{id}/runners"),
|
|
1424
|
+
cli: "fleet runners install",
|
|
1425
|
+
waitable: true,
|
|
1426
|
+
alwaysHeld: true
|
|
1427
|
+
}
|
|
1428
|
+
),
|
|
1429
|
+
act(
|
|
1430
|
+
"fleet_runners_action",
|
|
1431
|
+
"machines",
|
|
1432
|
+
"FL-18",
|
|
1433
|
+
"FLEET_ACTIONS_RUNNERS_ENABLED",
|
|
1434
|
+
"live",
|
|
1435
|
+
confirm("machine.admin"),
|
|
1436
|
+
{
|
|
1437
|
+
phase: "P3",
|
|
1438
|
+
route: POST("/api/fleet/nodes/{id}/runners/{runnerId}/{action}"),
|
|
1439
|
+
cli: "fleet runners action",
|
|
1440
|
+
waitable: true,
|
|
1441
|
+
confirmationNote: "plain to start; confirm to stop and restart (an Agent's stop or restart is held for the owner)"
|
|
1442
|
+
}
|
|
1443
|
+
),
|
|
1444
|
+
act(
|
|
1445
|
+
"fleet_runners_remove",
|
|
1446
|
+
"machines",
|
|
1447
|
+
"FL-18",
|
|
1448
|
+
"FLEET_ACTIONS_RUNNERS_ENABLED",
|
|
1449
|
+
"live",
|
|
1450
|
+
typed("write.destructive"),
|
|
1451
|
+
{
|
|
1452
|
+
phase: "P3",
|
|
1453
|
+
route: POST("/api/fleet/nodes/{id}/runners/{runnerId}/remove"),
|
|
1454
|
+
cli: "fleet runners remove",
|
|
1455
|
+
waitable: true,
|
|
1456
|
+
alwaysHeld: true
|
|
1457
|
+
}
|
|
1458
|
+
),
|
|
1459
|
+
act(
|
|
1460
|
+
"fleet_runners_cancel_run",
|
|
1461
|
+
"machines",
|
|
1462
|
+
"FL-18",
|
|
1463
|
+
"FLEET_ACTIONS_RUNNERS_ENABLED",
|
|
1464
|
+
"live",
|
|
1465
|
+
confirm("machine.admin"),
|
|
1466
|
+
{
|
|
1467
|
+
phase: "P3",
|
|
1468
|
+
route: POST("/api/fleet/runners/jobs/cancel"),
|
|
1469
|
+
cli: "fleet runners cancel-run",
|
|
1470
|
+
alwaysHeld: true
|
|
1471
|
+
}
|
|
1472
|
+
),
|
|
1473
|
+
// ── usage (FL-20) ── P1 shipped: the Usage object (totals, by model, by computer, busiest
|
|
1474
|
+
// checkouts, sessions) every surface renders, read-only, with the payer sentence in `note`.
|
|
1475
|
+
read("fleet_usage_get", "view", "FL-20", "FLEET_USAGE_SCAN_ENABLED", "live", {
|
|
1476
|
+
phase: "P3",
|
|
1477
|
+
route: GET("/api/fleet/usage"),
|
|
1478
|
+
cli: "fleet usage"
|
|
1479
|
+
}),
|
|
1480
|
+
// ── operations (FL-02, FL-19) ──
|
|
1481
|
+
read("fleet_operations_get", "view", "FL-02", "FLEET_NODE_LINK_ENABLED", "live", {
|
|
1482
|
+
route: GET("/api/fleet/operations/{id}"),
|
|
1483
|
+
cli: "fleet operations get"
|
|
1484
|
+
}),
|
|
1485
|
+
read("fleet_operations_list", "view", "FL-19", "FLEET_NODE_LINK_ENABLED", "live", {
|
|
1486
|
+
route: GET("/api/fleet/operations"),
|
|
1487
|
+
cli: "fleet operations list"
|
|
1488
|
+
}),
|
|
1489
|
+
act("fleet_operations_cancel", "view", "FL-02", "FLEET_NODE_LINK_ENABLED", "live", plain("machine.run"), {
|
|
1490
|
+
route: DELETE("/api/fleet/operations/{id}"),
|
|
1491
|
+
cli: "fleet operations cancel"
|
|
1492
|
+
})
|
|
1493
|
+
]);
|
|
1494
|
+
new Map(
|
|
1495
|
+
FLEET_TOOL_CATALOGUE.map((entry) => [entry.name, entry])
|
|
1496
|
+
);
|
|
1497
|
+
var FLEET_VIRTUAL_SYSTEMS = [
|
|
1498
|
+
{
|
|
1499
|
+
id: "windows-11",
|
|
1500
|
+
kind: "vm",
|
|
1501
|
+
label: "Windows 11",
|
|
1502
|
+
family: "windows",
|
|
1503
|
+
arch: ["x64"],
|
|
1504
|
+
windowsEdition: "11",
|
|
1505
|
+
approxDiskGiB: 64,
|
|
1506
|
+
approxDownloadGiB: 6
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
id: "windows-10",
|
|
1510
|
+
kind: "vm",
|
|
1511
|
+
label: "Windows 10",
|
|
1512
|
+
family: "windows",
|
|
1513
|
+
arch: ["x64"],
|
|
1514
|
+
windowsEdition: "10",
|
|
1515
|
+
approxDiskGiB: 64,
|
|
1516
|
+
approxDownloadGiB: 6
|
|
1517
|
+
},
|
|
1518
|
+
{
|
|
1519
|
+
id: "windows-server-2025",
|
|
1520
|
+
kind: "vm",
|
|
1521
|
+
label: "Windows Server 2025",
|
|
1522
|
+
family: "windows",
|
|
1523
|
+
arch: ["x64"],
|
|
1524
|
+
windowsEdition: "2025",
|
|
1525
|
+
approxDiskGiB: 64,
|
|
1526
|
+
approxDownloadGiB: 6
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
id: "windows-server-2022",
|
|
1530
|
+
kind: "vm",
|
|
1531
|
+
label: "Windows Server 2022",
|
|
1532
|
+
family: "windows",
|
|
1533
|
+
arch: ["x64"],
|
|
1534
|
+
windowsEdition: "2022",
|
|
1535
|
+
approxDiskGiB: 64,
|
|
1536
|
+
approxDownloadGiB: 6
|
|
1537
|
+
},
|
|
1538
|
+
{
|
|
1539
|
+
id: "ubuntu-26.04",
|
|
1540
|
+
kind: "container",
|
|
1541
|
+
label: "Ubuntu 26.04",
|
|
1542
|
+
family: "ubuntu",
|
|
1543
|
+
arch: ["x64", "arm64"],
|
|
1544
|
+
approxDiskGiB: 3,
|
|
1545
|
+
approxDownloadGiB: 0.5
|
|
1546
|
+
},
|
|
1547
|
+
{
|
|
1548
|
+
id: "ubuntu-24.04",
|
|
1549
|
+
kind: "container",
|
|
1550
|
+
label: "Ubuntu 24.04",
|
|
1551
|
+
family: "ubuntu",
|
|
1552
|
+
arch: ["x64", "arm64"],
|
|
1553
|
+
approxDiskGiB: 3,
|
|
1554
|
+
approxDownloadGiB: 0.5
|
|
1555
|
+
},
|
|
1556
|
+
{
|
|
1557
|
+
id: "debian-13",
|
|
1558
|
+
kind: "container",
|
|
1559
|
+
label: "Debian 13",
|
|
1560
|
+
family: "debian",
|
|
1561
|
+
arch: ["x64", "arm64"],
|
|
1562
|
+
approxDiskGiB: 3,
|
|
1563
|
+
approxDownloadGiB: 0.5
|
|
1564
|
+
},
|
|
1565
|
+
{
|
|
1566
|
+
id: "fedora",
|
|
1567
|
+
kind: "container",
|
|
1568
|
+
label: "Fedora",
|
|
1569
|
+
family: "fedora",
|
|
1570
|
+
arch: ["x64", "arm64"],
|
|
1571
|
+
approxDiskGiB: 3,
|
|
1572
|
+
approxDownloadGiB: 0.6
|
|
1573
|
+
},
|
|
1574
|
+
{
|
|
1575
|
+
id: "alpine",
|
|
1576
|
+
kind: "container",
|
|
1577
|
+
label: "Alpine",
|
|
1578
|
+
family: "alpine",
|
|
1579
|
+
arch: ["x64", "arm64"],
|
|
1580
|
+
approxDiskGiB: 1,
|
|
1581
|
+
approxDownloadGiB: 0.2
|
|
1582
|
+
},
|
|
1583
|
+
{
|
|
1584
|
+
// Arch Linux publishes no official arm64 image (FR-6).
|
|
1585
|
+
id: "arch",
|
|
1586
|
+
kind: "container",
|
|
1587
|
+
label: "Arch Linux",
|
|
1588
|
+
family: "arch",
|
|
1589
|
+
arch: ["x64"],
|
|
1590
|
+
approxDiskGiB: 3,
|
|
1591
|
+
approxDownloadGiB: 0.7
|
|
1592
|
+
}
|
|
1593
|
+
];
|
|
1594
|
+
FLEET_VIRTUAL_SYSTEMS.map(
|
|
1595
|
+
(system) => system.id
|
|
1596
|
+
);
|
|
1597
|
+
var EMAIL_INBOX_CAP_FIELDS = [
|
|
1598
|
+
"inboxDailySends",
|
|
1599
|
+
"inboxBurstSends",
|
|
1600
|
+
"inboxBurstRecipients",
|
|
1601
|
+
"recipientsPerMessage"
|
|
1602
|
+
];
|
|
1603
|
+
new Set(EMAIL_INBOX_CAP_FIELDS);
|
|
1604
|
+
var BACKUP_TRIM_POLICIES = Object.freeze({
|
|
1605
|
+
activity: Object.freeze({ field: "createdAt", defaultDays: 365, fullHistoryDays: 1095 }),
|
|
1606
|
+
runLogs: Object.freeze({ field: "createdAt", defaultDays: 90, fullHistoryDays: 1095 }),
|
|
1607
|
+
terminalTranscripts: Object.freeze({ field: "createdAt", defaultDays: 30, fullHistoryDays: 365 }),
|
|
1608
|
+
notifications: Object.freeze({ field: "createdAt", defaultDays: 180, fullHistoryDays: 1095 }),
|
|
1609
|
+
// `occurredAt`, not `createdAt`: `PluginUsageEvent` names its
|
|
1610
|
+
// `@CreateDateColumn` `occurredAt` and has no `createdAt` at all. The trim
|
|
1611
|
+
// resolver fails OPEN on an unknown column, so the wrong name here did not
|
|
1612
|
+
// error — it silently exported every plugin usage event for the lifetime
|
|
1613
|
+
// of the workspace, from the archive's single largest history table, while
|
|
1614
|
+
// the docs page published a 180-day window.
|
|
1615
|
+
pluginUsageEvents: Object.freeze({ field: "occurredAt", defaultDays: 180, fullHistoryDays: 1095 }),
|
|
1616
|
+
deliveryLogs: Object.freeze({ field: "createdAt", defaultDays: 30, fullHistoryDays: 365 }),
|
|
1617
|
+
// `firedAt`, for the same reason: `InboundTriggerFire`'s creation
|
|
1618
|
+
// timestamp is `firedAt` and it has no `createdAt`, so the declared
|
|
1619
|
+
// 90-day window was never applied to `data/schedules/trigger-fires.jsonl`
|
|
1620
|
+
// and the `schedules` domain reported `complete` where the docs promise a
|
|
1621
|
+
// trim.
|
|
1622
|
+
triggerFires: Object.freeze({ field: "firedAt", defaultDays: 90, fullHistoryDays: 1095 }),
|
|
1623
|
+
retrievalTrail: Object.freeze({ field: "createdAt", defaultDays: 30, fullHistoryDays: 365 }),
|
|
1624
|
+
fleetJobs: Object.freeze({ field: "createdAt", defaultDays: 30, fullHistoryDays: 365 })
|
|
1625
|
+
});
|
|
1626
|
+
var BACKUP_DOMAINS = Object.freeze([
|
|
1627
|
+
Object.freeze({
|
|
1628
|
+
key: "account",
|
|
1629
|
+
restorability: "restorable",
|
|
1630
|
+
collectorId: "account",
|
|
1631
|
+
dataDir: "account"
|
|
1632
|
+
}),
|
|
1633
|
+
Object.freeze({
|
|
1634
|
+
key: "organizations",
|
|
1635
|
+
restorability: "restorable",
|
|
1636
|
+
collectorId: "organizations",
|
|
1637
|
+
dataDir: "organizations"
|
|
1638
|
+
}),
|
|
1639
|
+
Object.freeze({
|
|
1640
|
+
key: "agents",
|
|
1641
|
+
restorability: "restorable",
|
|
1642
|
+
collectorId: "agents",
|
|
1643
|
+
dataDir: "agents"
|
|
1644
|
+
}),
|
|
1645
|
+
Object.freeze({
|
|
1646
|
+
key: "missions",
|
|
1647
|
+
restorability: "restorable",
|
|
1648
|
+
collectorId: "missions",
|
|
1649
|
+
dataDir: "missions"
|
|
1650
|
+
}),
|
|
1651
|
+
Object.freeze({
|
|
1652
|
+
key: "tasks",
|
|
1653
|
+
restorability: "restorable",
|
|
1654
|
+
collectorId: "tasks",
|
|
1655
|
+
dataDir: "tasks"
|
|
1656
|
+
}),
|
|
1657
|
+
Object.freeze({
|
|
1658
|
+
key: "works",
|
|
1659
|
+
restorability: "restorable",
|
|
1660
|
+
collectorId: "works",
|
|
1661
|
+
dataDir: "works"
|
|
1662
|
+
}),
|
|
1663
|
+
Object.freeze({
|
|
1664
|
+
key: "knowledge",
|
|
1665
|
+
restorability: "restorable",
|
|
1666
|
+
collectorId: "knowledge",
|
|
1667
|
+
dataDir: "knowledge"
|
|
1668
|
+
}),
|
|
1669
|
+
Object.freeze({
|
|
1670
|
+
key: "schedules",
|
|
1671
|
+
restorability: "restorable",
|
|
1672
|
+
collectorId: "schedules",
|
|
1673
|
+
dataDir: "schedules"
|
|
1674
|
+
}),
|
|
1675
|
+
Object.freeze({
|
|
1676
|
+
key: "runs",
|
|
1677
|
+
restorability: "record-only",
|
|
1678
|
+
collectorId: "runs",
|
|
1679
|
+
dataDir: "runs"
|
|
1680
|
+
}),
|
|
1681
|
+
Object.freeze({
|
|
1682
|
+
key: "decisions",
|
|
1683
|
+
restorability: "record-only",
|
|
1684
|
+
collectorId: "decisions",
|
|
1685
|
+
dataDir: "decisions"
|
|
1686
|
+
}),
|
|
1687
|
+
Object.freeze({
|
|
1688
|
+
key: "communication",
|
|
1689
|
+
restorability: "partly-restorable",
|
|
1690
|
+
collectorId: "communication",
|
|
1691
|
+
dataDir: "communication"
|
|
1692
|
+
}),
|
|
1693
|
+
Object.freeze({
|
|
1694
|
+
key: "connections",
|
|
1695
|
+
restorability: "restorable",
|
|
1696
|
+
collectorId: "connections",
|
|
1697
|
+
dataDir: "connections"
|
|
1698
|
+
}),
|
|
1699
|
+
Object.freeze({
|
|
1700
|
+
key: "fleet",
|
|
1701
|
+
restorability: "partly-restorable",
|
|
1702
|
+
collectorId: "fleet",
|
|
1703
|
+
dataDir: "fleet"
|
|
1704
|
+
}),
|
|
1705
|
+
Object.freeze({
|
|
1706
|
+
key: "billing",
|
|
1707
|
+
restorability: "record-only",
|
|
1708
|
+
collectorId: "billing",
|
|
1709
|
+
dataDir: "billing"
|
|
1710
|
+
}),
|
|
1711
|
+
Object.freeze({
|
|
1712
|
+
key: "activity",
|
|
1713
|
+
restorability: "record-only",
|
|
1714
|
+
collectorId: "activity",
|
|
1715
|
+
dataDir: "activity",
|
|
1716
|
+
trim: BACKUP_TRIM_POLICIES.activity
|
|
1717
|
+
})
|
|
1718
|
+
]);
|
|
1719
|
+
Object.freeze(BACKUP_DOMAINS.map((domain) => domain.key));
|
|
1720
|
+
BACKUP_DOMAINS.length;
|
|
1721
|
+
var ACTION_CATEGORIES = Object.freeze([
|
|
1722
|
+
"read.internal",
|
|
1723
|
+
"read.external",
|
|
1724
|
+
"write.internal",
|
|
1725
|
+
"write.destructive",
|
|
1726
|
+
"message.internal",
|
|
1727
|
+
"message.external",
|
|
1728
|
+
"publish.external",
|
|
1729
|
+
"spend.metered",
|
|
1730
|
+
"spend.commitment",
|
|
1731
|
+
"access.grant",
|
|
1732
|
+
"machine.run",
|
|
1733
|
+
"machine.admin",
|
|
1734
|
+
"agent.fanout"
|
|
1735
|
+
]);
|
|
1736
|
+
Object.freeze(
|
|
1737
|
+
ACTION_CATEGORIES.filter((c) => c !== "read.internal")
|
|
1738
|
+
);
|
|
1739
|
+
var DOMAIN_EVENT_CATALOG = [
|
|
1740
|
+
// EW-P2-6 — `org:write` (and the app) create Organizations.
|
|
1741
|
+
{ type: "organization.created", domain: "organization", aggregateType: "organization", phase: "P2" },
|
|
1742
|
+
{ type: "organization.updated", domain: "organization", aggregateType: "organization", phase: "P1" },
|
|
1743
|
+
{
|
|
1744
|
+
type: "organization.member.added",
|
|
1745
|
+
domain: "organization",
|
|
1746
|
+
aggregateType: "organization",
|
|
1747
|
+
phase: "P1",
|
|
1748
|
+
child: "member"
|
|
1749
|
+
},
|
|
1750
|
+
{
|
|
1751
|
+
type: "organization.member.updated",
|
|
1752
|
+
domain: "organization",
|
|
1753
|
+
aggregateType: "organization",
|
|
1754
|
+
phase: "P1",
|
|
1755
|
+
child: "member"
|
|
1756
|
+
},
|
|
1757
|
+
{
|
|
1758
|
+
type: "organization.member.removed",
|
|
1759
|
+
domain: "organization",
|
|
1760
|
+
aggregateType: "organization",
|
|
1761
|
+
phase: "P1",
|
|
1762
|
+
child: "member"
|
|
1763
|
+
},
|
|
1764
|
+
{ type: "agent.created", domain: "agents", aggregateType: "agent", phase: "P1" },
|
|
1765
|
+
{ type: "agent.updated", domain: "agents", aggregateType: "agent", phase: "P1" },
|
|
1766
|
+
{ type: "agent.status_changed", domain: "agents", aggregateType: "agent", phase: "P1" },
|
|
1767
|
+
{ type: "agent.archived", domain: "agents", aggregateType: "agent", phase: "P1" },
|
|
1768
|
+
{ type: "agent.deleted", domain: "agents", aggregateType: "agent", phase: "P1" },
|
|
1769
|
+
{ type: "team.created", domain: "teams", aggregateType: "team", phase: "P1" },
|
|
1770
|
+
{ type: "team.updated", domain: "teams", aggregateType: "team", phase: "P1" },
|
|
1771
|
+
{ type: "team.deleted", domain: "teams", aggregateType: "team", phase: "P1" },
|
|
1772
|
+
{ type: "team.member.added", domain: "teams", aggregateType: "team", phase: "P1", child: "member" },
|
|
1773
|
+
{ type: "team.member.updated", domain: "teams", aggregateType: "team", phase: "P1", child: "member" },
|
|
1774
|
+
{ type: "team.member.removed", domain: "teams", aggregateType: "team", phase: "P1", child: "member" },
|
|
1775
|
+
{ type: "team.resource.added", domain: "teams", aggregateType: "team", phase: "P1", child: "resource" },
|
|
1776
|
+
{ type: "team.resource.removed", domain: "teams", aggregateType: "team", phase: "P1", child: "resource" },
|
|
1777
|
+
{ type: "work.created", domain: "works", aggregateType: "work", phase: "P1" },
|
|
1778
|
+
{ type: "work.updated", domain: "works", aggregateType: "work", phase: "P1" },
|
|
1779
|
+
{ type: "work.archived", domain: "works", aggregateType: "work", phase: "P1" },
|
|
1780
|
+
{ type: "work.deleted", domain: "works", aggregateType: "work", phase: "P1" },
|
|
1781
|
+
{ type: "work.member.added", domain: "works", aggregateType: "work", phase: "P1", child: "member" },
|
|
1782
|
+
{ type: "work.member.updated", domain: "works", aggregateType: "work", phase: "P1", child: "member" },
|
|
1783
|
+
{ type: "work.member.removed", domain: "works", aggregateType: "work", phase: "P1", child: "member" },
|
|
1784
|
+
{ type: "mission.created", domain: "missions", aggregateType: "mission", phase: "P2" },
|
|
1785
|
+
{ type: "mission.updated", domain: "missions", aggregateType: "mission", phase: "P2" },
|
|
1786
|
+
{ type: "mission.status_changed", domain: "missions", aggregateType: "mission", phase: "P2" },
|
|
1787
|
+
{ type: "mission.deleted", domain: "missions", aggregateType: "mission", phase: "P2" },
|
|
1788
|
+
{ type: "mission.goal.linked", domain: "missions", aggregateType: "mission", phase: "P2", child: "goal" },
|
|
1789
|
+
{ type: "mission.goal.unlinked", domain: "missions", aggregateType: "mission", phase: "P2", child: "goal" },
|
|
1790
|
+
{ type: "mission.work.linked", domain: "missions", aggregateType: "mission", phase: "P2", child: "work" },
|
|
1791
|
+
{ type: "mission.work.unlinked", domain: "missions", aggregateType: "mission", phase: "P2", child: "work" },
|
|
1792
|
+
{ type: "goal.created", domain: "goals", aggregateType: "goal", phase: "P2" },
|
|
1793
|
+
{ type: "goal.updated", domain: "goals", aggregateType: "goal", phase: "P2" },
|
|
1794
|
+
{ type: "goal.status_changed", domain: "goals", aggregateType: "goal", phase: "P2" },
|
|
1795
|
+
{ type: "goal.archived", domain: "goals", aggregateType: "goal", phase: "P2" },
|
|
1796
|
+
{ type: "goal.unarchived", domain: "goals", aggregateType: "goal", phase: "P2" },
|
|
1797
|
+
{ type: "goal.deleted", domain: "goals", aggregateType: "goal", phase: "P2" },
|
|
1798
|
+
{ type: "goal.progress_changed", domain: "goals", aggregateType: "goal", phase: "P2" },
|
|
1799
|
+
{ type: "idea.created", domain: "ideas", aggregateType: "idea", phase: "P2" },
|
|
1800
|
+
{ type: "idea.updated", domain: "ideas", aggregateType: "idea", phase: "P2" },
|
|
1801
|
+
{ type: "idea.status_changed", domain: "ideas", aggregateType: "idea", phase: "P2" },
|
|
1802
|
+
{ type: "idea.deleted", domain: "ideas", aggregateType: "idea", phase: "P2" },
|
|
1803
|
+
{ type: "task.created", domain: "tasks", aggregateType: "task", phase: "P1" },
|
|
1804
|
+
{ type: "task.updated", domain: "tasks", aggregateType: "task", phase: "P1" },
|
|
1805
|
+
{ type: "task.transitioned", domain: "tasks", aggregateType: "task", phase: "P1" },
|
|
1806
|
+
{ type: "task.deleted", domain: "tasks", aggregateType: "task", phase: "P1" },
|
|
1807
|
+
{ type: "task.assignee.added", domain: "tasks", aggregateType: "task", phase: "P1", child: "assignee" },
|
|
1808
|
+
{ type: "task.assignee.removed", domain: "tasks", aggregateType: "task", phase: "P1", child: "assignee" },
|
|
1809
|
+
{ type: "task.watcher.added", domain: "tasks", aggregateType: "task", phase: "P1", child: "watcher" },
|
|
1810
|
+
{ type: "task.watcher.removed", domain: "tasks", aggregateType: "task", phase: "P1", child: "watcher" },
|
|
1811
|
+
{ type: "task.block.added", domain: "tasks", aggregateType: "task", phase: "P1", child: "block" },
|
|
1812
|
+
{ type: "task.block.removed", domain: "tasks", aggregateType: "task", phase: "P1", child: "block" },
|
|
1813
|
+
{ type: "task.relation.added", domain: "tasks", aggregateType: "task", phase: "P1", child: "relation" },
|
|
1814
|
+
{ type: "task.relation.removed", domain: "tasks", aggregateType: "task", phase: "P1", child: "relation" },
|
|
1815
|
+
{ type: "task.comment.created", domain: "tasks", aggregateType: "task", phase: "P1", child: "comment" },
|
|
1816
|
+
{ type: "task.comment.updated", domain: "tasks", aggregateType: "task", phase: "P1", child: "comment" },
|
|
1817
|
+
{ type: "task.comment.deleted", domain: "tasks", aggregateType: "task", phase: "P1", child: "comment" },
|
|
1818
|
+
{ type: "task.attachment.added", domain: "tasks", aggregateType: "task", phase: "P3", child: "attachment" },
|
|
1819
|
+
{ type: "task.attachment.removed", domain: "tasks", aggregateType: "task", phase: "P3", child: "attachment" },
|
|
1820
|
+
{ type: "task.runtime_updated", domain: "tasks", aggregateType: "task", phase: "P1", optIn: true },
|
|
1821
|
+
{ type: "inbox.item.created", domain: "inbox", aggregateType: "inbox_item", phase: "P3" },
|
|
1822
|
+
{ type: "inbox.item.answered", domain: "inbox", aggregateType: "inbox_item", phase: "P3" },
|
|
1823
|
+
{ type: "inbox.item.state_changed", domain: "inbox", aggregateType: "inbox_item", phase: "P3" },
|
|
1824
|
+
{ type: "inbox.item.deleted", domain: "inbox", aggregateType: "inbox_item", phase: "P3" },
|
|
1825
|
+
// Integration inbox push: an integration's PATCH of its own item, and the member's
|
|
1826
|
+
// answer to an integration item (stored on the item; no run is started).
|
|
1827
|
+
{ type: "inbox.item.updated", domain: "inbox", aggregateType: "inbox_item", phase: "P3" },
|
|
1828
|
+
{ type: "kb.document.created", domain: "kb", aggregateType: "kb_document", phase: "P3" },
|
|
1829
|
+
{ type: "kb.document.updated", domain: "kb", aggregateType: "kb_document", phase: "P3" },
|
|
1830
|
+
{ type: "kb.document.moved", domain: "kb", aggregateType: "kb_document", phase: "P3" },
|
|
1831
|
+
{ type: "kb.document.archived", domain: "kb", aggregateType: "kb_document", phase: "P3" },
|
|
1832
|
+
{ type: "kb.document.unarchived", domain: "kb", aggregateType: "kb_document", phase: "P3" },
|
|
1833
|
+
{ type: "kb.document.deleted", domain: "kb", aggregateType: "kb_document", phase: "P3" },
|
|
1834
|
+
{ type: "kb.document.review_changed", domain: "kb", aggregateType: "kb_document", phase: "P3" },
|
|
1835
|
+
{ type: "kb.folder.created", domain: "kb", aggregateType: "kb_folder", phase: "P3" },
|
|
1836
|
+
{ type: "kb.folder.updated", domain: "kb", aggregateType: "kb_folder", phase: "P3" },
|
|
1837
|
+
{ type: "kb.folder.deleted", domain: "kb", aggregateType: "kb_folder", phase: "P3" },
|
|
1838
|
+
{ type: "email.message.received", domain: "email", aggregateType: "email_message", phase: "P4" },
|
|
1839
|
+
{ type: "email.message.sent", domain: "email", aggregateType: "email_message", phase: "P4" },
|
|
1840
|
+
{ type: "email.message.status_changed", domain: "email", aggregateType: "email_message", phase: "P4" },
|
|
1841
|
+
{ type: "task.visibility_changed", domain: "visibility", aggregateType: "task", phase: "P1" },
|
|
1842
|
+
{ type: "agent.visibility_changed", domain: "visibility", aggregateType: "agent", phase: "P1" },
|
|
1843
|
+
{ type: "goal.visibility_changed", domain: "visibility", aggregateType: "goal", phase: "P2" },
|
|
1844
|
+
{ type: "mission.visibility_changed", domain: "visibility", aggregateType: "mission", phase: "P2" },
|
|
1845
|
+
{ type: "idea.visibility_changed", domain: "visibility", aggregateType: "idea", phase: "P2" }
|
|
1846
|
+
];
|
|
1847
|
+
DOMAIN_EVENT_CATALOG.map((entry) => entry.type);
|
|
1848
|
+
new Map(
|
|
1849
|
+
DOMAIN_EVENT_CATALOG.map((entry) => [entry.type, entry])
|
|
1850
|
+
);
|
|
1851
|
+
var EMAIL_MESSAGE_ID_MAX_LENGTH = 255;
|
|
1852
|
+
var EMAIL_REFERENCES_MAX_IDS = 50;
|
|
1853
|
+
function normalizeMessageId(raw) {
|
|
1854
|
+
if (typeof raw !== "string") return void 0;
|
|
1855
|
+
let value = raw.trim();
|
|
1856
|
+
const open = value.indexOf("<");
|
|
1857
|
+
if (open !== -1) {
|
|
1858
|
+
const close = value.indexOf(">", open + 1);
|
|
1859
|
+
value = close === -1 ? value.slice(open + 1) : value.slice(open + 1, close);
|
|
1860
|
+
}
|
|
1861
|
+
value = value.trim();
|
|
1862
|
+
if (!value || value.length > EMAIL_MESSAGE_ID_MAX_LENGTH) return void 0;
|
|
1863
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
1864
|
+
const code = value.charCodeAt(i);
|
|
1865
|
+
if (code <= 32 || code === 127 || value[i] === "<" || value[i] === ">") return void 0;
|
|
1866
|
+
}
|
|
1867
|
+
return value;
|
|
1868
|
+
}
|
|
1869
|
+
function parseMessageIdList(raw) {
|
|
1870
|
+
if (raw == null) return [];
|
|
1871
|
+
const text = Array.isArray(raw) ? raw.join(" ") : String(raw);
|
|
1872
|
+
const ids = [];
|
|
1873
|
+
if (text.includes("<")) {
|
|
1874
|
+
let open = text.indexOf("<");
|
|
1875
|
+
while (open !== -1) {
|
|
1876
|
+
const close = text.indexOf(">", open + 1);
|
|
1877
|
+
if (close === -1) break;
|
|
1878
|
+
const id = normalizeMessageId(text.slice(open + 1, close));
|
|
1879
|
+
if (id) ids.push(id);
|
|
1880
|
+
open = text.indexOf("<", close + 1);
|
|
1881
|
+
}
|
|
1882
|
+
} else {
|
|
1883
|
+
for (const part of text.split(/[\s,]+/)) {
|
|
1884
|
+
const id = normalizeMessageId(part);
|
|
1885
|
+
if (id) ids.push(id);
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
const unique = [...new Set(ids)];
|
|
1889
|
+
return unique.slice(Math.max(0, unique.length - EMAIL_REFERENCES_MAX_IDS));
|
|
1890
|
+
}
|
|
1891
|
+
var PLUGIN_CAPABILITIES = {
|
|
1892
|
+
EMAIL_INBOUND: "email-inbound"};
|
|
1893
|
+
|
|
1894
|
+
// src/ever-email-router-plugin.ts
|
|
1895
|
+
var SECRET_ENV = "EVER_EMAIL_ROUTER_SECRET";
|
|
1896
|
+
var EVER_EMAIL_SIGNATURE_HEADER = "x-ever-email-signature";
|
|
1897
|
+
var EVER_EMAIL_MIN_SECRET_LENGTH = 24;
|
|
1898
|
+
var EVER_EMAIL_MAX_SKEW_SECONDS = 300;
|
|
1899
|
+
var DEFAULT_EVER_EMAIL_DOMAIN = "ever.email";
|
|
1900
|
+
function everEmailDomain(env = process.env) {
|
|
1901
|
+
return (env.EVER_EMAIL_DOMAIN ?? "").trim().toLowerCase() || DEFAULT_EVER_EMAIL_DOMAIN;
|
|
1902
|
+
}
|
|
1903
|
+
var PROVIDER_MESSAGE_ID_MAX_LENGTH = 200;
|
|
1904
|
+
function resolveSecret(options) {
|
|
1905
|
+
const fromSettings = options.settings?.inboundWebhookSecret;
|
|
1906
|
+
if (typeof fromSettings === "string" && fromSettings.length > 0) return fromSettings;
|
|
1907
|
+
const fromEnv = process.env[SECRET_ENV];
|
|
1908
|
+
return fromEnv && fromEnv.length > 0 ? fromEnv : void 0;
|
|
1909
|
+
}
|
|
1910
|
+
function headerValue(headers, name) {
|
|
1911
|
+
const direct = headers[name];
|
|
1912
|
+
if (typeof direct === "string") return direct;
|
|
1913
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
1914
|
+
if (key.toLowerCase() === name && typeof value === "string") return value;
|
|
1915
|
+
}
|
|
1916
|
+
return void 0;
|
|
1917
|
+
}
|
|
1918
|
+
function decodePayload(rawBody) {
|
|
1919
|
+
const parsed = JSON.parse(rawBody.toString("utf8"));
|
|
1920
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1921
|
+
throw new Error("Ever Email Router inbound: the body is not a JSON object.");
|
|
1922
|
+
}
|
|
1923
|
+
return parsed;
|
|
1924
|
+
}
|
|
1925
|
+
function envelopeRecipient(payload) {
|
|
1926
|
+
const to = payload.envelope?.to;
|
|
1927
|
+
const first = Array.isArray(to) ? to[0] : void 0;
|
|
1928
|
+
if (typeof first !== "string") return void 0;
|
|
1929
|
+
const address = first.trim().toLowerCase();
|
|
1930
|
+
return address.includes("@") ? address : void 0;
|
|
1931
|
+
}
|
|
1932
|
+
function mailboxes(entries = []) {
|
|
1933
|
+
const out = [];
|
|
1934
|
+
const add = (mailbox) => {
|
|
1935
|
+
const address = mailbox.address.trim();
|
|
1936
|
+
if (address.includes("@") && !out.includes(address)) out.push(address);
|
|
1937
|
+
};
|
|
1938
|
+
for (const entry of entries) {
|
|
1939
|
+
if (entry.group) entry.group.forEach(add);
|
|
1940
|
+
else if (entry.address) add(entry);
|
|
1941
|
+
}
|
|
1942
|
+
return out;
|
|
1943
|
+
}
|
|
1944
|
+
function domainOf(value) {
|
|
1945
|
+
let start = 0;
|
|
1946
|
+
let end = value.length;
|
|
1947
|
+
const strip = (ch) => ch === "<" || ch === ">" || ch === '"' || ch.trim() === "";
|
|
1948
|
+
while (start < end && strip(value[start])) start += 1;
|
|
1949
|
+
while (end > start && strip(value[end - 1])) end -= 1;
|
|
1950
|
+
const text = value.slice(start, end);
|
|
1951
|
+
const at = text.lastIndexOf("@");
|
|
1952
|
+
return (at >= 0 ? text.slice(at + 1) : text).toLowerCase();
|
|
1953
|
+
}
|
|
1954
|
+
function aligned(a, b) {
|
|
1955
|
+
return !!a && !!b && (a === b || a.endsWith(`.${b}`) || b.endsWith(`.${a}`));
|
|
1956
|
+
}
|
|
1957
|
+
function authVerdictFields(value, fromDomain) {
|
|
1958
|
+
let text = "";
|
|
1959
|
+
let depth = 0;
|
|
1960
|
+
for (const ch of value) {
|
|
1961
|
+
if (ch === "(") depth += 1;
|
|
1962
|
+
else if (ch === ")" && depth > 0) depth -= 1;
|
|
1963
|
+
else if (depth === 0) text += ch;
|
|
1964
|
+
}
|
|
1965
|
+
const byMethod = /* @__PURE__ */ new Map();
|
|
1966
|
+
for (const clause of text.split(";").slice(1)) {
|
|
1967
|
+
const tokens = clause.trim().split(/\s+/);
|
|
1968
|
+
const head = /^(dmarc|spf|dkim)=([a-z]+)$/i.exec(tokens[0] ?? "");
|
|
1969
|
+
if (!head) continue;
|
|
1970
|
+
const props = /* @__PURE__ */ new Map();
|
|
1971
|
+
for (const token of tokens.slice(1)) {
|
|
1972
|
+
const eq = token.indexOf("=");
|
|
1973
|
+
if (eq > 0) props.set(token.slice(0, eq).toLowerCase(), token.slice(eq + 1));
|
|
1974
|
+
}
|
|
1975
|
+
const method = head[1].toLowerCase();
|
|
1976
|
+
byMethod.set(method, [...byMethod.get(method) ?? [], { result: head[2].toLowerCase(), props }]);
|
|
1977
|
+
}
|
|
1978
|
+
const fields = {};
|
|
1979
|
+
const dmarc = byMethod.get("dmarc")?.[0];
|
|
1980
|
+
if (dmarc) fields.dmarc = dmarc.result;
|
|
1981
|
+
const spf = byMethod.get("spf")?.[0];
|
|
1982
|
+
if (spf) {
|
|
1983
|
+
fields.spf = spf.result;
|
|
1984
|
+
const mailFrom = spf.props.get("smtp.mailfrom") ?? spf.props.get("smtp.helo");
|
|
1985
|
+
if (mailFrom) fields.spfDomain = domainOf(mailFrom);
|
|
1986
|
+
}
|
|
1987
|
+
const dkims = byMethod.get("dkim") ?? [];
|
|
1988
|
+
const dkim = dkims.find((r) => r.result === "pass" && aligned(domainOf(r.props.get("header.d") ?? ""), fromDomain)) ?? dkims.find((r) => r.result === "pass") ?? dkims[0];
|
|
1989
|
+
if (dkim) {
|
|
1990
|
+
fields.dkim = dkim.result;
|
|
1991
|
+
const signer = dkim.props.get("header.d");
|
|
1992
|
+
if (signer) fields.dkimDomain = domainOf(signer);
|
|
1993
|
+
}
|
|
1994
|
+
return fields;
|
|
1995
|
+
}
|
|
1996
|
+
function providerMessageIdFor(messageId, raw, recipient) {
|
|
1997
|
+
const digest = createHash("sha256").update(messageId ?? raw).digest("hex");
|
|
1998
|
+
const id = `${digest}:${recipient}`;
|
|
1999
|
+
return id.length <= PROVIDER_MESSAGE_ID_MAX_LENGTH ? id : `${digest}:${createHash("sha256").update(recipient).digest("hex")}`;
|
|
2000
|
+
}
|
|
2001
|
+
function attachmentContent(content) {
|
|
2002
|
+
if (typeof content === "string") return content;
|
|
2003
|
+
return Buffer.from(content instanceof Uint8Array ? content : new Uint8Array(content)).toString("base64");
|
|
2004
|
+
}
|
|
2005
|
+
var EverEmailRouterPlugin = class {
|
|
2006
|
+
constructor() {
|
|
2007
|
+
this.id = "ever-email-router";
|
|
2008
|
+
this.name = "Ever Email Router";
|
|
2009
|
+
this.version = "1.0.0";
|
|
2010
|
+
this.category = "email-provider";
|
|
2011
|
+
this.capabilities = [PLUGIN_CAPABILITIES.EMAIL_INBOUND];
|
|
2012
|
+
this.inboundAck = "counts";
|
|
2013
|
+
this.settingsSchema = {
|
|
2014
|
+
type: "object",
|
|
2015
|
+
properties: {
|
|
2016
|
+
// `x-adminOnly`: the secret is always the deployment's — a tenant can
|
|
2017
|
+
// never save their own, so no tenant can sign deliveries.
|
|
2018
|
+
inboundWebhookSecret: {
|
|
2019
|
+
type: "string",
|
|
2020
|
+
"x-secret": true,
|
|
2021
|
+
"x-envVar": SECRET_ENV,
|
|
2022
|
+
"x-adminOnly": true
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* The router delivers ONE domain, and every mailbox's mail comes from it:
|
|
2029
|
+
* an address of this plugin must be on that domain, with one owner per
|
|
2030
|
+
* deployment (a second registration of the same mailbox would never
|
|
2031
|
+
* receive anything). The platform enforces both on registration.
|
|
2032
|
+
*/
|
|
2033
|
+
get inboundAddressPolicy() {
|
|
2034
|
+
return { domain: everEmailDomain(), exclusive: true };
|
|
2035
|
+
}
|
|
2036
|
+
async onLoad() {
|
|
2037
|
+
}
|
|
2038
|
+
async onUnload() {
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* Authenticate a delivery: `x-ever-email-signature` must carry a fresh `t` and a `v1`
|
|
2042
|
+
* equal to HMAC-SHA256(secret, `<t>.` + the exact raw body). Throws on any failure.
|
|
2043
|
+
*/
|
|
2044
|
+
verifyWebhookSignature(rawBody, headers, options) {
|
|
2045
|
+
const secret = resolveSecret(options);
|
|
2046
|
+
if (!secret || secret.length < EVER_EMAIL_MIN_SECRET_LENGTH) {
|
|
2047
|
+
throw new Error(
|
|
2048
|
+
`Ever Email Router inbound: no \`inboundWebhookSecret\`/${SECRET_ENV} of at least ${EVER_EMAIL_MIN_SECRET_LENGTH} characters configured; refusing the webhook.`
|
|
2049
|
+
);
|
|
2050
|
+
}
|
|
2051
|
+
const signature = headerValue(headers, EVER_EMAIL_SIGNATURE_HEADER);
|
|
2052
|
+
if (!signature) {
|
|
2053
|
+
throw new Error(`Ever Email Router inbound: missing ${EVER_EMAIL_SIGNATURE_HEADER} header.`);
|
|
2054
|
+
}
|
|
2055
|
+
let timestamp;
|
|
2056
|
+
const candidates = [];
|
|
2057
|
+
for (const part of signature.split(",")) {
|
|
2058
|
+
const eq = part.indexOf("=");
|
|
2059
|
+
if (eq <= 0) continue;
|
|
2060
|
+
const key = part.slice(0, eq).trim();
|
|
2061
|
+
const value = part.slice(eq + 1).trim();
|
|
2062
|
+
if (key === "t") timestamp = value;
|
|
2063
|
+
else if (key === "v1") candidates.push(value);
|
|
2064
|
+
}
|
|
2065
|
+
if (!timestamp || !/^\d{1,12}$/.test(timestamp) || candidates.length === 0) {
|
|
2066
|
+
throw new Error(`Ever Email Router inbound: malformed ${EVER_EMAIL_SIGNATURE_HEADER} header.`);
|
|
2067
|
+
}
|
|
2068
|
+
if (Math.abs(Date.now() / 1e3 - Number(timestamp)) > EVER_EMAIL_MAX_SKEW_SECONDS) {
|
|
2069
|
+
throw new Error("Ever Email Router inbound: signature timestamp is outside the accepted window.");
|
|
2070
|
+
}
|
|
2071
|
+
const expected = createHmac("sha256", secret).update(`${timestamp}.`).update(rawBody).digest();
|
|
2072
|
+
const matches = candidates.some((candidate) => {
|
|
2073
|
+
if (!/^[0-9a-f]{64}$/.test(candidate)) return false;
|
|
2074
|
+
const provided = Buffer.from(candidate, "hex");
|
|
2075
|
+
return provided.length === expected.length && timingSafeEqual(provided, expected);
|
|
2076
|
+
});
|
|
2077
|
+
if (!matches) {
|
|
2078
|
+
throw new Error("Ever Email Router inbound: signature mismatch.");
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
/** The lower-cased envelope recipient the router delivered to (`[]` when unreadable). */
|
|
2082
|
+
extractInboundRecipients(rawBody, _headers) {
|
|
2083
|
+
try {
|
|
2084
|
+
const recipient = envelopeRecipient(decodePayload(rawBody));
|
|
2085
|
+
return recipient ? [recipient] : [];
|
|
2086
|
+
} catch {
|
|
2087
|
+
return [];
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
/** Decode the delivery's RFC 5322 message into the canonical inbound shape. */
|
|
2091
|
+
async parseInboundWebhook(rawBody, _headers, _options) {
|
|
2092
|
+
const payload = decodePayload(rawBody);
|
|
2093
|
+
const raw = typeof payload.raw === "string" ? Buffer.from(payload.raw, "base64") : Buffer.alloc(0);
|
|
2094
|
+
if (raw.length === 0) {
|
|
2095
|
+
throw new Error("Ever Email Router inbound: missing `raw` message.");
|
|
2096
|
+
}
|
|
2097
|
+
const recipient = envelopeRecipient(payload);
|
|
2098
|
+
if (!recipient) {
|
|
2099
|
+
throw new Error("Ever Email Router inbound: missing `envelope.to` recipient.");
|
|
2100
|
+
}
|
|
2101
|
+
const envelopeFrom = typeof payload.envelope?.from === "string" ? payload.envelope.from.trim() : "";
|
|
2102
|
+
const email = await PostalMime.parse(raw, { attachmentEncoding: "base64" });
|
|
2103
|
+
const sender = email.from && !email.from.group ? email.from : email.from?.group?.[0];
|
|
2104
|
+
const from = sender?.address?.trim() || envelopeFrom;
|
|
2105
|
+
const headerTo = mailboxes(email.to);
|
|
2106
|
+
const to = headerTo.length > 0 ? headerTo : [recipient];
|
|
2107
|
+
const cc = mailboxes(email.cc);
|
|
2108
|
+
const messageIdHeader = normalizeMessageId(email.messageId);
|
|
2109
|
+
const inReplyTo = parseMessageIdList(email.inReplyTo)[0];
|
|
2110
|
+
const references = parseMessageIdList(email.references);
|
|
2111
|
+
const attachments = email.attachments.map((a) => ({
|
|
2112
|
+
filename: a.filename ?? "attachment",
|
|
2113
|
+
mimeType: a.mimeType,
|
|
2114
|
+
content: attachmentContent(a.content),
|
|
2115
|
+
...a.contentId ? { cid: a.contentId.trim().replace(/^<|>$/g, "") } : {}
|
|
2116
|
+
}));
|
|
2117
|
+
const authenticationResults = typeof payload.authenticationResults === "string" && payload.authenticationResults.trim() ? payload.authenticationResults.trim() : void 0;
|
|
2118
|
+
const headers = [];
|
|
2119
|
+
if (authenticationResults) headers.push({ Name: "Authentication-Results", Value: authenticationResults });
|
|
2120
|
+
for (const header of email.headers) {
|
|
2121
|
+
if (header.key === "authentication-results") continue;
|
|
2122
|
+
headers.push({ Name: header.originalKey, Value: header.value });
|
|
2123
|
+
}
|
|
2124
|
+
return {
|
|
2125
|
+
provider: this.id,
|
|
2126
|
+
providerMessageId: providerMessageIdFor(messageIdHeader, raw, recipient),
|
|
2127
|
+
from,
|
|
2128
|
+
to,
|
|
2129
|
+
...cc.length > 0 ? { cc } : {},
|
|
2130
|
+
subject: email.subject ?? "",
|
|
2131
|
+
bodyText: email.text ?? "",
|
|
2132
|
+
bodyHtml: email.html,
|
|
2133
|
+
attachments,
|
|
2134
|
+
receivedAt: /* @__PURE__ */ new Date(),
|
|
2135
|
+
metadata: {
|
|
2136
|
+
recipient,
|
|
2137
|
+
envelope: { from: envelopeFrom, to: [recipient] },
|
|
2138
|
+
fromName: sender?.name || null,
|
|
2139
|
+
date: email.date ?? null,
|
|
2140
|
+
headers,
|
|
2141
|
+
...authenticationResults ? {
|
|
2142
|
+
authenticationResults,
|
|
2143
|
+
...authVerdictFields(authenticationResults, domainOf(from))
|
|
2144
|
+
} : {}
|
|
2145
|
+
},
|
|
2146
|
+
...messageIdHeader ? { messageIdHeader } : {},
|
|
2147
|
+
...inReplyTo ? { inReplyTo } : {},
|
|
2148
|
+
...references.length > 0 ? { references } : {}
|
|
2149
|
+
};
|
|
2150
|
+
}
|
|
2151
|
+
};
|
|
2152
|
+
var everEmailRouterPlugin = new EverEmailRouterPlugin();
|
|
2153
|
+
/**
|
|
2154
|
+
* One header finding of the licence scan (plan §2.6:324-325, FR-54): the
|
|
2155
|
+
* `SPDX-License-Identifier:` / `@license` tag a file declares in its first
|
|
2156
|
+
* `LICENSE_HEADER_SCAN_BYTES` bytes.
|
|
2157
|
+
*
|
|
2158
|
+
* **Gap, named rather than guessed:** plan §3.1:437 writes the column's third
|
|
2159
|
+
* field as `headerFindings: …` without a shape. `path` is certain — it is the
|
|
2160
|
+
* first field of the scan's input — and the detected identifier is the second
|
|
2161
|
+
* fact the scan produces, so both are declared; anything further an
|
|
2162
|
+
* implementation adds is additive.
|
|
2163
|
+
*/
|
|
2164
|
+
|
|
2165
|
+
export { DEFAULT_EVER_EMAIL_DOMAIN, EVER_EMAIL_MAX_SKEW_SECONDS, EVER_EMAIL_MIN_SECRET_LENGTH, EVER_EMAIL_SIGNATURE_HEADER, EverEmailRouterPlugin, everEmailDomain, everEmailRouterPlugin };
|