@prave/shared 1.4.14 → 1.4.15

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.
@@ -157,4 +157,55 @@ export declare const recordSkillUsageBySlugSchema: z.ZodObject<{
157
157
  meta?: Record<string, string | number | boolean | null> | undefined;
158
158
  }>;
159
159
  export type RecordSkillUsageBySlugInput = z.infer<typeof recordSkillUsageBySlugSchema>;
160
+ /**
161
+ * Bulk version of `recordSkillUsageBySlug` — drives the CLI's offline
162
+ * telemetry-buffer flush.
163
+ *
164
+ * The PostToolUse hook on a logged-out machine buffers events as JSONL
165
+ * lines in `~/.prave/telemetry-queue.jsonl`. Earlier flush logic
166
+ * replayed them with one POST per event, which after a long offline
167
+ * window (1 week of heavy use → 300+ events) burned through the
168
+ * default 240/min/user limit and stopped mid-flush with 429s. This
169
+ * schema lets the CLI send up to 500 events in ONE authenticated
170
+ * request — server resolves each unique (slug, agent_type) pair once
171
+ * and batch-inserts the lot.
172
+ */
173
+ export declare const recordSkillUsageBySlugBatchSchema: z.ZodObject<{
174
+ events: z.ZodArray<z.ZodObject<{
175
+ slug: z.ZodString;
176
+ trigger_phrase: z.ZodOptional<z.ZodNullable<z.ZodString>>;
177
+ triggered_at: z.ZodOptional<z.ZodString>;
178
+ agent_type: z.ZodOptional<z.ZodEnum<["claude", "codex", "cursor", "gemini", "cline", "amp"]>>;
179
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
180
+ }, "strip", z.ZodTypeAny, {
181
+ slug: string;
182
+ agent_type?: "claude" | "codex" | "cursor" | "gemini" | "cline" | "amp" | undefined;
183
+ trigger_phrase?: string | null | undefined;
184
+ triggered_at?: string | undefined;
185
+ meta?: Record<string, string | number | boolean | null> | undefined;
186
+ }, {
187
+ slug: string;
188
+ agent_type?: "claude" | "codex" | "cursor" | "gemini" | "cline" | "amp" | undefined;
189
+ trigger_phrase?: string | null | undefined;
190
+ triggered_at?: string | undefined;
191
+ meta?: Record<string, string | number | boolean | null> | undefined;
192
+ }>, "many">;
193
+ }, "strip", z.ZodTypeAny, {
194
+ events: {
195
+ slug: string;
196
+ agent_type?: "claude" | "codex" | "cursor" | "gemini" | "cline" | "amp" | undefined;
197
+ trigger_phrase?: string | null | undefined;
198
+ triggered_at?: string | undefined;
199
+ meta?: Record<string, string | number | boolean | null> | undefined;
200
+ }[];
201
+ }, {
202
+ events: {
203
+ slug: string;
204
+ agent_type?: "claude" | "codex" | "cursor" | "gemini" | "cline" | "amp" | undefined;
205
+ trigger_phrase?: string | null | undefined;
206
+ triggered_at?: string | undefined;
207
+ meta?: Record<string, string | number | boolean | null> | undefined;
208
+ }[];
209
+ }>;
210
+ export type RecordSkillUsageBySlugBatchInput = z.infer<typeof recordSkillUsageBySlugBatchSchema>;
160
211
  //# sourceMappingURL=intelligence.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intelligence.schema.d.ts","sourceRoot":"","sources":["../../src/schemas/intelligence.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,eAAe,oEAAsB,CAAA;AAElD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAKlC,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE,eAAO,MAAM,6BAA6B;;;;;;;;;EAGxC,CAAA;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAEnF,eAAO,MAAM,oBAAoB;;;;;;;;;EAG/B,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYpC,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K,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYpC,CAAA;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAEhF,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAA;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE1E;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;EAWtC,CAAA;AACF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAEpF;;;;;GAKG;AACH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,0GAKf,CAAA;AACb,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;EAUvC,CAAA;AACF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAEtF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmB5C,CAAA;AACF,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA"}
@@ -81,3 +81,34 @@ export const recordSkillUsageBySlugSchema = z.object({
81
81
  agent_type: z.enum(['claude', 'codex', 'cursor', 'gemini', 'cline', 'amp']).optional(),
82
82
  meta: usageMetaSchema,
83
83
  });
