@goose-plugins/lede 1.0.0 → 1.0.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @goose-plugins/lede
2
2
 
3
- Connect Goose to your Lede news reader using its authenticated REST API. Includes 14 native Goose tools, relevant news gathering, and examples for the Goose command centre’s Missions and Monitors views. No runtime dependencies; Node 18+.
3
+ Connect Goose to [Lede](https://github.com/rorystandley/lede/), a self-hosted news reader, using its authenticated REST API. Includes 14 native Goose tools, relevant news gathering, and examples for the Goose command centre’s Missions and Monitors views. No runtime dependencies; Node 18+.
4
4
 
5
5
  ## Why native REST tools
6
6
 
@@ -20,7 +20,7 @@ npm run plugins:link
20
20
  Add to Goose’s `.env` (or its service environment):
21
21
 
22
22
  ```dotenv
23
- LEDE_BASE_URL=https://lede.rorystandley.co.uk
23
+ LEDE_BASE_URL=https://your-lede.example.com
24
24
  LEDE_API_KEY=nrk_your_personal_api_key
25
25
  # Optional request timeout, in milliseconds; default 15000
26
26
  LEDE_TIMEOUT_MS=15000
@@ -30,7 +30,7 @@ Use an existing personal Lede API key or create a dedicated key named `Goose` th
30
30
 
31
31
  Restart Goose and `goose-scheduler` using your existing service manager. Configuration is lazy: importing the plugin needs no credentials and does not contact Lede. In command centre Chat, ask **“Check my Lede connection.”** `lede_status` verifies authenticated access and returns no key or email address.
32
32
 
33
- `LEDE_BASE_URL` is the origin only, without `/api/v1`. HTTPS is required except for local development at `http://localhost:3000` or a loopback IP. Redirects are refused. HTTP bodies and transport errors are not echoed, and writes are never automatically retried after a timeout or network failure.
33
+ `LEDE_BASE_URL` is required and must be the origin of your own Lede deployment, without `/api/v1`; the plugin has no hosted default. HTTPS is required except for local development at `http://localhost:3000` or a loopback IP. Redirects are refused. HTTP bodies and transport errors are not echoed, and writes are never automatically retried after a timeout or network failure.
34
34
 
35
35
  ## Command centre
36
36
 
package/client.js CHANGED
@@ -1,22 +1,26 @@
1
- const DEFAULT_URL = 'https://lede.rorystandley.co.uk';
2
-
3
1
  export class LedeError extends Error {}
4
2
 
5
3
  export function connectionInfo(env = process.env) {
4
+ const rawBaseUrl = env.LEDE_BASE_URL?.trim();
5
+ const apiKeyConfigured = Boolean(env.LEDE_API_KEY?.trim());
6
+ if (!rawBaseUrl) {
7
+ return { baseUrl: null, configured: false, baseUrlConfigured: false, apiKeyConfigured };
8
+ }
6
9
  let url;
7
- try { url = new URL(env.LEDE_BASE_URL || DEFAULT_URL); }
10
+ try { url = new URL(rawBaseUrl); }
8
11
  catch { throw new LedeError('LEDE_BASE_URL must be an HTTPS origin.'); }
9
12
  const local = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
10
13
  if ((url.protocol !== 'https:' && !(local && url.protocol === 'http:')) ||
11
14
  url.username || url.password || url.search || url.hash || url.pathname !== '/') {
12
15
  throw new LedeError('LEDE_BASE_URL must be an HTTPS origin (HTTP is allowed only on loopback). Do not include /api/v1 or credentials.');
13
16
  }
14
- return { baseUrl: url.origin, configured: Boolean(env.LEDE_API_KEY?.trim()) };
17
+ return { baseUrl: url.origin, configured: apiKeyConfigured, baseUrlConfigured: true, apiKeyConfigured };
15
18
  }
16
19
 
17
20
  // Lazy configuration: plugin discovery never needs credentials or network access.
18
21
  export function createClient({ env = process.env, fetchFn = globalThis.fetch } = {}) {
19
22
  const { baseUrl, configured } = connectionInfo(env);
23
+ if (!baseUrl) throw new LedeError('Set LEDE_BASE_URL to your Lede app origin, for example https://your-lede.example.com.');
20
24
  if (!configured) throw new LedeError('Set LEDE_API_KEY in Goose’s environment to a Lede nrk_ API key, then restart Goose and its scheduler.');
21
25
  const token = env.LEDE_API_KEY.trim();
22
26
  const timeout = Number(env.LEDE_TIMEOUT_MS || 15000);
package/index.js CHANGED
@@ -47,7 +47,7 @@ const pageQuery = args => ({ page: 1, pageSize: 20, ...args });
47
47
  export const tools = [
48
48
  tool('lede_status', 'Check Lede configuration and authenticated connectivity without exposing the API key.', {}, [], async () => {
49
49
  const info = connectionInfo();
50
- if (!info.configured) return { ...info, connected: false, nextStep: 'Set LEDE_API_KEY in Goose’s environment and restart Goose and its scheduler.' };
50
+ if (!info.configured) return { ...info, connected: false, nextStep: 'Set LEDE_BASE_URL to your Lede origin and LEDE_API_KEY to a Lede nrk_ API key, then restart Goose and its scheduler.' };
51
51
  const profile = await request('/user/profile');
52
52
  if (!profile?.id) throw new LedeError('Unexpected Lede profile response.');
53
53
  return { ...info, connected: true, displayName: profile.displayName, timezone: profile.timezone };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lede-health",
3
3
  "type": "url",
4
- "url": "https://lede.rorystandley.co.uk/api/health/ready",
4
+ "url": "https://your-lede.example.com/api/health/ready",
5
5
  "interval": "5m",
6
6
  "cooldown": "30m",
7
7
  "enabled": false,
package/package.json CHANGED
@@ -1,14 +1,40 @@
1
1
  {
2
2
  "name": "@goose-plugins/lede",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "description": "Lede news reader for Goose — relevant briefings, article search, reading and feed management",
6
- "exports": { ".": "./index.js" },
7
- "files": ["index.js", "client.js", "briefing.js", "README.md", "mission.example.json", "monitor.example.json"],
8
- "scripts": { "test": "node --test tests/*.test.js" },
9
- "engines": { "node": ">=18.0.0" },
10
- "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
11
- "keywords": ["goose", "goose-plugins", "lede", "news", "briefing"],
12
- "repository": { "type": "git", "url": "git+https://github.com/rorystandley/goose-plugins.git", "directory": "lede" },
6
+ "exports": {
7
+ ".": "./index.js"
8
+ },
9
+ "files": [
10
+ "index.js",
11
+ "client.js",
12
+ "briefing.js",
13
+ "README.md",
14
+ "mission.example.json",
15
+ "monitor.example.json"
16
+ ],
17
+ "scripts": {
18
+ "test": "node --test tests/*.test.js"
19
+ },
20
+ "engines": {
21
+ "node": ">=18.0.0"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org/"
26
+ },
27
+ "keywords": [
28
+ "goose",
29
+ "goose-plugins",
30
+ "lede",
31
+ "news",
32
+ "briefing"
33
+ ],
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/rorystandley/goose-plugins.git",
37
+ "directory": "lede"
38
+ },
13
39
  "license": "MIT"
14
40
  }