### createJSONTransformFunctionPrompt / createJSONTransformSchemaPrompt Source: https://context7.com/hexafield/conjure/llms.txt Utility functions to generate LLM prompts for creating data transformation logic. One function generates prompts for JavaScript functions, while the other generates prompts for JSONPath templates, based on input and output JSON Schemas. ```APIDOC ## `createJSONTransformFunctionPrompt(props)` / `createJSONTransformSchemaPrompt(props)` Prompt builders that convert a pair of JSON Schemas into an LLM prompt requesting either a JavaScript `transform` function or a JSONPath object-transform template. Used in the drag-and-drop file import flow to auto-generate tools between arbitrary schema pairs. ### Parameters - `props` (object): Configuration for prompt generation. - `inputSchema` (object): The JSON Schema for the input data. - `outputSchema` (object): The JSON Schema for the output data. - `additionalInstructions` (string, optional): Extra instructions to include in the prompt. ### Returns - A string containing the generated LLM prompt. ### Example (createJSONTransformFunctionPrompt) ```typescript import { createJSONTransformFunctionPrompt } from './src/tools/json-schema/createJSONTransformFunctionPrompt' const inputSchema = { type: 'object', properties: { firstName: { type: 'string' }, lastName: { type: 'string' }, birthYear: { type: 'integer' } }, required: ['firstName', 'lastName'] } const outputSchema = { type: 'object', properties: { fullName: { type: 'string' }, age: { type: 'integer' } }, required: ['fullName'] } // Prompt for a JS function transformer const fnPrompt = createJSONTransformFunctionPrompt({ inputSchema: inputSchema as any, outputSchema: outputSchema as any, additionalInstructions: 'Compute age from birthYear assuming current year is 2025.' }) // → "Please respond with valid javascript that implements a function to transform...\nAdditional Requirements:\n..." ``` ### Example (createJSONTransformSchemaPrompt) ```typescript import { createJSONTransformSchemaPrompt } from './src/tools/json-schema/createJSONTransformSchemaPrompt' const inputSchema = { type: 'object', properties: { firstName: { type: 'string' }, lastName: { type: 'string' }, birthYear: { type: 'integer' } }, required: ['firstName', 'lastName'] } const outputSchema = { type: 'object', properties: { fullName: { type: 'string' }, age: { type: 'integer' } }, required: ['fullName'] } // Prompt for a JSONPath template transformer const schemaPrompt = createJSONTransformSchemaPrompt({ inputSchema: inputSchema as any, outputSchema: outputSchema as any }) // → "Please respond with valid json that specifies a JSON Path template..." // Expected LLM output: { "fullName": "$.firstName", "age": "$.birthYear" } ``` ``` -------------------------------- ### P2P_API CRUD Operations with LocalBlobAPI Source: https://context7.com/hexafield/conjure/llms.txt Demonstrates basic CRUD operations using the P2P_API client set to LocalBlobAPI for local storage. Ensure the P2P_API.client is initialized and ready before use. ```typescript import { P2P_API } from './src/api/CRUD' import { LocalBlobAPI } from './src/api/local' import { getMutableState } from '@ir-engine/hyperflux' // --- Switch to local storage --- P2P_API.client = LocalBlobAPI getMutableState(P2P_API).ready.set(true) // Create an entry (source + predicate → target) await P2P_API.client.create({ source: 'sha256:abc123', predicate: 'conjure://schema', target: { type: 'object', properties: { name: { type: 'string' } } } }) // Check existence const exists = await P2P_API.client.has({ source: 'sha256:abc123', predicate: 'conjure://schema' }) console.log(exists) // → true // Retrieve const schema = await P2P_API.client.get({ source: 'sha256:abc123', predicate: 'conjure://schema' }) console.log(schema) // → { type: 'object', ... } // Find all sources for a predicate const sources = await P2P_API.client.find({ predicate: 'conjure://schema' }) console.log(sources) // → ['sha256:abc123', ...] // Delete await P2P_API.client.delete({ source: 'sha256:abc123', predicate: 'conjure://schema' }) ``` -------------------------------- ### Create and Execute Data Transformation Tools with ToolRegistry Source: https://context7.com/hexafield/conjure/llms.txt Utilize ToolRegistry to manage data transformation tools. Tools can be defined using JavaScript function strings (run in WebWorkers) or JSONPath templates. They are content-hashed and synced to a P2P backend. You can create tools, run them by hash, and remove them. ```typescript import { ToolRegistry } from './src/tools/registries/ToolRegistry' // Register a JS-function tool (runs sandboxed in a WebWorker) const toolHash = await ToolRegistry.create({ label: 'Normalize Name', description: 'Extracts first/last name from a full name string', input: { type: 'object', properties: { fullName: { type: 'string' } }, required: ['fullName'] } as any, output: { type: 'object', properties: { firstName: { type: 'string' }, lastName: { type: 'string' } }, required: ['firstName', 'lastName'] } as any, transformation: `function transform(input) { const parts = input.fullName.trim().split(' ') return { firstName: parts[0], lastName: parts.slice(1).join(' ') } }` }) console.log(toolHash) // → SHA-256 content hash // Register a JSONPath template tool (no WebWorker needed) const templateHash = await ToolRegistry.create({ label: 'Rename Keys', description: 'Remaps { id, name } → { userId, displayName }', input: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' } }, required: ['id', 'name'] } as any, output: { type: 'object', properties: { userId: { type: 'string' }, displayName: { type: 'string' } }, required: ['userId', 'displayName'] } as any, transformation: { userId: '$.id', displayName: '$.name' } }) // Run a tool by hash const result = await ToolRegistry.run(toolHash, { fullName: 'Alice Smith' }) console.log(result) // → { firstName: 'Alice', lastName: 'Smith' } // Remove a tool ToolRegistry.forget(toolHash) ``` -------------------------------- ### Registering Known Schemas with SchemaRegistry Source: https://context7.com/hexafield/conjure/llms.txt Initializes the SchemaRegistry with a set of predefined schemas. This function is typically called automatically on startup. The retrieved labels and hashes can be used to build pipelines. ```typescript import { registerKnownSchemas } from './src/tools/schemas/KnownSchemas' import { getState } from '@ir-engine/hyperflux' import { SchemaRegistry } from './src/tools/registries/SchemaRegistry' // Called automatically by SchemaRegistry.reactor on mount registerKnownSchemas() const schemas = getState(SchemaRegistry).schemas const labels = Object.values(schemas).map(s => s.label) console.log(labels) // → ['Murmurations - Organizations', 'Murmurations - People', 'Kumu - Limicon 2024', 'Kumu - Limicon 2025'] // Use a known schema hash to build a pipeline targeting Murmurations orgs const orgHash = Object.keys(schemas).find(h => schemas[h].label === 'Murmurations - Organizations') console.log(orgHash) // → deterministic SHA-256 hash ``` -------------------------------- ### useLLM / callLLM Source: https://context7.com/hexafield/conjure/llms.txt Provides a React hook (`useLLM`) and a standalone function (`callLLM`) for interacting with local or remote Large Language Models (LLMs). Supports various models and output formats, including structured JSON and JavaScript. ```APIDOC ## `useLLM(options)` / `callLLM(callOptions, options)` React hook (and standalone function) for calling local in-browser LLMs via WebLLM (MLC) or remote providers (OpenAI, Anthropic, Google, Ollama). Supports structured `json` and `javascript` output modes with automatic extraction. Used in Conjure to auto-generate data transformation functions from schema pairs. ### Parameters - `options` (object, for `useLLM`): Configuration options for the LLM hook. - `modelId` (string): The identifier for the LLM model to use. - `callOptions` (object, for `callLLM`): Options for the specific LLM call. - `prompt` (string): The prompt to send to the LLM. - `output` (string): The desired output format ('json' or 'javascript'). - `temperature` (number, optional): Controls randomness. Lower values make output more focused. - `maxTokens` (number, optional): The maximum number of tokens to generate. - `options` (object, for `callLLM`): Configuration options for the LLM, similar to `useLLM` options. - `modelId` (string): The identifier for the LLM model to use. - `ollamaUrl` (string, optional): The URL for an Ollama instance if using Ollama. ### Returns - `useLLM`: An object containing LLM state (`ready`, `progress`) and a `call` method. - `callLLM`: An object with `data` and `validationErrors` properties. ### Example (React Hook) ```typescript import { useLLM, callLLM, CODING_MODELS } from './src/tools/llm/useLLM' function MyComponent() { const llm = useLLM({ modelId: 'Hermes-3-Llama-3.1-8B-q4f32_1-MLC' }) const generate = async () => { if (!llm.ready) return const response = await llm.call({ prompt: 'Return JSON: { "greeting": "hello world" }', output: 'json', temperature: 0.3, maxTokens: 200 }) if (response.isValid) { console.log(response.data) // → { greeting: 'hello world' } } else { console.error(response.validationErrors) } } return } ``` ### Example (Standalone Function with Ollama) ```typescript const jsResult = await callLLM( { prompt: 'Write a JS function named transform that doubles every number in an array', output: 'javascript', temperature: 0.2 }, { modelId: 'gpt-oss:20b', ollamaUrl: 'http://localhost:11434/api/chat' } ) // Run: OLLAMA_ORIGINS='*' ollama serve console.log(jsResult?.data) // → "function transform(arr) { return arr.map(n => n * 2) }" ``` ``` -------------------------------- ### Run Pipeline with CSV Text Input Source: https://context7.com/hexafield/conjure/llms.txt Executes a pipeline that takes CSV formatted text as input. The `format` parameter must be set to 'csv'. ```typescript import { runPipelineSpec } from './src/tools/pipeline/runPipelineSpec' import type { PipelineSpec } from './src/tools/pipeline/model' // Pipeline with CSV text input const csvSpec: PipelineSpec = { stages: [ { type: 'input', params: { text: 'name,score\nAlice,95\nBob,87', format: 'csv' }, next: [] } ] } await runPipelineSpec(csvSpec) ``` -------------------------------- ### Build LLM Prompts for JSON Schema Transformation Source: https://context7.com/hexafield/conjure/llms.txt These prompt builders convert JSON Schemas into LLM prompts for generating either JavaScript transform functions or JSONPath object-transform templates. Useful for auto-generating tools between schema pairs. ```typescript import { createJSONTransformFunctionPrompt } from './src/tools/json-schema/createJSONTransformFunctionPrompt' import { createJSONTransformSchemaPrompt } from './src/tools/json-schema/createJSONTransformSchemaPrompt' const inputSchema = { type: 'object', properties: { firstName: { type: 'string' }, lastName: { type: 'string' }, birthYear: { type: 'integer' } }, required: ['firstName', 'lastName'] } const outputSchema = { type: 'object', properties: { fullName: { type: 'string' }, age: { type: 'integer' } }, required: ['fullName'] } // Prompt for a JS function transformer const fnPrompt = createJSONTransformFunctionPrompt({ inputSchema: inputSchema as any, outputSchema: outputSchema as any, additionalInstructions: 'Compute age from birthYear assuming current year is 2025.' }) // → "Please respond with valid javascript that implements a function to transform...\nAdditional Requirements:\n..." // Prompt for a JSONPath template transformer const schemaPrompt = createJSONTransformSchemaPrompt({ inputSchema: inputSchema as any, outputSchema: outputSchema as any }) // → "Please respond with valid json that specifies a JSON Path template..." // Expected LLM output: { "fullName": "$.firstName", "age": "$.birthYear" } ``` -------------------------------- ### P2P_API with AgentBlobAPI for Decentralized Storage Source: https://context7.com/hexafield/conjure/llms.txt Switches the P2P_API client to AgentBlobAPI for writing to the ADAM decentralized social graph. This enables automatic syncing of registry operations to the agent's public perspective links. ```typescript // --- Switch to ADAM decentralized backend --- import { AgentBlobAPI } from './src/ad4m/useADAM' P2P_API.client = AgentBlobAPI getMutableState(P2P_API).ready.set(true) // All subsequent registry operations (SchemaRegistry, ToolRegistry, PipelineRegistry) // now automatically sync to the agent's ADAM public perspective ``` -------------------------------- ### Register Output Target with TargetRegistry Source: https://context7.com/hexafield/conjure/llms.txt Registers a new output target (visualization or deserializer) with the `TargetRegistry`. The target is defined by a JSON schema and a `deserialize` callback. ```typescript import { TargetRegistry } from './src/tools/registries/TargetRegistry' import { getState } from '@ir-engine/hyperflux' // Register a target that renders people data into a force graph TargetRegistry.register({ label: 'Force Graph – People', value: { type: 'object', description: 'People network data', properties: { nodes: { type: 'array', items: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' } }, required: ['id'] } }, links: { type: 'array', items: { type: 'object', properties: { source: { type: 'string' }, target: { type: 'string' } }, required: ['source', 'target'] } } }, required: ['nodes', 'links'] } as any, deserialize: (data) => { console.log('Rendering force graph with', data.nodes.length, 'nodes') // trigger WebGL force graph render } }) ``` -------------------------------- ### Register and Manage JSON Schemas with SchemaRegistry Source: https://context7.com/hexafield/conjure/llms.txt Use SchemaRegistry to register, find, and manage JSON schemas. Schemas are keyed by their structural content hash and auto-sync to a P2P backend. You can manually register schemas, find schemas that validate given data, or auto-generate schemas from raw data. ```typescript import { SchemaRegistry } from './src/tools/registries/SchemaRegistry' import { getState } from '@ir-engine/hyperflux' // Register a schema manually const personSchema = { type: 'object', properties: { name: { type: 'string' }, age: { type: 'integer' } }, required: ['name'] } const hash = SchemaRegistry.register(personSchema as any, 'Person', 'A person object') console.log(hash) // → SHA-256 hash of the structural schema // Find an existing schema that validates given data const matchingHash = SchemaRegistry.findMatchingSchema({ name: 'Alice', age: 30 }) console.log(getState(SchemaRegistry).schemas[matchingHash!].label) // → 'Person' // Find existing or auto-generate a schema from raw data const result = SchemaRegistry.findOrGenerateMatchingSchema( [{ id: 1, score: 0.95 }, { id: 2, score: 0.8 }], 'Scores', 'Auto-generated from API response' ) console.log(result) // → SchemaType with hash, label, schema // Remove a schema (also deletes from P2P backend) SchemaRegistry.forget(hash) ``` -------------------------------- ### runPipelineSpec(spec) Source: https://context7.com/hexafield/conjure/llms.txt Executes a PipelineSpec by topologically evaluating stages in dependency order. Input stages parse inline data or CSV/JSON text. Tool stages call ToolRegistry.run. Output stages deserialize results to registered target visualizations. ```APIDOC ## `runPipelineSpec(spec)` Executes a `PipelineSpec` by topologically evaluating stages in dependency order. Input stages parse inline data or CSV/JSON text. Tool stages call `ToolRegistry.run`. Output stages deserialize results to registered target visualizations. ```typescript import { runPipelineSpec } from './src/tools/pipeline/runPipelineSpec' import type { PipelineSpec } from './src/tools/pipeline/model' // Pipeline with inline data const spec: PipelineSpec = { stages: [ { type: 'input', params: { data: [{ fullName: 'Alice Smith' }, { fullName: 'Bob Jones' }] }, next: [1] }, { type: 'tool', toolHash: '', next: [2] }, { type: 'output', params: { outputHash: '' }, next: [] } ] } await runPipelineSpec(spec) // Stage 0 data: [{ fullName: 'Alice Smith' }, ...] // Stage 1 data: [{ firstName: 'Alice', lastName: 'Smith' }, ...] // Stage 2: deserializes to target registry visualization // Pipeline with CSV text input const csvSpec: PipelineSpec = { stages: [ { type: 'input', params: { text: 'name,score\nAlice,95\nBob,87', format: 'csv' }, next: [] } ] } await runPipelineSpec(csvSpec) // → [{ name: 'Alice', score: '95' }, { name: 'Bob', score: '87' }] ``` ``` -------------------------------- ### hashFunctionSource(fnSource) / hashFunctionSourceSync(fnSource) Source: https://context7.com/hexafield/conjure/llms.txt Canonicalizes a JavaScript function source string via alpha-renaming and whitespace normalization, then hashes it with SHA-256. Two functions with identical logic but different variable names produce the same hash. ```APIDOC ## `hashFunctionSource(fnSource)` / `hashFunctionSourceSync(fnSource)` ### Description Canonicalizes a JavaScript function source string via alpha-renaming (parameters → `p0`, `p1`, …; local variables → `v0`, `v1`, …) and whitespace normalization, then hashes it with SHA-256. Two functions with identical logic but different variable names produce the same hash. ### Parameters - **fnSource** (string) - The JavaScript function source code as a string. ### Request Example ```javascript // Async (browser Web Crypto API) const hashA = await hashFunctionSource(`function transform(input) { return { name: input.fullName, age: input.years } }`) const hashB = await hashFunctionSource(`function transform(data) { return { name: data.fullName, age: data.years } }`) console.log(hashA === hashB) // → true (alpha-renamed to same canonical form) // Sync (Node.js, for tests) const hashSync = hashFunctionSourceSync(`function transform(input) { return { name: input.fullName, age: input.years } }`) console.log(hashSync) // → 'a1b2c3...' (SHA-256 hex) ``` ``` -------------------------------- ### Look up Registered Targets Source: https://context7.com/hexafield/conjure/llms.txt Retrieves all currently registered output targets from the `TargetRegistry`. The `getState` function from `@ir-engine/hyperflux` is used for this. ```typescript import { TargetRegistry } from './src/tools/registries/TargetRegistry' import { getState } from '@ir-engine/hyperflux' // Look up all registered targets const targets = getState(TargetRegistry) const [hash, target] = Object.entries(targets)[0] console.log(target.label) // → 'Force Graph – People' ``` -------------------------------- ### Interact with Local and Remote LLMs using useLLM and callLLM Source: https://context7.com/hexafield/conjure/llms.txt This hook and standalone function facilitate calls to local in-browser LLMs (WebLLM) or remote providers. Supports structured JSON and JavaScript output modes. For standalone function usage with Ollama, ensure OLLAMA_ORIGINS is set. ```typescript import { useLLM, callLLM, CODING_MODELS } from './src/tools/llm/useLLM' // --- React hook usage --- function MyComponent() { const llm = useLLM({ modelId: 'Hermes-3-Llama-3.1-8B-q4f32_1-MLC' }) const generate = async () => { if (!llm.ready) return const response = await llm.call({ prompt: 'Return JSON: { "greeting": "hello world" }', output: 'json', temperature: 0.3, maxTokens: 200 }) if (response.isValid) { console.log(response.data) // → { greeting: 'hello world' } } else { console.error(response.validationErrors) } } return } // --- Standalone function with Ollama --- const jsResult = await callLLM( { prompt: 'Write a JS function named transform that doubles every number in an array', output: 'javascript', temperature: 0.2 }, { modelId: 'gpt-oss:20b', ollamaUrl: 'http://localhost:11434/api/chat' } ) // Run: OLLAMA_ORIGINS='*' ollama serve console.log(jsResult?.data) // → "function transform(arr) { return arr.map(n => n * 2) }" ``` -------------------------------- ### ToolRegistry Operations Source: https://context7.com/hexafield/conjure/llms.txt Manage data-transformation tools. Tools can be JavaScript functions or JSONPath templates and are content-hashed. ```APIDOC ## ToolRegistry A global registry for data-transformation tools. Each tool is defined by input/output JSON Schemas and a transformation (either a JavaScript function string run in a WebWorker, or a JSONPath object-transform template). Tools are content-hashed and synced to the P2P backend. ### Create JS Function Tool Registers a JavaScript function as a tool, which runs sandboxed in a WebWorker. ```typescript import { ToolRegistry } from './src/tools/registries/ToolRegistry' const toolHash = await ToolRegistry.create({ label: 'Normalize Name', description: 'Extracts first/last name from a full name string', input: { type: 'object', properties: { fullName: { type: 'string' } }, required: ['fullName'] } as any, output: { type: 'object', properties: { firstName: { type: 'string' }, lastName: { type: 'string' } }, required: ['firstName', 'lastName'] } as any, transformation: `function transform(input) { const parts = input.fullName.trim().split(' ') return { firstName: parts[0], lastName: parts.slice(1).join(' ') } }` }) console.log(toolHash) // → SHA-256 content hash ``` ### Create JSONPath Template Tool Registers a JSONPath template as a tool. ```typescript import { ToolRegistry } from './src/tools/registries/ToolRegistry' const templateHash = await ToolRegistry.create({ label: 'Rename Keys', description: 'Remaps { id, name } → { userId, displayName }', input: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' } }, required: ['id', 'name'] } as any, output: { type: 'object', properties: { userId: { type: 'string' }, displayName: { type: 'string' } }, required: ['userId', 'displayName'] } as any, transformation: { userId: '$.id', displayName: '$.name' } }) ``` ### Run Tool Executes a registered tool using its hash. ```typescript import { ToolRegistry } from './src/tools/registries/ToolRegistry' const result = await ToolRegistry.run(toolHash, { fullName: 'Alice Smith' }) console.log(result) // → { firstName: 'Alice', lastName: 'Smith' } ``` ### Forget Tool Removes a tool from the registry. ```typescript import { ToolRegistry } from './src/tools/registries/ToolRegistry' ToolRegistry.forget(toolHash) ``` ``` -------------------------------- ### Manually Run Target Deserializer Source: https://context7.com/hexafield/conjure/llms.txt Manually invokes the `deserialize` callback for a specific registered target using its hash and provided data. ```typescript import { TargetRegistry } from './src/tools/registries/TargetRegistry' // Manually run a target's deserializer TargetRegistry.run(hash, { nodes: [{ id: '1', name: 'Alice' }], links: [] }) ``` -------------------------------- ### TargetRegistry Source: https://context7.com/hexafield/conjure/llms.txt Registers output targets (visualizations or deserializers) with a JSON Schema. The `deserialize` callback is called when a pipeline's output stage receives data, passing it to the appropriate visualization. ```APIDOC ## `TargetRegistry` Registers output targets (visualizations or deserializers) with a JSON Schema. The `deserialize` callback is called when a pipeline's output stage receives data, passing it to the appropriate visualization. ```typescript import { TargetRegistry } from './src/tools/registries/TargetRegistry' import { getState } from '@ir-engine/hyperflux' // Register a target that renders people data into a force graph TargetRegistry.register({ label: 'Force Graph – People', value: { type: 'object', description: 'People network data', properties: { nodes: { type: 'array', items: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' } }, required: ['id'] } }, links: { type: 'array', items: { type: 'object', properties: { source: { type: 'string' }, target: { type: 'string' } }, required: ['source', 'target'] } } }, required: ['nodes', 'links'] } as any, deserialize: (data) => { console.log('Rendering force graph with', data.nodes.length, 'nodes') // trigger WebGL force graph render } }) // Look up all registered targets const targets = getState(TargetRegistry) const [hash, target] = Object.entries(targets)[0] console.log(target.label) // → 'Force Graph – People' // Manually run a target's deserializer TargetRegistry.run(hash, { nodes: [{ id: '1', name: 'Alice' }], links: [] }) ``` ``` -------------------------------- ### createDynamicWebworker Source: https://context7.com/hexafield/conjure/llms.txt Creates an isolated WebWorker from a raw JavaScript function string. The worker can then be used to execute the function with provided messages and return results. It also supports termination and cleanup of the worker's resources. ```APIDOC ## `createDynamicWebworker(functionString)` Creates an isolated WebWorker from a raw JavaScript function string. The worker is initialized with the function, then accepts messages to call it and returns results. Errors are propagated back as rejections, and the worker can be terminated and its object URL revoked. ### Parameters - `functionString` (string): A string containing the JavaScript code for the function to be executed in the WebWorker. ### Returns - An object with a `call` method to send messages to the worker and a `terminate` method to clean up. ### Example ```typescript import { createDynamicWebworker } from './src/tools/utils/createDynamicWebworker' const functionSource = ` function transform(input) { return input.items.map(item => ({ id: item.id, label: item.name.toUpperCase(), value: item.count * 2 })) } ` const worker = await createDynamicWebworker(functionSource) try { const result = await worker.call({ items: [ { id: 'a', name: 'alpha', count: 3 }, { id: 'b', name: 'beta', count: 7 } ] }) console.log(result) // → [{ id: 'a', label: 'ALPHA', value: 6 }, { id: 'b', label: 'BETA', value: 14 }] } catch (err) { console.error('Transform failed:', err) } finally { worker.terminate() // Frees the blob URL and terminates the Worker } ``` ``` -------------------------------- ### Run Pipeline with Inline Data Source: https://context7.com/hexafield/conjure/llms.txt Executes a pipeline defined with inline data. Ensure the `PipelineSpec` is correctly structured with input, tool, and output stages. ```typescript import { runPipelineSpec } from './src/tools/pipeline/runPipelineSpec' import type { PipelineSpec } from './src/tools/pipeline/model' // Pipeline with inline data const spec: PipelineSpec = { stages: [ { type: 'input', params: { data: [{ fullName: 'Alice Smith' }, { fullName: 'Bob Jones' }] }, next: [1] }, { type: 'tool', toolHash: '', next: [2] }, { type: 'output', params: { outputHash: '' }, next: [] } ] } await runPipelineSpec(spec) ``` -------------------------------- ### Register and Manage DAG-based Pipelines with PipelineRegistry Source: https://context7.com/hexafield/conjure/llms.txt Use PipelineRegistry to store and manage named DAG-based pipelines. Pipelines are defined as `PipelineSpec` (an ordered array of stages), content-hashed, and synced to the P2P backend. This registry supports legacy graph-format migration. ```typescript import { PipelineRegistry } from './src/tools/registries/PipelineRegistry' import { getState } from '@ir-engine/hyperflux' import type { PipelineSpec } from './src/tools/pipeline/model' const spec: PipelineSpec = { stages: [ { type: 'input', params: { url: 'https://api.example.com/people.json', format: 'json' }, next: [1] }, { type: 'tool', toolHash: '', next: [2] }, { type: 'output', params: { outputHash: '' }, next: [] } ] } const hash = PipelineRegistry.register({ label: 'People Normalizer', description: 'Fetches people data and normalizes names', graph: spec }) // Read all pipelines const { pipelines } = getState(PipelineRegistry) console.log(Object.values(pipelines).map(p => p.label)) // → ['People Normalizer'] // Remove pipeline (also deletes from P2P backend) PipelineRegistry.forget(hash) ``` -------------------------------- ### Create Dynamic WebWorker from Function String Source: https://context7.com/hexafield/conjure/llms.txt Use this to create an isolated WebWorker from a JavaScript function string. The worker accepts messages to call the function and returns results. Ensure to terminate the worker when done to free resources. ```typescript import { createDynamicWebworker } from './src/tools/utils/createDynamicWebworker' const functionSource = ` function transform(input) { return input.items.map(item => ({ id: item.id, label: item.name.toUpperCase(), value: item.count * 2 })) } ` const worker = await createDynamicWebworker(functionSource) try { const result = await worker.call({ items: [ { id: 'a', name: 'alpha', count: 3 }, { id: 'b', name: 'beta', count: 7 } ] }) console.log(result) // → [{ id: 'a', label: 'ALPHA', value: 6 }, { id: 'b', label: 'BETA', value: 14 }] } catch (err) { console.error('Transform failed:', err) } finally { worker.terminate() // Frees the blob URL and terminates the Worker } ``` -------------------------------- ### SchemaRegistry Operations Source: https://context7.com/hexafield/conjure/llms.txt Manage JSON schemas within the HyperFlux state. Allows registration, lookup, and inference of schemas. ```APIDOC ## SchemaRegistry A global HyperFlux state registry for JSON Schemas, keyed by structural content hash. Schemas auto-sync to the selected P2P backend. Provides schema registration, lookup, and inference from live data. ### Register Schema Manually registers a JSON schema. ```typescript import { SchemaRegistry } from './src/tools/registries/SchemaRegistry' const personSchema = { type: 'object', properties: { name: { type: 'string' }, age: { type: 'integer' } }, required: ['name'] } const hash = SchemaRegistry.register(personSchema as any, 'Person', 'A person object') console.log(hash) // → SHA-256 hash of the structural schema ``` ### Find Matching Schema Finds an existing schema that validates the given data. ```typescript import { SchemaRegistry } from './src/tools/registries/SchemaRegistry' const matchingHash = SchemaRegistry.findMatchingSchema({ name: 'Alice', age: 30 }) console.log(getState(SchemaRegistry).schemas[matchingHash!].label) // → 'Person' ``` ### Find or Generate Schema Finds an existing schema or auto-generates one from raw data. ```typescript import { SchemaRegistry } from './src/tools/registries/SchemaRegistry' const result = SchemaRegistry.findOrGenerateMatchingSchema( [{ id: 1, score: 0.95 }, { id: 2, score: 0.8 }], 'Scores', 'Auto-generated from API response' ) console.log(result) // → SchemaType with hash, label, schema ``` ### Forget Schema Removes a schema from the registry and the P2P backend. ```typescript import { SchemaRegistry } from './src/tools/registries/SchemaRegistry' SchemaRegistry.forget(hash) ``` ``` -------------------------------- ### PipelineRegistry Operations Source: https://context7.com/hexafield/conjure/llms.txt Manage DAG-based data processing pipelines. Pipelines are stored by name, content-hashed, and synced to the P2P backend. ```APIDOC ## PipelineRegistry Stores named DAG-based pipelines (as `PipelineSpec` — an ordered array of stages). Pipelines are content-hashed and synced to the P2P backend. Supports legacy graph-format migration. ### Register Pipeline Registers a new pipeline with a label, description, and graph specification. ```typescript import { PipelineRegistry } from './src/tools/registries/PipelineRegistry' import type { PipelineSpec } from './src/tools/pipeline/model' const spec: PipelineSpec = { stages: [ { type: 'input', params: { url: 'https://api.example.com/people.json', format: 'json' }, next: [1] }, { type: 'tool', toolHash: '', next: [2] }, { type: 'output', params: { outputHash: '' }, next: [] } ] } const hash = PipelineRegistry.register({ label: 'People Normalizer', description: 'Fetches people data and normalizes names', graph: spec }) ``` ### Read Pipelines Retrieves all registered pipelines from the HyperFlux state. ```typescript import { PipelineRegistry } from './src/tools/registries/PipelineRegistry' import { getState } from '@ir-engine/hyperflux' const { pipelines } = getState(PipelineRegistry) console.log(Object.values(pipelines).map(p => p.label)) // → ['People Normalizer'] ``` ### Forget Pipeline Removes a pipeline from the registry and the P2P backend. ```typescript import { PipelineRegistry } from './src/tools/registries/PipelineRegistry' PipelineRegistry.forget(hash) ``` ``` -------------------------------- ### contentHash(obj) / contentHashJSONSchema(schema) Source: https://context7.com/hexafield/conjure/llms.txt Produces a deterministic SHA-256 hex string for any JSON-serializable object using RFC8785 canonicalization. `contentHashJSONSchema` additionally strips all annotation/metadata keys before hashing. ```APIDOC ## `contentHash(obj)` / `contentHashJSONSchema(schema)` ### Description Produces a deterministic SHA-256 hex string for any JSON-serializable object using RFC8785 canonicalization. `contentHashJSONSchema` additionally strips all annotation/metadata keys (title, description, $id, etc.) before hashing so that two semantically identical schemas always yield the same hash regardless of metadata differences. ### Parameters - **obj** (object) - The JSON-serializable object to hash. - **schema** (object) - The JSON schema object to hash, with metadata keys stripped. ### Request Example ```javascript // Hash any JSON object const objHash = contentHash({ foo: 'bar', baz: 42 }) // → 'a3f1c...' (SHA-256 hex, RFC8785-canonicalized) // Structural hash ignoring metadata const schema1 = { type: 'object', title: 'Person', properties: { name: { type: 'string' } }, required: ['name'] } const schema2 = { type: 'object', title: 'User', description: 'A user record', properties: { name: { type: 'string' } }, required: ['name'] } const hash1 = contentHashJSONSchema(schema1) const hash2 = contentHashJSONSchema(schema2) console.log(hash1 === hash2) // → true (titles/descriptions stripped before hashing) // Use hashes as stable schema identifiers console.log(hash1) // → 'e9b3a...' (same across renames, description edits) ``` ``` -------------------------------- ### graphToPipeline(nodes, edges) / pipelineToGraph(pipeline) Source: https://context7.com/hexafield/conjure/llms.txt Converts between ReactFlow graph representation (nodes + edges) and `PipelineSpec` (linear stages array). `graphToPipeline` is used to migrate legacy saved graphs; `pipelineToGraph` renders a pipeline as an editable visual DAG. ```APIDOC ## `graphToPipeline(nodes, edges)` / `pipelineToGraph(pipeline)` Converts between ReactFlow graph representation (nodes + edges) and `PipelineSpec` (linear stages array). `graphToPipeline` is used to migrate legacy saved graphs; `pipelineToGraph` renders a pipeline as an editable visual DAG. ```typescript import { graphToPipeline, pipelineToGraph } from './src/tools/pipeline/graphConvert' import type { Node, Edge } from 'reactflow' // ReactFlow → PipelineSpec const nodes: Node[] = [ { id: 'n1', data: { type: 'input.url', config: { url: 'https://api.example.com/data.json' } }, position: { x: 0, y: 0 } } as any, { id: 'n2', data: { type: 'xform.js', config: { toolHash: 'abc123' } }, position: { x: 260, y: 0 } } as any, { id: 'n3', data: { type: 'viz.table', config: { outputHash: 'def456' } }, position: { x: 520, y: 0 } } as any ] const edges: Edge[] = [ { id: 'e1', source: 'n1', target: 'n2' } as any, { id: 'e2', source: 'n2', target: 'n3' } as any ] const spec = graphToPipeline(nodes, edges) // → { stages: [ { type: 'input', params: { url: '...' }, next: [1] }, { type: 'tool', toolHash: 'abc123', next: [2] }, { type: 'output', params: { outputHash: 'def456' }, next: [] } ] } // PipelineSpec → ReactFlow graph const { nodes: rfNodes, edges: rfEdges } = pipelineToGraph(spec) // → nodes with auto-computed positions, edges connecting them ``` ``` -------------------------------- ### generateJsonSchema(rawData) Source: https://context7.com/hexafield/conjure/llms.txt Infers a JSON Schema from any raw JavaScript value or array of values. It handles mixed types with `anyOf`, detects RFC3339 date-time strings, and computes `required` from consistently-present object keys. ```APIDOC ## `generateJsonSchema(rawData)` ### Description Infers a JSON Schema from any raw JavaScript value or array of values, handling mixed types with `anyOf`, detecting RFC3339 date-time strings, and computing `required` from consistently-present object keys. ### Parameters - **rawData** (any) - The JavaScript value or array of values to infer the schema from. ### Request Example ```javascript // Single object const schema = generateJsonSchema({ name: 'Alice', age: 30, joined: '2024-01-15T10:00:00Z' }) // → { type: 'object', properties: { name: { type: 'string' }, age: { type: 'integer' }, joined: { type: 'string', format: 'date-time' } }, required: ['name', 'age', 'joined'] } // Array of heterogeneous objects (age sometimes missing → not required) const arraySchema = generateJsonSchema([ { id: 1, role: 'admin' }, { id: 2, role: 'user', tags: ['beta'] } ]) // → { type: 'array', items: { type: 'object', properties: { id: { type: 'integer' }, role: { type: 'string' }, tags: { type: 'array', items: { type: 'string' } } }, required: ['id', 'role'] } } // Primitive array const numSchema = generateJsonSchema([1, 2, 3.5]) // → { type: 'array', items: { type: 'number' } } ``` ``` -------------------------------- ### Content Hashing for JSON Objects and Schemas Source: https://context7.com/hexafield/conjure/llms.txt Produces deterministic SHA-256 hex strings for JSON-serializable objects using RFC8785 canonicalization. `contentHashJSONSchema` strips metadata for structural hashing. ```typescript import { contentHash, contentHashJSONSchema } from './src/tools/json-schema/contentHash' // Hash any JSON object const objHash = contentHash({ foo: 'bar', baz: 42 }) // → 'a3f1c...' (SHA-256 hex, RFC8785-canonicalized) // Structural hash ignoring metadata const schema1 = { type: 'object', title: 'Person', properties: { name: { type: 'string' } }, required: ['name'] } const schema2 = { type: 'object', title: 'User', description: 'A user record', properties: { name: { type: 'string' } }, required: ['name'] } const hash1 = contentHashJSONSchema(schema1 as any) const hash2 = contentHashJSONSchema(schema2 as any) console.log(hash1 === hash2) // → true (titles/descriptions stripped before hashing) // Use hashes as stable schema identifiers console.log(hash1) // → 'e9b3a...' (same across renames, description edits) ``` -------------------------------- ### Convert ReactFlow Graph to PipelineSpec Source: https://context7.com/hexafield/conjure/llms.txt Converts a ReactFlow graph representation (nodes and edges) into a `PipelineSpec` object. This is useful for migrating legacy saved graphs. ```typescript import { graphToPipeline, pipelineToGraph } from './src/tools/pipeline/graphConvert' import type { Node, Edge } from 'reactflow' // ReactFlow → PipelineSpec const nodes: Node[] = [ { id: 'n1', data: { type: 'input.url', config: { url: 'https://api.example.com/data.json' } }, position: { x: 0, y: 0 } } as any, { id: 'n2', data: { type: 'xform.js', config: { toolHash: 'abc123' } }, position: { x: 260, y: 0 } } as any, { id: 'n3', data: { type: 'viz.table', config: { outputHash: 'def456' } }, position: { x: 520, y: 0 } } as any ] const edges: Edge[] = [ { id: 'e1', source: 'n1', target: 'n2' } as any, { id: 'e2', source: 'n2', target: 'n3' } as any ] const spec = graphToPipeline(nodes, edges) ``` -------------------------------- ### Hashing JavaScript Function Sources Source: https://context7.com/hexafield/conjure/llms.txt Canonicalizes JavaScript function source strings by alpha-renaming parameters and local variables, then hashing with SHA-256. Useful for identifying functions with identical logic but different naming. ```typescript import { hashFunctionSource, hashFunctionSourceSync } from './src/tools/utils/hashFunction' const fnA = `function transform(input) { return { name: input.fullName, age: input.years } }` const fnB = `function transform(data) { return { name: data.fullName, age: data.years } }` // Async (browser Web Crypto API) const hashA = await hashFunctionSource(fnA) const hashB = await hashFunctionSource(fnB) console.log(hashA === hashB) // → true (alpha-renamed to same canonical form) // Sync (Node.js, for tests) const hashSync = hashFunctionSourceSync(fnA) console.log(hashSync) // → 'a1b2c3...' ```