@aiwatching/bastion-plugin-api 2.0.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.
@@ -0,0 +1,3 @@
1
+ export { PLUGIN_API_VERSION } from './types.js';
2
+ export type { BastionPlugin, PluginManifest, PluginContext, Logger, DatabaseAccess, ProxyRequest, ProxyResponse, PluginResult, PluginEvent, } from './types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,YAAY,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,MAAM,EACN,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_API_VERSION = void 0;
4
+ var types_js_1 = require("./types.js");
5
+ Object.defineProperty(exports, "PLUGIN_API_VERSION", { enumerable: true, get: function () { return types_js_1.PLUGIN_API_VERSION; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAgD;AAAvC,8GAAA,kBAAkB,OAAA"}
@@ -0,0 +1,77 @@
1
+ export declare const PLUGIN_API_VERSION = 2;
2
+ export interface BastionPlugin {
3
+ name: string;
4
+ version: string;
5
+ apiVersion: number;
6
+ onInit?(context: PluginContext): Promise<void>;
7
+ onDestroy?(): Promise<void>;
8
+ onRequest?(req: ProxyRequest): Promise<PluginResult | void>;
9
+ onResponse?(res: ProxyResponse): Promise<PluginResult | void>;
10
+ onResponseComplete?(res: ProxyResponse): Promise<void>;
11
+ }
12
+ export interface PluginManifest {
13
+ name: string;
14
+ version: string;
15
+ apiVersion: number;
16
+ main: string;
17
+ priority: number;
18
+ config?: Record<string, unknown>;
19
+ description?: string;
20
+ author?: string;
21
+ }
22
+ export interface PluginContext {
23
+ config: Record<string, unknown>;
24
+ logger: Logger;
25
+ db: DatabaseAccess;
26
+ getPluginState<T>(key: string): T | undefined;
27
+ setPluginState<T>(key: string, value: T): void;
28
+ emit(event: string, data: unknown): void;
29
+ on(event: string, handler: (data: unknown) => void): void;
30
+ }
31
+ export interface Logger {
32
+ debug(message: string, data?: Record<string, unknown>): void;
33
+ info(message: string, data?: Record<string, unknown>): void;
34
+ warn(message: string, data?: Record<string, unknown>): void;
35
+ error(message: string, data?: Record<string, unknown>): void;
36
+ }
37
+ export interface DatabaseAccess {
38
+ insertEvent(event: PluginEvent): void;
39
+ }
40
+ export interface ProxyRequest {
41
+ id: string;
42
+ provider: string;
43
+ model: string;
44
+ method: string;
45
+ path: string;
46
+ headers: Readonly<Record<string, string>>;
47
+ body: string;
48
+ parsedBody: Readonly<Record<string, unknown>>;
49
+ isStreaming: boolean;
50
+ sessionId?: string;
51
+ }
52
+ export interface ProxyResponse {
53
+ request: ProxyRequest;
54
+ statusCode: number;
55
+ headers: Readonly<Record<string, string>>;
56
+ body: string;
57
+ parsedBody: Readonly<Record<string, unknown>> | null;
58
+ isStreaming: boolean;
59
+ usage?: {
60
+ inputTokens: number;
61
+ outputTokens: number;
62
+ };
63
+ latencyMs?: number;
64
+ }
65
+ export interface PluginResult {
66
+ action: 'pass' | 'warn' | 'redact' | 'block';
67
+ modified?: boolean;
68
+ events?: PluginEvent[];
69
+ }
70
+ export interface PluginEvent {
71
+ type: 'dlp' | 'prompt-injection' | 'tool-guard' | 'custom';
72
+ severity: 'critical' | 'high' | 'medium' | 'low' | 'info';
73
+ rule: string;
74
+ detail: string;
75
+ matchedText?: string;
76
+ }
77
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot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AE,YAAY,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IACrD,WAAW,EAAE,OAAO,CAAC;IAErB,KAAK,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB;AAID,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,GAAG,kBAAkB,GAAG,YAAY,GAAG,QAAQ,CAAC;IAC3D,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_API_VERSION = void 0;
4
+ exports.PLUGIN_API_VERSION = 2;
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@aiwatching/bastion-plugin-api",
3
+ "version": "2.0.0",
4
+ "description": "Type definitions for Bastion AI Gateway plugins",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": ["dist"],
8
+ "scripts": {
9
+ "build": "tsc"
10
+ },
11
+ "devDependencies": {
12
+ "typescript": "^5.7.3"
13
+ }
14
+ }