@tensflare/sk

Installation

npm install @tensflare/sk

Overview

Semantic Kernel middleware wraps function invocations to record inputs, outputs, and function names as Truss actions with SHA-256 hashing. It handles both sync and async functions.

API

TrussSemanticKernelMiddleware

import { TrussSemanticKernelMiddleware } from "@tensflare/sk";

const truss = new TrussSemanticKernelMiddleware({
  apiUrl: "...",
  apiKey: "...",
  mandateId: "...",
});

const wrappedFn = truss.wrapFunction(myFunction, "my-function-name");

wrapFunction<T>(fn: T, name?: string): T

Wraps a function invocation, recording a sk_invoke action type. An optional name parameter labels the function in the action record.

Key Features

  • Records sk_invoke action type
  • Supports both sync and async functions
  • Optional function name labeling
  • SHA-256 hashing of inputs and outputs
  • Generic type preservation for wrapped functions