mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
b51bc3dffa
The 315-case language-neutral corpus was only ever *validated* in TypeScript. `sdk-python/tests/test_intelligence.py` and `IntelligenceClientTests.cs` read it solely to extract the canonical error-code enums, so every declarative assertion was unenforced outside TypeScript. Measured: 112 of the corpus's negative cases are accepted by a vanilla Draft 2020-12 validator and are enforceable only through `x-copilotkit-equal-properties` and `x-copilotkit-assertions`, which existed in TypeScript alone. Adds portable validators to both SDKs, peers of `packages/intelligence/src/portable-validator.ts`, covering the Draft 2020-12 subset the corpus uses plus both custom keywords and all fifteen assertion operations (compare, compare-values, unique, all-equal, strictly-increasing, contiguous, values-in-range, references, disjoint, ordered-ranges, lookup-equal, lookup-references, count, utf8-byte-length, bounded-json) with their `caseFold`/`unicode` normalization, `where` predicates, and bounds. Both consume the same corpus JSON with no per-language restatement of any rule, and both reuse their language's single case-folding definition site. Two properties keep the three implementations honest: - Unknown schema keywords and unknown assertion operations are hard errors, not ignored annotations, so a future corpus keyword fails loudly instead of silently under-enforcing. - ECMAScript `pattern` values are translated into each host dialect explicitly. Untranslated, `$` would also match before a trailing newline and `\d` would match non-ASCII digits in both Python and .NET, accepting strings the TypeScript reference validator rejects. All 315 cases now pass in all three languages, each suite independently re-measures the 112 figure as a regression guard, and the Python suite asserts that every corpus assertion operation decides at least one case.
104 lines
2.8 KiB
Python
104 lines
2.8 KiB
Python
"""CopilotKit SDK"""
|
|
|
|
from .sdk import (
|
|
CopilotKitRemoteEndpoint,
|
|
CopilotKitContext,
|
|
CopilotKitSDK,
|
|
CopilotKitSDKContext,
|
|
)
|
|
from .action import Action
|
|
from .exc import (
|
|
CopilotKitError,
|
|
CopilotKitMisuseError,
|
|
ActionNotFoundException,
|
|
AgentNotFoundException,
|
|
ActionExecutionException,
|
|
AgentExecutionException,
|
|
)
|
|
from .langgraph import CopilotKitState
|
|
from .parameter import Parameter
|
|
from .agent import Agent
|
|
from .langgraph_agui_agent import LangGraphAGUIAgent
|
|
from .copilotkit_lg_middleware import CopilotKitMiddleware
|
|
from ag_ui_langgraph.middlewares.state_streaming import (
|
|
StateStreamingMiddleware,
|
|
StateItem,
|
|
)
|
|
from .header_propagation import (
|
|
set_forwarded_headers,
|
|
get_forwarded_headers,
|
|
install_httpx_hook,
|
|
)
|
|
from .intelligence import (
|
|
AsyncCopilotKitIntelligence,
|
|
CopilotKitIntelligence,
|
|
IntelligenceAccessDeniedError,
|
|
IntelligenceCacheMissError,
|
|
IntelligenceError,
|
|
IntelligenceIntegrityError,
|
|
IntelligenceNotFoundError,
|
|
IntelligenceRequest,
|
|
IntelligenceResponse,
|
|
IntelligenceSkill,
|
|
IntelligenceSkillDescriptor,
|
|
IntelligenceSkillFileDescriptor,
|
|
IntelligenceSkillManifestDescriptor,
|
|
IntelligenceSkillSet,
|
|
IntelligenceUnavailableError,
|
|
)
|
|
from .learning_contract_validator import (
|
|
LearningContractValidatorError,
|
|
compile_learning_contract_schema,
|
|
validate_learning_contract,
|
|
)
|
|
from .unicode_default_case_folding import (
|
|
unicode_default_case_fold,
|
|
unicode_default_case_fold_normalized,
|
|
)
|
|
|
|
|
|
__all__ = [
|
|
"CopilotKitRemoteEndpoint",
|
|
"CopilotKitSDK",
|
|
"Action",
|
|
"CopilotKitState",
|
|
"Parameter",
|
|
"Agent",
|
|
"CopilotKitContext",
|
|
"CopilotKitSDKContext",
|
|
"CopilotKitError",
|
|
"CopilotKitMisuseError",
|
|
"ActionNotFoundException",
|
|
"AgentNotFoundException",
|
|
"ActionExecutionException",
|
|
"AgentExecutionException",
|
|
"CrewAIAgent", # pyright: ignore[reportUnsupportedDunderAll] pylint: disable=undefined-all-variable
|
|
"LangGraphAGUIAgent",
|
|
"CopilotKitMiddleware",
|
|
"StateStreamingMiddleware",
|
|
"StateItem",
|
|
"set_forwarded_headers",
|
|
"get_forwarded_headers",
|
|
"install_httpx_hook",
|
|
"AsyncCopilotKitIntelligence",
|
|
"CopilotKitIntelligence",
|
|
"IntelligenceAccessDeniedError",
|
|
"IntelligenceCacheMissError",
|
|
"IntelligenceError",
|
|
"IntelligenceIntegrityError",
|
|
"IntelligenceNotFoundError",
|
|
"IntelligenceRequest",
|
|
"IntelligenceResponse",
|
|
"IntelligenceSkill",
|
|
"IntelligenceSkillDescriptor",
|
|
"IntelligenceSkillFileDescriptor",
|
|
"IntelligenceSkillManifestDescriptor",
|
|
"IntelligenceSkillSet",
|
|
"IntelligenceUnavailableError",
|
|
"LearningContractValidatorError",
|
|
"compile_learning_contract_schema",
|
|
"validate_learning_contract",
|
|
"unicode_default_case_fold",
|
|
"unicode_default_case_fold_normalized",
|
|
]
|