Skip to content

Commit 150e663

Browse files
committed
feat: alias AgentV1SettingsAgentListenProvider to *AgentContextListenProvider
The 2026-05-06 regen renamed this type to AgentV1SettingsAgentContextListenProvider (the new V2 adds an optional language_hint field). Replace the regenerated duplicate with a one-line alias to the new canonical name plus namespace merge for .V1/.V2, so pinned-name callers (`const p: AgentV1SettingsAgentListenProvider = ...`) keep compiling without a cast. Purely additive at the type level — the old V2 is a subset of the new V2. - src/api/resources/.../AgentV1SettingsAgentListenProvider.ts: alias body - .fernignore + AGENTS.md: track the alias as a temporarily-frozen entry - tests/unit/compat-aliases.test.ts: Equals<X, Y> identity assertions for the alias (top-level + .V1 + .V2), plus compile-time call-site assertions for the pre-existing keys.create(request?) optionality patc
1 parent 4c72d31 commit 150e663

4 files changed

Lines changed: 81 additions & 42 deletions

File tree

.fernignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,13 @@ src/api/types/CreateKeyV1Request.ts
8686
# Regression coverage in tests/unit/compat-aliases.test.ts.
8787
# Swap to .bak before regen.
8888
src/api/resources/agent/resources/v1/types/AgentV1Settings.ts
89+
90+
# src/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.ts:
91+
# the 2026-05-06 regen renamed this type to AgentV1SettingsAgentContextListenProvider
92+
# (the new V2 adds an optional language_hint field). We replace the regenerated
93+
# duplicate with a one-line type alias to the new canonical name so pinned-name
94+
# callers (`const p: AgentV1SettingsAgentListenProvider = ...`) keep compiling
95+
# without a cast. Purely additive at the type level — the old V2 is a subset of
96+
# the new V2. Regression coverage in tests/unit/compat-aliases.test.ts.
97+
# Swap to .bak before regen.
98+
src/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.ts

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Current temporarily frozen files:
6363
- `src/api/resources/manage/resources/v1/resources/projects/resources/keys/client/Client.ts` — keep `manage.v1.projects.keys.create(projectId, request?)` source-compatible with older callers that omit the request body, while still allowing the regenerated request form.
6464
- `src/api/types/CreateKeyV1Request.ts` — preserve the old exported `CreateKeyV1RequestOne` alias alongside `CreateKeyV1Request` so existing type imports keep compiling.
6565
- `src/api/resources/agent/resources/v1/types/AgentV1Settings.ts` — backward-compat patch for the `AgentV1Settings.Agent` namespace. The 2026-05-06 regen restructured `Agent` from an interface with named sub-types into a union with anonymous shapes plus a string variant (`{...} | string`) for the new agent-by-ID-string flow. We restore the original interface form so existing imports of the sub-types (`Agent.Context`, `Agent.Listen`, `Agent.Think`, `Agent.Speak`, `Agent.Context.Messages.Item`) AND direct field reads (`settings.agent.context`, `.greeting`, etc.) keep compiling in TS strict mode without a `typeof` narrowing guard. The new agent-by-ID-string variant is surfaced as the opt-in `AgentReference = Agent | string` alias for callers who want to pass a string ID at the type level. Mirrors the Python SDK's compat shims for the same regen. Regression coverage in `tests/unit/compat-aliases.test.ts`.
66+
- `src/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.ts` — backward-compat alias for the type renamed by the 2026-05-06 regen to `AgentV1SettingsAgentContextListenProvider`. The new V2 only adds an optional `language_hint` field, so the regenerated duplicate is replaced with a one-line `type AgentV1SettingsAgentListenProvider = AgentV1SettingsAgentContextListenProvider` (plus namespace merge for `.V1`/`.V2` access). Purely additive at the type level — pinned-name callers (`const p: AgentV1SettingsAgentListenProvider = ...`) keep compiling without a cast. Regression coverage in `tests/unit/compat-aliases.test.ts`.
6667

6768
**Note:** If you need to patch a Fern-generated file, add it to `.fernignore` with a comment describing the patch, and add it to the "temporarily frozen" list above.
6869

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
1-
// This file was auto-generated by Fern from our API Definition.
1+
// Backward-compat alias for the type renamed by the 2026-05-06 regen to
2+
// `AgentV1SettingsAgentContextListenProvider`. The new V2 only adds an optional
3+
// `language_hint` field, so this alias is purely additive: every literal that
4+
// satisfied the old V2 still satisfies the new V2, and pinned-name callers
5+
// (`const p: AgentV1SettingsAgentListenProvider = ...`) keep compiling without
6+
// a cast. See AGENTS.md for the patch rationale; regression coverage in
7+
// tests/unit/compat-aliases.test.ts.
28

39
import type * as Deepgram from "../../../../../index.js";
410

5-
export type AgentV1SettingsAgentListenProvider =
6-
| Deepgram.agent.AgentV1SettingsAgentListenProvider.V1
7-
| Deepgram.agent.AgentV1SettingsAgentListenProvider.V2;
11+
export type AgentV1SettingsAgentListenProvider = Deepgram.agent.AgentV1SettingsAgentContextListenProvider;
812

