Skip to content

Commit a6c22eb

Browse files
luoxuanzaoQoder-AI
andauthored
feat(spawn): identify the host integration to the spawned CLI (#75)
The spawn adapter now injects QODER_INTEGRATION_ID into every CLI it starts, so the CLI can report its integration_id telemetry attribute; the adapter is the single point all SDK-spawned CLI processes go through. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
1 parent 827babc commit a6c22eb

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎src/qoder/runtime/custom-spawn.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ import {
1515
*/
1616
const CUSTOM_PROVIDER_CLI_ENV = { QODER_SDK_CUSTOM_BASE_URL_BYOK: '1' } as const;
1717

18+
/**
19+
* Identifies this host integration to the CLI, which reports it as the
20+
* `integration_id` telemetry attribute. Only a UUIDv4 is accepted; any other
21+
* value is silently dropped.
22+
*/
23+
const INTEGRATION_CLI_ENV = {
24+
QODER_INTEGRATION_ID: '70457212-a449-4ae3-af1e-5fb9e00fafcf',
25+
} as const;
26+
1827
/**
1928
* Spawn qodercli in Obsidian's Electron process.
2029
*
@@ -43,7 +52,7 @@ export function createCustomSpawnFunction(
4352
const resolvedSpawnSpec = resolveWindowsCmdShimSpawnSpec({ args, command });
4453
const child = spawn(resolvedSpawnSpec.command, resolvedSpawnSpec.args, {
4554
cwd,
46-
env: env ? { ...env, ...CUSTOM_PROVIDER_CLI_ENV } : env,
55+
env: env ? { ...env, ...CUSTOM_PROVIDER_CLI_ENV, ...INTEGRATION_CLI_ENV } : env,
4756
// stderr is always piped so host code (e.g. the runtime probe) can read
4857
// CLI diagnostics such as "No qodercli login found". A drain listener is
4958
// attached below to avoid pipe backpressure when nobody else listens.

‎tests/unit/qoder/runtime/custom-spawn.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ describe('createCustomSpawnFunction', () => {
125125
expect(spawnOptions.env).toEqual({
126126
PATH: '/usr/bin',
127127
QODER_SDK_CUSTOM_BASE_URL_BYOK: '1',
128+
QODER_INTEGRATION_ID: '70457212-a449-4ae3-af1e-5fb9e00fafcf',
128129
});
129130
});
130131

0 commit comments

Comments
 (0)