Skip to content
symbo-lsPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

@symbo.ls/sdk

npm version npm downloads bundle size license node ESM

Official SDK for the Symbols design platform — manage projects, collaborate in real-time, handle branches, pull requests, organizations, workspaces, credits, and more.

Looking for a complete machine-readable reference? See SDK_FOR_MCP.md — every service, every public method, every event, designed for MCP servers and automation agents.

Installation

npm install @symbo.ls/sdk

Basic Usage

Initialize SDK

import { SDK } from '@symbo.ls/sdk'

const sdk = new SDK({
  apiUrl: 'https://api.symbols.app',
  socketUrl: 'https://api.symbols.app',
  timeout: 30000,
  debug: false
})

await sdk.initialize({
  authToken: 'your-auth-token',
  appKey: 'your-app-key'
})

Service Access

const auth = sdk.getService('auth')
const project = sdk.getService('project')
const branch = sdk.getService('branch')
const pullRequest = sdk.getService('pullRequest')
const collab = sdk.getService('collab')
const file = sdk.getService('file')
const payment = sdk.getService('payment')
const plan = sdk.getService('plan')
const subscription = sdk.getService('subscription')
const dns = sdk.getService('dns')
const admin = sdk.getService('admin')
const screenshot = sdk.getService('screenshot')
const tracking = sdk.getService('tracking')
const waitlist = sdk.getService('waitlist')
const metrics = sdk.getService('metrics')
const integration = sdk.getService('integration')
const featureFlag = sdk.getService('featureFlag')
const organization = sdk.getService('organization')
const workspace = sdk.getService('workspace')
const workspaceData = sdk.getService('workspaceData')
const kv = sdk.getService('kv')
const allocationRule = sdk.getService('allocationRule')
const sharedAsset = sdk.getService('sharedAsset')
const credits = sdk.getService('credits')

All service methods are also available directly on the SDK instance via proxy methods:

// These are equivalent:
sdk.getService('project').getProject(projectId)
sdk.getProject(projectId)

Status & Context

// Check if SDK is ready
sdk.isReady()

// Get detailed status
const status = sdk.getStatus()
// { ready: true, services: [...], context: {...} }

// Update context
sdk.updateContext({ ... })

// Cleanup
await sdk.destroy()

Root Event Bus

The SDK exposes a global event bus for cross-service communication:

sdk.rootBus.on('checkpoint:done', (payload) => { ... })
sdk.rootBus.on('clients:updated', (payload) => { ... })
sdk.rootBus.on('bundle:done', (payload) => { ... })
sdk.rootBus.on('bundle:error', (payload) => { ... })

Services

Auth Service

Authentication:

const auth = sdk.getService('auth')

await auth.register(userData, options)
await auth.login(email, password, options)
await auth.logout()
await auth.refreshToken(refreshToken)
await auth.googleAuth(idToken, inviteToken, options)
await auth.googleAuthCallback(code, redirectUri, inviteToken, options)
await auth.githubAuth(code, inviteToken, options)
await auth.requestPasswordReset(email)
await auth.confirmPasswordReset(token, password)
await auth.confirmRegistration(token)
await auth.requestPasswordChange()
await auth.confirmPasswordChange(currentPassword, newPassword, code)

Sign-up intent. register and updateMe forward their body verbatim; the server validates the intent. An e-mail sign-up carries it on the register body; a Google / GitHub sign-up sends it once after sign-in through updateMe (the OAuth routes read no intent). acquisition.visitor is the page's analytics visitor id (window.SymbolsAnalytics.visitorId) — the one stitch from an anonymous visitor to the account.

await auth.register({ email, password, name, preset, acquisition: { visitor, source, campaign, plan } })
await sdk.updateMe({ signupIntent: { preset, acquisition: { visitor, source, campaign, plan } } })

Sign-up policy. What a sign-up form shows before the person types, read from the server instead of a copy: the password rule it enforces, whether a new account's first build is free, and the AI credits a new workspace gets. Public (no session needed, no token sent); the server's bare object.

const { password, firstBuildFree, signupCredits } = await sdk.getSignupPolicy()
// password: { minLength, lower, upper, digit, special }

User Data:

await auth.getMe(options)
auth.getStoredAuthState()
auth.getAuthToken()
auth.getUserProfile()
await auth.updateUserProfile(profileData)
await auth.getUserProjects()
await auth.getUser(userId)
await auth.getUserByEmail(email)
auth.isAuthenticated()
auth.hasValidTokens()
auth.getCurrentUser()

Project Roles:

await auth.getMyProjectRole(projectId)       // cached
await auth.getMyProjectRoleByKey(projectKey)  // cached
await auth.getProjectRoleWithFallback(projectId, userProjects)
await auth.getProjectRoleByKeyWithFallback(projectKey, userProjects)
auth.clearProjectRoleCache(projectId)

