@easynet/agent-tool-hub 1.0.6 → 1.0.8

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as ToolSpec, E as ExecContext, a as Evidence, b as ToolRegistry, c as ToolAdapter, S as SkillDefinition, d as SkillFrontmatter, e as SkillResource, f as ToolKind, C as Capability, g as CostHints, h as ToolHubInitOptions } from './toolhub-runtime-CQkP4QVW.js';
2
- export { A as AnyToolEvent, B as BudgetConfig, i as BudgetManager, j as BudgetOptions, k as ComfyUIAdapter, l as ComfyUIAdapterOptions, m as ComfyUIHistoryEntry, n as ComfyUIHttpClient, o as ComfyUIQueueResponse, p as CoreAdapter, q as CoreToolContext, r as CoreToolHandler, s as CoreToolResult, t as CoreToolsConfig, u as CoreToolsUserConfig, v as CounterValue, D as DEFAULT_CORE_TOOLS_CONFIG, w as DebugOptions, x as EventListener, y as EventLog, H as HistogramValue, z as HttpClient, I as InvokeOptions, J as JobCompletedEvent, F as JobFailedEvent, G as JobSubmittedEvent, L as LangChainAdapter, K as LangChainAdapterOptions, M as LangChainToolLike, N as LogEntry, O as LogLevel, P as Logger, Q as MCPAdapter, R as MCPAdapterOptions, U as MCPCallResult, V as MCPClientLike, W as MCPToolDefinition, X as Metrics, Y as N8nAdapter, Z as N8nAdapterOptions, _ as N8nInvokeMode, $ as N8nLocalAdapter, a0 as N8nLocalAdapterOptions, a1 as PTCRuntime, a2 as PTCRuntimeConfig, a3 as PolicyCheckResult, a4 as PolicyConfig, a5 as PolicyDeniedError, a6 as PolicyDeniedEvent, a7 as PolicyEngine, a8 as ResolvedDebugOptions, a9 as RetryEvent, aa as SchemaValidationError, ab as SchemaValidator, ac as SkillAdapter, ad as SkillAdapterOptions, ae as SkillContext, af as SkillHandler, ag as SkillInstructionResult, ah as SkillInvocationContext, ai as SkillManifestError, aj as SkillOutput, ak as Span, al as SpanEvent, am as ToolCalledEvent, an as ToolDescription, ao as ToolError, ap as ToolEvent, aq as ToolEventType, ar as ToolHub, as as ToolIntent, at as ToolMetadata, au as ToolResult, av as ToolResultEvent, aw as ToolSearchQuery, ax as Tracing, ay as ValidationResult, az as createAgentToolHub, aA as createLogger, aB as createToolHub, aC as createToolHubAndInitFromConfig, aD as registerCoreTools, aE as sanitizeForLog, aF as summarizeForLog, aG as validateFrontmatter } from './toolhub-runtime-CQkP4QVW.js';
1
+ import { T as ToolSpec, E as ExecContext, a as Evidence, b as ToolRegistry, c as ToolAdapter, S as SkillDefinition, d as SkillFrontmatter, e as SkillResource, f as ToolKind, C as Capability, g as CostHints, h as ToolHubInitOptions } from './toolhub-runtime-Du3j3gS3.js';
2
+ export { A as AgentToolHub, i as AnyToolEvent, B as BudgetConfig, j as BudgetManager, k as BudgetOptions, l as ComfyUIAdapter, m as ComfyUIAdapterOptions, n as ComfyUIHistoryEntry, o as ComfyUIHttpClient, p as ComfyUIQueueResponse, q as CoreAdapter, r as CoreToolContext, s as CoreToolHandler, t as CoreToolResult, u as CoreToolsConfig, v as CoreToolsUserConfig, w as CounterValue, D as DEFAULT_CORE_TOOLS_CONFIG, x as DebugOptions, y as EventListener, z as EventLog, H as HistogramValue, F as HttpClient, I as InvokeOptions, J as JobCompletedEvent, G as JobFailedEvent, K as JobSubmittedEvent, L as LangChainAdapter, M as LangChainAdapterOptions, N as LangChainToolLike, O as LogEntry, P as LogLevel, Q as Logger, R as MCPAdapter, U as MCPAdapterOptions, V as MCPCallResult, W as MCPClientLike, X as MCPToolDefinition, Y as Metrics, Z as N8nAdapter, _ as N8nAdapterOptions, $ as N8nInvokeMode, a0 as N8nLocalAdapter, a1 as N8nLocalAdapterOptions, a2 as PTCRuntime, a3 as PTCRuntimeConfig, a4 as PolicyCheckResult, a5 as PolicyConfig, a6 as PolicyDeniedError, a7 as PolicyDeniedEvent, a8 as PolicyEngine, a9 as ResolvedDebugOptions, aa as RetryEvent, ab as SchemaValidationError, ac as SchemaValidator, ad as SkillAdapter, ae as SkillAdapterOptions, af as SkillContext, ag as SkillHandler, ah as SkillInstructionResult, ai as SkillInvocationContext, aj as SkillManifestError, ak as SkillOutput, al as Span, am as SpanEvent, an as ToolCalledEvent, ao as ToolDescription, ap as ToolError, aq as ToolEvent, ar as ToolEventType, as as ToolHub, at as ToolIntent, au as ToolMetadata, av as ToolResult, aw as ToolResultEvent, ax as ToolSearchQuery, ay as Tracing, az as ValidationResult, aA as createAgentToolHub, aB as createLogger, aC as createToolHub, aD as createToolHubAndInitFromConfig, aE as registerCoreTools, aF as sanitizeForLog, aG as summarizeForLog, aH as validateFrontmatter } from './toolhub-runtime-Du3j3gS3.js';
3
3
  import '@easynet/n8n-local';
4
4
  import 'ajv';
5
5
  import 'cockatiel';
@@ -541,6 +541,58 @@ declare class DiscoveryError extends Error {
541
541
  constructor(toolDir: string, phase: "manifest" | "load" | "validate", message: string, cause?: Error);
542
542
  }
543
543
 
