@realtimex/sdk 1.7.8 → 1.7.10

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.
@@ -498,4 +498,4 @@ declare class ServerError extends DeveloperApiError {
498
498
  constructor(message?: string);
499
499
  }
500
500
 
501
- export { AuthenticationError as A, DeveloperApiClient as D, NotFoundError as N, ServerError as S, V1ApiNamespace as V, DeveloperApiError as a, ValidationError as b, V1AuthModule as c, V1AdminModule as d, V1DocumentModule as e, V1WorkspaceModule as f, V1SystemModule as g, V1ThreadModule as h, V1UsersModule as i, V1OpenAIModule as j, V1EmbedModule as k, V1DesktopRuntimeSessionsModule as l };
501
+ export { AuthenticationError as A, DeveloperApiClient as D, NotFoundError as N, ServerError as S, V1ApiNamespace as V, V1DesktopRuntimeSessionsModule as a, DeveloperApiError as b, ValidationError as c, V1AuthModule as d, V1AdminModule as e, V1DocumentModule as f, V1WorkspaceModule as g, V1SystemModule as h, V1ThreadModule as i, V1UsersModule as j, V1OpenAIModule as k, V1EmbedModule as l };
@@ -498,4 +498,4 @@ declare class ServerError extends DeveloperApiError {
498
498
  constructor(message?: string);
499
499
  }
500
500
 
501
- export { AuthenticationError as A, DeveloperApiClient as D, NotFoundError as N, ServerError as S, V1ApiNamespace as V, DeveloperApiError as a, ValidationError as b, V1AuthModule as c, V1AdminModule as d, V1DocumentModule as e, V1WorkspaceModule as f, V1SystemModule as g, V1ThreadModule as h, V1UsersModule as i, V1OpenAIModule as j, V1EmbedModule as k, V1DesktopRuntimeSessionsModule as l };
501
+ export { AuthenticationError as A, DeveloperApiClient as D, NotFoundError as N, ServerError as S, V1ApiNamespace as V, V1DesktopRuntimeSessionsModule as a, DeveloperApiError as b, ValidationError as c, V1AuthModule as d, V1AdminModule as e, V1DocumentModule as f, V1WorkspaceModule as g, V1SystemModule as h, V1ThreadModule as i, V1UsersModule as j, V1OpenAIModule as k, V1EmbedModule as l };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as V1ApiNamespace } from './errors-BmVxnpJS.mjs';
2
- export { A as AuthenticationError, D as DeveloperApiClient, a as DeveloperApiError, N as NotFoundError, S as ServerError, b as ValidationError } from './errors-BmVxnpJS.mjs';
1
+ import { V as V1ApiNamespace, a as V1DesktopRuntimeSessionsModule } from './errors-x6ngbrlA.mjs';
2
+ export { A as AuthenticationError, D as DeveloperApiClient, b as DeveloperApiError, N as NotFoundError, S as ServerError, c as ValidationError } from './errors-x6ngbrlA.mjs';
3
3
 
4
4
  /**
5
5
  * RealtimeX Local App SDK - Types
@@ -2022,6 +2022,11 @@ declare class RealtimeXSDK {
2022
2022
  * Provides access to workspace management, admin, documents, system settings, and more.
2023
2023
  */
2024
2024
  v1: V1ApiNamespace | undefined;
2025
+ /**
2026
+ * Desktop terminal sessions — top-level alias for the desktop runtime session APIs.
2027
+ * Backed by `sdk.v1.desktopRuntimeSessions` for compatibility with generated v1 modules.
2028
+ */
2029
+ desktopRuntimeSessions: V1DesktopRuntimeSessionsModule | undefined;
2025
2030
  readonly appId: string;
2026
2031
  readonly appName: string | undefined;
2027
2032
  readonly apiKey: string | undefined;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as V1ApiNamespace } from './errors-BmVxnpJS.js';
2
- export { A as AuthenticationError, D as DeveloperApiClient, a as DeveloperApiError, N as NotFoundError, S as ServerError, b as ValidationError } from './errors-BmVxnpJS.js';
1
+ import { V as V1ApiNamespace, a as V1DesktopRuntimeSessionsModule } from './errors-x6ngbrlA.js';
2
+ export { A as AuthenticationError, D as DeveloperApiClient, b as DeveloperApiError, N as NotFoundError, S as ServerError, c as ValidationError } from './errors-x6ngbrlA.js';
3
3
 