84
+ /**
85
+ * Bulk version of `recordSkillUsageBySlug` — drives the CLI's offline
86
+ * telemetry-buffer flush.
87
+ *
88
+ * The PostToolUse hook on a logged-out machine buffers events as JSONL
89
+ * lines in `~/.prave/telemetry-queue.jsonl`. Earlier flush logic
90
+ * replayed them with one POST per event, which after a long offline
91
+ * window (1 week of heavy use → 300+ events) burned through the
92
+ * default 240/min/user limit and stopped mid-flush with 429s. This
93
+ * schema lets the CLI send up to 500 events in ONE authenticated
94
+ * request — server resolves each unique (slug, agent_type) pair once
95
+ * and batch-inserts the lot.
96
+ */
97
+ export const recordSkillUsageBySlugBatchSchema = z.object({
98
+ events: z
99
+ .array(z.object({
100
+ slug: z
101
+ .string()
102
+ .min(1)
103
+ .max(120)
104
+ .regex(/^[a-z0-9][a-z0-9_-]*$/i, 'slug must be kebab/snake case'),
105
+ trigger_phrase: z.string().max(500).nullish(),
106
+ triggered_at: z.string().datetime().optional(),
107
+ agent_type: z
108
+ .enum(['claude', 'codex', 'cursor', 'gemini', 'cline', 'amp'])
109
+ .optional(),
110
+ meta: usageMetaSchema,
111
+ }))
112
+ .min(1)
113
+ .max(500),
114
+ });
@@ -508,4 +508,50 @@ export declare const autoSkillFromRepoRequestSchema: z.ZodObject<{
508
508
  custom_instructions?: string | undefined;
509
509
  }>;
510
510
  export type AutoSkillFromRepoRequest = z.infer<typeof autoSkillFromRepoRequestSchema>;
511
+ /**
512
+ * `prave sync` previously hit GET /skills/:slug + POST /skills/:slug/install
513
+ * + POST /intelligence/analyze for each locally installed skill. With 85
514
+ * skills that's 255 requests per sync — well past the default 240/min/user
515
+ * cap, hitting the user mid-sync with "Too many requests" 429s. The bulk
516
+ * endpoint below collapses the round-trips into one request that returns
517
+ * every skill's content and records every install in a single DB pass.
518
+ *
519
+ * Slug cap of 250 keeps payload size reasonable (avg SKILL.md is ~4KB →
520
+ * ~1MB max response). Real-world libraries hit 50–150 skills so this
521
+ * leaves plenty of headroom without uncapped abuse risk.
522
+ */
523
+ export declare const bulkSyncInputSchema: z.ZodObject<{
524
+ slugs: z.ZodArray<z.ZodString, "many">;
525
+ }, "strip", z.ZodTypeAny, {
526
+ slugs: string[];
527
+ }, {
528
+ slugs: string[];
529
+ }>;
530
+ export type BulkSyncInput = z.infer<typeof bulkSyncInputSchema>;
531
+ /**
532
+ * Per-slug result shape. Only the fields the CLI actually needs to write
533
+ * the file and to surface paywall errors — keeps payload tight.
534
+ *
535
+ * slug — echoed for client-side mapping
536
+ * content — SKILL.md body, or null when paid-and-unpurchased
537
+ * price_cents — 0 for free skills
538
+ * purchased — true if owner or has purchase receipt
539
+ * is_owner — true if caller authored the skill
540
+ * error — populated when the skill can't be installed (not found,
541
+ * paywalled, no content). Lets the bulk response carry
542
+ * per-slug failures without breaking the whole sync.
543
+ */
544
+ export interface BulkSyncItem {
545
+ slug: string;
546
+ content: string | null;
547
+ price_cents: number;
548
+ purchased: boolean;
549
+ is_owner: boolean;
550
+ error: string | null;
551
+ }
552
+ export interface BulkSyncResponse {
553
+ items: BulkSyncItem[];
554
+ /** Slugs that couldn't be resolved at all (skill deleted, never existed). */
555
+ missing: string[];
556
+ }
511
557
  //# sourceMappingURL=skill.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"skill.schema.d.ts","sourceRoot":"","sources":["../../src/schemas/skill.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,qBAAqB,kCAAgC,CAAA;AAClE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEnE;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS1B,CAAA;AACF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD,iFAAiF;AACjF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EAO5B,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D,eAAO,MAAM,WAAW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AK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,YAAY,EAAE,CAAA;IACrB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB"}
@@ -173,3 +173,19 @@ export const autoSkillFromRepoRequestSchema = z.object({
173
173
  */
174
174
  custom_instructions: z.string().min(1).max(800).optional(),
175
175
  });
176
+ /* ─── Bulk sync — used by `prave sync` ─────────────────────────── */
177
+ /**
178
+ * `prave sync` previously hit GET /skills/:slug + POST /skills/:slug/install
179
+ * + POST /intelligence/analyze for each locally installed skill. With 85
180
+ * skills that's 255 requests per sync — well past the default 240/min/user
181
+ * cap, hitting the user mid-sync with "Too many requests" 429s. The bulk
182
+ * endpoint below collapses the round-trips into one request that returns
183
+ * every skill's content and records every install in a single DB pass.
184
+ *
185
+ * Slug cap of 250 keeps payload size reasonable (avg SKILL.md is ~4KB →
186
+ * ~1MB max response). Real-world libraries hit 50–150 skills so this
187
+ * leaves plenty of headroom without uncapped abuse risk.
188
+ */
189
+ export const bulkSyncInputSchema = z.object({
190
+ slugs: z.array(z.string().min(1).max(120)).min(1).max(250),
191
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prave/shared",
3
- "version": "1.4.14",
3
+ "version": "1.4.15",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"