---
title: Context API reference
description: Look up the base Context fields, ComputeContextInput, computed properties, sharing rules, and reserved-key boundary.
sidebar:
  label: Context
---

Import `Context` and `ComputeContextInput` from `@evilkiwi/vector`.

```ts title="TypeScript"
type Context<
  RuntimeConfig = Record<never, never>,
  Computed extends object = Record<never, never>,
> = BaseContext<RuntimeConfig> & Computed;

type ComputeContextInput = Omit<BaseContext<never>, 'runtimeConfig'>;
```

## Base Context fields

| Field                 | Type                          | Meaning                                                      |
| --------------------- | ----------------------------- | ------------------------------------------------------------ |
| `runtimeConfig`       | Schema output or empty object | Validated Runtime Configuration for the active installation. |
| `cwd`                 | `string`                      | Active OpenCode location directory.                          |
| `project.id`          | `string`                      | Active project identity.                                     |
| `project.directory`   | `string`                      | Project directory supplied by OpenCode.                      |
| `project.canonical`   | `string`                      | Canonical project directory supplied by OpenCode.            |
| `project.workspaceId` | `string \| undefined`         | Workspace identity when the host supplies one.               |

The exact host value shapes remain owned by the pinned OpenCode packages. Vector imports those types directly rather than maintaining copies.

## ComputeContextInput

`ComputeContextInput` contains `cwd` and `project`. It excludes Runtime Configuration. A builder passes this value to `computeContext` once per activation.

The callback may return additional flat properties. `runtimeConfig`, `cwd`, and `project` are reserved and cannot be replaced. The return value must be synchronous and plain; see [`createVectorBuilder()`](/api/create-vector-builder) for accepted and rejected values.

## Sharing and inference

One Context object is shared by identity with the Vector Configuration callback and every selected Extension Definition callback in an activation. A later activation receives a separately resolved value.

Root `defineX` helpers and `createVectorBuilder()` without options use the base Context with an empty Runtime Configuration type. Helpers returned by a configured builder infer both its Runtime Configuration schema output and computed fields. Extension helpers do not accept a Runtime Configuration generic.

Use [Computed context](/build/computed-context) for a complete builder example and [Runtime Configuration](/api/runtime-config) for schema resolution.
