@getuserfeedback/protocol 3.0.14 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ export declare const attentionExclusiveSurfaceStrategySchema: z.ZodMiniEnum<{
9
9
  export declare const attentionBlockedBroadcastStrategySchema: z.ZodMiniEnum<{
10
10
  queue: "queue";
11
11
  }>;
12
- export declare const attentionPolicyConfigSchema: z.ZodMiniObject<{
12
+ export declare const legacyAttentionPolicyConfigSchema: z.ZodMiniObject<{
13
13
  version: z.ZodMiniString<string>;
14
14
  source: z.ZodMiniEnum<{
15
15
  default: "default";
@@ -23,6 +23,21 @@ export declare const attentionPolicyConfigSchema: z.ZodMiniObject<{
23
23
  queue: "queue";
24
24
  }>;
25
25
  }, z.core.$strict>;
26
+ export declare const attentionPolicyConfigSchema: z.ZodMiniObject<{
27
+ recentInAppCooldownMs: z.ZodMiniDefault<z.ZodMiniNumber<number>>;
28
+ version: z.ZodMiniString<string>;
29
+ source: z.ZodMiniEnum<{
30
+ default: "default";
31
+ custom: "custom";
32
+ }>;
33
+ recentFlowCooldownMs: z.ZodMiniNumber<number>;
34
+ exclusiveSurfaceStrategy: z.ZodMiniEnum<{
35
+ queue: "queue";
36
+ }>;
37
+ blockedBroadcastStrategy: z.ZodMiniEnum<{
38
+ queue: "queue";
39
+ }>;
40
+ }, z.core.$loose>;
26
41
  export type AttentionPolicyConfig = z.output<typeof attentionPolicyConfigSchema>;
27
42
  export declare const DEFAULT_ATTENTION_POLICY_CONFIG: AttentionPolicyConfig;
28
43
  //# sourceMappingURL=attention-policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attention-policy.d.ts","sourceRoot":"","sources":["../src/attention-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,eAAO,MAAM,2BAA2B;;;EAAgC,CAAC;AAEzE,eAAO,MAAM,uCAAuC;;EAAoB,CAAC;AAEzE,eAAO,MAAM,uCAAuC;;EAAoB,CAAC;AAEzE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;kBAMtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAC3C,OAAO,2BAA2B,CAClC,CAAC;AAEF,eAAO,MAAM,+BAA+B,EAAE,qBAM7C,CAAC"}
1
+ {"version":3,"file":"attention-policy.d.ts","sourceRoot":"","sources":["../src/attention-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,eAAO,MAAM,2BAA2B;;;EAAgC,CAAC;AAEzE,eAAO,MAAM,uCAAuC;;EAAoB,CAAC;AAEzE,eAAO,MAAM,uCAAuC;;EAAoB,CAAC;AAUzE,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;kBAE7C,CAAC;AAKF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;iBAGtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAC3C,OAAO,2BAA2B,CAClC,CAAC;AAEF,eAAO,MAAM,+BAA+B,EAAE,qBAO7C,CAAC"}
@@ -2,17 +2,26 @@ import * as z from "zod/mini";
2
2
  export const attentionPolicySourceSchema = z.enum(["default", "custom"]);
3
3
  export const attentionExclusiveSurfaceStrategySchema = z.enum(["queue"]);
4
4
  export const attentionBlockedBroadcastStrategySchema = z.enum(["queue"]);
5
- export const attentionPolicyConfigSchema = z.strictObject({
5
+ const legacyAttentionPolicyConfigFields = {
6
6
  version: z.string().check(z.trim(), z.minLength(1)),
7
7
  source: attentionPolicySourceSchema,
8
8
  recentFlowCooldownMs: z.number().check(z.positive()),
9
9
  exclusiveSurfaceStrategy: attentionExclusiveSurfaceStrategySchema,
10
10
  blockedBroadcastStrategy: attentionBlockedBroadcastStrategySchema,
11
+ };
12
+ export const legacyAttentionPolicyConfigSchema = z.strictObject(legacyAttentionPolicyConfigFields);
13
+ // V2 is the additive policy envelope for the flow-display wire contract.
14
+ // Keep legacy strict, and add future policy controls here instead of creating
15
+ // another versioned sibling field for every new setting.
16
+ export const attentionPolicyConfigSchema = z.looseObject({
17
+ ...legacyAttentionPolicyConfigFields,
18
+ recentInAppCooldownMs: z._default(z.number().check(z.nonnegative()), 0),
11
19
  });
12
20
  export const DEFAULT_ATTENTION_POLICY_CONFIG = {
13
21
  version: "attention-policy-default-v1",
14
22
  source: "default",
15
23
  recentFlowCooldownMs: 5 * 60 * 1000,
24
+ recentInAppCooldownMs: 0,
16
25
  exclusiveSurfaceStrategy: "queue",
17
26
  blockedBroadcastStrategy: "queue",
18
27
  };
@@ -42,7 +42,7 @@ export declare const coreCommandEnvelopeSchema: z.ZodMiniObject<{
42
42
  }, z.core.$strip>>;
43
43
  notes: z.ZodMiniOptional<z.ZodMiniString<string>>;
44
44
  }, z.core.$strip>>;
45
- command: z.ZodMiniUnion<readonly [z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
45
+ command: z.ZodMiniUnion<readonly [z.ZodMiniUnion<readonly [z.ZodMiniUnion<readonly [z.ZodMiniObject<{
46
46
  kind: z.ZodMiniLiteral<"open">;
47
47
  flowId: z.ZodMiniString<string>;
48
48
  flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
@@ -51,15 +51,53 @@ export declare const coreCommandEnvelopeSchema: z.ZodMiniObject<{
51
51
  }, z.core.$strict>>;
52
52
  hideCloseButton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
53
53
  }, z.core.$strict>, z.ZodMiniObject<{
54
+ kind: z.ZodMiniLiteral<"open">;
55
+ flow: z.ZodMiniObject<{
56
+ definition: z.ZodMiniUnknown;
57
+ theme: z.ZodMiniOptional<z.ZodMiniObject<{
58
+ css: z.ZodMiniOptional<z.ZodMiniString<string>>;
59
+ themeRuntimeArtifactId: z.ZodMiniOptional<z.ZodMiniString<string>>;
60
+ themeVersionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
61
+ }, z.core.$strict>>;
62
+ }, z.core.$strict>;
63
+ flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
64
+ metadata: z.ZodMiniOptional<z.ZodMiniObject<{
65
+ tags: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>>;
66
+ }, z.core.$strict>>;
67
+ hideCloseButton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
68
+ }, z.core.$strict>]>, z.ZodMiniUnion<readonly [z.ZodMiniObject<{
54
69
  kind: z.ZodMiniLiteral<"prefetch">;
55
70
  flowId: z.ZodMiniString<string>;
56
71
  flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
57
72
  }, z.core.$strict>, z.ZodMiniObject<{
73
+ kind: z.ZodMiniLiteral<"prefetch">;
74
+ flow: z.ZodMiniObject<{
75
+ definition: z.ZodMiniUnknown;
76
+ theme: z.ZodMiniOptional<z.ZodMiniObject<{
77
+ css: z.ZodMiniOptional<z.ZodMiniString<string>>;
78
+ themeRuntimeArtifactId: z.ZodMiniOptional<z.ZodMiniString<string>>;
79
+ themeVersionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
80
+ }, z.core.$strict>>;
81
+ }, z.core.$strict>;
82
+ flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
83
+ }, z.core.$strict>]>, z.ZodMiniUnion<readonly [z.ZodMiniObject<{
58
84
  kind: z.ZodMiniLiteral<"prerender">;
59
85
  flowId: z.ZodMiniString<string>;
60
86
  flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
61
87
  hideCloseButton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
62
88
  }, z.core.$strict>, z.ZodMiniObject<{
89
+ kind: z.ZodMiniLiteral<"prerender">;
90
+ flow: z.ZodMiniObject<{
91
+ definition: z.ZodMiniUnknown;
92
+ theme: z.ZodMiniOptional<z.ZodMiniObject<{
93
+ css: z.ZodMiniOptional<z.ZodMiniString<string>>;
94
+ themeRuntimeArtifactId: z.ZodMiniOptional<z.ZodMiniString<string>>;
95
+ themeVersionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
96
+ }, z.core.$strict>>;
97
+ }, z.core.$strict>;
98
+ flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
99
+ hideCloseButton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
100
+ }, z.core.$strict>]>, z.ZodMiniObject<{
63
101
  kind: z.ZodMiniLiteral<"hostContextUpdated">;
64
102
  context: z.ZodMiniObject<{
65
103
  url: z.ZodMiniString<string>;
@@ -346,7 +384,7 @@ export declare const coreCommandEnvelopeSchema: z.ZodMiniObject<{
346
384
  debug: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
347
385
  }, z.core.$strip>;
348
386
  }, z.core.$strip>;
349
- }, z.core.$strip>], "kind">, z.ZodMiniUnion<readonly [z.ZodMiniObject<{
387
+ }, z.core.$strip>]>, z.ZodMiniUnion<readonly [z.ZodMiniObject<{
350
388
  kind: z.ZodMiniLiteral<"identify">;
351
389
  traits: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
352
390
  options: z.ZodMiniOptional<z.ZodMiniObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"core-command-envelope.d.ts","sourceRoot":"","sources":["../src/core-command-envelope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAOrE,sEAAsE;AACtE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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MiniUnion<readonly [z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
2
+ export declare const coreCommandPayloadSchema: z.ZodMiniUnion<readonly [z.ZodMiniUnion<readonly [z.ZodMiniUnion<readonly [z.ZodMiniObject<{
3
3
  kind: z.ZodMiniLiteral<"open">;
4
4
  flowId: z.ZodMiniString<string>;
5
5
  flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
@@ -8,15 +8,53 @@ export declare const coreCommandPayloadSchema: z.ZodMiniUnion<readonly [z.ZodMin
8
8
  }, z.core.$strict>>;
9
9
  hideCloseButton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
10
10
  }, z.core.$strict>, z.ZodMiniObject<{
11
+ kind: z.ZodMiniLiteral<"open">;
12
+ flow: z.ZodMiniObject<{
13
+ definition: z.ZodMiniUnknown;
14
+ theme: z.ZodMiniOptional<z.ZodMiniObject<{
15
+ css: z.ZodMiniOptional<z.ZodMiniString<string>>;
16
+ themeRuntimeArtifactId: z.ZodMiniOptional<z.ZodMiniString<string>>;
17
+ themeVersionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
18
+ }, z.core.$strict>>;
19
+ }, z.core.$strict>;
20
+ flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
21
+ metadata: z.ZodMiniOptional<z.ZodMiniObject<{
22
+ tags: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>>;
23
+ }, z.core.$strict>>;
24
+ hideCloseButton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
25
+ }, z.core.$strict>]>, z.ZodMiniUnion<readonly [z.ZodMiniObject<{
11
26
  kind: z.ZodMiniLiteral<"prefetch">;
12
27
  flowId: z.ZodMiniString<string>;
13
28
  flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
14
29
  }, z.core.$strict>, z.ZodMiniObject<{
30
+ kind: z.ZodMiniLiteral<"prefetch">;
31
+ flow: z.ZodMiniObject<{
32
+ definition: z.ZodMiniUnknown;
33
+ theme: z.ZodMiniOptional<z.ZodMiniObject<{
34
+ css: z.ZodMiniOptional<z.ZodMiniString<string>>;
35
+ themeRuntimeArtifactId: z.ZodMiniOptional<z.ZodMiniString<string>>;
36
+ themeVersionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
37
+ }, z.core.$strict>>;
38
+ }, z.core.$strict>;
39
+ flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
40
+ }, z.core.$strict>]>, z.ZodMiniUnion<readonly [z.ZodMiniObject<{
15
41
  kind: z.ZodMiniLiteral<"prerender">;
16
42
  flowId: z.ZodMiniString<string>;
17
43
  flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
18
44
  hideCloseButton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
19
45
  }, z.core.$strict>, z.ZodMiniObject<{
46
+ kind: z.ZodMiniLiteral<"prerender">;
47
+ flow: z.ZodMiniObject<{
48
+ definition: z.ZodMiniUnknown;
49
+ theme: z.ZodMiniOptional<z.ZodMiniObject<{
50
+ css: z.ZodMiniOptional<z.ZodMiniString<string>>;
51
+ themeRuntimeArtifactId: z.ZodMiniOptional<z.ZodMiniString<string>>;
52
+ themeVersionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
53
+ }, z.core.$strict>>;
54
+ }, z.core.$strict>;
55
+ flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
56
+ hideCloseButton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
57
+ }, z.core.$strict>]>, z.ZodMiniObject<{
20
58
  kind: z.ZodMiniLiteral<"hostContextUpdated">;
21
59
  context: z.ZodMiniObject<{
22
60
  url: z.ZodMiniString<string>;
@@ -303,7 +341,7 @@ export declare const coreCommandPayloadSchema: z.ZodMiniUnion<readonly [z.ZodMin
303
341
  debug: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
304
342
  }, z.core.$strip>;
305
343
  }, z.core.$strip>;
306
- }, z.core.$strip>], "kind">, z.ZodMiniUnion<readonly [z.ZodMiniObject<{
344
+ }, z.core.$strip>]>, z.ZodMiniUnion<readonly [z.ZodMiniObject<{
307
345
  kind: z.ZodMiniLiteral<"identify">;
308
346
  traits: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
309
347
  options: z.ZodMiniOptional<z.ZodMiniObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"core-commands.d.ts","sourceRoot":"","sources":["../src/core-commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AA6J9B,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,CAAC,CAAC"}
@@ -41,19 +41,56 @@ const prefetchPayloadSchema = z.strictObject({
41
41
  flowId: flowIdSchema,
42
42
  flowHandleId: z.optional(flowHandleIdSchema),
43
43
  });
44
- const openCorePayloadSchema = z.strictObject({
44
+ const inlineFlowThemeSchema = z.strictObject({
45
+ css: z.optional(z.string()),
46
+ themeRuntimeArtifactId: z.optional(z.string().check(z.trim(), z.minLength(1))),
47
+ themeVersionId: z.optional(z.string().check(z.trim(), z.minLength(1))),
48
+ });
49
+ const inlineFlowSchema = z.strictObject({
50
+ definition: z.unknown().check(z.check((ctx) => {
51
+ if (ctx.value !== undefined) {
52
+ return;
53
+ }
54
+ ctx.issues.push({
55
+ code: "custom",
56
+ input: ctx.value,
57
+ message: "Inline flow definition is required.",
58
+ continue: false,
59
+ });
60
+ })),
61
+ theme: z.optional(inlineFlowThemeSchema),
62
+ });
63
+ const prefetchInlinePayloadSchema = z.strictObject({
64
+ kind: z.literal("prefetch"),
65
+ flow: inlineFlowSchema,
66
+ flowHandleId: z.optional(flowHandleIdSchema),
67
+ });
68
+ const openPersistedCorePayloadSchema = z.strictObject({
45
69
  kind: z.literal("open"),
46
70
  flowId: flowIdSchema,
47
71
  flowHandleId: z.optional(flowHandleIdSchema),
48
72
  metadata: z.optional(responseMetadataInputSchema),
49
73
  hideCloseButton: z.optional(z.boolean()),
50
74
  });
51
- const prerenderCorePayloadSchema = z.strictObject({
75
+ const openInlineCorePayloadSchema = z.strictObject({
76
+ kind: z.literal("open"),
77
+ flow: inlineFlowSchema,
78
+ flowHandleId: z.optional(flowHandleIdSchema),
79
+ metadata: z.optional(responseMetadataInputSchema),
80
+ hideCloseButton: z.optional(z.boolean()),
81
+ });
82
+ const prerenderPersistedCorePayloadSchema = z.strictObject({
52
83
  kind: z.literal("prerender"),
53
84
  flowId: flowIdSchema,
54
85
  flowHandleId: z.optional(flowHandleIdSchema),
55
86
  hideCloseButton: z.optional(z.boolean()),
56
87
  });
88
+ const prerenderInlineCorePayloadSchema = z.strictObject({
89
+ kind: z.literal("prerender"),
90
+ flow: inlineFlowSchema,
91
+ flowHandleId: z.optional(flowHandleIdSchema),
92
+ hideCloseButton: z.optional(z.boolean()),
93
+ });
57
94
  const closeCorePayloadSchema = z.object({
58
95
  kind: z.literal("close"),
59
96
  flowHandleId: z.optional(flowHandleIdSchema),
@@ -108,10 +145,13 @@ const initCorePayloadSchema = z.strictObject({
108
145
  const resetPayloadSchema = z.object({
109
146
  kind: z.literal("reset"),
110
147
  });
111
- const coreCommandPayloadWithoutIdentifySchema = z.discriminatedUnion("kind", [
112
- openCorePayloadSchema,
113
- prefetchPayloadSchema,
114
- prerenderCorePayloadSchema,
148
+ const coreCommandPayloadWithoutIdentifySchema = z.union([
149
+ z.union([openPersistedCorePayloadSchema, openInlineCorePayloadSchema]),
150
+ z.union([prefetchPayloadSchema, prefetchInlinePayloadSchema]),
151
+ z.union([
152
+ prerenderPersistedCorePayloadSchema,
153
+ prerenderInlineCorePayloadSchema,
154
+ ]),
115
155
  hostContextUpdatedPayloadSchema,
116
156
  hostSignalPayloadSchema,
117
157
  setTargetingPlanPayloadSchema,
@@ -214,6 +214,21 @@ export declare const flowDisplaySyncResponseSchema: z.ZodMiniObject<{
214
214
  queue: "queue";
215
215
  }>;
216
216
  }, z.core.$strict>>;
217
+ attentionPolicyV2: z.ZodMiniOptional<z.ZodMiniObject<{
218
+ recentInAppCooldownMs: z.ZodMiniDefault<z.ZodMiniNumber<number>>;
219
+ version: z.ZodMiniString<string>;
220
+ source: z.ZodMiniEnum<{
221
+ default: "default";
222
+ custom: "custom";
223
+ }>;
224
+ recentFlowCooldownMs: z.ZodMiniNumber<number>;
225
+ exclusiveSurfaceStrategy: z.ZodMiniEnum<{
226
+ queue: "queue";
227
+ }>;
228
+ blockedBroadcastStrategy: z.ZodMiniEnum<{
229
+ queue: "queue";
230
+ }>;
231
+ }, z.core.$loose>>;
217
232
  assignments: z.ZodMiniObject<{
218
233
  claimed: z.ZodMiniArray<z.ZodMiniObject<{
219
234
  flowAssignmentId: z.ZodMiniString<string>;
@@ -288,4 +303,5 @@ export type RuntimeDisplayTrigger = z.output<typeof runtimeDisplayTriggerSchema>
288
303
  export type FlowDisplaySyncRequest = z.output<typeof flowDisplaySyncRequestSchema>;
289
304
  export type FlowDisplaySyncResponse = z.output<typeof flowDisplaySyncResponseSchema>;
290
305
  export type FlowDisplayAttentionPolicyConfig = AttentionPolicyConfig;
306
+ export declare const resolveFlowDisplayAttentionPolicyConfig: (displaySync: Pick<FlowDisplaySyncResponse, "attentionPolicy" | "attentionPolicyV2">) => FlowDisplayAttentionPolicyConfig | undefined;
291
307
  //# sourceMappingURL=flow-display.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flow-display.d.ts","sourceRoot":"","sources":["../src/flow-display.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,OAAO,EACN,KAAK,qBAAqB,EAE1B,MAAM,uBAAuB,CAAC;AAO/B,eAAO,MAAM,+BAA+B;;;;;iBAU1C,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;2BAOtC,CAAC;AAQH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;iBAY9C,CAAC;AAEH,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAenD,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGzC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBASvC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOxC,CAAC;AAEH,MAAM,MAAM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;;;;;;;;;iBASvC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQxC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC9C,OAAO,8BAA8B,CACrC,CAAC;AACF,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CACxD,OAAO,wCAAwC,CAC/C,CAAC;AACF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CACnD,OAAO,mCAAmC,CAC1C,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAC/C,OAAO,+BAA+B,CACtC,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAC3C,OAAO,2BAA2B,CAClC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAC5C,OAAO,4BAA4B,CACnC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,6BAA6B,CACpC,CAAC;AACF,MAAM,MAAM,gCAAgC,GAAG,qBAAqB,CAAC;AAErE,eAAO,MAAM,uCAAuC,GACnD,aAAa,IAAI,CAChB,uBAAuB,EACvB,iBAAiB,GAAG,mBAAmB,CACvC,KACC,gCAAgC,GAAG,SAkBrC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import * as z from "zod/mini";
2
- import { attentionPolicyConfigSchema, } from "./attention-policy.js";
2
+ import { attentionPolicyConfigSchema, legacyAttentionPolicyConfigSchema, } from "./attention-policy.js";
3
3
  import { flowAssignmentIdentitySchema, flowAssignmentRecordSchema, flowAssignmentTargetingContextSchema, } from "./flow-assignments.js";
4
4
  export const runtimeDisplayEligibilitySchema = z.object({
5
5
  requiredCapabilities: z._default(z.array(z.string().check(z.trim(), z.minLength(1))), []),
@@ -56,9 +56,27 @@ export const flowDisplaySyncRequestSchema = z.object({
56
56
  });
57
57
  export const flowDisplaySyncResponseSchema = z.object({
58
58
  fetchedAt: z.string(),
59
- attentionPolicy: z.optional(attentionPolicyConfigSchema),
59
+ attentionPolicy: z.optional(legacyAttentionPolicyConfigSchema),
60
+ attentionPolicyV2: z.optional(attentionPolicyConfigSchema),
60
61
  assignments: z.object({
61
62
  claimed: z.array(flowAssignmentRecordSchema),
62
63
  }),
63
64
  broadcasts: runtimeDisplayBroadcastsSchema,
64
65
  });
66
+ export const resolveFlowDisplayAttentionPolicyConfig = (displaySync) => {
67
+ const policy = displaySync.attentionPolicyV2 ?? displaySync.attentionPolicy;
68
+ if (!policy) {
69
+ return undefined;
70
+ }
71
+ return {
72
+ version: policy.version,
73
+ source: policy.source,
74
+ recentFlowCooldownMs: policy.recentFlowCooldownMs,
75
+ recentInAppCooldownMs: "recentInAppCooldownMs" in policy &&
76
+ typeof policy.recentInAppCooldownMs === "number"
77
+ ? policy.recentInAppCooldownMs
78
+ : 0,
79
+ exclusiveSurfaceStrategy: policy.exclusiveSurfaceStrategy,
80
+ blockedBroadcastStrategy: policy.blockedBroadcastStrategy,
81
+ };
82
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"lazy-handle-client.d.ts","sourceRoot":"","sources":["../../src/host/lazy-handle-client.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,CAAC,SAAS,SAAS,MAAM,IAAI,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI,CAAC;AAC1E,KAAK,eAAe,CAAC,MAAM,SAAS,MAAM,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAEtE,KAAK,cAAc,GAAG,eAAe,GAAG,OAAO,GAAG,aAAa,CAAC;AAChE,KAAK,QAAQ,CAAC,MAAM,SAAS,MAAM,IAAI;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EA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C,MAAM,CAAC,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAuHF,wBAAgB,sBAAsB,CAAC,SAAS,SAAS,MAAM,EAAE,WAAW,EAC3E,OAAO,EAAE,oCAAoC,CAAC,SAAS,EAAE,WAAW,CAAC,GACnE,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;AAC5D,wBAAgB,sBAAsB,CACrC,SAAS,SAAS,MAAM,EACxB,WAAW,EACX,MAAM,SAAS,MAAM,EAErB,OAAO,EAAE,mCAAmC,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,GAC1E,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC"}
@@ -11,7 +11,7 @@ const DEFAULT_LIFECYCLE_STAGES = {
11
11
  const createLazyHandleClientWithStages = (input) => {
12
12
  let handleId;
13
13
  let tail = Promise.resolve();
14
- let isIdle = true;
14
+ let queuedCommandCount = 0;
15
15
  let epoch = 0;
16
16
  const { stages } = input;
17
17
  let stage = input.initialStage ?? stages.uninitialized;
@@ -53,12 +53,12 @@ const createLazyHandleClientWithStages = (input) => {
53
53
  }
54
54
  return settlement;
55
55
  };
56
- const run = isIdle ? execute() : tail.then(execute, execute);
57
- isIdle = false;
56
+ const run = queuedCommandCount === 0 ? execute() : tail.then(execute, execute);
57
+ queuedCommandCount += 1;
58
58
  tail = run.then(() => {
59
- isIdle = true;
59
+ queuedCommandCount -= 1;
60
60
  }, () => {
61
- isIdle = true;
61
+ queuedCommandCount -= 1;
62
62
  });
63
63
  return run;
64
64
  };
package/dist/index.d.ts CHANGED
@@ -7,8 +7,9 @@ export { DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS } from "./defaults.js";
7
7
  export type { ErrorEvent, ProtocolErrorCode } from "./errors.js";
8
8
  export { ErrorCategory, ErrorCategorySchema, ErrorEventSchema, ProtocolError, } from "./errors.js";
9
9
  export { type ClaimPendingFlowAssignmentsRequest, type ClaimPendingFlowAssignmentsResponse, claimPendingFlowAssignmentsRequestSchema, claimPendingFlowAssignmentsResponseSchema, type FlowAssignmentExternalIdIdentityTypeValue, type FlowAssignmentIdentityTypeValue, type FlowAssignmentRecipientRequest, type FlowAssignmentRecord, type FlowAssignmentStatus, type FlowAssignmentTargetingContext, flowAssignmentRecipientRequestSchema, flowAssignmentRecordSchema, flowAssignmentStatusSchema, flowAssignmentTargetingContextSchema, type ListPendingFlowAssignmentsResponse, listPendingFlowAssignmentsResponseSchema, nullableUpdateFlowAssignmentLifecycleResponseSchema, type ReleaseFlowAssignmentClaimRequest, type ReleaseFlowAssignmentClaimResponse, releaseFlowAssignmentClaimRequestSchema, releaseFlowAssignmentClaimResponseSchema, type UpdateFlowAssignmentLifecycleRequest, type UpdateFlowAssignmentLifecycleResponse, updateFlowAssignmentLifecycleRequestSchema, updateFlowAssignmentLifecycleResponseSchema, } from "./flow-assignments.js";
10
- export { type FlowDisplaySyncRequest, type FlowDisplaySyncResponse, flowDisplaySyncRequestSchema, flowDisplaySyncResponseSchema, type RuntimeDisplayAttentionPolicy, type RuntimeDisplayBroadcastOpportunity, type RuntimeDisplayBroadcasts, type RuntimeDisplayEligibility, type RuntimeDisplayTrigger, runtimeDisplayAttentionPolicySchema, runtimeDisplayBroadcastOpportunitySchema, runtimeDisplayBroadcastsSchema, runtimeDisplayEligibilitySchema, runtimeDisplayTriggerSchema, } from "./flow-display.js";
10
+ export { type FlowDisplaySyncRequest, type FlowDisplaySyncResponse, flowDisplaySyncRequestSchema, flowDisplaySyncResponseSchema, type RuntimeDisplayAttentionPolicy, type RuntimeDisplayBroadcastOpportunity, type RuntimeDisplayBroadcasts, type RuntimeDisplayEligibility, type RuntimeDisplayTrigger, resolveFlowDisplayAttentionPolicyConfig, runtimeDisplayAttentionPolicySchema, runtimeDisplayBroadcastOpportunitySchema, runtimeDisplayBroadcastsSchema, runtimeDisplayEligibilitySchema, runtimeDisplayTriggerSchema, } from "./flow-display.js";
11
11
  export { buildIdentityTypeGuidanceMessage, getIdentityTypeSuggestion, IDENTITY_TYPE_VALUES, type IdentityTypeValue, isIdentityTypeValue, type StandardIdentityTypeValue, } from "./identity-type.js";
12
+ export { type CaptureInstanceFeedbackRequest, type CaptureInstanceFeedbackResponse, captureInstanceFeedbackRequestSchema, captureInstanceFeedbackResponseSchema, type InstanceFeedbackDataType, type InstanceFeedbackValence, instanceFeedbackDataTypeSchema, instanceFeedbackValenceSchema, } from "./instance-feedback.js";
12
13
  export { type PreviewConnectionPairRequest, type PreviewConnectionPairResponse, previewConnectionPairRequestSchema, previewConnectionPairResponseSchema, } from "./preview-connection.js";
13
14
  export { PREVIEW_PAIRING_TRANSPORT_SOURCE, type PreviewPairingHostAck, type PreviewPairingHostRequest, type PreviewPairingHostResult, previewPairingHostAckSchema, previewPairingHostRequestSchema, previewPairingHostResultSchema, } from "./preview-pairing-transport.js";
14
15
  export { isPublicGrantScope, type PublicGrantScope, publicGrantScopeIdSchema, } from "./public-grant-scope.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,2BAA2B,EAC3B,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,2BAA2B,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,qBAAqB,EAC1B,uCAAuC,EACvC,uCAAuC,EACvC,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,GAC/B,MAAM,uBAAuB,CAAC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AAmC,EACnC,gCAAgC,GAChC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,6BAA6B,GAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC5B,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,2BAA2B,EAChC,iCAAiC,EACjC,KAAK,mBAAmB,EACxB,2BAA2B,EAC3B,KAAK,WAAW,EAChB,KAAK,wBAAwB,EAC7B,yBAAyB,EACzB,iBAAiB,EACjB,8BAA8B,EAC9B,KAAK,oBAAoB,EACzB,0BAA0B,GAC1B,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -6,8 +6,9 @@ export { coreCommandPayloadSchema, } from "./core-commands.js";
6
6
  export { DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS } from "./defaults.js";
7
7
  export { ErrorCategory, ErrorCategorySchema, ErrorEventSchema, ProtocolError, } from "./errors.js";
8
8
  export { claimPendingFlowAssignmentsRequestSchema, claimPendingFlowAssignmentsResponseSchema, flowAssignmentRecipientRequestSchema, flowAssignmentRecordSchema, flowAssignmentStatusSchema, flowAssignmentTargetingContextSchema, listPendingFlowAssignmentsResponseSchema, nullableUpdateFlowAssignmentLifecycleResponseSchema, releaseFlowAssignmentClaimRequestSchema, releaseFlowAssignmentClaimResponseSchema, updateFlowAssignmentLifecycleRequestSchema, updateFlowAssignmentLifecycleResponseSchema, } from "./flow-assignments.js";
9
- export { flowDisplaySyncRequestSchema, flowDisplaySyncResponseSchema, runtimeDisplayAttentionPolicySchema, runtimeDisplayBroadcastOpportunitySchema, runtimeDisplayBroadcastsSchema, runtimeDisplayEligibilitySchema, runtimeDisplayTriggerSchema, } from "./flow-display.js";
9
+ export { flowDisplaySyncRequestSchema, flowDisplaySyncResponseSchema, resolveFlowDisplayAttentionPolicyConfig, runtimeDisplayAttentionPolicySchema, runtimeDisplayBroadcastOpportunitySchema, runtimeDisplayBroadcastsSchema, runtimeDisplayEligibilitySchema, runtimeDisplayTriggerSchema, } from "./flow-display.js";
10
10
  export { buildIdentityTypeGuidanceMessage, getIdentityTypeSuggestion, IDENTITY_TYPE_VALUES, isIdentityTypeValue, } from "./identity-type.js";
11
+ export { captureInstanceFeedbackRequestSchema, captureInstanceFeedbackResponseSchema, instanceFeedbackDataTypeSchema, instanceFeedbackValenceSchema, } from "./instance-feedback.js";
11
12
  export { previewConnectionPairRequestSchema, previewConnectionPairResponseSchema, } from "./preview-connection.js";
12
13
  export { PREVIEW_PAIRING_TRANSPORT_SOURCE, previewPairingHostAckSchema, previewPairingHostRequestSchema, previewPairingHostResultSchema, } from "./preview-pairing-transport.js";
13
14
  export { isPublicGrantScope, publicGrantScopeIdSchema, } from "./public-grant-scope.js";
@@ -0,0 +1,40 @@
1
+ import * as z from "zod/mini";
2
+ export declare const instanceFeedbackDataTypeSchema: z.ZodMiniEnum<{
3
+ boolean: "boolean";
4
+ categorical: "categorical";
5
+ numeric: "numeric";
6
+ }>;
7
+ export declare const instanceFeedbackValenceSchema: z.ZodMiniEnum<{
8
+ positive: "positive";
9
+ negative: "negative";
10
+ neutral: "neutral";
11
+ }>;
12
+ export declare const captureInstanceFeedbackRequestSchema: z.ZodMiniObject<{
13
+ targetBindingToken: z.ZodMiniString<string>;
14
+ capturedAt: z.ZodMiniString<string>;
15
+ comment: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
16
+ dataType: z.ZodMiniEnum<{
17
+ boolean: "boolean";
18
+ categorical: "categorical";
19
+ numeric: "numeric";
20
+ }>;
21
+ label: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
22
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
23
+ reasonCategories: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
24
+ scoreValue: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniNumber<number>>>;
25
+ valence: z.ZodMiniEnum<{
26
+ positive: "positive";
27
+ negative: "negative";
28
+ neutral: "neutral";
29
+ }>;
30
+ }, z.core.$strip>;
31
+ export declare const captureInstanceFeedbackResponseSchema: z.ZodMiniObject<{
32
+ capturedAt: z.ZodMiniString<string>;
33
+ evaluationId: z.ZodMiniString<string>;
34
+ status: z.ZodMiniLiteral<"accepted">;
35
+ }, z.core.$strip>;
36
+ export type InstanceFeedbackDataType = z.output<typeof instanceFeedbackDataTypeSchema>;
37
+ export type InstanceFeedbackValence = z.output<typeof instanceFeedbackValenceSchema>;
38
+ export type CaptureInstanceFeedbackRequest = z.output<typeof captureInstanceFeedbackRequestSchema>;
39
+ export type CaptureInstanceFeedbackResponse = z.output<typeof captureInstanceFeedbackResponseSchema>;
40
+ //# sourceMappingURL=instance-feedback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance-feedback.d.ts","sourceRoot":"","sources":["../src/instance-feedback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAyB9B,eAAO,MAAM,8BAA8B;;;;EAIzC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;EAIxC,CAAC;AAEH,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;iBA0B/C,CAAC;AAEH,eAAO,MAAM,qCAAqC;;;;iBAIhD,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC9C,OAAO,8BAA8B,CACrC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,6BAA6B,CACpC,CAAC;AACF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CACpD,OAAO,oCAAoC,CAC3C,CAAC;AACF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CACrD,OAAO,qCAAqC,CAC5C,CAAC"}
@@ -0,0 +1,49 @@
1
+ import * as z from "zod/mini";
2
+ const maxCaptureRequestCommentLength = 64 * 1024;
3
+ const maxReasonCategoryCount = 20;
4
+ const maxTargetBindingTokenLength = 4096;
5
+ const canonicalUtcTimestampLength = "2026-07-01T12:00:00.000Z".length;
6
+ const canonicalUtcTimestampPattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u;
7
+ const isCanonicalUtcTimestamp = (value) => {
8
+ if (value.length !== canonicalUtcTimestampLength ||
9
+ !canonicalUtcTimestampPattern.test(value)) {
10
+ return false;
11
+ }
12
+ const date = new Date(value);
13
+ return !Number.isNaN(date.getTime()) && date.toISOString() === value;
14
+ };
15
+ const finiteNumberSchema = z.number().check(z.refine(Number.isFinite, {
16
+ message: "Expected a finite number.",
17
+ }));
18
+ export const instanceFeedbackDataTypeSchema = z.enum([
19
+ "boolean",
20
+ "categorical",
21
+ "numeric",
22
+ ]);
23
+ export const instanceFeedbackValenceSchema = z.enum([
24
+ "positive",
25
+ "negative",
26
+ "neutral",
27
+ ]);
28
+ export const captureInstanceFeedbackRequestSchema = z.object({
29
+ targetBindingToken: z
30
+ .string()
31
+ .check(z.trim(), z.minLength(1), z.maxLength(maxTargetBindingTokenLength)),
32
+ capturedAt: z.string().check(z.trim(), z.minLength(1), z.refine(isCanonicalUtcTimestamp, {
33
+ message: "capturedAt must be a canonical UTC timestamp.",
34
+ })),
35
+ comment: z.optional(z.nullable(z.string().check(z.maxLength(maxCaptureRequestCommentLength)))),
36
+ dataType: instanceFeedbackDataTypeSchema,
37
+ label: z.optional(z.nullable(z.string().check(z.maxLength(255)))),
38
+ name: z.optional(z.string().check(z.trim(), z.minLength(1), z.maxLength(255))),
39
+ reasonCategories: z.optional(z
40
+ .array(z.string().check(z.trim(), z.minLength(1), z.maxLength(128)))
41
+ .check(z.maxLength(maxReasonCategoryCount))),
42
+ scoreValue: z.optional(z.nullable(finiteNumberSchema)),
43
+ valence: instanceFeedbackValenceSchema,
44
+ });
45
+ export const captureInstanceFeedbackResponseSchema = z.object({
46
+ capturedAt: z.string(),
47
+ evaluationId: z.string().check(z.trim(), z.minLength(1)),
48
+ status: z.literal("accepted"),
49
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getuserfeedback/protocol",
3
- "version": "3.0.14",
3
+ "version": "3.1.1",
4
4
  "description": "getuserfeedback widget protocol — host surface and (later) wire protocol",
5
5
  "keywords": [
6
6
  "getuserfeedback",
@@ -124,6 +124,12 @@
124
124
  "import": "./dist/flow-display.js",
125
125
  "default": "./dist/flow-display.js"
126
126
  },
127
+ "./instance-feedback": {
128
+ "types": "./dist/instance-feedback.d.ts",
129
+ "bun": "./src/instance-feedback.ts",
130
+ "import": "./dist/instance-feedback.js",
131
+ "default": "./dist/instance-feedback.js"
132
+ },
127
133
  "./trpc-envelope": {
128
134
  "types": "./dist/trpc-envelope.d.ts",
129
135
  "bun": "./src/trpc-envelope.ts",
@@ -6,12 +6,24 @@ export const attentionExclusiveSurfaceStrategySchema = z.enum(["queue"]);
6
6
 
7
7
  export const attentionBlockedBroadcastStrategySchema = z.enum(["queue"]);
8
8
 
9
- export const attentionPolicyConfigSchema = z.strictObject({
9
+ const legacyAttentionPolicyConfigFields = {
10
10
  version: z.string().check(z.trim(), z.minLength(1)),
11
11
  source: attentionPolicySourceSchema,
12
12
  recentFlowCooldownMs: z.number().check(z.positive()),
13
13
  exclusiveSurfaceStrategy: attentionExclusiveSurfaceStrategySchema,
14
14
  blockedBroadcastStrategy: attentionBlockedBroadcastStrategySchema,
15
+ };
16
+
17
+ export const legacyAttentionPolicyConfigSchema = z.strictObject(
18
+ legacyAttentionPolicyConfigFields,
19
+ );
20
+
21
+ // V2 is the additive policy envelope for the flow-display wire contract.
22
+ // Keep legacy strict, and add future policy controls here instead of creating
23
+ // another versioned sibling field for every new setting.
24
+ export const attentionPolicyConfigSchema = z.looseObject({
25
+ ...legacyAttentionPolicyConfigFields,
26
+ recentInAppCooldownMs: z._default(z.number().check(z.nonnegative()), 0),
15
27
  });
16
28
 
17
29
  export type AttentionPolicyConfig = z.output<
@@ -22,6 +34,7 @@ export const DEFAULT_ATTENTION_POLICY_CONFIG: AttentionPolicyConfig = {
22
34
  version: "attention-policy-default-v1",
23
35
  source: "default",
24
36
  recentFlowCooldownMs: 5 * 60 * 1000,
37
+ recentInAppCooldownMs: 0,
25
38
  exclusiveSurfaceStrategy: "queue",
26
39
  blockedBroadcastStrategy: "queue",
27
40
  };
@@ -58,7 +58,38 @@ const prefetchPayloadSchema = z.strictObject({
58
58
  flowHandleId: z.optional(flowHandleIdSchema),
59
59
  });
60
60
 
61
- const openCorePayloadSchema = z.strictObject({
61
+ const inlineFlowThemeSchema = z.strictObject({
62
+ css: z.optional(z.string()),
63
+ themeRuntimeArtifactId: z.optional(
64
+ z.string().check(z.trim(), z.minLength(1)),
65
+ ),
66
+ themeVersionId: z.optional(z.string().check(z.trim(), z.minLength(1))),
67
+ });
68
+
69
+ const inlineFlowSchema = z.strictObject({
70
+ definition: z.unknown().check(
71
+ z.check((ctx) => {
72
+ if (ctx.value !== undefined) {
73
+ return;
74
+ }
75
+ ctx.issues.push({
76
+ code: "custom",
77
+ input: ctx.value,
78
+ message: "Inline flow definition is required.",
79
+ continue: false,
80
+ });
81
+ }),
82
+ ),
83
+ theme: z.optional(inlineFlowThemeSchema),
84
+ });
85
+
86
+ const prefetchInlinePayloadSchema = z.strictObject({
87
+ kind: z.literal("prefetch"),
88
+ flow: inlineFlowSchema,
89
+ flowHandleId: z.optional(flowHandleIdSchema),
90
+ });
91
+
92
+ const openPersistedCorePayloadSchema = z.strictObject({
62
93
  kind: z.literal("open"),
63
94
  flowId: flowIdSchema,
64
95
  flowHandleId: z.optional(flowHandleIdSchema),
@@ -66,13 +97,28 @@ const openCorePayloadSchema = z.strictObject({
66
97
  hideCloseButton: z.optional(z.boolean()),
67
98
  });
68
99
 
69
- const prerenderCorePayloadSchema = z.strictObject({
100
+ const openInlineCorePayloadSchema = z.strictObject({
101
+ kind: z.literal("open"),
102
+ flow: inlineFlowSchema,
103
+ flowHandleId: z.optional(flowHandleIdSchema),
104
+ metadata: z.optional(responseMetadataInputSchema),
105
+ hideCloseButton: z.optional(z.boolean()),
106
+ });
107
+
108
+ const prerenderPersistedCorePayloadSchema = z.strictObject({
70
109
  kind: z.literal("prerender"),
71
110
  flowId: flowIdSchema,
72
111
  flowHandleId: z.optional(flowHandleIdSchema),
73
112
  hideCloseButton: z.optional(z.boolean()),
74
113
  });
75
114
 
115
+ const prerenderInlineCorePayloadSchema = z.strictObject({
116
+ kind: z.literal("prerender"),
117
+ flow: inlineFlowSchema,
118
+ flowHandleId: z.optional(flowHandleIdSchema),
119
+ hideCloseButton: z.optional(z.boolean()),
120
+ });
121
+
76
122
  const closeCorePayloadSchema = z.object({
77
123
  kind: z.literal("close"),
78
124
  flowHandleId: z.optional(flowHandleIdSchema),
@@ -140,10 +186,13 @@ const resetPayloadSchema = z.object({
140
186
  kind: z.literal("reset"),
141
187
  });
142
188
 
143
- const coreCommandPayloadWithoutIdentifySchema = z.discriminatedUnion("kind", [
144
- openCorePayloadSchema,
145
- prefetchPayloadSchema,
146
- prerenderCorePayloadSchema,
189
+ const coreCommandPayloadWithoutIdentifySchema = z.union([
190
+ z.union([openPersistedCorePayloadSchema, openInlineCorePayloadSchema]),
191
+ z.union([prefetchPayloadSchema, prefetchInlinePayloadSchema]),
192
+ z.union([
193
+ prerenderPersistedCorePayloadSchema,
194
+ prerenderInlineCorePayloadSchema,
195
+ ]),
147
196
  hostContextUpdatedPayloadSchema,
148
197
  hostSignalPayloadSchema,
149
198
  setTargetingPlanPayloadSchema,
@@ -2,6 +2,7 @@ import { describe, expect, it } from "bun:test";
2
2
  import {
3
3
  flowDisplaySyncRequestSchema,
4
4
  flowDisplaySyncResponseSchema,
5
+ resolveFlowDisplayAttentionPolicyConfig,
5
6
  } from "./flow-display";
6
7
 
7
8
  describe("flow display sync contracts", () => {
@@ -55,6 +56,179 @@ describe("flow display sync contracts", () => {
55
56
  expect(result.attentionPolicy).toBeUndefined();
56
57
  });
57
58
 
59
+ it("keeps the legacy attention policy response shape backward compatible", () => {
60
+ const result = flowDisplaySyncResponseSchema.parse({
61
+ fetchedAt: "2026-06-18T00:00:00.000Z",
62
+ attentionPolicy: {
63
+ version: "attention-policy-organization-override-v1",
64
+ source: "custom",
65
+ recentFlowCooldownMs: 45_000,
66
+ exclusiveSurfaceStrategy: "queue",
67
+ blockedBroadcastStrategy: "queue",
68
+ },
69
+ attentionPolicyV2: {
70
+ version: "attention-policy-organization-override-v1",
71
+ source: "custom",
72
+ recentFlowCooldownMs: 45_000,
73
+ recentInAppCooldownMs: 60_000,
74
+ exclusiveSurfaceStrategy: "queue",
75
+ blockedBroadcastStrategy: "queue",
76
+ },
77
+ assignments: {
78
+ claimed: [],
79
+ },
80
+ broadcasts: {
81
+ version: "empty",
82
+ opportunities: [],
83
+ },
84
+ });
85
+
86
+ expect(result.attentionPolicy).toEqual({
87
+ version: "attention-policy-organization-override-v1",
88
+ source: "custom",
89
+ recentFlowCooldownMs: 45_000,
90
+ exclusiveSurfaceStrategy: "queue",
91
+ blockedBroadcastStrategy: "queue",
92
+ });
93
+ expect(result.attentionPolicyV2).toEqual({
94
+ version: "attention-policy-organization-override-v1",
95
+ source: "custom",
96
+ recentFlowCooldownMs: 45_000,
97
+ recentInAppCooldownMs: 60_000,
98
+ exclusiveSurfaceStrategy: "queue",
99
+ blockedBroadcastStrategy: "queue",
100
+ });
101
+ });
102
+
103
+ it("rejects new attention policy fields on the legacy response field", () => {
104
+ expect(() =>
105
+ flowDisplaySyncResponseSchema.parse({
106
+ fetchedAt: "2026-06-18T00:00:00.000Z",
107
+ attentionPolicy: {
108
+ version: "attention-policy-organization-override-v1",
109
+ source: "custom",
110
+ recentFlowCooldownMs: 45_000,
111
+ recentInAppCooldownMs: 60_000,
112
+ exclusiveSurfaceStrategy: "queue",
113
+ blockedBroadcastStrategy: "queue",
114
+ },
115
+ assignments: {
116
+ claimed: [],
117
+ },
118
+ broadcasts: {
119
+ version: "empty",
120
+ opportunities: [],
121
+ },
122
+ }),
123
+ ).toThrow();
124
+ });
125
+
126
+ it("accepts future additive fields on the v2 attention policy envelope", () => {
127
+ const result = flowDisplaySyncResponseSchema.parse({
128
+ fetchedAt: "2026-06-18T00:00:00.000Z",
129
+ attentionPolicyV2: {
130
+ version: "attention-policy-organization-override-v1",
131
+ source: "custom",
132
+ recentFlowCooldownMs: 45_000,
133
+ recentInAppCooldownMs: 60_000,
134
+ exclusiveSurfaceStrategy: "queue",
135
+ blockedBroadcastStrategy: "queue",
136
+ futureChannelStrategy: "digest",
137
+ },
138
+ assignments: {
139
+ claimed: [],
140
+ },
141
+ broadcasts: {
142
+ version: "empty",
143
+ opportunities: [],
144
+ },
145
+ });
146
+
147
+ expect(result.attentionPolicyV2).toEqual({
148
+ version: "attention-policy-organization-override-v1",
149
+ source: "custom",
150
+ recentFlowCooldownMs: 45_000,
151
+ recentInAppCooldownMs: 60_000,
152
+ exclusiveSurfaceStrategy: "queue",
153
+ blockedBroadcastStrategy: "queue",
154
+ futureChannelStrategy: "digest",
155
+ });
156
+ expect(resolveFlowDisplayAttentionPolicyConfig(result)).toEqual({
157
+ version: "attention-policy-organization-override-v1",
158
+ source: "custom",
159
+ recentFlowCooldownMs: 45_000,
160
+ recentInAppCooldownMs: 60_000,
161
+ exclusiveSurfaceStrategy: "queue",
162
+ blockedBroadcastStrategy: "queue",
163
+ });
164
+ });
165
+
166
+ it("resolves the v2 attention policy before the legacy fallback", () => {
167
+ const result = flowDisplaySyncResponseSchema.parse({
168
+ fetchedAt: "2026-06-18T00:00:00.000Z",
169
+ attentionPolicy: {
170
+ version: "attention-policy-legacy-v1",
171
+ source: "custom",
172
+ recentFlowCooldownMs: 45_000,
173
+ exclusiveSurfaceStrategy: "queue",
174
+ blockedBroadcastStrategy: "queue",
175
+ },
176
+ attentionPolicyV2: {
177
+ version: "attention-policy-v2-v1",
178
+ source: "custom",
179
+ recentFlowCooldownMs: 90_000,
180
+ recentInAppCooldownMs: 30_000,
181
+ exclusiveSurfaceStrategy: "queue",
182
+ blockedBroadcastStrategy: "queue",
183
+ },
184
+ assignments: {
185
+ claimed: [],
186
+ },
187
+ broadcasts: {
188
+ version: "empty",
189
+ opportunities: [],
190
+ },
191
+ });
192
+
193
+ expect(resolveFlowDisplayAttentionPolicyConfig(result)).toEqual({
194
+ version: "attention-policy-v2-v1",
195
+ source: "custom",
196
+ recentFlowCooldownMs: 90_000,
197
+ recentInAppCooldownMs: 30_000,
198
+ exclusiveSurfaceStrategy: "queue",
199
+ blockedBroadcastStrategy: "queue",
200
+ });
201
+ });
202
+
203
+ it("resolves legacy attention policy with default v2-only fields", () => {
204
+ const result = flowDisplaySyncResponseSchema.parse({
205
+ fetchedAt: "2026-06-18T00:00:00.000Z",
206
+ attentionPolicy: {
207
+ version: "attention-policy-legacy-v1",
208
+ source: "custom",
209
+ recentFlowCooldownMs: 45_000,
210
+ exclusiveSurfaceStrategy: "queue",
211
+ blockedBroadcastStrategy: "queue",
212
+ },
213
+ assignments: {
214
+ claimed: [],
215
+ },
216
+ broadcasts: {
217
+ version: "empty",
218
+ opportunities: [],
219
+ },
220
+ });
221
+
222
+ expect(resolveFlowDisplayAttentionPolicyConfig(result)).toEqual({
223
+ version: "attention-policy-legacy-v1",
224
+ source: "custom",
225
+ recentFlowCooldownMs: 45_000,
226
+ recentInAppCooldownMs: 0,
227
+ exclusiveSurfaceStrategy: "queue",
228
+ blockedBroadcastStrategy: "queue",
229
+ });
230
+ });
231
+
58
232
  it("accepts runtime broadcast opportunities", () => {
59
233
  const result = flowDisplaySyncResponseSchema.parse({
60
234
  fetchedAt: "2026-06-18T00:00:00.000Z",
@@ -3,6 +3,7 @@ import * as z from "zod/mini";
3
3
  import {
4
4
  type AttentionPolicyConfig,
5
5
  attentionPolicyConfigSchema,
6
+ legacyAttentionPolicyConfigSchema,
6
7
  } from "./attention-policy.js";
7
8
  import {
8
9
  flowAssignmentIdentitySchema,
@@ -86,7 +87,8 @@ export const flowDisplaySyncRequestSchema = z.object({
86
87
 
87
88
  export const flowDisplaySyncResponseSchema = z.object({
88
89
  fetchedAt: z.string(),
89
- attentionPolicy: z.optional(attentionPolicyConfigSchema),
90
+ attentionPolicy: z.optional(legacyAttentionPolicyConfigSchema),
91
+ attentionPolicyV2: z.optional(attentionPolicyConfigSchema),
90
92
  assignments: z.object({
91
93
  claimed: z.array(flowAssignmentRecordSchema),
92
94
  }),
@@ -115,3 +117,28 @@ export type FlowDisplaySyncResponse = z.output<
115
117
  typeof flowDisplaySyncResponseSchema
116
118
  >;
117
119
  export type FlowDisplayAttentionPolicyConfig = AttentionPolicyConfig;
120
+
121
+ export const resolveFlowDisplayAttentionPolicyConfig = (
122
+ displaySync: Pick<
123
+ FlowDisplaySyncResponse,
124
+ "attentionPolicy" | "attentionPolicyV2"
125
+ >,
126
+ ): FlowDisplayAttentionPolicyConfig | undefined => {
127
+ const policy = displaySync.attentionPolicyV2 ?? displaySync.attentionPolicy;
128
+ if (!policy) {
129
+ return undefined;
130
+ }
131
+
132
+ return {
133
+ version: policy.version,
134
+ source: policy.source,
135
+ recentFlowCooldownMs: policy.recentFlowCooldownMs,
136
+ recentInAppCooldownMs:
137
+ "recentInAppCooldownMs" in policy &&
138
+ typeof policy.recentInAppCooldownMs === "number"
139
+ ? policy.recentInAppCooldownMs
140
+ : 0,
141
+ exclusiveSurfaceStrategy: policy.exclusiveSurfaceStrategy,
142
+ blockedBroadcastStrategy: policy.blockedBroadcastStrategy,
143
+ };
144
+ };
@@ -77,7 +77,7 @@ const createLazyHandleClientWithStages = <
77
77
  }): LazyHandleClient<THandleId, TSettlement, TStage> => {
78
78
  let handleId: THandleId | undefined;
79
79
  let tail = Promise.resolve();
80
- let isIdle = true;
80
+ let queuedCommandCount = 0;
81
81
  let epoch = 0;
82
82
  const { stages } = input;
83
83
  let stage = input.initialStage ?? stages.uninitialized;
@@ -127,14 +127,15 @@ const createLazyHandleClientWithStages = <
127
127
  return settlement;
128
128
  };
129
129
 
130
- const run = isIdle ? execute() : tail.then(execute, execute);
131
- isIdle = false;
130
+ const run =
131
+ queuedCommandCount === 0 ? execute() : tail.then(execute, execute);
132
+ queuedCommandCount += 1;
132
133
  tail = run.then(
133
134
  () => {
134
- isIdle = true;
135
+ queuedCommandCount -= 1;
135
136
  },
136
137
  () => {
137
- isIdle = true;
138
+ queuedCommandCount -= 1;
138
139
  },
139
140
  );
140
141
  return run;
package/src/index.ts CHANGED
@@ -88,6 +88,7 @@ export {
88
88
  type RuntimeDisplayBroadcasts,
89
89
  type RuntimeDisplayEligibility,
90
90
  type RuntimeDisplayTrigger,
91
+ resolveFlowDisplayAttentionPolicyConfig,
91
92
  runtimeDisplayAttentionPolicySchema,
92
93
  runtimeDisplayBroadcastOpportunitySchema,
93
94
  runtimeDisplayBroadcastsSchema,
@@ -102,6 +103,16 @@ export {
102
103
  isIdentityTypeValue,
103
104
  type StandardIdentityTypeValue,
104
105
  } from "./identity-type.js";
106
+ export {
107
+ type CaptureInstanceFeedbackRequest,
108
+ type CaptureInstanceFeedbackResponse,
109
+ captureInstanceFeedbackRequestSchema,
110
+ captureInstanceFeedbackResponseSchema,
111
+ type InstanceFeedbackDataType,
112
+ type InstanceFeedbackValence,
113
+ instanceFeedbackDataTypeSchema,
114
+ instanceFeedbackValenceSchema,
115
+ } from "./instance-feedback.js";
105
116
  export {
106
117
  type PreviewConnectionPairRequest,
107
118
  type PreviewConnectionPairResponse,
@@ -0,0 +1,86 @@
1
+ import { describe, expect, it } from "bun:test";
2
+
3
+ import { captureInstanceFeedbackRequestSchema } from "./instance-feedback";
4
+
5
+ const validCaptureRequest = {
6
+ capturedAt: "2026-07-01T12:00:00.000Z",
7
+ dataType: "boolean",
8
+ scoreValue: 1,
9
+ targetBindingToken: "binding-token",
10
+ valence: "positive",
11
+ } as const;
12
+
13
+ describe("captureInstanceFeedbackRequestSchema", () => {
14
+ it("accepts canonical millisecond UTC capture timestamps", () => {
15
+ expect(
16
+ captureInstanceFeedbackRequestSchema.safeParse(validCaptureRequest)
17
+ .success,
18
+ ).toBe(true);
19
+ });
20
+
21
+ it("rejects non-canonical capture timestamps", () => {
22
+ expect(
23
+ captureInstanceFeedbackRequestSchema.safeParse({
24
+ ...validCaptureRequest,
25
+ capturedAt: "2026-07-01T12:00:00Z",
26
+ }).success,
27
+ ).toBe(false);
28
+ });
29
+
30
+ it("rejects impossible capture timestamps", () => {
31
+ expect(
32
+ captureInstanceFeedbackRequestSchema.safeParse({
33
+ ...validCaptureRequest,
34
+ capturedAt: "2026-02-31T00:00:00.000Z",
35
+ }).success,
36
+ ).toBe(false);
37
+ });
38
+
39
+ it("rejects oversized capture timestamps", () => {
40
+ expect(
41
+ captureInstanceFeedbackRequestSchema.safeParse({
42
+ ...validCaptureRequest,
43
+ capturedAt: `${"2".repeat(4096)}Z`,
44
+ }).success,
45
+ ).toBe(false);
46
+ });
47
+
48
+ it("caps target binding tokens before verification", () => {
49
+ expect(
50
+ captureInstanceFeedbackRequestSchema.safeParse({
51
+ ...validCaptureRequest,
52
+ targetBindingToken: "x".repeat(4097),
53
+ }).success,
54
+ ).toBe(false);
55
+ });
56
+
57
+ it("caps reason categories at the capture boundary limit", () => {
58
+ expect(
59
+ captureInstanceFeedbackRequestSchema.safeParse({
60
+ ...validCaptureRequest,
61
+ reasonCategories: Array.from(
62
+ { length: 21 },
63
+ (_, index) => `reason-${index}`,
64
+ ),
65
+ }).success,
66
+ ).toBe(false);
67
+ });
68
+
69
+ it("caps comments at the public capture body budget", () => {
70
+ expect(
71
+ captureInstanceFeedbackRequestSchema.safeParse({
72
+ ...validCaptureRequest,
73
+ comment: "x".repeat(64 * 1024 + 1),
74
+ }).success,
75
+ ).toBe(false);
76
+ });
77
+
78
+ it("rejects non-finite score values", () => {
79
+ expect(
80
+ captureInstanceFeedbackRequestSchema.safeParse({
81
+ ...validCaptureRequest,
82
+ scoreValue: Number.POSITIVE_INFINITY,
83
+ }).success,
84
+ ).toBe(false);
85
+ });
86
+ });
@@ -0,0 +1,83 @@
1
+ import * as z from "zod/mini";
2
+
3
+ const maxCaptureRequestCommentLength = 64 * 1024;
4
+ const maxReasonCategoryCount = 20;
5
+ const maxTargetBindingTokenLength = 4096;
6
+ const canonicalUtcTimestampLength = "2026-07-01T12:00:00.000Z".length;
7
+ const canonicalUtcTimestampPattern =
8
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u;
9
+ const isCanonicalUtcTimestamp = (value: string) => {
10
+ if (
11
+ value.length !== canonicalUtcTimestampLength ||
12
+ !canonicalUtcTimestampPattern.test(value)
13
+ ) {
14
+ return false;
15
+ }
16
+
17
+ const date = new Date(value);
18
+ return !Number.isNaN(date.getTime()) && date.toISOString() === value;
19
+ };
20
+ const finiteNumberSchema = z.number().check(
21
+ z.refine(Number.isFinite, {
22
+ message: "Expected a finite number.",
23
+ }),
24
+ );
25
+
26
+ export const instanceFeedbackDataTypeSchema = z.enum([
27
+ "boolean",
28
+ "categorical",
29
+ "numeric",
30
+ ]);
31
+
32
+ export const instanceFeedbackValenceSchema = z.enum([
33
+ "positive",
34
+ "negative",
35
+ "neutral",
36
+ ]);
37
+
38
+ export const captureInstanceFeedbackRequestSchema = z.object({
39
+ targetBindingToken: z
40
+ .string()
41
+ .check(z.trim(), z.minLength(1), z.maxLength(maxTargetBindingTokenLength)),
42
+ capturedAt: z.string().check(
43
+ z.trim(),
44
+ z.minLength(1),
45
+ z.refine(isCanonicalUtcTimestamp, {
46
+ message: "capturedAt must be a canonical UTC timestamp.",
47
+ }),
48
+ ),
49
+ comment: z.optional(
50
+ z.nullable(z.string().check(z.maxLength(maxCaptureRequestCommentLength))),
51
+ ),
52
+ dataType: instanceFeedbackDataTypeSchema,
53
+ label: z.optional(z.nullable(z.string().check(z.maxLength(255)))),
54
+ name: z.optional(
55
+ z.string().check(z.trim(), z.minLength(1), z.maxLength(255)),
56
+ ),
57
+ reasonCategories: z.optional(
58
+ z
59
+ .array(z.string().check(z.trim(), z.minLength(1), z.maxLength(128)))
60
+ .check(z.maxLength(maxReasonCategoryCount)),
61
+ ),
62
+ scoreValue: z.optional(z.nullable(finiteNumberSchema)),
63
+ valence: instanceFeedbackValenceSchema,
64
+ });
65
+
66
+ export const captureInstanceFeedbackResponseSchema = z.object({
67
+ capturedAt: z.string(),
68
+ evaluationId: z.string().check(z.trim(), z.minLength(1)),
69
+ status: z.literal("accepted"),
70
+ });
71
+
72
+ export type InstanceFeedbackDataType = z.output<
73
+ typeof instanceFeedbackDataTypeSchema
74
+ >;
75
+ export type InstanceFeedbackValence = z.output<
76
+ typeof instanceFeedbackValenceSchema
77
+ >;
78
+ export type CaptureInstanceFeedbackRequest = z.output<
79
+ typeof captureInstanceFeedbackRequestSchema
80
+ >;
81
+ export type CaptureInstanceFeedbackResponse = z.output<
82
+ typeof captureInstanceFeedbackResponseSchema
83
+ >;
@@ -63,6 +63,7 @@ describe("@getuserfeedback/protocol root contract", () => {
63
63
  version: "attention-policy-default-v1",
64
64
  source: "default",
65
65
  recentFlowCooldownMs: 5 * 60 * 1000,
66
+ recentInAppCooldownMs: 0,
66
67
  exclusiveSurfaceStrategy: "queue",
67
68
  blockedBroadcastStrategy: "queue",
68
69
  });