cordisx 0.1.0-beta.36 → 0.1.0-beta.37

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.
Files changed (220) hide show
  1. package/dist/assets/claude-bridge/.claude-plugin/plugin.json +6 -0
  2. package/dist/assets/claude-bridge/hooks/hooks.json +3 -0
  3. package/dist/assets/claude-bridge/hooks/register.ts +346 -0
  4. package/dist/assets/launcher/native-agent-models-mcp.mjs +76 -3
  5. package/dist/assets/launcher/native-app-server-protocol.mjs +44 -0
  6. package/dist/assets/launcher/terminal-claude-key.mjs +4 -0
  7. package/dist/native/native-helper-artifact.json +1 -1
  8. package/dist/src/cli/claude-desktop-command.d.ts +17 -0
  9. package/dist/src/cli/claude-desktop-command.d.ts.map +1 -0
  10. package/dist/src/cli/claude-desktop-command.js +114 -0
  11. package/dist/src/cli/claude-desktop-command.js.map +1 -0
  12. package/dist/src/cli/help.d.ts +1 -1
  13. package/dist/src/cli/help.d.ts.map +1 -1
  14. package/dist/src/cli/help.js +6 -0
  15. package/dist/src/cli/help.js.map +1 -1
  16. package/dist/src/cli/launch-fingerprint.d.ts.map +1 -1
  17. package/dist/src/cli/launch-fingerprint.js +2 -0
  18. package/dist/src/cli/launch-fingerprint.js.map +1 -1
  19. package/dist/src/cli/native-submission-catalog-options.d.ts +8 -3
  20. package/dist/src/cli/native-submission-catalog-options.d.ts.map +1 -1
  21. package/dist/src/cli/native-submission-catalog-options.js +5 -1
  22. package/dist/src/cli/native-submission-catalog-options.js.map +1 -1
  23. package/dist/src/cli/parse.d.ts +7 -2
  24. package/dist/src/cli/parse.d.ts.map +1 -1
  25. package/dist/src/cli/parse.js +30 -0
  26. package/dist/src/cli/parse.js.map +1 -1
  27. package/dist/src/cli/production-host-bootstrap.d.ts.map +1 -1
  28. package/dist/src/cli/production-host-bootstrap.js +9 -0
  29. package/dist/src/cli/production-host-bootstrap.js.map +1 -1
  30. package/dist/src/cli/production-plugin-management.d.ts +3 -0
  31. package/dist/src/cli/production-plugin-management.d.ts.map +1 -1
  32. package/dist/src/cli/production-plugin-management.js +9 -0
  33. package/dist/src/cli/production-plugin-management.js.map +1 -1
  34. package/dist/src/cli/run-command-dispatch.d.ts.map +1 -1
  35. package/dist/src/cli/run-command-dispatch.js +14 -0
  36. package/dist/src/cli/run-command-dispatch.js.map +1 -1
  37. package/dist/src/cli/run-command.d.ts.map +1 -1
  38. package/dist/src/cli/run-command.js +9 -6
  39. package/dist/src/cli/run-command.js.map +1 -1
  40. package/dist/src/cli/run-injected-host.d.ts +2 -0
  41. package/dist/src/cli/run-injected-host.d.ts.map +1 -1
  42. package/dist/src/cli/run-injected-host.js +1 -0
  43. package/dist/src/cli/run-injected-host.js.map +1 -1
  44. package/dist/src/cli/run-runtime.d.ts +2 -0
  45. package/dist/src/cli/run-runtime.d.ts.map +1 -1
  46. package/dist/src/cli/run-runtime.js.map +1 -1
  47. package/dist/src/cli/run-support.d.ts.map +1 -1
  48. package/dist/src/cli/run-support.js +3 -1
  49. package/dist/src/cli/run-support.js.map +1 -1
  50. package/dist/src/cli/start-mode.d.ts +3 -0
  51. package/dist/src/cli/start-mode.d.ts.map +1 -0
  52. package/dist/src/cli/start-mode.js +29 -0
  53. package/dist/src/cli/start-mode.js.map +1 -0
  54. package/dist/src/cli/supervisor-command.d.ts.map +1 -1
  55. package/dist/src/cli/supervisor-command.js +7 -2
  56. package/dist/src/cli/supervisor-command.js.map +1 -1
  57. package/dist/src/cli/supervisor-entry.d.ts +8 -0
  58. package/dist/src/cli/supervisor-entry.d.ts.map +1 -0
  59. package/dist/src/cli/supervisor-entry.js +13 -0
  60. package/dist/src/cli/supervisor-entry.js.map +1 -0
  61. package/dist/src/cli/supervisor-entry.test.d.ts +2 -0
  62. package/dist/src/cli/supervisor-entry.test.d.ts.map +1 -0
  63. package/dist/src/cli/supervisor-entry.test.js +22 -0
  64. package/dist/src/cli/supervisor-entry.test.js.map +1 -0
  65. package/dist/src/cli/terminal-command.d.ts +9 -0
  66. package/dist/src/cli/terminal-command.d.ts.map +1 -0
  67. package/dist/src/cli/terminal-command.js +263 -0
  68. package/dist/src/cli/terminal-command.js.map +1 -0
  69. package/dist/src/cli/terminal-parse.d.ts +15 -0
  70. package/dist/src/cli/terminal-parse.d.ts.map +1 -0
  71. package/dist/src/cli/terminal-parse.js +92 -0
  72. package/dist/src/cli/terminal-parse.js.map +1 -0
  73. package/dist/src/cli/terminal-shared-service.d.ts +27 -0
  74. package/dist/src/cli/terminal-shared-service.d.ts.map +1 -0
  75. package/dist/src/cli/terminal-shared-service.js +49 -0
  76. package/dist/src/cli/terminal-shared-service.js.map +1 -0
  77. package/dist/src/cli.js +5 -2
  78. package/dist/src/cli.js.map +1 -1
  79. package/dist/src/config/home-config-model-service.d.ts +25 -0
  80. package/dist/src/config/home-config-model-service.d.ts.map +1 -0
  81. package/dist/src/config/home-config-model-service.js +109 -0
  82. package/dist/src/config/home-config-model-service.js.map +1 -0
  83. package/dist/src/config/home-config.d.ts +5 -1
  84. package/dist/src/config/home-config.d.ts.map +1 -1
  85. package/dist/src/config/home-config.js +10 -5
  86. package/dist/src/config/home-config.js.map +1 -1
  87. package/dist/src/launcher/agent-bridge.d.ts +70 -0
  88. package/dist/src/launcher/agent-bridge.d.ts.map +1 -0
  89. package/dist/src/launcher/agent-bridge.js +320 -0
  90. package/dist/src/launcher/agent-bridge.js.map +1 -0
  91. package/dist/src/launcher/builtin-skill.d.ts +1 -0
  92. package/dist/src/launcher/builtin-skill.d.ts.map +1 -1
  93. package/dist/src/launcher/builtin-skill.js +1 -1
  94. package/dist/src/launcher/builtin-skill.js.map +1 -1
  95. package/dist/src/launcher/claude-bridge-plugin.d.ts +24 -0
  96. package/dist/src/launcher/claude-bridge-plugin.d.ts.map +1 -0
  97. package/dist/src/launcher/claude-bridge-plugin.js +77 -0
  98. package/dist/src/launcher/claude-bridge-plugin.js.map +1 -0
  99. package/dist/src/launcher/claude-desktop-process.d.ts +34 -0
  100. package/dist/src/launcher/claude-desktop-process.d.ts.map +1 -0
  101. package/dist/src/launcher/claude-desktop-process.js +123 -0
  102. package/dist/src/launcher/claude-desktop-process.js.map +1 -0
  103. package/dist/src/launcher/claude-desktop-profile.d.ts +57 -0
  104. package/dist/src/launcher/claude-desktop-profile.d.ts.map +1 -0
  105. package/dist/src/launcher/claude-desktop-profile.js +185 -0
  106. package/dist/src/launcher/claude-desktop-profile.js.map +1 -0
  107. package/dist/src/launcher/claude-host-sessions.d.ts +83 -0
  108. package/dist/src/launcher/claude-host-sessions.d.ts.map +1 -0
  109. package/dist/src/launcher/claude-host-sessions.js +387 -0
  110. package/dist/src/launcher/claude-host-sessions.js.map +1 -0
  111. package/dist/src/launcher/claude-permission-mode.d.ts +24 -0
  112. package/dist/src/launcher/claude-permission-mode.d.ts.map +1 -0
  113. package/dist/src/launcher/claude-permission-mode.js +98 -0
  114. package/dist/src/launcher/claude-permission-mode.js.map +1 -0
  115. package/dist/src/launcher/configured-encrypted-replay.d.ts +2 -0
  116. package/dist/src/launcher/configured-encrypted-replay.d.ts.map +1 -0
  117. package/dist/src/launcher/configured-encrypted-replay.js +34 -0
  118. package/dist/src/launcher/configured-encrypted-replay.js.map +1 -0
  119. package/dist/src/launcher/management-rpc.d.ts +5 -0
  120. package/dist/src/launcher/management-rpc.d.ts.map +1 -1
  121. package/dist/src/launcher/management-rpc.js +13 -4
  122. package/dist/src/launcher/management-rpc.js.map +1 -1
  123. package/dist/src/launcher/model-service-projection.d.ts +84 -0
  124. package/dist/src/launcher/model-service-projection.d.ts.map +1 -0
  125. package/dist/src/launcher/model-service-projection.js +259 -0
  126. package/dist/src/launcher/model-service-projection.js.map +1 -0
  127. package/dist/src/launcher/model-service-store.d.ts +7 -0
  128. package/dist/src/launcher/model-service-store.d.ts.map +1 -0
  129. package/dist/src/launcher/model-service-store.js +164 -0
  130. package/dist/src/launcher/model-service-store.js.map +1 -0
  131. package/dist/src/launcher/native-agent-models.d.ts +6 -0
  132. package/dist/src/launcher/native-agent-models.d.ts.map +1 -1
  133. package/dist/src/launcher/native-agent-models.js +25 -1
  134. package/dist/src/launcher/native-agent-models.js.map +1 -1
  135. package/dist/src/launcher/native-agent-task-source.d.ts +28 -0
  136. package/dist/src/launcher/native-agent-task-source.d.ts.map +1 -0
  137. package/dist/src/launcher/native-agent-task-source.js +77 -0
  138. package/dist/src/launcher/native-agent-task-source.js.map +1 -0
  139. package/dist/src/launcher/native-agent-task-transform.d.ts +4 -11
  140. package/dist/src/launcher/native-agent-task-transform.d.ts.map +1 -1
  141. package/dist/src/launcher/native-agent-task-transform.js +162 -84
  142. package/dist/src/launcher/native-agent-task-transform.js.map +1 -1
  143. package/dist/src/launcher/native-predispatch-interception.d.ts +2 -0
  144. package/dist/src/launcher/native-predispatch-interception.d.ts.map +1 -1
  145. package/dist/src/launcher/native-predispatch-interception.js.map +1 -1
  146. package/dist/src/launcher/native-submission-cdp-channel.d.ts +8 -0
  147. package/dist/src/launcher/native-submission-cdp-channel.d.ts.map +1 -1
  148. package/dist/src/launcher/native-submission-cdp-channel.js +47 -5
  149. package/dist/src/launcher/native-submission-cdp-channel.js.map +1 -1
  150. package/dist/src/launcher/native-submission-composition.d.ts +6 -0
  151. package/dist/src/launcher/native-submission-composition.d.ts.map +1 -1
  152. package/dist/src/launcher/native-submission-composition.js +88 -2
  153. package/dist/src/launcher/native-submission-composition.js.map +1 -1
  154. package/dist/src/launcher/native-submission-control-server.d.ts +4 -0
  155. package/dist/src/launcher/native-submission-control-server.d.ts.map +1 -1
  156. package/dist/src/launcher/native-submission-control-server.js +28 -0
  157. package/dist/src/launcher/native-submission-control-server.js.map +1 -1
  158. package/dist/src/launcher/native-submission-controller.d.ts +2 -0
  159. package/dist/src/launcher/native-submission-controller.d.ts.map +1 -1
  160. package/dist/src/launcher/native-submission-controller.js +9 -6
  161. package/dist/src/launcher/native-submission-controller.js.map +1 -1
  162. package/dist/src/launcher/native-submission-credentials.d.ts +1 -0
  163. package/dist/src/launcher/native-submission-credentials.d.ts.map +1 -1
  164. package/dist/src/launcher/native-submission-credentials.js +2 -1
  165. package/dist/src/launcher/native-submission-credentials.js.map +1 -1
  166. package/dist/src/launcher/responses-encrypted-replay.d.ts +7 -0
  167. package/dist/src/launcher/responses-encrypted-replay.d.ts.map +1 -0
  168. package/dist/src/launcher/responses-encrypted-replay.js +290 -0
  169. package/dist/src/launcher/responses-encrypted-replay.js.map +1 -0
  170. package/dist/src/launcher/terminal-provider.d.ts +48 -0
  171. package/dist/src/launcher/terminal-provider.d.ts.map +1 -0
  172. package/dist/src/launcher/terminal-provider.js +149 -0
  173. package/dist/src/launcher/terminal-provider.js.map +1 -0
  174. package/dist/src/model-catalog-management.d.ts +2 -0
  175. package/dist/src/model-catalog-management.d.ts.map +1 -1
  176. package/dist/src/model-service-contracts.d.ts +53 -0
  177. package/dist/src/model-service-contracts.d.ts.map +1 -0
  178. package/dist/src/model-service-contracts.js +10 -0
  179. package/dist/src/model-service-contracts.js.map +1 -0
  180. package/dist/src/providers/config.d.ts.map +1 -1
  181. package/dist/src/providers/config.js +4 -1
  182. package/dist/src/providers/config.js.map +1 -1
  183. package/dist/src/renderer/manager/pages/ModelServicesPage.d.ts.map +1 -1
  184. package/dist/src/renderer/manager/pages/ModelServicesPage.js +2 -1
  185. package/dist/src/renderer/manager/pages/ModelServicesPage.js.map +1 -1
  186. package/dist/src/renderer/manager/pages/model-catalog/SharedModelServices.d.ts +6 -0
  187. package/dist/src/renderer/manager/pages/model-catalog/SharedModelServices.d.ts.map +1 -0
  188. package/dist/src/renderer/manager/pages/model-catalog/SharedModelServices.js +191 -0
  189. package/dist/src/renderer/manager/pages/model-catalog/SharedModelServices.js.map +1 -0
  190. package/dist/src/renderer/manager/pages/model-services.css +87 -0
  191. package/dist/src/renderer/model-catalog-client.d.ts +5 -0
  192. package/dist/src/renderer/model-catalog-client.d.ts.map +1 -1
  193. package/dist/src/renderer/model-catalog-client.js +24 -0
  194. package/dist/src/renderer/model-catalog-client.js.map +1 -1
  195. package/dist/src/renderer/model-provider-selector.d.ts +1 -0
  196. package/dist/src/renderer/model-provider-selector.d.ts.map +1 -1
  197. package/dist/src/renderer/model-provider-selector.js +5 -3
  198. package/dist/src/renderer/model-provider-selector.js.map +1 -1
  199. package/dist/src/renderer/model-providers.d.ts.map +1 -1
  200. package/dist/src/renderer/model-providers.js +2 -0
  201. package/dist/src/renderer/model-providers.js.map +1 -1
  202. package/dist/src/renderer/native-model-provider-state.d.ts +10 -1
  203. package/dist/src/renderer/native-model-provider-state.d.ts.map +1 -1
  204. package/dist/src/renderer/native-model-provider-state.js +26 -2
  205. package/dist/src/renderer/native-model-provider-state.js.map +1 -1
  206. package/dist/src/renderer/native-model-provider-transport.d.ts +0 -2
  207. package/dist/src/renderer/native-model-provider-transport.d.ts.map +1 -1
  208. package/dist/src/renderer/native-model-provider-transport.js +16 -21
  209. package/dist/src/renderer/native-model-provider-transport.js.map +1 -1
  210. package/dist/src/renderer/native-provider-selection-client.d.ts +4 -0
  211. package/dist/src/renderer/native-provider-selection-client.d.ts.map +1 -1
  212. package/dist/src/renderer/native-provider-selection-client.js +82 -9
  213. package/dist/src/renderer/native-provider-selection-client.js.map +1 -1
  214. package/dist/src/renderer/ui-copy/model-catalog.d.ts +88 -0
  215. package/dist/src/renderer/ui-copy/model-catalog.d.ts.map +1 -1
  216. package/dist/src/renderer/ui-copy/model-catalog.js +40 -0
  217. package/dist/src/renderer/ui-copy/model-catalog.js.map +1 -1
  218. package/dist/src/renderer/ui-copy.d.ts +89 -1
  219. package/dist/src/renderer/ui-copy.d.ts.map +1 -1
  220. package/package.json +1 -1
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "cordisx",
3
+ "version": "0.1.0",
4
+ "description": "CordisX bridge between Claude Desktop and Codex Desktop conversations",
5
+ "license": "AGPL-3.0-or-later"
6
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "modules": ["./register.ts"]
3
+ }
@@ -0,0 +1,346 @@
1
+ import type { EngineInterface, Register } from 'claude-code'
2
+
3
+ /**
4
+ * CordisX bridge for Claude Code sessions in a Claude Desktop profile that
5
+ * `cordisx start claude` launched.
6
+ *
7
+ * - Claude -> Codex: registers `codex_*` tools; each one asks the CordisX agent
8
+ * bridge, which runs it on the Codex desktop's own app-server.
9
+ * - Codex -> Claude: the bridge drives Claude from outside the app; it queues
10
+ * only a message for a session the app has open, which this plugin polls
11
+ * for and sends with Claude Desktop's own session tools.
12
+ *
13
+ * The bridge's socket and token come from `<CORDISX_HOME>/run/agent-bridge.json`,
14
+ * written by a running CordisX Codex launch. Without it the tools say so.
15
+ */
16
+
17
+ interface Binding {
18
+ readonly socketPath: string
19
+ readonly token: string
20
+ }
21
+
22
+ interface BridgeReply {
23
+ readonly ok: boolean
24
+ readonly value?: unknown
25
+ readonly error?: string
26
+ /** No CordisX Codex launch is answering: Codex is closed. */
27
+ readonly unreachable?: boolean
28
+ }
29
+
30
+ const POLL_MS = 1500
31
+ const SESSION_ID = /local_[0-9a-f-]{36}/u
32
+ const CLAUDE_LINK = /claude:\/\/[^\s"]+/u
33
+
34
+ const APPS = ['codex', 'claude'] as const
35
+ const APP = { enum: APPS, description: 'The app whose conversations to use: "codex" or "claude".' }
36
+ const LAUNCH = {
37
+ enum: ['once', 'always', 'ask'],
38
+ description:
39
+ 'Only after the user answered a needs-confirmation result: "once" starts the app this time, "always" also from now on without asking, "ask" goes back to asking.',
40
+ }
41
+ /** How long a started Codex gets to bring its agent bridge up. */
42
+ const CODEX_START_MS = 90_000
43
+
44
+ /** One set of tool names for every app CordisX connects; `app` names the target. */
45
+ const SESSION_TOOLS = [
46
+ {
47
+ name: 'list_sessions',
48
+ description:
49
+ 'List conversations in an app CordisX connects (`app`: "codex" for Codex Desktop threads, "claude" for Claude Desktop Code sessions), most recent first, each with a link the user can click to open it. Read-only.',
50
+ inputSchema: {
51
+ type: 'object',
52
+ additionalProperties: false,
53
+ properties: {
54
+ app: APP,
55
+ limit: { type: 'integer', minimum: 1, maximum: 50 },
56
+ searchTerm: { type: 'string', maxLength: 256 },
57
+ launch: LAUNCH,
58
+ },
59
+ required: ['app'],
60
+ },
61
+ },
62
+ {
63
+ name: 'read_session',
64
+ description:
65
+ 'Read the recent transcript of one conversation by its sessionId (from list_sessions) in the named app, plus its link. Read-only.',
66
+ inputSchema: {
67
+ type: 'object',
68
+ additionalProperties: false,
69
+ properties: {
70
+ app: APP,
71
+ sessionId: { type: 'string', minLength: 1, maxLength: 512 },
72
+ limit: { type: 'integer', minimum: 1, maximum: 200 },
73
+ launch: LAUNCH,
74
+ },
75
+ required: ['app', 'sessionId'],
76
+ },
77
+ },
78
+ {
79
+ name: 'start_session',
80
+ description:
81
+ 'Start a new conversation in the named app for a task the user asked to hand over, and return its sessionId and link. The prompt is the full brief. For Codex, providerId and model pick one of the model services CordisX configured. Only when the user explicitly asks.',
82
+ inputSchema: {
83
+ type: 'object',
84
+ additionalProperties: false,
85
+ properties: {
86
+ app: APP,
87
+ prompt: { type: 'string', minLength: 1, maxLength: 100000 },
88
+ title: { type: 'string', minLength: 1, maxLength: 120 },
89
+ cwd: { type: 'string', minLength: 1, maxLength: 4096 },
90
+ providerId: { type: 'string', minLength: 1, maxLength: 128 },
91
+ model: { type: 'string', minLength: 1, maxLength: 512 },
92
+ launch: LAUNCH,
93
+ },
94
+ required: ['app', 'prompt'],
95
+ },
96
+ },
97
+ {
98
+ name: 'send_message',
99
+ description:
100
+ 'Send a message to an existing conversation by its sessionId in the named app; it runs there as the next turn. Only when the user explicitly asks.',
101
+ inputSchema: {
102
+ type: 'object',
103
+ additionalProperties: false,
104
+ properties: {
105
+ app: APP,
106
+ sessionId: { type: 'string', minLength: 1, maxLength: 512 },
107
+ prompt: { type: 'string', minLength: 1, maxLength: 100000 },
108
+ launch: LAUNCH,
109
+ },
110
+ required: ['app', 'sessionId', 'prompt'],
111
+ },
112
+ },
113
+ ] as const
114
+
115
+ let polling = false
116
+
117
+ async function readBinding($: EngineInterface): Promise<Binding | undefined> {
118
+ const home = await cordisxHome($)
119
+ try {
120
+ const value = JSON.parse(await $.fs.read(`${home}/run/agent-bridge.json`)) as Partial<Binding>
121
+ return typeof value.socketPath === 'string' && typeof value.token === 'string'
122
+ ? { socketPath: value.socketPath, token: value.token }
123
+ : undefined
124
+ } catch {
125
+ return undefined
126
+ }
127
+ }
128
+
129
+ async function post($: EngineInterface, route: string, body: unknown): Promise<BridgeReply> {
130
+ const binding = await readBinding($)
131
+ if (binding === undefined) {
132
+ return { ok: false, unreachable: true, error: 'CordisX is not running Codex (no agent bridge found)' }
133
+ }
134
+ try {
135
+ const response = await $.http.fetch(`http://cordisx${route}`, {
136
+ method: 'POST',
137
+ socketPath: binding.socketPath,
138
+ headers: { 'content-type': 'application/json', 'x-cordisx-bridge-token': binding.token },
139
+ body: JSON.stringify(body),
140
+ })
141
+ return JSON.parse(response.text) as BridgeReply
142
+ } catch {
143
+ return { ok: false, unreachable: true, error: 'The CordisX agent bridge is not reachable' }
144
+ }
145
+ }
146
+
147
+ function textOf(value: unknown): string {
148
+ const text = (value as { text?: unknown } | undefined)?.text
149
+ return typeof text === 'string' ? text : JSON.stringify(value)
150
+ }
151
+
152
+ function limitOf(args: Record<string, unknown>, fallback: number): number {
153
+ return typeof args.limit === 'number' ? args.limit : fallback
154
+ }
155
+
156
+ /** Runs one Codex -> Claude request with Claude Desktop's own session tools. */
157
+ async function answer($: EngineInterface, operation: string, args: Record<string, unknown>): Promise<unknown> {
158
+ if (operation === 'list_sessions') {
159
+ const current = await $.tool.call({ tool: 'mcp__ccd_session_mgmt__get_session', session_id: 'self' })
160
+ const others = await $.tool.call({ tool: 'mcp__ccd_session_mgmt__list_sessions', limit: limitOf(args, 20) })
161
+ return { current: textOf(current), others: textOf(others) }
162
+ }
163
+ if (operation === 'read_session') {
164
+ const sessionId = String(args.sessionId ?? '')
165
+ const details = await $.tool.call({ tool: 'mcp__ccd_session_mgmt__get_session', session_id: sessionId })
166
+ // list_events reads other sessions only; this session's own transcript is read directly.
167
+ const own = textOf(await $.tool.call({ tool: 'mcp__ccd_session_mgmt__get_session', session_id: 'self' }))
168
+ const transcript = own.includes(sessionId)
169
+ ? JSON.stringify((await $.session.messages()).slice(-limitOf(args, 40)))
170
+ : textOf(
171
+ await $.tool.call({
172
+ tool: 'mcp__ccd_session_mgmt__list_events',
173
+ session_id: sessionId,
174
+ limit: limitOf(args, 40),
175
+ }),
176
+ )
177
+ return { session: textOf(details), transcript }
178
+ }
179
+ if (operation === 'start_session') {
180
+ const started = await $.tool.call({
181
+ tool: 'mcp__ccd_session__start_session',
182
+ initiation: 'user_asked',
183
+ context: 'fresh',
184
+ title: String(args.title ?? 'Task from Codex'),
185
+ prompt: String(args.prompt ?? ''),
186
+ background:
187
+ "This task was handed over from a Codex Desktop conversation through the CordisX agent bridge, at the user's request. Treat the prompt as the complete brief.",
188
+ ...(typeof args.cwd === 'string' ? { cwd: args.cwd } : {}),
189
+ })
190
+ const sessionId = SESSION_ID.exec(textOf(started))?.[0]
191
+ if (sessionId === undefined) return { status: 'unknown', result: textOf(started) }
192
+ // A session this one starts nests under it; the user should see it as their own.
193
+ try {
194
+ await $.tool.call({ tool: 'mcp__ccd_session_mgmt__detach_session', session_id: sessionId })
195
+ } catch { /* stays nested; still usable */ }
196
+ const details = await $.tool.call({ tool: 'mcp__ccd_session_mgmt__get_session', session_id: sessionId })
197
+ const link = CLAUDE_LINK.exec(textOf(details))?.[0]
198
+ return { status: 'started', sessionId, ...(link === undefined ? {} : { link }) }
199
+ }
200
+ if (operation === 'send_message') {
201
+ const prompt = String(args.prompt ?? args.message ?? '')
202
+ // Claude refuses a session's message to itself; a prompt this session submits is its next turn.
203
+ if (args.cliSessionId === await $.session.id()) {
204
+ await $.prompt.submit({ text: prompt })
205
+ return { status: 'sent', sessionId: args.sessionId }
206
+ }
207
+ const sent = await $.tool.call({
208
+ tool: 'mcp__ccd_session_mgmt__send_message',
209
+ session_id: String(args.sessionId ?? ''),
210
+ message: prompt,
211
+ })
212
+ return { status: 'sent', result: textOf(sent) }
213
+ }
214
+ throw new Error(`unknown Claude bridge operation: ${operation}`)
215
+ }
216
+
217
+ async function poll($: EngineInterface): Promise<void> {
218
+ if (polling) return
219
+ polling = true
220
+ try {
221
+ // Claude's session tools connect after the session starts; until they do,
222
+ // this session cannot answer a Codex request and must not claim one.
223
+ if (!await hostsClaudeSessions($)) return
224
+ const next = await post($, '/claude/poll', { sessionId: await $.session.id() })
225
+ const request = (next.ok ? next.value : undefined) as
226
+ | { id?: string; operation?: string; args?: Record<string, unknown> }
227
+ | undefined
228
+ if (request?.id === undefined || request.operation === undefined) return
229
+ try {
230
+ const value = await answer($, request.operation, request.args ?? {})
231
+ await post($, '/claude/result', { id: request.id, ok: true, value })
232
+ } catch (error) {
233
+ await post($, '/claude/result', {
234
+ id: request.id,
235
+ ok: false,
236
+ error: error instanceof Error ? error.message : String(error),
237
+ })
238
+ }
239
+ } finally {
240
+ polling = false
241
+ }
242
+ }
243
+
244
+ async function hostsClaudeSessions($: EngineInterface): Promise<boolean> {
245
+ const tools = await $.tool.list()
246
+ return ['mcp__ccd_session__start_session', 'mcp__ccd_session_mgmt__list_sessions'].every(name =>
247
+ tools.some(tool => tool.name === name)
248
+ )
249
+ }
250
+
251
+ /** Runs one session tool: Codex through the agent bridge, Claude with this app's own session tools. */
252
+ async function runSessionTool($: EngineInterface, operation: string, input: Record<string, unknown>): Promise<string> {
253
+ const { app, ...args } = input
254
+ if (app === 'claude') {
255
+ // The bridge drives Claude from outside the app, so a new session needs no
256
+ // "start the session?" prompt; without a bridge, Claude's own tools answer.
257
+ const { launch: _launch, ...request } = args
258
+ const bridged = await post($, '/sessions', { app, operation, args: request })
259
+ if (bridged.ok) return JSON.stringify(bridged.value, null, 2)
260
+ try {
261
+ return JSON.stringify(await answer($, operation, args), null, 2)
262
+ } catch (error) {
263
+ return `Claude could not do it: ${error instanceof Error ? error.message : String(error)}`
264
+ }
265
+ }
266
+ if (app !== 'codex') return `app must be one of ${APPS.join(', ')}`
267
+ const { launch, ...request } = args
268
+ let answered = await post($, '/sessions', { app, operation, args: request })
269
+ if (!answered.ok && answered.unreachable === true) {
270
+ const started = await startCodex($, launch)
271
+ if (started !== true) return JSON.stringify(started, null, 2)
272
+ answered = await post($, '/sessions', { app, operation, args: request })
273
+ }
274
+ return answered.ok
275
+ ? JSON.stringify(answered.value, null, 2)
276
+ : `Codex is unavailable: ${answered.error ?? 'unknown error'}`
277
+ }
278
+
279
+ async function cordisxHome($: EngineInterface): Promise<string> {
280
+ return await $.env.get('CORDISX_HOME') ?? `${await $.env.get('HOME') ?? ''}/.cordisx`
281
+ }
282
+
283
+ /**
284
+ * Starts the CordisX Codex launch this home last ran, when the person allowed
285
+ * it: this call (`launch: "once" | "always"`, the latter remembered) or an
286
+ * earlier "always". Otherwise the same question the Codex side asks about
287
+ * Claude, at once.
288
+ */
289
+ async function startCodex($: EngineInterface, launch: unknown): Promise<true | Record<string, string>> {
290
+ const home = await cordisxHome($)
291
+ const preference = `${home}/apps/codex/bridge-launch.json`
292
+ if (launch === 'always' || launch === 'ask') {
293
+ await $.fs.write(preference, `${JSON.stringify({ launch })}\n`)
294
+ }
295
+ let remembered = false
296
+ try {
297
+ remembered = (JSON.parse(await $.fs.read(preference)) as { launch?: unknown }).launch === 'always'
298
+ } catch { /* never answered */ }
299
+ const allowed = launch === 'once' || launch === 'always' || (launch !== 'ask' && remembered)
300
+ if (!allowed) {
301
+ return {
302
+ status: 'needs-confirmation',
303
+ reason: 'codex-not-running',
304
+ question: 'Codex Desktop is not running. Start it?',
305
+ howToContinue:
306
+ 'Ask the user, in their language, whether to start Codex Desktop. If they agree, call this tool again with the same arguments plus launch "once" (start it this time) or "always" (start it automatically from now on, without asking). Do not retry without their answer.',
307
+ }
308
+ }
309
+ let cli: string[] = []
310
+ try {
311
+ cli = JSON.parse(await $.env.get('CORDISX_CLI') ?? '[]') as string[]
312
+ } catch { /* not launched by CordisX */ }
313
+ let target = { homeDir: home, profileId: 'default' }
314
+ try {
315
+ target = { ...target, ...JSON.parse(await $.fs.read(`${home}/run/codex-launch.json`)) as typeof target }
316
+ } catch { /* Codex never ran with the bridge; its default profile */ }
317
+ const argv = cli.length > 0
318
+ ? [...cli, 'start', 'codex', target.profileId]
319
+ : ['cordisx', 'start', 'codex', target.profileId]
320
+ const started = await $.process.run(argv, { env: { CORDISX_HOME: target.homeDir }, timeoutMs: CODEX_START_MS })
321
+ if (started.exitCode !== 0) {
322
+ return { status: 'failed', reason: 'codex-start-failed', detail: started.stderr.slice(-2000) }
323
+ }
324
+ for (const deadline = Date.now() + CODEX_START_MS; Date.now() < deadline;) {
325
+ if ((await post($, '/sessions', { app: 'codex', operation: 'list_sessions', args: { limit: 1 } })).ok) return true
326
+ await new Promise(resolve => setTimeout(resolve, 1000))
327
+ }
328
+ return { status: 'failed', reason: 'codex-bridge-not-ready' }
329
+ }
330
+
331
+ export const register: Register = on => {
332
+ on('session.start', async ($, e, next) => {
333
+ for (const tool of SESSION_TOOLS) {
334
+ await $.tool.register({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema })
335
+ }
336
+ $.clock.every(POLL_MS, () => void poll($))
337
+ return next(e)
338
+ })
339
+
340
+ for (const tool of SESSION_TOOLS) {
341
+ on('tool.call', { tool: `mcp__cordisx__${tool.name}` }, async ($, e) => {
342
+ const { tool: _tool, tool_use_id: _id, ...args } = e as Record<string, unknown>
343
+ return { result: await runSessionTool($, tool.name, args) }
344
+ })
345
+ }
346
+ }
@@ -53,7 +53,77 @@ const tools = [{
53
53
  },
54
54
  required: ['operationId', 'providerId', 'model', 'prompt', 'target'],
55
55
  },
56
+ }, {
57
+ name: 'list_sessions',
58
+ description:
59
+ 'List conversations in another app CordisX connects (`app`: "claude" for Claude Desktop Code sessions, "codex" for this Codex app), most recent first, each with a link the user can click to open it. Read-only. Claude needs Claude Desktop launched with `cordisx start claude`; no Claude session has to be open.',
60
+ inputSchema: {
61
+ type: 'object',
62
+ additionalProperties: false,
63
+ properties: {
64
+ app: { enum: ['claude', 'codex'] },
65
+ limit: { type: 'integer', minimum: 1, maximum: 50 },
66
+ searchTerm: { type: 'string', maxLength: 256 },
67
+ },
68
+ required: ['app'],
69
+ },
70
+ }, {
71
+ name: 'read_session',
72
+ description:
73
+ 'Read the recent transcript of one conversation by its sessionId (from list_sessions) in the named app, plus its link. Read-only.',
74
+ inputSchema: {
75
+ type: 'object',
76
+ additionalProperties: false,
77
+ properties: {
78
+ app: { enum: ['claude', 'codex'] },
79
+ sessionId: { type: 'string', minLength: 1, maxLength: 512 },
80
+ limit: { type: 'integer', minimum: 1, maximum: 200 },
81
+ },
82
+ required: ['app', 'sessionId'],
83
+ },
84
+ }, {
85
+ name: 'start_session',
86
+ description:
87
+ 'Start a new conversation in the named app for a task the user asked to hand over, and return its sessionId and link. The prompt is the full brief. In Claude the session runs in the background in bypass permissions mode on the CordisX model service (model picks a Claude model) and shows in Claude when its first turn ends; the link opens it. If Claude is not running the result asks you to ask the user whether to start it. Only when the user explicitly asks.',
88
+ inputSchema: {
89
+ type: 'object',
90
+ additionalProperties: false,
91
+ properties: {
92
+ app: { enum: ['claude', 'codex'] },
93
+ prompt: { type: 'string', minLength: 1, maxLength: 100000 },
94
+ title: { type: 'string', minLength: 1, maxLength: 120 },
95
+ cwd: { type: 'string', minLength: 1, maxLength: 4096 },
96
+ providerId: { type: 'string', minLength: 1, maxLength: 128 },
97
+ model: { type: 'string', minLength: 1, maxLength: 512 },
98
+ launch: {
99
+ enum: ['once', 'always', 'ask'],
100
+ description:
101
+ 'Only after the user answered a needs-confirmation result: "once" starts Claude this time, "always" also from now on without asking, "ask" goes back to asking.',
102
+ },
103
+ },
104
+ required: ['app', 'prompt'],
105
+ },
106
+ }, {
107
+ name: 'send_message',
108
+ description:
109
+ 'Send a message to an existing conversation by its sessionId in the named app. It runs there as the next turn, without any approval prompt. If Claude is not running the result asks you to ask the user first. Only when the user explicitly asks.',
110
+ inputSchema: {
111
+ type: 'object',
112
+ additionalProperties: false,
113
+ properties: {
114
+ app: { enum: ['claude', 'codex'] },
115
+ sessionId: { type: 'string', minLength: 1, maxLength: 512 },
116
+ prompt: { type: 'string', minLength: 1, maxLength: 100000 },
117
+ launch: {
118
+ enum: ['once', 'always', 'ask'],
119
+ description:
120
+ 'Only after the user answered a needs-confirmation result: "once" starts Claude this time, "always" also from now on without asking, "ask" goes back to asking.',
121
+ },
122
+ },
123
+ required: ['app', 'sessionId', 'prompt'],
124
+ },
56
125
  }]
