@devshub198211/devguard 2.0.2 → 2.0.3

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.
package/dist/ai.d.cts DELETED
@@ -1,169 +0,0 @@
1
- import { S as Schema } from './api-contract-5kJEwFIh.cjs';
2
- export { I as InferSchemaType, c, c as s } from './api-contract-5kJEwFIh.cjs';
3
-
4
- /**
5
- * agent-schema v2.1
6
- * FIX #3: repairJSON no longer corrupts strings with colons.
7
- * FIX #5: Unified — reuses schema builder from api-contract. 'parseSchema' + 'parseWithRetry' are the main exports.
8
- */
9
-
10
- interface ParseResult<T> {
11
- success: boolean;
12
- data?: T;
13
- raw?: string;
14
- errors: string[];
15
- attempts: number;
16
- }
17
- /** Strip markdown fences and extract the first complete JSON object or array */
18
- declare function cleanLLMOutput(raw: string): string;
19
- declare function parseSchema<T>(schema: Schema<T>, raw: string): ParseResult<T>;
20
- declare function parseWithRetry<T>(schema: Schema<T>, promptFn: (context: string) => Promise<string>, maxRetries?: number): Promise<ParseResult<T>>;
21
-
22
- /**
23
- * mcp-server-kit v2.1 — Production MCP server builder.
24
- * Full JSON-RPC 2.0 over stdio. Handles: initialize, tools/list, tools/call,
25
- * resources/list, resources/read, ping, cancellation, progress notifications.
26
- * Hardened: input validation, buffer size limits, jsonrpc validation, sequential processing.
27
- * No external dependencies.
28
- */
29
- interface MCPToolSchema {
30
- type: "object";
31
- properties: Record<string, {
32
- type: string;
33
- description?: string;
34
- enum?: any[];
35
- default?: any;
36
- }>;
37
- required?: string[];
38
- }
39
- interface MCPTool {
40
- name: string;
41
- description: string;
42
- inputSchema: MCPToolSchema;
43
- handler: (input: Record<string, any>, meta?: {
44
- progressToken?: string | number;
45
- }) => Promise<any>;
46
- }
47
- interface MCPResource {
48
- uri: string;
49
- name: string;
50
- description?: string;
51
- mimeType?: string;
52
- fetch: () => Promise<string | {
53
- text?: string;
54
- blob?: string;
55
- mimeType?: string;
56
- }>;
57
- }
58
- interface MCPPrompt {
59
- name: string;
60
- description?: string;
61
- arguments?: Array<{
62
- name: string;
63
- description?: string;
64
- required?: boolean;
65
- }>;
66
- handler: (args: Record<string, string>) => Promise<Array<{
67
- role: string;
68
- content: {
69
- type: string;
70
- text: string;
71
- };
72
- }>>;
73
- }
74
- declare class MCPServerBuilder {
75
- private name;
76
- private version;
77
- private description;
78
- private tools;
79
- private resources;
80
- private prompts;
81
- private capabilities;
82
- private initialized;
83
- constructor(name: string, version?: string, description?: string);
84
- addTool(tool: MCPTool): this;
85
- addResource(resource: MCPResource): this;
86
- addPrompt(prompt: MCPPrompt): this;
87
- private respond;
88
- private error;
89
- /** Run a handler with a timeout */
90
- private runWithTimeout;
91
- private dispatch;
92
- startStdio(): void;
93
- }
94
-
95
- interface MemoryEntry {
96
- id: string;
97
- role: "user" | "assistant" | "system" | "tool";
98
- content: string;
99
- timestamp: number;
100
- metadata?: Record<string, any>;
101
- }
102
- interface MemoryAdapter {
103
- save(agentId: string, entry: MemoryEntry): Promise<void>;
104
- getHistory(agentId: string, limit?: number): Promise<MemoryEntry[]>;
105
- clear(agentId: string): Promise<void>;
106
- }
107
- /**
108
- * FileSystemAdapter — uses local JSON files for persistence.
109
- * Keys are hashed to prevent path traversal.
110
- */
111
- declare class FileSystemAdapter implements MemoryAdapter {
112
- private baseDir;
113
- private keyIndex;
114
- constructor(dir?: string);
115
- private getFilePath;
116
- save(agentId: string, entry: MemoryEntry): Promise<void>;
117
- getHistory(agentId: string, limit?: number): Promise<MemoryEntry[]>;
118
- clear(agentId: string): Promise<void>;
119
- }
120
- /**
121
- * RedisAdapter — documentation only, requires 'redis' package.
122
- * Note: Uses KEYS for listing which is O(N). Production should use SCAN.
123
- */
124
- declare class RedisAdapter implements MemoryAdapter {
125
- private client;
126
- constructor(redisClient: any);
127
- save(agentId: string, entry: MemoryEntry): Promise<void>;
128
- getHistory(agentId: string, limit?: number): Promise<MemoryEntry[]>;
129
- clear(agentId: string): Promise<void>;
130
- }
131
- declare class AgentMemory {
132
- private adapter;
133
- constructor(adapter?: MemoryAdapter);
134
- track(agentId: string, role: MemoryEntry["role"], content: string, metadata?: any): Promise<MemoryEntry>;
135
- getContext(agentId: string, limit?: number): Promise<string>;
136
- clear(agentId: string): Promise<void>;
137
- }
138
-
139
- interface LLMUsage {
140
- id: string;
141
- model: string;
142
- provider: string;
143
- tokensPrompt: number;
144
- tokensCompletion: number;
145
- costUSD: number;
146
- timestamp: number;
147
- }
148
- interface BudgetConfig {
149
- monthlyLimitUSD: number;
150
- warnAtUSD?: number;
151
- }
152
- declare class LLMBudget {
153
- private records;
154
- private totalCost;
155
- private config;
156
- constructor(config: BudgetConfig);
157
- track(usage: Omit<LLMUsage, "id" | "timestamp">): LLMUsage;
158
- getSummary(): {
159
- totalCost: number;
160
- recordCount: number;
161
- limit: number;
162
- remaining: number;
163
- isExceeded: boolean;
164
- };
165
- getHistory(limit?: number): LLMUsage[];
166
- reset(): void;
167
- }
168
-
169
- export { AgentMemory, type BudgetConfig, FileSystemAdapter, LLMBudget, type LLMUsage, type MCPPrompt, type MCPResource, MCPServerBuilder, type MCPTool, type MCPToolSchema, type MemoryAdapter, type MemoryEntry, type ParseResult, RedisAdapter, Schema, cleanLLMOutput, parseSchema, parseWithRetry };
@@ -1,157 +0,0 @@
1
- /**
2
- * api-contract v2 — Zero-dependency shared schema for client & server.
3
- * Features: full type inference, nested objects, transforms, middleware,
4
- * OpenAPI JSON Schema export, fetch wrapper with validation.
5
- * No external dependencies.
6
- */
7
- type Infer<S> = S extends Schema<infer T> ? T : never;
8
- interface ValidationError {
9
- path: string;
10
- message: string;
11
- }
12
- interface ParseResult<T> {
13
- success: boolean;
14
- data?: T;
15
- errors: ValidationError[];
16
- }
17
- declare abstract class Schema<T> {
18
- abstract _parse(val: unknown, path: string): T;
19
- readonly _type: T;
20
- /** @internal */ _isOptional: boolean;
21
- /** @internal */ _default?: T;
22
- /** @internal */ _description?: string;
23
- /** @internal */ _transform?: (val: T) => any;
24
- safeParse(val: unknown): ParseResult<T>;
25
- parse(val: unknown): T;
26
- optional(): Schema<T | undefined>;
27
- nullable(): Schema<T | null>;
28
- default(val: T): this;
29
- describe(desc: string): this;
30
- transform<U>(fn: (val: T) => U): Schema<U>;
31
- toJSONSchema(): Record<string, any>;
32
- }
33
- declare class StringSchema extends Schema<string> {
34
- private _min?;
35
- private _max?;
36
- private _enum?;
37
- private _regex?;
38
- private _email;
39
- private _url;
40
- private _trim;
41
- _parse(val: unknown, path: string): string;
42
- min(n: number): this;
43
- max(n: number): this;
44
- length(n: number): this;
45
- enum<V extends string>(vals: V[]): Schema<V>;
46
- regex(r: RegExp): this;
47
- email(): this;
48
- url(): this;
49
- trim(): this;
50
- toJSONSchema(): {
51
- format?: string | undefined;
52
- enum?: string[] | undefined;
53
- maxLength?: number | undefined;
54
- minLength?: number | undefined;
55
- type: string;
56
- };
57
- }
58
- declare class NumberSchema extends Schema<number> {
59
- private _min?;
60
- private _max?;
61
- private _int;
62
- private _positive;
63
- _parse(val: unknown, path: string): number;
64
- min(n: number): this;
65
- max(n: number): this;
66
- int(): this;
67
- positive(): this;
68
- toJSONSchema(): {
69
- maximum?: number | undefined;
70
- minimum?: number | undefined;
71
- type: string;
72
- };
73
- }
74
- declare class BooleanSchema extends Schema<boolean> {
75
- _parse(val: unknown, path: string): boolean;
76
- toJSONSchema(): {
77
- type: string;
78
- };
79
- }
80
- type ObjectShape = Record<string, Schema<any>>;
81
- type ObjectOutput<S extends ObjectShape> = {
82
- [K in keyof S]: Infer<S[K]>;
83
- };
84
- declare class ObjectSchema<S extends ObjectShape> extends Schema<ObjectOutput<S>> {
85
- private shape;
86
- private _isStrict;
87
- constructor(shape: S, isStrict?: boolean);
88
- _parse(val: unknown, path: string): ObjectOutput<S>;
89
- extend<E extends ObjectShape>(extra: E): ObjectSchema<S & E>;
90
- pick<K extends keyof S>(keys: K[]): ObjectSchema<Pick<S, K>>;
91
- omit<K extends keyof S>(keys: K[]): ObjectSchema<Omit<S, K>>;
92
- strict(): ObjectSchema<S>;
93
- toJSONSchema(): Record<string, any>;
94
- }
95
- declare class ArraySchema<T> extends Schema<T[]> {
96
- private item;
97
- private _min?;
98
- private _max?;
99
- constructor(item: Schema<T>);
100
- _parse(val: unknown, path: string): T[];
101
- min(n: number): this;
102
- max(n: number): this;
103
- nonempty(): this;
104
- toJSONSchema(): {
105
- type: string;
106
- items: any;
107
- };
108
- }
109
- declare class RecordSchema<V> extends Schema<Record<string, V>> {
110
- private valueSchema;
111
- constructor(valueSchema: Schema<V>);
112
- _parse(val: unknown, path: string): Record<string, V>;
113
- }
114
- declare class LiteralSchema<T extends string | number | boolean> extends Schema<T> {
115
- private literal;
116
- constructor(literal: T);
117
- _parse(val: unknown, path: string): T;
118
- }
119
- declare class UnionSchema<T> extends Schema<T> {
120
- private options;
121
- constructor(options: Schema<any>[]);
122
- _parse(val: unknown, path: string): T;
123
- }
124
- declare const c: {
125
- string: () => StringSchema;
126
- number: () => NumberSchema;
127
- boolean: () => BooleanSchema;
128
- object: <S extends ObjectShape>(shape: S) => ObjectSchema<S>;
129
- array: <T>(item: Schema<T>) => ArraySchema<T>;
130
- record: <V>(val: Schema<V>) => RecordSchema<V>;
131
- literal: <T extends string | number | boolean>(v: T) => LiteralSchema<T>;
132
- union: <T>(opts: Schema<T>[]) => UnionSchema<T>;
133
- any: () => {
134
- _parse(v: any): any;
135
- readonly _type: any;
136
- /** @internal */ _isOptional: boolean;
137
- /** @internal */ _default?: any;
138
- /** @internal */ _description?: string;
139
- /** @internal */ _transform?: ((val: any) => any) | undefined;
140
- safeParse(val: unknown): ParseResult<any>;
141
- parse(val: unknown): any;
142
- optional(): Schema<any>;
143
- nullable(): Schema<any>;
144
- default(val: any): /*elided*/ any;
145
- describe(desc: string): /*elided*/ any;
146
- transform<U>(fn: (val: any) => U): Schema<U>;
147
- toJSONSchema(): Record<string, any>;
148
- };
149
- };
150
- declare function validateBody<S extends ObjectShape>(schema: ObjectSchema<S>): (req: any, res: any, next: any) => any;
151
- declare function validateQuery<S extends ObjectShape>(schema: ObjectSchema<S>): (req: any, res: any, next: any) => any;
152
- declare function typedFetch<T>(url: string, schema: Schema<T>, init?: RequestInit): Promise<{
153
- data: T;
154
- response: Response;
155
- }>;
156
-
157
- export { type Infer as I, type ParseResult as P, Schema as S, type ValidationError as V, validateQuery as a, c, typedFetch as t, validateBody as v };