@crawlcheck/sdk 1.9.2 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/index.d.ts +19 -0
- package/dist/index.js +14 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,16 +35,19 @@ Since 1.8.0 they also apply the signing policy (https://crawlcheck.io/keys#polic
|
|
|
35
35
|
Three tools your agent can call itself: `crawlcheck_check_site` (the signed, verified decision for an action on a site, including the business facts the site publishes and which AI engines get them wrong), `crawlcheck_verify_fact` (one signed verdict on a phone number, address, hours or service area you hold: does the business publish it, did it once, or whose is it) and `crawlcheck_fetch` (fetches a page only after its domain, and every redirect hop, is allowed). All fail closed.
|
|
36
36
|
|
|
37
37
|
```js
|
|
38
|
-
import { CrawlCheck, agentTools, toolsFor } from "@crawlcheck/sdk";
|
|
38
|
+
import { CrawlCheck, agentTools, toolsFor, vercelTools, langchainTools } from "@crawlcheck/sdk";
|
|
39
39
|
const tools = agentTools(new CrawlCheck(), { agent: "MyAgentBot" });
|
|
40
40
|
|
|
41
41
|
// OpenAI function calling
|
|
42
42
|
const oa = toolsFor("openai", tools); // oa.tools → tools: [...]; on a tool call: await oa.call(name, argumentsJson)
|
|
43
43
|
// Anthropic tool use
|
|
44
44
|
const an = toolsFor("anthropic", tools); // an.tools → tools: [...]; on tool_use: await an.call(block.name, block.input)
|
|
45
|
-
// Vercel AI SDK
|
|
46
|
-
import
|
|
47
|
-
const vt =
|
|
45
|
+
// Vercel AI SDK (1.10.0): one call; the "ai" module is passed in, so this package keeps no dependency
|
|
46
|
+
import * as ai from "ai";
|
|
47
|
+
const vt = vercelTools(new CrawlCheck(), ai); // generateText({ model, tools: vt, ... })
|
|
48
|
+
// LangChain.js (1.10.0)
|
|
49
|
+
import * as lc from "@langchain/core/tools";
|
|
50
|
+
const lt = langchainTools(new CrawlCheck(), lc); // createAgent({ model, tools: lt }) or model.bindTools(lt)
|
|
48
51
|
// An MCP server you run
|
|
49
52
|
const mc = toolsFor("mcp", tools); // list mc.tools; answer tools/call with mc.call(name, args)
|
|
50
53
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -762,4 +762,23 @@ export declare function toolsFor(format: ToolFormat, tools: AgentTool[]): {
|
|
|
762
762
|
tools: unknown;
|
|
763
763
|
call: (name: string, args: unknown) => Promise<JsonObject>;
|
|
764
764
|
};
|
|
765
|
+
/** Structural view of the Vercel AI SDK module ("ai") - passed in, so this package keeps no dependency. */
|
|
766
|
+
export interface VercelAiModule {
|
|
767
|
+
tool: (def: any) => any;
|
|
768
|
+
jsonSchema: (schema: any) => any;
|
|
769
|
+
}
|
|
770
|
+
/** Vercel AI SDK adapter (1.10.0): `import * as ai from "ai"; const tools = vercelTools(cc, ai);` then generateText({ tools, ... }).
|
|
771
|
+
* Same three tools as agentTools(); they fail closed. The schema is given as both inputSchema (AI SDK 5+) and parameters (AI SDK 4). */
|
|
772
|
+
export declare function vercelTools(cc: CrawlCheck, ai: VercelAiModule, opts?: AgentToolOptions): Record<string, unknown>;
|
|
773
|
+
/** Structural view of "@langchain/core/tools" - passed in, so this package keeps no dependency. */
|
|
774
|
+
export interface LangChainToolsModule {
|
|
775
|
+
tool: (fn: (input: any) => any, fields: {
|
|
776
|
+
name: string;
|
|
777
|
+
description: string;
|
|
778
|
+
schema: any;
|
|
779
|
+
}) => any;
|
|
780
|
+
}
|
|
781
|
+
/** LangChain.js adapter (1.10.0): `import * as lc from "@langchain/core/tools"; const tools = langchainTools(cc, lc);`
|
|
782
|
+
* Same three tools as agentTools(); each returns its result as a JSON string; they fail closed. */
|
|
783
|
+
export declare function langchainTools(cc: CrawlCheck, lc: LangChainToolsModule, opts?: AgentToolOptions): unknown[];
|
|
765
784
|
export default CrawlCheck;
|
package/dist/index.js
CHANGED
|
@@ -692,4 +692,18 @@ export function toolsFor(format, tools) {
|
|
|
692
692
|
return { tools: tools.map((t) => ({ name: t.name, description: t.description, inputSchema: t.parameters, annotations: { readOnlyHint: true, openWorldHint: true } })), call };
|
|
693
693
|
return { tools: Object.fromEntries(tools.map((t) => [t.name, { description: t.description, parameters: t.parameters, execute: t.execute }])), call };
|
|
694
694
|
}
|
|
695
|
+
/** Vercel AI SDK adapter (1.10.0): `import * as ai from "ai"; const tools = vercelTools(cc, ai);` then generateText({ tools, ... }).
|
|
696
|
+
* Same three tools as agentTools(); they fail closed. The schema is given as both inputSchema (AI SDK 5+) and parameters (AI SDK 4). */
|
|
697
|
+
export function vercelTools(cc, ai, opts = {}) {
|
|
698
|
+
if (!ai || typeof ai.tool !== "function" || typeof ai.jsonSchema !== "function")
|
|
699
|
+
throw new Error('vercelTools needs the "ai" module: import * as ai from "ai"');
|
|
700
|
+
return Object.fromEntries(agentTools(cc, opts).map((t) => { const sc = ai.jsonSchema(t.parameters); return [t.name, ai.tool({ description: t.description, inputSchema: sc, parameters: sc, execute: (args) => t.execute(args) })]; }));
|
|
701
|
+
}
|
|
702
|
+
/** LangChain.js adapter (1.10.0): `import * as lc from "@langchain/core/tools"; const tools = langchainTools(cc, lc);`
|
|
703
|
+
* Same three tools as agentTools(); each returns its result as a JSON string; they fail closed. */
|
|
704
|
+
export function langchainTools(cc, lc, opts = {}) {
|
|
705
|
+
if (!lc || typeof lc.tool !== "function")
|
|
706
|
+
throw new Error('langchainTools needs "@langchain/core/tools": import * as lc from "@langchain/core/tools"');
|
|
707
|
+
return agentTools(cc, opts).map((t) => lc.tool(async (input) => JSON.stringify(await t.execute(input ?? {})), { name: t.name, description: t.description, schema: t.parameters }));
|
|
708
|
+
}
|
|
695
709
|
export default CrawlCheck;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlcheck/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Typed client for the CrawlCheck API (generated from its OpenAPI document) and the zero-dependency offline verifier for evidence bundles and remediation receipts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|