@openclaw/inworld-speech 2026.11.3 → 2026.11.5-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.
@@ -0,0 +1 @@
1
+ {"version":3,"entries":[{"output":"capability-catalog.js","source":"extensions/inworld/capability-catalog.ts"},{"output":"index.js","source":"extensions/inworld/index.ts"},{"output":"speech-provider.js","source":"extensions/inworld/speech-provider.ts"},{"output":"tts.js","source":"extensions/inworld/tts.ts"}],"chunks":[{"output":"capability-catalog.js","sha256":"f5e8d3d7c9735e066f95e3abc0ac1b7f6a980d7575be93faa50791c8fa3913a0","facadeSource":"extensions/inworld/capability-catalog.ts","sources":["extensions/inworld/capability-catalog.ts"]},{"output":"index.js","sha256":"8cd12045b3cb3e14348379796bf4cfebdd969ec60a87bf8760ba369b7f7b89d1","facadeSource":"extensions/inworld/index.ts","sources":["extensions/inworld/index.ts"]},{"output":"speech-provider.js","sha256":"857ef2d89842cc0ea6857fc059c337ad3abeaa542ef67d653cf69f32fd25107c","facadeSource":"extensions/inworld/speech-provider.ts","sources":["extensions/inworld/speech-provider.ts"]},{"output":"tts.js","sha256":"cec8b0fe751467cad256f43adf8b65f7137289933b07ce3131430294759d35ba","facadeSource":"extensions/inworld/tts.ts","sources":["extensions/inworld/tts.ts"]}],"unrenderedSources":[]}
@@ -1,6 +1,6 @@
1
- import { DEFAULT_INWORLD_MODEL_ID, INWORLD_TTS_MODELS, inworldTTS, listInworldVoices, normalizeInworldBaseUrl } from "./tts.js";
1
+ import { DEFAULT_INWORLD_MODEL_ID, INWORLD_DELIVERY_MODES, INWORLD_TTS_MODELS, inworldTTS, listInworldVoices, normalizeInworldBaseUrl } from "./tts.js";
2
2
  import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
