@loopstack/llm-provider-module 0.2.0
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/contracts/index.d.ts +3 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +19 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/llm-context.d.ts +7 -0
- package/dist/contracts/llm-context.d.ts.map +1 -0
- package/dist/contracts/llm-context.js +3 -0
- package/dist/contracts/llm-context.js.map +1 -0
- package/dist/contracts/llm-provider.interface.d.ts +10 -0
- package/dist/contracts/llm-provider.interface.d.ts.map +1 -0
- package/dist/contracts/llm-provider.interface.js +3 -0
- package/dist/contracts/llm-provider.interface.js.map +1 -0
- package/dist/documents/index.d.ts +2 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +18 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/llm-message.document.d.ts +50 -0
- package/dist/documents/llm-message.document.d.ts.map +1 -0
- package/dist/documents/llm-message.document.js +35 -0
- package/dist/documents/llm-message.document.js.map +1 -0
- package/dist/documents/llm-message.document.yaml +5 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/llm-provider.module.d.ts +3 -0
- package/dist/llm-provider.module.d.ts.map +1 -0
- package/dist/llm-provider.module.js +46 -0
- package/dist/llm-provider.module.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +20 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/llm-delegate.service.d.ts +12 -0
- package/dist/services/llm-delegate.service.d.ts.map +1 -0
- package/dist/services/llm-delegate.service.js +134 -0
- package/dist/services/llm-delegate.service.js.map +1 -0
- package/dist/services/llm-provider-registry.d.ts +9 -0
- package/dist/services/llm-provider-registry.d.ts.map +1 -0
- package/dist/services/llm-provider-registry.js +36 -0
- package/dist/services/llm-provider-registry.js.map +1 -0
- package/dist/services/llm-tools-helper.service.d.ts +6 -0
- package/dist/services/llm-tools-helper.service.d.ts.map +1 -0
- package/dist/services/llm-tools-helper.service.js +48 -0
- package/dist/services/llm-tools-helper.service.js.map +1 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +21 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/llm-delegate-tool-calls.tool.d.ts +55 -0
- package/dist/tools/llm-delegate-tool-calls.tool.d.ts.map +1 -0
- package/dist/tools/llm-delegate-tool-calls.tool.js +55 -0
- package/dist/tools/llm-delegate-tool-calls.tool.js.map +1 -0
- package/dist/tools/llm-generate-object.tool.d.ts +40 -0
- package/dist/tools/llm-generate-object.tool.d.ts.map +1 -0
- package/dist/tools/llm-generate-object.tool.js +81 -0
- package/dist/tools/llm-generate-object.tool.js.map +1 -0
- package/dist/tools/llm-generate-text.tool.d.ts +39 -0
- package/dist/tools/llm-generate-text.tool.d.ts.map +1 -0
- package/dist/tools/llm-generate-text.tool.js +81 -0
- package/dist/tools/llm-generate-text.tool.js.map +1 -0
- package/dist/tools/llm-update-tool-result.tool.d.ts +21 -0
- package/dist/tools/llm-update-tool-result.tool.d.ts.map +1 -0
- package/dist/tools/llm-update-tool-result.tool.js +48 -0
- package/dist/tools/llm-update-tool-result.tool.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/llm.types.d.ts +155 -0
- package/dist/types/llm.types.d.ts.map +1 -0
- package/dist/types/llm.types.js +14 -0
- package/dist/types/llm.types.js.map +1 -0
- package/dist/utils/extract-text.util.d.ts +3 -0
- package/dist/utils/extract-text.util.d.ts.map +1 -0
- package/dist/utils/extract-text.util.js +13 -0
- package/dist/utils/extract-text.util.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./llm-context"), exports);
|
|
18
|
+
__exportStar(require("./llm-provider.interface"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,2DAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-context.d.ts","sourceRoot":"","sources":["../../src/contracts/llm-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAU3E,MAAM,WAAW,UAAU;IAEzB,SAAS,EAAE,cAAc,EAAE,CAAC;IAE5B,MAAM,EAAE,iBAAiB,CAAC;IAE1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-context.js","sourceRoot":"","sources":["../../src/contracts/llm-context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LlmGenerateObjectArgs, LlmGenerateObjectResult, LlmGenerateTextArgs, LlmGenerateTextResult, LlmNormalizedMessage, LlmUsage } from '../types';
|
|
2
|
+
import type { LlmContext } from './llm-context';
|
|
3
|
+
export interface LlmProviderInterface<TProviderConfig = Record<string, unknown>> {
|
|
4
|
+
readonly providerId: string;
|
|
5
|
+
generateText(args: LlmGenerateTextArgs<TProviderConfig>, ctx: LlmContext): Promise<LlmGenerateTextResult>;
|
|
6
|
+
generateObject(args: LlmGenerateObjectArgs<TProviderConfig>, ctx: LlmContext): Promise<LlmGenerateObjectResult>;
|
|
7
|
+
extractUsage(response: unknown): LlmUsage | undefined;
|
|
8
|
+
toProviderMessage(content: LlmNormalizedMessage): unknown;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=llm-provider.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-provider.interface.d.ts","sourceRoot":"","sources":["../../src/contracts/llm-provider.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,EACT,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAYhD,MAAM,WAAW,oBAAoB,CAAC,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAE7E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAG5B,YAAY,CAAC,IAAI,EAAE,mBAAmB,CAAC,eAAe,CAAC,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAG1G,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,eAAe,CAAC,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAGhH,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IAGtD,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC;CAC3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-provider.interface.js","sourceRoot":"","sources":["../../src/contracts/llm-provider.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./llm-message.document"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { LlmContentBlock, LlmStopReason } from '../types';
|
|
3
|
+
export declare const LlmMessageDocumentContentSchema: z.ZodObject<{
|
|
4
|
+
role: z.ZodEnum<{
|
|
5
|
+
user: "user";
|
|
6
|
+
assistant: "assistant";
|
|
7
|
+
}>;
|
|
8
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
|
+
type: z.ZodLiteral<"text">;
|
|
10
|
+
text: z.ZodString;
|
|
11
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
12
|
+
type: z.ZodLiteral<"thinking">;
|
|
13
|
+
text: z.ZodString;
|
|
14
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
15
|
+
type: z.ZodLiteral<"tool_call">;
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<"server_tool_use">;
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
24
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
25
|
+
type: z.ZodLiteral<"server_tool_result">;
|
|
26
|
+
toolUseId: z.ZodString;
|
|
27
|
+
content: z.ZodUnknown;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
29
|
+
type: z.ZodLiteral<"tool_result">;
|
|
30
|
+
toolCallId: z.ZodString;
|
|
31
|
+
content: z.ZodString;
|
|
32
|
+
isError: z.ZodBoolean;
|
|
33
|
+
}, z.core.$strip>], "type">>]>;
|
|
34
|
+
id: z.ZodOptional<z.ZodString>;
|
|
35
|
+
stopReason: z.ZodOptional<z.ZodEnum<{
|
|
36
|
+
end_turn: "end_turn";
|
|
37
|
+
tool_use: "tool_use";
|
|
38
|
+
max_tokens: "max_tokens";
|
|
39
|
+
stop_sequence: "stop_sequence";
|
|
40
|
+
}>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type LlmMessageDocumentContentType = z.infer<typeof LlmMessageDocumentContentSchema>;
|
|
43
|
+
export declare class LlmMessageDocument {
|
|
44
|
+
id?: string;
|
|
45
|
+
role: 'user' | 'assistant';
|
|
46
|
+
content: string | LlmContentBlock[];
|
|
47
|
+
stopReason?: LlmStopReason;
|
|
48
|
+
}
|
|
49
|
+
export declare function renderLlmMessage(doc: LlmMessageDocument): string;
|
|
50
|
+
//# sourceMappingURL=llm-message.document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-message.document.d.ts","sourceRoot":"","sources":["../../src/documents/llm-message.document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAO/D,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA6B,CAAC;AAE1E,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAM5F,qBAIa,kBAAkB;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE,CAAC;IACpC,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B;AAMD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAMhE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LlmMessageDocument = exports.LlmMessageDocumentContentSchema = void 0;
|
|
10
|
+
exports.renderLlmMessage = renderLlmMessage;
|
|
11
|
+
const common_1 = require("@loopstack/common");
|
|
12
|
+
const types_1 = require("../types");
|
|
13
|
+
exports.LlmMessageDocumentContentSchema = types_1.LlmNormalizedMessageSchema;
|
|
14
|
+
let LlmMessageDocument = class LlmMessageDocument {
|
|
15
|
+
id;
|
|
16
|
+
role;
|
|
17
|
+
content;
|
|
18
|
+
stopReason;
|
|
19
|
+
};
|
|
20
|
+
exports.LlmMessageDocument = LlmMessageDocument;
|
|
21
|
+
exports.LlmMessageDocument = LlmMessageDocument = __decorate([
|
|
22
|
+
(0, common_1.Document)({
|
|
23
|
+
schema: exports.LlmMessageDocumentContentSchema,
|
|
24
|
+
uiConfig: __dirname + '/llm-message.document.yaml',
|
|
25
|
+
})
|
|
26
|
+
], LlmMessageDocument);
|
|
27
|
+
function renderLlmMessage(doc) {
|
|
28
|
+
if (typeof doc.content === 'string')
|
|
29
|
+
return doc.content;
|
|
30
|
+
return doc.content
|
|
31
|
+
.filter((b) => b.type === 'text')
|
|
32
|
+
.map((b) => b.text)
|
|
33
|
+
.join('\n');
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=llm-message.document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-message.document.js","sourceRoot":"","sources":["../../src/documents/llm-message.document.ts"],"names":[],"mappings":";;;;;;;;;AAgCA,4CAMC;AArCD,8CAA6C;AAE7C,oCAAsD;AAMzC,QAAA,+BAA+B,GAAG,kCAA0B,CAAC;AAYnE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,EAAE,CAAU;IACZ,IAAI,CAAuB;IAC3B,OAAO,CAA6B;IACpC,UAAU,CAAiB;CAC5B,CAAA;AALY,gDAAkB;6BAAlB,kBAAkB;IAJ9B,IAAA,iBAAQ,EAAC;QACR,MAAM,EAAE,uCAA+B;QACvC,QAAQ,EAAE,SAAS,GAAG,4BAA4B;KACnD,CAAC;GACW,kBAAkB,CAK9B;AAMD,SAAgB,gBAAgB,CAAC,GAAuB;IACtD,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC,OAAO,CAAC;IACxD,OAAO,GAAG,CAAC,OAAO;SACf,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;SAChC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAE,CAAoC,CAAC,IAAI,CAAC;SACtD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./llm-provider.module"), exports);
|
|
18
|
+
__exportStar(require("./contracts"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
20
|
+
__exportStar(require("./utils"), exports);
|
|
21
|
+
__exportStar(require("./services"), exports);
|
|
22
|
+
__exportStar(require("./tools"), exports);
|
|
23
|
+
__exportStar(require("./documents"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAwB;AACxB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-provider.module.d.ts","sourceRoot":"","sources":["../src/llm-provider.module.ts"],"names":[],"mappings":"AAUA,qBAsBa,iBAAiB;CAAG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LlmProviderModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const core_1 = require("@loopstack/core");
|
|
12
|
+
const llm_delegate_service_1 = require("./services/llm-delegate.service");
|
|
13
|
+
const llm_provider_registry_1 = require("./services/llm-provider-registry");
|
|
14
|
+
const llm_tools_helper_service_1 = require("./services/llm-tools-helper.service");
|
|
15
|
+
const llm_delegate_tool_calls_tool_1 = require("./tools/llm-delegate-tool-calls.tool");
|
|
16
|
+
const llm_generate_object_tool_1 = require("./tools/llm-generate-object.tool");
|
|
17
|
+
const llm_generate_text_tool_1 = require("./tools/llm-generate-text.tool");
|
|
18
|
+
const llm_update_tool_result_tool_1 = require("./tools/llm-update-tool-result.tool");
|
|
19
|
+
let LlmProviderModule = class LlmProviderModule {
|
|
20
|
+
};
|
|
21
|
+
exports.LlmProviderModule = LlmProviderModule;
|
|
22
|
+
exports.LlmProviderModule = LlmProviderModule = __decorate([
|
|
23
|
+
(0, common_1.Global)(),
|
|
24
|
+
(0, common_1.Module)({
|
|
25
|
+
imports: [core_1.LoopCoreModule],
|
|
26
|
+
providers: [
|
|
27
|
+
llm_provider_registry_1.LlmProviderRegistry,
|
|
28
|
+
llm_tools_helper_service_1.LlmToolsHelperService,
|
|
29
|
+
llm_delegate_service_1.LlmDelegateService,
|
|
30
|
+
llm_generate_text_tool_1.LlmGenerateTextTool,
|
|
31
|
+
llm_generate_object_tool_1.LlmGenerateObjectTool,
|
|
32
|
+
llm_delegate_tool_calls_tool_1.LlmDelegateToolCallsTool,
|
|
33
|
+
llm_update_tool_result_tool_1.LlmUpdateToolResultTool,
|
|
34
|
+
],
|
|
35
|
+
exports: [
|
|
36
|
+
llm_provider_registry_1.LlmProviderRegistry,
|
|
37
|
+
llm_tools_helper_service_1.LlmToolsHelperService,
|
|
38
|
+
llm_delegate_service_1.LlmDelegateService,
|
|
39
|
+
llm_generate_text_tool_1.LlmGenerateTextTool,
|
|
40
|
+
llm_generate_object_tool_1.LlmGenerateObjectTool,
|
|
41
|
+
llm_delegate_tool_calls_tool_1.LlmDelegateToolCallsTool,
|
|
42
|
+
llm_update_tool_result_tool_1.LlmUpdateToolResultTool,
|
|
43
|
+
],
|
|
44
|
+
})
|
|
45
|
+
], LlmProviderModule);
|
|
46
|
+
//# sourceMappingURL=llm-provider.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-provider.module.js","sourceRoot":"","sources":["../src/llm-provider.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,0CAAiD;AACjD,0EAAqE;AACrE,4EAAuE;AACvE,kFAA4E;AAC5E,uFAAgF;AAChF,+EAAyE;AACzE,2EAAqE;AACrE,qFAA8E;AAwBvE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,8CAAiB;4BAAjB,iBAAiB;IAtB7B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,qBAAc,CAAC;QACzB,SAAS,EAAE;YACT,2CAAmB;YACnB,gDAAqB;YACrB,yCAAkB;YAClB,4CAAmB;YACnB,gDAAqB;YACrB,uDAAwB;YACxB,qDAAuB;SACxB;QACD,OAAO,EAAE;YACP,2CAAmB;YACnB,gDAAqB;YACrB,yCAAkB;YAClB,4CAAmB;YACnB,gDAAqB;YACrB,uDAAwB;YACxB,qDAAuB;SACxB;KACF,CAAC;GACW,iBAAiB,CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./llm-provider-registry"), exports);
|
|
18
|
+
__exportStar(require("./llm-tools-helper.service"), exports);
|
|
19
|
+
__exportStar(require("./llm-delegate.service"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,6DAA2C;AAC3C,yDAAuC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ToolCallOptions, ToolResult, WorkflowInterface } from '@loopstack/common';
|
|
2
|
+
import type { LlmDelegateResult, LlmToolCall } from '../types';
|
|
3
|
+
export declare class LlmDelegateService {
|
|
4
|
+
private readonly logger;
|
|
5
|
+
delegateToolCalls(toolCalls: LlmToolCall[], parent: WorkflowInterface, workspace?: object, callback?: {
|
|
6
|
+
transition: string;
|
|
7
|
+
}): Promise<LlmDelegateResult>;
|
|
8
|
+
updateToolResult(delegateResult: LlmDelegateResult, completedTool: unknown, parent: WorkflowInterface, workspace?: object): Promise<LlmDelegateResult>;
|
|
9
|
+
executeTool(toolCall: LlmToolCall, parent: WorkflowInterface, workspace?: object, options?: ToolCallOptions): Promise<ToolResult>;
|
|
10
|
+
handleToolCompletion(toolName: string, completedToolRecord: Record<string, unknown>, parent: WorkflowInterface, workspace?: object): Promise<ToolResult>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=llm-delegate.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-delegate.service.d.ts","sourceRoot":"","sources":["../../src/services/llm-delegate.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,eAAe,EAAE,UAAU,EAAE,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAC/G,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAyC,MAAM,UAAU,CAAC;AAStG,qBACa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAMxD,iBAAiB,CACrB,SAAS,EAAE,WAAW,EAAE,EACxB,MAAM,EAAE,iBAAiB,EACzB,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAChC,OAAO,CAAC,iBAAiB,CAAC;IAmDvB,gBAAgB,CACpB,cAAc,EAAE,iBAAiB,EACjC,aAAa,EAAE,OAAO,EACtB,MAAM,EAAE,iBAAiB,EACzB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC;IAgDvB,WAAW,CACf,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,iBAAiB,EACzB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,UAAU,CAAC;IAkBhB,oBAAoB,CACxB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5C,MAAM,EAAE,iBAAiB,EACzB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC;CA6BvB"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var LlmDelegateService_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.LlmDelegateService = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const common_2 = require("@loopstack/common");
|
|
13
|
+
let LlmDelegateService = LlmDelegateService_1 = class LlmDelegateService {
|
|
14
|
+
logger = new common_1.Logger(LlmDelegateService_1.name);
|
|
15
|
+
async delegateToolCalls(toolCalls, parent, workspace, callback) {
|
|
16
|
+
if (toolCalls.length === 0) {
|
|
17
|
+
return { allCompleted: true, toolResults: [], pendingCount: 0, errorCount: 0, hasErrors: false, errors: [] };
|
|
18
|
+
}
|
|
19
|
+
const results = await Promise.all(toolCalls.map((toolCall) => {
|
|
20
|
+
const toolCallback = callback
|
|
21
|
+
? { transition: callback.transition, metadata: { toolUseId: toolCall.id, toolName: toolCall.name } }
|
|
22
|
+
: undefined;
|
|
23
|
+
return this.executeTool(toolCall, parent, workspace, toolCallback ? { callback: toolCallback } : undefined);
|
|
24
|
+
}));
|
|
25
|
+
let pendingCount = 0;
|
|
26
|
+
const toolResults = [];
|
|
27
|
+
const errors = [];
|
|
28
|
+
for (let i = 0; i < toolCalls.length; i++) {
|
|
29
|
+
const tc = toolCalls[i];
|
|
30
|
+
const result = results[i];
|
|
31
|
+
if (result.pending) {
|
|
32
|
+
pendingCount++;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const isError = !!result.error;
|
|
36
|
+
toolResults.push({
|
|
37
|
+
type: 'tool_result',
|
|
38
|
+
toolCallId: tc.id,
|
|
39
|
+
content: result.data ? JSON.stringify(result.data, null, 2) : '',
|
|
40
|
+
isError,
|
|
41
|
+
});
|
|
42
|
+
if (isError) {
|
|
43
|
+
errors.push({ toolName: tc.name, toolCallId: tc.id, message: result.error });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
allCompleted: pendingCount === 0,
|
|
49
|
+
toolResults,
|
|
50
|
+
pendingCount,
|
|
51
|
+
errorCount: errors.length,
|
|
52
|
+
hasErrors: errors.length > 0,
|
|
53
|
+
errors,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async updateToolResult(delegateResult, completedTool, parent, workspace) {
|
|
57
|
+
const completedToolRecord = completedTool;
|
|
58
|
+
const subscriberMetadata = completedToolRecord._subscriberMetadata;
|
|
59
|
+
if (!subscriberMetadata?.toolUseId || !subscriberMetadata?.toolName) {
|
|
60
|
+
throw new Error('Callback payload is missing _subscriberMetadata with toolUseId and toolName. ' +
|
|
61
|
+
'Ensure the event subscriber was registered with metadata by delegateToolCalls.');
|
|
62
|
+
}
|
|
63
|
+
const { toolUseId, toolName } = subscriberMetadata;
|
|
64
|
+
const toolResult = await this.handleToolCompletion(toolName, completedToolRecord, parent, workspace);
|
|
65
|
+
const isError = !!toolResult.error;
|
|
66
|
+
const completedEntry = {
|
|
67
|
+
type: 'tool_result',
|
|
68
|
+
toolCallId: toolUseId,
|
|
69
|
+
content: toolResult.data ? JSON.stringify(toolResult.data, null, 2) : '',
|
|
70
|
+
isError,
|
|
71
|
+
};
|
|
72
|
+
const updatedResults = [...delegateResult.toolResults, completedEntry];
|
|
73
|
+
const pendingCount = delegateResult.pendingCount - 1;
|
|
74
|
+
const allCompleted = pendingCount === 0;
|
|
75
|
+
const previousErrors = delegateResult.errors;
|
|
76
|
+
const errors = isError
|
|
77
|
+
? [...previousErrors, { toolName, toolCallId: toolUseId, message: toolResult.error }]
|
|
78
|
+
: previousErrors;
|
|
79
|
+
return {
|
|
80
|
+
...delegateResult,
|
|
81
|
+
toolResults: updatedResults,
|
|
82
|
+
allCompleted,
|
|
83
|
+
pendingCount,
|
|
84
|
+
errorCount: errors.length,
|
|
85
|
+
hasErrors: errors.length > 0,
|
|
86
|
+
errors,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async executeTool(toolCall, parent, workspace, options) {
|
|
90
|
+
try {
|
|
91
|
+
const tool = (0, common_2.resolveBlockTool)(parent, toolCall.name, workspace);
|
|
92
|
+
if (!tool) {
|
|
93
|
+
throw new Error(`Tool with name ${toolCall.name} not found.`);
|
|
94
|
+
}
|
|
95
|
+
return await tool.call(toolCall.args, options);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
99
|
+
this.logger.error(`Tool "${toolCall.name}" failed: ${errorMessage}`);
|
|
100
|
+
return { data: errorMessage, error: errorMessage };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async handleToolCompletion(toolName, completedToolRecord, parent, workspace) {
|
|
104
|
+
const tool = (0, common_2.resolveBlockTool)(parent, toolName, workspace);
|
|
105
|
+
if (!tool) {
|
|
106
|
+
throw new Error(`Tool with name ${toolName} not found.`);
|
|
107
|
+
}
|
|
108
|
+
const callbackStatus = completedToolRecord.status;
|
|
109
|
+
const subWorkflowFailed = callbackStatus === 'failed' || callbackStatus === 'canceled';
|
|
110
|
+
let toolResult;
|
|
111
|
+
try {
|
|
112
|
+
toolResult = await tool.complete(completedToolRecord);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
116
|
+
this.logger.error(`Tool "${toolName}" complete() failed: ${errorMessage}`);
|
|
117
|
+
toolResult = { data: errorMessage, error: errorMessage };
|
|
118
|
+
}
|
|
119
|
+
if (subWorkflowFailed && !toolResult.error) {
|
|
120
|
+
const errorMessage = `Sub-workflow "${toolName}" ${callbackStatus}.`;
|
|
121
|
+
this.logger.error(errorMessage);
|
|
122
|
+
toolResult = {
|
|
123
|
+
data: toolResult.data ?? errorMessage,
|
|
124
|
+
error: errorMessage,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return toolResult;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
exports.LlmDelegateService = LlmDelegateService;
|
|
131
|
+
exports.LlmDelegateService = LlmDelegateService = LlmDelegateService_1 = __decorate([
|
|
132
|
+
(0, common_1.Injectable)()
|
|
133
|
+
], LlmDelegateService);
|
|
134
|
+
//# sourceMappingURL=llm-delegate.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-delegate.service.js","sourceRoot":"","sources":["../../src/services/llm-delegate.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,8CAA+G;AAWxG,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,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,QAAQ,wBAAwB,YAAY,EAAE,CAAC,CAAC;YAC3E,UAAU,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QAC3D,CAAC;QAED,IAAI,iBAAiB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YAC3C,MAAM,YAAY,GAAG,iBAAiB,QAAQ,KAAK,cAAc,GAAG,CAAC;YACrE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAChC,UAAU,GAAG;gBACX,IAAI,EAAG,UAAU,CAAC,IAAe,IAAI,YAAY;gBACjD,KAAK,EAAE,YAAY;aACpB,CAAC;QACJ,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF,CAAA;AA7KY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CA6K9B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LlmProviderInterface } from '../contracts';
|
|
2
|
+
export declare class LlmProviderRegistry {
|
|
3
|
+
private readonly providers;
|
|
4
|
+
register(provider: LlmProviderInterface): void;
|
|
5
|
+
get(providerId: string): LlmProviderInterface;
|
|
6
|
+
has(providerId: string): boolean;
|
|
7
|
+
getProviderIds(): string[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=llm-provider-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-provider-registry.d.ts","sourceRoot":"","sources":["../../src/services/llm-provider-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEzD,qBACa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2C;IAErE,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI;IAI9C,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB;IAY7C,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIhC,cAAc,IAAI,MAAM,EAAE;CAG3B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LlmProviderRegistry = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
let LlmProviderRegistry = class LlmProviderRegistry {
|
|
12
|
+
providers = new Map();
|
|
13
|
+
register(provider) {
|
|
14
|
+
this.providers.set(provider.providerId, provider);
|
|
15
|
+
}
|
|
16
|
+
get(providerId) {
|
|
17
|
+
const provider = this.providers.get(providerId);
|
|
18
|
+
if (!provider) {
|
|
19
|
+
throw new Error(`LLM provider "${providerId}" is not registered. ` +
|
|
20
|
+
`Available providers: ${[...this.providers.keys()].join(', ') || 'none'}. ` +
|
|
21
|
+
`Make sure to import the provider module (e.g. ClaudeModule) in your NestJS module.`);
|
|
22
|
+
}
|
|
23
|
+
return provider;
|
|
24
|
+
}
|
|
25
|
+
has(providerId) {
|
|
26
|
+
return this.providers.has(providerId);
|
|
27
|
+
}
|
|
28
|
+
getProviderIds() {
|
|
29
|
+
return [...this.providers.keys()];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.LlmProviderRegistry = LlmProviderRegistry;
|
|
33
|
+
exports.LlmProviderRegistry = LlmProviderRegistry = __decorate([
|
|
34
|
+
(0, common_1.Injectable)()
|
|
35
|
+
], LlmProviderRegistry);
|
|
36
|
+
//# sourceMappingURL=llm-provider-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-provider-registry.js","sourceRoot":"","sources":["../../src/services/llm-provider-registry.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAIrC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACb,SAAS,GAAG,IAAI,GAAG,EAAgC,CAAC;IAErE,QAAQ,CAAC,QAA8B;QACrC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,GAAG,CAAC,UAAkB;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACb,iBAAiB,UAAU,uBAAuB;gBAChD,wBAAwB,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,IAAI;gBAC3E,oFAAoF,CACvF,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,GAAG,CAAC,UAAkB;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,cAAc;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AA1BY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;GACA,mBAAmB,CA0B/B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WorkflowInterface } from '@loopstack/common';
|
|
2
|
+
import type { LlmResolvedTool } from '../types';
|
|
3
|
+
export declare class LlmToolsHelperService {
|
|
4
|
+
getTools(tools: string[], parent: WorkflowInterface, workspace?: object): LlmResolvedTool[];
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=llm-tools-helper.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-tools-helper.service.d.ts","sourceRoot":"","sources":["../../src/services/llm-tools-helper.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,iBAAiB,EAMlB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAahD,qBACa,qBAAqB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE;CAoC5F"}
|