@usenotra/geo
Version:
Request capture SDK for AI traffic attribution and agent feedback collection
89 lines (83 loc) • 3.2 kB
TypeScript
import { z } from 'zod';
declare const FEEDBACK_KINDS: readonly ["bug", "feature", "praise", "question", "other"];
declare const FEEDBACK_SENTIMENTS: readonly ["negative", "neutral", "positive"];
type FeedbackKind = (typeof FEEDBACK_KINDS)[number];
type FeedbackSentiment = (typeof FEEDBACK_SENTIMENTS)[number];
interface FeedbackInput {
message: string;
title?: string;
kind?: FeedbackKind;
sentiment?: FeedbackSentiment;
contextUrl?: string;
agentClient?: string;
agentModel?: string;
toolVersion?: string;
externalId?: string;
idempotencyKey?: string;
projectId?: string;
metadata?: Record<string, unknown>;
}
interface FeedbackClientOptions {
url?: string;
token?: string;
endpoint?: string;
fetch?: typeof globalThis.fetch;
timeoutMs?: number;
}
interface FeedbackSubmitResult {
id: string;
deduplicated: boolean;
}
interface FeedbackToolOptions extends FeedbackClientOptions {
productName?: string;
toolName?: string;
description?: string;
defaults?: Pick<FeedbackInput, "agentClient" | "agentModel" | "toolVersion" | "projectId" | "metadata">;
onError?: (error: unknown) => void;
}
interface FeedbackToolResult {
content: {
type: "text";
text: string;
}[];
structuredContent?: FeedbackSubmitResult;
isError?: boolean;
}
interface FeedbackToolServer {
registerTool(name: string, config: {
description: string;
annotations?: Record<string, unknown>;
inputSchema: Record<string, unknown>;
outputSchema?: Record<string, unknown>;
}, handler: (args: Record<string, unknown>) => Promise<FeedbackToolResult>): unknown;
}
declare class FeedbackSubmitError extends Error {
readonly status: number;
constructor(status: number, message: string);
}
declare function submitFeedback(input: FeedbackInput, options: FeedbackClientOptions): Promise<FeedbackSubmitResult>;
declare const feedbackToolInputSchema: {
message: z.ZodString;
title: z.ZodOptional<z.ZodString>;
kind: z.ZodOptional<z.ZodEnum<{
bug: "bug";
feature: "feature";
praise: "praise";
question: "question";
other: "other";
}>>;
sentiment: z.ZodOptional<z.ZodEnum<{
negative: "negative";
neutral: "neutral";
positive: "positive";
}>>;
contextUrl: z.ZodOptional<z.ZodString>;
};
declare const feedbackToolOutputSchema: {
id: z.ZodString;
deduplicated: z.ZodBoolean;
};
declare function buildFeedbackToolDescription(productName?: string): string;
declare function createFeedbackToolHandler(options: FeedbackToolOptions): (args: Record<string, unknown>) => Promise<FeedbackToolResult>;
declare function registerFeedbackTool(server: FeedbackToolServer, options: FeedbackToolOptions): unknown;
export { type FeedbackClientOptions, type FeedbackInput, type FeedbackKind, type FeedbackSentiment, FeedbackSubmitError, type FeedbackSubmitResult, type FeedbackToolOptions, type FeedbackToolResult, type FeedbackToolServer, buildFeedbackToolDescription, createFeedbackToolHandler, feedbackToolInputSchema, feedbackToolOutputSchema, registerFeedbackTool, submitFeedback };