@openclaw/voyage-provider 2026.8.1-beta.3 → 2026.8.2
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 +38 -45
- package/dist/embedding-provider.js +14 -6
- package/dist/index.js +1 -2
- package/dist/memory-embedding-adapter.js +3 -2
- package/package.json +4 -4
package/dist/embedding-batch.js
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
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
|
|
6
6
|
const VOYAGE_BATCH_ENDPOINT = EMBEDDING_BATCH_ENDPOINT;
|
|
7
7
|
const VOYAGE_BATCH_COMPLETION_WINDOW = "12h";
|
|
8
8
|
const VOYAGE_BATCH_MAX_REQUESTS = 5e4;
|
|
9
|
-
const VOYAGE_BATCH_RESPONSE_MAX_BYTES =
|
|
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
|
-
}
|
|
9
|
+
const VOYAGE_BATCH_RESPONSE_MAX_BYTES = 16777216;
|
|
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) => {
|
|
@@ -75,7 +63,8 @@ async function readVoyageBatchError(params) {
|
|
|
75
63
|
const bytes = await readResponseWithLimit(res, VOYAGE_BATCH_RESPONSE_MAX_BYTES, { onOverflow: ({ maxBytes: maxBytesLocal }) => /* @__PURE__ */ new Error(`voyage batch error file content exceeds ${maxBytesLocal} bytes`) });
|
|
76
64
|
const text = new TextDecoder().decode(bytes);
|
|
77
65
|
if (!text.trim()) return;
|
|
78
|
-
|
|
66
|
+
const lines = normalizeStringEntries(text.split("\n")).map((line) => JSON.parse(line));
|
|
67
|
+
return formatBatchErrorDetail(extractBatchErrorMessage(lines));
|
|
79
68
|
}
|
|
80
69
|
}));
|
|
81
70
|
} catch (err) {
|
|
@@ -83,20 +72,23 @@ async function readVoyageBatchError(params) {
|
|
|
83
72
|
}
|
|
84
73
|
}
|
|
85
74
|
async function waitForVoyageBatch(params) {
|
|
86
|
-
const deadline =
|
|
75
|
+
const deadline = createProviderOperationDeadline({
|
|
76
|
+
label: `voyage batch ${params.batchId}`,
|
|
77
|
+
timeoutMs: params.timeoutMs
|
|
78
|
+
});
|
|
87
79
|
let current = params.initial;
|
|
88
80
|
while (true) {
|
|
89
81
|
let status;
|
|
90
82
|
if (current) status = current;
|
|
91
83
|
else {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
const signal = AbortSignal.timeout(resolveProviderOperationTimeoutMs({
|
|
85
|
+
deadline,
|
|
86
|
+
defaultTimeoutMs: params.timeoutMs
|
|
87
|
+
}));
|
|
95
88
|
try {
|
|
96
89
|
status = await fetchVoyageBatchStatus({
|
|
97
90
|
client: params.client,
|
|
98
91
|
batchId: params.batchId,
|
|
99
|
-
deps: params.deps,
|
|
100
92
|
signal
|
|
101
93
|
});
|
|
102
94
|
} catch (error) {
|
|
@@ -113,8 +105,7 @@ async function waitForVoyageBatch(params) {
|
|
|
113
105
|
},
|
|
114
106
|
readError: async (errorFileId) => await readVoyageBatchError({
|
|
115
107
|
client: params.client,
|
|
116
|
-
errorFileId
|
|
117
|
-
deps: params.deps
|
|
108
|
+
errorFileId
|
|
118
109
|
})
|
|
119
110
|
});
|
|
120
111
|
if (state === "completed") return resolveBatchCompletionFromStatus({
|
|
@@ -130,21 +121,27 @@ async function waitForVoyageBatch(params) {
|
|
|
130
121
|
},
|
|
131
122
|
readError: async (errorFileId) => await readVoyageBatchError({
|
|
132
123
|
client: params.client,
|
|
133
|
-
errorFileId
|
|
134
|
-
deps: params.deps
|
|
124
|
+
errorFileId
|
|
135
125
|
})
|
|
136
126
|
});
|
|
137
127
|
if (!params.wait) throw new Error(`voyage batch ${params.batchId} still ${state}; wait disabled`);
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
128
|
+
const waitMs = Math.min(params.pollIntervalMs, resolveProviderOperationTimeoutMs({
|
|
129
|
+
deadline,
|
|
130
|
+
defaultTimeoutMs: params.timeoutMs
|
|
131
|
+
}));
|
|
141
132
|
params.debug?.(`voyage batch ${params.batchId} ${state}; waiting ${waitMs}ms`);
|
|
142
|
-
await
|
|
133
|
+
await waitProviderOperationPollInterval({
|
|
134
|
+
deadline,
|
|
135
|
+
pollIntervalMs: waitMs
|
|
136
|
+
});
|
|
137
|
+
resolveProviderOperationTimeoutMs({
|
|
138
|
+
deadline,
|
|
139
|
+
defaultTimeoutMs: params.timeoutMs
|
|
140
|
+
});
|
|
143
141
|
current = void 0;
|
|
144
142
|
}
|
|
145
143
|
}
|
|
146
144
|
async function runVoyageEmbeddingBatches(params) {
|
|
147
|
-
const deps = resolveVoyageBatchDeps(params.deps);
|
|
148
145
|
return await runEmbeddingBatchGroups({
|
|
149
146
|
...buildEmbeddingBatchGroupOptions(params, {
|
|
150
147
|
maxRequests: VOYAGE_BATCH_MAX_REQUESTS,
|
|
@@ -154,8 +151,7 @@ async function runVoyageEmbeddingBatches(params) {
|
|
|
154
151
|
const batchInfo = await submitVoyageBatch({
|
|
155
152
|
client: params.client,
|
|
156
153
|
requests: group,
|
|
157
|
-
agentId: params.agentId
|
|
158
|
-
deps
|
|
154
|
+
agentId: params.agentId
|
|
159
155
|
});
|
|
160
156
|
if (!batchInfo.id) throw new Error("voyage batch create failed: missing batch id");
|
|
161
157
|
const batchId = batchInfo.id;
|
|
@@ -171,8 +167,7 @@ async function runVoyageEmbeddingBatches(params) {
|
|
|
171
167
|
status: batchInfo,
|
|
172
168
|
readError: async (errorFileId) => await readVoyageBatchError({
|
|
173
169
|
client: params.client,
|
|
174
|
-
errorFileId
|
|
175
|
-
deps
|
|
170
|
+
errorFileId
|
|
176
171
|
})
|
|
177
172
|
});
|
|
178
173
|
const completed = await resolveCompletedBatchResult({
|
|
@@ -186,15 +181,13 @@ async function runVoyageEmbeddingBatches(params) {
|
|
|
186
181
|
pollIntervalMs,
|
|
187
182
|
timeoutMs,
|
|
188
183
|
debug: params.debug,
|
|
189
|
-
initial: batchInfo
|
|
190
|
-
deps
|
|
184
|
+
initial: batchInfo
|
|
191
185
|
})
|
|
192
186
|
});
|
|
193
|
-
const baseUrl = normalizeBatchBaseUrl(params.client);
|
|
194
187
|
const errors = [];
|
|
195
188
|
const remaining = new Set(group.map((request) => request.custom_id));
|
|
196
|
-
await
|
|
197
|
-
url:
|
|
189
|
+
await withRemoteHttpResponse({
|
|
190
|
+
url: resolveEmbeddingEndpointUrl(params.client.baseUrl, `files/${completed.outputFileId}/content`),
|
|
198
191
|
ssrfPolicy: params.client.ssrfPolicy,
|
|
199
192
|
init: { headers: buildBatchHeaders(params.client, { json: true }) },
|
|
200
193
|
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
|
|
@@ -27,7 +27,7 @@ const voyageMemoryEmbeddingProviderAdapter = {
|
|
|
27
27
|
headers: sanitizeEmbeddingCacheHeaders(client.headers, ["authorization"])
|
|
28
28
|
},
|
|
29
29
|
batchEmbed: async (batch) => {
|
|
30
|
-
|
|
30
|
+
const byCustomId = await runVoyageEmbeddingBatches({
|
|
31
31
|
client,
|
|
32
32
|
agentId: batch.agentId,
|
|
33
33
|
requests: batch.chunks.map((chunk, index) => ({
|
|
@@ -39,7 +39,8 @@ const voyageMemoryEmbeddingProviderAdapter = {
|
|
|
39
39
|
pollIntervalMs: batch.pollIntervalMs,
|
|
40
40
|
timeoutMs: batch.timeoutMs,
|
|
41
41
|
debug: batch.debug
|
|
42
|
-
})
|
|
42
|
+
});
|
|
43
|
+
return mapBatchEmbeddingsByIndex(byCustomId, batch.chunks.length);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/voyage-provider",
|
|
3
|
-
"version": "2026.8.
|
|
3
|
+
"version": "2026.8.2",
|
|
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.
|
|
21
|
+
"pluginApi": ">=2026.8.2"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.8.
|
|
24
|
+
"openclawVersion": "2026.8.2",
|
|
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.
|
|
41
|
+
"openclaw": ">=2026.8.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"openclaw": {
|