Cross-Org Reads:

await auth.getMyOrgNotifications()        // badge counts for org switcher
await auth.getMyFreebusy({ from, to })    // unified calendar busy slots
await auth.getMyProjects()                // every project across every org
await auth.getMyTeams()                   // every team grouped by org
await auth.getMyOrgMemberships()          // workspace switcher source
await auth.getOrgMemberRoles(orgId)       // People page enrichment
await auth.resendVerification()
await auth.verifyEmail(token)

Permissions:

auth.hasPermission(requiredPermission)
auth.hasGlobalPermission(globalRole, requiredPermission)
auth.checkProjectPermission(projectRole, requiredPermission)
auth.checkProjectFeature(projectTier, feature)
await auth.canPerformOperation(projectId, operation, options)
await auth.withPermission(projectId, operation, action)

Project Service

Project Management:

const project = sdk.getService('project')

await project.createProject(projectData)
await project.getProjects(params)
await project.getProject(projectId)
await project.getProjectByKey(key)
await project.getProjectDataByKey(key, options)
await project.getPublicProject(projectId)
await project.listPublicProjects(params)
await project.updateProject(projectId, data)
await project.updateProjectComponents(projectId, components)
await project.updateProjectSettings(projectId, settings)
await project.updateProjectName(projectId, name)
await project.updateProjectPackage(projectId, pkg)
await project.duplicateProject(projectId, newName, newKey, targetUserId)
await project.removeProject(projectId)
await project.transferProjectOwnership(projectId, { targetType, userId, organizationId })
await project.transferProjectToWorkspace(projectId, targetWorkspaceId)
await project.checkProjectKeyAvailability(key)

Granular Reads:

await project.getProjectComponents(projectId)
await project.getProjectFunctions(projectId)
await project.getProjectPages(projectId)
await project.getProjectComponentsByKey(projectKey)
await project.getProjectFunctionsByKey(projectKey)
await project.getProjectPagesByKey(projectKey)

Role Permissions Config:

await project.getProjectRolePermissionsConfig(projectId, options)
await project.updateProjectRolePermissionsConfig(projectId, rolePermissions, options)

Members:

await project.getProjectMembers(projectId)
await project.inviteMember(projectId, email, role, options)
await project.createMagicInviteLink(projectId, options)
await project.acceptInvite(token)
await project.updateMemberRole(projectId, memberId, role)
await project.removeMember(projectId, memberId)

Libraries:

await project.getAvailableLibraries(params)
await project.getProjectLibraries(projectId)
await project.addProjectLibraries(projectId, libraryIds)
await project.removeProjectLibraries(projectId, libraryIds)

Project Data (Version Control):

await project.applyProjectChanges(projectId, changes, options)
// changes: [['update', ['components', 'Button'], { color: 'blue' }], ['delete', ['pages', 'old']]]
// options: { message: 'Update button', type: 'patch' }

await project.getProjectData(projectId, options)
await project.getProjectVersions(projectId, options)
await project.restoreProjectVersion(projectId, version, options)
await project.updateProjectItem(projectId, path, value, options)
await project.deleteProjectItem(projectId, path, options)
await project.setProjectValue(projectId, path, value, options)
await project.addProjectItems(projectId, items, options)
await project.getProjectItemByPath(projectId, path, options)

Environments:

await project.listEnvironments(projectId, options)
await project.upsertEnvironment(projectId, envKey, config, options)
await project.updateEnvironment(projectId, envKey, updates, options)
await project.publishToEnvironment(projectId, envKey, payload, options)
await project.deleteEnvironment(projectId, envKey, options)
await project.promoteEnvironment(projectId, fromEnvKey, toEnvKey, options)

Favorites & Recent:

await project.getFavoriteProjects()
await project.addFavoriteProject(projectId)
await project.removeFavoriteProject(projectId)
await project.getRecentProjects(options)

Access Control:

await project.setProjectAccess(projectId, access)         // account/team/organization/public
await project.setProjectVisibility(projectId, visibility) // public/private/password-protected
await project.setProjectSourceAccess(projectId, source)   // public/org/workspace/restricted

Admin Project Ownership:

await project.listProjectOwnership(params)
await project.assignProjectOwner(args)
await project.autoAssignProjectOwners(args)

Branch Service

const branch = sdk.getService('branch')

await branch.listBranches(projectId)
await branch.createBranch(projectId, branchData)
await branch.deleteBranch(projectId, branchName)
await branch.renameBranch(projectId, branchName, newName)
await branch.getBranchChanges(projectId, branchName, options)
await branch.mergeBranch(projectId, branchName, mergeData)
await branch.resetBranch(projectId, branchName)
await branch.publishVersion(projectId, publishData)

