1pub mod contract;
14pub mod decoders;
15pub mod package;
16pub mod policy;
17pub mod record_store;
18pub mod records;
19pub mod router;
20pub mod signature;
21pub mod sources;
22pub mod tools;
23
24pub use contract::*;
25pub use decoders::{decode_jsonl, mcp_action_call, messages_from_mcp_result, DecodeIssue, Decoded, JsonlDecoder, SseDecoder};
26pub use package::{
27 available_extensions, client_capabilities, merge_data, package_sources, source_allowed, supported_catalog_ids, template_messages, validate_package, validate_package_with, version_satisfies, AvailableExtension, PackageIssue,
28 PACKAGE_FORMAT_VERSION,
29};
30pub use policy::{
31 combine_decisions, decide_function, decide_url, image_dimensions, image_frames, image_header, is_builtin_function, is_private_host, media_image_check, ImageHeader, matches_pattern, media_image_within_limits, media_request, media_within_limits, package_policy, svg_dimensions,
32 safe_href, FunctionDecision, FunctionPolicy, MediaOptions, MediaRequest, MediaRule, UrlDecision, UrlPolicy, BUILTIN_FUNCTIONS,
33};
34pub use router::{normalize_path, HostRouter, SurfaceInfo};
35pub use record_store::{parse_records_source, RecordsFilter, RecordsQuery, RECORDS_FUNCTIONS, RECORDS_RESERVED_PARAMS, RECORDS_SCHEME};
36pub use records::{is_record_kind, validate_record, validate_record_schema, RECORD_FIELD_TYPES, RECORD_FORMATS, RECORD_RESERVED_KEYS};
37pub use signature::{canonical_json, package_file_signed_bytes, AUTHOR_KEY_PREFIX, AUTHOR_NAME_MAX, PACKAGE_FILE_SIGNATURE_ALG, PACKAGE_FILE_SIGNATURE_CONTEXT};
38pub use sources::{parse_source, source_with_params, ParsedSource};
39pub use tools::{tool_call, tool_consent, tool_consent_key, validate_tools, ToolCall, ToolConsentRow, TOOL_KINDS};
40
41pub(crate) fn is_js_space(c: char) -> bool {
43 matches!(c, '\u{9}' | '\u{a}' | '\u{b}' | '\u{c}' | '\u{d}' | ' ' | '\u{a0}' | '\u{1680}' | '\u{2000}'..='\u{200a}' | '\u{2028}' | '\u{2029}' | '\u{202f}' | '\u{205f}' | '\u{3000}' | '\u{feff}')
44}
45
46pub(crate) fn js_trim(s: &str) -> &str {
48 s.trim_matches(is_js_space)
49}
50
51pub(crate) fn utf16_cmp(a: &str, b: &str) -> std::cmp::Ordering {
54 a.encode_utf16().cmp(b.encode_utf16())
55}
56
57pub(crate) fn js_truthy(value: &serde_json::Value) -> bool {
59 use serde_json::Value;
60 match value {
61 Value::Null => false,
62 Value::Bool(b) => *b,
63 Value::Number(n) => n.as_f64().is_some_and(|f| f != 0.0 && !f.is_nan()),
64 Value::String(s) => !s.is_empty(),
65 _ => true,
66 }
67}