@premai/api-sdk 1.0.47 → 1.0.48
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/README.md +57 -7
- package/dist/bare.cjs +20 -5
- package/dist/bare.mjs +20 -5
- package/dist/cli-claude.mjs +419 -3008
- package/dist/cli.mjs +2767 -2203
- package/dist/core.browser.cjs +26 -6
- package/dist/core.browser.mjs +20 -5
- package/dist/core.d.ts +2 -2
- package/dist/files/index.d.ts +3 -3
- package/dist/index.cjs +455 -36
- package/dist/index.mjs +467 -37
- package/dist/launcher/proxy-subprocess.d.ts +4 -2
- package/dist/server/create-app.d.ts +1 -0
- package/dist/server/create-drain-wrapper.d.ts +5 -0
- package/dist/server/discovery.d.ts +2 -0
- package/dist/server/request-debug.d.ts +2 -0
- package/dist/server/runtime.d.ts +2 -2
- package/dist/server/shutdown-route.d.ts +6 -0
- package/dist/server/start.d.ts +7 -4
- package/dist/server.d.ts +2 -0
- package/dist/tools/index.d.ts +1 -1
- package/dist/types.d.ts +17 -1
- package/dist/utils/crypto.d.ts +1 -1
- package/dist/utils/debug.d.ts +5 -0
- package/dist/utils/dek-store.d.ts +1 -1
- package/dist/utils/poll-ready.d.ts +2 -0
- package/dist/utils/state-file.d.ts +13 -0
- package/package.json +2 -1
package/dist/core.browser.cjs
CHANGED
|
@@ -171,7 +171,12 @@ async function attest(apiKey, options = { enabled: true }) {
|
|
|
171
171
|
// src/utils/crypto.ts
|
|
172
172
|
import { aeskwp } from "@noble/ciphers/aes.js";
|
|
173
173
|
import { xchacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
174
|
-
import {
|
|
174
|
+
import {
|
|
175
|
+
bytesToHex,
|
|
176
|
+
hexToBytes,
|
|
177
|
+
managedNonce,
|
|
178
|
+
randomBytes
|
|
179
|
+
} from "@noble/ciphers/utils.js";
|
|
175
180
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
176
181
|
import { sha3_256 } from "@noble/hashes/sha3.js";
|
|
177
182
|
import { XWing } from "@noble/post-quantum/hybrid.js";
|
|
@@ -425,7 +430,10 @@ function createAudioClient(apiKey, encryptionKeys, requestTimeoutMs = DEFAULT_RE
|
|
|
425
430
|
const controller = new AbortController;
|
|
426
431
|
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
427
432
|
try {
|
|
428
|
-
const sessionId = await attest(apiKey, {
|
|
433
|
+
const sessionId = await attest(apiKey, {
|
|
434
|
+
model: body.model,
|
|
435
|
+
enabled: attest2
|
|
436
|
+
});
|
|
429
437
|
const encryptedRequest = await preprocessAudioRequest(body, encryptionKeys);
|
|
430
438
|
const response = await fetch(`${endpoints.proxy}/rvenc/audio/transcriptions`, {
|
|
431
439
|
method: "POST",
|
|
@@ -457,7 +465,10 @@ function createAudioClient(apiKey, encryptionKeys, requestTimeoutMs = DEFAULT_RE
|
|
|
457
465
|
const controller = new AbortController;
|
|
458
466
|
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
459
467
|
try {
|
|
460
|
-
const sessionId = await attest(apiKey, {
|
|
468
|
+
const sessionId = await attest(apiKey, {
|
|
469
|
+
model: body.model,
|
|
470
|
+
enabled: attest2
|
|
471
|
+
});
|
|
461
472
|
const encryptedRequest = await preprocessAudioTranslationRequest(body, encryptionKeys);
|
|
462
473
|
const response = await fetch(`${endpoints.proxy}/rvenc/audio/translations`, {
|
|
463
474
|
method: "POST",
|
|
@@ -1148,7 +1159,10 @@ function createRvencChatClient(apiKey, encryptionKeys, requestTimeoutMs = DEFAUL
|
|
|
1148
1159
|
const controller = new AbortController;
|
|
1149
1160
|
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
1150
1161
|
try {
|
|
1151
|
-
const sessionId = await attest(apiKey, {
|
|
1162
|
+
const sessionId = await attest(apiKey, {
|
|
1163
|
+
model: body.model,
|
|
1164
|
+
enabled: attest2
|
|
1165
|
+
});
|
|
1152
1166
|
const encryptedRequest = preprocessRequest(body, encryptionKeys);
|
|
1153
1167
|
const response = await fetch(`${endpoints.proxy}/rvenc/chat/completions`, {
|
|
1154
1168
|
method: "POST",
|
|
@@ -1270,7 +1284,11 @@ async function* createDecryptedStreamGenerator(reader, sharedSecret, nonce, maxB
|
|
|
1270
1284
|
|
|
1271
1285
|
// src/tools/index.ts
|
|
1272
1286
|
import { bytesToHex as bytesToHex6, hexToBytes as hexToBytes6, randomBytes as randomBytes4 } from "@noble/ciphers/utils.js";
|
|
1273
|
-
var FILE_OUTPUT_TOOLS = [
|
|
1287
|
+
var FILE_OUTPUT_TOOLS = [
|
|
1288
|
+
"generateImage",
|
|
1289
|
+
"audioGenerateFromText",
|
|
1290
|
+
"createFileForUser"
|
|
1291
|
+
];
|
|
1274
1292
|
var FILE_INPUT_TOOLS = [
|
|
1275
1293
|
"imageDescribeAndCaption",
|
|
1276
1294
|
"imageDescribeAndCaptionFallback",
|
|
@@ -1329,7 +1347,9 @@ async function downloadEncryptedFile(fileId, apiKey, timeoutMs) {
|
|
|
1329
1347
|
if (!downloadUrl) {
|
|
1330
1348
|
throw new Error("No download URL in response");
|
|
1331
1349
|
}
|
|
1332
|
-
const fileResponse = await fetch(downloadUrl, {
|
|
1350
|
+
const fileResponse = await fetch(downloadUrl, {
|
|
1351
|
+
signal: controller.signal
|
|
1352
|
+
});
|
|
1333
1353
|
if (!fileResponse.ok) {
|
|
1334
1354
|
throw new Error(`Failed to download file: ${fileResponse.status}`);
|
|
1335
1355
|
}
|
package/dist/core.browser.mjs
CHANGED
|
@@ -5435,7 +5435,10 @@ function createAudioClient(apiKey, encryptionKeys, requestTimeoutMs = DEFAULT_RE
|
|
|
5435
5435
|
const controller = new AbortController;
|
|
5436
5436
|
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
5437
5437
|
try {
|
|
5438
|
-
const sessionId = await attest(apiKey, {
|
|
5438
|
+
const sessionId = await attest(apiKey, {
|
|
5439
|
+
model: body.model,
|
|
5440
|
+
enabled: attest2
|
|
5441
|
+
});
|
|
5439
5442
|
const encryptedRequest = await preprocessAudioRequest(body, encryptionKeys);
|
|
5440
5443
|
const response = await fetch(`${endpoints.proxy}/rvenc/audio/transcriptions`, {
|
|
5441
5444
|
method: "POST",
|
|
@@ -5467,7 +5470,10 @@ function createAudioClient(apiKey, encryptionKeys, requestTimeoutMs = DEFAULT_RE
|
|
|
5467
5470
|
const controller = new AbortController;
|
|
5468
5471
|
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
5469
5472
|
try {
|
|
5470
|
-
const sessionId = await attest(apiKey, {
|
|
5473
|
+
const sessionId = await attest(apiKey, {
|
|
5474
|
+
model: body.model,
|
|
5475
|
+
enabled: attest2
|
|
5476
|
+
});
|
|
5471
5477
|
const encryptedRequest = await preprocessAudioTranslationRequest(body, encryptionKeys);
|
|
5472
5478
|
const response = await fetch(`${endpoints.proxy}/rvenc/audio/translations`, {
|
|
5473
5479
|
method: "POST",
|
|
@@ -25419,7 +25425,10 @@ function createRvencChatClient(apiKey, encryptionKeys, requestTimeoutMs = DEFAUL
|
|
|
25419
25425
|
const controller = new AbortController;
|
|
25420
25426
|
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
25421
25427
|
try {
|
|
25422
|
-
const sessionId = await attest(apiKey, {
|
|
25428
|
+
const sessionId = await attest(apiKey, {
|
|
25429
|
+
model: body.model,
|
|
25430
|
+
enabled: attest2
|
|
25431
|
+
});
|
|
25423
25432
|
const encryptedRequest = preprocessRequest(body, encryptionKeys);
|
|
25424
25433
|
const response = await fetch(`${endpoints.proxy}/rvenc/chat/completions`, {
|
|
25425
25434
|
method: "POST",
|
|
@@ -25540,7 +25549,11 @@ async function* createDecryptedStreamGenerator(reader, sharedSecret, nonce, maxB
|
|
|
25540
25549
|
}
|
|
25541
25550
|
|
|
25542
25551
|
// src/tools/index.ts
|
|
25543
|
-
var FILE_OUTPUT_TOOLS = [
|
|
25552
|
+
var FILE_OUTPUT_TOOLS = [
|
|
25553
|
+
"generateImage",
|
|
25554
|
+
"audioGenerateFromText",
|
|
25555
|
+
"createFileForUser"
|
|
25556
|
+
];
|
|
25544
25557
|
var FILE_INPUT_TOOLS = [
|
|
25545
25558
|
"imageDescribeAndCaption",
|
|
25546
25559
|
"imageDescribeAndCaptionFallback",
|
|
@@ -25599,7 +25612,9 @@ async function downloadEncryptedFile(fileId, apiKey, timeoutMs) {
|
|
|
25599
25612
|
if (!downloadUrl) {
|
|
25600
25613
|
throw new Error("No download URL in response");
|
|
25601
25614
|
}
|
|
25602
|
-
const fileResponse = await fetch(downloadUrl, {
|
|
25615
|
+
const fileResponse = await fetch(downloadUrl, {
|
|
25616
|
+
signal: controller.signal
|
|
25617
|
+
});
|
|
25603
25618
|
if (!fileResponse.ok) {
|
|
25604
25619
|
throw new Error(`Failed to download file: ${fileResponse.status}`);
|
|
25605
25620
|
}
|
package/dist/core.d.ts
CHANGED
|
@@ -29,9 +29,9 @@ export interface RvencClient extends Omit<OpenAI, "files" | "audio" | "models">
|
|
|
29
29
|
export declare function createRvencClient(options: RvencClientOptions): Promise<RvencClient>;
|
|
30
30
|
export type { ModelsClient } from "./models";
|
|
31
31
|
export type { ToolsClient } from "./tools";
|
|
32
|
-
export type { ApiErrorResponse, DEKStore, DecryptedFile, DeleteFileOptions, DeleteFileResponse, DeleteIndexOptions, DeleteIndexResponse, EncryptionKeys, FileMetadata, FileUploadOptions, GetFileOptions, IndexFileInput, IndexFilesOptions, IndexFilesResponse, ListFilesOptions, ListFilesResponse, ListModelsParams, ListModelsResponse, Model, PaginationInfo, UploadedFile } from "./types";
|
|
32
|
+
export type { ApiErrorResponse, DEKStore, DecryptedFile, DeleteFileOptions, DeleteFileResponse, DeleteIndexOptions, DeleteIndexResponse, EncryptionKeys, FileMetadata, FileUploadOptions, GetFileOptions, IndexFileInput, IndexFilesOptions, IndexFilesResponse, ListFilesOptions, ListFilesResponse, ListModelsParams, ListModelsResponse, Model, PaginationInfo, UploadedFile, } from "./types";
|
|
33
33
|
export { generateEncryptionKeys } from "./utils/crypto";
|
|
34
34
|
export { deserializeDEKStore, generateNewClientKEK, getClientKEK, getClientKID, initializeDEKStore, serializeDEKStore, } from "./utils/dek-store";
|
|
35
35
|
export type { OpenAI };
|
|
36
|
-
export { getGatewayErrorMessage, isAttestationError, isGatewayError, loadPrem } from
|
|
36
|
+
export { getGatewayErrorMessage, isAttestationError, isGatewayError, loadPrem, } from "./utils/attestation";
|
|
37
37
|
export default createRvencClient;
|
package/dist/files/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { DEKStore, DeleteFileOptions, DeleteIndexOptions, DeleteIndexResponse, FileMetadata, FileUploadOptions, GetFileOptions, IndexFilesOptions, IndexFilesResponse, ListFilesOptions, ListFilesResponse, UploadedFile } from
|
|
1
|
+
import type { DEKStore, DeleteFileOptions, DeleteIndexOptions, DeleteIndexResponse, FileMetadata, FileUploadOptions, GetFileOptions, IndexFilesOptions, IndexFilesResponse, ListFilesOptions, ListFilesResponse, UploadedFile } from "../types";
|
|
2
2
|
export declare function uploadFile(apiKey: string, dekStore: DEKStore, options: FileUploadOptions, clientKEK?: string, timeoutMs?: number): Promise<UploadedFile>;
|
|
3
|
-
export declare function listFiles(apiKey: string, options?: ListFilesOptions, timeoutMs?: number): Promise<ListFilesResponse[
|
|
3
|
+
export declare function listFiles(apiKey: string, options?: ListFilesOptions, timeoutMs?: number): Promise<ListFilesResponse["data"]>;
|
|
4
4
|
export declare function getFile(apiKey: string, options: GetFileOptions, timeoutMs?: number): Promise<FileMetadata>;
|
|
5
5
|
export declare function deleteFile(apiKey: string, options: DeleteFileOptions, timeoutMs?: number): Promise<void>;
|
|
6
6
|
export declare function indexFiles(apiKey: string, dekStore: DEKStore, options: IndexFilesOptions, clientKEK?: string, timeoutMs?: number): Promise<IndexFilesResponse>;
|
|
7
7
|
export declare function deleteIndex(apiKey: string, dekStore: DEKStore, options: DeleteIndexOptions, clientKEK?: string, timeoutMs?: number): Promise<DeleteIndexResponse>;
|
|
8
8
|
export interface FilesClient {
|
|
9
9
|
upload: (options: FileUploadOptions) => Promise<UploadedFile>;
|
|
10
|
-
list: (options?: ListFilesOptions) => Promise<ListFilesResponse[
|
|
10
|
+
list: (options?: ListFilesOptions) => Promise<ListFilesResponse["data"]>;
|
|
11
11
|
get: (options: GetFileOptions) => Promise<FileMetadata>;
|
|
12
12
|
delete: (options: DeleteFileOptions) => Promise<void>;
|
|
13
13
|
index: (options: IndexFilesOptions) => Promise<IndexFilesResponse>;
|