# Workspace Nodes

> Applies to: ChengOS v0.2.0+ ｜ Last verified: 2026-09-25 ｜ Source: `crates/cheng-nodes/src/nodes/builtin/workspace`

Two nodes that answer "where am I working". `workspace/context` resolves the current workspace and
hands its identity to downstream nodes, which is what workspace-scoped tools bind against.
`workspace/knowledge_base` selects, lists, or creates a knowledge base inside that workspace and emits
the id the RAG nodes expect. Wire these first when a graph mixes workspace tools with retrieval;
everything downstream depends on the ids they produce.

## Workspace Context — `workspace/context`

Reads the current runtime workspace ID injected by the executor. Use this when a downstream node needs to consume the active workspace explicitly.

### Inputs

| Field | Type | Required | Default | Description |
|---|---|:-:|---|---|
| `workspaceId` | string | — | — | Runtime workspace identifier (auto-injected) |

### Outputs

| Field | Type | Description |
|---|---|---|
| `hasWorkspace` | boolean | True iff a workspace was actually present in the runtime context. |
| `workspaceId` | string | The resolved workspace ID, or empty string when the executor did not inject one (e.g. the workflow was triggered outside of any workspace). |

## Knowledge Base — `workspace/knowledge_base`

Select, list, or create knowledge bases in a workspace

### Inputs

| Field | Type | Required | Default | Description |
|---|---|:-:|---|---|
| `mode` | enum | — | `select` | select: Select existing KB; list: List all KBs in workspace; create: Create new KB. Control: `select`. Options: `select`, `list`, `create` |
| `kb_id` | string | — | `null` | Knowledge base to select (select mode). Control: `dynamic-select` |
| `name` | string | — | `null` | New knowledge base name (create mode) |
| `description` | string | — | `null` | Knowledge base description (create mode, optional) |
| `embedding_model` | string | — | `null` | Embedding model name (create mode, optional) |

### Outputs

| Field | Type | Description |
|---|---|---|
| `success` | boolean | Whether the operation succeeded. |
| `workspace_id` | string | Workspace ID (for direct connection) |
| `kb_id` | string | Knowledge base ID (for direct connection) |
| `knowledge_base` | object | Single knowledge base info (select/create modes). |
| `knowledge_bases` | array | List of knowledge bases (list mode). |
| `error` | string | Error message if the operation failed. |

## Next steps

- [Knowledge Bases & Workspace Context](/docs/data-knowledge-base)
- [Workspace Tool Nodes](/docs/nodes-workspace-tools)
- [RAG Nodes](/docs/nodes-rag)