3
- import { parseSpeechDirectiveNumberOverride, resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-provider";
3
+ import { createSpeechDirectiveParser, resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-provider";
4
4
  import { asFiniteNumberInRange, asOptionalRecord, filterStringRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  //#region extensions/inworld/speech-provider.ts
6
6
  function normalizeInworldTemperature(value) {
@@ -10,9 +10,20 @@ function normalizeInworldTemperature(value) {
10
10
  max: 2
11
11
  });
12
12
  }
13
+ const INWORLD_SPEAKING_RATE_RANGE = {
14
+ min: .5,
15
+ max: 1.5
16
+ };
17
+ function normalizeInworldSpeakingRate(value) {
18
+ return asFiniteNumberInRange(value, INWORLD_SPEAKING_RATE_RANGE);
19
+ }
20
+ function normalizeInworldDeliveryMode(value) {
21
+ const normalized = normalizeOptionalString(value)?.toUpperCase();
22
+ return INWORLD_DELIVERY_MODES.find((mode) => mode === normalized);
23
+ }
13
24
  function normalizeInworldProviderConfig(rawConfig) {
14
25
  const providers = asOptionalRecord(rawConfig.providers);
15
- const raw = asOptionalRecord(providers?.inworld) ?? asOptionalRecord(rawConfig.inworld);
26
+ const raw = asOptionalRecord(providers?.inworld);
16
27
  return {
17
28
  apiKey: normalizeResolvedSecretInputString({
18
29
  value: raw?.apiKey,
@@ -21,14 +32,16 @@ function normalizeInworldProviderConfig(rawConfig) {
21
32
  baseUrl: normalizeInworldBaseUrl(normalizeOptionalString(raw?.baseUrl)),
22
33
  voiceId: normalizeOptionalString(raw?.voiceId) ?? "Sarah",
23
34
  modelId: normalizeOptionalString(raw?.modelId) ?? "inworld-tts-1.5-max",
24
- temperature: normalizeInworldTemperature(raw?.temperature)
35
+ temperature: normalizeInworldTemperature(raw?.temperature),
36
+ speakingRate: normalizeInworldSpeakingRate(raw?.speakingRate),
37
+ deliveryMode: normalizeInworldDeliveryMode(raw?.deliveryMode)
25
38
  };
26
39
  }
27
40
  function readInworldProviderConfig(config) {
28
- return normalizeInworldProviderConfig({ inworld: {
41
+ return normalizeInworldProviderConfig({ providers: { inworld: {
29
42
  ...config,
30
43
  apiKey: normalizeOptionalString(config.apiKey)
31
- } });
44
+ } } });
32
45
  }
33
46
  function resolveInworldApiKey(primary, fallback) {
34
47
  return resolveSpeechProviderApiKey(primary, fallback, process.env.INWORLD_API_KEY);
@@ -47,39 +60,72 @@ async function synthesizeInworld(req) {
47
60
  audioEncoding: req.audioEncoding,
48
61
  ...req.sampleRateHertz === void 0 ? {} : { sampleRateHertz: req.sampleRateHertz },
49
62
  temperature: normalizeInworldTemperature(overrides?.temperature) ?? config.temperature,
63
+ speakingRate: normalizeInworldSpeakingRate(overrides?.speakingRate ?? overrides?.speed) ?? config.speakingRate,
64
+ deliveryMode: normalizeInworldDeliveryMode(overrides?.deliveryMode) ?? config.deliveryMode,
50
65
  timeoutMs: req.timeoutMs
51
66
  });
52
67
  }
53
- function parseDirectiveToken(ctx) {
54
- if (ctx.key === "temperature") return parseSpeechDirectiveNumberOverride({
55
- ctx,
56
- overrideKey: "temperature",
57
- range: {
58
- min: 0,
59
- minExclusive: true,
60
- max: 2
61
- },
62
- warning: (value) => `invalid Inworld temperature "${value}"`
63
- });
64
- const key = [
68
+ const parseDirectiveToken = createSpeechDirectiveParser({
69
+ temperature: [
70
+ "allowVoiceSettings",
71
+ ["temperature"],
72
+ { number: {
73
+ range: {
74
+ min: 0,
75
+ minExclusive: true,
76
+ max: 2
77
+ },
78
+ warning: (value) => `invalid Inworld temperature "${value}"`
79
+ } }
80
+ ],
81
+ voiceId: ["allowVoice", [
65
82
  "voice",
66
83
  "voiceid",
67
84
  "voice_id",
68
85
  "inworld_voice",
69
86
  "inworldvoice"
70
- ].includes(ctx.key) ? "voiceId" : [
87
+ ]],
88
+ modelId: ["allowModelId", [
71
89
  "model",
72
90
  "modelid",
73
91
  "model_id",
74
92
  "inworld_model",
75
93
  "inworldmodel"
76
- ].includes(ctx.key) ? "modelId" : void 0;
77
- if (!key) return { handled: false };
78
- return (key === "voiceId" ? ctx.policy.allowVoice : ctx.policy.allowModelId) ? {
79
- handled: true,
80
- overrides: { [key]: ctx.value }
81
- } : { handled: true };
82
- }
94
+ ]],
95
+ speakingRate: [
96
+ "allowVoiceSettings",
97
+ [
98
+ "speed",
99
+ "speaking_rate",
100
+ "speakingrate",
101
+ "inworld_speed",
102
+ "inworldspeed"
103
+ ],
104
+ { number: {
105
+ range: INWORLD_SPEAKING_RATE_RANGE,
106
+ warning: (value) => `invalid Inworld speaking rate "${value}" (0.5-1.5)`
107
+ } }
108
+ ],
109
+ deliveryMode: [
110
+ "allowVoiceSettings",
111
+ [
112
+ "delivery",
113
+ "delivery_mode",
114
+ "deliverymode",
115
+ "inworld_delivery"
116
+ ],
117
+ { parse: ({ value }) => {
118
+ const deliveryMode = normalizeInworldDeliveryMode(value);
119
+ return deliveryMode ? {
120
+ handled: true,
121
+ overrides: { deliveryMode }
122
+ } : {
123
+ handled: true,
124
+ warnings: [`invalid Inworld delivery mode "${value}" (stable, balanced, creative)`]
125
+ };
126
+ } }
127
+ ]
128
+ });
83
129
  function buildInworldSpeechProvider() {
84
130
  const isConfigured = ({ providerConfig }) => Boolean(resolveInworldApiKey(readInworldProviderConfig(providerConfig).apiKey));
85
131
  return {
@@ -104,7 +150,9 @@ function buildInworldSpeechProvider() {
104
150
  voiceId: normalizeOptionalString(talkProviderConfig.voiceId),
105
151
  modelId: normalizeOptionalString(talkProviderConfig.modelId)
106
152
  }),
107
- ...normalizeInworldTemperature(talkProviderConfig.temperature) == null ? {} : { temperature: normalizeInworldTemperature(talkProviderConfig.temperature) }
153
+ temperature: normalizeInworldTemperature(talkProviderConfig.temperature) ?? base.temperature,
154
+ speakingRate: normalizeInworldSpeakingRate(talkProviderConfig.speakingRate) ?? base.speakingRate,
155
+ deliveryMode: normalizeInworldDeliveryMode(talkProviderConfig.deliveryMode) ?? base.deliveryMode
108
156
  };
109
157
  },
110
158
  resolveTalkOverrides: ({ params }) => ({
@@ -112,7 +160,8 @@ function buildInworldSpeechProvider() {
112
160
  voiceId: normalizeOptionalString(params.voiceId),
113
161
  modelId: normalizeOptionalString(params.modelId)
114
162
  }),
115
- ...normalizeInworldTemperature(params.temperature) == null ? {} : { temperature: normalizeInworldTemperature(params.temperature) }
163
+ ...normalizeInworldTemperature(params.temperature) == null ? {} : { temperature: normalizeInworldTemperature(params.temperature) },
164
+ ...normalizeInworldSpeakingRate(params.speed) == null ? {} : { speakingRate: normalizeInworldSpeakingRate(params.speed) }
116
165
  }),
117
166
  listVoices: async (req) => {
118
167
  const config = req.providerConfig ? readInworldProviderConfig(req.providerConfig) : void 0;
package/dist/tts.js CHANGED
@@ -27,7 +27,14 @@ const INWORLD_TTS_MODELS = [
27
27
  "inworld-tts-1.5-max",
28
28
  "inworld-tts-1.5-mini",
29
29
  "inworld-tts-1-max",
30
- "inworld-tts-1"
30
+ "inworld-tts-1",
31
+ "inworld-tts-2",
32
+ "inworld-tts-2-flash"
33
+ ];
34
+ const INWORLD_DELIVERY_MODES = [
35
+ "STABLE",
36
+ "BALANCED",
37
+ "CREATIVE"
31
38
  ];
32
39
  function normalizeInworldBaseUrl(baseUrl) {
33
40
  return (baseUrl?.trim())?.replace(/\/+$/, "") || DEFAULT_INWORLD_BASE_URL;
@@ -41,51 +48,63 @@ function ssrfPolicyFromInworldBaseUrl(baseUrl) {
41
48
  return;
42
49
  }
43
50
  }
44
- /**
45
- * Calls the Inworld streaming TTS endpoint and concatenates every audio chunk
46
- * into a single buffer. The stream returns newline-delimited JSON, each line
47
- * carrying base64 audio in `result.audioContent`.
48
- */
49
- async function inworldTTS(params) {
50
- const { canonicalizeBase64, MAX_AUDIO_BYTES } = await import("openclaw/plugin-sdk/media-runtime");
51
- const INWORLD_TTS_BODY_MAX_BYTES = MAX_AUDIO_BYTES * 2;
51
+ async function requestInworldText(params, request, maxAudioBytes, parse) {
52
52
  const baseUrl = normalizeInworldBaseUrl(params.baseUrl);
53
- const url = `${baseUrl}/tts/v1/voice:stream`;
54
- const requestBody = JSON.stringify({
55
- text: params.text,
56
- voiceId: params.voiceId ?? "Sarah",
57
- modelId: params.modelId ?? "inworld-tts-1.5-max",
58
- audioConfig: {
59
- audioEncoding: params.audioEncoding ?? "MP3",
60
- ...params.sampleRateHertz && { sampleRateHertz: params.sampleRateHertz }
61
- },
62
- ...params.temperature != null && { temperature: params.temperature }
63
- });
53
+ const isTts = request.kind === "tts";
54
+ const apiLabel = isTts ? "TTS" : "voices";
55
+ const bodyLabel = isTts ? "TTS audio stream" : "voices response";
64
56
  const { fetchWithSsrFGuard } = await import("openclaw/plugin-sdk/ssrf-runtime");
65
57
  const { response, release } = await fetchWithSsrFGuard({
66
- url,
58
+ url: `${baseUrl}/${isTts ? "tts/v1/voice:stream" : "voices/v1/voices"}`,
67
59
  init: {
68
- method: "POST",
60
+ method: isTts ? "POST" : "GET",
69
61
  headers: {
70
- "Content-Type": "application/json",
62
+ ...isTts ? { "Content-Type": "application/json" } : {},
71
63
  Authorization: `Basic ${params.apiKey}`
72
64
  },
73
- body: requestBody
65
+ ...request.kind === "tts" ? { body: request.body } : {}
74
66
  },
75
- timeoutMs: params.timeoutMs,
67
+ timeoutMs: isTts ? params.timeoutMs : params.timeoutMs ?? INWORLD_UPSTREAM_IDLE_TIMEOUT_MS,
76
68
  policy: ssrfPolicyFromInworldBaseUrl(baseUrl),
77
- auditContext: "inworld-tts"
69
+ auditContext: isTts ? "inworld-tts" : "inworld-voices"
78
70
  });
79
71
  try {
80
72
  if (!response.ok) {
81
73
  const errorBody = await readInworldErrorBodySnippet(response);
82
- throw new Error(`Inworld TTS API error (${response.status}): ${errorBody}`);
74
+ throw new Error(`Inworld ${apiLabel} API error (${response.status}): ${errorBody}`);
83
75
  }
84
- const body = (await readResponseWithLimit(response, INWORLD_TTS_BODY_MAX_BYTES, {
76
+ return parse((await readResponseWithLimit(response, maxAudioBytes * (isTts ? 2 : 1), {
85
77
  chunkTimeoutMs: INWORLD_UPSTREAM_IDLE_TIMEOUT_MS,
86
- onOverflow: ({ size, maxBytes }) => /* @__PURE__ */ new Error(`Inworld TTS audio stream too large: ${size} bytes (limit: ${maxBytes} bytes)`),
87
- onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`Inworld TTS audio stream stalled: no data received for ${chunkTimeoutMs}ms`)
88
- })).toString("utf8");
78
+ onOverflow: ({ size, maxBytes }) => /* @__PURE__ */ new Error(`Inworld ${bodyLabel} too large: ${size} bytes (limit: ${maxBytes} bytes)`),
79
+ onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`Inworld ${bodyLabel} stalled: no data received for ${chunkTimeoutMs}ms`)
80
+ })).toString("utf8"));
81
+ } finally {
82
+ await release();
83
+ }
84
+ }
85
+ /**
86
+ * Calls the Inworld streaming TTS endpoint and concatenates every audio chunk
87
+ * into a single buffer. The stream returns newline-delimited JSON, each line
88
+ * carrying base64 audio in `result.audioContent`.
89
+ */
90
+ async function inworldTTS(params) {
91
+ const { canonicalizeBase64, MAX_AUDIO_BYTES } = await import("openclaw/plugin-sdk/media-runtime");
92
+ const modelId = params.modelId ?? "inworld-tts-1.5-max";
93
+ return await requestInworldText(params, {
94
+ kind: "tts",
95
+ body: JSON.stringify({
96
+ text: params.text,
97
+ voiceId: params.voiceId ?? "Sarah",
98
+ modelId,
99
+ audioConfig: {
100
+ audioEncoding: params.audioEncoding ?? "MP3",
101
+ ...params.sampleRateHertz && { sampleRateHertz: params.sampleRateHertz },
102
+ ...params.speakingRate != null && { speakingRate: params.speakingRate }
103
+ },
104
+ ...params.temperature != null && { temperature: params.temperature },
105
+ ...modelId === "inworld-tts-2" && params.deliveryMode ? { deliveryMode: params.deliveryMode } : {}
106
+ })
107
+ }, MAX_AUDIO_BYTES, (body) => {
89
108
  const chunks = [];
90
109
  let decodedAudioBytes = 0;
91
110
  for (const line of body.split("\n")) {
@@ -110,36 +129,11 @@ async function inworldTTS(params) {
110
129
  }
111
130
  if (chunks.length === 0) throw new Error("Inworld TTS returned no audio data");
112
131
  return Buffer.concat(chunks);
113
- } finally {
114
- await release();
115
- }
132
+ });
116
133
  }
117
134
  async function listInworldVoices(params) {
118
135
  const { MAX_AUDIO_BYTES } = await import("openclaw/plugin-sdk/media-runtime");
119
- const INWORLD_VOICES_BODY_MAX_BYTES = MAX_AUDIO_BYTES;
120
- const baseUrl = normalizeInworldBaseUrl(params.baseUrl);
121
- const url = `${baseUrl}/voices/v1/voices${params.language ? `?languages=${encodeURIComponent(params.language)}` : ""}`;
122
- const { fetchWithSsrFGuard } = await import("openclaw/plugin-sdk/ssrf-runtime");
123
- const { response, release } = await fetchWithSsrFGuard({
124
- url,
125
- init: {
126
- method: "GET",
127
- headers: { Authorization: `Basic ${params.apiKey}` }
128
- },
129
- timeoutMs: params.timeoutMs ?? INWORLD_UPSTREAM_IDLE_TIMEOUT_MS,
130
- policy: ssrfPolicyFromInworldBaseUrl(baseUrl),
131
- auditContext: "inworld-voices"
132
- });
133
- try {
134
- if (!response.ok) {
135
- const errorBody = await readInworldErrorBodySnippet(response);
136
- throw new Error(`Inworld voices API error (${response.status}): ${errorBody}`);
137
- }
138
- const voicesBody = (await readResponseWithLimit(response, INWORLD_VOICES_BODY_MAX_BYTES, {
139
- chunkTimeoutMs: INWORLD_UPSTREAM_IDLE_TIMEOUT_MS,
140
- onOverflow: ({ size, maxBytes }) => /* @__PURE__ */ new Error(`Inworld voices response too large: ${size} bytes (limit: ${maxBytes} bytes)`),
141
- onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`Inworld voices response stalled: no data received for ${chunkTimeoutMs}ms`)
142
- })).toString("utf8");
136
+ return await requestInworldText(params, { kind: "voices" }, MAX_AUDIO_BYTES, (voicesBody) => {
143
137
  let json;
144
138
  try {
145
139
  json = JSON.parse(voicesBody);
@@ -153,9 +147,7 @@ async function listInworldVoices(params) {
153
147
  locale: voice.langCode || void 0,
154
148
  gender: voice.tags?.find((t) => t === "male" || t === "female") || void 0
155
149
  })).filter((voice) => voice.id.length > 0) : [];
156
- } finally {
157
- await release();
158
- }
150
+ });
159
151
  }
