@scalemule/sdk 0.0.75 → 0.0.77

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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { PHONE_COUNTRIES, PhoneCountry, PhoneNormalizationResult, composePhoneNumber, countryFlag, detectCountryFromE164, findPhoneCountryByCode, findPhoneCountryByDialCode, isValidE164Phone, normalizeAndValidatePhone, normalizePhoneNumber } from '@scalemule/ui/phone';
2
+ import { E as ExperimentAssignment } from './experiments-RH_CTd1R.js';
3
+ export { a as EXPERIMENTS_PROPERTY, b as EXPERIMENT_EXPOSED_EVENT, c as ExperimentAssignments, d as ExperimentEvaluationLike, M as MAX_EXPERIMENTS_PER_EVENT, e as experimentVariant, f as exposureEvent, g as exposureStorageKey, i as isExperimentKey, h as isVariantKey, n as normalizeExperiments, w as withExperiments } from './experiments-RH_CTd1R.js';
2
4
 
3
5
  /**
4
6
  * ScaleMule SDK Types
@@ -3689,6 +3691,13 @@ declare class AnalyticsService extends ServiceModule {
3689
3691
  track(event: string, properties?: Record<string, unknown>, userId?: string, options?: RequestOptions): Promise<ApiResponse<{
3690
3692
  tracked: boolean;
3691
3693
  }>>;
3694
+ /**
3695
+ * Track that a visitor saw an experiment variant. Send it once per visitor and flag; the event
3696
+ * carries `properties.experiments` so the experiment report attributes it.
3697
+ */
3698
+ trackExposure(flagKey: string, variant: string, userId?: string, options?: RequestOptions): Promise<ApiResponse<{
3699
+ tracked: boolean;
3700
+ }>>;
3692
3701
  trackBatch(events: Array<{
3693
3702
  event: string;
3694
3703
  properties?: Record<string, unknown>;
@@ -3877,6 +3886,12 @@ interface UpsertEnvironmentRequest {
3877
3886
  declare class FlagsService extends ServiceModule {
3878
3887
  protected basePath: string;
3879
3888
  evaluate<T = unknown>(flagKey: string, context?: Record<string, unknown>, environment?: string, options?: RequestOptions): Promise<ApiResponse<FlagEvaluation<T>>>;
3889
+ /**
3890
+ * Assign a visitor to an experiment: a flag with weighted variants, evaluated with a stable
3891
+ * identifier (`session_id` or `user_id`) so the assignment is sticky. Attach the result to
3892
+ * analytics events with `withExperiments` and track one exposure with `analytics.trackExposure`.
3893
+ */
3894
+ experiment<T = unknown>(flagKey: string, context?: Record<string, unknown>, environment?: string, options?: RequestOptions): Promise<ApiResponse<ExperimentAssignment<T>>>;
3880
3895
  evaluateBatch(flagKeys: string[], context?: Record<string, unknown>, environment?: string, options?: RequestOptions): Promise<ApiResponse<Record<string, FlagEvaluation>>>;
3881
3896
  evaluateAll(context?: Record<string, unknown>, environment?: string, options?: RequestOptions): Promise<ApiResponse<Record<string, FlagEvaluation>>>;
3882
3897
  list(params?: {
@@ -5626,6 +5641,242 @@ declare class CommunityMapsGeographyService extends ServiceModule {
5626
5641
  }>>;
5627
5642
  }
5628
5643
 
5644
+ /** BaseNews delivery through the existing News service and ScaleMule identity.
5645
+ * Records are evidence-backed projections; a release is not an article.
5646
+ * Honor refresh_after and removals. Never use this API as a source-text archive.
5647
+ */
5648
+
5649
+ type IntelligenceKind = 'event' | 'development' | 'community_story' | 'opportunity' | 'public_notice';
5650
+ type IntelligenceStatus = 'proposed' | 'approved' | 'scheduled' | 'ongoing' | 'completed' | 'canceled' | 'postponed' | 'disputed';
5651
+ type IntelligenceVerification = 'unverified' | 'community_submitted' | 'supported' | 'officially_confirmed' | 'independently_verified' | 'disputed';
5652
+ type IntelligenceSection = 'important' | 'around_you' | 'people' | 'discover' | 'participate';
5653
+ type CommunityValueOutcome = 'understand' | 'discover' | 'decide' | 'participate' | 'not_relevant';
5654
+ interface IntelligenceEvent {
5655
+ starts_at: string;
5656
+ ends_at: string;
5657
+ time_zone: string;
5658
+ place_entity_id: string | null;
5659
+ organizer_entity_id: string | null;
5660
+ series_entity_id: string | null;
5661
+ cost: string | null;
5662
+ accessibility: string | null;
5663
+ }
5664
+ interface IntelligenceAction {
5665
+ label: string;
5666
+ url: string;
5667
+ deadline: string | null;
5668
+ }
5669
+ interface IntelligenceSource {
5670
+ id: string;
5671
+ title: string;
5672
+ publisher: string;
5673
+ url: string;
5674
+ published_at: string | null;
5675
+ retrieved_at: string | null;
5676
+ kind: string;
5677
+ distance: string;
5678
+ interested_party: boolean | null;
5679
+ }
5680
+ interface IntelligenceClaim {
5681
+ id: string;
5682
+ text: string;
5683
+ verification: 'UNVERIFIED' | 'SUPPORTED' | 'VERIFIED' | 'DISPUTED';
5684
+ attribution: string | null;
5685
+ evidence: {
5686
+ source_id: string;
5687
+ role: 'DIRECT' | 'CORROBORATING' | 'CONTEXT' | 'CONTRADICTING' | 'ATTRIBUTED_CLAIM';
5688
+ }[];
5689
+ }
5690
+ interface LocalIntelligenceRecord {
5691
+ contract_version: 'basenews/1';
5692
+ id: string;
5693
+ revision: number;
5694
+ title: string;
5695
+ why_it_matters: string;
5696
+ kind: IntelligenceKind;
5697
+ status: IntelligenceStatus;
5698
+ section: IntelligenceSection;
5699
+ civic_importance: boolean;
5700
+ geography_ids: string[];
5701
+ related_entity_ids: string[];
5702
+ issue_entity_ids: string[];
5703
+ topics: string[];
5704
+ event: IntelligenceEvent | null;
5705
+ actions: IntelligenceAction[];
5706
+ claims: IntelligenceClaim[];
5707
+ sources: IntelligenceSource[];
5708
+ verification: IntelligenceVerification;
5709
+ last_verified_at: string | null;
5710
+ observed_at: string;
5711
+ effective_at: string | null;
5712
+ review_due_at: string;
5713
+ published_at: string;
5714
+ original_reporting_url: string | null;
5715
+ original_byline: string;
5716
+ originating_publication_id: string;
5717
+ license: string;
5718
+ supersedes_revision: number | null;
5719
+ canonical_references: {
5720
+ reporting_package_id: string;
5721
+ reporting_revision: number;
5722
+ event_id: string | null;
5723
+ event_version: number | null;
5724
+ };
5725
+ /** Refresh or remove the record after this time. Access may have been revoked. */
5726
+ refresh_after: string;
5727
+ relevance_reasons?: string[];
5728
+ }
5729
+ interface LocalIntelligencePreferences {
5730
+ personalized: boolean;
5731
+ geography_ids: string[];
5732
+ topic_codes: string[];
5733
+ entity_ids: string[];
5734
+ issue_ids: string[];
5735
+ record_ids: string[];
5736
+ }
5737
+ interface IntelligenceRecordPage {
5738
+ contract_version: 'basenews/1';
5739
+ items: LocalIntelligenceRecord[];
5740
+ next_cursor: string | null;
5741
+ /** Keep the FIRST page's checkpoint while bootstrapping the inventory. */
5742
+ changes_cursor: string;
5743
+ /** Initialize IntelligenceCache.sequence from the FIRST page's value. */
5744
+ changes_sequence: string;
5745
+ }
5746
+ interface IntelligenceChangePage {
5747
+ contract_version: 'basenews/1';
5748
+ scope: {
5749
+ application_id: string;
5750
+ publication_id: string;
5751
+ };
5752
+ items: {
5753
+ sequence: string;
5754
+ id: string;
5755
+ changed_at: string;
5756
+ removed: boolean;
5757
+ record: LocalIntelligenceRecord | null;
5758
+ }[];
5759
+ next_cursor: string;
5760
+ has_more: boolean;
5761
+ lease_seconds: number;
5762
+ }
5763
+ interface LocalBriefing {
5764
+ contract_version: 'basenews/1';
5765
+ policy_version: string;
5766
+ as_of: string;
5767
+ geography_id: string;
5768
+ personalized: boolean;
5769
+ items: LocalIntelligenceRecord[];
5770
+ more_available: boolean;
5771
+ lease_seconds: number;
5772
+ }
5773
+ interface IntelligenceRelease {
5774
+ package_id: string;
5775
+ package_revision: number;
5776
+ expected_revision: number;
5777
+ title: string;
5778
+ why_it_matters: string;
5779
+ kind: IntelligenceKind;
5780
+ status: IntelligenceStatus;
5781
+ section: IntelligenceSection;
5782
+ civic_importance: boolean;
5783
+ claim_ids: string[];
5784
+ geography_ids: string[];
5785
+ related_entity_ids: string[];
5786
+ issue_entity_ids: string[];
5787
+ topics: string[];
5788
+ event: IntelligenceEvent | null;
5789
+ actions: IntelligenceAction[];
5790
+ verification: IntelligenceVerification;
5791
+ last_verified_at: string | null;
5792
+ observed_at: string;
5793
+ effective_at: string | null;
5794
+ review_due_at: string;
5795
+ original_reporting_url: string | null;
5796
+ redistribution_permitted: boolean;
5797
+ privacy_and_consent_reviewed: boolean;
5798
+ license: string;
5799
+ reason: string;
5800
+ destinations: {
5801
+ application_id: string;
5802
+ publication_id: string;
5803
+ expires_at: string;
5804
+ }[];
5805
+ sensitivity_review: {
5806
+ policy_version: string;
5807
+ rule_ids: string[];
5808
+ reason: string;
5809
+ } | null;
5810
+ }
5811
+ interface IntelligenceReleaseReceipt {
5812
+ id: string;
5813
+ revision: number;
5814
+ contract_version: 'basenews/1';
5815
+ }
5816
+ /** API keys remain server-side in publication apps. Personal preference writes
5817
+ * use the reader's authenticated session; agents cannot impersonate a reader.
5818
+ * Methods retain the SDK's {data,error} contract and RequestOptions propagation.
5819
+ */
5820
+ declare class LocalIntelligenceService extends ServiceModule {
5821
+ protected basePath: string;
5822
+ private scope;
5823
+ records(publication: string, params?: {
5824
+ cursor?: string;
5825
+ limit?: number;
5826
+ geography?: string;
5827
+ kind?: IntelligenceKind;
5828
+ }, options?: RequestOptions): Promise<ApiResponse<IntelligenceRecordPage>>;
5829
+ get(publication: string, record: string, options?: RequestOptions): Promise<ApiResponse<LocalIntelligenceRecord>>;
5830
+ changes(publication: string, params?: {
5831
+ cursor?: string;
5832
+ limit?: number;
5833
+ }, options?: RequestOptions): Promise<ApiResponse<IntelligenceChangePage>>;
5834
+ briefing(publication: string, params: {
5835
+ geography: string;
5836
+ limit?: number;
5837
+ personalized?: boolean;
5838
+ }, options?: RequestOptions): Promise<ApiResponse<LocalBriefing>>;
5839
+ /** Agent-safe explicit preferences: evaluated for this request and never saved. */
5840
+ briefingForPreferences(publication: string, input: {
5841
+ geography: string;
5842
+ preferences: LocalIntelligencePreferences;
5843
+ limit?: number;
5844
+ }, options?: RequestOptions): Promise<ApiResponse<LocalBriefing>>;
5845
+ preferences(publication: string, options?: RequestOptions): Promise<ApiResponse<{
5846
+ revision: number;
5847
+ preferences: LocalIntelligencePreferences;
5848
+ }>>;
5849
+ savePreferences(publication: string, expectedRevision: number, preferences: LocalIntelligencePreferences, options?: RequestOptions): Promise<ApiResponse<{
5850
+ revision: number;
5851
+ preferences: LocalIntelligencePreferences;
5852
+ }>>;
5853
+ deletePreferences(publication: string, options?: RequestOptions): Promise<ApiResponse<void>>;
5854
+ feedback(publication: string, record: string, recordRevision: number, outcome: CommunityValueOutcome, options?: RequestOptions): Promise<ApiResponse<{
5855
+ recorded: boolean;
5856
+ }>>;
5857
+ deleteFeedback(publication: string, record: string, options?: RequestOptions): Promise<ApiResponse<void>>;
5858
+ /** Requires a human editor with publication publish authority. */
5859
+ release(publication: string, input: IntelligenceRelease, idempotencyKey: string, options?: RequestOptions): Promise<ApiResponse<IntelligenceReleaseReceipt>>;
5860
+ withdraw(publication: string, record: string, expectedRevision: number, reason: string, options?: RequestOptions): Promise<ApiResponse<{
5861
+ id: string;
5862
+ revision: number;
5863
+ removed: true;
5864
+ }>>;
5865
+ }
5866
+ /** Apply a change batch only to a cache already scoped by application AND
5867
+ * publication. Lease expiry is mandatory even when no change notification arrives.
5868
+ * No persistence, tracking or cross-publication identity joins are performed.
5869
+ */
5870
+ interface IntelligenceCache {
5871
+ scope: {
5872
+ application_id: string;
5873
+ publication_id: string;
5874
+ };
5875
+ sequence: string;
5876
+ records: ReadonlyMap<string, LocalIntelligenceRecord>;
5877
+ }
5878
+ declare function applyIntelligenceChanges(current: IntelligenceCache, changes: IntelligenceChangePage, now?: number): IntelligenceCache;
5879
+
5629
5880
  /**
5630
5881
  * Polls Service Module
5631
5882
  *
@@ -8239,6 +8490,7 @@ declare class ScaleMule {
8239
8490
  readonly leaderboard: LeaderboardService;
8240
8491
  readonly listings: ListingsService;
8241
8492
  readonly communityMaps: CommunityMapsService;
8493
+ readonly localIntelligence: LocalIntelligenceService;
8242
8494
  readonly polls: PollsService;
8243
8495
  readonly events: EventsService;
8244
8496
  readonly graph: GraphService;
@@ -8321,4 +8573,4 @@ declare class ScaleMule {
8321
8573
  getClient(): ScaleMuleClient;
8322
8574
  }
8323
8575
 
8324
- export { type AcceptQuoteInput, type AccountBalance, type AccountSwitcherPrivacy, AccountsService, type ActiveUsers, type ActivityItem, AgentAuthService, AgentModelsService, type AgentProfile, AgentProjectsService, type AgentResponse, type AgentSecurityPolicy, AgentSessionsService, type AgentSigningKey, type AgentToken, type AgentToolEntitlement, AgentToolsService, type Workspace as AgentWorkspace, AgentsService, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type AppointmentDepositValue, type Attachment, type Attendee, type AudioRegisterResult, AudioService, type AudioUploadViaStorageResult, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type BookingCompletionResult, BookingsService, type CacheEntry, CacheService, type CalendarEvent, type CallParticipant, type CallSession, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CommunityMapArea, type CommunityMapCanonicalArea, type CommunityMapCollection, type CommunityMapCollectionConfig, type CommunityMapComment, type CommunityMapCommentInput, type CommunityMapCommentPage, type CommunityMapConsent, type CommunityMapEditorialCollection, type CommunityMapEditorialComment, type CommunityMapEditorialFeature, type CommunityMapEditorialMedia, type CommunityMapFeature, type CommunityMapFeatureDraft, type CommunityMapFeatureQuery, type CommunityMapFeatureStatus, type CommunityMapGeometry, type CommunityMapMedia, type CommunityMapOwnSubmission, type CommunityMapOwnSubmissionPage, type CommunityMapPage, type CommunityMapPosition, type CommunityMapPrecision, type CommunityMapPrivateReport, type CommunityMapPrivateSubmission, type CommunityMapProposal, type CommunityMapPublicContent, type CommunityMapQueueQuery, type CommunityMapReactionDefinition, type CommunityMapReceipt, type CommunityMapReportInput, type CommunityMapReportReason, type CommunityMapRevision, type CommunityMapSource, type CommunityMapSubmissionInput, type CommunityMapSubmissionPolicy, type CommunityMapSubmissionStatus, type CommunityMapSubmissionUpdate, type CommunityMapView, type CommunityMapVote, CommunityMapsEditorialService, CommunityMapsGeographyService, CommunityMapsService, type CompletedPart, ComplianceService, type CompressionConfig, ConferenceService, type ConferenceSettings, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type ContentPolicy, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, type CreateLeadInput, type CreatePollInput, type CreateQuoteInput, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type GenerationJob as CreatorJob, CreatorMakerService, type GenerationOutput as CreatorOutput, type CreatorProject, type CreatorUsage, type Credential, type CredentialScope, type Customer, type CustomerStats, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DecisionBatchItem, type DecisionBatchResult, type DecisionEvaluateOptions, type DecisionOutcome, type DecisionProposedAction, type DecisionReceipt, type DecisionResult, type DecisionTraceLevel, type DecisionVersions, DecisionsService, type DeviceInfo, type DirectoryUser, type DirectoryUserDetail, type DirectoryUsersListResponse, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, type FileStatus, type FlagAuditEntry, type FlagCheck, type FlagCondition, FlagContentService, type FlagDefinition, type FlagDetail, type FlagEnvironment, type FlagEvaluation, type FlagSegment, type FlagVariant, FlagsService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, type GenerateInput, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type JoinCallResponse, type KnownAccount, type KnownAccountDisplay, LEGACY_ANONYMOUS_ID_KEYS, type Lead, type Leaderboard, type LeaderboardEntry, LeaderboardService, LeadsService, type Like, type ListNotificationsParams, type Listing, ListingsService, type LogEntry, type LogInput, type LogQueryParams, type LogQueryResponse, type LogRecord, LoggerService, type LoginActivitySummary, type LoginDeviceInfo, type LoginHistoryEntry, type LoginRiskInfo, MEDIA_PRESETS, type MediaAsset, type MediaCaptureSession, type MediaKind, type MediaManifest, type MediaManifestOptions, type MediaPolicy, type MediaPreset, type MediaPresetSpec, MediaService, type MediaUploadEvent, type MediaUploadOptions, type MediaUploadPhase, type MediaUploadResult, type MessageCallback, type MessagePin, type MessageStatus, type MetricDataPoint, type MfaStatus, type Model, type ModelEntitlement, type ModelPricing, type ModelProvider, type UsageSummary as ModelUsageSummary, type MultipartCompleteResponse, type MultipartConfig, type MultipartPartUrl, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type Notification, type NotificationListResponse, NotificationsService, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, type PartResult, type PartUrl, type Participant, type Payment, type PaymentListParams, type PaymentMethod, type PaymentStatusResponse, type Payout, type PayoutSchedule, type PermissionCheck, type PermissionMatrix, PermissionsService, type PhotoInfo, PhotoService, type PinnedMessagesResponse, type Pipeline, type PipelineVersion, type Policy, type Poll, type PollBallot, type PollChoice, type PollChoiceInput, type PollListOptions, type PollMedia, type PollMediaKind, type PollStatus, PollsService, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type Project, type ProjectDocument, type ProjectGrant, type ProjectMember, type PushApiFetcher, type PushPreferences, type PushSettings, type PushSubscriptionInfo, type PushToken, type PushTokenAssociationResult, type PushTopic, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type Quote, type QuoteDeposit, type QuoteState, type ReadStatus, RealtimeService, type ReceiptVerification, type RedeemResult, type ReferralAnalytics, type ReferralCampaign, type ReferralProfile, type ReferralStats, ReferralsService, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterPushTokenData, type RequestOptions, type ResolvedReferral, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, type S3MultipartOptions, type S3MultipartResult, type S3SingleUploadOptions, type S3SingleUploadResult, type S3UploadProgress, STORAGE_KEYS, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type SearchUsersParams, type SecurityLayers, type ServerlessFunction, type ServiceHealth, ServiceModule, type Session, type SessionArtifact, type SessionInfo, type SessionLog, type SessionPoolEntry, type Severity, type ShareLink, type ShortestPathResult, type SignedUrlResponse, type SocialContentProjection, type SocialContentProjectionInput, type SocialDiscoveryCreatorInput, type SocialPolicyAction, type SocialPolicyBatchDecisionItem, type SocialPolicyBatchDecisionRequest, type SocialPolicyBatchDecisionResponse, type SocialPolicyBatchDecisionTarget, type SocialPolicyBlockRequest, type SocialPolicyContactRequest, type SocialPolicyContactRequestListItem, type SocialPolicyContactRequestQuery, type SocialPolicyContactRequestRequest, type SocialPolicyContext, type SocialPolicyDecision, type SocialPolicyDecisionLimits, type SocialPolicyDecisionRequest, type SocialPolicyDecisionResponse, type SocialPolicyIdentity, type SocialPolicyIdentityType, type SocialPolicyMuteRequest, type SocialPolicyPolicyPack, type SocialPolicyRelationship, type SocialPolicyRelationshipQuery, type SocialPolicyRelationshipRequest, type SocialPolicyReportRequest, SocialPolicyService, type SocialPolicySettings, type SocialPolicyUnblockRequest, type SocialPolicyUpdateSettingsRequest, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StorageSettings, type StrategyResult, type StylePreset, type SubmitResult, type Subscription, type TargetingRule, type Task, type TaskAttempt, type TaskTransition, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type Tool, type ToolCapability, type ToolIntegration, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type TtsAccessMode, type TtsAudioInfo, type TtsJobStatus, type TtsListVoicesParams, TtsService, type TtsSpeechMetadata, type TtsSpeechProfile, type TtsSynthesizeParams, type TtsSynthesizeQueuedResult, type TtsSynthesizeReadyResult, type TtsSynthesizeResult, type TtsVoice, type TtsVoicesResponse, type UnreadCountResponse, type UpdateFlagRequest, type UpdatePollInput, type UpdateRuleRequest, type UpdateSegmentRequest, type UpdateVariantRequest, type UploadCompleteResponse, type UploadEngineConfig, type UploadFailureReport, type UploadFailureReportResponse, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UpsertEnvironmentRequest, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, type VoteState, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type WebrtcStats, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, ensureAnonymousId, extractClientContext, generateAnonymousId, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, pollSharePercent, pollVoterKey, prepareCommunityMapAttachment, readAnonymousId, resolveStrategy, startMediaCapture, uploadMultipartToS3, uploadSingleToS3, validateIP };
8576
+ export { type AcceptQuoteInput, type AccountBalance, type AccountSwitcherPrivacy, AccountsService, type ActiveUsers, type ActivityItem, AgentAuthService, AgentModelsService, type AgentProfile, AgentProjectsService, type AgentResponse, type AgentSecurityPolicy, AgentSessionsService, type AgentSigningKey, type AgentToken, type AgentToolEntitlement, AgentToolsService, type Workspace as AgentWorkspace, AgentsService, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type AppointmentDepositValue, type Attachment, type Attendee, type AudioRegisterResult, AudioService, type AudioUploadViaStorageResult, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type BookingCompletionResult, BookingsService, type CacheEntry, CacheService, type CalendarEvent, type CallParticipant, type CallSession, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CommunityMapArea, type CommunityMapCanonicalArea, type CommunityMapCollection, type CommunityMapCollectionConfig, type CommunityMapComment, type CommunityMapCommentInput, type CommunityMapCommentPage, type CommunityMapConsent, type CommunityMapEditorialCollection, type CommunityMapEditorialComment, type CommunityMapEditorialFeature, type CommunityMapEditorialMedia, type CommunityMapFeature, type CommunityMapFeatureDraft, type CommunityMapFeatureQuery, type CommunityMapFeatureStatus, type CommunityMapGeometry, type CommunityMapMedia, type CommunityMapOwnSubmission, type CommunityMapOwnSubmissionPage, type CommunityMapPage, type CommunityMapPosition, type CommunityMapPrecision, type CommunityMapPrivateReport, type CommunityMapPrivateSubmission, type CommunityMapProposal, type CommunityMapPublicContent, type CommunityMapQueueQuery, type CommunityMapReactionDefinition, type CommunityMapReceipt, type CommunityMapReportInput, type CommunityMapReportReason, type CommunityMapRevision, type CommunityMapSource, type CommunityMapSubmissionInput, type CommunityMapSubmissionPolicy, type CommunityMapSubmissionStatus, type CommunityMapSubmissionUpdate, type CommunityMapView, type CommunityMapVote, CommunityMapsEditorialService, CommunityMapsGeographyService, CommunityMapsService, type CommunityValueOutcome, type CompletedPart, ComplianceService, type CompressionConfig, ConferenceService, type ConferenceSettings, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type ContentPolicy, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, type CreateLeadInput, type CreatePollInput, type CreateQuoteInput, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type GenerationJob as CreatorJob, CreatorMakerService, type GenerationOutput as CreatorOutput, type CreatorProject, type CreatorUsage, type Credential, type CredentialScope, type Customer, type CustomerStats, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DecisionBatchItem, type DecisionBatchResult, type DecisionEvaluateOptions, type DecisionOutcome, type DecisionProposedAction, type DecisionReceipt, type DecisionResult, type DecisionTraceLevel, type DecisionVersions, DecisionsService, type DeviceInfo, type DirectoryUser, type DirectoryUserDetail, type DirectoryUsersListResponse, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, ExperimentAssignment, type FileInfo, type FileStatus, type FlagAuditEntry, type FlagCheck, type FlagCondition, FlagContentService, type FlagDefinition, type FlagDetail, type FlagEnvironment, type FlagEvaluation, type FlagSegment, type FlagVariant, FlagsService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, type GenerateInput, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type IntelligenceAction, type IntelligenceCache, type IntelligenceChangePage, type IntelligenceClaim, type IntelligenceEvent, type IntelligenceKind, type IntelligenceRecordPage, type IntelligenceRelease, type IntelligenceReleaseReceipt, type IntelligenceSection, type IntelligenceSource, type IntelligenceStatus, type IntelligenceVerification, type Invoice, type JobExecution, type JobStats, type JoinCallResponse, type KnownAccount, type KnownAccountDisplay, LEGACY_ANONYMOUS_ID_KEYS, type Lead, type Leaderboard, type LeaderboardEntry, LeaderboardService, LeadsService, type Like, type ListNotificationsParams, type Listing, ListingsService, type LocalBriefing, type LocalIntelligencePreferences, type LocalIntelligenceRecord, LocalIntelligenceService, type LogEntry, type LogInput, type LogQueryParams, type LogQueryResponse, type LogRecord, LoggerService, type LoginActivitySummary, type LoginDeviceInfo, type LoginHistoryEntry, type LoginRiskInfo, MEDIA_PRESETS, type MediaAsset, type MediaCaptureSession, type MediaKind, type MediaManifest, type MediaManifestOptions, type MediaPolicy, type MediaPreset, type MediaPresetSpec, MediaService, type MediaUploadEvent, type MediaUploadOptions, type MediaUploadPhase, type MediaUploadResult, type MessageCallback, type MessagePin, type MessageStatus, type MetricDataPoint, type MfaStatus, type Model, type ModelEntitlement, type ModelPricing, type ModelProvider, type UsageSummary as ModelUsageSummary, type MultipartCompleteResponse, type MultipartConfig, type MultipartPartUrl, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type Notification, type NotificationListResponse, NotificationsService, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, type PartResult, type PartUrl, type Participant, type Payment, type PaymentListParams, type PaymentMethod, type PaymentStatusResponse, type Payout, type PayoutSchedule, type PermissionCheck, type PermissionMatrix, PermissionsService, type PhotoInfo, PhotoService, type PinnedMessagesResponse, type Pipeline, type PipelineVersion, type Policy, type Poll, type PollBallot, type PollChoice, type PollChoiceInput, type PollListOptions, type PollMedia, type PollMediaKind, type PollStatus, PollsService, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type Project, type ProjectDocument, type ProjectGrant, type ProjectMember, type PushApiFetcher, type PushPreferences, type PushSettings, type PushSubscriptionInfo, type PushToken, type PushTokenAssociationResult, type PushTopic, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type Quote, type QuoteDeposit, type QuoteState, type ReadStatus, RealtimeService, type ReceiptVerification, type RedeemResult, type ReferralAnalytics, type ReferralCampaign, type ReferralProfile, type ReferralStats, ReferralsService, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterPushTokenData, type RequestOptions, type ResolvedReferral, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, type S3MultipartOptions, type S3MultipartResult, type S3SingleUploadOptions, type S3SingleUploadResult, type S3UploadProgress, STORAGE_KEYS, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type SearchUsersParams, type SecurityLayers, type ServerlessFunction, type ServiceHealth, ServiceModule, type Session, type SessionArtifact, type SessionInfo, type SessionLog, type SessionPoolEntry, type Severity, type ShareLink, type ShortestPathResult, type SignedUrlResponse, type SocialContentProjection, type SocialContentProjectionInput, type SocialDiscoveryCreatorInput, type SocialPolicyAction, type SocialPolicyBatchDecisionItem, type SocialPolicyBatchDecisionRequest, type SocialPolicyBatchDecisionResponse, type SocialPolicyBatchDecisionTarget, type SocialPolicyBlockRequest, type SocialPolicyContactRequest, type SocialPolicyContactRequestListItem, type SocialPolicyContactRequestQuery, type SocialPolicyContactRequestRequest, type SocialPolicyContext, type SocialPolicyDecision, type SocialPolicyDecisionLimits, type SocialPolicyDecisionRequest, type SocialPolicyDecisionResponse, type SocialPolicyIdentity, type SocialPolicyIdentityType, type SocialPolicyMuteRequest, type SocialPolicyPolicyPack, type SocialPolicyRelationship, type SocialPolicyRelationshipQuery, type SocialPolicyRelationshipRequest, type SocialPolicyReportRequest, SocialPolicyService, type SocialPolicySettings, type SocialPolicyUnblockRequest, type SocialPolicyUpdateSettingsRequest, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StorageSettings, type StrategyResult, type StylePreset, type SubmitResult, type Subscription, type TargetingRule, type Task, type TaskAttempt, type TaskTransition, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type Tool, type ToolCapability, type ToolIntegration, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type TtsAccessMode, type TtsAudioInfo, type TtsJobStatus, type TtsListVoicesParams, TtsService, type TtsSpeechMetadata, type TtsSpeechProfile, type TtsSynthesizeParams, type TtsSynthesizeQueuedResult, type TtsSynthesizeReadyResult, type TtsSynthesizeResult, type TtsVoice, type TtsVoicesResponse, type UnreadCountResponse, type UpdateFlagRequest, type UpdatePollInput, type UpdateRuleRequest, type UpdateSegmentRequest, type UpdateVariantRequest, type UploadCompleteResponse, type UploadEngineConfig, type UploadFailureReport, type UploadFailureReportResponse, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UpsertEnvironmentRequest, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, type VoteState, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type WebrtcStats, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, applyIntelligenceChanges, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, ensureAnonymousId, extractClientContext, generateAnonymousId, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, pollSharePercent, pollVoterKey, prepareCommunityMapAttachment, readAnonymousId, resolveStrategy, startMediaCapture, uploadMultipartToS3, uploadSingleToS3, validateIP };
package/dist/index.js CHANGED
@@ -327,6 +327,8 @@ __export(index_exports, {
327
327
  CreatorMakerService: () => CreatorMakerService,
328
328
  DataService: () => DataService,
329
329
  DecisionsService: () => DecisionsService,
330
+ EXPERIMENTS_PROPERTY: () => EXPERIMENTS_PROPERTY,
331
+ EXPERIMENT_EXPOSED_EVENT: () => EXPERIMENT_EXPOSED_EVENT,
330
332
  ErrorCodes: () => ErrorCodes,
331
333
  EventsService: () => EventsService,
332
334
  FlagContentService: () => FlagContentService,
@@ -338,7 +340,9 @@ __export(index_exports, {
338
340
  LeaderboardService: () => LeaderboardService,
339
341
  LeadsService: () => LeadsService,
340
342
  ListingsService: () => ListingsService,
343
+ LocalIntelligenceService: () => LocalIntelligenceService,
341
344
  LoggerService: () => LoggerService,
345
+ MAX_EXPERIMENTS_PER_EVENT: () => MAX_EXPERIMENTS_PER_EVENT,
342
346
  MEDIA_PRESETS: () => MEDIA_PRESETS,
343
347
  MediaService: () => MediaService,
344
348
  NotificationsService: () => NotificationsService,
@@ -369,6 +373,7 @@ __export(index_exports, {
369
373
  WebPushManager: () => WebPushManager,
370
374
  WebhooksService: () => WebhooksService,
371
375
  WorkspacesService: () => WorkspacesService,
376
+ applyIntelligenceChanges: () => applyIntelligenceChanges,
372
377
  buildClientContextHeaders: () => buildClientContextHeaders,
373
378
  calculateTotalParts: () => calculateTotalParts,
374
379
  canPerform: () => canPerform,
@@ -379,6 +384,9 @@ __export(index_exports, {
379
384
  detectCountryFromE164: () => detectCountryFromE164,
380
385
  detectNetworkClass: () => detectNetworkClass,
381
386
  ensureAnonymousId: () => ensureAnonymousId,
387
+ experimentVariant: () => experimentVariant,
388
+ exposureEvent: () => exposureEvent,
389
+ exposureStorageKey: () => exposureStorageKey,
382
390
  extractClientContext: () => extractClientContext,
383
391
  findPhoneCountryByCode: () => findPhoneCountryByCode,
384
392
  findPhoneCountryByDialCode: () => findPhoneCountryByDialCode,
@@ -387,8 +395,11 @@ __export(index_exports, {
387
395
  getMeasuredBandwidthMbps: () => getMeasuredBandwidthMbps,
388
396
  getPartRange: () => getPartRange,
389
397
  hasMinRoleLevel: () => hasMinRoleLevel,
398
+ isExperimentKey: () => isExperimentKey,
390
399
  isValidE164Phone: () => isValidE164Phone,
400
+ isVariantKey: () => isVariantKey,
391
401
  normalizeAndValidatePhone: () => normalizeAndValidatePhone,
402
+ normalizeExperiments: () => normalizeExperiments,
392
403
  normalizePhoneNumber: () => normalizePhoneNumber,
393
404
  pollSharePercent: () => pollSharePercent,
394
405
  pollVoterKey: () => pollVoterKey,
@@ -398,7 +409,8 @@ __export(index_exports, {
398
409
  startMediaCapture: () => startMediaCapture,
399
410
  uploadMultipartToS3: () => uploadMultipartToS3,
400
411
  uploadSingleToS3: () => uploadSingleToS3,
401
- validateIP: () => validateIP
412
+ validateIP: () => validateIP,
413
+ withExperiments: () => withExperiments
402
414
  });
403
415
  module.exports = __toCommonJS(index_exports);
404
416
 
@@ -5808,6 +5820,58 @@ var BillingService = class extends ServiceModule {
5808
5820
  }
5809
5821
  };
5810
5822
 
5823
+ // src/experiments.ts
5824
+ var EXPERIMENTS_PROPERTY = "experiments";
5825
+ var EXPERIMENT_EXPOSED_EVENT = "experiment_exposed";
5826
+ var MAX_EXPERIMENTS_PER_EVENT = 10;
5827
+ var KEY_PATTERN = /^[a-z0-9][a-z0-9_.-]{0,63}$/;
5828
+ var VARIANT_PATTERN = /^[a-z0-9][a-z0-9_.:-]{0,63}$/;
5829
+ function isExperimentKey(value) {
5830
+ return typeof value === "string" && KEY_PATTERN.test(value);
5831
+ }
5832
+ function isVariantKey(value) {
5833
+ return typeof value === "string" && VARIANT_PATTERN.test(value);
5834
+ }
5835
+ function experimentVariant(evaluation) {
5836
+ if (!evaluation) return null;
5837
+ if (isVariantKey(evaluation.variant_key)) return evaluation.variant_key;
5838
+ if (isVariantKey(evaluation.value)) return evaluation.value;
5839
+ return null;
5840
+ }
5841
+ function normalizeExperiments(input) {
5842
+ const result = {};
5843
+ if (!input || typeof input !== "object" || Array.isArray(input)) return result;
5844
+ let count = 0;
5845
+ for (const [key, value] of Object.entries(input)) {
5846
+ if (count >= MAX_EXPERIMENTS_PER_EVENT) break;
5847
+ if (isExperimentKey(key) && isVariantKey(value)) {
5848
+ result[key] = value;
5849
+ count++;
5850
+ }
5851
+ }
5852
+ return result;
5853
+ }
5854
+ function withExperiments(properties, experiments) {
5855
+ const normalized = normalizeExperiments({
5856
+ ...normalizeExperiments(properties?.[EXPERIMENTS_PROPERTY]),
5857
+ ...experiments ?? {}
5858
+ });
5859
+ if (Object.keys(normalized).length === 0) return properties;
5860
+ return { ...properties ?? {}, [EXPERIMENTS_PROPERTY]: normalized };
5861
+ }
5862
+ function exposureEvent(flagKey, variant) {
5863
+ if (!isExperimentKey(flagKey)) throw new Error(`Invalid experiment flag key: ${flagKey}`);
5864
+ if (!isVariantKey(variant)) throw new Error(`Invalid experiment variant: ${variant}`);
5865
+ return {
5866
+ event_name: EXPERIMENT_EXPOSED_EVENT,
5867
+ event_category: "system",
5868
+ properties: { flag_key: flagKey, variant, [EXPERIMENTS_PROPERTY]: { [flagKey]: variant } }
5869
+ };
5870
+ }
5871
+ function exposureStorageKey(flagKey) {
5872
+ return `sm_experiment_exposed:${flagKey}`;
5873
+ }
5874
+
5811
5875
  // src/services/analytics.ts
5812
5876
  var AnalyticsService = class extends ServiceModule {
5813
5877
  constructor() {
@@ -5824,6 +5888,14 @@ var AnalyticsService = class extends ServiceModule {
5824
5888
  }
5825
5889
  return this.post("/v2/events", payload, options);
5826
5890
  }
5891
+ /**
5892
+ * Track that a visitor saw an experiment variant. Send it once per visitor and flag; the event
5893
+ * carries `properties.experiments` so the experiment report attributes it.
5894
+ */
5895
+ async trackExposure(flagKey, variant, userId, options) {
5896
+ const event = exposureEvent(flagKey, variant);
5897
+ return this.track(event.event_name, event.properties, userId, options);
5898
+ }
5827
5899
  async trackBatch(events, options) {
5828
5900
  const mapped = events.map(({ event, ...rest }) => ({ event_name: event, ...rest }));
5829
5901
  return this.post("/v2/events/batch", { events: mapped }, options);
@@ -5898,6 +5970,19 @@ var FlagsService = class extends ServiceModule {
5898
5970
  async evaluate(flagKey, context = {}, environment = "prod", options) {
5899
5971
  return this.post("/evaluate", { flag_key: flagKey, environment, context }, options);
5900
5972
  }
5973
+ /**
5974
+ * Assign a visitor to an experiment: a flag with weighted variants, evaluated with a stable
5975
+ * identifier (`session_id` or `user_id`) so the assignment is sticky. Attach the result to
5976
+ * analytics events with `withExperiments` and track one exposure with `analytics.trackExposure`.
5977
+ */
5978
+ async experiment(flagKey, context = {}, environment = "prod", options) {
5979
+ const response = await this.evaluate(flagKey, context, environment, options);
5980
+ if (response.error || !response.data) return { data: null, error: response.error };
5981
+ return {
5982
+ data: { flag_key: flagKey, variant: experimentVariant(response.data), evaluation: response.data },
5983
+ error: null
5984
+ };
5985
+ }
5901
5986
  async evaluateBatch(flagKeys, context = {}, environment = "prod", options) {
5902
5987
  return this.post(
5903
5988
  "/evaluate/batch",
@@ -7150,6 +7235,97 @@ var CommunityMapsGeographyService = class extends ServiceModule {
7150
7235
  }
7151
7236
  };
7152
7237
 
7238
+ // src/services/local-intelligence.ts
7239
+ var LocalIntelligenceService = class extends ServiceModule {
7240
+ constructor() {
7241
+ super(...arguments);
7242
+ this.basePath = "/v1/news";
7243
+ }
7244
+ scope(publication) {
7245
+ return `/intelligence/publications/${encodeURIComponent(publication)}`;
7246
+ }
7247
+ records(publication, params = {}, options) {
7248
+ return this._get(this.withQuery(`${this.scope(publication)}/records`, params), options);
7249
+ }
7250
+ get(publication, record, options) {
7251
+ return this._get(`${this.scope(publication)}/records/${encodeURIComponent(record)}`, options);
7252
+ }
7253
+ changes(publication, params = {}, options) {
7254
+ return this._get(this.withQuery(`${this.scope(publication)}/changes`, params), options);
7255
+ }
7256
+ briefing(publication, params, options) {
7257
+ return this._get(this.withQuery(`${this.scope(publication)}/briefing`, params), options);
7258
+ }
7259
+ /** Agent-safe explicit preferences: evaluated for this request and never saved. */
7260
+ briefingForPreferences(publication, input, options) {
7261
+ return this.post(`${this.scope(publication)}/briefing`, input, options);
7262
+ }
7263
+ preferences(publication, options) {
7264
+ return this._get(`${this.scope(publication)}/preferences`, options);
7265
+ }
7266
+ savePreferences(publication, expectedRevision, preferences, options) {
7267
+ return this.put(
7268
+ `${this.scope(publication)}/preferences`,
7269
+ { expected_revision: expectedRevision, preferences },
7270
+ options
7271
+ );
7272
+ }
7273
+ deletePreferences(publication, options) {
7274
+ return this.del(`${this.scope(publication)}/preferences`, options);
7275
+ }
7276
+ feedback(publication, record, recordRevision, outcome, options) {
7277
+ return this.post(
7278
+ `${this.scope(publication)}/records/${encodeURIComponent(record)}/feedback`,
7279
+ { record_revision: recordRevision, outcome },
7280
+ options
7281
+ );
7282
+ }
7283
+ deleteFeedback(publication, record, options) {
7284
+ return this.del(`${this.scope(publication)}/records/${encodeURIComponent(record)}/feedback`, options);
7285
+ }
7286
+ /** Requires a human editor with publication publish authority. */
7287
+ release(publication, input, idempotencyKey, options) {
7288
+ return this.post(`/publications/${encodeURIComponent(publication)}/intelligence`, input, {
7289
+ ...options,
7290
+ headers: { ...options?.headers, "idempotency-key": idempotencyKey }
7291
+ });
7292
+ }
7293
+ withdraw(publication, record, expectedRevision, reason, options) {
7294
+ return this.post(
7295
+ `/publications/${encodeURIComponent(publication)}/intelligence/${encodeURIComponent(record)}/withdraw`,
7296
+ { expected_revision: expectedRevision, reason },
7297
+ options
7298
+ );
7299
+ }
7300
+ };
7301
+ function applyIntelligenceChanges(current, changes, now = Date.now()) {
7302
+ if (changes.contract_version !== "basenews/1" || changes.scope.application_id !== current.scope.application_id || changes.scope.publication_id !== current.scope.publication_id)
7303
+ throw new Error("Intelligence change scope mismatch");
7304
+ const sequenceValue = (value) => {
7305
+ if (!/^(0|[1-9][0-9]{0,19})$/.test(value)) throw new Error("Invalid intelligence sequence");
7306
+ return BigInt(value);
7307
+ };
7308
+ let sequence = sequenceValue(current.sequence);
7309
+ let previous = -1n;
7310
+ const next = new Map(current.records);
7311
+ for (const item of changes.items) {
7312
+ const received = sequenceValue(item.sequence);
7313
+ if (received <= previous) throw new Error("Unordered intelligence change batch");
7314
+ previous = received;
7315
+ if (received <= sequence) continue;
7316
+ if (received !== sequence + 1n) throw new Error("Intelligence change gap; resume the previous cursor");
7317
+ sequence = received;
7318
+ if (item.removed || !item.record) next.delete(item.id);
7319
+ else if (item.record.id !== item.id) throw new Error("Intelligence change identity mismatch");
7320
+ else if (!next.has(item.id) || next.get(item.id).revision <= item.record.revision) next.set(item.id, item.record);
7321
+ }
7322
+ for (const [id, record] of next) {
7323
+ const expiry = Date.parse(record.refresh_after);
7324
+ if (record.contract_version !== "basenews/1" || !Number.isFinite(expiry) || expiry <= now) next.delete(id);
7325
+ }
7326
+ return { scope: current.scope, sequence: sequence.toString(), records: next };
7327
+ }
7328
+
7153
7329
  // src/services/polls.ts
7154
7330
  var PollsService = class extends ServiceModule {
7155
7331
  constructor() {
@@ -9297,6 +9473,7 @@ var ScaleMule = class {
9297
9473
  this.leaderboard = new LeaderboardService(this._client);
9298
9474
  this.listings = new ListingsService(this._client);
9299
9475
  this.communityMaps = new CommunityMapsService(this._client);
9476
+ this.localIntelligence = new LocalIntelligenceService(this._client);
9300
9477
  this.polls = new PollsService(this._client);
9301
9478
  this.events = new EventsService(this._client);
9302
9479
  this.graph = new GraphService(this._client);
@@ -9464,6 +9641,8 @@ var index_default = ScaleMule;
9464
9641
  CreatorMakerService,
9465
9642
  DataService,
9466
9643
  DecisionsService,
9644
+ EXPERIMENTS_PROPERTY,
9645
+ EXPERIMENT_EXPOSED_EVENT,
9467
9646
  ErrorCodes,
9468
9647
  EventsService,
9469
9648
  FlagContentService,
@@ -9475,7 +9654,9 @@ var index_default = ScaleMule;
9475
9654
  LeaderboardService,
9476
9655
  LeadsService,
9477
9656
  ListingsService,
9657
+ LocalIntelligenceService,
9478
9658
  LoggerService,
9659
+ MAX_EXPERIMENTS_PER_EVENT,
9479
9660
  MEDIA_PRESETS,
9480
9661
  MediaService,
9481
9662
  NotificationsService,
@@ -9506,6 +9687,7 @@ var index_default = ScaleMule;
9506
9687
  WebPushManager,
9507
9688
  WebhooksService,
9508
9689
  WorkspacesService,
9690
+ applyIntelligenceChanges,
9509
9691
  buildClientContextHeaders,
9510
9692
  calculateTotalParts,
9511
9693
  canPerform,
@@ -9515,6 +9697,9 @@ var index_default = ScaleMule;
9515
9697
  detectCountryFromE164,
9516
9698
  detectNetworkClass,
9517
9699
  ensureAnonymousId,
9700
+ experimentVariant,
9701
+ exposureEvent,
9702
+ exposureStorageKey,
9518
9703
  extractClientContext,
9519
9704
  findPhoneCountryByCode,
9520
9705
  findPhoneCountryByDialCode,
@@ -9523,8 +9708,11 @@ var index_default = ScaleMule;
9523
9708
  getMeasuredBandwidthMbps,
9524
9709
  getPartRange,
9525
9710
  hasMinRoleLevel,
9711
+ isExperimentKey,
9526
9712
  isValidE164Phone,
9713
+ isVariantKey,
9527
9714
  normalizeAndValidatePhone,
9715
+ normalizeExperiments,
9528
9716
  normalizePhoneNumber,
9529
9717
  pollSharePercent,
9530
9718
  pollVoterKey,
@@ -9534,5 +9722,6 @@ var index_default = ScaleMule;
9534
9722
  startMediaCapture,
9535
9723
  uploadMultipartToS3,
9536
9724
  uploadSingleToS3,
9537
- validateIP
9725
+ validateIP,
9726
+ withExperiments
9538
9727
  });