Skip to content

CampusSDK

CampusSDK is the typed capability surface between an installed application and CampusOS. The canonical browser client is createCampusApp(); it exposes named groups rather than one flat RPC client.

Canonical browser entry

js
import { createCampusApp } from '/assets/campus_sdk/campus_browser.js'

const campus = createCampusApp({
  appId: 'example-notes',
  pullToRefresh: true,
})

renderApp()
await campus.ready({ title: 'Notes' })

Construction is synchronous. Each capability call waits for the trusted launch exchange when necessary. Drawing does not wait for a backend or an SDK-owned hydration phase.

CampusOptions accepts appId, expectedAppId, window, storageKey, and pullToRefresh.

Browser SDK surface

Lifecycle, shell, and private backend

SurfaceCurrent methodsContract
App lifecycleready({ title? }), fail(error), close()Report a usable interface, expose structured startup failure, or close the app.
shellinsets, onInsetsChanged, onRefresh, setOverlayOpen, dismissInteract with trusted shell chrome without reading or mutating the parent DOM.
backendavailability, state, fetch, fetchJson, openSocket, openEventStream, warm, acquireLease, renewLease, releaseLease, onReach only this installation’s private backend through its scoped Gateway capability.

Backend state is absent, not-installed, stopped, queued, starting, running, connecting, ready, degraded, or unavailable. Availability also reports runtimeMode, node configuration/online state, and whether funding is required and ready.

js
const availability = await campus.backend.availability()

if (availability.available) {
  const report = await campus.backend.fetchJson('/v1/report', {
    method: 'POST',
    body: { range: 'week' },
  })
}

const stop = campus.backend.on('disconnected', ({ state, error }) => {
  showConnectionState({ state, error })
})

Apps, account, authority, and settings

SurfaceCurrent methodsContract
appslist, search, get, create, customize, activateCustomization, restoreOriginal, install, purchase, uninstall, open, start, warm, pause, stop, order.get/set, pins.get/setDiscover and manage account-visible Campus Apps through trusted lifecycle and installation flows.
appearanceget, updateRead or update scope, theme, wallpaper family, and wallpaper selection.
accountcurrent, identityRead public Campus name/address or the installation-bound account identity.
accesslist, status, grant, revokeManage the exact Campus users admitted to this app.
permissionscatalog, current, check, request, revoke, openManager, manager, setForApp, closeInspect and request bounded grants. Approval remains in trusted shell UI.
settingssnapshot, current, request, background/warm settings, permission/exposure/wallet/MCP/intelligence helpers, identity, schedule helpersRequest changes to lifecycle, routes, authority, identity, budgets, and schedules.
secretsbind, fetchBind and use a protected outbound credential without returning its plaintext.
paymentspropose, authorizations.*Stage exact financial intent and manage existing bounded authorizations.
js
if (!await campus.permissions.check('files.read', 'owner:*')) {
  await campus.permissions.request({
    permissions: [{ id: 'files.read', resources: ['owner:*'] }],
    reason: 'Open the file selected by the owner.',
  })
}

await campus.secrets.bind('github-token', {
  reason: 'Publish the selected repository.',
})
const response = await campus.secrets.fetch('github-token', '/user')

Data, storage, and cryptography

SurfaceCurrent methodsContract
kv(namespace, { scope })get, set, delete, listVersioned small JSON. account scope is synchronized; device stays in this browser.
fileslist, get, create, write, read, setPermissions, deleteLogical large/binary objects with explicit owner, protection, and permission metadata.
encryptedContentidentity/key preparation; collections, entries, objects, versions, imports, sinks, invitations, members, changesEnd-to-end encrypted collaborative content graph used by products such as Drive.
crypto.key(namespace)encrypt, decrypt, signDomainSeparated, verifyDomainSeparated, grant, rotate, revokeGrantScoped key handle; raw account keys never leave the trusted boundary.
crypto.recipients(namespace)prepare, sealTo, openRecipient-bound encryption using Campus address, app, namespace, domain, and context.
crypto.sealedAssets(namespace)sealTo, open, acknowledge, deleteChunked encrypted asset delivery.
crypto.commitments(namespace)prepare, sign, verifyDomain-separated signed commitments.
js
const preferences = campus.kv('preferences')
const record = await preferences.get('theme')
await preferences.set('theme', 'dark', {
  ifVersion: record?.version ?? 0,
})

