@fabricorg/sdk
v0.8.5
Published
TypeScript SDK for the Fabric AI platform
Readme
@fabricorg/sdk
TypeScript client for Fabric's REST API, with resources for projects, saved agents, workflows, coding instructions and more.
Install
npm install @fabricorg/sdk
# Or
pnpm add @fabricorg/sdkClient and authentication
createFabric(options) and new FabricClient(options) create the same client.
Supply an API key as apiKey or set FABRIC_API_KEY in the calling process.
The client sends it as a Bearer credential. Keep the key in server-side code
or a local script.
import { createFabric } from "@fabricorg/sdk";
const fabric = createFabric({
apiKey: process.env.FABRIC_API_KEY,
baseUrl: "https://example.com",
org: "example-org",
});
const identity = await fabric.auth.whoami();
const projects = await fabric.projects.list();| Option | Default or behavior |
| --- | --- |
| apiKey | FABRIC_API_KEY. A missing key throws FabricAuthError. |
| baseUrl | FABRIC_BASE_URL, then the default Fabric service. |
| org | FABRIC_ORG. The default organization slug. |
| project | FABRIC_PROJECT. The default project ID where the method accepts one. |
| personal | Deprecated. Personal context is retired. The client still reads FABRIC_PERSONAL (1 or case-insensitive true) and throws INVALID_CONTEXT if an organization and personal context are both set. |
| fetch | Global fetch. Supply a compatible implementation to customize requests. |
| timeoutMs | 60,000 ms per attempt. |
| retry | maxRetries defaults to 2, initialDelayMs to 250, multiplier to 2, and maxDelayMs to 5,000. Set maxRetries: 0 to disable retries. |
| onEvent | Optional callback for request, response, retry and error events. |
| userAgent | Optional User-Agent header. |
| onUpgradeNotice | Optional callback receiving the X-Fabric-Cli-Upgrade response header value when present. |
withOrg(slug), withProject(projectId) and withoutContext() return new
clients. Use withoutContext() to clear organization and personal defaults
when the request's project determines its organization. Read the client’s
project default through defaultProject.
withPersonal() is deprecated. Personal context is retired. Use
withOrg(slug) for organization context, the only supported tenant context.
Resources
The SDK entry point also exports option, result and domain types. The linked resource files define method signatures.
| Namespace | Methods |
| --- | --- |
| auth | whoami, listKeys, createKey, revokeKey |
| orgs | list |
| projects | list, get, create, update, listCodeRepositories, listFeatures, getFeature, createFeature, updateFeature, assignFeature, listTasks, listDocuments, getDocument, createDocument, updateDocument, listInstructionSets, createInstructionSet, updateInstructionSet, deleteInstructionSet, getPluginName |
| workflows | list, get, trigger, getExecution, listExecutions, cancelExecution |
| prompts | list, get, create, update |
| agents | list, get, invoke, invokeInstance, getInstanceExecution, execute (deprecated, use invoke) |
| agentRuns | search, list, get, cancel, getSchedule, setSchedule |
| skills | list, get |
| mcp | listServers, listConfigs, getConfig, deleteConfig |
| frames | list, get |
| instructions | getPublished, getRepositoryState, listRepositoryFiles, readRepositoryFiles, getRepositoryFile, resolveCheckout, createDownloadUrl, createFileDownloadUrls, createVersionFileDownloadUrls, submitRepositoryChange, submitChange, getProposalPullRequest, getOpenProposals, publishChange |
| contexts | linkedDocuments, linkWorkspaceDocument, unlinkWorkspaceDocument, readLinkedDocument, assemble, manifest, upsertSyncedFile, deleteSyncedFile, findMissingSyncedFiles, resetSyncedFiles |
| contextQuality | inspectAgentResult, checkAgentResult, inspect, evaluate |
| contextQuality.runs | capabilities, create, list, get, cancel, compare |
| memory | getTargets, listFiles, getFile, createUploadUrls, submitWrite, getWrite |
| workspaces | list, get, listDocuments, readDocument, query |
| chats | list, get, create, rename, update, delete, sendMessage |
| reports | listTemplates, getTemplate, listExecutions |
| integrations | list, [slug].call(operation, args), and vendor operation paths such as slack.channels.list(). Vendor packages add types for their paths. |
| channels | list, send |
| approvals | list, approve, deny |
| knowledge | getProjectTypes, search |
The root exports planPluginFiles, pluginPathFor, projectRulePathFor and
PLUGIN_LEFT_OUT_REASONS for coding-tool file mapping, plus
DOCUMENT_ERROR_CODES for document errors.
Errors
FabricErrorexposesstatus, optionalcodeand optional structureddata. Transport failures can useNETWORK_ERRORorTIMEOUT.FabricAuthErrorcovers missing API keys and HTTP 401.FabricForbiddenErrorcovers HTTP 403, including scope or access refusals.FabricNotFoundErrorcovers HTTP 404.FabricContextConflictErrorexposesconflictfor recognized synced-context file version conflicts (HTTP 409).
Related references
- Audit Log REST API for direct HTTP calls.
License
MIT.
