@premai/api-sdk 1.0.48 → 1.0.50
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/anthropic/from-openai.d.ts +8 -1
- package/dist/cli-claude.mjs +2 -6
- package/dist/cli.mjs +16 -8
- package/dist/index.cjs +25 -17
- package/dist/index.mjs +15 -7
- package/dist/server/discovery.d.ts +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,14 @@ export type AnthropicToolUseContentBlock = {
|
|
|
14
14
|
name: string;
|
|
15
15
|
input: unknown;
|
|
16
16
|
};
|
|
17
|
-
export type AnthropicAssistantContentBlock = AnthropicTextContentBlock | AnthropicToolUseContentBlock
|
|
17
|
+
export type AnthropicAssistantContentBlock = AnthropicTextContentBlock | AnthropicToolUseContentBlock | {
|
|
18
|
+
type: "thinking";
|
|
19
|
+
thinking: string;
|
|
20
|
+
signature: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: "redacted_thinking";
|
|
23
|
+
data: string;
|
|
24
|
+
};
|
|
18
25
|
export type AnthropicMessagePayload = {
|
|
19
26
|
id: string;
|
|
20
27
|
type: "message";
|
package/dist/cli-claude.mjs
CHANGED
|
@@ -271,12 +271,8 @@ var logger = winston.createLogger({
|
|
|
271
271
|
level,
|
|
272
272
|
transports: [fileTransport, consoleTransport]
|
|
273
273
|
});
|
|
274
|
-
|
|
275
274
|
// src/server/discovery.ts
|
|
276
|
-
import { readFileSync } from "node:fs";
|
|
277
|
-
var pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
|
|
278
275
|
var SERVER_MESSAGE = "Rvenc API Server";
|
|
279
|
-
var SERVER_VERSION = pkg.version;
|
|
280
276
|
|
|
281
277
|
// src/utils/poll-ready.ts
|
|
282
278
|
async function isProxyRoot(baseUrl) {
|
|
@@ -308,7 +304,7 @@ async function pollForReadiness(baseUrl, timeoutMs = 30000) {
|
|
|
308
304
|
import {
|
|
309
305
|
existsSync as existsSync2,
|
|
310
306
|
mkdirSync as mkdirSync2,
|
|
311
|
-
readFileSync
|
|
307
|
+
readFileSync,
|
|
312
308
|
unlinkSync,
|
|
313
309
|
writeFileSync
|
|
314
310
|
} from "node:fs";
|
|
@@ -320,7 +316,7 @@ function defaultStateFile() {
|
|
|
320
316
|
}
|
|
321
317
|
function readStateFile(path) {
|
|
322
318
|
try {
|
|
323
|
-
const raw =
|
|
319
|
+
const raw = readFileSync(path, "utf-8");
|
|
324
320
|
const parsed = JSON.parse(raw);
|
|
325
321
|
if (typeof parsed.pid !== "number" || typeof parsed.host !== "string" || typeof parsed.port !== "number" || typeof parsed.token !== "string") {
|
|
326
322
|
return null;
|
package/dist/cli.mjs
CHANGED
|
@@ -287,6 +287,9 @@ function anthropicAssistantContentToOpenAI(content) {
|
|
|
287
287
|
textParts.push(part.text);
|
|
288
288
|
continue;
|
|
289
289
|
}
|
|
290
|
+
if (part.type === "thinking" || part.type === "redacted_thinking") {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
290
293
|
if (part.type === "tool_use") {
|
|
291
294
|
const p = part;
|
|
292
295
|
if (typeof p.id !== "string" || p.id.length === 0) {
|
|
@@ -460,6 +463,13 @@ function extractTextCharCount(body) {
|
|
|
460
463
|
continue;
|
|
461
464
|
if (part.type === "text" && typeof part.text === "string") {
|
|
462
465
|
len += part.text.length;
|
|
466
|
+
} else if (part.type === "thinking" && typeof part.thinking === "string") {
|
|
467
|
+
len += part.thinking.length;
|
|
468
|
+
} else if (part.type === "redacted_thinking") {
|
|
469
|
+
const d = part.data;
|
|
470
|
+
if (typeof d === "string") {
|
|
471
|
+
len += d.length;
|
|
472
|
+
}
|
|
463
473
|
} else if (part.type === "tool_result") {
|
|
464
474
|
const c = part.content;
|
|
465
475
|
if (typeof c === "string") {
|
|
@@ -2730,9 +2740,8 @@ function setLogLevel(level2) {
|
|
|
2730
2740
|
t.level = level2;
|
|
2731
2741
|
});
|
|
2732
2742
|
}
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
import { readFileSync } from "node:fs";
|
|
2743
|
+
// package.json
|
|
2744
|
+
var version = "1.0.49";
|
|
2736
2745
|
|
|
2737
2746
|
// src/server/route-prefix.ts
|
|
2738
2747
|
function normalizeRoutePrefix(raw) {
|
|
@@ -2768,9 +2777,8 @@ function prefixedRoute(prefix, path) {
|
|
|
2768
2777
|
}
|
|
2769
2778
|
|
|
2770
2779
|
// src/server/discovery.ts
|
|
2771
|
-
var pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
|
|
2772
2780
|
var SERVER_MESSAGE = "Rvenc API Server";
|
|
2773
|
-
var SERVER_VERSION =
|
|
2781
|
+
var SERVER_VERSION = version;
|
|
2774
2782
|
function registerApiDiscoveryRoute(app, mount) {
|
|
2775
2783
|
const {
|
|
2776
2784
|
openai: mountOpenAI,
|
|
@@ -3130,7 +3138,7 @@ async function pollForReadiness(baseUrl, timeoutMs = 30000) {
|
|
|
3130
3138
|
import {
|
|
3131
3139
|
existsSync as existsSync2,
|
|
3132
3140
|
mkdirSync as mkdirSync2,
|
|
3133
|
-
readFileSync
|
|
3141
|
+
readFileSync,
|
|
3134
3142
|
unlinkSync,
|
|
3135
3143
|
writeFileSync
|
|
3136
3144
|
} from "node:fs";
|
|
@@ -3149,7 +3157,7 @@ function writeStateFile(path, state) {
|
|
|
3149
3157
|
}
|
|
3150
3158
|
function readStateFile(path) {
|
|
3151
3159
|
try {
|
|
3152
|
-
const raw =
|
|
3160
|
+
const raw = readFileSync(path, "utf-8");
|
|
3153
3161
|
const parsed = JSON.parse(raw);
|
|
3154
3162
|
if (typeof parsed.pid !== "number" || typeof parsed.host !== "string" || typeof parsed.port !== "number" || typeof parsed.token !== "string") {
|
|
3155
3163
|
return null;
|
|
@@ -3184,7 +3192,7 @@ function acquireDaemonLock(stateFile) {
|
|
|
3184
3192
|
} catch (err) {
|
|
3185
3193
|
if (err.code !== "EEXIST")
|
|
3186
3194
|
throw err;
|
|
3187
|
-
const lockPid = parseInt(
|
|
3195
|
+
const lockPid = parseInt(readFileSync(lockFile, "utf-8").trim(), 10);
|
|
3188
3196
|
if (Number.isFinite(lockPid) && lockPid > 0 && isProcessAlive(lockPid)) {
|
|
3189
3197
|
throw new Error(`Daemon lock is held by PID ${lockPid}. Another instance may already be running.`);
|
|
3190
3198
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1931,6 +1931,9 @@ function anthropicAssistantContentToOpenAI(content) {
|
|
|
1931
1931
|
textParts.push(part.text);
|
|
1932
1932
|
continue;
|
|
1933
1933
|
}
|
|
1934
|
+
if (part.type === "thinking" || part.type === "redacted_thinking") {
|
|
1935
|
+
continue;
|
|
1936
|
+
}
|
|
1934
1937
|
if (part.type === "tool_use") {
|
|
1935
1938
|
const p = part;
|
|
1936
1939
|
if (typeof p.id !== "string" || p.id.length === 0) {
|
|
@@ -2104,6 +2107,13 @@ function extractTextCharCount(body) {
|
|
|
2104
2107
|
continue;
|
|
2105
2108
|
if (part.type === "text" && typeof part.text === "string") {
|
|
2106
2109
|
len += part.text.length;
|
|
2110
|
+
} else if (part.type === "thinking" && typeof part.thinking === "string") {
|
|
2111
|
+
len += part.thinking.length;
|
|
2112
|
+
} else if (part.type === "redacted_thinking") {
|
|
2113
|
+
const d = part.data;
|
|
2114
|
+
if (typeof d === "string") {
|
|
2115
|
+
len += d.length;
|
|
2116
|
+
}
|
|
2107
2117
|
} else if (part.type === "tool_result") {
|
|
2108
2118
|
const c = part.content;
|
|
2109
2119
|
if (typeof c === "string") {
|
|
@@ -2836,9 +2846,8 @@ var logger = import_winston.default.createLogger({
|
|
|
2836
2846
|
level,
|
|
2837
2847
|
transports: [fileTransport, consoleTransport]
|
|
2838
2848
|
});
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
var import_node_fs2 = require("node:fs");
|
|
2849
|
+
// package.json
|
|
2850
|
+
var version = "1.0.49";
|
|
2842
2851
|
|
|
2843
2852
|
// src/server/route-prefix.ts
|
|
2844
2853
|
function normalizeRoutePrefix(raw) {
|
|
@@ -2874,9 +2883,8 @@ function prefixedRoute(prefix, path) {
|
|
|
2874
2883
|
}
|
|
2875
2884
|
|
|
2876
2885
|
// src/server/discovery.ts
|
|
2877
|
-
var pkg = JSON.parse(import_node_fs2.readFileSync(new URL("../../package.json", "file:///home/runner/_work/api-sdk-ts/api-sdk-ts/src/server/discovery.ts"), "utf8"));
|
|
2878
2886
|
var SERVER_MESSAGE = "Rvenc API Server";
|
|
2879
|
-
var SERVER_VERSION =
|
|
2887
|
+
var SERVER_VERSION = version;
|
|
2880
2888
|
function registerApiDiscoveryRoute(app, mount) {
|
|
2881
2889
|
const {
|
|
2882
2890
|
openai: mountOpenAI,
|
|
@@ -3233,7 +3241,7 @@ async function pollForReadiness(baseUrl, timeoutMs = 30000) {
|
|
|
3233
3241
|
}
|
|
3234
3242
|
|
|
3235
3243
|
// src/utils/state-file.ts
|
|
3236
|
-
var
|
|
3244
|
+
var import_node_fs2 = require("node:fs");
|
|
3237
3245
|
var import_node_path2 = require("node:path");
|
|
3238
3246
|
var import_utils8 = require("@noble/ciphers/utils.js");
|
|
3239
3247
|
var import_env_paths2 = __toESM(require("env-paths"));
|
|
@@ -3243,14 +3251,14 @@ function defaultStateFile() {
|
|
|
3243
3251
|
}
|
|
3244
3252
|
function writeStateFile(path, state) {
|
|
3245
3253
|
const dir2 = import_node_path2.dirname(path);
|
|
3246
|
-
if (!
|
|
3247
|
-
|
|
3248
|
-
|
|
3254
|
+
if (!import_node_fs2.existsSync(dir2))
|
|
3255
|
+
import_node_fs2.mkdirSync(dir2, { recursive: true });
|
|
3256
|
+
import_node_fs2.writeFileSync(path, JSON.stringify(state), { mode: 384 });
|
|
3249
3257
|
}
|
|
3250
3258
|
function removeStateFile(path) {
|
|
3251
3259
|
try {
|
|
3252
|
-
if (
|
|
3253
|
-
|
|
3260
|
+
if (import_node_fs2.existsSync(path))
|
|
3261
|
+
import_node_fs2.unlinkSync(path);
|
|
3254
3262
|
} catch {}
|
|
3255
3263
|
}
|
|
3256
3264
|
function generateShutdownToken() {
|
|
@@ -3266,22 +3274,22 @@ function isProcessAlive(pid) {
|
|
|
3266
3274
|
}
|
|
3267
3275
|
function acquireDaemonLock(stateFile) {
|
|
3268
3276
|
const lockFile = `${stateFile}.lock`;
|
|
3269
|
-
|
|
3277
|
+
import_node_fs2.mkdirSync(import_node_path2.dirname(lockFile), { recursive: true });
|
|
3270
3278
|
try {
|
|
3271
|
-
|
|
3279
|
+
import_node_fs2.writeFileSync(lockFile, String(process.pid), { flag: "wx" });
|
|
3272
3280
|
} catch (err) {
|
|
3273
3281
|
if (err.code !== "EEXIST")
|
|
3274
3282
|
throw err;
|
|
3275
|
-
const lockPid = parseInt(
|
|
3283
|
+
const lockPid = parseInt(import_node_fs2.readFileSync(lockFile, "utf-8").trim(), 10);
|
|
3276
3284
|
if (Number.isFinite(lockPid) && lockPid > 0 && isProcessAlive(lockPid)) {
|
|
3277
3285
|
throw new Error(`Daemon lock is held by PID ${lockPid}. Another instance may already be running.`);
|
|
3278
3286
|
}
|
|
3279
|
-
|
|
3280
|
-
|
|
3287
|
+
import_node_fs2.unlinkSync(lockFile);
|
|
3288
|
+
import_node_fs2.writeFileSync(lockFile, String(process.pid), { flag: "wx" });
|
|
3281
3289
|
}
|
|
3282
3290
|
return () => {
|
|
3283
3291
|
try {
|
|
3284
|
-
|
|
3292
|
+
import_node_fs2.unlinkSync(lockFile);
|
|
3285
3293
|
} catch {}
|
|
3286
3294
|
};
|
|
3287
3295
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1851,6 +1851,9 @@ function anthropicAssistantContentToOpenAI(content) {
|
|
|
1851
1851
|
textParts.push(part.text);
|
|
1852
1852
|
continue;
|
|
1853
1853
|
}
|
|
1854
|
+
if (part.type === "thinking" || part.type === "redacted_thinking") {
|
|
1855
|
+
continue;
|
|
1856
|
+
}
|
|
1854
1857
|
if (part.type === "tool_use") {
|
|
1855
1858
|
const p = part;
|
|
1856
1859
|
if (typeof p.id !== "string" || p.id.length === 0) {
|
|
@@ -2024,6 +2027,13 @@ function extractTextCharCount(body) {
|
|
|
2024
2027
|
continue;
|
|
2025
2028
|
if (part.type === "text" && typeof part.text === "string") {
|
|
2026
2029
|
len += part.text.length;
|
|
2030
|
+
} else if (part.type === "thinking" && typeof part.thinking === "string") {
|
|
2031
|
+
len += part.thinking.length;
|
|
2032
|
+
} else if (part.type === "redacted_thinking") {
|
|
2033
|
+
const d = part.data;
|
|
2034
|
+
if (typeof d === "string") {
|
|
2035
|
+
len += d.length;
|
|
2036
|
+
}
|
|
2027
2037
|
} else if (part.type === "tool_result") {
|
|
2028
2038
|
const c = part.content;
|
|
2029
2039
|
if (typeof c === "string") {
|
|
@@ -2756,9 +2766,8 @@ var logger = winston.createLogger({
|
|
|
2756
2766
|
level,
|
|
2757
2767
|
transports: [fileTransport, consoleTransport]
|
|
2758
2768
|
});
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
import { readFileSync } from "node:fs";
|
|
2769
|
+
// package.json
|
|
2770
|
+
var version = "1.0.49";
|
|
2762
2771
|
|
|
2763
2772
|
// src/server/route-prefix.ts
|
|
2764
2773
|
function normalizeRoutePrefix(raw) {
|
|
@@ -2794,9 +2803,8 @@ function prefixedRoute(prefix, path) {
|
|
|
2794
2803
|
}
|
|
2795
2804
|
|
|
2796
2805
|
// src/server/discovery.ts
|
|
2797
|
-
var pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
|
|
2798
2806
|
var SERVER_MESSAGE = "Rvenc API Server";
|
|
2799
|
-
var SERVER_VERSION =
|
|
2807
|
+
var SERVER_VERSION = version;
|
|
2800
2808
|
function registerApiDiscoveryRoute(app, mount) {
|
|
2801
2809
|
const {
|
|
2802
2810
|
openai: mountOpenAI,
|
|
@@ -3156,7 +3164,7 @@ async function pollForReadiness(baseUrl, timeoutMs = 30000) {
|
|
|
3156
3164
|
import {
|
|
3157
3165
|
existsSync as existsSync2,
|
|
3158
3166
|
mkdirSync as mkdirSync2,
|
|
3159
|
-
readFileSync
|
|
3167
|
+
readFileSync,
|
|
3160
3168
|
unlinkSync,
|
|
3161
3169
|
writeFileSync
|
|
3162
3170
|
} from "node:fs";
|
|
@@ -3198,7 +3206,7 @@ function acquireDaemonLock(stateFile) {
|
|
|
3198
3206
|
} catch (err) {
|
|
3199
3207
|
if (err.code !== "EEXIST")
|
|
3200
3208
|
throw err;
|
|
3201
|
-
const lockPid = parseInt(
|
|
3209
|
+
const lockPid = parseInt(readFileSync(lockFile, "utf-8").trim(), 10);
|
|
3202
3210
|
if (Number.isFinite(lockPid) && lockPid > 0 && isProcessAlive(lockPid)) {
|
|
3203
3211
|
throw new Error(`Daemon lock is held by PID ${lockPid}. Another instance may already be running.`);
|
|
3204
3212
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Application } from "express";
|
|
2
2
|
export declare const SERVER_MESSAGE = "Rvenc API Server";
|
|
3
|
-
export declare const SERVER_VERSION:
|
|
3
|
+
export declare const SERVER_VERSION: string;
|
|
4
4
|
export declare function registerApiDiscoveryRoute(app: Application, mount: {
|
|
5
5
|
openai: boolean;
|
|
6
6
|
anthropic: boolean;
|