Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/scripts/ci_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def changed(pattern):
r"^(examples/[^/]*(plugin|extension)[^/]*/|examples/memory-plugin-shared/|"
r"agent-plugins/|\.github/scripts/.*(plugin|marketplace|installer)|"
r"\.github/workflows/pr\.yml)|"
r"^(examples/)?(\.claude-plugin|\.agents/plugins)/marketplace\.json$"
r"^(examples/)?(\.claude-plugin|\.agents/plugins)/marketplace\.json$|"
r"^tests/fixtures/server_feature_versions\.json$"
)
# Keep unfamiliar paths on the safe side: only known independent trees
# bypass API tests. Added/removed/renamed paths are all included in the diff.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gateway.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: OpenViking Gateway
on:
pull_request:
paths: ["openviking_gateway/**", "tests/gateway/**", "scripts/gateway_*", "tests/fixtures/gateway_upstream_urls.json", "openviking_cli/utils/config/openviking_gateway_config.py", "openviking_cli/utils/config/encryption_config.py", "openviking_cli/utils/config/agfs_config.py", "openviking/server/account_stores/redis_client.py", "pyproject.toml", "MANIFEST.in", "openviking_cli/setup_wizard.py", "openviking/crypto/**", ".github/workflows/gateway.yml"]
paths: ["openviking_gateway/**", "tests/gateway/**", "scripts/gateway_*", "tests/fixtures/gateway_upstream_urls.json", "tests/fixtures/server_feature_versions.json", "openviking_cli/utils/config/openviking_gateway_config.py", "openviking_cli/utils/config/encryption_config.py", "openviking_cli/utils/config/agfs_config.py", "openviking/server/account_stores/redis_client.py", "pyproject.toml", "MANIFEST.in", "openviking_cli/setup_wizard.py", "openviking/crypto/**", ".github/workflows/gateway.yml"]
workflow_dispatch:
jobs:
test:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ jobs:
- name: Committed generator output must be up to date
run: |
# A module the closure grew reaches the committed lanes as an
# untracked file, which `git diff` does not see at all.
status=$(git status --porcelain --untracked-files=normal -- examples agent-plugins)
# untracked file, which `git diff` does not see at all. The gateway
# package holds a committed copy of the server feature table.
status=$(git status --porcelain --untracked-files=normal -- examples agent-plugins openviking_gateway)
if [ -n "$status" ]; then
printf '%s\n' "$status"
exit 1
Expand Down
21 changes: 21 additions & 0 deletions docs/en/agent-integrations/02-claude-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ Configuration priority: Environment variables > `ovcli.conf` > `ov.conf` > Built
| `OPENVIKING_CAPTURE_FILTERS` | `""` | CSV of sed-style regex rules applied to every captured turn (same grammar) |
| `OPENVIKING_MEMORY_ENABLED` | (auto) | Force on/off |
| `OPENVIKING_DEBUG` | `false` | Write logs to `~/.openviking/logs/cc-hooks.log` |
| `OPENVIKING_SEAL_SECRETS` | `false` | Seal secrets out of what the model sees (`sealSecrets`; needs OpenViking server 0.5.7 or newer) |
| `OPENVIKING_ENROLL_TOOL_SECRETS` | `false` | With `sealSecrets` on, also store new secrets found in tool output (`enrollToolSecrets`) |

