@diffra-ai/cli 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -47
- package/dist/bundle/chunks/{anthropic-messages-HME6WDIM.js → anthropic-messages-5EMOURYI.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-WKSFBZF5.js → azure-openai-responses-N67KWG2X.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-SMYD2SB5.js → chunk-3UNTEQ65.js} +1 -1
- package/dist/bundle/chunks/{chunk-MJRIJM22.js → chunk-BF423NQ7.js} +1 -1
- package/dist/bundle/chunks/{chunk-QMZGTPRI.js → chunk-CES65UJH.js} +1 -1
- package/dist/bundle/chunks/{chunk-PXE534VH.js → chunk-HFTZ6OJJ.js} +2 -2
- package/dist/bundle/chunks/{chunk-RUI3NOFB.js → chunk-NEFH2K3C.js} +1 -1
- package/dist/bundle/chunks/{chunk-E3MJ4MPN.js → chunk-PISJX26Y.js} +1 -1
- package/dist/bundle/chunks/{chunk-6L2FT6AE.js → chunk-QYYUGS66.js} +1 -1
- package/dist/bundle/chunks/{chunk-3MKQN3ZR.js → chunk-RLMZZV4Q.js} +1 -1
- package/dist/bundle/chunks/{chunk-GRDBYTYT.js → chunk-RTPG7C5I.js} +4 -4
- package/dist/bundle/chunks/{chunk-MITPYV3F.js → chunk-VOKUVFV4.js} +1 -1
- package/dist/bundle/chunks/{chunk-PQGGR7SQ.js → chunk-VWWMBH3G.js} +1 -1
- package/dist/bundle/chunks/{cli-GKHAGQO6.js → cli-55VO5MAJ.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-PVUECIVD.js → cloudflare-workers-ai-system-one-HB5U67WC.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-2YH7DK5J.js → google-generative-ai-XRHE7R52.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-QNIS4SPE.js → google-vertex-75CQOPKC.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-EMBT3ZMY.js → llama-cpp-classify-LKIRB7ZR.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-RCHJWX2M.js → mistral-conversations-KLGIHK73.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-LBZQ7HUY.js → openai-codex-responses-7L5VV67U.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-U7NS5GFY.js → openai-completions-RBF6UXDW.js} +1 -1
- package/dist/bundle/chunks/{openai-decisions-YC4ZEGAR.js → openai-decisions-W3PJQIOF.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-4YX6XMEO.js → openai-responses-W5ZMLOTR.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-QPPGKFJY.js → openrouter-images-4FW6VFV4.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-5W3GZ7B6.js → pi-messages-RT7FVQ4G.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-GWMQ2NLX.js → typesafe-system-one-DSJ7OYVL.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-ENTYMDSQ.js → virtual-modules-M75O3ECA.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/extensions/types.d.ts +2 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/docs/approval-modes.md +99 -99
- package/docs/cli.md +380 -380
- package/docs/docs.json +264 -264
- package/docs/environment-variables.md +110 -110
- package/docs/extensions.md +3 -2
- package/docs/security.md +100 -100
- package/docs/settings.md +198 -198
- package/package.json +6 -6
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
# Environment Variables
|
|
2
|
-
|
|
3
|
-
Diffra uses environment variables in three ways:
|
|
4
|
-
|
|
5
|
-
- Variables such as `DIFFRA_OFFLINE` configure the Diffra process.
|
|
6
|
-
- Diffra sets process markers so child processes can identify Diffra as the launching agent.
|
|
7
|
-
- Commands run by the LLM-callable shell tools receive `PI_*` variables describing the current session.
|
|
8
|
-
|
|
9
|
-
Provider API-key variables are documented separately in [Providers](providers.md#use-an-api-key-from-the-environment).
|
|
10
|
-
|
|
11
|
-
## Process Marker
|
|
12
|
-
|
|
13
|
-
The CLI and RPC entry points set two process markers:
|
|
14
|
-
|
|
15
|
-
- `AI_AGENT=diffra` is a generic marker that lets tooling identify Diffra as the agent that launched the process.
|
|
16
|
-
- `DIFFRA_CODING_AGENT=true` is Pi-specific and lets child processes detect that they run inside Diffra.
|
|
17
|
-
|
|
18
|
-
Child processes inherit both markers. They are not session-specific and are not set automatically when Diffra is embedded through the SDK.
|
|
19
|
-
|
|
20
|
-
## Shell Tool Session Environment
|
|
21
|
-
|
|
22
|
-
Commands run by the `bash` and `powershell` tools receive the current Diffra session state:
|
|
23
|
-
|
|
24
|
-
| Variable | Description |
|
|
25
|
-
|----------|-------------|
|
|
26
|
-
| `DIFFRA_SESSION_ID` | Current session ID |
|
|
27
|
-
| `DIFFRA_SESSION_FILE` | Absolute path to the current session JSONL file; unset for ephemeral sessions |
|
|
28
|
-
| `DIFFRA_PROVIDER` | Currently selected model provider |
|
|
29
|
-
| `DIFFRA_MODEL` | Currently selected model ID |
|
|
30
|
-
| `DIFFRA_REASONING_LEVEL` | Current effective reasoning level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` |
|
|
31
|
-
|
|
32
|
-
The values are resolved when each command starts. Switching models or changing the reasoning level therefore affects the next shell command without restarting Diffra. `DIFFRA_PROVIDER` and `DIFFRA_MODEL` identify the selected Diffra model, not a different upstream model that a router may choose internally.
|
|
33
|
-
|
|
34
|
-
When asked which model or provider is running, inspect these variables instead of inferring the answer from the system prompt:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
printf '%s/%s\n' "$DIFFRA_PROVIDER" "$DIFFRA_MODEL"
|
|
38
|
-
printf 'reasoning=%s session=%s\n' "$DIFFRA_REASONING_LEVEL" "$DIFFRA_SESSION_ID"
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
The session file can be inspected directly when the session is persistent:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
if [ -n "$DIFFRA_SESSION_FILE" ]; then
|
|
45
|
-
tail -n 1 "$DIFFRA_SESSION_FILE"
|
|
46
|
-
fi
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
These variables are injected into the LLM-callable `bash` and `powershell` tools. They are not injected into user-entered `!` or `!!` commands.
|
|
50
|
-
|
|
51
|
-
### Custom Shell Tools
|
|
52
|
-
|
|
53
|
-
Tools created with `createBashTool()` or `createPowerShellTool()` expose the session environment by default when registered with Diffra. Injection happens before `spawnHook`, so a hook receives the variables in `ctx.env`:
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
const bashTool = createBashTool(cwd, {
|
|
57
|
-
spawnHook: (ctx) => ({
|
|
58
|
-
...ctx,
|
|
59
|
-
env: { ...ctx.env, CI: "1" },
|
|
60
|
-
}),
|
|
61
|
-
});
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Disable session metadata independently of the spawn hook:
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
const powershellTool = createPowerShellTool(cwd, {
|
|
68
|
-
exposeSessionEnvironment: false,
|
|
69
|
-
spawnHook: (ctx) => ctx,
|
|
70
|
-
});
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
When disabled, Diffra removes inherited values for these variables so nested Diffra processes do not expose stale parent-session metadata.
|
|
74
|
-
|
|
75
|
-
## Diffra Process Configuration
|
|
76
|
-
|
|
77
|
-
These variables are read by Diffra itself:
|
|
78
|
-
|
|
79
|
-
| Variable | Description |
|
|
80
|
-
|----------|-------------|
|
|
81
|
-
| `DIFFRA_CODING_AGENT_DIR` | Override the config directory; default is `~/.diffra/agent` |
|
|
82
|
-
| `DIFFRA_CODING_AGENT_SESSION_DIR` | Override session storage; overridden by `--session-dir` |
|
|
83
|
-
| `DIFFRA_PACKAGE_DIR` | Override the package directory, useful for Nix/Guix store paths |
|
|
84
|
-
| `DIFFRA_OFFLINE` | Disable automatic network activity, including model catalog refreshes |
|
|
85
|
-
| `DIFFRA_SANDBOX_HELPER` | Path of a `diffra-sandbox.exe` to use instead of the downloaded one (Windows [sandbox](sandbox.md)) |
|
|
86
|
-
| `DIFFRA_MEMORY_BASE_DIR` | Base directory of [auto memory](memory.md) instead of the agent directory |
|
|
87
|
-
| `DIFFRA_ENABLE_LSP`, `DIFFRA_DISABLE_LSP` | Set to `1` to turn [LSP code intelligence](lsp.md) on or off; off wins |
|
|
88
|
-
| `DIFFRA_DISABLE_CRON` | Set to `1` to turn [scheduled tasks](scheduled-tasks.md) off |
|
|
89
|
-
| `DIFFRA_CRON_MAX_AGE_DAYS` | Days until a recurring scheduled job expires, overriding `experimental.cronRecurringMaxAgeDays`; `0` for never |
|
|
90
|
-
| `DIFFRA_WEB_FETCH_PROCESSING_TIMEOUT_MS` | Time limit of `web_fetch`'s model step (default 300000) |
|
|
91
|
-
| `ENABLE_WEB_SEARCH`, `WEB_SEARCH_*` | Configure [`web_search`](web-tools.md#settings) |
|
|
92
|
-
| `DIFFRA_SKIP_VERSION_CHECK` | Disable the npm registry latest-version request |
|
|
93
|
-
| `DIFFRA_SELF_UPDATE_COMMAND` | Command `diffra update` runs to update Diffra itself, split on whitespace, with `{packageName}`, `{version}`, and `{installSpec}` placeholders. Takes precedence over the `selfUpdateCommand` setting. See [Custom update command](cli.md#custom-update-command) |
|
|
94
|
-
| `DIFFRA_TELEMETRY` | Override provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no` |
|
|
95
|
-
| `DIFFRA_CODEMODE_MAX_WORKERS` | Maximum codemode workers alive at once across all sessions in the process; default `2`. Each worker's script may use up to 256 MB. Raise it when one process runs several sessions, such as in-process subagents. Further scripts wait for a free worker. See [Codemode](codemode.md) |
|
|
96
|
-
| `DIFFRA_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
|
|
97
|
-
| `DIFFRA_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
|
|
98
|
-
| `DIFFRA_RADIUS_GATEWAY` | Override the Radius gateway origin used by `/bug` uploads |
|
|
99
|
-
| `DIFFRA_CLEAR_ON_SHRINK` | Set to `1` to clear empty rows when rendered content shrinks; the `terminal.clearOnShrink` setting takes precedence. See [Settings](settings.md) |
|
|
100
|
-
| `DIFFRA_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
|
|
101
|
-
| `DIFFRA_CLIPBOARD_OSC52` | Set to `1` to also send copied text to the terminal with OSC 52 after the local clipboard write, as Diffra does over SSH. Use it when a remote client reaches Diffra without SSH variables, such as a multiplexer attached from another machine or a remote IDE daemon |
|
|
102
|
-
| `DIFFRA_HYPERLINKS` | Override OSC 8 hyperlink detection with `1`, `0`, or `auto` |
|
|
103
|
-
| `DIFFRA_PROGRAM_STATUS` | Override OSC 7501 program status detection: `1` always reports, `0` never reports; otherwise Diffra reports only after the terminal confirms support. See [Terminal setup](terminal-setup.md#program-status) |
|
|
104
|
-
| `DIFFRA_IMAGE_PROTOCOL` | Override inline image detection with `kitty`, `iterm2`, `none`, or `auto` |
|
|
105
|
-
| `DIFFRA_TRUE_COLOR` | Override truecolor detection with `1`, `0`, or `auto` |
|
|
106
|
-
| `DIFFRA_TUI_ESC_TIMEOUT` | How long to wait after a lone ESC before treating it as Escape, in milliseconds; defaults to `100` over SSH and `10` otherwise. Increase if Alt-key input is misread as Escape |
|
|
107
|
-
| `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
|
|
108
|
-
| `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
|
|
109
|
-
|
|
110
|
-
Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and provider-specific configuration are listed in [Providers](providers.md#use-an-api-key-from-the-environment).
|
|
1
|
+
# Environment Variables
|
|
2
|
+
|
|
3
|
+
Diffra uses environment variables in three ways:
|
|
4
|
+
|
|
5
|
+
- Variables such as `DIFFRA_OFFLINE` configure the Diffra process.
|
|
6
|
+
- Diffra sets process markers so child processes can identify Diffra as the launching agent.
|
|
7
|
+
- Commands run by the LLM-callable shell tools receive `PI_*` variables describing the current session.
|
|
8
|
+
|
|
9
|
+
Provider API-key variables are documented separately in [Providers](providers.md#use-an-api-key-from-the-environment).
|
|
10
|
+
|
|
11
|
+
## Process Marker
|
|
12
|
+
|
|
13
|
+
The CLI and RPC entry points set two process markers:
|
|
14
|
+
|
|
15
|
+
- `AI_AGENT=diffra` is a generic marker that lets tooling identify Diffra as the agent that launched the process.
|
|
16
|
+
- `DIFFRA_CODING_AGENT=true` is Pi-specific and lets child processes detect that they run inside Diffra.
|
|
17
|
+
|
|
18
|
+
Child processes inherit both markers. They are not session-specific and are not set automatically when Diffra is embedded through the SDK.
|
|
19
|
+
|
|
20
|
+
## Shell Tool Session Environment
|
|
21
|
+
|
|
22
|
+
Commands run by the `bash` and `powershell` tools receive the current Diffra session state:
|
|
23
|
+
|
|
24
|
+
| Variable | Description |
|
|
25
|
+
|----------|-------------|
|
|
26
|
+
| `DIFFRA_SESSION_ID` | Current session ID |
|
|
27
|
+
| `DIFFRA_SESSION_FILE` | Absolute path to the current session JSONL file; unset for ephemeral sessions |
|
|
28
|
+
| `DIFFRA_PROVIDER` | Currently selected model provider |
|
|
29
|
+
| `DIFFRA_MODEL` | Currently selected model ID |
|
|
30
|
+
| `DIFFRA_REASONING_LEVEL` | Current effective reasoning level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` |
|
|
31
|
+
|
|
32
|
+
The values are resolved when each command starts. Switching models or changing the reasoning level therefore affects the next shell command without restarting Diffra. `DIFFRA_PROVIDER` and `DIFFRA_MODEL` identify the selected Diffra model, not a different upstream model that a router may choose internally.
|
|
33
|
+
|
|
34
|
+
When asked which model or provider is running, inspect these variables instead of inferring the answer from the system prompt:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
printf '%s/%s\n' "$DIFFRA_PROVIDER" "$DIFFRA_MODEL"
|
|
38
|
+
printf 'reasoning=%s session=%s\n' "$DIFFRA_REASONING_LEVEL" "$DIFFRA_SESSION_ID"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The session file can be inspected directly when the session is persistent:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
if [ -n "$DIFFRA_SESSION_FILE" ]; then
|
|
45
|
+
tail -n 1 "$DIFFRA_SESSION_FILE"
|
|
46
|
+
fi
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
These variables are injected into the LLM-callable `bash` and `powershell` tools. They are not injected into user-entered `!` or `!!` commands.
|
|
50
|
+
|
|
51
|
+
### Custom Shell Tools
|
|
52
|
+
|
|
53
|
+
Tools created with `createBashTool()` or `createPowerShellTool()` expose the session environment by default when registered with Diffra. Injection happens before `spawnHook`, so a hook receives the variables in `ctx.env`:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const bashTool = createBashTool(cwd, {
|
|
57
|
+
spawnHook: (ctx) => ({
|
|
58
|
+
...ctx,
|
|
59
|
+
env: { ...ctx.env, CI: "1" },
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Disable session metadata independently of the spawn hook:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const powershellTool = createPowerShellTool(cwd, {
|
|
68
|
+
exposeSessionEnvironment: false,
|
|
69
|
+
spawnHook: (ctx) => ctx,
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
When disabled, Diffra removes inherited values for these variables so nested Diffra processes do not expose stale parent-session metadata.
|
|
74
|
+
|
|
75
|
+
## Diffra Process Configuration
|
|
76
|
+
|
|
77
|
+
These variables are read by Diffra itself:
|
|
78
|
+
|
|
79
|
+
| Variable | Description |
|
|
80
|
+
|----------|-------------|
|
|
81
|
+
| `DIFFRA_CODING_AGENT_DIR` | Override the config directory; default is `~/.diffra/agent` |
|
|
82
|
+
| `DIFFRA_CODING_AGENT_SESSION_DIR` | Override session storage; overridden by `--session-dir` |
|
|
83
|
+
| `DIFFRA_PACKAGE_DIR` | Override the package directory, useful for Nix/Guix store paths |
|
|
84
|
+
| `DIFFRA_OFFLINE` | Disable automatic network activity, including model catalog refreshes |
|
|
85
|
+
| `DIFFRA_SANDBOX_HELPER` | Path of a `diffra-sandbox.exe` to use instead of the downloaded one (Windows [sandbox](sandbox.md)) |
|
|
86
|
+
| `DIFFRA_MEMORY_BASE_DIR` | Base directory of [auto memory](memory.md) instead of the agent directory |
|
|
87
|
+
| `DIFFRA_ENABLE_LSP`, `DIFFRA_DISABLE_LSP` | Set to `1` to turn [LSP code intelligence](lsp.md) on or off; off wins |
|
|
88
|
+
| `DIFFRA_DISABLE_CRON` | Set to `1` to turn [scheduled tasks](scheduled-tasks.md) off |
|
|
89
|
+
| `DIFFRA_CRON_MAX_AGE_DAYS` | Days until a recurring scheduled job expires, overriding `experimental.cronRecurringMaxAgeDays`; `0` for never |
|
|
90
|
+
| `DIFFRA_WEB_FETCH_PROCESSING_TIMEOUT_MS` | Time limit of `web_fetch`'s model step (default 300000) |
|
|
91
|
+
| `ENABLE_WEB_SEARCH`, `WEB_SEARCH_*` | Configure [`web_search`](web-tools.md#settings) |
|
|
92
|
+
| `DIFFRA_SKIP_VERSION_CHECK` | Disable the npm registry latest-version request |
|
|
93
|
+
| `DIFFRA_SELF_UPDATE_COMMAND` | Command `diffra update` runs to update Diffra itself, split on whitespace, with `{packageName}`, `{version}`, and `{installSpec}` placeholders. Takes precedence over the `selfUpdateCommand` setting. See [Custom update command](cli.md#custom-update-command) |
|
|
94
|
+
| `DIFFRA_TELEMETRY` | Override provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no` |
|
|
95
|
+
| `DIFFRA_CODEMODE_MAX_WORKERS` | Maximum codemode workers alive at once across all sessions in the process; default `2`. Each worker's script may use up to 256 MB. Raise it when one process runs several sessions, such as in-process subagents. Further scripts wait for a free worker. See [Codemode](codemode.md) |
|
|
96
|
+
| `DIFFRA_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
|
|
97
|
+
| `DIFFRA_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
|
|
98
|
+
| `DIFFRA_RADIUS_GATEWAY` | Override the Radius gateway origin used by `/bug` uploads |
|
|
99
|
+
| `DIFFRA_CLEAR_ON_SHRINK` | Set to `1` to clear empty rows when rendered content shrinks; the `terminal.clearOnShrink` setting takes precedence. See [Settings](settings.md) |
|
|
100
|
+
| `DIFFRA_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
|
|
101
|
+
| `DIFFRA_CLIPBOARD_OSC52` | Set to `1` to also send copied text to the terminal with OSC 52 after the local clipboard write, as Diffra does over SSH. Use it when a remote client reaches Diffra without SSH variables, such as a multiplexer attached from another machine or a remote IDE daemon |
|
|
102
|
+
| `DIFFRA_HYPERLINKS` | Override OSC 8 hyperlink detection with `1`, `0`, or `auto` |
|
|
103
|
+
| `DIFFRA_PROGRAM_STATUS` | Override OSC 7501 program status detection: `1` always reports, `0` never reports; otherwise Diffra reports only after the terminal confirms support. See [Terminal setup](terminal-setup.md#program-status) |
|
|
104
|
+
| `DIFFRA_IMAGE_PROTOCOL` | Override inline image detection with `kitty`, `iterm2`, `none`, or `auto` |
|
|
105
|
+
| `DIFFRA_TRUE_COLOR` | Override truecolor detection with `1`, `0`, or `auto` |
|
|
106
|
+
| `DIFFRA_TUI_ESC_TIMEOUT` | How long to wait after a lone ESC before treating it as Escape, in milliseconds; defaults to `100` over SSH and `10` otherwise. Increase if Alt-key input is misread as Escape |
|
|
107
|
+
| `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
|
|
108
|
+
| `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
|
|
109
|
+
|
|
110
|
+
Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and provider-specific configuration are listed in [Providers](providers.md#use-an-api-key-from-the-environment).
|
package/docs/extensions.md
CHANGED
|
@@ -1181,7 +1181,7 @@ UI methods for user interaction. See [Custom UI](#custom-ui) for full details.
|
|
|
1181
1181
|
|
|
1182
1182
|
### ctx.mode
|
|
1183
1183
|
|
|
1184
|
-
Current run mode: `"tui"`, `"rpc"`, `"json"`, or `"print"`. Use `ctx.mode === "tui"` to guard terminal-only features such as `custom()`, component factories, terminal input, and direct TUI rendering.
|
|
1184
|
+
Current run mode: `"tui"`, `"rpc"`, `"desktop"`, `"json"`, or `"print"`. Use `ctx.mode === "tui"` to guard terminal-only features such as `custom()`, component factories, terminal input, and direct TUI rendering.
|
|
1185
1185
|
|
|
1186
1186
|
### ctx.hasUI
|
|
1187
1187
|
|
|
@@ -3287,10 +3287,11 @@ const highlighted = highlightCode(code, lang);
|
|
|
3287
3287
|
|------|------------|-------------|-------|
|
|
3288
3288
|
| Interactive | `"tui"` | `true` | Full TUI with terminal rendering |
|
|
3289
3289
|
| RPC (`--mode rpc`) | `"rpc"` | `true` | Dialogs and notifications via JSON protocol; `custom()` returns `undefined`, component factories are ignored. See [RPC Extension UI](rpc-extension-ui.md) |
|
|
3290
|
+
| Desktop app (SDK host) | `"desktop"` | `true` | The host shows dialogs, notifications, status and widget text in its own interface; as in RPC mode, `custom()` returns `undefined` and component factories are ignored |
|
|
3290
3291
|
| JSON (`--mode json`) | `"json"` | `false` | Event stream to stdout; UI methods are no-ops |
|
|
3291
3292
|
| Print (`-p`) | `"print"` | `false` | Extensions run but can't prompt |
|
|
3292
3293
|
|
|
3293
|
-
Use `ctx.mode === "tui"` before TUI-specific features (`custom()`, component factories, terminal input). Use `ctx.hasUI` before dialog and notification methods
|
|
3294
|
+
Use `ctx.mode === "tui"` before TUI-specific features (`custom()`, component factories, terminal input). Use `ctx.hasUI` before dialog and notification methods, which work in TUI, RPC and desktop modes.
|
|
3294
3295
|
|
|
3295
3296
|
<a id="use-examples-as-the-implementation-reference"></a>
|
|
3296
3297
|
|
package/docs/security.md
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
# Run Diffra safely
|
|
2
|
-
|
|
3
|
-
Treat model-generated commands and code as untrusted. Diffra can read, change, and execute files with the permissions of the account that started it, and by default it does not ask for approval before tool calls. [Approval modes](approval-modes.md) can make it ask, let a classifier decide, or keep a session read-only, but they only decide which calls run, not what an allowed call can reach. The optional [sandbox](sandbox.md) limits what the model's commands and edits can write and whether they reach the network. Extensions, package installers, language servers, and other child processes run with those same permissions unless an operating-system or virtualization boundary restricts them.
|
|
4
|
-
|
|
5
|
-
Files, comments, instructions, command output, and model responses can steer the model through prompt injection. Project trust controls which project resources load at startup, but it does not make that content or the resulting actions safe.
|
|
6
|
-
|
|
7
|
-
Safety comes from limiting the files, credentials, processes, and network services Diffra can access and affect if a generated action is wrong or hostile. Watching the transcript, using project trust, and reviewing changes do not create a security boundary.
|
|
8
|
-
|
|
9
|
-
## Choose how to run Diffra
|
|
10
|
-
|
|
11
|
-
Different ways of running Diffra place different limits on what generated commands can access:
|
|
12
|
-
|
|
13
|
-
| How Diffra runs | What remains protected |
|
|
14
|
-
|---|---|
|
|
15
|
-
| Directly, with the permissions of its operating-system user | Anything that user cannot access. A dedicated user account can narrow those permissions, but Diffra still shares the operating system and network with other users. |
|
|
16
|
-
| Entirely inside a container, virtual machine, or sandbox | Host files and processes that you do not expose to the environment. Credentials and network services remain accessible if you make them available inside it. This is usually the strongest practical option. |
|
|
17
|
-
| Outside the isolated environment, with only its built-in tools running inside | Host resources are protected from actions performed through those tools. Diffra itself and other extensions remain outside the boundary, so this is a narrower form of isolation. |
|
|
18
|
-
| Directly, with the built-in [sandbox](sandbox.md) on | Files outside the writable folders, and the network when it is off, from the model's commands and edits. Reads stay open except on Windows with the elevated backend, and the unelevated Windows backend does not stop deletes. Extensions, MCP servers, and hooks run outside it. |
|
|
19
|
-
|
|
20
|
-
The working folder controls resource discovery and the default location for tools, but it does not prevent commands from accessing other paths available to the Diffra process.
|
|
21
|
-
|
|
22
|
-
Whichever option you choose, only provide the files and services required for the task. Keep credentials outside the environment where possible, or use narrowly scoped, short-lived credentials. Restrict network access when commands do not need it.
|
|
23
|
-
|
|
24
|
-
For setup instructions and the limitations of each isolation method, see [Run Diffra in an isolated environment](containerization.md).
|
|
25
|
-
|
|
26
|
-
<a id="project-trust"></a>
|
|
27
|
-
|
|
28
|
-
## Understand project trust
|
|
29
|
-
|
|
30
|
-
Project trust controls whether Diffra loads most settings and resources supplied by a working folder. It prevents a folder from silently loading executable extensions before you approve it.
|
|
31
|
-
|
|
32
|
-
Project trust is not a complete startup boundary. Diffra reads the project `sessionDir` setting while selecting or creating a session, before it resolves project trust. Declining trust prevents the remaining project settings and protected resources from loading, but it cannot undo that initial session-directory lookup.
|
|
33
|
-
|
|
34
|
-
Project trust does not limit what tool calls can access or affect. After Diffra starts, enabled tools still use the operating-system permissions of the Diffra process. Instructions and other content in the folder can also influence the model.
|
|
35
|
-
|
|
36
|
-
### Resources protected by project trust
|
|
37
|
-
|
|
38
|
-
Diffra requires a project-trust decision when it finds any of these resources from the current working directory:
|
|
39
|
-
|
|
40
|
-
- `.diffra/settings.json`
|
|
41
|
-
- `.diffra/mcp.json`
|
|
42
|
-
- `.diffra/extensions`, `.diffra/skills`, `.diffra/prompts`, or `.diffra/themes`
|
|
43
|
-
- `.diffra/SYSTEM.md` or `.diffra/APPEND_SYSTEM.md`
|
|
44
|
-
- project `.agents/skills` in the current directory or an ancestor directory
|
|
45
|
-
|
|
46
|
-
A bare `.diffra` directory does not require project trust.
|
|
47
|
-
|
|
48
|
-
Granting project trust allows Diffra to load:
|
|
49
|
-
|
|
50
|
-
- project settings
|
|
51
|
-
- project MCP servers from `.diffra/mcp.json`
|
|
52
|
-
- extensions, skills, prompt templates, themes, and system-prompt files under `.diffra`
|
|
53
|
-
- missing packages configured through project settings
|
|
54
|
-
- project-local and project-package extensions
|
|
55
|
-
|
|
56
|
-
Declining project trust skips those protected resources, except for the initial `sessionDir` lookup described above.
|
|
57
|
-
|
|
58
|
-
Context files such as `AGENTS.override.md`, `AGENTS.md`, and `CLAUDE.md` load regardless of project trust unless you disable context loading. Treat instructions in a folder as untrusted input even when you decline project trust.
|
|
59
|
-
|
|
60
|
-
### How Diffra chooses a trust decision
|
|
61
|
-
|
|
62
|
-
A command-line `--approve` or `--no-approve` override applies first. When protected resources exist and there is no command-line override:
|
|
63
|
-
|
|
64
|
-
1. User-level and command-line extensions can handle the `project_trust` event. The first extension that returns yes or no owns the decision.
|
|
65
|
-
2. If no extension decides, Diffra looks for a saved decision for the current directory or one of its parents. The closest decision applies.
|
|
66
|
-
3. If no saved decision applies, Diffra follows the global `defaultProjectTrust` setting, whose default is `"ask"`.
|
|
67
|
-
|
|
68
|
-
Saved decisions use canonical directory paths and live in:
|
|
69
|
-
|
|
70
|
-
```text
|
|
71
|
-
~/.diffra/agent/trust.json
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Use `/trust` to save a decision for future Diffra processes.
|
|
75
|
-
|
|
76
|
-
### Project trust without an interactive prompt
|
|
77
|
-
|
|
78
|
-
Print, JSON, and RPC modes cannot show the built-in trust prompt. If no command-line override, extension, or saved decision applies:
|
|
79
|
-
|
|
80
|
-
- `defaultProjectTrust: "always"` loads protected project resources.
|
|
81
|
-
- `defaultProjectTrust: "ask"` or `"never"` skips them.
|
|
82
|
-
|
|
83
|
-
Use `--approve` or `--no-approve` when an automated run needs an explicit one-time decision.
|
|
84
|
-
|
|
85
|
-
## Reduce impact and improve recovery
|
|
86
|
-
|
|
87
|
-
These practices do not replace isolation, but they reduce exposure or make recovery easier:
|
|
88
|
-
|
|
89
|
-
- Give Diffra access only to files and services required for the task.
|
|
90
|
-
- Use snapshots, backups, or version control before substantial changes.
|
|
91
|
-
- Review extensions and packages before loading them. Extensions execute inside the Diffra process.
|
|
92
|
-
- Prefer narrowly scoped, short-lived credentials.
|
|
93
|
-
- Review diffs and generated output before applying results to another system.
|
|
94
|
-
- Review sessions before exporting or sharing them. They can contain prompts, tool arguments, command output, file contents, and credentials exposed during the conversation.
|
|
95
|
-
|
|
96
|
-
## Report a security issue
|
|
97
|
-
|
|
98
|
-
Follow the repository [Security Policy](https://github.com/DingxinTao0417/diffra-cli/blob/main/SECURITY.md). Do not open a public issue for a security-sensitive report.
|
|
99
|
-
|
|
100
|
-
Expected local-agent behavior, prompt injection from untrusted content, the documented limits of the built-in sandbox, and behavior from user-installed extensions or skills are generally outside the security boundary unless the report demonstrates a privilege-boundary bypass or access that the local user did not already have.
|
|
1
|
+
# Run Diffra safely
|
|
2
|
+
|
|
3
|
+
Treat model-generated commands and code as untrusted. Diffra can read, change, and execute files with the permissions of the account that started it, and by default it does not ask for approval before tool calls. [Approval modes](approval-modes.md) can make it ask, let a classifier decide, or keep a session read-only, but they only decide which calls run, not what an allowed call can reach. The optional [sandbox](sandbox.md) limits what the model's commands and edits can write and whether they reach the network. Extensions, package installers, language servers, and other child processes run with those same permissions unless an operating-system or virtualization boundary restricts them.
|
|
4
|
+
|
|
5
|
+
Files, comments, instructions, command output, and model responses can steer the model through prompt injection. Project trust controls which project resources load at startup, but it does not make that content or the resulting actions safe.
|
|
6
|
+
|
|
7
|
+
Safety comes from limiting the files, credentials, processes, and network services Diffra can access and affect if a generated action is wrong or hostile. Watching the transcript, using project trust, and reviewing changes do not create a security boundary.
|
|
8
|
+
|
|
9
|
+
## Choose how to run Diffra
|
|
10
|
+
|
|
11
|
+
Different ways of running Diffra place different limits on what generated commands can access:
|
|
12
|
+
|
|
13
|
+
| How Diffra runs | What remains protected |
|
|
14
|
+
|---|---|
|
|
15
|
+
| Directly, with the permissions of its operating-system user | Anything that user cannot access. A dedicated user account can narrow those permissions, but Diffra still shares the operating system and network with other users. |
|
|
16
|
+
| Entirely inside a container, virtual machine, or sandbox | Host files and processes that you do not expose to the environment. Credentials and network services remain accessible if you make them available inside it. This is usually the strongest practical option. |
|
|
17
|
+
| Outside the isolated environment, with only its built-in tools running inside | Host resources are protected from actions performed through those tools. Diffra itself and other extensions remain outside the boundary, so this is a narrower form of isolation. |
|
|
18
|
+
| Directly, with the built-in [sandbox](sandbox.md) on | Files outside the writable folders, and the network when it is off, from the model's commands and edits. Reads stay open except on Windows with the elevated backend, and the unelevated Windows backend does not stop deletes. Extensions, MCP servers, and hooks run outside it. |
|
|
19
|
+
|
|
20
|
+
The working folder controls resource discovery and the default location for tools, but it does not prevent commands from accessing other paths available to the Diffra process.
|
|
21
|
+
|
|
22
|
+
Whichever option you choose, only provide the files and services required for the task. Keep credentials outside the environment where possible, or use narrowly scoped, short-lived credentials. Restrict network access when commands do not need it.
|
|
23
|
+
|
|
24
|
+
For setup instructions and the limitations of each isolation method, see [Run Diffra in an isolated environment](containerization.md).
|
|
25
|
+
|
|
26
|
+
<a id="project-trust"></a>
|
|
27
|
+
|
|
28
|
+
## Understand project trust
|
|
29
|
+
|
|
30
|
+
Project trust controls whether Diffra loads most settings and resources supplied by a working folder. It prevents a folder from silently loading executable extensions before you approve it.
|
|
31
|
+
|
|
32
|
+
Project trust is not a complete startup boundary. Diffra reads the project `sessionDir` setting while selecting or creating a session, before it resolves project trust. Declining trust prevents the remaining project settings and protected resources from loading, but it cannot undo that initial session-directory lookup.
|
|
33
|
+
|
|
34
|
+
Project trust does not limit what tool calls can access or affect. After Diffra starts, enabled tools still use the operating-system permissions of the Diffra process. Instructions and other content in the folder can also influence the model.
|
|
35
|
+
|
|
36
|
+
### Resources protected by project trust
|
|
37
|
+
|
|
38
|
+
Diffra requires a project-trust decision when it finds any of these resources from the current working directory:
|
|
39
|
+
|
|
40
|
+
- `.diffra/settings.json`
|
|
41
|
+
- `.diffra/mcp.json`
|
|
42
|
+
- `.diffra/extensions`, `.diffra/skills`, `.diffra/prompts`, or `.diffra/themes`
|
|
43
|
+
- `.diffra/SYSTEM.md` or `.diffra/APPEND_SYSTEM.md`
|
|
44
|
+
- project `.agents/skills` in the current directory or an ancestor directory
|
|
45
|
+
|
|
46
|
+
A bare `.diffra` directory does not require project trust.
|
|
47
|
+
|
|
48
|
+
Granting project trust allows Diffra to load:
|
|
49
|
+
|
|
50
|
+
- project settings
|
|
51
|
+
- project MCP servers from `.diffra/mcp.json`
|
|
52
|
+
- extensions, skills, prompt templates, themes, and system-prompt files under `.diffra`
|
|
53
|
+
- missing packages configured through project settings
|
|
54
|
+
- project-local and project-package extensions
|
|
55
|
+
|
|
56
|
+
Declining project trust skips those protected resources, except for the initial `sessionDir` lookup described above.
|
|
57
|
+
|
|
58
|
+
Context files such as `AGENTS.override.md`, `AGENTS.md`, and `CLAUDE.md` load regardless of project trust unless you disable context loading. Treat instructions in a folder as untrusted input even when you decline project trust.
|
|
59
|
+
|
|
60
|
+
### How Diffra chooses a trust decision
|
|
61
|
+
|
|
62
|
+
A command-line `--approve` or `--no-approve` override applies first. When protected resources exist and there is no command-line override:
|
|
63
|
+
|
|
64
|
+
1. User-level and command-line extensions can handle the `project_trust` event. The first extension that returns yes or no owns the decision.
|
|
65
|
+
2. If no extension decides, Diffra looks for a saved decision for the current directory or one of its parents. The closest decision applies.
|
|
66
|
+
3. If no saved decision applies, Diffra follows the global `defaultProjectTrust` setting, whose default is `"ask"`.
|
|
67
|
+
|
|
68
|
+
Saved decisions use canonical directory paths and live in:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
~/.diffra/agent/trust.json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Use `/trust` to save a decision for future Diffra processes.
|
|
75
|
+
|
|
76
|
+
### Project trust without an interactive prompt
|
|
77
|
+
|
|
78
|
+
Print, JSON, and RPC modes cannot show the built-in trust prompt. If no command-line override, extension, or saved decision applies:
|
|
79
|
+
|
|
80
|
+
- `defaultProjectTrust: "always"` loads protected project resources.
|
|
81
|
+
- `defaultProjectTrust: "ask"` or `"never"` skips them.
|
|
82
|
+
|
|
83
|
+
Use `--approve` or `--no-approve` when an automated run needs an explicit one-time decision.
|
|
84
|
+
|
|
85
|
+
## Reduce impact and improve recovery
|
|
86
|
+
|
|
87
|
+
These practices do not replace isolation, but they reduce exposure or make recovery easier:
|
|
88
|
+
|
|
89
|
+
- Give Diffra access only to files and services required for the task.
|
|
90
|
+
- Use snapshots, backups, or version control before substantial changes.
|
|
91
|
+
- Review extensions and packages before loading them. Extensions execute inside the Diffra process.
|
|
92
|
+
- Prefer narrowly scoped, short-lived credentials.
|
|
93
|
+
- Review diffs and generated output before applying results to another system.
|
|
94
|
+
- Review sessions before exporting or sharing them. They can contain prompts, tool arguments, command output, file contents, and credentials exposed during the conversation.
|
|
95
|
+
|
|
96
|
+
## Report a security issue
|
|
97
|
+
|
|
98
|
+
Follow the repository [Security Policy](https://github.com/DingxinTao0417/diffra-cli/blob/main/SECURITY.md). Do not open a public issue for a security-sensitive report.
|
|
99
|
+
|
|
100
|
+
Expected local-agent behavior, prompt injection from untrusted content, the documented limits of the built-in sandbox, and behavior from user-installed extensions or skills are generally outside the security boundary unless the report demonstrates a privilege-boundary bypass or access that the local user did not already have.
|