913
export namespace AgentV1SettingsAgentListenProvider {
10-
export interface V1 {
11-
version: "v1";
12-
/** Provider type for speech-to-text */
13-
type: "deepgram";
14-
/** Model to use for speech to text using the V1 API (e.g. Nova-3, Nova-2) */
15-
model?: string | undefined;
16-
/** Language code to use for speech-to-text. Can be a BCP-47 language tag (e.g. `en`), or `multi` for code-switching transcription */
17-
language?: string | undefined;
18-
/** Prompt keyterm recognition to improve Keyword Recall Rate */
19-
keyterms?: string[] | undefined;
20-
/** Applies smart formatting to improve transcript readability */
21-
smart_format?: boolean | undefined;
22-
}
23-
24-
export interface V2 {
25-
version: "v2";
26-
/** Provider type for speech-to-text */
27-
type: "deepgram";
28-
/** Model to use for speech to text using the V2 API (e.g. flux-general-en) */
29-
model: string;
30-
/** Prompt keyterm recognition to improve Keyword Recall Rate */
31-
keyterms?: string[] | undefined;
32-
}
14+
export type V1 = Deepgram.agent.AgentV1SettingsAgentContextListenProvider.V1;
15+
export type V2 = Deepgram.agent.AgentV1SettingsAgentContextListenProvider.V2;
3316
}

tests/unit/compat-aliases.test.ts

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ import type {
55
AgentV1SettingsAgentListenProvider,
66
CreateKeyV1Request,
77
CreateKeyV1RequestOne,
8+
DeepgramClient,
89
} from "../../src";
910
import { Deepgram } from "../../src";
1011

12+
// Type-only handle for compile-time call-site assertions. Never assigned at
13+
// runtime — the `declare` binding lets us write expressions like
14+
// `client.manage.v1.projects.keys.create("project_id")` purely for type
15+
// checking. Any closure that references it must not be invoked.
16+
declare const client: DeepgramClient;
17+
1118
/**
1219
* Regression test for backward-compatibility aliases preserved across SDK
1320
* regenerations.
@@ -130,31 +137,69 @@ describe("Backwards-compatibility aliases", () => {
130137
});
131138
});
132139

133-
describe("AgentV1SettingsAgentListenProvider (renamed to *AgentContextListenProvider 2026-05-06)", () => {
140+
describe("manage.v1.projects.keys.create (request? optionality patch)", () => {
141+
it("accepts a project_id without a request body at the type level", () => {
142+
// Type-only: if a future regen drops the `request?` optionality
143+
// patch on KeysClient#create, this call site fails to compile and
144+
// the test run fails before any test body executes. The arrow
145+
// function is constructed but never invoked, so the unbound
146+
// `client` reference is safe at runtime.
147+
const _noArgIsCallable = (): unknown => client.manage.v1.projects.keys.create("project_id");
148+
expect(typeof _noArgIsCallable).toBe("function");
149+
});
150+
151+
it("still accepts a request body as the second argument", () => {
152+
const _withBodyIsCallable = (): unknown =>
153+
client.manage.v1.projects.keys.create("project_id", {
154+
comment: "compat check",
155+
scopes: ["usage:read"],
156+
});
157+
expect(typeof _withBodyIsCallable).toBe("function");
158+
});
159+
});
160+
161+
describe("AgentV1SettingsAgentListenProvider (aliased to *AgentContextListenProvider 2026-05-06)", () => {
134162
it("old name still exists at the top-level export", () => {
135163
// Sanity: the old type is still in the public surface even though
136164
// generated code now uses the new context-prefixed name.
137165
const _old: AgentV1SettingsAgentListenProvider = { version: "v1", type: "deepgram", model: "nova-3" };
138166
expect(_old.type).toBe("deepgram");
139167
});
140168

141-
it("old and new provider types are bidirectionally assignable (V2 added optional language_hint only)", () => {
142-
// V1 of both unions is structurally identical; V2 of the new
143-
// context-listen-provider only adds an optional `language_hint`
144-
// field, so structural typing makes the two unions assignable in
145-
// both directions for shared shapes.
146-
const fromOld: AgentV1SettingsAgentContextListenProvider = {
147-
version: "v1",
148-
type: "deepgram",
149-
model: "nova-3",
150-
} as AgentV1SettingsAgentListenProvider;
151-
const fromNew: AgentV1SettingsAgentListenProvider = {
169+
it("old name is a type-identical alias for the new context-prefixed name", () => {
170+
// The patched AgentV1SettingsAgentListenProvider.ts collapses the
171+
// regenerated duplicate into a one-line alias, so the two names
172+
// resolve to the exact same type. If a future regen blows away
173+
// the alias, this Equals<X, Y> identity check fails to compile.
174+
const _equality: Equals<
175+
AgentV1SettingsAgentListenProvider,
176+
AgentV1SettingsAgentContextListenProvider
177+
> = true;
178+
expect(_equality).toBe(true);
179+
});
180+
181+
it("nested .V1 and .V2 namespaces resolve through the alias", () => {
182+
const _v1Equality: Equals<
183+
AgentV1SettingsAgentListenProvider.V1,
184+
AgentV1SettingsAgentContextListenProvider.V1
185+
> = true;
186+
const _v2Equality: Equals<
187+
AgentV1SettingsAgentListenProvider.V2,
188+
AgentV1SettingsAgentContextListenProvider.V2
189+
> = true;
190+
expect(_v1Equality).toBe(true);
191+
expect(_v2Equality).toBe(true);
192+
});
193+
194+
it("legacy V2 literal (no language_hint) still compiles under the alias", () => {
195+
// Pre-regen V2 had no `language_hint`. Because the new V2 adds it
196+
// as optional, old literals continue to type-check unchanged.
197+
const _legacy: AgentV1SettingsAgentListenProvider.V2 = {
152198
version: "v2",
153199
type: "deepgram",
154200
model: "flux-general-en",
155-
} as AgentV1SettingsAgentContextListenProvider;
156-
expect(fromOld.version).toBe("v1");
157-
expect(fromNew.version).toBe("v2");
201+
};
202+
expect(_legacy.version).toBe("v2");
158203
});
159204
});
160205
});

0 commit comments

Comments
 (0)