vibes-diy 14.3.328 → 14.3.330

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.
@@ -541,6 +541,8 @@ export declare function cliEventoHandlers(): (import("@adviser/cement").EventoHa
541
541
  limit: string;
542
542
  flagId?: string | undefined;
543
543
  triage?: string | undefined;
544
+ summary?: boolean | undefined;
545
+ since?: string | undefined;
544
546
  }, {
545
547
  type: "vibes-diy.cli.res-moderation";
546
548
  op: string;
@@ -15,6 +15,8 @@ export declare const ReqModerationCli: import("arktype/internal/variants/object.
15
15
  limit: string;
16
16
  flagId?: string | undefined;
17
17
  triage?: string | undefined;
18
+ summary?: boolean | undefined;
19
+ since?: string | undefined;
18
20
  }, {}>;
19
21
  export type ReqModerationCli = typeof ReqModerationCli.infer;
20
22
  export declare function isReqModerationCli(obj: unknown): obj is ReqModerationCli;
@@ -44,6 +46,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
44
46
  limit: string;
45
47
  flag: string;
46
48
  as: string;
49
+ summary: boolean;
50
+ since: string;
47
51
  };
48
52
  } | {
49
53
  command: "pause-publishing";
@@ -59,6 +63,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
59
63
  limit: string;
60
64
  flag: string;
61
65
  as: string;
66
+ summary: boolean;
67
+ since: string;
62
68
  };
63
69
  } | {
64
70
  command: "reports";
@@ -74,6 +80,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
74
80
  limit: string;
75
81
  flag: string;
76
82
  as: string;
83
+ summary: boolean;
84
+ since: string;
77
85
  };
78
86
  } | {
79
87
  command: "resolve";
@@ -89,6 +97,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
89
97
  limit: string;
90
98
  flag: string;
91
99
  as: string;
100
+ summary: boolean;
101
+ since: string;
92
102
  };
93
103
  } | {
94
104
  command: "resume-publishing";
@@ -104,6 +114,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
104
114
  limit: string;
105
115
  flag: string;
106
116
  as: string;
117
+ summary: boolean;
118
+ since: string;
107
119
  };
108
120
  } | {
109
121
  command: "status";
@@ -119,6 +131,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
119
131
  limit: string;
120
132
  flag: string;
121
133
  as: string;
134
+ summary: boolean;
135
+ since: string;
122
136
  };
123
137
  } | {
124
138
  command: "suspend";
@@ -134,6 +148,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
134
148
  limit: string;
135
149
  flag: string;
136
150
  as: string;
151
+ summary: boolean;
152
+ since: string;
137
153
  };
138
154
  } | {
139
155
  command: "triage";
@@ -149,6 +165,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
149
165
  limit: string;
150
166
  flag: string;
151
167
  as: string;
168
+ summary: boolean;
169
+ since: string;
152
170
  };
153
171
  } | {
154
172
  command: "unsuspend";
@@ -164,6 +182,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
164
182
  limit: string;
165
183
  flag: string;
166
184
  as: string;
185
+ summary: boolean;
186
+ since: string;
167
187
  };
168
188
  }>>;
169
189
  } & import("cmd-ts/dist/cjs/helpdoc.js").Named & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Descriptive & import("cmd-ts/dist/cjs/helpdoc.js").Versioned> & import("cmd-ts/dist/cjs/helpdoc.js").PrintHelp & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Versioned> & import("cmd-ts/dist/cjs/argparser.js").Register & import("cmd-ts/dist/cjs/runner.js").Handling<{
@@ -180,6 +200,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
180
200
  limit: string;
181
201
  flag: string;
182
202
  as: string;
203
+ summary: boolean;
204
+ since: string;
183
205
  };
184
206
  } | {
185
207
  command: "pause-publishing";
@@ -195,6 +217,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
195
217
  limit: string;
196
218
  flag: string;
197
219
  as: string;
220
+ summary: boolean;
221
+ since: string;
198
222
  };
199
223
  } | {
200
224
  command: "reports";
@@ -210,6 +234,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
210
234
  limit: string;
211
235
  flag: string;
212
236
  as: string;
237
+ summary: boolean;
238
+ since: string;
213
239
  };
214
240
  } | {
215
241
  command: "resolve";
@@ -225,6 +251,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
225
251
  limit: string;
226
252
  flag: string;
227
253
  as: string;
254
+ summary: boolean;
255
+ since: string;
228
256
  };
229
257
  } | {
230
258
  command: "resume-publishing";
@@ -240,6 +268,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
240
268
  limit: string;
241
269
  flag: string;
242
270
  as: string;
271
+ summary: boolean;
272
+ since: string;
243
273
  };
244
274
  } | {
245
275
  command: "status";
@@ -255,6 +285,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
255
285
  limit: string;
256
286
  flag: string;
257
287
  as: string;
288
+ summary: boolean;
289
+ since: string;
258
290
  };
259
291
  } | {
260
292
  command: "suspend";
@@ -270,6 +302,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
270
302
  limit: string;
271
303
  flag: string;
272
304
  as: string;
305
+ summary: boolean;
306
+ since: string;
273
307
  };
274
308
  } | {
275
309
  command: "triage";
@@ -285,6 +319,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
285
319
  limit: string;
286
320
  flag: string;
287
321
  as: string;
322
+ summary: boolean;
323
+ since: string;
288
324
  };
