@openclaw/voyage-provider 2026.9.2 → 2026.9.4
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 +48 -127
- package/dist/embedding-provider.js +13 -48
- package/dist/memory-embedding-adapter.js +1 -1
- package/openclaw.plugin.json +1 -0
- package/package.json +4 -4
package/dist/embedding-batch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EMBEDDING_BATCH_ENDPOINT,
|
|
1
|
+
import { EMBEDDING_BATCH_ENDPOINT, buildBatchHeaders, buildEmbeddingBatchGroupOptions, extractBatchErrorMessage, formatBatchErrorDetail, formatUnavailableBatchError, postJsonWithRetry, resolveEmbeddingEndpointUrl, runEmbeddingBatches, uploadBatchJsonlFile, waitForEmbeddingBatch, withRemoteHttpResponse } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
2
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";
|
|
@@ -71,144 +71,65 @@ async function readVoyageBatchError(params) {
|
|
|
71
71
|
return formatUnavailableBatchError(err);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
async function waitForVoyageBatch(params) {
|
|
75
|
-
const deadline = createProviderOperationDeadline({
|
|
76
|
-
label: `voyage batch ${params.batchId}`,
|
|
77
|
-
timeoutMs: params.timeoutMs
|
|
78
|
-
});
|
|
79
|
-
let current = params.initial;
|
|
80
|
-
while (true) {
|
|
81
|
-
let status;
|
|
82
|
-
if (current) status = current;
|
|
83
|
-
else {
|
|
84
|
-
const signal = AbortSignal.timeout(resolveProviderOperationTimeoutMs({
|
|
85
|
-
deadline,
|
|
86
|
-
defaultTimeoutMs: params.timeoutMs
|
|
87
|
-
}));
|
|
88
|
-
try {
|
|
89
|
-
status = await fetchVoyageBatchStatus({
|
|
90
|
-
client: params.client,
|
|
91
|
-
batchId: params.batchId,
|
|
92
|
-
signal
|
|
93
|
-
});
|
|
94
|
-
} catch (error) {
|
|
95
|
-
if (signal.aborted) throw new Error(`voyage batch ${params.batchId} timed out after ${params.timeoutMs}ms`, { cause: error });
|
|
96
|
-
throw error;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const state = status.status ?? "unknown";
|
|
100
|
-
await throwIfBatchCompletionError({
|
|
101
|
-
provider: "voyage",
|
|
102
|
-
status: {
|
|
103
|
-
...status,
|
|
104
|
-
id: params.batchId
|
|
105
|
-
},
|
|
106
|
-
readError: async (errorFileId) => await readVoyageBatchError({
|
|
107
|
-
client: params.client,
|
|
108
|
-
errorFileId
|
|
109
|
-
})
|
|
110
|
-
});
|
|
111
|
-
if (state === "completed") return resolveBatchCompletionFromStatus({
|
|
112
|
-
provider: "voyage",
|
|
113
|
-
batchId: params.batchId,
|
|
114
|
-
status
|
|
115
|
-
});
|
|
116
|
-
await throwIfBatchTerminalFailure({
|
|
117
|
-
provider: "voyage",
|
|
118
|
-
status: {
|
|
119
|
-
...status,
|
|
120
|
-
id: params.batchId
|
|
121
|
-
},
|
|
122
|
-
readError: async (errorFileId) => await readVoyageBatchError({
|
|
123
|
-
client: params.client,
|
|
124
|
-
errorFileId
|
|
125
|
-
})
|
|
126
|
-
});
|
|
127
|
-
if (!params.wait) throw new Error(`voyage batch ${params.batchId} still ${state}; wait disabled`);
|
|
128
|
-
const waitMs = Math.min(params.pollIntervalMs, resolveProviderOperationTimeoutMs({
|
|
129
|
-
deadline,
|
|
130
|
-
defaultTimeoutMs: params.timeoutMs
|
|
131
|
-
}));
|
|
132
|
-
params.debug?.(`voyage batch ${params.batchId} ${state}; waiting ${waitMs}ms`);
|
|
133
|
-
await waitProviderOperationPollInterval({
|
|
134
|
-
deadline,
|
|
135
|
-
pollIntervalMs: waitMs
|
|
136
|
-
});
|
|
137
|
-
resolveProviderOperationTimeoutMs({
|
|
138
|
-
deadline,
|
|
139
|
-
defaultTimeoutMs: params.timeoutMs
|
|
140
|
-
});
|
|
141
|
-
current = void 0;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
74
|
async function runVoyageEmbeddingBatches(params) {
|
|
145
|
-
return await
|
|
75
|
+
return await runEmbeddingBatches({
|
|
76
|
+
provider: "voyage",
|
|
146
77
|
...buildEmbeddingBatchGroupOptions(params, {
|
|
147
78
|
maxRequests: VOYAGE_BATCH_MAX_REQUESTS,
|
|
148
79
|
debugLabel: "memory embeddings: voyage batch submit"
|
|
149
80
|
}),
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
81
|
+
submit: (group) => submitVoyageBatch({
|
|
82
|
+
client: params.client,
|
|
83
|
+
requests: group,
|
|
84
|
+
agentId: params.agentId
|
|
85
|
+
}),
|
|
86
|
+
readError: (errorFileId) => readVoyageBatchError({
|
|
87
|
+
client: params.client,
|
|
88
|
+
errorFileId
|
|
89
|
+
}),
|
|
90
|
+
readOutput: (fileId, read) => withRemoteHttpResponse(buildVoyageBatchRequest({
|
|
91
|
+
client: params.client,
|
|
92
|
+
path: `files/${fileId}/content`,
|
|
93
|
+
onResponse: async (response) => {
|
|
94
|
+
await assertOkOrThrowProviderError(response, "voyage.batch-file-content");
|
|
95
|
+
await read(response);
|
|
96
|
+
}
|
|
97
|
+
})),
|
|
98
|
+
waitForBatch: async (batchInfo, pollIntervalMs, timeoutMs) => {
|
|
157
99
|
const batchId = batchInfo.id;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
100
|
+
const client = params.client;
|
|
101
|
+
const wait = params.wait;
|
|
102
|
+
const debug = params.debug;
|
|
103
|
+
const deadline = createProviderOperationDeadline({
|
|
104
|
+
label: `voyage batch ${batchId}`,
|
|
105
|
+
timeoutMs
|
|
164
106
|
});
|
|
165
|
-
await
|
|
107
|
+
return await waitForEmbeddingBatch({
|
|
166
108
|
provider: "voyage",
|
|
167
|
-
|
|
109
|
+
batchId,
|
|
110
|
+
wait,
|
|
111
|
+
pollIntervalMs,
|
|
112
|
+
timeoutMs,
|
|
113
|
+
debug,
|
|
114
|
+
initial: batchInfo,
|
|
115
|
+
fetchStatus: (signal) => fetchVoyageBatchStatus({
|
|
116
|
+
client,
|
|
117
|
+
batchId,
|
|
118
|
+
signal
|
|
119
|
+
}),
|
|
120
|
+
resolveTimeoutMs: () => resolveProviderOperationTimeoutMs({
|
|
121
|
+
deadline,
|
|
122
|
+
defaultTimeoutMs: timeoutMs
|
|
123
|
+
}),
|
|
124
|
+
waitForPoll: (delayMs) => waitProviderOperationPollInterval({
|
|
125
|
+
deadline,
|
|
126
|
+
pollIntervalMs: delayMs
|
|
127
|
+
}),
|
|
168
128
|
readError: async (errorFileId) => await readVoyageBatchError({
|
|
169
|
-
client
|
|
129
|
+
client,
|
|
170
130
|
errorFileId
|
|
171
131
|
})
|
|
172
132
|
});
|
|
173
|
-
const completed = await resolveCompletedBatchResult({
|
|
174
|
-
provider: "voyage",
|
|
175
|
-
status: batchInfo,
|
|
176
|
-
wait: params.wait,
|
|
177
|
-
waitForBatch: async () => await waitForVoyageBatch({
|
|
178
|
-
client: params.client,
|
|
179
|
-
batchId,
|
|
180
|
-
wait: params.wait,
|
|
181
|
-
pollIntervalMs,
|
|
182
|
-
timeoutMs,
|
|
183
|
-
debug: params.debug,
|
|
184
|
-
initial: batchInfo
|
|
185
|
-
})
|
|
186
|
-
});
|
|
187
|
-
const errors = [];
|
|
188
|
-
const remaining = new Set(group.map((request) => request.custom_id));
|
|
189
|
-
await withRemoteHttpResponse({
|
|
190
|
-
url: resolveEmbeddingEndpointUrl(params.client.baseUrl, `files/${completed.outputFileId}/content`),
|
|
191
|
-
ssrfPolicy: params.client.ssrfPolicy,
|
|
192
|
-
init: { headers: buildBatchHeaders(params.client, { json: true }) },
|
|
193
|
-
onResponse: async (contentRes) => {
|
|
194
|
-
await assertOkOrThrowProviderError(contentRes, "voyage.batch-file-content");
|
|
195
|
-
await readEmbeddingBatchJsonl(contentRes, {
|
|
196
|
-
label: "voyage.batch-file-content",
|
|
197
|
-
maxRecords: group.length,
|
|
198
|
-
onRecord: (line) => {
|
|
199
|
-
if (line.custom_id && remaining.has(line.custom_id)) applyEmbeddingBatchOutputLine({
|
|
200
|
-
line,
|
|
201
|
-
remaining,
|
|
202
|
-
errors,
|
|
203
|
-
byCustomId
|
|
204
|
-
});
|
|
205
|
-
return errors.length === 0 && remaining.size > 0;
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
if (errors.length > 0) throw new Error(`voyage batch ${batchInfo.id} failed: ${formatBatchErrorDetail(errors[0]) ?? "unknown error"}`);
|
|
211
|
-
if (remaining.size > 0) throw new Error(`voyage batch ${batchInfo.id} missing ${remaining.size} embedding responses`);
|
|
212
133
|
}
|
|
213
134
|
});
|
|
214
135
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRemoteEmbeddingProvider, normalizeEmbeddingModelWithPrefixes, resolveRemoteEmbeddingClient } 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";
|
|
@@ -15,57 +15,22 @@ function normalizeVoyageModel(model) {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
async function createVoyageEmbeddingProvider(options) {
|
|
18
|
-
const client = await
|
|
19
|
-
const url = resolveEmbeddingEndpointUrl(client.baseUrl, "embeddings");
|
|
20
|
-
const embedMany = async (input, input_type, signal) => {
|
|
21
|
-
if (input.length === 0) return [];
|
|
22
|
-
const body = {
|
|
23
|
-
model: client.model,
|
|
24
|
-
input
|
|
25
|
-
};
|
|
26
|
-
if (input_type) body.input_type = input_type;
|
|
27
|
-
return await fetchRemoteEmbeddingVectors({
|
|
28
|
-
url,
|
|
29
|
-
headers: client.headers,
|
|
30
|
-
ssrfPolicy: client.ssrfPolicy,
|
|
31
|
-
signal,
|
|
32
|
-
body,
|
|
33
|
-
errorPrefix: "voyage embeddings failed"
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
provider: {
|
|
38
|
-
id: "voyage",
|
|
39
|
-
model: client.model,
|
|
40
|
-
maxInputTokens: VOYAGE_MAX_INPUT_TOKENS[client.model],
|
|
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);
|
|
44
|
-
return vec ?? [];
|
|
45
|
-
},
|
|
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
|
-
}
|
|
54
|
-
},
|
|
55
|
-
client
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
async function resolveVoyageEmbeddingClient(options) {
|
|
59
|
-
const { baseUrl, headers, ssrfPolicy } = await resolveRemoteEmbeddingBearerClient({
|
|
18
|
+
const client = await resolveRemoteEmbeddingClient({
|
|
60
19
|
provider: "voyage",
|
|
61
20
|
options,
|
|
62
|
-
defaultBaseUrl: DEFAULT_VOYAGE_BASE_URL
|
|
21
|
+
defaultBaseUrl: DEFAULT_VOYAGE_BASE_URL,
|
|
22
|
+
normalizeModel: normalizeVoyageModel
|
|
23
|
+
});
|
|
24
|
+
const provider = createRemoteEmbeddingProvider({
|
|
25
|
+
id: "voyage",
|
|
26
|
+
client,
|
|
27
|
+
errorPrefix: "voyage embeddings failed",
|
|
28
|
+
buildRequestFields: (kind) => ({ input_type: kind })
|
|
63
29
|
});
|
|
30
|
+
provider.maxInputTokens = VOYAGE_MAX_INPUT_TOKENS[client.model];
|
|
64
31
|
return {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
ssrfPolicy,
|
|
68
|
-
model: normalizeVoyageModel(options.model)
|
|
32
|
+
provider,
|
|
33
|
+
client
|
|
69
34
|
};
|
|
70
35
|
}
|
|
71
36
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runVoyageEmbeddingBatches } from "./embedding-batch.js";
|
|
2
2
|
import { DEFAULT_VOYAGE_EMBEDDING_MODEL, createVoyageEmbeddingProvider } from "./embedding-provider.js";
|
|
3
|
-
import { isMissingEmbeddingApiKeyError, mapBatchEmbeddingsByIndex, sanitizeEmbeddingCacheHeaders } from "openclaw/plugin-sdk/
|
|
3
|
+
import { isMissingEmbeddingApiKeyError, mapBatchEmbeddingsByIndex, sanitizeEmbeddingCacheHeaders } from "openclaw/plugin-sdk/embedding-provider-adapter";
|
|
4
4
|
//#region extensions/voyage/memory-embedding-adapter.ts
|
|
5
5
|
const voyageMemoryEmbeddingProviderAdapter = {
|
|
6
6
|
id: "voyage",
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/voyage-provider",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.4",
|
|
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.9.
|
|
21
|
+
"pluginApi": ">=2026.9.4"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.9.
|
|
24
|
+
"openclawVersion": "2026.9.4",
|
|
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.9.
|
|
41
|
+
"openclaw": ">=2026.9.4"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"openclaw": {
|