@scalemule/sdk 0.0.28 → 0.0.29

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.mts CHANGED
@@ -129,6 +129,30 @@ interface ScaleMuleConfig {
129
129
  enableOfflineQueue?: boolean;
130
130
  /** Enable multi-account session pool (Google Account Chooser style). Default: false */
131
131
  enableMultiSession?: boolean;
132
+ /**
133
+ * Enable the account switcher — remembers which accounts have logged in on
134
+ * this device so users can pick an account and re-authenticate.
135
+ *
136
+ * Unlike enableMultiSession, this stores **no tokens** for inactive accounts.
137
+ * Only display metadata (email, name, avatar) is persisted.
138
+ * Switching accounts always requires re-authentication.
139
+ *
140
+ * Default: false
141
+ */
142
+ enableAccountSwitcher?: boolean;
143
+ /**
144
+ * Privacy level for the account switcher.
145
+ *
146
+ * Controls how much identifying information is stored for inactive accounts:
147
+ * - `'full'` — Full email, name, avatar stored (like Google). Default.
148
+ * - `'masked'` — Email masked (j***@g***.com), name shows initial only, no avatar.
149
+ * Masked at write time — the full email is never persisted.
150
+ * - `'minimal'` — Only userId and provider stored. No PII at all.
151
+ *
152
+ * Privacy downgrades are lossy: switching from minimal/masked to full cannot
153
+ * recover stripped fields for existing entries until those accounts log in again.
154
+ */
155
+ accountSwitcherPrivacy?: AccountSwitcherPrivacy;
132
156
  }
133
157
  /**
134
158
  * A session entry in the multi-account session pool.
@@ -142,6 +166,55 @@ interface SessionPoolEntry {
142
166
  expiresAt?: string;
143
167
  addedAt: string;
144
168
  }
169
+ /**
170
+ * A remembered account for the account switcher.
171
+ *
172
+ * Contains display metadata only — NO tokens or session data.
173
+ * Switching to a known account requires re-authentication.
174
+ * This is the secure alternative to SessionPoolEntry which stores tokens.
175
+ */
176
+ interface KnownAccount {
177
+ /** User ID */
178
+ userId: string;
179
+ /** Email address (used for login pre-fill) */
180
+ email: string;
181
+ /** Display name */
182
+ fullName?: string;
183
+ /** Avatar URL */
184
+ avatarUrl?: string;
185
+ /** How the user last authenticated ('email', 'google', 'apple', etc.) */
186
+ provider?: string;
187
+ /** ISO timestamp of last successful login on this device */
188
+ lastActiveAt: string;
189
+ }
190
+ /**
191
+ * Privacy level for the account switcher.
192
+ */
193
+ type AccountSwitcherPrivacy = 'full' | 'masked' | 'minimal';
194
+ /**
195
+ * A known account after privacy transforms have been applied.
196
+ *
197
+ * This is what gets stored and returned to the UI. In 'masked' mode, email
198
+ * is partially masked and avatarUrl is stripped. In 'minimal' mode, all PII
199
+ * is stripped and only userId/provider/displayLabel/colorIndex remain.
200
+ */
201
+ interface KnownAccountDisplay {
202
+ userId: string;
203
+ /** Masked or full email, absent in 'minimal' mode */
204
+ email?: string;
205
+ /** Full name, first initial, or absent depending on privacy mode */
206
+ fullName?: string;
207
+ /** Avatar URL, absent in 'masked' and 'minimal' modes */
208
+ avatarUrl?: string;
209
+ /** Authentication provider ('email', 'google', etc.) */
210
+ provider?: string;
211
+ /** ISO timestamp of last successful login on this device */
212
+ lastActiveAt: string;
213
+ /** Display label for 'minimal' mode (constant "Account") */
214
+ displayLabel?: string;
215
+ /** Stable color index derived from userId hash (0-7), for avatar circles */
216
+ colorIndex?: number;
217
+ }
145
218
  /**
146
219
  * Per-request options that override client defaults.
147
220
  */