// Helper methods
await branch.createFeatureBranch(projectId, featureName)  // creates 'feature/<name>'
await branch.createHotfixBranch(projectId, hotfixName)
await branch.branchExists(projectId, branchName)
await branch.previewMerge(projectId, sourceBranch, targetBranch)
await branch.commitMerge(projectId, sourceBranch, options)
await branch.getBranchStatus(projectId, branchName)
await branch.deleteBranchSafely(projectId, branchName, options)
await branch.getBranchesWithStatus(projectId)
branch.validateBranchName(branchName)
branch.sanitizeBranchName(branchName)

Pull Request Service

const pr = sdk.getService('pullRequest')

await pr.createPullRequest(projectId, pullRequestData)
await pr.listPullRequests(projectId, options)
await pr.getPullRequest(projectId, prId)
await pr.reviewPullRequest(projectId, prId, reviewData)
await pr.addPullRequestComment(projectId, prId, commentData)
await pr.mergePullRequest(projectId, prId)
await pr.getPullRequestDiff(projectId, prId)
await pr.closePullRequest(projectId, prId)
await pr.reopenPullRequest(projectId, prId)

// Helper methods
await pr.approvePullRequest(projectId, prId, comment)
await pr.requestPullRequestChanges(projectId, prId, threads)
await pr.getOpenPullRequests(projectId, options)
await pr.getClosedPullRequests(projectId, options)
await pr.getMergedPullRequests(projectId, options)
await pr.isPullRequestMergeable(projectId, prId)
await pr.getPullRequestStatusSummary(projectId, prId)
await pr.getPullRequestStats(projectId, options)

Collab Service

Real-time collaboration via WebSocket and Yjs.

const collab = sdk.getService('collab')

// Connection
await collab.connect({ projectId, branch, authToken })
collab.disconnect()
collab.isConnected()
collab.getConnectionInfo()

// Data updates
collab.updateData(tuples, options)
collab.addItem(type, data, opts)
collab.addMultipleItems(items, opts)
collab.updateItem(type, data, opts)
collab.deleteItem(type, key, opts)

// Undo/Redo
collab.undo()
collab.redo()
collab.canUndo()
collab.canRedo()
collab.getUndoStackSize()
collab.getRedoStackSize()
collab.clearUndoHistory()
collab.checkpoint()

// Presence
collab.sendCursor(data)
collab.sendPresence(data)
collab.toggleLive(flag)

// Accessors
collab.ydoc   // Yjs document
collab.socket  // Socket instance

File Service

const file = sdk.getService('file')

await file.uploadFile(file, options)
await file.updateProjectIcon(projectId, iconFile)
await file.uploadImage(imageFile, options)
await file.uploadDocument(documentFile, options)
await file.uploadMultipleFiles(files, options)
file.getFileUrl(fileId)
file.validateFile(file, options)

Payment Service

const payment = sdk.getService('payment')

await payment.checkout(options)
await payment.getSubscriptionStatus(projectId)
await payment.hasActiveSubscription(projectId)
await payment.getSubscriptionDetails(projectId)
await payment.checkoutForPlan(options)
await payment.checkoutForTeam(options)
await payment.getSubscriptionSummary(projectId)

Plan Service

const plan = sdk.getService('plan')

// Public (no auth required)
await plan.getPlans()
await plan.getPlan(planId)
await plan.getPlansWithPricing()
await plan.getPlanByKey(key)
await plan.getActivePlans()
await plan.getPlansByPriceRange(minPrice, maxPrice)

// Admin
await plan.getAdminPlans()
await plan.createPlan(planData)
await plan.updatePlan(planId, planData)
await plan.deletePlan(planId)
await plan.initializePlans()

Subscription Service

const subscription = sdk.getService('subscription')

await subscription.createSubscription(subscriptionData)
await subscription.getProjectStatus(projectId)
await subscription.getUsage(subscriptionId)
await subscription.cancelSubscription(subscriptionId)
await subscription.listInvoices(subscriptionId, options)
await subscription.getPortalUrl(projectId)
await subscription.getProjectSubscription(projectId)
await subscription.getProjectUsage(projectId)
await subscription.hasActiveSubscription(projectId)
await subscription.changeSubscription(projectId, planId)
await subscription.downgrade(projectId)

DNS Service

const dns = sdk.getService('dns')