126
+ const sessionTools = new Set(['list_sessions', 'read_session', 'start_session', 'send_message'])
57
127
 
58
128
  async function invoke(operation, input, metadata) {
59
129
  const binding = JSON.parse(await readFile(bindingPath, 'utf8'))
@@ -71,7 +141,7 @@ async function invoke(operation, input, metadata) {
71
141
  socket.destroy()
72
142
  error ? reject(error) : resolve(value)
73
143
  }
74
- const timer = setTimeout(() => finish(new Error('Native selection acknowledgement unavailable')), 45000)
144
+ const timer = setTimeout(() => finish(new Error('Native selection acknowledgement unavailable')), 85000)
75
145
  socket.on('error', () => finish(new Error('Native model tools unavailable')))
76
146
  socket.on('end', () => finish(new Error('Native selection acknowledgement unavailable')))
77
147
  socket.on(
@@ -127,7 +197,9 @@ reader.on('line', line => {
127
197
  else if (request.method === 'resources/list') result = { resources: [] }
128
198
  else if (request.method === 'resources/templates/list') result = { resourceTemplates: [] }
129
199
  else if (request.method === 'tools/call') {
130
- const operation = request.params?.name === 'list_model_providers'
200
+ const operation = sessionTools.has(request.params?.name)
201
+ ? `session:${request.params.name}`
202
+ : request.params?.name === 'list_model_providers'
131
203
  ? 'list'
132
204
  : request.params?.name === 'select_thread_model_provider'
133
205
  ? 'select'
@@ -141,7 +213,8 @@ reader.on('line', line => {
141
213
  })
142
214
  result = {
143
215
  content: [{ type: 'text', text: JSON.stringify(value) }],
144
- isError: value?.status === 'rejected' || value?.status === 'reconciliation-required',
216
+ isError: value?.status === 'rejected' || value?.status === 'reconciliation-required'
217
+ || value?.status === 'unavailable',
145
218
  }
146
219
  } else {
147
220
  process.stdout.write(
@@ -37,6 +37,12 @@ if (agentModelsBinding && nativeArgs.includes('app-server')) {
37
37
  agentModelsBinding,
38
38
  ])
39
39
  }`,
40
+ // A message to an open Claude session waits for that session to take it.
41
+ '-c',
42
+ 'mcp_servers.cordisx_models.tool_timeout_sec=90',
43
+ // CordisX's own tools run without a per-call prompt; the agent still acts only when asked.
44
+ '-c',
45
+ 'mcp_servers.cordisx_models.default_tools_approval_mode="approve"',
40
46
  )
41
47
  }
42
48
  const child = spawn(executable, nativeArgs, { stdio: ['pipe', 'pipe', 'inherit'], env: process.env })
@@ -371,6 +377,23 @@ async function forward(line) {
371
377
  } else lifecycleCalls.set(message.id, params.threadId)
372
378
  if (message.method === 'thread/unsubscribe') unmarkedTurns.retireThread(params.threadId)
373
379
  }
380
+ if (['thread/start', 'thread/resume'].includes(message?.method) && params) {
381
+ try {
382
+ let providerId = params.modelProvider
383
+ if (message.method === 'thread/resume' && providerId === undefined && typeof params.threadId === 'string') {
384
+ const persisted = await nativeCall('thread/read', { threadId: params.threadId, includeTurns: false })
385
+ providerId = persisted?.thread?.modelProvider
386
+ }
387
+ const overrides = await controlCall('configured-provider', {
388
+ ...(typeof providerId === 'string' ? { providerId } : {}),
389
+ })
390
+ if (object(overrides) && Object.keys(overrides).length) {
391
+ params.config = { ...object(params.config), ...overrides }
392
+ await write(child.stdin, message)
393
+ return
394
+ }
395
+ } catch {}
396
+ }
374
397
  await write(child.stdin, line)
375
398
  return
376
399
  }
@@ -651,6 +674,14 @@ readLines(child.stdout, line => {
651
674
  })
652
675
 
653
676
  const switching = new Set()
677
+ const BRIDGE_NATIVE_METHODS = new Set([
678
+ 'thread/list',
679
+ 'thread/read',
680
+ 'thread/start',
681
+ 'thread/resume',
682
+ 'turn/start',
683
+ 'turn/interrupt',
684
+ ])
654
685
  readLines(control, line => {
655
686
  let message
656
687
  try {
@@ -675,6 +706,19 @@ readLines(control, line => {
675
706
  .catch(() => write(control, { id: message.id, ok: false }).catch(stop))
676
707
  return
677
708
  }
709
+ // The CordisX agent bridge reads and starts threads in this same app-server, so
710
+ // the desktop sees them. Only these methods cross; the Host validates params.
711
+ if (message.type === 'native-request' && typeof message.id === 'string') {
712
+ const params = object(message.params)
713
+ if (!BRIDGE_NATIVE_METHODS.has(message.method) || params === undefined) {
714
+ void write(control, { id: message.id, ok: false }).catch(stop)
715
+ return
716
+ }
717
+ void nativeCall(message.method, params)
718
+ .then(value => write(control, { id: message.id, ok: true, value }))
719
+ .catch(() => write(control, { id: message.id, ok: false }).catch(stop))
720
+ return
721
+ }
678
722
  if (message.type === 'idle' && typeof message.id === 'string' && typeof message.threadId === 'string') {
679
723
  void nativeCall('thread/read', { threadId: message.threadId, includeTurns: false }).then(result => {
680
724
  const status = result?.thread?.status?.type
@@ -0,0 +1,4 @@
1
+ // Only the selected CLI child receives this value. No key is passed in argv.
2
+ const key = process.env.CORDISX_TERMINAL_SERVICE_KEY
3
+ if (!key || key.includes('\0')) process.exit(1)
4
+ process.stdout.write(key)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schema": "cordisx/native-helper-artifact/v1",
3
- "sourceCommit": "055f7ddadb71a8020b05b2ec963818aecb0bed6a",
3
+ "sourceCommit": "2c059904482703b968b94567bfea579052d98b33",
4
4
  "deploymentTarget": "13.0",
5
5
  "architectures": [
6
6
  "arm64",
@@ -0,0 +1,17 @@
1
+ import type { CordisXLauncherOptions } from './parse.js';
2
+ import type { CordisXCliRuntime } from './run-support.js';
3
+ export declare const CLAUDE_APP_ID = "claude";
4
+ export interface ClaudeDesktopInvocation {
5
+ readonly action: 'start' | 'run' | 'restart' | 'stop' | 'status';
6
+ readonly profile?: string;
7
+ readonly options: Pick<CordisXLauncherOptions, 'provider' | 'executable' | 'dryRun'>;
8
+ }
9
+ /**
10
+ * `cordisx start|run|restart|stop|status claude [profile]`.
11
+ *
12
+ * Claude Desktop refuses debugging switches, so it gets no CDP host: CordisX
13
+ * seeds the profile's provider configuration, starts the app on that profile,
14
+ * and loads the CordisX bridge into its Claude Code sessions.
15
+ */
16
+ export declare function runClaudeDesktopCommand(invocation: ClaudeDesktopInvocation, runtime: CordisXCliRuntime): Promise<void>;
17
+ //# sourceMappingURL=claude-desktop-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-desktop-command.d.ts","sourceRoot":"","sources":["../../../src/cli/claude-desktop-command.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEzD,eAAO,MAAM,aAAa,WAAW,CAAA;AAErC,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAA;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,UAAU,GAAG,YAAY,GAAG,QAAQ,CAAC,CAAA;CACrF;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,uBAAuB,EACnC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAoGf"}