@@ -267,6 +340,9 @@ declare class ScaleMuleClient {
267
340
  private anonymousId;
268
341
  private multiSessionEnabled;
269
342
  private sessionPool;
343
+ private accountSwitcherEnabled;
344
+ private accountSwitcherPrivacy;
345
+ private knownAccounts;
270
346
  constructor(config: ScaleMuleConfig);
271
347
  initialize(): Promise<void>;
272
348
  setSession(token: string, userId: string): Promise<void>;
@@ -293,6 +369,23 @@ declare class ScaleMuleClient {
293
369
  clearAllAccounts(): Promise<void>;
294
370
  /** Persist session pool to storage */
295
371
  private persistSessionPool;
372
+ isAccountSwitcherEnabled(): boolean;
373
+ getAccountSwitcherPrivacy(): AccountSwitcherPrivacy;
374
+ /** Get all known accounts that have logged in on this device (privacy-transformed) */
375
+ getKnownAccounts(): KnownAccountDisplay[];
376
+ /**
377
+ * Record an account as "known" on this device.
378
+ * Applies privacy transforms before storing — full email is never persisted
379
+ * in masked/minimal modes. Evicts oldest accounts if over the cap.
380
+ * Called automatically after successful login/register when account switcher is enabled.
381
+ */
382
+ addKnownAccount(account: KnownAccount): Promise<void>;
383
+ /** Remove a specific account from the known accounts list ("forget this account") */
384
+ removeKnownAccount(userId: string): Promise<void>;
385
+ /** Clear all known accounts ("forget all accounts on this device") */
386
+ clearKnownAccounts(): Promise<void>;
387
+ /** Persist known accounts to storage */
388
+ private persistKnownAccounts;
296
389
  getBaseUrl(): string;
297
390
  getApiKey(): string;
298
391
  isOnline(): boolean;
@@ -4651,6 +4744,121 @@ declare class FlagContentService extends ServiceModule {
4651
4744
  getAppeal(id: string, options?: RequestOptions): Promise<ApiResponse<Appeal>>;
4652
4745
  }
4653
4746
 
4747
+ /**
4748
+ * Creator Maker Service Module
4749
+ *
4750
+ * Thin integration for AI image/clip generation via the creator-maker service.
4751
+ * For rich features (React hooks, waitForJob, WebSocket status), use
4752
+ * the standalone @scalemule/creator-maker package instead.
4753
+ */
4754
+
4755
+ interface GenerateInput {
4756
+ project_id?: string;
4757
+ output_type: 'image' | 'clip';
4758
+ content_mode: 'promo' | 'cartoon';
4759
+ aspect_ratio: '9:16' | '16:9' | '1:1';
4760
+ style_preset_slug?: string;
4761
+ prompt: string;
4762
+ provider_mode?: 'auto' | 'fast' | 'balanced' | 'quality';
4763
+ source_assets?: Array<{
4764
+ storage_file_id: string;
4765
+ role: 'reference' | 'init_image' | 'style_ref';
4766
+ weight?: number;
4767
+ }>;
4768
+ composition?: {
4769
+ caption?: string;
4770
+ watermark?: boolean;
4771
+ };
4772
+ }
4773
+ interface GenerationJob {
4774
+ id: string;
4775
+ project_id: string;
4776
+ output_type: string;
4777
+ content_mode: string;
4778
+ aspect_ratio: string;
4779
+ prompt: string;
4780
+ status: string;
4781
+ estimated_credits: number;
4782
+ actual_credits?: number;
4783
+ outputs: GenerationOutput[];
4784
+ error_code?: string;
4785
+ error_message?: string;
4786
+ created_at: string;
4787
+ completed_at?: string;
4788
+ }
4789
+ interface GenerationOutput {
4790
+ id: string;
4791
+ output_type: string;
4792
+ cdn_url?: string;
4793
+ width: number;
4794
+ height: number;
4795
+ mime_type: string;
4796
+ created_at: string;
4797
+ }
4798
+ interface StylePreset {
4799
+ id: string;
4800
+ mode: string;
4801
+ slug: string;
4802
+ name: string;
4803
+ description?: string;
4804
+ thumbnail_url?: string;
4805
+ estimated_credits: number;
4806
+ }
4807
+ interface CreatorUsage {
4808
+ balance_credits: number;
4809
+ total_generations: number;
4810
+ completed_generations: number;
4811
+ }
4812
+ interface CreateProjectInput {
4813
+ title?: string;
4814
+ content_mode: 'promo' | 'cartoon';
4815
+ }
4816
+ interface CreatorProject {
4817
+ id: string;
4818
+ title: string;
4819
+ content_mode: string;
4820
+ created_at: string;
4821
+ updated_at: string;
4822
+ }
4823
+ declare class CreatorMakerService extends ServiceModule {
4824
+ protected basePath: string;
4825
+ /** Submit a generation job. */
4826
+ generate(data: GenerateInput, options?: RequestOptions): Promise<ApiResponse<GenerationJob>>;
4827
+ /** Get a generation job by ID. */
4828
+ getJob(jobId: string, options?: RequestOptions): Promise<ApiResponse<GenerationJob>>;
4829
+ /** Long-poll for job completion (server holds up to 30s). */
4830
+ pollJob(jobId: string, options?: RequestOptions): Promise<ApiResponse<GenerationJob>>;
4831
+ /** List the current user's generation jobs. */
4832
+ listJobs(params?: Record<string, unknown>, options?: RequestOptions): Promise<PaginatedResponse<GenerationJob>>;
4833
+ /** Cancel a pending or queued job. */
4834
+ cancelJob(jobId: string, options?: RequestOptions): Promise<ApiResponse<{
4835
+ id: string;
4836
+ status: string;
4837
+ }>>;
4838
+ /** Retry a failed job. */
4839
+ retryJob(jobId: string, options?: RequestOptions): Promise<ApiResponse<GenerationJob>>;
4840
+ /** Generate variations of a completed job. */
4841
+ generateVariations(jobId: string, options?: RequestOptions): Promise<ApiResponse<GenerationJob[]>>;
4842
+ /** List available style presets, optionally filtered by mode. */
4843
+ listPresets(params?: {
4844
+ mode?: string;
4845
+ }, options?: RequestOptions): Promise<ApiResponse<StylePreset[]>>;
4846
+ /** Get a style preset by slug. */
4847
+ getPreset(slug: string, options?: RequestOptions): Promise<ApiResponse<StylePreset>>;
4848
+ /** Create a project. */
4849
+ createProject(data: CreateProjectInput, options?: RequestOptions): Promise<ApiResponse<CreatorProject>>;
4850
+ /** List the current user's projects. */
4851
+ listProjects(params?: Record<string, unknown>, options?: RequestOptions): Promise<PaginatedResponse<CreatorProject>>;
4852
+ /** Get generation usage and credit balance. */
4853
+ getUsage(options?: RequestOptions): Promise<ApiResponse<CreatorUsage>>;
4854
+ /** Get a generation output by ID. */
4855
+ getOutput(outputId: string, options?: RequestOptions): Promise<ApiResponse<GenerationOutput>>;
4856
+ /** Get a download URL for a generation output. */
4857
+ getDownloadUrl(outputId: string, options?: RequestOptions): Promise<ApiResponse<{
4858
+ cdn_url: string;
4859
+ }>>;
4860
+ }
4861
+
4654
4862
  interface AuthRegisterAgentRequest {
4655
4863
  name: string;
4656
4864
  agent_platform: string;
@@ -5571,6 +5779,7 @@ declare class ScaleMule {
5571
5779
  readonly functions: FunctionsService;
5572
5780
  readonly photo: PhotoService;
5573
5781
  readonly flagContent: FlagContentService;
5782
+ readonly creatorMaker: CreatorMakerService;
5574
5783
  readonly compliance: ComplianceService;
5575
5784
  readonly orchestrator: OrchestratorService;
5576
5785
  readonly agentAuth: AgentAuthService;
@@ -5614,6 +5823,23 @@ declare class ScaleMule {
5614
5823
  removeAccount(userId: string): Promise<void>;
5615
5824
  /** Clear all accounts from the pool */
5616
5825
  clearAllAccounts(): Promise<void>;
5826
+ /** Whether the account switcher is enabled */
5827
+ isAccountSwitcherEnabled(): boolean;
5828
+ /** The configured privacy level for the account switcher */
5829
+ getAccountSwitcherPrivacy(): AccountSwitcherPrivacy;
5830
+ /**
5831
+ * Get all accounts that have previously logged in on this device.
5832
+ * Returns privacy-transformed display data — no raw PII in masked/minimal modes.
5833
+ * Requires `enableAccountSwitcher: true` in config.
5834
+ */
5835
+ getKnownAccounts(): KnownAccountDisplay[];
5836
+ /**
5837
+ * Forget a specific account — removes it from the known accounts list.
5838
+ * Does NOT affect any active session.
5839
+ */
5840
+ removeKnownAccount(userId: string): Promise<void>;
5841
+ /** Forget all known accounts on this device. */
5842
+ clearKnownAccounts(): Promise<void>;
5617
5843
  /** The base URL being used for API requests. */
5618
5844
  getBaseUrl(): string;
5619
5845
  /** The application ID, or null if not configured. */
@@ -5626,4 +5852,4 @@ declare class ScaleMule {
5626
5852
  getClient(): ScaleMuleClient;
5627
5853
  }
5628
5854
 
5629
- export { type AccountBalance, 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 Attachment, type Attendee, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateFlagRequest, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, 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 GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type Leaderboard, type LeaderboardEntry, LeaderboardService, 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, type MessageCallback, 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 Pipeline, type PipelineVersion, type Policy, 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 ReadStatus, RealtimeService, 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, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, 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 SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, 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 UnreadCountResponse, type UpdateFlagRequest, 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, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
5855
+ export { 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 Attachment, type Attendee, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, 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 DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, 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 KnownAccount, type KnownAccountDisplay, type Leaderboard, type LeaderboardEntry, LeaderboardService, 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, type MessageCallback, 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 Pipeline, type PipelineVersion, type Policy, 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 ReadStatus, RealtimeService, 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, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, 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 SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, 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 UnreadCountResponse, type UpdateFlagRequest, 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, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
package/dist/index.d.ts CHANGED
@@ -129,6 +129,30 @@ interface ScaleMuleConfig {
129
129
  enableOfflineQueue?: boolean;
130
130
  /** Enable multi-account session pool (Google Account Chooser style). Default: false */
131
131
  enableMultiSession?: boolean;
132
+ /**
133
+ * Enable the account switcher — remembers which accounts have logged in on
134
+ * this device so users can pick an account and re-authenticate.
135
+ *
136
+ * Unlike enableMultiSession, this stores **no tokens** for inactive accounts.
137
+ * Only display metadata (email, name, avatar) is persisted.
138
+ * Switching accounts always requires re-authentication.
139
+ *
140
+ * Default: false
141
+ */
142
+ enableAccountSwitcher?: boolean;
143
+ /**
144
+ * Privacy level for the account switcher.
145
+ *
146
+ * Controls how much identifying information is stored for inactive accounts:
147
+ * - `'full'` — Full email, name, avatar stored (like Google). Default.
148
+ * - `'masked'` — Email masked (j***@g***.com), name shows initial only, no avatar.
149
+ * Masked at write time — the full email is never persisted.
150
+ * - `'minimal'` — Only userId and provider stored. No PII at all.
151
+ *
152
+ * Privacy downgrades are lossy: switching from minimal/masked to full cannot
153
+ * recover stripped fields for existing entries until those accounts log in again.
154
+ */
155
+ accountSwitcherPrivacy?: AccountSwitcherPrivacy;
132
156
  }
133
157
  /**
134
158
  * A session entry in the multi-account session pool.
@@ -142,6 +166,55 @@ interface SessionPoolEntry {
142
166
  expiresAt?: string;
143
167
  addedAt: string;
144
168
  }
169
+ /**
170
+ * A remembered account for the account switcher.
171
+ *
172
+ * Contains display metadata only — NO tokens or session data.
173
+ * Switching to a known account requires re-authentication.
174
+ * This is the secure alternative to SessionPoolEntry which stores tokens.
175
+ */
176
+ interface KnownAccount {
177
+ /** User ID */
178
+ userId: string;
179
+ /** Email address (used for login pre-fill) */
180
+ email: string;
181
+ /** Display name */
182
+ fullName?: string;
183
+ /** Avatar URL */
184
+ avatarUrl?: string;
185
+ /** How the user last authenticated ('email', 'google', 'apple', etc.) */
186
+ provider?: string;
187
+ /** ISO timestamp of last successful login on this device */
188
+ lastActiveAt: string;
189
+ }
190
+ /**
191
+ * Privacy level for the account switcher.
192
+ */
193
+ type AccountSwitcherPrivacy = 'full' | 'masked' | 'minimal';
194
+ /**
195
+ * A known account after privacy transforms have been applied.
196
+ *
197
+ * This is what gets stored and returned to the UI. In 'masked' mode, email
198
+ * is partially masked and avatarUrl is stripped. In 'minimal' mode, all PII
199
+ * is stripped and only userId/provider/displayLabel/colorIndex remain.
200
+ */
201
+ interface KnownAccountDisplay {
202
+ userId: string;
203
+ /** Masked or full email, absent in 'minimal' mode */
204
+ email?: string;
205
+ /** Full name, first initial, or absent depending on privacy mode */
206
+ fullName?: string;
207
+ /** Avatar URL, absent in 'masked' and 'minimal' modes */
208
+ avatarUrl?: string;
209
+ /** Authentication provider ('email', 'google', etc.) */
210
+ provider?: string;
211
+ /** ISO timestamp of last successful login on this device */
212
+ lastActiveAt: string;
213
+ /** Display label for 'minimal' mode (constant "Account") */
214
+ displayLabel?: string;
215
+ /** Stable color index derived from userId hash (0-7), for avatar circles */
216
+ colorIndex?: number;
217
+ }
145
218
  /**
146
219
  * Per-request options that override client defaults.
147
220
  */
@@ -267,6 +340,9 @@ declare class ScaleMuleClient {
267
340
  private anonymousId;
268
341
  private multiSessionEnabled;
269
342
  private sessionPool;
343
+ private accountSwitcherEnabled;
344
+ private accountSwitcherPrivacy;
345
+ private knownAccounts;
270
346
  constructor(config: ScaleMuleConfig);
271
347
  initialize(): Promise<void>;
272
348
  setSession(token: string, userId: string): Promise<void>;
@@ -293,6 +369,23 @@ declare class ScaleMuleClient {
293
369
  clearAllAccounts(): Promise<void>;
294
370
  /** Persist session pool to storage */
295
371
  private persistSessionPool;
372
+ isAccountSwitcherEnabled(): boolean;
373
+ getAccountSwitcherPrivacy(): AccountSwitcherPrivacy;
374
+ /** Get all known accounts that have logged in on this device (privacy-transformed) */
375
+ getKnownAccounts(): KnownAccountDisplay[];
376
+ /**
377
+ * Record an account as "known" on this device.
378
+ * Applies privacy transforms before storing — full email is never persisted
379
+ * in masked/minimal modes. Evicts oldest accounts if over the cap.
380
+ * Called automatically after successful login/register when account switcher is enabled.
381
+ */
382
+ addKnownAccount(account: KnownAccount): Promise<void>;
383
+ /** Remove a specific account from the known accounts list ("forget this account") */
384
+ removeKnownAccount(userId: string): Promise<void>;
385
+ /** Clear all known accounts ("forget all accounts on this device") */
386
+ clearKnownAccounts(): Promise<void>;
387
+ /** Persist known accounts to storage */
388
+ private persistKnownAccounts;
296
389
  getBaseUrl(): string;
297
390
  getApiKey(): string;
298
391
  isOnline(): boolean;
@@ -4651,6 +4744,121 @@ declare class FlagContentService extends ServiceModule {
4651
4744
  getAppeal(id: string, options?: RequestOptions): Promise<ApiResponse<Appeal>>;
4652
4745
  }
4653
4746
 
4747
+ /**
4748
+ * Creator Maker Service Module
4749
+ *
4750
+ * Thin integration for AI image/clip generation via the creator-maker service.
4751
+ * For rich features (React hooks, waitForJob, WebSocket status), use
4752
+ * the standalone @scalemule/creator-maker package instead.
4753
+ */
4754
+
4755
+ interface GenerateInput {
4756
+ project_id?: string;
4757
+ output_type: 'image' | 'clip';
4758
+ content_mode: 'promo' | 'cartoon';
4759
+ aspect_ratio: '9:16' | '16:9' | '1:1';
4760
+ style_preset_slug?: string;
4761
+ prompt: string;
4762
+ provider_mode?: 'auto' | 'fast' | 'balanced' | 'quality';
4763
+ source_assets?: Array<{
4764
+ storage_file_id: string;
4765
+ role: 'reference' | 'init_image' | 'style_ref';
4766
+ weight?: number;
4767
+ }>;
4768
+ composition?: {
4769
+ caption?: string;
4770
+ watermark?: boolean;
4771
+ };
4772
+ }
4773
+ interface GenerationJob {
4774
+ id: string;
4775
+ project_id: string;
4776
+ output_type: string;
4777
+ content_mode: string;
4778
+ aspect_ratio: string;
4779
+ prompt: string;
4780
+ status: string;
4781
+ estimated_credits: number;
4782
+ actual_credits?: number;
4783
+ outputs: GenerationOutput[];
4784
+ error_code?: string;
4785
+ error_message?: string;
4786
+ created_at: string;
4787
+ completed_at?: string;
4788
+ }
4789
+ interface GenerationOutput {
4790
+ id: string;
4791
+ output_type: string;
4792
+ cdn_url?: string;
4793
+ width: number;
4794
+ height: number;
4795
+ mime_type: string;
4796
+ created_at: string;
4797
+ }
4798
+ interface StylePreset {
4799
+ id: string;
4800
+ mode: string;
4801
+ slug: string;
4802
+ name: string;
4803
+ description?: string;
4804
+ thumbnail_url?: string;
4805
+ estimated_credits: number;
4806
+ }
4807
+ interface CreatorUsage {
4808
+ balance_credits: number;
4809
+ total_generations: number;
4810
+ completed_generations: number;
4811
+ }
4812
+ interface CreateProjectInput {
4813
+ title?: string;
4814
+ content_mode: 'promo' | 'cartoon';
4815
+ }
4816
+ interface CreatorProject {
4817
+ id: string;
4818
+ title: string;
4819
+ content_mode: string;
4820
+ created_at: string;
4821
+ updated_at: string;
4822
+ }
4823
+ declare class CreatorMakerService extends ServiceModule {
4824
+ protected basePath: string;
4825
+ /** Submit a generation job. */
4826
+ generate(data: GenerateInput, options?: RequestOptions): Promise<ApiResponse<GenerationJob>>;
4827
+ /** Get a generation job by ID. */
4828
+ getJob(jobId: string, options?: RequestOptions): Promise<ApiResponse<GenerationJob>>;
4829
+ /** Long-poll for job completion (server holds up to 30s). */
4830
+ pollJob(jobId: string, options?: RequestOptions): Promise<ApiResponse<GenerationJob>>;
4831
+ /** List the current user's generation jobs. */
4832
+ listJobs(params?: Record<string, unknown>, options?: RequestOptions): Promise<PaginatedResponse<GenerationJob>>;
4833
+ /** Cancel a pending or queued job. */
4834
+ cancelJob(jobId: string, options?: RequestOptions): Promise<ApiResponse<{
4835
+ id: string;
4836
+ status: string;
4837
+ }>>;
4838
+ /** Retry a failed job. */
4839
+ retryJob(jobId: string, options?: RequestOptions): Promise<ApiResponse<GenerationJob>>;
4840
+ /** Generate variations of a completed job. */
4841
+ generateVariations(jobId: string, options?: RequestOptions): Promise<ApiResponse<GenerationJob[]>>;
4842
+ /** List available style presets, optionally filtered by mode. */
4843
+ listPresets(params?: {
4844
+ mode?: string;
4845
+ }, options?: RequestOptions): Promise<ApiResponse<StylePreset[]>>;
4846
+ /** Get a style preset by slug. */
4847
+ getPreset(slug: string, options?: RequestOptions): Promise<ApiResponse<StylePreset>>;
4848
+ /** Create a project. */
4849
+ createProject(data: CreateProjectInput, options?: RequestOptions): Promise<ApiResponse<CreatorProject>>;
4850
+ /** List the current user's projects. */
4851
+ listProjects(params?: Record<string, unknown>, options?: RequestOptions): Promise<PaginatedResponse<CreatorProject>>;
4852
+ /** Get generation usage and credit balance. */
4853
+ getUsage(options?: RequestOptions): Promise<ApiResponse<CreatorUsage>>;
4854
+ /** Get a generation output by ID. */
4855
+ getOutput(outputId: string, options?: RequestOptions): Promise<ApiResponse<GenerationOutput>>;
4856
+ /** Get a download URL for a generation output. */
4857
+ getDownloadUrl(outputId: string, options?: RequestOptions): Promise<ApiResponse<{
4858
+ cdn_url: string;
4859
+ }>>;
4860
+ }
4861
+
4654
4862
  interface AuthRegisterAgentRequest {
4655
4863
  name: string;
4656
4864
  agent_platform: string;
@@ -5571,6 +5779,7 @@ declare class ScaleMule {
5571
5779
  readonly functions: FunctionsService;
5572
5780
  readonly photo: PhotoService;
5573
5781
  readonly flagContent: FlagContentService;
5782
+ readonly creatorMaker: CreatorMakerService;
5574
5783
  readonly compliance: ComplianceService;
5575
5784
  readonly orchestrator: OrchestratorService;
5576
5785
  readonly agentAuth: AgentAuthService;
@@ -5614,6 +5823,23 @@ declare class ScaleMule {
5614
5823
  removeAccount(userId: string): Promise<void>;
5615
5824
  /** Clear all accounts from the pool */
5616
5825
  clearAllAccounts(): Promise<void>;
5826
+ /** Whether the account switcher is enabled */
5827
+ isAccountSwitcherEnabled(): boolean;
5828
+ /** The configured privacy level for the account switcher */
5829
+ getAccountSwitcherPrivacy(): AccountSwitcherPrivacy;
5830
+ /**
5831
+ * Get all accounts that have previously logged in on this device.
5832
+ * Returns privacy-transformed display data — no raw PII in masked/minimal modes.
5833
+ * Requires `enableAccountSwitcher: true` in config.
5834
+ */
5835
+ getKnownAccounts(): KnownAccountDisplay[];
5836
+ /**
5837
+ * Forget a specific account — removes it from the known accounts list.
5838
+ * Does NOT affect any active session.
5839
+ */
5840
+ removeKnownAccount(userId: string): Promise<void>;
5841
+ /** Forget all known accounts on this device. */
5842
+ clearKnownAccounts(): Promise<void>;
5617
5843
  /** The base URL being used for API requests. */
5618
5844
  getBaseUrl(): string;
5619
5845
  /** The application ID, or null if not configured. */
@@ -5626,4 +5852,4 @@ declare class ScaleMule {
5626
5852
  getClient(): ScaleMuleClient;
5627
5853
  }
5628
5854
 
5629
- export { type AccountBalance, 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 Attachment, type Attendee, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateFlagRequest, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, 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 GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type Leaderboard, type LeaderboardEntry, LeaderboardService, 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, type MessageCallback, 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 Pipeline, type PipelineVersion, type Policy, 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 ReadStatus, RealtimeService, 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, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, 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 SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, 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 UnreadCountResponse, type UpdateFlagRequest, 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, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
5855
+ export { 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 Attachment, type Attendee, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, 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 DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, 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 KnownAccount, type KnownAccountDisplay, type Leaderboard, type LeaderboardEntry, LeaderboardService, 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, type MessageCallback, 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 Pipeline, type PipelineVersion, type Policy, 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 ReadStatus, RealtimeService, 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, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, 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 SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, 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 UnreadCountResponse, type UpdateFlagRequest, 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, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
package/dist/index.js CHANGED
@@ -308,6 +308,7 @@ __export(index_exports, {
308
308
  ChatService: () => ChatService,
309
309
  CommunicationService: () => CommunicationService,
310
310
  ComplianceService: () => ComplianceService,
311
+ CreatorMakerService: () => CreatorMakerService,
311
312
  DataService: () => DataService,
312
313
  ErrorCodes: () => ErrorCodes,
313
314
  EventsService: () => EventsService,
@@ -474,6 +475,7 @@ var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
474
475
  var ANONYMOUS_ID_STORAGE_KEY = "scalemule_anonymous_id";
475
476
  var SESSION_POOL_KEY = "scalemule_session_pool";
476
477
  var ACTIVE_ACCOUNT_KEY = "scalemule_active_account";
478
+ var KNOWN_ACCOUNTS_KEY = "scalemule_known_accounts";
477
479
  var GATEWAY_URLS = {
478
480
  dev: "https://api-dev.scalemule.com",
479
481
  prod: "https://api.scalemule.com"
@@ -523,6 +525,54 @@ function statusToErrorCode(status) {
523
525
  return status >= 500 ? "internal_error" : `http_${status}`;
524
526
  }
525
527
  }
528
+ var MAX_KNOWN_ACCOUNTS = 10;
529
+ function maskEmail(email) {
530
+ const parts = email.split("@");
531
+ const local = parts[0] ?? "";
532
+ const domain = parts[1];
533
+ if (!domain) return "***@***.***";
534
+ const tldDot = domain.lastIndexOf(".");
535
+ const tld = tldDot > 0 ? domain.slice(tldDot) : "";
536
+ const domainBase = tldDot > 0 ? domain.slice(0, tldDot) : domain;
537
+ return `${local[0] || "*"}***@${domainBase[0] || "*"}***${tld}`;
538
+ }
539
+ function stableColorIndex(userId) {
540
+ let hash = 0;
541
+ for (let i = 0; i < userId.length; i++) {
542
+ hash = (hash << 5) - hash + userId.charCodeAt(i) | 0;
543
+ }
544
+ return Math.abs(hash) % 8;
545
+ }
546
+ function applyPrivacy(account, privacy) {
547
+ switch (privacy) {
548
+ case "full":
549
+ return {
550
+ userId: account.userId,
551
+ email: account.email,
552
+ fullName: account.fullName,
553
+ avatarUrl: account.avatarUrl,
554
+ provider: account.provider,
555
+ lastActiveAt: account.lastActiveAt
556
+ };
557
+ case "masked":
558
+ return {
559
+ userId: account.userId,
560
+ email: account.email ? maskEmail(account.email) : void 0,
561
+ fullName: account.fullName && account.fullName.length > 0 ? `${account.fullName[0].toUpperCase()}.` : void 0,
562
+ provider: account.provider,
563
+ lastActiveAt: account.lastActiveAt,
564
+ colorIndex: stableColorIndex(account.userId)
565
+ };
566
+ case "minimal":
567
+ return {
568
+ userId: account.userId,
569
+ provider: account.provider,
570
+ lastActiveAt: account.lastActiveAt,
571
+ displayLabel: "Account",
572
+ colorIndex: stableColorIndex(account.userId)
573
+ };
574
+ }
575
+ }
526
576
  function createDefaultStorage() {
527
577
  if (typeof window !== "undefined" && window.localStorage) {
528
578
  return {
@@ -669,6 +719,7 @@ var ScaleMuleClient = class {
669
719
  this.workspaceId = null;
670
720
  this.anonymousId = null;
671
721
  this.sessionPool = /* @__PURE__ */ new Map();
722
+ this.knownAccounts = /* @__PURE__ */ new Map();
672
723
  this.apiKey = config.apiKey;
673
724
  this.applicationId = config.applicationId || null;
674
725
  this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
@@ -685,6 +736,8 @@ var ScaleMuleClient = class {
685
736
  this.offlineQueue.setOnlineCallback(() => this.syncOfflineQueue());
686
737
  }
687
738
  this.multiSessionEnabled = config.enableMultiSession || false;
739
+ this.accountSwitcherEnabled = config.enableAccountSwitcher || false;
740
+ this.accountSwitcherPrivacy = config.accountSwitcherPrivacy || "full";
688
741
  }
689
742
  // --------------------------------------------------------------------------
690
743
  // Session Management
@@ -727,6 +780,27 @@ var ScaleMuleClient = class {
727
780
  this.userId = activeId;
728
781
  }
729
782
  }
783
+ if (this.accountSwitcherEnabled) {
784
+ const knownJson = await this.storage.getItem(KNOWN_ACCOUNTS_KEY);
785
+ if (knownJson) {
786
+ try {
787
+ const entries = JSON.parse(knownJson);
788
+ this.knownAccounts = new Map(Object.entries(entries));
789
+ let changed = false;
790
+ for (const [userId2, entry] of this.knownAccounts) {
791
+ const normalized = applyPrivacy(entry, this.accountSwitcherPrivacy);
792
+ if (JSON.stringify(normalized) !== JSON.stringify(entry)) {
793
+ this.knownAccounts.set(userId2, normalized);
794
+ changed = true;
795
+ }
796
+ }
797
+ if (changed) {
798
+ await this.persistKnownAccounts();
799
+ }
800
+ } catch {
801
+ }
802
+ }
803
+ }
730
804
  if (this.debug)
731
805
  console.log(
732
806
  "[ScaleMule] Initialized, session:",
@@ -734,7 +808,9 @@ var ScaleMuleClient = class {
734
808
  "anonymousId:",
735
809
  anonId,
736
810
  "poolSize:",
737
- this.sessionPool.size
811
+ this.sessionPool.size,
812
+ "knownAccounts:",
813
+ this.knownAccounts.size
738
814
  );
739
815
  }
740
816
  async setSession(token, userId) {
@@ -858,6 +934,57 @@ var ScaleMuleClient = class {
858
934
  }
859
935
  await this.storage.setItem(SESSION_POOL_KEY, JSON.stringify(obj));
860
936
  }
937
+ // --------------------------------------------------------------------------
938
+ // Account Switcher (Secure — metadata only, no tokens)
939
+ // --------------------------------------------------------------------------
940
+ isAccountSwitcherEnabled() {
941
+ return this.accountSwitcherEnabled;
942
+ }
943
+ getAccountSwitcherPrivacy() {
944
+ return this.accountSwitcherPrivacy;
945
+ }
946
+ /** Get all known accounts that have logged in on this device (privacy-transformed) */
947
+ getKnownAccounts() {
948
+ return Array.from(this.knownAccounts.values());
949
+ }
950
+ /**
951
+ * Record an account as "known" on this device.
952
+ * Applies privacy transforms before storing — full email is never persisted
953
+ * in masked/minimal modes. Evicts oldest accounts if over the cap.
954
+ * Called automatically after successful login/register when account switcher is enabled.
955
+ */
956
+ async addKnownAccount(account) {
957
+ const display = applyPrivacy(account, this.accountSwitcherPrivacy);
958
+ this.knownAccounts.set(account.userId, display);
959
+ if (this.knownAccounts.size > MAX_KNOWN_ACCOUNTS) {
960
+ const sorted = Array.from(this.knownAccounts.entries()).sort(
961
+ (a, b) => (a[1].lastActiveAt || "").localeCompare(b[1].lastActiveAt || "")
962
+ );
963
+ while (this.knownAccounts.size > MAX_KNOWN_ACCOUNTS && sorted.length > 0) {
964
+ const oldest = sorted.shift();
965
+ this.knownAccounts.delete(oldest[0]);
966
+ }
967
+ }
968
+ await this.persistKnownAccounts();
969
+ }
970
+ /** Remove a specific account from the known accounts list ("forget this account") */
971
+ async removeKnownAccount(userId) {
972
+ this.knownAccounts.delete(userId);
973
+ await this.persistKnownAccounts();
974
+ }
975
+ /** Clear all known accounts ("forget all accounts on this device") */
976
+ async clearKnownAccounts() {
977
+ this.knownAccounts.clear();
978
+ await this.storage.removeItem(KNOWN_ACCOUNTS_KEY);
979
+ }
980
+ /** Persist known accounts to storage */
981
+ async persistKnownAccounts() {
982
+ const obj = {};
983
+ for (const [k, v] of this.knownAccounts) {
984
+ obj[k] = v;
985
+ }
986
+ await this.storage.setItem(KNOWN_ACCOUNTS_KEY, JSON.stringify(obj));
987
+ }
861
988
  getBaseUrl() {
862
989
  return this.baseUrl;
863
990
  }
@@ -1614,6 +1741,16 @@ var AuthService = class extends ServiceModule {
1614
1741
  addedAt: (/* @__PURE__ */ new Date()).toISOString()
1615
1742
  });
1616
1743
  }
1744
+ if (result.data && this.client.isAccountSwitcherEnabled()) {
1745
+ await this.client.addKnownAccount({
1746
+ userId: result.data.user.id,
1747
+ email: result.data.user.email,
1748
+ fullName: result.data.user.full_name,
1749
+ avatarUrl: result.data.user.avatar_url,
1750
+ provider: "email",
1751
+ lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
1752
+ });
1753
+ }
1617
1754
  return result;
1618
1755
  }
1619
1756
  async login(data, options) {
@@ -1634,6 +1771,16 @@ var AuthService = class extends ServiceModule {
1634
1771
  addedAt: (/* @__PURE__ */ new Date()).toISOString()
1635
1772
  });
1636
1773
  }
1774
+ if (result.data && this.client.isAccountSwitcherEnabled()) {
1775
+ await this.client.addKnownAccount({
1776
+ userId: result.data.user.id,
1777
+ email: result.data.user.email,
1778
+ fullName: result.data.user.full_name,
1779
+ avatarUrl: result.data.user.avatar_url,
1780
+ provider: "email",
1781
+ lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
1782
+ });
1783
+ }
1637
1784
  return result;
1638
1785
  }
1639
1786
  async logout(options) {
@@ -1775,7 +1922,18 @@ var AuthService = class extends ServiceModule {
1775
1922
  }
1776
1923
  async handleOAuthCallback(data, options) {
1777
1924
  const { provider, ...rest } = data;
1778
- return this._get(this.withQuery(`/oauth/${provider}/callback`, rest), options);
1925
+ const result = await this._get(this.withQuery(`/oauth/${provider}/callback`, rest), options);
1926
+ if (result.data && this.client.isAccountSwitcherEnabled()) {
1927
+ await this.client.addKnownAccount({
1928
+ userId: result.data.user.id,
1929
+ email: result.data.user.email,
1930
+ fullName: result.data.user.full_name,
1931
+ avatarUrl: result.data.user.avatar_url,
1932
+ provider,
1933
+ lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
1934
+ });
1935
+ }
1936
+ return result;
1779
1937
  }
1780
1938
  async listOAuthProviders(options) {
1781
1939
  return this._get("/oauth/providers", options);
@@ -6018,6 +6176,73 @@ var FlagContentService = class extends ServiceModule {
6018
6176
  }
6019
6177
  };
6020
6178
 
6179
+ // src/services/creator-maker.ts
6180
+ var CreatorMakerService = class extends ServiceModule {
6181
+ constructor() {
6182
+ super(...arguments);
6183
+ this.basePath = "/v1/creator-maker";
6184
+ }
6185
+ /** Submit a generation job. */
6186
+ async generate(data, options) {
6187
+ return this.post("/jobs", data, options);
6188
+ }
6189
+ /** Get a generation job by ID. */
6190
+ async getJob(jobId, options) {
6191
+ return this._get(`/jobs/${jobId}`, options);
6192
+ }
6193
+ /** Long-poll for job completion (server holds up to 30s). */
6194
+ async pollJob(jobId, options) {
6195
+ return this._get(`/jobs/${jobId}/poll`, {
6196
+ ...options,
6197
+ timeout: 35e3
6198
+ });
6199
+ }
6200
+ /** List the current user's generation jobs. */
6201
+ async listJobs(params, options) {
6202
+ return this._list("/jobs", params, options);
6203
+ }
6204
+ /** Cancel a pending or queued job. */
6205
+ async cancelJob(jobId, options) {
6206
+ return this.post(`/jobs/${jobId}/cancel`, void 0, options);
6207
+ }
6208
+ /** Retry a failed job. */
6209
+ async retryJob(jobId, options) {
6210
+ return this.post(`/jobs/${jobId}/retry`, void 0, options);
6211
+ }
6212
+ /** Generate variations of a completed job. */
6213
+ async generateVariations(jobId, options) {
6214
+ return this.post(`/jobs/${jobId}/variations`, void 0, options);
6215
+ }
6216
+ /** List available style presets, optionally filtered by mode. */
6217
+ async listPresets(params, options) {
6218
+ return this._get(this.withQuery("/presets", params), options);
6219
+ }
6220
+ /** Get a style preset by slug. */
6221
+ async getPreset(slug, options) {
6222
+ return this._get(`/presets/${slug}`, options);
6223
+ }
6224
+ /** Create a project. */
6225
+ async createProject(data, options) {
6226
+ return this.post("/projects", data, options);
6227
+ }
6228
+ /** List the current user's projects. */
6229
+ async listProjects(params, options) {
6230
+ return this._list("/projects", params, options);
6231
+ }
6232
+ /** Get generation usage and credit balance. */
6233
+ async getUsage(options) {
6234
+ return this._get("/usage", options);
6235
+ }
6236
+ /** Get a generation output by ID. */
6237
+ async getOutput(outputId, options) {
6238
+ return this._get(`/outputs/${outputId}`, options);
6239
+ }
6240
+ /** Get a download URL for a generation output. */
6241
+ async getDownloadUrl(outputId, options) {
6242
+ return this._get(`/outputs/${outputId}/download`, options);
6243
+ }
6244
+ };
6245
+
6021
6246
  // src/services/agent-auth.ts
6022
6247
  var AgentAuthService = class extends ServiceModule {
6023
6248
  constructor() {
@@ -6537,6 +6762,7 @@ var ScaleMule = class {
6537
6762
  this.functions = new FunctionsService(this._client);
6538
6763
  this.photo = new PhotoService(this._client);
6539
6764
  this.flagContent = new FlagContentService(this._client);
6765
+ this.creatorMaker = new CreatorMakerService(this._client);
6540
6766
  this.compliance = new ComplianceService(this._client);
6541
6767
  this.orchestrator = new OrchestratorService(this._client);
6542
6768
  this.agentAuth = new AgentAuthService(this._client);
@@ -6616,6 +6842,36 @@ var ScaleMule = class {
6616
6842
  async clearAllAccounts() {
6617
6843
  return this._client.clearAllAccounts();
6618
6844
  }
6845
+ // --------------------------------------------------------------------------
6846
+ // Account Switcher (Secure — metadata only, re-auth required)
6847
+ // --------------------------------------------------------------------------
6848
+ /** Whether the account switcher is enabled */
6849
+ isAccountSwitcherEnabled() {
6850
+ return this._client.isAccountSwitcherEnabled();
6851
+ }
6852
+ /** The configured privacy level for the account switcher */
6853
+ getAccountSwitcherPrivacy() {
6854
+ return this._client.getAccountSwitcherPrivacy();
6855
+ }
6856
+ /**
6857
+ * Get all accounts that have previously logged in on this device.
6858
+ * Returns privacy-transformed display data — no raw PII in masked/minimal modes.
6859
+ * Requires `enableAccountSwitcher: true` in config.
6860
+ */
6861
+ getKnownAccounts() {
6862
+ return this._client.getKnownAccounts();
6863
+ }
6864
+ /**
6865
+ * Forget a specific account — removes it from the known accounts list.
6866
+ * Does NOT affect any active session.
6867
+ */
6868
+ async removeKnownAccount(userId) {
6869
+ return this._client.removeKnownAccount(userId);
6870
+ }
6871
+ /** Forget all known accounts on this device. */
6872
+ async clearKnownAccounts() {
6873
+ return this._client.clearKnownAccounts();
6874
+ }
6619
6875
  /** The base URL being used for API requests. */
6620
6876
  getBaseUrl() {
6621
6877
  return this._client.getBaseUrl();
@@ -6655,6 +6911,7 @@ var index_default = ScaleMule;
6655
6911
  ChatService,
6656
6912
  CommunicationService,
6657
6913
  ComplianceService,
6914
+ CreatorMakerService,
6658
6915
  DataService,
6659
6916
  ErrorCodes,
6660
6917
  EventsService,
package/dist/index.mjs CHANGED
@@ -107,6 +107,7 @@ var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
107
107
  var ANONYMOUS_ID_STORAGE_KEY = "scalemule_anonymous_id";
108
108
  var SESSION_POOL_KEY = "scalemule_session_pool";
109
109
  var ACTIVE_ACCOUNT_KEY = "scalemule_active_account";
110
+ var KNOWN_ACCOUNTS_KEY = "scalemule_known_accounts";
110
111
  var GATEWAY_URLS = {
111
112
  dev: "https://api-dev.scalemule.com",
112
113
  prod: "https://api.scalemule.com"
@@ -156,6 +157,54 @@ function statusToErrorCode(status) {
156
157
  return status >= 500 ? "internal_error" : `http_${status}`;
157
158
  }
158
159
  }
160
+ var MAX_KNOWN_ACCOUNTS = 10;
161
+ function maskEmail(email) {
162
+ const parts = email.split("@");
163
+ const local = parts[0] ?? "";
164
+ const domain = parts[1];
165
+ if (!domain) return "***@***.***";
166
+ const tldDot = domain.lastIndexOf(".");
167
+ const tld = tldDot > 0 ? domain.slice(tldDot) : "";
168
+ const domainBase = tldDot > 0 ? domain.slice(0, tldDot) : domain;
169
+ return `${local[0] || "*"}***@${domainBase[0] || "*"}***${tld}`;
170
+ }
171
+ function stableColorIndex(userId) {
172
+ let hash = 0;
173
+ for (let i = 0; i < userId.length; i++) {
174
+ hash = (hash << 5) - hash + userId.charCodeAt(i) | 0;
175
+ }
176
+ return Math.abs(hash) % 8;
177
+ }
178
+ function applyPrivacy(account, privacy) {
179
+ switch (privacy) {
180
+ case "full":
181
+ return {
182
+ userId: account.userId,
183
+ email: account.email,
184
+ fullName: account.fullName,
185
+ avatarUrl: account.avatarUrl,
186
+ provider: account.provider,
187
+ lastActiveAt: account.lastActiveAt
188
+ };
189
+ case "masked":
190
+ return {
191
+ userId: account.userId,
192
+ email: account.email ? maskEmail(account.email) : void 0,
193
+ fullName: account.fullName && account.fullName.length > 0 ? `${account.fullName[0].toUpperCase()}.` : void 0,
194
+ provider: account.provider,
195
+ lastActiveAt: account.lastActiveAt,
196
+ colorIndex: stableColorIndex(account.userId)
197
+ };
198
+ case "minimal":
199
+ return {
200
+ userId: account.userId,
201
+ provider: account.provider,
202
+ lastActiveAt: account.lastActiveAt,
203
+ displayLabel: "Account",
204
+ colorIndex: stableColorIndex(account.userId)
205
+ };
206
+ }
207
+ }
159
208
  function createDefaultStorage() {
160
209
  if (typeof window !== "undefined" && window.localStorage) {
161
210
  return {
@@ -302,6 +351,7 @@ var ScaleMuleClient = class {
302
351
  this.workspaceId = null;
303
352
  this.anonymousId = null;
304
353
  this.sessionPool = /* @__PURE__ */ new Map();
354
+ this.knownAccounts = /* @__PURE__ */ new Map();
305
355
  this.apiKey = config.apiKey;
306
356
  this.applicationId = config.applicationId || null;
307
357
  this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
@@ -318,6 +368,8 @@ var ScaleMuleClient = class {
318
368
  this.offlineQueue.setOnlineCallback(() => this.syncOfflineQueue());
319
369
  }
320
370
  this.multiSessionEnabled = config.enableMultiSession || false;
371
+ this.accountSwitcherEnabled = config.enableAccountSwitcher || false;
372
+ this.accountSwitcherPrivacy = config.accountSwitcherPrivacy || "full";
321
373
  }
322
374
  // --------------------------------------------------------------------------
323
375
  // Session Management
@@ -360,6 +412,27 @@ var ScaleMuleClient = class {
360
412
  this.userId = activeId;
361
413
  }
362
414
  }
415
+ if (this.accountSwitcherEnabled) {
416
+ const knownJson = await this.storage.getItem(KNOWN_ACCOUNTS_KEY);
417
+ if (knownJson) {
418
+ try {
419
+ const entries = JSON.parse(knownJson);
420
+ this.knownAccounts = new Map(Object.entries(entries));
421
+ let changed = false;
422
+ for (const [userId2, entry] of this.knownAccounts) {
423
+ const normalized = applyPrivacy(entry, this.accountSwitcherPrivacy);
424
+ if (JSON.stringify(normalized) !== JSON.stringify(entry)) {
425
+ this.knownAccounts.set(userId2, normalized);
426
+ changed = true;
427
+ }
428
+ }
429
+ if (changed) {
430
+ await this.persistKnownAccounts();
431
+ }
432
+ } catch {
433
+ }
434
+ }
435
+ }
363
436
  if (this.debug)
364
437
  console.log(
365
438
  "[ScaleMule] Initialized, session:",
@@ -367,7 +440,9 @@ var ScaleMuleClient = class {
367
440
  "anonymousId:",
368
441
  anonId,
369
442
  "poolSize:",
370
- this.sessionPool.size
443
+ this.sessionPool.size,
444
+ "knownAccounts:",
445
+ this.knownAccounts.size
371
446
  );
372
447
  }
373
448
  async setSession(token, userId) {
@@ -491,6 +566,57 @@ var ScaleMuleClient = class {
491
566
  }
492
567
  await this.storage.setItem(SESSION_POOL_KEY, JSON.stringify(obj));
493
568
  }
569
+ // --------------------------------------------------------------------------
570
+ // Account Switcher (Secure — metadata only, no tokens)
571
+ // --------------------------------------------------------------------------
572
+ isAccountSwitcherEnabled() {
573
+ return this.accountSwitcherEnabled;
574
+ }
575
+ getAccountSwitcherPrivacy() {
576
+ return this.accountSwitcherPrivacy;
577
+ }
578
+ /** Get all known accounts that have logged in on this device (privacy-transformed) */
579
+ getKnownAccounts() {
580
+ return Array.from(this.knownAccounts.values());
581
+ }
582
+ /**
583
+ * Record an account as "known" on this device.
584
+ * Applies privacy transforms before storing — full email is never persisted
585
+ * in masked/minimal modes. Evicts oldest accounts if over the cap.
586
+ * Called automatically after successful login/register when account switcher is enabled.
587
+ */
588
+ async addKnownAccount(account) {
589
+ const display = applyPrivacy(account, this.accountSwitcherPrivacy);
590
+ this.knownAccounts.set(account.userId, display);
591
+ if (this.knownAccounts.size > MAX_KNOWN_ACCOUNTS) {
592
+ const sorted = Array.from(this.knownAccounts.entries()).sort(
593
+ (a, b) => (a[1].lastActiveAt || "").localeCompare(b[1].lastActiveAt || "")
594
+ );
595
+ while (this.knownAccounts.size > MAX_KNOWN_ACCOUNTS && sorted.length > 0) {
596
+ const oldest = sorted.shift();
597
+ this.knownAccounts.delete(oldest[0]);
598
+ }
599
+ }
600
+ await this.persistKnownAccounts();
601
+ }
602
+ /** Remove a specific account from the known accounts list ("forget this account") */
603
+ async removeKnownAccount(userId) {
604
+ this.knownAccounts.delete(userId);
605
+ await this.persistKnownAccounts();
606
+ }
607
+ /** Clear all known accounts ("forget all accounts on this device") */
608
+ async clearKnownAccounts() {
609
+ this.knownAccounts.clear();
610
+ await this.storage.removeItem(KNOWN_ACCOUNTS_KEY);
611
+ }
612
+ /** Persist known accounts to storage */
613
+ async persistKnownAccounts() {
614
+ const obj = {};
615
+ for (const [k, v] of this.knownAccounts) {
616
+ obj[k] = v;
617
+ }
618
+ await this.storage.setItem(KNOWN_ACCOUNTS_KEY, JSON.stringify(obj));
619
+ }
494
620
  getBaseUrl() {
495
621
  return this.baseUrl;
496
622
  }
@@ -1247,6 +1373,16 @@ var AuthService = class extends ServiceModule {
1247
1373
  addedAt: (/* @__PURE__ */ new Date()).toISOString()
1248
1374
  });
1249
1375
  }
1376
+ if (result.data && this.client.isAccountSwitcherEnabled()) {
1377
+ await this.client.addKnownAccount({
1378
+ userId: result.data.user.id,
1379
+ email: result.data.user.email,
1380
+ fullName: result.data.user.full_name,
1381
+ avatarUrl: result.data.user.avatar_url,
1382
+ provider: "email",
1383
+ lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
1384
+ });
1385
+ }
1250
1386
  return result;
1251
1387
  }
1252
1388
  async login(data, options) {
@@ -1267,6 +1403,16 @@ var AuthService = class extends ServiceModule {
1267
1403
  addedAt: (/* @__PURE__ */ new Date()).toISOString()
1268
1404
  });
1269
1405
  }
1406
+ if (result.data && this.client.isAccountSwitcherEnabled()) {
1407
+ await this.client.addKnownAccount({
1408
+ userId: result.data.user.id,
1409
+ email: result.data.user.email,
1410
+ fullName: result.data.user.full_name,
1411
+ avatarUrl: result.data.user.avatar_url,
1412
+ provider: "email",
1413
+ lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
1414
+ });
1415
+ }
1270
1416
  return result;
1271
1417
  }
1272
1418
  async logout(options) {
@@ -1408,7 +1554,18 @@ var AuthService = class extends ServiceModule {
1408
1554
  }
1409
1555
  async handleOAuthCallback(data, options) {
1410
1556
  const { provider, ...rest } = data;
1411
- return this._get(this.withQuery(`/oauth/${provider}/callback`, rest), options);
1557
+ const result = await this._get(this.withQuery(`/oauth/${provider}/callback`, rest), options);
1558
+ if (result.data && this.client.isAccountSwitcherEnabled()) {
1559
+ await this.client.addKnownAccount({
1560
+ userId: result.data.user.id,
1561
+ email: result.data.user.email,
1562
+ fullName: result.data.user.full_name,
1563
+ avatarUrl: result.data.user.avatar_url,
1564
+ provider,
1565
+ lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
1566
+ });
1567
+ }
1568
+ return result;
1412
1569
  }
1413
1570
  async listOAuthProviders(options) {
1414
1571
  return this._get("/oauth/providers", options);
@@ -5648,6 +5805,73 @@ var FlagContentService = class extends ServiceModule {
5648
5805
  }
5649
5806
  };
5650
5807
 
5808
+ // src/services/creator-maker.ts
5809
+ var CreatorMakerService = class extends ServiceModule {
5810
+ constructor() {
5811
+ super(...arguments);
5812
+ this.basePath = "/v1/creator-maker";
5813
+ }
5814
+ /** Submit a generation job. */
5815
+ async generate(data, options) {
5816
+ return this.post("/jobs", data, options);
5817
+ }
5818
+ /** Get a generation job by ID. */
5819
+ async getJob(jobId, options) {
5820
+ return this._get(`/jobs/${jobId}`, options);
5821
+ }
5822
+ /** Long-poll for job completion (server holds up to 30s). */
5823
+ async pollJob(jobId, options) {
5824
+ return this._get(`/jobs/${jobId}/poll`, {
5825
+ ...options,
5826
+ timeout: 35e3
5827
+ });
5828
+ }
5829
+ /** List the current user's generation jobs. */
5830
+ async listJobs(params, options) {
5831
+ return this._list("/jobs", params, options);
5832
+ }
5833
+ /** Cancel a pending or queued job. */
5834
+ async cancelJob(jobId, options) {
5835
+ return this.post(`/jobs/${jobId}/cancel`, void 0, options);
5836
+ }
5837
+ /** Retry a failed job. */
5838
+ async retryJob(jobId, options) {
5839
+ return this.post(`/jobs/${jobId}/retry`, void 0, options);
5840
+ }
5841
+ /** Generate variations of a completed job. */
5842
+ async generateVariations(jobId, options) {
5843
+ return this.post(`/jobs/${jobId}/variations`, void 0, options);
5844
+ }
5845
+ /** List available style presets, optionally filtered by mode. */
5846
+ async listPresets(params, options) {
5847
+ return this._get(this.withQuery("/presets", params), options);
5848
+ }
5849
+ /** Get a style preset by slug. */
5850
+ async getPreset(slug, options) {
5851
+ return this._get(`/presets/${slug}`, options);
5852
+ }
5853
+ /** Create a project. */
5854
+ async createProject(data, options) {
5855
+ return this.post("/projects", data, options);
5856
+ }
5857
+ /** List the current user's projects. */
5858
+ async listProjects(params, options) {
5859
+ return this._list("/projects", params, options);
5860
+ }
5861
+ /** Get generation usage and credit balance. */
5862
+ async getUsage(options) {
5863
+ return this._get("/usage", options);
5864
+ }
5865
+ /** Get a generation output by ID. */
5866
+ async getOutput(outputId, options) {
5867
+ return this._get(`/outputs/${outputId}`, options);
5868
+ }
5869
+ /** Get a download URL for a generation output. */
5870
+ async getDownloadUrl(outputId, options) {
5871
+ return this._get(`/outputs/${outputId}/download`, options);
5872
+ }
5873
+ };
5874
+
5651
5875
  // src/services/agent-auth.ts
5652
5876
  var AgentAuthService = class extends ServiceModule {
5653
5877
  constructor() {
@@ -6167,6 +6391,7 @@ var ScaleMule = class {
6167
6391
  this.functions = new FunctionsService(this._client);
6168
6392
  this.photo = new PhotoService(this._client);
6169
6393
  this.flagContent = new FlagContentService(this._client);
6394
+ this.creatorMaker = new CreatorMakerService(this._client);
6170
6395
  this.compliance = new ComplianceService(this._client);
6171
6396
  this.orchestrator = new OrchestratorService(this._client);
6172
6397
  this.agentAuth = new AgentAuthService(this._client);
@@ -6246,6 +6471,36 @@ var ScaleMule = class {
6246
6471
  async clearAllAccounts() {
6247
6472
  return this._client.clearAllAccounts();
6248
6473
  }
6474
+ // --------------------------------------------------------------------------
6475
+ // Account Switcher (Secure — metadata only, re-auth required)
6476
+ // --------------------------------------------------------------------------
6477
+ /** Whether the account switcher is enabled */
6478
+ isAccountSwitcherEnabled() {
6479
+ return this._client.isAccountSwitcherEnabled();
6480
+ }
6481
+ /** The configured privacy level for the account switcher */
6482
+ getAccountSwitcherPrivacy() {
6483
+ return this._client.getAccountSwitcherPrivacy();
6484
+ }
6485
+ /**
6486
+ * Get all accounts that have previously logged in on this device.
6487
+ * Returns privacy-transformed display data — no raw PII in masked/minimal modes.
6488
+ * Requires `enableAccountSwitcher: true` in config.
6489
+ */
6490
+ getKnownAccounts() {
6491
+ return this._client.getKnownAccounts();
6492
+ }
6493
+ /**
6494
+ * Forget a specific account — removes it from the known accounts list.
6495
+ * Does NOT affect any active session.
6496
+ */
6497
+ async removeKnownAccount(userId) {
6498
+ return this._client.removeKnownAccount(userId);
6499
+ }
6500
+ /** Forget all known accounts on this device. */
6501
+ async clearKnownAccounts() {
6502
+ return this._client.clearKnownAccounts();
6503
+ }
6249
6504
  /** The base URL being used for API requests. */
6250
6505
  getBaseUrl() {
6251
6506
  return this._client.getBaseUrl();
@@ -6284,6 +6539,7 @@ export {
6284
6539
  ChatService,
6285
6540
  CommunicationService,
6286
6541
  ComplianceService,
6542
+ CreatorMakerService,
6287
6543
  DataService,
6288
6544
  ErrorCodes,
6289
6545
  EventsService,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalemule/sdk",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "Official TypeScript/JavaScript SDK for ScaleMule Backend-as-a-Service",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",