await dns.createDnsRecord(domain, options)
await dns.getDnsRecord(domain)
await dns.removeDnsRecord(domain)
await dns.getCustomHost(hostname)
await dns.addProjectCustomDomains(projectId, customDomains, options)
await dns.addProjectCustomDomain(projectId, domain, { envKey })
await dns.checkProjectDomain(projectId, domain)
await dns.checkProjectCustomDomain(projectId, domain)
await dns.getProjectCustomDomainStatus(projectId, domain)
await dns.getProjectDomainInstructions(projectId, domain)
await dns.getProjectCustomDomainInstructions(projectId, domain)
await dns.startProjectCustomDomainSetup(projectId, domain, { envKey })
await dns.pollProjectCustomDomainStatus(projectId, domain, { timeoutMs, intervalMs })
await dns.isDomainAvailable(domain)
await dns.getDomainStatus(domain)
await dns.verifyDomainOwnership(domain)
await dns.getProjectDomains(projectId)
await dns.removeProjectCustomDomain(projectId, domain)
dns.validateDomain(domain)
dns.formatDomain(domain)
dns.extractDomainFromUrl(url)

Custom-domain onboarding should use the API-owned workflow:

const dns = sdk.getService('dns')

// 1. Preflight check for exact DNS records and current state.
const check = await dns.checkProjectDomain(projectId, 'www.customer.com')

// 2. Start setup. This provisions the Cloudflare Custom Hostname and
// returns the selected onboarding row for immediate UI rendering.
const setup = await dns.startProjectCustomDomainSetup(projectId, 'www.customer.com', {
  envKey: 'production'
})

// 3. Poll while the customer updates DNS.
const status = await dns.pollProjectCustomDomainStatus(projectId, 'www.customer.com', {
  timeoutMs: 120000,
  intervalMs: 2000
})

// 4. Remove if the user disconnects the domain.
await dns.removeProjectCustomDomain(projectId, 'www.customer.com')

// Stable server errors are preserved on thrown errors.
try {
  await dns.addProjectCustomDomain(projectId, 'www.customer.com')
} catch (err) {
  if (err.code === 'domain_already_claimed') {
    console.log(err.conflicts)
  }
}

void check
void setup
void status

Admin Service

const admin = sdk.getService('admin')

await admin.getAdminUsers(params)
await admin.updateUser(userId, userData)
await admin.searchAdminUsers(searchQuery, options)
await admin.getAdminUsersByEmails(emails)
await admin.getAdminUsersByIds(ids)
await admin.assignProjectsToUser(userId, options)
await admin.assignSpecificProjectsToUser(userId, projectIds, role)
await admin.assignAllProjectsToUser(userId, role)
await admin.getUserStats(userId)
await admin.bulkUpdateUsers(updates)
await admin.getUsersByRole(role)
await admin.getUsersByStatus(status)
await admin.activateUser(userId)
await admin.deactivateUser(userId)
await admin.suspendUser(userId)
await admin.promoteToAdmin(userId)
await admin.demoteFromAdmin(userId)

Screenshot Service

const screenshot = sdk.getService('screenshot')

await screenshot.createScreenshotProject(payload)
await screenshot.getProjectScreenshots(projectKey, params)
await screenshot.reprocessProjectScreenshots(projectKey, body)
await screenshot.recreateProjectScreenshots(projectKey, body)
await screenshot.deleteProjectScreenshots(projectKey)
await screenshot.getThumbnailCandidate(projectKey, options)
await screenshot.updateProjectThumbnail(projectKey, body)
await screenshot.refreshThumbnail(projectKey)
await screenshot.getPageScreenshot(screenshotId, format)
await screenshot.getComponentScreenshot(screenshotId, format)
await screenshot.getScreenshotByKey(key)
await screenshot.getQueueStatistics()

Tracking Service (Grafana Faro)

const tracking = sdk.getService('tracking')

// Events
tracking.trackEvent('purchase', { amount: 42, currency: 'USD' })
tracking.trackError(new Error('Login failed'), { context: { screen: 'Login' } })
tracking.captureException(error, context)
tracking.trackMeasurement('cart_value', 42, { context: { currency: 'USD' } })
tracking.trackView('Dashboard', { section: 'Analytics' })

// Logging
tracking.logMessage(message)
tracking.logDebug(message)
tracking.logInfo(message)
tracking.logWarning(message)
tracking.logError(message)
tracking.addBreadcrumb('Open modal', { id: 'planLimits' })

// User & Session
// setUser sends an ALLOWLIST: the user id (id | _id | userId) and `plan`.
// Never the e-mail, name, username or the rest of the user object; a user
// without an id (or with an e-mail as its id) stays anonymous.
tracking.setUser({ id: 'u_123', plan: 'pro' })
tracking.clearUser()
tracking.setSession(session)
tracking.clearSession()

// Global Attributes
tracking.setGlobalAttributes(attributes)
tracking.setGlobalAttribute(key, value)
tracking.removeGlobalAttribute(key)

// Queue & Status
tracking.flushQueue()
tracking.getClient()
tracking.isEnabled()
tracking.isInitialized()

Tracking Configuration

