@domino-sdk/relay 1.0.0-next.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/dist/activity-DeKJsRry.d.ts +9112 -0
  3. package/dist/authoring.d.ts +1135 -285
  4. package/dist/authoring.js +545 -269
  5. package/dist/automatic-outcomes-B1xrETxm.d.ts +758 -0
  6. package/dist/avatar.d.ts +2 -2
  7. package/dist/browser-DFe7sWSN.d.ts +4154 -0
  8. package/dist/browser.d.ts +11 -2528
  9. package/dist/browser.js +8 -6
  10. package/dist/capability-error-DNMwKmlL.d.ts +458 -0
  11. package/dist/{chunk-V7EZUZ3Z.js → chunk-36HTX2BM.js} +389 -169
  12. package/dist/chunk-6QJ3LADK.js +112 -0
  13. package/dist/{chunk-77H7APVD.js → chunk-BGGKNIRP.js} +1 -1
  14. package/dist/chunk-EYH5RDIE.js +496 -0
  15. package/dist/chunk-GQKYAQM6.js +84 -0
  16. package/dist/chunk-GUP7YRR4.js +42 -0
  17. package/dist/{chunk-V5R2DMGY.js → chunk-GZ6FJAXN.js} +380 -128
  18. package/dist/chunk-JON5SESL.js +2986 -0
  19. package/dist/chunk-MC6V6VMG.js +49 -0
  20. package/dist/chunk-NPGENI7K.js +37 -0
  21. package/dist/chunk-VFHHLN6A.js +284 -0
  22. package/dist/chunk-WJSSJ7AF.js +151 -0
  23. package/dist/{chunk-QBOHLT7M.js → chunk-XFMSUPNS.js} +1 -1
  24. package/dist/{chunk-6A6K5RUD.js → chunk-ZVIRG24J.js} +145 -42
  25. package/dist/{client-CK4nwt7V.d.ts → client-XiuFnug_.d.ts} +2193 -562
  26. package/dist/{submission-input-C9qm9ixd.d.ts → groups-Ck-OxzjD.d.ts} +919 -1142
  27. package/dist/identity-integration-GxAHdKR2.d.ts +58 -0
  28. package/dist/{images--vZ9U0kr.d.ts → images-Dv-P5VBw.d.ts} +2 -2
  29. package/dist/index.d.ts +13 -9
  30. package/dist/index.js +17 -6
  31. package/dist/internal.d.ts +82 -43
  32. package/dist/internal.js +58 -90
  33. package/dist/offers-Cy-e4o5x.d.ts +431 -0
  34. package/dist/{pages-BzqJuI69.d.ts → outcomes-kVB-Juzs.d.ts} +2386 -1490
  35. package/dist/pages-BBYD21IE.d.ts +359 -0
  36. package/dist/participant-rewards-3duLb8YJ.d.ts +668 -0
  37. package/dist/portal-proxy.js +22 -4
  38. package/dist/{profiles-DDMFBRKe.d.ts → profiles-D2aFcOxu.d.ts} +15 -15
  39. package/dist/react/index.d.ts +3122 -1011
  40. package/dist/react/index.js +1627 -779
  41. package/dist/request-error-DWduJCGV.d.ts +62 -0
  42. package/dist/schema-DfJzH2ci.d.ts +5644 -0
  43. package/dist/schema.d.ts +15 -4216
  44. package/dist/schema.js +322 -81
  45. package/dist/server/index.d.ts +81498 -0
  46. package/dist/server/index.js +2520 -0
  47. package/dist/{streaks-CwGReWGt.d.ts → streaks-CWyq8Px5.d.ts} +2 -4
  48. package/dist/submission-input-BZkm6ohU.d.ts +290 -0
  49. package/dist/vite.d.ts +1 -1
  50. package/dist/vite.js +1 -0
  51. package/dist/{wallet-BGOfFkG9.d.ts → wallet-YssWxGg8.d.ts} +35 -38
  52. package/package.json +8 -2
  53. package/dist/chunk-MRIURJE3.js +0 -257
  54. package/dist/chunk-VARGF4JS.js +0 -1733
  55. package/dist/chunk-ZWY3R6B3.js +0 -26
  56. package/dist/collection-BGneJ6Bk.d.ts +0 -114
  57. package/dist/integrations-C3Sp558f.d.ts +0 -1297
  58. package/dist/point-ledgers-iS00Z_v0.d.ts +0 -37
  59. package/dist/schema-pnuWqvGn.d.ts +0 -3396
@@ -1,55 +1,34 @@
1
+ import { cB as xContentBodySchema, I as IdentityKind, aM as customSourceSchema, at as WithRecordData, as as WithContent, ar as WithAccountRoles, cG as QuestHandle, cH as LedgerReference, cI as GroupHandle, cF as ResourceHandle, ad as TrackerSource, c1 as trackerDefinitionSchema, U as Tracker, $ as TrackerData, H as SourceRoles, cJ as LedgerHandle, cD as xSearchSourceSchema, av as XTweet, au as XContentMetric, aj as TrackerTriggerPolicy, ap as Where, r as MemberIdentity, ah as TrackerTriggerContext, ab as TrackerReader, L as TextReviewInput, J as TextResult, P as PhotoResult, n as Decision, by as rewardSchema, ai as TrackerTriggerMode, F as RoleOf, aq as WhereSetting, k as ContentBody, l as ContentMetricName, cw as triggerSchema, d as QuestPresentation, e as QuestProfile, f as QuizEvidence, N as TieredRewardDefinition } from './schema-DfJzH2ci.js';
2
+ export { cK as LedgerSetting, a1 as TrackerDataSchema, a6 as TrackerPage, aa as TrackerReadQuery, cL as trackerDataSchema, cn as trackerTriggerContextSchema } from './schema-DfJzH2ci.js';
1
3
  import { z } from 'zod';
2
- import { C as ContentPolicy, g as ContentMetric, E as EngagementDefinition, l as leaderboardAuthoringSchema, r as referralAuthoringSchema, h as AdmittedContent, D as DiscordMember, T as TextEvidence, U as UrlEvidence, e as TextOptions, f as UrlOptions } from './submission-input-C9qm9ixd.js';
3
- import { Q as QuizContent, a as StreakPolicy } from './streaks-CwGReWGt.js';
4
- import { T as TrackerDefinition, I as IdentityKind, t as trackerDefinitionSchema, R as ResourceSource, O as Observation, a as TrackerTriggerContext, b as TrackerReader, X as XReader, D as DiscordMessage, c as TrackerTriggerMode, d as TrackerWhere, o as observationTriggerSchema, e as TrackerTriggerPolicy, B as Budget, f as IntegrationProvider } from './integrations-C3Sp558f.js';
5
- export { g as trackerTriggerContextSchema } from './integrations-C3Sp558f.js';
6
- import { I as ImageReader } from './images--vZ9U0kr.js';
7
- import { d as TextReviewInput, e as TextResult, P as PhotoResult, r as rewardSchema, t as triggerSchema, Q as QuestPresentation, a as QuestProfile, b as QuizEvidence, D as Decision, f as TieredRewardDefinition } from './schema-pnuWqvGn.js';
8
- import { h as WalletConnection, S as SolanaBalance, L as LinkedWallet, i as WalletBalanceQuery, j as WalletBalance } from './wallet-BGOfFkG9.js';
9
- export { E as EvmChainId, k as isEvmChainId } from './wallet-BGOfFkG9.js';
4
+ export { z } from 'zod';
5
+ import { E as EngagementBudget, a4 as leaderboardDefinitionSchema, aQ as AuthoringIdentity, au as pointLedgerDeclarationSchema, aJ as referralAuthoringSchema, C as CampaignDefinition, A as AvailabilityWindow } from './groups-Ck-OxzjD.js';
6
+ export { G as defineCampaign, H as defineGroup } from './groups-Ck-OxzjD.js';
7
+ import { u as discordMessagesSourceSchema, e as DiscordMessageData, f as DiscordMessageTextData, w as discordReactionsSourceSchema, g as DiscordReactionData, h as DiscordReader, P as Prerequisite, T as TextEvidence, U as UrlEvidence, b as TextOptions, c as UrlOptions } from './submission-input-BZkm6ohU.js';
8
+ export { k as balanceAtLeast, m as completed, B as inGroup } from './submission-input-BZkm6ohU.js';
9
+ import { Q as QuizContent, a as StreakPolicy } from './streaks-CWyq8Px5.js';
10
+ import { d as ResourceSource, S as Setting, b as IntegrationModule, i as XReader, B as Budget, I as IntegerSettings } from './capability-error-DNMwKmlL.js';
11
+ export { L as CapabilityError, C as CapabilityErrorCode, k as capabilityErrorCodes } from './capability-error-DNMwKmlL.js';
12
+ import { e as ImageReader } from './images-Dv-P5VBw.js';
13
+ export { e as defineOffer } from './offers-Cy-e4o5x.js';
14
+ import { l as WalletReader } from './wallet-YssWxGg8.js';
15
+ export { h as CosmosDenom, a as CosmosNetwork, E as EvmChainId, j as WalletBalance, k as WalletBalanceQuery, p as cosmosDenomSchema, q as cosmosNetworkSchema, t as isEvmChainId } from './wallet-YssWxGg8.js';
10
16
  export { f as formatUnits, p as parseUnits } from './units-CwgsPB_r.js';
11
17
 
12
- /** Legacy `id` names an authoring key, never a server resource ID. */
13
- type AuthoringIdentity = {
18
+ declare function defineLedger(input: z.input<typeof pointLedgerDeclarationSchema>): {
19
+ name: string;
20
+ description: string;
14
21
  key: string;
15
- id?: string;
16
- } | {
17
- key?: never; /** @deprecated Use key. */
18
- id: string;
19
- };
20
-
21
- /** Discover posts automatically; historical release remains an explicit policy. */
22
- declare function content(tracker: TrackerDefinition, policy?: Partial<Pick<ContentPolicy, "enrollment" | "posts" | "historical">>): {
23
- kind: "automatic";
24
- content: {
25
- tracker: string;
26
- window: {
27
- start: number;
28
- end?: number | undefined;
29
- };
30
- enrollment: "none" | "required";
31
- posts: "after-enrollment" | "since-start";
32
- historical: "automatic" | "claim" | "staff";
33
- };
34
- };
35
- declare function perContent(): {
36
- kind: "keyed";
37
- perContent: true;
38
- key: (ctx: {
39
- content?: AdmittedContent | null;
40
- }) => string;
41
- };
22
+ } & ResourceHandle<"ledger">;
42
23
  /** One independent cumulative formula; management changes capture a new scoring boundary. */