Most of these knobs can also live in `ovcli.conf` under `plugin` — see [Plugin Settings](../configuration/02-client.md#plugin-settings). The two filter knobs are better written there, as JSON arrays, because the environment form is split on commas.

Sealing secrets is described in [Seal secrets](#seal-secrets).

If recall latency matters most, see [Low-latency recall](./01-overview.md#low-latency-recall) for the environment-variable and `ovcli.conf` settings that disable query expansion and result compression.

With a user/admin key, the server derives identity from the key. Set `OPENVIKING_ACCOUNT` and `OPENVIKING_USER` only for trusted mode, using values supplied by your administrator. The complete list of environment variables is available in the [plugin README](https://github.com/volcengine/OpenViking/blob/main/examples/claude-code-memory-plugin/README.md#configuration).
Expand All @@ -126,6 +130,23 @@ Under each answer, the plugin adds a one-line card listing the OpenViking source

The cards need Claude Code 2.1.286 or newer with plugin hooks modules enabled. On older versions, or with modules off, no cards are shown, and recall, capture and the other hooks work as before. See [Source cards](https://github.com/volcengine/OpenViking/blob/main/examples/claude-code-memory-plugin/README.md#source-cards) in the plugin README.

## Seal secrets {#seal-secrets}

With `sealSecrets` on, the plugin replaces the secrets your OpenViking server knows with <code v-pre>{{ov_privacy:…}}</code> references in what Claude reads, and gives tools the real values back. It is off by default and needs OpenViking server 0.5.7 or newer. It runs on your machine.

| Setting | Environment variable | Default | Effect |
|---------|----------------------|---------|--------|
| `sealSecrets` | `OPENVIKING_SEAL_SECRETS` | `false` | Turns sealing on |
| `enrollToolSecrets` | `OPENVIKING_ENROLL_TOOL_SECRETS` | `false` | Also stores new secrets found in tool output |

Set them in `ovcli.conf` (see the plugin README) or in the environment; a changed setting takes effect in a new session. Sealing runs in the plugin's hooks module, so it needs what [Source cards](#source-cards) need; where the module is not loaded, nothing is sealed.

- **Sealed:** your prompt, tool results, and the files, reminders and hook context Claude Code attaches. New secrets are stored from your prompt, and from tool results only with `enrollToolSecrets`. A reference Claude writes in a tool call becomes the real value before the tool runs. The local transcript stores prompts and tool results with references; for attached files and reminders it keeps Claude Code's own record, with the original text.
- **When sealing cannot be done** (a server older than 0.5.7, a failed `/health`, seal or resolve call), it stops: your prompt is not sent, a tool result is withheld, and a tool call whose references cannot be resolved does not run. The message says why. Upgrade the server or restore the connection, or turn `sealSecrets` off.
- **Not covered:** the system prompt, slash-command arguments, skill bodies, and history written before sealing was turned on.

Details: [plugin README](https://github.com/volcengine/OpenViking/blob/main/examples/claude-code-memory-plugin/README.md#seal-secrets).

## Troubleshooting

| Issue | Cause | Solution |
Expand Down
17 changes: 17 additions & 0 deletions docs/en/agent-integrations/11-pi.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ Settings resolve highest priority first: `OPENVIKING_*` environment variables, t

Takeover is fail-open: if pending writes cannot flush, commit fails, the archive overview is not ready, or the branch fingerprint no longer matches, pi keeps full local history or falls back to its default compaction. Set `OPENVIKING_DEBUG_LOG=/tmp/ov-pi.log` when validating boundary advances; the log is JSON Lines, one record per event. `OV_DEBUG_LOG` is a deprecated alias that still works.

## Seal secrets {#seal-secrets}

`sealSecrets` keeps the secrets your OpenViking server knows out of what the model sees; a reference the model writes in a tool call is turned back into the real value for the tool only. It is off by default and needs OpenViking server 0.5.7 or newer.

| Setting | Environment variable | Default | Effect |
|---------|----------------------|---------|--------|
| `sealSecrets` | `OPENVIKING_SEAL_SECRETS` | `false` | Seals what you type and every tool result |
| `enrollToolSecrets` | `OPENVIKING_ENROLL_TOOL_SECRETS` | `false` | Also stores new secrets found in tool results |

Neither can be set in a workspace file.

- **Sealed:** what you type and every tool result, before pi stores or sends them, so the model and the session file see references (<code v-pre>{{ov_privacy:…}}</code>). New secrets in what you type are stored automatically; a reference the model writes in a tool call becomes the real value for the tool only.
- **When sealing cannot be done** (a server older than 0.5.7, a failed `/health`, seal or resolve call), it stops: what you typed is not sent, a tool result is withheld, and a tool call whose references cannot be resolved does not run. pi tells you why. Upgrade the server or restore the connection, or turn `sealSecrets` off.
- **Not covered:** the system prompt and context files, skill and prompt-template text, recall blocks, compaction summaries, and history from before sealing was turned on.

Details: [extension README](https://github.com/volcengine/OpenViking/blob/main/examples/pi-coding-agent-extension/README.md#secret-sealing).

## Verify

Start `pi`. Once connected, the footer shows an `OV ✓` status segment, and `/viking` prints the current session mapping and how many `openviking_*` tools registered. Ask pi about something you mentioned in an earlier session to confirm recall.
Expand Down
1 change: 1 addition & 0 deletions docs/en/api/01-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ This catalog follows the routes actually mounted by the server. Each group headi
| GET | `/api/v1/privacy-configs` | List privacy configuration categories |
| GET | `/api/v1/privacy-configs/tree` | List current targets and field metadata as a tree without values |
| POST | `/api/v1/privacy-configs/scan` | Scan or repair registered values in content |
| POST | `/api/v1/privacy-configs/seal` | Replace registered values in texts with references, optionally enrolling new tokens |
| GET | `/api/v1/privacy-configs/{category}` | List category targets |
| GET | `/api/v1/privacy-configs/{category}/{target_key}` | Get the active configuration |
| GET | `/api/v1/privacy-configs/{category}/{target_key}/fields` | List safe active-field metadata without values |
Expand Down
99 changes: 98 additions & 1 deletion docs/en/api/10-privacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Mutations of the same `category + target_key` for the same user require the targ
| GET | `/api/v1/privacy-configs` | List privacy config categories |
| GET | `/api/v1/privacy-configs/tree` | List current targets and field metadata as a tree without values |
| POST | `/api/v1/privacy-configs/scan` | Scan or repair registered values in stored content |
| POST | `/api/v1/privacy-configs/seal` | Replace registered secrets in caller-supplied texts; optionally enroll new ones |
| GET | `/api/v1/privacy-configs/{category}` | List targets under a category |
| GET | `/api/v1/privacy-configs/{category}/{target_key}` | Get active config (`meta + current`) |
| GET | `/api/v1/privacy-configs/{category}/{target_key}/fields` | List safe active-field metadata without values |
Expand All @@ -39,6 +40,7 @@ Mutations of the same `category + target_key` for the same user require the targ
- Rotate keys by writing a new version
- Roll back to an old version
- Restore values from placeholders when reading Skill or Session content
- Keep secrets out of model requests (see [Seal Texts](#seal-texts))

---

Expand All @@ -63,6 +65,89 @@ By default, a fixed order selects a restorable reference. Set `OPENVIKING_PRIVAC

---

## Seal Texts

Replace the caller's registered values (in the `credential` and `auto` categories) in caller-supplied texts with their canonical references, and optionally store new tokens it recognizes, for example before the texts are sent to a model provider. The result does not depend on the user's privacy `mode`; it also works when `mode` is `off`. Intended for clients such as the gateway and agent plugins.

```text
POST /api/v1/privacy-configs/seal
```

```json
{
"texts": [
{"text": "My new GitHub token is ghp_..., use it from now on", "enroll": true},
{"text": "(tool output)"}
]
}
```

```json
{
"status": "ok",
"result": {
"revision": "4f0c...-9a1b...",
"texts": [
{
"text": "My new GitHub token is {{ov_privacy:alice:viking://~/privacy/auto/github-k3j2m8#/values/token}}, use it from now on",
"replaced": [
{"start": 23, "end": 63, "reference": "{{ov_privacy:alice:viking://~/privacy/auto/github-k3j2m8#/values/token}}", "created": true, "temporary": true}
]
},
null
]
}
}
```

**Request**

| Field | Type | Required | Meaning |
|-------|------|----------|---------|
| `texts` | array | Yes | 1 to 1024 items whose UTF-8 sizes sum to at most 16 MiB |
| `texts[].text` | string | Yes | The text to seal |
| `texts[].enroll` | bool | No (default `false`) | Also store unregistered tokens it recognizes; see **Enrollment** below |

**Response**

| Field | Meaning |
|-------|---------|
| `result.revision` | Opaque string that changes after every write to `credential` or `auto` and every change to `never_mask` or `custom_rules`. It already includes what the call enrolled. Compare it for equality only, for example as part of a cache key |
| `result.texts[i]` | `null` when nothing in that text was replaced; keep the original text |
| `result.texts[i].text` | The text with references in place of the values |
| `result.texts[i].replaced[].start`, `end` | Unicode code point offsets into the original text; `end` is exclusive |
| `result.texts[i].replaced[].reference` | The canonical reference that replaced the span |
| `result.texts[i].replaced[].temporary` | True exactly when the reference is in the `auto` category, that is, the value has not been saved under a proper name yet. It depends only on the vault at the returned `revision`, so callers may cache it under that revision |
| `result.texts[i].replaced[].created` | True for every occurrence, in any text of the request, of a value enrolled by this call. A statistic about this one call; do not cache it or base decisions on it |

**What is matched**

- Matching follows the storage-path rules: string values of at least 6 characters, `never_mask` excluded, existing <code v-pre>{{ov_privacy:...}}</code> spans skipped, and the same ambiguity handling.
- Registered values are those of the `credential` category and of the `auto` category, which holds automatically enrolled values (see **Enrollment**). The storage-path sanitizer does not look at `auto`.
- Unlike the storage paths, seal also matches the values of earlier stored versions of each target, so a rotated token that is still in a conversation's history keeps being replaced. An earlier value gets the reference of its field, the same one the current value gets. When a value is held by several fields, a `credential` field wins over an `auto` one, and within a category a current value wins over an earlier one. Deleting a target removes its history, and its values are no longer sealed.

**Enrollment**

- With `enroll: true`, tokens recognized by the built-in detectors and the user's `custom_rules` (minus `never_mask`) that are not registered yet are stored as one new target each in the `auto` category, named `<rule>-<random suffix>` with field `token` and label `{"ov.rule": "<rule>"}`. Their reference is <code v-pre>{{ov_privacy:&lt;owner&gt;:viking://~/privacy/auto/&lt;target&gt;#/values/token}}</code>.
- The same value always yields the same reference, also across workers. Every occurrence of a value enrolled by this call, in any text of the request, reports `created: true`.
- At most 1024 new values can be enrolled per call; a request with more returns `RESOURCE_EXHAUSTED` and enrolls none of them. Because enrollment is idempotent, a caller that timed out can simply retry.

To give an enrolled entry a proper name, write its reference as a value (see [upsert_privacy_config()](#upsert-privacy-config)); the `auto` entry is then removed. Entries in `auto` otherwise stay and accumulate; they can be listed, resolved and deleted like any other target. Only the seal endpoint writes into `auto`: upsert and patch with `category=auto` are rejected with `INVALID_ARGUMENT`.

**Errors**

| Condition | Error |
|-----------|-------|
| `texts` has fewer than 1 or more than 1024 items | `INVALID_ARGUMENT` |
| The texts' UTF-8 sizes sum to more than 16 MiB | `RESOURCE_EXHAUSTED` |
| More than 1024 new values to enroll | `RESOURCE_EXHAUSTED`; none of them is enrolled |
| More than 10,000 replacements in total | `RESOURCE_EXHAUSTED` |

- An error never comes back as unchanged text.
- Callers should treat any non-`ok` outcome, including HTTP 404 from an older server, as a failure and not forward the original text.

---

## Data Structures

### current (active version snapshot)
Expand Down Expand Up @@ -146,7 +231,7 @@ curl -X GET http://localhost:1933/api/v1/privacy-configs \
}
```

Only categories with stored configs are returned; a Session with no extracted values does not create a privacy config.
Only categories with stored configs are returned, including `auto` once something was enrolled; a Session with no extracted values does not create a privacy config.

---

Expand All @@ -165,6 +250,8 @@ GET /api/v1/privacy-configs/tree
The optional `category` query parameter limits the tree to one category. An invalid
identifier returns `INVALID_ARGUMENT`. An empty store returns `categories: []`;
a missing filtered category returns that category with `targets: []`.
The HTTP route and `ov privacy tree` list every category. The MCP `privacy_tree` tool
leaves the `auto` category out unless it is called with `category="auto"`.

```bash
curl "http://localhost:1933/api/v1/privacy-configs/tree?category=credential" \
Expand Down Expand Up @@ -350,6 +437,10 @@ Write a new version and set it as active.
- `values` replaces the complete value map for that version; omitted keys are absent from the new snapshot
- New keys are allowed and persisted
- If `values` is identical to the current version, no new version is created
- A top-level string value that is, as a whole, a reference to a field in the caller's own `credential` or `auto` category stores that field's current value instead of the reference text. Writing to a new target renames the credential; writing to an existing target rotates it to a new version. A source in `auto` is deleted after the write succeeds (if that cleanup fails, the write still stands); a source in `credential` is kept. The destination may not be in `auto`
- When at least one value in the request was such a reference, the response's `values` holds each field's own canonical reference in place of every stored value, so the copied secret is never echoed (also by `ov privacy upsert`, in table and JSON output). Requests with only plain values get the stored values back as before
- Any other top-level string value that contains a reference is rejected with `INVALID_ARGUMENT`: references to another category or user, to a missing target or field, and references inside a longer string. References nested inside object or array values are not inspected and are stored as written. This also applies to PATCH, the MCP `privacy_upsert` tool, and the CLI
- A target can carry a short description in the label `description`. `list_privacy_tree()` returns it on each target that has one; other labels are not returned there. The MCP `privacy_upsert` tool takes an optional `description` (at most 500 characters) that sets this label and keeps the other labels; without it, labels stay as they are. From the CLI, pass `--labels-json '{"description":"..."}'`

**HTTP API**

Expand Down Expand Up @@ -418,6 +509,12 @@ PATCH /api/v1/privacy-configs/{category}/{target_key}
}
```

A whole-value reference to a `credential` or `auto` field is copied the same way as for upsert, so a model that only holds a reference can rename or rotate a credential without seeing it. As with upsert, the response then shows every value as its field's reference. For example, this body saves an automatically enrolled token as `pat`:

```json
{"values": {"pat": "{{ov_privacy:alice:viking://~/privacy/auto/github-k3j2m8#/values/token}}"}}
```

Canonical CLI `--field` and `--field-*` flags use this endpoint without reading current values in the CLI. `--key` and `--key-*` remain backward-compatible aliases:

```bash
Expand Down
Loading
Loading