const sdk = new SDK({
  tracking: {
    url: 'https://<your-faro-receiver-url>',
    appName: 'Symbols Platform',
    environment: 'production',
    appVersion: '1.0.0',
    sessionTracking: true,
    enableTracing: true,
    globalAttributes: { region: 'us-east-1' }
  }
})

Tracking is automatically disabled on localhost and in non-browser environments.

Growth Service

The Symbols sign-up funnel (landing → Fly → workspace) for the Growth app. Both reads are system-org only on the server; any other caller gets the server's refusal as a thrown error. The server owns the query vocabulary: every scalar field of the filter goes out as a query param (a Date as ISO, an array joined with ,), nothing is added or renamed.

const growth = sdk.getService('growth')

// GET /core/growth/funnel — stage counts, step conversion, drop-off
await growth.funnel({ since: '2026-10-01', until: '2026-10-24', tz: 'Asia/Tbilisi', groupBy: 'source' })

// GET /core/growth/accounts — per-account stage; the stalled list
await growth.accounts({ stage: 'stalled' }, { limit: 50, offset: 0 })

// Same reads through the dispatcher / declarative fetch
await sdk.execute('growth', 'funnel', { since: '2026-10-01' })
await sdk.execute('growth.accounts', 'list', { stage: 'stalled', limit: 50 })

Waitlist Service

const waitlist = sdk.getService('waitlist')

await waitlist.joinWaitlist(data)              // public
await waitlist.listWaitlistEntries(options)     // admin
await waitlist.updateWaitlistEntry(id, update)  // admin
await waitlist.inviteWaitlistEntry(id)          // admin

Metrics Service

const metrics = sdk.getService('metrics')

await metrics.getContributions(options)  // contribution heat-map stats

Integration Service

const integration = sdk.getService('integration')

// Integration management
await integration.integrationWhoami(apiKey, options)
await integration.listIntegrations(options)
await integration.createIntegration(data)
await integration.updateIntegration(integrationId, update)

// API Keys
await integration.createIntegrationApiKey(integrationId, data)
await integration.listIntegrationApiKeys(integrationId)
await integration.revokeIntegrationApiKey(integrationId, keyId)

// Webhooks
await integration.createIntegrationWebhook(integrationId, data)
await integration.listIntegrationWebhooks(integrationId)
await integration.updateIntegrationWebhook(integrationId, webhookId, update)
await integration.deleteIntegrationWebhook(integrationId, webhookId)
await integration.listIntegrationWebhookDeliveries(integrationId, webhookId, options)
await integration.replayIntegrationWebhookDelivery(integrationId, webhookId, deliveryId)

// GitHub Connectors
await integration.listGitHubConnectors()
await integration.createGitHubConnector(data)
await integration.updateGitHubConnector(connectorId, update)
await integration.deleteGitHubConnector(connectorId)

Feature Flag Service

const featureFlag = sdk.getService('featureFlag')

// User-facing
await featureFlag.getFeatureFlags(params)
await featureFlag.getFeatureFlag(key)

// Admin
await featureFlag.getAdminFeatureFlags(params)
await featureFlag.createFeatureFlag(flagData)
await featureFlag.updateFeatureFlag(id, patch)
await featureFlag.archiveFeatureFlag(id)

See src/docs/FeatureFlags.md for full recipes (kill switch, allowlist, percentage rollout, A/B variants).

Organization Service

const organization = sdk.getService('organization')

// Org CRUD
await organization.createOrganization({ name, slug })
await organization.listOrganizations()
await organization.getOrganization(orgId)
await organization.updateOrganization(orgId, updates)
await organization.transferOrgOwnership(orgId, { userId })
await organization.deleteOrganization(orgId)

// Members
await organization.listOrgMembers(orgId)
await organization.addOrgMember(orgId, { userId, role })
await organization.updateOrgMember(orgId, memberId, { role })
await organization.removeOrgMember(orgId, memberId)
await organization.getMemberEffectiveRole(orgId, memberId)

// One member's profile, acted on by the org (signed-in only)
// needs profile.edit_others + a strictly higher rank; never an owner, never self
await organization.updateOrgMemberProfile(orgId, userId, { name, timezone, position, city, country, github, bio })
// needs profile.private.read + a strictly higher rank; never an owner, never self;
// the member's personal documents created in this org (new ones carry the stamp), metadata only
await organization.listOrgMemberDocuments(orgId, userId, { limit, offset })
// would the two calls above go through for me on this member? any org member may ask; writes nothing
// → { edit: { allowed, error? }, documents: { allowed, error? } } (a refused side is a value, not a throw)
await organization.getOrgMemberProfileAccess(orgId, userId)
// needs member.remove + a strictly higher rank; never an owner, never self; active <-> inactive only
await organization.setMemberStatus(orgId, userId, 'inactive')

