---
title: "Open"
description: "The @devframes/service-open wire service: open files in an editor or reveal them in the OS explorer over RPC, with workspace-root path containment and editor gating."
canonical_url: "https://devfra.me/add-ons/services/open"
---
# Open

> The @devframes/service-open wire service: open files in an editor or reveal them in the OS explorer over RPC, with workspace-root path containment and editor gating.

Open files in an editor or reveal them in the OS explorer, shared over RPC by every devframe on the host. Replaces per-devframe registration of the (deprecated) `devframe/recipes/common-rpc-functions` recipe with one install, feature-detectable from RPC clients, adding workspace-root path containment on top of editor gating.

Package: `@devframes/service-open` · Scope: `devframes:service:open`

## Installing

```ts
defineDevframe({
  importMetaUrl: import.meta.url,
  services: [
    {
      package: '@devframes/service-open',
      options: { editor: 'code' }
    },
  ],
})
```

A hub installs a shared instance with `initHub({ services: [createOpenService(options)] })`.

## Options

`OpenServiceOptions`: later installer wins on `editor`; `roots` union-merged.

| Option   | Type          | Description                                                                                                                             |
| -------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `editor` | `KnownEditor` | Preferred editor command (one of `KNOWN_EDITORS`). Auto-detected via `LAUNCH_EDITOR` and common defaults when omitted.                  |
| `roots`  | `string[]`    | Extra directories files may be opened from, on top of the context's `workspaceRoot` (e.g. a managed storage dir outside the workspace). |

## RPC functions

Registered under `devframes:service:open:*`, both `action`s. Paths may be absolute or relative to the `workspaceRoot`; the service refuses paths outside the workspace root plus the configured `roots` (`DS_OPEN_0002`), and gates `editor` to the `KNOWN_EDITORS` picklist so the surface can't spawn an arbitrary command.

| Function         | Args                                | Purpose                                                         |
| ---------------- | ----------------------------------- | --------------------------------------------------------------- |
| `open-in-editor` | `{ path, line?, column?, editor? }` | Open a file, optionally at a line/column, in the user's editor. |
| `open-in-finder` | `{ path }`                          | Reveal a path in the OS file explorer.                          |

## Node API

`ctx.services.get('@devframes/service-open')` returns the in-process `OpenServiceApi` (no RPC hop server-side): `openInEditor(input)` and `openInFinder({ path })`.

## On the RPC client

```ts
const rpc = await connectDevframe()

if (rpc.services.has('@devframes/service-open')) {
  const open = rpc.services.get('@devframes/service-open')!
  await open.rpc.call('open-in-editor', { path: 'src/main.ts', line: 42, column: 7 })
  await open.rpc.call('open-in-finder', { path: 'public' })
}
```

## Source

[`services/open`](https://github.com/devframes/devframe/tree/main/services/open)


## Sitemap

See the full [sitemap](https://devfra.me/sitemap.md) for all pages.
