oc-discord-rpc 0.3.0 → 0.4.1
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 +5 -1
- package/README.md +15 -3
- package/package.json +1 -1
- package/src/index.js +12 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [0.
|
|
10
|
+
## [0.4.1] - 2026-11-29
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- The plugin now ships a bundled Discord application id (`1576225438995316886`) and works on install with no Developer Portal setup. Resolution order is `appId` option, then `OC_DISCORD_APP_ID`, then the bundled default; an explicit `appId: ""`, `null` or `false` stays inert. The bundled app is named `OpenCode`, is community-run and unverified (not an official anomalyco application), and its public id is permanent by policy.
|
|
11
15
|
|
|
12
16
|
### Changed
|
|
13
17
|
|
package/README.md
CHANGED
|
@@ -16,7 +16,11 @@ Add the plugin to `~/.config/opencode/opencode.jsonc` and restart OpenCode:
|
|
|
16
16
|
{ "plugins": ["oc-discord-rpc"] }
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
That is all: the plugin ships with a bundled application id and publishes a card out of the box. No Discord Developer Portal account or setup step is needed.
|
|
20
|
+
|
|
21
|
+
Verify it after the restart: trigger any tool call in a session. The Discord desktop client should show a `Playing OpenCode` card with the model and reasoning lines and an elapsed timer (for example `0:31`, counted from when OpenCode opened) that keeps running while OpenCode stays open. If nothing appears, confirm the Discord client is running locally and the plugin loaded; `OC_DISCORD_RPC_TRACE=1` logs each decision.
|
|
22
|
+
|
|
23
|
+
To use your own application for different branding, create an application in the Discord Developer Portal, **enable Rich Presence** for it, and pass its id as `appId` (or set `OC_DISCORD_APP_ID`). A custom application without Rich Presence enabled cannot publish a card; the bundled one already has it enabled.
|
|
20
24
|
|
|
21
25
|
```jsonc
|
|
22
26
|
{
|
|
@@ -29,6 +33,14 @@ The plugin needs a Discord **application id** and is inert without one. Create a
|
|
|
29
33
|
}
|
|
30
34
|
```
|
|
31
35
|
|
|
36
|
+
To stay inert, set `"enabled": false`, or pass `appId: ""`, `appId: null` or `appId: false`. An explicit empty or false option is an opt-out: it does not fall back to the bundled id, and the plugin logs one line and sends nothing.
|
|
37
|
+
|
|
38
|
+
## About the bundled app
|
|
39
|
+
|
|
40
|
+
The bundled application is named `OpenCode`. It is community-run and unverified, and is **not** an official anomalyco application. Its id (`1576225438995316886`) is public by design: it appears in OAuth URLs and is not a secret.
|
|
41
|
+
|
|
42
|
+
The id is stable by policy — it will not be removed or renamed — so you can rely on the default without configuring anything, and a presence outage will not come from the id disappearing.
|
|
43
|
+
|
|
32
44
|
## What it shows
|
|
33
45
|
|
|
34
46
|
The header and the mark are drawn by Discord; three fields come from the payload:
|
|
@@ -67,7 +79,7 @@ The alternative is `https://raw.githubusercontent.com/lobehub/lobe-icons/refs/he
|
|
|
67
79
|
|
|
68
80
|
- The Discord desktop client must be running on the same machine. The plugin speaks Discord's local IPC socket (`discord-ipc-0` through `discord-ipc-9`) and does nothing when no client is up.
|
|
69
81
|
- Updates are coalesced at a minimum interval (`minIntervalMs`, default 15 seconds) because Discord rate-limits activity updates. The card is a status line, not a live log.
|
|
70
|
-
-
|
|
82
|
+
- The bundled id works out of the box. A custom `appId` must already exist with Rich Presence enabled; the plugin does not create Discord applications for you. Explicit `appId: ""`, `null` or `false`, and `enabled: false`, keep the plugin inert.
|
|
71
83
|
- The header line reads `activity.name` and is not taken from `details`. Discord's docs only say that the App Name is configured in the app's settings ("You can't set App Name when setting presence—it's always the name configured in your app's settings"), but the live card contradicts that: over the local IPC path `activity.name` is honoured, so a registered portal app named `OpenCode` is **not** required for the header. This was observed with the app id still naming a different program. The icon still comes from the application registered against your `appId`.
|
|
72
84
|
|
|
73
85
|
## Known limitations
|
|
@@ -76,7 +88,7 @@ The alternative is `https://raw.githubusercontent.com/lobehub/lobe-icons/refs/he
|
|
|
76
88
|
|
|
77
89
|
## Options
|
|
78
90
|
|
|
79
|
-
- `appId` —
|
|
91
|
+
- `appId` — a custom Discord application id for different branding; also settable with `OC_DISCORD_APP_ID`. Defaults to the bundled `1576225438995316886` when neither is set; pass `""`, `null` or `false` to stay inert.
|
|
80
92
|
- `enabled` — default `true`; `false` disables the plugin without uninstalling it.
|
|
81
93
|
- `minIntervalMs` — minimum gap between presence updates, default `15000`; positive values under `1000` clamp up to `1000`.
|
|
82
94
|
- `largeImage` — a full `https://` URL or an uploaded asset key for `large_image`; empty sends no image.
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -24,6 +24,10 @@ const SWEEP_RETRY_DELAYS_MS = [2000, 5000, 15000, 60000];
|
|
|
24
24
|
const SWEEP_RETRY_CAP = 12;
|
|
25
25
|
const DEFAULT_HOLD_GRACE_MS = 5000;
|
|
26
26
|
|
|
27
|
+
// Bundled Discord application id. Public by design (it appears in OAuth URLs)
|
|
28
|
+
// and permanent by policy: installed users rely on it, so it is never rotated.
|
|
29
|
+
export const DEFAULT_APP_ID = '1576225438995316886';
|
|
30
|
+
|
|
27
31
|
// The official OpenCode mark, pinned to an immutable commit so the URL cannot
|
|
28
32
|
// move under a user who never configured an image. Discord's media proxy
|
|
29
33
|
// fetches it; an external https URL means no Art Asset upload is needed.
|
|
@@ -182,9 +186,15 @@ export default {
|
|
|
182
186
|
? (message) => console.log('oc-discord-rpc: ' + message)
|
|
183
187
|
: () => {};
|
|
184
188
|
|
|
185
|
-
|
|
189
|
+
// First non-empty wins: option, then env, then the bundled id. An
|
|
190
|
+
// explicit '' / null / false is an opt-out, not a missing value: ??
|
|
191
|
+
// alone would resurrect the default for an empty string.
|
|
192
|
+
const optedOut = o.appId === '' || o.appId === null || o.appId === false;
|
|
193
|
+
const appId = optedOut
|
|
194
|
+
? undefined
|
|
195
|
+
: textOf(o.appId) ?? textOf(process.env.OC_DISCORD_APP_ID) ?? DEFAULT_APP_ID;
|
|
186
196
|
if (!appId || o.enabled === false) {
|
|
187
|
-
//
|
|
197
|
+
// Explicit opt-out only: one line, no factory call, no socket, no timers.
|
|
188
198
|
trace('inert: set appId in plugin options or OC_DISCORD_APP_ID to enable Discord presence');
|
|
189
199
|
return () => {};
|
|
190
200
|
}
|