cordisx 0.1.0-beta.36 → 0.1.0-beta.38
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/dist/assets/claude-bridge/.claude-plugin/plugin.json +6 -0
- package/dist/assets/claude-bridge/hooks/hooks.json +3 -0
- package/dist/assets/claude-bridge/hooks/register.ts +397 -0
- package/dist/assets/launcher/native-agent-models-mcp.mjs +76 -3
- package/dist/assets/launcher/native-app-server-protocol.mjs +67 -0
- package/dist/assets/launcher/terminal-claude-key.mjs +4 -0
- package/dist/native/native-helper-artifact.json +1 -1
- package/dist/src/cli/claude-desktop-command.d.ts +17 -0
- package/dist/src/cli/claude-desktop-command.d.ts.map +1 -0
- package/dist/src/cli/claude-desktop-command.js +114 -0
- package/dist/src/cli/claude-desktop-command.js.map +1 -0
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/help.d.ts.map +1 -1
- package/dist/src/cli/help.js +6 -0
- package/dist/src/cli/help.js.map +1 -1
- package/dist/src/cli/launch-fingerprint.d.ts.map +1 -1
- package/dist/src/cli/launch-fingerprint.js +2 -0
- package/dist/src/cli/launch-fingerprint.js.map +1 -1
- package/dist/src/cli/native-submission-catalog-options.d.ts +8 -3
- package/dist/src/cli/native-submission-catalog-options.d.ts.map +1 -1
- package/dist/src/cli/native-submission-catalog-options.js +5 -1
- package/dist/src/cli/native-submission-catalog-options.js.map +1 -1
- package/dist/src/cli/parse.d.ts +7 -2
- package/dist/src/cli/parse.d.ts.map +1 -1
- package/dist/src/cli/parse.js +30 -0
- package/dist/src/cli/parse.js.map +1 -1
- package/dist/src/cli/production-host-bootstrap.d.ts.map +1 -1
- package/dist/src/cli/production-host-bootstrap.js +9 -0
- package/dist/src/cli/production-host-bootstrap.js.map +1 -1
- package/dist/src/cli/production-plugin-management.d.ts +3 -0
- package/dist/src/cli/production-plugin-management.d.ts.map +1 -1
- package/dist/src/cli/production-plugin-management.js +9 -0
- package/dist/src/cli/production-plugin-management.js.map +1 -1
- package/dist/src/cli/run-command-dispatch.d.ts.map +1 -1
- package/dist/src/cli/run-command-dispatch.js +14 -0
- package/dist/src/cli/run-command-dispatch.js.map +1 -1
- package/dist/src/cli/run-command.d.ts.map +1 -1
- package/dist/src/cli/run-command.js +9 -6
- package/dist/src/cli/run-command.js.map +1 -1
- package/dist/src/cli/run-injected-host.d.ts +2 -0
- package/dist/src/cli/run-injected-host.d.ts.map +1 -1
- package/dist/src/cli/run-injected-host.js +1 -0
- package/dist/src/cli/run-injected-host.js.map +1 -1
- package/dist/src/cli/run-runtime.d.ts +2 -0
- package/dist/src/cli/run-runtime.d.ts.map +1 -1
- package/dist/src/cli/run-runtime.js.map +1 -1
- package/dist/src/cli/run-support.d.ts.map +1 -1
- package/dist/src/cli/run-support.js +3 -1
- package/dist/src/cli/run-support.js.map +1 -1
- package/dist/src/cli/start-mode.d.ts +3 -0
- package/dist/src/cli/start-mode.d.ts.map +1 -0
- package/dist/src/cli/start-mode.js +29 -0
- package/dist/src/cli/start-mode.js.map +1 -0
- package/dist/src/cli/supervisor-command.d.ts.map +1 -1
- package/dist/src/cli/supervisor-command.js +7 -2
- package/dist/src/cli/supervisor-command.js.map +1 -1
- package/dist/src/cli/supervisor-entry.d.ts +8 -0
- package/dist/src/cli/supervisor-entry.d.ts.map +1 -0
- package/dist/src/cli/supervisor-entry.js +13 -0
- package/dist/src/cli/supervisor-entry.js.map +1 -0
- package/dist/src/cli/supervisor-entry.test.d.ts +2 -0
- package/dist/src/cli/supervisor-entry.test.d.ts.map +1 -0
- package/dist/src/cli/supervisor-entry.test.js +22 -0
- package/dist/src/cli/supervisor-entry.test.js.map +1 -0
- package/dist/src/cli/terminal-command.d.ts +9 -0
- package/dist/src/cli/terminal-command.d.ts.map +1 -0
- package/dist/src/cli/terminal-command.js +263 -0
- package/dist/src/cli/terminal-command.js.map +1 -0
- package/dist/src/cli/terminal-parse.d.ts +15 -0
- package/dist/src/cli/terminal-parse.d.ts.map +1 -0
- package/dist/src/cli/terminal-parse.js +92 -0
- package/dist/src/cli/terminal-parse.js.map +1 -0
- package/dist/src/cli/terminal-shared-service.d.ts +27 -0
- package/dist/src/cli/terminal-shared-service.d.ts.map +1 -0
- package/dist/src/cli/terminal-shared-service.js +49 -0
- package/dist/src/cli/terminal-shared-service.js.map +1 -0
- package/dist/src/cli.js +5 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/config/home-config-model-service.d.ts +25 -0
- package/dist/src/config/home-config-model-service.d.ts.map +1 -0
- package/dist/src/config/home-config-model-service.js +109 -0
- package/dist/src/config/home-config-model-service.js.map +1 -0
- package/dist/src/config/home-config.d.ts +5 -1
- package/dist/src/config/home-config.d.ts.map +1 -1
- package/dist/src/config/home-config.js +10 -5
- package/dist/src/config/home-config.js.map +1 -1
- package/dist/src/launcher/agent-bridge.d.ts +73 -0
- package/dist/src/launcher/agent-bridge.d.ts.map +1 -0
- package/dist/src/launcher/agent-bridge.js +354 -0
- package/dist/src/launcher/agent-bridge.js.map +1 -0
- package/dist/src/launcher/builtin-skill.d.ts +1 -0
- package/dist/src/launcher/builtin-skill.d.ts.map +1 -1
- package/dist/src/launcher/builtin-skill.js +1 -1
- package/dist/src/launcher/builtin-skill.js.map +1 -1
- package/dist/src/launcher/claude-bridge-plugin.d.ts +24 -0
- package/dist/src/launcher/claude-bridge-plugin.d.ts.map +1 -0
- package/dist/src/launcher/claude-bridge-plugin.js +77 -0
- package/dist/src/launcher/claude-bridge-plugin.js.map +1 -0
- package/dist/src/launcher/claude-desktop-process.d.ts +34 -0
- package/dist/src/launcher/claude-desktop-process.d.ts.map +1 -0
- package/dist/src/launcher/claude-desktop-process.js +123 -0
- package/dist/src/launcher/claude-desktop-process.js.map +1 -0
- package/dist/src/launcher/claude-desktop-profile.d.ts +57 -0
- package/dist/src/launcher/claude-desktop-profile.d.ts.map +1 -0
- package/dist/src/launcher/claude-desktop-profile.js +185 -0
- package/dist/src/launcher/claude-desktop-profile.js.map +1 -0
- package/dist/src/launcher/claude-host-sessions.d.ts +100 -0
- package/dist/src/launcher/claude-host-sessions.d.ts.map +1 -0
- package/dist/src/launcher/claude-host-sessions.js +610 -0
- package/dist/src/launcher/claude-host-sessions.js.map +1 -0
- package/dist/src/launcher/claude-permission-mode.d.ts +24 -0
- package/dist/src/launcher/claude-permission-mode.d.ts.map +1 -0
- package/dist/src/launcher/claude-permission-mode.js +98 -0
- package/dist/src/launcher/claude-permission-mode.js.map +1 -0
- package/dist/src/launcher/configured-encrypted-replay.d.ts +2 -0
- package/dist/src/launcher/configured-encrypted-replay.d.ts.map +1 -0
- package/dist/src/launcher/configured-encrypted-replay.js +34 -0
- package/dist/src/launcher/configured-encrypted-replay.js.map +1 -0
- package/dist/src/launcher/management-rpc.d.ts +5 -0
- package/dist/src/launcher/management-rpc.d.ts.map +1 -1
- package/dist/src/launcher/management-rpc.js +13 -4
- package/dist/src/launcher/management-rpc.js.map +1 -1
- package/dist/src/launcher/model-service-projection.d.ts +84 -0
- package/dist/src/launcher/model-service-projection.d.ts.map +1 -0
- package/dist/src/launcher/model-service-projection.js +259 -0
- package/dist/src/launcher/model-service-projection.js.map +1 -0
- package/dist/src/launcher/model-service-store.d.ts +7 -0
- package/dist/src/launcher/model-service-store.d.ts.map +1 -0
- package/dist/src/launcher/model-service-store.js +164 -0
- package/dist/src/launcher/model-service-store.js.map +1 -0
- package/dist/src/launcher/native-account-structure.d.ts +1 -1
- package/dist/src/launcher/native-account-structure.d.ts.map +1 -1
- package/dist/src/launcher/native-account-structure.js +42 -9
- package/dist/src/launcher/native-account-structure.js.map +1 -1
- package/dist/src/launcher/native-agent-models.d.ts +6 -0
- package/dist/src/launcher/native-agent-models.d.ts.map +1 -1
- package/dist/src/launcher/native-agent-models.js +25 -1
- package/dist/src/launcher/native-agent-models.js.map +1 -1
- package/dist/src/launcher/native-agent-task-source.d.ts +28 -0
- package/dist/src/launcher/native-agent-task-source.d.ts.map +1 -0
- package/dist/src/launcher/native-agent-task-source.js +77 -0
- package/dist/src/launcher/native-agent-task-source.js.map +1 -0
- package/dist/src/launcher/native-agent-task-transform.d.ts +4 -11
- package/dist/src/launcher/native-agent-task-transform.d.ts.map +1 -1
- package/dist/src/launcher/native-agent-task-transform.js +162 -84
- package/dist/src/launcher/native-agent-task-transform.js.map +1 -1
- package/dist/src/launcher/native-app-resources.d.ts.map +1 -1
- package/dist/src/launcher/native-app-resources.js +2 -1
- package/dist/src/launcher/native-app-resources.js.map +1 -1
- package/dist/src/launcher/native-lazy-wire-request.d.ts +10 -0
- package/dist/src/launcher/native-lazy-wire-request.d.ts.map +1 -0
- package/dist/src/launcher/native-lazy-wire-request.js +48 -0
- package/dist/src/launcher/native-lazy-wire-request.js.map +1 -0
- package/dist/src/launcher/native-predispatch-interception.d.ts +2 -0
- package/dist/src/launcher/native-predispatch-interception.d.ts.map +1 -1
- package/dist/src/launcher/native-predispatch-interception.js.map +1 -1
- package/dist/src/launcher/native-submission-cdp-channel.d.ts +8 -0
- package/dist/src/launcher/native-submission-cdp-channel.d.ts.map +1 -1
- package/dist/src/launcher/native-submission-cdp-channel.js +47 -5
- package/dist/src/launcher/native-submission-cdp-channel.js.map +1 -1
- package/dist/src/launcher/native-submission-composition.d.ts +6 -0
- package/dist/src/launcher/native-submission-composition.d.ts.map +1 -1
- package/dist/src/launcher/native-submission-composition.js +92 -4
- package/dist/src/launcher/native-submission-composition.js.map +1 -1
- package/dist/src/launcher/native-submission-control-server.d.ts +4 -0
- package/dist/src/launcher/native-submission-control-server.d.ts.map +1 -1
- package/dist/src/launcher/native-submission-control-server.js +28 -0
- package/dist/src/launcher/native-submission-control-server.js.map +1 -1
- package/dist/src/launcher/native-submission-controller.d.ts +2 -0
- package/dist/src/launcher/native-submission-controller.d.ts.map +1 -1
- package/dist/src/launcher/native-submission-controller.js +9 -6
- package/dist/src/launcher/native-submission-controller.js.map +1 -1
- package/dist/src/launcher/native-submission-credentials.d.ts +1 -0
- package/dist/src/launcher/native-submission-credentials.d.ts.map +1 -1
- package/dist/src/launcher/native-submission-credentials.js +2 -1
- package/dist/src/launcher/native-submission-credentials.js.map +1 -1
- package/dist/src/launcher/native-submission-structure.d.ts.map +1 -1
- package/dist/src/launcher/native-submission-structure.js +37 -4
- package/dist/src/launcher/native-submission-structure.js.map +1 -1
- package/dist/src/launcher/responses-encrypted-replay.d.ts +7 -0
- package/dist/src/launcher/responses-encrypted-replay.d.ts.map +1 -0
- package/dist/src/launcher/responses-encrypted-replay.js +290 -0
- package/dist/src/launcher/responses-encrypted-replay.js.map +1 -0
- package/dist/src/launcher/terminal-provider.d.ts +48 -0
- package/dist/src/launcher/terminal-provider.d.ts.map +1 -0
- package/dist/src/launcher/terminal-provider.js +149 -0
- package/dist/src/launcher/terminal-provider.js.map +1 -0
- package/dist/src/model-catalog-management.d.ts +2 -0
- package/dist/src/model-catalog-management.d.ts.map +1 -1
- package/dist/src/model-service-contracts.d.ts +53 -0
- package/dist/src/model-service-contracts.d.ts.map +1 -0
- package/dist/src/model-service-contracts.js +10 -0
- package/dist/src/model-service-contracts.js.map +1 -0
- package/dist/src/native-account-capability.d.ts +1 -0
- package/dist/src/native-account-capability.d.ts.map +1 -1
- package/dist/src/native-account-capability.js +25 -7
- package/dist/src/native-account-capability.js.map +1 -1
- package/dist/src/providers/config.d.ts.map +1 -1
- package/dist/src/providers/config.js +4 -1
- package/dist/src/providers/config.js.map +1 -1
- package/dist/src/renderer/adapter/startup-readiness.d.ts.map +1 -1
- package/dist/src/renderer/adapter/startup-readiness.js +5 -1
- package/dist/src/renderer/adapter/startup-readiness.js.map +1 -1
- package/dist/src/renderer/manager/pages/ModelServicesPage.d.ts.map +1 -1
- package/dist/src/renderer/manager/pages/ModelServicesPage.js +2 -1
- package/dist/src/renderer/manager/pages/ModelServicesPage.js.map +1 -1
- package/dist/src/renderer/manager/pages/model-catalog/SharedModelServices.d.ts +6 -0
- package/dist/src/renderer/manager/pages/model-catalog/SharedModelServices.d.ts.map +1 -0
- package/dist/src/renderer/manager/pages/model-catalog/SharedModelServices.js +191 -0
- package/dist/src/renderer/manager/pages/model-catalog/SharedModelServices.js.map +1 -0
- package/dist/src/renderer/manager/pages/model-services.css +87 -0
- package/dist/src/renderer/model-catalog-client.d.ts +5 -0
- package/dist/src/renderer/model-catalog-client.d.ts.map +1 -1
- package/dist/src/renderer/model-catalog-client.js +24 -0
- package/dist/src/renderer/model-catalog-client.js.map +1 -1
- package/dist/src/renderer/model-provider-selector.d.ts +1 -0
- package/dist/src/renderer/model-provider-selector.d.ts.map +1 -1
- package/dist/src/renderer/model-provider-selector.js +5 -3
- package/dist/src/renderer/model-provider-selector.js.map +1 -1
- package/dist/src/renderer/model-providers.d.ts.map +1 -1
- package/dist/src/renderer/model-providers.js +2 -0
- package/dist/src/renderer/model-providers.js.map +1 -1
- package/dist/src/renderer/native-model-provider-state.d.ts +10 -1
- package/dist/src/renderer/native-model-provider-state.d.ts.map +1 -1
- package/dist/src/renderer/native-model-provider-state.js +26 -2
- package/dist/src/renderer/native-model-provider-state.js.map +1 -1
- package/dist/src/renderer/native-model-provider-transport.d.ts +0 -2
- package/dist/src/renderer/native-model-provider-transport.d.ts.map +1 -1
- package/dist/src/renderer/native-model-provider-transport.js +16 -21
- package/dist/src/renderer/native-model-provider-transport.js.map +1 -1
- package/dist/src/renderer/native-provider-selection-client.d.ts +4 -0
- package/dist/src/renderer/native-provider-selection-client.d.ts.map +1 -1
- package/dist/src/renderer/native-provider-selection-client.js +82 -9
- package/dist/src/renderer/native-provider-selection-client.js.map +1 -1
- package/dist/src/renderer/ui-copy/model-catalog.d.ts +88 -0
- package/dist/src/renderer/ui-copy/model-catalog.d.ts.map +1 -1
- package/dist/src/renderer/ui-copy/model-catalog.js +40 -0
- package/dist/src/renderer/ui-copy/model-catalog.js.map +1 -1
- package/dist/src/renderer/ui-copy.d.ts +89 -1
- package/dist/src/renderer/ui-copy.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,397 @@
|
|
|
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 MODEL_PROVIDER_TOOL = {
|
|
46
|
+
name: 'list_model_providers',
|
|
47
|
+
description:
|
|
48
|
+
'List the CordisX model services declared for Claude in this CordisX home (`<CORDISX_HOME>/config.json`) merged with the services this Claude profile already holds, with their exact model ids. Read-only: never returns endpoints or credentials, and changes no default. The same shape the Codex app returns. `start_session` with `app: "claude"` takes a `providerId` and `model` from here; one it does not list is refused.',
|
|
49
|
+
inputSchema: { type: 'object', additionalProperties: false, properties: {} },
|
|
50
|
+
} as const
|
|
51
|
+
|
|
52
|
+
/** One set of tool names for every app CordisX connects; `app` names the target. */
|
|
53
|
+
const SESSION_TOOLS = [
|
|
54
|
+
{
|
|
55
|
+
name: 'list_sessions',
|
|
56
|
+
description:
|
|
57
|
+
'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.',
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
properties: {
|
|
62
|
+
app: APP,
|
|
63
|
+
limit: { type: 'integer', minimum: 1, maximum: 50 },
|
|
64
|
+
searchTerm: { type: 'string', maxLength: 256 },
|
|
65
|
+
launch: LAUNCH,
|
|
66
|
+
},
|
|
67
|
+
required: ['app'],
|
|
68
|
+
},
|
|
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. `limit` caps the number of returned message entries (the newest ones); the transcript is also capped at about 60k characters.',
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
additionalProperties: false,
|
|
77
|
+
properties: {
|
|
78
|
+
app: APP,
|
|
79
|
+
sessionId: { type: 'string', minLength: 1, maxLength: 512 },
|
|
80
|
+
limit: { type: 'integer', minimum: 1, maximum: 200 },
|
|
81
|
+
launch: LAUNCH,
|
|
82
|
+
},
|
|
83
|
+
required: ['app', 'sessionId'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'start_session',
|
|
88
|
+
description:
|
|
89
|
+
'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. `title` names the conversation where the app supports it. `providerId` and `model` pick one of the model services `list_model_providers` returns for that app; a value it does not list is refused. For Claude the turn runs in the background, and the result says whether it failed within a short wait; a turn still running is reported as started. Only when the user explicitly asks.',
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
additionalProperties: false,
|
|
93
|
+
properties: {
|
|
94
|
+
app: APP,
|
|
95
|
+
prompt: { type: 'string', minLength: 1, maxLength: 100000 },
|
|
96
|
+
title: { type: 'string', minLength: 1, maxLength: 120 },
|
|
97
|
+
cwd: { type: 'string', minLength: 1, maxLength: 4096 },
|
|
98
|
+
providerId: { type: 'string', minLength: 1, maxLength: 128 },
|
|
99
|
+
model: { type: 'string', minLength: 1, maxLength: 512 },
|
|
100
|
+
launch: LAUNCH,
|
|
101
|
+
},
|
|
102
|
+
required: ['app', 'prompt'],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'send_message',
|
|
107
|
+
description:
|
|
108
|
+
'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.',
|
|
109
|
+
inputSchema: {
|
|
110
|
+
type: 'object',
|
|
111
|
+
additionalProperties: false,
|
|
112
|
+
properties: {
|
|
113
|
+
app: APP,
|
|
114
|
+
sessionId: { type: 'string', minLength: 1, maxLength: 512 },
|
|
115
|
+
prompt: { type: 'string', minLength: 1, maxLength: 100000 },
|
|
116
|
+
launch: LAUNCH,
|
|
117
|
+
},
|
|
118
|
+
required: ['app', 'sessionId', 'prompt'],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
] as const
|
|
122
|
+
|
|
123
|
+
let polling = false
|
|
124
|
+
|
|
125
|
+
async function readBinding($: EngineInterface): Promise<Binding | undefined> {
|
|
126
|
+
const home = await cordisxHome($)
|
|
127
|
+
try {
|
|
128
|
+
const value = JSON.parse(await $.fs.read(`${home}/run/agent-bridge.json`)) as Partial<Binding>
|
|
129
|
+
return typeof value.socketPath === 'string' && typeof value.token === 'string'
|
|
130
|
+
? { socketPath: value.socketPath, token: value.token }
|
|
131
|
+
: undefined
|
|
132
|
+
} catch {
|
|
133
|
+
return undefined
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function post($: EngineInterface, route: string, body: unknown): Promise<BridgeReply> {
|
|
138
|
+
const binding = await readBinding($)
|
|
139
|
+
if (binding === undefined) {
|
|
140
|
+
return { ok: false, unreachable: true, error: 'CordisX is not running Codex (no agent bridge found)' }
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
const response = await $.http.fetch(`http://cordisx${route}`, {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
socketPath: binding.socketPath,
|
|
146
|
+
headers: { 'content-type': 'application/json', 'x-cordisx-bridge-token': binding.token },
|
|
147
|
+
body: JSON.stringify(body),
|
|
148
|
+
})
|
|
149
|
+
return JSON.parse(response.text) as BridgeReply
|
|
150
|
+
} catch {
|
|
151
|
+
return { ok: false, unreachable: true, error: 'The CordisX agent bridge is not reachable' }
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function textOf(value: unknown): string {
|
|
156
|
+
const text = (value as { text?: unknown } | undefined)?.text
|
|
157
|
+
return typeof text === 'string' ? text : JSON.stringify(value)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function limitOf(args: Record<string, unknown>, fallback: number): number {
|
|
161
|
+
return typeof args.limit === 'number' ? args.limit : fallback
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The model services a Claude start may name, in the shape the Codex tool
|
|
166
|
+
* returns: provider id, title, exact model ids and labels. The CordisX side
|
|
167
|
+
* merges the home config's declarations with this profile's own library, so
|
|
168
|
+
* the two apps answer the same list; without a bridge, the declarations alone
|
|
169
|
+
* are read from `<CORDISX_HOME>/config.json`.
|
|
170
|
+
*/
|
|
171
|
+
async function modelProviders($: EngineInterface): Promise<unknown> {
|
|
172
|
+
const bridged = await post($, '/sessions', { app: 'claude', operation: 'list_model_providers', args: {} })
|
|
173
|
+
if (bridged.ok) return bridged.value
|
|
174
|
+
const home = await cordisxHome($)
|
|
175
|
+
let providers: Record<string, unknown>[] = []
|
|
176
|
+
try {
|
|
177
|
+
const config = JSON.parse(await $.fs.read(`${home}/config.json`)) as { providers?: unknown }
|
|
178
|
+
const declared = Array.isArray(config.providers) ? config.providers : []
|
|
179
|
+
providers = declared.flatMap(entry => {
|
|
180
|
+
const provider = entry as Record<string, unknown>
|
|
181
|
+
if (provider?.kind !== 'model-service' || provider.enabled === false) return []
|
|
182
|
+
const protocols = Array.isArray(provider.protocols) ? provider.protocols : []
|
|
183
|
+
const appliesTo = Array.isArray(provider.appliesTo) ? provider.appliesTo : undefined
|
|
184
|
+
if (!protocols.includes('anthropic-messages')) return []
|
|
185
|
+
if (appliesTo !== undefined && !appliesTo.includes('claude')) return []
|
|
186
|
+
const models = (provider.models as Record<string, unknown> | undefined)?.claude
|
|
187
|
+
return [{
|
|
188
|
+
providerId: String(provider.id ?? ''),
|
|
189
|
+
title: String(provider.displayName ?? provider.id ?? ''),
|
|
190
|
+
models: (Array.isArray(models) ? models : []).map(id => ({ id: String(id), label: String(id) })),
|
|
191
|
+
}]
|
|
192
|
+
})
|
|
193
|
+
} catch { /* no config yet: nothing is declared */ }
|
|
194
|
+
return { providers }
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Runs one Codex -> Claude request with Claude Desktop's own session tools. */
|
|
198
|
+
async function answer($: EngineInterface, operation: string, args: Record<string, unknown>): Promise<unknown> {
|
|
199
|
+
if (operation === 'list_sessions') {
|
|
200
|
+
const current = await $.tool.call({ tool: 'mcp__ccd_session_mgmt__get_session', session_id: 'self' })
|
|
201
|
+
const others = await $.tool.call({ tool: 'mcp__ccd_session_mgmt__list_sessions', limit: limitOf(args, 20) })
|
|
202
|
+
return { current: textOf(current), others: textOf(others) }
|
|
203
|
+
}
|
|
204
|
+
if (operation === 'read_session') {
|
|
205
|
+
const sessionId = String(args.sessionId ?? '')
|
|
206
|
+
const details = await $.tool.call({ tool: 'mcp__ccd_session_mgmt__get_session', session_id: sessionId })
|
|
207
|
+
// list_events reads other sessions only; this session's own transcript is read directly.
|
|
208
|
+
const own = textOf(await $.tool.call({ tool: 'mcp__ccd_session_mgmt__get_session', session_id: 'self' }))
|
|
209
|
+
const transcript = own.includes(sessionId)
|
|
210
|
+
? JSON.stringify((await $.session.messages()).slice(-limitOf(args, 40)))
|
|
211
|
+
: textOf(
|
|
212
|
+
await $.tool.call({
|
|
213
|
+
tool: 'mcp__ccd_session_mgmt__list_events',
|
|
214
|
+
session_id: sessionId,
|
|
215
|
+
limit: limitOf(args, 40),
|
|
216
|
+
}),
|
|
217
|
+
)
|
|
218
|
+
return { session: textOf(details), transcript }
|
|
219
|
+
}
|
|
220
|
+
if (operation === 'start_session') {
|
|
221
|
+
const started = await $.tool.call({
|
|
222
|
+
tool: 'mcp__ccd_session__start_session',
|
|
223
|
+
initiation: 'user_asked',
|
|
224
|
+
context: 'fresh',
|
|
225
|
+
title: String(args.title ?? 'Task from Codex'),
|
|
226
|
+
prompt: String(args.prompt ?? ''),
|
|
227
|
+
background:
|
|
228
|
+
"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.",
|
|
229
|
+
...(typeof args.cwd === 'string' ? { cwd: args.cwd } : {}),
|
|
230
|
+
})
|
|
231
|
+
const sessionId = SESSION_ID.exec(textOf(started))?.[0]
|
|
232
|
+
if (sessionId === undefined) return { status: 'unknown', result: textOf(started) }
|
|
233
|
+
// A session this one starts nests under it; the user should see it as their own.
|
|
234
|
+
try {
|
|
235
|
+
await $.tool.call({ tool: 'mcp__ccd_session_mgmt__detach_session', session_id: sessionId })
|
|
236
|
+
} catch { /* stays nested; still usable */ }
|
|
237
|
+
const details = await $.tool.call({ tool: 'mcp__ccd_session_mgmt__get_session', session_id: sessionId })
|
|
238
|
+
const link = CLAUDE_LINK.exec(textOf(details))?.[0]
|
|
239
|
+
return { status: 'started', sessionId, ...(link === undefined ? {} : { link }) }
|
|
240
|
+
}
|
|
241
|
+
if (operation === 'send_message') {
|
|
242
|
+
const prompt = String(args.prompt ?? args.message ?? '')
|
|
243
|
+
// Claude refuses a session's message to itself; a prompt this session submits is its next turn.
|
|
244
|
+
if (args.cliSessionId === await $.session.id()) {
|
|
245
|
+
await $.prompt.submit({ text: prompt })
|
|
246
|
+
return { status: 'sent', sessionId: args.sessionId }
|
|
247
|
+
}
|
|
248
|
+
const sent = await $.tool.call({
|
|
249
|
+
tool: 'mcp__ccd_session_mgmt__send_message',
|
|
250
|
+
session_id: String(args.sessionId ?? ''),
|
|
251
|
+
message: prompt,
|
|
252
|
+
})
|
|
253
|
+
return { status: 'sent', result: textOf(sent) }
|
|
254
|
+
}
|
|
255
|
+
throw new Error(`unknown Claude bridge operation: ${operation}`)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
async function poll($: EngineInterface): Promise<void> {
|
|
259
|
+
if (polling) return
|
|
260
|
+
polling = true
|
|
261
|
+
try {
|
|
262
|
+
// Claude's session tools connect after the session starts; until they do,
|
|
263
|
+
// this session cannot answer a Codex request and must not claim one.
|
|
264
|
+
if (!await hostsClaudeSessions($)) return
|
|
265
|
+
const next = await post($, '/claude/poll', { sessionId: await $.session.id() })
|
|
266
|
+
const request = (next.ok ? next.value : undefined) as
|
|
267
|
+
| { id?: string; operation?: string; args?: Record<string, unknown> }
|
|
268
|
+
| undefined
|
|
269
|
+
if (request?.id === undefined || request.operation === undefined) return
|
|
270
|
+
try {
|
|
271
|
+
const value = await answer($, request.operation, request.args ?? {})
|
|
272
|
+
await post($, '/claude/result', { id: request.id, ok: true, value })
|
|
273
|
+
} catch (error) {
|
|
274
|
+
await post($, '/claude/result', {
|
|
275
|
+
id: request.id,
|
|
276
|
+
ok: false,
|
|
277
|
+
error: error instanceof Error ? error.message : String(error),
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
} finally {
|
|
281
|
+
polling = false
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function hostsClaudeSessions($: EngineInterface): Promise<boolean> {
|
|
286
|
+
const tools = await $.tool.list()
|
|
287
|
+
return ['mcp__ccd_session__start_session', 'mcp__ccd_session_mgmt__list_sessions'].every(name =>
|
|
288
|
+
tools.some(tool => tool.name === name)
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Runs one session tool: Codex through the agent bridge, Claude with this app's own session tools. */
|
|
293
|
+
async function runSessionTool($: EngineInterface, operation: string, input: Record<string, unknown>): Promise<string> {
|
|
294
|
+
const { app, ...args } = input
|
|
295
|
+
if (app === 'claude') {
|
|
296
|
+
// The bridge drives Claude from outside the app, so a new session needs no
|
|
297
|
+
// "start the session?" prompt; without a bridge, Claude's own tools answer.
|
|
298
|
+
const { launch: _launch, ...request } = args
|
|
299
|
+
const bridged = await post($, '/sessions', { app, operation, args: request })
|
|
300
|
+
if (bridged.ok) return JSON.stringify(bridged.value, null, 2)
|
|
301
|
+
try {
|
|
302
|
+
return JSON.stringify(await answer($, operation, args), null, 2)
|
|
303
|
+
} catch (error) {
|
|
304
|
+
return `Claude could not do it: ${error instanceof Error ? error.message : String(error)}`
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (app !== 'codex') return `app must be one of ${APPS.join(', ')}`
|
|
308
|
+
const { launch, ...request } = args
|
|
309
|
+
let answered = await post($, '/sessions', { app, operation, args: request })
|
|
310
|
+
if (!answered.ok && answered.unreachable === true) {
|
|
311
|
+
const started = await startCodex($, launch)
|
|
312
|
+
if (started !== true) return JSON.stringify(started, null, 2)
|
|
313
|
+
answered = await post($, '/sessions', { app, operation, args: request })
|
|
314
|
+
}
|
|
315
|
+
return answered.ok
|
|
316
|
+
? JSON.stringify(answered.value, null, 2)
|
|
317
|
+
: `Codex is unavailable: ${answered.error ?? 'unknown error'}`
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
async function cordisxHome($: EngineInterface): Promise<string> {
|
|
321
|
+
return await $.env.get('CORDISX_HOME') ?? `${await $.env.get('HOME') ?? ''}/.cordisx`
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Starts the CordisX Codex launch this home last ran, when the person allowed
|
|
326
|
+
* it: this call (`launch: "once" | "always"`, the latter remembered) or an
|
|
327
|
+
* earlier "always". Otherwise the same question the Codex side asks about
|
|
328
|
+
* Claude, at once.
|
|
329
|
+
*/
|
|
330
|
+
async function startCodex($: EngineInterface, launch: unknown): Promise<true | Record<string, string>> {
|
|
331
|
+
const home = await cordisxHome($)
|
|
332
|
+
const preference = `${home}/apps/codex/bridge-launch.json`
|
|
333
|
+
if (launch === 'always' || launch === 'ask') {
|
|
334
|
+
await $.fs.write(preference, `${JSON.stringify({ launch })}\n`)
|
|
335
|
+
}
|
|
336
|
+
let remembered = false
|
|
337
|
+
try {
|
|
338
|
+
remembered = (JSON.parse(await $.fs.read(preference)) as { launch?: unknown }).launch === 'always'
|
|
339
|
+
} catch { /* never answered */ }
|
|
340
|
+
const allowed = launch === 'once' || launch === 'always' || (launch !== 'ask' && remembered)
|
|
341
|
+
if (!allowed) {
|
|
342
|
+
return {
|
|
343
|
+
status: 'needs-confirmation',
|
|
344
|
+
reason: 'codex-not-running',
|
|
345
|
+
question: 'Codex Desktop is not running. Start it?',
|
|
346
|
+
howToContinue:
|
|
347
|
+
'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.',
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
let cli: string[] = []
|
|
351
|
+
try {
|
|
352
|
+
cli = JSON.parse(await $.env.get('CORDISX_CLI') ?? '[]') as string[]
|
|
353
|
+
} catch { /* not launched by CordisX */ }
|
|
354
|
+
let target = { homeDir: home, profileId: 'default' }
|
|
355
|
+
try {
|
|
356
|
+
target = { ...target, ...JSON.parse(await $.fs.read(`${home}/run/codex-launch.json`)) as typeof target }
|
|
357
|
+
} catch { /* Codex never ran with the bridge; its default profile */ }
|
|
358
|
+
const argv = cli.length > 0
|
|
359
|
+
? [...cli, 'start', 'codex', target.profileId]
|
|
360
|
+
: ['cordisx', 'start', 'codex', target.profileId]
|
|
361
|
+
const started = await $.process.run(argv, { env: { CORDISX_HOME: target.homeDir }, timeoutMs: CODEX_START_MS })
|
|
362
|
+
if (started.exitCode !== 0) {
|
|
363
|
+
return { status: 'failed', reason: 'codex-start-failed', detail: started.stderr.slice(-2000) }
|
|
364
|
+
}
|
|
365
|
+
for (const deadline = Date.now() + CODEX_START_MS; Date.now() < deadline;) {
|
|
366
|
+
if ((await post($, '/sessions', { app: 'codex', operation: 'list_sessions', args: { limit: 1 } })).ok) return true
|
|
367
|
+
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
368
|
+
}
|
|
369
|
+
return { status: 'failed', reason: 'codex-bridge-not-ready' }
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export const register: Register = on => {
|
|
373
|
+
on('session.start', async ($, e, next) => {
|
|
374
|
+
for (const tool of [...SESSION_TOOLS, MODEL_PROVIDER_TOOL]) {
|
|
375
|
+
await $.tool.register({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema })
|
|
376
|
+
}
|
|
377
|
+
$.clock.every(POLL_MS, () => void poll($))
|
|
378
|
+
return next(e)
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
on('tool.call', { tool: `mcp__cordisx__${MODEL_PROVIDER_TOOL.name}` }, async $ => {
|
|
382
|
+
try {
|
|
383
|
+
return { result: JSON.stringify(await modelProviders($), null, 2) }
|
|
384
|
+
} catch (error) {
|
|
385
|
+
return {
|
|
386
|
+
result: `The model services could not be read: ${error instanceof Error ? error.message : String(error)}`,
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
for (const tool of SESSION_TOOLS) {
|
|
392
|
+
on('tool.call', { tool: `mcp__cordisx__${tool.name}` }, async ($, e) => {
|
|
393
|
+
const { tool: _tool, tool_use_id: _id, ...args } = e as Record<string, unknown>
|
|
394
|
+
return { result: await runSessionTool($, tool.name, args) }
|
|
395
|
+
})
|
|
396
|
+
}
|
|
397
|
+
}
|
|
@@ -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. `limit` caps the number of returned message entries (the newest ones); the transcript is also capped at about 60k characters.',
|
|
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. `title` names the conversation where the app supports it. `providerId` and `model` pick one of the model services `list_model_providers` returns for that app; a value it does not list is refused. In Claude the session runs in the background in bypass permissions mode on the CordisX model service and shows in Claude when its first turn ends; the result says whether that turn failed within a short wait, and 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')),
|
|
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
|
|
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 })
|
|
@@ -314,6 +320,28 @@ async function forward(line) {
|
|
|
314
320
|
return
|
|
315
321
|
}
|
|
316
322
|
const params = object(message?.params)
|
|
323
|
+
const clientMetadata = object(params?.responsesapiClientMetadata)
|
|
324
|
+
if (clientMetadata && Object.hasOwn(clientMetadata, marker)) {
|
|
325
|
+
const carried = clientMetadata[marker]
|
|
326
|
+
const originalConfig = object(params.config)
|
|
327
|
+
if (
|
|
328
|
+
!['thread/start', 'turn/start'].includes(message.method) || !validToken(carried)
|
|
329
|
+
|| (originalConfig && Object.hasOwn(originalConfig, marker) && originalConfig[marker] !== carried)
|
|
330
|
+
) {
|
|
331
|
+
await write(process.stdout, {
|
|
332
|
+
id: message.id,
|
|
333
|
+
error: { code: -32000, message: 'Invalid managed Send association' },
|
|
334
|
+
})
|
|
335
|
+
return
|
|
336
|
+
}
|
|
337
|
+
// The main-process first-turn builder retains metadata but drops config.
|
|
338
|
+
// This is the original Send token, not authority inferred from a thread ID.
|
|
339
|
+
params.config = { ...originalConfig, [marker]: carried }
|
|
340
|
+
const nextMetadata = { ...clientMetadata }
|
|
341
|
+
delete nextMetadata[marker]
|
|
342
|
+
if (Object.keys(nextMetadata).length === 0) delete params.responsesapiClientMetadata
|
|
343
|
+
else params.responsesapiClientMetadata = nextMetadata
|
|
344
|
+
}
|
|
317
345
|
if (
|
|
318
346
|
message?.method === 'turn/start' && agentFirstTurns.has(params?.threadId)
|
|
319
347
|
&& params.config?.[marker] !== agentFirstTurns.get(params.threadId)
|
|
@@ -371,6 +399,23 @@ async function forward(line) {
|
|
|
371
399
|
} else lifecycleCalls.set(message.id, params.threadId)
|
|
372
400
|
if (message.method === 'thread/unsubscribe') unmarkedTurns.retireThread(params.threadId)
|
|
373
401
|
}
|
|
402
|
+
if (['thread/start', 'thread/resume'].includes(message?.method) && params) {
|
|
403
|
+
try {
|
|
404
|
+
let providerId = params.modelProvider
|
|
405
|
+
if (message.method === 'thread/resume' && providerId === undefined && typeof params.threadId === 'string') {
|
|
406
|
+
const persisted = await nativeCall('thread/read', { threadId: params.threadId, includeTurns: false })
|
|
407
|
+
providerId = persisted?.thread?.modelProvider
|
|
408
|
+
}
|
|
409
|
+
const overrides = await controlCall('configured-provider', {
|
|
410
|
+
...(typeof providerId === 'string' ? { providerId } : {}),
|
|
411
|
+
})
|
|
412
|
+
if (object(overrides) && Object.keys(overrides).length) {
|
|
413
|
+
params.config = { ...object(params.config), ...overrides }
|
|
414
|
+
await write(child.stdin, message)
|
|
415
|
+
return
|
|
416
|
+
}
|
|
417
|
+
} catch {}
|
|
418
|
+
}
|
|
374
419
|
await write(child.stdin, line)
|
|
375
420
|
return
|
|
376
421
|
}
|
|
@@ -651,6 +696,15 @@ readLines(child.stdout, line => {
|
|
|
651
696
|
})
|
|
652
697
|
|
|
653
698
|
const switching = new Set()
|
|
699
|
+
const BRIDGE_NATIVE_METHODS = new Set([
|
|
700
|
+
'thread/list',
|
|
701
|
+
'thread/read',
|
|
702
|
+
'thread/start',
|
|
703
|
+
'thread/resume',
|
|
704
|
+
'thread/name/set',
|
|
705
|
+
'turn/start',
|
|
706
|
+
'turn/interrupt',
|
|
707
|
+
])
|
|
654
708
|
readLines(control, line => {
|
|
655
709
|
let message
|
|
656
710
|
try {
|
|
@@ -675,6 +729,19 @@ readLines(control, line => {
|
|
|
675
729
|
.catch(() => write(control, { id: message.id, ok: false }).catch(stop))
|
|
676
730
|
return
|
|
677
731
|
}
|
|
732
|
+
// The CordisX agent bridge reads and starts threads in this same app-server, so
|
|
733
|
+
// the desktop sees them. Only these methods cross; the Host validates params.
|
|
734
|
+
if (message.type === 'native-request' && typeof message.id === 'string') {
|
|
735
|
+
const params = object(message.params)
|
|
736
|
+
if (!BRIDGE_NATIVE_METHODS.has(message.method) || params === undefined) {
|
|
737
|
+
void write(control, { id: message.id, ok: false }).catch(stop)
|
|
738
|
+
return
|
|
739
|
+
}
|
|
740
|
+
void nativeCall(message.method, params)
|
|
741
|
+
.then(value => write(control, { id: message.id, ok: true, value }))
|
|
742
|
+
.catch(() => write(control, { id: message.id, ok: false }).catch(stop))
|
|
743
|
+
return
|
|
744
|
+
}
|
|
678
745
|
if (message.type === 'idle' && typeof message.id === 'string' && typeof message.threadId === 'string') {
|
|
679
746
|
void nativeCall('thread/read', { threadId: message.threadId, includeTurns: false }).then(result => {
|
|
680
747
|
const status = result?.thread?.status?.type
|
|
@@ -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"}
|