lancer-shared 1.2.77 → 1.2.78

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.
@@ -12097,395 +12097,6 @@ const generateLeadCountsRequestSchema = z.object({
12097
12097
  campaignId: z.string().optional(),
12098
12098
  });
12099
12099
 
12100
- const proposalSchema = z.object({
12101
- coverLetter: z.string(),
12102
- questionAnswerPairs: questionAnswerPairSchema.array(),
12103
- });
12104
-
12105
- const LogEventTypeEnum = z.enum([
12106
- // Scraper Events
12107
- "scraperStarted",
12108
- "scraperCompleted",
12109
- "jobScraped",
12110
- "jobScrapeFailed",
12111
- "jobsIndexed",
12112
- "jobDuplicateSkipped",
12113
- "scraperFailed",
12114
- "jobActivityScraped",
12115
- "jobActivityScrapeFailed",
12116
- "leadStatusCheckFailed",
12117
- "leadStatusUpdated",
12118
- // Feed Scraper Events
12119
- "feedScrapeStarted",
12120
- "feedScrapeCompleted",
12121
- "feedScrapeFailed",
12122
- "jobListingScraped",
12123
- // Job Sync & Campaign Matching
12124
- "jobSyncPublished",
12125
- "jobSyncReceived",
12126
- "leadsCreatedAndSynced",
12127
- // Suitability Events
12128
- "suitabilityPending",
12129
- "suitabilityProcessing",
12130
- "suitabilityComplete",
12131
- "suitabilityFailed",
12132
- "manualSuitabilityAnalyzed",
12133
- // Proposal Events
12134
- "proposalProcessing",
12135
- "proposalComplete",
12136
- "proposalFailed",
12137
- "manualProposalGenerated",
12138
- // Bidding Events
12139
- "biddingProcessing",
12140
- "biddingComplete",
12141
- "biddingFailed",
12142
- "biddingSkipped",
12143
- "biddingPending",
12144
- "biddingRetry",
12145
- "biddingInsufficientConnects",
12146
- "biddingWarningAlert",
12147
- // System/Generic Events
12148
- "errorLogged",
12149
- "cloudTaskRetry",
12150
- "manualLeadEdited",
12151
- "leadArchived",
12152
- "auditTrailLogged",
12153
- ]);
12154
- const logEventSchema = z.object({
12155
- // The type of event (use a z.enum if possible)
12156
- type: LogEventTypeEnum, // e.g. "suitability-failed", "proposal-generated"
12157
- // The service that triggered the event
12158
- source: z.string(), // e.g. "lancer-agents", "lancer-bidding"
12159
- // Optional: Allow logging non-lead events in the future
12160
- resourceType: z.string().default("lead"), // e.g. "lead", "campaign", "user"
12161
- // ID of the resource (primary entity affected)
12162
- resourceId: z.string().nullable(), // fallback if leadId is not applicable
12163
- // Lead-level metadata
12164
- organizationId: z.string().nullable(),
12165
- userId: z.string().nullable(),
12166
- campaignId: z.string().nullable(),
12167
- leadId: z.string().nullable(),
12168
- // Reason or message for the event
12169
- reason: z.string().nullable(),
12170
- // Generic metadata (stacktrace, score, raw request, etc.)
12171
- metadata: z.record(z.unknown()).nullable(),
12172
- // Optional timestamp override
12173
- timestamp: z.number(),
12174
- });
12175
- const listingScrapedEventMetadata = objectType({
12176
- listing: jobListingSchema,
12177
- region: regionSchema,
12178
- });
12179
- const jobActivityScrapedEventMetadata = objectType({
12180
- activity: jobActivitySchema,
12181
- region: regionSchema,
12182
- offsetHour: jobActivityOffsetHourSchema,
12183
- scrapedAt: numberType(),
12184
- });
12185
- const jobActivityScrapeFailedEventMetadata = objectType({
12186
- listing: jobListingSchema,
12187
- region: regionSchema,
12188
- offsetHour: jobActivityOffsetHourSchema,
12189
- });
12190
- const feedScrapeStartedEventMetadata = objectType({
12191
- id: stringType(),
12192
- startTime: numberType(),
12193
- region: regionSchema,
12194
- });
12195
- const feedScrapeCompletedEventMetadata = objectType({
12196
- id: stringType(),
12197
- endTime: numberType(),
12198
- region: regionSchema,
12199
- accountUsername: stringType(),
12200
- listings: arrayType(jobListingSchema),
12201
- });
12202
- const biddingCompletedEventMetadata = objectType({
12203
- biddingAmount: numberType(),
12204
- boosted: booleanType(),
12205
- boostingAmount: numberType(),
12206
- });
12207
- const biddingFailedEventMetadata = objectType({
12208
- error: z.any(),
12209
- });
12210
- const userAccountBiddingExceptionEventMetadata = objectType({
12211
- errorType: z.enum(["insufficientConnects", "proposalFormWarningAlert"]),
12212
- context: z.string().optional(),
12213
- });
12214
- const lancerBiddingExceptionEventMetadata = objectType({
12215
- errorType: z.string(),
12216
- errorMessage: z.string(),
12217
- context: z.string().optional(),
12218
- });
12219
- const leadStatusEventMetadata = objectType({
12220
- campaignId: stringType(),
12221
- organizationId: stringType(),
12222
- leadId: stringType(),
12223
- userId: stringType(),
12224
- metadata: z
12225
- .object({
12226
- status: leadStatusSchema,
12227
- proposalId: stringType().nullable(),
12228
- })
12229
- .optional(),
12230
- reason: z.string().optional(),
12231
- });
12232
- const suitabilityCompleteEventMetadataSchema = objectType({
12233
- suitabilityRating: z.number(),
12234
- suitabilityReason: z.string(),
12235
- agentStatus: z.string(),
12236
- model: z.string(),
12237
- provider: z.string(),
12238
- promptTokens: z.number(),
12239
- completionTokens: z.number(),
12240
- messages: z.array(objectType({
12241
- role: z.string(),
12242
- content: z.string(),
12243
- })),
12244
- });
12245
- const suitabilityFailedEventMetadataSchema = objectType({
12246
- agentStatus: z.string(),
12247
- reason: z.string(),
12248
- });
12249
- const proposalCompleteEventMetadataSchema = objectType({
12250
- agentStatus: z.string(),
12251
- proposal: proposalSchema,
12252
- model: z.string(),
12253
- provider: z.string(),
12254
- promptTokens: z.number(),
12255
- completionTokens: z.number(),
12256
- messages: z.array(objectType({
12257
- role: z.string(),
12258
- content: z.string(),
12259
- })),
12260
- });
12261
- const eventLoggerPayloadSchema = unionType([
12262
- logEventSchema,
12263
- arrayType(logEventSchema),
12264
- ]);
12265
-
12266
- const usageEventTypeEnum = LogEventTypeEnum.extract([
12267
- "suitabilityComplete",
12268
- "proposalComplete",
12269
- "biddingComplete",
12270
- ]);
12271
- const usageEventMetadataSchema = objectType({
12272
- campaignId: stringType().nullable(),
12273
- userId: stringType().nullable(),
12274
- stripeSubscriptionId: stringType().nullable(),
12275
- planId: stringType().nullable(),
12276
- });
12277
- const usageEventSchema = objectType({
12278
- organizationId: stringType(),
12279
- typeId: usageEventTypeEnum,
12280
- timestamp: numberType(),
12281
- metadata: usageEventMetadataSchema,
12282
- });
12283
-
12284
- const billingStripeMetadataSchema = objectType({
12285
- customer: objectType({ id: stringType().nullable() }),
12286
- });
12287
- const billingSchema = objectType({
12288
- savedCard: booleanType(),
12289
- stripe: billingStripeMetadataSchema,
12290
- });
12291
-
12292
- const subscriptionStatusEnum = z.enum([
12293
- "active",
12294
- "trialing",
12295
- "cancelled",
12296
- "paused",
12297
- "payment_processing",
12298
- "payment_pending",
12299
- "payment_failed",
12300
- ]);
12301
- const subscriptionSourceEnum = z.enum(["stripe", "manual"]);
12302
- const subscriptionStripeMetadataItemSchema = objectType({
12303
- id: stringType(),
12304
- price: objectType({
12305
- id: stringType(),
12306
- }),
12307
- });
12308
- const subscriptionStripeMetadataSchema = objectType({
12309
- id: stringType(),
12310
- items: arrayType(subscriptionStripeMetadataItemSchema),
12311
- invoice: objectType({
12312
- id: stringType(),
12313
- hosted_invoice_url: stringType().nullable(),
12314
- }),
12315
- });
12316
- const subscriptionSchema = objectType({
12317
- planId: stringType(),
12318
- pendingPlanId: stringType().nullable(),
12319
- status: subscriptionStatusEnum,
12320
- startedAt: numberType(),
12321
- currentPeriodEnd: numberType(),
12322
- stripe: subscriptionStripeMetadataSchema,
12323
- source: subscriptionSourceEnum,
12324
- usage: recordType(usageEventTypeEnum, numberType()),
12325
- });
12326
-
12327
- const coverLetterTemplateSchema = z.object({
12328
- id: z.string(),
12329
- name: z.string(),
12330
- description: z.string().nullable(),
12331
- template: z.string(),
12332
- instructions: z.string(),
12333
- });
12334
- const createCoverLetterTemplateSchema = coverLetterTemplateSchema.pick({
12335
- name: true,
12336
- template: true,
12337
- instructions: true,
12338
- });
12339
-
12340
- const organizationMemberRoleEnum = z.enum(["admin", "member"]);
12341
- const organizationMemberSchema = objectType({
12342
- role: organizationMemberRoleEnum,
12343
- joinedAt: numberType(),
12344
- invitedBy: stringType(),
12345
- });
12346
-
12347
- const onboardingProgressSchema = z.object({
12348
- profileSetup: z.boolean(),
12349
- campaignCreated: z.boolean(),
12350
- filtersAdded: z.boolean(),
12351
- automationEnabled: z.boolean(),
12352
- startCampaign: z.boolean(),
12353
- });
12354
-
12355
- const organizationTypeSchema = z.enum(["agency", "freelancer"]);
12356
- const organizationTierEnum = z.enum(["free", "premium"]);
12357
- const limitsSchema = objectType({
12358
- monthlyCredits: numberType(),
12359
- usedCredits: numberType(),
12360
- extraCredits: numberType(),
12361
- });
12362
- const organizationSchema = objectType({
12363
- id: stringType(),
12364
- name: stringType(),
12365
- type: organizationTypeSchema,
12366
- associatedBidders: z.array(stringType()).nullable(),
12367
- subscription: subscriptionSchema.nullable(),
12368
- active: booleanType(),
12369
- limits: limitsSchema,
12370
- billing: billingSchema.nullable(),
12371
- lastBidTime: numberType().nullable(),
12372
- createdAt: numberType(),
12373
- updatedAt: numberType(),
12374
- openRouterApiKey: stringType().nullable(),
12375
- });
12376
- const caseStudySchema = objectType({
12377
- title: stringType(),
12378
- description: stringType(),
12379
- });
12380
- z.object({
12381
- type: z.enum(["freelancer", "agency"]),
12382
- name: z.string(),
12383
- summary: z.string(),
12384
- coreServices: z.string(),
12385
- toolsSkillsTechnologies: z.string(),
12386
- approach: z.string(),
12387
- icp: z.string(),
12388
- projectsTheyAvoid: z.string(),
12389
- spokenLanguages: z.string(),
12390
- agencyInfo: z.object({
12391
- location: z.array(z.string()),
12392
- website: z.string().url(),
12393
- teamSize: z.number(),
12394
- }),
12395
- caseStudies: z.array(caseStudySchema),
12396
- });
12397
- const createOrganizationSchema = organizationSchema.pick({
12398
- name: true,
12399
- type: true,
12400
- });
12401
- const trackUsageEventTypeEnum = LogEventTypeEnum.extract([
12402
- "suitabilityComplete",
12403
- "proposalComplete",
12404
- "biddingComplete",
12405
- ]);
12406
- const trackUsagePayloadSchema = objectType({
12407
- event: usageEventTypeEnum,
12408
- campaignId: stringType().nullish(),
12409
- });
12410
- const questionRulesSchema = objectType({
12411
- question: stringType(),
12412
- answer: stringType(),
12413
- category: stringType(),
12414
- });
12415
- const aiConfigSchema = objectType({
12416
- // suitabilityRules: string().nullable(),
12417
- // coverLetterRules: string().nullable(),
12418
- // coverLetterTemplate: string().nullable(),
12419
- questionRules: arrayType(questionRulesSchema).nullable(),
12420
- // approvedSuitabilityJobs: number().nullable(),
12421
- // approvedProposalJobs: number().nullable(),
12422
- });
12423
- const notificationConfigSchema = objectType({
12424
- emailEnabled: booleanType(),
12425
- discordWebhookUrl: stringType().nullable(),
12426
- slackWebhookUrl: stringType().nullable(),
12427
- });
12428
- const organizationSettingsSchema = objectType({
12429
- aiConfig: aiConfigSchema,
12430
- });
12431
- const subscribePayloadSchema = objectType({
12432
- planId: stringType().min(1, "Plan id is required."),
12433
- paymentMethodId: stringType().min(1, "Payment method is required."),
12434
- toltReferral: stringType().optional(),
12435
- couponCode: stringType().nullish(),
12436
- });
12437
-
12438
- const systemPromptSchema = objectType({
12439
- suitability: stringType(),
12440
- proposal: stringType(),
12441
- questionHandlingGuidelines: stringType(),
12442
- });
12443
- const systemSchema = objectType({
12444
- prompts: systemPromptSchema,
12445
- });
12446
-
12447
- const agentTaskRequestSchema = z.object({
12448
- userId: z.string().nullable(),
12449
- organizationId: z.string(),
12450
- campaignId: z.string(),
12451
- lead: leadSchema,
12452
- });
12453
- const testSystemPromptsRequestSchema = z.object({
12454
- organizationId: z.string(),
12455
- modelSuitability: z.string(),
12456
- modelProposal: z.string(),
12457
- systemPrompt: systemPromptSchema,
12458
- aiConfig: aiConfigSchema,
12459
- lead: leadSchema,
12460
- });
12461
- const suitabilityRatingSchema = z.object({
12462
- rating: z.number(),
12463
- reason: z.string(),
12464
- });
12465
- const agentTaskResponseSchema = z.object({
12466
- result: z.union([suitabilityRatingSchema, proposalSchema]),
12467
- model: z.string(),
12468
- provider: z.string(),
12469
- promptTokens: z.number(),
12470
- completionTokens: z.number(),
12471
- });
12472
- const testSystemPromptsResponseSchema = z.object({
12473
- proposal: z.object({
12474
- result: proposalSchema,
12475
- model: z.string(),
12476
- provider: z.string(),
12477
- promptTokens: z.number(),
12478
- completionTokens: z.number(),
12479
- }),
12480
- suitability: z.object({
12481
- result: suitabilityRatingSchema,
12482
- model: z.string(),
12483
- provider: z.string(),
12484
- promptTokens: z.number(),
12485
- completionTokens: z.number(),
12486
- }),
12487
- });
12488
-
12489
12100
  const bidPayloadProposalDataSchema = z.object({
12490
12101
  coverLetter: z.string(),
12491
12102
  questionAnswerPairs: questionAnswerPairSchema.array().nullable(),
@@ -12826,73 +12437,411 @@ const campaignWebhookSchema = z.object({
12826
12437
  url: z.string().url(),
12827
12438
  notificationSettings: campaignWebhookSettingsSchema,
12828
12439
  });
12829
- const sendNotificationRequestSchema = z.object({
12830
- organizationId: z.string(),
12831
- campaignId: z.string(),
12832
- leadId: z.string(),
12833
- type: campaignNotificationType,
12440
+ const sendNotificationRequestSchema = z.object({
12441
+ organizationId: z.string(),
12442
+ campaignId: z.string(),
12443
+ leadId: z.string(),
12444
+ type: campaignNotificationType,
12445
+ });
12446
+
12447
+ const bidConfigSchema = z.object({
12448
+ agencyName: z.string().nullable(),
12449
+ bidderId: z.string().nullable(),
12450
+ contractorName: z.string().nullable(),
12451
+ specialisedProfile: z.string().nullable(),
12452
+ });
12453
+ const campaignStatusSchema = z.union([
12454
+ z.literal("active"),
12455
+ z.literal("draft"),
12456
+ z.literal("paused"),
12457
+ z.literal("error"),
12458
+ ]);
12459
+ const campaignSchema = z.object({
12460
+ id: z.string(),
12461
+ name: z.string(),
12462
+ filters: jobFiltersSchema,
12463
+ createdAt: numberType(),
12464
+ updatedAt: numberType(),
12465
+ confirmedBillingAt: numberType().nullable(),
12466
+ // automatedSuitability: z.boolean().nullable(),
12467
+ boostingEnabled: z.boolean().nullable().default(false),
12468
+ maximumBoost: z.number().nullable().default(30),
12469
+ // minimumBoost: z.number().nullable().default(0),
12470
+ monthlyBudget: z.number().nullable(),
12471
+ // suitabilityThreshold: z.number().min(0).max(100).nullable().default(0),
12472
+ boostingThreshold: z.number().min(0).max(100).nullable().default(0),
12473
+ leadCounts: z.record(leadStatusSchema, z.number()).nullable(),
12474
+ expenses: campaignExpensesSchema,
12475
+ notificationsEnabled: z.boolean().nullable(),
12476
+ webhooks: z.array(campaignWebhookSchema),
12477
+ status: campaignStatusSchema.optional(),
12478
+ bidConfig: bidConfigSchema.nullable(),
12479
+ coverLetterTemplateId: z.string().nullable(),
12480
+ });
12481
+ const upworkAccountConnectStatusSchema = z.union([
12482
+ z.literal("processing"),
12483
+ z.literal("connected"),
12484
+ z.literal("failed"),
12485
+ ]);
12486
+ const upworkAccountConnectSchema = z.object({
12487
+ status: upworkAccountConnectStatusSchema.nullable(),
12488
+ error: z.string().nullable(),
12489
+ });
12490
+ const createCampaignSchema = campaignSchema.omit({
12491
+ id: true,
12492
+ createdAt: true,
12493
+ updatedAt: true,
12494
+ bidConfig: true,
12495
+ });
12496
+ const updateCampaignSchema = campaignSchema
12497
+ .omit({
12498
+ createdAt: true,
12499
+ updatedAt: true,
12500
+ })
12501
+ .partial();
12502
+
12503
+ const campaignAIMetricsSchema = z.object({
12504
+ leadsAnalyzed: z.number(),
12505
+ leadsBidded: z.number(),
12506
+ connectsSaved: z.number(),
12507
+ });
12508
+
12509
+ const proposalSchema = z.object({
12510
+ coverLetter: z.string(),
12511
+ questionAnswerPairs: questionAnswerPairSchema.array(),
12512
+ });
12513
+
12514
+ const LogEventTypeEnum = z.enum([
12515
+ // Scraper Events
12516
+ "scraperStarted",
12517
+ "scraperCompleted",
12518
+ "jobScraped",
12519
+ "jobScrapeFailed",
12520
+ "jobsIndexed",
12521
+ "jobDuplicateSkipped",
12522
+ "scraperFailed",
12523
+ "jobActivityScraped",
12524
+ "jobActivityScrapeFailed",
12525
+ "leadStatusCheckFailed",
12526
+ "leadStatusUpdated",
12527
+ // Feed Scraper Events
12528
+ "feedScrapeStarted",
12529
+ "feedScrapeCompleted",
12530
+ "feedScrapeFailed",
12531
+ "jobListingScraped",
12532
+ // Job Sync & Campaign Matching
12533
+ "jobSyncPublished",
12534
+ "jobSyncReceived",
12535
+ "leadsCreatedAndSynced",
12536
+ // Suitability Events
12537
+ "suitabilityPending",
12538
+ "suitabilityProcessing",
12539
+ "suitabilityComplete",
12540
+ "suitabilityFailed",
12541
+ "manualSuitabilityAnalyzed",
12542
+ // Proposal Events
12543
+ "proposalProcessing",
12544
+ "proposalComplete",
12545
+ "proposalFailed",
12546
+ "manualProposalGenerated",
12547
+ // Bidding Events
12548
+ "biddingProcessing",
12549
+ "biddingComplete",
12550
+ "biddingFailed",
12551
+ "biddingSkipped",
12552
+ "biddingPending",
12553
+ "biddingRetry",
12554
+ "biddingInsufficientConnects",
12555
+ "biddingWarningAlert",
12556
+ // System/Generic Events
12557
+ "errorLogged",
12558
+ "cloudTaskRetry",
12559
+ "manualLeadEdited",
12560
+ "leadArchived",
12561
+ "auditTrailLogged",
12562
+ ]);
12563
+ const logEventSchema = z.object({
12564
+ // The type of event (use a z.enum if possible)
12565
+ type: LogEventTypeEnum, // e.g. "suitability-failed", "proposal-generated"
12566
+ // The service that triggered the event
12567
+ source: z.string(), // e.g. "lancer-agents", "lancer-bidding"
12568
+ // Optional: Allow logging non-lead events in the future
12569
+ resourceType: z.string().default("lead"), // e.g. "lead", "campaign", "user"
12570
+ // ID of the resource (primary entity affected)
12571
+ resourceId: z.string().nullable(), // fallback if leadId is not applicable
12572
+ // Lead-level metadata
12573
+ organizationId: z.string().nullable(),
12574
+ userId: z.string().nullable(),
12575
+ campaignId: z.string().nullable(),
12576
+ leadId: z.string().nullable(),
12577
+ // Reason or message for the event
12578
+ reason: z.string().nullable(),
12579
+ // Generic metadata (stacktrace, score, raw request, etc.)
12580
+ metadata: z.record(z.unknown()).nullable(),
12581
+ // Optional timestamp override
12582
+ timestamp: z.number(),
12583
+ });
12584
+ const listingScrapedEventMetadata = objectType({
12585
+ listing: jobListingSchema,
12586
+ region: regionSchema,
12587
+ });
12588
+ const jobActivityScrapedEventMetadata = objectType({
12589
+ activity: jobActivitySchema,
12590
+ region: regionSchema,
12591
+ offsetHour: jobActivityOffsetHourSchema,
12592
+ scrapedAt: numberType(),
12593
+ });
12594
+ const jobActivityScrapeFailedEventMetadata = objectType({
12595
+ listing: jobListingSchema,
12596
+ region: regionSchema,
12597
+ offsetHour: jobActivityOffsetHourSchema,
12598
+ });
12599
+ const feedScrapeStartedEventMetadata = objectType({
12600
+ id: stringType(),
12601
+ startTime: numberType(),
12602
+ region: regionSchema,
12603
+ });
12604
+ const feedScrapeCompletedEventMetadata = objectType({
12605
+ id: stringType(),
12606
+ endTime: numberType(),
12607
+ region: regionSchema,
12608
+ accountUsername: stringType(),
12609
+ listings: arrayType(jobListingSchema),
12610
+ });
12611
+ const biddingCompletedEventMetadata = objectType({
12612
+ biddingAmount: numberType(),
12613
+ boosted: booleanType(),
12614
+ boostingAmount: numberType(),
12615
+ });
12616
+ const biddingFailedEventMetadata = objectType({
12617
+ error: z.any(),
12618
+ });
12619
+ const userAccountBiddingExceptionEventMetadata = objectType({
12620
+ errorType: z.enum(["insufficientConnects", "proposalFormWarningAlert"]),
12621
+ context: z.string().optional(),
12622
+ });
12623
+ const lancerBiddingExceptionEventMetadata = objectType({
12624
+ errorType: z.string(),
12625
+ errorMessage: z.string(),
12626
+ context: z.string().optional(),
12627
+ });
12628
+ const leadStatusEventMetadata = objectType({
12629
+ campaignId: stringType(),
12630
+ organizationId: stringType(),
12631
+ leadId: stringType(),
12632
+ userId: stringType(),
12633
+ metadata: z
12634
+ .object({
12635
+ status: leadStatusSchema,
12636
+ proposalId: stringType().nullable(),
12637
+ })
12638
+ .optional(),
12639
+ reason: z.string().optional(),
12640
+ });
12641
+ const suitabilityCompleteEventMetadataSchema = objectType({
12642
+ suitabilityRating: z.number(),
12643
+ suitabilityReason: z.string(),
12644
+ agentStatus: z.string(),
12645
+ model: z.string(),
12646
+ provider: z.string(),
12647
+ promptTokens: z.number(),
12648
+ completionTokens: z.number(),
12649
+ messages: z.array(objectType({
12650
+ role: z.string(),
12651
+ content: z.string(),
12652
+ })),
12653
+ });
12654
+ const suitabilityFailedEventMetadataSchema = objectType({
12655
+ agentStatus: z.string(),
12656
+ reason: z.string(),
12657
+ });
12658
+ const proposalCompleteEventMetadataSchema = objectType({
12659
+ agentStatus: z.string(),
12660
+ proposal: proposalSchema,
12661
+ model: z.string(),
12662
+ provider: z.string(),
12663
+ promptTokens: z.number(),
12664
+ completionTokens: z.number(),
12665
+ messages: z.array(objectType({
12666
+ role: z.string(),
12667
+ content: z.string(),
12668
+ })),
12669
+ });
12670
+ const eventLoggerPayloadSchema = unionType([
12671
+ logEventSchema,
12672
+ arrayType(logEventSchema),
12673
+ ]);
12674
+
12675
+ const usageEventTypeEnum = LogEventTypeEnum.extract([
12676
+ "suitabilityComplete",
12677
+ "proposalComplete",
12678
+ "biddingComplete",
12679
+ ]);
12680
+ const usageEventMetadataSchema = objectType({
12681
+ campaignId: stringType().nullable(),
12682
+ userId: stringType().nullable(),
12683
+ stripeSubscriptionId: stringType().nullable(),
12684
+ planId: stringType().nullable(),
12685
+ });
12686
+ const usageEventSchema = objectType({
12687
+ organizationId: stringType(),
12688
+ typeId: usageEventTypeEnum,
12689
+ timestamp: numberType(),
12690
+ metadata: usageEventMetadataSchema,
12834
12691
  });
12835
12692
 
12836
- const bidConfigSchema = z.object({
12837
- agencyName: z.string().nullable(),
12838
- bidderId: z.string().nullable(),
12839
- contractorName: z.string().nullable(),
12840
- specialisedProfile: z.string().nullable(),
12693
+ const billingStripeMetadataSchema = objectType({
12694
+ customer: objectType({ id: stringType().nullable() }),
12841
12695
  });
12842
- const campaignStatusSchema = z.union([
12843
- z.literal("active"),
12844
- z.literal("draft"),
12845
- z.literal("paused"),
12846
- z.literal("error"),
12696
+ const billingSchema = objectType({
12697
+ savedCard: booleanType(),
12698
+ stripe: billingStripeMetadataSchema,
12699
+ });
12700
+
12701
+ const subscriptionStatusEnum = z.enum([
12702
+ "active",
12703
+ "trialing",
12704
+ "cancelled",
12705
+ "paused",
12706
+ "payment_processing",
12707
+ "payment_pending",
12708
+ "payment_failed",
12847
12709
  ]);
12848
- const campaignSchema = z.object({
12710
+ const subscriptionSourceEnum = z.enum(["stripe", "manual"]);
12711
+ const subscriptionStripeMetadataItemSchema = objectType({
12712
+ id: stringType(),
12713
+ price: objectType({
12714
+ id: stringType(),
12715
+ }),
12716
+ });
12717
+ const subscriptionStripeMetadataSchema = objectType({
12718
+ id: stringType(),
12719
+ items: arrayType(subscriptionStripeMetadataItemSchema),
12720
+ invoice: objectType({
12721
+ id: stringType(),
12722
+ hosted_invoice_url: stringType().nullable(),
12723
+ }),
12724
+ });
12725
+ const subscriptionSchema = objectType({
12726
+ planId: stringType(),
12727
+ pendingPlanId: stringType().nullable(),
12728
+ status: subscriptionStatusEnum,
12729
+ startedAt: numberType(),
12730
+ currentPeriodEnd: numberType(),
12731
+ stripe: subscriptionStripeMetadataSchema,
12732
+ source: subscriptionSourceEnum,
12733
+ usage: recordType(usageEventTypeEnum, numberType()),
12734
+ });
12735
+
12736
+ const coverLetterTemplateSchema = z.object({
12849
12737
  id: z.string(),
12850
12738
  name: z.string(),
12851
- filters: jobFiltersSchema,
12739
+ description: z.string().nullable(),
12740
+ template: z.string(),
12741
+ instructions: z.string(),
12742
+ });
12743
+ const createCoverLetterTemplateSchema = coverLetterTemplateSchema.pick({
12744
+ name: true,
12745
+ template: true,
12746
+ instructions: true,
12747
+ });
12748
+
12749
+ const organizationMemberRoleEnum = z.enum(["admin", "member"]);
12750
+ const organizationMemberSchema = objectType({
12751
+ role: organizationMemberRoleEnum,
12752
+ joinedAt: numberType(),
12753
+ invitedBy: stringType(),
12754
+ });
12755
+
12756
+ const onboardingProgressSchema = z.object({
12757
+ profileSetup: z.boolean(),
12758
+ campaignCreated: z.boolean(),
12759
+ filtersAdded: z.boolean(),
12760
+ automationEnabled: z.boolean(),
12761
+ startCampaign: z.boolean(),
12762
+ });
12763
+
12764
+ const organizationTypeSchema = z.enum(["agency", "freelancer"]);
12765
+ const organizationTierEnum = z.enum(["free", "premium"]);
12766
+ const limitsSchema = objectType({
12767
+ monthlyCredits: numberType(),
12768
+ usedCredits: numberType(),
12769
+ extraCredits: numberType(),
12770
+ });
12771
+ const organizationSchema = objectType({
12772
+ id: stringType(),
12773
+ name: stringType(),
12774
+ type: organizationTypeSchema,
12775
+ associatedBidders: z.array(stringType()).nullable(),
12776
+ subscription: subscriptionSchema.nullable(),
12777
+ active: booleanType(),
12778
+ limits: limitsSchema,
12779
+ billing: billingSchema.nullable(),
12780
+ lastBidTime: numberType().nullable(),
12852
12781
  createdAt: numberType(),
12853
12782
  updatedAt: numberType(),
12854
- confirmedBillingAt: numberType().nullable(),
12855
- // automatedSuitability: z.boolean().nullable(),
12856
- boostingEnabled: z.boolean().nullable().default(false),
12857
- maximumBoost: z.number().nullable().default(30),
12858
- // minimumBoost: z.number().nullable().default(0),
12859
- monthlyBudget: z.number().nullable(),
12860
- // suitabilityThreshold: z.number().min(0).max(100).nullable().default(0),
12861
- boostingThreshold: z.number().min(0).max(100).nullable().default(0),
12862
- leadCounts: z.record(leadStatusSchema, z.number()).nullable(),
12863
- expenses: campaignExpensesSchema,
12864
- notificationsEnabled: z.boolean().nullable(),
12865
- webhooks: z.array(campaignWebhookSchema),
12866
- status: campaignStatusSchema.optional(),
12867
- bidConfig: bidConfigSchema.nullable(),
12868
- coverLetterTemplateId: z.string().nullable(),
12783
+ openRouterApiKey: stringType().nullable(),
12869
12784
  });
12870
- const upworkAccountConnectStatusSchema = z.union([
12871
- z.literal("processing"),
12872
- z.literal("connected"),
12873
- z.literal("failed"),
12785
+ const caseStudySchema = objectType({
12786
+ title: stringType(),
12787
+ description: stringType(),
12788
+ });
12789
+ z.object({
12790
+ type: z.enum(["freelancer", "agency"]),
12791
+ name: z.string(),
12792
+ summary: z.string(),
12793
+ coreServices: z.string(),
12794
+ toolsSkillsTechnologies: z.string(),
12795
+ approach: z.string(),
12796
+ icp: z.string(),
12797
+ projectsTheyAvoid: z.string(),
12798
+ spokenLanguages: z.string(),
12799
+ agencyInfo: z.object({
12800
+ location: z.array(z.string()),
12801
+ website: z.string().url(),
12802
+ teamSize: z.number(),
12803
+ }),
12804
+ caseStudies: z.array(caseStudySchema),
12805
+ });
12806
+ const createOrganizationSchema = organizationSchema.pick({
12807
+ name: true,
12808
+ type: true,
12809
+ });
12810
+ const trackUsageEventTypeEnum = LogEventTypeEnum.extract([
12811
+ "suitabilityComplete",
12812
+ "proposalComplete",
12813
+ "biddingComplete",
12874
12814
  ]);
12875
- const upworkAccountConnectSchema = z.object({
12876
- status: upworkAccountConnectStatusSchema.nullable(),
12877
- error: z.string().nullable(),
12815
+ const trackUsagePayloadSchema = objectType({
12816
+ event: usageEventTypeEnum,
12817
+ campaignId: stringType().nullish(),
12878
12818
  });
12879
- const createCampaignSchema = campaignSchema.omit({
12880
- id: true,
12881
- createdAt: true,
12882
- updatedAt: true,
12883
- bidConfig: true,
12819
+ const questionRulesSchema = objectType({
12820
+ question: stringType(),
12821
+ answer: stringType(),
12822
+ category: stringType(),
12884
12823
  });
12885
- const updateCampaignSchema = campaignSchema
12886
- .omit({
12887
- createdAt: true,
12888
- updatedAt: true,
12889
- })
12890
- .partial();
12891
-
12892
- const campaignAIMetricsSchema = z.object({
12893
- leadsAnalyzed: z.number(),
12894
- leadsBidded: z.number(),
12895
- connectsSaved: z.number(),
12824
+ const aiConfigSchema = objectType({
12825
+ // suitabilityRules: string().nullable(),
12826
+ // coverLetterRules: string().nullable(),
12827
+ // coverLetterTemplate: string().nullable(),
12828
+ questionRules: arrayType(questionRulesSchema).nullable(),
12829
+ // approvedSuitabilityJobs: number().nullable(),
12830
+ // approvedProposalJobs: number().nullable(),
12831
+ });
12832
+ const notificationConfigSchema = objectType({
12833
+ emailEnabled: booleanType(),
12834
+ discordWebhookUrl: stringType().nullable(),
12835
+ slackWebhookUrl: stringType().nullable(),
12836
+ });
12837
+ const organizationSettingsSchema = objectType({
12838
+ aiConfig: aiConfigSchema,
12839
+ });
12840
+ const subscribePayloadSchema = objectType({
12841
+ planId: stringType().min(1, "Plan id is required."),
12842
+ paymentMethodId: stringType().min(1, "Payment method is required."),
12843
+ toltReferral: stringType().optional(),
12844
+ couponCode: stringType().nullish(),
12896
12845
  });
12897
12846
 
12898
12847
  const campaignAnalyticsSchema = z.object({
@@ -13085,6 +13034,57 @@ const invoiceSchema = objectType({
13085
13034
  updatedAt: numberType(),
13086
13035
  });
13087
13036
 
13037
+ const systemPromptSchema = objectType({
13038
+ suitability: stringType(),
13039
+ proposal: stringType(),
13040
+ questionHandlingGuidelines: stringType(),
13041
+ });
13042
+ const systemSchema = objectType({
13043
+ prompts: systemPromptSchema,
13044
+ });
13045
+
13046
+ const agentTaskRequestSchema = z.object({
13047
+ userId: z.string().nullable(),
13048
+ organizationId: z.string(),
13049
+ campaignId: z.string(),
13050
+ lead: leadSchema,
13051
+ });
13052
+ const testSystemPromptsRequestSchema = z.object({
13053
+ organizationId: z.string(),
13054
+ modelSuitability: z.string(),
13055
+ modelProposal: z.string(),
13056
+ systemPrompt: systemPromptSchema,
13057
+ aiConfig: aiConfigSchema,
13058
+ lead: leadSchema,
13059
+ });
13060
+ const suitabilityRatingSchema = z.object({
13061
+ rating: z.number(),
13062
+ reason: z.string(),
13063
+ });
13064
+ const agentTaskResponseSchema = z.object({
13065
+ result: z.union([suitabilityRatingSchema, proposalSchema]),
13066
+ model: z.string(),
13067
+ provider: z.string(),
13068
+ promptTokens: z.number(),
13069
+ completionTokens: z.number(),
13070
+ });
13071
+ const testSystemPromptsResponseSchema = z.object({
13072
+ proposal: z.object({
13073
+ result: proposalSchema,
13074
+ model: z.string(),
13075
+ provider: z.string(),
13076
+ promptTokens: z.number(),
13077
+ completionTokens: z.number(),
13078
+ }),
13079
+ suitability: z.object({
13080
+ result: suitabilityRatingSchema,
13081
+ model: z.string(),
13082
+ provider: z.string(),
13083
+ promptTokens: z.number(),
13084
+ completionTokens: z.number(),
13085
+ }),
13086
+ });
13087
+
13088
13088
  const planStripeMetadataSchema = objectType({
13089
13089
  id: stringType().regex(/^prod_[a-zA-Z0-9]+$/),
13090
13090
  name: stringType(),
@@ -303,6 +303,7 @@ export declare const agentTaskRequestSchema: z.ZodObject<{
303
303
  }>>>;
304
304
  }, {
305
305
  jobId: z.ZodString;
306
+ scrapedAt: z.ZodNullable<z.ZodNumber>;
306
307
  updatedAt: z.ZodNullable<z.ZodNumber>;
307
308
  suitabilityRating: z.ZodNullable<z.ZodNumber>;
308
309
  suitabilityReason: z.ZodNullable<z.ZodString>;
@@ -418,6 +419,7 @@ export declare const agentTaskRequestSchema: z.ZodObject<{
418
419
  } | null;
419
420
  activityUpdates: 1 | 2 | 3 | null;
420
421
  jobId: string;
422
+ scrapedAt: number | null;
421
423
  suitabilityRating: number | null;
422
424
  suitabilityReason: string | null;
423
425
  proposal: string | null;
@@ -546,6 +548,7 @@ export declare const agentTaskRequestSchema: z.ZodObject<{
546
548
  } | null;
547
549
  activityUpdates: 1 | 2 | 3 | null;
548
550
  jobId: string;
551
+ scrapedAt: number | null;
549
552
  suitabilityRating: number | null;
550
553
  suitabilityReason: string | null;
551
554
  proposal: string | null;
@@ -679,6 +682,7 @@ export declare const agentTaskRequestSchema: z.ZodObject<{
679
682
  } | null;
680
683
  activityUpdates: 1 | 2 | 3 | null;
681
684
  jobId: string;
685
+ scrapedAt: number | null;
682
686
  suitabilityRating: number | null;
683
687
  suitabilityReason: string | null;
684
688
  proposal: string | null;
@@ -812,6 +816,7 @@ export declare const agentTaskRequestSchema: z.ZodObject<{
812
816
  } | null;
813
817
  activityUpdates: 1 | 2 | 3 | null;
814
818
  jobId: string;
819
+ scrapedAt: number | null;
815
820
  suitabilityRating: number | null;
816
821
  suitabilityReason: string | null;
817
822
  proposal: string | null;
@@ -1194,6 +1199,7 @@ export declare const testSystemPromptsRequestSchema: z.ZodObject<{
1194
1199
  }>>>;
1195
1200
  }, {
1196
1201
  jobId: z.ZodString;
1202
+ scrapedAt: z.ZodNullable<z.ZodNumber>;
1197
1203
  updatedAt: z.ZodNullable<z.ZodNumber>;
1198
1204
  suitabilityRating: z.ZodNullable<z.ZodNumber>;
1199
1205
  suitabilityReason: z.ZodNullable<z.ZodString>;
@@ -1309,6 +1315,7 @@ export declare const testSystemPromptsRequestSchema: z.ZodObject<{
1309
1315
  } | null;
1310
1316
  activityUpdates: 1 | 2 | 3 | null;
1311
1317
  jobId: string;
1318
+ scrapedAt: number | null;
1312
1319
  suitabilityRating: number | null;
1313
1320
  suitabilityReason: string | null;
1314
1321
  proposal: string | null;
@@ -1437,6 +1444,7 @@ export declare const testSystemPromptsRequestSchema: z.ZodObject<{
1437
1444
  } | null;
1438
1445
  activityUpdates: 1 | 2 | 3 | null;
1439
1446
  jobId: string;
1447
+ scrapedAt: number | null;
1440
1448
  suitabilityRating: number | null;
1441
1449
  suitabilityReason: string | null;
1442
1450
  proposal: string | null;
@@ -1568,6 +1576,7 @@ export declare const testSystemPromptsRequestSchema: z.ZodObject<{
1568
1576
  } | null;
1569
1577
  activityUpdates: 1 | 2 | 3 | null;
1570
1578
  jobId: string;
1579
+ scrapedAt: number | null;
1571
1580
  suitabilityRating: number | null;
1572
1581
  suitabilityReason: string | null;
1573
1582
  proposal: string | null;
@@ -1713,6 +1722,7 @@ export declare const testSystemPromptsRequestSchema: z.ZodObject<{
1713
1722
  } | null;
1714
1723
  activityUpdates: 1 | 2 | 3 | null;
1715
1724
  jobId: string;
1725
+ scrapedAt: number | null;
1716
1726
  suitabilityRating: number | null;
1717
1727
  suitabilityReason: string | null;
1718
1728
  proposal: string | null;
@@ -1,10 +1,10 @@
1
1
  export * from "./account";
2
- export * from "./agent";
3
2
  export * from "./bid";
4
3
  export * from "./campaign";
5
4
  export * from "./invoice";
6
5
  export * from "./job";
7
6
  export * from "./lead";
7
+ export * from "./agent";
8
8
  export * from "./logger";
9
9
  export * from "./organization";
10
10
  export * from "./plan";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lancer-shared",
3
- "version": "1.2.77",
3
+ "version": "1.2.78",
4
4
  "description": "This package contains shared stuff.",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "dist/bundle.cjs.js",