@realtimex/sdk 1.5.1 → 1.7.0

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.
@@ -0,0 +1,111 @@
1
+ # Credentials Reference
2
+
3
+ Credentials are managed by the user in **Settings > Credentials**. Agents have read-only access via `sdk.credentials`.
4
+
5
+ ## Security Rules
6
+
7
+ 1. **Never** print credential values to stdout (they become tool results in chat history)
8
+ 2. **Never** include credential values in your response text
9
+ 3. **Never** write credential values to files or logs
10
+ 4. **Never** pass credential values as CLI arguments (visible in process list)
11
+ 5. **Always** consume credentials inside scripts — fetch, use, discard
12
+ 6. **Always** call `process.exit(0)` at the end of custom scripts (prevents hanging on open HTTP sockets)
13
+ 7. **Never** write helper scripts into the SKILL directory — use the working directory or system temp
14
+
15
+ ## Credential Types
16
+
17
+ | Type | Payload | How to Apply |
18
+ |------|---------|-------------|
19
+ | `http_header` | `{ name, value }` | Set as HTTP header: `headers[payload.name] = payload.value` |
20
+ | `query_auth` | `{ name, value }` | Append to URL: `?${payload.name}=${payload.value}` |
21
+ | `basic_auth` | `{ username, password }` | Encode: `Authorization: Basic ${btoa(username + ":" + password)}` |
22
+ | `env_var` | `{ name, value }` | Set in subprocess: `env[payload.name] = payload.value` |
23
+
24
+ ## Usage Patterns
25
+
26
+ ### List available credentials
27
+
28
+ ```bash
29
+ node "$SKILL" credentials
30
+ ```
31
+
32
+ Output: table of names and types (no values).
33
+
34
+ ### Important: credential payload structure
35
+
36
+ `sdk.credentials.get(name)` returns `{ name, type, payload }`. The `payload` object contains structured fields — use them directly. **Never** extract raw values and construct headers manually.
37
+
38
+ ### Use an http_header credential in a script
39
+
40
+ ```javascript
41
+ const { initSDK } = require('<SKILL_DIR>/scripts/lib/sdk-init');
42
+ (async () => {
43
+ const { sdk } = await initSDK();
44
+ const cred = await sdk.credentials.get('github-token');
45
+ // cred.type === "http_header"
46
+ // cred.payload === { name: "Authorization", value: "Bearer ghp_xxx" }
47
+ // The value already includes the full header value — use as-is
48
+ const res = await fetch('https://api.github.com/user', {
49
+ headers: { [cred.payload.name]: cred.payload.value }
50
+ });
51
+ console.log('Status:', res.status); // Only non-sensitive output
52
+ process.exit(0);
53
+ })();
54
+ // WRONG: const token = cred.payload.value; headers.Authorization = `Bearer ${token}`
55
+ // The value already contains "Bearer ..." — adding prefix again causes 401
56
+ ```
57
+
58
+ ### Use a basic_auth credential
59
+
60
+ ```javascript
61
+ const { initSDK } = require('<SKILL_DIR>/scripts/lib/sdk-init');
62
+ (async () => {
63
+ const { sdk } = await initSDK();
64
+ const cred = await sdk.credentials.get('registry-login');
65
+ const auth = Buffer.from(cred.payload.username + ':' + cred.payload.password).toString('base64');
66
+ const res = await fetch('https://registry.example.com/v2/_catalog', {
67
+ headers: { 'Authorization': 'Basic ' + auth }
68
+ });
69
+ console.log('Status:', res.status);
70
+ process.exit(0);
71
+ })();
72
+ ```
73
+
74
+ ### Use an env_var credential with a subprocess
75
+
76
+ ```javascript
77
+ const { initSDK } = require('<SKILL_DIR>/scripts/lib/sdk-init');
78
+ const { execSync } = require('child_process');
79
+ (async () => {
80
+ const { sdk } = await initSDK();
81
+ const cred = await sdk.credentials.get('aws-key');
82
+ // cred.type === "env_var"
83
+ // cred.payload === { name: "AWS_ACCESS_KEY_ID", value: "AKIA..." }
84
+ execSync('aws s3 ls', {
85
+ env: { ...process.env, [cred.payload.name]: cred.payload.value },
86
+ stdio: 'inherit'
87
+ });
88
+ process.exit(0);
89
+ })();
90
+ ```
91
+
92
+ ### Error handling
93
+
94
+ ```javascript
95
+ const { initSDK } = require('<SKILL_DIR>/scripts/lib/sdk-init');
96
+ (async () => {
97
+ try {
98
+ const { sdk } = await initSDK();
99
+ const cred = await sdk.credentials.get('my-key');
100
+ // use cred...
101
+ process.exit(0);
102
+ } catch (err) {
103
+ if (err.message.includes('not found')) {
104
+ console.log('Credential not found. Ask the user to add it in Settings > Credentials.');
105
+ } else {
106
+ console.log('Error:', err.message);
107
+ }
108
+ process.exit(1);
109
+ }
110
+ })();
111
+ ```
@@ -1,6 +1,6 @@
1
1
  # Known Issues — Source-Detected