// Teams
await organization.createTeam(orgId, { name, slug, parentTeam })
await organization.listTeams(orgId)
await organization.updateTeam(orgId, teamId, updates)
await organization.deleteTeam(orgId, teamId)
await organization.listTeamMembers(orgId, teamId)
await organization.addTeamMember(orgId, teamId, { userId, role })
await organization.updateTeamMember(orgId, teamId, teamMemberId, { role })
await organization.removeTeamMember(orgId, teamId, teamMemberId)

// Org & team invitations
await organization.createOrgInvitation(orgId, { email, role, teams })
// "Share by magic link": bound to no email; the first person who opens the
// link and accepts joins at `role`, once. Returns the row + its one-time
// `inviteUrl` (never stored, never listed) and the server's `expiresAt`.
await organization.createOrgInvitationLink(orgId, { role })
await organization.listOrgInvitations(orgId)
await organization.revokeOrgInvitation(orgId, inviteId)
await organization.acceptOrgInvitation({ token })
await organization.listTeamInvitations(orgId, teamId)
await organization.createTeamInvitation(orgId, teamId, { email, recipientName })
await organization.revokeTeamInvitation(orgId, teamId, inviteId)
await organization.acceptTeamInvitation({ token })

// Project & workspace permissions
await organization.getOrgProjectPermissions(orgId)
await organization.updateOrgProjectPermissions(orgId, permissions)
await organization.listTeamAccess(orgId, teamId)
await organization.grantTeamAccess(orgId, teamId, { projectId, role })
await organization.updateTeamAccess(orgId, teamId, accessId, { role })
await organization.revokeTeamAccess(orgId, teamId, accessId)
await organization.listTeamWorkspaceAccess(orgId, teamId)
await organization.grantTeamWorkspaceAccess(orgId, teamId, { workspaceId, role })
await organization.updateTeamWorkspaceAccess(orgId, teamId, accessId, { role })
await organization.revokeTeamWorkspaceAccess(orgId, teamId, accessId)

// Org-scoped projects
await organization.createOrgProject(orgId, projectData)

// Roles
await organization.listOrgRoles(orgId)
await organization.createOrgRole(orgId, role)
await organization.updateOrgRole(orgId, roleKey, updates)
await organization.deleteOrgRole(orgId, roleKey)

// Billing & credit pool
await organization.listOrgPayments(orgId)
await organization.getCreditPool(orgId)
await organization.updateCreditPool(orgId, pooledCredits)
await organization.ensureOrgStripeCustomer(orgId)

// SSO / SCIM
await organization.getSso(orgId)
await organization.updateSso(orgId, sso)
await organization.getScim(orgId)
await organization.updateScim(orgId, { enabled, rotateToken })

// Admin overrides
await organization.adminListOrganizations(params)
await organization.adminListAllTeams(orgId)
await organization.adminOverrideTeam(orgId, teamId)

Workspace Service

