honeyhive 1.0.19 → 1.0.21
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/index.d.ts +1 -0
- package/dist/index.js +20 -0
- package/dist/internal/utils/contenttype.d.ts +1 -0
- package/dist/internal/utils/contenttype.js +33 -0
- package/dist/internal/utils/headers.d.ts +4 -0
- package/dist/internal/utils/headers.js +92 -0
- package/dist/internal/utils/index.d.ts +8 -0
- package/dist/internal/utils/index.js +27 -0
- package/dist/internal/utils/pathparams.d.ts +2 -0
- package/dist/internal/utils/pathparams.js +53 -0
- package/dist/internal/utils/queryparams.d.ts +2 -0
- package/dist/internal/utils/queryparams.js +182 -0
- package/dist/internal/utils/requestbody.d.ts +2 -0
- package/dist/internal/utils/requestbody.js +328 -0
- package/dist/internal/utils/retries.d.ts +20 -0
- package/dist/internal/utils/retries.js +250 -0
- package/dist/internal/utils/security.d.ts +5 -0
- package/dist/internal/utils/security.js +196 -0
- package/dist/internal/utils/utils.d.ts +37 -0
- package/dist/internal/utils/utils.js +368 -0
- package/dist/models/components/configuration.d.ts +44 -0
- package/dist/models/components/configuration.js +94 -0
- package/dist/models/components/createdatapointrequest.d.ts +31 -0
- package/dist/models/components/createdatapointrequest.js +75 -0
- package/dist/models/components/createdatasetrequest.d.ts +50 -0
- package/dist/models/components/createdatasetrequest.js +101 -0
- package/dist/models/components/createeventrequest.d.ts +87 -0
- package/dist/models/components/createeventrequest.js +144 -0
- package/dist/models/components/createmodelevent.d.ts +71 -0
- package/dist/models/components/createmodelevent.js +125 -0
- package/dist/models/components/createprojectrequest.d.ts +5 -0
- package/dist/models/components/createprojectrequest.js +50 -0
- package/dist/models/components/createrunrequest.d.ts +42 -0
- package/dist/models/components/createrunrequest.js +88 -0
- package/dist/models/components/createrunresponse.d.ts +6 -0
- package/dist/models/components/createrunresponse.js +52 -0
- package/dist/models/components/createtoolrequest.d.ts +18 -0
- package/dist/models/components/createtoolrequest.js +70 -0
- package/dist/models/components/datapoint.d.ts +41 -0
- package/dist/models/components/datapoint.js +118 -0
- package/dist/models/components/dataset.d.ts +58 -0
- package/dist/models/components/dataset.js +119 -0
- package/dist/models/components/datasetupdate.d.ts +27 -0
- package/dist/models/components/datasetupdate.js +70 -0
- package/dist/models/components/deleterunresponse.d.ts +5 -0
- package/dist/models/components/deleterunresponse.js +50 -0
- package/dist/models/components/evaluationrun.d.ts +50 -0
- package/dist/models/components/evaluationrun.js +116 -0
- package/dist/models/components/event.d.ts +88 -0
- package/dist/models/components/event.js +145 -0
- package/dist/models/components/eventfilter.d.ts +38 -0
- package/dist/models/components/eventfilter.js +81 -0
- package/dist/models/components/getrunresponse.d.ts +5 -0
- package/dist/models/components/getrunresponse.js +47 -0
- package/dist/models/components/getrunsresponse.d.ts +5 -0
- package/dist/models/components/getrunsresponse.js +47 -0
- package/dist/models/components/index.d.ts +31 -0
- package/dist/models/components/index.js +50 -0
- package/dist/models/components/metric.d.ts +86 -0
- package/dist/models/components/metric.js +155 -0
- package/dist/models/components/metricedit.d.ts +91 -0
- package/dist/models/components/metricedit.js +160 -0
- package/dist/models/components/postconfigurationrequest.d.ts +29 -0
- package/dist/models/components/postconfigurationrequest.js +76 -0
- package/dist/models/components/project.d.ts +6 -0
- package/dist/models/components/project.js +55 -0
- package/dist/models/components/putconfigurationrequest.d.ts +40 -0
- package/dist/models/components/putconfigurationrequest.js +89 -0
- package/dist/models/components/security.d.ts +4 -0
- package/dist/models/components/security.js +45 -0
- package/dist/models/components/sessionstartrequest.d.ts +67 -0
- package/dist/models/components/sessionstartrequest.js +120 -0
- package/dist/models/components/tool.d.ts +19 -0
- package/dist/models/components/tool.js +75 -0
- package/dist/models/components/updatedatapointrequest.d.ts +27 -0
- package/dist/models/components/updatedatapointrequest.js +70 -0
- package/dist/models/components/updateprojectrequest.d.ts +6 -0
- package/dist/models/components/updateprojectrequest.js +55 -0
- package/dist/models/components/updaterunrequest.d.ts +32 -0
- package/dist/models/components/updaterunrequest.js +80 -0
- package/dist/models/components/updaterunresponse.d.ts +11 -0
- package/dist/models/components/updaterunresponse.js +50 -0
- package/dist/models/components/updatetoolrequest.d.ts +7 -0
- package/dist/models/components/updatetoolrequest.js +60 -0
- package/dist/models/errors/createeventbatch.d.ts +14 -0
- package/dist/models/errors/createeventbatch.js +70 -0
- package/dist/models/errors/createmodeleventbatch.d.ts +14 -0
- package/dist/models/errors/createmodeleventbatch.js +70 -0
- package/dist/models/errors/index.d.ts +3 -0
- package/dist/models/errors/index.js +22 -0
- package/dist/models/errors/sdkerror.d.ts +7 -0
- package/dist/models/errors/sdkerror.js +40 -0
- package/dist/models/operations/adddatapoints.d.ts +68 -0
- package/dist/models/operations/adddatapoints.js +143 -0
- package/dist/models/operations/createconfiguration.d.ts +16 -0
- package/dist/models/operations/createconfiguration.js +51 -0
- package/dist/models/operations/createdatapoint.d.ts +29 -0
- package/dist/models/operations/createdatapoint.js +86 -0
- package/dist/models/operations/createdataset.d.ts +33 -0
- package/dist/models/operations/createdataset.js +91 -0
- package/dist/models/operations/createevent.d.ts +31 -0
- package/dist/models/operations/createevent.js +115 -0
- package/dist/models/operations/createeventbatch.d.ts +36 -0
- package/dist/models/operations/createeventbatch.js +125 -0
- package/dist/models/operations/createmetric.d.ts +16 -0
- package/dist/models/operations/createmetric.js +51 -0
- package/dist/models/operations/createmodelevent.d.ts +31 -0
- package/dist/models/operations/createmodelevent.js +115 -0
- package/dist/models/operations/createmodeleventbatch.d.ts +31 -0
- package/dist/models/operations/createmodeleventbatch.js +115 -0
- package/dist/models/operations/createproject.d.ts +21 -0
- package/dist/models/operations/createproject.js +79 -0
- package/dist/models/operations/createrun.d.ts +21 -0
- package/dist/models/operations/createrun.js +79 -0
- package/dist/models/operations/createtool.d.ts +29 -0
- package/dist/models/operations/createtool.js +86 -0
- package/dist/models/operations/deleteconfiguration.d.ts +22 -0
- package/dist/models/operations/deleteconfiguration.js +63 -0
- package/dist/models/operations/deletedatapoint.d.ts +32 -0
- package/dist/models/operations/deletedatapoint.js +84 -0
- package/dist/models/operations/deletedataset.d.ts +22 -0
- package/dist/models/operations/deletedataset.js +63 -0
- package/dist/models/operations/deletemetric.d.ts +19 -0
- package/dist/models/operations/deletemetric.js +63 -0
- package/dist/models/operations/deleteproject.d.ts +19 -0
- package/dist/models/operations/deleteproject.js +63 -0
- package/dist/models/operations/deleterun.d.ts +24 -0
- package/dist/models/operations/deleterun.js +91 -0
- package/dist/models/operations/deletetool.d.ts +19 -0
- package/dist/models/operations/deletetool.js +63 -0
- package/dist/models/operations/getconfigurations.d.ts +43 -0
- package/dist/models/operations/getconfigurations.js +108 -0
- package/dist/models/operations/getdatapoint.d.ts +33 -0
- package/dist/models/operations/getdatapoint.js +109 -0
- package/dist/models/operations/getdatapoints.d.ts +41 -0
- package/dist/models/operations/getdatapoints.js +117 -0
- package/dist/models/operations/getdatasets.d.ts +48 -0
- package/dist/models/operations/getdatasets.js +125 -0
- package/dist/models/operations/getevents.d.ts +57 -0
- package/dist/models/operations/getevents.js +155 -0
- package/dist/models/operations/getmetrics.d.ts +27 -0
- package/dist/models/operations/getmetrics.js +91 -0
- package/dist/models/operations/getprojects.d.ts +24 -0
- package/dist/models/operations/getprojects.js +91 -0
- package/dist/models/operations/getrun.d.ts +24 -0
- package/dist/models/operations/getrun.js +91 -0
- package/dist/models/operations/getruns.d.ts +24 -0
- package/dist/models/operations/getruns.js +91 -0
- package/dist/models/operations/getsession.d.ts +24 -0
- package/dist/models/operations/getsession.js +91 -0
- package/dist/models/operations/gettools.d.ts +21 -0
- package/dist/models/operations/gettools.js +79 -0
- package/dist/models/operations/index.d.ts +39 -0
- package/dist/models/operations/index.js +58 -0
- package/dist/models/operations/startsession.d.ts +30 -0
- package/dist/models/operations/startsession.js +110 -0
- package/dist/models/operations/updateconfiguration.d.ts +24 -0
- package/dist/models/operations/updateconfiguration.js +91 -0
- package/dist/models/operations/updatedatapoint.d.ts +24 -0
- package/dist/models/operations/updatedatapoint.js +91 -0
- package/dist/models/operations/updatedataset.d.ts +16 -0
- package/dist/models/operations/updatedataset.js +51 -0
- package/dist/models/operations/updateevent.d.ts +26 -0
- package/dist/models/operations/updateevent.js +100 -0
- package/dist/models/operations/updatemetric.d.ts +16 -0
- package/dist/models/operations/updatemetric.js +51 -0
- package/dist/models/operations/updateproject.d.ts +16 -0
- package/dist/models/operations/updateproject.js +51 -0
- package/dist/models/operations/updaterun.d.ts +25 -0
- package/dist/models/operations/updaterun.js +95 -0
- package/dist/models/operations/updatetool.d.ts +16 -0
- package/dist/models/operations/updatetool.js +51 -0
- package/dist/sdk/configurations.d.ts +24 -0
- package/dist/sdk/configurations.js +356 -0
- package/dist/sdk/datapoints.d.ts +28 -0
- package/dist/sdk/datapoints.js +430 -0
- package/dist/sdk/datasets.d.ts +28 -0
- package/dist/sdk/datasets.js +435 -0
- package/dist/sdk/events.d.ts +43 -0
- package/dist/sdk/events.js +567 -0
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +21 -0
- package/dist/sdk/metrics.d.ts +36 -0
- package/dist/sdk/metrics.js +366 -0
- package/dist/sdk/projects.d.ts +24 -0
- package/dist/sdk/projects.js +361 -0
- package/dist/sdk/runs.d.ts +28 -0
- package/dist/sdk/runs.js +439 -0
- package/dist/sdk/sdk.d.ts +64 -0
- package/dist/sdk/sdk.js +90 -0
- package/dist/sdk/session.d.ts +15 -0
- package/dist/sdk/session.js +237 -0
- package/dist/sdk/telemetry.d.ts +21 -0
- package/dist/sdk/telemetry.js +243 -0
- package/dist/sdk/tools.d.ts +24 -0
- package/dist/sdk/tools.js +357 -0
- package/dist/sdk/tracer.d.ts +26 -0
- package/dist/sdk/tracer.js +308 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +20 -0
- package/dist/types/rfcdate.d.ts +9 -0
- package/dist/types/rfcdate.js +59 -0
- package/funcs/runsCreateRun.d.ts.map +1 -1
- package/funcs/runsCreateRun.js +2 -1
- package/funcs/runsCreateRun.js.map +1 -1
- package/funcs/runsUpdateRun.d.ts +1 -1
- package/funcs/runsUpdateRun.d.ts.map +1 -1
- package/funcs/runsUpdateRun.js +2 -2
- package/funcs/runsUpdateRun.js.map +1 -1
- package/package.json +4 -3
- package/sdk/evaluation.d.ts +7 -1
- package/sdk/evaluation.d.ts.map +1 -1
- package/sdk/evaluation.js +52 -5
- package/sdk/evaluation.js.map +1 -1
- package/sdk/runs.d.ts +1 -1
- package/sdk/runs.d.ts.map +1 -1
- package/sdk/runs.js +2 -2
- package/sdk/runs.js.map +1 -1
- package/src/sdk/evaluation.ts +38 -8
- package/tests/openai_test.ts +72 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
|
4
|
+
*/
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
40
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
41
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
42
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
43
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
44
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
45
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
49
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
50
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
51
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
52
|
+
function step(op) {
|
|
53
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
54
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
55
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
56
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
57
|
+
switch (op[0]) {
|
|
58
|
+
case 0: case 1: t = op; break;
|
|
59
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
60
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
61
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
62
|
+
default:
|
|
63
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
64
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
65
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
66
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
67
|
+
if (t[2]) _.ops.pop();
|
|
68
|
+
_.trys.pop(); continue;
|
|
69
|
+
}
|
|
70
|
+
op = body.call(thisArg, _);
|
|
71
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
72
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
76
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
77
|
+
if (!m) return o;
|
|
78
|
+
var i = m.call(o), r, ar = [], e;
|
|
79
|
+
try {
|
|
80
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
81
|
+
}
|
|
82
|
+
catch (error) { e = { error: error }; }
|
|
83
|
+
finally {
|
|
84
|
+
try {
|
|
85
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
86
|
+
}
|
|
87
|
+
finally { if (e) throw e.error; }
|
|
88
|
+
}
|
|
89
|
+
return ar;
|
|
90
|
+
};
|
|
91
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
|
+
exports.Session = void 0;
|
|
93
|
+
var utils = __importStar(require("../internal/utils"));
|
|
94
|
+
var components = __importStar(require("../models/components"));
|
|
95
|
+
var errors = __importStar(require("../models/errors"));
|
|
96
|
+
var operations = __importStar(require("../models/operations"));
|
|
97
|
+
var Session = /** @class */ (function () {
|
|
98
|
+
function Session(sdkConfig) {
|
|
99
|
+
this.sdkConfiguration = sdkConfig;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Start a new session
|
|
103
|
+
*/
|
|
104
|
+
Session.prototype.startSession = function (req, config) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
var baseURL, operationUrl, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes;
|
|
108
|
+
var _d;
|
|
109
|
+
return __generator(this, function (_e) {
|
|
110
|
+
switch (_e.label) {
|
|
111
|
+
case 0:
|
|
112
|
+
if (!(req instanceof utils.SpeakeasyBase)) {
|
|
113
|
+
req = new operations.StartSessionRequestBody(req);
|
|
114
|
+
}
|
|
115
|
+
baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
|
|
116
|
+
operationUrl = baseURL.replace(/\/$/, "") + "/session/start";
|
|
117
|
+
_c = __read([{}, null], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
|
|
118
|
+
try {
|
|
119
|
+
_d = __read(utils.serializeRequestBody(req, "request", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
if (e instanceof Error) {
|
|
123
|
+
throw new Error("Error serializing request body, cause: ".concat(e.message));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
client = this.sdkConfiguration.defaultClient;
|
|
127
|
+
globalSecurity = this.sdkConfiguration.security;
|
|
128
|
+
if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
|
|
129
|
+
return [4 /*yield*/, globalSecurity()];
|
|
130
|
+
case 1:
|
|
131
|
+
globalSecurity = _e.sent();
|
|
132
|
+
_e.label = 2;
|
|
133
|
+
case 2:
|
|
134
|
+
if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
|
|
135
|
+
globalSecurity = new components.Security(globalSecurity);
|
|
136
|
+
}
|
|
137
|
+
properties = utils.parseSecurityProperties(globalSecurity);
|
|
138
|
+
headers = __assign(__assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers), properties.headers);
|
|
139
|
+
if (reqBody == null)
|
|
140
|
+
throw new Error("request body is required");
|
|
141
|
+
headers["Accept"] = "application/json";
|
|
142
|
+
headers["user-agent"] = this.sdkConfiguration.userAgent;
|
|
143
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
|
|
144
|
+
case 3:
|
|
145
|
+
httpRes = _e.sent();
|
|
146
|
+
responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
|
|
147
|
+
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
148
|
+
throw new Error("status code not found in response: ".concat(httpRes));
|
|
149
|
+
}
|
|
150
|
+
res = new operations.StartSessionResponse({
|
|
151
|
+
statusCode: httpRes.status,
|
|
152
|
+
contentType: responseContentType,
|
|
153
|
+
rawResponse: httpRes,
|
|
154
|
+
});
|
|
155
|
+
decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
|
|
156
|
+
switch (true) {
|
|
157
|
+
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
158
|
+
if (utils.matchContentType(responseContentType, "application/json")) {
|
|
159
|
+
res.object = utils.objectToClass(JSON.parse(decodedRes), operations.StartSessionResponseBody);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
|
|
166
|
+
((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
|
|
167
|
+
throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
|
|
168
|
+
}
|
|
169
|
+
return [2 /*return*/, res];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Retrieve a session
|
|
176
|
+
*/
|
|
177
|
+
Session.prototype.getSession = function (sessionId, config) {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
180
|
+
var req, baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes;
|
|
181
|
+
return __generator(this, function (_c) {
|
|
182
|
+
switch (_c.label) {
|
|
183
|
+
case 0:
|
|
184
|
+
req = new operations.GetSessionRequest({
|
|
185
|
+
sessionId: sessionId,
|
|
186
|
+
});
|
|
187
|
+
baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
|
|
188
|
+
operationUrl = utils.generateURL(baseURL, "/session/{session_id}", req);
|
|
189
|
+
client = this.sdkConfiguration.defaultClient;
|
|
190
|
+
globalSecurity = this.sdkConfiguration.security;
|
|
191
|
+
if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
|
|
192
|
+
return [4 /*yield*/, globalSecurity()];
|
|
193
|
+
case 1:
|
|
194
|
+
globalSecurity = _c.sent();
|
|
195
|
+
_c.label = 2;
|
|
196
|
+
case 2:
|
|
197
|
+
if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
|
|
198
|
+
globalSecurity = new components.Security(globalSecurity);
|
|
199
|
+
}
|
|
200
|
+
properties = utils.parseSecurityProperties(globalSecurity);
|
|
201
|
+
headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
|
|
202
|
+
headers["Accept"] = "application/json";
|
|
203
|
+
headers["user-agent"] = this.sdkConfiguration.userAgent;
|
|
204
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
|
|
205
|
+
case 3:
|
|
206
|
+
httpRes = _c.sent();
|
|
207
|
+
responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
|
|
208
|
+
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
209
|
+
throw new Error("status code not found in response: ".concat(httpRes));
|
|
210
|
+
}
|
|
211
|
+
res = new operations.GetSessionResponse({
|
|
212
|
+
statusCode: httpRes.status,
|
|
213
|
+
contentType: responseContentType,
|
|
214
|
+
rawResponse: httpRes,
|
|
215
|
+
});
|
|
216
|
+
decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
|
|
217
|
+
switch (true) {
|
|
218
|
+
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
219
|
+
if (utils.matchContentType(responseContentType, "application/json")) {
|
|
220
|
+
res.event = utils.objectToClass(JSON.parse(decodedRes), components.Event);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
|
|
227
|
+
((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
|
|
228
|
+
throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
|
|
229
|
+
}
|
|
230
|
+
return [2 /*return*/, res];
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
return Session;
|
|
236
|
+
}());
|
|
237
|
+
exports.Session = Session;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class Telemetry {
|
|
2
|
+
private static instance;
|
|
3
|
+
private static readonly ANON_ID_PATH;
|
|
4
|
+
private static readonly UNKNOWN_ANON_ID;
|
|
5
|
+
private telemetryEnabled;
|
|
6
|
+
private posthog;
|
|
7
|
+
private anonId;
|
|
8
|
+
static getInstance(): Telemetry;
|
|
9
|
+
private constructor();
|
|
10
|
+
private getAnonId;
|
|
11
|
+
private getHoneyhiveVersion;
|
|
12
|
+
private getContext;
|
|
13
|
+
private getRuntimeInfo;
|
|
14
|
+
private getUserAgent;
|
|
15
|
+
private getServiceProviderInfo;
|
|
16
|
+
private getNotebookInfo;
|
|
17
|
+
private getExecutionInfo;
|
|
18
|
+
private getExecutionMethod;
|
|
19
|
+
capture(event: string, properties?: Record<string, any>): Promise<void>;
|
|
20
|
+
logException(error: Error): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.Telemetry = void 0;
|
|
74
|
+
var os = __importStar(require("os"));
|
|
75
|
+
var fs = __importStar(require("fs"));
|
|
76
|
+
var path = __importStar(require("path"));
|
|
77
|
+
var uuid_1 = require("uuid");
|
|
78
|
+
var posthog_node_1 = require("posthog-node");
|
|
79
|
+
var process = __importStar(require("process"));
|
|
80
|
+
var Telemetry = /** @class */ (function () {
|
|
81
|
+
function Telemetry() {
|
|
82
|
+
this.telemetryEnabled =
|
|
83
|
+
!process.env.HONEYHIVE_TELEMETRY ||
|
|
84
|
+
process.env.HONEYHIVE_TELEMETRY.toLowerCase() === "true";
|
|
85
|
+
if (this.telemetryEnabled) {
|
|
86
|
+
this.posthog = new posthog_node_1.PostHog("phc_yeqaIP07fjwZ5n3w47wPtSz7G58igfczuQ9X3zKhuxa", {
|
|
87
|
+
host: 'https://us.i.posthog.com'
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
Telemetry.getInstance = function () {
|
|
92
|
+
if (!Telemetry.instance) {
|
|
93
|
+
Telemetry.instance = new Telemetry();
|
|
94
|
+
}
|
|
95
|
+
return Telemetry.instance;
|
|
96
|
+
};
|
|
97
|
+
Telemetry.prototype.getAnonId = function () {
|
|
98
|
+
if (this.anonId) {
|
|
99
|
+
return this.anonId;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
if (!fs.existsSync(Telemetry.ANON_ID_PATH)) {
|
|
103
|
+
fs.mkdirSync(path.dirname(Telemetry.ANON_ID_PATH), { recursive: true });
|
|
104
|
+
var anonIdFile = fs.openSync(Telemetry.ANON_ID_PATH, "w");
|
|
105
|
+
this.anonId = (0, uuid_1.v4)();
|
|
106
|
+
fs.writeSync(anonIdFile, this.anonId);
|
|
107
|
+
fs.closeSync(anonIdFile);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
var anonIdFile = fs.openSync(Telemetry.ANON_ID_PATH, "r");
|
|
111
|
+
this.anonId = fs.readFileSync(anonIdFile, "utf8");
|
|
112
|
+
fs.closeSync(anonIdFile);
|
|
113
|
+
}
|
|
114
|
+
return this.anonId;
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
return Telemetry.UNKNOWN_ANON_ID;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
Telemetry.prototype.getHoneyhiveVersion = function () {
|
|
121
|
+
try {
|
|
122
|
+
var packageJson = require('honeyhive/package.json');
|
|
123
|
+
return packageJson.version;
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
return "Not installed";
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
Telemetry.prototype.getContext = function () {
|
|
130
|
+
var _a;
|
|
131
|
+
return {
|
|
132
|
+
sdk: "honeyhive",
|
|
133
|
+
sdk_version: this.getHoneyhiveVersion(),
|
|
134
|
+
language: {
|
|
135
|
+
name: "typescript",
|
|
136
|
+
version: process.version,
|
|
137
|
+
runtime: "Node.js",
|
|
138
|
+
},
|
|
139
|
+
runtime: this.getRuntimeInfo(),
|
|
140
|
+
os: {
|
|
141
|
+
name: os.type(),
|
|
142
|
+
release: os.release(),
|
|
143
|
+
version: os.version(),
|
|
144
|
+
},
|
|
145
|
+
chip: {
|
|
146
|
+
architecture: os.arch(),
|
|
147
|
+
processor: ((_a = os.cpus()[0]) === null || _a === void 0 ? void 0 : _a.model) || "Unknown",
|
|
148
|
+
},
|
|
149
|
+
user_agent: this.getUserAgent(),
|
|
150
|
+
service_provider_info: this.getServiceProviderInfo(),
|
|
151
|
+
notebook_info: this.getNotebookInfo(),
|
|
152
|
+
execution_info: this.getExecutionInfo(),
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
Telemetry.prototype.getRuntimeInfo = function () {
|
|
156
|
+
var runtimeInfo = {};
|
|
157
|
+
if (process.env.AWS_LAMBDA_FUNCTION_NAME) {
|
|
158
|
+
runtimeInfo.environment = 'AWS Lambda';
|
|
159
|
+
}
|
|
160
|
+
else if (process.env.AZURE_FUNCTIONS_ENVIRONMENT) {
|
|
161
|
+
runtimeInfo.environment = 'Azure Functions';
|
|
162
|
+
}
|
|
163
|
+
else if (process.env.GOOGLE_CLOUD_PROJECT) {
|
|
164
|
+
runtimeInfo.environment = 'Google Cloud Functions';
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
runtimeInfo.environment = 'Unknown';
|
|
168
|
+
}
|
|
169
|
+
// You may want to add detection for server-side frameworks here
|
|
170
|
+
// This might require checking for specific packages in package.json
|
|
171
|
+
return runtimeInfo;
|
|
172
|
+
};
|
|
173
|
+
Telemetry.prototype.getUserAgent = function () {
|
|
174
|
+
return "Node.js/".concat(process.version);
|
|
175
|
+
};
|
|
176
|
+
Telemetry.prototype.getServiceProviderInfo = function () {
|
|
177
|
+
// In a real implementation, you might want to use a library like 'axios' to make an HTTP request
|
|
178
|
+
// to ipinfo.io. For this example, we'll return a placeholder.
|
|
179
|
+
return { note: "Service provider info not implemented in TypeScript version" };
|
|
180
|
+
};
|
|
181
|
+
Telemetry.prototype.getNotebookInfo = function () {
|
|
182
|
+
// Detecting notebook environments in Node.js is not as straightforward as in Python
|
|
183
|
+
// You might want to check for specific environment variables or installed packages
|
|
184
|
+
return { in_notebook: false, environment: 'standard_nodejs' };
|
|
185
|
+
};
|
|
186
|
+
Telemetry.prototype.getExecutionInfo = function () {
|
|
187
|
+
return {
|
|
188
|
+
executable: process.execPath,
|
|
189
|
+
argv: process.argv,
|
|
190
|
+
execution_method: this.getExecutionMethod(),
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
Telemetry.prototype.getExecutionMethod = function () {
|
|
194
|
+
var execPath = process.argv[0].toLowerCase();
|
|
195
|
+
if (execPath.includes('node')) {
|
|
196
|
+
return 'nodejs';
|
|
197
|
+
}
|
|
198
|
+
else if (execPath.includes('npm')) {
|
|
199
|
+
return 'npm';
|
|
200
|
+
}
|
|
201
|
+
else if (execPath.includes('yarn')) {
|
|
202
|
+
return 'yarn';
|
|
203
|
+
}
|
|
204
|
+
else if (execPath.includes('ts-node')) {
|
|
205
|
+
return 'ts-node';
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
return 'unknown';
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
Telemetry.prototype.capture = function (event, properties) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
var posthogPayload;
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
switch (_a.label) {
|
|
216
|
+
case 0:
|
|
217
|
+
if (!(this.telemetryEnabled && this.posthog)) return [3 /*break*/, 2];
|
|
218
|
+
posthogPayload = {
|
|
219
|
+
distinctId: this.getAnonId(),
|
|
220
|
+
event: event,
|
|
221
|
+
properties: __assign(__assign({}, properties), this.getContext()),
|
|
222
|
+
};
|
|
223
|
+
this.posthog.capture(posthogPayload);
|
|
224
|
+
this.posthog.flush();
|
|
225
|
+
return [4 /*yield*/, this.posthog.shutdown()];
|
|
226
|
+
case 1:
|
|
227
|
+
_a.sent();
|
|
228
|
+
_a.label = 2;
|
|
229
|
+
case 2: return [2 /*return*/];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
Telemetry.prototype.logException = function (error) {
|
|
235
|
+
if (this.telemetryEnabled) {
|
|
236
|
+
this.capture("error", { error: error.message, stack: error.stack || "" });
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
Telemetry.ANON_ID_PATH = "".concat(os.homedir(), "/.cache/honeyhive/telemetry_anon_id");
|
|
240
|
+
Telemetry.UNKNOWN_ANON_ID = "UNKNOWN";
|
|
241
|
+
return Telemetry;
|
|
242
|
+
}());
|
|
243
|
+
exports.Telemetry = Telemetry;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as components from "../models/components";
|
|
2
|
+
import * as operations from "../models/operations";
|
|
3
|
+
import { SDKConfiguration } from "./sdk";
|
|
4
|
+
import { AxiosRequestConfig } from "axios";
|
|
5
|
+
export declare class Tools {
|
|
6
|
+
private sdkConfiguration;
|
|
7
|
+
constructor(sdkConfig: SDKConfiguration);
|
|
8
|
+
/**
|
|
9
|
+
* Retrieve a list of tools
|
|
10
|
+
*/
|
|
11
|
+
getTools(config?: AxiosRequestConfig): Promise<operations.GetToolsResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new tool
|
|
14
|
+
*/
|
|
15
|
+
createTool(req: components.CreateToolRequest, config?: AxiosRequestConfig): Promise<operations.CreateToolResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Update an existing tool
|
|
18
|
+
*/
|
|
19
|
+
updateTool(req: components.UpdateToolRequest, config?: AxiosRequestConfig): Promise<operations.UpdateToolResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Delete a tool
|
|
22
|
+
*/
|
|
23
|
+
deleteTool(functionId: string, config?: AxiosRequestConfig): Promise<operations.DeleteToolResponse>;
|
|
24
|
+
}
|