@inworld/cli 1.0.0-rc.3 → 1.0.0-rc.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/cli/inworld-mcp.js +341 -4
- package/dist/index.js +35714 -23853
- package/package.json +18 -2
package/dist/cli/inworld-mcp.js
CHANGED
|
@@ -62399,13 +62399,15 @@ function hasStoredCredentials() {
|
|
|
62399
62399
|
return typeof s.firebaseRefreshToken === "string" && s.firebaseRefreshToken.length > 0;
|
|
62400
62400
|
}
|
|
62401
62401
|
async function hasUsableAuthCredentials() {
|
|
62402
|
+
if (process.env.INWORLD_API_KEY?.trim()) return true;
|
|
62402
62403
|
if (hasStoredCredentials()) return true;
|
|
62403
62404
|
try {
|
|
62404
62405
|
const c = await readStoredCredentials();
|
|
62405
|
-
|
|
62406
|
+
if (c?.refreshToken?.trim()) return true;
|
|
62407
|
+
if (c?.apiKey?.trim()) return true;
|
|
62406
62408
|
} catch {
|
|
62407
|
-
return false;
|
|
62408
62409
|
}
|
|
62410
|
+
return false;
|
|
62409
62411
|
}
|
|
62410
62412
|
var TIME_DIFF_MS;
|
|
62411
62413
|
var init_session = __esm({
|
|
@@ -62877,6 +62879,139 @@ var init_studio_config = __esm({
|
|
|
62877
62879
|
}
|
|
62878
62880
|
});
|
|
62879
62881
|
|
|
62882
|
+
// src/mcp/inworld/studio-api.ts
|
|
62883
|
+
async function requireApiKey() {
|
|
62884
|
+
const fromEnv = process.env.INWORLD_API_KEY?.trim();
|
|
62885
|
+
if (fromEnv) return fromEnv;
|
|
62886
|
+
try {
|
|
62887
|
+
const creds = await readStoredCredentials();
|
|
62888
|
+
const k = creds?.apiKey?.trim();
|
|
62889
|
+
if (k) return k;
|
|
62890
|
+
} catch {
|
|
62891
|
+
}
|
|
62892
|
+
throw new Error(
|
|
62893
|
+
"No Inworld API key available. Set INWORLD_API_KEY in the environment, or run `inworld workspace select-key` from a terminal to bind one to the local credential store (shared with this MCP server)."
|
|
62894
|
+
);
|
|
62895
|
+
}
|
|
62896
|
+
function studioBase() {
|
|
62897
|
+
return getStudioApiUrl().replace(/\/$/, "");
|
|
62898
|
+
}
|
|
62899
|
+
function parseJson(text, label, status) {
|
|
62900
|
+
if (!text) return {};
|
|
62901
|
+
try {
|
|
62902
|
+
return JSON.parse(text);
|
|
62903
|
+
} catch {
|
|
62904
|
+
throw new Error(
|
|
62905
|
+
`${label}: expected JSON (HTTP ${status}): ${text.slice(0, 400)}`
|
|
62906
|
+
);
|
|
62907
|
+
}
|
|
62908
|
+
}
|
|
62909
|
+
function extractMessage(data, fallbackStatus) {
|
|
62910
|
+
if (data && typeof data === "object") {
|
|
62911
|
+
const o = data;
|
|
62912
|
+
if (typeof o.message === "string") return o.message;
|
|
62913
|
+
const inner = o.error;
|
|
62914
|
+
if (inner && typeof inner === "object" && typeof inner.message === "string") {
|
|
62915
|
+
return inner.message;
|
|
62916
|
+
}
|
|
62917
|
+
}
|
|
62918
|
+
return `HTTP ${fallbackStatus}`;
|
|
62919
|
+
}
|
|
62920
|
+
async function studioApiGet(pathAndQuery, label = "Studio API") {
|
|
62921
|
+
const apiKey = await requireApiKey();
|
|
62922
|
+
const path7 = pathAndQuery.startsWith("/") ? pathAndQuery : `/${pathAndQuery}`;
|
|
62923
|
+
const res = await fetch(`${studioBase()}${path7}`, {
|
|
62924
|
+
method: "GET",
|
|
62925
|
+
headers: {
|
|
62926
|
+
Authorization: `Basic ${apiKey}`,
|
|
62927
|
+
Accept: "application/json"
|
|
62928
|
+
}
|
|
62929
|
+
});
|
|
62930
|
+
const text = await res.text();
|
|
62931
|
+
const data = parseJson(text, label, res.status);
|
|
62932
|
+
if (!res.ok) {
|
|
62933
|
+
throw new Error(`${label}: ${extractMessage(data, res.status)}`);
|
|
62934
|
+
}
|
|
62935
|
+
return data;
|
|
62936
|
+
}
|
|
62937
|
+
async function studioApiPostJson(path7, body, label = "Studio API") {
|
|
62938
|
+
const apiKey = await requireApiKey();
|
|
62939
|
+
const p = path7.startsWith("/") ? path7 : `/${path7}`;
|
|
62940
|
+
const res = await fetch(`${studioBase()}${p}`, {
|
|
62941
|
+
method: "POST",
|
|
62942
|
+
headers: {
|
|
62943
|
+
Authorization: `Basic ${apiKey}`,
|
|
62944
|
+
"Content-Type": "application/json",
|
|
62945
|
+
Accept: "application/json"
|
|
62946
|
+
},
|
|
62947
|
+
body: JSON.stringify(body)
|
|
62948
|
+
});
|
|
62949
|
+
const text = await res.text();
|
|
62950
|
+
const data = parseJson(text, label, res.status);
|
|
62951
|
+
if (!res.ok) {
|
|
62952
|
+
throw new Error(`${label}: ${extractMessage(data, res.status)}`);
|
|
62953
|
+
}
|
|
62954
|
+
return data;
|
|
62955
|
+
}
|
|
62956
|
+
var init_studio_api = __esm({
|
|
62957
|
+
"src/mcp/inworld/studio-api.ts"() {
|
|
62958
|
+
"use strict";
|
|
62959
|
+
init_dist5();
|
|
62960
|
+
init_studio_config();
|
|
62961
|
+
}
|
|
62962
|
+
});
|
|
62963
|
+
|
|
62964
|
+
// src/mcp/llm/chat.ts
|
|
62965
|
+
async function completeChat(req) {
|
|
62966
|
+
const model = req.model?.trim();
|
|
62967
|
+
if (!model) {
|
|
62968
|
+
throw new Error("model is required (e.g. 'gpt-4o-mini')");
|
|
62969
|
+
}
|
|
62970
|
+
if (!req.messages?.length) {
|
|
62971
|
+
throw new Error("messages array is required and must be non-empty");
|
|
62972
|
+
}
|
|
62973
|
+
const body = {
|
|
62974
|
+
servingId: {
|
|
62975
|
+
modelId: {
|
|
62976
|
+
model,
|
|
62977
|
+
serviceProvider: req.serviceProvider ?? "SERVICE_PROVIDER_OPENAI"
|
|
62978
|
+
},
|
|
62979
|
+
// The endpoint rejects requests with an empty user id; default to a
|
|
62980
|
+
// stable string when the caller doesn't provide one.
|
|
62981
|
+
userId: req.userId ?? "inworld-mcp"
|
|
62982
|
+
},
|
|
62983
|
+
messages: req.messages,
|
|
62984
|
+
textGenerationConfig: {
|
|
62985
|
+
...req.maxTokens !== void 0 ? { maxTokens: req.maxTokens } : {},
|
|
62986
|
+
...req.temperature !== void 0 ? { temperature: req.temperature } : {},
|
|
62987
|
+
...req.topP !== void 0 ? { topP: req.topP } : {},
|
|
62988
|
+
stream: false
|
|
62989
|
+
}
|
|
62990
|
+
};
|
|
62991
|
+
return studioApiPostJson(
|
|
62992
|
+
"/llm/v1alpha/completions:completeChat",
|
|
62993
|
+
body,
|
|
62994
|
+
"LLM completeChat"
|
|
62995
|
+
);
|
|
62996
|
+
}
|
|
62997
|
+
var init_chat = __esm({
|
|
62998
|
+
"src/mcp/llm/chat.ts"() {
|
|
62999
|
+
"use strict";
|
|
63000
|
+
init_studio_api();
|
|
63001
|
+
}
|
|
63002
|
+
});
|
|
63003
|
+
|
|
63004
|
+
// src/mcp/llm/models.ts
|
|
63005
|
+
async function listModels() {
|
|
63006
|
+
return studioApiGet("/llm/v1alpha/models", "LLM listModels");
|
|
63007
|
+
}
|
|
63008
|
+
var init_models = __esm({
|
|
63009
|
+
"src/mcp/llm/models.ts"() {
|
|
63010
|
+
"use strict";
|
|
63011
|
+
init_studio_api();
|
|
63012
|
+
}
|
|
63013
|
+
});
|
|
63014
|
+
|
|
62880
63015
|
// src/mcp/workspace/gateway.ts
|
|
62881
63016
|
function workspaceResourceName(workspaceId) {
|
|
62882
63017
|
const id = workspaceId.trim();
|
|
@@ -63001,12 +63136,12 @@ var init_engine_session = __esm({
|
|
|
63001
63136
|
});
|
|
63002
63137
|
|
|
63003
63138
|
// src/mcp/router/gateway.ts
|
|
63004
|
-
function
|
|
63139
|
+
function studioBase2() {
|
|
63005
63140
|
return getStudioApiUrl().replace(/\/$/, "");
|
|
63006
63141
|
}
|
|
63007
63142
|
async function studioEngineJson(workspaceId, method, path7, body) {
|
|
63008
63143
|
const engine = await fetchWorkspaceEngineSession(workspaceId);
|
|
63009
|
-
const url = `${
|
|
63144
|
+
const url = `${studioBase2()}${path7.startsWith("/") ? path7 : `/${path7}`}`;
|
|
63010
63145
|
const headers = {
|
|
63011
63146
|
Authorization: `Bearer ${engine.token}`,
|
|
63012
63147
|
Accept: "application/json"
|
|
@@ -63169,6 +63304,46 @@ var init_gateway2 = __esm({
|
|
|
63169
63304
|
}
|
|
63170
63305
|
});
|
|
63171
63306
|
|
|
63307
|
+
// src/mcp/stt/transcribe.ts
|
|
63308
|
+
async function transcribeSpeech(req) {
|
|
63309
|
+
if (!req.audioBase64 || !req.audioBase64.trim()) {
|
|
63310
|
+
throw new Error("audioBase64 is required (raw base64 \u2014 no data: prefix)");
|
|
63311
|
+
}
|
|
63312
|
+
const body = {
|
|
63313
|
+
transcribeConfig: {
|
|
63314
|
+
modelId: req.modelId ?? "inworld/inworld-stt-1",
|
|
63315
|
+
audioEncoding: req.audioEncoding ?? "AUTO_DETECT",
|
|
63316
|
+
...req.language ? { language: req.language } : {}
|
|
63317
|
+
},
|
|
63318
|
+
audioData: { content: req.audioBase64.trim() }
|
|
63319
|
+
};
|
|
63320
|
+
return studioApiPostJson("/stt/v1/transcribe", body, "STT transcribe");
|
|
63321
|
+
}
|
|
63322
|
+
var init_transcribe = __esm({
|
|
63323
|
+
"src/mcp/stt/transcribe.ts"() {
|
|
63324
|
+
"use strict";
|
|
63325
|
+
init_studio_api();
|
|
63326
|
+
}
|
|
63327
|
+
});
|
|
63328
|
+
|
|
63329
|
+
// src/mcp/tts/preview.ts
|
|
63330
|
+
async function getVoicePreviewV1(voiceId, modelId = DEFAULT_TTS_MODEL) {
|
|
63331
|
+
const id = voiceId.trim();
|
|
63332
|
+
if (!id) {
|
|
63333
|
+
throw new Error("voiceId is required");
|
|
63334
|
+
}
|
|
63335
|
+
const qs = new URLSearchParams({ voice_id: id, model_id: modelId });
|
|
63336
|
+
return studioApiGet(`/tts/v1/voice:preview?${qs.toString()}`, "TTS preview");
|
|
63337
|
+
}
|
|
63338
|
+
var DEFAULT_TTS_MODEL;
|
|
63339
|
+
var init_preview = __esm({
|
|
63340
|
+
"src/mcp/tts/preview.ts"() {
|
|
63341
|
+
"use strict";
|
|
63342
|
+
init_studio_api();
|
|
63343
|
+
DEFAULT_TTS_MODEL = "inworld-tts-1.5-max";
|
|
63344
|
+
}
|
|
63345
|
+
});
|
|
63346
|
+
|
|
63172
63347
|
// src/mcp/voice/design.ts
|
|
63173
63348
|
async function designVoiceV1(workspaceId, request) {
|
|
63174
63349
|
const parent = workspaceResourceName(workspaceId);
|
|
@@ -63256,6 +63431,24 @@ var init_design_response = __esm({
|
|
|
63256
63431
|
}
|
|
63257
63432
|
});
|
|
63258
63433
|
|
|
63434
|
+
// src/mcp/voice/get.ts
|
|
63435
|
+
async function getVoiceV1(voiceId) {
|
|
63436
|
+
const id = voiceId.trim();
|
|
63437
|
+
if (!id) {
|
|
63438
|
+
throw new Error("voiceId is required");
|
|
63439
|
+
}
|
|
63440
|
+
return studioApiGet(
|
|
63441
|
+
`/voices/v1/voices/${encodeURIComponent(id)}`,
|
|
63442
|
+
"Voice get"
|
|
63443
|
+
);
|
|
63444
|
+
}
|
|
63445
|
+
var init_get = __esm({
|
|
63446
|
+
"src/mcp/voice/get.ts"() {
|
|
63447
|
+
"use strict";
|
|
63448
|
+
init_studio_api();
|
|
63449
|
+
}
|
|
63450
|
+
});
|
|
63451
|
+
|
|
63259
63452
|
// src/mcp/voice/list-v1.ts
|
|
63260
63453
|
async function listVoicesV1(workspaceId) {
|
|
63261
63454
|
const parent = workspaceResourceName(workspaceId);
|
|
@@ -63832,6 +64025,145 @@ function createMcpServer() {
|
|
|
63832
64025
|
}
|
|
63833
64026
|
}
|
|
63834
64027
|
);
|
|
64028
|
+
server.registerTool(
|
|
64029
|
+
"inworld_tts_voice_preview",
|
|
64030
|
+
{
|
|
64031
|
+
description: "Fetch a short, server-side audio preview for an existing voice (GET /tts/v1/voice:preview). Not metered or billed \u2014 ideal for catalog browsing. Returns base64 MP3 audio. Uses the workspace API key (Basic auth); requires inworld auth login + inworld workspace select-key or INWORLD_API_KEY.",
|
|
64032
|
+
inputSchema: external_exports.object({
|
|
64033
|
+
voiceId: external_exports.string().min(1).describe(
|
|
64034
|
+
"Voice ID (e.g. Ashley, Dennis). See inworld_voice_catalog_list."
|
|
64035
|
+
),
|
|
64036
|
+
modelId: external_exports.string().optional().describe("Optional TTS model id (e.g. inworld-tts-2)")
|
|
64037
|
+
})
|
|
64038
|
+
},
|
|
64039
|
+
async ({ voiceId, modelId }) => {
|
|
64040
|
+
try {
|
|
64041
|
+
const data = await getVoicePreviewV1(voiceId, modelId);
|
|
64042
|
+
return {
|
|
64043
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
64044
|
+
};
|
|
64045
|
+
} catch (e) {
|
|
64046
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
64047
|
+
return {
|
|
64048
|
+
content: [{ type: "text", text: `Error: ${msg}` }],
|
|
64049
|
+
isError: true
|
|
64050
|
+
};
|
|
64051
|
+
}
|
|
64052
|
+
}
|
|
64053
|
+
);
|
|
64054
|
+
server.registerTool(
|
|
64055
|
+
"inworld_voice_get",
|
|
64056
|
+
{
|
|
64057
|
+
description: "Get a single voice's metadata by ID (GET /voices/v1/voices/{voiceId}). Read-only. Uses the workspace API key (Basic auth).",
|
|
64058
|
+
inputSchema: external_exports.object({
|
|
64059
|
+
voiceId: external_exports.string().min(1).describe("Voice ID (e.g. Dennis or workspace_id__voice_name).")
|
|
64060
|
+
})
|
|
64061
|
+
},
|
|
64062
|
+
async ({ voiceId }) => {
|
|
64063
|
+
try {
|
|
64064
|
+
const data = await getVoiceV1(voiceId);
|
|
64065
|
+
return {
|
|
64066
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
64067
|
+
};
|
|
64068
|
+
} catch (e) {
|
|
64069
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
64070
|
+
return {
|
|
64071
|
+
content: [{ type: "text", text: `Error: ${msg}` }],
|
|
64072
|
+
isError: true
|
|
64073
|
+
};
|
|
64074
|
+
}
|
|
64075
|
+
}
|
|
64076
|
+
);
|
|
64077
|
+
server.registerTool(
|
|
64078
|
+
"inworld_stt_transcribe",
|
|
64079
|
+
{
|
|
64080
|
+
description: "Transcribe an audio clip via the Inworld Speech-to-Text API (POST /stt/v1/transcribe). The whole audio must fit in one request; for long files, chunk client-side. Pass base64-encoded audio bytes (no `data:` prefix). Uses the workspace API key (Basic auth).",
|
|
64081
|
+
inputSchema: external_exports.object({
|
|
64082
|
+
audioBase64: external_exports.string().min(1).describe("Base64-encoded audio bytes (raw \u2014 no data: prefix)."),
|
|
64083
|
+
language: external_exports.string().optional().describe("BCP-47 language code, e.g. en-US"),
|
|
64084
|
+
audioEncoding: external_exports.enum(["AUTO_DETECT", "LINEAR16", "MP3", "OGG_OPUS", "FLAC"]).optional().describe(
|
|
64085
|
+
"Audio encoding. Default AUTO_DETECT works for most self-describing formats."
|
|
64086
|
+
),
|
|
64087
|
+
modelId: external_exports.string().optional().describe("STT model id (default: inworld/inworld-stt-1)")
|
|
64088
|
+
})
|
|
64089
|
+
},
|
|
64090
|
+
async (args) => {
|
|
64091
|
+
try {
|
|
64092
|
+
const data = await transcribeSpeech(args);
|
|
64093
|
+
return {
|
|
64094
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
64095
|
+
};
|
|
64096
|
+
} catch (e) {
|
|
64097
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
64098
|
+
return {
|
|
64099
|
+
content: [{ type: "text", text: `Error: ${msg}` }],
|
|
64100
|
+
isError: true
|
|
64101
|
+
};
|
|
64102
|
+
}
|
|
64103
|
+
}
|
|
64104
|
+
);
|
|
64105
|
+
server.registerTool(
|
|
64106
|
+
"inworld_llm_chat",
|
|
64107
|
+
{
|
|
64108
|
+
description: "Generate a chat completion via the Inworld LLM Router (POST /llm/v1alpha/completions:completeChat). Non-streaming. Pass model id + service provider + a list of role/content messages. Uses the workspace API key (Basic auth).",
|
|
64109
|
+
inputSchema: external_exports.object({
|
|
64110
|
+
model: external_exports.string().min(1).describe("Model id (e.g. gpt-4o-mini, gemini-2.5-flash)"),
|
|
64111
|
+
serviceProvider: external_exports.string().optional().describe(
|
|
64112
|
+
"Service provider (SERVICE_PROVIDER_OPENAI, SERVICE_PROVIDER_GOOGLE, ...). Default: SERVICE_PROVIDER_OPENAI."
|
|
64113
|
+
),
|
|
64114
|
+
userId: external_exports.string().optional().describe("Stable user id for analytics/routing"),
|
|
64115
|
+
messages: external_exports.array(
|
|
64116
|
+
external_exports.object({
|
|
64117
|
+
role: external_exports.enum([
|
|
64118
|
+
"MESSAGE_ROLE_SYSTEM",
|
|
64119
|
+
"MESSAGE_ROLE_USER",
|
|
64120
|
+
"MESSAGE_ROLE_ASSISTANT",
|
|
64121
|
+
"MESSAGE_ROLE_TOOL"
|
|
64122
|
+
]),
|
|
64123
|
+
content: external_exports.string()
|
|
64124
|
+
})
|
|
64125
|
+
).min(1).describe("Conversation messages in order"),
|
|
64126
|
+
maxTokens: external_exports.number().int().positive().optional().describe("Maximum tokens in response"),
|
|
64127
|
+
temperature: external_exports.number().min(0).max(2).optional(),
|
|
64128
|
+
topP: external_exports.number().min(0).max(1).optional()
|
|
64129
|
+
})
|
|
64130
|
+
},
|
|
64131
|
+
async (args) => {
|
|
64132
|
+
try {
|
|
64133
|
+
const data = await completeChat(args);
|
|
64134
|
+
return {
|
|
64135
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
64136
|
+
};
|
|
64137
|
+
} catch (e) {
|
|
64138
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
64139
|
+
return {
|
|
64140
|
+
content: [{ type: "text", text: `Error: ${msg}` }],
|
|
64141
|
+
isError: true
|
|
64142
|
+
};
|
|
64143
|
+
}
|
|
64144
|
+
}
|
|
64145
|
+
);
|
|
64146
|
+
server.registerTool(
|
|
64147
|
+
"inworld_llm_list_models",
|
|
64148
|
+
{
|
|
64149
|
+
description: "List LLM models available to your account, with capabilities and pricing (GET /llm/v1alpha/models). Read-only. Uses the workspace API key (Basic auth).",
|
|
64150
|
+
inputSchema: external_exports.object({})
|
|
64151
|
+
},
|
|
64152
|
+
async () => {
|
|
64153
|
+
try {
|
|
64154
|
+
const data = await listModels();
|
|
64155
|
+
return {
|
|
64156
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
64157
|
+
};
|
|
64158
|
+
} catch (e) {
|
|
64159
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
64160
|
+
return {
|
|
64161
|
+
content: [{ type: "text", text: `Error: ${msg}` }],
|
|
64162
|
+
isError: true
|
|
64163
|
+
};
|
|
64164
|
+
}
|
|
64165
|
+
}
|
|
64166
|
+
);
|
|
63835
64167
|
server.registerTool(
|
|
63836
64168
|
"inworld_voice_catalog_list",
|
|
63837
64169
|
{
|
|
@@ -64421,9 +64753,14 @@ var init_mcp2 = __esm({
|
|
|
64421
64753
|
init_session();
|
|
64422
64754
|
init_session_refresh();
|
|
64423
64755
|
init_summary();
|
|
64756
|
+
init_chat();
|
|
64757
|
+
init_models();
|
|
64424
64758
|
init_gateway2();
|
|
64759
|
+
init_transcribe();
|
|
64760
|
+
init_preview();
|
|
64425
64761
|
init_design();
|
|
64426
64762
|
init_design_response();
|
|
64763
|
+
init_get();
|
|
64427
64764
|
init_list_v1();
|
|
64428
64765
|
init_publish();
|
|
64429
64766
|
init_studio_gateway();
|