Workspace-org CRUD against /core/workspaces/*. Distinct from workspaceData (typed surface against /workspace/*).

const workspace = sdk.getService('workspace')

await workspace.createWorkspace({ organization, displayName, slug })
await workspace.listWorkspaces({ organization, page, limit })
await workspace.getWorkspace(workspaceId)
await workspace.updateWorkspace(workspaceId, updates)
await workspace.deleteWorkspace(workspaceId)

// Members
await workspace.listWorkspaceMembers(workspaceId)
await workspace.addWorkspaceMember(workspaceId, { userId, role })
await workspace.updateWorkspaceMemberRole(workspaceId, userId, { role })
await workspace.removeWorkspaceMember(workspaceId, userId)

// Team grants
await workspace.grantWorkspaceTeamAccess(workspaceId, { teamId, role })
await workspace.revokeWorkspaceTeamAccess(workspaceId, teamId)

// Billing & credits
await workspace.getBilling(workspaceId)
await workspace.getCreditBalance(workspaceId)
await workspace.getCreditLedger(workspaceId, { limit, before, reason })
await workspace.getSpendControls(workspaceId)
await workspace.updateSpendControls(workspaceId, controls)
// The price of a builder turn before it is sent: the turn's own body (plus
// conversationId for an existing thread), POST only. No model call, no write.
const { step, balance, waived, canStart, enough } =
  await workspace.estimateBuild(workspaceId, { content, context: { surface: 'add-app-builder' } })

// Permissions / projects
await workspace.getWorkspacePermissions(workspaceId)
await workspace.createWorkspaceProject(workspaceId, projectData)

// Invitations
await workspace.listWorkspaceInvitations(workspaceId)
await workspace.createWorkspaceInvitation(workspaceId, { email, role, recipientName })
await workspace.revokeWorkspaceInvitation(workspaceId, inviteId)
await workspace.acceptWorkspaceInvitation({ token })

Workspace Data Service

Typed surface against ${apiUrl}/workspace/*. Methods are namespaced sub-objects on the service. Auth requires a workspace JWT carrying sub + workspace_id claims — supply via context.workspaceTokenProvider.

const ws = sdk.getService('workspaceData')

// Tickets
await ws.tickets.list(filter, options)
await ws.tickets.get(number)
await ws.tickets.create(payload)
await ws.tickets.update(number, payload)
await ws.tickets.remove(number)
await ws.tickets.epicCounts()
await ws.tickets.assign(id, assigneeEmail)

// Chat
await ws.chat.listChannels()
await ws.chat.createChannel(payload)
await ws.chat.listMessages(channelId)
await ws.chat.sendMessage(channelId, payload)
await ws.chat.listMembers(channelId)

// Calendar
await ws.calendar.listEvents(filter)
await ws.calendar.createEvent(payload)
await ws.calendar.updateEvent(id, payload)
await ws.calendar.deleteEvent(id)
await ws.calendar.sync(params)

// Meet
await ws.meet.listRooms()
await ws.meet.createRoom(payload)
await ws.meet.getRoom(id)
await ws.meet.listMembers(id)
await ws.meet.listTranscripts(id)
await ws.meet.waitingRoom()
// ws.meet.issueToken / ws.meet.mute — removed (reject with code 'route_removed'):
//   use sdk.meetMintToken({ roomId }) / sdk.meetMuteParticipant({ … })

// Documents
await ws.documents.list()
await ws.documents.create(payload)
await ws.documents.get(id)
await ws.documents.update(id, payload)
await ws.documents.listKb()
await ws.documents.listResourceLinks()
await ws.documents.addResourceLink(payload)

// Presence, notifications, search, permissions, system, people, activity
// ws.presence.online / heartbeat — removed ('route_removed'): use sdk.subscribePresence({ scope }, onSync)
await ws.notifications.list()
await ws.notifications.unreadCount()
await ws.notifications.markRead(id)
await ws.notifications.markAllRead()
await ws.notifications.create({ title, body, toRole: 'admin' }) // notify by audience
await ws.notifications.close({ appId, dedupKey })
await ws.notifications.audience() // [{ ref, name, avatar }] for toMembers
await ws.search(q, opts)
// ws.permissions.me / check — removed ('route_removed'): use sdk.getPermissions(orgId)
// ws.system.status / featureFlags — removed ('route_removed'): use sdk.getSystemStatus() / sdk.getFeatureFlags()
await ws.people.list()
await ws.people.get(id)
await ws.people.me()
await ws.activity.listNotes()
await ws.activity.addNote(payload)
await ws.activity.scoringConfig()

// ws.query — removed ('route_removed'); no generic escape hatch: every call has its own route

KV Service

Cloudflare KV worker proxy (URL from environment.kvUrl).

const kv = sdk.getService('kv')

await kv.get(key, { env: 'production' })
await kv.put(key, value, { env, expirationTtl, metadata })
await kv.delete(key, { env })
await kv.list({ env, prefix, limit, cursor })

Allocation Rule Service

Org-level credit-allocation rules.

const rules = sdk.getService('allocationRule')

await rules.listRules(orgId)
await rules.getRule(ruleId)
await rules.createRule({ organizationId, workspaceId, policy, monthlyAllocation, priority })
await rules.updateRule(ruleId, patch)
await rules.deleteRule(ruleId)

Shared Asset Service

Cross-workspace shared assets.

const assets = sdk.getService('sharedAsset')

await assets.createAsset(body)
await assets.listAssets(query)
await assets.getAsset(id)
await assets.updateAsset(id, patch)
await assets.deleteAsset(id)

Credits Service

Project-scoped credit ledger + Stripe top-ups.

const credits = sdk.getService('credits')

await credits.getRates()
await credits.getProjectBalance(projectId)
await credits.getProjectLedger(projectId, { limit, cursor, reason })
await credits.getProjectSpendControls(projectId)
await credits.updateProjectSpendControls(projectId, controls)
await credits.topupProjectCredits(projectId, { packs, returnUrl })

AI Service

Workspace AI turns. turn and turnStream are EPHEMERAL: one answer, no stored conversation (POST /core/agents/workspaces/:workspaceId/turn), with the workspace's model routing, monthly cap and credit billing applied by the server.

const ai = await sdk.getService('ai')

// One answer, as JSON.
const { text, usage } = await ai.turn(
  { messages, system, systemRef, modelMode, allowTools },
  { workspaceId, signal }
)

// The same turn, streamed (SSE). Render fullText — it restarts ('' ) when
// the server drops words that are not the answer (a tool step's narration).
const controller = new AbortController()
const result = await ai.turnStream(
  { messages, system, allowTools: false },
  {
    workspaceId,
    signal: controller.signal,                  // abort → the server stops the model call
    onDelta: (deltaText, fullText) => render(fullText),
    onReset: (reason) => {}                     // optional, for consumers that append
  }
)
// result: { text, usage: { inputTokens, outputTokens }, raw }

turnStream resolves with the same { text, usage, raw } as turn. It rejects with the server's message (code, status) when the request is refused (e.g. ai_cap_exceeded, 402) or the server sends an error frame, with code: 'STREAM_TRUNCATED' when the stream ends without its done frame, and with an AbortError when signal aborts. Against a server that has no stream yet it resolves with the JSON answer and calls onDelta once.

Wire format (stream: true or Accept: text/event-stream on the same route): event: delta {text}, event: reset {reason}, event: done {text, type, usage}, event: error {message, code}, and : heartbeat comments. The delta texts since the last reset always add up to done.text.


Token Management

The SDK includes automatic token management with persistence and refresh:

  • Automatic Token Refresh - tokens are refreshed before expiration
  • Persistent Storage - tokens persist across page refreshes via localStorage
  • Secure Handling - automatic cleanup on logout
  • Flexible Storage - supports localStorage, sessionStorage, or memory
import { getTokenManager } from '@symbo.ls/sdk'

const tokenManager = getTokenManager({
  storageType: 'localStorage',        // 'localStorage' | 'sessionStorage' | 'memory'
  refreshBuffer: 60 * 1000,           // refresh 1 minute before expiry
  apiUrl: '/api',
  onTokenRefresh: (tokens) => { ... },
  onTokenExpired: () => { ... },
  onTokenError: (error) => { ... }
})

All authenticated API calls automatically use fresh tokens via the BaseService _request() method.


Permissions

Role Permissions

// Global roles
const ROLE_PERMISSIONS = {
  guest: ['viewPublicProjects'],
  user: ['viewPublicProjects', 'createProject'],
  admin: ['viewPublicProjects', 'createProject', 'governance'],
  superAdmin: ['viewPublicProjects', 'createProject', 'governance', 'managePlatform']
}

// Project roles
const PROJECT_ROLE_PERMISSIONS = {
  guest: ['platformSettings', 'showContent'],
  editor: ['platformSettings', 'showContent', 'showCode', 'editMode', 'versions'],
  admin: [/* editor + */ 'inviteMembers', 'branchProtection', 'projectSettings'],
  owner: [/* admin + */ 'copyPasteAllowanceSetting', 'iam']
}