544
+ /**
545
+ * Minimal client for OpenAI-compatible chat completions API.
546
+ * Use createOpenAICompatibleClient(baseUrl, model, apiKey?) and then .chat(messages).
547
+ */
548
+ interface ChatMessage {
549
+ role: "system" | "user" | "assistant";
550
+ content: string;
551
+ }
552
+ interface ChatOptions {
553
+ /** Request timeout in milliseconds. Default 60000. */
554
+ timeoutMs?: number;
555
+ }
556
+ interface ChatResult {
557
+ /** Content of the first assistant reply. */
558
+ content: string;
559
+ /** Raw response from the API (for debugging or advanced use). */
560
+ raw: unknown;
561
+ }
562
+ interface OpenAICompatibleClientConfig {
563
+ /** Base URL of the API (e.g. https://api.openai.com/v1). Trailing slash is optional. */
564
+ baseUrl: string;
565
+ /** Model name (e.g. gpt-4o-mini). */
566
+ model: string;
567
+ /** API key; optional if the provider does not require it. */
568
+ apiKey?: string;
569
+ }
570
+ /**
571
+ * Creates an OpenAI-compatible LLM client.
572
+ *
573
+ * @param baseUrl - LLM API base URL (e.g. https://api.openai.com/v1)
574
+ * @param model - Model name (e.g. gpt-4o-mini)
575
+ * @param apiKey - Optional API key
576
+ * @returns Client instance with .chat(messages, options?)
577
+ */
578
+ declare function createOpenAICompatibleClient(baseUrl: string, model: string, apiKey?: string): OpenAICompatibleClient;
579
+ declare class OpenAICompatibleClient {
580
+ private readonly baseUrl;
581
+ private readonly model;
582
+ private readonly apiKey?;
583
+ constructor(config: OpenAICompatibleClientConfig);
584
+ /**
585
+ * Send chat messages and return the first assistant reply.
586
+ *
587
+ * @param messages - Array of { role, content }
588
+ * @param options - Optional timeout
589
+ * @returns Promise of { content, raw }
590
+ */
591
+ chat(messages: ChatMessage[], options?: ChatOptions): Promise<ChatResult>;
592
+ }
593
+
594
+ /** Default config filename used when no path is given (e.g. AgentToolHub(), CLI). */
595
+ declare const DEFAULT_CONFIG_FILE = "toolhub.yaml";
544
596
  interface ToolHubConfigLoadResult {
545
597
  configPath: string;
546
598
  rawConfig: unknown;
@@ -549,4 +601,4 @@ interface ToolHubConfigLoadResult {
549
601
  declare function mapToolHubConfig(raw: unknown, configDir: string): ToolHubInitOptions;
550
602
  declare function loadToolHubConfig(configPath: string): Promise<ToolHubConfigLoadResult>;
551
603
 
552
- export { AsyncJobManager, type BuildEvidenceOptions, Capability, CostHints, type DirectoryDiscoveryOptions, DirectoryScanner, type DirectoryScannerOptions, DirectoryToolAdapter, type DiscoverableKind, Discovery, DiscoveryError, type DiscoverySource, Evidence, ExecContext, InMemoryJobStore, type Job, type JobStatus, type JobStore, type LoadedTool, type MCPConnectionInfo, MCPProcessManager, type MCPServerConfig, type RetryOptions, SkillDefinition, SkillFrontmatter, SkillResource, type SubmitJobOptions, ToolAdapter, type ToolHubConfigLoadResult, ToolHubInitOptions, ToolKind, type ToolManifest, ToolRegistry, ToolSpec, buildEvidence, createDirectoryDiscoverySource, createTaggedError, deletePathSpec, downloadFileSpec, fetchJsonSpec, fetchTextSpec, hashTextSpec, headSpec, isIpInBlockedCidrs, isRetryable, jsonSelectSpec, listDirSpec, loadSkillDefinition, loadToolHubConfig, mapToolHubConfig, nowSpec, parseSkillMd, readTextSpec, resolveSandboxedPath, scanSkillResources, searchTextSpec, sha256Spec, templateRenderSpec, truncateSpec, validateUrl, withRetry, writeTextSpec };
604
+ export { AsyncJobManager, type BuildEvidenceOptions, Capability, type ChatMessage, type ChatOptions, type ChatResult, CostHints, DEFAULT_CONFIG_FILE, type DirectoryDiscoveryOptions, DirectoryScanner, type DirectoryScannerOptions, DirectoryToolAdapter, type DiscoverableKind, Discovery, DiscoveryError, type DiscoverySource, Evidence, ExecContext, InMemoryJobStore, type Job, type JobStatus, type JobStore, type LoadedTool, type MCPConnectionInfo, MCPProcessManager, type MCPServerConfig, OpenAICompatibleClient, type OpenAICompatibleClientConfig, type RetryOptions, SkillDefinition, SkillFrontmatter, SkillResource, type SubmitJobOptions, ToolAdapter, type ToolHubConfigLoadResult, ToolHubInitOptions, ToolKind, type ToolManifest, ToolRegistry, ToolSpec, buildEvidence, createDirectoryDiscoverySource, createOpenAICompatibleClient, createTaggedError, deletePathSpec, downloadFileSpec, fetchJsonSpec, fetchTextSpec, hashTextSpec, headSpec, isIpInBlockedCidrs, isRetryable, jsonSelectSpec, listDirSpec, loadSkillDefinition, loadToolHubConfig, mapToolHubConfig, nowSpec, parseSkillMd, readTextSpec, resolveSandboxedPath, scanSkillResources, searchTextSpec, sha256Spec, templateRenderSpec, truncateSpec, validateUrl, withRetry, writeTextSpec };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { createAgentToolHub, createToolHubAndInitFromConfig } from './chunk-57LVNNHL.js';
2
- import { DirectoryScanner } from './chunk-HPDQEW2P.js';
3
- export { BudgetManager, ComfyUIAdapter, CoreAdapter, DEFAULT_CORE_TOOLS_CONFIG, DirectoryScanner, DiscoveryError, EventLog, LangChainAdapter, MCPAdapter, Metrics, N8nAdapter, PTCRuntime, PolicyDeniedError, PolicyEngine, SchemaValidationError, SchemaValidator, SkillAdapter, SkillManifestError, ToolHub, ToolRegistry, Tracing, buildEvidence, createTaggedError, createToolHub, deletePathSpec, downloadFileSpec, fetchJsonSpec, fetchTextSpec, hashTextSpec, headSpec, isIpInBlockedCidrs, isRetryable, jsonSelectSpec, listDirSpec, loadSkillDefinition, loadToolHubConfig, mapToolHubConfig, nowSpec, parseSkillMd, readTextSpec, registerCoreTools, resolveSandboxedPath, scanSkillResources, searchTextSpec, sha256Spec, templateRenderSpec, truncateSpec, validateFrontmatter, validateUrl, withRetry, writeTextSpec } from './chunk-HPDQEW2P.js';
1
+ export { AgentToolHub, createAgentToolHub, createToolHubAndInitFromConfig } from './chunk-MMNUEPKB.js';
2
+ import { DirectoryScanner } from './chunk-QSBCXLMH.js';
3
+ export { BudgetManager, ComfyUIAdapter, CoreAdapter, DEFAULT_CONFIG_FILE, DEFAULT_CORE_TOOLS_CONFIG, DirectoryScanner, DiscoveryError, EventLog, LangChainAdapter, MCPAdapter, Metrics, N8nAdapter, PTCRuntime, PolicyDeniedError, PolicyEngine, SchemaValidationError, SchemaValidator, SkillAdapter, SkillManifestError, ToolHub, ToolRegistry, Tracing, buildEvidence, createTaggedError, createToolHub, deletePathSpec, downloadFileSpec, fetchJsonSpec, fetchTextSpec, hashTextSpec, headSpec, isIpInBlockedCidrs, isRetryable, jsonSelectSpec, listDirSpec, loadSkillDefinition, loadToolHubConfig, mapToolHubConfig, nowSpec, parseSkillMd, readTextSpec, registerCoreTools, resolveSandboxedPath, scanSkillResources, searchTextSpec, sha256Spec, templateRenderSpec, truncateSpec, validateFrontmatter, validateUrl, withRetry, writeTextSpec } from './chunk-QSBCXLMH.js';
4
4
  export { N8nLocalAdapter } from './chunk-MHEFFZBB.js';
5
5
  export { createLogger, sanitizeForLog, summarizeForLog } from './chunk-YSYEED4K.js';
6
6
  import { v4 } from 'uuid';
@@ -353,6 +353,69 @@ var MCPProcessManager = class {
353
353
  }
354
354
  };
355
355
 
356
- export { AsyncJobManager, DirectoryToolAdapter, Discovery, InMemoryJobStore, MCPProcessManager, createDirectoryDiscoverySource };
356
+ // src/llm/OpenAICompatibleClient.ts
357
+ function createOpenAICompatibleClient(baseUrl, model, apiKey) {
358
+ return new OpenAICompatibleClient({ baseUrl, model, apiKey });
359
+ }
360
+ var OpenAICompatibleClient = class {
361
+ baseUrl;
362
+ model;
363
+ apiKey;
364
+ constructor(config) {
365
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
366
+ this.model = config.model;
367
+ this.apiKey = config.apiKey;
368
+ }
369
+ /**
370
+ * Send chat messages and return the first assistant reply.
371
+ *
372
+ * @param messages - Array of { role, content }
373
+ * @param options - Optional timeout
374
+ * @returns Promise of { content, raw }
375
+ */
376
+ async chat(messages, options) {
377
+ const timeoutMs = options?.timeoutMs ?? 6e4;
378
+ const url = `${this.baseUrl}/chat/completions`;
379
+ const headers = {
380
+ "Content-Type": "application/json"
381
+ };
382
+ if (this.apiKey) {
383
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
384
+ }
385
+ const controller = new AbortController();
386
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
387
+ let response;
388
+ try {
389
+ response = await fetch(url, {
390
+ method: "POST",
391
+ headers,
392
+ body: JSON.stringify({
393
+ model: this.model,
394
+ messages: messages.map((m) => ({ role: m.role, content: m.content }))
395
+ }),
396
+ signal: controller.signal
397
+ });
398
+ } catch (err) {
399
+ clearTimeout(timer);
400
+ if (err instanceof Error && err.name === "AbortError") {
401
+ throw new Error(`LLM request timed out after ${timeoutMs}ms`);
402
+ }
403
+ throw err;
404
+ }
405
+ clearTimeout(timer);
406
+ const raw = await response.json();
407
+ if (!response.ok) {
408
+ const errBody = typeof raw === "object" && raw !== null && "error" in raw ? raw.error : raw;
409
+ throw new Error(
410
+ `LLM API error ${response.status}: ${JSON.stringify(errBody)}`
411
+ );
412
+ }
413
+ const choices = raw.choices;
414
+ const content = Array.isArray(choices) && choices[0]?.message?.content != null ? String(choices[0].message.content) : "";
415
+ return { content, raw };
416
+ }
417
+ };
418
+
419
+ export { AsyncJobManager, DirectoryToolAdapter, Discovery, InMemoryJobStore, MCPProcessManager, OpenAICompatibleClient, createDirectoryDiscoverySource, createOpenAICompatibleClient };
357
420
  //# sourceMappingURL=index.js.map
358
421
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/registry/Discovery.ts","../src/jobs/AsyncJobManager.ts","../src/discovery/DirectoryDiscoverySource.ts","../src/discovery/MCPProcessManager.ts"],"names":["uuidv4"],"mappings":";;;;;;;;;AAqBO,IAAM,YAAN,MAAgB;AAAA,EACJ,OAAA,uBAAc,GAAA,EAA6B;AAAA,EAC3C,MAAA,uBAAa,GAAA,EAA4C;AAAA,EACzD,QAAA;AAAA,EACA,WAAA,uBAAkB,GAAA,EAAoB;AAAA,EACtC,eAAA,uBAAsB,GAAA,EAAyB;AAAA;AAAA,EAEhE,YAAY,QAAA,EAAwB;AAClC,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,MAAA,EAA+B;AACvC,IAAA,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAO,EAAA,EAAI,MAAM,CAAA;AAClC,IAAA,IAAA,CAAK,gBAAgB,GAAA,CAAI,MAAA,CAAO,EAAA,kBAAI,IAAI,KAAK,CAAA;AAG7C,IAAA,IAAI,MAAA,CAAO,iBAAA,IAAqB,MAAA,CAAO,iBAAA,GAAoB,CAAA,EAAG;AAC5D,MAAA,MAAM,KAAA,GAAQ,WAAA;AAAA,QACZ,MAAM,KAAK,IAAA,CAAK,OAAA,CAAQ,OAAO,EAAE,CAAA;AAAA,QACjC,MAAA,CAAO;AAAA,OACT;AAEA,MAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,OAAA,IAAW,KAAA,EAAO;AACjD,QAAA,KAAA,CAAM,KAAA,EAAM;AAAA,MACd;AACA,MAAA,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,MAAA,CAAO,EAAA,EAAI,KAAK,CAAA;AAAA,IAClC;AAGA,IA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AAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,QAAA,EAA2B;AAChC,IAAA,OAAO,IAAA,CAAK,WAAA,CAAY,MAAA,CAAO,QAAQ,CAAA;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAKA,YAAA,GAAyB;AACvB,IAAA,OAAO,CAAC,GAAG,IAAA,CAAK,WAAA,CAAY,MAAM,CAAA;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA,GAAgB;AACd,IAAA,IAAA,CAAK,YAAY,KAAA,EAAM;AAAA,EACzB;AACF","file":"index.js","sourcesContent":["import type { ToolAdapter, ToolSpec } from \"../types/ToolSpec.js\";\nimport type { ToolRegistry } from \"./ToolRegistry.js\";\n\n/**\n * Discovery source configuration.\n */\nexport interface DiscoverySource {\n /** Unique identifier for this source */\n id: string;\n /** The adapter that supports listTools() */\n adapter: ToolAdapter;\n /** Refresh interval in ms (0 = manual only) */\n refreshIntervalMs?: number;\n /** Whether to auto-discover on startup */\n autoDiscover?: boolean;\n}\n\n/**\n * Discovery manager that pulls tool specs from adapters\n * and registers them into the ToolRegistry.\n */\nexport class Discovery {\n private readonly sources = new Map<string, DiscoverySource>();\n private readonly timers = new Map<string, ReturnType<typeof setInterval>>();\n private readonly registry: ToolRegistry;\n private readonly lastRefresh = new Map<string, number>();\n private readonly discoveredTools = new Map<string, Set<string>>(); // sourceId → tool names\n\n constructor(registry: ToolRegistry) {\n this.registry = registry;\n }\n\n /**\n * Add a discovery source.\n */\n addSource(source: DiscoverySource): void {\n this.sources.set(source.id, source);\n this.discoveredTools.set(source.id, new Set());\n\n // Start auto-refresh if configured\n if (source.refreshIntervalMs && source.refreshIntervalMs > 0) {\n const timer = setInterval(\n () => void this.refresh(source.id),\n source.refreshIntervalMs,\n );\n // Unref so it doesn't prevent process exit\n if (typeof timer === \"object\" && \"unref\" in timer) {\n timer.unref();\n }\n this.timers.set(source.id, timer);\n }\n\n // Auto-discover on add if configured\n if (source.autoDiscover) {\n void this.refresh(source.id);\n }\n }\n\n /**\n * Remove a discovery source and its registered tools.\n */\n removeSource(id: string): void {\n const timer = this.timers.get(id);\n if (timer) {\n clearInterval(timer);\n this.timers.delete(id);\n }\n\n // Unregister tools from this source\n const tools = this.discoveredTools.get(id);\n if (tools) {\n for (const name of tools) {\n this.registry.unregister(name);\n }\n }\n\n this.sources.delete(id);\n this.discoveredTools.delete(id);\n this.lastRefresh.delete(id);\n }\n\n /**\n * Refresh tools from a specific source (or all sources).\n */\n async refresh(sourceId?: string): Promise<ToolSpec[]> {\n if (sourceId) {\n return this.refreshSource(sourceId);\n }\n\n const allSpecs: ToolSpec[] = [];\n for (const id of this.sources.keys()) {\n const specs = await this.refreshSource(id);\n allSpecs.push(...specs);\n }\n return allSpecs;\n }\n\n /**\n * Get the last refresh timestamp for a source.\n */\n getLastRefresh(sourceId: string): number | undefined {\n return this.lastRefresh.get(sourceId);\n }\n\n /**\n * Get all registered source IDs.\n */\n getSources(): string[] {\n return [...this.sources.keys()];\n }\n\n /**\n * Stop all refresh timers.\n */\n dispose(): void {\n for (const timer of this.timers.values()) {\n clearInterval(timer);\n }\n this.timers.clear();\n }\n\n private async refreshSource(sourceId: string): Promise<ToolSpec[]> {\n const source = this.sources.get(sourceId);\n if (!source) return [];\n\n if (!source.adapter.listTools) {\n return [];\n }\n\n try {\n const specs = await source.adapter.listTools();\n const currentTools = this.discoveredTools.get(sourceId) ?? new Set();\n const newToolNames = new Set(specs.map((s) => s.name));\n\n // Unregister tools that are no longer present\n for (const name of currentTools) {\n if (!newToolNames.has(name)) {\n this.registry.unregister(name);\n }\n }\n\n // Register/update tools\n for (const spec of specs) {\n this.registry.register(spec);\n }\n\n this.discoveredTools.set(sourceId, newToolNames);\n this.lastRefresh.set(sourceId, Date.now());\n\n return specs;\n } catch (error) {\n // Log but don't throw - discovery failures shouldn't crash the system\n console.error(`Discovery refresh failed for source ${sourceId}:`, error);\n return [];\n }\n }\n}\n","import { v4 as uuidv4 } from \"uuid\";\nimport { EventEmitter } from \"eventemitter3\";\n\n/**\n * Job status in the lifecycle.\n */\nexport type JobStatus = \"queued\" | \"running\" | \"completed\" | \"failed\";\n\n/**\n * A job record representing an async tool invocation.\n */\nexport interface Job {\n jobId: string;\n toolName: string;\n requestId: string;\n taskId: string;\n status: JobStatus;\n createdAt: number; // epoch ms\n updatedAt: number;\n result?: unknown;\n error?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Options for submitting a job.\n */\nexport interface SubmitJobOptions {\n toolName: string;\n requestId: string;\n taskId: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Job store interface for pluggable backends.\n */\nexport interface JobStore {\n set(jobId: string, job: Job): Promise<void>;\n get(jobId: string): Promise<Job | undefined>;\n list(filter?: { toolName?: string; status?: JobStatus }): Promise<Job[]>;\n delete(jobId: string): Promise<void>;\n}\n\n/**\n * In-memory job store (default, for PoC and testing).\n */\nexport class InMemoryJobStore implements JobStore {\n private readonly jobs = new Map<string, Job>();\n\n async set(jobId: string, job: Job): Promise<void> {\n this.jobs.set(jobId, job);\n }\n\n async get(jobId: string): Promise<Job | undefined> {\n return this.jobs.get(jobId);\n }\n\n async list(filter?: { toolName?: string; status?: JobStatus }): Promise<Job[]> {\n let results = [...this.jobs.values()];\n if (filter?.toolName) {\n results = results.filter((j) => j.toolName === filter.toolName);\n }\n if (filter?.status) {\n results = results.filter((j) => j.status === filter.status);\n }\n return results;\n }\n\n async delete(jobId: string): Promise<void> {\n this.jobs.delete(jobId);\n }\n\n get size(): number {\n return this.jobs.size;\n }\n\n clear(): void {\n this.jobs.clear();\n }\n}\n\n/**\n * Async Job Manager: unified async task handling for tools.\n * Provides submit/poll/getResult pattern.\n */\nexport class AsyncJobManager {\n private readonly store: JobStore;\n private readonly emitter = new EventEmitter();\n private readonly ttlMs: number;\n private cleanupTimer?: ReturnType<typeof setInterval>;\n\n constructor(options: { store?: JobStore; ttlMs?: number } = {}) {\n this.store = options.store ?? new InMemoryJobStore();\n this.ttlMs = options.ttlMs ?? 3600_000; // 1 hour default TTL\n this.startCleanup();\n }\n\n /**\n * Submit a new async job.\n */\n async submit(options: SubmitJobOptions): Promise<Job> {\n const now = Date.now();\n const job: Job = {\n jobId: uuidv4(),\n toolName: options.toolName,\n requestId: options.requestId,\n taskId: options.taskId,\n status: \"queued\",\n createdAt: now,\n updatedAt: now,\n metadata: options.metadata,\n };\n\n await this.store.set(job.jobId, job);\n this.emitter.emit(\"submitted\", job);\n return job;\n }\n\n /**\n * Update job status to running.\n */\n async markRunning(jobId: string): Promise<Job | undefined> {\n const job = await this.store.get(jobId);\n if (!job) return undefined;\n\n job.status = \"running\";\n job.updatedAt = Date.now();\n await this.store.set(jobId, job);\n this.emitter.emit(\"running\", job);\n return job;\n }\n\n /**\n * Complete a job with a result.\n */\n async complete(jobId: string, result: unknown): Promise<Job | undefined> {\n const job = await this.store.get(jobId);\n if (!job) return undefined;\n\n job.status = \"completed\";\n job.result = result;\n job.updatedAt = Date.now();\n await this.store.set(jobId, job);\n this.emitter.emit(\"completed\", job);\n return job;\n }\n\n /**\n * Fail a job with an error message.\n */\n async fail(jobId: string, error: string): Promise<Job | undefined> {\n const job = await this.store.get(jobId);\n if (!job) return undefined;\n\n job.status = \"failed\";\n job.error = error;\n job.updatedAt = Date.now();\n await this.store.set(jobId, job);\n this.emitter.emit(\"failed\", job);\n return job;\n }\n\n /**\n * Get current job status.\n */\n async getStatus(jobId: string): Promise<JobStatus | undefined> {\n const job = await this.store.get(jobId);\n return job?.status;\n }\n\n /**\n * Get the full job record.\n */\n async getJob(jobId: string): Promise<Job | undefined> {\n return this.store.get(jobId);\n }\n\n /**\n * Get the result of a completed job.\n */\n async getResult(jobId: string): Promise<unknown | undefined> {\n const job = await this.store.get(jobId);\n if (!job || job.status !== \"completed\") return undefined;\n return job.result;\n }\n\n /**\n * List jobs with optional filter.\n */\n async list(filter?: {\n toolName?: string;\n status?: JobStatus;\n }): Promise<Job[]> {\n return this.store.list(filter);\n }\n\n /**\n * Subscribe to job events.\n */\n on(\n event: \"submitted\" | \"running\" | \"completed\" | \"failed\",\n listener: (job: Job) => void,\n ): () => void {\n this.emitter.on(event, listener);\n return () => this.emitter.off(event, listener);\n }\n\n /**\n * Stop cleanup timer.\n */\n dispose(): void {\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n this.cleanupTimer = undefined;\n }\n }\n\n private startCleanup(): void {\n // Run cleanup every TTL/2 interval\n const interval = Math.max(this.ttlMs / 2, 60_000);\n this.cleanupTimer = setInterval(() => void this.cleanup(), interval);\n if (typeof this.cleanupTimer === \"object\" && \"unref\" in this.cleanupTimer) {\n this.cleanupTimer.unref();\n }\n }\n\n private async cleanup(): Promise<void> {\n const now = Date.now();\n const all = await this.store.list();\n for (const job of all) {\n if (\n (job.status === \"completed\" || job.status === \"failed\") &&\n now - job.updatedAt > this.ttlMs\n ) {\n await this.store.delete(job.jobId);\n }\n }\n }\n}\n","import type { ToolAdapter, ToolSpec } from \"../types/ToolSpec.js\";\nimport type { ExecContext } from \"../types/ToolIntent.js\";\nimport type { DirectoryScannerOptions } from \"./types.js\";\nimport type { DiscoverySource } from \"../registry/Discovery.js\";\nimport { DirectoryScanner } from \"./DirectoryScanner.js\";\n\n/**\n * A ToolAdapter that discovers tools from filesystem directories.\n * Used as the adapter within a DiscoverySource for the Discovery system.\n *\n * Note: This adapter's invoke() is not called directly. Discovered tools\n * retain their original kind (mcp/langchain/skill/n8n) and are invoked\n * by the kind-specific adapter registered on PTCRuntime.\n */\nexport class DirectoryToolAdapter implements ToolAdapter {\n readonly kind = \"mcp\" as const; // Required by ToolAdapter but not used for routing\n private readonly scanner: DirectoryScanner;\n\n constructor(options: DirectoryScannerOptions) {\n this.scanner = new DirectoryScanner(options);\n }\n\n /**\n * Scan directories and return discovered tool specs.\n * Called by Discovery.refresh().\n */\n async listTools(): Promise<ToolSpec[]> {\n return this.scanner.scan();\n }\n\n /**\n * Not used — actual invocation routes through kind-specific adapters.\n */\n async invoke(\n _spec: ToolSpec,\n _args: unknown,\n _ctx: ExecContext,\n ): Promise<{ result: unknown }> {\n throw new Error(\n \"DirectoryToolAdapter.invoke() should not be called directly. \" +\n \"Tool execution is handled by the kind-specific adapter (MCPAdapter, LangChainAdapter, etc.).\",\n );\n }\n\n /**\n * Get the underlying scanner for direct usage.\n */\n getScanner(): DirectoryScanner {\n return this.scanner;\n }\n}\n\n/**\n * Options for creating a directory discovery source.\n */\nexport interface DirectoryDiscoveryOptions extends DirectoryScannerOptions {\n /** Refresh interval in ms (0 = manual only, default: 0) */\n refreshIntervalMs?: number;\n /** Whether to auto-discover on startup (default: true) */\n autoDiscover?: boolean;\n}\n\n/**\n * Factory: create a DiscoverySource for directory-based tool discovery.\n *\n * Usage:\n * ```ts\n * const discovery = new Discovery(registry);\n * discovery.addSource(\n * createDirectoryDiscoverySource(\"local-tools\", {\n * roots: [\"/path/to/tools\"],\n * namespace: \"local\",\n * refreshIntervalMs: 60_000,\n * autoDiscover: true,\n * })\n * );\n * ```\n */\nexport function createDirectoryDiscoverySource(\n id: string,\n options: DirectoryDiscoveryOptions,\n): DiscoverySource {\n const { refreshIntervalMs, autoDiscover, ...scannerOptions } = options;\n\n return {\n id,\n adapter: new DirectoryToolAdapter(scannerOptions),\n refreshIntervalMs: refreshIntervalMs ?? 0,\n autoDiscover: autoDiscover ?? true,\n };\n}\n","import type { MCPServerConfig } from \"./types.js\";\n\n/**\n * Connection info for an MCP server.\n */\nexport interface MCPConnectionInfo {\n /** Transport type: \"url\" for SSE/HTTP, \"stdio\" for command-based */\n type: \"url\" | \"stdio\";\n /** SSE/HTTP URL (when type=\"url\") */\n url?: string;\n /** Command to spawn (when type=\"stdio\") */\n command?: string;\n /** Command arguments (when type=\"stdio\") */\n args?: string[];\n /** Environment variables (when type=\"stdio\") */\n env?: Record<string, string>;\n}\n\n/**\n * Manages MCP server connection information extracted from directory discovery.\n *\n * This class provides connection configuration for MCP servers discovered\n * from mcp.json files. The actual MCP client creation and lifecycle management\n * is the consumer's responsibility (using @modelcontextprotocol/sdk or similar).\n *\n * Usage:\n * ```ts\n * const manager = new MCPProcessManager();\n * const info = manager.getConnectionInfo(\"my-tool\", mcpConfig);\n * if (info.type === \"stdio\") {\n * // Spawn process with info.command, info.args, info.env\n * } else {\n * // Connect SSE client to info.url\n * }\n * ```\n */\nexport class MCPProcessManager {\n private readonly connections = new Map<string, MCPConnectionInfo>();\n\n /**\n * Get connection info for an MCP tool based on its config.\n * Caches the result by tool name.\n */\n getConnectionInfo(toolName: string, config: MCPServerConfig): MCPConnectionInfo {\n const cached = this.connections.get(toolName);\n if (cached) return cached;\n\n const info: MCPConnectionInfo = config.url\n ? { type: \"url\", url: config.url }\n : {\n type: \"stdio\",\n command: config.command!,\n args: config.args,\n env: config.env,\n };\n\n this.connections.set(toolName, info);\n return info;\n }\n\n /**\n * Remove cached connection info for a tool.\n */\n remove(toolName: string): boolean {\n return this.connections.delete(toolName);\n }\n\n /**\n * Get all registered tool names.\n */\n getToolNames(): string[] {\n return [...this.connections.keys()];\n }\n\n /**\n * Clear all cached connection info.\n */\n dispose(): void {\n this.connections.clear();\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/registry/Discovery.ts","../src/jobs/AsyncJobManager.ts","../src/discovery/DirectoryDiscoverySource.ts","../src/discovery/MCPProcessManager.ts","../src/llm/OpenAICompatibleClient.ts"],"names":["uuidv4"],"mappings":";;;;;;;;;AAqBO,IAAM,YAAN,MAAgB;AAAA,EACJ,OAAA,uBAAc,GAAA,EAA6B;AAAA,EAC3C,MAAA,uBAAa,GAAA,EAA4C;AAAA,EACzD,QAAA;AAAA,EACA,WAAA,uBAAkB,GAAA,EAAoB;AAAA,EACtC,eAAA,uBAAsB,GAAA,EAAyB;AAAA;AAAA,EAEhE,YAAY,QAAA,EAAwB;AAClC,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,MAAA,EAA+B;AACvC,IAAA,IAAA,CAAK,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AA,CAAa,KAAK,CAAA;AAClB,MAAA,IAAI,GAAA,YAAe,KAAA,IAAS,GAAA,CAAI,IAAA,KAAS,YAAA,EAAc;AACrD,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+B,SAAS,CAAA,EAAA,CAAI,CAAA;AAAA,MAC9D;AACA,MAAA,MAAM,GAAA;AAAA,IACR;AACA,IAAA,YAAA,CAAa,KAAK,CAAA;AAElB,IAAA,MAAM,GAAA,GAAO,MAAM,QAAA,CAAS,IAAA,EAAK;AACjC,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,MAAM,OAAA,GACJ,OAAO,GAAA,KAAQ,QAAA,IAAY,QAAQ,IAAA,IAAQ,OAAA,IAAY,GAAA,GAClD,GAAA,CAA2B,KAAA,GAC5B,GAAA;AACN,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,iBAAiB,QAAA,CAAS,MAAM,KAAK,IAAA,CAAK,SAAA,CAAU,OAAO,CAAC,CAAA;AAAA,OAC9D;AAAA,IACF;AAEA,IAAA,MAAM,UAAW,GAAA,CAAgE,OAAA;AACjF,IAAA,MAAM,UACJ,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,IAAK,QAAQ,CAAC,CAAA,EAAG,OAAA,EAAS,OAAA,IAAW,OACtD,MAAA,CAAO,OAAA,CAAQ,CAAC,CAAA,CAAE,OAAA,CAAQ,OAAO,CAAA,GACjC,EAAA;AAEN,IAAA,OAAO,EAAE,SAAS,GAAA,EAAI;AAAA,EACxB;AACF","file":"index.js","sourcesContent":["import type { ToolAdapter, ToolSpec } from \"../types/ToolSpec.js\";\nimport type { ToolRegistry } from \"./ToolRegistry.js\";\n\n/**\n * Discovery source configuration.\n */\nexport interface DiscoverySource {\n /** Unique identifier for this source */\n id: string;\n /** The adapter that supports listTools() */\n adapter: ToolAdapter;\n /** Refresh interval in ms (0 = manual only) */\n refreshIntervalMs?: number;\n /** Whether to auto-discover on startup */\n autoDiscover?: boolean;\n}\n\n/**\n * Discovery manager that pulls tool specs from adapters\n * and registers them into the ToolRegistry.\n */\nexport class Discovery {\n private readonly sources = new Map<string, DiscoverySource>();\n private readonly timers = new Map<string, ReturnType<typeof setInterval>>();\n private readonly registry: ToolRegistry;\n private readonly lastRefresh = new Map<string, number>();\n private readonly discoveredTools = new Map<string, Set<string>>(); // sourceId → tool names\n\n constructor(registry: ToolRegistry) {\n this.registry = registry;\n }\n\n /**\n * Add a discovery source.\n */\n addSource(source: DiscoverySource): void {\n this.sources.set(source.id, source);\n this.discoveredTools.set(source.id, new Set());\n\n // Start auto-refresh if configured\n if (source.refreshIntervalMs && source.refreshIntervalMs > 0) {\n const timer = setInterval(\n () => void this.refresh(source.id),\n source.refreshIntervalMs,\n );\n // Unref so it doesn't prevent process exit\n if (typeof timer === \"object\" && \"unref\" in timer) {\n timer.unref();\n }\n this.timers.set(source.id, timer);\n }\n\n // Auto-discover on add if configured\n if (source.autoDiscover) {\n void this.refresh(source.id);\n }\n }\n\n /**\n * Remove a discovery source and its registered tools.\n */\n removeSource(id: string): void {\n const timer = this.timers.get(id);\n if (timer) {\n clearInterval(timer);\n this.timers.delete(id);\n }\n\n // Unregister tools from this source\n const tools = this.discoveredTools.get(id);\n if (tools) {\n for (const name of tools) {\n this.registry.unregister(name);\n }\n }\n\n this.sources.delete(id);\n this.discoveredTools.delete(id);\n this.lastRefresh.delete(id);\n }\n\n /**\n * Refresh tools from a specific source (or all sources).\n */\n async refresh(sourceId?: string): Promise<ToolSpec[]> {\n if (sourceId) {\n return this.refreshSource(sourceId);\n }\n\n const allSpecs: ToolSpec[] = [];\n for (const id of this.sources.keys()) {\n const specs = await this.refreshSource(id);\n allSpecs.push(...specs);\n }\n return allSpecs;\n }\n\n /**\n * Get the last refresh timestamp for a source.\n */\n getLastRefresh(sourceId: string): number | undefined {\n return this.lastRefresh.get(sourceId);\n }\n\n /**\n * Get all registered source IDs.\n */\n getSources(): string[] {\n return [...this.sources.keys()];\n }\n\n /**\n * Stop all refresh timers.\n */\n dispose(): void {\n for (const timer of this.timers.values()) {\n clearInterval(timer);\n }\n this.timers.clear();\n }\n\n private async refreshSource(sourceId: string): Promise<ToolSpec[]> {\n const source = this.sources.get(sourceId);\n if (!source) return [];\n\n if (!source.adapter.listTools) {\n return [];\n }\n\n try {\n const specs = await source.adapter.listTools();\n const currentTools = this.discoveredTools.get(sourceId) ?? new Set();\n const newToolNames = new Set(specs.map((s) => s.name));\n\n // Unregister tools that are no longer present\n for (const name of currentTools) {\n if (!newToolNames.has(name)) {\n this.registry.unregister(name);\n }\n }\n\n // Register/update tools\n for (const spec of specs) {\n this.registry.register(spec);\n }\n\n this.discoveredTools.set(sourceId, newToolNames);\n this.lastRefresh.set(sourceId, Date.now());\n\n return specs;\n } catch (error) {\n // Log but don't throw - discovery failures shouldn't crash the system\n console.error(`Discovery refresh failed for source ${sourceId}:`, error);\n return [];\n }\n }\n}\n","import { v4 as uuidv4 } from \"uuid\";\nimport { EventEmitter } from \"eventemitter3\";\n\n/**\n * Job status in the lifecycle.\n */\nexport type JobStatus = \"queued\" | \"running\" | \"completed\" | \"failed\";\n\n/**\n * A job record representing an async tool invocation.\n */\nexport interface Job {\n jobId: string;\n toolName: string;\n requestId: string;\n taskId: string;\n status: JobStatus;\n createdAt: number; // epoch ms\n updatedAt: number;\n result?: unknown;\n error?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Options for submitting a job.\n */\nexport interface SubmitJobOptions {\n toolName: string;\n requestId: string;\n taskId: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Job store interface for pluggable backends.\n */\nexport interface JobStore {\n set(jobId: string, job: Job): Promise<void>;\n get(jobId: string): Promise<Job | undefined>;\n list(filter?: { toolName?: string; status?: JobStatus }): Promise<Job[]>;\n delete(jobId: string): Promise<void>;\n}\n\n/**\n * In-memory job store (default, for PoC and testing).\n */\nexport class InMemoryJobStore implements JobStore {\n private readonly jobs = new Map<string, Job>();\n\n async set(jobId: string, job: Job): Promise<void> {\n this.jobs.set(jobId, job);\n }\n\n async get(jobId: string): Promise<Job | undefined> {\n return this.jobs.get(jobId);\n }\n\n async list(filter?: { toolName?: string; status?: JobStatus }): Promise<Job[]> {\n let results = [...this.jobs.values()];\n if (filter?.toolName) {\n results = results.filter((j) => j.toolName === filter.toolName);\n }\n if (filter?.status) {\n results = results.filter((j) => j.status === filter.status);\n }\n return results;\n }\n\n async delete(jobId: string): Promise<void> {\n this.jobs.delete(jobId);\n }\n\n get size(): number {\n return this.jobs.size;\n }\n\n clear(): void {\n this.jobs.clear();\n }\n}\n\n/**\n * Async Job Manager: unified async task handling for tools.\n * Provides submit/poll/getResult pattern.\n */\nexport class AsyncJobManager {\n private readonly store: JobStore;\n private readonly emitter = new EventEmitter();\n private readonly ttlMs: number;\n private cleanupTimer?: ReturnType<typeof setInterval>;\n\n constructor(options: { store?: JobStore; ttlMs?: number } = {}) {\n this.store = options.store ?? new InMemoryJobStore();\n this.ttlMs = options.ttlMs ?? 3600_000; // 1 hour default TTL\n this.startCleanup();\n }\n\n /**\n * Submit a new async job.\n */\n async submit(options: SubmitJobOptions): Promise<Job> {\n const now = Date.now();\n const job: Job = {\n jobId: uuidv4(),\n toolName: options.toolName,\n requestId: options.requestId,\n taskId: options.taskId,\n status: \"queued\",\n createdAt: now,\n updatedAt: now,\n metadata: options.metadata,\n };\n\n await this.store.set(job.jobId, job);\n this.emitter.emit(\"submitted\", job);\n return job;\n }\n\n /**\n * Update job status to running.\n */\n async markRunning(jobId: string): Promise<Job | undefined> {\n const job = await this.store.get(jobId);\n if (!job) return undefined;\n\n job.status = \"running\";\n job.updatedAt = Date.now();\n await this.store.set(jobId, job);\n this.emitter.emit(\"running\", job);\n return job;\n }\n\n /**\n * Complete a job with a result.\n */\n async complete(jobId: string, result: unknown): Promise<Job | undefined> {\n const job = await this.store.get(jobId);\n if (!job) return undefined;\n\n job.status = \"completed\";\n job.result = result;\n job.updatedAt = Date.now();\n await this.store.set(jobId, job);\n this.emitter.emit(\"completed\", job);\n return job;\n }\n\n /**\n * Fail a job with an error message.\n */\n async fail(jobId: string, error: string): Promise<Job | undefined> {\n const job = await this.store.get(jobId);\n if (!job) return undefined;\n\n job.status = \"failed\";\n job.error = error;\n job.updatedAt = Date.now();\n await this.store.set(jobId, job);\n this.emitter.emit(\"failed\", job);\n return job;\n }\n\n /**\n * Get current job status.\n */\n async getStatus(jobId: string): Promise<JobStatus | undefined> {\n const job = await this.store.get(jobId);\n return job?.status;\n }\n\n /**\n * Get the full job record.\n */\n async getJob(jobId: string): Promise<Job | undefined> {\n return this.store.get(jobId);\n }\n\n /**\n * Get the result of a completed job.\n */\n async getResult(jobId: string): Promise<unknown | undefined> {\n const job = await this.store.get(jobId);\n if (!job || job.status !== \"completed\") return undefined;\n return job.result;\n }\n\n /**\n * List jobs with optional filter.\n */\n async list(filter?: {\n toolName?: string;\n status?: JobStatus;\n }): Promise<Job[]> {\n return this.store.list(filter);\n }\n\n /**\n * Subscribe to job events.\n */\n on(\n event: \"submitted\" | \"running\" | \"completed\" | \"failed\",\n listener: (job: Job) => void,\n ): () => void {\n this.emitter.on(event, listener);\n return () => this.emitter.off(event, listener);\n }\n\n /**\n * Stop cleanup timer.\n */\n dispose(): void {\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n this.cleanupTimer = undefined;\n }\n }\n\n private startCleanup(): void {\n // Run cleanup every TTL/2 interval\n const interval = Math.max(this.ttlMs / 2, 60_000);\n this.cleanupTimer = setInterval(() => void this.cleanup(), interval);\n if (typeof this.cleanupTimer === \"object\" && \"unref\" in this.cleanupTimer) {\n this.cleanupTimer.unref();\n }\n }\n\n private async cleanup(): Promise<void> {\n const now = Date.now();\n const all = await this.store.list();\n for (const job of all) {\n if (\n (job.status === \"completed\" || job.status === \"failed\") &&\n now - job.updatedAt > this.ttlMs\n ) {\n await this.store.delete(job.jobId);\n }\n }\n }\n}\n","import type { ToolAdapter, ToolSpec } from \"../types/ToolSpec.js\";\nimport type { ExecContext } from \"../types/ToolIntent.js\";\nimport type { DirectoryScannerOptions } from \"./types.js\";\nimport type { DiscoverySource } from \"../registry/Discovery.js\";\nimport { DirectoryScanner } from \"./DirectoryScanner.js\";\n\n/**\n * A ToolAdapter that discovers tools from filesystem directories.\n * Used as the adapter within a DiscoverySource for the Discovery system.\n *\n * Note: This adapter's invoke() is not called directly. Discovered tools\n * retain their original kind (mcp/langchain/skill/n8n) and are invoked\n * by the kind-specific adapter registered on PTCRuntime.\n */\nexport class DirectoryToolAdapter implements ToolAdapter {\n readonly kind = \"mcp\" as const; // Required by ToolAdapter but not used for routing\n private readonly scanner: DirectoryScanner;\n\n constructor(options: DirectoryScannerOptions) {\n this.scanner = new DirectoryScanner(options);\n }\n\n /**\n * Scan directories and return discovered tool specs.\n * Called by Discovery.refresh().\n */\n async listTools(): Promise<ToolSpec[]> {\n return this.scanner.scan();\n }\n\n /**\n * Not used — actual invocation routes through kind-specific adapters.\n */\n async invoke(\n _spec: ToolSpec,\n _args: unknown,\n _ctx: ExecContext,\n ): Promise<{ result: unknown }> {\n throw new Error(\n \"DirectoryToolAdapter.invoke() should not be called directly. \" +\n \"Tool execution is handled by the kind-specific adapter (MCPAdapter, LangChainAdapter, etc.).\",\n );\n }\n\n /**\n * Get the underlying scanner for direct usage.\n */\n getScanner(): DirectoryScanner {\n return this.scanner;\n }\n}\n\n/**\n * Options for creating a directory discovery source.\n */\nexport interface DirectoryDiscoveryOptions extends DirectoryScannerOptions {\n /** Refresh interval in ms (0 = manual only, default: 0) */\n refreshIntervalMs?: number;\n /** Whether to auto-discover on startup (default: true) */\n autoDiscover?: boolean;\n}\n\n/**\n * Factory: create a DiscoverySource for directory-based tool discovery.\n *\n * Usage:\n * ```ts\n * const discovery = new Discovery(registry);\n * discovery.addSource(\n * createDirectoryDiscoverySource(\"local-tools\", {\n * roots: [\"/path/to/tools\"],\n * namespace: \"local\",\n * refreshIntervalMs: 60_000,\n * autoDiscover: true,\n * })\n * );\n * ```\n */\nexport function createDirectoryDiscoverySource(\n id: string,\n options: DirectoryDiscoveryOptions,\n): DiscoverySource {\n const { refreshIntervalMs, autoDiscover, ...scannerOptions } = options;\n\n return {\n id,\n adapter: new DirectoryToolAdapter(scannerOptions),\n refreshIntervalMs: refreshIntervalMs ?? 0,\n autoDiscover: autoDiscover ?? true,\n };\n}\n","import type { MCPServerConfig } from \"./types.js\";\n\n/**\n * Connection info for an MCP server.\n */\nexport interface MCPConnectionInfo {\n /** Transport type: \"url\" for SSE/HTTP, \"stdio\" for command-based */\n type: \"url\" | \"stdio\";\n /** SSE/HTTP URL (when type=\"url\") */\n url?: string;\n /** Command to spawn (when type=\"stdio\") */\n command?: string;\n /** Command arguments (when type=\"stdio\") */\n args?: string[];\n /** Environment variables (when type=\"stdio\") */\n env?: Record<string, string>;\n}\n\n/**\n * Manages MCP server connection information extracted from directory discovery.\n *\n * This class provides connection configuration for MCP servers discovered\n * from mcp.json files. The actual MCP client creation and lifecycle management\n * is the consumer's responsibility (using @modelcontextprotocol/sdk or similar).\n *\n * Usage:\n * ```ts\n * const manager = new MCPProcessManager();\n * const info = manager.getConnectionInfo(\"my-tool\", mcpConfig);\n * if (info.type === \"stdio\") {\n * // Spawn process with info.command, info.args, info.env\n * } else {\n * // Connect SSE client to info.url\n * }\n * ```\n */\nexport class MCPProcessManager {\n private readonly connections = new Map<string, MCPConnectionInfo>();\n\n /**\n * Get connection info for an MCP tool based on its config.\n * Caches the result by tool name.\n */\n getConnectionInfo(toolName: string, config: MCPServerConfig): MCPConnectionInfo {\n const cached = this.connections.get(toolName);\n if (cached) return cached;\n\n const info: MCPConnectionInfo = config.url\n ? { type: \"url\", url: config.url }\n : {\n type: \"stdio\",\n command: config.command!,\n args: config.args,\n env: config.env,\n };\n\n this.connections.set(toolName, info);\n return info;\n }\n\n /**\n * Remove cached connection info for a tool.\n */\n remove(toolName: string): boolean {\n return this.connections.delete(toolName);\n }\n\n /**\n * Get all registered tool names.\n */\n getToolNames(): string[] {\n return [...this.connections.keys()];\n }\n\n /**\n * Clear all cached connection info.\n */\n dispose(): void {\n this.connections.clear();\n }\n}\n","/**\n * Minimal client for OpenAI-compatible chat completions API.\n * Use createOpenAICompatibleClient(baseUrl, model, apiKey?) and then .chat(messages).\n */\n\nexport interface ChatMessage {\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n}\n\nexport interface ChatOptions {\n /** Request timeout in milliseconds. Default 60000. */\n timeoutMs?: number;\n}\n\nexport interface ChatResult {\n /** Content of the first assistant reply. */\n content: string;\n /** Raw response from the API (for debugging or advanced use). */\n raw: unknown;\n}\n\nexport interface OpenAICompatibleClientConfig {\n /** Base URL of the API (e.g. https://api.openai.com/v1). Trailing slash is optional. */\n baseUrl: string;\n /** Model name (e.g. gpt-4o-mini). */\n model: string;\n /** API key; optional if the provider does not require it. */\n apiKey?: string;\n}\n\n/**\n * Creates an OpenAI-compatible LLM client.\n *\n * @param baseUrl - LLM API base URL (e.g. https://api.openai.com/v1)\n * @param model - Model name (e.g. gpt-4o-mini)\n * @param apiKey - Optional API key\n * @returns Client instance with .chat(messages, options?)\n */\nexport function createOpenAICompatibleClient(\n baseUrl: string,\n model: string,\n apiKey?: string\n): OpenAICompatibleClient {\n return new OpenAICompatibleClient({ baseUrl, model, apiKey });\n}\n\nexport class OpenAICompatibleClient {\n private readonly baseUrl: string;\n private readonly model: string;\n private readonly apiKey?: string;\n\n constructor(config: OpenAICompatibleClientConfig) {\n this.baseUrl = config.baseUrl.replace(/\\/$/, \"\");\n this.model = config.model;\n this.apiKey = config.apiKey;\n }\n\n /**\n * Send chat messages and return the first assistant reply.\n *\n * @param messages - Array of { role, content }\n * @param options - Optional timeout\n * @returns Promise of { content, raw }\n */\n async chat(\n messages: ChatMessage[],\n options?: ChatOptions\n ): Promise<ChatResult> {\n const timeoutMs = options?.timeoutMs ?? 60_000;\n const url = `${this.baseUrl}/chat/completions`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n if (this.apiKey) {\n headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n\n let response: Response;\n try {\n response = await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n model: this.model,\n messages: messages.map((m) => ({ role: m.role, content: m.content })),\n }),\n signal: controller.signal,\n });\n } catch (err) {\n clearTimeout(timer);\n if (err instanceof Error && err.name === \"AbortError\") {\n throw new Error(`LLM request timed out after ${timeoutMs}ms`);\n }\n throw err;\n }\n clearTimeout(timer);\n\n const raw = (await response.json()) as unknown;\n if (!response.ok) {\n const errBody =\n typeof raw === \"object\" && raw !== null && \"error\" in (raw as object)\n ? (raw as { error: unknown }).error\n : raw;\n throw new Error(\n `LLM API error ${response.status}: ${JSON.stringify(errBody)}`\n );\n }\n\n const choices = (raw as { choices?: Array<{ message?: { content?: string } }> }).choices;\n const content =\n Array.isArray(choices) && choices[0]?.message?.content != null\n ? String(choices[0].message.content)\n : \"\";\n\n return { content, raw };\n }\n}\n"]}
@@ -1557,8 +1557,59 @@ declare class ToolHub {
1557
1557
  }
