@openclaw/voyage-provider 0.0.0 → 2026.8.1-beta.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/README.md CHANGED
@@ -1,3 +1,14 @@
1
- # @openclaw/voyage-provider
1
+ # OpenClaw Voyage Provider
2
2
 
3
- Reserved placeholder for the official OpenClaw plugin package. Use a published release version instead.
3
+ Official OpenClaw memory embedding provider plugin for Voyage AI.
4
+
5
+ Install from OpenClaw:
6
+
7
+ ```bash
8
+ openclaw plugins install @openclaw/voyage-provider
9
+ openclaw gateway restart
10
+ ```
11
+
12
+ Set `VOYAGE_API_KEY`, then configure memory search with `provider: "voyage"`.
13
+ See <https://docs.openclaw.ai/reference/memory-config> for setup and
14
+ configuration.
@@ -0,0 +1,223 @@
1
+ import { EMBEDDING_BATCH_ENDPOINT, applyEmbeddingBatchOutputLine, buildBatchHeaders, buildEmbeddingBatchGroupOptions, extractBatchErrorMessage, formatBatchErrorDetail, formatUnavailableBatchError, normalizeBatchBaseUrl, postJsonWithRetry, readEmbeddingBatchJsonl, resolveBatchCompletionFromStatus, resolveCompletedBatchResult, runEmbeddingBatchGroups, throwIfBatchCompletionError, throwIfBatchTerminalFailure, uploadBatchJsonlFile, withRemoteHttpResponse } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
2
+ import { assertOkOrThrowProviderError, readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
3
+ import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
4
+ import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
5
+ //#region extensions/voyage/embedding-batch.ts
6
+ const VOYAGE_BATCH_ENDPOINT = EMBEDDING_BATCH_ENDPOINT;
7
+ const VOYAGE_BATCH_COMPLETION_WINDOW = "12h";
8
+ const VOYAGE_BATCH_MAX_REQUESTS = 5e4;
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
+ function buildVoyageBatchRequest(params) {
22
+ return {
23
+ url: `${normalizeBatchBaseUrl(params.client)}/${params.path}`,
24
+ ssrfPolicy: params.client.ssrfPolicy,
25
+ signal: params.signal,
26
+ init: { headers: buildBatchHeaders(params.client, { json: true }) },
27
+ onResponse: params.onResponse
28
+ };
29
+ }
30
+ async function submitVoyageBatch(params) {
31
+ const baseUrl = normalizeBatchBaseUrl(params.client);
32
+ const inputFileId = await params.deps.uploadBatchJsonlFile({
33
+ client: params.client,
34
+ requests: params.requests,
35
+ errorPrefix: "voyage batch file upload failed"
36
+ });
37
+ return await params.deps.postJsonWithRetry({
38
+ url: `${baseUrl}/batches`,
39
+ headers: buildBatchHeaders(params.client, { json: true }),
40
+ ssrfPolicy: params.client.ssrfPolicy,
41
+ body: {
42
+ input_file_id: inputFileId,
43
+ endpoint: VOYAGE_BATCH_ENDPOINT,
44
+ completion_window: VOYAGE_BATCH_COMPLETION_WINDOW,
45
+ request_params: {
46
+ model: params.client.model,
47
+ input_type: "document"
48
+ },
49
+ metadata: {
50
+ source: "clawdbot-memory",
51
+ agent: params.agentId
52
+ }
53
+ },
54
+ errorPrefix: "voyage batch create failed"
55
+ });
56
+ }
57
+ async function fetchVoyageBatchStatus(params) {
58
+ return await params.deps.withRemoteHttpResponse(buildVoyageBatchRequest({
59
+ client: params.client,
60
+ path: `batches/${params.batchId}`,
61
+ signal: params.signal,
62
+ onResponse: async (res) => {
63
+ await assertOkOrThrowProviderError(res, "voyage.batch-status");
64
+ return await readProviderJsonResponse(res, "voyage-batch-status", { maxBytes: VOYAGE_BATCH_RESPONSE_MAX_BYTES });
65
+ }
66
+ }));
67
+ }
68
+ async function readVoyageBatchError(params) {
69
+ try {
70
+ return await params.deps.withRemoteHttpResponse(buildVoyageBatchRequest({
71
+ client: params.client,
72
+ path: `files/${params.errorFileId}/content`,
73
+ onResponse: async (res) => {
74
+ await assertOkOrThrowProviderError(res, "voyage.batch-error-file-content");
75
+ 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
+ const text = new TextDecoder().decode(bytes);
77
+ if (!text.trim()) return;
78
+ return formatBatchErrorDetail(extractBatchErrorMessage(normalizeStringEntries(text.split("\n")).map((line) => JSON.parse(line))));
79
+ }
80
+ }));
81
+ } catch (err) {
82
+ return formatUnavailableBatchError(err);
83
+ }
84
+ }
85
+ async function waitForVoyageBatch(params) {
86
+ const deadline = params.deps.now() + params.timeoutMs;
87
+ let current = params.initial;
88
+ while (true) {
89
+ let status;
90
+ if (current) status = current;
91
+ else {
92
+ const remainingRequestMs = deadline - params.deps.now();
93
+ if (remainingRequestMs <= 0) throw new Error(`voyage batch ${params.batchId} timed out after ${params.timeoutMs}ms`);
94
+ const signal = AbortSignal.timeout(Math.max(1, remainingRequestMs));
95
+ try {
96
+ status = await fetchVoyageBatchStatus({
97
+ client: params.client,
98
+ batchId: params.batchId,
99
+ deps: params.deps,
100
+ signal
101
+ });
102
+ } catch (error) {
103
+ if (signal.aborted) throw new Error(`voyage batch ${params.batchId} timed out after ${params.timeoutMs}ms`, { cause: error });
104
+ throw error;
105
+ }
106
+ }
107
+ const state = status.status ?? "unknown";
108
+ await throwIfBatchCompletionError({
109
+ provider: "voyage",
110
+ status: {
111
+ ...status,
112
+ id: params.batchId
113
+ },
114
+ readError: async (errorFileId) => await readVoyageBatchError({
115
+ client: params.client,
116
+ errorFileId,
117
+ deps: params.deps
118
+ })
119
+ });
120
+ if (state === "completed") return resolveBatchCompletionFromStatus({
121
+ provider: "voyage",
122
+ batchId: params.batchId,
123
+ status
124
+ });
125
+ await throwIfBatchTerminalFailure({
126
+ provider: "voyage",
127
+ status: {
128
+ ...status,
129
+ id: params.batchId
130
+ },
131
+ readError: async (errorFileId) => await readVoyageBatchError({
132
+ client: params.client,
133
+ errorFileId,
134
+ deps: params.deps
135
+ })
136
+ });
137
+ if (!params.wait) throw new Error(`voyage batch ${params.batchId} still ${state}; wait disabled`);
138
+ const remainingMs = deadline - params.deps.now();
139
+ if (remainingMs <= 0) throw new Error(`voyage batch ${params.batchId} timed out after ${params.timeoutMs}ms`);
140
+ const waitMs = Math.min(params.pollIntervalMs, remainingMs);
141
+ params.debug?.(`voyage batch ${params.batchId} ${state}; waiting ${waitMs}ms`);
142
+ await params.deps.sleep(waitMs);
143
+ current = void 0;
144
+ }
145
+ }
146
+ async function runVoyageEmbeddingBatches(params) {
147
+ const deps = resolveVoyageBatchDeps(params.deps);
148
+ return await runEmbeddingBatchGroups({
149
+ ...buildEmbeddingBatchGroupOptions(params, {
150
+ maxRequests: VOYAGE_BATCH_MAX_REQUESTS,
151
+ debugLabel: "memory embeddings: voyage batch submit"
152
+ }),
153
+ runGroup: async ({ group, groupIndex, groups, byCustomId, pollIntervalMs, timeoutMs }) => {
154
+ const batchInfo = await submitVoyageBatch({
155
+ client: params.client,
156
+ requests: group,
157
+ agentId: params.agentId,
158
+ deps
159
+ });
160
+ if (!batchInfo.id) throw new Error("voyage batch create failed: missing batch id");
161
+ const batchId = batchInfo.id;
162
+ params.debug?.("memory embeddings: voyage batch created", {
163
+ batchId: batchInfo.id,
164
+ status: batchInfo.status,
165
+ group: groupIndex + 1,
166
+ groups,
167
+ requests: group.length
168
+ });
169
+ await throwIfBatchCompletionError({
170
+ provider: "voyage",
171
+ status: batchInfo,
172
+ readError: async (errorFileId) => await readVoyageBatchError({
173
+ client: params.client,
174
+ errorFileId,
175
+ deps
176
+ })
177
+ });
178
+ const completed = await resolveCompletedBatchResult({
179
+ provider: "voyage",
180
+ status: batchInfo,
181
+ wait: params.wait,
182
+ waitForBatch: async () => await waitForVoyageBatch({
183
+ client: params.client,
184
+ batchId,
185
+ wait: params.wait,
186
+ pollIntervalMs,
187
+ timeoutMs,
188
+ debug: params.debug,
189
+ initial: batchInfo,
190
+ deps
191
+ })
192
+ });
193
+ const baseUrl = normalizeBatchBaseUrl(params.client);
194
+ const errors = [];
195
+ const remaining = new Set(group.map((request) => request.custom_id));
196
+ await deps.withRemoteHttpResponse({
197
+ url: `${baseUrl}/files/${completed.outputFileId}/content`,
198
+ ssrfPolicy: params.client.ssrfPolicy,
199
+ init: { headers: buildBatchHeaders(params.client, { json: true }) },
200
+ onResponse: async (contentRes) => {
201
+ await assertOkOrThrowProviderError(contentRes, "voyage.batch-file-content");
202
+ await readEmbeddingBatchJsonl(contentRes, {
203
+ label: "voyage.batch-file-content",
204
+ maxRecords: group.length,
205
+ onRecord: (line) => {
206
+ if (line.custom_id && remaining.has(line.custom_id)) applyEmbeddingBatchOutputLine({
207
+ line,
208
+ remaining,
209
+ errors,
210
+ byCustomId
211
+ });
212
+ return errors.length === 0 && remaining.size > 0;
213
+ }
214
+ });
215
+ }
216
+ });
217
+ if (errors.length > 0) throw new Error(`voyage batch ${batchInfo.id} failed: ${formatBatchErrorDetail(errors[0]) ?? "unknown error"}`);
218
+ if (remaining.size > 0) throw new Error(`voyage batch ${batchInfo.id} missing ${remaining.size} embedding responses`);
219
+ }
220
+ });
221
+ }
222
+ //#endregion
223
+ export { runVoyageEmbeddingBatches };
@@ -0,0 +1,64 @@
1
+ import { fetchRemoteEmbeddingVectors, normalizeEmbeddingModelWithPrefixes, resolveRemoteEmbeddingBearerClient } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
2
+ //#region extensions/voyage/embedding-provider.ts
3
+ const DEFAULT_VOYAGE_EMBEDDING_MODEL = "voyage-4-large";
4
+ const DEFAULT_VOYAGE_BASE_URL = "https://api.voyageai.com/v1";
5
+ const VOYAGE_MAX_INPUT_TOKENS = {
6
+ "voyage-3": 32e3,
7
+ "voyage-3-lite": 16e3,
8
+ "voyage-code-3": 32e3
9
+ };
10
+ function normalizeVoyageModel(model) {
11
+ return normalizeEmbeddingModelWithPrefixes({
12
+ model,
13
+ defaultModel: DEFAULT_VOYAGE_EMBEDDING_MODEL,
14
+ prefixes: ["voyage/"]
15
+ });
16
+ }
17
+ async function createVoyageEmbeddingProvider(options) {
18
+ const client = await resolveVoyageEmbeddingClient(options);
19
+ const url = `${client.baseUrl.replace(/\/$/, "")}/embeddings`;
20
+ const embed = 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
+ embedQuery: async (text, optionsValue) => {
42
+ const [vec] = await embed([text], "query", optionsValue?.signal);
43
+ return vec ?? [];
44
+ },
45
+ embedBatch: async (texts, optionsLocal) => embed(texts, "document", optionsLocal?.signal)
46
+ },
47
+ client
48
+ };
49
+ }
50
+ async function resolveVoyageEmbeddingClient(options) {
51
+ const { baseUrl, headers, ssrfPolicy } = await resolveRemoteEmbeddingBearerClient({
52
+ provider: "voyage",
53
+ options,
54
+ defaultBaseUrl: DEFAULT_VOYAGE_BASE_URL
55
+ });
56
+ return {
57
+ baseUrl,
58
+ headers,
59
+ ssrfPolicy,
60
+ model: normalizeVoyageModel(options.model)
61
+ };
62
+ }
63
+ //#endregion
64
+ export { DEFAULT_VOYAGE_EMBEDDING_MODEL, createVoyageEmbeddingProvider };
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ import { voyageMemoryEmbeddingProviderAdapter } from "./memory-embedding-adapter.js";
2
+ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
3
+ //#region extensions/voyage/index.ts
4
+ var voyage_default = definePluginEntry({
5
+ id: "voyage",
6
+ name: "Voyage Embeddings",
7
+ description: "Voyage memory embedding provider plugin",
8
+ register(api) {
9
+ api.registerMemoryEmbeddingProvider(voyageMemoryEmbeddingProviderAdapter);
10
+ }
11
+ });
12
+ //#endregion
13
+ export { voyage_default as default };
@@ -0,0 +1,49 @@
1
+ import { runVoyageEmbeddingBatches } from "./embedding-batch.js";
2
+ import { DEFAULT_VOYAGE_EMBEDDING_MODEL, createVoyageEmbeddingProvider } from "./embedding-provider.js";
3
+ import { isMissingEmbeddingApiKeyError, mapBatchEmbeddingsByIndex, sanitizeEmbeddingCacheHeaders } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
4
+ //#region extensions/voyage/memory-embedding-adapter.ts
5
+ const voyageMemoryEmbeddingProviderAdapter = {
6
+ id: "voyage",
7
+ defaultModel: DEFAULT_VOYAGE_EMBEDDING_MODEL,
8
+ transport: "remote",
9
+ authProviderId: "voyage",
10
+ autoSelectPriority: 40,
11
+ allowExplicitWhenConfiguredAuto: true,
12
+ shouldContinueAutoSelection: isMissingEmbeddingApiKeyError,
13
+ create: async (options) => {
14
+ const { provider, client } = await createVoyageEmbeddingProvider({
15
+ ...options,
16
+ provider: "voyage",
17
+ fallback: "none"
18
+ });
19
+ return {
20
+ provider,
21
+ runtime: {
22
+ id: "voyage",
23
+ cacheKeyData: {
24
+ provider: "voyage",
25
+ baseUrl: client.baseUrl,
26
+ model: client.model,
27
+ headers: sanitizeEmbeddingCacheHeaders(client.headers, ["authorization"])
28
+ },
29
+ batchEmbed: async (batch) => {
30
+ return mapBatchEmbeddingsByIndex(await runVoyageEmbeddingBatches({
31
+ client,
32
+ agentId: batch.agentId,
33
+ requests: batch.chunks.map((chunk, index) => ({
34
+ custom_id: String(index),
35
+ body: { input: chunk.text }
36
+ })),
37
+ wait: batch.wait,
38
+ concurrency: batch.concurrency,
39
+ pollIntervalMs: batch.pollIntervalMs,
40
+ timeoutMs: batch.timeoutMs,
41
+ debug: batch.debug
42
+ }), batch.chunks.length);
43
+ }
44
+ }
45
+ };
46
+ }
47
+ };
48
+ //#endregion
49
+ export { voyageMemoryEmbeddingProviderAdapter };
@@ -0,0 +1,23 @@
1
+ {
2
+ "id": "voyage",
3
+ "activation": {
4
+ "onStartup": false
5
+ },
6
+ "enabledByDefault": true,
7
+ "contracts": {
8
+ "memoryEmbeddingProviders": ["voyage"]
9
+ },
10
+ "setup": {
11
+ "providers": [
12
+ {
13
+ "id": "voyage",
14
+ "envVars": ["VOYAGE_API_KEY"]
15
+ }
16
+ ]
17
+ },
18
+ "configSchema": {
19
+ "type": "object",
20
+ "additionalProperties": false,
21
+ "properties": {}
22
+ }
23
+ }
package/package.json CHANGED
@@ -1,14 +1,49 @@
1
1
  {
2
2
  "name": "@openclaw/voyage-provider",
3
- "version": "0.0.0",
4
- "description": "Reserved package name for an official OpenClaw plugin.",
5
- "license": "MIT",
3
+ "version": "2026.8.1-beta.2",
4
+ "description": "OpenClaw Voyage embedding provider plugin.",
6
5
  "repository": {
7
6
  "type": "git",
8
- "url": "git+https://github.com/openclaw/openclaw.git"
7
+ "url": "https://github.com/openclaw/openclaw"
9
8
  },
10
- "publishConfig": {
11
- "access": "public",
12
- "tag": "placeholder"
13
- }
9
+ "type": "module",
10
+ "openclaw": {
11
+ "extensions": [
12
+ "./index.ts"
13
+ ],
14
+ "install": {
15
+ "clawhubSpec": "clawhub:@openclaw/voyage-provider",
16
+ "npmSpec": "@openclaw/voyage-provider",
17
+ "defaultChoice": "npm",
18
+ "minHostVersion": ">=2026.7.2"
19
+ },
20
+ "compat": {
21
+ "pluginApi": ">=2026.8.1-beta.2"
22
+ },
23
+ "build": {
24
+ "openclawVersion": "2026.8.1-beta.2",
25
+ "bundledDist": false
26
+ },
27
+ "release": {
28
+ "publishToClawHub": true,
29
+ "publishToNpm": true
30
+ },
31
+ "runtimeExtensions": [
32
+ "./dist/index.js"
33
+ ]
34
+ },
35
+ "files": [
36
+ "dist/**",
37
+ "openclaw.plugin.json",
38
+ "README.md"
39
+ ],
40
+ "peerDependencies": {
41
+ "openclaw": ">=2026.8.1-beta.2"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "openclaw": {
45
+ "optional": true
46
+ }
47
+ },
48
+ "bundledDependencies": []
14
49
  }