2
2
 
3
- > Auto-generated by `scripts/generate-skill.mjs` · SDK **1.5.1** · 2026-04-02
3
+ > Auto-generated by `scripts/generate-skill.mjs` · SDK **1.7.0** · 2026-04-16
4
4
 
5
5
  Run `node scripts/generate-skill.mjs --force` after SDK source changes to refresh.
6
6
 
@@ -8,7 +8,7 @@
8
8
  * 2. ~/.realtimex.ai/.sdk-app-id file (written by RealtimeX server)
9
9
  * 3. RTX_APP_ID in process.env (injected by RealtimeX for local apps)
10
10
  * 4. RTX_API_KEY in process.env (standalone dev)
11
- * 5. REALTIMEX_API_KEY / REALTIMEX_AI_API_KEY in <envDir>/.env (standalone dev)
11
+ * 5. RTX_API_KEY in <envDir>/.env (standalone dev)
12
12
  * 6. Interactive readline prompt (fallback)
13
13
  */
14
14
 
@@ -304,6 +304,13 @@ CMD['mcp-exec'] = async () => {
304
304
  print(await sdk.mcp.executeTool(server, tool, argsStr ? JSON.parse(argsStr) : {}, flags.provider));
305
305
  };
306
306
 
307
+ // -- credentials ------------------------------------------------------------
308
+ CMD['credentials'] = async () => {
309
+ const { sdk } = await getSDK();
310
+ const list = await sdk.credentials.list();
311
+ printTable(list, ['name', 'type']);
312
+ };
313
+
307
314
  // -- acp-agents -------------------------------------------------------------
308
315
  // Source: AcpAgentModule.listAgents({ includeModels? })
309
316
  // Returns: AcpAgentInfo[] { id, label, handles[], installed, authReady, status }
@@ -797,6 +804,10 @@ sdk.mcp.*:
797
804
  mcp-tools <server> [--provider]
798
805
  mcp-exec <server> <tool> [<args-json>] [--provider]
799
806
 
807
+ sdk.credentials.*:
808
+ credentials
809
+ List available credentials (names and types, no values).
810
+
800
811
  sdk.acpAgent.* — Session Management:
801
812
  acp-agents [--models=true]
802
813
  List available ACP CLI agents.
@@ -871,8 +882,10 @@ sdk.database.* / sdk.auth.*:
871
882
  console.error('Unknown command: ' + (command || '(none)') + '\nRun: node rtx.js help');
872
883
  process.exit(1);
873
884
  }
874
- try { await handler(); }
875
- catch (err) {
885
+ try {
886
+ await handler();
887
+ process.exit(0);
888
+ } catch (err) {
876
889
  console.error('Error:', err.message || err);
877
890
  if (flags.debug) console.error(err);
878
891
  process.exit(1);