1558
1558
  declare function createToolHub(options: ToolHubInitOptions): ToolHub;
1559
1559
 
1560
+ /**
1561
+ * High-level facade for initializing and using the tool hub from a config file.
1562
+ * Supports two constructor forms:
1563
+ * - `new AgentToolHub()` — uses default config path (toolhub.yaml in cwd).
1564
+ * - `new AgentToolHub(configPath)` — uses the given config file path.
1565
+ *
1566
+ * Call `await toolHub.init()` after construction to load config and discover tools.
1567
+ * Then use the same API as ToolHub (invokeTool, listToolMetadata, etc.).
1568
+ */
1569
+ declare class AgentToolHub {
1570
+ private readonly configPath;
1571
+ private hub;
1572
+ /**
1573
+ * @param configPath Optional path to toolhub config (YAML). If omitted, uses
1574
+ * default "toolhub.yaml" resolved from process.cwd().
1575
+ */
1576
+ constructor(configPath?: string);
1577
+ /**
1578
+ * Load config from the path given at construction, create the underlying ToolHub,
1579
+ * and initialize all tools. Must be called before using invokeTool, listToolMetadata, etc.
1580
+ */
1581
+ init(): Promise<ToolSpec[]>;
1582
+ private requireHub;
1583
+ listToolMetadata(): ToolMetadata[];
1584
+ getToolDescription(toolName: string): ToolDescription;
1585
+ invokeTool(toolName: string, args: unknown, options?: InvokeOptions): Promise<ToolResult>;
1586
+ invokeIntent(intent: ToolIntent, ctx: ExecContext): Promise<ToolResult>;
1587
+ getRegistry(): ToolRegistry;
1588
+ getRuntime(): PTCRuntime;
1589
+ refreshTools(): Promise<ToolSpec[]>;
1590
+ addRoots(roots: Array<string | {
1591
+ path: string;
1592
+ namespace?: string;
1593
+ }>, refresh?: boolean): Promise<ToolSpec[] | void>;
1594
+ setRoots(roots: Array<string | {
1595
+ path: string;
1596
+ namespace?: string;
1597
+ }>, refresh?: boolean): Promise<ToolSpec[] | void>;
1598
+ watchRoots(options?: {
1599
+ debounceMs?: number;
1600
+ persistent?: boolean;
1601
+ }): void;
1602
+ unwatchRoots(): void;
1603
+ shutdown(): Promise<void>;
1604
+ /** Config path used for init (resolved absolute path). */
1605
+ getConfigPath(): string;
1606
+ }
1560
1607
  declare function createToolHubAndInit(options: ToolHubInitOptions): Promise<ToolHub>;