289
325
  } | {
290
326
  command: "unsuspend";
@@ -300,6 +336,8 @@ export declare function moderationSubcommands(ctx: CliCtx): Partial<import("cmd-
300
336
  limit: string;
301
337
  flag: string;
302
338
  as: string;
339
+ summary: boolean;
340
+ since: string;
303
341
  };
304
342
  }, {
305
343
  command: "flags";
@@ -1,4 +1,4 @@
1
- import { command, option, string, subcommands } from "cmd-ts";
1
+ import { command, flag, option, string, subcommands } from "cmd-ts";
2
2
  import { Result, Option } from "@adviser/cement";
3
3
  import { type } from "arktype";
4
4
  import { isResModerationAdmin, } from "@vibes.diy/api-types";
@@ -18,6 +18,8 @@ export const ReqModerationCli = type({
18
18
  limit: "string",
19
19
  "flagId?": "string",
20
20
  "triage?": "string",
21
+ "summary?": "boolean",
22
+ "since?": "string",
21
23
  });
22
24
  export function isReqModerationCli(obj) {
23
25
  return ReqModerationCli.allows(obj);
@@ -30,7 +32,7 @@ export const ResModerationCli = type({
30
32
  export function isResModerationCli(obj) {
31
33
  return ResModerationCli.allows(obj);
32
34
  }
33
- const FLAG_STATUSES = ["open", "false_alarm", "escalated", "resolved", "all"];
35
+ const FLAG_STATUSES = ["open", "false_alarm", "escalated", "resolved", "allowed", "error", "all"];
34
36
  const FLAG_TRIAGES = ["false_alarm", "escalated", "resolved"];
35
37
  export function moderationArgsProblem(args) {
36
38
  const writes = args.op !== "list-reports" && args.op !== "status" && args.op !== "list-flags";
@@ -47,7 +49,9 @@ export function moderationArgsProblem(args) {
47
49
  return "--as is false_alarm, escalated or resolved";
48
50
  if (args.op === "list-flags") {
49
51
  if (args.status !== "" && !FLAG_STATUSES.includes(args.status))
50
- return "--status is open, false_alarm, escalated, resolved or all";
52
+ return "--status is open, false_alarm, escalated, resolved, allowed, error or all";
53
+ if ((args.since ?? "") !== "" && Number.isNaN(Date.parse(args.since ?? "")))
54
+ return "--since is an ISO 8601 time";
51
55
  }
52
56
  else if (args.status !== "" && !["open", "resolved", "all"].includes(args.status))
53
57
  return "--status is open, resolved or all";
@@ -67,6 +71,8 @@ export function toModerationAdminReq(args) {
67
71
  ...(args.op === "list-flags" && args.status !== ""
68
72
  ? { flagStatus: args.status }
69
73
  : {}),
74
+ ...(args.summary === true ? { summary: true } : {}),
75
+ ...(args.since === undefined || args.since === "" ? {} : { since: args.since }),
70
76
  ...(args.flagId === undefined || args.flagId === "" ? {} : { flagId: args.flagId }),
71
77
  ...(args.triage === undefined || args.triage === "" ? {} : { triage: args.triage }),
72
78
  ...(args.limit === "" ? {} : { limit: Math.min(500, Number(args.limit)) }),
@@ -121,6 +127,11 @@ export function renderModerationLines(msg) {
121
127
  }
122
128
  if (r.flag !== undefined)
123
129
  lines.push(`Flag ${r.flag.flagId} is ${r.flag.status}.`);
130
+ if (r.flagSummary !== undefined) {
131
+ lines.push(`Decisions since ${r.flagSummary.since}: ${r.flagSummary.total}`);
132
+ for (const row of r.flagSummary.rows)
133
+ lines.push(` ${String(row.n).padStart(6)} ${row.status} ${row.category} ${row.inputKind}`);
134
+ }
124
135
  return lines;
125
136
  }
126
137
  export const moderationEvento = {
@@ -163,6 +174,11 @@ function opCmd(ctx, name, description, op, extra = {}) {
163
174
  limit: textOpt("limit", "How many reports to list, newest first (default 50, up to 500)"),
164
175
  flag: textOpt("flag", "Auto flag id (triage)"),
165
176
  as: textOpt("as", "Triage verdict: false_alarm, escalated or resolved"),
177
+ summary: flag({
178
+ long: "summary",
179
+ description: "Auto flags: count every decision by status, category and kind instead of listing",
180
+ }),
181
+ since: textOpt("since", "Auto flags --summary: window start, ISO 8601 (default the last 24 hours)"),
166
182
  },
167
183
  handler: ctx.cliStream.enqueue((args) => {
168
184
  return {
@@ -177,6 +193,8 @@ function opCmd(ctx, name, description, op, extra = {}) {
177
193
  limit: args.limit,
178
194
  flagId: args.flag,
179
195
  triage: args.as,
196
+ ...(args.summary ? { summary: true } : {}),
197
+ ...(args.since === "" ? {} : { since: args.since }),
180
198
  ...extra,
181
199
  };
182
200
  }),
@@ -198,7 +216,7 @@ export function moderationSubcommands(ctx) {
198
216
  paused: false,
199
217
  }),
200
218
  status: opCmd(ctx, "status", "The publishing switch, active suspensions and the open report count", "status"),
201
- flags: opCmd(ctx, "flags", "List the prompt and code checker's flags, newest first (open by default)", "list-flags"),
219
+ flags: opCmd(ctx, "flags", "List the prompt and code checker's flags, newest first (open by default; --status allowed or error for records, --summary for counts)", "list-flags"),
202
220
  triage: opCmd(ctx, "triage", "Triage an auto flag: --flag <id> --as false_alarm|escalated|resolved --reason <note>", "triage-flag"),
203
221
  },
204
222
  });
@@ -211660,6 +211660,13 @@ var evtAutoFlagWaiting = lazyType(
211660
211660
  at: "string"
211661
211661
  })
211662
211662
  );
211663
+ var autoFlagSummary = lazyType(
211664
+ () => type({
211665
+ since: "string",
211666
+ total: "number",
211667
+ rows: type({ status: "string", category: "string", inputKind: "string", n: "number" }).array()
211668
+ })
211669
+ );
211663
211670
  var reqModerationAdmin = lazyType(
211664
211671
  () => type({
211665
211672
  type: "'vibes.diy.req-moderation-admin'",
@@ -211674,7 +211681,10 @@ var reqModerationAdmin = lazyType(
211674
211681
  "limit?": "number",
211675
211682
  "flagId?": "string",
211676
211683
  "triage?": autoFlagTriage,
211677
- "flagStatus?": "'open' | 'false_alarm' | 'escalated' | 'resolved' | 'all'"
211684
+ "flagStatus?": "'open' | 'false_alarm' | 'escalated' | 'resolved' | 'allowed' | 'error' | 'all'",
211685
+ "summary?": "boolean",
211686
+ // ISO 8601; the summary's window start. Default: 24 hours ago.
211687
+ "since?": "string"
211678
211688
  })
211679
211689
  );
211680
211690
  var vibeReportRow = lazyType(
@@ -211721,7 +211731,8 @@ var resModerationAdmin = lazyType(
211721
211731
  "publishing?": publishingSwitchState,
211722
211732
  "openReports?": "number",
211723
211733
  "flags?": autoFlagRow.array(),
211724
- "flag?": autoFlagRow
211734
+ "flag?": autoFlagRow,
211735
+ "flagSummary?": autoFlagSummary
211725
211736
  })
211726
211737
  );
211727
211738
 
@@ -261306,6 +261317,23 @@ function captureWelcomeBonusGranted(vctx, args3) {
261306
261317
  vctx.waitUntil?.(promise2);
261307
261318
  }
261308
261319
  __name(captureWelcomeBonusGranted, "captureWelcomeBonusGranted");
261320
+ function capturePromptTurnStarted(vctx, args3) {
261321
+ const promise2 = capturePostHogServerEvent(vctx, {
261322
+ event: "prompt_turn_started",
261323
+ distinctId: args3.userId,
261324
+ properties: {
261325
+ turn_lane: args3.lane,
261326
+ top_level: args3.topLevel,
261327
+ follow_up: args3.followUp,
261328
+ by_text: args3.byText,
261329
+ ...args3.submitId === void 0 ? {} : { submit_id: args3.submitId },
261330
+ ...clientProperties(vctx.client)
261331
+ }
261332
+ }).catch(() => {
261333
+ });
261334
+ vctx.waitUntil?.(promise2);
261335
+ }
261336
+ __name(capturePromptTurnStarted, "capturePromptTurnStarted");
261309
261337
  function captureAgentFeedback(vctx, args3) {
261310
261338
  const promise2 = capturePostHogServerEvent(vctx, {
261311
261339
  event: "agent_feedback",
@@ -354154,11 +354182,20 @@ async function decideModeration(llm, input3) {
354154
354182
  model: `${AUTO_MODERATION_PRIMARY.id},${AUTO_MODERATION_FALLBACK.id}`
354155
354183
  });
354156
354184
  }
354157
- return Result.Err(
354158
- `auto-moderation: no verdict (${first.kind === "error" ? first.why : "?"}; ${second.kind === "error" ? second.why : "?"})`
354159
- );
354185
+ const firstWhy = first.kind === "error" ? first.why : "?";
354186
+ const secondWhy = second.kind === "error" ? second.why : "?";
354187
+ console.warn(`[auto-moderation] no verdict: ${firstWhy}; ${secondWhy}`);
354188
+ return Result.Err(moderationErrorClass(secondWhy));
354160
354189
  }
354161
354190
  __name(decideModeration, "decideModeration");
354191
+ function moderationErrorClass(why) {
354192
+ const status = why.match(/status (\d{3})/)?.[1];
354193
+ if (status !== void 0) return `http_${status}`;
354194
+ if (/timeout|timed out|abort/i.test(why)) return "timeout";
354195
+ if (/JSON|empty reply/.test(why)) return "unreadable_reply";
354196
+ return "unreachable";
354197
+ }
354198
+ __name(moderationErrorClass, "moderationErrorClass");
354162
354199
  function submittedPromptText(messages) {
354163
354200
  const last = [...messages].reverse().find((m) => m.role === "user");
354164
354201
  if (last === void 0) return void 0;
@@ -354173,6 +354210,9 @@ function autoModerationEnabled(flag) {
354173
354210
  return flag !== "off" && flag !== "false";
354174
354211
  }
354175
354212
  __name(autoModerationEnabled, "autoModerationEnabled");
354213
+ var AUTO_FLAG_ALLOWED_STATUS = "allowed";
354214
+ var AUTO_FLAG_ERROR_STATUS = "error";
354215
+ var AUTO_FLAG_RECORD_STATUSES = [AUTO_FLAG_ALLOWED_STATUS, AUTO_FLAG_ERROR_STATUS];
354176
354216
  async function readCodeBundle(vctx, job) {
354177
354217
  const t3 = vctx.sql.tables.apps;
354178
354218
  const row = await vctx.sql.db.select({ fileSystem: t3.fileSystem }).from(t3).where(and(eq(t3.ownerHandle, job.ownerHandle), eq(t3.appSlug, job.appSlug), eq(t3.fsId, job.fsId))).limit(1).then((r2) => r2[0]);
@@ -354199,29 +354239,38 @@ async function runAutoModeration(vctx, job, llm = { llmRequest: /* @__PURE__ */
354199
354239
  input3 = { kind: "code", files };
354200
354240
  }
354201
354241
  const rVerdict = await decideModeration(llm, input3);
354202
- if (rVerdict.isErr()) {
354203
- console.warn(`[auto-moderation] ${job.kind} ${job.ownerHandle}/${job.appSlug}: ${rVerdict.Err().message}`);
354204
- return { kind: "skipped", why: "no verdict" };
354205
- }
354206
- const v3 = rVerdict.Ok();
354207
- if (v3.decision === "allow") return { kind: "allowed", model: v3.model };
354208
354242
  const flagId = vctx.sthis.nextId(96 / 8).str;
354209
- const category = v3.category === "refused" ? "refused" : storedCategory(v3.category);
354210
- await vctx.sql.db.insert(vctx.sql.tables.autoModerationFlags).values({
354243
+ const refs = {
354211
354244
  flagId,
354212
354245
  ownerHandle: job.ownerHandle,
354213
354246
  appSlug: job.appSlug,
354214
354247
  actorUserId: job.actorUserId,
354215
354248
  inputKind: job.kind,
354216
- category,
354217
- reason: v3.reason,
354218
- model: v3.model,
354219
354249
  chatId: job.kind === "prompt" ? job.chatId : null,
354220
354250
  promptId: job.kind === "prompt" ? job.promptId : null,
354221
354251
  fsId: job.kind === "code" ? job.fsId : null,
354222
- status: "open",
354223
354252
  created: now3().toISOString()
354224
- });
354253
+ };
354254
+ if (rVerdict.isErr()) {
354255
+ const errorClass = rVerdict.Err().message;
354256
+ console.warn(`[auto-moderation] ${job.kind} ${job.ownerHandle}/${job.appSlug}: no verdict (${errorClass})`);
354257
+ await vctx.sql.db.insert(vctx.sql.tables.autoModerationFlags).values({
354258
+ ...refs,
354259
+ category: "none",
354260
+ reason: errorClass,
354261
+ model: AUTO_MODERATION_FALLBACK.id,
354262
+ status: AUTO_FLAG_ERROR_STATUS
354263
+ });
354264
+ return { kind: "error", flagId, errorClass };
354265
+ }
354266
+ const v3 = rVerdict.Ok();
354267
+ const row = { ...refs, reason: v3.reason, model: v3.model };
354268
+ if (v3.decision === "allow") {
354269
+ await vctx.sql.db.insert(vctx.sql.tables.autoModerationFlags).values({ ...row, category: "none", status: AUTO_FLAG_ALLOWED_STATUS });
354270
+ return { kind: "allowed", model: v3.model, flagId };
354271
+ }
354272
+ const category = v3.category === "refused" ? "refused" : storedCategory(v3.category);
354273
+ await vctx.sql.db.insert(vctx.sql.tables.autoModerationFlags).values({ ...row, category, status: "open" });
354225
354274
  console.info(`[auto-moderation] flag ${flagId} ${category} on ${job.ownerHandle}/${job.appSlug} (${job.kind})`);
354226
354275
  const childSafety = category === "minors_sexual";
354227
354276
  if (childSafety) {
@@ -390588,6 +390637,7 @@ async function runPromptTurn(ctx) {
390588
390637
  let agentReaction;
390589
390638
  const turnLatency = {};
390590
390639
  let agentFirstTurnMint = false;
390640
+ let hasPriorTurn = false;
390591
390641
  const facts = { toolsOffered: [], errored: false };
390592
390642
  if (isReqCreationPromptChatSection(orig)) {
390593
390643
  const rRoute = await routeCodegenTurn(vctx, {
@@ -390600,6 +390650,7 @@ async function runPromptTurn(ctx) {
390600
390650
  if (rRoute.isErr()) return Result.Err(rRoute);
390601
390651
  const route = rRoute.Ok();
390602
390652
  agentFirstTurnMint = route.agentFirstTurnMint;
390653
+ hasPriorTurn = route.hasPriorTurn;
390603
390654
  if (route.agentRoute.route === "agent") {
390604
390655
  const rAgent = await assembleAgentTurn({
390605
390656
  ctx,
@@ -390748,6 +390799,16 @@ async function runPromptTurn(ctx) {
390748
390799
  });
390749
390800
  }
390750
390801
  }
390802
+ if (isReqCreationPromptChatSection(orig) && orig.dryRun !== true && agentDispatchedBuild !== true && envelope.agentWakeTurn !== true) {
390803
+ capturePromptTurnStarted(vctx, {
390804
+ userId: req2._auth.verifiedAuth.claims.userId,
390805
+ lane: agentAssembled === void 0 ? "codegen" : "agent",
390806
+ topLevel: isAgentChatAppSlug(resChat.appSlug),
390807
+ followUp: hasPriorTurn,
390808
+ byText: envelope.byText,
390809
+ ..."clientMessageId" in orig && typeof orig.clientMessageId === "string" ? { submitId: orig.clientMessageId } : {}
390810
+ });
390811
+ }
390751
390812
  if (agentDispatchedBuild) {
390752
390813
  vctx.logger.Info().Str("chatId", req2.chatId).Str("promptId", promptId).Str("ownerHandle", resChat.ownerHandle).Str("appSlug", resChat.appSlug).Msg("agent-dispatched-turn-started");
390753
390814
  }
@@ -394365,6 +394426,7 @@ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
394365
394426
  init_performance2();
394366
394427
  init_esm();
394367
394428
  init_out4();
394429
+ var FLAG_SUMMARY_DEFAULT_MS = 24 * 60 * 60 * 1e3;
394368
394430
  var DEFAULT_LIST_LIMIT = 50;
394369
394431
  var MAX_LIST_LIMIT = 500;
394370
394432
  function toReportRow(r2) {
@@ -394523,10 +394585,23 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
394523
394585
  }
394524
394586
  case "list-flags": {
394525
394587
  const flags = vctx.sql.tables.autoModerationFlags;
394588
+ if (req2.summary === true) {
394589
+ const since = req2.since ?? new Date(now3.getTime() - FLAG_SUMMARY_DEFAULT_MS).toISOString();
394590
+ if (Number.isNaN(Date.parse(since))) return Result.Err("moderation: --since is an ISO 8601 time");
394591
+ const counted = await vctx.sql.db.select({ status: flags.status, category: flags.category, inputKind: flags.inputKind, n: count3() }).from(flags).where(gte(flags.created, new Date(since).toISOString())).groupBy(flags.status, flags.category, flags.inputKind);
394592
+ const rows2 = counted.map((r2) => ({ status: r2.status, category: r2.category, inputKind: r2.inputKind, n: Number(r2.n) })).sort(
394593
+ (a4, b4) => b4.n - a4.n || `${a4.status} ${a4.category} ${a4.inputKind}`.localeCompare(`${b4.status} ${b4.category} ${b4.inputKind}`)
394594
+ );
394595
+ return Result.Ok({
394596
+ type: "vibes.diy.res-moderation-admin",
394597
+ op: req2.op,
394598
+ flagSummary: { since: new Date(since).toISOString(), total: rows2.reduce((s2, r2) => s2 + r2.n, 0), rows: rows2 }
394599
+ });
394600
+ }
394526
394601
  const status = req2.flagStatus ?? "open";
394527
394602
  const limit = Math.max(1, Math.min(MAX_LIST_LIMIT, Math.floor(req2.limit ?? DEFAULT_LIST_LIMIT)));
394528
394603
  const base2 = vctx.sql.db.select().from(flags);
394529
- const rows = await (status === "all" ? base2 : base2.where(eq(flags.status, status))).orderBy(desc(flags.created)).limit(limit);
394604
+ const rows = await (status === "all" ? base2.where(notInArray(flags.status, [...AUTO_FLAG_RECORD_STATUSES])) : base2.where(eq(flags.status, status))).orderBy(desc(flags.created)).limit(limit);
394530
394605
  const out = [];
394531
394606
  for (const r2 of rows) {
394532
394607
  const text3 = r2.inputKind === "prompt" && r2.chatId && r2.promptId ? await readFlaggedPrompt(vctx, r2.chatId, r2.promptId) : void 0;
@@ -394540,6 +394615,12 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
394540
394615
  const flags = vctx.sql.tables.autoModerationFlags;
394541
394616
  const existing = await vctx.sql.db.select().from(flags).where(eq(flags.flagId, req2.flagId)).limit(1).then((r2) => r2[0]);
394542
394617
  if (existing === void 0) return Result.Err(`moderation: no flag ${req2.flagId}`);
394618
+ if (existing.status === AUTO_FLAG_ALLOWED_STATUS) {
394619
+ return Result.Err(`moderation: ${req2.flagId} records an allow, not a flag; there is nothing to triage`);
394620
+ }
394621
+ if (existing.status === AUTO_FLAG_ERROR_STATUS) {
394622
+ return Result.Err(`moderation: ${req2.flagId} records a check no model answered, not a flag; there is nothing to triage`);
394623
+ }
394543
394624
  const escalating = req2.triage === "escalated" && existing.status !== "escalated";
394544
394625
  const set3 = {
394545
394626
  status: req2.triage,
@@ -14737,7 +14737,7 @@ function isResReportVibe(obj) {
14737
14737
  function isResModerationAdmin(obj) {
14738
14738
  return resModerationAdmin.allows(obj);
14739
14739
  }
14740
- var vibeReportCategory, VIBE_REPORT_NOTE_MAX, reqReportVibe, resReportVibe, REPORT_RATE_LIMITED, evtVibeReported, evtChildSafetySignal, moderationAdminOp, autoFlagTriage, autoFlagRow, evtAutoFlagWaiting, reqModerationAdmin, vibeReportRow, accountSuspensionRow, publishingSwitchState, resModerationAdmin;
14740
+ var vibeReportCategory, VIBE_REPORT_NOTE_MAX, reqReportVibe, resReportVibe, REPORT_RATE_LIMITED, evtVibeReported, evtChildSafetySignal, moderationAdminOp, autoFlagTriage, autoFlagRow, evtAutoFlagWaiting, autoFlagSummary, reqModerationAdmin, vibeReportRow, accountSuspensionRow, publishingSwitchState, resModerationAdmin;
14741
14741
  var init_moderation = __esm({
14742
14742
  "../vibes.diy/api/types/moderation.ts"() {
14743
14743
  "use strict";
@@ -14827,6 +14827,13 @@ var init_moderation = __esm({
14827
14827
  at: "string"
14828
14828
  })
14829
14829
  );
14830
+ autoFlagSummary = lazyType(
14831
+ () => type58({
14832
+ since: "string",
14833
+ total: "number",
14834
+ rows: type58({ status: "string", category: "string", inputKind: "string", n: "number" }).array()
14835
+ })
14836
+ );
14830
14837
  reqModerationAdmin = lazyType(
14831
14838
  () => type58({
14832
14839
  type: "'vibes.diy.req-moderation-admin'",
@@ -14841,7 +14848,10 @@ var init_moderation = __esm({
14841
14848
  "limit?": "number",
14842
14849
  "flagId?": "string",
14843
14850
  "triage?": autoFlagTriage,
14844
- "flagStatus?": "'open' | 'false_alarm' | 'escalated' | 'resolved' | 'all'"
14851
+ "flagStatus?": "'open' | 'false_alarm' | 'escalated' | 'resolved' | 'allowed' | 'error' | 'all'",
14852
+ "summary?": "boolean",
14853
+ // ISO 8601; the summary's window start. Default: 24 hours ago.
14854
+ "since?": "string"
14845
14855
  })
14846
14856
  );
14847
14857
  vibeReportRow = lazyType(
@@ -14888,7 +14898,8 @@ var init_moderation = __esm({
14888
14898
  "publishing?": publishingSwitchState,
14889
14899
  "openReports?": "number",
14890
14900
  "flags?": autoFlagRow.array(),
14891
- "flag?": autoFlagRow
14901
+ "flag?": autoFlagRow,
14902
+ "flagSummary?": autoFlagSummary
14892
14903
  })
14893
14904
  );
14894
14905
  __name(isResModerationAdmin, "isResModerationAdmin");
@@ -26655,7 +26666,6 @@ var init_version_timeline = __esm({
26655
26666
  var POUF_ENTRY_EXPORTS, POUF_TAUGHT_NAMES;
26656
26667
  var init_exports = __esm({
26657
26668
  "../vibes.diy/pouf/exports.ts"() {
26658
- "use strict";
26659
26669
  POUF_ENTRY_EXPORTS = {
26660
26670
  index: [
26661
26671
  "AlertBell",
@@ -30811,6 +30821,22 @@ function captureWelcomeBonusGranted(vctx, args) {
30811
30821
  });
30812
30822
  vctx.waitUntil?.(promise);
30813
30823
  }
30824
+ function capturePromptTurnStarted(vctx, args) {
30825
+ const promise = capturePostHogServerEvent(vctx, {
30826
+ event: "prompt_turn_started",
30827
+ distinctId: args.userId,
30828
+ properties: {
30829
+ turn_lane: args.lane,
30830
+ top_level: args.topLevel,
30831
+ follow_up: args.followUp,
30832
+ by_text: args.byText,
30833
+ ...args.submitId === void 0 ? {} : { submit_id: args.submitId },
30834
+ ...clientProperties(vctx.client)
30835
+ }
30836
+ }).catch(() => {
30837
+ });
30838
+ vctx.waitUntil?.(promise);
30839
+ }
30814
30840
  function captureAgentFeedback(vctx, args) {
30815
30841
  const promise = capturePostHogServerEvent(vctx, {
30816
30842
  event: "agent_feedback",
@@ -30873,6 +30899,7 @@ var init_analytics = __esm({
30873
30899
  __name(captureCreditUsageMilestones, "captureCreditUsageMilestones");
30874
30900
  __name(captureRestyleRefused, "captureRestyleRefused");
30875
30901
  __name(captureWelcomeBonusGranted, "captureWelcomeBonusGranted");
30902
+ __name(capturePromptTurnStarted, "capturePromptTurnStarted");
30876
30903
  __name(captureAgentFeedback, "captureAgentFeedback");
30877
30904
  }
30878
30905
  });
@@ -51064,8 +51091,8 @@ var init_turn_terminal = __esm({
51064
51091
  });
51065
51092
 
51066
51093
  // ../vibes.diy/api/svc/intern/chat-section-persist.ts
51067
- function chatPackCodeLinesEnabled(flag21) {
51068
- return flag21 === "on";
51094
+ function chatPackCodeLinesEnabled(flag22) {
51095
+ return flag22 === "on";
51069
51096
  }
51070
51097
  function blocksForPersist(vctx, blocks) {
51071
51098
  return chatPackCodeLinesEnabled(vctx.sthis.env.get(CHAT_PACK_CODE_LINES_ENV)) ? packChatSectionBlocks(blocks) : blocks;
@@ -52742,8 +52769,8 @@ var init_turn_summary = __esm({
52742
52769
  // ../vibes.diy/api/svc/intern/app-inventory.ts
52743
52770
  import { exception2Result as exception2Result79, Result as Result51 } from "@adviser/cement";
52744
52771
  import { type as type97 } from "arktype";
52745
- function appInventoryEnabled(flag21) {
52746
- return flag21 !== "off";
52772
+ function appInventoryEnabled(flag22) {
52773
+ return flag22 !== "off";
52747
52774
  }
52748
52775
  function withSlash(path2) {
52749
52776
  return path2.startsWith("/") ? path2 : `/${path2}`;
@@ -72484,8 +72511,8 @@ function MountVibe(props) {
72484
72511
  }
72485
72512
  function SandboxServiceWorker({ svcEnv, captureRender }) {
72486
72513
  if (captureRender === true) return null;
72487
- const flag21 = svcEnv.VIBE_SERVICE_WORKER;
72488
- const enabled = flag21 !== "false" && flag21 !== "off";
72514
+ const flag22 = svcEnv.VIBE_SERVICE_WORKER;
72515
+ const enabled = flag22 !== "false" && flag22 !== "off";
72489
72516
  if (enabled === false) {
72490
72517
  const off = `if("serviceWorker" in navigator){navigator.serviceWorker.getRegistrations().then(function(rs){rs.forEach(function(r){r.unregister()})}).catch(function(){});if(typeof caches!=="undefined"){caches.keys().then(function(ks){ks.forEach(function(k){k.indexOf("vibes-sandbox-")===0&&caches.delete(k)})}).catch(function(){})}}`;
72491
72518
  return /* @__PURE__ */ React11.createElement("script", { dangerouslySetInnerHTML: { __html: inlineScript(off) } });
@@ -72536,48 +72563,48 @@ function BootErrorReporter({ bootError }) {
72536
72563
  return /* @__PURE__ */ React11.createElement("script", { dangerouslySetInnerHTML: { __html: js } });
72537
72564
  }
72538
72565
  function BootStatsReporter({ svcEnv }) {
72539
- const flag21 = svcEnv.VIBE_BOOT_STATS;
72540
- if (flag21 === "false" || flag21 === "off") return null;
72566
+ const flag22 = svcEnv.VIBE_BOOT_STATS;
72567
+ if (flag22 === "false" || flag22 === "off") return null;
72541
72568
  const js = inlineScript(
72542
72569
  `if(window.parent!==window){addEventListener("load",function(){try{var p=performance,s=navigator.serviceWorker,b=0,k=0,m=0,w=0,r=p.getEntriesByType("resource");r.forEach(function(e){b=b+(e.encodedBodySize||e.transferSize||0);if(e.name.indexOf("/vibe-pkg/")+1){k++;m=Math.max(m,e.duration);if(e.duration>=${PKG_SLOW_MS})w++}});window.parent.postMessage({type:${JSON.stringify(BOOT_STATS_EVENT_TYPE)},loadMs:p.now()|0,resourceCount:r.length,resourceBytes:b,pkgCount:k,pkgMaxMs:m|0,pkgSlowCount:w,swControlled:!!(s&&s.controller),replayGranted:window.__vibesReplayGranted===true},"*")}catch(e){}})}`
72543
72570
  );
72544
72571
  return /* @__PURE__ */ React11.createElement("script", { dangerouslySetInnerHTML: { __html: js } });
72545
72572
  }
72546
72573
  function WebVitalsReporter({ svcEnv }) {
72547
- const flag21 = svcEnv.VIBE_WEB_VITALS;
72548
- if (flag21 === "false" || flag21 === "off") return null;
72574
+ const flag22 = svcEnv.VIBE_WEB_VITALS;
72575
+ if (flag22 === "false" || flag22 === "off") return null;
72549
72576
  const js = inlineScript(
72550
72577
  `if(window.parent!==window){try{var vvS=0,vvL=-1,vvR=[];var vvLcb=function(e){vvL=e.startTime};var vvO=function(t,cb){try{var st=PerformanceObserver.supportedEntryTypes;if(st&&st.indexOf(t)===-1)return false;var o=new PerformanceObserver(function(l){l.getEntries().forEach(cb)});o.observe({type:t,buffered:true});vvR.push([o,cb]);return true}catch(e){return false}};var vvTake=function(){for(var i=0;i!==vvR.length;i++){try{var rs=vvR[i][0].takeRecords();if(rs){rs.forEach(vvR[i][1])}}catch(e){}}};var vvF=function(){if(vvS)return;vvS=1;try{vvTake()}catch(e){}try{var m={type:${JSON.stringify(WEB_VITALS_EVENT_TYPE)}};if(vvL>=0){m.lcpMs=vvL|0}window.parent.postMessage(m,"*")}catch(e){}};vvO("largest-contentful-paint",vvLcb);addEventListener("visibilitychange",function(){if(document.visibilityState==="hidden")vvF()},true);addEventListener("pagehide",vvF,true);addEventListener("pointerdown",vvF,{once:true,capture:true});addEventListener("keydown",vvF,{once:true,capture:true})}catch(e){}}`
72551
72578
  );
72552
72579
  return /* @__PURE__ */ React11.createElement("script", { dangerouslySetInnerHTML: { __html: js } });
72553
72580
  }
72554
72581
  function CpuBusyReporter({ svcEnv }) {
72555
- const flag21 = svcEnv.VIBE_CPU_BUSY;
72556
- if (flag21 === "false" || flag21 === "off") return null;
72582
+ const flag22 = svcEnv.VIBE_CPU_BUSY;
72583
+ if (flag22 === "false" || flag22 === "off") return null;
72557
72584
  const js = inlineScript(
72558
72585
  `if(window.parent!==window){try{var cbS=0,cbN=0,cbB=0,cbX=0,cbO=0,cbV=0,cbM=0,cbC=0,cbK=0,cbP=0,cbR=0,cbI=0;var cbVis=function(){try{return document.visibilityState==="visible"}catch(e){return true}};try{var st=PerformanceObserver.supportedEntryTypes;if(!st||st.indexOf("longtask")!==-1){var o=new PerformanceObserver(function(l){l.getEntries().forEach(function(e){if(!cbVis())return;var d=e.duration;if(typeof d!=="number"||!isFinite(d)||!(d>=0))return;cbN++;var b=d-50;if(b>0)cbB+=b;if(d>cbX)cbX=d})});o.observe({type:"longtask"});cbO=1}}catch(e){}var cbSend=function(ph){try{if(!(cbV>=1))return;if(cbR>=12)return;cbR++;var m={type:"vibe.evt.cpu-busy",phase:ph,elapsedMs:cbV|0,stallMax:cbM|0,stallOverCount:cbC,stallSampleCount:cbK,replayGranted:window.__vibesReplayGranted===true};if(cbO){m.longTaskCount=cbN;m.blockingMs=cbB|0;m.longestTaskMs=cbX|0}window.parent.postMessage(m,"*")}catch(e){}};var cbReset=function(){cbN=0;cbB=0;cbX=0;cbV=0;cbM=0;cbC=0;cbK=0;cbP=0;try{cbT=performance.now()}catch(e){}};var cbT=performance.now();var cbTick=function(){try{var n=performance.now(),dt=n-cbT;cbT=n;if(!cbVis())return;cbV+=dt;cbK++;var late=dt-1000;if(late>cbM)cbM=late;if(late>=250)cbC++;if(cbK%60===0&&!(cbP>=5)){cbP++;cbSend("interim")}}catch(e){}};cbI=setInterval(cbTick,1000);var cbF=function(stop){try{if(!cbS){cbS=1;cbSend("final");cbReset()}if(stop===1&&cbI){clearInterval(cbI);cbI=0}}catch(e){}};addEventListener("visibilitychange",function(){try{if(cbVis()){cbS=0;cbT=performance.now()}else{cbF(0)}}catch(e){}},true);addEventListener("pagehide",function(){cbF(1)},true);}catch(e){}}`
72559
72586
  );
72560
72587
  return /* @__PURE__ */ React11.createElement("script", { dangerouslySetInnerHTML: { __html: js } });
72561
72588
  }
72562
72589
  function LocalWritesReporter({ svcEnv }) {
72563
- const flag21 = svcEnv.VIBE_LOCAL_WRITES;
72564
- if (flag21 === "false" || flag21 === "off") return null;
72590
+ const flag22 = svcEnv.VIBE_LOCAL_WRITES;
72591
+ if (flag22 === "false" || flag22 === "off") return null;
72565
72592
  const js = inlineScript(
72566
72593
  `if(window.parent!==window){try{var lwS=0,lwR=0,lwL=0,lwI=0,lwA=0;var lwRead=function(){try{var n=window.__vibesLocalWrites;return typeof n==="number"&&isFinite(n)&&n>=0?n|0:0}catch(e){return 0}};var lwPost=function(ph,c){window.parent.postMessage({type:"vibe.evt.local-writes",phase:ph,writeCount:c,elapsedMs:performance.now()|0},"*")};var lwSend=function(ph){try{var c=lwRead();if(ph==="final"){if(lwS)return;lwS=1;lwR++;lwL=c;lwA=1;lwPost("final",c);return}if(lwR>=11)return;if(lwA===1&&c===lwL)return;lwR++;lwL=c;lwA=1;lwPost("interim",c)}catch(e){}};var lwArm=function(){if(!lwI){lwI=setInterval(function(){lwSend("interim")},15000)}};lwArm();addEventListener("visibilitychange",function(){try{if(document.visibilityState!=="visible"){lwSend("interim")}}catch(e){}},true);addEventListener("pagehide",function(){try{lwSend("final");if(lwI){clearInterval(lwI);lwI=0}}catch(e){}},true);addEventListener("pageshow",function(ev){try{if(ev&&ev.persisted===true){lwS=0;lwArm()}}catch(e){}},true);}catch(e){}}`
72567
72594
  );
72568
72595
  return /* @__PURE__ */ React11.createElement("script", { dangerouslySetInnerHTML: { __html: js } });
72569
72596
  }
72570
72597
  function EngagementReporter({ svcEnv }) {
72571
- const flag21 = svcEnv.VIBE_ENGAGEMENT;
72572
- if (flag21 === "false" || flag21 === "off") return null;
72598
+ const flag22 = svcEnv.VIBE_ENGAGEMENT;
72599
+ if (flag22 === "false" || flag22 === "off") return null;
72573
72600
  const js = inlineScript(
72574
72601
  `if(window.parent!==window){try{var egT=0,egK=0,egV=0,egF=0,egVs=-1,egFs=-1,egS=0,egR=0,egI=0,egLast="";var egNow=function(){return performance.now()|0};var egVis=function(){try{return document.visibilityState==="visible"}catch(e){return false}};var egFoc=function(){try{return typeof document.hasFocus==="function"&&document.hasFocus()===true}catch(e){return false}};var egRoll=function(){var t=egNow();if(egVs>=0){egV+=t-egVs;egVs=egVis()?t:-1}else if(egVis()){egVs=t}if(egFs>=0){egF+=t-egFs;egFs=egFoc()?t:-1}else if(egFoc()){egFs=t}};var egBlank=function(){try{var b=document.querySelector(".vibe-app-container");if(!b)return true;var n=b.getElementsByTagName("*").length;var t=String(b.innerText||"").trim().length;return !(n>4)||t===0}catch(e){return false}};var egPost=function(ph){window.parent.postMessage({type:"vibe.evt.engagement",phase:ph,taps:egT,keys:egK,visibleMs:egV,focusedMs:egF,elapsedMs:egNow(),blank:egBlank()},"*")};var egSend=function(ph){try{egRoll();if(ph==="final"){if(egS)return;egS=1;egPost("final");return}if(egR>=20)return;var sig=egT+":"+egK;if(sig===egLast)return;egLast=sig;egR++;egPost("interim")}catch(e){}};var egArm=function(){if(!egI){egI=setInterval(function(){egSend("interim")},30000)}};egRoll();egArm();addEventListener("pointerdown",function(){egT++},{capture:true,passive:true});addEventListener("keydown",function(){egK++},{capture:true,passive:true});addEventListener("focus",function(){try{egRoll()}catch(e){}},true);addEventListener("blur",function(){try{egRoll()}catch(e){}},true);addEventListener("visibilitychange",function(){try{if(document.visibilityState!=="visible"){egSend("interim")}else{egRoll()}}catch(e){}},true);addEventListener("pagehide",function(){try{egSend("final");if(egI){clearInterval(egI);egI=0}}catch(e){}},true);addEventListener("pageshow",function(ev){try{if(ev&&ev.persisted===true){egS=0;egArm()}}catch(e){}},true);}catch(e){}}`
72575
72602
  );
72576
72603
  return /* @__PURE__ */ React11.createElement("script", { dangerouslySetInnerHTML: { __html: js } });
72577
72604
  }
72578
72605
  function BootProgressReporter({ svcEnv, bootProgress }) {
72579
- const flag21 = svcEnv.VIBE_BOOT_PROGRESS;
72580
- if (flag21 === "false" || flag21 === "off") return null;
72606
+ const flag22 = svcEnv.VIBE_BOOT_PROGRESS;
72607
+ if (flag22 === "false" || flag22 === "off") return null;
72581
72608
  if (bootProgress === void 0) return null;
72582
72609
  const js = bootProgressScript({ runtimeUrl: bootProgress.runtimeUrl, imports: bootProgress.imports });
72583
72610
  return /* @__PURE__ */ React11.createElement("script", { dangerouslySetInnerHTML: { __html: inlineScript(js) } });
@@ -100158,8 +100185,8 @@ var init_agent_skill_catalog = __esm({
100158
100185
  // ../vibes.diy/api/svc/intern/first-build-selector.ts
100159
100186
  import { Result as Result132, exception2Result as exception2Result193 } from "@adviser/cement";
100160
100187
  import { type as type135 } from "arktype";
100161
- function firstBuildSelectorEnabled(flag21) {
100162
- return flag21?.trim().toLowerCase() !== "off";
100188
+ function firstBuildSelectorEnabled(flag22) {
100189
+ return flag22?.trim().toLowerCase() !== "off";
100163
100190
  }
100164
100191
  function firstBuildSelectorPrompt(personWords, mintLook) {
100165
100192
  return [
@@ -101183,9 +101210,9 @@ function gateMercuryCards(raw, o) {
101183
101210
  if (p.cardLines.length === 0) miss("cards", "none");
101184
101211
  const caps = [];
101185
101212
  for (const c of tailList(p.keys.capabilities).map((x) => x.toLowerCase())) {
101186
- const flag21 = MERCURY_FLAGS.find((f) => f.toLowerCase() === c);
101187
- if (flag21 === void 0) miss("capabilities", "unknown");
101188
- else if (!caps.includes(flag21)) caps.push(flag21);
101213
+ const flag22 = MERCURY_FLAGS.find((f) => f.toLowerCase() === c);
101214
+ if (flag22 === void 0) miss("capabilities", "unknown");
101215
+ else if (!caps.includes(flag22)) caps.push(flag22);
101189
101216
  }
101190
101217
  const menu = mercuryMintMenu(o.look);
101191
101218
  const gatedNamed = gateMercurySkills(p.keys.skills, menu);
@@ -102041,8 +102068,8 @@ Otherwise, the one that fits who takes part:
102041
102068
 
102042
102069
  // ../vibes.diy/api/svc/intern/agent-reaction-classifier.ts
102043
102070
  import { Result as Result134, exception2Result as exception2Result195 } from "@adviser/cement";
102044
- function agentReactionClassifierEnabled(flag21) {
102045
- const v = flag21?.trim().toLowerCase();
102071
+ function agentReactionClassifierEnabled(flag22) {
102072
+ const v = flag22?.trim().toLowerCase();
102046
102073
  return v !== "off" && v !== "false";
102047
102074
  }
102048
102075
  function agentReactionPrompt(personWords) {
@@ -104462,9 +104489,17 @@ async function decideModeration(llm, input) {
104462
104489
  model: `${AUTO_MODERATION_PRIMARY.id},${AUTO_MODERATION_FALLBACK.id}`
104463
104490
  });
104464
104491
  }
104465
- return Result147.Err(
104466
- `auto-moderation: no verdict (${first.kind === "error" ? first.why : "?"}; ${second.kind === "error" ? second.why : "?"})`
104467
- );
104492
+ const firstWhy = first.kind === "error" ? first.why : "?";
104493
+ const secondWhy = second.kind === "error" ? second.why : "?";
104494
+ console.warn(`[auto-moderation] no verdict: ${firstWhy}; ${secondWhy}`);
104495
+ return Result147.Err(moderationErrorClass(secondWhy));
104496
+ }
104497
+ function moderationErrorClass(why) {
104498
+ const status = why.match(/status (\d{3})/)?.[1];
104499
+ if (status !== void 0) return `http_${status}`;
104500
+ if (/timeout|timed out|abort/i.test(why)) return "timeout";
104501
+ if (/JSON|empty reply/.test(why)) return "unreadable_reply";
104502
+ return "unreachable";
104468
104503
  }
104469
104504
  function submittedPromptText(messages) {
104470
104505
  const last = [...messages].reverse().find((m) => m.role === "user");
@@ -104475,8 +104510,8 @@ function submittedPromptText(messages) {
104475
104510
  ).join("\n").trim();
104476
104511
  return text3 === "" ? void 0 : text3;
104477
104512
  }
104478
- function autoModerationEnabled(flag21) {
104479
- return flag21 !== "off" && flag21 !== "false";
104513
+ function autoModerationEnabled(flag22) {
104514
+ return flag22 !== "off" && flag22 !== "false";
104480
104515
  }
104481
104516
  async function readCodeBundle(vctx, job) {
104482
104517
  const t = vctx.sql.tables.apps;
@@ -104503,29 +104538,38 @@ async function runAutoModeration(vctx, job, llm = { llmRequest: /* @__PURE__ */
104503
104538
  input = { kind: "code", files };
104504
104539
  }
104505
104540
  const rVerdict = await decideModeration(llm, input);
104506
- if (rVerdict.isErr()) {
104507
- console.warn(`[auto-moderation] ${job.kind} ${job.ownerHandle}/${job.appSlug}: ${rVerdict.Err().message}`);
104508
- return { kind: "skipped", why: "no verdict" };
104509
- }
104510
- const v = rVerdict.Ok();
104511
- if (v.decision === "allow") return { kind: "allowed", model: v.model };
104512
104541
  const flagId = vctx.sthis.nextId(96 / 8).str;
104513
- const category = v.category === "refused" ? "refused" : storedCategory(v.category);
104514
- await vctx.sql.db.insert(vctx.sql.tables.autoModerationFlags).values({
104542
+ const refs = {
104515
104543
  flagId,
104516
104544
  ownerHandle: job.ownerHandle,
104517
104545
  appSlug: job.appSlug,
104518
104546
  actorUserId: job.actorUserId,
104519
104547
  inputKind: job.kind,
104520
- category,
104521
- reason: v.reason,
104522
- model: v.model,
104523
104548
  chatId: job.kind === "prompt" ? job.chatId : null,
104524
104549
  promptId: job.kind === "prompt" ? job.promptId : null,
104525
104550
  fsId: job.kind === "code" ? job.fsId : null,
104526
- status: "open",
104527
104551
  created: now3().toISOString()
104528
- });
104552
+ };
104553
+ if (rVerdict.isErr()) {
104554
+ const errorClass = rVerdict.Err().message;
104555
+ console.warn(`[auto-moderation] ${job.kind} ${job.ownerHandle}/${job.appSlug}: no verdict (${errorClass})`);
104556
+ await vctx.sql.db.insert(vctx.sql.tables.autoModerationFlags).values({
104557
+ ...refs,
104558
+ category: "none",
104559
+ reason: errorClass,
104560
+ model: AUTO_MODERATION_FALLBACK.id,
104561
+ status: AUTO_FLAG_ERROR_STATUS
104562
+ });
104563
+ return { kind: "error", flagId, errorClass };
104564
+ }
104565
+ const v = rVerdict.Ok();
104566
+ const row = { ...refs, reason: v.reason, model: v.model };
104567
+ if (v.decision === "allow") {
104568
+ await vctx.sql.db.insert(vctx.sql.tables.autoModerationFlags).values({ ...row, category: "none", status: AUTO_FLAG_ALLOWED_STATUS });
104569
+ return { kind: "allowed", model: v.model, flagId };
104570
+ }
104571
+ const category = v.category === "refused" ? "refused" : storedCategory(v.category);
104572
+ await vctx.sql.db.insert(vctx.sql.tables.autoModerationFlags).values({ ...row, category, status: "open" });
104529
104573
  console.info(`[auto-moderation] flag ${flagId} ${category} on ${job.ownerHandle}/${job.appSlug} (${job.kind})`);
104530
104574
  const childSafety = category === "minors_sexual";
104531
104575
  if (childSafety) {
@@ -104561,7 +104605,7 @@ function scheduleAutoModeration(vctx, job) {
104561
104605
  console.warn("[auto-moderation] could not schedule:", e);
104562
104606
  }
104563
104607
  }
104564
- var AUTO_MODERATION_RUBRIC_CATEGORIES, RUBRIC, OUTPUT, AUTO_MODERATION_SYSTEM, AUTO_MODERATION_PRIMARY, AUTO_MODERATION_FALLBACK, AUTO_MODERATION_CODE_FILES, AUTO_MODERATION_MAX_CHARS, CALL_TIMEOUT_MS;
104608
+ var AUTO_MODERATION_RUBRIC_CATEGORIES, RUBRIC, OUTPUT, AUTO_MODERATION_SYSTEM, AUTO_MODERATION_PRIMARY, AUTO_MODERATION_FALLBACK, AUTO_MODERATION_CODE_FILES, AUTO_MODERATION_MAX_CHARS, CALL_TIMEOUT_MS, AUTO_FLAG_ALLOWED_STATUS, AUTO_FLAG_ERROR_STATUS, AUTO_FLAG_RECORD_STATUSES;
104565
104609
  var init_auto_moderation = __esm({
104566
104610
  "../vibes.diy/api/svc/intern/auto-moderation.ts"() {
104567
104611
  "use strict";
@@ -104614,8 +104658,12 @@ var init_auto_moderation = __esm({
104614
104658
  __name(moderationMessages, "moderationMessages");
104615
104659
  __name(callOnce, "callOnce");
104616
104660
  __name(decideModeration, "decideModeration");
104661
+ __name(moderationErrorClass, "moderationErrorClass");
104617
104662
  __name(submittedPromptText, "submittedPromptText");
104618
104663
  __name(autoModerationEnabled, "autoModerationEnabled");
104664
+ AUTO_FLAG_ALLOWED_STATUS = "allowed";
104665
+ AUTO_FLAG_ERROR_STATUS = "error";
104666
+ AUTO_FLAG_RECORD_STATUSES = [AUTO_FLAG_ALLOWED_STATUS, AUTO_FLAG_ERROR_STATUS];
104619
104667
  __name(readCodeBundle, "readCodeBundle");
104620
104668
  __name(runAutoModeration, "runAutoModeration");
104621
104669
  __name(scheduleAutoModeration, "scheduleAutoModeration");
@@ -104880,8 +104928,8 @@ function managedModule(mod, look = "house") {
104880
104928
  if (found === void 0 || LOOK_OWNED_MODULES.has(found) === false) return found;
104881
104929
  return LOOK_ROUTING[look].ownModules.includes(found) ? found : void 0;
104882
104930
  }
104883
- function importSynthEnabled(flag21) {
104884
- return flag21 === "on";
104931
+ function importSynthEnabled(flag22) {
104932
+ return flag22 === "on";
104885
104933
  }
104886
104934
  function synthesizeImports(args) {
104887
104935
  const out = new Map(args.vfs);
@@ -106224,8 +106272,8 @@ var init_egress_read_lane = __esm({
106224
106272
 
106225
106273
  // ../vibes.diy/api/svc/intern/backend-egress.ts
106226
106274
  import { exception2Result as exception2Result211 } from "@adviser/cement";
106227
- function optimisticReadLaneFor(flag21) {
106228
- if (flag21 !== "on") return void 0;
106275
+ function optimisticReadLaneFor(flag22) {
106276
+ if (flag22 !== "on") return void 0;
106229
106277
  return { rate: new EgressRateWindow(OPTIMISTIC_READ_RATE_TIER), cache: new EgressReadCache(), suspect: new ReadSuspectLog() };
106230
106278
  }
106231
106279
  function egressDenial(gate, host) {
@@ -117546,8 +117594,8 @@ var init_save_repair_io = __esm({
117546
117594
 
117547
117595
  // ../vibes.diy/api/svc/intern/save-repair.ts
117548
117596
  import { exception2Result as exception2Result252 } from "@adviser/cement";
117549
- function saveRepairEnabled(flag21) {
117550
- return flag21 !== "off";
117597
+ function saveRepairEnabled(flag22) {
117598
+ return flag22 !== "off";
117551
117599
  }
117552
117600
  function saveRepairFindings(files, changedPaths) {
117553
117601
  const vfs = /* @__PURE__ */ new Map();
@@ -117700,8 +117748,8 @@ var init_save_repair = __esm({
117700
117748
 
117701
117749
  // ../vibes.diy/api/svc/intern/seed-repair.ts
117702
117750
  import { exception2Result as exception2Result253 } from "@adviser/cement";
117703
- function seedRepairEnabled(flag21) {
117704
- return flag21 !== "off";
117751
+ function seedRepairEnabled(flag22) {
117752
+ return flag22 !== "off";
117705
117753
  }
117706
117754
  function seedRefusalCount(report2) {
117707
117755
  if (report2 === void 0) return 0;
@@ -121809,8 +121857,8 @@ var init_progress_label = __esm({
121809
121857
 
121810
121858
  // ../vibes.diy/api/svc/public/progress-label-dispatch.ts
121811
121859
  import { exception2Result as exception2Result259 } from "@adviser/cement";
121812
- function progressLabelEnabled(flag21) {
121813
- return flag21 !== "off";
121860
+ function progressLabelEnabled(flag22) {
121861
+ return flag22 !== "off";
121814
121862
  }
121815
121863
  function wantsProgressLabels(i) {
121816
121864
  return i.enabled && i.codegen && !i.proseOnly && !i.byok;
@@ -123311,8 +123359,8 @@ function firstBriefArmed(variant, firstTurn, defaultOn) {
123311
123359
  if (variant === "opus-server-first-build") return true;
123312
123360
  return variant === void 0 && defaultOn;
123313
123361
  }
123314
- function agentFirstBriefEnabled(flag21) {
123315
- return flag21 !== "off";
123362
+ function agentFirstBriefEnabled(flag22) {
123363
+ return flag22 !== "off";
123316
123364
  }
123317
123365
  function addressWordsSentence(words) {
123318
123366
  return words.length === 0 ? "" : `Fold a different one of these words into each candidate address, picking the ones that best
@@ -123328,8 +123376,8 @@ ${opts?.buildAsk === true ? BUILD_ASK_ROUND_SENTENCE : ""}Write pairs first in t
123328
123376
  rest of the brief.
123329
123377
  ${addressWordsSentence(words)}</first-brief-round>`;
123330
123378
  }
123331
- function agentBuildAskEnabled(flag21) {
123332
- return flag21 === "on";
123379
+ function agentBuildAskEnabled(flag22) {
123380
+ return flag22 === "on";
123333
123381
  }
123334
123382
  function buildAskArmed(o) {
123335
123383
  return o.requested === true && agentBuildAskEnabled(o.flag) && o.briefArmed && o.nonInteractive !== true && o.byText !== true;
@@ -123363,8 +123411,8 @@ function mercuryPlannerFor(variant) {
123363
123411
  function mercuryFormatFor(variant) {
123364
123412
  return variant === "mercury-cards-fim-first-build" ? "cards-fim" : "cards";
123365
123413
  }
123366
- function mercuryFirstBuildMode(flag21) {
123367
- const v = flag21?.trim().toLowerCase();
123414
+ function mercuryFirstBuildMode(flag22) {
123415
+ const v = flag22?.trim().toLowerCase();
123368
123416
  if (v === "off") return "off";
123369
123417
  if (v === "cards") return "cards";
123370
123418
  return MERCURY_DEFAULT_SWITCH_MODE;
@@ -123379,19 +123427,19 @@ function mercuryVariantForTurn(o) {
123379
123427
  const mode = mercuryFirstBuildMode(o.flag);
123380
123428
  return mode === "off" ? void 0 : MERCURY_SWITCH_VARIANTS[mode];
123381
123429
  }
123382
- function firstLookEnabled(flag21) {
123383
- return flag21?.trim().toLowerCase() !== "off";
123430
+ function firstLookEnabled(flag22) {
123431
+ return flag22?.trim().toLowerCase() !== "off";
123384
123432
  }
123385
123433
  function firstLookArmed(o) {
123386
123434
  if (o.mercuryVariant === void 0) return false;
123387
123435
  const switchArm = Object.values(MERCURY_SWITCH_VARIANTS).includes(o.mercuryVariant);
123388
123436
  return switchArm && firstLookEnabled(o.flag);
123389
123437
  }
123390
- function firstLookRotateEnabled(flag21) {
123391
- return flag21?.trim().toLowerCase() !== "off";
123438
+ function firstLookRotateEnabled(flag22) {
123439
+ return flag22?.trim().toLowerCase() !== "off";
123392
123440
  }
123393
- function firstLookShellCount(flag21) {
123394
- return firstLookRotateEnabled(flag21) ? FIRST_LOOK_ROTATE_SHELLS : 1;
123441
+ function firstLookShellCount(flag22) {
123442
+ return firstLookRotateEnabled(flag22) ? FIRST_LOOK_ROTATE_SHELLS : 1;
123395
123443
  }
123396
123444
  function fastFirstTurnLevers(variant, firstTurn) {
123397
123445
  if (variant === void 0 || FAST_FIRST_TURN_LEVER_VARIANTS.includes(variant) === false || firstTurn === false) return void 0;
@@ -140786,8 +140834,8 @@ var init_deliver_post_turn_version = __esm({
140786
140834
  import { Result as Result248, exception2Result as exception2Result315, stream2uint8array as stream2uint8array15 } from "@adviser/cement";
140787
140835
  import { and as and158, desc as desc36, eq as eq185, isNotNull as isNotNull7 } from "drizzle-orm";
140788
140836
  import { type as type192 } from "arktype";
140789
- function designRepairEnabled(flag21) {
140790
- return flag21 !== "off";
140837
+ function designRepairEnabled(flag22) {
140838
+ return flag22 !== "off";
140791
140839
  }
140792
140840
  function findingLine2(f) {
140793
140841
  return `${f.file.replace(/^\/+/, "")}:${f.line} [${f.ruleId}] ${f.message}`;
@@ -141406,8 +141454,8 @@ var init_prompt_dispatch_context = __esm({
141406
141454
  // ../vibes.diy/api/svc/public/turn-summary-dispatch.ts
141407
141455
  import { exception2Result as exception2Result316 } from "@adviser/cement";
141408
141456
  import { and as and159, asc as asc17, eq as eq186, inArray as inArray48, ne as ne25 } from "drizzle-orm/sql/expressions";
141409
- function turnSummaryEnabled(flag21) {
141410
- return flag21 !== "off";
141457
+ function turnSummaryEnabled(flag22) {
141458
+ return flag22 !== "off";
141411
141459
  }
141412
141460
  function wantsTurnSummary(i) {
141413
141461
  return i.enabled && i.codegen && i.turnBegan && !i.errored && !i.agentDispatched && !i.byok;
@@ -142280,6 +142328,7 @@ async function runPromptTurn(ctx) {
142280
142328
  let agentReaction;
142281
142329
  const turnLatency = {};
142282
142330
  let agentFirstTurnMint = false;
142331
+ let hasPriorTurn = false;
142283
142332
  const facts = { toolsOffered: [], errored: false };
142284
142333
  if (isReqCreationPromptChatSection(orig)) {
142285
142334
  const rRoute = await routeCodegenTurn(vctx, {
@@ -142292,6 +142341,7 @@ async function runPromptTurn(ctx) {
142292
142341
  if (rRoute.isErr()) return Result251.Err(rRoute);
142293
142342
  const route = rRoute.Ok();
142294
142343
  agentFirstTurnMint = route.agentFirstTurnMint;
142344
+ hasPriorTurn = route.hasPriorTurn;
142295
142345
  if (route.agentRoute.route === "agent") {
142296
142346
  const rAgent = await assembleAgentTurn({
142297
142347
  ctx,
@@ -142440,6 +142490,16 @@ async function runPromptTurn(ctx) {
142440
142490
  });
142441
142491
  }
142442
142492
  }
142493
+ if (isReqCreationPromptChatSection(orig) && orig.dryRun !== true && agentDispatchedBuild !== true && envelope.agentWakeTurn !== true) {
142494
+ capturePromptTurnStarted(vctx, {
142495
+ userId: req2._auth.verifiedAuth.claims.userId,
142496
+ lane: agentAssembled === void 0 ? "codegen" : "agent",
142497
+ topLevel: isAgentChatAppSlug(resChat.appSlug),
142498
+ followUp: hasPriorTurn,
142499
+ byText: envelope.byText,
142500
+ ..."clientMessageId" in orig && typeof orig.clientMessageId === "string" ? { submitId: orig.clientMessageId } : {}
142501
+ });
142502
+ }
142443
142503
  if (agentDispatchedBuild) {
142444
142504
  vctx.logger.Info().Str("chatId", req2.chatId).Str("promptId", promptId).Str("ownerHandle", resChat.ownerHandle).Str("appSlug", resChat.appSlug).Msg("agent-dispatched-turn-started");
142445
142505
  }
@@ -142545,6 +142605,7 @@ var init_prompt_chat_section = __esm({
142545
142605
  init_caller_model();
142546
142606
  init_prompt_turn_terminal();
142547
142607
  init_prompt_turn_settled();
142608
+ init_analytics();
142548
142609
  init_llm_dispatch();
142549
142610
  promptChatSection = {
142550
142611
  hash: "prompt-chat-section-handler",
@@ -146396,7 +146457,7 @@ var init_report_vibe = __esm({
146396
146457
  // ../vibes.diy/api/svc/public/moderation-admin.ts
146397
146458
  import { Result as Result279, Option as Option76, EventoResult as EventoResult70 } from "@adviser/cement";
146398
146459
  import { type as type221 } from "arktype";
146399
- import { and as and171, count as count5, desc as desc41, eq as eq201, inArray as inArray51 } from "drizzle-orm";
146460
+ import { and as and171, count as count5, desc as desc41, eq as eq201, gte as gte8, inArray as inArray51, notInArray as notInArray9 } from "drizzle-orm";
146400
146461
  function toReportRow(r) {
146401
146462
  return {
146402
146463
  reportId: r.reportId,
@@ -146546,10 +146607,23 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
146546
146607
  }
146547
146608
  case "list-flags": {
146548
146609
  const flags = vctx.sql.tables.autoModerationFlags;
146610
+ if (req2.summary === true) {
146611
+ const since = req2.since ?? new Date(now3.getTime() - FLAG_SUMMARY_DEFAULT_MS).toISOString();
146612
+ if (Number.isNaN(Date.parse(since))) return Result279.Err("moderation: --since is an ISO 8601 time");
146613
+ const counted = await vctx.sql.db.select({ status: flags.status, category: flags.category, inputKind: flags.inputKind, n: count5() }).from(flags).where(gte8(flags.created, new Date(since).toISOString())).groupBy(flags.status, flags.category, flags.inputKind);
146614
+ const rows2 = counted.map((r) => ({ status: r.status, category: r.category, inputKind: r.inputKind, n: Number(r.n) })).sort(
146615
+ (a, b) => b.n - a.n || `${a.status} ${a.category} ${a.inputKind}`.localeCompare(`${b.status} ${b.category} ${b.inputKind}`)
146616
+ );
146617
+ return Result279.Ok({
146618
+ type: "vibes.diy.res-moderation-admin",
146619
+ op: req2.op,
146620
+ flagSummary: { since: new Date(since).toISOString(), total: rows2.reduce((s, r) => s + r.n, 0), rows: rows2 }
146621
+ });
146622
+ }
146549
146623
  const status = req2.flagStatus ?? "open";
146550
146624
  const limit = Math.max(1, Math.min(MAX_LIST_LIMIT, Math.floor(req2.limit ?? DEFAULT_LIST_LIMIT)));
146551
146625
  const base = vctx.sql.db.select().from(flags);
146552
- const rows = await (status === "all" ? base : base.where(eq201(flags.status, status))).orderBy(desc41(flags.created)).limit(limit);
146626
+ const rows = await (status === "all" ? base.where(notInArray9(flags.status, [...AUTO_FLAG_RECORD_STATUSES])) : base.where(eq201(flags.status, status))).orderBy(desc41(flags.created)).limit(limit);
146553
146627
  const out = [];
146554
146628
  for (const r of rows) {
146555
146629
  const text3 = r.inputKind === "prompt" && r.chatId && r.promptId ? await readFlaggedPrompt(vctx, r.chatId, r.promptId) : void 0;
@@ -146563,6 +146637,12 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
146563
146637
  const flags = vctx.sql.tables.autoModerationFlags;
146564
146638
  const existing = await vctx.sql.db.select().from(flags).where(eq201(flags.flagId, req2.flagId)).limit(1).then((r) => r[0]);
146565
146639
  if (existing === void 0) return Result279.Err(`moderation: no flag ${req2.flagId}`);
146640
+ if (existing.status === AUTO_FLAG_ALLOWED_STATUS) {
146641
+ return Result279.Err(`moderation: ${req2.flagId} records an allow, not a flag; there is nothing to triage`);
146642
+ }
146643
+ if (existing.status === AUTO_FLAG_ERROR_STATUS) {
146644
+ return Result279.Err(`moderation: ${req2.flagId} records a check no model answered, not a flag; there is nothing to triage`);
146645
+ }
146566
146646
  const escalating = req2.triage === "escalated" && existing.status !== "escalated";
146567
146647
  const set = {
146568
146648
  status: req2.triage,
@@ -146609,7 +146689,7 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
146609
146689
  }
146610
146690
  }
146611
146691
  }
146612
- var DEFAULT_LIST_LIMIT, MAX_LIST_LIMIT, moderationAdminEvento;
146692
+ var FLAG_SUMMARY_DEFAULT_MS, DEFAULT_LIST_LIMIT, MAX_LIST_LIMIT, moderationAdminEvento;
146613
146693
  var init_moderation_admin = __esm({
146614
146694
  "../vibes.diy/api/svc/public/moderation-admin.ts"() {
146615
146695
  "use strict";
@@ -146622,6 +146702,7 @@ var init_moderation_admin = __esm({
146622
146702
  init_platform_admin();
146623
146703
  init_auto_moderation();
146624
146704
  init_post_maker_fact();
146705
+ FLAG_SUMMARY_DEFAULT_MS = 24 * 60 * 60 * 1e3;
146625
146706
  DEFAULT_LIST_LIMIT = 50;
146626
146707
  MAX_LIST_LIMIT = 500;
146627
146708
  __name(toReportRow, "toReportRow");
@@ -149926,8 +150007,8 @@ var init_social_invite_flow = __esm({
149926
150007
  // ../vibes.diy/api/svc/intern/invite-note-check.ts
149927
150008
  import { exception2Result as exception2Result338, Result as Result303 } from "@adviser/cement";
149928
150009
  import { type as type238 } from "arktype";
149929
- function inviteNoteCheckEnabled(flag21) {
149930
- return flag21 !== "off";
150010
+ function inviteNoteCheckEnabled(flag22) {
150011
+ return flag22 !== "off";
149931
150012
  }
149932
150013
  function inviteNoteCheckMessages(note) {
149933
150014
  return [
@@ -152377,7 +152458,7 @@ var init_report_growth_vibes_with_data = __esm({
152377
152458
  // ../vibes.diy/api/svc/public/report-active-members.ts
152378
152459
  import { Result as Result325, Option as Option117, EventoResult as EventoResult114 } from "@adviser/cement";
152379
152460
  import { type as type247 } from "arktype";
152380
- import { gte as gte8 } from "drizzle-orm";
152461
+ import { gte as gte9 } from "drizzle-orm";
152381
152462
  async function computeActiveMembers(vctx) {
152382
152463
  const t = vctx.sql.tables;
152383
152464
  const participantRows = await vctx.sql.db.selectDistinct({
@@ -152397,7 +152478,7 @@ async function computeActiveMembers(vctx) {
152397
152478
  ownerHandle: t.appDocuments.ownerHandle,
152398
152479
  appSlug: t.appDocuments.appSlug,
152399
152480
  created: t.appDocuments.created
152400
- }).from(t.appDocuments).where(gte8(t.appDocuments.created, since));
152481
+ }).from(t.appDocuments).where(gte9(t.appDocuments.created, since));
152401
152482
  const dayBuckets = /* @__PURE__ */ new Map();
152402
152483
  for (const w of writes) {
152403
152484
  if (w.userId === "unknown") continue;
@@ -152971,18 +153052,18 @@ var init_report_top_vibes_by_traffic = __esm({
152971
153052
  // ../vibes.diy/api/svc/public/report-attribution-referrers.ts
152972
153053
  import { Result as Result329, Option as Option120, EventoResult as EventoResult117 } from "@adviser/cement";
152973
153054
  import { type as type250 } from "arktype";
152974
- import { sql as sql35, desc as desc47, eq as eq227, notInArray as notInArray9, and as and194, like as like8, notLike as notLike3, not as not4, gte as gte9 } from "drizzle-orm";
153055
+ import { sql as sql35, desc as desc47, eq as eq227, notInArray as notInArray10, and as and194, like as like8, notLike as notLike3, not as not4, gte as gte10 } from "drizzle-orm";
152975
153056
  function legacyVibePath(reqPath) {
152976
153057
  return and194(like8(reqPath, "/vibe/_%"), notLike3(reqPath, "/vibe/%/%"));
152977
153058
  }
152978
153059
  function windowStartFilter(tsColumn, window2) {
152979
153060
  if (window2 !== "7d") return void 0;
152980
153061
  const cutoffMs = Date.now() - 7 * 24 * 60 * 60 * 1e3;
152981
- return gte9(tsColumn, new Date(cutoffMs).toISOString());
153062
+ return gte10(tsColumn, new Date(cutoffMs).toISOString());
152982
153063
  }
152983
153064
  async function computeAttributionReferrers(vctx, reqPathFilter, window2 = "all") {
152984
153065
  const t = vctx.sql.tables;
152985
- const ownedFilter = notInArray9(t.refererEvents.refHost, OWNED_HOSTS);
153066
+ const ownedFilter = notInArray10(t.refererEvents.refHost, OWNED_HOSTS);
152986
153067
  const notLegacyVibeFilter = not4(legacyVibePath(t.refererEvents.reqPath));
152987
153068
  const windowFilter = windowStartFilter(t.refererEvents.ts, window2);
152988
153069
  const baseQuery = vctx.sql.db.select({
@@ -153069,7 +153150,7 @@ var init_report_attribution_referrers = __esm({
153069
153150
  // ../vibes.diy/api/svc/public/report-api-traffic.ts
153070
153151
  import { Result as Result330, Option as Option121, EventoResult as EventoResult118 } from "@adviser/cement";
153071
153152
  import { type as type251 } from "arktype";
153072
- import { sql as sql36, asc as asc20, desc as desc48, eq as eq228, and as and195, gte as gte10 } from "drizzle-orm";
153153
+ import { sql as sql36, asc as asc20, desc as desc48, eq as eq228, and as and195, gte as gte11 } from "drizzle-orm";
153073
153154
  function percentile(sortedAsc, p) {
153074
153155
  if (sortedAsc.length === 0) return 0;
153075
153156
  const rank = Math.ceil(p / 100 * sortedAsc.length);
@@ -153145,7 +153226,7 @@ function aggregateApiTraffic(rows) {
153145
153226
  async function computeApiTraffic(vctx, hostFilter) {
153146
153227
  const t = vctx.sql.tables;
153147
153228
  const cutoff = new Date(Date.now() - WINDOW_DAYS2 * 24 * 60 * 60 * 1e3).toISOString();
153148
- const windowFilter = gte10(t.apiRequestEvents.ts, cutoff);
153229
+ const windowFilter = gte11(t.apiRequestEvents.ts, cutoff);
153149
153230
  const where = hostFilter !== void 0 ? and195(windowFilter, eq228(t.apiRequestEvents.host, hostFilter)) : windowFilter;
153150
153231
  const dayExpr = sql36`substr(${t.apiRequestEvents.ts}, 1, 10)`;
153151
153232
  const perDay = await vctx.sql.db.select({
@@ -153222,7 +153303,7 @@ var init_report_api_traffic = __esm({
153222
153303
  // ../vibes.diy/api/svc/public/report-egress.ts
153223
153304
  import { Result as Result331, Option as Option122, EventoResult as EventoResult119 } from "@adviser/cement";
153224
153305
  import { type as type252 } from "arktype";
153225
- import { sql as sql37, asc as asc21, desc as desc49, eq as eq229, and as and196, or as or24, gte as gte11 } from "drizzle-orm";
153306
+ import { sql as sql37, asc as asc21, desc as desc49, eq as eq229, and as and196, or as or24, gte as gte12 } from "drizzle-orm";
153226
153307
  function aggregateEgress(rows) {
153227
153308
  const hosts = /* @__PURE__ */ new Map();
153228
153309
  const vibes = /* @__PURE__ */ new Map();
@@ -153290,7 +153371,7 @@ function aggregateEgress(rows) {
153290
153371
  async function computeEgress(vctx, hostFilter) {
153291
153372
  const t = vctx.sql.tables;
153292
153373
  const cutoff = new Date(Date.now() - WINDOW_DAYS3 * 24 * 60 * 60 * 1e3).toISOString();
153293
- const windowFilter = gte11(t.egressEvents.ts, cutoff);
153374
+ const windowFilter = gte12(t.egressEvents.ts, cutoff);
153294
153375
  const where = hostFilter !== void 0 ? and196(windowFilter, or24(eq229(t.egressEvents.host, hostFilter), eq229(t.egressEvents.finalHost, hostFilter))) : windowFilter;
153295
153376
  const sample = await vctx.sql.db.select({
153296
153377
  host: t.egressEvents.host,
@@ -153303,7 +153384,7 @@ async function computeEgress(vctx, hostFilter) {
153303
153384
  cached: t.egressEvents.cached,
153304
153385
  ts: t.egressEvents.ts
153305
153386
  }).from(t.egressEvents).where(where).orderBy(desc49(t.egressEvents.ts)).limit(SAMPLE_ROW_CAP2);
153306
- const suspectWindow = gte11(t.egressSuspectEvents.ts, cutoff);
153387
+ const suspectWindow = gte12(t.egressSuspectEvents.ts, cutoff);
153307
153388
  const suspectWhere = hostFilter !== void 0 ? and196(suspectWindow, eq229(t.egressSuspectEvents.host, hostFilter)) : suspectWindow;
153308
153389
  const suspects = await vctx.sql.db.select({
153309
153390
  host: t.egressSuspectEvents.host,
@@ -153377,7 +153458,7 @@ var init_report_egress = __esm({
153377
153458
  // ../vibes.diy/api/svc/public/report-prompt-cache.ts
153378
153459
  import { Result as Result332, Option as Option123, EventoResult as EventoResult120, exception2Result as exception2Result345 } from "@adviser/cement";
153379
153460
  import { type as type253 } from "arktype";
153380
- import { asc as asc22, eq as eq230, gte as gte12 } from "drizzle-orm";
153461
+ import { asc as asc22, eq as eq230, gte as gte13 } from "drizzle-orm";
153381
153462
  function summarizeUsageGiven(ref) {
153382
153463
  const num4 = /* @__PURE__ */ __name((v) => {
153383
153464
  if (typeof v === "number") return Number.isFinite(v) ? v : void 0;
@@ -153534,7 +153615,7 @@ async function computePromptCache(vctx) {
153534
153615
  chatId: t.promptContexts.chatId,
153535
153616
  created: t.promptContexts.created,
153536
153617
  ref: t.promptContexts.ref
153537
- }).from(t.promptContexts).where(gte12(t.promptContexts.created, cutoff)).orderBy(asc22(t.promptContexts.created)).limit(SAMPLE_ROW_CAP3);
153618
+ }).from(t.promptContexts).where(gte13(t.promptContexts.created, cutoff)).orderBy(asc22(t.promptContexts.created)).limit(SAMPLE_ROW_CAP3);
153538
153619
  const usage = raw.map((row) => {
153539
153620
  const ref = row.ref;
153540
153621
  return {
@@ -154385,7 +154466,7 @@ var init_campaign_health_readout_source = __esm({
154385
154466
  // ../vibes.diy/api/svc/public/report-campaign-health.ts
154386
154467
  import { Result as Result334, Option as Option124, EventoResult as EventoResult121, exception2Result as exception2Result347 } from "@adviser/cement";
154387
154468
  import { type as type254 } from "arktype";
154388
- import { and as and197, eq as eq231, gte as gte13, lte as lte8 } from "drizzle-orm";
154469
+ import { and as and197, eq as eq231, gte as gte14, lte as lte8 } from "drizzle-orm";
154389
154470
  async function metaGet(path2, token) {
154390
154471
  return metaGraphGet((input, init) => fetch(input, init), path2, token);
154391
154472
  }
@@ -154410,7 +154491,7 @@ function goodVibesLandingPath(websiteUrl) {
154410
154491
  async function fetchGoodVibesClickThroughs(vctx, sinceIso, untilIso) {
154411
154492
  const t = vctx.sql.tables;
154412
154493
  const rows = await vctx.sql.db.select({ refPath: t.refererEvents.refPath, refHref: t.refererEvents.refHref }).from(t.refererEvents).where(
154413
- and197(eq231(t.refererEvents.refHost, "good.vibes.diy"), gte13(t.refererEvents.ts, sinceIso), lte8(t.refererEvents.ts, untilIso))
154494
+ and197(eq231(t.refererEvents.refHost, "good.vibes.diy"), gte14(t.refererEvents.ts, sinceIso), lte8(t.refererEvents.ts, untilIso))
154414
154495
  );
154415
154496
  const byPath = /* @__PURE__ */ Object.create(null);
154416
154497
  const byCampaignId = /* @__PURE__ */ Object.create(null);
@@ -154429,7 +154510,7 @@ async function fetchGoodVibesClickThroughs(vctx, sinceIso, untilIso) {
154429
154510
  }
154430
154511
  async function fetchDirectAppLandings(vctx, sinceIso, untilIso) {
154431
154512
  const t = vctx.sql.tables;
154432
- const rows = await vctx.sql.db.select({ fbclid: t.landingEvents.fbclid, utmCampaign: t.landingEvents.utmCampaign }).from(t.landingEvents).where(and197(gte13(t.landingEvents.ts, sinceIso), lte8(t.landingEvents.ts, untilIso)));
154513
+ const rows = await vctx.sql.db.select({ fbclid: t.landingEvents.fbclid, utmCampaign: t.landingEvents.utmCampaign }).from(t.landingEvents).where(and197(gte14(t.landingEvents.ts, sinceIso), lte8(t.landingEvents.ts, untilIso)));
154433
154514
  const byUtmCampaign = /* @__PURE__ */ Object.create(null);
154434
154515
  for (const r of rows) {
154435
154516
  if (r.fbclid === "" || r.utmCampaign === "") continue;
@@ -154943,10 +155024,10 @@ var init_prompt_turn_sql = __esm({
154943
155024
  // ../vibes.diy/api/svc/public/report-activity.ts
154944
155025
  import { Result as Result338, Option as Option126, EventoResult as EventoResult123 } from "@adviser/cement";
154945
155026
  import { type as type257 } from "arktype";
154946
- import { and as and198, gte as gte14, inArray as inArray61, lt as lt19, max as max13, min, sql as sql38 } from "drizzle-orm";
155027
+ import { and as and198, gte as gte15, inArray as inArray61, lt as lt19, max as max13, min, sql as sql38 } from "drizzle-orm";
154947
155028
  function turnFilter(vctx) {
154948
155029
  const t = vctx.sql.tables;
154949
- return and198(gte14(t.promptContexts.totalTokens, MIN_TURN_TOKENS), sql38.raw(promptBuildTurnSql(vctx.sql.flavour)));
155030
+ return and198(gte15(t.promptContexts.totalTokens, MIN_TURN_TOKENS), sql38.raw(promptBuildTurnSql(vctx.sql.flavour)));
154950
155031
  }
154951
155032
  function bucketFor(days, day, owner, appSlug) {
154952
155033
  let owners = days.get(day);
@@ -155015,17 +155096,17 @@ async function computeActivity(vctx, days) {
155015
155096
  ownerHandle: t.apps.ownerHandle,
155016
155097
  appSlug: t.apps.appSlug,
155017
155098
  created: t.apps.created
155018
- }).from(t.apps).where(and198(gte14(t.apps.created, since), lt19(t.apps.created, until))),
155099
+ }).from(t.apps).where(and198(gte15(t.apps.created, since), lt19(t.apps.created, until))),
155019
155100
  vctx.sql.db.select({
155020
155101
  ownerHandle: t.appDocuments.ownerHandle,
155021
155102
  appSlug: t.appDocuments.appSlug,
155022
155103
  userId: t.appDocuments.userId,
155023
155104
  created: t.appDocuments.created
155024
- }).from(t.appDocuments).where(and198(gte14(t.appDocuments.created, since), lt19(t.appDocuments.created, until))),
155105
+ }).from(t.appDocuments).where(and198(gte15(t.appDocuments.created, since), lt19(t.appDocuments.created, until))),
155025
155106
  // A UserSettings row is created at the account's first sign-in to vibes.diy.
155026
- vctx.sql.db.select({ userId: t.userSettings.userId, created: t.userSettings.created }).from(t.userSettings).where(and198(gte14(t.userSettings.created, since), lt19(t.userSettings.created, until))),
155027
- vctx.sql.db.select({ userId: t.handleBinding.userId, handle: t.handleBinding.handle, created: t.handleBinding.created }).from(t.handleBinding).where(and198(gte14(t.handleBinding.created, since), lt19(t.handleBinding.created, until))),
155028
- vctx.sql.db.select({ userId: t.promptContexts.userId, created: t.promptContexts.created }).from(t.promptContexts).where(and198(gte14(t.promptContexts.created, since), lt19(t.promptContexts.created, until), turnFilter(vctx))),
155107
+ vctx.sql.db.select({ userId: t.userSettings.userId, created: t.userSettings.created }).from(t.userSettings).where(and198(gte15(t.userSettings.created, since), lt19(t.userSettings.created, until))),
155108
+ vctx.sql.db.select({ userId: t.handleBinding.userId, handle: t.handleBinding.handle, created: t.handleBinding.created }).from(t.handleBinding).where(and198(gte15(t.handleBinding.created, since), lt19(t.handleBinding.created, until))),
155109
+ vctx.sql.db.select({ userId: t.promptContexts.userId, created: t.promptContexts.created }).from(t.promptContexts).where(and198(gte15(t.promptContexts.created, since), lt19(t.promptContexts.created, until), turnFilter(vctx))),
155029
155110
  // Anything older? One row from ANY source the report reads decides whether
155030
155111
  // the client may scroll further — a stretch of signups and chats with no
155031
155112
  // release must not read as the beginning. (AppDocuments needs no probe: a
@@ -155887,7 +155968,7 @@ var init_curate_approve = __esm({
155887
155968
  import { Result as Result344, Option as Option131, EventoResult as EventoResult128 } from "@adviser/cement";
155888
155969
  import { type as type263 } from "arktype";
155889
155970
  import { cosineDistance as cosineDistance2, sql as sql40 } from "drizzle-orm";
155890
- import { and as and203, asc as asc25, desc as desc53, eq as eq236, notInArray as notInArray10, notLike as notLike4, or as or25 } from "drizzle-orm/sql/expressions";
155971
+ import { and as and203, asc as asc25, desc as desc53, eq as eq236, notInArray as notInArray11, notLike as notLike4, or as or25 } from "drizzle-orm/sql/expressions";
155891
155972
  async function computeRelatedVibes(vctx, { ownerHandle, appSlug, isOwner }) {
155892
155973
  const docs = vctx.sql.tables.appDocuments;
155893
155974
  const asb = vctx.sql.tables.appSlugBinding;
@@ -155983,7 +156064,7 @@ async function computeRelatedVibes(vctx, { ownerHandle, appSlug, isOwner }) {
155983
156064
  // The test-handle drop runs in the query, ahead of the over-fetch
155984
156065
  // window: eval near-copies of a real app would otherwise fill the
155985
156066
  // window and crowd every real neighbor out.
155986
- hiddenElsewhere.length > 0 ? notInArray10(emb.ownerHandle, hiddenElsewhere) : void 0,
156067
+ hiddenElsewhere.length > 0 ? notInArray11(emb.ownerHandle, hiddenElsewhere) : void 0,
155987
156068
  notFamily("qa-"),
155988
156069
  notFamily("eval-")
155989
156070
  )
@@ -167337,7 +167418,7 @@ var init_retention = __esm({
167337
167418
  });
167338
167419
 
167339
167420
  // cli/cmds/moderation/index.ts
167340
- import { command as command47, option as option38, string as string42, subcommands as subcommands12 } from "cmd-ts";
167421
+ import { command as command47, flag as flag20, option as option38, string as string42, subcommands as subcommands12 } from "cmd-ts";
167341
167422
  import { Result as Result442, Option as Option187 } from "@adviser/cement";
167342
167423
  import { type as type328 } from "arktype";
167343
167424
  var ReqModerationCli, ResModerationCli;
@@ -167360,7 +167441,9 @@ var init_moderation2 = __esm({
167360
167441
  status: "string",
167361
167442
  limit: "string",
167362
167443
  "flagId?": "string",
167363
- "triage?": "string"
167444
+ "triage?": "string",
167445
+ "summary?": "boolean",
167446
+ "since?": "string"
167364
167447
  });
167365
167448
  ResModerationCli = type328({
167366
167449
  type: "'vibes-diy.cli.res-moderation'",
@@ -167436,7 +167519,7 @@ var init_phone_link_classify_cmd = __esm({
167436
167519
  });
167437
167520
 
167438
167521
  // cli/cmds/phone-link-cmd.ts
167439
- import { command as command50, flag as flag20, option as option41, string as string45, subcommands as subcommands13 } from "cmd-ts";
167522
+ import { command as command50, flag as flag21, option as option41, string as string45, subcommands as subcommands13 } from "cmd-ts";
167440
167523
  import { Result as Result445, Option as Option190 } from "@adviser/cement";
167441
167524
  import { type as type331 } from "arktype";
167442
167525
  var ReqPhoneLinkRedeemCli, ResPhoneLinkRedeemCli, ReqPhoneLinkGroupCli, ResPhoneLinkGroupCli, ReqPhoneLinkPayForGroupCli, ResPhoneLinkPayForGroupCli, ReqPhoneLinkGroupRosterCli, ResPhoneLinkGroupRosterCli, ReqPhoneLinkStopSponsoringCli, sponsoredChatCli, ResPhoneLinkStopSponsoringCli, ReqPhoneLinkAlertsCli, ResPhoneLinkAlertsCli, ReqPhoneLinkWakesCli, ResPhoneLinkWakesCli, ReqPhoneLinkVibesCli, ResPhoneLinkVibesCli, ReqPhoneLinkPauseVibeCli, ResPhoneLinkPauseVibeCli;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibes-diy",
3
- "version": "14.3.328",
3
+ "version": "14.3.330",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "description": "Command-line tool for vibes.diy — generate, edit, pull, push, and publish AI-built apps",
@@ -41,13 +41,13 @@
41
41
  "@neondatabase/serverless": "~1.2.0",
42
42
  "@noble/hashes": "~2.4.0",
43
43
  "@shadcn/lint": "~0.2.3",
44
- "@vibes.diy/api-impl": "14.3.328",
45
- "@vibes.diy/api-types": "14.3.328",
46
- "@vibes.diy/call-ai-v2": "14.3.328",
47
- "@vibes.diy/cmd-harness": "14.3.328",
48
- "@vibes.diy/cmd-tools": "14.3.328",
49
- "@vibes.diy/identity": "14.3.328",
50
- "@vibes.diy/prompts": "14.3.328",
44
+ "@vibes.diy/api-impl": "14.3.330",
45
+ "@vibes.diy/api-types": "14.3.330",
46
+ "@vibes.diy/call-ai-v2": "14.3.330",
47
+ "@vibes.diy/cmd-harness": "14.3.330",
48
+ "@vibes.diy/cmd-tools": "14.3.330",
49
+ "@vibes.diy/identity": "14.3.330",
50
+ "@vibes.diy/prompts": "14.3.330",
51
51
  "acorn": "~8.19.0",
52
52
  "acorn-jsx": "~5.3.2",
53
53
  "arktype": "~2.2.9",