From 67aeba6210d742c2284a94a4e07bd60034ab1469 Mon Sep 17 00:00:00 2001 From: William FH <13333726+hinthornw@users.noreply.github.com> Date: Mon, 28 Apr 2025 08:10:07 -0700 Subject: [PATCH] Add schema updates for the configurable headers (#4437) --- docs/docs/cloud/reference/cli.md | 2 +- libs/cli/generate_schema.py | 2 ++ libs/cli/langgraph_cli/config.py | 32 ++++++++++++++++++++ libs/cli/schemas/schema.json | 50 ++++++++++++++++++++++++++++++++ libs/cli/schemas/schema.v0.json | 50 ++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+), 1 deletion(-) diff --git a/docs/docs/cloud/reference/cli.md b/docs/docs/cloud/reference/cli.md index d0bce410f..b71a660ff 100644 --- a/docs/docs/cloud/reference/cli.md +++ b/docs/docs/cloud/reference/cli.md @@ -49,7 +49,7 @@ The LangGraph CLI requires a JSON configuration file that follows this [schema]( | `pip_config_file` | Path to `pip` config file. | | `dockerfile_lines` | Array of additional lines to add to Dockerfile following the import from parent image. | | `checkpointer` | Configuration for the checkpointer. Contains a `ttl` field which is an object with the following keys: | - | `http` | HTTP server configuration with the following fields: | + | `http` | HTTP server configuration with the following fields: | === "JS" diff --git a/libs/cli/generate_schema.py b/libs/cli/generate_schema.py index 8a2e3718d..7a76ca5fa 100644 --- a/libs/cli/generate_schema.py +++ b/libs/cli/generate_schema.py @@ -17,6 +17,7 @@ from langgraph_cli.config import ( AuthConfig, CheckpointerConfig, Config, + ConfigurableHeaderConfig, CorsConfig, HttpConfig, IndexConfig, @@ -112,6 +113,7 @@ def add_descriptions_to_schema(schema, cls): ThreadTTLConfig, CheckpointerConfig, TTLConfig, + ConfigurableHeaderConfig, ]: if potential_cls.__name__ == def_name: add_descriptions_to_schema(def_schema, potential_cls) diff --git a/libs/cli/langgraph_cli/config.py b/libs/cli/langgraph_cli/config.py index efbe55aa2..3ebe3fda4 100644 --- a/libs/cli/langgraph_cli/config.py +++ b/libs/cli/langgraph_cli/config.py @@ -273,6 +273,33 @@ class CorsConfig(TypedDict, total=False): """ +class ConfigurableHeaderConfig(TypedDict): + """Customize which headers to include as configurable values in your runs. + + By default, omits x-api-key, x-tenant-id, and x-service-key. + + Exclusions (if provided) take precedence. + + Each value can be a raw string with an optional wildcard. + """ + + includes: Optional[list[str]] + """Headers to include (if not also matches against an 'exludes' pattern. + + Examples: + - 'user-agent' + - 'x-configurable-*' + """ + excludes: Optional[list[str]] + """Headers to exclude. Applied before the 'includes' checks. + + Examples: + - 'x-api-key' + - '*key*' + - '*token*' + """ + + class HttpConfig(TypedDict, total=False): """Configuration for the built-in HTTP server that powers your deployment's routes and endpoints.""" @@ -311,6 +338,11 @@ class HttpConfig(TypedDict, total=False): """Optional. Defines CORS restrictions. If omitted, no special rules are set and cross-origin behavior depends on default server settings. """ + configurable_headers: Optional[ConfigurableHeaderConfig] + """Optional. Defines how headers are treated for a run's configuration. + + You can include or exclude headers as configurable values to condition your + agent's behavior or permissions on a request's headers.""" class Config(TypedDict, total=False): diff --git a/libs/cli/schemas/schema.json b/libs/cli/schemas/schema.json index 845e5e0ab..1421e249e 100644 --- a/libs/cli/schemas/schema.json +++ b/libs/cli/schemas/schema.json @@ -399,6 +399,17 @@ "type": "string", "description": "Optional. Import path to a custom Starlette/FastAPI application to mount.\n" }, + "configurable_headers": { + "anyOf": [ + { + "$ref": "#/$defs/ConfigurableHeaderConfig" + }, + { + "type": "null" + } + ], + "description": "Optional. Defines how headers are treated for a run's configuration.\n\nYou can include or exclude headers as configurable values to condition your\nagent's behavior or permissions on a request's headers." + }, "cors": { "anyOf": [ { @@ -433,6 +444,45 @@ }, "required": [] }, + "ConfigurableHeaderConfig": { + "title": "ConfigurableHeaderConfig", + "description": "Customize which headers to include as configurable values in your runs.\n\nBy default, omits x-api-key, x-tenant-id, and x-service-key.\n\nExclusions (if provided) take precedence.\n\nEach value can be a raw string with an optional wildcard.", + "type": "object", + "properties": { + "excludes": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "null" + } + ], + "description": "Headers to exclude. Applied before the 'includes' checks.\n" + }, + "includes": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "null" + } + ], + "description": "Headers to include (if not also matches against an 'exludes' pattern.\n" + } + }, + "required": [ + "excludes", + "includes" + ] + }, "CorsConfig": { "title": "CorsConfig", "description": "Specifies Cross-Origin Resource Sharing (CORS) rules for your server.\n\nIf omitted, defaults are typically very restrictive (often no cross-origin requests).\nConfigure carefully if you want to allow usage from browsers hosted on other domains.", diff --git a/libs/cli/schemas/schema.v0.json b/libs/cli/schemas/schema.v0.json index 845e5e0ab..1421e249e 100644 --- a/libs/cli/schemas/schema.v0.json +++ b/libs/cli/schemas/schema.v0.json @@ -399,6 +399,17 @@ "type": "string", "description": "Optional. Import path to a custom Starlette/FastAPI application to mount.\n" }, + "configurable_headers": { + "anyOf": [ + { + "$ref": "#/$defs/ConfigurableHeaderConfig" + }, + { + "type": "null" + } + ], + "description": "Optional. Defines how headers are treated for a run's configuration.\n\nYou can include or exclude headers as configurable values to condition your\nagent's behavior or permissions on a request's headers." + }, "cors": { "anyOf": [ { @@ -433,6 +444,45 @@ }, "required": [] }, + "ConfigurableHeaderConfig": { + "title": "ConfigurableHeaderConfig", + "description": "Customize which headers to include as configurable values in your runs.\n\nBy default, omits x-api-key, x-tenant-id, and x-service-key.\n\nExclusions (if provided) take precedence.\n\nEach value can be a raw string with an optional wildcard.", + "type": "object", + "properties": { + "excludes": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "null" + } + ], + "description": "Headers to exclude. Applied before the 'includes' checks.\n" + }, + "includes": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "null" + } + ], + "description": "Headers to include (if not also matches against an 'exludes' pattern.\n" + } + }, + "required": [ + "excludes", + "includes" + ] + }, "CorsConfig": { "title": "CorsConfig", "description": "Specifies Cross-Origin Resource Sharing (CORS) rules for your server.\n\nIf omitted, defaults are typically very restrictive (often no cross-origin requests).\nConfigure carefully if you want to allow usage from browsers hosted on other domains.",