1561
1608
  declare function createToolHubAndInitFromConfig(configPath: string): Promise<ToolHub>;
1562
- declare function createAgentToolHub(configPath: string): Promise<ToolHub>;
1609
+ /**
1610
+ * Create an AgentToolHub from a config path, run init(), and return the instance.
1611
+ * Equivalent to: `const hub = new AgentToolHub(configPath); await hub.init(); return hub;`
1612
+ */
1613
+ declare function createAgentToolHub(configPath: string): Promise<AgentToolHub>;
1563
1614
 
1564
- export { N8nLocalAdapter as $, type AnyToolEvent as A, type BudgetConfig as B, type Capability as C, DEFAULT_CORE_TOOLS_CONFIG as D, type ExecContext as E, type JobFailedEvent as F, type JobSubmittedEvent as G, type HistogramValue as H, type InvokeOptions as I, type JobCompletedEvent as J, type LangChainAdapterOptions as K, LangChainAdapter as L, type LangChainToolLike as M, type LogEntry as N, type LogLevel as O, type Logger as P, MCPAdapter as Q, type MCPAdapterOptions as R, type SkillDefinition as S, type ToolSpec as T, type MCPCallResult as U, type MCPClientLike as V, type MCPToolDefinition as W, Metrics as X, N8nAdapter as Y, type N8nAdapterOptions as Z, type N8nInvokeMode as _, type Evidence as a, type N8nLocalAdapterOptions as a0, PTCRuntime as a1, type PTCRuntimeConfig as a2, type PolicyCheckResult as a3, type PolicyConfig as a4, PolicyDeniedError as a5, type PolicyDeniedEvent as a6, PolicyEngine as a7, type ResolvedDebugOptions as a8, type RetryEvent as a9, createLogger as aA, createToolHub as aB, createToolHubAndInitFromConfig as aC, registerCoreTools as aD, sanitizeForLog as aE, summarizeForLog as aF, validateFrontmatter as aG, createToolHubAndInit as aH, SchemaValidationError as aa, SchemaValidator as ab, SkillAdapter as ac, type SkillAdapterOptions as ad, type SkillContext as ae, type SkillHandler as af, type SkillInstructionResult as ag, type SkillInvocationContext as ah, SkillManifestError as ai, type SkillOutput as aj, type Span as ak, type SpanEvent as al, type ToolCalledEvent as am, type ToolDescription as an, type ToolError as ao, type ToolEvent as ap, type ToolEventType as aq, ToolHub as ar, type ToolIntent as as, type ToolMetadata as at, type ToolResult as au, type ToolResultEvent as av, type ToolSearchQuery as aw, Tracing as ax, type ValidationResult as ay, createAgentToolHub as az, ToolRegistry as b, type ToolAdapter as c, type SkillFrontmatter as d, type SkillResource as e, type ToolKind as f, type CostHints as g, type ToolHubInitOptions as h, BudgetManager as i, type BudgetOptions as j, ComfyUIAdapter as k, type ComfyUIAdapterOptions as l, type ComfyUIHistoryEntry as m, type ComfyUIHttpClient as n, type ComfyUIQueueResponse as o, CoreAdapter as p, type CoreToolContext as q, type CoreToolHandler as r, type CoreToolResult as s, type CoreToolsConfig as t, type CoreToolsUserConfig as u, type CounterValue as v, type DebugOptions as w, type EventListener as x, EventLog as y, type HttpClient as z };
1615
+ export { type N8nInvokeMode as $, AgentToolHub as A, type BudgetConfig as B, type Capability as C, DEFAULT_CORE_TOOLS_CONFIG as D, type ExecContext as E, type HttpClient as F, type JobFailedEvent as G, type HistogramValue as H, type InvokeOptions as I, type JobCompletedEvent as J, type JobSubmittedEvent as K, LangChainAdapter as L, type LangChainAdapterOptions as M, type LangChainToolLike as N, type LogEntry as O, type LogLevel as P, type Logger as Q, MCPAdapter as R, type SkillDefinition as S, type ToolSpec as T, type MCPAdapterOptions as U, type MCPCallResult as V, type MCPClientLike as W, type MCPToolDefinition as X, Metrics as Y, N8nAdapter as Z, type N8nAdapterOptions as _, type Evidence as a, N8nLocalAdapter as a0, type N8nLocalAdapterOptions as a1, PTCRuntime as a2, type PTCRuntimeConfig as a3, type PolicyCheckResult as a4, type PolicyConfig as a5, PolicyDeniedError as a6, type PolicyDeniedEvent as a7, PolicyEngine as a8, type ResolvedDebugOptions as a9, createAgentToolHub as aA, createLogger as aB, createToolHub as aC, createToolHubAndInitFromConfig as aD, registerCoreTools as aE, sanitizeForLog as aF, summarizeForLog as aG, validateFrontmatter as aH, createToolHubAndInit as aI, type RetryEvent as aa, SchemaValidationError as ab, SchemaValidator as ac, SkillAdapter as ad, type SkillAdapterOptions as ae, type SkillContext as af, type SkillHandler as ag, type SkillInstructionResult as ah, type SkillInvocationContext as ai, SkillManifestError as aj, type SkillOutput as ak, type Span as al, type SpanEvent as am, type ToolCalledEvent as an, type ToolDescription as ao, type ToolError as ap, type ToolEvent as aq, type ToolEventType as ar, ToolHub as as, type ToolIntent as at, type ToolMetadata as au, type ToolResult as av, type ToolResultEvent as aw, type ToolSearchQuery as ax, Tracing as ay, type ValidationResult as az, ToolRegistry as b, type ToolAdapter as c, type SkillFrontmatter as d, type SkillResource as e, type ToolKind as f, type CostHints as g, type ToolHubInitOptions as h, type AnyToolEvent as i, BudgetManager as j, type BudgetOptions as k, ComfyUIAdapter as l, type ComfyUIAdapterOptions as m, type ComfyUIHistoryEntry as n, type ComfyUIHttpClient as o, type ComfyUIQueueResponse as p, CoreAdapter as q, type CoreToolContext as r, type CoreToolHandler as s, type CoreToolResult as t, type CoreToolsConfig as u, type CoreToolsUserConfig as v, type CounterValue as w, type DebugOptions as x, type EventListener as y, EventLog as z };
@@ -1557,8 +1557,59 @@ declare class ToolHub {
1557
1557
  }
