quidproquo-actionprocessor-node 0.0.177 → 0.0.179
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/lib/commonjs/actionProcessor/core/claudeAi/ClaudeAiActionProcessor.d.ts +5 -0
- package/lib/commonjs/actionProcessor/core/claudeAi/ClaudeAiActionProcessor.js +58 -0
- package/lib/commonjs/actionProcessor/core/index.d.ts +1 -0
- package/lib/commonjs/actionProcessor/core/index.js +2 -1
- package/package.json +4 -3
|
@@ -0,0 +1,58 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const sdk_1 = __importStar(require("@anthropic-ai/sdk"));
|
|
36
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
37
|
+
const processMessagesApi = ({ body, apiKey }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const anthropic = new sdk_1.default({ apiKey });
|
|
39
|
+
try {
|
|
40
|
+
const msg = yield anthropic.messages.create(body);
|
|
41
|
+
return (0, quidproquo_core_1.actionResult)(msg);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.log(error);
|
|
45
|
+
if (error instanceof sdk_1.AuthenticationError) {
|
|
46
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.Unauthorized, 'Invalid API key.');
|
|
47
|
+
}
|
|
48
|
+
else if (error instanceof Error) {
|
|
49
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, error.message);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, 'An error occurred while processing your request.');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
exports.default = {
|
|
57
|
+
[quidproquo_core_1.ClaudeAiActionType.MessagesApi]: processMessagesApi,
|
|
58
|
+
};
|
|
@@ -7,5 +7,6 @@ declare const _default: {
|
|
|
7
7
|
"@quidproquo-core/Guid/New": import("quidproquo-core").GuidNewActionProcessor;
|
|
8
8
|
"@quidproquo-core/error/ThrowError": import("quidproquo-core").ErrorThrowErrorActionProcessor<any>;
|
|
9
9
|
"@quidproquo-core/Date/Now": import("quidproquo-core").DateNowActionProcessor;
|
|
10
|
+
"@quidproquo-core/ClaudeAi/MessagesApi": import("quidproquo-core").ClaudeAiMessagesApiActionProcessor;
|
|
10
11
|
};
|
|
11
12
|
export default _default;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ClaudeAiActionProcessor_1 = __importDefault(require("./claudeAi/ClaudeAiActionProcessor"));
|
|
6
7
|
const DateActionProcessor_1 = __importDefault(require("./date/DateActionProcessor"));
|
|
7
8
|
const ErrorActionProcessor_1 = __importDefault(require("./error/ErrorActionProcessor"));
|
|
8
9
|
const EventActionProcessor_1 = __importDefault(require("./event/EventActionProcessor"));
|
|
@@ -12,4 +13,4 @@ const MathActionProcessor_1 = __importDefault(require("./math/MathActionProcesso
|
|
|
12
13
|
const NetworkActionProcessor_1 = __importDefault(require("./network/NetworkActionProcessor"));
|
|
13
14
|
const PlatformActionProcessor_1 = __importDefault(require("./platform/PlatformActionProcessor"));
|
|
14
15
|
const SystemActionProcessor_1 = __importDefault(require("./system/SystemActionProcessor"));
|
|
15
|
-
exports.default = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, DateActionProcessor_1.default), ErrorActionProcessor_1.default), EventActionProcessor_1.default), GuidActionProcessor_1.default), LogActionProcessor_1.default), MathActionProcessor_1.default), NetworkActionProcessor_1.default), PlatformActionProcessor_1.default), SystemActionProcessor_1.default);
|
|
16
|
+
exports.default = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ClaudeAiActionProcessor_1.default), DateActionProcessor_1.default), ErrorActionProcessor_1.default), EventActionProcessor_1.default), GuidActionProcessor_1.default), LogActionProcessor_1.default), MathActionProcessor_1.default), NetworkActionProcessor_1.default), PlatformActionProcessor_1.default), SystemActionProcessor_1.default);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-actionprocessor-node",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.179",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"types": "./lib/commonjs/index.d.ts",
|
|
@@ -25,15 +25,16 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/joe-coady/quidproquo#readme",
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@anthropic-ai/sdk": "^0.19.1",
|
|
28
29
|
"axios": "^1.2.1",
|
|
29
30
|
"mime-types": "^2.1.35",
|
|
30
|
-
"quidproquo-core": "0.0.
|
|
31
|
+
"quidproquo-core": "0.0.179",
|
|
31
32
|
"uuid": "^9.0.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/mime-types": "^2.1.1",
|
|
35
36
|
"@types/uuid": "^9.0.0",
|
|
36
|
-
"quidproquo-tsconfig": "0.0.
|
|
37
|
+
"quidproquo-tsconfig": "0.0.179",
|
|
37
38
|
"typescript": "^4.9.3"
|
|
38
39
|
}
|
|
39
40
|
}
|