careervivid 1.12.7 → 1.12.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/providers/AnthropicProvider.d.ts +1 -0
- package/dist/agent/providers/AnthropicProvider.d.ts.map +1 -1
- package/dist/agent/providers/AnthropicProvider.js +30 -1
- package/dist/agent/providers/OpenAIProvider.d.ts +1 -0
- package/dist/agent/providers/OpenAIProvider.d.ts.map +1 -1
- package/dist/agent/providers/OpenAIProvider.js +43 -1
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ export interface AnthropicProviderOptions {
|
|
|
14
14
|
export declare class AnthropicProvider implements LLMProvider {
|
|
15
15
|
private apiKey;
|
|
16
16
|
constructor(options: AnthropicProviderOptions);
|
|
17
|
+
private geminiSchemaToJsonSchema;
|
|
17
18
|
private toAnthropicTools;
|
|
18
19
|
private toAnthropicMessages;
|
|
19
20
|
generate(request: LLMRequest): Promise<LLMResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnthropicProvider.d.ts","sourceRoot":"","sources":["../../../src/agent/providers/AnthropicProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,cAAc,EACf,MAAM,kBAAkB,CAAC;AAK1B,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,iBAAkB,YAAW,WAAW;IACnD,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,wBAAwB;IAK7C,OAAO,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"file":"AnthropicProvider.d.ts","sourceRoot":"","sources":["../../../src/agent/providers/AnthropicProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,cAAc,EACf,MAAM,kBAAkB,CAAC;AAK1B,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,iBAAkB,YAAW,WAAW;IACnD,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,wBAAwB;IAK7C,OAAO,CAAC,wBAAwB;IAwBhC,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,mBAAmB;IAgErB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;IA+DnD,cAAc,CAClB,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GACvC,OAAO,CAAC,WAAW,CAAC;CA+GxB"}
|
|
@@ -14,12 +14,41 @@ export class AnthropicProvider {
|
|
|
14
14
|
constructor(options) {
|
|
15
15
|
this.apiKey = options.apiKey;
|
|
16
16
|
}
|
|
17
|
+
// ── Convert Gemini @google/genai Type enum values to JSON Schema ──────────
|
|
18
|
+
geminiSchemaToJsonSchema(schema) {
|
|
19
|
+
if (!schema || typeof schema !== "object")
|
|
20
|
+
return schema;
|
|
21
|
+
const TYPE_MAP = {
|
|
22
|
+
OBJECT: "object", STRING: "string", NUMBER: "number",
|
|
23
|
+
INTEGER: "integer", BOOLEAN: "boolean", ARRAY: "array",
|
|
24
|
+
object: "object", string: "string", number: "number",
|
|
25
|
+
integer: "integer", boolean: "boolean", array: "array",
|
|
26
|
+
};
|
|
27
|
+
const result = {};
|
|
28
|
+
if (schema.type)
|
|
29
|
+
result.type = TYPE_MAP[schema.type] ?? schema.type.toLowerCase();
|
|
30
|
+
if (schema.description)
|
|
31
|
+
result.description = schema.description;
|
|
32
|
+
if (schema.enum)
|
|
33
|
+
result.enum = schema.enum;
|
|
34
|
+
if (schema.required)
|
|
35
|
+
result.required = schema.required;
|
|
36
|
+
if (schema.properties && typeof schema.properties === "object") {
|
|
37
|
+
result.properties = {};
|
|
38
|
+
for (const [key, val] of Object.entries(schema.properties)) {
|
|
39
|
+
result.properties[key] = this.geminiSchemaToJsonSchema(val);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (schema.items)
|
|
43
|
+
result.items = this.geminiSchemaToJsonSchema(schema.items);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
17
46
|
// ── Convert our Tool[] to Anthropic tool definitions ─────────────────────
|
|
18
47
|
toAnthropicTools(tools) {
|
|
19
48
|
return tools.map((t) => ({
|
|
20
49
|
name: t.name,
|
|
21
50
|
description: t.description,
|
|
22
|
-
input_schema: t.parameters,
|
|
51
|
+
input_schema: this.geminiSchemaToJsonSchema(t.parameters),
|
|
23
52
|
}));
|
|
24
53
|
}
|
|
25
54
|
// ── Convert Gemini Content[] to Anthropic messages[] ─────────────────────
|
|
@@ -27,6 +27,7 @@ export declare class OpenAIProvider implements LLMProvider {
|
|
|
27
27
|
private baseUrl;
|
|
28
28
|
private extraHeaders;
|
|
29
29
|
constructor(options: OpenAIProviderOptions);
|
|
30
|
+
private geminiSchemaToJsonSchema;
|
|
30
31
|
private toOpenAITools;
|
|
31
32
|
private toOpenAIMessages;
|
|
32
33
|
generate(request: LLMRequest): Promise<LLMResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAIProvider.d.ts","sourceRoot":"","sources":["../../../src/agent/providers/OpenAIProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,cAAc,EACf,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,qBAAa,cAAe,YAAW,WAAW;IAChD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAyB;gBAEjC,OAAO,EAAE,qBAAqB;
|
|
1
|
+
{"version":3,"file":"OpenAIProvider.d.ts","sourceRoot":"","sources":["../../../src/agent/providers/OpenAIProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,cAAc,EACf,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,qBAAa,cAAe,YAAW,WAAW;IAChD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAyB;gBAEjC,OAAO,EAAE,qBAAqB;IAY1C,OAAO,CAAC,wBAAwB;IA2ChC,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,gBAAgB;IAgElB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;IA2DnD,cAAc,CAClB,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GACvC,OAAO,CAAC,WAAW,CAAC;CAuGxB;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,QAAQ,GAAG,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,EACzE,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,MAAM,GACrB,cAAc,CAqBhB"}
|
|
@@ -24,6 +24,48 @@ export class OpenAIProvider {
|
|
|
24
24
|
this.baseUrl = (options.baseUrl || "https://api.openai.com/v1").replace(/\/$/, "");
|
|
25
25
|
this.extraHeaders = options.extraHeaders || {};
|
|
26
26
|
}
|
|
27
|
+
// ── Convert Gemini @google/genai Type enum values to JSON Schema ──────────
|
|
28
|
+
// Gemini uses uppercase strings like "OBJECT", "STRING", "ARRAY".
|
|
29
|
+
// OpenAI-compatible APIs (OpenRouter, OpenAI, etc.) use lowercase JSON Schema.
|
|
30
|
+
geminiSchemaToJsonSchema(schema) {
|
|
31
|
+
if (!schema || typeof schema !== "object")
|
|
32
|
+
return schema;
|
|
33
|
+
const TYPE_MAP = {
|
|
34
|
+
OBJECT: "object",
|
|
35
|
+
STRING: "string",
|
|
36
|
+
NUMBER: "number",
|
|
37
|
+
INTEGER: "integer",
|
|
38
|
+
BOOLEAN: "boolean",
|
|
39
|
+
ARRAY: "array",
|
|
40
|
+
// Already lowercase passthrough
|
|
41
|
+
object: "object",
|
|
42
|
+
string: "string",
|
|
43
|
+
number: "number",
|
|
44
|
+
integer: "integer",
|
|
45
|
+
boolean: "boolean",
|
|
46
|
+
array: "array",
|
|
47
|
+
};
|
|
48
|
+
const result = {};
|
|
49
|
+
if (schema.type) {
|
|
50
|
+
result.type = TYPE_MAP[schema.type] ?? schema.type.toLowerCase();
|
|
51
|
+
}
|
|
52
|
+
if (schema.description)
|
|
53
|
+
result.description = schema.description;
|
|
54
|
+
if (schema.enum)
|
|
55
|
+
result.enum = schema.enum;
|
|
56
|
+
if (schema.required)
|
|
57
|
+
result.required = schema.required;
|
|
58
|
+
if (schema.properties && typeof schema.properties === "object") {
|
|
59
|
+
result.properties = {};
|
|
60
|
+
for (const [key, val] of Object.entries(schema.properties)) {
|
|
61
|
+
result.properties[key] = this.geminiSchemaToJsonSchema(val);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (schema.items) {
|
|
65
|
+
result.items = this.geminiSchemaToJsonSchema(schema.items);
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
27
69
|
// ── convert our Tool[] to OpenAI function definitions ────────────────────
|
|
28
70
|
toOpenAITools(tools) {
|
|
29
71
|
return tools.map((t) => ({
|
|
@@ -31,7 +73,7 @@ export class OpenAIProvider {
|
|
|
31
73
|
function: {
|
|
32
74
|
name: t.name,
|
|
33
75
|
description: t.description,
|
|
34
|
-
parameters: t.parameters,
|
|
76
|
+
parameters: this.geminiSchemaToJsonSchema(t.parameters),
|
|
35
77
|
},
|
|
36
78
|
}));
|
|
37
79
|
}
|