1558
1558
  declare function createToolHub(options: ToolHubInitOptions): ToolHub;
1559
1559
 
1560
+ /**
1561
+ * High-level facade for initializing and using the tool hub from a config file.
1562
+ * Supports two constructor forms:
1563
+ * - `new AgentToolHub()` — uses default config path (toolhub.yaml in cwd).
1564
+ * - `new AgentToolHub(configPath)` — uses the given config file path.
1565
+ *
1566
+ * Call `await toolHub.init()` after construction to load config and discover tools.
1567
+ * Then use the same API as ToolHub (invokeTool, listToolMetadata, etc.).
1568
+ */
1569
+ declare class AgentToolHub {
1570
+ private readonly configPath;
1571
+ private hub;
1572
+ /**
1573
+ * @param configPath Optional path to toolhub config (YAML). If omitted, uses
1574
+ * default "toolhub.yaml" resolved from process.cwd().
1575
+ */
1576
+ constructor(configPath?: string);
1577
+ /**
1578
+ * Load config from the path given at construction, create the underlying ToolHub,
1579
+ * and initialize all tools. Must be called before using invokeTool, listToolMetadata, etc.
1580
+ */
1581
+ init(): Promise<ToolSpec[]>;
1582
+ private requireHub;
1583
+ listToolMetadata(): ToolMetadata[];
1584
+ getToolDescription(toolName: string): ToolDescription;
1585
+ invokeTool(toolName: string, args: unknown, options?: InvokeOptions): Promise<ToolResult>;
1586
+ invokeIntent(intent: ToolIntent, ctx: ExecContext): Promise<ToolResult>;
1587
+ getRegistry(): ToolRegistry;
1588
+ getRuntime(): PTCRuntime;
1589
+ refreshTools(): Promise<ToolSpec[]>;
1590
+ addRoots(roots: Array<string | {
1591
+ path: string;
1592
+ namespace?: string;
1593
+ }>, refresh?: boolean): Promise<ToolSpec[] | void>;
1594
+ setRoots(roots: Array<string | {
1595
+ path: string;
1596
+ namespace?: string;
1597
+ }>, refresh?: boolean): Promise<ToolSpec[] | void>;
1598
+ watchRoots(options?: {
1599
+ debounceMs?: number;
1600
+ persistent?: boolean;
1601
+ }): void;
1602
+ unwatchRoots(): void;
1603
+ shutdown(): Promise<void>;
1604
+ /** Config path used for init (resolved absolute path). */
1605
+ getConfigPath(): string;
1606
+ }
1560
1607
  declare function createToolHubAndInit(options: ToolHubInitOptions): Promise<ToolHub>;
