Server-side module at platform/src/lib/sdk.ts. It uses Prisma directly, is not published as an npm package, and must not be imported by browser code.
This module is not authenticated by an API key. Authenticate the user and enforce route-level authorization and entitlements before calling methods that expose user or platform data. The optional region value is response metadata; it does not select a database or route network traffic.
Reads and returns the SDS system prompt for a skill from the server-side registry. This internal method does not perform caller authentication or entitlement checks; allowed means the artifact loaded, not that the caller is entitled to use it.
Parameters
options.skillName | string | The skill slug to load |
Returns
{ skillName, version, systemPrompt, allowed, region } — allowed reports artifact loading onlyThrows
SKILL_NOT_FOUND · SKILL_CONTENT_MISSINGQueries the live registry. Supports filtering by tier, domain, access level, and free-text search.
Parameters
options.tier | number | SDS tier filter (0–4) |
options.domain | string | Vertical/domain filter |
options.accessLevel | string | ordinary | premium | enterprise_only |
options.search | string | Free-text search against display name or domain |
Returns
SkillSummary[] — { skillName, displayName, version, tier, domain, accessLevel, description? }Throws
REGISTRY_UNAVAILABLEPersists a draft workflow definition. Workflow execution is a separate operation.
Parameters
options.name | string | Workflow name, at least three characters |
options.skills | string[] | One or more skill names |
options.outcome | string | Expected workflow outcome |
options.userId | string | Owning user ID |
Returns
{ workflowId, name, status }Throws
VALIDATION_ERROR · WORKFLOW_PERSIST_FAILEDCreates an owner-scoped WorkflowRun. Approval-gated runs return as awaiting_approval and are not dispatched. Other eligible runs return queued only after Inngest accepts the event; dispatch failures return failed, the worker's current run status, or dispatch_unconfirmed.
Parameters
options.workflowId | string | The workflow ID returned by createWorkflow |
options.userId | string | Requesting user ID |
options.input | Record<string, unknown> | Optional runtime input variables |
Returns
{ runId, workflowId, status, queuedAt }Throws
EXECUTION_DISABLED · WORKFLOW_NOT_FOUND · WORKFLOW_ARCHIVED · WORKFLOW_NOT_READY · RUN_QUOTA_EXCEEDED · RUN_QUOTA_UNAVAILABLE are SkillOSError codes; database errors may propagate, and queue delivery failures are returned in status and dispatchState.Queries the project memory layer. Supports tag matching, multi-field case-insensitive search, and native PostgreSQL array operators.
Parameters
userId | string | Owner whose private and globally seeded records may be returned |
query.tag | string | Single tag match |
query.tags | string[] | Any-of tag match; ignored when tag is set |
query.search | string | Case-insensitive search across title, content, and tags |
Returns
Records owned by the user plus globally seeded records, newest firstThrows
Database errors propagate from PrismaQueues URL ingestion through Inngest or synchronously persists plaintext knowledge.
Parameters
options.url | string | Optional URL; when set, text is ignored |
options.text | string | Optional raw plaintext; provide URL or text |
options.title | string | Required document title |
options.authorityScore | number | Optional authority score |
options.ttlDays | number | Optional document TTL in days |
Returns
{ status: 'queued' | 'persisted', documentId? }Throws
VALIDATION_ERROR · KNOWLEDGE_PERSIST_FAILEDAggregates decision counts. The alignment rate remains null until at least ten evaluated decisions exist.
Returns
{ total, aligned, alignmentRate, overrideCount, inconclusiveCount }Throws
DECISION_LEDGER_UNAVAILABLEChecks an explicitly supplied user, plan, and skill access level against entitlements.
Parameters
options.userId | string | User ID |
options.plan | Plan | Current plan |
options.skillAccessLevel | string | ordinary | premium | enterprise_only |
options.skillName | string | Optional skill slug |
Returns
{ allowed, reason?, remaining?, dailyQuota?, resetAt? }Throws
ENTITLEMENT_CHECK_FAILEDThese are errors wrapped by the internal SDK. Some database and Inngest failures are not wrapped and may propagate from their clients.
| Code | Description |
|---|---|
SKILL_NOT_FOUND | The requested skill is absent from the registry artifacts |
SKILL_CONTENT_MISSING | The skill exists but has no loadable content |
REGISTRY_UNAVAILABLE | The registry database query failed |
VALIDATION_ERROR | Workflow or knowledge input failed validation |
WORKFLOW_PERSIST_FAILED | Workflow creation failed in the database |
WORKFLOW_NOT_FOUND | No workflow matches the requested ID |
KNOWLEDGE_PERSIST_FAILED | Text knowledge could not be persisted |
ENTITLEMENT_CHECK_FAILED | The entitlement database check failed |
DECISION_LEDGER_UNAVAILABLE | Decision summary query failed |