Getting Started
Quickstart: TypeScript
Add IntentLayer to Node.js 18+ and gate one request with typed results.
TypeScript SDK targets Node.js 18+ and uses built-in fetch.
#Install
npm install intentlayerRepository notes say releases may use @intentlayer/sdk if unscoped package name is unavailable. Current package manifest name is intentlayer.
#Observe first
import { IntentLayer } from "intentlayer";
const il = new IntentLayer({
apiKey: process.env.INTENTLAYER_API_KEY,
baseUrl: process.env.INTENTLAYER_BASE_URL,
mode: "observe",
});
const gate = await il.gate(
"improve the report",
"conversation-42",
{ channel: "support" },
);
const answer = await runAgent("improve the report");
il.recordOutcome("conversation-42", "accept");#Suggest questions
const il = new IntentLayer({ mode: "suggest" });
const gate = await il.gate("cancel it", "conversation-43");
if (gate.questions.length) {
return { clarifyingQuestions: gate.questions };
}
return runAgent("cancel it");Core client does not enforce mode. Caller implements this branch. OpenAI adapter can intercept suggestions when explicitly enabled.
#Wrap agent
const wrapped = il.wrap(runAgent);
const result = await wrapped("improve the report", "conversation-44");Gate failures resolve to { ambiguityScore: 0, dimensions: {}, questions: [], intentSpec: null }. Telemetry errors are swallowed. Set DEBUG=intentlayer for debug logs.
Source truth
sdk-js/README.mdsdk-js/src/index.tssdk-js/package.json