Skip to content

Commit daee24b

Browse files
authored
Route Codex dashboard connect pings
Send Clone Loop dashboard connect pings to the runtime-specific agent card so Codex does not appear as Claude Code.
1 parent 1c2aed2 commit daee24b

3 files changed

Lines changed: 46 additions & 2 deletions

File tree

scripts/manage-api-key.mjs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,30 @@ const args = process.argv.slice(2)
1515
const positionalArgs = args.filter((arg) => arg !== '--connect')
1616
const connectAfterStore = args.includes('--connect')
1717
const command = positionalArgs[0] || 'status'
18-
const CLONE_LOOP_SOURCE_DETAIL = 'clone-loop:claude-code'
1918
let handled = false
2019

20+
function cloneLoopAgentId() {
21+
const explicit = String(process.env.CLONE_LOOP_AGENT_ID || '').trim()
22+
if (explicit) return explicit
23+
24+
if (process.env.CLAUDE_PLUGIN_DATA || process.env.CLAUDE_PLUGIN_ROOT) {
25+
return 'claude-code'
26+
}
27+
28+
const hasCodexPluginData = Boolean(process.env.PLUGIN_DATA) && !process.env.CLAUDE_PLUGIN_DATA
29+
const hasCodexPluginRoot = Boolean(process.env.PLUGIN_ROOT) && !process.env.CLAUDE_PLUGIN_ROOT
30+
const hasCodexRuntime =
31+
Boolean(process.env.CODEX_HOME) ||
32+
Boolean(process.env.CODEX_SESSION_ID) ||
33+
Boolean(process.env.CODEX_THREAD_ID)
34+
35+
return hasCodexPluginData || hasCodexPluginRoot || hasCodexRuntime ? 'codex' : 'claude-code'
36+
}
37+
38+
function cloneLoopSourceDetail() {
39+
return `clone-loop:${cloneLoopAgentId()}`
40+
}
41+
2142
function usage() {
2243
console.log(`Clone API key manager
2344
@@ -79,7 +100,7 @@ async function startDashboardSession(token) {
79100
name: 'start_session',
80101
arguments: {
81102
source: 'agent',
82-
source_detail: CLONE_LOOP_SOURCE_DETAIL,
103+
source_detail: cloneLoopSourceDetail(),
83104
},
84105
},
85106
init.sessionId,

skills/clone-api-key/SKILL.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ Supported subcommands:
1717

1818
- `status`
1919
- `import-env`
20+
- `import-env --connect`
2021
- `set <key>`
22+
- `set <key> --connect`
23+
- `connect`
2124
- `clear`
2225

2326
Never print the full token. Report only the masked token and active source: `environment`, `plugin config`, or `demo fallback`.

tests/api-key-manager.test.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,26 @@ describe('Clone API key manager', () => {
238238
})
239239
})
240240

241+
it('pings the Codex plugin card when Codex plugin data is injected', async () => {
242+
await withMcpServer(async (mcpUrl, calls) => {
243+
await withPluginDataAsync(async (pluginDataDir) => {
244+
const token = 'clone_codex_connect_token_1234567890'
245+
const result = await runManagerAsync(['set', token, '--connect'], {
246+
env: {
247+
CLONE_LOOP_AGENT_ID: 'codex',
248+
PLUGIN_DATA: pluginDataDir,
249+
CLONE_MCP_URL: mcpUrl,
250+
},
251+
})
252+
253+
assert.equal(result.status, 0, JSON.stringify({ stdout: result.stdout, stderr: result.stderr }, null, 2))
254+
assert.equal(calls[1].params.arguments.source_detail, 'clone-loop:codex')
255+
assert.match(result.stdout, /Clone session: clone-session-123/)
256+
assert.doesNotMatch(result.stdout, new RegExp(token))
257+
})
258+
})
259+
})
260+
241261
it('clears a plugin config token', () => {
242262
withPluginData((pluginDataDir) => {
243263
writeFileSync(

0 commit comments

Comments
 (0)