SDK Reference

The complete surface of the CloudPeek client from @cloudpeek/core/agent. This inventory is locked by tests in the package — a method appears here if and only if it exists on the client — and breaking changes to it bump the package's major version.

Initialization

MethodWhat it does
CloudPeek.init(options)Configure the module default instance the static namespaces delegate to.
CloudPeek.create(options)Build an independent instance (tests, multiple runtimes per process).
CloudPeek.as(principal)Principal-bound view of the default runtime (multi-tenant embedders).
CloudPeek.on(eventType, handler)Subscribe to lifecycle events; "*" for all. Returns an unsubscribe function.
CloudPeek.dispose()Abort in-flight runs and close the database.
CloudPeek.initializedWhether init() has been called.

Options

OptionPurpose
database":memory:", "sqlite:///path.db", or a Postgres URL. SQLite schema is always created by the SDK.
migratePostgres only: opt in to running core migrations. Without it, a missing schema fails closed.
migrationsDirOverride the packaged migrations directory.
llm / modelExplicit LLM configuration, or a model override for the environment-derived default.
principalDefault PrincipalContext (tenantId, userId?, roles?, token?, displayName?).
executeDynamicTool / resolveDynamicToolRouteIn-process custom tool execution and optional name routing.
runbookProviderPlaybook source enabling playbook_list / playbook_execute.
wikiManagerPre-built core WikiManager enabling the wiki_* built-ins.
memoryServiceBacking service enabling memory_* built-ins and CloudPeek.memory.
eventPublisherLifecycle event hook (same stream as on()).
maxContextTokensContext window override; defaults to a per-model lookup.

CloudPeek.agent

MethodWhat it does
run(opts)Run the agent to completion. Returns the result with status completed, failed, incomplete, or requires_action, plus runId.
stream(opts)Same run as an async iterable of live events. Approval gates only fire here.
resume(runId, outputs)Continue a run that stopped with requires_action, supplying client-side tool results.
cancel(runId)Stop an in-flight run cooperatively. Returns false for unknown ids.

Run options: input, instructions, agentsMd (behaviour profile layered below the core rules and above instructions), maxIterations (default 10), agentName, hitlMode (disabled / approval_only / external_only / external_write_only / full), planMode, model, tools (each optionally isReadOnly), history, principal, signal, runId.

CloudPeek.sessions

Every operation is tenant-scoped: sessions belonging to another tenant fail closed as not-found.

MethodWhat it does
get(sessionId)Fetch one session with its state and metadata.
list(filter?)List the principal tenant's sessions.
status(sessionId)Lightweight status check.
pause(sessionId) / resume(sessionId)Pause at the next safe point / resume a paused session.
complete(sessionId) / cancel(sessionId)Mark finished / cancel and release resources.

CloudPeek.hitl

MethodWhat it does
pending(runId?)Approvals waiting on a human, optionally filtered to one run.
approve(approvalId)Approve a pending tool call; the paused run continues.
deny(approvalId)Reject it; the agent receives the rejection as context.

Approve/deny are scoped to the initiating user's principal.userId; unauthorized callers are rejected and the approval stays visible in pending().

CloudPeek.llm

Direct model access on the configured provider — no agent loop.

MethodWhat it does
text(prompt, opts?)One completion, plain text back.
json(prompt, opts?)One completion, parsed JSON back.
embed(input)Embedding vector(s) for the input.

CloudPeek.memory

Requires a configured memoryService; otherwise every method throws a structured not-configured error.

MethodWhat it does
add(content, opts?)Store a memory for the principal's tenant.
search(query, opts?)Semantic search over stored memories.
list(opts?)All memories in scope.
delete(memoryId, opts?)Remove one memory.

All four accept an optional operationId to scope memories to one operation.

Errors

ErrorThrown when
CloudPeekNotInitializedErrorA static namespace is used before init().
CloudPeekNotConfiguredErrorA namespace's backing service isn't configured, no principal is available, or resume() is called without outputs or for an unknown run.
CloudPeekSchemaErrorThe Postgres schema is missing and migrate: true was not passed.

All three carry stable name values for programmatic handling.

Stability

@cloudpeek/core/agent is a curated surface: its exports and the per-namespace method inventories above are asserted exactly by the package's surface-lock tests, and semver on the package tracks this surface. Types re-exported here (AgenticExecutor, the persistence and LLM seams) let advanced embedders bypass the facade and construct the runtime directly with the same contract.

© 2026 CloudPeek. Agentic AI for high-consequence security operations.