Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- Add `--agent-model` and `DX_AGENT_MODEL` support. When set, the CLI sends the model name as the `X-DX-Agent-Model` header alongside existing agent provenance headers.

### Fixed

- `dx -v` now prints the CLI version, matching the documented lowercase version flag. Version checks are also skipped for help/version output and global-option-only invocations, preventing update prompts from interfering with those commands.
Expand Down
6 changes: 6 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ function createProgram(): Command {
.addOption(
new Option("--agent <name>", "Agent name to send as an HTTP header"),
)
.addOption(
new Option(
"--agent-model <model>",
"Agent model name to send as an HTTP header",
),
)
.addOption(
new Option(
"--agent-session-id <id>",
Expand Down
1 change: 1 addition & 0 deletions src/commandHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function getContext(command: Command): CliContext {
return {
json: Boolean(root.json),
agent: root.agent || process.env.DX_AGENT_NAME,
agentModel: root.agentModel || process.env.DX_AGENT_MODEL,
agentSessionId: root.agentSessionId || process.env.DX_AGENT_SESSION_ID,
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/commands/catalog/entities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@ describe("catalog entities commands", () => {
it("sends agent provenance from environment variables", async () => {
process.env.DX_API_BASE_URL = "https://api.example.com";
process.env.DX_AGENT_NAME = "codex";
process.env.DX_AGENT_MODEL = "gpt-5";
process.env.DX_AGENT_SESSION_ID = "session-123";
getToken.mockReturnValue("token-123");

Expand Down Expand Up @@ -1099,6 +1100,7 @@ describe("catalog entities commands", () => {
const headers = (vi.mocked(fetch).mock.calls[0]?.[1] as RequestInit)
.headers as Headers;
expect(headers.get("X-DX-Agent-Name")).toBe("codex");
expect(headers.get("X-DX-Agent-Model")).toBe("gpt-5");
expect(headers.get("X-DX-Agent-Session-Id")).toBe("session-123");
});

Expand Down
4 changes: 4 additions & 0 deletions src/commands/studio/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ function buildHeaders(runtime: Runtime, accept: string): Headers {
headers.set("X-DX-Agent-Name", runtime.context.agent);
}

if (runtime.context.agentModel) {
headers.set("X-DX-Agent-Model", runtime.context.agentModel);
}

if (runtime.context.agentSessionId) {
headers.set("X-DX-Agent-Session-Id", runtime.context.agentSessionId);
}
Expand Down
4 changes: 4 additions & 0 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export async function request<T extends Record<string, unknown>>(
headers.set("X-DX-Agent-Name", runtime.context.agent);
}

if (runtime.context.agentModel) {
headers.set("X-DX-Agent-Model", runtime.context.agentModel);
}

if (runtime.context.agentSessionId) {
headers.set("X-DX-Agent-Session-Id", runtime.context.agentSessionId);
}
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface Runtime {
export interface CliContext {
json: boolean;
agent?: string;
agentModel?: string;
agentSessionId?: string;
}

Expand Down
1 change: 1 addition & 0 deletions src/versionCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export async function checkForNewVersion(
const context = {
json: argv.includes("--json"),
agent: undefined,
agentModel: undefined,
agentSessionId: undefined,
};
const runtime = await buildRuntimeSafe(context);
Expand Down
Loading