@gopher.security/gopher-mcp-js 0.1.1
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/LICENSE +201 -0
- package/README.md +224 -0
- package/dist/agent.d.ts +118 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +240 -0
- package/dist/agent.js.map +1 -0
- package/dist/config.d.ts +63 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +101 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +29 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +53 -0
- package/dist/errors.js.map +1 -0
- package/dist/ffi/index.d.ts +6 -0
- package/dist/ffi/index.d.ts.map +1 -0
- package/dist/ffi/index.js +9 -0
- package/dist/ffi/index.js.map +1 -0
- package/dist/ffi/library.d.ts +80 -0
- package/dist/ffi/library.d.ts.map +1 -0
- package/dist/ffi/library.js +357 -0
- package/dist/ffi/library.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/result.d.ts +81 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +129 -0
- package/dist/result.js.map +1 -0
- package/dist/serverConfig.d.ts +18 -0
- package/dist/serverConfig.d.ts.map +1 -0
- package/dist/serverConfig.js +48 -0
- package/dist/serverConfig.js.map +1 -0
- package/package.json +68 -0
- package/scripts/download-native.js +328 -0
- package/scripts/update-version.js +108 -0
package/dist/agent.js
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GopherAgent - Main entry point for the gopher-orch TypeScript SDK.
|
|
4
|
+
*
|
|
5
|
+
* Provides a clean, TypeScript-friendly interface to the gopher-orch agent functionality.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Create an agent with API key
|
|
10
|
+
* const agent = GopherAgent.create(
|
|
11
|
+
* GopherAgentConfig.builder()
|
|
12
|
+
* .provider('AnthropicProvider')
|
|
13
|
+
* .model('claude-3-haiku-20240307')
|
|
14
|
+
* .apiKey('your-api-key')
|
|
15
|
+
* .build()
|
|
16
|
+
* );
|
|
17
|
+
*
|
|
18
|
+
* // Run a query
|
|
19
|
+
* const answer = agent.run('What time is it in Tokyo?');
|
|
20
|
+
* console.log(answer);
|
|
21
|
+
*
|
|
22
|
+
* // Cleanup
|
|
23
|
+
* agent.dispose();
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Use try-finally for automatic cleanup
|
|
29
|
+
* const agent = GopherAgent.create(config);
|
|
30
|
+
* try {
|
|
31
|
+
* const answer = agent.run('What time is it in Tokyo?');
|
|
32
|
+
* console.log(answer);
|
|
33
|
+
* } finally {
|
|
34
|
+
* agent.dispose();
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.GopherAgent = void 0;
|
|
40
|
+
const config_1 = require("./config");
|
|
41
|
+
const result_1 = require("./result");
|
|
42
|
+
const errors_1 = require("./errors");
|
|
43
|
+
const ffi_1 = require("./ffi");
|
|
44
|
+
let initialized = false;
|
|
45
|
+
let cleanupHandlerRegistered = false;
|
|
46
|
+
/**
|
|
47
|
+
* Main agent class for interacting with the gopher-orch native library.
|
|
48
|
+
*/
|
|
49
|
+
class GopherAgent {
|
|
50
|
+
handle;
|
|
51
|
+
disposed = false;
|
|
52
|
+
constructor(handle) {
|
|
53
|
+
this.handle = handle;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Initialize the gopher-orch library.
|
|
57
|
+
*
|
|
58
|
+
* Must be called before creating any agents. Called automatically by create() if not already
|
|
59
|
+
* initialized.
|
|
60
|
+
*
|
|
61
|
+
* @throws {AgentError} if initialization fails
|
|
62
|
+
*/
|
|
63
|
+
static init() {
|
|
64
|
+
if (initialized) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const lib = ffi_1.GopherOrchLibrary.getInstance();
|
|
68
|
+
if (lib === null) {
|
|
69
|
+
throw new errors_1.AgentError('Failed to load gopher-orch native library');
|
|
70
|
+
}
|
|
71
|
+
initialized = true;
|
|
72
|
+
setupCleanupHandler();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Shutdown the gopher-orch library.
|
|
76
|
+
*
|
|
77
|
+
* Called automatically on process exit, but can be called manually.
|
|
78
|
+
*/
|
|
79
|
+
static shutdown() {
|
|
80
|
+
initialized = false;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if the library is initialized.
|
|
84
|
+
*/
|
|
85
|
+
static isInitialized() {
|
|
86
|
+
return initialized;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a new GopherAgent instance.
|
|
90
|
+
*
|
|
91
|
+
* @param config Agent configuration
|
|
92
|
+
* @returns GopherAgent instance
|
|
93
|
+
* @throws {AgentError} if agent creation fails
|
|
94
|
+
*/
|
|
95
|
+
static create(config) {
|
|
96
|
+
if (!initialized) {
|
|
97
|
+
GopherAgent.init();
|
|
98
|
+
}
|
|
99
|
+
const lib = ffi_1.GopherOrchLibrary.getInstance();
|
|
100
|
+
if (lib === null) {
|
|
101
|
+
throw new errors_1.AgentError('Native library not available');
|
|
102
|
+
}
|
|
103
|
+
let handle;
|
|
104
|
+
try {
|
|
105
|
+
if (config.hasApiKey()) {
|
|
106
|
+
handle = lib.agentCreateByApiKey(config.provider, config.model, config.apiKey);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
handle = lib.agentCreateByJson(config.provider, config.model, config.serverConfig);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
throw new errors_1.AgentError(`Failed to create agent: ${e.message}`);
|
|
114
|
+
}
|
|
115
|
+
if (handle === null) {
|
|
116
|
+
const errorInfo = lib.lastError();
|
|
117
|
+
lib.clearError();
|
|
118
|
+
if (errorInfo) {
|
|
119
|
+
const details = errorInfo.details ? `: ${errorInfo.details}` : '';
|
|
120
|
+
throw new errors_1.AgentError(`${errorInfo.message ?? 'Failed to create agent'}${details}`);
|
|
121
|
+
}
|
|
122
|
+
throw new errors_1.AgentError('Failed to create agent');
|
|
123
|
+
}
|
|
124
|
+
return new GopherAgent(handle);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Create a new GopherAgent with API key.
|
|
128
|
+
*
|
|
129
|
+
* @param provider Provider name (e.g., "AnthropicProvider")
|
|
130
|
+
* @param model Model name (e.g., "claude-3-haiku-20240307")
|
|
131
|
+
* @param apiKey API key for fetching remote server config
|
|
132
|
+
* @returns GopherAgent instance
|
|
133
|
+
*/
|
|
134
|
+
static createWithApiKey(provider, model, apiKey) {
|
|
135
|
+
return GopherAgent.create(config_1.GopherAgentConfig.builder()
|
|
136
|
+
.provider(provider)
|
|
137
|
+
.model(model)
|
|
138
|
+
.apiKey(apiKey)
|
|
139
|
+
.build());
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a new GopherAgent with JSON server config.
|
|
143
|
+
*
|
|
144
|
+
* @param provider Provider name (e.g., "AnthropicProvider")
|
|
145
|
+
* @param model Model name (e.g., "claude-3-haiku-20240307")
|
|
146
|
+
* @param serverConfig JSON server configuration
|
|
147
|
+
* @returns GopherAgent instance
|
|
148
|
+
*/
|
|
149
|
+
static createWithServerConfig(provider, model, serverConfig) {
|
|
150
|
+
return GopherAgent.create(config_1.GopherAgentConfig.builder()
|
|
151
|
+
.provider(provider)
|
|
152
|
+
.model(model)
|
|
153
|
+
.serverConfig(serverConfig)
|
|
154
|
+
.build());
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Run a query against the agent.
|
|
158
|
+
*
|
|
159
|
+
* @param query The user query to process
|
|
160
|
+
* @param timeoutMs Timeout in milliseconds (default: 60000)
|
|
161
|
+
* @returns The agent's response
|
|
162
|
+
* @throws {AgentError} if the query fails
|
|
163
|
+
*/
|
|
164
|
+
run(query, timeoutMs = 60000) {
|
|
165
|
+
this.ensureNotDisposed();
|
|
166
|
+
const lib = ffi_1.GopherOrchLibrary.getInstance();
|
|
167
|
+
if (lib === null) {
|
|
168
|
+
throw new errors_1.AgentError('Native library not available');
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
const response = lib.agentRun(this.handle, query, timeoutMs);
|
|
172
|
+
if (response === null) {
|
|
173
|
+
return `No response for query: "${query}"`;
|
|
174
|
+
}
|
|
175
|
+
return response;
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
throw new errors_1.AgentError(`Query execution failed: ${e.message}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Run a query with detailed result information.
|
|
183
|
+
*
|
|
184
|
+
* @param query The user query to process
|
|
185
|
+
* @param timeoutMs Timeout in milliseconds (default: 60000)
|
|
186
|
+
* @returns AgentResult with response and metadata
|
|
187
|
+
*/
|
|
188
|
+
runDetailed(query, timeoutMs = 60000) {
|
|
189
|
+
try {
|
|
190
|
+
const response = this.run(query, timeoutMs);
|
|
191
|
+
return result_1.AgentResult.builder()
|
|
192
|
+
.response(response)
|
|
193
|
+
.status(result_1.AgentResultStatus.SUCCESS)
|
|
194
|
+
.iterationCount(1)
|
|
195
|
+
.tokensUsed(0)
|
|
196
|
+
.build();
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
if (e instanceof errors_1.TimeoutError) {
|
|
200
|
+
return result_1.AgentResult.timeout(e.message);
|
|
201
|
+
}
|
|
202
|
+
return result_1.AgentResult.error(e.message);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Dispose of the agent and free resources.
|
|
207
|
+
*/
|
|
208
|
+
dispose() {
|
|
209
|
+
if (this.disposed) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.disposed = true;
|
|
213
|
+
const lib = ffi_1.GopherOrchLibrary.getInstance();
|
|
214
|
+
if (lib !== null && this.handle !== null) {
|
|
215
|
+
lib.agentRelease(this.handle);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Check if agent is disposed.
|
|
220
|
+
*/
|
|
221
|
+
isDisposed() {
|
|
222
|
+
return this.disposed;
|
|
223
|
+
}
|
|
224
|
+
ensureNotDisposed() {
|
|
225
|
+
if (this.disposed) {
|
|
226
|
+
throw new errors_1.AgentError('Agent has been disposed');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
exports.GopherAgent = GopherAgent;
|
|
231
|
+
function setupCleanupHandler() {
|
|
232
|
+
if (cleanupHandlerRegistered) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
cleanupHandlerRegistered = true;
|
|
236
|
+
process.on('exit', () => {
|
|
237
|
+
GopherAgent.shutdown();
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;AAEH,qCAA6C;AAC7C,qCAA0D;AAC1D,qCAAoD;AACpD,+BAA4D;AAE5D,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,wBAAwB,GAAG,KAAK,CAAC;AAErC;;GAEG;AACH,MAAa,WAAW;IACd,MAAM,CAAmB;IACzB,QAAQ,GAAG,KAAK,CAAC;IAEzB,YAAoB,MAAwB;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI;QACT,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO;QACT,C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,WAAW,EAAE,CAAC;QAC5C,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACzC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEO,iBAAiB;QACvB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,mBAAU,CAAC,yBAAyB,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF;AAzND,kCAyNC;AAED,SAAS,mBAAmB;IAC1B,IAAI,wBAAwB,EAAE,CAAC;QAC7B,OAAO;IACT,CAAC;IAED,wBAAwB,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACtB,WAAW,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for creating a GopherAgent.
|
|
3
|
+
*/
|
|
4
|
+
export interface GopherAgentConfigOptions {
|
|
5
|
+
provider: string;
|
|
6
|
+
model: string;
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
serverConfig?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for creating a GopherAgent.
|
|
12
|
+
*/
|
|
13
|
+
export declare class GopherAgentConfig {
|
|
14
|
+
readonly provider: string;
|
|
15
|
+
readonly model: string;
|
|
16
|
+
readonly apiKey?: string;
|
|
17
|
+
readonly serverConfig?: string;
|
|
18
|
+
private constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Check if this config uses an API key.
|
|
21
|
+
*/
|
|
22
|
+
hasApiKey(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check if this config uses a server config.
|
|
25
|
+
*/
|
|
26
|
+
hasServerConfig(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new builder for GopherAgentConfig.
|
|
29
|
+
*/
|
|
30
|
+
static builder(): GopherAgentConfigBuilder;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Builder for GopherAgentConfig.
|
|
34
|
+
*/
|
|
35
|
+
export declare class GopherAgentConfigBuilder {
|
|
36
|
+
private _provider?;
|
|
37
|
+
private _model?;
|
|
38
|
+
private _apiKey?;
|
|
39
|
+
private _serverConfig?;
|
|
40
|
+
/**
|
|
41
|
+
* Set the LLM provider (e.g., "AnthropicProvider").
|
|
42
|
+
*/
|
|
43
|
+
provider(provider: string): this;
|
|
44
|
+
/**
|
|
45
|
+
* Set the model name (e.g., "claude-3-haiku-20240307").
|
|
46
|
+
*/
|
|
47
|
+
model(model: string): this;
|
|
48
|
+
/**
|
|
49
|
+
* Set the API key for fetching remote server config.
|
|
50
|
+
* Mutually exclusive with serverConfig.
|
|
51
|
+
*/
|
|
52
|
+
apiKey(apiKey: string): this;
|
|
53
|
+
/**
|
|
54
|
+
* Set the JSON server configuration.
|
|
55
|
+
* Mutually exclusive with apiKey.
|
|
56
|
+
*/
|
|
57
|
+
serverConfig(serverConfig: string): this;
|
|
58
|
+
/**
|
|
59
|
+
* Build the GopherAgentConfig.
|
|
60
|
+
*/
|
|
61
|
+
build(): GopherAgentConfig;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChC,SAAgB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtC,OAAO;IAoBP;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;OAEG;IACH,MAAM,CAAC,OAAO,IAAI,wBAAwB;CAG3C;AAED;;GAEG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,aAAa,CAAC,CAAS;IAE/B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKhC;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK5B;;;OAGG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAKxC;;OAEG;IACH,KAAK,IAAI,iBAAiB;CAU3B"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GopherAgentConfigBuilder = exports.GopherAgentConfig = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for creating a GopherAgent.
|
|
6
|
+
*/
|
|
7
|
+
class GopherAgentConfig {
|
|
8
|
+
provider;
|
|
9
|
+
model;
|
|
10
|
+
apiKey;
|
|
11
|
+
serverConfig;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
if (!options.provider) {
|
|
14
|
+
throw new Error('Provider is required');
|
|
15
|
+
}
|
|
16
|
+
if (!options.model) {
|
|
17
|
+
throw new Error('Model is required');
|
|
18
|
+
}
|
|
19
|
+
if (!options.apiKey && !options.serverConfig) {
|
|
20
|
+
throw new Error('Either apiKey or serverConfig is required');
|
|
21
|
+
}
|
|
22
|
+
if (options.apiKey && options.serverConfig) {
|
|
23
|
+
throw new Error('Cannot specify both apiKey and serverConfig');
|
|
24
|
+
}
|
|
25
|
+
this.provider = options.provider;
|
|
26
|
+
this.model = options.model;
|
|
27
|
+
this.apiKey = options.apiKey;
|
|
28
|
+
this.serverConfig = options.serverConfig;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if this config uses an API key.
|
|
32
|
+
*/
|
|
33
|
+
hasApiKey() {
|
|
34
|
+
return this.apiKey !== undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if this config uses a server config.
|
|
38
|
+
*/
|
|
39
|
+
hasServerConfig() {
|
|
40
|
+
return this.serverConfig !== undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create a new builder for GopherAgentConfig.
|
|
44
|
+
*/
|
|
45
|
+
static builder() {
|
|
46
|
+
return new GopherAgentConfigBuilder();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.GopherAgentConfig = GopherAgentConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Builder for GopherAgentConfig.
|
|
52
|
+
*/
|
|
53
|
+
class GopherAgentConfigBuilder {
|
|
54
|
+
_provider;
|
|
55
|
+
_model;
|
|
56
|
+
_apiKey;
|
|
57
|
+
_serverConfig;
|
|
58
|
+
/**
|
|
59
|
+
* Set the LLM provider (e.g., "AnthropicProvider").
|
|
60
|
+
*/
|
|
61
|
+
provider(provider) {
|
|
62
|
+
this._provider = provider;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Set the model name (e.g., "claude-3-haiku-20240307").
|
|
67
|
+
*/
|
|
68
|
+
model(model) {
|
|
69
|
+
this._model = model;
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Set the API key for fetching remote server config.
|
|
74
|
+
* Mutually exclusive with serverConfig.
|
|
75
|
+
*/
|
|
76
|
+
apiKey(apiKey) {
|
|
77
|
+
this._apiKey = apiKey;
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Set the JSON server configuration.
|
|
82
|
+
* Mutually exclusive with apiKey.
|
|
83
|
+
*/
|
|
84
|
+
serverConfig(serverConfig) {
|
|
85
|
+
this._serverConfig = serverConfig;
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Build the GopherAgentConfig.
|
|
90
|
+
*/
|
|
91
|
+
build() {
|
|
92
|
+
return new GopherAgentConfig({
|
|
93
|
+
provider: this._provider ?? '',
|
|
94
|
+
model: this._model ?? '',
|
|
95
|
+
apiKey: this._apiKey,
|
|
96
|
+
serverConfig: this._serverConfig,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.GopherAgentConfigBuilder = GopherAgentConfigBuilder;
|
|
101
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAUA;;GAEG;AACH,MAAa,iBAAiB;IACZ,QAAQ,CAAS;IACjB,KAAK,CAAS;IACd,MAAM,CAAU;IAChB,YAAY,CAAU;IAEtC,YAAoB,OAAiC;QACnD,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;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OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK;QACH,OAAO,IAAK,iBAEV,CAAC;YACD,QAAQ,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;YAC9B,KAAK,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;YACxB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,YAAY,EAAE,IAAI,CAAC,aAAa;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AArDD,4DAqDC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for gopher-orch operations.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Base error class for agent operations.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AgentError extends Error {
|
|
8
|
+
readonly code?: string;
|
|
9
|
+
constructor(message: string, code?: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Error thrown when API key is invalid or missing.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ApiKeyError extends AgentError {
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Error thrown when connection fails.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ConnectionError extends AgentError {
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Error thrown when operation times out.
|
|
25
|
+
*/
|
|
26
|
+
export declare class TimeoutError extends AgentError {
|
|
27
|
+
constructor(message: string);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAM3C;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,UAAU;gBAC7B,OAAO,EAAE,MAAM;CAK5B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,OAAO,EAAE,MAAM;CAK5B;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,UAAU;gBAC9B,OAAO,EAAE,MAAM;CAK5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Custom error classes for gopher-orch operations.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TimeoutError = exports.ConnectionError = exports.ApiKeyError = exports.AgentError = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Base error class for agent operations.
|
|
9
|
+
*/
|
|
10
|
+
class AgentError extends Error {
|
|
11
|
+
code;
|
|
12
|
+
constructor(message, code) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'AgentError';
|
|
15
|
+
this.code = code;
|
|
16
|
+
Object.setPrototypeOf(this, AgentError.prototype);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.AgentError = AgentError;
|
|
20
|
+
/**
|
|
21
|
+
* Error thrown when API key is invalid or missing.
|
|
22
|
+
*/
|
|
23
|
+
class ApiKeyError extends AgentError {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super(message, 'API_KEY_ERROR');
|
|
26
|
+
this.name = 'ApiKeyError';
|
|
27
|
+
Object.setPrototypeOf(this, ApiKeyError.prototype);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ApiKeyError = ApiKeyError;
|
|
31
|
+
/**
|
|
32
|
+
* Error thrown when connection fails.
|
|
33
|
+
*/
|
|
34
|
+
class ConnectionError extends AgentError {
|
|
35
|
+
constructor(message) {
|
|
36
|
+
super(message, 'CONNECTION_ERROR');
|
|
37
|
+
this.name = 'ConnectionError';
|
|
38
|
+
Object.setPrototypeOf(this, ConnectionError.prototype);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ConnectionError = ConnectionError;
|
|
42
|
+
/**
|
|
43
|
+
* Error thrown when operation times out.
|
|
44
|
+
*/
|
|
45
|
+
class TimeoutError extends AgentError {
|
|
46
|
+
constructor(message) {
|
|
47
|
+
super(message, 'TIMEOUT_ERROR');
|
|
48
|
+
this.name = 'TimeoutError';
|
|
49
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.TimeoutError = TimeoutError;
|
|
53
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH;;GAEG;AACH,MAAa,UAAW,SAAQ,KAAK;IACnB,IAAI,CAAU;IAE9B,YAAY,OAAe,EAAE,IAAa;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AATD,gCASC;AAED;;GAEG;AACH,MAAa,WAAY,SAAQ,UAAU;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;CACF;AAND,kCAMC;AAED;;GAEG;AACH,MAAa,eAAgB,SAAQ,UAAU;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;CACF;AAND,0CAMC;AAED;;GAEG;AACH,MAAa,YAAa,SAAQ,UAAU;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACF;AAND,oCAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ffi/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FFI module exports.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GopherOrchLibrary = void 0;
|
|
7
|
+
var library_1 = require("./library");
|
|
8
|
+
Object.defineProperty(exports, "GopherOrchLibrary", { enumerable: true, get: function () { return library_1.GopherOrchLibrary; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffi/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,qCAA8C;AAArC,4GAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* koffi interface to the gopher-orch native library.
|
|
3
|
+
*/
|
|
4
|
+
declare const OpaqueHandle: unique symbol;
|
|
5
|
+
export type GopherOrchHandle = {
|
|
6
|
+
readonly [OpaqueHandle]: 'GopherOrchHandle';
|
|
7
|
+
};
|
|
8
|
+
export interface GopherOrchErrorInfoData {
|
|
9
|
+
code: number;
|
|
10
|
+
message: string | null;
|
|
11
|
+
details: string | null;
|
|
12
|
+
file: string | null;
|
|
13
|
+
line: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Wrapper for the gopher-orch native library using koffi.
|
|
17
|
+
*/
|
|
18
|
+
export declare class GopherOrchLibrary {
|
|
19
|
+
private static instance;
|
|
20
|
+
private lib;
|
|
21
|
+
private available;
|
|
22
|
+
private debug;
|
|
23
|
+
private _agentCreateByJson;
|
|
24
|
+
private _agentCreateByApiKey;
|
|
25
|
+
private _agentRun;
|
|
26
|
+
private _agentAddRef;
|
|
27
|
+
private _agentRelease;
|
|
28
|
+
private _apiFetchServers;
|
|
29
|
+
private _lastError;
|
|
30
|
+
private _clearError;
|
|
31
|
+
private _free;
|
|
32
|
+
private _setLogLevel;
|
|
33
|
+
private constructor();
|
|
34
|
+
/**
|
|
35
|
+
* Get the library instance, loading it if necessary.
|
|
36
|
+
*/
|
|
37
|
+
static getInstance(): GopherOrchLibrary | null;
|
|
38
|
+
/**
|
|
39
|
+
* Check if the library is available.
|
|
40
|
+
*/
|
|
41
|
+
static isAvailable(): boolean;
|
|
42
|
+
private loadLibrary;
|
|
43
|
+
private setupFunctions;
|
|
44
|
+
private getLibraryName;
|
|
45
|
+
private getSearchPaths;
|
|
46
|
+
/**
|
|
47
|
+
* Get the path to the platform-specific optional dependency package.
|
|
48
|
+
* These packages are published as gopher-orch-{platform}-{arch}
|
|
49
|
+
* and contain the native library for that specific platform.
|
|
50
|
+
*/
|
|
51
|
+
private getPlatformPackagePath;
|
|
52
|
+
agentCreateByJson(provider: string, model: string, serverJson: string): GopherOrchHandle | null;
|
|
53
|
+
agentCreateByApiKey(provider: string, model: string, apiKey: string): GopherOrchHandle | null;
|
|
54
|
+
agentRun(agent: GopherOrchHandle, query: string, timeoutMs: number): string | null;
|
|
55
|
+
agentAddRef(agent: GopherOrchHandle): void;
|
|
56
|
+
agentRelease(agent: GopherOrchHandle): void;
|
|
57
|
+
apiFetchServers(apiKey: string): string | null;
|
|
58
|
+
lastError(): GopherOrchErrorInfoData | null;
|
|
59
|
+
getLastErrorMessage(): string | null;
|
|
60
|
+
clearError(): void;
|
|
61
|
+
free(ptr: unknown): void;
|
|
62
|
+
/**
|
|
63
|
+
* Set the global log level for the native library.
|
|
64
|
+
* Log levels:
|
|
65
|
+
* 0 = Debug (most verbose)
|
|
66
|
+
* 1 = Info
|
|
67
|
+
* 2 = Notice
|
|
68
|
+
* 3 = Warning (default for production)
|
|
69
|
+
* 4 = Error
|
|
70
|
+
* 5 = Critical
|
|
71
|
+
* 6 = Alert
|
|
72
|
+
* 7 = Emergency
|
|
73
|
+
* 8 = Off (no logging)
|
|
74
|
+
*
|
|
75
|
+
* @param level - Log level (0-8)
|
|
76
|
+
*/
|
|
77
|
+
setLogLevel(level: number): void;
|
|
78
|
+
}
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=library.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../src/ffi/library.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,CAAC,MAAM,YAAY,EAAE,OAAO,MAAM,CAAC;AAC1C,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,CAAC,CAAC,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAoB/E,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,qBAA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