# @dxos/operation

> Operation Invoker

Latest version **0.16.0** (published 2026-10-19) · FSL-1.1-Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @dxos/operation
pnpm add @dxos/operation
yarn add @dxos/operation
bun add @dxos/operation
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.16.0 |
| Published | 2026-10-19 |
| First published | 2026-01-31 |
| Weekly downloads | 0 |
| License | FSL-1.1-Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 4 |
| Unpacked size | 439.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 532 |
| Author | info@dxos.org |
| Maintainers | richburdon, marik_d, wittjosiah, dxos-bot, mykola-vrmchk |

## Links

- npm: https://www.npmjs.com/package/@dxos/operation
- Repository: https://github.com/dxos/dxos
- Homepage: https://dxos.org
- Issues: https://github.com/dxos/dxos/issues
- npm.io page: https://npm.io/package/@dxos/operation

## Dependencies (4)

- [@dxos/log](https://npm.io/package/@dxos/log.md) 0.16.0
- [@dxos/keys](https://npm.io/package/@dxos/keys.md) 0.16.0
- [@dxos/effect](https://npm.io/package/@dxos/effect.md) 0.16.0
- [@dxos/compute](https://npm.io/package/@dxos/compute.md) 0.16.0

## Recent versions

- 0.16.0 (latest) — 2026-10-19
- 0.16.0-next-60712ab191a99ba90316cc4be753e9e11b17100a (next) — 2026-10-19
- 0.9.1-main.c7dcc2e112 (main) — 2026-06-19
- 0.16.0-next-b440559823fb87ed1a4590dab21ae924d4d76c3a — 2026-10-19
- 0.14.0 — 2026-10-10
- 0.13.0 — 2026-10-07
- 0.12.0-next-73daef452f1464b62efdbca75fb0067c1066f264 — 2026-08-27
- 0.12.0-next-2800d0376abcc62d5544afdd744b16b2b960434e — 2026-08-27
- 0.12.0-next-2be9f24c465d98f4bd186aa03ece788902e6c17a — 2026-08-27
- 1.0.0-next-bbabc02363f18d7643ea4160e3a7a7809870fd0d — 2026-08-10
- 0.11.1 — 2026-08-05
- 0.11.0 — 2026-08-05
- 0.10.0 — 2026-07-02
- 0.9.1-staging.ee54ba693a — 2026-07-02
- 0.9.0 — 2026-06-15
- … 47 more at https://npm.io/package/@dxos/operation/versions

## README

# @dxos/operation

Unified Operation Primitives for DXOS.

## Overview

This package provides the core primitives for defining and executing operations that can run both locally (as Intents) and remotely (as Functions).

## Usage

```typescript
import { Operation } from '@dxos/operation';
import * as Schema from 'effect/Schema';

// Define an operation
const CreateSpace = Operation.make({
  input: Schema.Struct({ name: Schema.String }),
  output: Schema.Struct({ id: Schema.String }),
  meta: {
    key: 'space.create',
    name: 'Create Space',
    description: 'Creates a new space',
  },
});

// Attach a handler (direct call)
const createSpaceWithHandler = Operation.withHandler(CreateSpace, (input) =>
  Effect.gen(function* () {
    // ... implementation
    return { id: 'space-id' };
  }),
);

// Or use in a pipe (piped call)
import * as Function from 'effect/Function';
const createSpaceWithHandler2 = Function.pipe(
  CreateSpace,
  Operation.withHandler((input) =>
    Effect.gen(function* () {
      // ... implementation
      return { id: 'space-id' };
    }),
  ),
);
```

## API

- `Operation.make<I, O>(props)` - Creates a new operation definition
- `Operation.withHandler<I, O, E, R>(op, handler)` - Attaches a handler to an operation (direct call)
- `Operation.withHandler<I, O, E, R>(handler)` - Returns a function for piped usage
- `OperationDefinition<I, O>` - The operation definition interface
- `OperationHandler<I, O, E, R>` - The handler type

---
_Source: https://npm.io/package/@dxos/operation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
