@scalemule/sdk 0.0.7 → 0.0.10

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
@@ -261,6 +261,7 @@ declare class ScaleMuleClient {
261
261
  private userId;
262
262
  private rateLimitQueue;
263
263
  private offlineQueue;
264
+ private workspaceId;
264
265
  constructor(config: ScaleMuleConfig);
265
266
  initialize(): Promise<void>;
266
267
  setSession(token: string, userId: string): Promise<void>;
@@ -276,6 +277,8 @@ declare class ScaleMuleClient {
276
277
  getOfflineQueueLength(): number;
277
278
  getRateLimitQueueLength(): number;
278
279
  isRateLimited(): boolean;
280
+ setWorkspaceContext(id: string | null): void;
281
+ getWorkspaceId(): string | null;
279
282
  request<T>(path: string, init?: {
280
283
  method?: string;
281
284
  body?: unknown;
@@ -2505,16 +2508,18 @@ declare class PermissionsService extends ServiceModule {
2505
2508
  }
2506
2509
 
2507
2510
  /**
2508
- * Teams Service Module
2511
+ * Workspaces Service Module
2509
2512
  *
2510
- * Team CRUD, members, invitations, SSO.
2513
+ * Workspace CRUD, members, invitations, SSO.
2514
+ * Workspaces are resource containers (own projects, goals, settings, people, agents).
2511
2515
  *
2512
- * Routes:
2513
- * POST / → create team
2514
- * GET / → list teams
2515
- * GET /{id} → get team
2516
- * PATCH /{id} → update team
2517
- * DELETE /{id} → delete team
2516
+ * Routes (via /v1/workspaces):
2517
+ * POST / → create workspace
2518
+ * GET / → list workspaces
2519
+ * GET /mine → list my workspaces
2520
+ * GET /{id} → get workspace
2521
+ * PATCH /{id} → update workspace
2522
+ * DELETE /{id} → delete workspace
2518
2523
  * GET /{id}/members → list members
2519
2524
  * POST /{id}/members → add member
2520
2525
  * PATCH /{id}/members/{userId} → update member role
@@ -2527,25 +2532,29 @@ declare class PermissionsService extends ServiceModule {
2527
2532
  * GET /{id}/sso → get SSO config
2528
2533
  */
2529
2534
 
2530
- interface Team {
2535
+ interface Workspace$1 {
2531
2536
  id: string;
2532
- team_name: string;
2537
+ kind: 'workspace';
2538
+ name: string;
2533
2539
  description?: string;
2534
2540
  owner_user_id: string;
2535
2541
  plan_type?: string;
2536
2542
  member_limit?: number;
2537
2543
  created_at: string;
2538
2544
  }
2539
- interface TeamMember {
2545
+ interface WorkspaceMember {
2540
2546
  id: string;
2541
- team_id: string;
2547
+ container_id: string;
2542
2548
  sm_user_id: string;
2543
2549
  role: string;
2544
2550
  joined_at: string;
2551
+ full_name?: string;
2552
+ email?: string;
2553
+ avatar_url?: string;
2545
2554
  }
2546
- interface TeamInvitation {
2555
+ interface WorkspaceInvitation {
2547
2556
  id: string;
2548
- team_id: string;
2557
+ container_id: string;
2549
2558
  email: string;
2550
2559
  invited_by: string;
2551
2560
  role: string;
@@ -2556,7 +2565,7 @@ interface TeamInvitation {
2556
2565
  }
2557
2566
  interface SsoConfig {
2558
2567
  id: string;
2559
- team_id: string;
2568
+ container_id: string;
2560
2569
  provider_type: string;
2561
2570
  provider_name?: string;
2562
2571
  saml_idp_entity_id?: string;
@@ -2575,6 +2584,105 @@ interface SsoConfig {
2575
2584
  created_at: string;
2576
2585
  updated_at: string;
2577
2586
  }
2587
+ declare class WorkspacesService extends ServiceModule {
2588
+ protected basePath: string;
2589
+ create(data: {
2590
+ name: string;
2591
+ description?: string;
2592
+ }, options?: RequestOptions): Promise<ApiResponse<Workspace$1>>;
2593
+ list(params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Workspace$1>>;
2594
+ mine(params?: PaginationParams, options?: RequestOptions): Promise<PaginatedResponse<Workspace$1>>;
2595
+ get(id: string, options?: RequestOptions): Promise<ApiResponse<Workspace$1>>;
2596
+ update(id: string, data: Partial<{
2597
+ name: string;
2598
+ description: string;
2599
+ }>, options?: RequestOptions): Promise<ApiResponse<Workspace$1>>;
2600
+ delete(id: string, options?: RequestOptions): Promise<ApiResponse<{
2601
+ deleted: boolean;
2602
+ }>>;
2603
+ listMembers(workspaceId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<WorkspaceMember>>;
2604
+ addMember(workspaceId: string, data: {
2605
+ user_id: string;
2606
+ role: string;
2607
+ }, options?: RequestOptions): Promise<ApiResponse<WorkspaceMember>>;
2608
+ updateMember(workspaceId: string, userId: string, data: {
2609
+ role: string;
2610
+ }, options?: RequestOptions): Promise<ApiResponse<WorkspaceMember>>;
2611
+ removeMember(workspaceId: string, userId: string, options?: RequestOptions): Promise<ApiResponse<{
2612
+ removed: boolean;
2613
+ }>>;
2614
+ invite(workspaceId: string, data: {
2615
+ email: string;
2616
+ role: string;
2617
+ }, options?: RequestOptions): Promise<ApiResponse<WorkspaceInvitation>>;
2618
+ listInvitations(workspaceId: string, options?: RequestOptions): Promise<ApiResponse<WorkspaceInvitation[]>>;
2619
+ acceptInvitation(token: string, options?: RequestOptions): Promise<ApiResponse<WorkspaceInvitation>>;
2620
+ cancelInvitation(id: string, options?: RequestOptions): Promise<ApiResponse<{
2621
+ cancelled: boolean;
2622
+ }>>;
2623
+ configureSso(workspaceId: string, data: {
2624
+ provider: string;
2625
+ domain: string;
2626
+ metadata_url?: string;
2627
+ }, options?: RequestOptions): Promise<ApiResponse<SsoConfig>>;
2628
+ getSso(workspaceId: string, options?: RequestOptions): Promise<ApiResponse<SsoConfig>>;
2629
+ }
2630
+
2631
+ /**
2632
+ * Teams Service Module
2633
+ *
2634
+ * Team CRUD, members, invitations.
2635
+ * Teams are membership/coordination groups (group people and agents; do not own resources).
2636
+ * SSO is NOT available for teams — use workspaces for SSO.
2637
+ *
2638
+ * Routes (via /v1/teams):
2639
+ * POST / → create team
2640
+ * GET / → list teams
2641
+ * GET /mine → list my teams
2642
+ * GET /{id} → get team
2643
+ * PATCH /{id} → update team
2644
+ * DELETE /{id} → delete team
2645
+ * GET /{id}/members → list members
2646
+ * POST /{id}/members → add member
2647
+ * PATCH /{id}/members/{userId} → update member role
2648
+ * DELETE /{id}/members/{userId} → remove member
2649
+ * POST /{id}/invitations → invite
2650
+ * GET /{id}/invitations → list invitations
2651
+ * POST /invitations/{token}/accept → accept invitation
2652
+ * DELETE /invitations/{id} → cancel invitation
2653
+ */
2654
+
2655
+ interface Team {
2656
+ id: string;
2657
+ kind: 'team';
2658
+ name: string;
2659
+ description?: string;
2660
+ owner_user_id: string;
2661
+ plan_type?: string;
2662
+ member_limit?: number;
2663
+ created_at: string;
2664
+ }
2665
+ interface TeamMember {
2666
+ id: string;
2667
+ container_id: string;
2668
+ sm_user_id: string;
2669
+ role: string;
2670
+ joined_at: string;
2671
+ full_name?: string;
2672
+ email?: string;
2673
+ avatar_url?: string;
2674
+ }
2675
+ interface TeamInvitation {
2676
+ id: string;
2677
+ container_id: string;
2678
+ email: string;
2679
+ invited_by: string;
2680
+ role: string;
2681
+ token?: string;
2682
+ status: string;
2683
+ expires_at: string;
2684
+ created_at: string;
2685
+ }
2578
2686
  declare class TeamsService extends ServiceModule {
2579
2687
  protected basePath: string;
2580
2688
  create(data: {
@@ -2611,19 +2719,6 @@ declare class TeamsService extends ServiceModule {
2611
2719
  cancelInvitation(id: string, options?: RequestOptions): Promise<ApiResponse<{
2612
2720
  cancelled: boolean;
2613
2721
  }>>;
2614
- configureSso(teamId: string, data: {
2615
- provider: string;
2616
- domain: string;
2617
- metadata_url?: string;
2618
- }, options?: RequestOptions): Promise<ApiResponse<SsoConfig>>;
2619
- getSso(teamId: string, options?: RequestOptions): Promise<ApiResponse<SsoConfig>>;
2620
- /** @deprecated Use create() instead */
2621
- createTeam(data: {
2622
- name: string;
2623
- description?: string;
2624
- }): Promise<ApiResponse<Team>>;
2625
- /** @deprecated Use invite() instead */
2626
- inviteMember(teamId: string, email: string, role: string): Promise<ApiResponse<TeamInvitation>>;
2627
2722
  }
2628
2723
 
2629
2724
  /**
@@ -4280,6 +4375,8 @@ interface ProjectGrant {
4280
4375
  expires_at: string;
4281
4376
  redeemed_at?: string;
4282
4377
  email_sent?: boolean;
4378
+ container_invitation_id?: string;
4379
+ /** @deprecated Use container_invitation_id */
4283
4380
  team_invitation_id?: string;
4284
4381
  }
4285
4382
  interface GrantInfo {
@@ -4397,7 +4494,11 @@ declare class AgentProjectsService extends ServiceModule {
4397
4494
  user_email: string;
4398
4495
  expires_at: string;
4399
4496
  invite_url?: string;
4497
+ container_invitation_id?: string;
4498
+ container_id?: string;
4499
+ /** @deprecated Use container_invitation_id */
4400
4500
  team_invitation_id?: string;
4501
+ /** @deprecated Use container_id */
4401
4502
  team_id?: string;
4402
4503
  }, options?: RequestOptions): Promise<ApiResponse<ProjectGrant>>;
4403
4504
  listGrants(projectId: string, options?: RequestOptions): Promise<ApiResponse<ProjectGrant[]>>;
@@ -4804,7 +4905,9 @@ declare class ScaleMule {
4804
4905
  readonly communication: CommunicationService;
4805
4906
  readonly scheduler: SchedulerService;
4806
4907
  readonly permissions: PermissionsService;
4807
- readonly teams: TeamsService;
4908
+ readonly workspaces: WorkspacesService;
4909
+ /** @deprecated Use `workspaces` instead */
4910
+ get teams(): WorkspacesService;
4808
4911
  readonly accounts: AccountsService;
4809
4912
  readonly identity: IdentityService;
4810
4913
  readonly catalog: CatalogService;
@@ -4853,8 +4956,12 @@ declare class ScaleMule {
4853
4956
  isAuthenticated(): boolean;
4854
4957
  /** The base URL being used for API requests. */
4855
4958
  getBaseUrl(): string;
4959
+ /** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
4960
+ setWorkspaceContext(id: string | null): void;
4961
+ /** Get the current workspace ID, or null. */
4962
+ getWorkspaceId(): string | null;
4856
4963
  /** Access the underlying ScaleMuleClient for advanced usage. */
4857
4964
  getClient(): ScaleMuleClient;
4858
4965
  }
4859
4966
 
4860
- 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, 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 CreateSessionResponse, 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 FlagCheck, FlagContentService, 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 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 MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, 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 PushToken, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type RedeemResult, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RequestOptions, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, 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 Severity, type ShortestPathResult, type SignedUrlResponse, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, type SubmitResult, type Subscription, 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 UploadCompleteResponse, type UploadEngineConfig, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, type Workspace, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, validateIP };
4967
+ 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 CreateSessionResponse, 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 FlagCheck, FlagContentService, 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 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 MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, 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 PushToken, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type RedeemResult, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RequestOptions, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, 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 Severity, type ShortestPathResult, type SignedUrlResponse, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, type SubmitResult, type Subscription, 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 UploadCompleteResponse, type UploadEngineConfig, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, 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, validateIP };
package/dist/index.d.ts CHANGED
@@ -261,6 +261,7 @@ declare class ScaleMuleClient {
261
261
  private userId;
262
262
  private rateLimitQueue;
263
263
  private offlineQueue;
264
+ private workspaceId;
264
265
  constructor(config: ScaleMuleConfig);
265
266
  initialize(): Promise<void>;
266
267
  setSession(token: string, userId: string): Promise<void>;
@@ -276,6 +277,8 @@ declare class ScaleMuleClient {
276
277
  getOfflineQueueLength(): number;
277
278
  getRateLimitQueueLength(): number;
278
279
  isRateLimited(): boolean;
280
+ setWorkspaceContext(id: string | null): void;
281
+ getWorkspaceId(): string | null;
279
282
  request<T>(path: string, init?: {
280
283
  method?: string;
281
284
  body?: unknown;
@@ -2505,16 +2508,18 @@ declare class PermissionsService extends ServiceModule {
2505
2508
  }
2506
2509
 
2507
2510
  /**
2508
- * Teams Service Module
2511
+ * Workspaces Service Module
2509
2512
  *
2510
- * Team CRUD, members, invitations, SSO.
2513
+ * Workspace CRUD, members, invitations, SSO.
2514
+ * Workspaces are resource containers (own projects, goals, settings, people, agents).
2511
2515
  *
2512
- * Routes:
2513
- * POST / → create team
2514
- * GET / → list teams
2515
- * GET /{id} → get team
2516
- * PATCH /{id} → update team
2517
- * DELETE /{id} → delete team
2516
+ * Routes (via /v1/workspaces):
2517
+ * POST / → create workspace
2518
+ * GET / → list workspaces
2519
+ * GET /mine → list my workspaces
2520
+ * GET /{id} → get workspace
2521
+ * PATCH /{id} → update workspace
2522
+ * DELETE /{id} → delete workspace
2518
2523
  * GET /{id}/members → list members
2519
2524
  * POST /{id}/members → add member
2520
2525
  * PATCH /{id}/members/{userId} → update member role
@@ -2527,25 +2532,29 @@ declare class PermissionsService extends ServiceModule {
2527
2532
  * GET /{id}/sso → get SSO config
2528
2533
  */
2529
2534
 
2530
- interface Team {
2535
+ interface Workspace$1 {
2531
2536
  id: string;
2532
- team_name: string;
2537
+ kind: 'workspace';
2538
+ name: string;
2533
2539
  description?: string;
2534
2540
  owner_user_id: string;
2535
2541
  plan_type?: string;
2536
2542
  member_limit?: number;
2537
2543
  created_at: string;
2538
2544
  }
2539
- interface TeamMember {
2545
+ interface WorkspaceMember {
2540
2546
  id: string;
2541
- team_id: string;
2547
+ container_id: string;
2542
2548
  sm_user_id: string;
2543
2549
  role: string;
2544
2550
  joined_at: string;
2551
+ full_name?: string;
2552
+ email?: string;
2553
+ avatar_url?: string;
2545
2554
  }
2546
- interface TeamInvitation {
2555
+ interface WorkspaceInvitation {
2547
2556
  id: string;
2548
- team_id: string;
2557
+ container_id: string;
2549
2558
  email: string;
2550
2559
  invited_by: string;
2551
2560
  role: string;
@@ -2556,7 +2565,7 @@ interface TeamInvitation {
2556
2565
  }
2557
2566
  interface SsoConfig {
2558
2567
  id: string;
2559
- team_id: string;
2568
+ container_id: string;
2560
2569
  provider_type: string;
2561
2570
  provider_name?: string;
2562
2571
  saml_idp_entity_id?: string;
@@ -2575,6 +2584,105 @@ interface SsoConfig {
2575
2584
  created_at: string;
2576
2585
  updated_at: string;
2577
2586
  }
2587
+ declare class WorkspacesService extends ServiceModule {
2588
+ protected basePath: string;
2589
+ create(data: {
2590
+ name: string;
2591
+ description?: string;
2592
+ }, options?: RequestOptions): Promise<ApiResponse<Workspace$1>>;
2593
+ list(params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Workspace$1>>;
2594
+ mine(params?: PaginationParams, options?: RequestOptions): Promise<PaginatedResponse<Workspace$1>>;
2595
+ get(id: string, options?: RequestOptions): Promise<ApiResponse<Workspace$1>>;
2596
+ update(id: string, data: Partial<{
2597
+ name: string;
2598
+ description: string;
2599
+ }>, options?: RequestOptions): Promise<ApiResponse<Workspace$1>>;
2600
+ delete(id: string, options?: RequestOptions): Promise<ApiResponse<{
2601
+ deleted: boolean;
2602
+ }>>;
2603
+ listMembers(workspaceId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<WorkspaceMember>>;
2604
+ addMember(workspaceId: string, data: {
2605
+ user_id: string;
2606
+ role: string;
2607
+ }, options?: RequestOptions): Promise<ApiResponse<WorkspaceMember>>;
2608
+ updateMember(workspaceId: string, userId: string, data: {
2609
+ role: string;
2610
+ }, options?: RequestOptions): Promise<ApiResponse<WorkspaceMember>>;
2611
+ removeMember(workspaceId: string, userId: string, options?: RequestOptions): Promise<ApiResponse<{
2612
+ removed: boolean;
2613
+ }>>;
2614
+ invite(workspaceId: string, data: {
2615
+ email: string;
2616
+ role: string;
2617
+ }, options?: RequestOptions): Promise<ApiResponse<WorkspaceInvitation>>;
2618
+ listInvitations(workspaceId: string, options?: RequestOptions): Promise<ApiResponse<WorkspaceInvitation[]>>;
2619
+ acceptInvitation(token: string, options?: RequestOptions): Promise<ApiResponse<WorkspaceInvitation>>;
2620
+ cancelInvitation(id: string, options?: RequestOptions): Promise<ApiResponse<{
2621
+ cancelled: boolean;
2622
+ }>>;
2623
+ configureSso(workspaceId: string, data: {
2624
+ provider: string;
2625
+ domain: string;
2626
+ metadata_url?: string;
2627
+ }, options?: RequestOptions): Promise<ApiResponse<SsoConfig>>;
2628
+ getSso(workspaceId: string, options?: RequestOptions): Promise<ApiResponse<SsoConfig>>;
2629
+ }
2630
+
2631
+ /**
2632
+ * Teams Service Module
2633
+ *
2634
+ * Team CRUD, members, invitations.
2635
+ * Teams are membership/coordination groups (group people and agents; do not own resources).
2636
+ * SSO is NOT available for teams — use workspaces for SSO.
2637
+ *
2638
+ * Routes (via /v1/teams):
2639
+ * POST / → create team
2640
+ * GET / → list teams
2641
+ * GET /mine → list my teams
2642
+ * GET /{id} → get team
2643
+ * PATCH /{id} → update team
2644
+ * DELETE /{id} → delete team
2645
+ * GET /{id}/members → list members
2646
+ * POST /{id}/members → add member
2647
+ * PATCH /{id}/members/{userId} → update member role
2648
+ * DELETE /{id}/members/{userId} → remove member
2649
+ * POST /{id}/invitations → invite
2650
+ * GET /{id}/invitations → list invitations
2651
+ * POST /invitations/{token}/accept → accept invitation
2652
+ * DELETE /invitations/{id} → cancel invitation
2653
+ */
2654
+
2655
+ interface Team {
2656
+ id: string;
2657
+ kind: 'team';
2658
+ name: string;
2659
+ description?: string;
2660
+ owner_user_id: string;
2661
+ plan_type?: string;
2662
+ member_limit?: number;
2663
+ created_at: string;
2664
+ }
2665
+ interface TeamMember {
2666
+ id: string;
2667
+ container_id: string;
2668
+ sm_user_id: string;
2669
+ role: string;
2670
+ joined_at: string;
2671
+ full_name?: string;
2672
+ email?: string;
2673
+ avatar_url?: string;
2674
+ }
2675
+ interface TeamInvitation {
2676
+ id: string;
2677
+ container_id: string;
2678
+ email: string;
2679
+ invited_by: string;
2680
+ role: string;
2681
+ token?: string;
2682
+ status: string;
2683
+ expires_at: string;
2684
+ created_at: string;
2685
+ }
2578
2686
  declare class TeamsService extends ServiceModule {
2579
2687
  protected basePath: string;
2580
2688
  create(data: {
@@ -2611,19 +2719,6 @@ declare class TeamsService extends ServiceModule {
2611
2719
  cancelInvitation(id: string, options?: RequestOptions): Promise<ApiResponse<{
2612
2720
  cancelled: boolean;
2613
2721
  }>>;
2614
- configureSso(teamId: string, data: {
2615
- provider: string;
2616
- domain: string;
2617
- metadata_url?: string;
2618
- }, options?: RequestOptions): Promise<ApiResponse<SsoConfig>>;
2619
- getSso(teamId: string, options?: RequestOptions): Promise<ApiResponse<SsoConfig>>;
2620
- /** @deprecated Use create() instead */
2621
- createTeam(data: {
2622
- name: string;
2623
- description?: string;
2624
- }): Promise<ApiResponse<Team>>;
2625
- /** @deprecated Use invite() instead */
2626
- inviteMember(teamId: string, email: string, role: string): Promise<ApiResponse<TeamInvitation>>;
2627
2722
  }
2628
2723
 
2629
2724
  /**
@@ -4280,6 +4375,8 @@ interface ProjectGrant {
4280
4375
  expires_at: string;
4281
4376
  redeemed_at?: string;
4282
4377
  email_sent?: boolean;
4378
+ container_invitation_id?: string;
4379
+ /** @deprecated Use container_invitation_id */
4283
4380
  team_invitation_id?: string;
4284
4381
  }
4285
4382
  interface GrantInfo {
@@ -4397,7 +4494,11 @@ declare class AgentProjectsService extends ServiceModule {
4397
4494
  user_email: string;
4398
4495
  expires_at: string;
4399
4496
  invite_url?: string;
4497
+ container_invitation_id?: string;
4498
+ container_id?: string;
4499
+ /** @deprecated Use container_invitation_id */
4400
4500
  team_invitation_id?: string;
4501
+ /** @deprecated Use container_id */
4401
4502
  team_id?: string;
4402
4503
  }, options?: RequestOptions): Promise<ApiResponse<ProjectGrant>>;
4403
4504
  listGrants(projectId: string, options?: RequestOptions): Promise<ApiResponse<ProjectGrant[]>>;
@@ -4804,7 +4905,9 @@ declare class ScaleMule {
4804
4905
  readonly communication: CommunicationService;
4805
4906
  readonly scheduler: SchedulerService;
4806
4907
  readonly permissions: PermissionsService;
4807
- readonly teams: TeamsService;
4908
+ readonly workspaces: WorkspacesService;
4909
+ /** @deprecated Use `workspaces` instead */
4910
+ get teams(): WorkspacesService;
4808
4911
  readonly accounts: AccountsService;
4809
4912
  readonly identity: IdentityService;
4810
4913
  readonly catalog: CatalogService;
@@ -4853,8 +4956,12 @@ declare class ScaleMule {
4853
4956
  isAuthenticated(): boolean;
4854
4957
  /** The base URL being used for API requests. */
4855
4958
  getBaseUrl(): string;
4959
+ /** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
4960
+ setWorkspaceContext(id: string | null): void;
4961
+ /** Get the current workspace ID, or null. */
4962
+ getWorkspaceId(): string | null;
4856
4963
  /** Access the underlying ScaleMuleClient for advanced usage. */
4857
4964
  getClient(): ScaleMuleClient;
4858
4965
  }
4859
4966
 
4860
- 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, 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 CreateSessionResponse, 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 FlagCheck, FlagContentService, 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 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 MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, 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 PushToken, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type RedeemResult, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RequestOptions, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, 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 Severity, type ShortestPathResult, type SignedUrlResponse, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, type SubmitResult, type Subscription, 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 UploadCompleteResponse, type UploadEngineConfig, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, type Workspace, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, validateIP };
4967
+ 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 CreateSessionResponse, 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 FlagCheck, FlagContentService, 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 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 MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, 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 PushToken, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type RedeemResult, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RequestOptions, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, 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 Severity, type ShortestPathResult, type SignedUrlResponse, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, type SubmitResult, type Subscription, 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 UploadCompleteResponse, type UploadEngineConfig, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, 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, validateIP };
package/dist/index.js CHANGED
@@ -337,6 +337,7 @@ __export(index_exports, {
337
337
  UploadTelemetry: () => UploadTelemetry,
338
338
  VideoService: () => VideoService,
339
339
  WebhooksService: () => WebhooksService,
340
+ WorkspacesService: () => WorkspacesService,
340
341
  buildClientContextHeaders: () => buildClientContextHeaders,
341
342
  calculateTotalParts: () => calculateTotalParts,
342
343
  canPerform: () => canPerform,
@@ -462,6 +463,7 @@ var MAX_BACKOFF_MS = 3e4;
462
463
  var SESSION_STORAGE_KEY = "scalemule_session";
463
464
  var USER_ID_STORAGE_KEY = "scalemule_user_id";
464
465
  var OFFLINE_QUEUE_KEY = "scalemule_offline_queue";
466
+ var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
465
467
  var GATEWAY_URLS = {
466
468
  dev: "https://api-dev.scalemule.com",
467
469
  prod: "https://api.scalemule.com"
@@ -653,6 +655,7 @@ var ScaleMuleClient = class {
653
655
  this.userId = null;
654
656
  this.rateLimitQueue = null;
655
657
  this.offlineQueue = null;
658
+ this.workspaceId = null;
656
659
  this.apiKey = config.apiKey;
657
660
  this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
658
661
  this.debug = config.debug || false;
@@ -676,6 +679,8 @@ var ScaleMuleClient = class {
676
679
  const userId = await this.storage.getItem(USER_ID_STORAGE_KEY);
677
680
  if (token) this.sessionToken = token;
678
681
  if (userId) this.userId = userId;
682
+ const wsId = await this.storage.getItem(WORKSPACE_STORAGE_KEY);
683
+ if (wsId) this.workspaceId = wsId;
679
684
  if (this.debug) console.log("[ScaleMule] Initialized, session:", !!token);
680
685
  }
681
686
  async setSession(token, userId) {
@@ -687,8 +692,10 @@ var ScaleMuleClient = class {
687
692
  async clearSession() {
688
693
  this.sessionToken = null;
689
694
  this.userId = null;
695
+ this.workspaceId = null;
690
696
  await this.storage.removeItem(SESSION_STORAGE_KEY);
691
697
  await this.storage.removeItem(USER_ID_STORAGE_KEY);
698
+ await this.storage.removeItem(WORKSPACE_STORAGE_KEY);
692
699
  }
693
700
  setAccessToken(token) {
694
701
  this.sessionToken = token;
@@ -724,6 +731,17 @@ var ScaleMuleClient = class {
724
731
  isRateLimited() {
725
732
  return this.rateLimitQueue?.isRateLimited || false;
726
733
  }
734
+ setWorkspaceContext(id) {
735
+ this.workspaceId = id;
736
+ if (id) {
737
+ this.storage.setItem(WORKSPACE_STORAGE_KEY, id);
738
+ } else {
739
+ this.storage.removeItem(WORKSPACE_STORAGE_KEY);
740
+ }
741
+ }
742
+ getWorkspaceId() {
743
+ return this.workspaceId;
744
+ }
727
745
  // --------------------------------------------------------------------------
728
746
  // Core Request Method
729
747
  // --------------------------------------------------------------------------
@@ -740,6 +758,9 @@ var ScaleMuleClient = class {
740
758
  if (!init.skipAuth && this.sessionToken) {
741
759
  headers["Authorization"] = `Bearer ${this.sessionToken}`;
742
760
  }
761
+ if (this.workspaceId) {
762
+ headers["x-sm-workspace-id"] = this.workspaceId;
763
+ }
743
764
  let bodyStr;
744
765
  if (init.body !== void 0 && init.body !== null) {
745
766
  bodyStr = typeof init.body === "string" ? init.body : JSON.stringify(init.body);
@@ -891,6 +912,7 @@ var ScaleMuleClient = class {
891
912
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
892
913
  const headers = { "x-api-key": this.apiKey };
893
914
  if (this.sessionToken) headers["Authorization"] = `Bearer ${this.sessionToken}`;
915
+ if (this.workspaceId) headers["x-sm-workspace-id"] = this.workspaceId;
894
916
  try {
895
917
  const response = await fetch(url, {
896
918
  method: "POST",
@@ -985,6 +1007,9 @@ var ScaleMuleClient = class {
985
1007
  if (this.sessionToken) {
986
1008
  xhr.setRequestHeader("Authorization", `Bearer ${this.sessionToken}`);
987
1009
  }
1010
+ if (this.workspaceId) {
1011
+ xhr.setRequestHeader("x-sm-workspace-id", this.workspaceId);
1012
+ }
988
1013
  xhr.send(buildFormData());
989
1014
  });
990
1015
  if (result.error === null) {
@@ -3904,6 +3929,74 @@ var PermissionsService = class extends ServiceModule {
3904
3929
  }
3905
3930
  };
3906
3931
 
3932
+ // src/services/workspaces.ts
3933
+ var WorkspacesService = class extends ServiceModule {
3934
+ constructor() {
3935
+ super(...arguments);
3936
+ this.basePath = "/v1/workspaces";
3937
+ }
3938
+ // --------------------------------------------------------------------------
3939
+ // Workspace CRUD
3940
+ // --------------------------------------------------------------------------
3941
+ async create(data, options) {
3942
+ return this.post("", data, options);
3943
+ }
3944
+ async list(params, requestOptions) {
3945
+ return this._list("", params, requestOptions);
3946
+ }
3947
+ async mine(params, options) {
3948
+ return this._list("/mine", params, options);
3949
+ }
3950
+ async get(id, options) {
3951
+ return this._get(`/${id}`, options);
3952
+ }
3953
+ async update(id, data, options) {
3954
+ return this.patch(`/${id}`, data, options);
3955
+ }
3956
+ async delete(id, options) {
3957
+ return this.del(`/${id}`, options);
3958
+ }
3959
+ // --------------------------------------------------------------------------
3960
+ // Members
3961
+ // --------------------------------------------------------------------------
3962
+ async listMembers(workspaceId, params, requestOptions) {
3963
+ return this._list(`/${workspaceId}/members`, params, requestOptions);
3964
+ }
3965
+ async addMember(workspaceId, data, options) {
3966
+ return this.post(`/${workspaceId}/members`, data, options);
3967
+ }
3968
+ async updateMember(workspaceId, userId, data, options) {
3969
+ return this.patch(`/${workspaceId}/members/${userId}`, data, options);
3970
+ }
3971
+ async removeMember(workspaceId, userId, options) {
3972
+ return this.del(`/${workspaceId}/members/${userId}`, options);
3973
+ }
3974
+ // --------------------------------------------------------------------------
3975
+ // Invitations
3976
+ // --------------------------------------------------------------------------
3977
+ async invite(workspaceId, data, options) {
3978
+ return this.post(`/${workspaceId}/invitations`, data, options);
3979
+ }
3980
+ async listInvitations(workspaceId, options) {
3981
+ return this._get(`/${workspaceId}/invitations`, options);
3982
+ }
3983
+ async acceptInvitation(token, options) {
3984
+ return this.post(`/invitations/${token}/accept`, void 0, options);
3985
+ }
3986
+ async cancelInvitation(id, options) {
3987
+ return this.del(`/invitations/${id}`, options);
3988
+ }
3989
+ // --------------------------------------------------------------------------
3990
+ // SSO (workspace-only)
3991
+ // --------------------------------------------------------------------------
3992
+ async configureSso(workspaceId, data, options) {
3993
+ return this.post(`/${workspaceId}/sso/configure`, data, options);
3994
+ }
3995
+ async getSso(workspaceId, options) {
3996
+ return this._get(`/${workspaceId}/sso`, options);
3997
+ }
3998
+ };
3999
+
3907
4000
  // src/services/teams.ts
3908
4001
  var TeamsService = class extends ServiceModule {
3909
4002
  constructor() {
@@ -3961,26 +4054,6 @@ var TeamsService = class extends ServiceModule {
3961
4054
  async cancelInvitation(id, options) {
3962
4055
  return this.del(`/invitations/${id}`, options);
3963
4056
  }
3964
- // --------------------------------------------------------------------------
3965
- // SSO
3966
- // --------------------------------------------------------------------------
3967
- async configureSso(teamId, data, options) {
3968
- return this.post(`/${teamId}/sso/configure`, data, options);
3969
- }
3970
- async getSso(teamId, options) {
3971
- return this._get(`/${teamId}/sso`, options);
3972
- }
3973
- // --------------------------------------------------------------------------
3974
- // Legacy methods (backward compat)
3975
- // --------------------------------------------------------------------------
3976
- /** @deprecated Use create() instead */
3977
- async createTeam(data) {
3978
- return this.create(data);
3979
- }
3980
- /** @deprecated Use invite() instead */
3981
- async inviteMember(teamId, email, role) {
3982
- return this.invite(teamId, { email, role });
3983
- }
3984
4057
  };
3985
4058
 
3986
4059
  // src/services/graph.ts
@@ -5102,6 +5175,10 @@ var AgentSessionsService = class extends ServiceModule {
5102
5175
 
5103
5176
  // src/index.ts
5104
5177
  var ScaleMule = class {
5178
+ /** @deprecated Use `workspaces` instead */
5179
+ get teams() {
5180
+ return this.workspaces;
5181
+ }
5105
5182
  constructor(config) {
5106
5183
  this._client = new ScaleMuleClient(config);
5107
5184
  this.auth = new AuthService(this._client);
@@ -5116,7 +5193,7 @@ var ScaleMule = class {
5116
5193
  this.communication = new CommunicationService(this._client);
5117
5194
  this.scheduler = new SchedulerService(this._client);
5118
5195
  this.permissions = new PermissionsService(this._client);
5119
- this.teams = new TeamsService(this._client);
5196
+ this.workspaces = new WorkspacesService(this._client);
5120
5197
  this.accounts = new AccountsService(this._client);
5121
5198
  this.identity = new IdentityService(this._client);
5122
5199
  this.catalog = new CatalogService(this._client);
@@ -5183,6 +5260,14 @@ var ScaleMule = class {
5183
5260
  getBaseUrl() {
5184
5261
  return this._client.getBaseUrl();
5185
5262
  }
5263
+ /** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
5264
+ setWorkspaceContext(id) {
5265
+ this._client.setWorkspaceContext(id);
5266
+ }
5267
+ /** Get the current workspace ID, or null. */
5268
+ getWorkspaceId() {
5269
+ return this._client.getWorkspaceId();
5270
+ }
5186
5271
  /** Access the underlying ScaleMuleClient for advanced usage. */
5187
5272
  getClient() {
5188
5273
  return this._client;
@@ -5235,6 +5320,7 @@ var index_default = ScaleMule;
5235
5320
  UploadTelemetry,
5236
5321
  VideoService,
5237
5322
  WebhooksService,
5323
+ WorkspacesService,
5238
5324
  buildClientContextHeaders,
5239
5325
  calculateTotalParts,
5240
5326
  canPerform,
package/dist/index.mjs CHANGED
@@ -103,6 +103,7 @@ var MAX_BACKOFF_MS = 3e4;
103
103
  var SESSION_STORAGE_KEY = "scalemule_session";
104
104
  var USER_ID_STORAGE_KEY = "scalemule_user_id";
105
105
  var OFFLINE_QUEUE_KEY = "scalemule_offline_queue";
106
+ var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
106
107
  var GATEWAY_URLS = {
107
108
  dev: "https://api-dev.scalemule.com",
108
109
  prod: "https://api.scalemule.com"
@@ -294,6 +295,7 @@ var ScaleMuleClient = class {
294
295
  this.userId = null;
295
296
  this.rateLimitQueue = null;
296
297
  this.offlineQueue = null;
298
+ this.workspaceId = null;
297
299
  this.apiKey = config.apiKey;
298
300
  this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
299
301
  this.debug = config.debug || false;
@@ -317,6 +319,8 @@ var ScaleMuleClient = class {
317
319
  const userId = await this.storage.getItem(USER_ID_STORAGE_KEY);
318
320
  if (token) this.sessionToken = token;
319
321
  if (userId) this.userId = userId;
322
+ const wsId = await this.storage.getItem(WORKSPACE_STORAGE_KEY);
323
+ if (wsId) this.workspaceId = wsId;
320
324
  if (this.debug) console.log("[ScaleMule] Initialized, session:", !!token);
321
325
  }
322
326
  async setSession(token, userId) {
@@ -328,8 +332,10 @@ var ScaleMuleClient = class {
328
332
  async clearSession() {
329
333
  this.sessionToken = null;
330
334
  this.userId = null;
335
+ this.workspaceId = null;
331
336
  await this.storage.removeItem(SESSION_STORAGE_KEY);
332
337
  await this.storage.removeItem(USER_ID_STORAGE_KEY);
338
+ await this.storage.removeItem(WORKSPACE_STORAGE_KEY);
333
339
  }
334
340
  setAccessToken(token) {
335
341
  this.sessionToken = token;
@@ -365,6 +371,17 @@ var ScaleMuleClient = class {
365
371
  isRateLimited() {
366
372
  return this.rateLimitQueue?.isRateLimited || false;
367
373
  }
374
+ setWorkspaceContext(id) {
375
+ this.workspaceId = id;
376
+ if (id) {
377
+ this.storage.setItem(WORKSPACE_STORAGE_KEY, id);
378
+ } else {
379
+ this.storage.removeItem(WORKSPACE_STORAGE_KEY);
380
+ }
381
+ }
382
+ getWorkspaceId() {
383
+ return this.workspaceId;
384
+ }
368
385
  // --------------------------------------------------------------------------
369
386
  // Core Request Method
370
387
  // --------------------------------------------------------------------------
@@ -381,6 +398,9 @@ var ScaleMuleClient = class {
381
398
  if (!init.skipAuth && this.sessionToken) {
382
399
  headers["Authorization"] = `Bearer ${this.sessionToken}`;
383
400
  }
401
+ if (this.workspaceId) {
402
+ headers["x-sm-workspace-id"] = this.workspaceId;
403
+ }
384
404
  let bodyStr;
385
405
  if (init.body !== void 0 && init.body !== null) {
386
406
  bodyStr = typeof init.body === "string" ? init.body : JSON.stringify(init.body);
@@ -532,6 +552,7 @@ var ScaleMuleClient = class {
532
552
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
533
553
  const headers = { "x-api-key": this.apiKey };
534
554
  if (this.sessionToken) headers["Authorization"] = `Bearer ${this.sessionToken}`;
555
+ if (this.workspaceId) headers["x-sm-workspace-id"] = this.workspaceId;
535
556
  try {
536
557
  const response = await fetch(url, {
537
558
  method: "POST",
@@ -626,6 +647,9 @@ var ScaleMuleClient = class {
626
647
  if (this.sessionToken) {
627
648
  xhr.setRequestHeader("Authorization", `Bearer ${this.sessionToken}`);
628
649
  }
650
+ if (this.workspaceId) {
651
+ xhr.setRequestHeader("x-sm-workspace-id", this.workspaceId);
652
+ }
629
653
  xhr.send(buildFormData());
630
654
  });
631
655
  if (result.error === null) {
@@ -3552,6 +3576,74 @@ var PermissionsService = class extends ServiceModule {
3552
3576
  }
3553
3577
  };
3554
3578
 
3579
+ // src/services/workspaces.ts
3580
+ var WorkspacesService = class extends ServiceModule {
3581
+ constructor() {
3582
+ super(...arguments);
3583
+ this.basePath = "/v1/workspaces";
3584
+ }
3585
+ // --------------------------------------------------------------------------
3586
+ // Workspace CRUD
3587
+ // --------------------------------------------------------------------------
3588
+ async create(data, options) {
3589
+ return this.post("", data, options);
3590
+ }
3591
+ async list(params, requestOptions) {
3592
+ return this._list("", params, requestOptions);
3593
+ }
3594
+ async mine(params, options) {
3595
+ return this._list("/mine", params, options);
3596
+ }
3597
+ async get(id, options) {
3598
+ return this._get(`/${id}`, options);
3599
+ }
3600
+ async update(id, data, options) {
3601
+ return this.patch(`/${id}`, data, options);
3602
+ }
3603
+ async delete(id, options) {
3604
+ return this.del(`/${id}`, options);
3605
+ }
3606
+ // --------------------------------------------------------------------------
3607
+ // Members
3608
+ // --------------------------------------------------------------------------
3609
+ async listMembers(workspaceId, params, requestOptions) {
3610
+ return this._list(`/${workspaceId}/members`, params, requestOptions);
3611
+ }
3612
+ async addMember(workspaceId, data, options) {
3613
+ return this.post(`/${workspaceId}/members`, data, options);
3614
+ }
3615
+ async updateMember(workspaceId, userId, data, options) {
3616
+ return this.patch(`/${workspaceId}/members/${userId}`, data, options);
3617
+ }
3618
+ async removeMember(workspaceId, userId, options) {
3619
+ return this.del(`/${workspaceId}/members/${userId}`, options);
3620
+ }
3621
+ // --------------------------------------------------------------------------
3622
+ // Invitations
3623
+ // --------------------------------------------------------------------------
3624
+ async invite(workspaceId, data, options) {
3625
+ return this.post(`/${workspaceId}/invitations`, data, options);
3626
+ }
3627
+ async listInvitations(workspaceId, options) {
3628
+ return this._get(`/${workspaceId}/invitations`, options);
3629
+ }
3630
+ async acceptInvitation(token, options) {
3631
+ return this.post(`/invitations/${token}/accept`, void 0, options);
3632
+ }
3633
+ async cancelInvitation(id, options) {
3634
+ return this.del(`/invitations/${id}`, options);
3635
+ }
3636
+ // --------------------------------------------------------------------------
3637
+ // SSO (workspace-only)
3638
+ // --------------------------------------------------------------------------
3639
+ async configureSso(workspaceId, data, options) {
3640
+ return this.post(`/${workspaceId}/sso/configure`, data, options);
3641
+ }
3642
+ async getSso(workspaceId, options) {
3643
+ return this._get(`/${workspaceId}/sso`, options);
3644
+ }
3645
+ };
3646
+
3555
3647
  // src/services/teams.ts
3556
3648
  var TeamsService = class extends ServiceModule {
3557
3649
  constructor() {
@@ -3609,26 +3701,6 @@ var TeamsService = class extends ServiceModule {
3609
3701
  async cancelInvitation(id, options) {
3610
3702
  return this.del(`/invitations/${id}`, options);
3611
3703
  }
3612
- // --------------------------------------------------------------------------
3613
- // SSO
3614
- // --------------------------------------------------------------------------
3615
- async configureSso(teamId, data, options) {
3616
- return this.post(`/${teamId}/sso/configure`, data, options);
3617
- }
3618
- async getSso(teamId, options) {
3619
- return this._get(`/${teamId}/sso`, options);
3620
- }
3621
- // --------------------------------------------------------------------------
3622
- // Legacy methods (backward compat)
3623
- // --------------------------------------------------------------------------
3624
- /** @deprecated Use create() instead */
3625
- async createTeam(data) {
3626
- return this.create(data);
3627
- }
3628
- /** @deprecated Use invite() instead */
3629
- async inviteMember(teamId, email, role) {
3630
- return this.invite(teamId, { email, role });
3631
- }
3632
3704
  };
3633
3705
 
3634
3706
  // src/services/graph.ts
@@ -4750,6 +4822,10 @@ var AgentSessionsService = class extends ServiceModule {
4750
4822
 
4751
4823
  // src/index.ts
4752
4824
  var ScaleMule = class {
4825
+ /** @deprecated Use `workspaces` instead */
4826
+ get teams() {
4827
+ return this.workspaces;
4828
+ }
4753
4829
  constructor(config) {
4754
4830
  this._client = new ScaleMuleClient(config);
4755
4831
  this.auth = new AuthService(this._client);
@@ -4764,7 +4840,7 @@ var ScaleMule = class {
4764
4840
  this.communication = new CommunicationService(this._client);
4765
4841
  this.scheduler = new SchedulerService(this._client);
4766
4842
  this.permissions = new PermissionsService(this._client);
4767
- this.teams = new TeamsService(this._client);
4843
+ this.workspaces = new WorkspacesService(this._client);
4768
4844
  this.accounts = new AccountsService(this._client);
4769
4845
  this.identity = new IdentityService(this._client);
4770
4846
  this.catalog = new CatalogService(this._client);
@@ -4831,6 +4907,14 @@ var ScaleMule = class {
4831
4907
  getBaseUrl() {
4832
4908
  return this._client.getBaseUrl();
4833
4909
  }
4910
+ /** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
4911
+ setWorkspaceContext(id) {
4912
+ this._client.setWorkspaceContext(id);
4913
+ }
4914
+ /** Get the current workspace ID, or null. */
4915
+ getWorkspaceId() {
4916
+ return this._client.getWorkspaceId();
4917
+ }
4834
4918
  /** Access the underlying ScaleMuleClient for advanced usage. */
4835
4919
  getClient() {
4836
4920
  return this._client;
@@ -4882,6 +4966,7 @@ export {
4882
4966
  UploadTelemetry,
4883
4967
  VideoService,
4884
4968
  WebhooksService,
4969
+ WorkspacesService,
4885
4970
  buildClientContextHeaders,
4886
4971
  calculateTotalParts,
4887
4972
  canPerform,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalemule/sdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.10",
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",