@silverprotocol/google-adk 0.6.6 → 0.7.0

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.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * JSON-shape guards shared by the facet's modules. Internal to
3
+ * @silverprotocol/google-adk (not part of its package exports).
4
+ */
5
+ import type { JsonValue } from "@silverprotocol/core";
6
+
7
+ /** True for a non-null, non-array plain JSON object (guard idiom from the OpenAI facet). */
8
+ export function isJsonObject(v: unknown): v is { readonly [k: string]: JsonValue } {
9
+ return typeof v === "object" && v !== null && !Array.isArray(v);
10
+ }
11
+
12
+ // ─── genai-optional arm members (adk-13 hardening) ───────────────────────────
13
+ // A Part arm's member when it is a string, else undefined. Read through
14
+ // `unknown` + `isJsonObject` so a JSON-null arm (a snake_case serializer that
15
+ // keeps None) is guarded too, never dereferenced.
16
+ export function stringMember(arm: unknown, key: string): string | undefined {
17
+ if (!isJsonObject(arm)) return undefined;
18
+ const v = arm[key];
19
+ return typeof v === "string" ? v : undefined;
20
+ }