160
152
  //#endregion
161
- export { DEFAULT_INWORLD_MODEL_ID, DEFAULT_INWORLD_VOICE_ID, INWORLD_TTS_MODELS, inworldTTS, listInworldVoices, normalizeInworldBaseUrl };
153
+ export { DEFAULT_INWORLD_MODEL_ID, DEFAULT_INWORLD_VOICE_ID, INWORLD_DELIVERY_MODES, INWORLD_TTS_MODELS, inworldTTS, listInworldVoices, normalizeInworldBaseUrl };
@@ -42,7 +42,9 @@
42
42
  "properties": [
43
43
  "voiceId",
44
44
  "modelId",
45
- "temperature"
45
+ "temperature",
46
+ "speakingRate",
47
+ "deliveryMode"
46
48
  ]
47
49
  }
48
50
  ],
@@ -64,13 +66,28 @@
64
66
  },
65
67
  "modelId": {
66
68
  "type": "string",
67
- "description": "TTS model id (default inworld-tts-1.5-max)."
69
+ "description": "TTS model id (default inworld-tts-1.5-max; also inworld-tts-2, inworld-tts-2-flash)."
68
70
  },
69
71
  "temperature": {
70
72
  "type": "number",
71
73
  "minimum": 0,
72
74
  "maximum": 2,
73
75
  "description": "Sampling temperature 0..2."
76
+ },
77
+ "speakingRate": {
78
+ "type": "number",
79
+ "minimum": 0.5,
80
+ "maximum": 1.5,
81
+ "description": "Speaking rate 0.5..1.5 (1.0 is the voice's native speed)."
82
+ },
83
+ "deliveryMode": {
84
+ "type": "string",
85
+ "enum": [
86
+ "STABLE",
87
+ "BALANCED",
88
+ "CREATIVE"
89
+ ],
90
+ "description": "Delivery preset, honored only by inworld-tts-2 (which ignores temperature); Not sent to other models."
74
91
  }
75
92
  }
76
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/inworld-speech",
3
- "version": "2026.11.3",
3
+ "version": "2026.11.5-beta.2",
4
4
  "description": "OpenClaw Inworld speech plugin.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,10 +18,10 @@
18
18
  "minHostVersion": ">=2026.6.8"
19
19
  },
20
20
  "compat": {
21
- "pluginApi": ">=2026.11.3"
21
+ "pluginApi": ">=2026.11.5-beta.2"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.11.3",
24
+ "openclawVersion": "2026.11.5-beta.2",
25
25
  "bundledDist": false
26
26
  },
27
27
  "release": {
@@ -40,7 +40,7 @@
40
40
  "assets/activity.svg"
41
41
  ],
42
42
  "peerDependencies": {
43
- "openclaw": ">=2026.11.3"
43
+ "openclaw": ">=2026.11.5-beta.2"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "openclaw": {