43
- declare function defineEngagementReward<const M extends readonly [ContentMetric, ...ContentMetric[]]>(input: {
24
+ declare function defineEngagementReward<const M extends readonly [string, ...string[]]>(input: {
44
25
  key: string;
45
- qualifiedBy: string | {
46
- key: string;
47
- };
48
- balance: string;
26
+ qualifiedBy: QuestHandle;
27
+ ledger: LedgerReference;
49
28
  metrics: M;
50
29
  baseline: "historical";
51
30
  maxAgeMs?: number;
52
- budget?: EngagementDefinition["budget"];
31
+ budgets?: EngagementBudget[];
53
32
  target: (input: {
54
33
  metrics: Record<M[number], number>;
55
34
  }) => number;
@@ -59,14 +38,14 @@ declare function defineEngagementReward<const M extends readonly [ContentMetric,
59
38
  key: string;
60
39
  qualifiedBy: string;
61
40
  balance: string;
62
- metrics: ("likes" | "replies" | "reposts" | "quotes" | "views" | "bookmarks")[];
41
+ metrics: string[];
63
42
  baseline: "historical";
64
43
  maxAgeMs: number;
65
- budget: {
66
- projectDaily?: number | undefined;
67
- memberDaily?: number | undefined;
68
- projectLifetime?: number | undefined;
69
- };
44
+ budgets: {
45
+ scope: "member" | "project";
46
+ period: "lifetime" | "day" | "week" | "month";
47
+ limit: number;
48
+ }[];
70
49
  };
71
50
  score(raw: unknown): {
72
51
  target: number;
@@ -74,15 +53,68 @@ declare function defineEngagementReward<const M extends readonly [ContentMetric,
74
53
  };
75
54
  };
76
55
  /**
77
- * One milestone per quest, after `days` consecutive community days with an accepted attempt.
78
- * Multiple accepted attempts occupy one day. The day comes from the attempt's trusted occurrence
79
- * time: a tracker record's (or observation's) `occurredAt` for `automatic({ tracker })`, and the
56
+ * One milestone per quest, after `days` consecutive project calendar days with an accepted
57
+ * attempt. Multiple accepted attempts occupy one day. The day comes from the attempt's trusted
58
+ * occurrence time: a tracker record's `occurredAt` for `automatic({ tracker })`, and the
80
59
  * submission's admission time for `manual()`, so a manual streak counts the days a member
81
- * submitted. Not available on content quests or prerequisite-only `automatic()`.
60
+ * submitted. Days begin at midnight in the project timezone (`calendar.timeZone` in relay.json, or
61
+ * Console settings). Not available on content quests or prerequisite-only `automatic()`.
82
62
  */
83
- declare const streak: (options: Omit<StreakPolicy, "kind">) => StreakPolicy;
84
- declare function defineReferral(input: Omit<z.input<typeof referralAuthoringSchema>, "key" | "id"> & AuthoringIdentity): {
85
- id: string;
63
+ declare const streak: (options: {
64
+ days: number;
65
+ }) => StreakPolicy;
66
+ /** The number of distinct qualifying actions in one counter achievement. */
67
+ declare const count: (count: number) => {
68
+ kind: "count";
69
+ count: number;
70
+ } & z.core.$brand<"counter-goal">;
71
+ /** A counter window in the shared project calendar, with a bounded lateness allowance. */
72
+ declare const calendar: (period: "day" | "week" | "month", options?: {
73
+ latenessMs?: number;
74
+ }) => ({
75
+ kind: "lifetime";
76
+ } & z.core.$brand<"counter-window">) | ({
77
+ kind: "calendar";
78
+ period: "day" | "week" | "month";
79
+ latenessMs: number;
80
+ } & z.core.$brand<"counter-window">) | ({
81
+ kind: "rolling";
82
+ durationMs: number;
83
+ } & z.core.$brand<"counter-window">);
84
+ /** A trailing elapsed-time window, independent of timezone and calendar boundaries. */
85
+ declare const rolling: ({ days }: {
86
+ days: number;
87
+ }) => ({
88
+ kind: "lifetime";
89
+ } & z.core.$brand<"counter-window">) | ({
90
+ kind: "calendar";
91
+ period: "day" | "week" | "month";
92
+ latenessMs: number;
93
+ } & z.core.$brand<"counter-window">) | ({
94
+ kind: "rolling";
95
+ durationMs: number;
96
+ } & z.core.$brand<"counter-window">);
97
+ declare const questCompleted: (quest: QuestHandle) => {
98
+ kind: "quest";
99
+ quest: QuestHandle;
100
+ };
101
+ type ReferralInput = z.input<typeof referralAuthoringSchema>;
102
+ type ReferralBonus = NonNullable<ReferralInput["bonuses"]>[number];
103
+ type ReferralMilestone = NonNullable<ReferralInput["milestones"]>[number];
104
+ declare function defineReferral(input: Omit<ReferralInput, "qualification" | "inviterGroup" | "milestones" | "bonuses"> & {
105
+ qualification: {
106
+ kind: "signup" | "external";
107
+ } | ReturnType<typeof questCompleted>;
108
+ inviterGroup?: GroupHandle;
109
+ milestones?: (Omit<ReferralMilestone, "id"> & {
110
+ key: string;
111
+ })[];
112
+ bonuses?: (Omit<ReferralBonus, "id" | "balance" | "quests"> & {
113
+ key: string;
114
+ ledger: LedgerReference;
115
+ quests?: QuestHandle[];
116
+ })[];
117
+ }): {
86
118
  title: string;
87
119
  rewards: {
88
120
  inviter: ({
@@ -99,6 +131,8 @@ declare function defineReferral(input: Omit<z.input<typeof referralAuthoringSche
99
131
  };
100
132
  fulfillment: {
101
133
  kind: "staff-handover";
134
+ } | {
135
+ kind: "automatic";
102
136
  };
103
137
  };
104
138
  tier: string;
@@ -121,6 +155,8 @@ declare function defineReferral(input: Omit<z.input<typeof referralAuthoringSche
121
155
  };
122
156
  fulfillment: {
123
157
  kind: "staff-handover";
158
+ } | {
159
+ kind: "automatic";
124
160
  };
125
161
  };
126
162
  tier: string;
@@ -139,7 +175,6 @@ declare function defineReferral(input: Omit<z.input<typeof referralAuthoringSche
139
175
  kind: "external";
140
176
  };
141
177
  enabled: boolean;
142
- inviterGroup?: string | undefined;
143
178
  milestones: {
144
179
  id: string;
145
180
  count: number;
@@ -157,6 +192,8 @@ declare function defineReferral(input: Omit<z.input<typeof referralAuthoringSche
157
192
  };
158
193
  fulfillment: {
159
194
  kind: "staff-handover";
195
+ } | {
196
+ kind: "automatic";
160
197
  };
161
198
  };
162
199
  tier: string;
@@ -176,12 +213,41 @@ declare function defineReferral(input: Omit<z.input<typeof referralAuthoringSche
176
213
  maxPoints?: number | undefined;
177
214
  }[];
178
215
  key: string;
216
+ inviterGroup?: string | undefined;
217
+ } & ResourceHandle<"referral">;
218
+ type LeaderboardInput = z.input<typeof leaderboardDefinitionSchema>;
219
+ type EarnedScore = Extract<NonNullable<LeaderboardInput["score"]>, {
220
+ kind: "earned";
221
+ }>;
222
+ declare function earned(options?: Omit<EarnedScore, "kind" | "quests"> & {
223
+ quests?: QuestHandle[];
224
+ }): {
225
+ window?: {
226
+ kind: "fixed";
227
+ start: number;
228
+ end: number;
229
+ } | {
230
+ kind: "all-time";
231
+ } | {
232
+ kind: "rolling";
233
+ days: number;
234
+ } | {
235
+ kind: "calendar";
236
+ period: "day" | "week" | "month";
237
+ } | undefined;
238
+ quests?: QuestHandle[];
239
+ kind: "earned";
179
240
  };
180
- declare function defineLeaderboard(input: Omit<z.input<typeof leaderboardAuthoringSchema>, "key" | "id"> & AuthoringIdentity): {
181
- id: string;
182
- title: string;
241
+ declare function defineLeaderboard(input: Omit<LeaderboardInput, "key" | "id" | "balance" | "group" | "score"> & AuthoringIdentity & {
242
+ ledger: LedgerReference;
243
+ group?: GroupHandle;
244
+ score?: Exclude<LeaderboardInput["score"], {
245
+ kind: "earned";
246
+ }> | ReturnType<typeof earned>;
247
+ }): {
183
248
  balance: string;
184
- group?: string | undefined;
249
+ title: string;
250
+ access: "participants" | "public";
185
251
  score: {
186
252
  kind: "balance";
187
253
  } | {
@@ -197,7 +263,6 @@ declare function defineLeaderboard(input: Omit<z.input<typeof leaderboardAuthori
197
263
  } | {
198
264
  kind: "calendar";
199
265
  period: "day" | "week" | "month";
200
- timeZone: string;
201
266
  };
202
267
  kind: "earned";
203
268
  quests?: string[] | undefined;
@@ -215,41 +280,133 @@ declare function defineLeaderboard(input: Omit<z.input<typeof leaderboardAuthori
215
280
  } | {
216
281
  kind: "calendar";
217
282
  period: "day" | "week" | "month";
218
- timeZone: string;
219
283
  };
220
284
  };
221
- access: "participants" | "public";
222
285
  key: string;
223
- };
286
+ settle?: {
287
+ at: "window-end";
288
+ ties: "shared" | "earliest";
289
+ prizes: {
290
+ ranks: [number, number];
291
+ rewards: ({
292
+ kind: "tier";
293
+ reward: {
294
+ id: string;
295
+ title: string;
296
+ tiers: {
297
+ id: string;
298
+ title: string;
299
+ }[];
300
+ inventory: {
301
+ kind: "untracked";
302
+ };
303
+ fulfillment: {
304
+ kind: "staff-handover";
305
+ } | {
306
+ kind: "automatic";
307
+ };
308
+ };
309
+ tier: string;
310
+ } | {
311
+ kind: "points";
312
+ balance: string;
313
+ amount: number;
314
+ })[];
315
+ }[];
316
+ } | undefined;
317
+ group?: string | undefined;
318
+ } & ResourceHandle<"leaderboard">;
319
+ /** An X post's body as content quests read it in `ctx.tracker.content.body`. */
320
+ type XContentBody = z.infer<typeof xContentBodySchema>;
224
321
  declare const x: {
322
+ provider: "x";
323
+ /**
324
+ * Posts matching an X search. Each record's `data` is the provider's post payload. Its content
325
+ * is the post's normalized body (`XContentBody`), measured by the six X counters, so `content()`
326
+ * quests can use it.
327
+ */
225
328
  search: (input: {
226
329
  query: string;
227
- }) => {
228
- kind: "x-search";
229
- query: string;
230
- };
330
+ }) => z.output<typeof xSearchSourceSchema> & WithRecordData<XTweet> & WithContent<XContentBody, XContentMetric>;
231
331
  };
232
332
  /**
233
- * Records your own code sends with `trackers.ingest`. With `identities`, each record's author, and
234
- * each named account in `accounts`, is a verified identity of one of those kinds, which Relay
235
- * attributes to the member who verified it, so quests can trigger from the tracker. A record states
236
- * each account's `kind` unless the source names exactly one.
333
+ * Records your own code sends with `trackers.ingest`. `data` is a zod object schema that every
334
+ * record's `data` must match: Relay stores its JSON Schema form with the tracker and rejects
335
+ * records that do not match it, and quests read each record's data with its type. With
336
+ * `identities`, each record's author, and each named account in `accounts`, is a verified identity
337
+ * of one of those kinds, which Relay attributes to the member who verified it, so quests can
338
+ * trigger from the tracker. A record states each account's `kind` unless the source names exactly
339
+ * one.
237
340
  */
238
- declare const customSource: (namespace: string, options?: {
239
- identities?: IdentityKind[];
240
- accounts?: string[];
241
- }) => {
242
- kind: "custom";
243
- namespace: string;
244
- identities?: ("x" | "discord" | "member" | "wallet")[] | undefined;
245
- accounts?: string[] | undefined;
246
- authors?: "wallet" | undefined;
341
+ /** What a content source's records carry in `data`: the body, and the metrics each sample measures. */
342
+ type ContentData<B, M extends string> = {
343
+ body: B;
344
+ metrics?: Partial<Record<M, number>>;
247
345
  };
248
- declare function defineTracker(input: z.input<typeof trackerDefinitionSchema>): TrackerDefinition;
346
+ /**
347
+ * Content your own code collects, such as posts from another platform: each record's `data` is
348
+ * `{ body, metrics? }`, where `body` matches the `body` schema and `metrics` holds the declared
349
+ * counters a sample measured (a counter a sample leaves out is unknown, never zero). The record's
350
+ * `author` is the creator, `occurredAt` the publication time, and its ID the content item. Quests
351
+ * use the tracker with `content()`, and a performance stage or engagement reward reads the
352
+ * declared metrics.
353
+ */
354
+ declare function customSource<B extends z.ZodObject, const M extends readonly string[] = [], const A extends readonly string[] = []>(namespace: string, options: {
355
+ identities?: IdentityKind[];
356
+ accounts?: A;
357
+ content: {
358
+ body: B;
359
+ metrics?: M;
360
+ };
361
+ }): z.output<typeof customSourceSchema> & WithRecordData<ContentData<z.input<B>, M[number]>> & WithContent<z.input<B>, M[number]> & WithAccountRoles<"author" | A[number]>;
362
+ declare function customSource<S extends z.ZodObject, const A extends readonly string[] = []>(namespace: string, options: {
363
+ identities?: IdentityKind[];
364
+ accounts?: A;
365
+ data: S;
366
+ }): z.output<typeof customSourceSchema> & WithRecordData<z.input<S>> & WithAccountRoles<"author" | A[number]>;
367
+ /** The content marker of a source, carried by the tracker built from it. */
368
+ type ContentOf<S> = S extends WithContent<infer B, infer M> ? WithContent<B, M> : unknown;
369
+ declare function defineTracker<S extends TrackerSource>(input: Omit<z.input<typeof trackerDefinitionSchema>, "source"> & {
370
+ source: S;
371
+ }): Tracker<TrackerData<S>> & ContentOf<S> & WithAccountRoles<SourceRoles<S>>;
249
372
  type ChannelTypes = Extract<ResourceSource, {
250
373
  resource: "channel";
251
374
  }>["types"];
375
+ type DiscordMessagesSource = z.output<typeof discordMessagesSourceSchema>;
376
+ /**
377
+ * Messages members post in the project's Discord server. The Discord gateway writes one record per
378
+ * message, keyed by the message ID: its `author` is the poster's Discord account, `occurredAt` is
379
+ * when the message arrived, and `data` holds the channel, the replied-to message and the post time.
380
+ * A record is stored only when its author has linked that Discord account in the project, and its
381
+ * text only with `text: true`. Edits update stored text. Deleting a message, or publishing this
382
+ * tracker without `text: true`, removes retained text.
383
+ */
384
+ declare function messages(options?: {
385
+ text?: false;
386
+ }): DiscordMessagesSource & WithRecordData<DiscordMessageData>;
387
+ declare function messages(options: {
388
+ text: true;
389
+ }): DiscordMessagesSource & WithRecordData<DiscordMessageTextData>;
390
+ /**
391
+ * Reactions members add in the project's Discord server. The Discord gateway writes one record per
392
+ * reaction, keyed by message, reactor and emoji: its `author` is the reactor's Discord account and
393
+ * its `messageAuthor` account the message's author, when Discord names it. `occurredAt` is when
394
+ * the reaction arrived. A record is stored only when the reactor or the message author has linked
395
+ * that Discord account in the project. Pay the message author with
396
+ * `automatic({ tracker, beneficiary: "messageAuthor" })`; reactions to one's own message are
397
+ * skipped.
398
+ */
399
+ declare function reactions(): z.output<typeof discordReactionsSourceSchema> & WithRecordData<DiscordReactionData>;
252
400
  declare const discord: {
401
+ provider: "discord";
402
+ grantRole: (roleId: string) => {
403
+ kind: "integration";
404
+ provider: "discord";
405
+ action: "grant-role";
406
+ roleId: string;
407
+ };
408
+ messages: typeof messages;
409
+ reactions: typeof reactions;
253
410
  roles(options?: {
254
411
  assignable?: boolean;
255
412
  }): ResourceSource;
@@ -264,18 +421,18 @@ type Label = {
264
421
  };
265
422
  declare const settings: {
266
423
  pointLedger(options: Label & {
267
- default: string;
268
- }): z.ZodDefault<z.ZodString>;
424
+ default?: LedgerHandle;
425
+ }): Setting<"point-ledger", z.ZodPrefault<z.core.$ZodBranded<z.ZodUnion<[z.ZodString, z.ZodLiteral<"">]>, "ledger-reference", "out">>>;
269
426
  datetime(options: Label & {
270
427
  default: string;
271
- }): z.ZodDefault<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<string, string>>>;
428
+ }): Setting<"datetime", z.ZodDefault<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<string, string>>>>;
272
429
  resource(options: Label & {
273
430
  source: ResourceSource;
274
431
  default?: string;
275
- }): z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
432
+ }): Setting<"resource", z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>>;
276
433
  quiz(options: Label & {
277
434
  default: QuizContent;
278
- }): z.ZodDefault<z.ZodArray<z.ZodObject<{
435
+ }): Setting<"quiz", z.ZodDefault<z.ZodArray<z.ZodObject<{
279
436
  id: z.ZodString;
280
437
  prompt: z.ZodString;
281
438
  choices: z.ZodArray<z.ZodObject<{
@@ -283,40 +440,35 @@ declare const settings: {
283
440
  label: z.ZodString;
284
441
  }, z.core.$strict>>;
285
442
  correct: z.ZodString;
286
- }, z.core.$strict>>>;
443
+ }, z.core.$strict>>>>;
287
444
  text(options: Label & {
288
445
  default: string;
289
446
  minLength?: number;
290
447
  maxLength?: number;
291
448
  multiline?: boolean;
292
- }): z.ZodDefault<z.ZodString>;
449
+ }): Setting<"text", z.ZodDefault<z.ZodString>>;
293
450
  integer(options: Label & {
294
451
  default: number;
295
452
  min: number;
296
453
  max: number;
297
- }): z.ZodDefault<z.ZodNumber>;
454
+ }): Setting<"integer", z.ZodDefault<z.ZodNumber>>;
298
455
  boolean(options: Label & {
299
456
  default: boolean;
300
- }): z.ZodDefault<z.ZodBoolean>;
457
+ }): Setting<"boolean", z.ZodDefault<z.ZodBoolean>>;
301
458
  choice<const T extends readonly [string, ...string[]]>(options: Label & {
302
459
  options: T;
303
460
  default: T[number];
304
- }): z.ZodDefault<z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>>;
305
- object<T extends Record<string, z.ZodType>>(shape: T): z.ZodObject<{ -readonly [P in keyof T]: T[P]; }, z.core.$strict>;
461
+ }): Setting<"choice", z.ZodDefault<z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>>>;
462
+ /** A quest's settings: every field is built with one of the builders above. */
463
+ object<T extends Record<string, Setting>>(shape: T): z.ZodObject<{ -readonly [P in keyof T]: T[P]; }, z.core.$strict>;
306
464
  };