const file = await campus.files.create('report.json', JSON.stringify(report), {
  contentType: 'application/json',
  owner: 'user',
  protection: { mode: 'platform-readable', service: 'example-notes', purpose: 'report' },
})

const recipients = campus.crypto.recipients('messages', {
  domain: 'example.message',
})
const envelope = await recipients.sealTo('bob.campus.host', {
  text: 'hello',
})

Do not put large values in KV. Files is not automatically end-to-end encrypted; choose explicit file protection or use encryptedContent when endpoints must own plaintext.

Events, communication, and discovery

SurfaceCurrent methodsContract
accountEventssubscribe, connect; stream receive, events, ack, close, abortRealtime or durable account-scoped events. Durable delivery is at-least-once and explicitly acknowledged.
deliveriessend, list, get, acknowledge, cancelTTL-bound opaque envelope delivery to an exact Campus address, app, and channel.
rendezvouscreate, list, get, messages, send, closeShort-lived ordered coordination with an exact account/app peer.
notificationssnapshot, list, markRead, markAllRead, activate, system/web-push helpers, publishAccount notifications with optional trusted presentation actions.
schedulessnapshot, create, update, delete, run, runs, closeSchedule an eligible installed app tool with timezone and bounded runtime/run count.
searchreplace, index, upsert, delete, clear, queryMaintain this app’s private entries and query the account search index.
js
const stream = await campus.accountEvents.subscribe(['report:*'], {
  delivery: 'durable',
  consumer: 'report-indexer',
  ackMode: 'explicit',
})

for await (const event of stream) {
  await commitIdempotently(event.id, event.data)
  await stream.ack(event)
}

await campus.notifications.publish({
  topic: 'report.ready',
  title: 'Report ready',
})
await campus.search.upsert([{ id: 'report:weekly', title: 'Weekly report' }])

Platform services and tools

SurfaceCurrent methodsContract
intelligencerequest(provider, path, options)Run inference within the installation’s provider, model, and budget grants.
speechstart, toggle, cancel, onTranscript, closeBrowser microphone transcription with visible browser permission.
mcplist, searchPublic, call, callAdmitted, cancelAdmission, serveBrowser, callBrowser, appStatus, closeDiscover, call, or serve permission-filtered product tools while preserving admission contracts.
activitysnapshotRead the account’s authorized runtime activity view.
domainssnapshot, bind, attachDns, refresh, unbind, finalizeManage public domain bindings for apps with approved public routes.
distributionproducts, sources, mcpListings, revenue, publish, setPrice, publishRelease, withdraw, setMcpListingPackage and publish immutable app releases and MCP listings.
securityReviewslist, get, requestRequest and read Store release security review state.
js
const response = await campus.intelligence.request('openai', '/v1/responses', {
  method: 'POST',
  body: { model: 'configured', input: 'Summarize this report.' },
})

const result = await campus.mcp.call({
  name: 'campus-calendar.availability',
  arguments: { query: { fromMs, toMs } },
})

if (result.resultType === 'complete') {
  renderAvailability(result.structuredContent)
}

Product behavior such as starting a call, sending a Matrix message, or booking a calendar offer is app-owned MCP—not a new CampusSDK namespace.

Execution surfaces

EnvironmentEntryUse
Browser appcreateCampusApp()Trusted launch, shell, typed Campus primitives, private backend transport, and MCP.
JavaScript backendCampusServicesClient.fromEnv()Installation-scoped Gateway services, durable events/workflows, files, and work leases.
Rust backendcampus_sdk::CampusServicesClientNative equivalent for Rust workloads.
Native Agent@campus/sdk/account-mcpCaller-filtered account/product MCP catalog over stdio.
App MCP providermanifest mcp.toolsApp-owned product contracts executed by browser, workload, or reviewed service transport.

Transport and authority

The browser SDK routes each operation through one of three transports:

  • shell for trusted visible UI and user confirmation;
  • service for installation-authorized Campus services;
  • workload for this installation’s private backend.

The app receives a Gateway endpoint ticket and installation capability, never a reusable backend address. Product MCP calls preserve the product package’s own schemas, permissions, routing, and admission contract.

Compatibility

CampusApp.connect(), storage(), content(), and workload-named browser methods remain deprecated compatibility APIs. New code uses createCampusApp(), kv(), encryptedContent, and backend.*.

For exact TypeScript shapes and ownership boundaries, continue to the full SDK surface, generated Platform API operation catalog, WebSockets, server-sent events, and Drive/files model.

Software belongs to people. Campus gives it a durable place to run.