1561
1608
  declare function createToolHubAndInitFromConfig(configPath: string): Promise<ToolHub>;
1562
- declare function createAgentToolHub(configPath: string): Promise<ToolHub>;
1609
+ /**
1610
+ * Create an AgentToolHub from a config path, run init(), and return the instance.
1611
+ * Equivalent to: `const hub = new AgentToolHub(configPath); await hub.init(); return hub;`
1612
+ */
1613
+ declare function createAgentToolHub(configPath: string): Promise<AgentToolHub>;
1563
1614
 
1564
- export { N8nLocalAdapter as $, type AnyToolEvent as A, type BudgetConfig as B, type Capability as C, DEFAULT_CORE_TOOLS_CONFIG as D, type ExecContext as E, type JobFailedEvent as F, type JobSubmittedEvent as G, type HistogramValue as H, type InvokeOptions as I, type JobCompletedEvent as J, type LangChainAdapterOptions as K, LangChainAdapter as L, type LangChainToolLike as M, type LogEntry as N, type LogLevel as O, type Logger as P, MCPAdapter as Q, type MCPAdapterOptions as R, type SkillDefinition as S, type ToolSpec as T, type MCPCallResult as U, type MCPClientLike as V, type MCPToolDefinition as W, Metrics as X, N8nAdapter as Y, type N8nAdapterOptions as Z, type N8nInvokeMode as _, type Evidence as a, type N8nLocalAdapterOptions as a0, PTCRuntime as a1, type PTCRuntimeConfig as a2, type PolicyCheckResult as a3, type PolicyConfig as a4, PolicyDeniedError as a5, type PolicyDeniedEvent as a6, PolicyEngine as a7, type ResolvedDebugOptions as a8, type RetryEvent as a9, createLogger as aA, createToolHub as aB, createToolHubAndInitFromConfig as aC, registerCoreTools as aD, sanitizeForLog as aE, summarizeForLog as aF, validateFrontmatter as aG, createToolHubAndInit as aH, SchemaValidationError as aa, SchemaValidator as ab, SkillAdapter as ac, type SkillAdapterOptions as ad, type SkillContext as ae, type SkillHandler as af, type SkillInstructionResult as ag, type SkillInvocationContext as ah, SkillManifestError as ai, type SkillOutput as aj, type Span as ak, type SpanEvent as al, type ToolCalledEvent as am, type ToolDescription as an, type ToolError as ao, type ToolEvent as ap, type ToolEventType as aq, ToolHub as ar, type ToolIntent as as, type ToolMetadata as at, type ToolResult as au, type ToolResultEvent as av, type ToolSearchQuery as aw, Tracing as ax, type ValidationResult as ay, createAgentToolHub as az, ToolRegistry as b, type ToolAdapter as c, type SkillFrontmatter as d, type SkillResource as e, type ToolKind as f, type CostHints as g, type ToolHubInitOptions as h, BudgetManager as i, type BudgetOptions as j, ComfyUIAdapter as k, type ComfyUIAdapterOptions as l, type ComfyUIHistoryEntry as m, type ComfyUIHttpClient as n, type ComfyUIQueueResponse as o, CoreAdapter as p, type CoreToolContext as q, type CoreToolHandler as r, type CoreToolResult as s, type CoreToolsConfig as t, type CoreToolsUserConfig as u, type CounterValue as v, type DebugOptions as w, type EventListener as x, EventLog as y, type HttpClient as z };
1615
+ export { type N8nInvokeMode as $, AgentToolHub as A, type BudgetConfig as B, type Capability as C, DEFAULT_CORE_TOOLS_CONFIG as D, type ExecContext as E, type HttpClient as F, type JobFailedEvent as G, type HistogramValue as H, type InvokeOptions as I, type JobCompletedEvent as J, type JobSubmittedEvent as K, LangChainAdapter as L, type LangChainAdapterOptions as M, type LangChainToolLike as N, type LogEntry as O, type LogLevel as P, type Logger as Q, MCPAdapter as R, type SkillDefinition as S, type ToolSpec as T, type MCPAdapterOptions as U, type MCPCallResult as V, type MCPClientLike as W, type MCPToolDefinition as X, Metrics as Y, N8nAdapter as Z, type N8nAdapterOptions as _, type Evidence as a, N8nLocalAdapter as a0, type N8nLocalAdapterOptions as a1, PTCRuntime as a2, type PTCRuntimeConfig as a3, type PolicyCheckResult as a4, type PolicyConfig as a5, PolicyDeniedError as a6, type PolicyDeniedEvent as a7, PolicyEngine as a8, type ResolvedDebugOptions as a9, createAgentToolHub as aA, createLogger as aB, createToolHub as aC, createToolHubAndInitFromConfig as aD, registerCoreTools as aE, sanitizeForLog as aF, summarizeForLog as aG, validateFrontmatter as aH, createToolHubAndInit as aI, type RetryEvent as aa, SchemaValidationError as ab, SchemaValidator as ac, SkillAdapter as ad, type SkillAdapterOptions as ae, type SkillContext as af, type SkillHandler as ag, type SkillInstructionResult as ah, type SkillInvocationContext as ai, SkillManifestError as aj, type SkillOutput as ak, type Span as al, type SpanEvent as am, type ToolCalledEvent as an, type ToolDescription as ao, type ToolError as ap, type ToolEvent as aq, type ToolEventType as ar, ToolHub as as, type ToolIntent as at, type ToolMetadata as au, type ToolResult as av, type ToolResultEvent as aw, type ToolSearchQuery as ax, Tracing as ay, type ValidationResult as az, ToolRegistry as b, type ToolAdapter as c, type SkillFrontmatter as d, type SkillResource as e, type ToolKind as f, type CostHints as g, type ToolHubInitOptions as h, type AnyToolEvent as i, BudgetManager as j, type BudgetOptions as k, ComfyUIAdapter as l, type ComfyUIAdapterOptions as m, type ComfyUIHistoryEntry as n, type ComfyUIHttpClient as o, type ComfyUIQueueResponse as p, CoreAdapter as q, type CoreToolContext as r, type CoreToolHandler as s, type CoreToolResult as t, type CoreToolsConfig as u, type CoreToolsUserConfig as v, type CounterValue as w, type DebugOptions as x, type EventListener as y, EventLog as z };
@@ -1,30 +1,34 @@
1
1
  'use strict';
