@workglow/util 0.0.120 → 0.0.122
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.
- package/dist/browser.js +337 -1250
- package/dist/browser.js.map +6 -11
- package/dist/bun.js +334 -1260
- package/dist/bun.js.map +6 -11
- package/dist/common.d.ts +0 -5
- package/dist/common.d.ts.map +1 -1
- package/dist/credentials/ChainedCredentialStore.d.ts.map +1 -1
- package/dist/credentials/EnvCredentialStore.d.ts.map +1 -1
- package/dist/credentials/InMemoryCredentialStore.d.ts.map +1 -1
- package/dist/di/Container.d.ts.map +1 -1
- package/dist/di/ServiceRegistry.d.ts.map +1 -1
- package/dist/events/EventEmitter.d.ts.map +1 -1
- package/dist/graph/directedAcyclicGraph.d.ts.map +1 -1
- package/dist/graph/directedGraph.d.ts.map +1 -1
- package/dist/graph/errors.d.ts.map +1 -1
- package/dist/graph/graph.d.ts.map +1 -1
- package/dist/logging/ConsoleLogger.d.ts.map +1 -1
- package/dist/logging/NullLogger.d.ts.map +1 -1
- package/dist/node.js +335 -1260
- package/dist/node.js.map +6 -11
- package/dist/telemetry/ConsoleTelemetryProvider.d.ts.map +1 -1
- package/dist/telemetry/NoopTelemetryProvider.d.ts.map +1 -1
- package/dist/telemetry/OTelTelemetryProvider.d.ts.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/BaseError.d.ts.map +1 -1
- package/dist/vector/Tensor.d.ts +1 -1
- package/dist/vector/Tensor.d.ts.map +1 -1
- package/dist/vector/TypedArray.d.ts +4 -4
- package/dist/vector/TypedArray.d.ts.map +1 -1
- package/dist/worker/Worker.browser.d.ts +6 -1
- package/dist/worker/Worker.browser.d.ts.map +1 -1
- package/dist/worker/Worker.bun.d.ts +6 -1
- package/dist/worker/Worker.bun.d.ts.map +1 -1
- package/dist/worker/Worker.node.d.ts +6 -1
- package/dist/worker/Worker.node.d.ts.map +1 -1
- package/dist/worker/WorkerManager.d.ts +7 -1
- package/dist/worker/WorkerManager.d.ts.map +1 -1
- package/dist/worker/{WorkerServer.d.ts → WorkerServerBase.d.ts} +5 -4
- package/dist/worker/WorkerServerBase.d.ts.map +1 -0
- package/dist/worker-browser.js +894 -0
- package/dist/worker-browser.js.map +19 -0
- package/dist/worker-bun.js +895 -0
- package/dist/worker-bun.js.map +19 -0
- package/dist/worker-entry.d.ts +25 -0
- package/dist/worker-entry.d.ts.map +1 -0
- package/dist/worker-node.js +914 -0
- package/dist/worker-node.js.map +19 -0
- package/package.json +23 -20
- package/dist/json-schema/SchemaUtils.d.ts +0 -58
- package/dist/json-schema/SchemaUtils.d.ts.map +0 -1
- package/dist/json-schema/SchemaValidation.d.ts +0 -8
- package/dist/json-schema/SchemaValidation.d.ts.map +0 -1
- package/dist/mcp/McpAuthProvider.d.ts +0 -70
- package/dist/mcp/McpAuthProvider.d.ts.map +0 -1
- package/dist/mcp/McpAuthTypes.d.ts +0 -218
- package/dist/mcp/McpAuthTypes.d.ts.map +0 -1
- package/dist/mcp/McpClientUtil.browser.d.ts +0 -198
- package/dist/mcp/McpClientUtil.browser.d.ts.map +0 -1
- package/dist/mcp/McpClientUtil.node.d.ts +0 -222
- package/dist/mcp/McpClientUtil.node.d.ts.map +0 -1
- package/dist/worker/WorkerServer.d.ts.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/di/Container.ts", "../src/di/ServiceRegistry.ts", "../src/di/InputResolverRegistry.ts", "../src/logging/ConsoleLogger.ts", "../src/logging/NullLogger.ts", "../src/logging/LoggerRegistry.ts", "../src/worker/WorkerServerBase.ts", "../src/worker/WorkerManager.ts", "../src/json-schema/parsePartialJson.ts", "../src/worker/Worker.node.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Simple dependency injection container for managing service instances and dependencies\n */\nexport class Container {\n private services: Map<string, any> = new Map();\n private factories: Map<string, () => any> = new Map();\n private singletons: Set<string> = new Set();\n\n /**\n * Register a service factory\n * @param token The identifier token for the service\n * @param factory A factory function that creates the service\n * @param singleton Whether the service should be a singleton (created once)\n */\n register<T>(token: string, factory: () => T, singleton = true): void {\n this.factories.set(token, factory);\n if (singleton) {\n this.singletons.add(token);\n }\n }\n\n /**\n * Register an instance as a service\n * @param token The identifier token for the service\n * @param instance The instance to register\n */\n registerInstance<T>(token: string, instance: T): void {\n this.services.set(token, instance);\n this.singletons.add(token);\n }\n\n /**\n * Get a service by its token\n * @param token The identifier token for the service\n * @returns The service instance\n */\n get<T>(token: string): T {\n // Return existing instance if available\n if (this.services.has(token)) {\n return this.services.get(token) as T;\n }\n\n // Create new instance\n const factory = this.factories.get(token);\n if (!factory) {\n throw new Error(`Service not registered: ${String(token)}`);\n }\n\n const instance = factory();\n\n // Store singleton instances\n if (this.singletons.has(token)) {\n this.services.set(token, instance);\n }\n\n return instance as T;\n }\n\n /**\n * Check if a service is registered\n * @param token The identifier token for the service\n * @returns True if the service is registered\n */\n has(token: string): boolean {\n return this.services.has(token) || this.factories.has(token);\n }\n\n /**\n * Remove a service registration\n * @param token The identifier token for the service\n */\n remove(token: string): void {\n this.services.delete(token);\n this.factories.delete(token);\n this.singletons.delete(token);\n }\n\n /**\n * Create a child container that inherits registrations from the parent\n * @returns A new child container\n */\n createChildContainer(): Container {\n const child = new Container();\n\n // Copy all registrations to the child\n this.factories.forEach((factory, token) => {\n child.factories.set(token, factory);\n if (this.singletons.has(token)) {\n child.singletons.add(token);\n }\n });\n\n // Copy all singleton instances to the child\n this.services.forEach((service, token) => {\n if (this.singletons.has(token)) {\n child.services.set(token, service);\n child.singletons.add(token);\n }\n });\n\n return child;\n }\n}\n\n/**\n * Global container instance\n */\nexport const globalContainer = new Container();\n",
|
|
6
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Container, globalContainer } from \"./Container\";\n\n/**\n * Service token type for type-safe dependency injection\n */\nexport interface ServiceToken<T> {\n readonly _type: T;\n readonly id: string;\n}\n\n/**\n * Create a typed service token\n * @param id Unique identifier for the service\n * @returns A typed service token\n */\nexport function createServiceToken<T>(id: string): ServiceToken<T> {\n return { id, _type: null as any };\n}\n\n/**\n * Service registry for managing and accessing services\n */\nexport class ServiceRegistry {\n public container: Container;\n\n /**\n * Create a new service registry\n * @param container Optional container to use (defaults to global container)\n */\n constructor(container: Container = globalContainer) {\n this.container = container;\n }\n\n /**\n * Register a service factory\n * @param token Service token\n * @param factory Factory function to create the service\n * @param singleton Whether the service should be a singleton\n */\n register<T>(token: ServiceToken<T>, factory: () => T, singleton = true): void {\n this.container.register(token.id, factory, singleton);\n }\n\n /**\n * Register a service instance\n * @param token Service token\n * @param instance Service instance to register\n */\n registerInstance<T>(token: ServiceToken<T>, instance: T): void {\n this.container.registerInstance(token.id, instance);\n }\n\n /**\n * Get a service by its token\n * @param token Service token\n * @returns The service instance\n */\n get<T>(token: ServiceToken<T>): T {\n return this.container.get<T>(token.id);\n }\n\n /**\n * Check if a service is registered\n * @param token Service token\n * @returns True if the service is registered\n */\n has<T>(token: ServiceToken<T>): boolean {\n return this.container.has(token.id);\n }\n}\n\n/**\n * Global service registry instance\n */\nexport const globalServiceRegistry = new ServiceRegistry(globalContainer);\n",
|
|
7
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ServiceRegistry } from \"./ServiceRegistry\";\nimport { createServiceToken, globalServiceRegistry } from \"./ServiceRegistry\";\n\n/**\n * A resolver function that converts a string ID to an instance.\n * Returns undefined if the resolver cannot handle this format.\n * Throws an error if the ID is not found.\n *\n * @param id The string ID to resolve\n * @param format The full format string (e.g., \"model:TextEmbedding\", \"storage:tabular\")\n * @param registry The service registry to use for lookups\n */\nexport type InputResolverFn = (\n id: string,\n format: string,\n registry: ServiceRegistry\n) => unknown | Promise<unknown>;\n\n/**\n * Service token for the input resolver registry.\n * Maps format prefixes to resolver functions.\n */\nexport const INPUT_RESOLVERS =\n createServiceToken<Map<string, InputResolverFn>>(\"task.input.resolvers\");\n\n// Register default factory if not already registered\nif (!globalServiceRegistry.has(INPUT_RESOLVERS)) {\n globalServiceRegistry.register(\n INPUT_RESOLVERS,\n (): Map<string, InputResolverFn> => new Map(),\n true\n );\n}\n\n/**\n * Gets the global input resolver registry\n * @returns Map of format prefix to resolver function\n */\nexport function getInputResolvers(): Map<string, InputResolverFn> {\n return globalServiceRegistry.get(INPUT_RESOLVERS);\n}\n\n/**\n * Registers an input resolver for a format prefix.\n * The resolver will be called for any format that starts with this prefix.\n *\n * @param formatPrefix The format prefix to match (e.g., \"model\", \"dataset\")\n * @param resolver The resolver function\n *\n * @example\n * ```typescript\n * // Register model resolver\n * registerInputResolver(\"model\", async (id, format, registry) => {\n * const modelRepo = registry.get(MODEL_REPOSITORY);\n * const model = await modelRepo.findByName(id);\n * if (!model) throw new Error(`Model \"${id}\" not found`);\n * return model;\n * });\n *\n * // Register dataset resolver\n * registerInputResolver(\"dataset\", (id, format, registry) => {\n * const datasetType = format.split(\":\")[1]; // \"tabular\", \"vector\", etc.\n * if (datasetType === \"tabular\") {\n * const datasets = registry.get(TABULAR_DATASETS);\n * const dataset = datasets.get(id);\n * if (!dataset) throw new Error(`Dataset \"${id}\" not found`);\n * return dataset;\n * }\n * throw new Error(`Unknown dataset type: ${datasetType}`);\n * });\n * ```\n */\nexport function registerInputResolver(formatPrefix: string, resolver: InputResolverFn): void {\n const resolvers = getInputResolvers();\n resolvers.set(formatPrefix, resolver);\n}\n",
|
|
8
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ILogger } from \"./ILogger\";\n\n/**\n * Log-level names in ascending severity order.\n */\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\" | \"fatal\";\n\nconst LOG_LEVEL_ORDER: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n fatal: 4,\n};\n\nexport interface ConsoleLoggerOptions {\n readonly bindings?: Record<string, unknown>;\n readonly level?: LogLevel;\n readonly timings?: boolean;\n}\n\n/**\n * Logger that delegates to the global `console` object.\n * When created via {@link child}, accumulated bindings are passed\n * as a second argument to every console call.\n *\n * Supports optional level filtering (messages below the configured\n * level are silently discarded) and an opt-in `timings` flag that\n * controls whether {@link time}/{@link timeEnd} produce output.\n */\nexport class ConsoleLogger implements ILogger {\n private readonly bindings: Record<string, unknown>;\n private readonly level: LogLevel;\n private readonly timings: boolean;\n\n constructor(options: ConsoleLoggerOptions = {}) {\n this.bindings = options.bindings ?? {};\n this.level = options.level ?? \"debug\";\n this.timings = options.timings ?? false;\n }\n\n private enabled(level: LogLevel): boolean {\n return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[this.level];\n }\n\n info(message: string, meta?: Record<string, unknown>): void {\n if (!this.enabled(\"info\")) return;\n const merged = this.merge(meta);\n if (merged) {\n console.info(message, merged);\n } else {\n console.info(message);\n }\n }\n\n warn(message: string, meta?: Record<string, unknown>): void {\n if (!this.enabled(\"warn\")) return;\n const merged = this.merge(meta);\n if (merged) {\n console.warn(message, merged);\n } else {\n console.warn(message);\n }\n }\n\n error(message: string, meta?: Record<string, unknown>): void {\n if (!this.enabled(\"error\")) return;\n const merged = this.merge(meta);\n if (merged) {\n console.error(message, merged);\n } else {\n console.error(message);\n }\n }\n\n debug(message: string, meta?: Record<string, unknown>): void {\n if (!this.enabled(\"debug\")) return;\n const merged = this.merge(meta);\n if (merged) {\n console.debug(message, merged);\n } else {\n console.debug(message);\n }\n }\n\n fatal(err: Error, message: string, meta?: Record<string, unknown>): void {\n if (!this.enabled(\"fatal\")) return;\n const merged = this.merge(meta);\n if (merged) {\n console.error(message, { ...merged, error: err });\n } else {\n console.error(message, { error: err });\n }\n }\n\n time(label: string, meta?: Record<string, unknown>): void {\n if (!this.timings) return;\n const merged = this.merge(meta);\n if (merged) {\n console.info(`[time] ${label}`, merged);\n }\n console.time(label);\n }\n\n timeEnd(label: string, meta?: Record<string, unknown>): void {\n if (!this.timings) return;\n console.timeEnd(label);\n const merged = this.merge(meta);\n if (merged) {\n console.info(`[timeEnd] ${label}`, merged);\n }\n }\n\n group(label: string, meta?: Record<string, unknown>): void {\n const merged = this.merge(meta);\n if (merged) {\n console.group(label, merged);\n } else {\n console.group(label);\n }\n }\n\n groupEnd(): void {\n console.groupEnd();\n }\n\n child(bindings: Record<string, unknown>): ILogger {\n return new ConsoleLogger({\n bindings: { ...this.bindings, ...bindings },\n level: this.level,\n timings: this.timings,\n });\n }\n\n private merge(meta: Record<string, unknown> | undefined): Record<string, unknown> | undefined {\n const hasBindings = Object.keys(this.bindings).length > 0;\n if (!hasBindings && !meta) return undefined;\n if (!hasBindings) return meta;\n if (!meta) return this.bindings;\n return { ...this.bindings, ...meta };\n }\n}\n",
|
|
9
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ILogger } from \"./ILogger\";\n\n/**\n * Silent logger that discards all output.\n * Useful for suppressing log noise in tests.\n */\nexport class NullLogger implements ILogger {\n info(_message: string, _meta?: Record<string, unknown>): void {}\n error(_message: string, _meta?: Record<string, unknown>): void {}\n warn(_message: string, _meta?: Record<string, unknown>): void {}\n debug(_message: string, _meta?: Record<string, unknown>): void {}\n fatal(_err: Error, _message: string, _meta?: Record<string, unknown>): void {}\n time(_label: string, _meta?: Record<string, unknown>): void {}\n timeEnd(_label: string, _meta?: Record<string, unknown>): void {}\n group(_label: string, _meta?: Record<string, unknown>): void {}\n groupEnd(): void {}\n child(_bindings: Record<string, unknown>): ILogger {\n return this;\n }\n}\n",
|
|
10
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createServiceToken, globalServiceRegistry } from \"../di/ServiceRegistry\";\nimport type { LogLevel } from \"./ConsoleLogger\";\nimport { ConsoleLogger } from \"./ConsoleLogger\";\nimport type { ILogger } from \"./ILogger\";\nimport { NullLogger } from \"./NullLogger\";\n\n/**\n * Service token for the global logger instance.\n */\nexport const LOGGER = createServiceToken<ILogger>(\"logger\");\n\nconst VALID_LOG_LEVELS: ReadonlySet<string> = new Set<string>([\n \"debug\",\n \"info\",\n \"warn\",\n \"error\",\n \"fatal\",\n]);\n\nfunction getEnv(name: string): string | undefined {\n if (typeof process !== \"undefined\" && process.env) {\n return process.env[name];\n }\n return import.meta.env[name];\n}\n\nfunction isTruthy(value: string | undefined): boolean {\n return value !== undefined && value !== \"\" && value !== \"0\" && value !== \"false\";\n}\n\nfunction createDefaultLogger(): ILogger {\n const levelEnv = getEnv(\"LOGGER_LEVEL\")?.toLowerCase();\n if (levelEnv && VALID_LOG_LEVELS.has(levelEnv)) {\n return new ConsoleLogger({\n level: levelEnv as LogLevel,\n timings: isTruthy(getEnv(\"LOGGER_TIMINGS\")),\n });\n }\n if (getEnv(\"DEV\")) {\n return new ConsoleLogger({\n level: \"debug\" as LogLevel,\n timings: true,\n });\n }\n return new NullLogger();\n}\n\n// Register default logger: NullLogger unless LOGGER_LEVEL env var is set.\nif (!globalServiceRegistry.has(LOGGER)) {\n globalServiceRegistry.register(LOGGER, createDefaultLogger, true);\n}\n\n/**\n * Returns the current global logger.\n */\nexport function getLogger(): ILogger {\n return globalServiceRegistry.get(LOGGER);\n}\n\n/**\n * Replaces the global logger instance.\n */\nexport function setLogger(logger: ILogger): void {\n globalServiceRegistry.registerInstance(LOGGER, logger);\n}\n",
|
|
11
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createServiceToken } from \"../di\";\n\n/** Service token for the platform-specific WorkerServer instance. */\nexport const WORKER_SERVER = createServiceToken<WorkerServerBase>(\"worker.server\");\n\n/**\n * Extracts transferables from an object.\n * @param obj - The object to extract transferables from.\n * @returns An array of transferables.\n */\nfunction extractTransferables(obj: any) {\n const transferables: Transferable[] = [];\n const seen = new WeakSet();\n\n function findTransferables(value: any) {\n // Avoid infinite recursion\n if (value && typeof value === \"object\" && seen.has(value)) {\n return;\n }\n if (value && typeof value === \"object\") {\n seen.add(value);\n }\n\n // Handle TypedArrays\n if (value instanceof Float32Array || value instanceof Int16Array) {\n transferables.push(value.buffer);\n }\n // Handle other TypedArrays\n else if (\n value instanceof Uint8Array ||\n value instanceof Uint8ClampedArray ||\n value instanceof Int8Array ||\n value instanceof Uint16Array ||\n value instanceof Int32Array ||\n value instanceof Uint32Array ||\n value instanceof Float64Array ||\n value instanceof BigInt64Array ||\n value instanceof BigUint64Array\n ) {\n transferables.push(value.buffer);\n }\n // Handle OffscreenCanvas\n else if (typeof OffscreenCanvas !== \"undefined\" && value instanceof OffscreenCanvas) {\n transferables.push(value);\n }\n // Handle ImageBitmap\n else if (typeof ImageBitmap !== \"undefined\" && value instanceof ImageBitmap) {\n transferables.push(value);\n }\n // Handle VideoFrame\n else if (typeof VideoFrame !== \"undefined\" && value instanceof VideoFrame) {\n transferables.push(value);\n }\n // Handle MessagePort\n else if (typeof MessagePort !== \"undefined\" && value instanceof MessagePort) {\n transferables.push(value);\n }\n // Handle ArrayBuffer\n else if (value instanceof ArrayBuffer) {\n transferables.push(value);\n }\n // Recursively search arrays and objects\n else if (Array.isArray(value)) {\n value.forEach(findTransferables);\n } else if (value && typeof value === \"object\") {\n Object.values(value).forEach(findTransferables);\n }\n }\n\n findTransferables(obj);\n return transferables;\n}\n\n/**\n * WorkerServerBase is a class that handles messages from the main thread to the worker.\n * It is used to register functions that can be called from the main thread.\n * It also handles the transfer of transferables to the main thread.\n */\nexport class WorkerServerBase {\n constructor() {} // overridden in subclasses\n\n private functions: Record<string, (...args: any[]) => Promise<any>> = {};\n private streamFunctions: Record<string, (...args: any[]) => AsyncIterable<any>> = {};\n private reactiveFunctions: Record<string, (input: any, output: any, model: any) => Promise<any>> =\n {};\n\n // Keep track of each request's AbortController\n private requestControllers = new Map<string, AbortController>();\n // Keep track of requests that have already been responded to\n private completedRequests = new Set<string>();\n\n private postResult = (id: string, result: any) => {\n if (this.completedRequests.has(id)) {\n return; // Already responded to this request\n }\n this.completedRequests.add(id);\n const transferables = extractTransferables(result);\n const uniqueTransferables = [...new Set(transferables)];\n // @ts-ignore - Ignore type mismatch between standard Transferable and Bun.Transferable\n postMessage({ id, type: \"complete\", data: result }, uniqueTransferables);\n };\n\n private postError = (id: string, errorMessage: string) => {\n if (this.completedRequests.has(id)) {\n return; // Already responded to this request\n }\n this.completedRequests.add(id);\n postMessage({ id, type: \"error\", data: errorMessage });\n };\n\n private postStreamChunk = (id: string, event: any) => {\n if (this.completedRequests.has(id)) {\n return;\n }\n postMessage({ id, type: \"stream_chunk\", data: event });\n };\n\n /**\n * Send the ready message to the main thread, advertising which functions are\n * registered in each category. Call this after all functions have been registered\n * so WorkerManager can skip unnecessary roundtrips for unregistered calls.\n */\n sendReady() {\n // @ts-ignore\n postMessage({\n type: \"ready\",\n functions: Object.keys(this.functions),\n streamFunctions: Object.keys(this.streamFunctions),\n reactiveFunctions: Object.keys(this.reactiveFunctions),\n });\n }\n\n registerFunction(name: string, fn: (...args: any[]) => Promise<any>) {\n this.functions[name] = fn;\n }\n\n /**\n * Register a reactive function for lightweight preview execution.\n * Reactive functions receive (input, output, model) and return a fast preview\n * without progress tracking or abort signals.\n *\n * @param name - The function name (e.g., task type identifier)\n * @param fn - Async function: (input, output, model) => Promise<output | undefined>\n */\n registerReactiveFunction(\n name: string,\n fn: (input: any, output: any, model: any) => Promise<any>\n ) {\n this.reactiveFunctions[name] = fn;\n }\n\n /**\n * Register an async generator function for streaming execution.\n * When called via the worker protocol with `stream: true`, the server\n * iterates the generator and sends each yielded value as a `stream_chunk`\n * message, followed by a `complete` message when the generator finishes.\n *\n * @param name - The function name (e.g., task type identifier)\n * @param fn - Async generator function: (input, model, signal) => AsyncIterable\n */\n registerStreamFunction(name: string, fn: (...args: any[]) => AsyncIterable<any>) {\n this.streamFunctions[name] = fn;\n }\n\n // Handle messages from the main thread\n async handleMessage(event: { type: string; data: any }) {\n const { id, type, functionName, args, stream, reactive } = event.data;\n if (type === \"abort\") {\n return await this.handleAbort(id);\n }\n if (type === \"call\") {\n if (stream) {\n return await this.handleStreamCall(id, functionName, args);\n }\n if (reactive) {\n return await this.handleReactiveCall(id, functionName, args);\n }\n return await this.handleCall(id, functionName, args);\n }\n }\n\n async handleAbort(id: string) {\n if (this.requestControllers.has(id)) {\n const controller = this.requestControllers.get(id);\n controller?.abort();\n this.requestControllers.delete(id);\n // Send error response back to main thread so the promise rejects\n this.postError(id, \"Operation aborted\");\n }\n }\n\n /**\n * Handle a reactive call. Returns undefined (non-error) if the reactive\n * function is not registered, since not all task types expose a reactive fn.\n */\n async handleReactiveCall(\n id: string,\n functionName: string,\n [input, output, model]: [any, any, any]\n ) {\n if (!(functionName in this.reactiveFunctions)) {\n this.postResult(id, undefined);\n return;\n }\n try {\n const fn = this.reactiveFunctions[functionName];\n const result = await fn(input, output, model);\n this.postResult(id, result);\n } catch (error: any) {\n this.postError(id, error.message);\n }\n }\n\n async handleCall(id: string, functionName: string, [input, model]: [any, any]) {\n if (!(functionName in this.functions)) {\n this.postError(id, `Function ${functionName} not found`);\n return;\n }\n\n try {\n const abortController = new AbortController();\n this.requestControllers.set(id, abortController);\n\n const fn = this.functions[functionName];\n const postProgress = (progress: number, message?: string, details?: any) => {\n // Don't send progress updates after the request is completed/aborted\n if (!this.completedRequests.has(id)) {\n postMessage({ id, type: \"progress\", data: { progress, message, details } });\n }\n };\n const result = await fn(input, model, postProgress, abortController.signal);\n this.postResult(id, result);\n } catch (error: any) {\n this.postError(id, error.message);\n } finally {\n this.requestControllers.delete(id);\n // Clean up completed requests set after a delay to handle any race conditions\n // where abort message might arrive shortly after completion\n setTimeout(() => {\n this.completedRequests.delete(id);\n }, 1000);\n }\n }\n\n /**\n * Handle a streaming call. If a stream function is registered for the given name,\n * iterate it and send each yielded event as a `stream_chunk` message. If only a\n * regular function is registered, run it and wrap the result as a single `finish`\n * stream event (graceful fallback for providers that don't implement streaming).\n */\n async handleStreamCall(id: string, functionName: string, [input, model]: [any, any]) {\n if (functionName in this.streamFunctions) {\n try {\n const abortController = new AbortController();\n this.requestControllers.set(id, abortController);\n\n const fn = this.streamFunctions[functionName];\n const iterable = fn(input, model, abortController.signal);\n\n for await (const event of iterable) {\n if (this.completedRequests.has(id)) break;\n this.postStreamChunk(id, event);\n }\n\n this.postResult(id, undefined);\n } catch (error: any) {\n this.postError(id, error.message);\n } finally {\n this.requestControllers.delete(id);\n setTimeout(() => {\n this.completedRequests.delete(id);\n }, 1000);\n }\n } else if (functionName in this.functions) {\n // Fallback: run regular function and wrap result as a finish stream event\n try {\n const abortController = new AbortController();\n this.requestControllers.set(id, abortController);\n\n const fn = this.functions[functionName];\n const noopProgress = () => {};\n const result = await fn(input, model, noopProgress, abortController.signal);\n\n this.postStreamChunk(id, { type: \"finish\", data: result });\n this.postResult(id, undefined);\n } catch (error: any) {\n this.postError(id, error.message);\n } finally {\n this.requestControllers.delete(id);\n setTimeout(() => {\n this.completedRequests.delete(id);\n }, 1000);\n }\n } else {\n this.postError(id, `Function ${functionName} not found`);\n }\n }\n}\n",
|
|
12
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createServiceToken, globalServiceRegistry } from \"../di\";\nimport { getLogger } from \"../logging\";\n\nexport class WorkerManager {\n private workers: Map<string, Worker> = new Map();\n private readyWorkers: Map<string, Promise<void>> = new Map();\n /** Function names registered on each worker, populated from the ready message. */\n private workerFunctions: Map<string, Set<string>> = new Map();\n private workerStreamFunctions: Map<string, Set<string>> = new Map();\n private workerReactiveFunctions: Map<string, Set<string>> = new Map();\n /** Pending lazy factories (worker not yet constructed). */\n private lazyFactories: Map<string, () => Worker> = new Map();\n /** Single-flight init promise per name (lazy path). */\n private lazyInitPromises: Map<string, Promise<void>> = new Map();\n\n registerWorker(name: string, workerOrFactory: Worker | (() => Worker)): void {\n if (this.workers.has(name)) {\n throw new Error(`Worker ${name} is already registered.`);\n }\n if (this.lazyFactories.has(name)) {\n throw new Error(`Worker ${name} is already registered.`);\n }\n if (typeof workerOrFactory === \"function\") {\n this.lazyFactories.set(name, workerOrFactory);\n } else {\n this.attachWorkerInstance(name, workerOrFactory);\n }\n }\n\n private attachWorkerInstance(name: string, worker: Worker): void {\n this.workers.set(name, worker);\n worker.addEventListener(\"error\", (event) => {\n console.error(\"Worker Error:\", event.message, \"at\", event.filename, \"line:\", event.lineno);\n });\n worker.addEventListener(\"messageerror\", (event) => {\n console.error(\"Worker message error:\", event);\n });\n\n const readyPromise = new Promise<void>((resolve) => {\n const handleReady = (event: MessageEvent) => {\n if (event.data?.type === \"ready\") {\n worker.removeEventListener(\"message\", handleReady);\n this.workerFunctions.set(name, new Set(event.data.functions ?? []));\n this.workerStreamFunctions.set(name, new Set(event.data.streamFunctions ?? []));\n this.workerReactiveFunctions.set(name, new Set(event.data.reactiveFunctions ?? []));\n resolve();\n }\n };\n\n worker.addEventListener(\"message\", handleReady);\n });\n\n this.readyWorkers.set(name, readyPromise);\n }\n\n /**\n * Ensures a lazy worker is constructed and ready. No-op if already\n * registered eagerly.\n */\n private async ensureWorkerReady(name: string): Promise<void> {\n if (this.workers.has(name)) {\n await this.readyWorkers.get(name)!;\n return;\n }\n const factory = this.lazyFactories.get(name);\n if (!factory) {\n throw new Error(`Worker ${name} not found.`);\n }\n let init = this.lazyInitPromises.get(name);\n if (!init) {\n init = (async () => {\n const f = this.lazyFactories.get(name)!;\n this.lazyFactories.delete(name);\n const worker = f();\n this.attachWorkerInstance(name, worker);\n })();\n this.lazyInitPromises.set(name, init);\n }\n await init;\n await this.readyWorkers.get(name)!;\n this.lazyInitPromises.delete(name);\n }\n\n getWorker(name: string): Worker {\n const worker = this.workers.get(name);\n if (!worker) throw new Error(`Worker ${name} not found.`);\n return worker;\n }\n\n async callWorkerFunction<T>(\n workerName: string,\n functionName: string,\n args: any[],\n options?: {\n signal?: AbortSignal;\n onProgress?: (progress: number, message?: string, details?: any) => void;\n }\n ): Promise<T> {\n await this.ensureWorkerReady(workerName);\n const worker = this.workers.get(workerName);\n if (!worker) throw new Error(`Worker ${workerName} not found.`);\n await this.readyWorkers.get(workerName);\n\n const knownFunctions = this.workerFunctions.get(workerName);\n if (knownFunctions && !knownFunctions.has(functionName)) {\n throw new Error(`Function \"${functionName}\" is not registered on worker \"${workerName}\".`);\n }\n\n return new Promise((resolve, reject) => {\n const requestId = crypto.randomUUID();\n\n const handleMessage = (event: MessageEvent) => {\n const { id, type, data } = event.data;\n if (id !== requestId) return;\n if (type === \"progress\" && options?.onProgress) {\n options.onProgress(data.progress, data.message, data.details);\n getLogger().debug(\n `Worker ${workerName} function ${functionName} progress: ${data.progress}, `,\n { data }\n );\n } else if (type === \"complete\") {\n cleanup();\n getLogger().debug(`Worker ${workerName} function ${functionName} complete.`, { data });\n resolve(data);\n } else if (type === \"error\") {\n cleanup();\n getLogger().debug(`Worker ${workerName} function ${functionName} error.`, { data });\n reject(new Error(data));\n }\n };\n\n const handleAbort = () => {\n worker.postMessage({ id: requestId, type: \"abort\" });\n getLogger().info(`Worker ${workerName} function ${functionName} aborted.`);\n };\n\n const cleanup = () => {\n worker.removeEventListener(\"message\", handleMessage);\n options?.signal?.removeEventListener(\"abort\", handleAbort);\n };\n\n worker.addEventListener(\"message\", handleMessage);\n\n if (options?.signal) {\n options.signal.addEventListener(\"abort\", handleAbort, { once: true });\n }\n\n // Note: We intentionally do NOT transfer TypedArrays from the main thread to the worker.\n // Transferring detaches the buffers on the main thread, which breaks downstream tasks\n // that still need those TypedArrays (e.g., the embedding vectors flowing through the\n // task graph). Workers send results back with transferables (zero-copy), but the\n // main thread always clones data going to workers to preserve its own references.\n const message = { id: requestId, type: \"call\", functionName, args };\n worker.postMessage(message);\n getLogger().info(`Worker ${workerName} function ${functionName} called.`);\n });\n }\n\n /**\n * Call a reactive function on a worker. Returns undefined (rather than throwing)\n * if the worker has no reactive function registered for the given name, so callers\n * can treat the result as an optional preview.\n *\n * @param workerName - Registered worker name\n * @param functionName - Name of the reactive function registered on the worker\n * @param args - Arguments to pass: [input, output, model]\n * @returns The reactive result, or undefined if not registered / on error\n */\n async callWorkerReactiveFunction<T>(\n workerName: string,\n functionName: string,\n args: any[]\n ): Promise<T | undefined> {\n await this.ensureWorkerReady(workerName);\n const worker = this.workers.get(workerName);\n if (!worker) return undefined;\n await this.readyWorkers.get(workerName);\n\n // Skip the roundtrip if the worker didn't register a reactive function for this name.\n const knownReactive = this.workerReactiveFunctions.get(workerName);\n if (knownReactive && !knownReactive.has(functionName)) return undefined;\n\n return new Promise((resolve) => {\n const requestId = crypto.randomUUID();\n\n const handleMessage = (event: MessageEvent) => {\n const { id, type, data } = event.data;\n if (id !== requestId) return;\n if (type === \"complete\") {\n cleanup();\n resolve(data as T | undefined);\n } else if (type === \"error\") {\n cleanup();\n resolve(undefined);\n }\n };\n\n const cleanup = () => {\n worker.removeEventListener(\"message\", handleMessage);\n };\n\n worker.addEventListener(\"message\", handleMessage);\n\n const message = { id: requestId, type: \"call\", functionName, args, reactive: true };\n // Note: No transferables — same reasoning as callWorkerFunction above.\n worker.postMessage(message);\n getLogger().info(`Worker ${workerName} reactive function ${functionName} called.`);\n });\n }\n\n /**\n * Call a streaming function on a worker and return an AsyncGenerator that\n * yields each stream chunk sent by the worker. The worker sends `stream_chunk`\n * messages for each yielded event and a `complete` message when the generator\n * finishes. An `error` message from the worker causes the iterator to throw.\n *\n * @param workerName - Registered worker name\n * @param functionName - Name of the stream function registered on the worker\n * @param args - Arguments to pass to the stream function\n * @param options - Optional abort signal\n * @returns AsyncGenerator yielding stream events from the worker\n */\n async *callWorkerStreamFunction<T>(\n workerName: string,\n functionName: string,\n args: any[],\n options?: { signal?: AbortSignal }\n ): AsyncGenerator<T> {\n await this.ensureWorkerReady(workerName);\n const worker = this.workers.get(workerName);\n if (!worker) throw new Error(`Worker ${workerName} not found.`);\n await this.readyWorkers.get(workerName);\n\n // The worker falls back to regular functions for stream calls, so either counts.\n const knownStream = this.workerStreamFunctions.get(workerName);\n const knownFns = this.workerFunctions.get(workerName);\n if (knownStream && knownFns && !knownStream.has(functionName) && !knownFns.has(functionName)) {\n throw new Error(`Function \"${functionName}\" is not registered on worker \"${workerName}\".`);\n }\n\n const requestId = crypto.randomUUID();\n\n // Push-queue pattern: messages push items, async generator pulls them\n type QueueItem =\n | { kind: \"event\"; data: T }\n | { kind: \"done\" }\n | { kind: \"error\"; error: Error };\n\n const queue: QueueItem[] = [];\n let waiting: ((value: void) => void) | null = null;\n\n const notify = () => {\n if (waiting) {\n const resolve = waiting;\n waiting = null;\n resolve();\n }\n };\n\n const handleMessage = (event: MessageEvent) => {\n const { id, type, data } = event.data;\n if (id !== requestId) return;\n\n if (type === \"stream_chunk\") {\n queue.push({ kind: \"event\", data });\n notify();\n } else if (type === \"complete\") {\n queue.push({ kind: \"done\" });\n notify();\n } else if (type === \"error\") {\n queue.push({ kind: \"error\", error: new Error(data) });\n notify();\n }\n };\n\n const handleAbort = () => {\n worker.postMessage({ id: requestId, type: \"abort\" });\n getLogger().info(`Worker ${workerName} stream function ${functionName} aborted.`);\n };\n\n const cleanup = () => {\n worker.removeEventListener(\"message\", handleMessage);\n options?.signal?.removeEventListener(\"abort\", handleAbort);\n };\n\n worker.addEventListener(\"message\", handleMessage);\n\n if (options?.signal) {\n if (options.signal.aborted) {\n cleanup();\n throw new Error(\"Operation aborted\");\n }\n options.signal.addEventListener(\"abort\", handleAbort, { once: true });\n }\n\n // Send call message with stream flag\n // Note: No transferables — same reasoning as callWorkerFunction above.\n const message = { id: requestId, type: \"call\", functionName, args, stream: true };\n worker.postMessage(message);\n getLogger().info(`Worker ${workerName} stream function ${functionName} called.`);\n\n let completedNormally = false;\n try {\n while (true) {\n while (queue.length > 0) {\n const item = queue.shift()!;\n if (item.kind === \"event\") {\n yield item.data;\n } else if (item.kind === \"done\") {\n completedNormally = true;\n return;\n } else if (item.kind === \"error\") {\n completedNormally = true;\n throw item.error;\n }\n }\n\n // Wait for the next message to arrive\n await new Promise<void>((resolve) => {\n waiting = resolve;\n });\n }\n } finally {\n // If the consumer stopped iterating early (break/return), notify\n // the worker to abort so it doesn't continue generating tokens.\n if (!completedNormally) {\n worker.postMessage({ id: requestId, type: \"abort\" });\n getLogger().info(`Worker ${workerName} stream function ${functionName} aborted.`);\n }\n cleanup();\n }\n }\n}\n\nexport const WORKER_MANAGER = createServiceToken<WorkerManager>(\"worker.manager\");\n\nglobalServiceRegistry.register(WORKER_MANAGER, () => new WorkerManager(), true);\n",
|
|
13
|
+
"/**\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",
|
|
14
|
+
"import { Worker as NodeWorker, isMainThread, parentPort } from \"worker_threads\";\nimport type { WorkerOptions } from \"worker_threads\";\nimport { pathToFileURL } from \"url\";\nimport { URL as NodeURL } from \"url\";\n\nclass WorkerPolyfill extends NodeWorker {\n constructor(scriptUrl: string | NodeURL, options?: WorkerOptions) {\n const resolved: string =\n scriptUrl instanceof NodeURL ? scriptUrl.toString() : pathToFileURL(scriptUrl).toString();\n super(resolved, options);\n }\n\n addEventListener(event: \"message\" | \"error\", listener: (...args: any[]) => void) {\n if (event === \"message\") this.on(\"message\", listener);\n if (event === \"error\") this.on(\"error\", listener);\n }\n\n removeEventListener(event: \"message\" | \"error\", listener: (...args: any[]) => void) {\n if (event === \"message\") this.off(\"message\", listener);\n if (event === \"error\") this.off(\"error\", listener);\n }\n}\n\nconst Worker = isMainThread ? WorkerPolyfill : parentPort;\nexport { Worker, parentPort };\n\nimport { WorkerServerBase, WORKER_SERVER } from \"./WorkerServerBase\";\nimport { globalServiceRegistry } from \"../di\";\nexport { WORKER_SERVER };\nexport class WorkerServer extends WorkerServerBase {\n constructor() {\n parentPort?.addEventListener(\"message\", async (event) => {\n const msg = {\n type: event.type,\n // @ts-ignore - Ignore type mismatch between standard MessageEvent and our message type\n data: event.data,\n };\n await this.handleMessage(msg);\n });\n super();\n }\n}\n\nglobalServiceRegistry.register(WORKER_SERVER, () => new WorkerServer(), true);\n"
|
|
15
|
+
],
|
|
16
|
+
"mappings": ";AASO,MAAM,UAAU;AAAA,EACb,WAA6B,IAAI;AAAA,EACjC,YAAoC,IAAI;AAAA,EACxC,aAA0B,IAAI;AAAA,EAQtC,QAAW,CAAC,OAAe,SAAkB,YAAY,MAAY;AAAA,IACnE,KAAK,UAAU,IAAI,OAAO,OAAO;AAAA,IACjC,IAAI,WAAW;AAAA,MACb,KAAK,WAAW,IAAI,KAAK;AAAA,IAC3B;AAAA;AAAA,EAQF,gBAAmB,CAAC,OAAe,UAAmB;AAAA,IACpD,KAAK,SAAS,IAAI,OAAO,QAAQ;AAAA,IACjC,KAAK,WAAW,IAAI,KAAK;AAAA;AAAA,EAQ3B,GAAM,CAAC,OAAkB;AAAA,IAEvB,IAAI,KAAK,SAAS,IAAI,KAAK,GAAG;AAAA,MAC5B,OAAO,KAAK,SAAS,IAAI,KAAK;AAA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,GAAG;AAAA,IACZ,YAAY,iBAAiB,WAAW,OAAO,UAAU;AAAA,MACvD,MAAM,MAAM;AAAA,QACV,MAAM,MAAM;AAAA,QAEZ,MAAM,MAAM;AAAA,MACd;AAAA,MACA,MAAM,KAAK,cAAc,GAAG;AAAA,KAC7B;AAAA,IACD,MAAM;AAAA;AAEV;AAEA,sBAAsB,SAAS,eAAe,MAAM,IAAI,cAAgB,IAAI;",
|
|
17
|
+
"debugId": "860124BFCE9F93F264756E2164756E21",
|
|
18
|
+
"names": []
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workglow/util",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.122",
|
|
5
5
|
"description": "Utility functions and shared types for Workglow, providing common functionality across all packages.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"watch": "concurrently -c 'auto' 'bun:watch-*'",
|
|
8
|
-
"watch-js": "concurrently -c 'auto' -n 'browser,node,bun' 'bun run watch-browser' 'bun run watch-node' 'bun run watch-bun'",
|
|
9
|
-
"watch-browser": "bun build --
|
|
10
|
-
"watch-node": "bun build --
|
|
11
|
-
"watch-bun": "bun build --
|
|
8
|
+
"watch-js": "concurrently -c 'auto' -n 'browser,node,bun,worker' 'bun run watch-browser' 'bun run watch-node' 'bun run watch-bun' 'bun run watch-worker'",
|
|
9
|
+
"watch-browser": "bun build --watch --no-clear-screen --target=browser --sourcemap=external --packages=external --outdir ./dist ./src/browser.ts",
|
|
10
|
+
"watch-node": "bun build --watch --no-clear-screen --target=node --sourcemap=external --packages=external --outdir ./dist ./src/node.ts",
|
|
11
|
+
"watch-bun": "bun build --watch --no-clear-screen --target=bun --sourcemap=external --packages=external --outdir ./dist ./src/bun.ts",
|
|
12
|
+
"watch-worker": "bun build --watch --no-clear-screen --target=browser --sourcemap=external --packages=external --outdir ./dist ./src/worker-browser.ts",
|
|
12
13
|
"watch-types": "tsc --watch --preserveWatchOutput",
|
|
13
|
-
"build-package": "concurrently -c 'auto' -n 'browser,node,bun,types' 'bun run build-browser' 'bun run build-node' 'bun run build-bun' 'bun run build-types'",
|
|
14
|
-
"build-js": "concurrently -c 'auto' -n 'browser,node,bun' 'bun run build-browser' 'bun run build-node' 'bun run build-bun'",
|
|
14
|
+
"build-package": "concurrently -c 'auto' -n 'browser,node,bun,worker,types' 'bun run build-browser' 'bun run build-node' 'bun run build-bun' 'bun run build-worker' 'bun run build-types'",
|
|
15
|
+
"build-js": "concurrently -c 'auto' -n 'browser,node,bun,worker' 'bun run build-browser' 'bun run build-node' 'bun run build-bun' 'bun run build-worker'",
|
|
15
16
|
"build-clean": "rm -fr dist/* tsconfig.tsbuildinfo",
|
|
16
|
-
"build-browser": "bun build --
|
|
17
|
-
"build-node": "bun build --
|
|
18
|
-
"build-bun": "bun build --
|
|
19
|
-
"build-
|
|
17
|
+
"build-browser": "bun build --target=browser --sourcemap=external --packages=external --outdir ./dist ./src/browser.ts",
|
|
18
|
+
"build-node": "bun build --target=node --sourcemap=external --packages=external --outdir ./dist ./src/node.ts",
|
|
19
|
+
"build-bun": "bun build --target=bun --sourcemap=external --packages=external --outdir ./dist ./src/bun.ts",
|
|
20
|
+
"build-worker": "concurrently -c 'auto' -n 'w-browser,w-node,w-bun' 'bun run build-worker-browser' 'bun run build-worker-node' 'bun run build-worker-bun'",
|
|
21
|
+
"build-worker-browser": "bun build --target=browser --sourcemap=external --packages=external --outdir ./dist ./src/worker-browser.ts",
|
|
22
|
+
"build-worker-node": "bun build --target=node --sourcemap=external --packages=external --outdir ./dist ./src/worker-node.ts",
|
|
23
|
+
"build-worker-bun": "bun build --target=bun --sourcemap=external --packages=external --outdir ./dist ./src/worker-bun.ts",
|
|
24
|
+
"build-types": "rm -f tsconfig.tsbuildinfo && tsgo",
|
|
20
25
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
21
26
|
"test": "bun test"
|
|
22
27
|
},
|
|
@@ -27,6 +32,13 @@
|
|
|
27
32
|
"bun": "./dist/bun.js",
|
|
28
33
|
"types": "./dist/types.d.ts",
|
|
29
34
|
"import": "./dist/node.js"
|
|
35
|
+
},
|
|
36
|
+
"./worker": {
|
|
37
|
+
"react-native": "./dist/worker-browser.js",
|
|
38
|
+
"browser": "./dist/worker-browser.js",
|
|
39
|
+
"bun": "./dist/worker-bun.js",
|
|
40
|
+
"types": "./dist/worker-entry.d.ts",
|
|
41
|
+
"import": "./dist/worker-node.js"
|
|
30
42
|
}
|
|
31
43
|
},
|
|
32
44
|
"files": [
|
|
@@ -37,15 +49,6 @@
|
|
|
37
49
|
"access": "public"
|
|
38
50
|
},
|
|
39
51
|
"dependencies": {
|
|
40
|
-
"@sroussey/json-schema-library": "^11.0.0",
|
|
41
52
|
"@sroussey/json-schema-to-ts": "3.1.4"
|
|
42
|
-
},
|
|
43
|
-
"peerDependencies": {
|
|
44
|
-
"@modelcontextprotocol/sdk": "^1.27.1"
|
|
45
|
-
},
|
|
46
|
-
"peerDependenciesMeta": {
|
|
47
|
-
"@modelcontextprotocol/sdk": {
|
|
48
|
-
"optional": true
|
|
49
|
-
}
|
|
50
53
|
}
|
|
51
54
|
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Semantic Compatibility Utilities for Task Graph Dataflows
|
|
8
|
-
*
|
|
9
|
-
* In this project, task graphs have connections between tasks called dataflows.
|
|
10
|
-
* These dataflows have different kinds of compatibility checks:
|
|
11
|
-
*
|
|
12
|
-
* **Static Compatibility:**
|
|
13
|
-
* Static rules help decide if an edge should be connected at all. A connection
|
|
14
|
-
* is statically compatible if:
|
|
15
|
-
* - The source and target are the same exact type
|
|
16
|
-
* - The source connects to the equivalent of "any" (target accepts anything)
|
|
17
|
-
* - The source type is acceptable to the target (e.g., a string to something
|
|
18
|
-
* that accepts oneOf[string[], string])
|
|
19
|
-
*
|
|
20
|
-
* **Runtime Compatibility:**
|
|
21
|
-
* Assuming the connection is allowed at design time (passes static check),
|
|
22
|
-
* runtime rules determine if they are compatible during execution.
|
|
23
|
-
*
|
|
24
|
-
* Currently, there is one runtime compatibility check:
|
|
25
|
-
* - If both input and output schemas have 'format' annotations attached,
|
|
26
|
-
* the format annotation has the format /\w+(:\w+)?/ where the first part
|
|
27
|
-
* is the "name" and if alone matches any other with the same "name".
|
|
28
|
-
* If there is a second part, then that narrows the type.
|
|
29
|
-
* - Format checks apply to all types (strings, arrays, etc.), not just strings
|
|
30
|
-
* - A schema with format can connect to a schema with no format (source has format, target doesn't)
|
|
31
|
-
* - A schema with no format cannot connect to a schema with format (source doesn't have format, target does)
|
|
32
|
-
*
|
|
33
|
-
* Example: In the AI package, 'format':'model' and 'format': 'model:EmbeddingTask'
|
|
34
|
-
* are used on string types. An input with property `model` and 'format':'model'
|
|
35
|
-
* connects to a target with property `model` and 'format':'model:EmbeddingTask' --
|
|
36
|
-
* this compatibility is called "runtime". It first passes the static check as
|
|
37
|
-
* compatible and then notices a difference in format runtime.
|
|
38
|
-
*
|
|
39
|
-
* Format is also used on array types, e.g., 'format':'Float64Array' on arrays
|
|
40
|
-
* containing Float64 numbers.
|
|
41
|
-
*
|
|
42
|
-
* Only connections that pass the runtime check will pass data at runtime.
|
|
43
|
-
*/
|
|
44
|
-
import type { JsonSchema } from "./JsonSchema";
|
|
45
|
-
/**
|
|
46
|
-
* Checks if two JSON schemas are semantically compatible.
|
|
47
|
-
* Returns:
|
|
48
|
-
* - "static": Compatible at design time, no runtime check needed
|
|
49
|
-
* - "runtime": Compatible at design time, but needs runtime semantic check
|
|
50
|
-
* - "incompatible": Not compatible
|
|
51
|
-
*/
|
|
52
|
-
export declare function areSemanticallyCompatible(sourceSchema: JsonSchema, targetSchema: JsonSchema): "static" | "runtime" | "incompatible";
|
|
53
|
-
/**
|
|
54
|
-
* Checks if two object schemas are semantically compatible.
|
|
55
|
-
* This is a helper function for checking object-level schema compatibility.
|
|
56
|
-
*/
|
|
57
|
-
export declare function areObjectSchemasSemanticallyCompatible(sourceSchema: JsonSchema, targetSchema: JsonSchema): "static" | "runtime" | "incompatible";
|
|
58
|
-
//# sourceMappingURL=SchemaUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaUtils.d.ts","sourceRoot":"","sources":["../../src/json-schema/SchemaUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA8N/C;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,UAAU,GACvB,QAAQ,GAAG,SAAS,GAAG,cAAc,CAgSvC;AAED;;;GAGG;AACH,wBAAgB,sCAAsC,CACpD,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,UAAU,GACvB,QAAQ,GAAG,SAAS,GAAG,cAAc,CAEvC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
export { compileSchema } from "@sroussey/json-schema-library";
|
|
7
|
-
export type { SchemaNode } from "@sroussey/json-schema-library";
|
|
8
|
-
//# sourceMappingURL=SchemaValidation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaValidation.d.ts","sourceRoot":"","sources":["../../src/json-schema/SchemaValidation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,YAAY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*
|
|
6
|
-
* MCP OAuth provider adapter backed by ICredentialStore, and factory function.
|
|
7
|
-
*/
|
|
8
|
-
import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
9
|
-
import type { AddClientAuthentication, OAuthClientProvider, OAuthDiscoveryState } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
10
|
-
export { UnauthorizedError };
|
|
11
|
-
export type { OAuthClientProvider };
|
|
12
|
-
import type { OAuthClientInformationMixed, OAuthClientMetadata, OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth.js";
|
|
13
|
-
import type { ICredentialStore } from "../credentials/ICredentialStore";
|
|
14
|
-
import type { McpAuthConfig } from "./McpAuthTypes";
|
|
15
|
-
/**
|
|
16
|
-
* OAuthClientProvider backed by ICredentialStore.
|
|
17
|
-
*
|
|
18
|
-
* Stores tokens, client info, code verifiers, and discovery state as JSON
|
|
19
|
-
* strings under namespaced keys. Enables token persistence across
|
|
20
|
-
* short-lived MCP connections that share the same server URL.
|
|
21
|
-
*/
|
|
22
|
-
export declare class CredentialStoreOAuthProvider implements OAuthClientProvider {
|
|
23
|
-
private readonly store;
|
|
24
|
-
private readonly serverUrl;
|
|
25
|
-
private readonly _clientMetadata;
|
|
26
|
-
private readonly _redirectUrl;
|
|
27
|
-
private readonly _initialClientInfo;
|
|
28
|
-
/** Optional override for grant-specific token request preparation. */
|
|
29
|
-
prepareTokenRequest?: (scope?: string) => URLSearchParams | Promise<URLSearchParams | undefined> | undefined;
|
|
30
|
-
/** Optional override for custom client authentication on token requests. */
|
|
31
|
-
addClientAuthentication?: AddClientAuthentication;
|
|
32
|
-
constructor(options: {
|
|
33
|
-
store: ICredentialStore;
|
|
34
|
-
serverUrl: string;
|
|
35
|
-
clientMetadata: OAuthClientMetadata;
|
|
36
|
-
redirectUrl?: string | URL;
|
|
37
|
-
initialClientInfo?: OAuthClientInformationMixed;
|
|
38
|
-
prepareTokenRequest?: OAuthClientProvider["prepareTokenRequest"];
|
|
39
|
-
addClientAuthentication?: AddClientAuthentication;
|
|
40
|
-
});
|
|
41
|
-
get redirectUrl(): string | URL | undefined;
|
|
42
|
-
get clientMetadata(): OAuthClientMetadata;
|
|
43
|
-
clientInformation(): Promise<OAuthClientInformationMixed | undefined>;
|
|
44
|
-
saveClientInformation(info: OAuthClientInformationMixed): Promise<void>;
|
|
45
|
-
tokens(): Promise<OAuthTokens | undefined>;
|
|
46
|
-
saveTokens(tokens: OAuthTokens): Promise<void>;
|
|
47
|
-
redirectToAuthorization(authorizationUrl: URL): Promise<void>;
|
|
48
|
-
saveCodeVerifier(codeVerifier: string): Promise<void>;
|
|
49
|
-
codeVerifier(): Promise<string>;
|
|
50
|
-
saveDiscoveryState(state: OAuthDiscoveryState): Promise<void>;
|
|
51
|
-
discoveryState(): Promise<OAuthDiscoveryState | undefined>;
|
|
52
|
-
invalidateCredentials(scope: "all" | "client" | "tokens" | "verifier" | "discovery"): Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Creates an OAuthClientProvider for the given auth config, or returns
|
|
56
|
-
* `undefined` when no provider is needed (none / bearer).
|
|
57
|
-
*
|
|
58
|
-
* Bearer auth is handled at the transport level via request headers,
|
|
59
|
-
* so this function returns `undefined` for it.
|
|
60
|
-
*/
|
|
61
|
-
export declare function createAuthProvider(auth: McpAuthConfig, serverUrl: string, credentialStore?: ICredentialStore): OAuthClientProvider | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Resolves credential-store keys in auth config to actual secret values.
|
|
64
|
-
*
|
|
65
|
-
* This is needed for the standalone MCP task path where config properties
|
|
66
|
-
* are NOT auto-resolved by `resolveSchemaInputs`. For the AgentTask path,
|
|
67
|
-
* credential resolution happens automatically via `format: "credential"`.
|
|
68
|
-
*/
|
|
69
|
-
export declare function resolveAuthSecrets(auth: McpAuthConfig, credentialStore?: ICredentialStore): Promise<McpAuthConfig>;
|
|
70
|
-
//# sourceMappingURL=McpAuthProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"McpAuthProvider.d.ts","sourceRoot":"","sources":["../../src/mcp/McpAuthProvider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,YAAY,EAAE,mBAAmB,EAAE,CAAC;AACpC,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,WAAW,EACZ,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAoBpD;;;;;;GAMG;AACH,qBAAa,4BAA6B,YAAW,mBAAmB;IACtE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsB;IACtD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA2B;IACxD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA0C;IAE7E,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,CACpB,KAAK,CAAC,EAAE,MAAM,KACX,eAAe,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IAExE,4EAA4E;IAC5E,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;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B,GACjC,mBAAmB,GAAG,SAAS,CAuJjC;AAID;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,aAAa,EACnB,eAAe,CAAC,EAAE,gBAAgB,GACjC,OAAO,CAAC,aAAa,CAAC,CA6CxB"}
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*
|
|
6
|
-
* Shared MCP authentication type definitions and JSON Schema.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Supported MCP authentication types.
|
|
10
|
-
*/
|
|
11
|
-
export declare const mcpAuthTypes: readonly ["none", "bearer", "client_credentials", "private_key_jwt", "static_private_key_jwt", "authorization_code"];
|
|
12
|
-
export type McpAuthType = (typeof mcpAuthTypes)[number];
|
|
13
|
-
export interface McpAuthNone {
|
|
14
|
-
readonly type: "none";
|
|
15
|
-
}
|
|
16
|
-
export interface McpAuthBearer {
|
|
17
|
-
readonly type: "bearer";
|
|
18
|
-
/** Static token or credential-store key (format: "credential"). */
|
|
19
|
-
readonly token: string;
|
|
20
|
-
}
|
|
21
|
-
export interface McpAuthClientCredentials {
|
|
22
|
-
readonly type: "client_credentials";
|
|
23
|
-
readonly client_id: string;
|
|
24
|
-
/** Client secret or credential-store key (format: "credential"). */
|
|
25
|
-
readonly client_secret: string;
|
|
26
|
-
readonly client_name?: string;
|
|
27
|
-
readonly scope?: string;
|
|
28
|
-
}
|
|
29
|
-
export interface McpAuthPrivateKeyJwt {
|
|
30
|
-
readonly type: "private_key_jwt";
|
|
31
|
-
readonly client_id: string;
|
|
32
|
-
/** PEM / JWK private key or credential-store key (format: "credential"). */
|
|
33
|
-
readonly private_key: string;
|
|
34
|
-
readonly algorithm: string;
|
|
35
|
-
readonly client_name?: string;
|
|
36
|
-
readonly jwt_lifetime_seconds?: number;
|
|
37
|
-
readonly scope?: string;
|
|
38
|
-
}
|
|
39
|
-
export interface McpAuthStaticPrivateKeyJwt {
|
|
40
|
-
readonly type: "static_private_key_jwt";
|
|
41
|
-
readonly client_id: string;
|
|
42
|
-
/** Pre-built JWT assertion or credential-store key (format: "credential"). */
|
|
43
|
-
readonly jwt_bearer_assertion: string;
|
|
44
|
-
readonly client_name?: string;
|
|
45
|
-
readonly scope?: string;
|
|
46
|
-
}
|
|
47
|
-
export interface McpAuthAuthorizationCode {
|
|
48
|
-
readonly type: "authorization_code";
|
|
49
|
-
readonly client_id: string;
|
|
50
|
-
readonly client_secret?: string;
|
|
51
|
-
readonly redirect_url: string;
|
|
52
|
-
readonly scope?: string;
|
|
53
|
-
}
|
|
54
|
-
export type McpAuthConfig = McpAuthNone | McpAuthBearer | McpAuthClientCredentials | McpAuthPrivateKeyJwt | McpAuthStaticPrivateKeyJwt | McpAuthAuthorizationCode;
|
|
55
|
-
export declare const mcpAuthConfigSchema: {
|
|
56
|
-
readonly properties: {
|
|
57
|
-
readonly auth_type: {
|
|
58
|
-
readonly type: "string";
|
|
59
|
-
readonly enum: readonly ["none", "bearer", "client_credentials", "private_key_jwt", "static_private_key_jwt", "authorization_code"];
|
|
60
|
-
readonly title: "Auth Type";
|
|
61
|
-
readonly description: "Authentication method for connecting to the MCP server";
|
|
62
|
-
readonly default: "none";
|
|
63
|
-
};
|
|
64
|
-
readonly auth_token: {
|
|
65
|
-
readonly type: "string";
|
|
66
|
-
readonly format: "credential";
|
|
67
|
-
readonly title: "Bearer Token";
|
|
68
|
-
readonly description: "Static bearer token or API key (for bearer auth)";
|
|
69
|
-
};
|
|
70
|
-
readonly auth_client_id: {
|
|
71
|
-
readonly type: "string";
|
|
72
|
-
readonly title: "Client ID";
|
|
73
|
-
readonly description: "OAuth client ID (for OAuth auth types)";
|
|
74
|
-
};
|
|
75
|
-
readonly auth_client_secret: {
|
|
76
|
-
readonly type: "string";
|
|
77
|
-
readonly format: "credential";
|
|
78
|
-
readonly title: "Client Secret";
|
|
79
|
-
readonly description: "OAuth client secret (for client_credentials auth)";
|
|
80
|
-
};
|
|
81
|
-
readonly auth_private_key: {
|
|
82
|
-
readonly type: "string";
|
|
83
|
-
readonly format: "credential";
|
|
84
|
-
readonly title: "Private Key";
|
|
85
|
-
readonly description: "PEM or JWK private key (for private_key_jwt auth)";
|
|
86
|
-
};
|
|
87
|
-
readonly auth_algorithm: {
|
|
88
|
-
readonly type: "string";
|
|
89
|
-
readonly title: "Algorithm";
|
|
90
|
-
readonly description: "JWT signing algorithm, e.g. RS256, ES256 (for private_key_jwt auth)";
|
|
91
|
-
};
|
|
92
|
-
readonly auth_jwt_bearer_assertion: {
|
|
93
|
-
readonly type: "string";
|
|
94
|
-
readonly format: "credential";
|
|
95
|
-
readonly title: "JWT Assertion";
|
|
96
|
-
readonly description: "Pre-built JWT assertion (for static_private_key_jwt auth)";
|
|
97
|
-
};
|
|
98
|
-
readonly auth_redirect_url: {
|
|
99
|
-
readonly type: "string";
|
|
100
|
-
readonly format: "uri";
|
|
101
|
-
readonly title: "Redirect URL";
|
|
102
|
-
readonly description: "OAuth redirect URL (for authorization_code auth)";
|
|
103
|
-
};
|
|
104
|
-
readonly auth_scope: {
|
|
105
|
-
readonly type: "string";
|
|
106
|
-
readonly title: "Scope";
|
|
107
|
-
readonly description: "OAuth scope (space-separated)";
|
|
108
|
-
};
|
|
109
|
-
readonly auth_client_name: {
|
|
110
|
-
readonly type: "string";
|
|
111
|
-
readonly title: "Client Name";
|
|
112
|
-
readonly description: "Optional OAuth client display name";
|
|
113
|
-
};
|
|
114
|
-
readonly auth_jwt_lifetime_seconds: {
|
|
115
|
-
readonly type: "number";
|
|
116
|
-
readonly title: "JWT Lifetime";
|
|
117
|
-
readonly description: "JWT lifetime in seconds (default: 300)";
|
|
118
|
-
readonly minimum: 1;
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
readonly allOf: readonly [{
|
|
122
|
-
readonly if: {
|
|
123
|
-
readonly properties: {
|
|
124
|
-
readonly auth_type: {
|
|
125
|
-
readonly const: "bearer";
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
readonly required: readonly ["auth_type"];
|
|
129
|
-
};
|
|
130
|
-
readonly then: {
|
|
131
|
-
readonly required: readonly ["auth_token"];
|
|
132
|
-
readonly properties: {
|
|
133
|
-
readonly auth_token: true;
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
}, {
|
|
137
|
-
readonly if: {
|
|
138
|
-
readonly properties: {
|
|
139
|
-
readonly auth_type: {
|
|
140
|
-
readonly const: "client_credentials";
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
readonly required: readonly ["auth_type"];
|
|
144
|
-
};
|
|
145
|
-
readonly then: {
|
|
146
|
-
readonly required: readonly ["auth_client_id", "auth_client_secret"];
|
|
147
|
-
readonly properties: {
|
|
148
|
-
readonly auth_client_id: true;
|
|
149
|
-
readonly auth_client_secret: true;
|
|
150
|
-
readonly auth_client_name: true;
|
|
151
|
-
readonly auth_scope: true;
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
}, {
|
|
155
|
-
readonly if: {
|
|
156
|
-
readonly properties: {
|
|
157
|
-
readonly auth_type: {
|
|
158
|
-
readonly const: "private_key_jwt";
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
|
-
readonly required: readonly ["auth_type"];
|
|
162
|
-
};
|
|
163
|
-
readonly then: {
|
|
164
|
-
readonly required: readonly ["auth_client_id", "auth_private_key", "auth_algorithm"];
|
|
165
|
-
readonly properties: {
|
|
166
|
-
readonly auth_client_id: true;
|
|
167
|
-
readonly auth_private_key: true;
|
|
168
|
-
readonly auth_algorithm: true;
|
|
169
|
-
readonly auth_client_name: true;
|
|
170
|
-
readonly auth_jwt_lifetime_seconds: true;
|
|
171
|
-
readonly auth_scope: true;
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
}, {
|
|
175
|
-
readonly if: {
|
|
176
|
-
readonly properties: {
|
|
177
|
-
readonly auth_type: {
|
|
178
|
-
readonly const: "static_private_key_jwt";
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
readonly required: readonly ["auth_type"];
|
|
182
|
-
};
|
|
183
|
-
readonly then: {
|
|
184
|
-
readonly required: readonly ["auth_client_id", "auth_jwt_bearer_assertion"];
|
|
185
|
-
readonly properties: {
|
|
186
|
-
readonly auth_client_id: true;
|
|
187
|
-
readonly auth_jwt_bearer_assertion: true;
|
|
188
|
-
readonly auth_client_name: true;
|
|
189
|
-
readonly auth_scope: true;
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
}, {
|
|
193
|
-
readonly if: {
|
|
194
|
-
readonly properties: {
|
|
195
|
-
readonly auth_type: {
|
|
196
|
-
readonly const: "authorization_code";
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
readonly required: readonly ["auth_type"];
|
|
200
|
-
};
|
|
201
|
-
readonly then: {
|
|
202
|
-
readonly required: readonly ["auth_client_id", "auth_redirect_url"];
|
|
203
|
-
readonly properties: {
|
|
204
|
-
readonly auth_client_id: true;
|
|
205
|
-
readonly auth_client_secret: true;
|
|
206
|
-
readonly auth_redirect_url: true;
|
|
207
|
-
readonly auth_scope: true;
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
}];
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* Constructs a typed McpAuthConfig from flat schema properties.
|
|
214
|
-
* Used by `createMcpClient()` to normalize the config.
|
|
215
|
-
* Returns `undefined` if required fields for the selected auth type are missing.
|
|
216
|
-
*/
|
|
217
|
-
export declare function buildAuthConfig(flat: Record<string, unknown>): McpAuthConfig | undefined;
|
|
218
|
-
//# sourceMappingURL=McpAuthTypes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"McpAuthTypes.d.ts","sourceRoot":"","sources":["../../src/mcp/McpAuthTypes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH;;GAEG;AACH,eAAO,MA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