@gajae-code/ai 0.21.0 → 0.21.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.21.1] - 2026-11-17
6
+
7
+ ### Fixed
8
+
9
+ - Schema normalization for Cloud Code Assist (CCA) now correctly filters type-specific keys when collapsing mixed-type `anyOf` variants. Previously, when collapsing `anyOf: [{ type: "string", ... }, { type: "array", items: {...} }]` to a single type (string variant first), the collapsed schema would retain `items` from the array variant, resulting in invalid schemas with type-mismatched keys. The fix ensures only keys valid for the chosen type are carried forward (issue #7808).
10
+
5
11
  ## [0.21.0] - 2026-11-16
6
12
 
7
13
  ### Added
@@ -37,6 +37,25 @@ export declare function getOAuthApiKey(provider: OAuthProvider, credentials: Rec
37
37
  apiKey: string;
38
38
  } | null>;
39
39
  export declare function resolveOAuthStorageProvider(provider: OAuthProviderId): OAuthProviderId;
40
+ /**
41
+ * True when an exported credential-snapshot row is an api_key credential stored
42
+ * for `provider` (after storage-id normalization). The consumers are provider
43
+ * setup's cleanup scope, its disable accounting, the discovery probe's
44
+ * credential presence check, and the registry's load-time `credential: store`
45
+ * warning; all four decide "stored api_key rows for this provider" here so a
46
+ * change to the stored-credential model moves them together.
47
+ */
48
+ export declare function isStoredApiKeyCredentialForProvider<T extends {
49
+ provider: string;
50
+ credential: {
51
+ type: string;
52
+ };
53
+ }>(entry: T, provider: OAuthProviderId): entry is T & {
54
+ credential: {
55
+ type: "api_key";
56
+ key: string;
57
+ };
58
+ };
40
59
  /**
41
60
  * Get list of OAuth providers.
42
61
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/ai",
4
- "version": "0.21.0",
4
+ "version": "0.21.1",
5
5
  "description": "Unified LLM API with automatic model discovery and provider configuration",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo and Gajae Code Contributors",
@@ -41,8 +41,8 @@
41
41
  "@agentclientprotocol/sdk": "1.3.0",
42
42
  "@anthropic-ai/sdk": "^0.94.0",
43
43
  "@bufbuild/protobuf": "^2.12.0",
44
- "@gajae-code/natives": "0.21.0",
45
- "@gajae-code/utils": "0.21.0",
44
+ "@gajae-code/natives": "0.21.1",
45
+ "@gajae-code/utils": "0.21.1",
46
46
  "openai": "^6.36.0",
47
47
  "partial-json": "^0.1.7",
48
48
  "zod": "4.4.3"
package/src/stream.ts CHANGED
@@ -163,6 +163,7 @@ const serviceProviderMap: Record<string, KeyResolver> = {
163
163
  tavily: "TAVILY_API_KEY",
164
164
  parallel: "PARALLEL_API_KEY",
165
165
  kagi: "KAGI_API_KEY",
166
+ keenable: "KEENABLE_API_KEY",
166
167
  // Kiro API keys use the ksk_ prefix; preserve the AWS bearer fallback for OAuth.
167
168
  kiro: () => {
168
169
  const apiKey = $credentialEnv("KIRO_API_KEY");
@@ -547,6 +547,22 @@ export async function getOAuthApiKey(
547
547
  export function resolveOAuthStorageProvider(provider: OAuthProviderId): OAuthProviderId {
548
548
  return provider === "openai-codex-device" ? "openai-codex" : provider;
549
549
  }
550
+
551
+ /**
552
+ * True when an exported credential-snapshot row is an api_key credential stored
553
+ * for `provider` (after storage-id normalization). The consumers are provider
554
+ * setup's cleanup scope, its disable accounting, the discovery probe's
555
+ * credential presence check, and the registry's load-time `credential: store`
556
+ * warning; all four decide "stored api_key rows for this provider" here so a
557
+ * change to the stored-credential model moves them together.
558
+ */
559
+ export function isStoredApiKeyCredentialForProvider<T extends { provider: string; credential: { type: string } }>(
560
+ entry: T,
561
+ provider: OAuthProviderId,
562
+ ): entry is T & { credential: { type: "api_key"; key: string } } {
563
+ return entry.provider === resolveOAuthStorageProvider(provider) && entry.credential.type === "api_key";
564
+ }
565
+
550
566
  /**
551
567
  * Get list of OAuth providers.
552
568
  */
@@ -595,10 +595,43 @@ function collapseMixedTypeCombinerVariants(schema: JsonObject, combiner: "anyOf"
595
595
 
596
596
  const nextSchema = copySchemaWithout(schema, combiner);
597
597
  const nonNullTypes = variantTypes.filter(t => t !== "null");
598
- nextSchema.type = nonNullTypes[0] ?? variantTypes[0];
598
+ const chosenType = nonNullTypes[0] ?? variantTypes[0];
599
+ nextSchema.type = chosenType;
600
+
601
+ // Only apply fields valid for the chosen type. Each variant was validated above
602
+ // to have only keys allowed for its own type, but merged fields may include keys
603
+ // from different variants. We must filter to only keys allowed for chosenType.
604
+ // Keep first non-null type semantics (not preferring array) for backward compatibility
605
+ // with existing test [array,string,null] → array behavior.
606
+ const allowedKeysForChosenType = CLOUD_CODE_ASSIST_TYPE_SPECIFIC_KEYS[chosenType];
607
+ if (!allowedKeysForChosenType) {
608
+ return schema;
609
+ }
610
+
611
+ // Conservative bailout: if parent (after removing combiner) has type-specific keys
612
+ // incompatible with chosenType, return schema unchanged so residual checks catch it.
613
+ // This handles sibling-key conflicts like {items: ..., anyOf: [string, array]}.
614
+ for (const otherType in CLOUD_CODE_ASSIST_TYPE_SPECIFIC_KEYS) {
615
+ if (otherType === chosenType || otherType === "null") continue;
616
+ const otherTypeKeys = CLOUD_CODE_ASSIST_TYPE_SPECIFIC_KEYS[otherType];
617
+ for (const key in otherTypeKeys) {
618
+ if (Object.hasOwn(nextSchema, key) && !Object.hasOwn(allowedKeysForChosenType, key)) {
619
+ // Parent has a key valid only for otherType but not for chosenType.
620
+ // This creates a type mismatch; bail out and let residual checks handle it.
621
+ return schema;
622
+ }
623
+ }
624
+ }
625
+
599
626
  for (const key in mergedVariantFields) {
600
627
  if (!Object.hasOwn(mergedVariantFields, key)) continue;
601
628
  const value = mergedVariantFields[key];
629
+
630
+ // Only apply fields valid for the chosen type or shared across all types
631
+ if (!Object.hasOwn(allowedKeysForChosenType, key) && !Object.hasOwn(CLOUD_CODE_ASSIST_SHARED_SCHEMA_KEYS, key)) {
632
+ continue;
633
+ }
634
+
602
635
  const existingValue = Object.hasOwn(nextSchema, key) ? nextSchema[key] : undefined;
603
636
  if (existingValue !== undefined && !areJsonValuesEqual(existingValue, value)) {
604
637
  return schema;