2
2
 
3
- var chunk6QTWECRD_cjs = require('./chunk-6QTWECRD.cjs');
4
- var chunkTIKHPRMB_cjs = require('./chunk-TIKHPRMB.cjs');
3
+ var chunkCJZ2EWUG_cjs = require('./chunk-CJZ2EWUG.cjs');
4
+ var chunkXHNKPSOO_cjs = require('./chunk-XHNKPSOO.cjs');
5
5
  require('./chunk-NTTBDQUF.cjs');
6
6
 
7
7
 
8
8
 
9
+ Object.defineProperty(exports, "AgentToolHub", {
10
+ enumerable: true,
11
+ get: function () { return chunkCJZ2EWUG_cjs.AgentToolHub; }
12
+ });
9
13
  Object.defineProperty(exports, "createAgentToolHub", {
10
14
  enumerable: true,
11
- get: function () { return chunk6QTWECRD_cjs.createAgentToolHub; }
15
+ get: function () { return chunkCJZ2EWUG_cjs.createAgentToolHub; }
12
16
  });
13
17
  Object.defineProperty(exports, "createToolHubAndInit", {
14
18
  enumerable: true,
15
- get: function () { return chunk6QTWECRD_cjs.createToolHubAndInit; }
19
+ get: function () { return chunkCJZ2EWUG_cjs.createToolHubAndInit; }
16
20
  });
