@illuma-ai/agents 1.4.0-alpha.3 → 1.4.0-alpha.5
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/cjs/providers/tools-server/ToolsServerCapabilityProvider.cjs +8 -1
- package/dist/cjs/providers/tools-server/ToolsServerCapabilityProvider.cjs.map +1 -1
- package/dist/cjs/providers/types.cjs.map +1 -1
- package/dist/cjs/tools/artifacts/schema.cjs +30 -7
- package/dist/cjs/tools/artifacts/schema.cjs.map +1 -1
- package/dist/cjs/tools/artifacts/tool.cjs +8 -2
- package/dist/cjs/tools/artifacts/tool.cjs.map +1 -1
- package/dist/cjs/tools/proxyTool.cjs +7 -5
- package/dist/cjs/tools/proxyTool.cjs.map +1 -1
- package/dist/esm/providers/tools-server/ToolsServerCapabilityProvider.mjs +8 -1
- package/dist/esm/providers/tools-server/ToolsServerCapabilityProvider.mjs.map +1 -1
- package/dist/esm/providers/types.mjs.map +1 -1
- package/dist/esm/tools/artifacts/schema.mjs +30 -7
- package/dist/esm/tools/artifacts/schema.mjs.map +1 -1
- package/dist/esm/tools/artifacts/tool.mjs +8 -2
- package/dist/esm/tools/artifacts/tool.mjs.map +1 -1
- package/dist/esm/tools/proxyTool.mjs +7 -5
- package/dist/esm/tools/proxyTool.mjs.map +1 -1
- package/dist/types/providers/tools-server/ToolsServerCapabilityProvider.d.ts +14 -0
- package/dist/types/providers/types.d.ts +14 -0
- package/dist/types/tools/proxyTool.d.ts +7 -0
- package/package.json +1 -1
- package/src/providers/__tests__/ToolsServerCapabilityProvider.test.ts +63 -0
- package/src/providers/tools-server/ToolsServerCapabilityProvider.ts +28 -0
- package/src/providers/types.ts +17 -0
- package/src/tools/artifacts/__tests__/tool.test.ts +31 -15
- package/src/tools/artifacts/schema.ts +36 -13
- package/src/tools/artifacts/tool.ts +28 -16
- package/src/tools/artifacts/types.ts +18 -5
- package/src/tools/proxyTool.ts +25 -5
|
@@ -22,9 +22,10 @@ class ToolsServerCapabilityProvider {
|
|
|
22
22
|
manifestPath;
|
|
23
23
|
executePath;
|
|
24
24
|
cache;
|
|
25
|
+
getExecuteAuthHeaders;
|
|
25
26
|
constructor(config) {
|
|
26
27
|
this.config = config;
|
|
27
|
-
const { baseUrl, apiKey, manifestPath = '/manifest', executePath = '/execute/:name', timeoutMs = 30_000, manifestTtlMs = 60_000, client, proxy, } = config;
|
|
28
|
+
const { baseUrl, apiKey, manifestPath = '/manifest', executePath = '/execute/:name', timeoutMs = 30_000, manifestTtlMs = 60_000, client, proxy, getExecuteAuthHeaders, } = config;
|
|
28
29
|
if (!baseUrl) {
|
|
29
30
|
throw new Error('ToolsServerCapabilityProvider: baseUrl is required');
|
|
30
31
|
}
|
|
@@ -35,6 +36,7 @@ class ToolsServerCapabilityProvider {
|
|
|
35
36
|
this.manifestPath = manifestPath;
|
|
36
37
|
this.executePath = executePath;
|
|
37
38
|
this.cache = new toolManifest.ManifestCache({ ttlMs: manifestTtlMs });
|
|
39
|
+
this.getExecuteAuthHeaders = getExecuteAuthHeaders;
|
|
38
40
|
if (client) {
|
|
39
41
|
this.client = client;
|
|
40
42
|
}
|
|
@@ -81,6 +83,7 @@ class ToolsServerCapabilityProvider {
|
|
|
81
83
|
return capabilities.map((cap) => proxyTool.buildProxyTool(cap, credentials, {
|
|
82
84
|
client: this.client,
|
|
83
85
|
executePath: this.executePath,
|
|
86
|
+
getAuthHeaders: this.getExecuteAuthHeaders,
|
|
84
87
|
}));
|
|
85
88
|
}
|
|
86
89
|
/** Force a manifest refresh on next fetchManifest call. */
|
|
@@ -113,6 +116,10 @@ function normalizeEntry(entry) {
|
|
|
113
116
|
icon: entry.icon,
|
|
114
117
|
category: entry.category,
|
|
115
118
|
tags: entry.tags,
|
|
119
|
+
// Governance — hosts use these to gate UI/role/environment.
|
|
120
|
+
hidden: entry.hidden,
|
|
121
|
+
admin: entry.admin,
|
|
122
|
+
env: entry.env,
|
|
116
123
|
},
|
|
117
124
|
};
|
|
118
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolsServerCapabilityProvider.cjs","sources":["../../../../src/providers/tools-server/ToolsServerCapabilityProvider.ts"],"sourcesContent":["/**\n * ToolsServerCapabilityProvider — capabilities sourced from a tools-server\n * HTTP endpoint.\n *\n * Fetches the manifest via GET /manifest, builds proxy StructuredTools via\n * POST /execute/:tool. Manifest is cached (TTL-configurable) so repeated\n * init cycles don't refetch.\n *\n * See docs/architecture-capability-layer.md for the design rationale.\n */\n\nimport type { AxiosInstance } from 'axios';\nimport type { StructuredToolInterface } from '@langchain/core/tools';\nimport {\n CapabilityKind,\n type Capability,\n type CapabilityFilter,\n type CapabilityProvider,\n type CredentialMap,\n} from '@/providers/types';\nimport {\n createHttpClient,\n type HttpClientConfig,\n assertOk,\n} from '@/utils/httpClient';\nimport {\n ManifestCache,\n filterToCacheKey,\n applyFilter,\n} from '@/utils/toolManifest';\nimport { buildProxyTool } from '@/tools/proxyTool';\n\n/** Configuration for ToolsServerCapabilityProvider. */\nexport interface ToolsServerConfig {\n /** Tools-server base URL (e.g., https://tools.illuma.ai or http://localhost:3500). */\n baseUrl: string;\n /** API key sent as x-api-key header on all requests. Required. */\n apiKey: string;\n /** Optional override for manifest path. Defaults to `/manifest`. */\n manifestPath?: string;\n /** Optional override for execute path template. Defaults to `/execute/:name`. */\n executePath?: string;\n /** Request timeout in ms. Defaults to 30_000. */\n timeoutMs?: number;\n /** Manifest cache TTL in ms. 0 disables. Defaults to 60_000 (1 min). */\n manifestTtlMs?: number;\n /** Optional pre-built axios instance (for testing). */\n client?: AxiosInstance;\n /** Optional proxy override (defaults to process.env.PROXY). */\n proxy?: string | null;\n}\n\n/**\n * Shape of a single entry from tools-server's /manifest response.\n *\n * Matches the tools-server ManifestToolEntry type. We define our own here\n * to avoid cross-package coupling — the shape is a stable HTTP contract.\n */\ninterface ToolsServerManifestEntry {\n pluginKey: string;\n name: string;\n description: string;\n icon?: string;\n authConfig?: Array<{\n authField: string;\n label?: string;\n description?: string;\n source?: string;\n required?: boolean;\n prod?: boolean;\n admin?: boolean;\n hide?: boolean;\n }>;\n /** Input schema as JSON Schema (tools-server emits `schema`). */\n schema?: unknown;\n /** Legacy alias accepted for backwards compatibility. */\n jsonSchema?: unknown;\n category?: string;\n tags?: string[];\n toolkit?: string;\n endpoint?: string;\n}\n\nexport class ToolsServerCapabilityProvider implements CapabilityProvider {\n readonly providerId: string;\n private readonly client: AxiosInstance;\n private readonly manifestPath: string;\n private readonly executePath: string;\n private readonly cache: ManifestCache;\n\n constructor(private readonly config: ToolsServerConfig) {\n const {\n baseUrl,\n apiKey,\n manifestPath = '/manifest',\n executePath = '/execute/:name',\n timeoutMs = 30_000,\n manifestTtlMs = 60_000,\n client,\n proxy,\n } = config;\n\n if (!baseUrl) {\n throw new Error('ToolsServerCapabilityProvider: baseUrl is required');\n }\n if (!apiKey) {\n throw new Error('ToolsServerCapabilityProvider: apiKey is required');\n }\n\n this.providerId = `tools-server:${baseUrl}`;\n this.manifestPath = manifestPath;\n this.executePath = executePath;\n this.cache = new ManifestCache({ ttlMs: manifestTtlMs });\n\n if (client) {\n this.client = client;\n } else {\n const httpConfig: HttpClientConfig = {\n baseURL: baseUrl,\n apiKey,\n timeoutMs,\n proxy,\n };\n this.client = createHttpClient(httpConfig);\n }\n }\n\n async fetchManifest(filter?: CapabilityFilter): Promise<Capability[]> {\n const cacheKey = filterToCacheKey(filter);\n const cached = this.cache.get(cacheKey);\n if (cached) {\n // DEBUG: cache hit (remove after stabilization)\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] manifest cache hit — ${cached.length} caps`\n );\n return cached;\n }\n\n // DEBUG\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] fetching manifest from ${this.manifestPath}`\n );\n\n const res = await this.client.get<ToolsServerManifestEntry[]>(\n this.manifestPath\n );\n assertOk(res.status, this.manifestPath, res.data);\n\n const entries = Array.isArray(res.data) ? res.data : [];\n const capabilities: Capability[] = entries.map((entry) =>\n normalizeEntry(entry)\n );\n\n // Apply filter before caching the full list separately so unfiltered\n // refetches don't re-hit the network.\n const fullCacheKey = filterToCacheKey();\n this.cache.set(fullCacheKey, capabilities);\n\n const filtered = applyFilter(capabilities, filter);\n if (cacheKey !== fullCacheKey) {\n this.cache.set(cacheKey, filtered);\n }\n\n // DEBUG\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] manifest loaded — ${capabilities.length} caps, ${filtered.length} after filter`\n );\n\n return filtered;\n }\n\n async createRunnables(\n capabilities: Capability[],\n credentials: CredentialMap\n ): Promise<StructuredToolInterface[]> {\n return capabilities.map((cap) =>\n buildProxyTool(cap, credentials, {\n client: this.client,\n executePath: this.executePath,\n })\n );\n }\n\n /** Force a manifest refresh on next fetchManifest call. */\n invalidateCache(): void {\n this.cache.clear();\n }\n}\n\n/**\n * Translate a raw tools-server manifest entry into a typed Capability.\n * Defensive — tools-server may add fields; we pull only what we need.\n */\nfunction normalizeEntry(entry: ToolsServerManifestEntry): Capability {\n return {\n kind: CapabilityKind.TOOL,\n name: entry.pluginKey,\n description: entry.description ?? '',\n schema: entry.schema ?? entry.jsonSchema,\n authConfig: (entry.authConfig ?? []).map((ac) => ({\n authField: ac.authField,\n label: ac.label,\n description: ac.description,\n required: ac.required,\n prod: ac.prod,\n admin: ac.admin,\n hide: ac.hide,\n // Source is a string in wire format; downstream consumers coerce to AuthSource.\n source: ac.source as Capability['authConfig'][number]['source'],\n })),\n metadata: {\n icon: entry.icon,\n category: entry.category,\n tags: entry.tags,\n },\n };\n}\n"],"names":["ManifestCache","createHttpClient","filterToCacheKey","assertOk","applyFilter","buildProxyTool","CapabilityKind"],"mappings":";;;;;;;AAAA;;;;;;;;;AASG;MA0EU,6BAA6B,CAAA;AAOX,IAAA,MAAA;AANpB,IAAA,UAAU;AACF,IAAA,MAAM;AACN,IAAA,YAAY;AACZ,IAAA,WAAW;AACX,IAAA,KAAK;AAEtB,IAAA,WAAA,CAA6B,MAAyB,E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IAAI,CAAC,MAAM;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;AAC9B,SAAA,CAAC,CACH;IACH;;IAGA,eAAe,GAAA;AACb,QAAA,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;IACpB;AACD;AAED;;;AAGG;AACH,SAAS,cAAc,CAAC,KAA+B,EAAA;IACrD,OAAO;QACL,IAAI,EAAEC,oBAAc,CAAC,IAAI;QACzB,IAAI,EAAE,KAAK,CAAC,SAAS;AACrB,QAAA,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE;AACpC,QAAA,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU;AACxC,QAAA,UAAU,EAAE,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,MAAM;YAChD,SAAS,EAAE,EAAE,CAAC,SAAS;YACvB,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,WAAW,EAAE,EAAE,CAAC,WAAW;YAC3B,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,IAAI,EAAE,EAAE,CAAC,IAAI;YACb,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,IAAI,EAAE,EAAE,CAAC,IAAI;;YAEb,MAAM,EAAE,EAAE,CAAC,MAAoD;AAChE,SAAA,CAAC,CAAC;AACH,QAAA,QAAQ,EAAE;YACR,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;AACjB,SAAA;KACF;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"ToolsServerCapabilityProvider.cjs","sources":["../../../../src/providers/tools-server/ToolsServerCapabilityProvider.ts"],"sourcesContent":["/**\n * ToolsServerCapabilityProvider — capabilities sourced from a tools-server\n * HTTP endpoint.\n *\n * Fetches the manifest via GET /manifest, builds proxy StructuredTools via\n * POST /execute/:tool. Manifest is cached (TTL-configurable) so repeated\n * init cycles don't refetch.\n *\n * See docs/architecture-capability-layer.md for the design rationale.\n */\n\nimport type { AxiosInstance } from 'axios';\nimport type { StructuredToolInterface } from '@langchain/core/tools';\nimport {\n CapabilityKind,\n type Capability,\n type CapabilityFilter,\n type CapabilityProvider,\n type CredentialMap,\n} from '@/providers/types';\nimport {\n createHttpClient,\n type HttpClientConfig,\n assertOk,\n} from '@/utils/httpClient';\nimport {\n ManifestCache,\n filterToCacheKey,\n applyFilter,\n} from '@/utils/toolManifest';\nimport { buildProxyTool } from '@/tools/proxyTool';\n\n/** Configuration for ToolsServerCapabilityProvider. */\nexport interface ToolsServerConfig {\n /** Tools-server base URL (e.g., https://tools.illuma.ai or http://localhost:3500). */\n baseUrl: string;\n /** API key sent as x-api-key header on all requests. Required. */\n apiKey: string;\n /** Optional override for manifest path. Defaults to `/manifest`. */\n manifestPath?: string;\n /** Optional override for execute path template. Defaults to `/execute/:name`. */\n executePath?: string;\n /** Request timeout in ms. Defaults to 30_000. */\n timeoutMs?: number;\n /** Manifest cache TTL in ms. 0 disables. Defaults to 60_000 (1 min). */\n manifestTtlMs?: number;\n /** Optional pre-built axios instance (for testing). */\n client?: AxiosInstance;\n /** Optional proxy override (defaults to process.env.PROXY). */\n proxy?: string | null;\n /**\n * Optional per-request auth header builder — invoked on every tool\n * invocation (NOT on the manifest fetch, which is service-to-service).\n * When provided, the returned headers are merged into the `/execute`\n * request so the host can pass user-scoped identity (e.g.,\n * `Authorization: Bearer <jwt>`) that tools-server verifies for\n * admin-gated tools.\n *\n * Typical host wiring: mint a short-lived JWT per call carrying the\n * authenticated user's `{ userId, role }` claims; tools-server's\n * `TOOLS_SERVER_JWT_SECRET` validates.\n */\n getExecuteAuthHeaders?: () =>\n | Record<string, string>\n | Promise<Record<string, string>>;\n}\n\n/**\n * Shape of a single entry from tools-server's /manifest response.\n *\n * Matches the tools-server ManifestToolEntry type. We define our own here\n * to avoid cross-package coupling — the shape is a stable HTTP contract.\n */\ninterface ToolsServerManifestEntry {\n pluginKey: string;\n name: string;\n description: string;\n icon?: string;\n authConfig?: Array<{\n authField: string;\n label?: string;\n description?: string;\n source?: string;\n required?: boolean;\n prod?: boolean;\n admin?: boolean;\n hide?: boolean;\n }>;\n /** Input schema as JSON Schema (tools-server emits `schema`). */\n schema?: unknown;\n /** Legacy alias accepted for backwards compatibility. */\n jsonSchema?: unknown;\n category?: string;\n tags?: string[];\n toolkit?: string;\n endpoint?: string;\n /** Governance flags forwarded by tools-server getManifest(). */\n hidden?: boolean;\n admin?: boolean;\n env?: Array<'development' | 'production' | 'test' | 'staging'>;\n}\n\nexport class ToolsServerCapabilityProvider implements CapabilityProvider {\n readonly providerId: string;\n private readonly client: AxiosInstance;\n private readonly manifestPath: string;\n private readonly executePath: string;\n private readonly cache: ManifestCache;\n private readonly getExecuteAuthHeaders?:\n | (() => Record<string, string> | Promise<Record<string, string>>);\n\n constructor(private readonly config: ToolsServerConfig) {\n const {\n baseUrl,\n apiKey,\n manifestPath = '/manifest',\n executePath = '/execute/:name',\n timeoutMs = 30_000,\n manifestTtlMs = 60_000,\n client,\n proxy,\n getExecuteAuthHeaders,\n } = config;\n\n if (!baseUrl) {\n throw new Error('ToolsServerCapabilityProvider: baseUrl is required');\n }\n if (!apiKey) {\n throw new Error('ToolsServerCapabilityProvider: apiKey is required');\n }\n\n this.providerId = `tools-server:${baseUrl}`;\n this.manifestPath = manifestPath;\n this.executePath = executePath;\n this.cache = new ManifestCache({ ttlMs: manifestTtlMs });\n this.getExecuteAuthHeaders = getExecuteAuthHeaders;\n\n if (client) {\n this.client = client;\n } else {\n const httpConfig: HttpClientConfig = {\n baseURL: baseUrl,\n apiKey,\n timeoutMs,\n proxy,\n };\n this.client = createHttpClient(httpConfig);\n }\n }\n\n async fetchManifest(filter?: CapabilityFilter): Promise<Capability[]> {\n const cacheKey = filterToCacheKey(filter);\n const cached = this.cache.get(cacheKey);\n if (cached) {\n // DEBUG: cache hit (remove after stabilization)\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] manifest cache hit — ${cached.length} caps`\n );\n return cached;\n }\n\n // DEBUG\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] fetching manifest from ${this.manifestPath}`\n );\n\n const res = await this.client.get<ToolsServerManifestEntry[]>(\n this.manifestPath\n );\n assertOk(res.status, this.manifestPath, res.data);\n\n const entries = Array.isArray(res.data) ? res.data : [];\n const capabilities: Capability[] = entries.map((entry) =>\n normalizeEntry(entry)\n );\n\n // Apply filter before caching the full list separately so unfiltered\n // refetches don't re-hit the network.\n const fullCacheKey = filterToCacheKey();\n this.cache.set(fullCacheKey, capabilities);\n\n const filtered = applyFilter(capabilities, filter);\n if (cacheKey !== fullCacheKey) {\n this.cache.set(cacheKey, filtered);\n }\n\n // DEBUG\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] manifest loaded — ${capabilities.length} caps, ${filtered.length} after filter`\n );\n\n return filtered;\n }\n\n async createRunnables(\n capabilities: Capability[],\n credentials: CredentialMap\n ): Promise<StructuredToolInterface[]> {\n return capabilities.map((cap) =>\n buildProxyTool(cap, credentials, {\n client: this.client,\n executePath: this.executePath,\n getAuthHeaders: this.getExecuteAuthHeaders,\n })\n );\n }\n\n /** Force a manifest refresh on next fetchManifest call. */\n invalidateCache(): void {\n this.cache.clear();\n }\n}\n\n/**\n * Translate a raw tools-server manifest entry into a typed Capability.\n * Defensive — tools-server may add fields; we pull only what we need.\n */\nfunction normalizeEntry(entry: ToolsServerManifestEntry): Capability {\n return {\n kind: CapabilityKind.TOOL,\n name: entry.pluginKey,\n description: entry.description ?? '',\n schema: entry.schema ?? entry.jsonSchema,\n authConfig: (entry.authConfig ?? []).map((ac) => ({\n authField: ac.authField,\n label: ac.label,\n description: ac.description,\n required: ac.required,\n prod: ac.prod,\n admin: ac.admin,\n hide: ac.hide,\n // Source is a string in wire format; downstream consumers coerce to AuthSource.\n source: ac.source as Capability['authConfig'][number]['source'],\n })),\n metadata: {\n icon: entry.icon,\n category: entry.category,\n tags: entry.tags,\n // Governance — hosts use these to gate UI/role/environment.\n hidden: entry.hidden,\n admin: entry.admin,\n env: entry.env,\n },\n };\n}\n"],"names":["ManifestCache","createHttpClient","filterToCacheKey","assertOk","applyFilter","buildProxyTool","CapabilityKind"],"mappings":";;;;;;;AAAA;;;;;;;;;AASG;MA6FU,6BAA6B,CAAA;AASX,IAAA,MAAA;AARpB,IAAA,UAAU;AACF,IAAA,MAAM;AACN,IAAA,YAAY;AACZ,IAAA,WAAW;AACX,IAAA,KAAK;AACL,IAAA,qBAAqB;AAGtC,IAAA,WAAA,CAA6B,MAAyB,EAAA;QAAzB,IAAA,CAAA,MAAM,GAAN,MAAM;AACjC,QAAA,MAAM,EACJ,OAAO,EACP,MAAM,EACN,YAAY,GAAG,WAAW,EAC1B,WAAW,GAAG,gBAAgB,EAC9B,SAAS,GAAG,MAAM,EAClB,aAAa,GAAG,MAAM,EACtB,MAAM,EACN,KAAK,EACL,qBAAqB,GACtB,GAAG,MAAM;QAEV,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC;QACvE;QACA,IAAI,CAAC,MAAM,EAAE;AACX,YAAA,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC;QACtE;AAEA,QAAA,IAAI,CAAC,UAAU,GAAG,CAAA,aAAA,EAAgB,OAAO,EAAE;AAC3C,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY;AAChC,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW;AAC9B,QAAA,IAAI,CAAC,KAAK,GAAG,IAAIA,0BAAa,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AACxD,QAAA,IAAI,CAAC,qBAAqB,GAAG,qBAAqB;QAElD,IAAI,MAAM,EAAE;AACV,YAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACtB;aAAO;AACL,YAAA,MAAM,UAAU,GAAqB;AACnC,gBAAA,OAAO,EAAE,OAAO;gBAChB,MAAM;gBACN,S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AAC,IAAI;;YAEb,MAAM,EAAE,EAAE,CAAC,MAAoD;AAChE,SAAA,CAAC,CAAC;AACH,QAAA,QAAQ,EAAE;YACR,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;;YAEhB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,GAAG,EAAE,KAAK,CAAC,GAAG;AACf,SAAA;KACF;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sources":["../../../src/providers/types.ts"],"sourcesContent":["/**\n * CapabilityProvider types — the abstraction that lets agents consume tools,\n * skills, and MCP-backed capabilities through a single interface regardless\n * of where they come from.\n *\n * Design principles:\n * 1. Source-agnostic — providers are distinguished by WHERE they come from\n * (tools-server, skill store, MCP server), not by the backend service\n * any individual tool calls.\n * 2. Credential-agnostic — providers receive a flat credentialMap from the\n * host; they don't know about user settings, databases, OAuth flows.\n * 3. Extension-ready — the shape reserves slots for upcoming patterns\n * (skills injectedMessages, ToolCall.auth/expires_at, skill sessions)\n * so when those land we don't refactor the core.\n */\n\nimport type { StructuredToolInterface } from '@langchain/core/tools';\n\n/**\n * Kind of capability. Today only TOOL is implemented; SKILL and MCP are\n * reserved — SkillCapabilityProvider + MCPCapabilityProvider will populate\n * them in later phases. Keeping the enum from day one prevents a breaking\n * change when those ship.\n */\nexport enum CapabilityKind {\n TOOL = 'tool',\n SKILL = 'skill',\n MCP = 'mcp',\n /**\n * Remote agent reachable over the A2A (Agent-to-Agent) protocol.\n * The library's `A2ACapabilityProvider` is a client for this kind —\n * invoking an A2A capability sends a JSON-RPC `tasks/send` to the\n * remote agent's endpoint.\n */\n A2A = 'a2a',\n}\n\n/**\n * Where an auth credential comes from. Used by hosts to decide whether to\n * forward the credential per-request or let the capability provider resolve\n * it from its own environment.\n */\nexport enum AuthSource {\n /** Resolved by the capability provider itself from its environment. Host never sends. */\n SERVER = 'server',\n /** User-configured value stored in the host's credential store. Host forwards per-request. */\n USER = 'user',\n /** Active OAuth/session token. Host forwards per-request from active session. */\n FORWARDED = 'forwarded',\n}\n\n/**\n * One entry in a capability's auth config. Describes a single credential\n * the capability needs. The `source` field tells the host how to resolve\n * the value; the `prod`/`admin`/`hide` flags control UI visibility.\n */\nexport interface AuthConfigEntry {\n /** Environment-variable-style name (e.g., \"OPENAI_API_KEY\"). Stable identifier. */\n authField: string;\n /** Human-readable label for UI. */\n label?: string;\n /** Optional description of how to obtain the credential. */\n description?: string;\n /** Where the value comes from. Defaults to USER if unspecified. */\n source?: AuthSource;\n /** True if the credential is required for the capability to function. */\n required?: boolean;\n /** Platform-managed in production — never prompt user. */\n prod?: boolean;\n /** Only admins can configure. */\n admin?: boolean;\n /** Never show in any UI (used when source === SERVER). */\n hide?: boolean;\n}\n\n/**\n * Arbitrary metadata attached to a capability. Extension point.\n *\n * Fields prefixed with \"Reserved for\" are not populated today but exist in\n * the type so upstream patterns (skills, auth expiration, sessions) can\n * drop in without a schema migration.\n */\nexport interface CapabilityMetadata {\n /** Icon URL or path relative to the provider's static asset root. */\n icon?: string;\n /** Category for UI grouping (e.g., \"search\", \"image\", \"finance\"). */\n category?: string;\n /** Free-form tags for filtering / search. */\n tags?: string[];\n\n // --- Reserved for upstream patterns (not populated today) ---\n\n /** Reserved for upstream `fix/auth-events` — auth mode declared by tool. */\n auth?: string;\n /** Reserved for upstream `fix/auth-events` — Unix timestamp for token expiration. */\n expires_at?: number;\n /** Reserved for upstream skills — capability returns injected messages on execute. */\n injectedMessages?: boolean;\n /** Reserved for upstream skills — capability consumes ToolSessionMap state. */\n sessionAware?: boolean;\n}\n\n/**\n * A single capability — a tool, skill, or MCP-backed operation that an agent\n * can invoke. The shape mirrors common plugin-manifest conventions so the\n * same entry can round-trip between an upstream catalog and a host registry.\n */\nexport interface Capability {\n /** What kind of capability this is. Controls how it's invoked downstream. */\n kind: CapabilityKind;\n /**\n * Stable unique identifier. For tools this is the pluginKey\n * (e.g., \"dalle\", \"wikipedia\"). For skills this is the skill's `name`.\n * Used everywhere the capability is referenced.\n */\n name: string;\n /** Human-readable description for the LLM and UI. */\n description: string;\n /**\n * Input schema as JSON Schema. For tools this comes from the Zod schema\n * passed through `zodToJsonSchema`. Optional for capabilities with no\n * input (e.g., parameter-less skills).\n */\n schema?: unknown;\n /** Credential requirements. */\n authConfig: AuthConfigEntry[];\n /** Extension metadata. See CapabilityMetadata. */\n metadata: CapabilityMetadata;\n}\n\n/** Filter for fetchManifest. All fields optional; missing = no filter. */\nexport interface CapabilityFilter {\n kind?: CapabilityKind;\n tags?: string[];\n /** Restrict to capabilities whose `name` is in this list. */\n names?: string[];\n}\n\n/**\n * A flat credential map: authField → value.\n *\n * The host is responsible for resolving values (from env vars, user\n * settings, OAuth sessions, etc.) before passing to the provider. The\n * provider does not inspect the origin — it just forwards to the tool.\n */\nexport type CredentialMap = Record<string, string>;\n\n/**\n * The core interface. All concrete providers implement this.\n *\n * Providers are identified by `providerId` for logging/debug. They fetch\n * their own manifest and build LangChain-compatible runnables from it.\n *\n * Lifetime: a provider may be instantiated once at startup (e.g., tools-\n * server pointing at a stable URL) or per-user (e.g., MCP with per-user\n * OAuth). The interface is agnostic.\n */\nexport interface CapabilityProvider {\n /** Stable identifier for this provider instance (e.g., \"tools-server:https://...\"). */\n readonly providerId: string;\n\n /**\n * Return the list of capabilities this provider exposes.\n *\n * Implementations may cache the manifest — the contract is that the\n * returned list reflects the provider's current view of available\n * capabilities.\n *\n * @param filter optional filter to scope the result\n */\n fetchManifest(filter?: CapabilityFilter): Promise<Capability[]>;\n\n /**\n * Build LangChain StructuredTools from a set of capabilities using the\n * caller-supplied credentials.\n *\n * Called at agent init. The returned tools are bound to the LLM and\n * invoked during the graph's tool-calling loop.\n *\n * @param capabilities the subset of capabilities the agent wants to use\n * @param credentials credential values keyed by authField\n */\n createRunnables(\n capabilities: Capability[],\n credentials: CredentialMap\n ): Promise<StructuredToolInterface[]>;\n}\n"],"names":["CapabilityKind","AuthSource"],"mappings":";;AAAA;;;;;;;;;;;;;;AAcG;AAIH;;;;;AAKG;AACSA;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX;;;;;AAKG;AACH,IAAA,cAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACb,CAAC,EAXWA,sBAAc,KAAdA,sBAAc,GAAA,EAAA,CAAA,CAAA;AAa1B;;;;AAIG;AACSC;AAAZ,CAAA,UAAY,UAAU,EAAA;;AAEpB,IAAA,UAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;;AAEjB,IAAA,UAAA,CAAA,MAAA,CAAA,GAAA,MAAa;;AAEb,IAAA,UAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACzB,CAAC,EAPWA,kBAAU,KAAVA,kBAAU,GAAA,EAAA,CAAA,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"types.cjs","sources":["../../../src/providers/types.ts"],"sourcesContent":["/**\n * CapabilityProvider types — the abstraction that lets agents consume tools,\n * skills, and MCP-backed capabilities through a single interface regardless\n * of where they come from.\n *\n * Design principles:\n * 1. Source-agnostic — providers are distinguished by WHERE they come from\n * (tools-server, skill store, MCP server), not by the backend service\n * any individual tool calls.\n * 2. Credential-agnostic — providers receive a flat credentialMap from the\n * host; they don't know about user settings, databases, OAuth flows.\n * 3. Extension-ready — the shape reserves slots for upcoming patterns\n * (skills injectedMessages, ToolCall.auth/expires_at, skill sessions)\n * so when those land we don't refactor the core.\n */\n\nimport type { StructuredToolInterface } from '@langchain/core/tools';\n\n/**\n * Kind of capability. Today only TOOL is implemented; SKILL and MCP are\n * reserved — SkillCapabilityProvider + MCPCapabilityProvider will populate\n * them in later phases. Keeping the enum from day one prevents a breaking\n * change when those ship.\n */\nexport enum CapabilityKind {\n TOOL = 'tool',\n SKILL = 'skill',\n MCP = 'mcp',\n /**\n * Remote agent reachable over the A2A (Agent-to-Agent) protocol.\n * The library's `A2ACapabilityProvider` is a client for this kind —\n * invoking an A2A capability sends a JSON-RPC `tasks/send` to the\n * remote agent's endpoint.\n */\n A2A = 'a2a',\n}\n\n/**\n * Where an auth credential comes from. Used by hosts to decide whether to\n * forward the credential per-request or let the capability provider resolve\n * it from its own environment.\n */\nexport enum AuthSource {\n /** Resolved by the capability provider itself from its environment. Host never sends. */\n SERVER = 'server',\n /** User-configured value stored in the host's credential store. Host forwards per-request. */\n USER = 'user',\n /** Active OAuth/session token. Host forwards per-request from active session. */\n FORWARDED = 'forwarded',\n}\n\n/**\n * One entry in a capability's auth config. Describes a single credential\n * the capability needs. The `source` field tells the host how to resolve\n * the value; the `prod`/`admin`/`hide` flags control UI visibility.\n */\nexport interface AuthConfigEntry {\n /** Environment-variable-style name (e.g., \"OPENAI_API_KEY\"). Stable identifier. */\n authField: string;\n /** Human-readable label for UI. */\n label?: string;\n /** Optional description of how to obtain the credential. */\n description?: string;\n /** Where the value comes from. Defaults to USER if unspecified. */\n source?: AuthSource;\n /** True if the credential is required for the capability to function. */\n required?: boolean;\n /** Platform-managed in production — never prompt user. */\n prod?: boolean;\n /** Only admins can configure. */\n admin?: boolean;\n /** Never show in any UI (used when source === SERVER). */\n hide?: boolean;\n}\n\n/**\n * Arbitrary metadata attached to a capability. Extension point.\n *\n * Fields prefixed with \"Reserved for\" are not populated today but exist in\n * the type so upstream patterns (skills, auth expiration, sessions) can\n * drop in without a schema migration.\n */\nexport interface CapabilityMetadata {\n /** Icon URL or path relative to the provider's static asset root. */\n icon?: string;\n /** Category for UI grouping (e.g., \"search\", \"image\", \"finance\"). */\n category?: string;\n /** Free-form tags for filtering / search. */\n tags?: string[];\n\n // --- Governance flags ------------------------------------------------\n\n /**\n * When true, hosts omit this capability from user-facing pickers\n * (Agent Builder, tool dropdown). Still invokable when a saved agent\n * references it by name.\n */\n hidden?: boolean;\n /** When true, only admin-role users can enable or invoke this capability. */\n admin?: boolean;\n /**\n * Deployment-stage restriction. When set, hosts whose deployment stage\n * isn't in the array should hide the capability (e.g., a prod host\n * shouldn't surface a tool with `env: ['development']`).\n */\n env?: Array<'development' | 'production' | 'test' | 'staging'>;\n\n // --- Reserved for upstream patterns (not populated today) ---\n\n /** Reserved for upstream `fix/auth-events` — auth mode declared by tool. */\n auth?: string;\n /** Reserved for upstream `fix/auth-events` — Unix timestamp for token expiration. */\n expires_at?: number;\n /** Reserved for upstream skills — capability returns injected messages on execute. */\n injectedMessages?: boolean;\n /** Reserved for upstream skills — capability consumes ToolSessionMap state. */\n sessionAware?: boolean;\n}\n\n/**\n * A single capability — a tool, skill, or MCP-backed operation that an agent\n * can invoke. The shape mirrors common plugin-manifest conventions so the\n * same entry can round-trip between an upstream catalog and a host registry.\n */\nexport interface Capability {\n /** What kind of capability this is. Controls how it's invoked downstream. */\n kind: CapabilityKind;\n /**\n * Stable unique identifier. For tools this is the pluginKey\n * (e.g., \"dalle\", \"wikipedia\"). For skills this is the skill's `name`.\n * Used everywhere the capability is referenced.\n */\n name: string;\n /** Human-readable description for the LLM and UI. */\n description: string;\n /**\n * Input schema as JSON Schema. For tools this comes from the Zod schema\n * passed through `zodToJsonSchema`. Optional for capabilities with no\n * input (e.g., parameter-less skills).\n */\n schema?: unknown;\n /** Credential requirements. */\n authConfig: AuthConfigEntry[];\n /** Extension metadata. See CapabilityMetadata. */\n metadata: CapabilityMetadata;\n}\n\n/** Filter for fetchManifest. All fields optional; missing = no filter. */\nexport interface CapabilityFilter {\n kind?: CapabilityKind;\n tags?: string[];\n /** Restrict to capabilities whose `name` is in this list. */\n names?: string[];\n}\n\n/**\n * A flat credential map: authField → value.\n *\n * The host is responsible for resolving values (from env vars, user\n * settings, OAuth sessions, etc.) before passing to the provider. The\n * provider does not inspect the origin — it just forwards to the tool.\n */\nexport type CredentialMap = Record<string, string>;\n\n/**\n * The core interface. All concrete providers implement this.\n *\n * Providers are identified by `providerId` for logging/debug. They fetch\n * their own manifest and build LangChain-compatible runnables from it.\n *\n * Lifetime: a provider may be instantiated once at startup (e.g., tools-\n * server pointing at a stable URL) or per-user (e.g., MCP with per-user\n * OAuth). The interface is agnostic.\n */\nexport interface CapabilityProvider {\n /** Stable identifier for this provider instance (e.g., \"tools-server:https://...\"). */\n readonly providerId: string;\n\n /**\n * Return the list of capabilities this provider exposes.\n *\n * Implementations may cache the manifest — the contract is that the\n * returned list reflects the provider's current view of available\n * capabilities.\n *\n * @param filter optional filter to scope the result\n */\n fetchManifest(filter?: CapabilityFilter): Promise<Capability[]>;\n\n /**\n * Build LangChain StructuredTools from a set of capabilities using the\n * caller-supplied credentials.\n *\n * Called at agent init. The returned tools are bound to the LLM and\n * invoked during the graph's tool-calling loop.\n *\n * @param capabilities the subset of capabilities the agent wants to use\n * @param credentials credential values keyed by authField\n */\n createRunnables(\n capabilities: Capability[],\n credentials: CredentialMap\n ): Promise<StructuredToolInterface[]>;\n}\n"],"names":["CapabilityKind","AuthSource"],"mappings":";;AAAA;;;;;;;;;;;;;;AAcG;AAIH;;;;;AAKG;AACSA;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX;;;;;AAKG;AACH,IAAA,cAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACb,CAAC,EAXWA,sBAAc,KAAdA,sBAAc,GAAA,EAAA,CAAA,CAAA;AAa1B;;;;AAIG;AACSC;AAAZ,CAAA,UAAY,UAAU,EAAA;;AAEpB,IAAA,UAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;;AAEjB,IAAA,UAAA,CAAA,MAAA,CAAA,GAAA,MAAa;;AAEb,IAAA,UAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACzB,CAAC,EAPWA,kBAAU,KAAVA,kBAAU,GAAA,EAAA,CAAA,CAAA;;"}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
|
|
5
|
-
const ARTIFACT_WRITE_ACTIONS = [
|
|
5
|
+
const ARTIFACT_WRITE_ACTIONS = [
|
|
6
|
+
'write',
|
|
7
|
+
'edit',
|
|
8
|
+
'verify',
|
|
9
|
+
'delete',
|
|
10
|
+
];
|
|
6
11
|
const CONTENT_READ_ACTIONS = ['read', 'search', 'list', 'info'];
|
|
7
12
|
const artifactToolSchema = zod.z.object({
|
|
8
13
|
action: zod.z
|
|
@@ -26,7 +31,10 @@ const artifactToolSchema = zod.z.object({
|
|
|
26
31
|
.string()
|
|
27
32
|
.optional()
|
|
28
33
|
.describe('Exact string to find and replace (required for edit).'),
|
|
29
|
-
new_str: zod.z
|
|
34
|
+
new_str: zod.z
|
|
35
|
+
.string()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe('Replacement string (required for edit).'),
|
|
30
38
|
replace_all: zod.z
|
|
31
39
|
.boolean()
|
|
32
40
|
.optional()
|
|
@@ -44,12 +52,27 @@ const contentReaderSchema = zod.z.object({
|
|
|
44
52
|
start_line: zod.z.number().optional().describe('1-based start line for reading.'),
|
|
45
53
|
end_line: zod.z.number().optional().describe('1-based end line (inclusive).'),
|
|
46
54
|
// search
|
|
47
|
-
pattern: zod.z
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
pattern: zod.z
|
|
56
|
+
.string()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe('Regex pattern (required for search).'),
|
|
59
|
+
flags: zod.z
|
|
60
|
+
.string()
|
|
61
|
+
.optional()
|
|
62
|
+
.describe('Regex flags (e.g., "i" for case-insensitive).'),
|
|
63
|
+
context: zod.z
|
|
64
|
+
.number()
|
|
65
|
+
.optional()
|
|
66
|
+
.describe('Lines of context around each match.'),
|
|
50
67
|
// shared pagination
|
|
51
|
-
offset: zod.z
|
|
52
|
-
|
|
68
|
+
offset: zod.z
|
|
69
|
+
.number()
|
|
70
|
+
.optional()
|
|
71
|
+
.describe('Offset for read or search pagination.'),
|
|
72
|
+
limit: zod.z
|
|
73
|
+
.number()
|
|
74
|
+
.optional()
|
|
75
|
+
.describe('Max lines (read) or matches (search).'),
|
|
53
76
|
});
|
|
54
77
|
const ARTIFACT_TOOL_NAME = 'artifact_tool';
|
|
55
78
|
const CONTENT_READER_NAME = 'content_reader';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.cjs","sources":["../../../../src/tools/artifacts/schema.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const ARTIFACT_WRITE_ACTIONS = ['write'
|
|
1
|
+
{"version":3,"file":"schema.cjs","sources":["../../../../src/tools/artifacts/schema.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const ARTIFACT_WRITE_ACTIONS = [\n 'write',\n 'edit',\n 'verify',\n 'delete',\n] as const;\nexport const CONTENT_READ_ACTIONS = ['read', 'search', 'list', 'info'] as const;\n\nexport const artifactToolSchema = z.object({\n action: z\n .enum(ARTIFACT_WRITE_ACTIONS)\n .describe(\n 'Authoring action: write (create/overwrite), edit (str_replace), verify (syntax check), delete (remove).'\n ),\n content_id: z\n .string()\n .optional()\n .describe(\n 'ID of the artifact entry. Required for edit/verify/delete; optional for write (supply to overwrite an existing entry).'\n ),\n\n // write\n content: z\n .string()\n .optional()\n .describe('Full file content (required for write action).'),\n name: z\n .string()\n .optional()\n .describe(\n 'Filename for the new entry (required when creating). MUST include the correct file extension — the extension drives the preview template.'\n ),\n\n // edit (str_replace)\n old_str: z\n .string()\n .optional()\n .describe('Exact string to find and replace (required for edit).'),\n new_str: z\n .string()\n .optional()\n .describe('Replacement string (required for edit).'),\n replace_all: z\n .boolean()\n .optional()\n .describe(\n 'edit: when true, replaces every occurrence of old_str. When false (default) and old_str matches more than one location, the edit is refused.'\n ),\n});\n\nexport const contentReaderSchema = z.object({\n action: z\n .enum(CONTENT_READ_ACTIONS)\n .describe(\n 'Read-only action: read (lines), search (regex), list (all entries), info (metadata).'\n ),\n content_id: z\n .string()\n .optional()\n .describe(\n 'ID of the content entry. Required for read/search/info. Omit for list.'\n ),\n\n // read pagination\n start_line: z.number().optional().describe('1-based start line for reading.'),\n end_line: z.number().optional().describe('1-based end line (inclusive).'),\n\n // search\n pattern: z\n .string()\n .optional()\n .describe('Regex pattern (required for search).'),\n flags: z\n .string()\n .optional()\n .describe('Regex flags (e.g., \"i\" for case-insensitive).'),\n context: z\n .number()\n .optional()\n .describe('Lines of context around each match.'),\n\n // shared pagination\n offset: z\n .number()\n .optional()\n .describe('Offset for read or search pagination.'),\n limit: z\n .number()\n .optional()\n .describe('Max lines (read) or matches (search).'),\n});\n\nexport const ARTIFACT_TOOL_NAME = 'artifact_tool';\nexport const CONTENT_READER_NAME = 'content_reader';\n\nexport type ArtifactToolInput = z.infer<typeof artifactToolSchema>;\nexport type ContentReaderInput = z.infer<typeof contentReaderSchema>;\n"],"names":["z"],"mappings":";;;;AAEO,MAAM,sBAAsB,GAAG;IACpC,OAAO;IACP,MAAM;IACN,QAAQ;IACR,QAAQ;;AAEH,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM;AAE9D,MAAM,kBAAkB,GAAGA,KAAC,CAAC,MAAM,CAAC;AACzC,IAAA,MAAM,EAAEA;SACL,IAAI,CAAC,sBAAsB;SAC3B,QAAQ,CACP,yGAAyG,CAC1G;AACH,IAAA,UAAU,EAAEA;AACT,SAAA,MAAM;AACN,SAAA,QAAQ;SACR,QAAQ,CACP,wHAAwH,CACzH;;AAGH,IAAA,OAAO,EAAEA;AACN,SAAA,MAAM;AACN,SAAA,QAAQ;SACR,QAAQ,CAAC,gDAAgD,CAAC;AAC7D,IAAA,IAAI,EAAEA;AACH,SAAA,MAAM;AACN,SAAA,QAAQ;SACR,QAAQ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AEM,MAAM,kBAAkB,GAAG;AAC3B,MAAM,mBAAmB,GAAG;;;;;;;;;"}
|
|
@@ -106,7 +106,10 @@ function createArtifactTool(config) {
|
|
|
106
106
|
return await handlers.delete(args, scope);
|
|
107
107
|
}
|
|
108
108
|
default:
|
|
109
|
-
return [
|
|
109
|
+
return [
|
|
110
|
+
`Unknown action: ${input.action}`,
|
|
111
|
+
{},
|
|
112
|
+
];
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
catch (err) {
|
|
@@ -183,7 +186,10 @@ function createContentReaderTool(config) {
|
|
|
183
186
|
return await handlers.info(args, scope);
|
|
184
187
|
}
|
|
185
188
|
default:
|
|
186
|
-
return [
|
|
189
|
+
return [
|
|
190
|
+
`Unknown action: ${input.action}`,
|
|
191
|
+
{},
|
|
192
|
+
];
|
|
187
193
|
}
|
|
188
194
|
}
|
|
189
195
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.cjs","sources":["../../../../src/tools/artifacts/tool.ts"],"sourcesContent":["/**\n * artifact_tool + content_reader library factories.\n *\n * The library owns the LangChain wiring (schema, description, response\n * shape) and the action dispatch; the runtime supplies a handler bundle\n * matching the `ArtifactWriteHandlers` / `ContentReadHandlers` interface.\n *\n * This keeps 800+ LOC of host-specific handler logic (S3 adapters, file\n * model CRUD, syntax checkers, line utils) out of the library while\n * still centralizing the tool surface every runtime shares.\n */\n\nimport { tool, DynamicStructuredTool } from '@langchain/core/tools';\nimport {\n artifactToolSchema,\n contentReaderSchema,\n ARTIFACT_TOOL_NAME,\n CONTENT_READER_NAME,\n} from './schema';\nimport type {\n ArtifactToolConfig,\n ContentReaderToolConfig,\n ArtifactToolScope,\n ArtifactToolResult,\n WriteArgs,\n EditArgs,\n VerifyArgs,\n DeleteArgs,\n ReadArgs,\n SearchArgs,\n ListArgs,\n InfoArgs,\n ContentIdResolver,\n} from './types';\n\nconst DEFAULT_ARTIFACT_DESCRIPTION = `Author content artifacts that render live in the host's preview panel — this tool does NOT produce downloadable files (use execute_code for those).\n\nActions:\n- write: Create a new artifact. Write a COMPLETE file in one call. The \\`name\\` field MUST include the file extension — it routes the preview (.tsx, .html, .mmd, .svg, .csv, .json, .dot, .md, .drawio).\n- verify: Check an artifact for syntax errors. REQUIRED as the next step after every write/edit on code files — do not render until verify passes.\n- edit: Surgical string replacement — provide old_str (exact match) and new_str. Works on all file types.\n- delete: Remove an artifact and its backing file.\n\nArtifacts are persisted by the host. No manual save needed.`;\n\nconst DEFAULT_CONTENT_READER_DESCRIPTION = `Read and navigate stored content — artifacts authored by artifact_tool, large tool results auto-cached by the host, uploaded file attachments, and code blocks.\n\nRead-only surface. Use write/edit tools (artifact_tool, execute_code) to mutate.\n\nActions:\n- read: Return line ranges from a specific content_id.\n- search: Regex search across a specific content_id with paginated matches.\n- list: Enumerate every content entry currently stored.\n- info: Metadata (size, kind, creation time) for a specific content_id.`;\n\n/**\n * Optional content_id self-healing — if the runtime supplies a resolver,\n * we pre-resolve the ID on every action that takes one so nicknames\n * (e.g., \"Dashboard\") map to canonical IDs.\n */\nasync function resolveContentIdIfPresent(\n resolver: ContentIdResolver | undefined,\n id: string | undefined,\n scope: ArtifactToolScope,\n logger?: { debug: (msg: string) => void },\n): Promise<string | undefined> {\n if (!resolver || !id) return id;\n const out = await resolver.resolve(id, scope);\n if (!out) return id;\n if (out.resolvedId !== id) {\n logger?.debug(\n `[artifact] resolved \"${id}\" → \"${out.resolvedId}\"${out.resolvedName ? ` (\"${out.resolvedName}\")` : ''}`,\n );\n }\n return out.resolvedId;\n}\n\n// ─── Writer tool (artifact_tool) ─────────────────────────────────────────\n\nexport function createArtifactTool(\n config: ArtifactToolConfig,\n): DynamicStructuredTool {\n const { handlers, getScope, resolver, logger, descriptionOverride } = config;\n\n return tool(\n async (rawInput, runnableConfig): Promise<ArtifactToolResult> => {\n const scope = getScope(runnableConfig);\n if (!scope) {\n logger?.warn('[artifact_tool] no scope resolved from runnableConfig');\n return ['Error: No conversation context available', {}];\n }\n\n const input = rawInput as {\n action: 'write' | 'edit' | 'verify' | 'delete';\n content_id?: string;\n content?: string;\n name?: string;\n old_str?: string;\n new_str?: string;\n replace_all?: boolean;\n };\n\n const resolvedContentId = await resolveContentIdIfPresent(\n resolver,\n input.content_id,\n scope,\n logger,\n );\n\n const started = Date.now();\n try {\n switch (input.action) {\n case 'write': {\n const args: WriteArgs = {\n action: 'write',\n content_id: resolvedContentId,\n content: input.content ?? '',\n name: input.name,\n };\n if (!args.content) return ['Error: write requires content', {}];\n return await handlers.write(args, scope);\n }\n case 'edit': {\n if (!resolvedContentId) return ['Error: edit requires content_id', {}];\n const args: EditArgs = {\n action: 'edit',\n content_id: resolvedContentId,\n old_str: input.old_str ?? '',\n new_str: input.new_str ?? '',\n replace_all: input.replace_all,\n };\n if (!args.old_str) return ['Error: edit requires old_str', {}];\n return await handlers.edit(args, scope);\n }\n case 'verify': {\n if (!resolvedContentId) return ['Error: verify requires content_id', {}];\n const args: VerifyArgs = {\n action: 'verify',\n content_id: resolvedContentId,\n };\n return await handlers.verify(args, scope);\n }\n case 'delete': {\n if (!resolvedContentId) return ['Error: delete requires content_id', {}];\n const args: DeleteArgs = {\n action: 'delete',\n content_id: resolvedContentId,\n };\n return await handlers.delete(args, scope);\n }\n default:\n return [`Unknown action: ${(input as { action: string }).action}`, {}];\n }\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n logger?.error('[artifact_tool] handler threw', {\n action: input.action,\n contentId: resolvedContentId,\n error: e.message,\n elapsed: `${Date.now() - started}ms`,\n });\n return [`Error: ${e.message}`, {}];\n }\n },\n {\n name: ARTIFACT_TOOL_NAME,\n responseFormat: 'content_and_artifact',\n description: descriptionOverride ?? DEFAULT_ARTIFACT_DESCRIPTION,\n schema: artifactToolSchema,\n },\n );\n}\n\n// ─── Reader tool (content_reader) ────────────────────────────────────────\n\nexport function createContentReaderTool(\n config: ContentReaderToolConfig,\n): DynamicStructuredTool {\n const { handlers, getScope, resolver, logger, descriptionOverride } = config;\n\n return tool(\n async (rawInput, runnableConfig): Promise<ArtifactToolResult> => {\n const scope = getScope(runnableConfig);\n if (!scope) {\n logger?.warn('[content_reader] no scope resolved from runnableConfig');\n return ['Error: No conversation context available', {}];\n }\n\n const input = rawInput as {\n action: 'read' | 'search' | 'list' | 'info';\n content_id?: string;\n start_line?: number;\n end_line?: number;\n pattern?: string;\n flags?: string;\n context?: number;\n offset?: number;\n limit?: number;\n };\n\n const resolvedContentId = await resolveContentIdIfPresent(\n resolver,\n input.content_id,\n scope,\n logger,\n );\n\n const started = Date.now();\n try {\n switch (input.action) {\n case 'read': {\n if (!resolvedContentId) return ['Error: read requires content_id', {}];\n const args: ReadArgs = {\n action: 'read',\n content_id: resolvedContentId,\n start_line: input.start_line,\n end_line: input.end_line,\n offset: input.offset,\n limit: input.limit,\n };\n return await handlers.read(args, scope);\n }\n case 'search': {\n if (!resolvedContentId) return ['Error: search requires content_id', {}];\n if (!input.pattern) return ['Error: search requires pattern', {}];\n const args: SearchArgs = {\n action: 'search',\n content_id: resolvedContentId,\n pattern: input.pattern,\n flags: input.flags,\n context: input.context,\n offset: input.offset,\n limit: input.limit,\n };\n return await handlers.search(args, scope);\n }\n case 'list': {\n const args: ListArgs = { action: 'list' };\n return await handlers.list(args, scope);\n }\n case 'info': {\n if (!resolvedContentId) return ['Error: info requires content_id', {}];\n const args: InfoArgs = {\n action: 'info',\n content_id: resolvedContentId,\n };\n return await handlers.info(args, scope);\n }\n default:\n return [`Unknown action: ${(input as { action: string }).action}`, {}];\n }\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n logger?.error('[content_reader] handler threw', {\n action: input.action,\n contentId: resolvedContentId,\n error: e.message,\n elapsed: `${Date.now() - started}ms`,\n });\n return [`Error: ${e.message}`, {}];\n }\n },\n {\n name: CONTENT_READER_NAME,\n responseFormat: 'content_and_artifact',\n description: descriptionOverride ?? DEFAULT_CONTENT_READER_DESCRIPTION,\n schema: contentReaderSchema,\n },\n );\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;AAC7D,YAAA,MAAM,EAAE,KAAK,CAAC,gCAAgC,EAAE;gBAC9C,MAAM,EAAE,KAAK,CAAC,MAAM;AACpB,gBAAA,SAAS,EAAE,iBAAiB;gBAC5B,KAAK,EAAE,CAAC,CAAC,OAAO;gBAChB,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAA,EAAA,CAAI;AACrC,aAAA,CAAC;YACF,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAA,CAAE,EAAE,EAAE,CAAC;QACpC;AACF,IAAA,CAAC,EACD;AACE,QAAA,IAAI,EAAEG,0BAAmB;AACzB,QAAA,cAAc,EAAE,sBAAsB;QACtC,WAAW,EAAE,mBAAmB,IAAI,kCAAkC;AACtE,QAAA,MAAM,EAAEC,0BAAmB;AAC5B,KAAA,CACF;AACH;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"tool.cjs","sources":["../../../../src/tools/artifacts/tool.ts"],"sourcesContent":["/**\n * artifact_tool + content_reader library factories.\n *\n * The library owns the LangChain wiring (schema, description, response\n * shape) and the action dispatch; the runtime supplies a handler bundle\n * matching the `ArtifactWriteHandlers` / `ContentReadHandlers` interface.\n *\n * This keeps 800+ LOC of host-specific handler logic (S3 adapters, file\n * model CRUD, syntax checkers, line utils) out of the library while\n * still centralizing the tool surface every runtime shares.\n */\n\nimport { tool, DynamicStructuredTool } from '@langchain/core/tools';\nimport {\n artifactToolSchema,\n contentReaderSchema,\n ARTIFACT_TOOL_NAME,\n CONTENT_READER_NAME,\n} from './schema';\nimport type {\n ArtifactToolConfig,\n ContentReaderToolConfig,\n ArtifactToolScope,\n ArtifactToolResult,\n WriteArgs,\n EditArgs,\n VerifyArgs,\n DeleteArgs,\n ReadArgs,\n SearchArgs,\n ListArgs,\n InfoArgs,\n ContentIdResolver,\n} from './types';\n\nconst DEFAULT_ARTIFACT_DESCRIPTION = `Author content artifacts that render live in the host's preview panel — this tool does NOT produce downloadable files (use execute_code for those).\n\nActions:\n- write: Create a new artifact. Write a COMPLETE file in one call. The \\`name\\` field MUST include the file extension — it routes the preview (.tsx, .html, .mmd, .svg, .csv, .json, .dot, .md, .drawio).\n- verify: Check an artifact for syntax errors. REQUIRED as the next step after every write/edit on code files — do not render until verify passes.\n- edit: Surgical string replacement — provide old_str (exact match) and new_str. Works on all file types.\n- delete: Remove an artifact and its backing file.\n\nArtifacts are persisted by the host. No manual save needed.`;\n\nconst DEFAULT_CONTENT_READER_DESCRIPTION = `Read and navigate stored content — artifacts authored by artifact_tool, large tool results auto-cached by the host, uploaded file attachments, and code blocks.\n\nRead-only surface. Use write/edit tools (artifact_tool, execute_code) to mutate.\n\nActions:\n- read: Return line ranges from a specific content_id.\n- search: Regex search across a specific content_id with paginated matches.\n- list: Enumerate every content entry currently stored.\n- info: Metadata (size, kind, creation time) for a specific content_id.`;\n\n/**\n * Optional content_id self-healing — if the runtime supplies a resolver,\n * we pre-resolve the ID on every action that takes one so nicknames\n * (e.g., \"Dashboard\") map to canonical IDs.\n */\nasync function resolveContentIdIfPresent(\n resolver: ContentIdResolver | undefined,\n id: string | undefined,\n scope: ArtifactToolScope,\n logger?: { debug: (msg: string) => void }\n): Promise<string | undefined> {\n if (!resolver || !id) return id;\n const out = await resolver.resolve(id, scope);\n if (!out) return id;\n if (out.resolvedId !== id) {\n logger?.debug(\n `[artifact] resolved \"${id}\" → \"${out.resolvedId}\"${out.resolvedName ? ` (\"${out.resolvedName}\")` : ''}`\n );\n }\n return out.resolvedId;\n}\n\n// ─── Writer tool (artifact_tool) ─────────────────────────────────────────\n\nexport function createArtifactTool(\n config: ArtifactToolConfig\n): DynamicStructuredTool {\n const { handlers, getScope, resolver, logger, descriptionOverride } = config;\n\n return tool(\n async (rawInput, runnableConfig): Promise<ArtifactToolResult> => {\n const scope = getScope(runnableConfig);\n if (!scope) {\n logger?.warn('[artifact_tool] no scope resolved from runnableConfig');\n return ['Error: No conversation context available', {}];\n }\n\n const input = rawInput as {\n action: 'write' | 'edit' | 'verify' | 'delete';\n content_id?: string;\n content?: string;\n name?: string;\n old_str?: string;\n new_str?: string;\n replace_all?: boolean;\n };\n\n const resolvedContentId = await resolveContentIdIfPresent(\n resolver,\n input.content_id,\n scope,\n logger\n );\n\n const started = Date.now();\n try {\n switch (input.action) {\n case 'write': {\n const args: WriteArgs = {\n action: 'write',\n content_id: resolvedContentId,\n content: input.content ?? '',\n name: input.name,\n };\n if (!args.content) return ['Error: write requires content', {}];\n return await handlers.write(args, scope);\n }\n case 'edit': {\n if (!resolvedContentId)\n return ['Error: edit requires content_id', {}];\n const args: EditArgs = {\n action: 'edit',\n content_id: resolvedContentId,\n old_str: input.old_str ?? '',\n new_str: input.new_str ?? '',\n replace_all: input.replace_all,\n };\n if (!args.old_str) return ['Error: edit requires old_str', {}];\n return await handlers.edit(args, scope);\n }\n case 'verify': {\n if (!resolvedContentId)\n return ['Error: verify requires content_id', {}];\n const args: VerifyArgs = {\n action: 'verify',\n content_id: resolvedContentId,\n };\n return await handlers.verify(args, scope);\n }\n case 'delete': {\n if (!resolvedContentId)\n return ['Error: delete requires content_id', {}];\n const args: DeleteArgs = {\n action: 'delete',\n content_id: resolvedContentId,\n };\n return await handlers.delete(args, scope);\n }\n default:\n return [\n `Unknown action: ${(input as { action: string }).action}`,\n {},\n ];\n }\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n logger?.error('[artifact_tool] handler threw', {\n action: input.action,\n contentId: resolvedContentId,\n error: e.message,\n elapsed: `${Date.now() - started}ms`,\n });\n return [`Error: ${e.message}`, {}];\n }\n },\n {\n name: ARTIFACT_TOOL_NAME,\n responseFormat: 'content_and_artifact',\n description: descriptionOverride ?? DEFAULT_ARTIFACT_DESCRIPTION,\n schema: artifactToolSchema,\n }\n );\n}\n\n// ─── Reader tool (content_reader) ────────────────────────────────────────\n\nexport function createContentReaderTool(\n config: ContentReaderToolConfig\n): DynamicStructuredTool {\n const { handlers, getScope, resolver, logger, descriptionOverride } = config;\n\n return tool(\n async (rawInput, runnableConfig): Promise<ArtifactToolResult> => {\n const scope = getScope(runnableConfig);\n if (!scope) {\n logger?.warn('[content_reader] no scope resolved from runnableConfig');\n return ['Error: No conversation context available', {}];\n }\n\n const input = rawInput as {\n action: 'read' | 'search' | 'list' | 'info';\n content_id?: string;\n start_line?: number;\n end_line?: number;\n pattern?: string;\n flags?: string;\n context?: number;\n offset?: number;\n limit?: number;\n };\n\n const resolvedContentId = await resolveContentIdIfPresent(\n resolver,\n input.content_id,\n scope,\n logger\n );\n\n const started = Date.now();\n try {\n switch (input.action) {\n case 'read': {\n if (!resolvedContentId)\n return ['Error: read requires content_id', {}];\n const args: ReadArgs = {\n action: 'read',\n content_id: resolvedContentId,\n start_line: input.start_line,\n end_line: input.end_line,\n offset: input.offset,\n limit: input.limit,\n };\n return await handlers.read(args, scope);\n }\n case 'search': {\n if (!resolvedContentId)\n return ['Error: search requires content_id', {}];\n if (!input.pattern) return ['Error: search requires pattern', {}];\n const args: SearchArgs = {\n action: 'search',\n content_id: resolvedContentId,\n pattern: input.pattern,\n flags: input.flags,\n context: input.context,\n offset: input.offset,\n limit: input.limit,\n };\n return await handlers.search(args, scope);\n }\n case 'list': {\n const args: ListArgs = { action: 'list' };\n return await handlers.list(args, scope);\n }\n case 'info': {\n if (!resolvedContentId)\n return ['Error: info requires content_id', {}];\n const args: InfoArgs = {\n action: 'info',\n content_id: resolvedContentId,\n };\n return await handlers.info(args, scope);\n }\n default:\n return [\n `Unknown action: ${(input as { action: string }).action}`,\n {},\n ];\n }\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n logger?.error('[content_reader] handler threw', {\n action: input.action,\n contentId: resolvedContentId,\n error: e.message,\n elapsed: `${Date.now() - started}ms`,\n });\n return [`Error: ${e.message}`, {}];\n }\n },\n {\n name: CONTENT_READER_NAME,\n responseFormat: 'content_and_artifact',\n description: descriptionOverride ?? DEFAULT_CONTENT_READER_DESCRIPTION,\n schema: contentReaderSchema,\n }\n );\n}\n\nexport {\n AR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AC,CAAC;AAC7D,YAAA,MAAM,EAAE,KAAK,CAAC,gCAAgC,EAAE;gBAC9C,MAAM,EAAE,KAAK,CAAC,MAAM;AACpB,gBAAA,SAAS,EAAE,iBAAiB;gBAC5B,KAAK,EAAE,CAAC,CAAC,OAAO;gBAChB,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAA,EAAA,CAAI;AACrC,aAAA,CAAC;YACF,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAA,CAAE,EAAE,EAAE,CAAC;QACpC;AACF,IAAA,CAAC,EACD;AACE,QAAA,IAAI,EAAEG,0BAAmB;AACzB,QAAA,cAAc,EAAE,sBAAsB;QACtC,WAAW,EAAE,mBAAmB,IAAI,kCAAkC;AACtE,QAAA,MAAM,EAAEC,0BAAmB;AAC5B,KAAA,CACF;AACH;;;;;;;;;"}
|
|
@@ -24,7 +24,7 @@ var httpClient = require('../utils/httpClient.cjs');
|
|
|
24
24
|
* per-invocation credential rotation should rebuild the tool.
|
|
25
25
|
*/
|
|
26
26
|
function buildProxyTool(capability, credentials, options) {
|
|
27
|
-
const { client, executePath = '/execute/:name', onExecute } = options;
|
|
27
|
+
const { client, executePath = '/execute/:name', onExecute, getAuthHeaders, } = options;
|
|
28
28
|
const url = executePath.replace(':name', encodeURIComponent(capability.name));
|
|
29
29
|
return tools.tool(async (input) => {
|
|
30
30
|
const startMs = Date.now();
|
|
@@ -33,10 +33,12 @@ function buildProxyTool(capability, credentials, options) {
|
|
|
33
33
|
// DEBUG: log (remove after POC stabilizes)
|
|
34
34
|
// eslint-disable-next-line no-console
|
|
35
35
|
console.debug(`${debugPrefix} invoking — inputKeys=${input && typeof input === 'object' ? Object.keys(input).length : 0}`);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
36
|
+
const extraHeaders = getAuthHeaders
|
|
37
|
+
? await getAuthHeaders()
|
|
38
|
+
: undefined;
|
|
39
|
+
const res = await client.post(url, { input, credentials }, extraHeaders && Object.keys(extraHeaders).length > 0
|
|
40
|
+
? { headers: extraHeaders }
|
|
41
|
+
: undefined);
|
|
40
42
|
const durationMs = Date.now() - startMs;
|
|
41
43
|
if (res.status < 200 || res.status >= 300) {
|
|
42
44
|
throw new httpClient.HttpError(res.status, url, res.data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyTool.cjs","sources":["../../../src/tools/proxyTool.ts"],"sourcesContent":["/**\n * proxyTool — wraps a Capability into a LangChain StructuredTool that\n * dispatches execution to a remote backend (e.g., tools-server) over HTTP.\n *\n * The LLM sees this tool identically to a locally-implemented tool:\n * - same name\n * - same description\n * - same input schema (JSON Schema)\n * - same invoke(input) contract\n *\n * Under the hood, invoke() POSTs to the backend's execute endpoint with\n * the input and a caller-supplied credential map. The backend returns\n * { success, result, error, timing } which this wrapper unpacks.\n */\n\nimport type { AxiosInstance } from 'axios';\nimport { tool, type StructuredToolInterface } from '@langchain/core/tools';\nimport type { Capability, CredentialMap } from '@/providers/types';\nimport { HttpError } from '@/utils/httpClient';\n\n/** Shape of the backend's execute response. Matches tools-server. */\nexport interface ExecuteResponse {\n success: boolean;\n result?: unknown;\n error?: string;\n timing?: { durationMs: number };\n}\n\n/** Options passed to buildProxyTool. */\nexport interface ProxyToolOptions {\n /** HTTP client configured with backend base URL + auth. */\n client: AxiosInstance;\n /**\n * Path template for execution. The literal `:name` is replaced with the\n * capability's name. Defaults to `/execute/:name` (tools-server convention).\n */\n executePath?: string;\n /**\n * Optional callback invoked on every execution — used for metrics,\n * telemetry, debug logging. Errors in the hook are swallowed.\n */\n onExecute?: (ctx: ExecuteCallbackContext) => void;\n}\n\nexport interface ExecuteCallbackContext {\n capabilityName: string;\n input: unknown;\n response?: ExecuteResponse;\n error?: Error;\n durationMs: number;\n}\n\n/**\n * Build a StructuredTool that proxies to a remote backend.\n *\n * The credentialMap is baked into the closure — callers that need\n * per-invocation credential rotation should rebuild the tool.\n */\nexport function buildProxyTool(\n capability: Capability,\n credentials: CredentialMap,\n options: ProxyToolOptions\n): StructuredToolInterface {\n const {
|
|
1
|
+
{"version":3,"file":"proxyTool.cjs","sources":["../../../src/tools/proxyTool.ts"],"sourcesContent":["/**\n * proxyTool — wraps a Capability into a LangChain StructuredTool that\n * dispatches execution to a remote backend (e.g., tools-server) over HTTP.\n *\n * The LLM sees this tool identically to a locally-implemented tool:\n * - same name\n * - same description\n * - same input schema (JSON Schema)\n * - same invoke(input) contract\n *\n * Under the hood, invoke() POSTs to the backend's execute endpoint with\n * the input and a caller-supplied credential map. The backend returns\n * { success, result, error, timing } which this wrapper unpacks.\n */\n\nimport type { AxiosInstance } from 'axios';\nimport { tool, type StructuredToolInterface } from '@langchain/core/tools';\nimport type { Capability, CredentialMap } from '@/providers/types';\nimport { HttpError } from '@/utils/httpClient';\n\n/** Shape of the backend's execute response. Matches tools-server. */\nexport interface ExecuteResponse {\n success: boolean;\n result?: unknown;\n error?: string;\n timing?: { durationMs: number };\n}\n\n/** Options passed to buildProxyTool. */\nexport interface ProxyToolOptions {\n /** HTTP client configured with backend base URL + auth. */\n client: AxiosInstance;\n /**\n * Path template for execution. The literal `:name` is replaced with the\n * capability's name. Defaults to `/execute/:name` (tools-server convention).\n */\n executePath?: string;\n /**\n * Optional callback invoked on every execution — used for metrics,\n * telemetry, debug logging. Errors in the hook are swallowed.\n */\n onExecute?: (ctx: ExecuteCallbackContext) => void;\n /**\n * Optional per-invocation auth header builder. Called on every tool\n * invocation before POSTing; returned headers are merged into the\n * request alongside the base client's headers. Typical use: pass a\n * freshly minted per-user JWT for admin-gated tools.\n */\n getAuthHeaders?: () =>\n | Record<string, string>\n | Promise<Record<string, string>>;\n}\n\nexport interface ExecuteCallbackContext {\n capabilityName: string;\n input: unknown;\n response?: ExecuteResponse;\n error?: Error;\n durationMs: number;\n}\n\n/**\n * Build a StructuredTool that proxies to a remote backend.\n *\n * The credentialMap is baked into the closure — callers that need\n * per-invocation credential rotation should rebuild the tool.\n */\nexport function buildProxyTool(\n capability: Capability,\n credentials: CredentialMap,\n options: ProxyToolOptions\n): StructuredToolInterface {\n const {\n client,\n executePath = '/execute/:name',\n onExecute,\n getAuthHeaders,\n } = options;\n const url = executePath.replace(':name', encodeURIComponent(capability.name));\n\n return tool(\n async (input: unknown): Promise<string> => {\n const startMs = Date.now();\n const debugPrefix = `[proxyTool:${capability.name}]`;\n\n try {\n // DEBUG: log (remove after POC stabilizes)\n // eslint-disable-next-line no-console\n console.debug(\n `${debugPrefix} invoking — inputKeys=${input && typeof input === 'object' ? Object.keys(input as object).length : 0}`\n );\n\n const extraHeaders = getAuthHeaders\n ? await getAuthHeaders()\n : undefined;\n const res = await client.post<ExecuteResponse>(\n url,\n { input, credentials },\n extraHeaders && Object.keys(extraHeaders).length > 0\n ? { headers: extraHeaders }\n : undefined,\n );\n\n const durationMs = Date.now() - startMs;\n\n if (res.status < 200 || res.status >= 300) {\n throw new HttpError(res.status, url, res.data);\n }\n\n const body = res.data;\n if (onExecute) {\n try {\n onExecute({\n capabilityName: capability.name,\n input,\n response: body,\n durationMs,\n });\n } catch {\n // hook errors are non-fatal\n }\n }\n\n if (!body.success) {\n // DEBUG\n // eslint-disable-next-line no-console\n console.debug(\n `${debugPrefix} backend reported failure — ${body.error}`\n );\n throw new Error(body.error ?? 'Tool execution failed');\n }\n\n // LangChain tools typically return strings; stringify non-string results\n if (typeof body.result === 'string') {\n return body.result;\n }\n return JSON.stringify(body.result);\n } catch (err) {\n const durationMs = Date.now() - startMs;\n const error = err instanceof Error ? err : new Error(String(err));\n if (onExecute) {\n try {\n onExecute({\n capabilityName: capability.name,\n input,\n error,\n durationMs,\n });\n } catch {\n // hook errors are non-fatal\n }\n }\n throw error;\n }\n },\n {\n name: capability.name,\n description: capability.description,\n schema: (capability.schema as object) ?? {\n type: 'object',\n properties: {},\n },\n responseFormat: 'content',\n }\n );\n}\n"],"names":["tool","HttpError"],"mappings":";;;;;AAAA;;;;;;;;;;;;;AAaG;AAgDH;;;;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,UAAU,EAAE,EAAE;AACf,SAAA;AACD,QAAA,cAAc,EAAE,SAAS;AAC1B,KAAA,CACF;AACH;;;;"}
|
|
@@ -20,9 +20,10 @@ class ToolsServerCapabilityProvider {
|
|
|
20
20
|
manifestPath;
|
|
21
21
|
executePath;
|
|
22
22
|
cache;
|
|
23
|
+
getExecuteAuthHeaders;
|
|
23
24
|
constructor(config) {
|
|
24
25
|
this.config = config;
|
|
25
|
-
const { baseUrl, apiKey, manifestPath = '/manifest', executePath = '/execute/:name', timeoutMs = 30_000, manifestTtlMs = 60_000, client, proxy, } = config;
|
|
26
|
+
const { baseUrl, apiKey, manifestPath = '/manifest', executePath = '/execute/:name', timeoutMs = 30_000, manifestTtlMs = 60_000, client, proxy, getExecuteAuthHeaders, } = config;
|
|
26
27
|
if (!baseUrl) {
|
|
27
28
|
throw new Error('ToolsServerCapabilityProvider: baseUrl is required');
|
|
28
29
|
}
|
|
@@ -33,6 +34,7 @@ class ToolsServerCapabilityProvider {
|
|
|
33
34
|
this.manifestPath = manifestPath;
|
|
34
35
|
this.executePath = executePath;
|
|
35
36
|
this.cache = new ManifestCache({ ttlMs: manifestTtlMs });
|
|
37
|
+
this.getExecuteAuthHeaders = getExecuteAuthHeaders;
|
|
36
38
|
if (client) {
|
|
37
39
|
this.client = client;
|
|
38
40
|
}
|
|
@@ -79,6 +81,7 @@ class ToolsServerCapabilityProvider {
|
|
|
79
81
|
return capabilities.map((cap) => buildProxyTool(cap, credentials, {
|
|
80
82
|
client: this.client,
|
|
81
83
|
executePath: this.executePath,
|
|
84
|
+
getAuthHeaders: this.getExecuteAuthHeaders,
|
|
82
85
|
}));
|
|
83
86
|
}
|
|
84
87
|
/** Force a manifest refresh on next fetchManifest call. */
|
|
@@ -111,6 +114,10 @@ function normalizeEntry(entry) {
|
|
|
111
114
|
icon: entry.icon,
|
|
112
115
|
category: entry.category,
|
|
113
116
|
tags: entry.tags,
|
|
117
|
+
// Governance — hosts use these to gate UI/role/environment.
|
|
118
|
+
hidden: entry.hidden,
|
|
119
|
+
admin: entry.admin,
|
|
120
|
+
env: entry.env,
|
|
114
121
|
},
|
|
115
122
|
};
|
|
116
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolsServerCapabilityProvider.mjs","sources":["../../../../src/providers/tools-server/ToolsServerCapabilityProvider.ts"],"sourcesContent":["/**\n * ToolsServerCapabilityProvider — capabilities sourced from a tools-server\n * HTTP endpoint.\n *\n * Fetches the manifest via GET /manifest, builds proxy StructuredTools via\n * POST /execute/:tool. Manifest is cached (TTL-configurable) so repeated\n * init cycles don't refetch.\n *\n * See docs/architecture-capability-layer.md for the design rationale.\n */\n\nimport type { AxiosInstance } from 'axios';\nimport type { StructuredToolInterface } from '@langchain/core/tools';\nimport {\n CapabilityKind,\n type Capability,\n type CapabilityFilter,\n type CapabilityProvider,\n type CredentialMap,\n} from '@/providers/types';\nimport {\n createHttpClient,\n type HttpClientConfig,\n assertOk,\n} from '@/utils/httpClient';\nimport {\n ManifestCache,\n filterToCacheKey,\n applyFilter,\n} from '@/utils/toolManifest';\nimport { buildProxyTool } from '@/tools/proxyTool';\n\n/** Configuration for ToolsServerCapabilityProvider. */\nexport interface ToolsServerConfig {\n /** Tools-server base URL (e.g., https://tools.illuma.ai or http://localhost:3500). */\n baseUrl: string;\n /** API key sent as x-api-key header on all requests. Required. */\n apiKey: string;\n /** Optional override for manifest path. Defaults to `/manifest`. */\n manifestPath?: string;\n /** Optional override for execute path template. Defaults to `/execute/:name`. */\n executePath?: string;\n /** Request timeout in ms. Defaults to 30_000. */\n timeoutMs?: number;\n /** Manifest cache TTL in ms. 0 disables. Defaults to 60_000 (1 min). */\n manifestTtlMs?: number;\n /** Optional pre-built axios instance (for testing). */\n client?: AxiosInstance;\n /** Optional proxy override (defaults to process.env.PROXY). */\n proxy?: string | null;\n}\n\n/**\n * Shape of a single entry from tools-server's /manifest response.\n *\n * Matches the tools-server ManifestToolEntry type. We define our own here\n * to avoid cross-package coupling — the shape is a stable HTTP contract.\n */\ninterface ToolsServerManifestEntry {\n pluginKey: string;\n name: string;\n description: string;\n icon?: string;\n authConfig?: Array<{\n authField: string;\n label?: string;\n description?: string;\n source?: string;\n required?: boolean;\n prod?: boolean;\n admin?: boolean;\n hide?: boolean;\n }>;\n /** Input schema as JSON Schema (tools-server emits `schema`). */\n schema?: unknown;\n /** Legacy alias accepted for backwards compatibility. */\n jsonSchema?: unknown;\n category?: string;\n tags?: string[];\n toolkit?: string;\n endpoint?: string;\n}\n\nexport class ToolsServerCapabilityProvider implements CapabilityProvider {\n readonly providerId: string;\n private readonly client: AxiosInstance;\n private readonly manifestPath: string;\n private readonly executePath: string;\n private readonly cache: ManifestCache;\n\n constructor(private readonly config: ToolsServerConfig) {\n const {\n baseUrl,\n apiKey,\n manifestPath = '/manifest',\n executePath = '/execute/:name',\n timeoutMs = 30_000,\n manifestTtlMs = 60_000,\n client,\n proxy,\n } = config;\n\n if (!baseUrl) {\n throw new Error('ToolsServerCapabilityProvider: baseUrl is required');\n }\n if (!apiKey) {\n throw new Error('ToolsServerCapabilityProvider: apiKey is required');\n }\n\n this.providerId = `tools-server:${baseUrl}`;\n this.manifestPath = manifestPath;\n this.executePath = executePath;\n this.cache = new ManifestCache({ ttlMs: manifestTtlMs });\n\n if (client) {\n this.client = client;\n } else {\n const httpConfig: HttpClientConfig = {\n baseURL: baseUrl,\n apiKey,\n timeoutMs,\n proxy,\n };\n this.client = createHttpClient(httpConfig);\n }\n }\n\n async fetchManifest(filter?: CapabilityFilter): Promise<Capability[]> {\n const cacheKey = filterToCacheKey(filter);\n const cached = this.cache.get(cacheKey);\n if (cached) {\n // DEBUG: cache hit (remove after stabilization)\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] manifest cache hit — ${cached.length} caps`\n );\n return cached;\n }\n\n // DEBUG\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] fetching manifest from ${this.manifestPath}`\n );\n\n const res = await this.client.get<ToolsServerManifestEntry[]>(\n this.manifestPath\n );\n assertOk(res.status, this.manifestPath, res.data);\n\n const entries = Array.isArray(res.data) ? res.data : [];\n const capabilities: Capability[] = entries.map((entry) =>\n normalizeEntry(entry)\n );\n\n // Apply filter before caching the full list separately so unfiltered\n // refetches don't re-hit the network.\n const fullCacheKey = filterToCacheKey();\n this.cache.set(fullCacheKey, capabilities);\n\n const filtered = applyFilter(capabilities, filter);\n if (cacheKey !== fullCacheKey) {\n this.cache.set(cacheKey, filtered);\n }\n\n // DEBUG\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] manifest loaded — ${capabilities.length} caps, ${filtered.length} after filter`\n );\n\n return filtered;\n }\n\n async createRunnables(\n capabilities: Capability[],\n credentials: CredentialMap\n ): Promise<StructuredToolInterface[]> {\n return capabilities.map((cap) =>\n buildProxyTool(cap, credentials, {\n client: this.client,\n executePath: this.executePath,\n })\n );\n }\n\n /** Force a manifest refresh on next fetchManifest call. */\n invalidateCache(): void {\n this.cache.clear();\n }\n}\n\n/**\n * Translate a raw tools-server manifest entry into a typed Capability.\n * Defensive — tools-server may add fields; we pull only what we need.\n */\nfunction normalizeEntry(entry: ToolsServerManifestEntry): Capability {\n return {\n kind: CapabilityKind.TOOL,\n name: entry.pluginKey,\n description: entry.description ?? '',\n schema: entry.schema ?? entry.jsonSchema,\n authConfig: (entry.authConfig ?? []).map((ac) => ({\n authField: ac.authField,\n label: ac.label,\n description: ac.description,\n required: ac.required,\n prod: ac.prod,\n admin: ac.admin,\n hide: ac.hide,\n // Source is a string in wire format; downstream consumers coerce to AuthSource.\n source: ac.source as Capability['authConfig'][number]['source'],\n })),\n metadata: {\n icon: entry.icon,\n category: entry.category,\n tags: entry.tags,\n },\n };\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;AASG;MA0EU,6BAA6B,CAAA;AAOX,IAAA,MAAA;AANpB,IAAA,UAAU;AACF,IAAA,MAAM;AACN,IAAA,YAAY;AACZ,IAAA,WAAW;AACX,IAAA,KA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EAAE;YAC/B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;AAC9B,SAAA,CAAC,CACH;IACH;;IAGA,eAAe,GAAA;AACb,QAAA,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;IACpB;AACD;AAED;;;AAGG;AACH,SAAS,cAAc,CAAC,KAA+B,EAAA;IACrD,OAAO;QACL,IAAI,EAAE,cAAc,CAAC,IAAI;QACzB,IAAI,EAAE,KAAK,CAAC,SAAS;AACrB,QAAA,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE;AACpC,QAAA,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU;AACxC,QAAA,UAAU,EAAE,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,MAAM;YAChD,SAAS,EAAE,EAAE,CAAC,SAAS;YACvB,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,WAAW,EAAE,EAAE,CAAC,WAAW;YAC3B,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,IAAI,EAAE,EAAE,CAAC,IAAI;YACb,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,IAAI,EAAE,EAAE,CAAC,IAAI;;YAEb,MAAM,EAAE,EAAE,CAAC,MAAoD;AAChE,SAAA,CAAC,CAAC;AACH,QAAA,QAAQ,EAAE;YACR,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;AACjB,SAAA;KACF;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"ToolsServerCapabilityProvider.mjs","sources":["../../../../src/providers/tools-server/ToolsServerCapabilityProvider.ts"],"sourcesContent":["/**\n * ToolsServerCapabilityProvider — capabilities sourced from a tools-server\n * HTTP endpoint.\n *\n * Fetches the manifest via GET /manifest, builds proxy StructuredTools via\n * POST /execute/:tool. Manifest is cached (TTL-configurable) so repeated\n * init cycles don't refetch.\n *\n * See docs/architecture-capability-layer.md for the design rationale.\n */\n\nimport type { AxiosInstance } from 'axios';\nimport type { StructuredToolInterface } from '@langchain/core/tools';\nimport {\n CapabilityKind,\n type Capability,\n type CapabilityFilter,\n type CapabilityProvider,\n type CredentialMap,\n} from '@/providers/types';\nimport {\n createHttpClient,\n type HttpClientConfig,\n assertOk,\n} from '@/utils/httpClient';\nimport {\n ManifestCache,\n filterToCacheKey,\n applyFilter,\n} from '@/utils/toolManifest';\nimport { buildProxyTool } from '@/tools/proxyTool';\n\n/** Configuration for ToolsServerCapabilityProvider. */\nexport interface ToolsServerConfig {\n /** Tools-server base URL (e.g., https://tools.illuma.ai or http://localhost:3500). */\n baseUrl: string;\n /** API key sent as x-api-key header on all requests. Required. */\n apiKey: string;\n /** Optional override for manifest path. Defaults to `/manifest`. */\n manifestPath?: string;\n /** Optional override for execute path template. Defaults to `/execute/:name`. */\n executePath?: string;\n /** Request timeout in ms. Defaults to 30_000. */\n timeoutMs?: number;\n /** Manifest cache TTL in ms. 0 disables. Defaults to 60_000 (1 min). */\n manifestTtlMs?: number;\n /** Optional pre-built axios instance (for testing). */\n client?: AxiosInstance;\n /** Optional proxy override (defaults to process.env.PROXY). */\n proxy?: string | null;\n /**\n * Optional per-request auth header builder — invoked on every tool\n * invocation (NOT on the manifest fetch, which is service-to-service).\n * When provided, the returned headers are merged into the `/execute`\n * request so the host can pass user-scoped identity (e.g.,\n * `Authorization: Bearer <jwt>`) that tools-server verifies for\n * admin-gated tools.\n *\n * Typical host wiring: mint a short-lived JWT per call carrying the\n * authenticated user's `{ userId, role }` claims; tools-server's\n * `TOOLS_SERVER_JWT_SECRET` validates.\n */\n getExecuteAuthHeaders?: () =>\n | Record<string, string>\n | Promise<Record<string, string>>;\n}\n\n/**\n * Shape of a single entry from tools-server's /manifest response.\n *\n * Matches the tools-server ManifestToolEntry type. We define our own here\n * to avoid cross-package coupling — the shape is a stable HTTP contract.\n */\ninterface ToolsServerManifestEntry {\n pluginKey: string;\n name: string;\n description: string;\n icon?: string;\n authConfig?: Array<{\n authField: string;\n label?: string;\n description?: string;\n source?: string;\n required?: boolean;\n prod?: boolean;\n admin?: boolean;\n hide?: boolean;\n }>;\n /** Input schema as JSON Schema (tools-server emits `schema`). */\n schema?: unknown;\n /** Legacy alias accepted for backwards compatibility. */\n jsonSchema?: unknown;\n category?: string;\n tags?: string[];\n toolkit?: string;\n endpoint?: string;\n /** Governance flags forwarded by tools-server getManifest(). */\n hidden?: boolean;\n admin?: boolean;\n env?: Array<'development' | 'production' | 'test' | 'staging'>;\n}\n\nexport class ToolsServerCapabilityProvider implements CapabilityProvider {\n readonly providerId: string;\n private readonly client: AxiosInstance;\n private readonly manifestPath: string;\n private readonly executePath: string;\n private readonly cache: ManifestCache;\n private readonly getExecuteAuthHeaders?:\n | (() => Record<string, string> | Promise<Record<string, string>>);\n\n constructor(private readonly config: ToolsServerConfig) {\n const {\n baseUrl,\n apiKey,\n manifestPath = '/manifest',\n executePath = '/execute/:name',\n timeoutMs = 30_000,\n manifestTtlMs = 60_000,\n client,\n proxy,\n getExecuteAuthHeaders,\n } = config;\n\n if (!baseUrl) {\n throw new Error('ToolsServerCapabilityProvider: baseUrl is required');\n }\n if (!apiKey) {\n throw new Error('ToolsServerCapabilityProvider: apiKey is required');\n }\n\n this.providerId = `tools-server:${baseUrl}`;\n this.manifestPath = manifestPath;\n this.executePath = executePath;\n this.cache = new ManifestCache({ ttlMs: manifestTtlMs });\n this.getExecuteAuthHeaders = getExecuteAuthHeaders;\n\n if (client) {\n this.client = client;\n } else {\n const httpConfig: HttpClientConfig = {\n baseURL: baseUrl,\n apiKey,\n timeoutMs,\n proxy,\n };\n this.client = createHttpClient(httpConfig);\n }\n }\n\n async fetchManifest(filter?: CapabilityFilter): Promise<Capability[]> {\n const cacheKey = filterToCacheKey(filter);\n const cached = this.cache.get(cacheKey);\n if (cached) {\n // DEBUG: cache hit (remove after stabilization)\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] manifest cache hit — ${cached.length} caps`\n );\n return cached;\n }\n\n // DEBUG\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] fetching manifest from ${this.manifestPath}`\n );\n\n const res = await this.client.get<ToolsServerManifestEntry[]>(\n this.manifestPath\n );\n assertOk(res.status, this.manifestPath, res.data);\n\n const entries = Array.isArray(res.data) ? res.data : [];\n const capabilities: Capability[] = entries.map((entry) =>\n normalizeEntry(entry)\n );\n\n // Apply filter before caching the full list separately so unfiltered\n // refetches don't re-hit the network.\n const fullCacheKey = filterToCacheKey();\n this.cache.set(fullCacheKey, capabilities);\n\n const filtered = applyFilter(capabilities, filter);\n if (cacheKey !== fullCacheKey) {\n this.cache.set(cacheKey, filtered);\n }\n\n // DEBUG\n // eslint-disable-next-line no-console\n console.debug(\n `[${this.providerId}] manifest loaded — ${capabilities.length} caps, ${filtered.length} after filter`\n );\n\n return filtered;\n }\n\n async createRunnables(\n capabilities: Capability[],\n credentials: CredentialMap\n ): Promise<StructuredToolInterface[]> {\n return capabilities.map((cap) =>\n buildProxyTool(cap, credentials, {\n client: this.client,\n executePath: this.executePath,\n getAuthHeaders: this.getExecuteAuthHeaders,\n })\n );\n }\n\n /** Force a manifest refresh on next fetchManifest call. */\n invalidateCache(): void {\n this.cache.clear();\n }\n}\n\n/**\n * Translate a raw tools-server manifest entry into a typed Capability.\n * Defensive — tools-server may add fields; we pull only what we need.\n */\nfunction normalizeEntry(entry: ToolsServerManifestEntry): Capability {\n return {\n kind: CapabilityKind.TOOL,\n name: entry.pluginKey,\n description: entry.description ?? '',\n schema: entry.schema ?? entry.jsonSchema,\n authConfig: (entry.authConfig ?? []).map((ac) => ({\n authField: ac.authField,\n label: ac.label,\n description: ac.description,\n required: ac.required,\n prod: ac.prod,\n admin: ac.admin,\n hide: ac.hide,\n // Source is a string in wire format; downstream consumers coerce to AuthSource.\n source: ac.source as Capability['authConfig'][number]['source'],\n })),\n metadata: {\n icon: entry.icon,\n category: entry.category,\n tags: entry.tags,\n // Governance — hosts use these to gate UI/role/environment.\n hidden: entry.hidden,\n admin: entry.admin,\n env: entry.env,\n },\n };\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;AASG;MA6FU,6BAA6B,CAAA;AASX,IAAA,MAAA;AARpB,IAAA,UAAU;AACF,IAAA,MAAM;AACN,IAAA,YAAY;AACZ,IAAA,WAAW;AACX,IAAA,KAAK;AACL,IAAA,qBAAqB;AAGtC,IAAA,WAAA,CAA6B,MAAyB,EAAA;QAAzB,IAAA,CAAA,MAAM,GAAN,MAAM;AACjC,QAAA,MAAM,EACJ,OAAO,EACP,MAAM,EACN,YAAY,GAAG,WAAW,EAC1B,WAAW,GAAG,gBAAgB,EAC9B,SAAS,GAAG,MAAM,EAClB,aAAa,GAAG,MAAM,EACtB,MAAM,EACN,KAAK,EACL,qBAAqB,GACtB,GAAG,MAAM;QAEV,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC;QACvE;QACA,IAAI,CAAC,MAAM,EAAE;AACX,YAAA,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC;QACtE;AAEA,QAAA,IAAI,CAAC,UAAU,GAAG,CAAA,aAAA,EAAgB,OAAO,EAAE;AAC3C,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY;AAChC,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW;AAC9B,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AACxD,QAAA,IAAI,CAAC,qBAAqB,GAAG,qBAAqB;QAElD,IAAI,MAAM,EAAE;AACV,YAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACtB;aAAO;AACL,YAAA,MAAM,UAAU,GAAqB;AACnC,gBAAA,OAAO,EAAE,OAAO;gBAChB,MAAM;gBACN,SAAS;gBACT,KAAK;aACN;AACD,YAAA,IAAI,CAA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SAAA,CAAC,CAAC;AACH,QAAA,QAAQ,EAAE;YACR,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;;YAEhB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,GAAG,EAAE,KAAK,CAAC,GAAG;AACf,SAAA;KACF;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sources":["../../../src/providers/types.ts"],"sourcesContent":["/**\n * CapabilityProvider types — the abstraction that lets agents consume tools,\n * skills, and MCP-backed capabilities through a single interface regardless\n * of where they come from.\n *\n * Design principles:\n * 1. Source-agnostic — providers are distinguished by WHERE they come from\n * (tools-server, skill store, MCP server), not by the backend service\n * any individual tool calls.\n * 2. Credential-agnostic — providers receive a flat credentialMap from the\n * host; they don't know about user settings, databases, OAuth flows.\n * 3. Extension-ready — the shape reserves slots for upcoming patterns\n * (skills injectedMessages, ToolCall.auth/expires_at, skill sessions)\n * so when those land we don't refactor the core.\n */\n\nimport type { StructuredToolInterface } from '@langchain/core/tools';\n\n/**\n * Kind of capability. Today only TOOL is implemented; SKILL and MCP are\n * reserved — SkillCapabilityProvider + MCPCapabilityProvider will populate\n * them in later phases. Keeping the enum from day one prevents a breaking\n * change when those ship.\n */\nexport enum CapabilityKind {\n TOOL = 'tool',\n SKILL = 'skill',\n MCP = 'mcp',\n /**\n * Remote agent reachable over the A2A (Agent-to-Agent) protocol.\n * The library's `A2ACapabilityProvider` is a client for this kind —\n * invoking an A2A capability sends a JSON-RPC `tasks/send` to the\n * remote agent's endpoint.\n */\n A2A = 'a2a',\n}\n\n/**\n * Where an auth credential comes from. Used by hosts to decide whether to\n * forward the credential per-request or let the capability provider resolve\n * it from its own environment.\n */\nexport enum AuthSource {\n /** Resolved by the capability provider itself from its environment. Host never sends. */\n SERVER = 'server',\n /** User-configured value stored in the host's credential store. Host forwards per-request. */\n USER = 'user',\n /** Active OAuth/session token. Host forwards per-request from active session. */\n FORWARDED = 'forwarded',\n}\n\n/**\n * One entry in a capability's auth config. Describes a single credential\n * the capability needs. The `source` field tells the host how to resolve\n * the value; the `prod`/`admin`/`hide` flags control UI visibility.\n */\nexport interface AuthConfigEntry {\n /** Environment-variable-style name (e.g., \"OPENAI_API_KEY\"). Stable identifier. */\n authField: string;\n /** Human-readable label for UI. */\n label?: string;\n /** Optional description of how to obtain the credential. */\n description?: string;\n /** Where the value comes from. Defaults to USER if unspecified. */\n source?: AuthSource;\n /** True if the credential is required for the capability to function. */\n required?: boolean;\n /** Platform-managed in production — never prompt user. */\n prod?: boolean;\n /** Only admins can configure. */\n admin?: boolean;\n /** Never show in any UI (used when source === SERVER). */\n hide?: boolean;\n}\n\n/**\n * Arbitrary metadata attached to a capability. Extension point.\n *\n * Fields prefixed with \"Reserved for\" are not populated today but exist in\n * the type so upstream patterns (skills, auth expiration, sessions) can\n * drop in without a schema migration.\n */\nexport interface CapabilityMetadata {\n /** Icon URL or path relative to the provider's static asset root. */\n icon?: string;\n /** Category for UI grouping (e.g., \"search\", \"image\", \"finance\"). */\n category?: string;\n /** Free-form tags for filtering / search. */\n tags?: string[];\n\n // --- Reserved for upstream patterns (not populated today) ---\n\n /** Reserved for upstream `fix/auth-events` — auth mode declared by tool. */\n auth?: string;\n /** Reserved for upstream `fix/auth-events` — Unix timestamp for token expiration. */\n expires_at?: number;\n /** Reserved for upstream skills — capability returns injected messages on execute. */\n injectedMessages?: boolean;\n /** Reserved for upstream skills — capability consumes ToolSessionMap state. */\n sessionAware?: boolean;\n}\n\n/**\n * A single capability — a tool, skill, or MCP-backed operation that an agent\n * can invoke. The shape mirrors common plugin-manifest conventions so the\n * same entry can round-trip between an upstream catalog and a host registry.\n */\nexport interface Capability {\n /** What kind of capability this is. Controls how it's invoked downstream. */\n kind: CapabilityKind;\n /**\n * Stable unique identifier. For tools this is the pluginKey\n * (e.g., \"dalle\", \"wikipedia\"). For skills this is the skill's `name`.\n * Used everywhere the capability is referenced.\n */\n name: string;\n /** Human-readable description for the LLM and UI. */\n description: string;\n /**\n * Input schema as JSON Schema. For tools this comes from the Zod schema\n * passed through `zodToJsonSchema`. Optional for capabilities with no\n * input (e.g., parameter-less skills).\n */\n schema?: unknown;\n /** Credential requirements. */\n authConfig: AuthConfigEntry[];\n /** Extension metadata. See CapabilityMetadata. */\n metadata: CapabilityMetadata;\n}\n\n/** Filter for fetchManifest. All fields optional; missing = no filter. */\nexport interface CapabilityFilter {\n kind?: CapabilityKind;\n tags?: string[];\n /** Restrict to capabilities whose `name` is in this list. */\n names?: string[];\n}\n\n/**\n * A flat credential map: authField → value.\n *\n * The host is responsible for resolving values (from env vars, user\n * settings, OAuth sessions, etc.) before passing to the provider. The\n * provider does not inspect the origin — it just forwards to the tool.\n */\nexport type CredentialMap = Record<string, string>;\n\n/**\n * The core interface. All concrete providers implement this.\n *\n * Providers are identified by `providerId` for logging/debug. They fetch\n * their own manifest and build LangChain-compatible runnables from it.\n *\n * Lifetime: a provider may be instantiated once at startup (e.g., tools-\n * server pointing at a stable URL) or per-user (e.g., MCP with per-user\n * OAuth). The interface is agnostic.\n */\nexport interface CapabilityProvider {\n /** Stable identifier for this provider instance (e.g., \"tools-server:https://...\"). */\n readonly providerId: string;\n\n /**\n * Return the list of capabilities this provider exposes.\n *\n * Implementations may cache the manifest — the contract is that the\n * returned list reflects the provider's current view of available\n * capabilities.\n *\n * @param filter optional filter to scope the result\n */\n fetchManifest(filter?: CapabilityFilter): Promise<Capability[]>;\n\n /**\n * Build LangChain StructuredTools from a set of capabilities using the\n * caller-supplied credentials.\n *\n * Called at agent init. The returned tools are bound to the LLM and\n * invoked during the graph's tool-calling loop.\n *\n * @param capabilities the subset of capabilities the agent wants to use\n * @param credentials credential values keyed by authField\n */\n createRunnables(\n capabilities: Capability[],\n credentials: CredentialMap\n ): Promise<StructuredToolInterface[]>;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;AAcG;AAIH;;;;;AAKG;IACS;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX;;;;;AAKG;AACH,IAAA,cAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACb,CAAC,EAXW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;AAa1B;;;;AAIG;IACS;AAAZ,CAAA,UAAY,UAAU,EAAA;;AAEpB,IAAA,UAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;;AAEjB,IAAA,UAAA,CAAA,MAAA,CAAA,GAAA,MAAa;;AAEb,IAAA,UAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACzB,CAAC,EAPW,UAAU,KAAV,UAAU,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":["../../../src/providers/types.ts"],"sourcesContent":["/**\n * CapabilityProvider types — the abstraction that lets agents consume tools,\n * skills, and MCP-backed capabilities through a single interface regardless\n * of where they come from.\n *\n * Design principles:\n * 1. Source-agnostic — providers are distinguished by WHERE they come from\n * (tools-server, skill store, MCP server), not by the backend service\n * any individual tool calls.\n * 2. Credential-agnostic — providers receive a flat credentialMap from the\n * host; they don't know about user settings, databases, OAuth flows.\n * 3. Extension-ready — the shape reserves slots for upcoming patterns\n * (skills injectedMessages, ToolCall.auth/expires_at, skill sessions)\n * so when those land we don't refactor the core.\n */\n\nimport type { StructuredToolInterface } from '@langchain/core/tools';\n\n/**\n * Kind of capability. Today only TOOL is implemented; SKILL and MCP are\n * reserved — SkillCapabilityProvider + MCPCapabilityProvider will populate\n * them in later phases. Keeping the enum from day one prevents a breaking\n * change when those ship.\n */\nexport enum CapabilityKind {\n TOOL = 'tool',\n SKILL = 'skill',\n MCP = 'mcp',\n /**\n * Remote agent reachable over the A2A (Agent-to-Agent) protocol.\n * The library's `A2ACapabilityProvider` is a client for this kind —\n * invoking an A2A capability sends a JSON-RPC `tasks/send` to the\n * remote agent's endpoint.\n */\n A2A = 'a2a',\n}\n\n/**\n * Where an auth credential comes from. Used by hosts to decide whether to\n * forward the credential per-request or let the capability provider resolve\n * it from its own environment.\n */\nexport enum AuthSource {\n /** Resolved by the capability provider itself from its environment. Host never sends. */\n SERVER = 'server',\n /** User-configured value stored in the host's credential store. Host forwards per-request. */\n USER = 'user',\n /** Active OAuth/session token. Host forwards per-request from active session. */\n FORWARDED = 'forwarded',\n}\n\n/**\n * One entry in a capability's auth config. Describes a single credential\n * the capability needs. The `source` field tells the host how to resolve\n * the value; the `prod`/`admin`/`hide` flags control UI visibility.\n */\nexport interface AuthConfigEntry {\n /** Environment-variable-style name (e.g., \"OPENAI_API_KEY\"). Stable identifier. */\n authField: string;\n /** Human-readable label for UI. */\n label?: string;\n /** Optional description of how to obtain the credential. */\n description?: string;\n /** Where the value comes from. Defaults to USER if unspecified. */\n source?: AuthSource;\n /** True if the credential is required for the capability to function. */\n required?: boolean;\n /** Platform-managed in production — never prompt user. */\n prod?: boolean;\n /** Only admins can configure. */\n admin?: boolean;\n /** Never show in any UI (used when source === SERVER). */\n hide?: boolean;\n}\n\n/**\n * Arbitrary metadata attached to a capability. Extension point.\n *\n * Fields prefixed with \"Reserved for\" are not populated today but exist in\n * the type so upstream patterns (skills, auth expiration, sessions) can\n * drop in without a schema migration.\n */\nexport interface CapabilityMetadata {\n /** Icon URL or path relative to the provider's static asset root. */\n icon?: string;\n /** Category for UI grouping (e.g., \"search\", \"image\", \"finance\"). */\n category?: string;\n /** Free-form tags for filtering / search. */\n tags?: string[];\n\n // --- Governance flags ------------------------------------------------\n\n /**\n * When true, hosts omit this capability from user-facing pickers\n * (Agent Builder, tool dropdown). Still invokable when a saved agent\n * references it by name.\n */\n hidden?: boolean;\n /** When true, only admin-role users can enable or invoke this capability. */\n admin?: boolean;\n /**\n * Deployment-stage restriction. When set, hosts whose deployment stage\n * isn't in the array should hide the capability (e.g., a prod host\n * shouldn't surface a tool with `env: ['development']`).\n */\n env?: Array<'development' | 'production' | 'test' | 'staging'>;\n\n // --- Reserved for upstream patterns (not populated today) ---\n\n /** Reserved for upstream `fix/auth-events` — auth mode declared by tool. */\n auth?: string;\n /** Reserved for upstream `fix/auth-events` — Unix timestamp for token expiration. */\n expires_at?: number;\n /** Reserved for upstream skills — capability returns injected messages on execute. */\n injectedMessages?: boolean;\n /** Reserved for upstream skills — capability consumes ToolSessionMap state. */\n sessionAware?: boolean;\n}\n\n/**\n * A single capability — a tool, skill, or MCP-backed operation that an agent\n * can invoke. The shape mirrors common plugin-manifest conventions so the\n * same entry can round-trip between an upstream catalog and a host registry.\n */\nexport interface Capability {\n /** What kind of capability this is. Controls how it's invoked downstream. */\n kind: CapabilityKind;\n /**\n * Stable unique identifier. For tools this is the pluginKey\n * (e.g., \"dalle\", \"wikipedia\"). For skills this is the skill's `name`.\n * Used everywhere the capability is referenced.\n */\n name: string;\n /** Human-readable description for the LLM and UI. */\n description: string;\n /**\n * Input schema as JSON Schema. For tools this comes from the Zod schema\n * passed through `zodToJsonSchema`. Optional for capabilities with no\n * input (e.g., parameter-less skills).\n */\n schema?: unknown;\n /** Credential requirements. */\n authConfig: AuthConfigEntry[];\n /** Extension metadata. See CapabilityMetadata. */\n metadata: CapabilityMetadata;\n}\n\n/** Filter for fetchManifest. All fields optional; missing = no filter. */\nexport interface CapabilityFilter {\n kind?: CapabilityKind;\n tags?: string[];\n /** Restrict to capabilities whose `name` is in this list. */\n names?: string[];\n}\n\n/**\n * A flat credential map: authField → value.\n *\n * The host is responsible for resolving values (from env vars, user\n * settings, OAuth sessions, etc.) before passing to the provider. The\n * provider does not inspect the origin — it just forwards to the tool.\n */\nexport type CredentialMap = Record<string, string>;\n\n/**\n * The core interface. All concrete providers implement this.\n *\n * Providers are identified by `providerId` for logging/debug. They fetch\n * their own manifest and build LangChain-compatible runnables from it.\n *\n * Lifetime: a provider may be instantiated once at startup (e.g., tools-\n * server pointing at a stable URL) or per-user (e.g., MCP with per-user\n * OAuth). The interface is agnostic.\n */\nexport interface CapabilityProvider {\n /** Stable identifier for this provider instance (e.g., \"tools-server:https://...\"). */\n readonly providerId: string;\n\n /**\n * Return the list of capabilities this provider exposes.\n *\n * Implementations may cache the manifest — the contract is that the\n * returned list reflects the provider's current view of available\n * capabilities.\n *\n * @param filter optional filter to scope the result\n */\n fetchManifest(filter?: CapabilityFilter): Promise<Capability[]>;\n\n /**\n * Build LangChain StructuredTools from a set of capabilities using the\n * caller-supplied credentials.\n *\n * Called at agent init. The returned tools are bound to the LLM and\n * invoked during the graph's tool-calling loop.\n *\n * @param capabilities the subset of capabilities the agent wants to use\n * @param credentials credential values keyed by authField\n */\n createRunnables(\n capabilities: Capability[],\n credentials: CredentialMap\n ): Promise<StructuredToolInterface[]>;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;AAcG;AAIH;;;;;AAKG;IACS;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX;;;;;AAKG;AACH,IAAA,cAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACb,CAAC,EAXW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;AAa1B;;;;AAIG;IACS;AAAZ,CAAA,UAAY,UAAU,EAAA;;AAEpB,IAAA,UAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;;AAEjB,IAAA,UAAA,CAAA,MAAA,CAAA,GAAA,MAAa;;AAEb,IAAA,UAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACzB,CAAC,EAPW,UAAU,KAAV,UAAU,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
const ARTIFACT_WRITE_ACTIONS = [
|
|
3
|
+
const ARTIFACT_WRITE_ACTIONS = [
|
|
4
|
+
'write',
|
|
5
|
+
'edit',
|
|
6
|
+
'verify',
|
|
7
|
+
'delete',
|
|
8
|
+
];
|
|
4
9
|
const CONTENT_READ_ACTIONS = ['read', 'search', 'list', 'info'];
|
|
5
10
|
const artifactToolSchema = z.object({
|
|
6
11
|
action: z
|
|
@@ -24,7 +29,10 @@ const artifactToolSchema = z.object({
|
|
|
24
29
|
.string()
|
|
25
30
|
.optional()
|
|
26
31
|
.describe('Exact string to find and replace (required for edit).'),
|
|
27
|
-
new_str: z
|
|
32
|
+
new_str: z
|
|
33
|
+
.string()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('Replacement string (required for edit).'),
|
|
28
36
|
replace_all: z
|
|
29
37
|
.boolean()
|
|
30
38
|
.optional()
|
|
@@ -42,12 +50,27 @@ const contentReaderSchema = z.object({
|
|
|
42
50
|
start_line: z.number().optional().describe('1-based start line for reading.'),
|
|
43
51
|
end_line: z.number().optional().describe('1-based end line (inclusive).'),
|
|
44
52
|
// search
|
|
45
|
-
pattern: z
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
pattern: z
|
|
54
|
+
.string()
|
|
55
|
+
.optional()
|
|
56
|
+
.describe('Regex pattern (required for search).'),
|
|
57
|
+
flags: z
|
|
58
|
+
.string()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe('Regex flags (e.g., "i" for case-insensitive).'),
|
|
61
|
+
context: z
|
|
62
|
+
.number()
|
|
63
|
+
.optional()
|
|
64
|
+
.describe('Lines of context around each match.'),
|
|
48
65
|
// shared pagination
|
|
49
|
-
offset: z
|
|
50
|
-
|
|
66
|
+
offset: z
|
|
67
|
+
.number()
|
|
68
|
+
.optional()
|
|
69
|
+
.describe('Offset for read or search pagination.'),
|
|
70
|
+
limit: z
|
|
71
|
+
.number()
|
|
72
|
+
.optional()
|
|
73
|
+
.describe('Max lines (read) or matches (search).'),
|
|
51
74
|
});
|
|
52
75
|
const ARTIFACT_TOOL_NAME = 'artifact_tool';
|
|
53
76
|
const CONTENT_READER_NAME = 'content_reader';
|