307
465
 
308
466
  type Reward = z.infer<typeof rewardSchema>;
309
- declare const points: (balance: string, amount: number) => {
467
+ declare const points: (ledger: LedgerReference, amount: number) => {
310
468
  kind: "points";
311
469
  balance: string;
312
470
  amount: number;
313
471
  };
314
- declare const discordRole: (roleId: string) => {
315
- kind: "integration";
316
- provider: "discord";
317
- action: "grant-role";
318
- roleId: string;
319
- };
320
472
 
321
473
  declare const evidence: {
322
474
  text: (options?: TextOptions) => {
@@ -360,81 +512,209 @@ declare function manual(options: {
360
512
  input: "none";
361
513
  actor: "staff";
362
514
  };
515
+ /**
516
+ * Which members' activity a tracker trigger counts, and from when. With `enrollment: "required"`,
517
+ * a member's activity counts only once they enroll (`relay.quests.enroll`, or
518
+ * `management.quests.enroll` from a server), and `since` can also be `"enrollment"`.
519
+ */
520
+ type TriggerAdmission = {
521
+ /** `"none"` (the default): every member who has joined the project. */
522
+ enrollment?: "none";
523
+ /**
524
+ * The earliest activity counted: `"activation"` (the default), records since the quest was
525
+ * published; `"window"`, every record in the tracker's window.
526
+ */
527
+ since?: "activation" | "window";
528
+ } | {
529
+ /** Members enroll in the quest before their activity counts. */
530
+ enrollment: "required";
531
+ /**
532
+ * The earliest activity counted: `"activation"` (the default), `"window"`, or
533
+ * `"enrollment"`, records since the member enrolled. With `"activation"` or `"window"`, a
534
+ * record from before the member enrolled is historical.
535
+ */
536
+ since?: "activation" | "window" | "enrollment";
537
+ };
363
538
  /** A tracker trigger: which observations of which tracker run the quest, and for whom. */
364
- type TrackerTriggerInput = {
365
- tracker: TrackerDefinition;
539
+ type TrackerTriggerInput<T extends Tracker = Tracker, W extends Where<TrackerData<T>> | undefined = Where<TrackerData<T>> | undefined> = TriggerAdmission & {
540
+ /** The tracker handle `defineTracker` returns. */
541
+ tracker: T;
366
542
  /**
367
543
  * Which observations fire. `"new-record"`: each record's first observation (the default for X
368
- * trackers, where it means each newly collected post). `"new-observation"`: each observation
369
- * that becomes its record's current one (the default for custom trackers). `"data-changed"`: a
544
+ * and Discord trackers, where it means each newly collected post, message or reaction).
545
+ * `"new-observation"`: each observation that becomes its record's current one (the default for
546
+ * custom trackers). `"data-changed"`: a
370
547
  * new record, or a current observation whose `data` differs from the previous one.
371
548
  */
372
549
  on?: TrackerTriggerMode;
373
550
  /**
374
551
  * Admit only observations whose `data` matches, such as `{ path: "amount", gte: 1000 }` or
375
- * `{ path: "amount", gte: { setting: "threshold" } }`. Others record no outcome.
552
+ * `{ path: "amount", gte: { setting: "threshold" } }`, or a list of at most 10 such conditions
553
+ * that must all hold. Paths and values are checked against the tracker's data type, and a
554
+ * `setting` must name one of the quest's integer settings. Others record no outcome.
376
555
  */
377
- where?: TrackerWhere;
556
+ where?: W;
378
557
  /**
379
558
  * The record account whose member the quest pays: `"author"` (the default), `"inReplyTo"` on
380
- * an X tracker, or a named account a custom source declares in `accounts`. Skipped when that
381
- * account is the record's author account or belongs to the author's member.
559
+ * an X tracker, `"messageAuthor"` on a Discord reactions tracker, or a named account a custom
560
+ * source declares in `accounts`. Skipped when that account is the record's author account or
561
+ * belongs to the author's member, such as a reaction to one's own message.
562
+ */
563
+ beneficiary?: RoleOf<T>;
564
+ /**
565
+ * Who releases historical activity: a record that occurred before the member linked the
566
+ * account it pays (an unknown link time counts as before), or before they enrolled. `"staff"`
567
+ * (the default): only a reviewer's retry. `"claim"`: also the member, with
568
+ * `relay.quests.claim`. `"automatic"`: Relay admits it, including when the member links the
569
+ * account or enrolls later. Accounts of kind `member` are never historical.
382
570
  */
383
- beneficiary?: string;
571
+ historical?: "staff" | "claim" | "automatic";
384
572
  };
573
+ /** Type-only markers a tracker trigger carries into `defineQuest`. They never exist at runtime. */
574
+ declare const triggerData: unique symbol;
575
+ declare const triggerSettings: unique symbol;
576
+ declare const triggerBody: unique symbol;
577
+ declare const triggerMetrics: unique symbol;
385
578
  /**
386
- * An automatic quest. With no argument it runs once its prerequisites are complete; with an
387
- * observation it runs for each matching observation; with a tracker it runs for each observation
388
- * its firing mode and filter admit, for the member Relay attributes the beneficiary account to.
579
+ * A tracker trigger whose records carry `data` of type `D` and whose filter compares with the
580
+ * settings `S`. On a content source, its content body has type `B` and its metrics are `M`.
581
+ * `defineQuest` types `ctx.tracker` from `D` and `B` and checks `S` against its integer settings.
389
582
  */
390
- declare function automatic(): {
583
+ type TrackerTrigger<D = unknown, S extends string = never, B = never, M extends string = never> = {
391
584
  kind: "automatic";
585
+ tracker: TrackerTriggerPolicy;
586
+ readonly [triggerData]?: D;
587
+ readonly [triggerSettings]?: S;
588
+ readonly [triggerBody]?: B;
589
+ readonly [triggerMetrics]?: M;
392
590
  };
393
- declare function automatic(observation: z.infer<typeof observationTriggerSchema>): {
394
- kind: "automatic";
395
- observation: z.infer<typeof observationTriggerSchema>;
591
+ /**
592
+ * A content quest's trigger: a tracker trigger on a content source with the content stage. It
593
+ * completes once per content item, so its quest takes no `completion`.
594
+ */
595
+ type ContentTrigger<D = unknown, S extends string = never, B = unknown, M extends string = string> = TrackerTrigger<D, S, B, M> & {
596
+ tracker: TrackerTriggerPolicy & {
597
+ content: true;
598
+ };
396
599
  };
397
- declare function automatic(input: TrackerTriggerInput): {
600
+ type TriggerData<G> = G extends {
601
+ readonly [triggerData]?: infer D;
602
+ } ? unknown extends D ? unknown : Exclude<D, undefined> : unknown;
603
+ type TriggerSettings<G> = G extends {
604
+ readonly [triggerSettings]?: infer S;
605
+ } ? unknown extends S ? never : Exclude<S, undefined> : never;
606
+ type TriggerBody<G> = G extends {
607
+ readonly [triggerBody]?: infer B;
608
+ } ? Exclude<B, undefined> : never;
609
+ /** The metric names a content trigger's source measures. */
610
+ type TriggerMetrics<G> = G extends {
611
+ readonly [triggerMetrics]?: infer M;
612
+ } ? Exclude<M, undefined> : never;
613
+ /** A trigger that runs a content stage. */
614
+ type IsContent<G> = G extends {
615
+ tracker: {
616
+ content: true;
617
+ };
618
+ } ? true : false;
619
+ /** A tracker's content body type, or never when its source declares no content. */
620
+ type BodyOf<T> = T extends WithContent<unknown, string> ? ContentBody<T> : never;
621
+ /**
622
+ * An automatic quest. With no argument it runs once its prerequisites are complete; with a tracker
623
+ * it runs for each observation its firing mode and filter admit, for the member Relay attributes
624
+ * the beneficiary account to.
625
+ */
626
+ declare function automatic(): {
398
627
  kind: "automatic";
399
- tracker: TrackerTriggerPolicy;
400
628
  };
401
- declare const budget: (definition: Budget) => {
402
- id: string;
403
- scope: "member" | "project";
404
- period: "day" | "lifetime" | "week";
405
- limit: number;
406
- cost: number | {
407
- balance: string;
408
- };
629
+ declare function automatic<T extends Tracker, const W extends Where<TrackerData<T>> | undefined = undefined>(input: TrackerTriggerInput<T, W>): TrackerTrigger<TrackerData<T>, WhereSetting<W>, BodyOf<T>>;
630
+ /** A content quest's trigger: which content items of which tracker it takes, and from whom. */
631
+ type ContentTriggerInput<T extends Tracker = Tracker, W extends Where<TrackerData<T>> | undefined = Where<TrackerData<T>> | undefined> = TriggerAdmission & {
632
+ /** A tracker handle from `defineTracker` whose source has content. */
633
+ tracker: T;
634
+ /** Take only content items whose first observation's `data` matches. */
635
+ where?: W;
636
+ /**
637
+ * Who releases historical content: posts from before the creator linked the account or
638
+ * enrolled. `"claim"` (the default): the creator claims it with `relay.quests.claim`. `"staff"`:
639
+ * only a reviewer's retry. `"automatic"`: Relay takes it.
640
+ */
641
+ historical?: "staff" | "claim" | "automatic";
409
642
  };
410
- declare const keyed: (key: (ctx: {
643
+ /**
644
+ * A content quest: each content item a tracker collects, such as an X post or a custom source's
645
+ * record, becomes one attempt for its author's member, decided once on its first observation and
646
+ * evaluated again when its body changes. Completes once per content item: the quest takes no
647
+ * `completion`. With `performance`, a later observation's metrics gate the rewards.
648
+ */
649
+ declare function content<T extends Tracker & WithContent<unknown, string>, const W extends Where<TrackerData<T>> | undefined = undefined>(input: ContentTriggerInput<T, W>): ContentTrigger<TrackerData<T>, WhereSetting<W>, ContentBody<T>, ContentMetricName<T>>;
650
+ /**
651
+ * What a trigger `G` supplies under key `K`: `Present` when the trigger has it, null when it cannot,
652
+ * and `Present | null` when `G` is not known.
653
+ */
654
+ type Supplied<G, K extends string, Present, Base> = unknown extends G ? Base | null : G extends unknown ? K extends keyof G ? [G[K]] extends [object] ? Present : Base | null : null : never;
655
+ /**
656
+ * `ctx.tracker` for a trigger: non-null and typed for a tracker trigger, null for others. On a
657
+ * content source, `content.body` has the source's body type.
658
+ */
659
+ type ContextTracker<G> = Supplied<G, "tracker", TrackerTriggerContext<TriggerData<G>, TriggerBody<G>>, TrackerTriggerContext>;
660
+ /**
661
+ * What a `keyed()` completion key reads. TypeScript cannot carry the trigger into a completion
662
+ * built inline, so `tracker` stays nullable here; the evaluator's `ctx.tracker` is typed.
663
+ */
664
+ type KeyedContext = {
411
665
  member: {
412
666
  id: string;
413
667
  };
414
- content?: AdmittedContent | null;
415
- observation: Observation | null;
416
- /** The pinned tracker observation of a tracker-triggered quest. */
417
- tracker?: TrackerTriggerContext | null;
668
+ /** The pinned tracker observation of a tracker-triggered quest; null for other triggers. */
669
+ tracker: TrackerTriggerContext | null;
418
670
  eligibleAt: number;
671
+ /** The evaluation run's pinned project calendar. */
672
+ calendar: EvaluationCalendar;
419
673
  /** The attempt's evaluation time; see {@link EvaluationContext.now}. */
420
674
  now: number;
421
- }) => string) => {
675
+ };
676
+ declare const budget: (definition: Omit<Budget, "id" | "cost"> & {
677
+ key: string;
678
+ cost: number | {
679
+ ledger: LedgerReference;
680
+ };
681
+ }) => {
682
+ id: string;
683
+ scope: "member" | "project";
684
+ period: "lifetime" | "day" | "week" | "month";
685
+ limit: number;
686
+ cost: number | {
687
+ balance: string;
688
+ };
689
+ };
690
+ declare const keyed: (key: (ctx: KeyedContext) => string) => {
422
691
  kind: "keyed";
423
- key: (ctx: {
424
- member: {
425
- id: string;
426
- };
427
- content?: AdmittedContent | null;
428
- observation: Observation | null;
429
- /** The pinned tracker observation of a tracker-triggered quest. */
430
- tracker?: TrackerTriggerContext | null;
431
- eligibleAt: number;
432
- /** The attempt's evaluation time; see {@link EvaluationContext.now}. */
433
- now: number;
434
- }) => string;
692
+ key: (ctx: KeyedContext) => string;
435
693
  };
436
- declare const completed: (quest: AuthoringIdentity | string) => {
437
- quest: string;
694
+ /** Accepted evidence contributes once under its distinct key; Relay commits progress with rewards. */
695
+ declare const progress: (definition: {
696
+ distinct: (ctx: KeyedContext) => string;
697
+ goal: ReturnType<typeof count>;
698
+ window?: ReturnType<typeof calendar>;
699
+ repeat?: "once" | "repeat";
700
+ }) => {
701
+ distinct: (ctx: KeyedContext) => string;
702
+ kind: "progress";
703
+ goal: {
704
+ kind: "count";
705
+ count: number;
706
+ };
707
+ window: {
708
+ kind: "lifetime";
709
+ } | {
710
+ kind: "calendar";
711
+ period: "day" | "week" | "month";
712
+ latenessMs: number;
713
+ } | {
714
+ kind: "rolling";
715
+ durationMs: number;
716
+ };
717
+ repeat: "repeat" | "once";
438
718
  };
439
719
  declare const untracked: () => {
440
720
  kind: "untracked";
@@ -442,11 +722,17 @@ declare const untracked: () => {
442
722
  declare const staffHandover: () => {
443
723
  kind: "staff-handover";
444
724
  };
445
- declare function defineTieredReward(input: Omit<TieredRewardDefinition, "id"> & AuthoringIdentity): {
725
+ declare const automaticFulfillment: () => {
726
+ kind: "automatic";
727
+ };
728
+ declare function defineTieredReward<const T extends readonly {
446
729
  key: string;
447
- /** @deprecated Authoring key alias. Use key. */
448
- id: string;
449
- tier: (tier: string) => {
730
+ title: string;
731
+ }[]>(input: Omit<TieredRewardDefinition, "id" | "tiers"> & AuthoringIdentity & {
732
+ tiers: T;
733
+ }): {
734
+ key: string;
735
+ tier: (tier: T[number]["key"]) => {
450
736
  kind: "tier";
451
737
  reward: {
452
738
  id: string;
@@ -460,25 +746,23 @@ declare function defineTieredReward(input: Omit<TieredRewardDefinition, "id"> &
460
746
  };
461
747
  fulfillment: {
462
748
  kind: "staff-handover";
749
+ } | {
750
+ kind: "automatic";
463
751
  };
464
752
  };
465
753
  tier: string;
466
754
  };
467
- };
755
+ } & ResourceHandle<"tiered-reward">;
468
756
  declare const once: () => {
469
757
  kind: "once";
470
758
  };
471
- type Outcome = {
759
+ type Outcome = (Omit<Extract<Decision, {
472
760
  kind: "accept";
761
+ }>, "rewards"> & {
473
762
  rewards?: Reward[];
474
- } | {
475
- kind: "review";
476
- reason: string;
477
- rewards?: Reward[];
478
- } | {
479
- kind: "reject";
480
- reason: string;
481
- };
763
+ }) | Exclude<Decision, {
764
+ kind: "accept";
765
+ }>;
482
766
  /**
483
767
  * A performance evaluator's answer. It gates the rewards content evaluation already selected, so
484
768
  * it carries none: a `rewards` value fails the evaluation.
@@ -497,9 +781,11 @@ type PerformanceOutcome = {
497
781
  declare function accept(): {
498
782
  kind: "accept";
499
783
  };
500
- declare function accept(options: {
501
- rewards?: Reward[];
502
- }): Outcome;
784
+ declare function accept(options: Omit<Extract<Outcome, {
785
+ kind: "accept";
786
+ }>, "kind">): Extract<Outcome, {
787
+ kind: "accept";
788
+ }>;
503
789
  declare function review(options: {
504
790
  reason: string;
505
791
  rewards?: undefined;
@@ -507,12 +793,23 @@ declare function review(options: {
507
793
  kind: "review";
508
794
  reason: string;
509
795
  };
510
- declare function review(options: {
511
- reason: string;
512
- rewards?: Reward[];
513
- }): Outcome;
796
+ declare function review(options: Omit<Extract<Outcome, {
797
+ kind: "review";
798
+ }>, "kind">): Extract<Outcome, {
799
+ kind: "review";
800
+ }>;
514
801
  declare const decision: {
515
802
  accept: typeof accept;
803
+ defer: (options: Omit<Extract<Decision, {
804
+ kind: "defer";
805
+ }>, "kind">) => Extract<Decision, {
806
+ kind: "defer";
807
+ }>;
808
+ progress: (options: Omit<Extract<Decision, {
809
+ kind: "progress";
810
+ }>, "kind">) => Extract<Decision, {
811
+ kind: "progress";
812
+ }>;
516
813
  reject: (options: {
517
814
  reason: string;
518
815
  }) => {
@@ -521,35 +818,70 @@ declare const decision: {
521
818
  };
522
819
  review: typeof review;
523
820
  };
821
+ /** The member an attempt evaluates. */
822
+ type EvaluationMember = {
823
+ id: string;
824
+ /**
825
+ * The member's selected X and Discord accounts and their `app:<name>` identities in this
826
+ * project, pinned once per evaluation run at the first call: later links and unlinks do not change
827
+ * this evaluation. Null when the member has none. `ctx.wallet.list()` reads wallets.
828
+ */
829
+ identities(): Promise<MemberIdentity[] | null>;
830
+ };
831
+ /** One project-calendar day, with epoch-millisecond bounds. */
832
+ type EvaluationCalendarDay = {
833
+ /** The stable completion-key form, such as `2026-10-01@Europe/Budapest`. */
834
+ key: string;
835
+ /** The local ISO date in `timeZone`. */
836
+ date: string;
837
+ timeZone: string;
838
+ /** Inclusive epoch-millisecond boundary. */
839
+ start: number;
840
+ /** Exclusive epoch-millisecond boundary. */
841
+ end: number;
842
+ };
843
+ /** The project calendar pinned for one evaluation run. */
844
+ type EvaluationCalendar = {
845
+ /** The day containing `at`, or the activity's `eligibleAt` when omitted. */
846
+ day(at?: number): EvaluationCalendarDay;
847
+ };
848
+ /**
849
+ * What an evaluator reads. `G` is the quest's trigger: `tracker` and `content` are non-null for
850
+ * the trigger that supplies them and null otherwise. `G` defaults to `any`, which
851
+ * leaves them nullable and lets a shared evaluator, such as `evaluators.photo()`, fit every quest.
852
+ */
853
+ type IntegrationReaders<D extends readonly IntegrationModule[]> = Pick<{
854
+ x: XReader;
855
+ discord: DiscordReader;
856
+ }, D[number]["provider"]>;
524
857
  type EvaluationContext<T, I = {
525
858
  photo: string;
526
- }> = {
859
+ }, G = any, D extends readonly IntegrationModule[] = readonly IntegrationModule[]> = {
527
860
  settings: T;
528
- member: {
529
- id: string;
530
- };
861
+ member: EvaluationMember;
531
862
  input: I;
532
- content: AdmittedContent | null;
533
- observation: Observation | null;
534
863
  /**
535
864
  * The tracker observation that admitted this attempt, and the member and verified account it
536
- * was attributed to. Null unless the quest has a tracker trigger.
865
+ * was attributed to. Present for a tracker trigger, with `record.data` of the tracker's type.
866
+ * On a content source, `content` holds the body revision being evaluated, with the source's
867
+ * body type.
537
868
  */
538
- tracker: TrackerTriggerContext | null;
869
+ tracker: ContextTracker<G>;
539
870
  /**
540
- * When the activity happened, in epoch milliseconds: the observation's or tracker record's
541
- * occurrence time, else when the attempt was admitted. Budgets and daily keys use it.
871
+ * When the activity happened, in epoch milliseconds: the tracker record's occurrence time, else
872
+ * when the attempt was admitted. Budgets and daily keys use it.
542
873
  */
543
874
  eligibleAt: number;
875
+ /** The project calendar pinned when this evaluation run started. */
876
+ calendar: EvaluationCalendar;
544
877
  /**
545
- * The attempt's evaluation time, in epoch milliseconds: when its first evaluation started.
546
- * Every retry and replay of the attempt receives the same value, and the sandbox freezes
878
+ * The current evaluation run's start time in epoch milliseconds.
879
+ * Retries and replays of that run receive the same value; a scheduled defer starts a fresh run, and the sandbox freezes
547
880
  * `Date.now()` and `new Date()` at it. Use `eligibleAt` for when the activity
548
881
  * happened.
549
882
  */
550
883
  now: number;
551
884
  trackers: TrackerReader;
552
- x: XReader;
553
885
  images: ImageReader;
554
886
  review: {
555
887
  text(options: TextReviewInput): Promise<TextResult>;
@@ -558,31 +890,11 @@ type EvaluationContext<T, I = {
558
890
  criteria: string;
559
891
  }): Promise<PhotoResult>;
560
892
  };
561
- discord: {
562
- member(): Promise<DiscordMember | null>;
563
- message(input: {
564
- channelId: string;
565
- messageId: string;
566
- }): Promise<DiscordMessage | null>;
567
- };
568
- wallet: {
569
- /** The member's newest linked Solana wallet. */
570
- connection(): Promise<WalletConnection | null>;
571
- /** SOL held by the newest linked Solana wallet. */
572
- solanaBalance(): Promise<SolanaBalance | null>;
573
- /** Every wallet the member has linked to this project, pinned once per attempt. */
574
- list(): Promise<LinkedWallet[]>;
575
- /**
576
- * The native or token balance of the member's pinned linked wallets on one chain: all wallets of
577
- * that family, or `address` (which must be one of them). No wallets gives `total: "0"` and
578
- * `wallets: []`. Provider failures throw; they never read as a zero balance.
579
- */
580
- balance(query: WalletBalanceQuery): Promise<WalletBalance>;
581
- };
582
- };
893
+ wallet: WalletReader;
894
+ } & IntegrationReaders<D>;
583
895
  type Evaluator<T, I = {
584
896
  photo: string;
585
- }> = (ctx: EvaluationContext<T, I>) => Promise<Outcome>;
897
+ }, G = any, D extends readonly IntegrationModule[] = readonly []> = (ctx: EvaluationContext<T, I, G, D>) => Promise<Outcome>;
586
898
  declare const evaluators: {
587
899
  quiz(answerKey: QuizEvidence["answers"], options?: {
588
900
  minimumCorrect?: number;
@@ -606,21 +918,59 @@ type QuestInput<T extends Trigger> = T extends {
606
918
  } ? TextEvidence : T extends {
607
919
  input: "url";
608
920
  } ? UrlEvidence : Record<string, never>;
609
- declare function defineQuest<T extends Record<string, z.ZodType>, const G extends Trigger, const M extends readonly [ContentMetric, ...ContentMetric[]] = readonly [
610
- ContentMetric,
611
- ...ContentMetric[]
612
- ]>(definition: AuthoringIdentity & {
921
+ /**
922
+ * Rejects a trigger whose filter compares with settings that are not integer settings of the
923
+ * quest, naming them.
924
+ */
925
+ type IntegerSettingBounds<G, T> = [
926
+ Exclude<TriggerSettings<G>, IntegerSettings<T>>
927
+ ] extends [never] ? unknown : {
928
+ readonly "The tracker filter compares with settings that are not integer settings of this quest": Exclude<TriggerSettings<G>, IntegerSettings<T>>;
929
+ };
930
+ /** How a quest completes: a content quest once per content item, so it takes no `completion`. */
931
+ type CompletionFor<G> = IsContent<G> extends true ? {
932
+ /** A content quest completes once per content item; it takes no completion. */
933
+ completion?: never;
934
+ } : G extends {
935
+ kind: "automatic";
936
+ tracker?: never;
937
+ } ? {
938
+ completion: ReturnType<typeof once>;
939
+ } : {
940
+ completion: ReturnType<typeof once> | ReturnType<typeof keyed> | StreakPolicy | ReturnType<typeof progress>;
941
+ };
942
+ /** What a content quest's performance stage reads: the declared metrics it chose, fresh. */
943
+ type PerformanceContext<S, G, M extends string> = {
944
+ settings: S;
945
+ member: {
946
+ id: string;
947
+ };
948
+ /** The content item's pinned observation, attribution and body revision. */
949
+ tracker: ContextTracker<G>;
950
+ /** The chosen metrics of one complete, fresh sample. */
951
+ metrics: Record<M, number>;
952
+ /** When the sample was observed. */
953
+ observedAt: number;
954
+ };
955
+ /** A concrete quest: prerequisite-only automatic triggers need at least one prerequisite. */
956
+ declare const defineQuest: <T extends Record<string, Setting>, const G extends Trigger, const D extends readonly IntegrationModule[] = readonly [], const M extends readonly [string, ...string[]] = readonly [string, ...string[]]>(definition: AuthoringIdentity & CompletionFor<G> & (G extends {
957
+ kind: "automatic";
958
+ tracker?: never;
959
+ } ? {
960
+ requires: readonly [Prerequisite, ...Prerequisite[]];
961
+ } : unknown) & {
613
962
  title: string | ((ctx: {
614
- settings: z.output<z.ZodObject<T>>;
963
+ settings: z.core.$InferObjectOutput<T, {}>;
615
964
  }) => string);
616
- settings: z.ZodObject<T>;
617
- presentation?: (ctx: {
618
- settings: z.output<z.ZodObject<T>>;
619
- }) => QuestPresentation;
620
- trigger: G;
621
- integrations?: IntegrationProvider[];
622
- requires?: ReturnType<typeof completed>[];
623
- completion: ReturnType<typeof once> | ReturnType<typeof keyed> | StreakPolicy;
965
+ settings: z.ZodObject<T, z.core.$strip>;
966
+ presentation?: ((ctx: {
967
+ settings: z.core.$InferObjectOutput<T, {}>;
968
+ }) => QuestPresentation) | undefined;
969
+ trigger: G & NoInfer<IntegerSettingBounds<G, T>>;
970
+ integrations?: D | undefined;
971
+ requires?: readonly Prerequisite[];
972
+ campaign?: CampaignDefinition;
973
+ availability?: AvailabilityWindow;
624
974
  visibility?: "visible" | "hidden";
625
975
  /**
626
976
  * `{ visible: true }` lists the quest's completions on participant profiles
@@ -634,37 +984,59 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
634
984
  * review reason, and the attempt records `requestedReview: true`; Console shows "Would have
635
985
  * gone to review; human review is off".
636
986
  */
637
- review?: (ctx: {
638
- settings: z.output<z.ZodObject<T>>;
987
+ review?: ((ctx: {
988
+ settings: z.core.$InferObjectOutput<T, {}>;
639
989
  }) => {
640
990
  enabled: boolean;
641
- };
642
- rewards: Reward[] | ((ctx: {
643
- settings: z.output<z.ZodObject<T>>;
644
- }) => Reward[]);
645
- evaluate?: Evaluator<z.output<z.ZodObject<T>>, QuestInput<G>>;
646
- performance?: G extends {
647
- content: unknown;
648
- } ? {
649
- metrics: M;
650
- maxAgeMs?: number;
651
- evaluate: (ctx: {
652
- settings: z.output<z.ZodObject<T>>;
653
- member: {
991
+ }) | undefined;
992
+ rewards: ({
993
+ kind: "tier";
994
+ reward: {
995
+ id: string;
996
+ title: string;
997
+ tiers: {
654
998
  id: string;
999
+ title: string;
1000
+ }[];
1001
+ inventory: {
1002
+ kind: "untracked";
655
1003
  };
656
- content: AdmittedContent;
657
- metrics: Record<M[number], number>;
658
- observedAt: number;
659
- }) => PerformanceOutcome | Promise<PerformanceOutcome>;
660
- } : never;
661
- }): {
1004
+ fulfillment: {
1005
+ kind: "staff-handover";
1006
+ } | {
1007
+ kind: "automatic";
1008
+ };
1009
+ };
1010
+ tier: string;
1011
+ } | {
1012
+ kind: "points";
1013
+ balance: string;
1014
+ amount: number;
1015
+ } | {
1016
+ kind: "integration";
1017
+ provider: "discord";
1018
+ action: "grant-role";
1019
+ roleId: string;
1020
+ })[] | ((ctx: {
1021
+ settings: z.core.$InferObjectOutput<T, {}>;
1022
+ }) => Reward[]);
1023
+ evaluate?: Evaluator<z.core.$InferObjectOutput<T, {}>, QuestInput<G>, NoInfer<G>, NoInfer<D>> | undefined;
1024
+ /**
1025
+ * A content quest's performance stage: once content evaluation accepts an item, each later
1026
+ * complete and fresh sample of `metrics` (a subset of the tracker's declared metrics) gates the
1027
+ * rewards it selected.
1028
+ */
1029
+ performance?: (IsContent<G> extends true ? {
1030
+ metrics: M & readonly TriggerMetrics<G>[];
1031
+ maxAgeMs?: number;
1032
+ evaluate: (ctx: PerformanceContext<z.core.$InferObjectOutput<T, {}>, G, M[number]>) => PerformanceOutcome | Promise<PerformanceOutcome>;
1033
+ } : never) | undefined;
1034
+ }) => {
1035
+ protocol: number;
662
1036
  key: string;
663
- /** @deprecated Authoring key alias. Use key. */
664
- id: string;
665
1037
  describe: (input: unknown) => {
666
1038
  quest: string;
667
- runtimeVersion: 1 | 2;
1039
+ evaluatorProtocol: 2;
668
1040
  title: string;
669
1041
  presentation: {
670
1042
  quiz?: {
@@ -686,7 +1058,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
686
1058
  } | undefined;
687
1059
  } | undefined;
688
1060
  };
689
- integrations: "discord"[];
1061
+ integrations: ("discord" | "x")[];
690
1062
  fields: Record<string, {
691
1063
  kind: "point-ledger";
692
1064
  default: string;
@@ -701,12 +1073,12 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
701
1073
  kind: "resource";
702
1074
  default: string;
703
1075
  source: {
1076
+ provider: "domino";
1077
+ resource: "point-ledger";
1078
+ } | {
704
1079
  provider: "discord";
705
1080
  resource: "channel";
706
1081
  types: ("text" | "announcement")[];
707
- } | {
708
- provider: "domino";
709
- resource: "point-ledger";
710
1082
  } | {
711
1083
  provider: "discord";
712
1084
  resource: "role";
@@ -777,6 +1149,8 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
777
1149
  };
778
1150
  fulfillment: {
779
1151
  kind: "staff-handover";
1152
+ } | {
1153
+ kind: "automatic";
780
1154
  };
781
1155
  };
782
1156
  tier: string;
@@ -792,26 +1166,33 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
792
1166
  })[];
793
1167
  humanReview: boolean;
794
1168
  trigger: {
1169
+ kind: "manual";
1170
+ input: "text";
1171
+ constraints: {
1172
+ required: boolean;
1173
+ minLength: number;
1174
+ maxLength: number;
1175
+ };
1176
+ actor?: "staff" | "member" | undefined;
1177
+ } | {
1178
+ kind: "manual";
1179
+ input: "url";
1180
+ constraints: {
1181
+ required: boolean;
1182
+ allowedHosts?: string[] | undefined;
1183
+ };
1184
+ actor?: "staff" | "member" | undefined;
1185
+ } | {
1186
+ kind: "manual";
1187
+ input: "photo" | "quiz" | "none";
1188
+ actor?: "staff" | "member" | undefined;
1189
+ } | {
795
1190
  kind: "automatic";
796
- observation?: {
797
- source: string;
798
- type: string;
799
- } | undefined;
800
- content?: {
801
- tracker: string;
802
- window: {
803
- start: number;
804
- end?: number | undefined;
805
- };
806
- enrollment: "none" | "required";
807
- posts: "after-enrollment" | "since-start";
808
- historical: "automatic" | "claim" | "staff";
809
- } | undefined;
810
1191
  tracker?: {
811
1192
  tracker: string;
812
- source: "custom" | "x-search";
1193
+ source: string;
1194
+ on: "new-record" | "new-observation" | "data-changed";
813
1195
  beneficiary: string;
814
- on?: "new-record" | "new-observation" | "data-changed" | undefined;
815
1196
  where?: {
816
1197
  path: string;
817
1198
  gt?: number | {
@@ -829,17 +1210,363 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
829
1210
  } | {
830
1211
  path: string;
831
1212
  equals: string | number | boolean;
832
- } | undefined;
833
- } | undefined;
834
- } | {
835
- kind: "manual";
836
- input: "text";
837
- constraints: {
838
- required: boolean;
1213
+ } | ({
1214
+ path: string;
1215
+ gt?: number | {
1216
+ setting: string;
1217
+ } | undefined;
1218
+ gte?: number | {
1219
+ setting: string;
1220
+ } | undefined;
1221
+ lt?: number | {
1222
+ setting: string;
1223
+ } | undefined;
1224
+ lte?: number | {
1225
+ setting: string;
1226
+ } | undefined;
1227
+ } | {
1228
+ path: string;
1229
+ equals: string | number | boolean;
1230
+ })[] | undefined;
1231
+ enrollment?: "required" | "none" | undefined;
1232
+ since?: "activation" | "window" | "enrollment" | undefined;
1233
+ historical?: "automatic" | "staff" | "claim" | undefined;
1234
+ content?: true | undefined;
1235
+ } | undefined;
1236
+ };
1237
+ requires: ({
1238
+ kind: "completion";
1239
+ quest: string;
1240
+ scope: "ever";
1241
+ } | {
1242
+ kind: "completion";
1243
+ quest: string;
1244
+ scope: "period";
1245
+ period: "day" | "week" | "month";
1246
+ } | {
1247
+ kind: "balance";
1248
+ balance: string;
1249
+ minimum: number;
1250
+ } | {
1251
+ kind: "group";
1252
+ group: string;
1253
+ title: string;
1254
+ })[];
1255
+ completion: {
1256
+ kind: "streak";
1257
+ days: number;
1258
+ } | {
1259
+ kind: "progress";
1260
+ goal: {
1261
+ kind: "count";
1262
+ count: number;
1263
+ };
1264
+ window: {
1265
+ kind: "lifetime";
1266
+ } | {
1267
+ kind: "calendar";
1268
+ period: "day" | "week" | "month";
1269
+ latenessMs: number;
1270
+ } | {
1271
+ kind: "rolling";
1272
+ durationMs: number;
1273
+ };
1274
+ repeat: "repeat" | "once";
1275
+ } | {
1276
+ kind: "once";
1277
+ } | {
1278
+ kind: "keyed";
1279
+ };
1280
+ visibility: "visible" | "hidden";
1281
+ profile: {
1282
+ visible: boolean;
1283
+ };
1284
+ budgets: {
1285
+ id: string;
1286
+ scope: "member" | "project";
1287
+ period: "lifetime" | "day" | "week" | "month";
1288
+ limit: number;
1289
+ cost: number | {
1290
+ balance: string;
1291
+ };
1292
+ }[];
1293
+ performance?: {
1294
+ metrics: string[];
1295
+ maxAgeMs: number;
1296
+ } | undefined;
1297
+ campaign?: {
1298
+ key: string;
1299
+ title: string;
1300
+ enrollment: "required" | "none";
1301
+ window?: {
1302
+ from: number;
1303
+ until: number;
1304
+ } | undefined;
1305
+ } | undefined;
1306
+ availability?: {
1307
+ from: number;
1308
+ until: number;
1309
+ } | undefined;
1310
+ };
1311
+ evaluate(ctx: {
1312
+ settings: unknown;
1313
+ member: EvaluationMember;
1314
+ input: QuestInput<G>;
1315
+ /**
1316
+ * The tracker observation that admitted this attempt, and the member and verified account it
1317
+ * was attributed to. Present for a tracker trigger, with `record.data` of the tracker's type.
1318
+ * On a content source, `content` holds the body revision being evaluated, with the source's
1319
+ * body type.
1320
+ */
1321
+ tracker: TrackerTriggerContext | null;
1322
+ /**
1323
+ * When the activity happened, in epoch milliseconds: the tracker record's occurrence time, else
1324
+ * when the attempt was admitted. Budgets and daily keys use it.
1325
+ */
1326
+ eligibleAt: number;
1327
+ /** The project calendar pinned when this evaluation run started. */
1328
+ calendar: EvaluationCalendar;
1329
+ /**
1330
+ * The current evaluation run's start time in epoch milliseconds.
1331
+ * Retries and replays of that run receive the same value; a scheduled defer starts a fresh run, and the sandbox freezes
1332
+ * `Date.now()` and `new Date()` at it. Use `eligibleAt` for when the activity
1333
+ * happened.
1334
+ */
1335
+ now: number;
1336
+ trackers: TrackerReader;
1337
+ images: ImageReader;
1338
+ review: {
1339
+ text(options: TextReviewInput): Promise<TextResult>;
1340
+ photo(options: {
1341
+ image: string;
1342
+ criteria: string;
1343
+ }): Promise<PhotoResult>;
1344
+ };
1345
+ wallet: WalletReader;
1346
+ } & IntegrationReaders<readonly IntegrationModule[]> & {
1347
+ rewards: Reward[];
1348
+ humanReview: boolean;
1349
+ performance?: unknown;
1350
+ }): Promise<Decision>;
1351
+ } & ResourceHandle<"quest">;
1352
+ /** Publish this artifact as a reusable type. Its key names the type;
1353
+ * Console instances receive independent quest identities and pinned versions. */
1354
+ declare const defineQuestType: <T extends Record<string, Setting>, const G extends Trigger, const D extends readonly IntegrationModule[] = readonly [], const M extends readonly [string, ...string[]] = readonly [string, ...string[]]>(definition: AuthoringIdentity & CompletionFor<G> & {
1355
+ title: string | ((ctx: {
1356
+ settings: z.core.$InferObjectOutput<T, {}>;
1357
+ }) => string);
1358
+ settings: z.ZodObject<T, z.core.$strip>;
1359
+ presentation?: ((ctx: {
1360
+ settings: z.core.$InferObjectOutput<T, {}>;
1361
+ }) => QuestPresentation) | undefined;
1362
+ trigger: G & NoInfer<IntegerSettingBounds<G, T>>;
1363
+ integrations?: D | undefined;
1364
+ requires?: readonly Prerequisite[];
1365
+ campaign?: CampaignDefinition;
1366
+ availability?: AvailabilityWindow;
1367
+ visibility?: "visible" | "hidden";
1368
+ /**
1369
+ * `{ visible: true }` lists the quest's completions on participant profiles
1370
+ * (`relay.profiles.completions`). Hidden by default.
1371
+ */
1372
+ profile?: QuestProfile;
1373
+ budgets?: Budget[];
1374
+ /**
1375
+ * Whether staff can review this quest's attempts. Human review is on unless this returns
1376
+ * `{ enabled: false }`. With it off, `decision.review(...)` becomes a reject that keeps the
1377
+ * review reason, and the attempt records `requestedReview: true`; Console shows "Would have
1378
+ * gone to review; human review is off".
1379
+ */
1380
+ review?: ((ctx: {
1381
+ settings: z.core.$InferObjectOutput<T, {}>;
1382
+ }) => {
1383
+ enabled: boolean;
1384
+ }) | undefined;
1385
+ rewards: ({
1386
+ kind: "tier";
1387
+ reward: {
1388
+ id: string;
1389
+ title: string;
1390
+ tiers: {
1391
+ id: string;
1392
+ title: string;
1393
+ }[];
1394
+ inventory: {
1395
+ kind: "untracked";
1396
+ };
1397
+ fulfillment: {
1398
+ kind: "staff-handover";
1399
+ } | {
1400
+ kind: "automatic";
1401
+ };
1402
+ };
1403
+ tier: string;
1404
+ } | {
1405
+ kind: "points";
1406
+ balance: string;
1407
+ amount: number;
1408
+ } | {
1409
+ kind: "integration";
1410
+ provider: "discord";
1411
+ action: "grant-role";
1412
+ roleId: string;
1413
+ })[] | ((ctx: {
1414
+ settings: z.core.$InferObjectOutput<T, {}>;
1415
+ }) => Reward[]);
1416
+ evaluate?: Evaluator<z.core.$InferObjectOutput<T, {}>, QuestInput<G>, NoInfer<G>, NoInfer<D>> | undefined;
1417
+ /**
1418
+ * A content quest's performance stage: once content evaluation accepts an item, each later
1419
+ * complete and fresh sample of `metrics` (a subset of the tracker's declared metrics) gates the
1420
+ * rewards it selected.
1421
+ */
1422
+ performance?: (IsContent<G> extends true ? {
1423
+ metrics: M & readonly TriggerMetrics<G>[];
1424
+ maxAgeMs?: number;
1425
+ evaluate: (ctx: PerformanceContext<z.core.$InferObjectOutput<T, {}>, G, M[number]>) => PerformanceOutcome | Promise<PerformanceOutcome>;
1426
+ } : never) | undefined;
1427
+ }) => {
1428
+ protocol: number;
1429
+ key: string;
1430
+ describe: (input: unknown) => {
1431
+ quest: string;
1432
+ evaluatorProtocol: 2;
1433
+ title: string;
1434
+ presentation: {
1435
+ quiz?: {
1436
+ id: string;
1437
+ prompt: string;
1438
+ choices: {
1439
+ id: string;
1440
+ label: string;
1441
+ }[];
1442
+ }[] | undefined;
1443
+ instructions?: string | undefined;
1444
+ video?: {
1445
+ url: string;
1446
+ poster?: string | undefined;
1447
+ captions?: {
1448
+ url: string;
1449
+ language: string;
1450
+ label: string;
1451
+ } | undefined;
1452
+ } | undefined;
1453
+ };
1454
+ integrations: ("discord" | "x")[];
1455
+ fields: Record<string, {
1456
+ kind: "point-ledger";
1457
+ default: string;
1458
+ label: string;
1459
+ description?: string | undefined;
1460
+ } | {
1461
+ kind: "datetime";
1462
+ default: string;
1463
+ label: string;
1464
+ description?: string | undefined;
1465
+ } | {
1466
+ kind: "resource";
1467
+ default: string;
1468
+ source: {
1469
+ provider: "domino";
1470
+ resource: "point-ledger";
1471
+ } | {
1472
+ provider: "discord";
1473
+ resource: "channel";
1474
+ types: ("text" | "announcement")[];
1475
+ } | {
1476
+ provider: "discord";
1477
+ resource: "role";
1478
+ assignable: boolean;
1479
+ };
1480
+ label: string;
1481
+ description?: string | undefined;
1482
+ } | {
1483
+ kind: "quiz";
1484
+ default: {
1485
+ id: string;
1486
+ prompt: string;
1487
+ choices: {
1488
+ id: string;
1489
+ label: string;
1490
+ }[];
1491
+ correct: string;
1492
+ }[];
1493
+ label: string;
1494
+ description?: string | undefined;
1495
+ } | {
1496
+ kind: "text";
1497
+ default: string;
1498
+ minLength: number;
1499
+ maxLength: number;
1500
+ multiline: boolean;
1501
+ label: string;
1502
+ description?: string | undefined;
1503
+ } | {
1504
+ kind: "integer";
1505
+ default: number;
1506
+ min: number;
1507
+ max: number;
1508
+ label: string;
1509
+ description?: string | undefined;
1510
+ } | {
1511
+ kind: "boolean";
1512
+ default: boolean;
1513
+ label: string;
1514
+ description?: string | undefined;
1515
+ } | {
1516
+ kind: "choice";
1517
+ default: string;
1518
+ options: string[];
1519
+ label: string;
1520
+ description?: string | undefined;
1521
+ }>;
1522
+ values: Record<string, string | number | boolean | {
1523
+ id: string;
1524
+ prompt: string;
1525
+ choices: {
1526
+ id: string;
1527
+ label: string;
1528
+ }[];
1529
+ correct: string;
1530
+ }[]>;
1531
+ rewards: ({
1532
+ kind: "tier";
1533
+ reward: {
1534
+ id: string;
1535
+ title: string;
1536
+ tiers: {
1537
+ id: string;
1538
+ title: string;
1539
+ }[];
1540
+ inventory: {
1541
+ kind: "untracked";
1542
+ };
1543
+ fulfillment: {
1544
+ kind: "staff-handover";
1545
+ } | {
1546
+ kind: "automatic";
1547
+ };
1548
+ };
1549
+ tier: string;
1550
+ } | {
1551
+ kind: "points";
1552
+ balance: string;
1553
+ amount: number;
1554
+ } | {
1555
+ kind: "integration";
1556
+ provider: "discord";
1557
+ action: "grant-role";
1558
+ roleId: string;
1559
+ })[];
1560
+ humanReview: boolean;
1561
+ trigger: {
1562
+ kind: "manual";
1563
+ input: "text";
1564
+ constraints: {
1565
+ required: boolean;
839
1566
  minLength: number;
840
1567
  maxLength: number;
841
1568
  };
842
- actor?: "member" | "staff" | undefined;
1569
+ actor?: "staff" | "member" | undefined;
843
1570
  } | {
844
1571
  kind: "manual";
845
1572
  input: "url";
@@ -847,50 +1574,173 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
847
1574
  required: boolean;
848
1575
  allowedHosts?: string[] | undefined;
849
1576
  };
850
- actor?: "member" | "staff" | undefined;
1577
+ actor?: "staff" | "member" | undefined;
851
1578
  } | {
852
1579
  kind: "manual";
853
- input: "none" | "quiz" | "photo";
854
- actor?: "member" | "staff" | undefined;
1580
+ input: "photo" | "quiz" | "none";
1581
+ actor?: "staff" | "member" | undefined;
1582
+ } | {
1583
+ kind: "automatic";
1584
+ tracker?: {
1585
+ tracker: string;
1586
+ source: string;
1587
+ on: "new-record" | "new-observation" | "data-changed";
1588
+ beneficiary: string;
1589
+ where?: {
1590
+ path: string;
1591
+ gt?: number | {
1592
+ setting: string;
1593
+ } | undefined;
1594
+ gte?: number | {
1595
+ setting: string;
1596
+ } | undefined;
1597
+ lt?: number | {
1598
+ setting: string;
1599
+ } | undefined;
1600
+ lte?: number | {
1601
+ setting: string;
1602
+ } | undefined;
1603
+ } | {
1604
+ path: string;
1605
+ equals: string | number | boolean;
1606
+ } | ({
1607
+ path: string;
1608
+ gt?: number | {
1609
+ setting: string;
1610
+ } | undefined;
1611
+ gte?: number | {
1612
+ setting: string;
1613
+ } | undefined;
1614
+ lt?: number | {
1615
+ setting: string;
1616
+ } | undefined;
1617
+ lte?: number | {
1618
+ setting: string;
1619
+ } | undefined;
1620
+ } | {
1621
+ path: string;
1622
+ equals: string | number | boolean;
1623
+ })[] | undefined;
1624
+ enrollment?: "required" | "none" | undefined;
1625
+ since?: "activation" | "window" | "enrollment" | undefined;
1626
+ historical?: "automatic" | "staff" | "claim" | undefined;
1627
+ content?: true | undefined;
1628
+ } | undefined;
855
1629
  };
856
- requires: {
1630
+ requires: ({
1631
+ kind: "completion";
857
1632
  quest: string;
858
- }[];
1633
+ scope: "ever";
1634
+ } | {
1635
+ kind: "completion";
1636
+ quest: string;
1637
+ scope: "period";
1638
+ period: "day" | "week" | "month";
1639
+ } | {
1640
+ kind: "balance";
1641
+ balance: string;
1642
+ minimum: number;
1643
+ } | {
1644
+ kind: "group";
1645
+ group: string;
1646
+ title: string;
1647
+ })[];
859
1648
  completion: {
860
1649
  kind: "streak";
861
1650
  days: number;
862
- timeZone: string;
1651
+ } | {
1652
+ kind: "progress";
1653
+ goal: {
1654
+ kind: "count";
1655
+ count: number;
1656
+ };
1657
+ window: {
1658
+ kind: "lifetime";
1659
+ } | {
1660
+ kind: "calendar";
1661
+ period: "day" | "week" | "month";
1662
+ latenessMs: number;
1663
+ } | {
1664
+ kind: "rolling";
1665
+ durationMs: number;
1666
+ };
1667
+ repeat: "repeat" | "once";
863
1668
  } | {
864
1669
  kind: "once";
865
1670
  } | {
866
1671
  kind: "keyed";
867
1672
  };
868
1673
  visibility: "visible" | "hidden";
1674
+ profile: {
1675
+ visible: boolean;
1676
+ };
869
1677
  budgets: {
870
1678
  id: string;
871
1679
  scope: "member" | "project";
872
- period: "day" | "lifetime" | "week";
1680
+ period: "lifetime" | "day" | "week" | "month";
873
1681
  limit: number;
874
1682
  cost: number | {
875
1683
  balance: string;
876
1684
  };
877
1685
  }[];
878
1686
  performance?: {
879
- metrics: ("likes" | "replies" | "reposts" | "quotes" | "views" | "bookmarks")[];
1687
+ metrics: string[];
880
1688
  maxAgeMs: number;
881
1689
  } | undefined;
882
- profile?: {
883
- visible: boolean;
1690
+ campaign?: {
1691
+ key: string;
1692
+ title: string;
1693
+ enrollment: "required" | "none";
1694
+ window?: {
1695
+ from: number;
1696
+ until: number;
1697
+ } | undefined;
1698
+ } | undefined;
1699
+ availability?: {
1700
+ from: number;
1701
+ until: number;
884
1702
  } | undefined;
885
1703
  };
886
- evaluate(ctx: EvaluationContext<unknown, QuestInput<G>> & {
1704
+ evaluate(ctx: {
1705
+ settings: unknown;
1706
+ member: EvaluationMember;
1707
+ input: QuestInput<G>;
1708
+ /**
1709
+ * The tracker observation that admitted this attempt, and the member and verified account it
1710
+ * was attributed to. Present for a tracker trigger, with `record.data` of the tracker's type.
1711
+ * On a content source, `content` holds the body revision being evaluated, with the source's
1712
+ * body type.
1713
+ */
1714
+ tracker: TrackerTriggerContext | null;
1715
+ /**
1716
+ * When the activity happened, in epoch milliseconds: the tracker record's occurrence time, else
1717
+ * when the attempt was admitted. Budgets and daily keys use it.
1718
+ */
1719
+ eligibleAt: number;
1720
+ /** The project calendar pinned when this evaluation run started. */
1721
+ calendar: EvaluationCalendar;
1722
+ /**
1723
+ * The current evaluation run's start time in epoch milliseconds.
1724
+ * Retries and replays of that run receive the same value; a scheduled defer starts a fresh run, and the sandbox freezes
1725
+ * `Date.now()` and `new Date()` at it. Use `eligibleAt` for when the activity
1726
+ * happened.
1727
+ */
1728
+ now: number;
1729
+ trackers: TrackerReader;
1730
+ images: ImageReader;
1731
+ review: {
1732
+ text(options: TextReviewInput): Promise<TextResult>;
1733
+ photo(options: {
1734
+ image: string;
1735
+ criteria: string;
1736
+ }): Promise<PhotoResult>;
1737
+ };
1738
+ wallet: WalletReader;
1739
+ } & IntegrationReaders<readonly IntegrationModule[]> & {
887
1740
  rewards: Reward[];
888
1741
  humanReview: boolean;
889
1742
  performance?: unknown;
890
1743
  }): Promise<Decision>;
891
- };
892
- /** Publish this artifact as a reusable type. Its key names the type;
893
- * Console instances receive independent quest identities and pinned versions. */
894
- declare const defineQuestType: typeof defineQuest;
1744
+ } & ResourceHandle<"quest">;
895
1745
 
896
- export { type EvaluationContext, ImageReader, type PerformanceOutcome, TrackerReader, TrackerTriggerContext, type TrackerTriggerInput, WalletBalance, WalletBalanceQuery, XReader, automatic, budget, completed, content, customSource, decision, defineEngagementReward, defineLeaderboard, defineQuest, defineQuestType, defineReferral, defineTieredReward, defineTracker, discord, discordRole, evaluators, evidence, keyed, manual, once, perContent, pointLedgers, points, settings, staffHandover, streak, untracked, x };
1746
+ export { ContentBody, type ContentData, ContentMetricName, type ContentTrigger, type ContentTriggerInput, DiscordMessageData, DiscordMessageTextData, DiscordReactionData, DiscordReader, type EvaluationCalendar, type EvaluationCalendarDay, type EvaluationContext, type EvaluationMember, GroupHandle, IdentityKind, ImageReader, IntegrationModule, type KeyedContext, LedgerHandle, LedgerReference, MemberIdentity, type Outcome, type PerformanceContext, type PerformanceOutcome, QuestHandle, RoleOf, Setting, Tracker, TrackerData, TrackerReader, type TrackerTrigger, TrackerTriggerContext, type TrackerTriggerInput, type TriggerAdmission, WalletReader, Where, type XContentBody, XReader, automatic, automaticFulfillment, budget, calendar, content, count, customSource, decision, defineEngagementReward, defineLeaderboard, defineLedger, defineQuest, defineQuestType, defineReferral, defineTieredReward, defineTracker, discord, earned, evaluators, evidence, keyed, manual, once, pointLedgers, points, progress, questCompleted, rolling, settings, staffHandover, streak, untracked, x };