4
4
  /**
5
5
  * RealtimeX Local App SDK - Types
@@ -2022,6 +2022,11 @@ declare class RealtimeXSDK {
2022
2022
  * Provides access to workspace management, admin, documents, system settings, and more.
2023
2023
  */
2024
2024
  v1: V1ApiNamespace | undefined;
2025
+ /**
2026
+ * Desktop terminal sessions — top-level alias for the desktop runtime session APIs.
2027
+ * Backed by `sdk.v1.desktopRuntimeSessions` for compatibility with generated v1 modules.
2028
+ */
2029
+ desktopRuntimeSessions: V1DesktopRuntimeSessionsModule | undefined;
2025
2030
  readonly appId: string;
2026
2031
  readonly appName: string | undefined;
2027
2032
  readonly apiKey: string | undefined;
package/dist/index.js CHANGED
@@ -4467,6 +4467,7 @@ var _RealtimeXSDK = class _RealtimeXSDK {
4467
4467
  this.auth = new AuthModule(this.realtimexUrl, this.appId, this.apiKey);
4468
4468
  this.credentials = new CredentialsModule(this.httpClient);
4469
4469
  this.v1 = this.apiKey || this.appId ? new V1ApiNamespace(this.realtimexUrl, this.apiKey ?? "", this.appId || void 0) : void 0;
4470
+ this.desktopRuntimeSessions = this.v1?.desktopRuntimeSessions;
4470
4471
  if (this.permissions.length > 0 && this.appId && !this.apiKey) {
4471
4472
  this.register().catch((err) => {
4472
4473
  console.error("[RealtimeX SDK] Auto-registration failed:", err.message);
package/dist/index.mjs CHANGED
@@ -3652,6 +3652,7 @@ var _RealtimeXSDK = class _RealtimeXSDK {
3652
3652
  this.auth = new AuthModule(this.realtimexUrl, this.appId, this.apiKey);
3653
3653
  this.credentials = new CredentialsModule(this.httpClient);
3654
3654
  this.v1 = this.apiKey || this.appId ? new V1ApiNamespace(this.realtimexUrl, this.apiKey ?? "", this.appId || void 0) : void 0;
3655
+ this.desktopRuntimeSessions = this.v1?.desktopRuntimeSessions;
3655
3656
  if (this.permissions.length > 0 && this.appId && !this.apiKey) {
3656
3657
  this.register().catch((err) => {
3657
3658
  console.error("[RealtimeX SDK] Auto-registration failed:", err.message);
@@ -1,5 +1,5 @@
1
- import { D as DeveloperApiClient } from '../errors-BmVxnpJS.mjs';
2
- export { A as AuthenticationError, a as DeveloperApiError, N as NotFoundError, S as ServerError, d as V1AdminModule, V as V1ApiNamespace, c as V1AuthModule, l as V1DesktopRuntimeSessionsModule, e as V1DocumentModule, k as V1EmbedModule, j as V1OpenAIModule, g as V1SystemModule, h as V1ThreadModule, i as V1UsersModule, f as V1WorkspaceModule, b as ValidationError } from '../errors-BmVxnpJS.mjs';
1
+ import { D as DeveloperApiClient } from '../errors-x6ngbrlA.mjs';
2
+ export { A as AuthenticationError, b as DeveloperApiError, N as NotFoundError, S as ServerError, e as V1AdminModule, V as V1ApiNamespace, d as V1AuthModule, a as V1DesktopRuntimeSessionsModule, f as V1DocumentModule, l as V1EmbedModule, k as V1OpenAIModule, h as V1SystemModule, i as V1ThreadModule, j as V1UsersModule, g as V1WorkspaceModule, c as ValidationError } from '../errors-x6ngbrlA.mjs';
3
3
 
4
4
  interface WorkspaceStreamChunk {
5
5
  /** The text fragment emitted by this SSE event */
@@ -1,5 +1,5 @@
1
- import { D as DeveloperApiClient } from '../errors-BmVxnpJS.js';
2
- export { A as AuthenticationError, a as DeveloperApiError, N as NotFoundError, S as ServerError, d as V1AdminModule, V as V1ApiNamespace, c as V1AuthModule, l as V1DesktopRuntimeSessionsModule, e as V1DocumentModule, k as V1EmbedModule, j as V1OpenAIModule, g as V1SystemModule, h as V1ThreadModule, i as V1UsersModule, f as V1WorkspaceModule, b as ValidationError } from '../errors-BmVxnpJS.js';
1
+ import { D as DeveloperApiClient } from '../errors-x6ngbrlA.js';
2
+ export { A as AuthenticationError, b as DeveloperApiError, N as NotFoundError, S as ServerError, e as V1AdminModule, V as V1ApiNamespace, d as V1AuthModule, a as V1DesktopRuntimeSessionsModule, f as V1DocumentModule, l as V1EmbedModule, k as V1OpenAIModule, h as V1SystemModule, i as V1ThreadModule, j as V1UsersModule, g as V1WorkspaceModule, c as ValidationError } from '../errors-x6ngbrlA.js';
3
3
 
4
4
  interface WorkspaceStreamChunk {
5
5
  /** The text fragment emitted by this SSE event */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realtimex/sdk",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "description": "SDK for building Local Apps that integrate with RealtimeX",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: realtimex-moderator-sdk
3
3
  description: Control and interact with the RealTimeX application through its Node.js SDK. This skill should be used when users want to manage workspaces, threads, agents, activities, LLM chat, vector store, MCP tools, ACP agent sessions, TTS/STT, or any other RealTimeX platform feature via the API. All method signatures are verified against the SDK source code.
4
- generated: 2026-05-06
5
- sdk_version: 1.7.8
4
+ generated: 2026-05-07
5
+ sdk_version: 1.7.10
6
6
  ---
7
7
 
8
8
  # RealTimeX Moderator (SDK Source-Verified)
9
9
 
10
- Interact with the RealTimeX platform (`http://localhost:3001`) using `@realtimex/sdk` **v1.7.8**. Authentication is automatic when running inside RealtimeX.
10
+ Interact with the RealTimeX platform (`http://localhost:3001`) using `@realtimex/sdk` **v1.7.10**. Authentication is automatic when running inside RealtimeX.
11
11
 
12
12
  `<SKILL_DIR>` below refers to the directory containing this SKILL.md.
13
13
 
@@ -24,6 +24,10 @@ node "$SKILL" agents $ENV
24
24
  node "$SKILL" workspaces $ENV
25
25
  node "$SKILL" threads <workspace-slug> $ENV
26
26
  node "$SKILL" trigger-agent <agent> <workspace> <msg> $ENV
27
+ node "$SKILL" terminal-launch-cli-agent claude claude-cli "what is current working dir" --workspace=<slug> --thread=<slug> $ENV
28
+ node "$SKILL" terminal-launch-shell --workspace=<slug> --thread=<slug> --command="pwd" $ENV
29
+ node "$SKILL" terminal-sessions --workspace=<slug> $ENV
30
+ node "$SKILL" terminal-write <session-id> "continue" $ENV
27
31
  node "$SKILL" acp-chat qwen-cli "question" --cwd=<path> $ENV
28
32
  node "$SKILL" llm-chat "message" $ENV
29
33
  node "$SKILL" activities --status=pending $ENV
@@ -35,24 +39,115 @@ node "$SKILL" help
35
39
 
36
40
  ```js
37
41
  const { initSDK } = require('<SKILL_DIR>/scripts/lib/sdk-init');
38
- const { sdk } = await initSDK();
42
+ const { sdk, context } = await initSDK();
39
43
  // All SDK APIs — see references/api-reference.md
40
44
  ```
41
45
 
42
46
  When writing helper scripts, use the working directory or system temp — never the SKILL directory.
43
47
  Scripts using the SDK must exit explicitly — `process.exit(0)` on success, `process.exit(1)` on error — or they hang on open HTTP sockets.
44
48
 
49
+ When the skill runs inside a spawned ACP or desktop terminal session, RealtimeX injects:
50
+ - `RTX_WORKSPACE_SLUG`
51
+ - `RTX_THREAD_SLUG`
52
+
53
+ The bundled `sdk-init` and `rtx.js` helpers use those env vars as default context for terminal actions and thread listing. Explicit arguments still win.
54
+
45
55
  ---
46
56
 
47
- ## Runtime Sessions
57
+ ## Desktop Terminal Sessions
58
+
59
+ For anything that says **launch terminal**, **open shell**, **open Claude/Gemini in terminal**, or **send another message to an existing terminal session**, use:
60
+
61
+ - `sdk.desktopRuntimeSessions.*`
62
+
63
+ Do **not** use ACP for that unless the user explicitly asks for a headless ACP session.
64
+
65
+ ### Use desktop terminal sessions for
66
+ - opening a visible terminal in the Electron app
67
+ - launching a shell session
68
+ - launching a CLI agent in a terminal tab/panel
69
+ - listing desktop terminal sessions
70
+ - writing more input to an existing terminal session
71
+ - approving or denying a pending terminal action
72
+ - closing a terminal session
73
+
74
+ ### Use ACP only for
75
+ - headless background agent sessions
76
+ - persistent server-side automation
77
+ - `acp-chat`, `acp-stream`, `acp-session-*`
78
+
79
+ ### Correct SDK namespace
80
+
81
+ ```js
82
+ sdk.desktopRuntimeSessions
83
+ ```
84
+
85
+ Compatibility:
86
+ - `sdk.desktopRuntimeSessions` is the preferred alias
87
+ - `sdk.v1.desktopRuntimeSessions` still exists for backward compatibility
88
+ - there is no `sdk.v1.runtimeSessions`
89
+
90
+ ### Required payloads
91
+
92
+ Launch terminal CLI agent:
93
+
94
+ ```js
95
+ await sdk.desktopRuntimeSessions.launchTerminalCliAgent({
96
+ workspaceSlug: "agent-heartbeat",
97
+ threadSlug: "ambient-agent-week-agent-heartbeat-2026-w17",
98
+ agentName: "claude", // required
99
+ providerId: "claude-cli", // strongly recommended
100
+ presentationMode: "panel", // optional: "panel" | "tab"
101
+ message: "what is current working dir"
102
+ });
103
+ ```
104
+
105
+ If `workspaceSlug` and `threadSlug` are omitted, prefer this order:
106
+ - explicit user-provided values
107
+ - `RTX_WORKSPACE_SLUG` / `RTX_THREAD_SLUG` from the current spawned process
108
+ - list workspaces/threads and ask only if still ambiguous
109
+
110
+ Important:
111
+ - `agentName` is the agent label, like `"claude"` or `"gemini"`
112
+ - `providerId` is the launcher/provider id, like `"claude-cli"` or `"gemini-cli"`
113
+ - Do not pass `agentName: "claude-cli"` unless that is truly the agent label shown by the app
114
+
115
+ Launch terminal shell:
116
+
117
+ ```js
118
+ await sdk.desktopRuntimeSessions.launchTerminalShell({
119
+ workspaceSlug: "agent-heartbeat",
120
+ threadSlug: "ambient-agent-week-agent-heartbeat-2026-w17",
121
+ presentationMode: "panel",
122
+ initialCommand: "pwd",
123
+ initialCommandMode: "direct"
124
+ });
125
+ ```
126
+
127
+ Manage existing terminal sessions:
128
+
129
+ ```js
130
+ await sdk.desktopRuntimeSessions.listRuntimeSessions();
131
+ await sdk.desktopRuntimeSessions.getRuntimeSession("cli-agent:pty-123");
132
+ await sdk.desktopRuntimeSessions.write("cli-agent:pty-123", {
133
+ message: "continue"
134
+ });
135
+ await sdk.desktopRuntimeSessions.permission("cli-agent:pty-123", {
136
+ outcome: "approved",
137
+ actionId: "terminal-action-1"
138
+ });
139
+ await sdk.desktopRuntimeSessions.deleteRuntimeSession("cli-agent:pty-123");
140
+ ```
48
141
 
49
- In this SDK, **Runtime Sessions** means the CLI Agent in **Terminal mode**. Use `sdk.agent.*` for that path.
142
+ ### Preferred decision rule
50
143
 
51
- This is separate from ACP mode:
52
- - `sdk.agent.*` = Runtime Sessions = CLI Agent / Terminal mode
53
- - `sdk.acpAgent.*` = ACP-backed CLI agent sessions
144
+ If the user says:
145
+ - "launch in terminal"
146
+ - "open Claude in terminal"
147
+ - "ask Gemini in terminal"
148
+ - "open a shell and run pwd"
54
149
 
55
- If a user refers to the v1/OpenAPI tag `Runtime Sessions`, interpret that as the Terminal mode session flow, not ACP.
150
+ then prefer `sdk.desktopRuntimeSessions.*`, not ACP.
56
151
 
57
152
  ---
58
153
 
@@ -1,6 +1,6 @@
1
1
  # RealTimeX SDK — API Reference
2
2
 
3
- > Auto-generated from `@realtimex/sdk` source · v**1.7.8** · 2026-05-06
3
+ > Auto-generated from `@realtimex/sdk` source · v**1.7.10** · 2026-05-07
4
4
 
5
5
  **Package:** `@realtimex/sdk` (CJS) · **Server:** `http://localhost:3001`
6
6
  **Developer Mode auth:** `Authorization: Bearer <apiKey>`
@@ -30,6 +30,78 @@
30
30
 
31
31
  ---
32
32
 
33
+ ## sdk.desktopRuntimeSessions — Desktop Terminal Sessions
34
+
35
+ Use this module for visible Electron terminal sessions. This is the correct path for:
36
+ - launching a shell terminal
37
+ - launching Claude/Gemini/Qwen in a terminal
38
+ - listing existing terminal sessions
39
+ - sending more input to an existing terminal
40
+ - approving terminal prompts
41
+ - closing a terminal session
42
+
43
+ Do not use ACP for these unless the user explicitly asks for ACP/headless mode.
44
+ If the current process was spawned by RealtimeX, prefer `process.env.RTX_WORKSPACE_SLUG` and `process.env.RTX_THREAD_SLUG` as default context before guessing or asking the user.
45
+
46
+ ### `V1DesktopRuntimeSessionsModule`
47
+
48
+ ```ts
49
+ async openLauncher(body?: { workspaceSlug?: string; threadSlug?: string; presentationMode?: 'panel' | 'tab'; preferredAgentName?: string; preferredAgentProviderId?: string; }): Promise<unknown>
50
+ async launchTerminalShell(body?: { workspaceSlug?: string; threadSlug?: string; presentationMode?: 'panel' | 'tab'; title?: string; subtitle?: string; initialCommand?: string; initialCommandMode?: 'direct' | 'prefill' | 'shell'; }): Promise<unknown>
51
+ async launchTerminalCliAgent(body?: { workspaceSlug?: string; threadSlug?: string; agentName: string; providerId?: string; modelId?: string; presentationMode?: 'panel' | 'tab'; message?: string; }): Promise<unknown>
52
+ async listRuntimeSessions(): Promise<unknown>
53
+ async getRuntimeSession(sessionId: string): Promise<unknown>
54
+ async write(sessionId: string, body?: { message?: string; input?: string; }): Promise<unknown>
55
+ async permission(sessionId: string, body?: { outcome: 'approved' | 'denied'; actionId?: string; requestId?: string; optionId?: string; optionLabel?: string; input?: string; reason?: string; }): Promise<unknown>
56
+ async deleteRuntimeSession(sessionId: string): Promise<unknown>
57
+ ```
58
+
59
+ ### Correct examples
60
+
61
+ Launch Claude in a terminal:
62
+
63
+ ```js
64
+ await sdk.desktopRuntimeSessions.launchTerminalCliAgent({
65
+ workspaceSlug: 'agent-heartbeat',
66
+ threadSlug: 'ambient-agent-week-agent-heartbeat-2026-w17',
67
+ agentName: 'claude',
68
+ providerId: 'claude-cli',
69
+ presentationMode: 'panel',
70
+ message: 'what is current working dir'
71
+ });
72
+ ```
73
+
74
+ Launch a shell and run `pwd`:
75
+
76
+ ```js
77
+ await sdk.desktopRuntimeSessions.launchTerminalShell({
78
+ workspaceSlug: 'agent-heartbeat',
79
+ threadSlug: 'ambient-agent-week-agent-heartbeat-2026-w17',
80
+ presentationMode: 'panel',
81
+ initialCommand: 'pwd',
82
+ initialCommandMode: 'direct'
83
+ });
84
+ ```
85
+
86
+ Common mistake:
87
+
88
+ ```js
89
+ // ❌ WRONG
90
+ await sdk.desktopRuntimeSessions.launchTerminalCliAgent({
91
+ agentName: 'claude-cli'
92
+ });
93
+
94
+ // ✅ CORRECT
95
+ await sdk.desktopRuntimeSessions.launchTerminalCliAgent({
96
+ agentName: 'claude',
97
+ providerId: 'claude-cli'
98
+ });
99
+ ```
100
+
101
+ Compatibility: `sdk.v1.desktopRuntimeSessions` remains available, but prefer the top-level alias.
102
+
103
+ ---
104
+
33
105
  ## Core — RealtimeXSDK
34
106
 
35
107
  ### `RealtimeXSDK`
@@ -52,6 +124,7 @@
52
124
  - `auth: AuthModule`
53
125
  - `credentials: CredentialsModule`
54
126
  - `v1: V1ApiNamespace | undefined`
127
+ - `desktopRuntimeSessions: V1DesktopRuntimeSessionsModule | undefined`
55
128
 
56
129
  ```ts
57
130
  // Developer API (v1) — requires apiKey to be set in config.
@@ -503,7 +576,7 @@ outcome?: string
503
576
 
504
577
  ---
505
578
 
506
- ## sdk.agent — Runtime Sessions (CLI Agent / Terminal mode)
579
+ ## sdk.agent — LLM Agent Sessions (REST/SSE)
507
580
 
508
581
  ### `AgentModule`
509
582
 
@@ -1,6 +1,6 @@
1
1
  # Known Issues — Source-Detected
2
2
 
3
- > Auto-generated by `scripts/generate-skill.mjs` · SDK **1.7.8** · 2026-05-06
3
+ > Auto-generated by `scripts/generate-skill.mjs` · SDK **1.7.10** · 2026-05-07
4
4
 
5
5
  Run `node scripts/generate-skill.mjs --force` after SDK source changes to refresh.
6
6
 
@@ -23,11 +23,17 @@ const ALL_PERMISSIONS = [
23
23
  'llm.chat', 'llm.embed', 'llm.providers',
24
24
  'vectors.read', 'vectors.write',
25
25
  'tts.generate', 'mcp.servers', 'mcp.tools', 'acp.agent',
26
+ 'desktop.runtime-sessions',
26
27
  ];
27
28
 
28
29
  /** Well-known file written by RealtimeX server for seamless auth. */
29
30
  const SDK_APP_ID_FILE = path.join(os.homedir(), '.realtimex.ai', '.sdk-app-id');
30
31
 
32
+ function normalizeContextValue(value) {
33
+ const normalized = String(value || '').trim();
34
+ return normalized || null;
35
+ }
36
+
31
37
  function parseEnvFile(filePath) {
32
38
  const vars = {};
33
39
  if (!fs.existsSync(filePath)) return vars;
@@ -86,9 +92,24 @@ async function resolveCredentials({ envDir, apiKey, appId } = {}) {
86
92
  return { apiKey: null, appId: null };
87
93
  }
88
94
 
95
+ function resolveDefaultWorkspaceThreadContext(overrides = {}) {
96
+ const workspaceSlug =
97
+ normalizeContextValue(overrides.workspaceSlug) ||
98
+ normalizeContextValue(process.env.RTX_WORKSPACE_SLUG);
99
+ const threadSlug =
100
+ normalizeContextValue(overrides.threadSlug) ||
101
+ normalizeContextValue(process.env.RTX_THREAD_SLUG);
102
+
103
+ return {
104
+ workspaceSlug,
105
+ threadSlug,
106
+ };
107
+ }
108
+
89
109
  async function initSDK(opts = {}) {
90
110
  const { RealtimeXSDK } = require('@realtimex/sdk');
91
111
  const { apiKey, appId } = await resolveCredentials(opts);
112
+ const context = resolveDefaultWorkspaceThreadContext(opts);
92
113
 
93
114
  if (!apiKey && !appId) {
94
115
  throw new Error(
@@ -105,7 +126,14 @@ async function initSDK(opts = {}) {
105
126
  permissions: opts.permissions || ALL_PERMISSIONS,
106
127
  });
107
128
 
108
- return { sdk, apiKey: apiKey || null, appId: appId || null };
129
+ return { sdk, apiKey: apiKey || null, appId: appId || null, context };
109
130
  }
110
131
 
111
- module.exports = { initSDK, resolveCredentials, parseEnvFile, ALL_PERMISSIONS, SDK_APP_ID_FILE };
132
+ module.exports = {
133
+ initSDK,
134
+ resolveCredentials,
135
+ resolveDefaultWorkspaceThreadContext,
136
+ parseEnvFile,
137
+ ALL_PERMISSIONS,
138
+ SDK_APP_ID_FILE,
139
+ };
@@ -53,6 +53,21 @@ async function getSDK() {
53
53
  return _sdk;
54
54
  }
55
55
 
56
+ function applyWorkspaceThreadDefaults(body = {}, context = {}) {
57
+ const nextBody = { ...body };
58
+ if (!nextBody.workspaceSlug && context?.workspaceSlug) {
59
+ nextBody.workspaceSlug = context.workspaceSlug;
60
+ }
61
+ if (!nextBody.threadSlug && context?.threadSlug) {
62
+ nextBody.threadSlug = context.threadSlug;
63
+ }
64
+ return nextBody;
65
+ }
66
+
67
+ function resolveWorkspaceFlagOrContext(context = {}) {
68
+ return flags.workspace || context?.workspaceSlug || null;
69
+ }
70
+
56
71
  // ---------------------------------------------------------------------------
57
72
  // Commands
58
73
  // ---------------------------------------------------------------------------
@@ -89,9 +104,10 @@ CMD.workspaces = async () => {
89
104
  // -- threads ----------------------------------------------------------------
90
105
  // Source: ApiModule.getThreads(workspaceSlug) → Thread[] { id, slug, name }
91
106
  CMD.threads = async () => {
92
- const [slug] = cmdArgs;
107
+ const [slugArg] = cmdArgs;
108
+ const { sdk, context } = await getSDK();
109
+ const slug = slugArg || resolveWorkspaceFlagOrContext(context);
93
110
  if (!slug) { console.error('Usage: rtx.js threads <workspace-slug>'); process.exit(1); }
94
- const { sdk } = await getSDK();
95
111
  printTable(await sdk.api.getThreads(slug), ['id', 'slug', 'name']);
96
112
  };
97
113
 
@@ -311,6 +327,116 @@ CMD['credentials'] = async () => {
311
327
  printTable(list, ['name', 'type']);
312
328
  };
313
329
 
330
+ function getDesktopRuntimeSessionsModule(sdk) {
331
+ const module = sdk?.desktopRuntimeSessions || sdk?.v1?.desktopRuntimeSessions;
332
+ if (!module) {
333
+ throw new Error('sdk.desktopRuntimeSessions is unavailable. Ensure the SDK was initialized with Developer API access.');
334
+ }
335
+ return module;
336
+ }
337
+
338
+ // -- terminal-launcher / terminal sessions ----------------------------------
339
+ CMD['terminal-open-launcher'] = async () => {
340
+ const { sdk, context } = await getSDK();
341
+ const terminal = getDesktopRuntimeSessionsModule(sdk);
342
+ const body = applyWorkspaceThreadDefaults({}, context);
343
+ if (flags.workspace) body.workspaceSlug = flags.workspace;
344
+ if (flags.thread) body.threadSlug = flags.thread;
345
+ if (flags.presentation) body.presentationMode = flags.presentation;
346
+ if (flags.agent) body.preferredAgentName = flags.agent;
347
+ if (flags.provider) body.preferredAgentProviderId = flags.provider;
348
+ print(await terminal.openLauncher(body));
349
+ };
350
+
351
+ CMD['terminal-launch-shell'] = async () => {
352
+ const { sdk, context } = await getSDK();
353
+ const terminal = getDesktopRuntimeSessionsModule(sdk);
354
+ const body = applyWorkspaceThreadDefaults({}, context);
355
+ if (flags.workspace) body.workspaceSlug = flags.workspace;
356
+ if (flags.thread) body.threadSlug = flags.thread;
357
+ if (flags.presentation) body.presentationMode = flags.presentation;
358
+ if (flags.command) body.initialCommand = flags.command;
359
+ if (flags['command-mode']) body.initialCommandMode = flags['command-mode'];
360
+ if (flags.title) body.title = flags.title;
361
+ if (flags.subtitle) body.subtitle = flags.subtitle;
362
+ print(await terminal.launchTerminalShell(body));
363
+ };
364
+
365
+ CMD['terminal-launch-cli-agent'] = async () => {
366
+ const [agentName, providerId, ...messageParts] = cmdArgs;
367
+ const message = messageParts.join(' ');
368
+ if (!agentName) {
369
+ console.error('Usage: rtx.js terminal-launch-cli-agent <agent-name> [<provider-id>] [<message>] [--workspace=<slug>] [--thread=<slug>] [--presentation=panel|tab] [--model=<id>]');
370
+ process.exit(1);
371
+ }
372
+ const { sdk, context } = await getSDK();
373
+ const terminal = getDesktopRuntimeSessionsModule(sdk);
374
+ const body = applyWorkspaceThreadDefaults({ agentName }, context);
375
+ if (providerId) body.providerId = providerId;
376
+ if (message) body.message = message;
377
+ if (flags.workspace) body.workspaceSlug = flags.workspace;
378
+ if (flags.thread) body.threadSlug = flags.thread;
379
+ if (flags.presentation) body.presentationMode = flags.presentation;
380
+ if (flags.model) body.modelId = flags.model;
381
+ print(await terminal.launchTerminalCliAgent(body));
382
+ };
383
+
384
+ CMD['terminal-sessions'] = async () => {
385
+ const { sdk } = await getSDK();
386
+ const terminal = getDesktopRuntimeSessionsModule(sdk);
387
+ const sessions = await terminal.listRuntimeSessions();
388
+ print(sessions);
389
+ };
390
+
391
+ CMD['terminal-session-get'] = async () => {
392
+ const [sessionId] = cmdArgs;
393
+ if (!sessionId) {
394
+ console.error('Usage: rtx.js terminal-session-get <session-id>');
395
+ process.exit(1);
396
+ }
397
+ const { sdk } = await getSDK();
398
+ const terminal = getDesktopRuntimeSessionsModule(sdk);
399
+ print(await terminal.getRuntimeSession(sessionId));
400
+ };
401
+
402
+ CMD['terminal-write'] = async () => {
403
+ const [sessionId, ...rest] = cmdArgs;
404
+ if (!sessionId || rest.length === 0) {
405
+ console.error('Usage: rtx.js terminal-write <session-id> <message> [--raw]');
406
+ process.exit(1);
407
+ }
408
+ const { sdk } = await getSDK();
409
+ const terminal = getDesktopRuntimeSessionsModule(sdk);
410
+ const payload = rest.join(' ');
411
+ print(await terminal.write(sessionId, flags.raw ? { input: payload } : { message: payload }));
412
+ };
413
+
414
+ CMD['terminal-permission'] = async () => {
415
+ const [sessionId, outcome, actionId] = cmdArgs;
416
+ if (!sessionId || !outcome) {
417
+ console.error('Usage: rtx.js terminal-permission <session-id> <approved|denied> [<action-id>] [--option-id=<id>] [--reason=<text>]');
418
+ process.exit(1);
419
+ }
420
+ const { sdk } = await getSDK();
421
+ const terminal = getDesktopRuntimeSessionsModule(sdk);
422
+ const body = { outcome };
423
+ if (actionId) body.actionId = actionId;
424
+ if (flags['option-id']) body.optionId = flags['option-id'];
425
+ if (flags.reason) body.reason = flags.reason;
426
+ print(await terminal.permission(sessionId, body));
427
+ };
428
+
429
+ CMD['terminal-close'] = async () => {
430
+ const [sessionId] = cmdArgs;
431
+ if (!sessionId) {
432
+ console.error('Usage: rtx.js terminal-close <session-id>');
433
+ process.exit(1);
434
+ }
435
+ const { sdk } = await getSDK();
436
+ const terminal = getDesktopRuntimeSessionsModule(sdk);
437
+ print(await terminal.deleteRuntimeSession(sessionId));
438
+ };
439
+
314
440
  // -- acp-agents -------------------------------------------------------------
315
441
  // Source: AcpAgentModule.listAgents({ includeModels? })
316
442
  // Returns: AcpAgentInfo[] { id, label, handles[], installed, authReady, status }
@@ -808,6 +934,39 @@ sdk.credentials.*:
808
934
  credentials
809
935
  List available credentials (names and types, no values).
810
936
 
937
+ sdk.desktopRuntimeSessions.* — Desktop terminal sessions:
938
+ terminal-open-launcher
939
+ [--workspace=<slug>] [--thread=<slug>] [--presentation=panel|tab]
940
+ Open the terminal launcher UI in the Electron app.
941
+
942
+ terminal-launch-shell
943
+ [--workspace=<slug>] [--thread=<slug>] [--presentation=panel|tab]
944
+ [--command="pwd"] [--command-mode=direct|prefill|shell]
945
+ Launch a visible shell terminal.
946
+
947
+ terminal-launch-cli-agent <agent-name> [<provider-id>] [<message>]
948
+ [--workspace=<slug>] [--thread=<slug>] [--presentation=panel|tab] [--model=<id>]
949
+ Launch a visible CLI agent terminal.
950
+ Example: terminal-launch-cli-agent claude claude-cli "what is current working dir"
951
+
952
+ terminal-sessions
953
+ List desktop terminal sessions.
954
+
955
+ terminal-session-get <session-id>
956
+ Fetch one desktop terminal session by runtime session id.
957
+
958
+ terminal-write <session-id> <message> [--raw]
959
+ Send another message or raw PTY input to an existing terminal session.
960
+
961
+ terminal-permission <session-id> <approved|denied> [<action-id>] [--option-id=<id>] [--reason=<text>]
962
+ Resolve a pending terminal approval request.
963
+
964
+ terminal-close <session-id>
965
+ Close a desktop terminal session.
966
+
967
+ Compatibility:
968
+ The SDK also exposes this module as sdk.v1.desktopRuntimeSessions.
969
+
811
970
  sdk.acpAgent.* — Session Management:
812
971
  acp-agents [--models=true]
813
972
  List available ACP CLI agents.