Permission Checks

auth.hasPermission('edit')
auth.hasGlobalPermission('admin', 'governance')
auth.checkProjectPermission('editor', 'editMode')
auth.checkProjectFeature('pro1', 'aiCopilot')  // returns tier limit (e.g. 5)
await auth.canPerformOperation(projectId, 'edit', { checkFeatures: true })
await auth.withPermission(projectId, 'edit', () => { /* action */ })

Tier Features

Feature Free Pro1 Pro2
aiCopilot 3 5 15
aiChatbot 3 5 15

Environment Configuration

The SDK auto-detects environment from hostname and provides:

import { environment } from '@symbo.ls/sdk'

environment.apiUrl      // HTTP API URL
environment.socketUrl   // WebSocket URL
environment.features    // { trackingEnabled, betaFeatures, newUserOnboarding }

Supported environments: local, development, testing, upcoming, staging, preview, production.


Error Handling

try {
  await sdk.initialize()
} catch (error) {
  console.error('SDK initialization failed:', error.message)
}

try {
  await project.mergePullRequest(projectId, prId)
} catch (error) {
  if (error.message.includes('conflicts')) {
    // Handle merge conflicts
  } else if (error.message.includes('403')) {
    // Handle permission errors
  }
}

Direct Service Creation

Services can be created independently without the SDK class:

import { createAuthService, createProjectService } from '@symbo.ls/sdk'

const auth = createAuthService({ context, options })
await auth.init({ context, options })

Available factory functions: createAuthService, createCollabService, createProjectService, createPlanService, createFileService, createPaymentService, createDnsService, createBranchService, createPullRequestService, createAdminService, createSubscriptionService, createScreenshotService, createTrackingService, createWaitlistService, createMetricsService, createIntegrationService, createFeatureFlagService, createOrganizationService, createWorkspaceService, createWorkspaceDataService, createKvService, createAllocationRuleService, createSharedAssetService, createCreditsService.


Validations

import { validate, validators } from '@symbo.ls/sdk'

validate('component', componentData)   // singular or plural accepted
validate('pages', pagesData)

validators.components / validators.pages / validators.functions
validators.files / validators.dependencies

Each Validator class exposes validateAll() returning { isValid, errors }.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages