@bedrockio/ai 0.8.0 → 0.8.2
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/CHANGELOG.md +8 -0
- package/dist/cjs/BaseClient.js +14 -6
- package/dist/cjs/McpServer.js +3 -3
- package/dist/cjs/anthropic.js +1 -1
- package/dist/cjs/openai.js +1 -1
- package/dist/esm/BaseClient.js +14 -6
- package/dist/esm/McpServer.js +3 -3
- package/dist/esm/anthropic.js +1 -1
- package/dist/esm/openai.js +1 -1
- package/package.json +1 -1
- package/types/BaseClient.d.ts +3 -6
- package/types/BaseClient.d.ts.map +1 -1
- package/types/McpServer.d.ts +2 -2
package/CHANGELOG.md
CHANGED
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -155,18 +155,21 @@ class BaseClient {
|
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
normalizeInputs(options) {
|
|
158
|
-
|
|
159
|
-
let { system,
|
|
158
|
+
options = this.normalizeTemplateOptions(options);
|
|
159
|
+
let { system, output = 'text' } = options;
|
|
160
160
|
if (output === 'json') {
|
|
161
161
|
system = [system, 'Output only valid JSON.'].join('\n\n');
|
|
162
162
|
}
|
|
163
163
|
return {
|
|
164
164
|
system,
|
|
165
|
-
messages:
|
|
165
|
+
messages: this.normalizeMessages(options),
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
normalizeTemplateOptions(options) {
|
|
169
169
|
const { template, params } = options;
|
|
170
|
+
if (!template) {
|
|
171
|
+
return options;
|
|
172
|
+
}
|
|
170
173
|
const { sections } = this.renderer.run({
|
|
171
174
|
params,
|
|
172
175
|
template,
|
|
@@ -191,12 +194,17 @@ class BaseClient {
|
|
|
191
194
|
}
|
|
192
195
|
system = system.trim();
|
|
193
196
|
return {
|
|
197
|
+
...options,
|
|
194
198
|
system,
|
|
195
199
|
messages,
|
|
196
200
|
};
|
|
197
201
|
}
|
|
198
|
-
|
|
199
|
-
|
|
202
|
+
normalizeMessages(options) {
|
|
203
|
+
let input = options.input || options.messages;
|
|
204
|
+
// Empty array is equivalent to no input.
|
|
205
|
+
if (Array.isArray(input) && !input.length) {
|
|
206
|
+
input = '';
|
|
207
|
+
}
|
|
200
208
|
if (Array.isArray(input)) {
|
|
201
209
|
return input;
|
|
202
210
|
}
|
package/dist/cjs/McpServer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const MIN_SUPPORTED_VERSION = '2025-03-26';
|
|
4
4
|
const ERROR_INVALID_SESSION = -32000;
|
|
5
5
|
const ERROR_UNAUTHORIZED = -32001;
|
|
6
6
|
const ERROR_METHOD_NOT_FOUND = -32601;
|
|
@@ -158,7 +158,7 @@ class McpServer {
|
|
|
158
158
|
message: 'Unsupported protocol version',
|
|
159
159
|
data: {
|
|
160
160
|
requested: request.params.protocolVersion,
|
|
161
|
-
|
|
161
|
+
minimum: MIN_SUPPORTED_VERSION,
|
|
162
162
|
},
|
|
163
163
|
},
|
|
164
164
|
};
|
|
@@ -199,7 +199,7 @@ class McpServer {
|
|
|
199
199
|
}
|
|
200
200
|
// Version helpers
|
|
201
201
|
isSupportedVersion(version) {
|
|
202
|
-
return
|
|
202
|
+
return version >= MIN_SUPPORTED_VERSION;
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
exports.default = McpServer;
|
package/dist/cjs/anthropic.js
CHANGED
|
@@ -22,7 +22,7 @@ class AnthropicClient extends BaseClient_js_1.default {
|
|
|
22
22
|
return data.map((o) => o.id);
|
|
23
23
|
}
|
|
24
24
|
async runPrompt(options) {
|
|
25
|
-
const { model,
|
|
25
|
+
const { model, messages, temperature, system = '', stream = false, tokens = DEFAULT_TOKENS, } = options;
|
|
26
26
|
const params = {
|
|
27
27
|
model,
|
|
28
28
|
stream,
|
package/dist/cjs/openai.js
CHANGED
|
@@ -43,7 +43,7 @@ class OpenAiClient extends BaseClient_js_1.default {
|
|
|
43
43
|
return names;
|
|
44
44
|
}
|
|
45
45
|
async runPrompt(options) {
|
|
46
|
-
const { model, tools, verbosity, temperature, prevResponseId, messages: input, system: instructions, tool_choice = 'auto', stream = false, } = options;
|
|
46
|
+
const { model, tools, verbosity, temperature, prevResponseId, messages: input, system: instructions = '', tool_choice = 'auto', stream = false, } = options;
|
|
47
47
|
const params = {
|
|
48
48
|
model,
|
|
49
49
|
tools,
|
package/dist/esm/BaseClient.js
CHANGED
|
@@ -153,18 +153,21 @@ export default class BaseClient {
|
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
normalizeInputs(options) {
|
|
156
|
-
|
|
157
|
-
let { system,
|
|
156
|
+
options = this.normalizeTemplateOptions(options);
|
|
157
|
+
let { system, output = 'text' } = options;
|
|
158
158
|
if (output === 'json') {
|
|
159
159
|
system = [system, 'Output only valid JSON.'].join('\n\n');
|
|
160
160
|
}
|
|
161
161
|
return {
|
|
162
162
|
system,
|
|
163
|
-
messages:
|
|
163
|
+
messages: this.normalizeMessages(options),
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
normalizeTemplateOptions(options) {
|
|
167
167
|
const { template, params } = options;
|
|
168
|
+
if (!template) {
|
|
169
|
+
return options;
|
|
170
|
+
}
|
|
168
171
|
const { sections } = this.renderer.run({
|
|
169
172
|
params,
|
|
170
173
|
template,
|
|
@@ -189,12 +192,17 @@ export default class BaseClient {
|
|
|
189
192
|
}
|
|
190
193
|
system = system.trim();
|
|
191
194
|
return {
|
|
195
|
+
...options,
|
|
192
196
|
system,
|
|
193
197
|
messages,
|
|
194
198
|
};
|
|
195
199
|
}
|
|
196
|
-
|
|
197
|
-
|
|
200
|
+
normalizeMessages(options) {
|
|
201
|
+
let input = options.input || options.messages;
|
|
202
|
+
// Empty array is equivalent to no input.
|
|
203
|
+
if (Array.isArray(input) && !input.length) {
|
|
204
|
+
input = '';
|
|
205
|
+
}
|
|
198
206
|
if (Array.isArray(input)) {
|
|
199
207
|
return input;
|
|
200
208
|
}
|
package/dist/esm/McpServer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const MIN_SUPPORTED_VERSION = '2025-03-26';
|
|
2
2
|
const ERROR_INVALID_SESSION = -32000;
|
|
3
3
|
const ERROR_UNAUTHORIZED = -32001;
|
|
4
4
|
const ERROR_METHOD_NOT_FOUND = -32601;
|
|
@@ -156,7 +156,7 @@ export default class McpServer {
|
|
|
156
156
|
message: 'Unsupported protocol version',
|
|
157
157
|
data: {
|
|
158
158
|
requested: request.params.protocolVersion,
|
|
159
|
-
|
|
159
|
+
minimum: MIN_SUPPORTED_VERSION,
|
|
160
160
|
},
|
|
161
161
|
},
|
|
162
162
|
};
|
|
@@ -197,7 +197,7 @@ export default class McpServer {
|
|
|
197
197
|
}
|
|
198
198
|
// Version helpers
|
|
199
199
|
isSupportedVersion(version) {
|
|
200
|
-
return
|
|
200
|
+
return version >= MIN_SUPPORTED_VERSION;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
class InvalidRequestError extends Error {
|
package/dist/esm/anthropic.js
CHANGED
|
@@ -16,7 +16,7 @@ export class AnthropicClient extends BaseClient {
|
|
|
16
16
|
return data.map((o) => o.id);
|
|
17
17
|
}
|
|
18
18
|
async runPrompt(options) {
|
|
19
|
-
const { model,
|
|
19
|
+
const { model, messages, temperature, system = '', stream = false, tokens = DEFAULT_TOKENS, } = options;
|
|
20
20
|
const params = {
|
|
21
21
|
model,
|
|
22
22
|
stream,
|
package/dist/esm/openai.js
CHANGED
|
@@ -37,7 +37,7 @@ export class OpenAiClient extends BaseClient {
|
|
|
37
37
|
return names;
|
|
38
38
|
}
|
|
39
39
|
async runPrompt(options) {
|
|
40
|
-
const { model, tools, verbosity, temperature, prevResponseId, messages: input, system: instructions, tool_choice = 'auto', stream = false, } = options;
|
|
40
|
+
const { model, tools, verbosity, temperature, prevResponseId, messages: input, system: instructions = '', tool_choice = 'auto', stream = false, } = options;
|
|
41
41
|
const params = {
|
|
42
42
|
model,
|
|
43
43
|
tools,
|
package/package.json
CHANGED
package/types/BaseClient.d.ts
CHANGED
|
@@ -42,14 +42,11 @@ export default class BaseClient {
|
|
|
42
42
|
*/
|
|
43
43
|
normalizeOptions(options: any): any;
|
|
44
44
|
normalizeInputs(options: any): {
|
|
45
|
-
system:
|
|
45
|
+
system: any;
|
|
46
46
|
messages: any[];
|
|
47
47
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
messages: any[];
|
|
51
|
-
};
|
|
52
|
-
normalizeOptionsMessages(options: any): any[];
|
|
48
|
+
normalizeTemplateOptions(options: any): any;
|
|
49
|
+
normalizeMessages(options: any): any[];
|
|
53
50
|
normalizeSchema(options: any): {
|
|
54
51
|
schema: any;
|
|
55
52
|
hasWrappedSchema: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../src/BaseClient.js"],"names":[],"mappings":"AAKA;IACE,0BASC;IARC,aAIC;IACD,2BAEE;IAKJ;;;;;OAKG;IACH,gBAFW,aAAa,gBAgCvB;IAED;;;;;OAKG;IACH,gBAHW,aAAa,GAAG,aAAa,gCAsDvC;IAED;;;;OAIG;IACH,wBAFW,MAAM,OAIhB;IAID,8BAGC;IAED,8BAGC;IAED,qCAGC;IAED;;OAEG;IACH,0CAGC;IAED;;OAEG;IACH,oDAIC;IAED;;OAEG;IACH,oDAIC;IAID;;OAEG;IACH,oCAOC;IAED;;;MAaC;IAED
|
|
1
|
+
{"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../src/BaseClient.js"],"names":[],"mappings":"AAKA;IACE,0BASC;IARC,aAIC;IACD,2BAEE;IAKJ;;;;;OAKG;IACH,gBAFW,aAAa,gBAgCvB;IAED;;;;;OAKG;IACH,gBAHW,aAAa,GAAG,aAAa,gCAsDvC;IAED;;;;OAIG;IACH,wBAFW,MAAM,OAIhB;IAID,8BAGC;IAED,8BAGC;IAED,qCAGC;IAED;;OAEG;IACH,0CAGC;IAED;;OAEG;IACH,oDAIC;IAED;;OAEG;IACH,oDAIC;IAID;;OAEG;IACH,oCAOC;IAED;;;MAaC;IAED,4CAwCC;IAED,uCAkBC;IAED;;;MA4BC;IAED,uDAWC;IAED,kDAMC;CACF;;;;;WAIa,MAAM,GAAC,aAAa,EAAE;;;;YACtB,MAAM;;;;YACN,OAAO;;;;;;;;aAEP,MAAM,GAAG,MAAM;;;;;;;;;;;sBAOf,MAAM;;;UAKN,QAAQ,GAAG,MAAM,GAAG,WAAW;aAC/B,MAAM;;iCA1Ua,sBAAsB"}
|
package/types/McpServer.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export default class McpServer {
|
|
|
23
23
|
message: string;
|
|
24
24
|
data: {
|
|
25
25
|
requested: any;
|
|
26
|
-
|
|
26
|
+
minimum: string;
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
} | {
|
|
@@ -85,7 +85,7 @@ export default class McpServer {
|
|
|
85
85
|
message: string;
|
|
86
86
|
data: {
|
|
87
87
|
requested: any;
|
|
88
|
-
|
|
88
|
+
minimum: string;
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
91
|
};
|