@marktoflow/integrations 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/README.md +1 -1
- package/dist/adapters/claude-agent-types.d.ts +36 -34
- package/dist/adapters/claude-agent-types.d.ts.map +1 -1
- package/dist/adapters/claude-agent-types.js.map +1 -1
- package/dist/adapters/claude-agent-workflow.d.ts +22 -22
- package/dist/adapters/claude-agent.d.ts +2 -2
- package/dist/adapters/claude-agent.d.ts.map +1 -1
- package/dist/adapters/claude-agent.js +8 -2
- package/dist/adapters/claude-agent.js.map +1 -1
- package/dist/adapters/github-copilot-workflow.d.ts +4 -4
- package/dist/adapters/openai-types.d.ts +194 -0
- package/dist/adapters/openai-types.d.ts.map +1 -0
- package/dist/adapters/openai-types.js +38 -0
- package/dist/adapters/openai-types.js.map +1 -0
- package/dist/adapters/openai.d.ts +74 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/adapters/openai.js +208 -0
- package/dist/adapters/openai.js.map +1 -0
- package/dist/adapters/opencode.d.ts +25 -0
- package/dist/adapters/opencode.d.ts.map +1 -1
- package/dist/adapters/opencode.js +205 -15
- package/dist/adapters/opencode.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/services/ai-browser.d.ts +3 -3
- package/dist/services/ai-browser.d.ts.map +1 -1
- package/dist/services/ai-browser.js +1 -1
- package/dist/services/ai-browser.js.map +1 -1
- package/dist/services/playwright.d.ts +3 -3
- package/dist/services/playwright.d.ts.map +1 -1
- package/dist/services/playwright.js +1 -1
- package/dist/services/playwright.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for OpenAI SDK integration with marktoflow
|
|
3
|
+
*
|
|
4
|
+
* These types enable integration with OpenAI-compatible APIs including
|
|
5
|
+
* OpenAI, VLLM, and other local/remote endpoints.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for OpenAI client
|
|
10
|
+
*/
|
|
11
|
+
export interface OpenAIClientConfig {
|
|
12
|
+
/** Base URL for the API (default: https://api.openai.com/v1) */
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
/** API key for authentication */
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
/** Default model to use */
|
|
17
|
+
model?: string;
|
|
18
|
+
/** Organization ID */
|
|
19
|
+
organization?: string;
|
|
20
|
+
/** Request timeout in milliseconds */
|
|
21
|
+
timeout?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Chat message format
|
|
25
|
+
*/
|
|
26
|
+
export interface OpenAIChatMessage {
|
|
27
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
28
|
+
content: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for chat completion
|
|
33
|
+
*/
|
|
34
|
+
export interface OpenAIChatOptions {
|
|
35
|
+
/** Model to use */
|
|
36
|
+
model?: string;
|
|
37
|
+
/** Messages for the conversation */
|
|
38
|
+
messages: OpenAIChatMessage[];
|
|
39
|
+
/** Sampling temperature (0-2) */
|
|
40
|
+
temperature?: number;
|
|
41
|
+
/** Max tokens to generate */
|
|
42
|
+
max_tokens?: number;
|
|
43
|
+
/** Top-p sampling */
|
|
44
|
+
top_p?: number;
|
|
45
|
+
/** Number of completions to generate */
|
|
46
|
+
n?: number;
|
|
47
|
+
/** Stop sequences */
|
|
48
|
+
stop?: string | string[];
|
|
49
|
+
/** Frequency penalty (-2 to 2) */
|
|
50
|
+
frequency_penalty?: number;
|
|
51
|
+
/** Presence penalty (-2 to 2) */
|
|
52
|
+
presence_penalty?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Chat completion result
|
|
56
|
+
*/
|
|
57
|
+
export interface OpenAIChatResult {
|
|
58
|
+
id: string;
|
|
59
|
+
object: string;
|
|
60
|
+
created: number;
|
|
61
|
+
model: string;
|
|
62
|
+
choices: Array<{
|
|
63
|
+
index: number;
|
|
64
|
+
message: {
|
|
65
|
+
role: string;
|
|
66
|
+
content: string;
|
|
67
|
+
};
|
|
68
|
+
finish_reason: string;
|
|
69
|
+
}>;
|
|
70
|
+
usage?: {
|
|
71
|
+
prompt_tokens: number;
|
|
72
|
+
completion_tokens: number;
|
|
73
|
+
total_tokens: number;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Options for embeddings
|
|
78
|
+
*/
|
|
79
|
+
export interface OpenAIEmbeddingOptions {
|
|
80
|
+
/** Model to use for embeddings */
|
|
81
|
+
model?: string;
|
|
82
|
+
/** Input text(s) to embed */
|
|
83
|
+
input: string | string[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Embedding result
|
|
87
|
+
*/
|
|
88
|
+
export interface OpenAIEmbeddingResult {
|
|
89
|
+
object: string;
|
|
90
|
+
data: Array<{
|
|
91
|
+
object: string;
|
|
92
|
+
embedding: number[];
|
|
93
|
+
index: number;
|
|
94
|
+
}>;
|
|
95
|
+
model: string;
|
|
96
|
+
usage: {
|
|
97
|
+
prompt_tokens: number;
|
|
98
|
+
total_tokens: number;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export declare const OpenAIClientConfigSchema: z.ZodObject<{
|
|
102
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
103
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
104
|
+
model: z.ZodOptional<z.ZodString>;
|
|
105
|
+
organization: z.ZodOptional<z.ZodString>;
|
|
106
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
107
|
+
}, "strip", z.ZodTypeAny, {
|
|
108
|
+
timeout?: number | undefined;
|
|
109
|
+
apiKey?: string | undefined;
|
|
110
|
+
organization?: string | undefined;
|
|
111
|
+
model?: string | undefined;
|
|
112
|
+
baseUrl?: string | undefined;
|
|
113
|
+
}, {
|
|
114
|
+
timeout?: number | undefined;
|
|
115
|
+
apiKey?: string | undefined;
|
|
116
|
+
organization?: string | undefined;
|
|
117
|
+
model?: string | undefined;
|
|
118
|
+
baseUrl?: string | undefined;
|
|
119
|
+
}>;
|
|
120
|
+
export declare const OpenAIChatMessageSchema: z.ZodObject<{
|
|
121
|
+
role: z.ZodEnum<["system", "user", "assistant", "tool"]>;
|
|
122
|
+
content: z.ZodString;
|
|
123
|
+
name: z.ZodOptional<z.ZodString>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
content: string;
|
|
126
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
127
|
+
name?: string | undefined;
|
|
128
|
+
}, {
|
|
129
|
+
content: string;
|
|
130
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
131
|
+
name?: string | undefined;
|
|
132
|
+
}>;
|
|
133
|
+
export declare const OpenAIChatOptionsSchema: z.ZodObject<{
|
|
134
|
+
model: z.ZodOptional<z.ZodString>;
|
|
135
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
136
|
+
role: z.ZodEnum<["system", "user", "assistant", "tool"]>;
|
|
137
|
+
content: z.ZodString;
|
|
138
|
+
name: z.ZodOptional<z.ZodString>;
|
|
139
|
+
}, "strip", z.ZodTypeAny, {
|
|
140
|
+
content: string;
|
|
141
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
142
|
+
name?: string | undefined;
|
|
143
|
+
}, {
|
|
144
|
+
content: string;
|
|
145
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
146
|
+
name?: string | undefined;
|
|
147
|
+
}>, "many">;
|
|
148
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
149
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
152
|
+
stop: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
153
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
messages: {
|
|
157
|
+
content: string;
|
|
158
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
159
|
+
name?: string | undefined;
|
|
160
|
+
}[];
|
|
161
|
+
model?: string | undefined;
|
|
162
|
+
temperature?: number | undefined;
|
|
163
|
+
max_tokens?: number | undefined;
|
|
164
|
+
top_p?: number | undefined;
|
|
165
|
+
n?: number | undefined;
|
|
166
|
+
stop?: string | string[] | undefined;
|
|
167
|
+
frequency_penalty?: number | undefined;
|
|
168
|
+
presence_penalty?: number | undefined;
|
|
169
|
+
}, {
|
|
170
|
+
messages: {
|
|
171
|
+
content: string;
|
|
172
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
173
|
+
name?: string | undefined;
|
|
174
|
+
}[];
|
|
175
|
+
model?: string | undefined;
|
|
176
|
+
temperature?: number | undefined;
|
|
177
|
+
max_tokens?: number | undefined;
|
|
178
|
+
top_p?: number | undefined;
|
|
179
|
+
n?: number | undefined;
|
|
180
|
+
stop?: string | string[] | undefined;
|
|
181
|
+
frequency_penalty?: number | undefined;
|
|
182
|
+
presence_penalty?: number | undefined;
|
|
183
|
+
}>;
|
|
184
|
+
export declare const OpenAIEmbeddingOptionsSchema: z.ZodObject<{
|
|
185
|
+
model: z.ZodOptional<z.ZodString>;
|
|
186
|
+
input: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
187
|
+
}, "strip", z.ZodTypeAny, {
|
|
188
|
+
input: string | string[];
|
|
189
|
+
model?: string | undefined;
|
|
190
|
+
}, {
|
|
191
|
+
input: string | string[];
|
|
192
|
+
model?: string | undefined;
|
|
193
|
+
}>;
|
|
194
|
+
//# sourceMappingURL=openai-types.d.ts.map
|
|
@@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AI SDK integration with marktoflow
|
|
3
|
+
*
|
|
4
|
+
* These types enable integration with OpenAI-compatible APIs including
|
|
5
|
+
* OpenAI, VLLM, and other local/remote endpoints.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Zod Schemas
|
|
10
|
+
// ============================================================================
|
|
11
|
+
export const OpenAIClientConfigSchema = z.object({
|
|
12
|
+
baseUrl: z.string().optional(),
|
|
13
|
+
apiKey: z.string().optional(),
|
|
14
|
+
model: z.string().optional(),
|
|
15
|
+
organization: z.string().optional(),
|
|
16
|
+
timeout: z.number().positive().optional(),
|
|
17
|
+
});
|
|
18
|
+
export const OpenAIChatMessageSchema = z.object({
|
|
19
|
+
role: z.enum(['system', 'user', 'assistant', 'tool']),
|
|
20
|
+
content: z.string(),
|
|
21
|
+
name: z.string().optional(),
|
|
22
|
+
});
|
|
23
|
+
export const OpenAIChatOptionsSchema = z.object({
|
|
24
|
+
model: z.string().optional(),
|
|
25
|
+
messages: z.array(OpenAIChatMessageSchema),
|
|
26
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
27
|
+
max_tokens: z.number().positive().optional(),
|
|
28
|
+
top_p: z.number().min(0).max(1).optional(),
|
|
29
|
+
n: z.number().positive().optional(),
|
|
30
|
+
stop: z.union([z.string(), z.array(z.string())]).optional(),
|
|
31
|
+
frequency_penalty: z.number().min(-2).max(2).optional(),
|
|
32
|
+
presence_penalty: z.number().min(-2).max(2).optional(),
|
|
33
|
+
});
|
|
34
|
+
export const OpenAIEmbeddingOptionsSchema = z.object({
|
|
35
|
+
model: z.string().optional(),
|
|
36
|
+
input: z.union([z.string(), z.array(z.string())]),
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=openai-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-types.js","sourceRoot":"","sources":["../../src/adapters/openai-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,E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AAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC1C,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACnC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3D,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACvD,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACvD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;CAClD,CAAC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI SDK Adapter for marktoflow
|
|
3
|
+
*
|
|
4
|
+
* This adapter provides integration with OpenAI-compatible APIs,
|
|
5
|
+
* including OpenAI, VLLM, and other local/remote endpoints that
|
|
6
|
+
* implement the OpenAI API specification.
|
|
7
|
+
*/
|
|
8
|
+
import { SDKInitializer } from '@marktoflow/core';
|
|
9
|
+
import type { OpenAIClientConfig, OpenAIChatOptions, OpenAIChatResult, OpenAIEmbeddingOptions, OpenAIEmbeddingResult } from './openai-types.js';
|
|
10
|
+
export declare class OpenAIClient {
|
|
11
|
+
private client;
|
|
12
|
+
private defaultModel;
|
|
13
|
+
constructor(config?: OpenAIClientConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Simple text generation from a prompt
|
|
16
|
+
*/
|
|
17
|
+
generate(inputs: {
|
|
18
|
+
prompt: string;
|
|
19
|
+
model?: string;
|
|
20
|
+
} | string, model?: string): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Full chat completion with all options
|
|
23
|
+
*/
|
|
24
|
+
chatCompletion(options: OpenAIChatOptions): Promise<OpenAIChatResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Streaming chat completion
|
|
27
|
+
*/
|
|
28
|
+
chatStream(options: OpenAIChatOptions): AsyncGenerator<string, void, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Create embeddings for text input
|
|
31
|
+
*/
|
|
32
|
+
embeddings(options: OpenAIEmbeddingOptions): Promise<OpenAIEmbeddingResult>;
|
|
33
|
+
/**
|
|
34
|
+
* List available models
|
|
35
|
+
*/
|
|
36
|
+
listModels(): Promise<Array<{
|
|
37
|
+
id: string;
|
|
38
|
+
owned_by: string;
|
|
39
|
+
}>>;
|
|
40
|
+
/**
|
|
41
|
+
* Check if the API endpoint is available
|
|
42
|
+
*/
|
|
43
|
+
isAvailable(): Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* Get the default model
|
|
46
|
+
*/
|
|
47
|
+
getDefaultModel(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Set the default model
|
|
50
|
+
*/
|
|
51
|
+
setDefaultModel(model: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* OpenAI-compatible chat.completions interface
|
|
54
|
+
*/
|
|
55
|
+
chat: {
|
|
56
|
+
completions: (inputs: {
|
|
57
|
+
model?: string;
|
|
58
|
+
messages: Array<{
|
|
59
|
+
role: string;
|
|
60
|
+
content: string;
|
|
61
|
+
}>;
|
|
62
|
+
temperature?: number;
|
|
63
|
+
max_tokens?: number;
|
|
64
|
+
}) => Promise<{
|
|
65
|
+
choices: Array<{
|
|
66
|
+
message: {
|
|
67
|
+
content: string;
|
|
68
|
+
};
|
|
69
|
+
}>;
|
|
70
|
+
}>;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export declare const OpenAIInitializer: SDKInitializer;
|
|
74
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAc,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAM3B,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,GAAE,kBAAuB;IAkB3C;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBpG;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsC3E;;OAEG;IACI,UAAU,CACf,OAAO,EAAE,iBAAiB,GACzB,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC;IAuBxC;;OAEG;IACG,UAAU,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA2BjF;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAapE;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IASrC;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQpC;;OAEG;IACH,IAAI;8BAC0B;YAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,QAAQ,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;YACnD,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,UAAU,CAAC,EAAE,MAAM,CAAC;SACrB,KAAG,OAAO,CAAC;YAAE,OAAO,EAAE,KAAK,CAAC;gBAAE,OAAO,EAAE;oBAAE,OAAO,EAAE,MAAM,CAAA;iBAAE,CAAA;aAAE,CAAC,CAAA;SAAE,CAAC;MAgBjE;CACH;AAMD,eAAO,MAAM,iBAAiB,EAAE,cAa/B,CAAC"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI SDK Adapter for marktoflow
|
|
3
|
+
*
|
|
4
|
+
* This adapter provides integration with OpenAI-compatible APIs,
|
|
5
|
+
* including OpenAI, VLLM, and other local/remote endpoints that
|
|
6
|
+
* implement the OpenAI API specification.
|
|
7
|
+
*/
|
|
8
|
+
import OpenAI from 'openai';
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// OpenAI Client
|
|
11
|
+
// ============================================================================
|
|
12
|
+
export class OpenAIClient {
|
|
13
|
+
client;
|
|
14
|
+
defaultModel;
|
|
15
|
+
constructor(config = {}) {
|
|
16
|
+
// For VLLM/local endpoints, a dummy key is needed since the SDK requires non-empty string
|
|
17
|
+
const apiKey = config.apiKey || process.env.OPENAI_API_KEY || 'dummy-key';
|
|
18
|
+
this.client = new OpenAI({
|
|
19
|
+
apiKey,
|
|
20
|
+
baseURL: config.baseUrl || 'https://api.openai.com/v1',
|
|
21
|
+
organization: config.organization,
|
|
22
|
+
timeout: config.timeout || 60000,
|
|
23
|
+
});
|
|
24
|
+
this.defaultModel = config.model || 'gpt-4o';
|
|
25
|
+
}
|
|
26
|
+
// --------------------------------------------------------------------------
|
|
27
|
+
// Generation
|
|
28
|
+
// --------------------------------------------------------------------------
|
|
29
|
+
/**
|
|
30
|
+
* Simple text generation from a prompt
|
|
31
|
+
*/
|
|
32
|
+
async generate(inputs, model) {
|
|
33
|
+
const prompt = typeof inputs === 'string' ? inputs : inputs.prompt;
|
|
34
|
+
const selectedModel = typeof inputs === 'object' && inputs.model ? inputs.model : model || this.defaultModel;
|
|
35
|
+
const response = await this.client.chat.completions.create({
|
|
36
|
+
model: selectedModel,
|
|
37
|
+
messages: [{ role: 'user', content: prompt }],
|
|
38
|
+
});
|
|
39
|
+
return response.choices[0]?.message?.content || '';
|
|
40
|
+
}
|
|
41
|
+
// --------------------------------------------------------------------------
|
|
42
|
+
// Chat Completions
|
|
43
|
+
// --------------------------------------------------------------------------
|
|
44
|
+
/**
|
|
45
|
+
* Full chat completion with all options
|
|
46
|
+
*/
|
|
47
|
+
async chatCompletion(options) {
|
|
48
|
+
const model = options.model || this.defaultModel;
|
|
49
|
+
const response = await this.client.chat.completions.create({
|
|
50
|
+
model,
|
|
51
|
+
messages: options.messages,
|
|
52
|
+
temperature: options.temperature,
|
|
53
|
+
max_tokens: options.max_tokens,
|
|
54
|
+
top_p: options.top_p,
|
|
55
|
+
n: options.n,
|
|
56
|
+
stop: options.stop,
|
|
57
|
+
frequency_penalty: options.frequency_penalty,
|
|
58
|
+
presence_penalty: options.presence_penalty,
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
id: response.id,
|
|
62
|
+
object: response.object,
|
|
63
|
+
created: response.created,
|
|
64
|
+
model: response.model,
|
|
65
|
+
choices: response.choices.map((choice, index) => ({
|
|
66
|
+
index,
|
|
67
|
+
message: {
|
|
68
|
+
role: choice.message.role,
|
|
69
|
+
content: choice.message.content || '',
|
|
70
|
+
},
|
|
71
|
+
finish_reason: choice.finish_reason || 'stop',
|
|
72
|
+
})),
|
|
73
|
+
usage: response.usage
|
|
74
|
+
? {
|
|
75
|
+
prompt_tokens: response.usage.prompt_tokens,
|
|
76
|
+
completion_tokens: response.usage.completion_tokens,
|
|
77
|
+
total_tokens: response.usage.total_tokens,
|
|
78
|
+
}
|
|
79
|
+
: undefined,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Streaming chat completion
|
|
84
|
+
*/
|
|
85
|
+
async *chatStream(options) {
|
|
86
|
+
const model = options.model || this.defaultModel;
|
|
87
|
+
const stream = await this.client.chat.completions.create({
|
|
88
|
+
model,
|
|
89
|
+
messages: options.messages,
|
|
90
|
+
temperature: options.temperature,
|
|
91
|
+
max_tokens: options.max_tokens,
|
|
92
|
+
stream: true,
|
|
93
|
+
});
|
|
94
|
+
for await (const chunk of stream) {
|
|
95
|
+
const content = chunk.choices[0]?.delta?.content;
|
|
96
|
+
if (content) {
|
|
97
|
+
yield content;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// --------------------------------------------------------------------------
|
|
102
|
+
// Embeddings
|
|
103
|
+
// --------------------------------------------------------------------------
|
|
104
|
+
/**
|
|
105
|
+
* Create embeddings for text input
|
|
106
|
+
*/
|
|
107
|
+
async embeddings(options) {
|
|
108
|
+
const model = options.model || 'text-embedding-3-small';
|
|
109
|
+
const response = await this.client.embeddings.create({
|
|
110
|
+
model,
|
|
111
|
+
input: options.input,
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
object: response.object,
|
|
115
|
+
data: response.data.map((item) => ({
|
|
116
|
+
object: item.object,
|
|
117
|
+
embedding: item.embedding,
|
|
118
|
+
index: item.index,
|
|
119
|
+
})),
|
|
120
|
+
model: response.model,
|
|
121
|
+
usage: {
|
|
122
|
+
prompt_tokens: response.usage.prompt_tokens,
|
|
123
|
+
total_tokens: response.usage.total_tokens,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// --------------------------------------------------------------------------
|
|
128
|
+
// Models
|
|
129
|
+
// --------------------------------------------------------------------------
|
|
130
|
+
/**
|
|
131
|
+
* List available models
|
|
132
|
+
*/
|
|
133
|
+
async listModels() {
|
|
134
|
+
const response = await this.client.models.list();
|
|
135
|
+
const models = [];
|
|
136
|
+
for await (const model of response) {
|
|
137
|
+
models.push({ id: model.id, owned_by: model.owned_by });
|
|
138
|
+
}
|
|
139
|
+
return models;
|
|
140
|
+
}
|
|
141
|
+
// --------------------------------------------------------------------------
|
|
142
|
+
// Utility
|
|
143
|
+
// --------------------------------------------------------------------------
|
|
144
|
+
/**
|
|
145
|
+
* Check if the API endpoint is available
|
|
146
|
+
*/
|
|
147
|
+
async isAvailable() {
|
|
148
|
+
try {
|
|
149
|
+
await this.client.models.list();
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get the default model
|
|
158
|
+
*/
|
|
159
|
+
getDefaultModel() {
|
|
160
|
+
return this.defaultModel;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Set the default model
|
|
164
|
+
*/
|
|
165
|
+
setDefaultModel(model) {
|
|
166
|
+
this.defaultModel = model;
|
|
167
|
+
}
|
|
168
|
+
// --------------------------------------------------------------------------
|
|
169
|
+
// OpenAI-Compatible Interface (for workflow compatibility)
|
|
170
|
+
// --------------------------------------------------------------------------
|
|
171
|
+
/**
|
|
172
|
+
* OpenAI-compatible chat.completions interface
|
|
173
|
+
*/
|
|
174
|
+
chat = {
|
|
175
|
+
completions: async (inputs) => {
|
|
176
|
+
const response = await this.client.chat.completions.create({
|
|
177
|
+
model: inputs.model || this.defaultModel,
|
|
178
|
+
messages: inputs.messages,
|
|
179
|
+
temperature: inputs.temperature,
|
|
180
|
+
max_tokens: inputs.max_tokens,
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
choices: response.choices.map((choice) => ({
|
|
184
|
+
message: {
|
|
185
|
+
content: choice.message.content || '',
|
|
186
|
+
},
|
|
187
|
+
})),
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
// ============================================================================
|
|
193
|
+
// SDK Initializer
|
|
194
|
+
// ============================================================================
|
|
195
|
+
export const OpenAIInitializer = {
|
|
196
|
+
async initialize(_module, config) {
|
|
197
|
+
const auth = config.auth || {};
|
|
198
|
+
const options = config.options || {};
|
|
199
|
+
return new OpenAIClient({
|
|
200
|
+
baseUrl: auth['base_url'] || options['baseUrl'],
|
|
201
|
+
apiKey: auth['api_key'] || options['apiKey'],
|
|
202
|
+
model: options['model'],
|
|
203
|
+
organization: options['organization'],
|
|
204
|
+
timeout: options['timeout'],
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAU5B,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,MAAM,OAAO,YAAY;IACf,MAAM,CAAS;IACf,YAAY,CAAS;IAE7B,YAAY,SAA6B,EAAE;QACzC,0FAA0F;QAC1F,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,WAAW,CAAC;QAE1E,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;YACvB,MAAM;YACN,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,2BAA2B;YACtD,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;SACjC,CAAC,CA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AC,OAAO,IAAI,EAAE;qBACtC;iBACF,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC;KACF,CAAC;CACH;AAED,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,iBAAiB,GAAmB;IAC/C,KAAK,CAAC,UAAU,CAAC,OAAgB,EAAE,MAAkB;QACnD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QAErC,OAAO,IAAI,YAAY,CAAC;YACtB,OAAO,EAAG,IAAI,CAAC,UAAU,CAAY,IAAK,OAAO,CAAC,SAAS,CAAY;YACvE,MAAM,EAAG,IAAI,CAAC,SAAS,CAAY,IAAK,OAAO,CAAC,QAAQ,CAAY;YACpE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAW;YACjC,YAAY,EAAE,OAAO,CAAC,cAAc,CAAW;YAC/C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAW;SACtC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -6,18 +6,43 @@ export declare class OpenCodeClient {
|
|
|
6
6
|
private model;
|
|
7
7
|
private excludeFiles;
|
|
8
8
|
private sdkClient;
|
|
9
|
+
private currentSessionId;
|
|
9
10
|
constructor(options?: {
|
|
10
11
|
mode?: 'cli' | 'server' | 'auto';
|
|
11
12
|
serverUrl?: string;
|
|
12
13
|
cliPath?: string;
|
|
13
14
|
model?: string;
|
|
14
15
|
excludeFiles?: string[];
|
|
16
|
+
sessionId?: string;
|
|
15
17
|
});
|
|
16
18
|
generate(inputs: {
|
|
17
19
|
prompt: string;
|
|
18
20
|
} | string): Promise<string>;
|
|
21
|
+
private getOrCreateSession;
|
|
19
22
|
private generateViaServer;
|
|
20
23
|
private generateViaCli;
|
|
24
|
+
listSessions(): Promise<any[]>;
|
|
25
|
+
getSession(sessionId: string): Promise<any>;
|
|
26
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
27
|
+
abort(sessionId?: string): Promise<void>;
|
|
28
|
+
getMessages(sessionId?: string): Promise<any[]>;
|
|
29
|
+
share(sessionId?: string): Promise<any>;
|
|
30
|
+
unshare(sessionId?: string): Promise<void>;
|
|
31
|
+
summarize(sessionId?: string): Promise<any>;
|
|
32
|
+
listProviders(): Promise<any>;
|
|
33
|
+
listAgents(): Promise<any>;
|
|
34
|
+
getConfig(): Promise<any>;
|
|
35
|
+
search: {
|
|
36
|
+
text: (pattern: string) => Promise<any>;
|
|
37
|
+
files: (query: string) => Promise<any>;
|
|
38
|
+
symbols: (query: string) => Promise<any>;
|
|
39
|
+
};
|
|
40
|
+
file: {
|
|
41
|
+
read: (path: string) => Promise<any>;
|
|
42
|
+
status: () => Promise<any>;
|
|
43
|
+
};
|
|
44
|
+
streamEvents(): Promise<any>;
|
|
45
|
+
getSessionId(): string | null;
|
|
21
46
|
/**
|
|
22
47
|
* OpenAI-compatible chat interface for workflow compatibility
|
|
23
48
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../src/adapters/opencode.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG9D,qBAAa,cAAc;IACzB,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAqB;IAElC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,SAAS,CAA+B;
|
|
1
|
+
{"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../src/adapters/opencode.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG9D,qBAAa,cAAc;IACzB,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OA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