17
21
  Object.defineProperty(exports, "createToolHubAndInitFromConfig", {
18
22
  enumerable: true,
19
- get: function () { return chunk6QTWECRD_cjs.createToolHubAndInitFromConfig; }
23
+ get: function () { return chunkCJZ2EWUG_cjs.createToolHubAndInitFromConfig; }
20
24
  });
21
25
  Object.defineProperty(exports, "ToolHub", {
22
26
  enumerable: true,
23
- get: function () { return chunkTIKHPRMB_cjs.ToolHub; }
27
+ get: function () { return chunkXHNKPSOO_cjs.ToolHub; }
24
28
  });
25
29
  Object.defineProperty(exports, "createToolHub", {
26
30
  enumerable: true,
27
- get: function () { return chunkTIKHPRMB_cjs.createToolHub; }
31
+ get: function () { return chunkXHNKPSOO_cjs.createToolHub; }
28
32
  });
29
33
  //# sourceMappingURL=toolhub-runtime.cjs.map
30
34
  //# sourceMappingURL=toolhub-runtime.cjs.map
@@ -1,4 +1,4 @@
1
- export { I as InvokeOptions, ar as ToolHub, h as ToolHubInitOptions, az as createAgentToolHub, aB as createToolHub, aH as createToolHubAndInit, aC as createToolHubAndInitFromConfig } from './toolhub-runtime-CQkP4QVW.cjs';
1
+ export { A as AgentToolHub, I as InvokeOptions, as as ToolHub, h as ToolHubInitOptions, aA as createAgentToolHub, aC as createToolHub, aI as createToolHubAndInit, aD as createToolHubAndInitFromConfig } from './toolhub-runtime-Du3j3gS3.cjs';
2
2
  import '@easynet/n8n-local';
3
3
  import 'ajv';
4
4
  import 'cockatiel';
@@ -1,4 +1,4 @@
1
- export { I as InvokeOptions, ar as ToolHub, h as ToolHubInitOptions, az as createAgentToolHub, aB as createToolHub, aH as createToolHubAndInit, aC as createToolHubAndInitFromConfig } from './toolhub-runtime-CQkP4QVW.js';
1
+ export { A as AgentToolHub, I as InvokeOptions, as as ToolHub, h as ToolHubInitOptions, aA as createAgentToolHub, aC as createToolHub, aI as createToolHubAndInit, aD as createToolHubAndInitFromConfig } from './toolhub-runtime-Du3j3gS3.js';
2
2
  import '@easynet/n8n-local';
3
3
  import 'ajv';
4
4
  import 'cockatiel';
@@ -1,5 +1,5 @@
1
- export { createAgentToolHub, createToolHubAndInit, createToolHubAndInitFromConfig } from './chunk-57LVNNHL.js';
2
- export { ToolHub, createToolHub } from './chunk-HPDQEW2P.js';
1
+ export { AgentToolHub, createAgentToolHub, createToolHubAndInit, createToolHubAndInitFromConfig } from './chunk-MMNUEPKB.js';
2
+ export { ToolHub, createToolHub } from './chunk-QSBCXLMH.js';
3
3
  import './chunk-YSYEED4K.js';
4
4
  //# sourceMappingURL=toolhub-runtime.js.map
5
5
  //# sourceMappingURL=toolhub-runtime.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easynet/agent-tool-hub",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Agent Tool Hub: multi-protocol tool registry, PTC runtime, and adapter layer for MCP/LangChain/n8n/ComfyUI/SKILL",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1,19 +0,0 @@
1
- import { createToolHub, loadToolHubConfig } from './chunk-HPDQEW2P.js';
2
-
3
- // src/toolhub-runtime.ts
4
- async function createToolHubAndInit(options) {
5
- const hub = createToolHub(options);
6
- await hub.initAllTools();
7
- return hub;
8
- }
9
- async function createToolHubAndInitFromConfig(configPath) {
10
- const { options } = await loadToolHubConfig(configPath);
11
- return createToolHubAndInit(options);
12
- }
13
- async function createAgentToolHub(configPath) {
14
- return createToolHubAndInitFromConfig(configPath);
15
- }
16
-
17
- export { createAgentToolHub, createToolHubAndInit, createToolHubAndInitFromConfig };
18
- //# sourceMappingURL=chunk-57LVNNHL.js.map
19
- //# sourceMappingURL=chunk-57LVNNHL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/toolhub-runtime.ts"],"names":[],"mappings":";;;AAKA,eAAsB,qBACpB,OAAA,EACA;AACA,EAAA,MAAM,GAAA,GAAM,cAAc,OAAO,CAAA;AACjC,EAAA,MAAM,IAAI,YAAA,EAAa;AACvB,EAAA,OAAO,GAAA;AACT;AAEA,eAAsB,+BAA+B,UAAA,EAAoB;AACvE,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,MAAM,kBAAkB,UAAU,CAAA;AACtD,EAAA,OAAO,qBAAqB,OAAO,CAAA;AACrC;AAEA,eAAsB,mBAAmB,UAAA,EAAoB;AAC3D,EAAA,OAAO,+BAA+B,UAAU,CAAA;AAClD","file":"chunk-57LVNNHL.js","sourcesContent":["import { ToolHub, createToolHub } from \"./tool-hub/ToolHub.js\";\nimport { loadToolHubConfig } from \"./config/ToolHubConfig.js\";\nexport { ToolHub, createToolHub };\nexport type { ToolHubInitOptions, InvokeOptions } from \"./tool-hub/ToolHub.js\";\n\nexport async function createToolHubAndInit(\n options: import(\"./tool-hub/ToolHub.js\").ToolHubInitOptions,\n) {\n const hub = createToolHub(options);\n await hub.initAllTools();\n return hub;\n}\n\nexport async function createToolHubAndInitFromConfig(configPath: string) {\n const { options } = await loadToolHubConfig(configPath);\n return createToolHubAndInit(options);\n}\n\nexport async function createAgentToolHub(configPath: string) {\n return createToolHubAndInitFromConfig(configPath);\n}\n"]}
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkTIKHPRMB_cjs = require('./chunk-TIKHPRMB.cjs');
4
-
5
- // src/toolhub-runtime.ts
6
- async function createToolHubAndInit(options) {
7
- const hub = chunkTIKHPRMB_cjs.createToolHub(options);
8
- await hub.initAllTools();
9
- return hub;
10
- }
11
- async function createToolHubAndInitFromConfig(configPath) {
12
- const { options } = await chunkTIKHPRMB_cjs.loadToolHubConfig(configPath);
13
- return createToolHubAndInit(options);
14
- }
15
- async function createAgentToolHub(configPath) {
16
- return createToolHubAndInitFromConfig(configPath);
17
- }
18
-
19
- exports.createAgentToolHub = createAgentToolHub;
20
- exports.createToolHubAndInit = createToolHubAndInit;
21
- exports.createToolHubAndInitFromConfig = createToolHubAndInitFromConfig;
22
- //# sourceMappingURL=chunk-6QTWECRD.cjs.map
23
- //# sourceMappingURL=chunk-6QTWECRD.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/toolhub-runtime.ts"],"names":["createToolHub","loadToolHubConfig"],"mappings":";;;;;AAKA,eAAsB,qBACpB,OAAA,EACA;AACA,EAAA,MAAM,GAAA,GAAMA,gCAAc,OAAO,CAAA;AACjC,EAAA,MAAM,IAAI,YAAA,EAAa;AACvB,EAAA,OAAO,GAAA;AACT;AAEA,eAAsB,+BAA+B,UAAA,EAAoB;AACvE,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,MAAMC,oCAAkB,UAAU,CAAA;AACtD,EAAA,OAAO,qBAAqB,OAAO,CAAA;AACrC;AAEA,eAAsB,mBAAmB,UAAA,EAAoB;AAC3D,EAAA,OAAO,+BAA+B,UAAU,CAAA;AAClD","file":"chunk-6QTWECRD.cjs","sourcesContent":["import { ToolHub, createToolHub } from \"./tool-hub/ToolHub.js\";\nimport { loadToolHubConfig } from \"./config/ToolHubConfig.js\";\nexport { ToolHub, createToolHub };\nexport type { ToolHubInitOptions, InvokeOptions } from \"./tool-hub/ToolHub.js\";\n\nexport async function createToolHubAndInit(\n options: import(\"./tool-hub/ToolHub.js\").ToolHubInitOptions,\n) {\n const hub = createToolHub(options);\n await hub.initAllTools();\n return hub;\n}\n\nexport async function createToolHubAndInitFromConfig(configPath: string) {\n const { options } = await loadToolHubConfig(configPath);\n return createToolHubAndInit(options);\n}\n\nexport async function createAgentToolHub(configPath: string) {\n return createToolHubAndInitFromConfig(configPath);\n}\n"]}