-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathaltimate-core-fingerprint.ts
More file actions
29 lines (28 loc) · 1.29 KB
/
altimate-core-fingerprint.ts
File metadata and controls
29 lines (28 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import z from "zod"
import { Tool } from "../../tool/tool"
import { Dispatcher } from "../native"
export const AltimateCoreFingerprintTool = Tool.define("altimate_core_fingerprint", {
description:
"Compute a SHA-256 fingerprint of a schema. Useful for cache invalidation and change detection. Provide schema_context or schema_path for accurate table/column resolution.",
parameters: z.object({
schema_path: z.string().optional().describe("Path to YAML/JSON schema file"),
schema_context: z.record(z.string(), z.any()).optional().describe("Inline schema definition"),
}),
async execute(args, ctx) {
try {
const result = await Dispatcher.call("altimate_core.fingerprint", {
schema_path: args.schema_path ?? "",
schema_context: args.schema_context,
})
const data = result.data as Record<string, any>
return {
title: `Fingerprint: ${data.fingerprint?.substring(0, 12) ?? "computed"}...`,
metadata: { success: result.success, fingerprint: data.fingerprint },
output: `SHA-256: ${data.fingerprint ?? "unknown"}`,
}
} catch (e) {
const msg = e instanceof Error ? e.message : String(e)
return { title: "Fingerprint: ERROR", metadata: { success: false, fingerprint: null }, output: `Failed: ${msg}` }
}
},
})