@openclaw/voyage-provider 2026.8.1-beta.3 → 2026.8.1
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/embedding-batch.js +35 -43
- package/dist/embedding-provider.js +14 -6
- package/dist/index.js +1 -2
- package/package.json +4 -4
package/dist/embedding-batch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EMBEDDING_BATCH_ENDPOINT, applyEmbeddingBatchOutputLine, buildBatchHeaders, buildEmbeddingBatchGroupOptions, extractBatchErrorMessage, formatBatchErrorDetail, formatUnavailableBatchError,
|
|
2
|
-
import { assertOkOrThrowProviderError, readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
|
|
1
|
+
import { EMBEDDING_BATCH_ENDPOINT, applyEmbeddingBatchOutputLine, buildBatchHeaders, buildEmbeddingBatchGroupOptions, extractBatchErrorMessage, formatBatchErrorDetail, formatUnavailableBatchError, postJsonWithRetry, readEmbeddingBatchJsonl, resolveBatchCompletionFromStatus, resolveCompletedBatchResult, resolveEmbeddingEndpointUrl, runEmbeddingBatchGroups, throwIfBatchCompletionError, throwIfBatchTerminalFailure, uploadBatchJsonlFile, withRemoteHttpResponse } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
2
|
+
import { assertOkOrThrowProviderError, createProviderOperationDeadline, readProviderJsonResponse, resolveProviderOperationTimeoutMs, waitProviderOperationPollInterval } from "openclaw/plugin-sdk/provider-http";
|
|
3
3
|
import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
|
|
4
4
|
import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
//#region extensions/voyage/embedding-batch.ts
|
|
@@ -7,20 +7,9 @@ const VOYAGE_BATCH_ENDPOINT = EMBEDDING_BATCH_ENDPOINT;
|
|
|
7
7
|
const VOYAGE_BATCH_COMPLETION_WINDOW = "12h";
|
|
8
8
|
const VOYAGE_BATCH_MAX_REQUESTS = 5e4;
|
|
9
9
|
const VOYAGE_BATCH_RESPONSE_MAX_BYTES = 16 * 1024 * 1024;
|
|
10
|
-
function resolveVoyageBatchDeps(overrides) {
|
|
11
|
-
return {
|
|
12
|
-
now: overrides?.now ?? Date.now,
|
|
13
|
-
sleep: overrides?.sleep ?? (async (ms) => await new Promise((resolve) => {
|
|
14
|
-
setTimeout(resolve, ms);
|
|
15
|
-
})),
|
|
16
|
-
postJsonWithRetry: overrides?.postJsonWithRetry ?? postJsonWithRetry,
|
|
17
|
-
uploadBatchJsonlFile: overrides?.uploadBatchJsonlFile ?? uploadBatchJsonlFile,
|
|
18
|
-
withRemoteHttpResponse: overrides?.withRemoteHttpResponse ?? withRemoteHttpResponse
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
10
|
function buildVoyageBatchRequest(params) {
|
|
22
11
|
return {
|
|
23
|
-
url:
|
|
12
|
+
url: resolveEmbeddingEndpointUrl(params.client.baseUrl, params.path),
|
|
24
13
|
ssrfPolicy: params.client.ssrfPolicy,
|
|
25
14
|
signal: params.signal,
|
|
26
15
|
init: { headers: buildBatchHeaders(params.client, { json: true }) },
|
|
@@ -28,14 +17,13 @@ function buildVoyageBatchRequest(params) {
|
|
|
28
17
|
};
|
|
29
18
|
}
|
|
30
19
|
async function submitVoyageBatch(params) {
|
|
31
|
-
const
|
|
32
|
-
const inputFileId = await params.deps.uploadBatchJsonlFile({
|
|
20
|
+
const inputFileId = await uploadBatchJsonlFile({
|
|
33
21
|
client: params.client,
|
|
34
22
|
requests: params.requests,
|
|
35
23
|
errorPrefix: "voyage batch file upload failed"
|
|
36
24
|
});
|
|
37
|
-
return await
|
|
38
|
-
url:
|
|
25
|
+
return await postJsonWithRetry({
|
|
26
|
+
url: resolveEmbeddingEndpointUrl(params.client.baseUrl, "batches"),
|
|
39
27
|
headers: buildBatchHeaders(params.client, { json: true }),
|
|
40
28
|
ssrfPolicy: params.client.ssrfPolicy,
|
|
41
29
|
body: {
|
|
@@ -55,7 +43,7 @@ async function submitVoyageBatch(params) {
|
|
|
55
43
|
});
|
|
56
44
|
}
|
|
57
45
|
async function fetchVoyageBatchStatus(params) {
|
|
58
|
-
return await
|
|
46
|
+
return await withRemoteHttpResponse(buildVoyageBatchRequest({
|
|
59
47
|
client: params.client,
|
|
60
48
|
path: `batches/${params.batchId}`,
|
|
61
49
|
signal: params.signal,
|
|
@@ -67,7 +55,7 @@ async function fetchVoyageBatchStatus(params) {
|
|
|
67
55
|
}
|
|
68
56
|
async function readVoyageBatchError(params) {
|
|
69
57
|
try {
|
|
70
|
-
return await
|
|
58
|
+
return await withRemoteHttpResponse(buildVoyageBatchRequest({
|
|
71
59
|
client: params.client,
|
|
72
60
|
path: `files/${params.errorFileId}/content`,
|
|
73
61
|
onResponse: async (res) => {
|
|
@@ -83,20 +71,23 @@ async function readVoyageBatchError(params) {
|
|
|
83
71
|
}
|
|
84
72
|
}
|
|
85
73
|
async function waitForVoyageBatch(params) {
|
|
86
|
-
const deadline =
|
|
74
|
+
const deadline = createProviderOperationDeadline({
|
|
75
|
+
label: `voyage batch ${params.batchId}`,
|
|
76
|
+
timeoutMs: params.timeoutMs
|
|
77
|
+
});
|
|
87
78
|
let current = params.initial;
|
|
88
79
|
while (true) {
|
|
89
80
|
let status;
|
|
90
81
|
if (current) status = current;
|
|
91
82
|
else {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
83
|
+
const signal = AbortSignal.timeout(resolveProviderOperationTimeoutMs({
|
|
84
|
+
deadline,
|
|
85
|
+
defaultTimeoutMs: params.timeoutMs
|
|
86
|
+
}));
|
|
95
87
|
try {
|
|
96
88
|
status = await fetchVoyageBatchStatus({
|
|
97
89
|
client: params.client,
|
|
98
90
|
batchId: params.batchId,
|
|
99
|
-
deps: params.deps,
|
|
100
91
|
signal
|
|
101
92
|
});
|
|
102
93
|
} catch (error) {
|
|
@@ -113,8 +104,7 @@ async function waitForVoyageBatch(params) {
|
|
|
113
104
|
},
|
|
114
105
|
readError: async (errorFileId) => await readVoyageBatchError({
|
|
115
106
|
client: params.client,
|
|
116
|
-
errorFileId
|
|
117
|
-
deps: params.deps
|
|
107
|
+
errorFileId
|
|
118
108
|
})
|
|
119
109
|
});
|
|
120
110
|
if (state === "completed") return resolveBatchCompletionFromStatus({
|
|
@@ -130,21 +120,27 @@ async function waitForVoyageBatch(params) {
|
|
|
130
120
|
},
|
|
131
121
|
readError: async (errorFileId) => await readVoyageBatchError({
|
|
132
122
|
client: params.client,
|
|
133
|
-
errorFileId
|
|
134
|
-
deps: params.deps
|
|
123
|
+
errorFileId
|
|
135
124
|
})
|
|
136
125
|
});
|
|
137
126
|
if (!params.wait) throw new Error(`voyage batch ${params.batchId} still ${state}; wait disabled`);
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
127
|
+
const waitMs = Math.min(params.pollIntervalMs, resolveProviderOperationTimeoutMs({
|
|
128
|
+
deadline,
|
|
129
|
+
defaultTimeoutMs: params.timeoutMs
|
|
130
|
+
}));
|
|
141
131
|
params.debug?.(`voyage batch ${params.batchId} ${state}; waiting ${waitMs}ms`);
|
|
142
|
-
await
|
|
132
|
+
await waitProviderOperationPollInterval({
|
|
133
|
+
deadline,
|
|
134
|
+
pollIntervalMs: waitMs
|
|
135
|
+
});
|
|
136
|
+
resolveProviderOperationTimeoutMs({
|
|
137
|
+
deadline,
|
|
138
|
+
defaultTimeoutMs: params.timeoutMs
|
|
139
|
+
});
|
|
143
140
|
current = void 0;
|
|
144
141
|
}
|
|
145
142
|
}
|
|
146
143
|
async function runVoyageEmbeddingBatches(params) {
|
|
147
|
-
const deps = resolveVoyageBatchDeps(params.deps);
|
|
148
144
|
return await runEmbeddingBatchGroups({
|
|
149
145
|
...buildEmbeddingBatchGroupOptions(params, {
|
|
150
146
|
maxRequests: VOYAGE_BATCH_MAX_REQUESTS,
|
|
@@ -154,8 +150,7 @@ async function runVoyageEmbeddingBatches(params) {
|
|
|
154
150
|
const batchInfo = await submitVoyageBatch({
|
|
155
151
|
client: params.client,
|
|
156
152
|
requests: group,
|
|
157
|
-
agentId: params.agentId
|
|
158
|
-
deps
|
|
153
|
+
agentId: params.agentId
|
|
159
154
|
});
|
|
160
155
|
if (!batchInfo.id) throw new Error("voyage batch create failed: missing batch id");
|
|
161
156
|
const batchId = batchInfo.id;
|
|
@@ -171,8 +166,7 @@ async function runVoyageEmbeddingBatches(params) {
|
|
|
171
166
|
status: batchInfo,
|
|
172
167
|
readError: async (errorFileId) => await readVoyageBatchError({
|
|
173
168
|
client: params.client,
|
|
174
|
-
errorFileId
|
|
175
|
-
deps
|
|
169
|
+
errorFileId
|
|
176
170
|
})
|
|
177
171
|
});
|
|
178
172
|
const completed = await resolveCompletedBatchResult({
|
|
@@ -186,15 +180,13 @@ async function runVoyageEmbeddingBatches(params) {
|
|
|
186
180
|
pollIntervalMs,
|
|
187
181
|
timeoutMs,
|
|
188
182
|
debug: params.debug,
|
|
189
|
-
initial: batchInfo
|
|
190
|
-
deps
|
|
183
|
+
initial: batchInfo
|
|
191
184
|
})
|
|
192
185
|
});
|
|
193
|
-
const baseUrl = normalizeBatchBaseUrl(params.client);
|
|
194
186
|
const errors = [];
|
|
195
187
|
const remaining = new Set(group.map((request) => request.custom_id));
|
|
196
|
-
await
|
|
197
|
-
url:
|
|
188
|
+
await withRemoteHttpResponse({
|
|
189
|
+
url: resolveEmbeddingEndpointUrl(params.client.baseUrl, `files/${completed.outputFileId}/content`),
|
|
198
190
|
ssrfPolicy: params.client.ssrfPolicy,
|
|
199
191
|
init: { headers: buildBatchHeaders(params.client, { json: true }) },
|
|
200
192
|
onResponse: async (contentRes) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fetchRemoteEmbeddingVectors, normalizeEmbeddingModelWithPrefixes, resolveRemoteEmbeddingBearerClient } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
1
|
+
import { fetchRemoteEmbeddingVectors, normalizeEmbeddingModelWithPrefixes, resolveEmbeddingEndpointUrl, resolveRemoteEmbeddingBearerClient } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
2
2
|
//#region extensions/voyage/embedding-provider.ts
|
|
3
3
|
const DEFAULT_VOYAGE_EMBEDDING_MODEL = "voyage-4-large";
|
|
4
4
|
const DEFAULT_VOYAGE_BASE_URL = "https://api.voyageai.com/v1";
|
|
@@ -16,8 +16,8 @@ function normalizeVoyageModel(model) {
|
|
|
16
16
|
}
|
|
17
17
|
async function createVoyageEmbeddingProvider(options) {
|
|
18
18
|
const client = await resolveVoyageEmbeddingClient(options);
|
|
19
|
-
const url =
|
|
20
|
-
const
|
|
19
|
+
const url = resolveEmbeddingEndpointUrl(client.baseUrl, "embeddings");
|
|
20
|
+
const embedMany = async (input, input_type, signal) => {
|
|
21
21
|
if (input.length === 0) return [];
|
|
22
22
|
const body = {
|
|
23
23
|
model: client.model,
|
|
@@ -38,11 +38,19 @@ async function createVoyageEmbeddingProvider(options) {
|
|
|
38
38
|
id: "voyage",
|
|
39
39
|
model: client.model,
|
|
40
40
|
maxInputTokens: VOYAGE_MAX_INPUT_TOKENS[client.model],
|
|
41
|
-
|
|
42
|
-
const
|
|
41
|
+
embed: async (input, optionsValue) => {
|
|
42
|
+
const text = typeof input === "string" ? input : input.text;
|
|
43
|
+
const [vec] = await embedMany([text], optionsValue?.inputType === "query" ? "query" : "document", optionsValue?.signal);
|
|
43
44
|
return vec ?? [];
|
|
44
45
|
},
|
|
45
|
-
embedBatch: async (
|
|
46
|
+
embedBatch: async (inputs, optionsLocal) => {
|
|
47
|
+
const texts = inputs.map((input) => typeof input === "string" ? input : input.text);
|
|
48
|
+
if (optionsLocal?.inputType === "query") return await Promise.all(texts.map(async (text) => {
|
|
49
|
+
const [vec] = await embedMany([text], "query", optionsLocal.signal);
|
|
50
|
+
return vec ?? [];
|
|
51
|
+
}));
|
|
52
|
+
return await embedMany(texts, "document", optionsLocal?.signal);
|
|
53
|
+
}
|
|
46
54
|
},
|
|
47
55
|
client
|
|
48
56
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { voyageMemoryEmbeddingProviderAdapter } from "./memory-embedding-adapter.js";
|
|
2
|
-
import { adaptMemoryEmbeddingProviderAdapter } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
3
2
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
4
3
|
//#region extensions/voyage/index.ts
|
|
5
4
|
var voyage_default = definePluginEntry({
|
|
@@ -7,7 +6,7 @@ var voyage_default = definePluginEntry({
|
|
|
7
6
|
name: "Voyage Embeddings",
|
|
8
7
|
description: "Voyage memory embedding provider plugin",
|
|
9
8
|
register(api) {
|
|
10
|
-
api.registerEmbeddingProvider(
|
|
9
|
+
api.registerEmbeddingProvider(voyageMemoryEmbeddingProviderAdapter);
|
|
11
10
|
}
|
|
12
11
|
});
|
|
13
12
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/voyage-provider",
|
|
3
|
-
"version": "2026.8.1
|
|
3
|
+
"version": "2026.8.1",
|
|
4
4
|
"description": "OpenClaw Voyage embedding provider plugin.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"minHostVersion": ">=2026.7.2"
|
|
19
19
|
},
|
|
20
20
|
"compat": {
|
|
21
|
-
"pluginApi": ">=2026.8.1
|
|
21
|
+
"pluginApi": ">=2026.8.1"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.8.1
|
|
24
|
+
"openclawVersion": "2026.8.1",
|
|
25
25
|
"bundledDist": false
|
|
26
26
|
},
|
|
27
27
|
"release": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"README.md"
|
|
39
39
|
],
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"openclaw": ">=2026.8.1
|
|
41
|
+
"openclaw": ">=2026.8.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"openclaw": {
|