@abassey/aid 0.1.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.
- package/dist/agents/index.cjs +741 -0
- package/dist/agents/index.d.cts +78 -0
- package/dist/agents/index.d.ts +78 -0
- package/dist/agents/index.js +741 -0
- package/dist/ai-AWJOUXFM.js +9 -0
- package/dist/ai-DOAYJKKI.cjs +9 -0
- package/dist/chunk-2TNYBUNK.js +124 -0
- package/dist/chunk-3LGKZRGY.cjs +124 -0
- package/dist/chunk-AUR2BBB5.cjs +1436 -0
- package/dist/chunk-IJLTRQF4.cjs +276 -0
- package/dist/chunk-JPD7UBAZ.js +58 -0
- package/dist/chunk-M4RQALTT.js +276 -0
- package/dist/chunk-NB65IHJE.cjs +58 -0
- package/dist/chunk-YNIEOBDF.js +1436 -0
- package/dist/client/index.cjs +18 -0
- package/dist/client/index.d.cts +8 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +18 -0
- package/dist/errors-CUVTnseb.d.ts +13 -0
- package/dist/errors-CgCce4cK.d.cts +158 -0
- package/dist/errors-CgCce4cK.d.ts +158 -0
- package/dist/errors-zAPbTlpe.d.cts +13 -0
- package/dist/eval/index.cjs +308 -0
- package/dist/eval/index.d.cts +106 -0
- package/dist/eval/index.d.ts +106 -0
- package/dist/eval/index.js +308 -0
- package/dist/index.cjs +35 -0
- package/dist/index.d.cts +107 -0
- package/dist/index.d.ts +107 -0
- package/dist/index.js +35 -0
- package/dist/middleware/index.cjs +201 -0
- package/dist/middleware/index.d.cts +36 -0
- package/dist/middleware/index.d.ts +36 -0
- package/dist/middleware/index.js +201 -0
- package/dist/observability/index.cjs +147 -0
- package/dist/observability/index.d.cts +30 -0
- package/dist/observability/index.d.ts +30 -0
- package/dist/observability/index.js +147 -0
- package/dist/react/index.cjs +253 -0
- package/dist/react/index.d.cts +64 -0
- package/dist/react/index.d.ts +64 -0
- package/dist/react/index.js +253 -0
- package/dist/serve/index.cjs +545 -0
- package/dist/serve/index.d.cts +69 -0
- package/dist/serve/index.d.ts +69 -0
- package/dist/serve/index.js +545 -0
- package/dist/types-BJReASS-.d.cts +196 -0
- package/dist/types-BJReASS-.d.ts +196 -0
- package/dist/types-CguX3F16.d.cts +173 -0
- package/dist/types-CrFH-_qp.d.cts +68 -0
- package/dist/types-DvdzPmW0.d.ts +173 -0
- package/dist/types-qfE32ADy.d.ts +68 -0
- package/package.json +144 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkIJLTRQF4cjs = require('../chunk-IJLTRQF4.cjs');
|
|
7
|
+
|
|
8
|
+
// src/client/index.ts
|
|
9
|
+
function createClient(config) {
|
|
10
|
+
return new (0, _chunkIJLTRQF4cjs.AidClient)(config);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.AidClient = _chunkIJLTRQF4cjs.AidClient; exports.AidClientError = _chunkIJLTRQF4cjs.AidClientError; exports.ChatClient = _chunkIJLTRQF4cjs.ChatClient; exports.createClient = createClient; exports.parseSSE = _chunkIJLTRQF4cjs.parseSSE;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { C as ClientConfig, A as AidClient } from '../errors-CgCce4cK.cjs';
|
|
2
|
+
export { a as AgentResponse, b as AgentStreamEvent, c as AiRequest, d as AiResponse, e as AidClientError, f as ChatClient, g as ChatHistory, h as ChatMessage, i as ChatSession, S as StreamChunk } from '../errors-CgCce4cK.cjs';
|
|
3
|
+
|
|
4
|
+
declare function parseSSE<T = unknown>(response: Response): AsyncGenerator<T>;
|
|
5
|
+
|
|
6
|
+
declare function createClient(config: ClientConfig): AidClient;
|
|
7
|
+
|
|
8
|
+
export { AidClient, ClientConfig, createClient, parseSSE };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { C as ClientConfig, A as AidClient } from '../errors-CgCce4cK.js';
|
|
2
|
+
export { a as AgentResponse, b as AgentStreamEvent, c as AiRequest, d as AiResponse, e as AidClientError, f as ChatClient, g as ChatHistory, h as ChatMessage, i as ChatSession, S as StreamChunk } from '../errors-CgCce4cK.js';
|
|
3
|
+
|
|
4
|
+
declare function parseSSE<T = unknown>(response: Response): AsyncGenerator<T>;
|
|
5
|
+
|
|
6
|
+
declare function createClient(config: ClientConfig): AidClient;
|
|
7
|
+
|
|
8
|
+
export { AidClient, ClientConfig, createClient, parseSSE };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AidClient,
|
|
3
|
+
AidClientError,
|
|
4
|
+
ChatClient,
|
|
5
|
+
parseSSE
|
|
6
|
+
} from "../chunk-M4RQALTT.js";
|
|
7
|
+
|
|
8
|
+
// src/client/index.ts
|
|
9
|
+
function createClient(config) {
|
|
10
|
+
return new AidClient(config);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
AidClient,
|
|
14
|
+
AidClientError,
|
|
15
|
+
ChatClient,
|
|
16
|
+
createClient,
|
|
17
|
+
parseSSE
|
|
18
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { E as ErrorCode, k as AidErrorOptions } from './types-BJReASS-.js';
|
|
2
|
+
|
|
3
|
+
declare class AidError extends Error {
|
|
4
|
+
readonly code: ErrorCode;
|
|
5
|
+
readonly provider?: string;
|
|
6
|
+
readonly model?: string;
|
|
7
|
+
readonly retryAfter?: number;
|
|
8
|
+
readonly statusCode?: number;
|
|
9
|
+
readonly raw?: unknown;
|
|
10
|
+
constructor(code: ErrorCode, message: string, options?: AidErrorOptions);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { AidError as A };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
interface ClientConfig {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
headers?: Record<string, string>;
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
}
|
|
6
|
+
interface AiRequest {
|
|
7
|
+
prompt: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
system?: string;
|
|
10
|
+
temperature?: number;
|
|
11
|
+
maxTokens?: number;
|
|
12
|
+
}
|
|
13
|
+
interface AiResponse {
|
|
14
|
+
text: string;
|
|
15
|
+
model: string;
|
|
16
|
+
tokens: {
|
|
17
|
+
input: number;
|
|
18
|
+
output: number;
|
|
19
|
+
total: number;
|
|
20
|
+
};
|
|
21
|
+
cost: number;
|
|
22
|
+
latencyMs: number;
|
|
23
|
+
}
|
|
24
|
+
interface StreamChunk {
|
|
25
|
+
type: "text" | "done" | "error";
|
|
26
|
+
text: string;
|
|
27
|
+
delta: string;
|
|
28
|
+
model?: string;
|
|
29
|
+
tokens?: {
|
|
30
|
+
input: number;
|
|
31
|
+
output: number;
|
|
32
|
+
total: number;
|
|
33
|
+
};
|
|
34
|
+
cost?: number;
|
|
35
|
+
latencyMs?: number;
|
|
36
|
+
code?: string;
|
|
37
|
+
message?: string;
|
|
38
|
+
}
|
|
39
|
+
interface AgentResponse {
|
|
40
|
+
text: string;
|
|
41
|
+
model: string;
|
|
42
|
+
tokens: {
|
|
43
|
+
input: number;
|
|
44
|
+
output: number;
|
|
45
|
+
total: number;
|
|
46
|
+
};
|
|
47
|
+
cost: number;
|
|
48
|
+
steps: number;
|
|
49
|
+
}
|
|
50
|
+
interface AgentStreamEvent {
|
|
51
|
+
type: "step:start" | "step:end" | "tool:call" | "tool:result" | "text" | "done" | "error";
|
|
52
|
+
step?: number;
|
|
53
|
+
name?: string;
|
|
54
|
+
args?: Record<string, unknown>;
|
|
55
|
+
result?: string;
|
|
56
|
+
text?: string;
|
|
57
|
+
tokens?: {
|
|
58
|
+
input: number;
|
|
59
|
+
output: number;
|
|
60
|
+
total: number;
|
|
61
|
+
};
|
|
62
|
+
cost?: number;
|
|
63
|
+
steps?: number;
|
|
64
|
+
code?: string;
|
|
65
|
+
message?: string;
|
|
66
|
+
}
|
|
67
|
+
interface ChatSession {
|
|
68
|
+
sessionId: string;
|
|
69
|
+
}
|
|
70
|
+
interface ChatMessage {
|
|
71
|
+
text: string;
|
|
72
|
+
model: string;
|
|
73
|
+
tokens: {
|
|
74
|
+
input: number;
|
|
75
|
+
output: number;
|
|
76
|
+
total: number;
|
|
77
|
+
};
|
|
78
|
+
cost: number;
|
|
79
|
+
}
|
|
80
|
+
interface ChatHistory {
|
|
81
|
+
sessionId: string;
|
|
82
|
+
messages: Array<{
|
|
83
|
+
role: string;
|
|
84
|
+
content: string;
|
|
85
|
+
}>;
|
|
86
|
+
createdAt: number;
|
|
87
|
+
lastActiveAt: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare class AidClient {
|
|
91
|
+
private readonly baseUrl;
|
|
92
|
+
private readonly headers;
|
|
93
|
+
private readonly signal?;
|
|
94
|
+
constructor(config: ClientConfig);
|
|
95
|
+
private request;
|
|
96
|
+
private requestSSE;
|
|
97
|
+
ai(prompt: string, options?: Partial<AiRequest> & {
|
|
98
|
+
signal?: AbortSignal;
|
|
99
|
+
}): Promise<AiResponse>;
|
|
100
|
+
stream(prompt: string, options?: Partial<AiRequest> & {
|
|
101
|
+
signal?: AbortSignal;
|
|
102
|
+
}): AsyncGenerator<StreamChunk>;
|
|
103
|
+
agent(name: string, task: string, options?: {
|
|
104
|
+
signal?: AbortSignal;
|
|
105
|
+
}): Promise<AgentResponse>;
|
|
106
|
+
agentStream(name: string, task: string, options?: {
|
|
107
|
+
signal?: AbortSignal;
|
|
108
|
+
}): AsyncGenerator<AgentStreamEvent>;
|
|
109
|
+
chat(options?: {
|
|
110
|
+
system?: string;
|
|
111
|
+
model?: string;
|
|
112
|
+
}): ChatClient;
|
|
113
|
+
/** @internal */
|
|
114
|
+
_chatCreate(options?: {
|
|
115
|
+
system?: string;
|
|
116
|
+
model?: string;
|
|
117
|
+
}): Promise<ChatSession>;
|
|
118
|
+
/** @internal */
|
|
119
|
+
_chatSend(sessionId: string, message: string): Promise<ChatMessage>;
|
|
120
|
+
/** @internal */
|
|
121
|
+
_chatStream(sessionId: string, message: string, signal?: AbortSignal): AsyncGenerator<StreamChunk>;
|
|
122
|
+
/** @internal */
|
|
123
|
+
_chatHistory(sessionId: string): Promise<ChatHistory>;
|
|
124
|
+
/** @internal */
|
|
125
|
+
_chatDelete(sessionId: string): Promise<void>;
|
|
126
|
+
health(): Promise<{
|
|
127
|
+
status: string;
|
|
128
|
+
}>;
|
|
129
|
+
models(): Promise<Array<{
|
|
130
|
+
alias: string;
|
|
131
|
+
provider: string;
|
|
132
|
+
model: string;
|
|
133
|
+
}>>;
|
|
134
|
+
}
|
|
135
|
+
declare class ChatClient {
|
|
136
|
+
private _sessionId;
|
|
137
|
+
private readonly chatOptions?;
|
|
138
|
+
private readonly client;
|
|
139
|
+
constructor(client: AidClient, options?: {
|
|
140
|
+
system?: string;
|
|
141
|
+
model?: string;
|
|
142
|
+
});
|
|
143
|
+
get sessionId(): string | null;
|
|
144
|
+
private ensureSession;
|
|
145
|
+
send(message: string): Promise<ChatMessage>;
|
|
146
|
+
stream(message: string, signal?: AbortSignal): AsyncGenerator<StreamChunk>;
|
|
147
|
+
history(): Promise<ChatHistory>;
|
|
148
|
+
destroy(): Promise<void>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare class AidClientError extends Error {
|
|
152
|
+
readonly code: string;
|
|
153
|
+
readonly status: number;
|
|
154
|
+
constructor(code: string, message: string, status: number);
|
|
155
|
+
static fromResponse(body: unknown, status: number): AidClientError;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export { AidClient as A, type ClientConfig as C, type StreamChunk as S, type AgentResponse as a, type AgentStreamEvent as b, type AiRequest as c, type AiResponse as d, AidClientError as e, ChatClient as f, type ChatHistory as g, type ChatMessage as h, type ChatSession as i };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
interface ClientConfig {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
headers?: Record<string, string>;
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
}
|
|
6
|
+
interface AiRequest {
|
|
7
|
+
prompt: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
system?: string;
|
|
10
|
+
temperature?: number;
|
|
11
|
+
maxTokens?: number;
|
|
12
|
+
}
|
|
13
|
+
interface AiResponse {
|
|
14
|
+
text: string;
|
|
15
|
+
model: string;
|
|
16
|
+
tokens: {
|
|
17
|
+
input: number;
|
|
18
|
+
output: number;
|
|
19
|
+
total: number;
|
|
20
|
+
};
|
|
21
|
+
cost: number;
|
|
22
|
+
latencyMs: number;
|
|
23
|
+
}
|
|
24
|
+
interface StreamChunk {
|
|
25
|
+
type: "text" | "done" | "error";
|
|
26
|
+
text: string;
|
|
27
|
+
delta: string;
|
|
28
|
+
model?: string;
|
|
29
|
+
tokens?: {
|
|
30
|
+
input: number;
|
|
31
|
+
output: number;
|
|
32
|
+
total: number;
|
|
33
|
+
};
|
|
34
|
+
cost?: number;
|
|
35
|
+
latencyMs?: number;
|
|
36
|
+
code?: string;
|
|
37
|
+
message?: string;
|
|
38
|
+
}
|
|
39
|
+
interface AgentResponse {
|
|
40
|
+
text: string;
|
|
41
|
+
model: string;
|
|
42
|
+
tokens: {
|
|
43
|
+
input: number;
|
|
44
|
+
output: number;
|
|
45
|
+
total: number;
|
|
46
|
+
};
|
|
47
|
+
cost: number;
|
|
48
|
+
steps: number;
|
|
49
|
+
}
|
|
50
|
+
interface AgentStreamEvent {
|
|
51
|
+
type: "step:start" | "step:end" | "tool:call" | "tool:result" | "text" | "done" | "error";
|
|
52
|
+
step?: number;
|
|
53
|
+
name?: string;
|
|
54
|
+
args?: Record<string, unknown>;
|
|
55
|
+
result?: string;
|
|
56
|
+
text?: string;
|
|
57
|
+
tokens?: {
|
|
58
|
+
input: number;
|
|
59
|
+
output: number;
|
|
60
|
+
total: number;
|
|
61
|
+
};
|
|
62
|
+
cost?: number;
|
|
63
|
+
steps?: number;
|
|
64
|
+
code?: string;
|
|
65
|
+
message?: string;
|
|
66
|
+
}
|
|
67
|
+
interface ChatSession {
|
|
68
|
+
sessionId: string;
|
|
69
|
+
}
|
|
70
|
+
interface ChatMessage {
|
|
71
|
+
text: string;
|
|
72
|
+
model: string;
|
|
73
|
+
tokens: {
|
|
74
|
+
input: number;
|
|
75
|
+
output: number;
|
|
76
|
+
total: number;
|
|
77
|
+
};
|
|
78
|
+
cost: number;
|
|
79
|
+
}
|
|
80
|
+
interface ChatHistory {
|
|
81
|
+
sessionId: string;
|
|
82
|
+
messages: Array<{
|
|
83
|
+
role: string;
|
|
84
|
+
content: string;
|
|
85
|
+
}>;
|
|
86
|
+
createdAt: number;
|
|
87
|
+
lastActiveAt: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare class AidClient {
|
|
91
|
+
private readonly baseUrl;
|
|
92
|
+
private readonly headers;
|
|
93
|
+
private readonly signal?;
|
|
94
|
+
constructor(config: ClientConfig);
|
|
95
|
+
private request;
|
|
96
|
+
private requestSSE;
|
|
97
|
+
ai(prompt: string, options?: Partial<AiRequest> & {
|
|
98
|
+
signal?: AbortSignal;
|
|
99
|
+
}): Promise<AiResponse>;
|
|
100
|
+
stream(prompt: string, options?: Partial<AiRequest> & {
|
|
101
|
+
signal?: AbortSignal;
|
|
102
|
+
}): AsyncGenerator<StreamChunk>;
|
|
103
|
+
agent(name: string, task: string, options?: {
|
|
104
|
+
signal?: AbortSignal;
|
|
105
|
+
}): Promise<AgentResponse>;
|
|
106
|
+
agentStream(name: string, task: string, options?: {
|
|
107
|
+
signal?: AbortSignal;
|
|
108
|
+
}): AsyncGenerator<AgentStreamEvent>;
|
|
109
|
+
chat(options?: {
|
|
110
|
+
system?: string;
|
|
111
|
+
model?: string;
|
|
112
|
+
}): ChatClient;
|
|
113
|
+
/** @internal */
|
|
114
|
+
_chatCreate(options?: {
|
|
115
|
+
system?: string;
|
|
116
|
+
model?: string;
|
|
117
|
+
}): Promise<ChatSession>;
|
|
118
|
+
/** @internal */
|
|
119
|
+
_chatSend(sessionId: string, message: string): Promise<ChatMessage>;
|
|
120
|
+
/** @internal */
|
|
121
|
+
_chatStream(sessionId: string, message: string, signal?: AbortSignal): AsyncGenerator<StreamChunk>;
|
|
122
|
+
/** @internal */
|
|
123
|
+
_chatHistory(sessionId: string): Promise<ChatHistory>;
|
|
124
|
+
/** @internal */
|
|
125
|
+
_chatDelete(sessionId: string): Promise<void>;
|
|
126
|
+
health(): Promise<{
|
|
127
|
+
status: string;
|
|
128
|
+
}>;
|
|
129
|
+
models(): Promise<Array<{
|
|
130
|
+
alias: string;
|
|
131
|
+
provider: string;
|
|
132
|
+
model: string;
|
|
133
|
+
}>>;
|
|
134
|
+
}
|
|
135
|
+
declare class ChatClient {
|
|
136
|
+
private _sessionId;
|
|
137
|
+
private readonly chatOptions?;
|
|
138
|
+
private readonly client;
|
|
139
|
+
constructor(client: AidClient, options?: {
|
|
140
|
+
system?: string;
|
|
141
|
+
model?: string;
|
|
142
|
+
});
|
|
143
|
+
get sessionId(): string | null;
|
|
144
|
+
private ensureSession;
|
|
145
|
+
send(message: string): Promise<ChatMessage>;
|
|
146
|
+
stream(message: string, signal?: AbortSignal): AsyncGenerator<StreamChunk>;
|
|
147
|
+
history(): Promise<ChatHistory>;
|
|
148
|
+
destroy(): Promise<void>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare class AidClientError extends Error {
|
|
152
|
+
readonly code: string;
|
|
153
|
+
readonly status: number;
|
|
154
|
+
constructor(code: string, message: string, status: number);
|
|
155
|
+
static fromResponse(body: unknown, status: number): AidClientError;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export { AidClient as A, type ClientConfig as C, type StreamChunk as S, type AgentResponse as a, type AgentStreamEvent as b, type AiRequest as c, type AiResponse as d, AidClientError as e, ChatClient as f, type ChatHistory as g, type ChatMessage as h, type ChatSession as i };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { E as ErrorCode, k as AidErrorOptions } from './types-BJReASS-.cjs';
|
|
2
|
+
|
|
3
|
+
declare class AidError extends Error {
|
|
4
|
+
readonly code: ErrorCode;
|
|
5
|
+
readonly provider?: string;
|
|
6
|
+
readonly model?: string;
|
|
7
|
+
readonly retryAfter?: number;
|
|
8
|
+
readonly statusCode?: number;
|
|
9
|
+
readonly raw?: unknown;
|
|
10
|
+
constructor(code: ErrorCode, message: string, options?: AidErrorOptions);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { AidError as A };
|