@workglow/util 0.0.126 → 0.1.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.
@@ -3,16 +3,16 @@
3
3
  "sources": ["../src/json-schema/FromSchema.ts", "../src/json-schema/SchemaUtils.ts", "../src/json-schema/SchemaValidation.ts", "../src/json-schema/parsePartialJson.ts", "../src/vector/TypedArray.ts", "../src/vector/Tensor.ts", "../src/vector/TypedArrayUtils.ts", "../src/vector/VectorSimilarityUtils.ts", "../src/vector/VectorUtils.ts"],
4
4
  "sourcesContent": [
5
5
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n FromExtendedSchema,\n FromExtendedSchemaOptions,\n FromSchemaOptions,\n} from \"@sroussey/json-schema-to-ts\";\nimport type { JsonSchema, JsonSchemaCustomProps } from \"./JsonSchema\";\n\nexport { FromSchemaOptions };\n\n/**\n * Removes the [$JSONSchema] symbol property from a type\n * This is needed because json-schema-to-ts adds this property which cannot be serialized\n */\nexport type StripJSONSchema<T> = T extends object\n ? {\n [K in keyof T as K extends symbol ? never : K]: T[K];\n }\n : T;\n\nexport const FromSchemaDefaultOptions = {\n parseNotKeyword: true,\n parseIfThenElseKeywords: true,\n keepDefaultedPropertiesOptional: true,\n references: false,\n deserialize: false,\n} as const satisfies FromSchemaOptions;\n\nexport type FromSchema<\n SCHEMA extends JsonSchema<EXTENSION>,\n OPTIONS extends FromExtendedSchemaOptions<EXTENSION> = typeof FromSchemaDefaultOptions,\n EXTENSION extends JsonSchemaCustomProps = JsonSchemaCustomProps,\n> = StripJSONSchema<FromExtendedSchema<EXTENSION, SCHEMA, OPTIONS>>;\n\n/**\n * IncludeProps - Returns a new schema with only the specified properties\n *\n * This is a schema transformer that returns a new schema object.\n * Use with FromSchema like: FromSchema<IncludeProps<typeof schema, typeof [\"prop1\", \"prop2\"]>>\n *\n * @template Schema - The JSON schema object (with 'as const')\n * @template Keys - Readonly array type of property keys to include (use typeof [\"key1\", \"key2\"] as const)\n *\n * @example\n * const schema = {\n * type: \"object\",\n * properties: {\n * name: { type: \"string\" },\n * age: { type: \"number\" },\n * email: { type: \"string\" }\n * },\n * required: [\"name\"],\n * additionalProperties: false\n * } as const;\n *\n * type Filtered = FromSchema<IncludeProps<typeof schema, typeof [\"name\", \"age\"]>>;\n * // => { name: string, age?: number }\n */\nexport type IncludeProps<\n Schema extends { readonly type: \"object\"; readonly properties: Record<string, unknown> },\n Keys extends readonly (keyof Schema[\"properties\"])[],\n> = Omit<Schema, \"properties\" | \"required\"> & {\n readonly properties: {\n readonly [K in Extract<keyof Schema[\"properties\"], Keys[number]>]: Schema[\"properties\"][K];\n };\n} & (Schema extends { readonly required: readonly (infer R extends string)[] }\n ? { readonly required: readonly Extract<R, Keys[number]>[] }\n : {});\n\n/**\n * ExcludeProps - Returns a new schema without the specified properties\n *\n * This is a schema transformer that returns a new schema object.\n * Use with FromSchema like: FromSchema<ExcludeProps<typeof schema, typeof [\"prop1\", \"prop2\"]>>\n *\n * @template Schema - The JSON schema object (with 'as const')\n * @template Keys - Readonly array type of property keys to exclude (use typeof [\"key1\", \"key2\"] as const)\n *\n * @example\n * const schema = {\n * type: \"object\",\n * properties: {\n * name: { type: \"string\" },\n * age: { type: \"number\" },\n * email: { type: \"string\" }\n * },\n * required: [\"name\"],\n * additionalProperties: false\n * } as const;\n *\n * type Filtered = FromSchema<ExcludeProps<typeof schema, typeof [\"email\"]>>;\n * // => { name: string, age?: number }\n */\nexport type ExcludeProps<\n Schema extends { readonly type: \"object\"; readonly properties: Record<string, unknown> },\n Keys extends readonly (keyof Schema[\"properties\"])[],\n> = Omit<Schema, \"properties\" | \"required\"> & {\n readonly properties: {\n readonly [K in Exclude<keyof Schema[\"properties\"], Keys[number]>]: Schema[\"properties\"][K];\n };\n} & (Schema extends { readonly required: readonly (infer R extends string)[] }\n ? { readonly required: readonly Exclude<R, Keys[number]>[] }\n : {});\n",
6
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Semantic Compatibility Utilities for Task Graph Dataflows\n *\n * In this project, task graphs have connections between tasks called dataflows.\n * These dataflows have different kinds of compatibility checks:\n *\n * **Static Compatibility:**\n * Static rules help decide if an edge should be connected at all. A connection\n * is statically compatible if:\n * - The source and target are the same exact type\n * - The source connects to the equivalent of \"any\" (target accepts anything)\n * - The source type is acceptable to the target (e.g., a string to something\n * that accepts oneOf[string[], string])\n *\n * **Runtime Compatibility:**\n * Assuming the connection is allowed at design time (passes static check),\n * runtime rules determine if they are compatible during execution.\n *\n * Currently, there is one runtime compatibility check:\n * - If both input and output schemas have 'format' annotations attached,\n * the format annotation has the format /\\w+(:\\w+)?/ where the first part\n * is the \"name\" and if alone matches any other with the same \"name\".\n * If there is a second part, then that narrows the type.\n * - Format checks apply to all types (strings, arrays, etc.), not just strings\n * - A schema with format can connect to a schema with no format (source has format, target doesn't)\n * - A schema with no format cannot connect to a schema with format (source doesn't have format, target does)\n *\n * Example: In the AI package, 'format':'model' and 'format': 'model:EmbeddingTask'\n * are used on string types. An input with property `model` and 'format':'model'\n * connects to a target with property `model` and 'format':'model:EmbeddingTask' --\n * this compatibility is called \"runtime\". It first passes the static check as\n * compatible and then notices a difference in format runtime.\n *\n * Format is also used on array types, e.g., 'format':'Float64Array' on arrays\n * containing Float64 numbers.\n *\n * Only connections that pass the runtime check will pass data at runtime.\n */\n\nimport type { JsonSchema } from \"./JsonSchema\";\n\n/**\n * Checks if two format strings are compatible.\n * Format: /\\w+(:\\w+)?/ where first part is the \"name\" and optional second part narrows the type.\n * - Same name without narrowing: static compatible\n * - Source name matches target narrowed name: runtime compatible\n * - Different names or incompatible narrowing: incompatible\n */\nfunction areFormatStringsCompatible(\n sourceFormat: string,\n targetFormat: string\n): \"static\" | \"runtime\" | \"incompatible\" {\n // Allow letters (must start), numbers, underscore, and dash; e.g., my-type:another_type\n const formatPattern = /^[a-zA-Z][a-zA-Z0-9_-]*(?::[a-zA-Z][a-zA-Z0-9_-]*)?$/;\n if (!formatPattern.test(sourceFormat) || !formatPattern.test(targetFormat)) {\n return \"incompatible\";\n }\n\n const [sourceName, sourceNarrow] = sourceFormat.split(\":\");\n const [targetName, targetNarrow] = targetFormat.split(\":\");\n\n // Different base names are incompatible\n if (sourceName !== targetName) {\n return \"incompatible\";\n }\n\n // Same name, no narrowing on either: static compatible\n if (!sourceNarrow && !targetNarrow) {\n return \"static\";\n }\n\n // Source has narrowing, target doesn't: static compatible (source is more specific)\n if (sourceNarrow && !targetNarrow) {\n return \"static\";\n }\n\n // Target has narrowing, source doesn't: runtime compatible (target is more specific)\n if (!sourceNarrow && targetNarrow) {\n return \"runtime\";\n }\n\n // Both have narrowing: must match exactly for static, otherwise incompatible\n if (sourceNarrow === targetNarrow) {\n return \"static\";\n }\n\n return \"incompatible\";\n}\n\n/**\n * Checks if a source type is statically compatible with a target type.\n * Handles cases like string to oneOf[string[], string] or string to any.\n */\nfunction isTypeStaticallyCompatible(sourceType: unknown, targetType: unknown): boolean {\n // Target accepts any type (no type constraint)\n if (!targetType) {\n return true;\n }\n\n // Source has no type constraint\n if (!sourceType) {\n return false;\n }\n\n // Convert to arrays for comparison\n const sourceTypes = Array.isArray(sourceType) ? sourceType : [sourceType];\n const targetTypes = Array.isArray(targetType) ? targetType : [targetType];\n\n // Check if any source type matches any target type\n return sourceTypes.some((st) => targetTypes.includes(st as any));\n}\n\n/**\n * Merges allOf schemas into a single schema representing their intersection.\n * For example: allOf: [{ type: \"string\", format: \"model\" }, { type: \"string\" }]\n * becomes: { type: \"string\", format: \"model\" }\n */\nfunction mergeAllOfSchemas(schemas: JsonSchema[]): JsonSchema | null {\n if (schemas.length === 0) return null;\n if (schemas.length === 1) return schemas[0] as JsonSchema;\n\n let merged: Record<string, unknown> = {};\n\n for (const schema of schemas) {\n if (typeof schema === \"boolean\") {\n if (schema === false) return false; // false in allOf makes the whole thing false\n // true in allOf doesn't add constraints, so we can skip it\n continue;\n }\n\n // At this point, schema is an object\n const schemaObj = schema as Record<string, unknown>;\n\n // Merge type\n if (schemaObj.type !== undefined) {\n if (merged.type === undefined) {\n merged.type = schemaObj.type;\n } else if (merged.type !== schemaObj.type) {\n // Types must be compatible - if they're different primitives, it's incompatible\n const mergedTypes = Array.isArray(merged.type) ? merged.type : [merged.type];\n const schemaTypes = Array.isArray(schemaObj.type) ? schemaObj.type : [schemaObj.type];\n const commonTypes = mergedTypes.filter((t: unknown) => schemaTypes.includes(t));\n if (commonTypes.length === 0) {\n return false; // Incompatible types\n }\n merged.type = commonTypes.length === 1 ? commonTypes[0] : commonTypes;\n }\n }\n\n // Merge format - use the most specific one (the one with narrowing if any)\n const schemaFormat = schemaObj.format as string | undefined;\n const mergedFormat = merged.format as string | undefined;\n if (schemaFormat) {\n if (!mergedFormat) {\n merged.format = schemaFormat;\n } else {\n // Both have formats - check if they're compatible\n const formatCompat = areFormatStringsCompatible(mergedFormat, schemaFormat);\n if (formatCompat === \"incompatible\") {\n return false; // Incompatible formats\n }\n // Use the more specific format (the one with narrowing, or either if both same)\n const mergedHasNarrow = mergedFormat.includes(\":\");\n const schemaHasNarrow = schemaFormat.includes(\":\");\n if (schemaHasNarrow && !mergedHasNarrow) {\n merged.format = schemaFormat;\n } else if (!schemaHasNarrow && mergedHasNarrow) {\n // Keep merged format (it's more specific)\n } else if (mergedFormat !== schemaFormat) {\n // Both have narrowing and they're different - should be caught by areFormatStringsCompatible\n return false;\n }\n }\n }\n\n // Merge properties for objects\n if (schemaObj.properties && typeof schemaObj.properties === \"object\") {\n if (!merged.properties) {\n merged.properties = {};\n }\n const mergedProps = merged.properties as Record<string, JsonSchema>;\n const schemaProps = schemaObj.properties as Record<string, JsonSchema>;\n for (const [key, value] of Object.entries(schemaProps)) {\n if (mergedProps[key]) {\n // Recursively merge nested schemas\n const nestedMerged = mergeAllOfSchemas([mergedProps[key], value]);\n if (nestedMerged === null || nestedMerged === false) {\n return false;\n }\n mergedProps[key] = nestedMerged as JsonSchema;\n } else {\n mergedProps[key] = value;\n }\n }\n }\n\n // Merge required arrays\n if (schemaObj.required && Array.isArray(schemaObj.required)) {\n if (!merged.required) {\n merged.required = [];\n }\n const mergedRequired = merged.required as string[];\n const schemaRequired = schemaObj.required as string[];\n // Intersection of required arrays\n merged.required = mergedRequired.filter((r) => schemaRequired.includes(r));\n }\n\n // Merge additionalProperties - most restrictive wins\n if (schemaObj.additionalProperties !== undefined) {\n if (merged.additionalProperties === undefined) {\n merged.additionalProperties = schemaObj.additionalProperties;\n } else if (merged.additionalProperties === true && schemaObj.additionalProperties === false) {\n merged.additionalProperties = false; // false is more restrictive\n }\n }\n\n // Merge items for arrays\n if (schemaObj.items !== undefined) {\n if (merged.items === undefined) {\n merged.items = schemaObj.items;\n } else {\n // Recursively merge item schemas\n const mergedItems = mergeAllOfSchemas([\n merged.items as JsonSchema,\n schemaObj.items as JsonSchema,\n ]);\n if (mergedItems === null || mergedItems === false) {\n return false;\n }\n merged.items = mergedItems;\n }\n }\n }\n\n return merged as JsonSchema;\n}\n\n/**\n * Checks if a source schema is compatible with a target schema in a oneOf/anyOf union.\n */\nfunction isCompatibleWithUnion(\n sourceSchema: JsonSchema,\n unionSchemas: JsonSchema[]\n): \"static\" | \"runtime\" | \"incompatible\" {\n let hasStatic = false;\n let hasRuntime = false;\n\n for (const unionSchema of unionSchemas) {\n const compatibility = areSemanticallyCompatible(sourceSchema, unionSchema);\n if (compatibility === \"static\") {\n hasStatic = true;\n } else if (compatibility === \"runtime\") {\n hasRuntime = true;\n }\n }\n\n if (hasStatic) return \"static\";\n if (hasRuntime) return \"runtime\";\n return \"incompatible\";\n}\n\n/**\n * Checks if two JSON schemas are semantically compatible.\n * Returns:\n * - \"static\": Compatible at design time, no runtime check needed\n * - \"runtime\": Compatible at design time, but needs runtime semantic check\n * - \"incompatible\": Not compatible\n */\nexport function areSemanticallyCompatible(\n sourceSchema: JsonSchema,\n targetSchema: JsonSchema\n): \"static\" | \"runtime\" | \"incompatible\" {\n // Handle undefined schemas (non-existent ports)\n if (sourceSchema === undefined || targetSchema === undefined) {\n return \"incompatible\";\n }\n\n // Handle boolean schemas\n if (typeof targetSchema === \"boolean\") {\n if (targetSchema === false) return \"incompatible\";\n if (targetSchema === true) return \"static\"; // target accepts anything\n return \"incompatible\";\n }\n\n if (typeof sourceSchema === \"boolean\") {\n if (sourceSchema === false) return \"incompatible\";\n // sourceSchema === true means source can be anything, which is compatible with any target, but may not be at runtime\n if (sourceSchema === true) return \"runtime\";\n }\n\n // Handle allOf in source (intersection types - merge all schemas first)\n if (sourceSchema.allOf && Array.isArray(sourceSchema.allOf)) {\n const mergedSchema = mergeAllOfSchemas(sourceSchema.allOf);\n if (mergedSchema === null || mergedSchema === false) {\n return \"incompatible\";\n }\n // Check compatibility of the merged schema against the target\n return areSemanticallyCompatible(mergedSchema, targetSchema);\n }\n\n // Check type compatibility first\n const sourceType = sourceSchema.type;\n const targetType = targetSchema.type;\n\n // Handle oneOf/anyOf in source first\n if (sourceSchema.oneOf && Array.isArray(sourceSchema.oneOf)) {\n let hasStatic = false;\n let hasRuntime = false;\n\n for (const sourceOption of sourceSchema.oneOf) {\n const compatibility = areSemanticallyCompatible(sourceOption as JsonSchema, targetSchema);\n if (compatibility === \"static\") {\n hasStatic = true;\n } else if (compatibility === \"runtime\") {\n hasRuntime = true;\n }\n }\n\n // If any option requires runtime check, the whole thing requires runtime check\n if (hasRuntime) return \"runtime\";\n if (hasStatic) return \"static\";\n return \"incompatible\";\n }\n\n if (sourceSchema.anyOf && Array.isArray(sourceSchema.anyOf)) {\n let hasStatic = false;\n let hasRuntime = false;\n\n for (const sourceOption of sourceSchema.anyOf) {\n const compatibility = areSemanticallyCompatible(sourceOption as JsonSchema, targetSchema);\n if (compatibility === \"static\") {\n hasStatic = true;\n } else if (compatibility === \"runtime\") {\n hasRuntime = true;\n }\n }\n\n // If any option requires runtime check, the whole thing requires runtime check\n if (hasRuntime) return \"runtime\";\n if (hasStatic) return \"static\";\n return \"incompatible\";\n }\n\n // Handle oneOf/anyOf in target (e.g., oneOf[string[], string])\n if (targetSchema.oneOf && Array.isArray(targetSchema.oneOf)) {\n return isCompatibleWithUnion(sourceSchema, targetSchema.oneOf);\n }\n\n if (targetSchema.anyOf && Array.isArray(targetSchema.anyOf)) {\n return isCompatibleWithUnion(sourceSchema, targetSchema.anyOf);\n }\n\n // Handle allOf in target (intersection types - source must be compatible with all)\n if (targetSchema.allOf && Array.isArray(targetSchema.allOf)) {\n let hasStatic = false;\n let hasRuntime = false;\n\n for (const allOfSchema of targetSchema.allOf) {\n const compatibility = areSemanticallyCompatible(sourceSchema, allOfSchema as JsonSchema);\n if (compatibility === \"incompatible\") {\n return \"incompatible\";\n } else if (compatibility === \"static\") {\n hasStatic = true;\n } else if (compatibility === \"runtime\") {\n hasRuntime = true;\n }\n }\n\n if (hasRuntime) return \"runtime\";\n if (hasStatic) return \"static\";\n return \"incompatible\";\n }\n\n // Handle object types - check if properties are compatible\n if (sourceType === \"object\" && targetType === \"object\") {\n const sourceProperties = sourceSchema.properties;\n const targetProperties = targetSchema.properties;\n\n // If target has no properties constraint, it accepts any object\n if (!targetProperties) {\n return \"static\";\n }\n\n // If source has no properties but target does, check if target allows additional properties\n if (!sourceProperties) {\n // If target doesn't allow additional properties, incompatible\n if (targetSchema.additionalProperties === false) {\n return \"incompatible\";\n }\n // Otherwise, source (any object) is compatible with target that allows additional properties\n return \"static\";\n }\n\n // Check if all required target properties are present and compatible in source\n const targetRequired = targetSchema.required || [];\n let hasRuntime = false;\n\n for (const propName of targetRequired) {\n const targetProp = (targetProperties as Record<string, JsonSchema>)?.[propName];\n const sourceProp = (sourceProperties as Record<string, JsonSchema>)?.[propName];\n\n // If target requires a property that source doesn't have, incompatible\n if (!sourceProp) {\n return \"incompatible\";\n }\n\n // Check compatibility of the property\n if (targetProp) {\n const propCompatibility = areSemanticallyCompatible(sourceProp, targetProp);\n if (propCompatibility === \"incompatible\") {\n return \"incompatible\";\n } else if (propCompatibility === \"runtime\") {\n hasRuntime = true;\n }\n }\n }\n\n // Check if target allows additional properties\n if (targetSchema.additionalProperties === false) {\n // Target doesn't allow additional properties, so source can't have extra properties\n const sourcePropNames = Object.keys(sourceProperties as Record<string, JsonSchema>);\n const targetPropNames = Object.keys(targetProperties as Record<string, JsonSchema>);\n const extraProps = sourcePropNames.filter((name) => !targetPropNames.includes(name));\n if (extraProps.length > 0) {\n return \"incompatible\";\n }\n }\n\n if (hasRuntime) return \"runtime\";\n return \"static\";\n }\n\n // Handle array types - check compatibility of array items and array format\n if (sourceType === \"array\" && targetType === \"array\") {\n // First check format on the array schema itself (e.g., format: \"Float64Array\")\n const sourceFormat = (sourceSchema as any)?.format;\n const targetFormat = (targetSchema as any)?.format;\n\n let formatCompatibility: \"static\" | \"runtime\" | \"incompatible\" | null = null;\n\n // Both have format: check compatibility using prefix matching\n if (sourceFormat && targetFormat) {\n formatCompatibility = areFormatStringsCompatible(sourceFormat, targetFormat);\n // If formats are incompatible, the arrays are incompatible\n if (formatCompatibility === \"incompatible\") {\n return \"incompatible\";\n }\n }\n\n // Source has format, target doesn't: static compatible (source is more specific)\n if (sourceFormat && !targetFormat) {\n return \"static\";\n }\n\n // Source doesn't have format, target does: incompatible (target requires format)\n if (!sourceFormat && targetFormat) {\n return \"incompatible\";\n }\n\n // Now check array items compatibility\n const sourceItems = sourceSchema.items;\n const targetItems = targetSchema.items;\n\n // If both have items schemas, recursively check compatibility\n if (\n sourceItems &&\n typeof sourceItems === \"object\" &&\n !Array.isArray(sourceItems) &&\n targetItems &&\n typeof targetItems === \"object\" &&\n !Array.isArray(targetItems)\n ) {\n const itemsCompatibility = areSemanticallyCompatible(\n sourceItems as JsonSchema,\n targetItems as JsonSchema\n );\n // If format requires runtime check, return runtime (more restrictive)\n if (formatCompatibility === \"runtime\") {\n return \"runtime\";\n }\n return itemsCompatibility;\n }\n\n // If target accepts any array items, it's statically compatible\n if (!targetItems) {\n return \"static\";\n }\n\n // If source has no items but target does, incompatible\n if (!sourceItems) {\n return \"incompatible\";\n }\n\n // If target items is an array (tuple), check if source is compatible with any item\n if (Array.isArray(targetItems)) {\n return isCompatibleWithUnion(sourceItems as JsonSchema, targetItems as JsonSchema[]);\n }\n\n // Fallback to static if we can't determine\n return \"static\";\n }\n\n // If source has no type constraint, it can be anything (compatible with any target)\n // But we need to check if target has constraints that might require runtime checks\n if (!sourceType) {\n // Source accepts any type, but target might have format requiring runtime check\n const targetFormat = (targetSchema as any)?.format;\n if (targetFormat) {\n return \"runtime\";\n }\n return \"static\";\n }\n\n // Check if types are statically compatible\n if (!targetType) {\n // Target has no type constraint, it accepts anything\n // But we still need to check format - if target requires format, source must have it\n const targetFormat = (targetSchema as any)?.format;\n if (targetFormat) {\n // Target requires format, check if source has it\n const sourceFormat = (sourceSchema as any)?.format;\n if (!sourceFormat) {\n return \"incompatible\";\n }\n // Both have format, check compatibility\n return areFormatStringsCompatible(sourceFormat, targetFormat);\n }\n return \"static\";\n }\n\n if (!isTypeStaticallyCompatible(sourceType, targetType)) {\n return \"incompatible\";\n }\n\n // If types are compatible, check format compatibility\n // Format checks apply to all types, not just strings\n // Access format field directly (it's a standard JSON Schema field)\n const sourceFormat = (sourceSchema as any)?.format;\n const targetFormat = (targetSchema as any)?.format;\n\n // Both have format: check compatibility using prefix matching\n if (sourceFormat && targetFormat) {\n return areFormatStringsCompatible(sourceFormat, targetFormat);\n }\n\n // Source has format, target doesn't: static compatible (source is more specific)\n if (sourceFormat && !targetFormat) {\n return \"static\";\n }\n\n // Source doesn't have format, target does: incompatible (target requires format)\n if (!sourceFormat && targetFormat) {\n return \"incompatible\";\n }\n\n // Neither has format: static compatible\n return \"static\";\n}\n\n/**\n * Checks if two object schemas are semantically compatible.\n * This is a helper function for checking object-level schema compatibility.\n */\nexport function areObjectSchemasSemanticallyCompatible(\n sourceSchema: JsonSchema,\n targetSchema: JsonSchema\n): \"static\" | \"runtime\" | \"incompatible\" {\n return areSemanticallyCompatible(sourceSchema, targetSchema);\n}\n",
6
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Semantic Compatibility Utilities for Task Graph Dataflows\n *\n * In this project, task graphs have connections between tasks called dataflows.\n * These dataflows have different kinds of compatibility checks:\n *\n * **Static Compatibility:**\n * Static rules help decide if an edge should be connected at all. A connection\n * is statically compatible if:\n * - The source and target are the same exact type\n * - The source connects to the equivalent of \"any\" (target accepts anything)\n * - The source type is acceptable to the target (e.g., a string to something\n * that accepts oneOf[string[], string])\n *\n * **Runtime Compatibility:**\n * Assuming the connection is allowed at design time (passes static check),\n * runtime rules determine if they are compatible during execution.\n *\n * Currently, there is one runtime compatibility check:\n * - If both input and output schemas have 'format' annotations attached,\n * the format annotation has the format /\\w+(:\\w+)?/ where the first part\n * is the \"name\" and if alone matches any other with the same \"name\".\n * If there is a second part, then that narrows the type.\n * - Format checks apply to all types (strings, arrays, etc.), not just strings\n * - A schema with format can connect to a schema with no format (source has format, target doesn't)\n * - A schema with no format cannot connect to a schema with format (source doesn't have format, target does)\n *\n * Example: In the AI package, 'format':'model' and 'format': 'model:EmbeddingTask'\n * are used on string types. An input with property `model` and 'format':'model'\n * connects to a target with property `model` and 'format':'model:EmbeddingTask' --\n * this compatibility is called \"runtime\". It first passes the static check as\n * compatible and then notices a difference in format runtime.\n *\n * Format is also used on array types, e.g., 'format':'Float64Array' on arrays\n * containing Float64 numbers.\n *\n * Only connections that pass the runtime check will pass data at runtime.\n */\n\nimport type { JsonSchema } from \"./JsonSchema\";\n\n/**\n * Checks if two format strings are compatible.\n * Format: /\\w+(:\\w+)?/ where first part is the \"name\" and optional second part narrows the type.\n * - Same name without narrowing: static compatible\n * - Source name matches target narrowed name: runtime compatible\n * - Different names or incompatible narrowing: incompatible\n */\nfunction areFormatStringsCompatible(\n sourceFormat: string,\n targetFormat: string\n): \"static\" | \"runtime\" | \"incompatible\" {\n // Allow letters (must start), numbers, underscore, and dash; e.g., my-type:another_type\n const formatPattern = /^[a-zA-Z][a-zA-Z0-9_-]*(?::[a-zA-Z][a-zA-Z0-9_-]*)?$/;\n if (!formatPattern.test(sourceFormat) || !formatPattern.test(targetFormat)) {\n return \"incompatible\";\n }\n\n const [sourceName, sourceNarrow] = sourceFormat.split(\":\");\n const [targetName, targetNarrow] = targetFormat.split(\":\");\n\n // Different base names are incompatible\n if (sourceName !== targetName) {\n return \"incompatible\";\n }\n\n // Same name, no narrowing on either: static compatible\n if (!sourceNarrow && !targetNarrow) {\n return \"static\";\n }\n\n // Source has narrowing, target doesn't: static compatible (source is more specific)\n if (sourceNarrow && !targetNarrow) {\n return \"static\";\n }\n\n // Target has narrowing, source doesn't: runtime compatible (target is more specific)\n if (!sourceNarrow && targetNarrow) {\n return \"runtime\";\n }\n\n // Both have narrowing: must match exactly for static, otherwise incompatible\n if (sourceNarrow === targetNarrow) {\n return \"static\";\n }\n\n return \"incompatible\";\n}\n\n/**\n * Checks if a source type is statically compatible with a target type.\n * Handles cases like string to oneOf[string[], string] or string to any.\n */\nfunction isTypeStaticallyCompatible(sourceType: unknown, targetType: unknown): boolean {\n // Target accepts any type (no type constraint)\n if (!targetType) {\n return true;\n }\n\n // Source has no type constraint\n if (!sourceType) {\n return false;\n }\n\n // Convert to arrays for comparison\n const sourceTypes = Array.isArray(sourceType) ? sourceType : [sourceType];\n const targetTypes = Array.isArray(targetType) ? targetType : [targetType];\n\n // Check if any source type matches any target type\n return sourceTypes.some((st) => targetTypes.includes(st as any));\n}\n\n/**\n * Merges allOf schemas into a single schema representing their intersection.\n * For example: allOf: [{ type: \"string\", format: \"model\" }, { type: \"string\" }]\n * becomes: { type: \"string\", format: \"model\" }\n */\nfunction mergeAllOfSchemas(schemas: JsonSchema[]): JsonSchema | null {\n if (schemas.length === 0) return null;\n if (schemas.length === 1) return schemas[0] as JsonSchema;\n\n let merged: Record<string, unknown> = {};\n\n for (const schema of schemas) {\n if (typeof schema === \"boolean\") {\n if (schema === false) return false; // false in allOf makes the whole thing false\n // true in allOf doesn't add constraints, so we can skip it\n continue;\n }\n\n // At this point, schema is an object\n const schemaObj = schema as Record<string, unknown>;\n\n // Merge type\n if (schemaObj.type !== undefined) {\n if (merged.type === undefined) {\n merged.type = schemaObj.type;\n } else if (merged.type !== schemaObj.type) {\n // Types must be compatible - if they're different primitives, it's incompatible\n const mergedTypes = Array.isArray(merged.type) ? merged.type : [merged.type];\n const schemaTypes = Array.isArray(schemaObj.type) ? schemaObj.type : [schemaObj.type];\n const commonTypes = mergedTypes.filter((t: unknown) => schemaTypes.includes(t));\n if (commonTypes.length === 0) {\n return false; // Incompatible types\n }\n merged.type = commonTypes.length === 1 ? commonTypes[0] : commonTypes;\n }\n }\n\n // Merge format - use the most specific one (the one with narrowing if any)\n const schemaFormat = schemaObj.format as string | undefined;\n const mergedFormat = merged.format as string | undefined;\n if (schemaFormat) {\n if (!mergedFormat) {\n merged.format = schemaFormat;\n } else {\n // Both have formats - check if they're compatible\n const formatCompat = areFormatStringsCompatible(mergedFormat, schemaFormat);\n if (formatCompat === \"incompatible\") {\n return false; // Incompatible formats\n }\n // Use the more specific format (the one with narrowing, or either if both same)\n const mergedHasNarrow = mergedFormat.includes(\":\");\n const schemaHasNarrow = schemaFormat.includes(\":\");\n if (schemaHasNarrow && !mergedHasNarrow) {\n merged.format = schemaFormat;\n } else if (!schemaHasNarrow && mergedHasNarrow) {\n // Keep merged format (it's more specific)\n } else if (mergedFormat !== schemaFormat) {\n // Both have narrowing and they're different - should be caught by areFormatStringsCompatible\n return false;\n }\n }\n }\n\n // Merge properties for objects\n if (schemaObj.properties && typeof schemaObj.properties === \"object\") {\n if (!merged.properties) {\n merged.properties = {};\n }\n const mergedProps = merged.properties as Record<string, JsonSchema>;\n const schemaProps = schemaObj.properties as Record<string, JsonSchema>;\n for (const [key, value] of Object.entries(schemaProps)) {\n if (mergedProps[key]) {\n // Recursively merge nested schemas\n const nestedMerged = mergeAllOfSchemas([mergedProps[key], value]);\n if (nestedMerged === null || nestedMerged === false) {\n return false;\n }\n mergedProps[key] = nestedMerged as JsonSchema;\n } else {\n mergedProps[key] = value;\n }\n }\n }\n\n // Merge required arrays\n if (schemaObj.required && Array.isArray(schemaObj.required)) {\n if (!merged.required) {\n merged.required = [];\n }\n const mergedRequired = merged.required as string[];\n const schemaRequired = schemaObj.required as string[];\n // Intersection of required arrays\n merged.required = mergedRequired.filter((r) => schemaRequired.includes(r));\n }\n\n // Merge additionalProperties - most restrictive wins\n if (schemaObj.additionalProperties !== undefined) {\n if (merged.additionalProperties === undefined) {\n merged.additionalProperties = schemaObj.additionalProperties;\n } else if (merged.additionalProperties === true && schemaObj.additionalProperties === false) {\n merged.additionalProperties = false; // false is more restrictive\n }\n }\n\n // Merge items for arrays\n if (schemaObj.items !== undefined) {\n if (merged.items === undefined) {\n merged.items = schemaObj.items;\n } else {\n // Recursively merge item schemas\n const mergedItems = mergeAllOfSchemas([\n merged.items as JsonSchema,\n schemaObj.items as JsonSchema,\n ]);\n if (mergedItems === null || mergedItems === false) {\n return false;\n }\n merged.items = mergedItems;\n }\n }\n }\n\n return merged as JsonSchema;\n}\n\n/**\n * Checks if a source schema is compatible with a target schema in a oneOf/anyOf union.\n */\nfunction isCompatibleWithUnion(\n sourceSchema: JsonSchema,\n unionSchemas: JsonSchema[]\n): \"static\" | \"runtime\" | \"incompatible\" {\n let hasStatic = false;\n let hasRuntime = false;\n\n for (const unionSchema of unionSchemas) {\n const compatibility = areSemanticallyCompatible(sourceSchema, unionSchema);\n if (compatibility === \"static\") {\n hasStatic = true;\n } else if (compatibility === \"runtime\") {\n hasRuntime = true;\n }\n }\n\n if (hasStatic) return \"static\";\n if (hasRuntime) return \"runtime\";\n return \"incompatible\";\n}\n\n/**\n * Checks if two JSON schemas are semantically compatible.\n * Returns:\n * - \"static\": Compatible at design time, no runtime check needed\n * - \"runtime\": Compatible at design time, but needs runtime semantic check\n * - \"incompatible\": Not compatible\n */\nexport function areSemanticallyCompatible(\n sourceSchema: JsonSchema,\n targetSchema: JsonSchema\n): \"static\" | \"runtime\" | \"incompatible\" {\n // Handle undefined schemas (non-existent ports)\n if (sourceSchema === undefined || targetSchema === undefined) {\n return \"incompatible\";\n }\n\n // Handle boolean schemas\n if (typeof targetSchema === \"boolean\") {\n if (targetSchema === false) return \"incompatible\";\n if (targetSchema === true) return \"static\"; // target accepts anything\n return \"incompatible\";\n }\n\n if (typeof sourceSchema === \"boolean\") {\n if (sourceSchema === false) return \"incompatible\";\n // sourceSchema === true means source can be anything, which is compatible with any target, but may not be at runtime\n if (sourceSchema === true) return \"runtime\";\n }\n\n // Handle allOf in source (intersection types - merge all schemas first)\n if (sourceSchema.allOf && Array.isArray(sourceSchema.allOf)) {\n const mergedSchema = mergeAllOfSchemas(sourceSchema.allOf);\n if (mergedSchema === null || mergedSchema === false) {\n return \"incompatible\";\n }\n // Check compatibility of the merged schema against the target\n return areSemanticallyCompatible(mergedSchema, targetSchema);\n }\n\n // Check type compatibility first\n const sourceType = sourceSchema.type;\n const targetType = targetSchema.type;\n\n // Handle oneOf/anyOf in source first\n if (sourceSchema.oneOf && Array.isArray(sourceSchema.oneOf)) {\n let hasStatic = false;\n let hasRuntime = false;\n\n for (const sourceOption of sourceSchema.oneOf) {\n const compatibility = areSemanticallyCompatible(sourceOption as JsonSchema, targetSchema);\n if (compatibility === \"static\") {\n hasStatic = true;\n } else if (compatibility === \"runtime\") {\n hasRuntime = true;\n }\n }\n\n // If any option requires runtime check, the whole thing requires runtime check\n if (hasRuntime) return \"runtime\";\n if (hasStatic) return \"static\";\n return \"incompatible\";\n }\n\n if (sourceSchema.anyOf && Array.isArray(sourceSchema.anyOf)) {\n let hasStatic = false;\n let hasRuntime = false;\n\n for (const sourceOption of sourceSchema.anyOf) {\n const compatibility = areSemanticallyCompatible(sourceOption as JsonSchema, targetSchema);\n if (compatibility === \"static\") {\n hasStatic = true;\n } else if (compatibility === \"runtime\") {\n hasRuntime = true;\n }\n }\n\n // If any option requires runtime check, the whole thing requires runtime check\n if (hasRuntime) return \"runtime\";\n if (hasStatic) return \"static\";\n return \"incompatible\";\n }\n\n // Handle oneOf/anyOf in target (e.g., oneOf[string[], string])\n if (targetSchema.oneOf && Array.isArray(targetSchema.oneOf)) {\n return isCompatibleWithUnion(sourceSchema, targetSchema.oneOf);\n }\n\n if (targetSchema.anyOf && Array.isArray(targetSchema.anyOf)) {\n return isCompatibleWithUnion(sourceSchema, targetSchema.anyOf);\n }\n\n // Handle allOf in target (intersection types - source must be compatible with all)\n if (targetSchema.allOf && Array.isArray(targetSchema.allOf)) {\n let hasStatic = false;\n let hasRuntime = false;\n\n for (const allOfSchema of targetSchema.allOf) {\n const compatibility = areSemanticallyCompatible(sourceSchema, allOfSchema as JsonSchema);\n if (compatibility === \"incompatible\") {\n return \"incompatible\";\n } else if (compatibility === \"static\") {\n hasStatic = true;\n } else if (compatibility === \"runtime\") {\n hasRuntime = true;\n }\n }\n\n if (hasRuntime) return \"runtime\";\n if (hasStatic) return \"static\";\n return \"incompatible\";\n }\n\n // Handle object types - check if properties are compatible\n if (sourceType === \"object\" && targetType === \"object\") {\n const sourceProperties = sourceSchema.properties;\n const targetProperties = targetSchema.properties;\n\n // If target has no properties constraint, it accepts any object\n if (!targetProperties) {\n return \"static\";\n }\n\n // If source has no properties but target does, check if target allows additional properties\n if (!sourceProperties) {\n // If target doesn't allow additional properties, incompatible\n if (targetSchema.additionalProperties === false) {\n return \"incompatible\";\n }\n // Otherwise, source (any object) is compatible with target that allows additional properties\n return \"static\";\n }\n\n // Check if all required target properties are present and compatible in source\n const targetRequired = targetSchema.required || [];\n let hasRuntime = false;\n\n for (const propName of targetRequired) {\n const targetProp = (targetProperties as Record<string, JsonSchema>)?.[propName];\n const sourceProp = (sourceProperties as Record<string, JsonSchema>)?.[propName];\n\n // If target requires a property that source doesn't have, incompatible\n if (!sourceProp) {\n return \"incompatible\";\n }\n\n // Check compatibility of the property\n if (targetProp) {\n const propCompatibility = areSemanticallyCompatible(sourceProp, targetProp);\n if (propCompatibility === \"incompatible\") {\n return \"incompatible\";\n } else if (propCompatibility === \"runtime\") {\n hasRuntime = true;\n }\n }\n }\n\n // Check if target allows additional properties\n if (targetSchema.additionalProperties === false) {\n // Target doesn't allow additional properties, so source can't have extra properties\n const sourcePropNames = Object.keys(sourceProperties as Record<string, JsonSchema>);\n const targetPropNames = Object.keys(targetProperties as Record<string, JsonSchema>);\n const extraProps = sourcePropNames.filter((name) => !targetPropNames.includes(name));\n if (extraProps.length > 0) {\n return \"incompatible\";\n }\n }\n\n if (hasRuntime) return \"runtime\";\n return \"static\";\n }\n\n // Handle array types - check compatibility of array items and array format\n if (sourceType === \"array\" && targetType === \"array\") {\n // First check format on the array schema itself (e.g., format: \"Float64Array\")\n const sourceFormat = (sourceSchema as any)?.format;\n const targetFormat = (targetSchema as any)?.format;\n\n let formatCompatibility: \"static\" | \"runtime\" | \"incompatible\" | null = null;\n\n // Both have format: check compatibility using prefix matching\n if (sourceFormat && targetFormat) {\n formatCompatibility = areFormatStringsCompatible(sourceFormat, targetFormat);\n // If formats are incompatible, the arrays are incompatible\n if (formatCompatibility === \"incompatible\") {\n return \"incompatible\";\n }\n }\n\n // Source has format, target doesn't: static compatible (source is more specific)\n if (sourceFormat && !targetFormat) {\n return \"static\";\n }\n\n // Source doesn't have format, target does: incompatible (target requires format)\n if (!sourceFormat && targetFormat) {\n return \"incompatible\";\n }\n\n const sourceItems = sourceSchema.items;\n const targetItems = targetSchema.items;\n\n // If both have items schemas, recursively check compatibility\n if (\n sourceItems &&\n typeof sourceItems === \"object\" &&\n !Array.isArray(sourceItems) &&\n targetItems &&\n typeof targetItems === \"object\" &&\n !Array.isArray(targetItems)\n ) {\n const itemsCompatibility = areSemanticallyCompatible(\n sourceItems as JsonSchema,\n targetItems as JsonSchema\n );\n // If format requires runtime check, return runtime (more restrictive)\n if (formatCompatibility === \"runtime\") {\n return \"runtime\";\n }\n return itemsCompatibility;\n }\n\n // If target accepts any array items, it's statically compatible\n if (!targetItems) {\n return \"static\";\n }\n\n // If source has no items but target does, incompatible\n if (!sourceItems) {\n return \"incompatible\";\n }\n\n // If target items is an array (tuple), check if source is compatible with any item\n if (Array.isArray(targetItems)) {\n return isCompatibleWithUnion(sourceItems as JsonSchema, targetItems as JsonSchema[]);\n }\n\n // Fallback to static if we can't determine\n return \"static\";\n }\n\n // If source has no type constraint, it can be anything (compatible with any target)\n // But we need to check if target has constraints that might require runtime checks\n if (!sourceType) {\n // Source accepts any type, but target might have format requiring runtime check\n const targetFormat = (targetSchema as any)?.format;\n if (targetFormat) {\n return \"runtime\";\n }\n return \"static\";\n }\n\n // Check if types are statically compatible\n if (!targetType) {\n // Target has no type constraint, it accepts anything\n // But we still need to check format - if target requires format, source must have it\n const targetFormat = (targetSchema as any)?.format;\n if (targetFormat) {\n // Target requires format, check if source has it\n const sourceFormat = (sourceSchema as any)?.format;\n if (!sourceFormat) {\n return \"incompatible\";\n }\n // Both have format, check compatibility\n return areFormatStringsCompatible(sourceFormat, targetFormat);\n }\n return \"static\";\n }\n\n if (!isTypeStaticallyCompatible(sourceType, targetType)) {\n return \"incompatible\";\n }\n\n // If types are compatible, check format compatibility\n // Format checks apply to all types, not just strings\n // Access format field directly (it's a standard JSON Schema field)\n const sourceFormat = (sourceSchema as any)?.format;\n const targetFormat = (targetSchema as any)?.format;\n\n // Both have format: check compatibility using prefix matching\n if (sourceFormat && targetFormat) {\n return areFormatStringsCompatible(sourceFormat, targetFormat);\n }\n\n // Source has format, target doesn't: static compatible (source is more specific)\n if (sourceFormat && !targetFormat) {\n return \"static\";\n }\n\n // Source doesn't have format, target does: incompatible (target requires format)\n if (!sourceFormat && targetFormat) {\n return \"incompatible\";\n }\n\n // Neither has format: static compatible\n return \"static\";\n}\n\n/**\n * Checks if two object schemas are semantically compatible.\n * This is a helper function for checking object-level schema compatibility.\n */\nexport function areObjectSchemasSemanticallyCompatible(\n sourceSchema: JsonSchema,\n targetSchema: JsonSchema\n): \"static\" | \"runtime\" | \"incompatible\" {\n return areSemanticallyCompatible(sourceSchema, targetSchema);\n}\n",
7
7
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { compileSchema } from \"@sroussey/json-schema-library\";\nexport type { SchemaNode } from \"@sroussey/json-schema-library\";\n",
8
8
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Attempts to parse a potentially incomplete JSON string into a partial object.\n *\n * Useful for progressive rendering of streamed JSON output from AI providers.\n * Each call returns the most complete object that can be parsed from the\n * accumulated text so far.\n *\n * Strategy:\n * 1. Try JSON.parse directly (handles complete JSON)\n * 2. If that fails, attempt to close open delimiters and re-parse\n *\n * @param text - The (possibly incomplete) JSON string\n * @returns The parsed partial object, or undefined if text is too incomplete\n */\nexport function parsePartialJson(text: string): Record<string, unknown> | undefined {\n const trimmed = text.trim();\n if (!trimmed) return undefined;\n\n // Fast path: try parsing as-is\n try {\n const result = JSON.parse(trimmed);\n if (typeof result === \"object\" && result !== null && !Array.isArray(result)) {\n return result as Record<string, unknown>;\n }\n return undefined;\n } catch {\n // Fall through to repair logic\n }\n\n // Must start with '{' for an object\n if (trimmed[0] !== \"{\") return undefined;\n\n const repaired = repairJson(trimmed);\n if (repaired === undefined) return undefined;\n\n try {\n const result = JSON.parse(repaired);\n if (typeof result === \"object\" && result !== null && !Array.isArray(result)) {\n return result as Record<string, unknown>;\n }\n return undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Attempts to repair incomplete JSON by closing open structures.\n * Returns the repaired string, or undefined if the text is too malformed.\n */\nfunction repairJson(text: string): string | undefined {\n let result = \"\";\n let i = 0;\n const len = text.length;\n\n // Track open delimiters for closing\n const stack: string[] = [];\n let inString = false;\n let escaped = false;\n // Track position of last structurally complete point\n let lastSafeEnd = 0;\n\n while (i < len) {\n const ch = text[i];\n\n if (escaped) {\n escaped = false;\n result += ch;\n i++;\n continue;\n }\n\n if (ch === \"\\\\\") {\n escaped = true;\n result += ch;\n i++;\n continue;\n }\n\n if (inString) {\n if (ch === '\"') {\n inString = false;\n result += ch;\n i++;\n lastSafeEnd = result.length;\n continue;\n }\n result += ch;\n i++;\n continue;\n }\n\n // Not in a string\n switch (ch) {\n case '\"':\n inString = true;\n result += ch;\n i++;\n break;\n case \"{\":\n stack.push(\"}\");\n result += ch;\n i++;\n break;\n case \"[\":\n stack.push(\"]\");\n result += ch;\n i++;\n break;\n case \"}\":\n if (stack.length > 0 && stack[stack.length - 1] === \"}\") {\n stack.pop();\n result += ch;\n i++;\n lastSafeEnd = result.length;\n } else {\n // Mismatched brace, truncate here\n return closeStack(result, stack);\n }\n break;\n case \"]\":\n if (stack.length > 0 && stack[stack.length - 1] === \"]\") {\n stack.pop();\n result += ch;\n i++;\n lastSafeEnd = result.length;\n } else {\n return closeStack(result, stack);\n }\n break;\n default:\n result += ch;\n i++;\n break;\n }\n }\n\n // Reached the end with unclosed structures\n if (inString) {\n // Close the unclosed string, then close the stack\n result += '\"';\n }\n\n if (stack.length === 0) {\n // Already valid\n return result;\n }\n\n return closeStack(cleanTrailing(result), stack);\n}\n\n/**\n * Removes trailing incomplete tokens that would prevent JSON parsing.\n * Strips trailing commas, colons, and incomplete key/value fragments.\n */\nfunction cleanTrailing(text: string): string {\n // Remove trailing whitespace\n let s = text.trimEnd();\n\n // Repeatedly strip trailing problematic characters\n let changed = true;\n while (changed) {\n changed = false;\n const trimmed = s.trimEnd();\n\n // Trailing comma\n if (trimmed.endsWith(\",\")) {\n s = trimmed.slice(0, -1);\n changed = true;\n continue;\n }\n\n // Trailing colon (incomplete key-value pair)\n if (trimmed.endsWith(\":\")) {\n // Remove the colon and the preceding key\n const withoutColon = trimmed.slice(0, -1).trimEnd();\n // Remove the key (should be a string ending with \")\n if (withoutColon.endsWith('\"')) {\n const keyStart = withoutColon.lastIndexOf('\"', withoutColon.length - 2);\n if (keyStart >= 0) {\n // Also remove any preceding comma\n let before = withoutColon.slice(0, keyStart).trimEnd();\n if (before.endsWith(\",\")) {\n before = before.slice(0, -1);\n }\n s = before;\n changed = true;\n continue;\n }\n }\n // Can't find the key, just remove the colon\n s = withoutColon;\n changed = true;\n continue;\n }\n\n // Trailing incomplete value after a colon (e.g., `\"key\": tru` or `\"key\": 12`)\n // Check if there's an incomplete bare token at the end\n const bareTokenMatch = trimmed.match(\n /,\\s*\"[^\"]*\"\\s*:\\s*(?:tru|fal|nul|true|false|null|[\\d.eE+-]+)$/\n );\n if (bareTokenMatch) {\n // Check if the bare value is complete\n const valueStr = trimmed.slice(trimmed.lastIndexOf(\":\") + 1).trim();\n try {\n JSON.parse(valueStr);\n // Value is complete, keep it\n } catch {\n // Value is incomplete, remove the whole key-value pair\n s = trimmed.slice(0, bareTokenMatch.index!).trimEnd();\n if (s.endsWith(\",\")) s = s.slice(0, -1);\n changed = true;\n continue;\n }\n }\n }\n\n return s;\n}\n\n/**\n * Closes all open delimiters in the stack.\n */\nfunction closeStack(text: string, stack: string[]): string {\n let result = text;\n for (let i = stack.length - 1; i >= 0; i--) {\n result += stack[i];\n }\n return result;\n}\n",
9
9
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { FromSchema, FromSchemaDefaultOptions, FromSchemaOptions } from \"../json-schema/FromSchema\";\nimport { JsonSchema } from \"../json-schema/JsonSchema\";\n\n/**\n * Supported typed array types\n * - Float16Array: 16-bit floating point (medium precision)\n * - Float32Array: Standard 32-bit floating point (most common)\n * - Float64Array: 64-bit floating point (high precision)\n * - Int8Array: 8-bit signed integer (binary quantization)\n * - Uint8Array: 8-bit unsigned integer (quantization)\n * - Int16Array: 16-bit signed integer (quantization)\n * - Uint16Array: 16-bit unsigned integer (quantization)\n */\nexport type TypedArray =\n | Float32Array\n | Float16Array\n | Float64Array\n | Int8Array\n | Uint8Array\n | Int16Array\n | Uint16Array;\n\nexport type TypedArrayString =\n | \"TypedArray\"\n | \"TypedArray:Float16Array\"\n | \"TypedArray:Float32Array\"\n | \"TypedArray:Float64Array\"\n | \"TypedArray:Int8Array\"\n | \"TypedArray:Uint8Array\"\n | \"TypedArray:Int16Array\"\n | \"TypedArray:Uint16Array\";\n\nexport function isTypedArray(value: unknown): value is TypedArray {\n return ArrayBuffer.isView(value) && !(value instanceof DataView);\n}\n\n// Type-only value for use in deserialize patterns\nconst TypedArrayType = null as any as TypedArray;\n\nconst TypedArraySchemaOptions = {\n ...FromSchemaDefaultOptions,\n deserialize: [\n {\n pattern: { type: \"array\", format: \"TypedArray:Float64Array\" },\n output: Float64Array,\n },\n {\n pattern: { type: \"array\", format: \"TypedArray:Float32Array\" },\n output: Float32Array,\n },\n {\n pattern: { type: \"array\", format: \"TypedArray:Float16Array\" },\n output: Float16Array,\n },\n {\n pattern: { type: \"array\", format: \"TypedArray:Int16Array\" },\n output: Int16Array,\n },\n {\n pattern: { type: \"array\", format: \"TypedArray:Int8Array\" },\n output: Int8Array,\n },\n {\n pattern: { type: \"array\", format: \"TypedArray:Uint8Array\" },\n output: Uint8Array,\n },\n {\n pattern: { type: \"array\", format: \"TypedArray:Uint16Array\" },\n output: Uint16Array,\n },\n {\n pattern: { type: \"array\", format: \"TypedArray\" },\n output: TypedArrayType,\n },\n ],\n} as const satisfies FromSchemaOptions;\n\nexport type TypedArraySchemaOptions = typeof TypedArraySchemaOptions;\n\nexport type VectorFromSchema<SCHEMA extends JsonSchema> = FromSchema<\n SCHEMA,\n TypedArraySchemaOptions\n>;\n\nexport const TypedArraySchema = (annotations: Record<string, unknown> = {}) => {\n return {\n type: \"array\",\n format: \"TypedArray\",\n title: \"Typed Array\",\n description: \"A typed array (Float32Array, Int8Array, etc.)\",\n ...annotations,\n } as const satisfies JsonSchema;\n};\n",
10
10
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { FromSchema } from \"../json-schema/FromSchema\";\nimport { JsonSchema } from \"../json-schema/JsonSchema\";\nimport { TypedArraySchema, TypedArraySchemaOptions } from \"./TypedArray\";\n\nexport const TensorType = {\n FLOAT16: \"float16\",\n FLOAT32: \"float32\",\n FLOAT64: \"float64\",\n INT8: \"int8\",\n UINT8: \"uint8\",\n INT16: \"int16\",\n UINT16: \"uint16\",\n} as const;\n\nexport type TensorType = (typeof TensorType)[keyof typeof TensorType];\n\n/**\n * Tensor schema for representing tensors as arrays of numbers\n * @param annotations - Additional annotations for the schema\n * @returns The tensor schema\n */\nexport const TensorSchema = (annotations: Record<string, unknown> = {}) =>\n ({\n type: \"object\",\n properties: {\n type: {\n type: \"string\",\n enum: Object.values(TensorType),\n title: \"Type\",\n description: \"The type of the tensor\",\n },\n data: TypedArraySchema({\n title: \"Data\",\n description: \"The data of the tensor\",\n }),\n shape: {\n type: \"array\",\n items: { type: \"number\" },\n title: \"Shape\",\n description: \"The shape of the tensor (dimensions)\",\n minItems: 1,\n default: [1],\n },\n normalized: {\n type: \"boolean\",\n title: \"Normalized\",\n description: \"Whether the tensor data is normalized\",\n default: false,\n },\n },\n required: [\"data\"],\n additionalProperties: false,\n ...annotations,\n }) as const satisfies JsonSchema;\n\nexport type Tensor = FromSchema<ReturnType<typeof TensorSchema>, TypedArraySchemaOptions>;\n",
11
11
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { TypedArray } from \"./TypedArray\";\n\n/** Width ranking: higher = wider type (more precision). Float64 > Float32 > Float16 > Int16 > Int8. */\nconst WIDTH_RANK: Record<string, number> = {\n Float64Array: 6,\n Float32Array: 5,\n Float16Array: 4,\n Int16Array: 3,\n Uint16Array: 3,\n Int8Array: 2,\n Uint8Array: 2,\n};\n\nfunction getWidthRank(arr: TypedArray): number {\n return WIDTH_RANK[arr.constructor.name] ?? 0;\n}\n\n/**\n * Returns the widest (highest-precision) TypedArray constructor among the given sources.\n * E.g. Int8Array × Float32Array → Float32Array.\n */\nfunction widestConstructor(sources: TypedArray[]): new (len: number) => TypedArray {\n let best = sources[0];\n for (let i = 1; i < sources.length; i++) {\n if (getWidthRank(sources[i]) > getWidthRank(best)) best = sources[i];\n }\n return best.constructor as new (len: number) => TypedArray;\n}\n\n/**\n * Creates a new TypedArray with the widest type among the given sources,\n * filled with the provided values. Use when combining multiple vectors\n * (e.g. a * b) so output precision matches the widest input.\n */\nexport function createTypedArrayFrom(sources: TypedArray[], values: number[]): TypedArray {\n const Ctor = widestConstructor(sources);\n const result = new Ctor(values.length);\n for (let i = 0; i < values.length; i++) result[i] = values[i];\n return result;\n}\n",
12
12
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { TypedArray } from \"./TypedArray\";\n\n/**\n * Calculates cosine similarity between two vectors\n * Returns a value between -1 and 1, where 1 means identical direction\n */\nexport function cosineSimilarity(a: TypedArray, b: TypedArray): number {\n if (a.length !== b.length) {\n throw new Error(\"Vectors must have the same length\");\n }\n let dotProduct = 0;\n let normA = 0;\n let normB = 0;\n for (let i = 0; i < a.length; i++) {\n dotProduct += a[i] * b[i];\n normA += a[i] * a[i];\n normB += b[i] * b[i];\n }\n const denominator = Math.sqrt(normA) * Math.sqrt(normB);\n if (denominator === 0) {\n return 0;\n }\n return dotProduct / denominator;\n}\n\n/**\n * Calculates Jaccard similarity between two vectors\n * Uses the formula: sum(min(a[i], b[i])) / sum(max(a[i], b[i]))\n * Returns a value between 0 and 1\n * For negative values, normalizes by finding the global min and shifting to non-negative range\n */\nexport function jaccardSimilarity(a: TypedArray, b: TypedArray): number {\n if (a.length !== b.length) {\n throw new Error(\"Vectors must have the same length\");\n }\n\n // Find global min across both vectors to handle negative values\n let globalMin = a[0];\n for (let i = 0; i < a.length; i++) {\n globalMin = Math.min(globalMin, a[i], b[i]);\n }\n\n // Shift values to non-negative range if needed\n const shift = globalMin < 0 ? -globalMin : 0;\n\n let minSum = 0;\n let maxSum = 0;\n\n for (let i = 0; i < a.length; i++) {\n const shiftedA = a[i] + shift;\n const shiftedB = b[i] + shift;\n minSum += Math.min(shiftedA, shiftedB);\n maxSum += Math.max(shiftedA, shiftedB);\n }\n\n return maxSum === 0 ? 0 : minSum / maxSum;\n}\n\n/**\n * Calculates Hamming distance between two vectors (normalized)\n * Counts the number of positions where vectors differ\n * Returns a value between 0 and 1 (0 = identical, 1 = completely different)\n */\nexport function hammingDistance(a: TypedArray, b: TypedArray): number {\n if (a.length !== b.length) {\n throw new Error(\"Vectors must have the same length\");\n }\n\n let differences = 0;\n\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n differences++;\n }\n }\n\n return differences / a.length;\n}\n\n/**\n * Calculates Hamming similarity (inverse of distance)\n * Returns a value between 0 and 1 (1 = identical, 0 = completely different)\n */\nexport function hammingSimilarity(a: TypedArray, b: TypedArray): number {\n return 1 - hammingDistance(a, b);\n}\n",
13
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { TypedArray } from \"./TypedArray\";\n\n/**\n * Calculates the magnitude (L2 norm) of a vector\n */\nexport function magnitude(arr: TypedArray | number[]): number {\n // @ts-ignore - Vector reduce works but TS doesn't recognize it\n return Math.sqrt(arr.reduce((acc, val) => acc + val * val, 0));\n}\n\n/**\n * Calculates the inner (dot) product of two vectors\n */\nexport function inner(arr1: TypedArray, arr2: TypedArray): number {\n if (arr1.length !== arr2.length) {\n throw new Error(\"Vectors must have the same length to compute inner product.\");\n }\n // @ts-ignore - Vector reduce works but TS doesn't recognize it\n return arr1.reduce((acc, val, i) => acc + val * arr2[i], 0);\n}\n\n/**\n * Normalizes a vector to unit length (L2 normalization)\n *\n * @param vector - The vector to normalize\n * @param throwOnZero - If true, throws an error for zero vectors. If false, returns the original vector.\n * @returns Normalized vector with the same type as input\n */\nexport function normalize(vector: TypedArray, throwOnZero = true, float32 = false): TypedArray {\n const mag = magnitude(vector);\n\n if (mag === 0) {\n if (throwOnZero) {\n throw new Error(\"Cannot normalize a zero vector.\");\n }\n return vector;\n }\n\n const normalized = Array.from(vector).map((val) => Number(val) / mag);\n\n if (float32) {\n return new Float32Array(normalized);\n }\n\n // Preserve the original Vector type\n if (vector instanceof Float64Array) {\n return new Float64Array(normalized);\n }\n if (vector instanceof Float16Array) {\n return new Float16Array(normalized);\n }\n if (vector instanceof Float32Array) {\n return new Float32Array(normalized);\n }\n if (vector instanceof Int8Array) {\n return new Int8Array(normalized);\n }\n if (vector instanceof Uint8Array) {\n return new Uint8Array(normalized);\n }\n if (vector instanceof Int16Array) {\n return new Int16Array(normalized);\n }\n if (vector instanceof Uint16Array) {\n return new Uint16Array(normalized);\n }\n // For other integer arrays, use Float32Array since normalization produces floats\n return new Float32Array(normalized);\n}\n\n/**\n * Normalizes an array of numbers to unit length (L2 normalization)\n *\n * @param values - The array of numbers to normalize\n * @param throwOnZero - If true, throws an error for zero vectors. If false, returns the original array.\n * @returns Normalized array of numbers\n */\nexport function normalizeNumberArray(values: number[], throwOnZero = false): number[] {\n const norm = magnitude(values);\n\n if (norm === 0) {\n if (throwOnZero) {\n throw new Error(\"Cannot normalize a zero vector.\");\n }\n return values;\n }\n\n return values.map((v) => v / norm);\n}\n"
13
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { TypedArray } from \"./TypedArray\";\n\n/**\n * Calculates the magnitude (L2 norm) of a vector\n */\nexport function magnitude(arr: TypedArray | number[]): number {\n // @ts-ignore - Vector reduce works but TS doesn't recognize it\n return Math.sqrt(arr.reduce((acc, val) => acc + val * val, 0));\n}\n\n/**\n * Calculates the inner (dot) product of two vectors\n */\nexport function inner(arr1: TypedArray, arr2: TypedArray): number {\n if (arr1.length !== arr2.length) {\n throw new Error(\"Vectors must have the same length to compute inner product.\");\n }\n // @ts-ignore - Vector reduce works but TS doesn't recognize it\n return arr1.reduce((acc, val, i) => acc + val * arr2[i], 0);\n}\n\n/**\n * Normalizes a vector to unit length (L2 normalization)\n *\n * @param vector - The vector to normalize\n * @param throwOnZero - If true, throws an error for zero vectors. If false, returns the original vector.\n * @param float32 - If true, always returns a Float32Array regardless of input type. When false (default),\n * the return type matches the input type. Note: for integer typed arrays (Int8Array, Uint8Array,\n * Int16Array, Uint16Array), normalized float values are truncated to integers when stored back in\n * the original type — use `float32=true` to preserve precision for integer inputs.\n * @returns Normalized vector. Float arrays preserve their type. Integer arrays preserve their type\n * (with truncation). Pass `float32=true` to always get a Float32Array.\n */\nexport function normalize(vector: TypedArray, throwOnZero = true, float32 = false): TypedArray {\n const mag = magnitude(vector);\n\n if (mag === 0) {\n if (throwOnZero) {\n throw new Error(\"Cannot normalize a zero vector.\");\n }\n return vector;\n }\n\n const normalized = Array.from(vector).map((val) => Number(val) / mag);\n\n if (float32) {\n return new Float32Array(normalized);\n }\n\n if (vector instanceof Float64Array) {\n return new Float64Array(normalized);\n }\n if (vector instanceof Float16Array) {\n return new Float16Array(normalized);\n }\n if (vector instanceof Float32Array) {\n return new Float32Array(normalized);\n }\n if (vector instanceof Int8Array) {\n return new Int8Array(normalized);\n }\n if (vector instanceof Uint8Array) {\n return new Uint8Array(normalized);\n }\n if (vector instanceof Int16Array) {\n return new Int16Array(normalized);\n }\n if (vector instanceof Uint16Array) {\n return new Uint16Array(normalized);\n }\n return new Float32Array(normalized);\n}\n\n/**\n * Normalizes an array of numbers to unit length (L2 normalization)\n *\n * @param values - The array of numbers to normalize\n * @param throwOnZero - If true, throws an error for zero vectors. If false, returns the original array.\n * @returns Normalized array of numbers\n */\nexport function normalizeNumberArray(values: number[], throwOnZero = false): number[] {\n const norm = magnitude(values);\n\n if (norm === 0) {\n if (throwOnZero) {\n throw new Error(\"Cannot normalize a zero vector.\");\n }\n return values;\n }\n\n return values.map((v) => v / norm);\n}\n"
14
14
  ],
