@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/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# @gopher.security/gopher-mcp-js
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for AI Agent orchestration with MCP (Model Context Protocol) support.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@gopher.security/gopher-mcp-js)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Multi-Provider LLM Support** - Anthropic, OpenAI, Google, Azure, and more
|
|
11
|
+
- **MCP Protocol** - Full Model Context Protocol client support
|
|
12
|
+
- **Native Performance** - Powered by C++ core with TypeScript bindings
|
|
13
|
+
- **Tool Orchestration** - Execute tools across multiple MCP servers
|
|
14
|
+
- **Type Safety** - Full TypeScript support with strict mode
|
|
15
|
+
|
|
16
|
+
## Supported LLM Providers
|
|
17
|
+
|
|
18
|
+
| Provider | Models |
|
|
19
|
+
|----------|--------|
|
|
20
|
+
| Anthropic | Claude 3.5 Sonnet, Claude 3 Haiku, Claude 3 Opus |
|
|
21
|
+
| OpenAI | GPT-4o, GPT-4o-mini, GPT-4 Turbo |
|
|
22
|
+
| Google | Gemini 2.5 Flash, Gemini 2.0 Pro |
|
|
23
|
+
| Azure OpenAI | GPT-4o, GPT-4 (via Azure deployment) |
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @gopher.security/gopher-mcp-js
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The package automatically installs the correct native library for your platform:
|
|
32
|
+
- macOS (ARM64, x64)
|
|
33
|
+
- Linux (ARM64, x64)
|
|
34
|
+
- Windows (ARM64, x64)
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
### Using Gopher API Key (Recommended)
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { GopherAgent } from '@gopher.security/gopher-mcp-js';
|
|
42
|
+
|
|
43
|
+
// Create agent with Gopher API key (fetches MCP config automatically)
|
|
44
|
+
const agent = GopherAgent.createWithApiKey(
|
|
45
|
+
'AnthropicProvider',
|
|
46
|
+
'claude-3-haiku-20240307',
|
|
47
|
+
process.env.GOPHER_API_KEY!
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const answer = agent.run('List all my Gmail drafts');
|
|
52
|
+
console.log(answer);
|
|
53
|
+
} finally {
|
|
54
|
+
agent.dispose();
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Using Custom Server Configuration
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { GopherAgent } from '@gopher.security/gopher-mcp-js';
|
|
62
|
+
|
|
63
|
+
const serverConfig = JSON.stringify({
|
|
64
|
+
succeeded: true,
|
|
65
|
+
code: 200000000,
|
|
66
|
+
message: 'success',
|
|
67
|
+
data: {
|
|
68
|
+
servers: [
|
|
69
|
+
{
|
|
70
|
+
version: '2025-01-09',
|
|
71
|
+
serverId: '1',
|
|
72
|
+
name: 'my-server',
|
|
73
|
+
transport: 'http_sse',
|
|
74
|
+
config: { url: 'http://localhost:3001/mcp', headers: {} },
|
|
75
|
+
connectTimeout: 5000,
|
|
76
|
+
requestTimeout: 30000,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const agent = GopherAgent.createWithServerConfig(
|
|
83
|
+
'OpenAIProvider',
|
|
84
|
+
'gpt-4o-mini',
|
|
85
|
+
serverConfig
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const answer = agent.run('What tools are available?');
|
|
90
|
+
console.log(answer);
|
|
91
|
+
} finally {
|
|
92
|
+
agent.dispose();
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Using Configuration Builder
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { GopherAgent, GopherAgentConfig } from '@gopher.security/gopher-mcp-js';
|
|
100
|
+
|
|
101
|
+
const config = GopherAgentConfig.builder()
|
|
102
|
+
.provider('AnthropicProvider')
|
|
103
|
+
.model('claude-3-haiku-20240307')
|
|
104
|
+
.apiKey(process.env.GOPHER_API_KEY!)
|
|
105
|
+
.build();
|
|
106
|
+
|
|
107
|
+
const agent = GopherAgent.create(config);
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
const answer = agent.run('Hello, what can you do?');
|
|
111
|
+
console.log(answer);
|
|
112
|
+
} finally {
|
|
113
|
+
agent.dispose();
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## API Reference
|
|
118
|
+
|
|
119
|
+
### GopherAgent
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// Create agent with Gopher API key
|
|
123
|
+
GopherAgent.createWithApiKey(provider, model, apiKey): GopherAgent
|
|
124
|
+
|
|
125
|
+
// Create agent with server configuration JSON
|
|
126
|
+
GopherAgent.createWithServerConfig(provider, model, serverConfigJson): GopherAgent
|
|
127
|
+
|
|
128
|
+
// Create agent with config object
|
|
129
|
+
GopherAgent.create(config): GopherAgent
|
|
130
|
+
|
|
131
|
+
// Run a query
|
|
132
|
+
agent.run(query, timeoutMs?): string
|
|
133
|
+
|
|
134
|
+
// Run with detailed result
|
|
135
|
+
agent.runDetailed(query, timeoutMs?): AgentResult
|
|
136
|
+
|
|
137
|
+
// Release resources (must be called when done)
|
|
138
|
+
agent.dispose(): void
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Error Handling
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import {
|
|
145
|
+
GopherAgent,
|
|
146
|
+
AgentError,
|
|
147
|
+
ApiKeyError,
|
|
148
|
+
ConnectionError,
|
|
149
|
+
TimeoutError
|
|
150
|
+
} from '@gopher.security/gopher-mcp-js';
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
const agent = GopherAgent.createWithApiKey(provider, model, apiKey);
|
|
154
|
+
const result = agent.run('query');
|
|
155
|
+
agent.dispose();
|
|
156
|
+
} catch (e) {
|
|
157
|
+
if (e instanceof ApiKeyError) {
|
|
158
|
+
console.error('Invalid API key:', e.message);
|
|
159
|
+
} else if (e instanceof ConnectionError) {
|
|
160
|
+
console.error('Connection failed:', e.message);
|
|
161
|
+
} else if (e instanceof TimeoutError) {
|
|
162
|
+
console.error('Operation timed out:', e.message);
|
|
163
|
+
} else if (e instanceof AgentError) {
|
|
164
|
+
console.error('Agent error:', e.message);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Environment Variables
|
|
170
|
+
|
|
171
|
+
| Variable | Description |
|
|
172
|
+
|----------|-------------|
|
|
173
|
+
| `GOPHER_API_KEY` | Your Gopher API key (get one at https://gopher.security) |
|
|
174
|
+
| `ANTHROPIC_API_KEY` | Required when using AnthropicProvider |
|
|
175
|
+
| `OPENAI_API_KEY` | Required when using OpenAIProvider |
|
|
176
|
+
| `GOOGLE_API_KEY` | Required when using GoogleProvider |
|
|
177
|
+
| `AZURE_OPENAI_API_KEY` | Required when using AzureProvider |
|
|
178
|
+
| `GOPHER_DEBUG=1` | Enable debug logging |
|
|
179
|
+
|
|
180
|
+
## Platform Packages
|
|
181
|
+
|
|
182
|
+
The SDK uses platform-specific packages for native binaries:
|
|
183
|
+
|
|
184
|
+
| Platform | Package |
|
|
185
|
+
|----------|---------|
|
|
186
|
+
| macOS ARM64 | `@gopher.security/gopher-orch-darwin-arm64` |
|
|
187
|
+
| macOS x64 | `@gopher.security/gopher-orch-darwin-x64` |
|
|
188
|
+
| Linux ARM64 | `@gopher.security/gopher-orch-linux-arm64` |
|
|
189
|
+
| Linux x64 | `@gopher.security/gopher-orch-linux-x64` |
|
|
190
|
+
| Windows ARM64 | `@gopher.security/gopher-orch-win32-arm64` |
|
|
191
|
+
| Windows x64 | `@gopher.security/gopher-orch-win32-x64` |
|
|
192
|
+
|
|
193
|
+
These are installed automatically as optional dependencies.
|
|
194
|
+
|
|
195
|
+
## Requirements
|
|
196
|
+
|
|
197
|
+
- Node.js 18+
|
|
198
|
+
- Supported platforms: macOS, Linux, Windows (ARM64 or x64)
|
|
199
|
+
|
|
200
|
+
## Troubleshooting
|
|
201
|
+
|
|
202
|
+
### Native library not found
|
|
203
|
+
|
|
204
|
+
If you see "Failed to load gopher-mcp native library":
|
|
205
|
+
|
|
206
|
+
1. Ensure you're on a supported platform
|
|
207
|
+
2. Try reinstalling: `npm install @gopher.security/gopher-mcp-js --force`
|
|
208
|
+
3. Enable debug logging: `GOPHER_DEBUG=1 node your-app.js`
|
|
209
|
+
|
|
210
|
+
### Permission errors on macOS
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
xattr -d com.apple.quarantine node_modules/@gopher.security/gopher-orch-darwin-*/lib/*.dylib
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Links
|
|
217
|
+
|
|
218
|
+
- [GitHub Repository](https://github.com/GopherSecurity/gopher-mcp-js)
|
|
219
|
+
- [Gopher Security](https://gopher.security)
|
|
220
|
+
- [MCP Protocol Specification](https://modelcontextprotocol.io)
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
Apache License 2.0 - See [LICENSE](LICENSE) for details.
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GopherAgent - Main entry point for the gopher-orch TypeScript SDK.
|
|
3
|
+
*
|
|
4
|
+
* Provides a clean, TypeScript-friendly interface to the gopher-orch agent functionality.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // Create an agent with API key
|
|
9
|
+
* const agent = GopherAgent.create(
|
|
10
|
+
* GopherAgentConfig.builder()
|
|
11
|
+
* .provider('AnthropicProvider')
|
|
12
|
+
* .model('claude-3-haiku-20240307')
|
|
13
|
+
* .apiKey('your-api-key')
|
|
14
|
+
* .build()
|
|
15
|
+
* );
|
|
16
|
+
*
|
|
17
|
+
* // Run a query
|
|
18
|
+
* const answer = agent.run('What time is it in Tokyo?');
|
|
19
|
+
* console.log(answer);
|
|
20
|
+
*
|
|
21
|
+
* // Cleanup
|
|
22
|
+
* agent.dispose();
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* // Use try-finally for automatic cleanup
|
|
28
|
+
* const agent = GopherAgent.create(config);
|
|
29
|
+
* try {
|
|
30
|
+
* const answer = agent.run('What time is it in Tokyo?');
|
|
31
|
+
* console.log(answer);
|
|
32
|
+
* } finally {
|
|
33
|
+
* agent.dispose();
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
import { GopherAgentConfig } from './config';
|
|
38
|
+
import { AgentResult } from './result';
|
|
39
|
+
/**
|
|
40
|
+
* Main agent class for interacting with the gopher-orch native library.
|
|
41
|
+
*/
|
|
42
|
+
export declare class GopherAgent {
|
|
43
|
+
private handle;
|
|
44
|
+
private disposed;
|
|
45
|
+
private constructor();
|
|
46
|
+
/**
|
|
47
|
+
* Initialize the gopher-orch library.
|
|
48
|
+
*
|
|
49
|
+
* Must be called before creating any agents. Called automatically by create() if not already
|
|
50
|
+
* initialized.
|
|
51
|
+
*
|
|
52
|
+
* @throws {AgentError} if initialization fails
|
|
53
|
+
*/
|
|
54
|
+
static init(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Shutdown the gopher-orch library.
|
|
57
|
+
*
|
|
58
|
+
* Called automatically on process exit, but can be called manually.
|
|
59
|
+
*/
|
|
60
|
+
static shutdown(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Check if the library is initialized.
|
|
63
|
+
*/
|
|
64
|
+
static isInitialized(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Create a new GopherAgent instance.
|
|
67
|
+
*
|
|
68
|
+
* @param config Agent configuration
|
|
69
|
+
* @returns GopherAgent instance
|
|
70
|
+
* @throws {AgentError} if agent creation fails
|
|
71
|
+
*/
|
|
72
|
+
static create(config: GopherAgentConfig): GopherAgent;
|
|
73
|
+
/**
|
|
74
|
+
* Create a new GopherAgent with API key.
|
|
75
|
+
*
|
|
76
|
+
* @param provider Provider name (e.g., "AnthropicProvider")
|
|
77
|
+
* @param model Model name (e.g., "claude-3-haiku-20240307")
|
|
78
|
+
* @param apiKey API key for fetching remote server config
|
|
79
|
+
* @returns GopherAgent instance
|
|
80
|
+
*/
|
|
81
|
+
static createWithApiKey(provider: string, model: string, apiKey: string): GopherAgent;
|
|
82
|
+
/**
|
|
83
|
+
* Create a new GopherAgent with JSON server config.
|
|
84
|
+
*
|
|
85
|
+
* @param provider Provider name (e.g., "AnthropicProvider")
|
|
86
|
+
* @param model Model name (e.g., "claude-3-haiku-20240307")
|
|
87
|
+
* @param serverConfig JSON server configuration
|
|
88
|
+
* @returns GopherAgent instance
|
|
89
|
+
*/
|
|
90
|
+
static createWithServerConfig(provider: string, model: string, serverConfig: string): GopherAgent;
|
|
91
|
+
/**
|
|
92
|
+
* Run a query against the agent.
|
|
93
|
+
*
|
|
94
|
+
* @param query The user query to process
|
|
95
|
+
* @param timeoutMs Timeout in milliseconds (default: 60000)
|
|
96
|
+
* @returns The agent's response
|
|
97
|
+
* @throws {AgentError} if the query fails
|
|
98
|
+
*/
|
|
99
|
+
run(query: string, timeoutMs?: number): string;
|
|
100
|
+
/**
|
|
101
|
+
* Run a query with detailed result information.
|
|
102
|
+
*
|
|
103
|
+
* @param query The user query to process
|
|
104
|
+
* @param timeoutMs Timeout in milliseconds (default: 60000)
|
|
105
|
+
* @returns AgentResult with response and metadata
|
|
106
|
+
*/
|
|
107
|
+
runDetailed(query: string, timeoutMs?: number): AgentResult;
|
|
108
|
+
/**
|
|
109
|
+
* Dispose of the agent and free resources.
|
|
110
|
+
*/
|
|
111
|
+
dispose(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Check if agent is disposed.
|
|
114
|
+
*/
|
|
115
|
+
isDisposed(): boolean;
|
|
116
|
+
private ensureNotDisposed;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAqB,MAAM,UAAU,CAAC;AAO1D;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO;IAIP;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,IAAI,IAAI;IAcnB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,IAAI,IAAI;IAIvB;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,OAAO;IAI/B;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW;IA0CrD;;;;;;;OAOG;IACH,MAAM,CAAC,gBAAgB,CACrB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,WAAW;IAUd;;;;;;;OAOG;IACH,MAAM,CAAC,sBAAsB,CAC3B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,GACnB,WAAW;IAUd;;;;;;;OAOG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAQ,GAAG,MAAM;IAmB7C;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAQ,GAAG,WAAW;IAiB1D;;OAEG;IACH,OAAO,IAAI,IAAI;IAYf;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB,OAAO,CAAC,iBAAiB;CAK1B"}
|