@teith/openclaw-runware-provider 0.1.8 → 0.1.11
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/index.d.ts.map +1 -1
- package/dist/index.js +3 -158
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,QAAA,MAAM,KAAK,EAAE,WASZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,166 +1,11 @@
|
|
|
1
|
-
import { fetchModelIds } from "./catalog.js";
|
|
2
1
|
const PLUGIN_ID = "runware-openclaw-provider";
|
|
3
|
-
const PROVIDER_ID = "runware";
|
|
4
|
-
const PROVIDER_LABEL = "Runware";
|
|
5
|
-
const DEFAULT_BASE_URL = "https://api.runware.ai/v1";
|
|
6
|
-
const DEFAULT_MODEL = "runware/anthropic-claude-sonnet-4-6";
|
|
7
|
-
const API_KEY_ENV_VAR = "RUNWARE_API_KEY";
|
|
8
|
-
const BASE_URL_ENV_VAR = "RUNWARE_BASE_URL";
|
|
9
|
-
const REQUEST_TIMEOUT_SECONDS = 600;
|
|
10
|
-
const MODEL_CONTEXT_WINDOW = 200_000;
|
|
11
|
-
const MODEL_MAX_TOKENS = 32_768;
|
|
12
|
-
const MODEL_INPUT_MODALITIES = ["text"];
|
|
13
|
-
const MODEL_PARAMS = { extra_body: { reasoning_effort: "high" } };
|
|
14
|
-
const ZERO_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
15
|
-
function getBaseUrl(env) {
|
|
16
|
-
const override = (env?.[BASE_URL_ENV_VAR] ?? process.env[BASE_URL_ENV_VAR])?.trim();
|
|
17
|
-
return override && override.length > 0 ? override : DEFAULT_BASE_URL;
|
|
18
|
-
}
|
|
19
|
-
function resolveApiKey(ctx) {
|
|
20
|
-
return ctx?.env?.[API_KEY_ENV_VAR] ?? process.env[API_KEY_ENV_VAR];
|
|
21
|
-
}
|
|
22
|
-
function humanizeModelId(id) {
|
|
23
|
-
return id
|
|
24
|
-
.replace(/[-_:@]/g, " ")
|
|
25
|
-
.replace(/\bfp8\b/gi, "FP8")
|
|
26
|
-
.trim()
|
|
27
|
-
.split(/\s+/)
|
|
28
|
-
.map((word) => (word.length > 0 ? word[0].toUpperCase() + word.slice(1) : word))
|
|
29
|
-
.join(" ");
|
|
30
|
-
}
|
|
31
|
-
function buildModelEntry(id) {
|
|
32
|
-
return {
|
|
33
|
-
id,
|
|
34
|
-
name: humanizeModelId(id),
|
|
35
|
-
reasoning: true,
|
|
36
|
-
input: MODEL_INPUT_MODALITIES,
|
|
37
|
-
contextWindow: MODEL_CONTEXT_WINDOW,
|
|
38
|
-
maxTokens: MODEL_MAX_TOKENS,
|
|
39
|
-
cost: ZERO_COST,
|
|
40
|
-
params: MODEL_PARAMS,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
async function buildProvider(apiKey, baseUrl) {
|
|
44
|
-
const ids = await fetchModelIds(baseUrl, apiKey);
|
|
45
|
-
return {
|
|
46
|
-
baseUrl,
|
|
47
|
-
apiKey,
|
|
48
|
-
api: "openai-completions",
|
|
49
|
-
timeoutSeconds: REQUEST_TIMEOUT_SECONDS,
|
|
50
|
-
models: ids.map(buildModelEntry),
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function buildStaticProvider(baseUrl) {
|
|
54
|
-
return {
|
|
55
|
-
baseUrl,
|
|
56
|
-
apiKey: "",
|
|
57
|
-
api: "openai-completions",
|
|
58
|
-
timeoutSeconds: REQUEST_TIMEOUT_SECONDS,
|
|
59
|
-
models: [],
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function resolveApiKeyFromCatalogContext(ctx) {
|
|
63
|
-
const fromAuth = ctx.resolveProviderApiKey?.(PROVIDER_ID).apiKey;
|
|
64
|
-
if (fromAuth && fromAuth.length > 0)
|
|
65
|
-
return fromAuth;
|
|
66
|
-
return resolveApiKey(ctx);
|
|
67
|
-
}
|
|
68
|
-
function buildAgentModelsPatch(provider) {
|
|
69
|
-
const patch = {};
|
|
70
|
-
for (const model of provider.models) {
|
|
71
|
-
const key = `${PROVIDER_ID}/${model.id}`;
|
|
72
|
-
patch[key] = model.params ? { params: model.params } : {};
|
|
73
|
-
}
|
|
74
|
-
return patch;
|
|
75
|
-
}
|
|
76
|
-
async function authFlow(ctx) {
|
|
77
|
-
const apiKey = resolveApiKey(ctx);
|
|
78
|
-
if (!apiKey) {
|
|
79
|
-
throw new Error(`${API_KEY_ENV_VAR} is not set. Export it before running auth.`);
|
|
80
|
-
}
|
|
81
|
-
const provider = await buildProvider(apiKey, getBaseUrl(ctx.env));
|
|
82
|
-
return {
|
|
83
|
-
profiles: [
|
|
84
|
-
{
|
|
85
|
-
profileId: `${PROVIDER_ID}:default`,
|
|
86
|
-
provider: PROVIDER_ID,
|
|
87
|
-
credential: { type: "api-key", provider: PROVIDER_ID, apiKey },
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
defaultModel: DEFAULT_MODEL,
|
|
91
|
-
configPatch: {
|
|
92
|
-
models: { providers: { [PROVIDER_ID]: provider } },
|
|
93
|
-
agents: { defaults: { models: buildAgentModelsPatch(provider) } },
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
2
|
const entry = {
|
|
98
3
|
id: PLUGIN_ID,
|
|
99
4
|
name: "Runware",
|
|
100
5
|
description: "Runware — unified OpenAI-compatible access to Claude, GPT, Gemini, Qwen, GLM, MiniMax, Kimi, and Gemma.",
|
|
101
|
-
register(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
label: PROVIDER_LABEL,
|
|
105
|
-
docsPath: "https://docs.runware.ai",
|
|
106
|
-
envVars: [API_KEY_ENV_VAR, BASE_URL_ENV_VAR],
|
|
107
|
-
auth: [
|
|
108
|
-
{
|
|
109
|
-
id: "runware",
|
|
110
|
-
kind: "custom",
|
|
111
|
-
label: PROVIDER_LABEL,
|
|
112
|
-
hint: `Runware API key — set ${API_KEY_ENV_VAR} or get one at https://runware.ai`,
|
|
113
|
-
envVar: API_KEY_ENV_VAR,
|
|
114
|
-
flagName: "--runware-api-key",
|
|
115
|
-
optionKey: "runwareApiKey",
|
|
116
|
-
promptMessage: "Enter your Runware API key",
|
|
117
|
-
defaultModel: DEFAULT_MODEL,
|
|
118
|
-
run: authFlow,
|
|
119
|
-
runNonInteractive: authFlow,
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
catalog: {
|
|
123
|
-
order: "simple",
|
|
124
|
-
run: async (ctx) => {
|
|
125
|
-
const apiKey = resolveApiKeyFromCatalogContext(ctx);
|
|
126
|
-
if (!apiKey)
|
|
127
|
-
return null;
|
|
128
|
-
return { provider: await buildProvider(apiKey, getBaseUrl(ctx.env)) };
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
staticCatalog: {
|
|
132
|
-
order: "simple",
|
|
133
|
-
run: async (ctx) => {
|
|
134
|
-
const apiKey = resolveApiKeyFromCatalogContext(ctx);
|
|
135
|
-
const baseUrl = getBaseUrl(ctx.env);
|
|
136
|
-
if (!apiKey)
|
|
137
|
-
return { provider: buildStaticProvider(baseUrl) };
|
|
138
|
-
try {
|
|
139
|
-
return { provider: await buildProvider(apiKey, baseUrl) };
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
return { provider: buildStaticProvider(baseUrl) };
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
wizard: {
|
|
147
|
-
setup: {
|
|
148
|
-
choiceId: "runware",
|
|
149
|
-
choiceLabel: "Runware",
|
|
150
|
-
choiceHint: "Runware multi-model gateway",
|
|
151
|
-
groupId: "runware",
|
|
152
|
-
groupLabel: "Runware",
|
|
153
|
-
groupHint: "Runware multi-model gateway",
|
|
154
|
-
methodId: "api-key",
|
|
155
|
-
},
|
|
156
|
-
modelPicker: {
|
|
157
|
-
label: "Runware",
|
|
158
|
-
hint: "Enter your Runware API key",
|
|
159
|
-
methodId: "api-key",
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
buildUnknownModelHint: () => `Runware requires authentication. Set ${API_KEY_ENV_VAR} or run "openclaw models auth login --provider runware".`,
|
|
163
|
-
});
|
|
6
|
+
register() {
|
|
7
|
+
// All provider surfaces (auth, catalog, staticCatalog) are declared in
|
|
8
|
+
// ./provider-discovery.js as the manifest's providerCatalogEntry.
|
|
164
9
|
},
|
|
165
10
|
};
|
|
166
11
|
export default entry;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAE9C,MAAM,KAAK,GAAgB;IACzB,EAAE,EAAE,SAAS;IACb,IAAI,EAAE,SAAS;IACf,WAAW,EACT,yGAAyG;IAC3G,QAAQ;QACN,uEAAuE;QACvE,kEAAkE;IACpE,CAAC;CACF,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teith/openclaw-runware-provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "OpenClaw provider plugin for Runware — unified OpenAI-compatible access to Claude, GPT, Gemini, Qwen, GLM, MiniMax, Kimi, and Gemma.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|