15
- "mappings": ";A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17
17
  "names": []
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"objectOfArraysAsArrayOfObjects.d.ts","sourceRoot":"","sources":["../../src/utilities/objectOfArraysAsArrayOfObjects.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,cAAc,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC;CACtC,CAAC;AACF;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE;KACjF,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;CACvB,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,CAAC,CAAA;CAAE,CAgYzC"}
1
+ {"version":3,"file":"objectOfArraysAsArrayOfObjects.d.ts","sourceRoot":"","sources":["../../src/utilities/objectOfArraysAsArrayOfObjects.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,cAAc,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC;CACtC,CAAC;AACF;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE;KACjF,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;CACvB,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,CAAC,CAAA;CAAE,CA8XzC"}
@@ -17,7 +17,12 @@ export declare function inner(arr1: TypedArray, arr2: TypedArray): number;
17
17
  *
18
18
  * @param vector - The vector to normalize
19
19
  * @param throwOnZero - If true, throws an error for zero vectors. If false, returns the original vector.
20
- * @returns Normalized vector with the same type as input
20
+ * @param float32 - If true, always returns a Float32Array regardless of input type. When false (default),
21
+ * the return type matches the input type. Note: for integer typed arrays (Int8Array, Uint8Array,
22
+ * Int16Array, Uint16Array), normalized float values are truncated to integers when stored back in
23
+ * the original type — use `float32=true` to preserve precision for integer inputs.
24
+ * @returns Normalized vector. Float arrays preserve their type. Integer arrays preserve their type
25
+ * (with truncation). Pass `float32=true` to always get a Float32Array.
21
26
  */
22
27
  export declare function normalize(vector: TypedArray, throwOnZero?: boolean, float32?: boolean): TypedArray;
23
28
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"VectorUtils.d.ts","sourceRoot":"","sources":["../../src/vector/VectorUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,EAAE,GAAG,MAAM,CAG5D;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAMhE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,UAAO,EAAE,OAAO,UAAQ,GAAG,UAAU,CAwC7F;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,WAAW,UAAQ,GAAG,MAAM,EAAE,CAWpF"}
1
+ {"version":3,"file":"VectorUtils.d.ts","sourceRoot":"","sources":["../../src/vector/VectorUtils.ts"],"names":[],"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AAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI9B;IAEK,kBAAkB,CAAC,CAAC,EACxB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,GAAG,EAAE,EACX,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;KAC1E,GACA,OAAO,CAAC,CAAC,CAAC,CAiEZ;IAED;;;;;;;;;OASG;IACG,0BAA0B,CAAC,CAAC,EAChC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,GAAG,EAAE,GACV,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAoCxB;IAED;;;;;;;;;;;OAWG;IACI,wBAAwB,CAAC,CAAC,EAC/B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,GAAG,EAAE,EACX,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACjC,cAAc,CAAC,CAAC,CAAC,CAwGnB;CACF;AAED,eAAO,MAAM,cAAc,6CAAsD,CAAC"}
@@ -64,5 +64,11 @@ export declare class WorkerServerBase {
64
64
  * stream event (graceful fallback for providers that don't implement streaming).
65
65
  */
66
66
  handleStreamCall(id: string, functionName: string, [input, model]: [any, any]): Promise<void>;
67
+ /**
68
+ * Schedule cleanup of a completed request ID. Uses a 5-second delay to
69
+ * handle late-arriving abort messages, and caps the completed set size
70
+ * to prevent unbounded growth.
71
+ */
72
+ private scheduleCompletedRequestCleanup;
67
73
  }
68
74
  //# sourceMappingURL=WorkerServerBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WorkerServerBase.d.ts","sourceRoot":"","sources":["../../src/worker/WorkerServerBase.ts"],"names":[],"mapp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E;IAGK,aAAa,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,iBAcrD;IAEK,WAAW,CAAC,EAAE,EAAE,MAAM,iBAS3B;IAED;;;OAGG;IACG,kBAAkB,CACtB,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,MAAM,EACpB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,iBAaxC;IAEK,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,iBAyB5E;IAED;;;;;OAKG;IACG,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,iBA0ClF;IAED;;;;OAIG;IACH,OAAO,CAAC,+BAA+B;CAexC"}
@@ -318,12 +318,20 @@ class WorkerServerBase {
318
318
  const uniqueTransferables = [...new Set(transferables)];
319
319
  postMessage({ id, type: "complete", data: result }, uniqueTransferables);
320
320
  };
321
- postError = (id, errorMessage) => {
321
+ postError = (id, error) => {
322
322
  if (this.completedRequests.has(id)) {
323
323
  return;
324
324
  }
325
325
  this.completedRequests.add(id);
326
- postMessage({ id, type: "error", data: errorMessage });
326
+ let data;
327
+ if (typeof error === "string") {
328
+ data = { message: error, name: "Error" };
329
+ } else if (error instanceof Error) {
330
+ data = { message: error.message, name: error.name };
331
+ } else {
332
+ data = { message: String(error), name: "Error" };
333
+ }
334
+ postMessage({ id, type: "error", data });
327
335
  };
328
336
  postStreamChunk = (id, event) => {
329
337
  if (this.completedRequests.has(id)) {
@@ -369,6 +377,7 @@ class WorkerServerBase {
369
377
  controller?.abort();
370
378
  this.requestControllers.delete(id);
371
379
  this.postError(id, "Operation aborted");
380
+ this.scheduleCompletedRequestCleanup(id);
372
381
  }
373
382
  }
374
383
  async handleReactiveCall(id, functionName, [input, output, model]) {
@@ -381,7 +390,7 @@ class WorkerServerBase {
381
390
  const result = await fn(input, output, model);
382
391
  this.postResult(id, result);
383
392
  } catch (error) {
384
- this.postError(id, error.message);
393
+ this.postError(id, error);
385
394
  }
386
395
  }
387
396
  async handleCall(id, functionName, [input, model]) {
@@ -401,12 +410,10 @@ class WorkerServerBase {
401
410
  const result = await fn(input, model, postProgress, abortController.signal);
402
411
  this.postResult(id, result);
403
412
  } catch (error) {
404
- this.postError(id, error.message);
413
+ this.postError(id, error);
405
414
  } finally {
406
415
  this.requestControllers.delete(id);
407
- setTimeout(() => {
408
- this.completedRequests.delete(id);
409
- }, 1000);
416
+ this.scheduleCompletedRequestCleanup(id);
410
417
  }
411
418
  }
412
419
  async handleStreamCall(id, functionName, [input, model]) {
@@ -423,12 +430,10 @@ class WorkerServerBase {
423
430
  }
424
431
  this.postResult(id, undefined);
425
432
  } catch (error) {
426
- this.postError(id, error.message);
433
+ this.postError(id, error);
427
434
  } finally {
428
435
  this.requestControllers.delete(id);
429
- setTimeout(() => {
430
- this.completedRequests.delete(id);
431
- }, 1000);
436
+ this.scheduleCompletedRequestCleanup(id);
432
437
  }
433
438
  } else if (functionName in this.functions) {
434
439
  try {
@@ -440,17 +445,29 @@ class WorkerServerBase {
440
445
  this.postStreamChunk(id, { type: "finish", data: result });
441
446
  this.postResult(id, undefined);
442
447
  } catch (error) {
443
- this.postError(id, error.message);
448
+ this.postError(id, error);
444
449
  } finally {
445
450
  this.requestControllers.delete(id);
446
- setTimeout(() => {
447
- this.completedRequests.delete(id);
448
- }, 1000);
451
+ this.scheduleCompletedRequestCleanup(id);
449
452
  }
450
453
  } else {
451
454
  this.postError(id, `Function ${functionName} not found`);
452
455
  }
453
456
  }
457
+ scheduleCompletedRequestCleanup(id) {
458
+ setTimeout(() => {
459
+ this.completedRequests.delete(id);
460
+ }, 5000);
461
+ if (this.completedRequests.size > 1e4) {
462
+ const iter = this.completedRequests.values();
463
+ for (let i = 0;i < 5000; i++) {
464
+ const entry = iter.next();
465
+ if (entry.done)
466
+ break;
467
+ this.completedRequests.delete(entry.value);
468
+ }
469
+ }
470
+ }
454
471
  }
455
472
  // src/worker/WorkerManager.ts
456
473
  class WorkerManager {
@@ -482,10 +499,23 @@ class WorkerManager {
482
499
  worker.addEventListener("messageerror", (event) => {
483
500
  console.error("Worker message error:", event);
484
501
  });
485
- const readyPromise = new Promise((resolve) => {
502
+ const readyPromise = new Promise((resolve, reject) => {
503
+ const timeout = setTimeout(() => {
504
+ worker.removeEventListener("message", handleReady);
505
+ worker.removeEventListener("error", handleError);
506
+ reject(new Error(`Worker "${name}" did not become ready within 10s`));
507
+ }, 1e4);
508
+ const handleError = (event) => {
509
+ clearTimeout(timeout);
510
+ worker.removeEventListener("message", handleReady);
511
+ worker.removeEventListener("error", handleError);
512
+ reject(new Error(`Worker "${name}" initialization error: ${event.message ?? "unknown error"}`));
513
+ };
486
514
  const handleReady = (event) => {
487
515
  if (event.data?.type === "ready") {
516
+ clearTimeout(timeout);
488
517
  worker.removeEventListener("message", handleReady);
518
+ worker.removeEventListener("error", handleError);
489
519
  this.workerFunctions.set(name, new Set(event.data.functions ?? []));
490
520
  this.workerStreamFunctions.set(name, new Set(event.data.streamFunctions ?? []));
491
521
  this.workerReactiveFunctions.set(name, new Set(event.data.reactiveFunctions ?? []));
@@ -493,6 +523,7 @@ class WorkerManager {
493
523
  }
494
524
  };
495
525
  worker.addEventListener("message", handleReady);
526
+ worker.addEventListener("error", handleError);
496
527
  });
497
528
  this.readyWorkers.set(name, readyPromise);
498
529
  }
@@ -551,7 +582,10 @@ class WorkerManager {
551
582
  } else if (type === "error") {
552
583
  cleanup();
553
584
  getLogger().debug(`Worker ${workerName} function ${functionName} error.`, { data });
554
- reject(new Error(data));
585
+ const err = typeof data === "object" && data !== null ? Object.assign(new Error(data.message ?? String(data)), {
586
+ name: data.name ?? "Error"
587
+ }) : new Error(String(data));
588
+ reject(err);
555
589
  }
556
590
  };
557
591
  const handleAbort = () => {
@@ -891,4 +925,4 @@ export {
891
925
  ConsoleLogger
892
926
  };
893
927
 
894
- //# debugId=CBC09EE101BA59BA64756E2164756E21
928
+ //# debugId=D0D75E95947E4BDD64756E2164756E21