sunpeak 0.20.34 → 0.20.35
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/bin/commands/inspect.mjs +54 -3
- package/dist/chatgpt/index.cjs +1 -1
- package/dist/chatgpt/index.js +1 -1
- package/dist/claude/index.cjs +1 -1
- package/dist/claude/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/inspector/index.cjs +1 -1
- package/dist/inspector/index.cjs.map +1 -1
- package/dist/inspector/index.d.ts +1 -1
- package/dist/inspector/index.js +1 -1
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/inspector.d.ts +5 -0
- package/dist/inspector/use-inspector-state.d.ts +6 -0
- package/dist/{inspector-mGvDvMCR.js → inspector-D0TWNx_T.js} +17 -5
- package/dist/{inspector-mGvDvMCR.js.map → inspector-D0TWNx_T.js.map} +1 -1
- package/dist/{inspector-CJA_uM9g.cjs → inspector-DQ_vv1wj.cjs} +17 -5
- package/dist/{inspector-CJA_uM9g.cjs.map → inspector-DQ_vv1wj.cjs.map} +1 -1
- package/package.json +1 -1
- package/template/dist/albums/albums.json +1 -1
- package/template/dist/carousel/carousel.json +1 -1
- package/template/dist/map/map.json +1 -1
- package/template/dist/review/review.json +1 -1
package/bin/commands/inspect.mjs
CHANGED
|
@@ -1402,6 +1402,32 @@ async function createModelInstance(provider, modelId, apiKey) {
|
|
|
1402
1402
|
return createAnthropic({ apiKey })(normalizedModelId);
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
|
+
const MODEL_VISIBLE_JSON_LIMIT_BYTES = 20000;
|
|
1406
|
+
|
|
1407
|
+
function formatJsonForModel(value) {
|
|
1408
|
+
const json = JSON.stringify(value);
|
|
1409
|
+
if (json.length <= MODEL_VISIBLE_JSON_LIMIT_BYTES) return json;
|
|
1410
|
+
return `${json.slice(0, MODEL_VISIBLE_JSON_LIMIT_BYTES)}...`;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
function normalizeModelAppContext(appContext) {
|
|
1414
|
+
if (!appContext || typeof appContext !== 'object') return undefined;
|
|
1415
|
+
const normalized = {};
|
|
1416
|
+
if (Array.isArray(appContext.content) && appContext.content.length > 0) {
|
|
1417
|
+
normalized.content = appContext.content;
|
|
1418
|
+
}
|
|
1419
|
+
if (appContext.structuredContent !== undefined) {
|
|
1420
|
+
normalized.structuredContent = appContext.structuredContent;
|
|
1421
|
+
}
|
|
1422
|
+
return Object.keys(normalized).length > 0 ? normalized : undefined;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
function formatSharedAppContextForModel(appContext) {
|
|
1426
|
+
const normalized = normalizeModelAppContext(appContext);
|
|
1427
|
+
if (!normalized) return '';
|
|
1428
|
+
return formatJsonForModel(normalized);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1405
1431
|
function formatModelVisibleToolResult(tool, result) {
|
|
1406
1432
|
const toolName = tool?.name || 'MCP tool';
|
|
1407
1433
|
if (result?.isError) {
|
|
@@ -1412,7 +1438,21 @@ function formatModelVisibleToolResult(tool, result) {
|
|
|
1412
1438
|
.trim();
|
|
1413
1439
|
return text || `${toolName} returned an error.`;
|
|
1414
1440
|
}
|
|
1415
|
-
|
|
1441
|
+
|
|
1442
|
+
const visibleResult = {};
|
|
1443
|
+
if (Array.isArray(result?.content)) {
|
|
1444
|
+
visibleResult.content = result.content;
|
|
1445
|
+
}
|
|
1446
|
+
if (result && 'structuredContent' in result) {
|
|
1447
|
+
visibleResult.structuredContent = result.structuredContent;
|
|
1448
|
+
}
|
|
1449
|
+
if (result?.isError != null) {
|
|
1450
|
+
visibleResult.isError = result.isError;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
return Object.keys(visibleResult).length > 0
|
|
1454
|
+
? formatJsonForModel(visibleResult)
|
|
1455
|
+
: `${toolName} completed. The MCP App is ready to render.`;
|
|
1416
1456
|
}
|
|
1417
1457
|
|
|
1418
1458
|
async function executeModelChatToolCall({ client, name, arguments: args }) {
|
|
@@ -1424,7 +1464,7 @@ async function executeModelChatToolCall({ client, name, arguments: args }) {
|
|
|
1424
1464
|
};
|
|
1425
1465
|
}
|
|
1426
1466
|
|
|
1427
|
-
async function runModelChat({ client, provider, modelId, messages, apiKey }) {
|
|
1467
|
+
async function runModelChat({ client, provider, modelId, messages, apiKey, appContext }) {
|
|
1428
1468
|
assertModelProvider(provider);
|
|
1429
1469
|
const { generateText, tool: aiTool, jsonSchema } = await import('ai');
|
|
1430
1470
|
const model = await createModelInstance(provider, modelId, apiKey);
|
|
@@ -1451,11 +1491,19 @@ async function runModelChat({ client, provider, modelId, messages, apiKey }) {
|
|
|
1451
1491
|
});
|
|
1452
1492
|
}
|
|
1453
1493
|
|
|
1494
|
+
const sharedAppContext = formatSharedAppContextForModel(appContext);
|
|
1495
|
+
|
|
1454
1496
|
const result = await generateText({
|
|
1455
1497
|
model,
|
|
1456
1498
|
tools,
|
|
1457
|
-
system:
|
|
1499
|
+
system: [
|
|
1458
1500
|
'You are chatting inside the Sunpeak Inspector. When you call an MCP tool that renders an app, the host will render the app below your message. Do not repeat raw tool output, JSON, image URLs, markdown image lists, or full item inventories. Keep any narration brief and let the app carry the visual result.',
|
|
1501
|
+
sharedAppContext
|
|
1502
|
+
? `Shared MCP App context from the currently rendered app, available for this turn:\n${sharedAppContext}`
|
|
1503
|
+
: '',
|
|
1504
|
+
]
|
|
1505
|
+
.filter(Boolean)
|
|
1506
|
+
.join('\n\n'),
|
|
1459
1507
|
messages: messages.map((message) => ({
|
|
1460
1508
|
role: message.role,
|
|
1461
1509
|
content: String(message.content ?? ''),
|
|
@@ -2485,6 +2533,7 @@ function sunpeakInspectEndpointsPlugin(getClient, setClient, pluginOpts = {}) {
|
|
|
2485
2533
|
modelId: parsed.modelId,
|
|
2486
2534
|
messages: safeMessages,
|
|
2487
2535
|
apiKey,
|
|
2536
|
+
appContext: normalizeModelAppContext(parsed.appContext),
|
|
2488
2537
|
})
|
|
2489
2538
|
);
|
|
2490
2539
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
@@ -2625,7 +2674,9 @@ export const _securityTestExports = {
|
|
|
2625
2674
|
isToolVisibleToModel,
|
|
2626
2675
|
executeModelChatToolCall,
|
|
2627
2676
|
formatModelVisibleToolResult,
|
|
2677
|
+
formatSharedAppContextForModel,
|
|
2628
2678
|
normalizeApiKey,
|
|
2679
|
+
normalizeModelAppContext,
|
|
2629
2680
|
normalizeModelId,
|
|
2630
2681
|
quoteSecurityInteractiveArg,
|
|
2631
2682
|
readRequestBody,
|
package/dist/chatgpt/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../chunk-Cek0wNdY.cjs");
|
|
3
|
-
const require_inspector = require("../inspector-
|
|
3
|
+
const require_inspector = require("../inspector-DQ_vv1wj.cjs");
|
|
4
4
|
const require_inspector_url = require("../inspector-url-BxScdDag.cjs");
|
|
5
5
|
const require_discovery = require("../discovery-31_n0zcu.cjs");
|
|
6
6
|
//#region src/chatgpt/index.ts
|
package/dist/chatgpt/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ct as __exportAll } from "../protocol-bhrz2H_E.js";
|
|
2
|
-
import { _ as extractResourceCSP, f as ThemeProvider, g as IframeResource, p as useThemeContext, r as resolveServerToolResult, t as Inspector, v as McpAppHost, y as SCREEN_WIDTHS } from "../inspector-
|
|
2
|
+
import { _ as extractResourceCSP, f as ThemeProvider, g as IframeResource, p as useThemeContext, r as resolveServerToolResult, t as Inspector, v as McpAppHost, y as SCREEN_WIDTHS } from "../inspector-D0TWNx_T.js";
|
|
3
3
|
import { t as createInspectorUrl } from "../inspector-url-xUMGbWis.js";
|
|
4
4
|
import { c as toPascalCase, i as findResourceKey, n as extractSimulationKey, r as findResourceDirs, s as getComponentName, t as extractResourceKey } from "../discovery-DOVner--.js";
|
|
5
5
|
//#region src/chatgpt/index.ts
|
package/dist/claude/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../chunk-Cek0wNdY.cjs");
|
|
3
|
-
const require_inspector = require("../inspector-
|
|
3
|
+
const require_inspector = require("../inspector-DQ_vv1wj.cjs");
|
|
4
4
|
exports.Inspector = require_inspector.Inspector;
|
package/dist/claude/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Inspector } from "../inspector-
|
|
1
|
+
import { t as Inspector } from "../inspector-D0TWNx_T.js";
|
|
2
2
|
export { Inspector };
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_chunk = require("./chunk-Cek0wNdY.cjs");
|
|
3
3
|
const require_protocol = require("./protocol-Cafvpf0x.cjs");
|
|
4
4
|
const require_use_app = require("./use-app-DUdnDLP5.cjs");
|
|
5
|
-
const require_inspector = require("./inspector-
|
|
5
|
+
const require_inspector = require("./inspector-DQ_vv1wj.cjs");
|
|
6
6
|
const require_host_index = require("./host/index.cjs");
|
|
7
7
|
const require_inspector_index = require("./inspector/index.cjs");
|
|
8
8
|
const require_chatgpt_index = require("./chatgpt/index.cjs");
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $ as _undefined, B as ResourceLinkSchema, G as ToolSchema, a as CallToolResultSchema, at as object, ct as union, et as array, it as number, lt as unknown, m as EmbeddedResourceSchema, nt as literal, ot as record, rt as never, s as ContentBlockSchema, st as string, tt as boolean, v as ImplementationSchema, wt as __require, z as RequestIdSchema } from "./protocol-bhrz2H_E.js";
|
|
2
2
|
import { $ as s, A as TQ, B as e, C as PQ, D as RQ, E as R, F as ZQ, G as i, H as f, I as _, J as l, K as j, L as _Q, M as W, N as XQ, O as SQ, P as YQ, Q as r, R as bQ, S as P, T as QY, U as g, V as eX, W as h, X as q, Y as n, Z as qQ, _ as JQ, a as AQ, at as z, b as O, c as CQ, d as F, et as t, f as FQ, g as IQ, h as I, i as A, it as wQ, j as U, k as T, l as DQ, m as HQ, n as AppProvider, nt as v, o as B, ot as zQ, p as H, q as kQ, r as $Q, rt as w, s as C, t as useApp, tt as u, u as E, v as L, w as QQ, x as OQ, y as M, z as d } from "./use-app-Duar2Ipu.js";
|
|
3
|
-
import { C as cn, w as DEFAULT_STYLE_VARIABLES } from "./inspector-
|
|
3
|
+
import { C as cn, w as DEFAULT_STYLE_VARIABLES } from "./inspector-D0TWNx_T.js";
|
|
4
4
|
import { detectHost, isChatGPT, isClaude } from "./host/index.js";
|
|
5
5
|
import { t as inspector_exports } from "./inspector/index.js";
|
|
6
6
|
import { t as chatgpt_exports } from "./chatgpt/index.js";
|
package/dist/inspector/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../chunk-Cek0wNdY.cjs");
|
|
3
|
-
const require_inspector = require("../inspector-
|
|
3
|
+
const require_inspector = require("../inspector-DQ_vv1wj.cjs");
|
|
4
4
|
const require_inspector_url = require("../inspector-url-BxScdDag.cjs");
|
|
5
5
|
const require_discovery = require("../discovery-31_n0zcu.cjs");
|
|
6
6
|
//#region src/inspector/index.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/inspector/index.ts"],"sourcesContent":["/**\n * Generic multi-host inspector for Sunpeak MCP Apps.\n *\n * The Inspector component provides a dev environment for testing MCP Apps\n * against multiple host platforms (ChatGPT, Claude, etc.).\n *\n * @example\n * ```tsx\n * import { inspector } from 'sunpeak';\n * const { Inspector } = inspector;\n *\n * <Inspector simulations={simulations} appName=\"My App\" />\n * ```\n *\n * @module sunpeak/inspector\n */\n\n// Register built-in host shells\nimport '../chatgpt/chatgpt-host';\nimport '../claude/claude-host';\n\n// Core inspector component\nexport { Inspector } from './inspector';\nexport type {\n InspectorModelApiKeyController,\n InspectorModelChatMessage,\n InspectorModelChatOptions,\n InspectorModelChatRequest,\n InspectorModelChatResponse,\n InspectorModelChatToolCall,\n InspectorModelKeyStatus,\n InspectorModelProvider,\n InspectorProps,\n} from './inspector';\n\n// Public input shape for embedding (App → resources + tools → simulations).\nexport type {\n InspectorApp,\n InspectorAppResource,\n InspectorAppTool,\n InspectorAppSimulation,\n} from './app-types';\nexport { flattenAppToSimulations } from './app-flatten';\n\n// State hook (for custom inspector builds)\nexport { useInspectorState } from './use-inspector-state';\nexport type { UseInspectorStateOptions, InspectorState } from './use-inspector-state';\n\n// Host shell system\nexport { registerHostShell, getHostShell, getRegisteredHosts } from './hosts';\nexport type { HostConversationProps, HostShell, HostId } from './hosts';\n\n// Infrastructure\nexport { McpAppHost } from './mcp-app-host';\nexport type { McpAppHostOptions } from './mcp-app-host';\nexport { IframeResource, extractResourceCSP } from './iframe-resource';\nexport type { ResourceCSP } from './iframe-resource';\nexport { ThemeProvider, useThemeContext } from './theme-provider';\n\n// MCP connection\nexport { useMcpConnection } from './use-mcp-connection';\nexport type { McpConnectionState } from './use-mcp-connection';\n\n// Simulation types & resolution\nexport type { Simulation, ServerToolMock } from '../types/simulation';\nexport { resolveServerToolResult } from '../types/simulation';\n\n// Types & URL helpers\nexport type { ScreenWidth, InspectorConfig } from './inspector-types';\nexport { SCREEN_WIDTHS } from './inspector-types';\nexport { createInspectorUrl } from './inspector-url';\nexport type { InspectorUrlParams } from './inspector-url';\n\n// Sidebar components (for building custom inspectors)\nexport {\n SimpleSidebar,\n SidebarControl,\n SidebarCollapsibleControl,\n SidebarSelect,\n SidebarInput,\n SidebarCheckbox,\n SidebarTextarea,\n SidebarToggle,\n} from './simple-sidebar';\n\n// Discovery utilities\nexport {\n toPascalCase,\n extractResourceKey,\n extractSimulationKey,\n findResourceKey,\n getComponentName,\n findResourceDirs,\n} from '../lib/discovery';\nexport type { ResourceDirInfo, FsOps } from '../lib/discovery';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/inspector/index.ts"],"sourcesContent":["/**\n * Generic multi-host inspector for Sunpeak MCP Apps.\n *\n * The Inspector component provides a dev environment for testing MCP Apps\n * against multiple host platforms (ChatGPT, Claude, etc.).\n *\n * @example\n * ```tsx\n * import { inspector } from 'sunpeak';\n * const { Inspector } = inspector;\n *\n * <Inspector simulations={simulations} appName=\"My App\" />\n * ```\n *\n * @module sunpeak/inspector\n */\n\n// Register built-in host shells\nimport '../chatgpt/chatgpt-host';\nimport '../claude/claude-host';\n\n// Core inspector component\nexport { Inspector } from './inspector';\nexport type {\n InspectorModelApiKeyController,\n InspectorModelAppContext,\n InspectorModelChatMessage,\n InspectorModelChatOptions,\n InspectorModelChatRequest,\n InspectorModelChatResponse,\n InspectorModelChatToolCall,\n InspectorModelKeyStatus,\n InspectorModelProvider,\n InspectorProps,\n} from './inspector';\n\n// Public input shape for embedding (App → resources + tools → simulations).\nexport type {\n InspectorApp,\n InspectorAppResource,\n InspectorAppTool,\n InspectorAppSimulation,\n} from './app-types';\nexport { flattenAppToSimulations } from './app-flatten';\n\n// State hook (for custom inspector builds)\nexport { useInspectorState } from './use-inspector-state';\nexport type { UseInspectorStateOptions, InspectorState } from './use-inspector-state';\n\n// Host shell system\nexport { registerHostShell, getHostShell, getRegisteredHosts } from './hosts';\nexport type { HostConversationProps, HostShell, HostId } from './hosts';\n\n// Infrastructure\nexport { McpAppHost } from './mcp-app-host';\nexport type { McpAppHostOptions } from './mcp-app-host';\nexport { IframeResource, extractResourceCSP } from './iframe-resource';\nexport type { ResourceCSP } from './iframe-resource';\nexport { ThemeProvider, useThemeContext } from './theme-provider';\n\n// MCP connection\nexport { useMcpConnection } from './use-mcp-connection';\nexport type { McpConnectionState } from './use-mcp-connection';\n\n// Simulation types & resolution\nexport type { Simulation, ServerToolMock } from '../types/simulation';\nexport { resolveServerToolResult } from '../types/simulation';\n\n// Types & URL helpers\nexport type { ScreenWidth, InspectorConfig } from './inspector-types';\nexport { SCREEN_WIDTHS } from './inspector-types';\nexport { createInspectorUrl } from './inspector-url';\nexport type { InspectorUrlParams } from './inspector-url';\n\n// Sidebar components (for building custom inspectors)\nexport {\n SimpleSidebar,\n SidebarControl,\n SidebarCollapsibleControl,\n SidebarSelect,\n SidebarInput,\n SidebarCheckbox,\n SidebarTextarea,\n SidebarToggle,\n} from './simple-sidebar';\n\n// Discovery utilities\nexport {\n toPascalCase,\n extractResourceKey,\n extractSimulationKey,\n findResourceKey,\n getComponentName,\n findResourceDirs,\n} from '../lib/discovery';\nexport type { ResourceDirInfo, FsOps } from '../lib/discovery';\n"],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Inspector } from './inspector';
|
|
2
|
-
export type { InspectorModelApiKeyController, InspectorModelChatMessage, InspectorModelChatOptions, InspectorModelChatRequest, InspectorModelChatResponse, InspectorModelChatToolCall, InspectorModelKeyStatus, InspectorModelProvider, InspectorProps, } from './inspector';
|
|
2
|
+
export type { InspectorModelApiKeyController, InspectorModelAppContext, InspectorModelChatMessage, InspectorModelChatOptions, InspectorModelChatRequest, InspectorModelChatResponse, InspectorModelChatToolCall, InspectorModelKeyStatus, InspectorModelProvider, InspectorProps, } from './inspector';
|
|
3
3
|
export type { InspectorApp, InspectorAppResource, InspectorAppTool, InspectorAppSimulation, } from './app-types';
|
|
4
4
|
export { flattenAppToSimulations } from './app-flatten';
|
|
5
5
|
export { useInspectorState } from './use-inspector-state';
|
package/dist/inspector/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ct as __exportAll } from "../protocol-bhrz2H_E.js";
|
|
2
|
-
import { S as registerHostShell, _ as extractResourceCSP, a as SidebarCollapsibleControl, b as getHostShell, c as SidebarSelect, d as SimpleSidebar, f as ThemeProvider, g as IframeResource, h as useInspectorState, i as SidebarCheckbox, l as SidebarTextarea, m as useMcpConnection, n as flattenAppToSimulations, o as SidebarControl, p as useThemeContext, r as resolveServerToolResult, s as SidebarInput, t as Inspector, u as SidebarToggle, v as McpAppHost, x as getRegisteredHosts, y as SCREEN_WIDTHS } from "../inspector-
|
|
2
|
+
import { S as registerHostShell, _ as extractResourceCSP, a as SidebarCollapsibleControl, b as getHostShell, c as SidebarSelect, d as SimpleSidebar, f as ThemeProvider, g as IframeResource, h as useInspectorState, i as SidebarCheckbox, l as SidebarTextarea, m as useMcpConnection, n as flattenAppToSimulations, o as SidebarControl, p as useThemeContext, r as resolveServerToolResult, s as SidebarInput, t as Inspector, u as SidebarToggle, v as McpAppHost, x as getRegisteredHosts, y as SCREEN_WIDTHS } from "../inspector-D0TWNx_T.js";
|
|
3
3
|
import { t as createInspectorUrl } from "../inspector-url-xUMGbWis.js";
|
|
4
4
|
import { c as toPascalCase, i as findResourceKey, n as extractSimulationKey, r as findResourceDirs, s as getComponentName, t as extractResourceKey } from "../discovery-DOVner--.js";
|
|
5
5
|
//#region src/inspector/index.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/inspector/index.ts"],"sourcesContent":["/**\n * Generic multi-host inspector for Sunpeak MCP Apps.\n *\n * The Inspector component provides a dev environment for testing MCP Apps\n * against multiple host platforms (ChatGPT, Claude, etc.).\n *\n * @example\n * ```tsx\n * import { inspector } from 'sunpeak';\n * const { Inspector } = inspector;\n *\n * <Inspector simulations={simulations} appName=\"My App\" />\n * ```\n *\n * @module sunpeak/inspector\n */\n\n// Register built-in host shells\nimport '../chatgpt/chatgpt-host';\nimport '../claude/claude-host';\n\n// Core inspector component\nexport { Inspector } from './inspector';\nexport type {\n InspectorModelApiKeyController,\n InspectorModelChatMessage,\n InspectorModelChatOptions,\n InspectorModelChatRequest,\n InspectorModelChatResponse,\n InspectorModelChatToolCall,\n InspectorModelKeyStatus,\n InspectorModelProvider,\n InspectorProps,\n} from './inspector';\n\n// Public input shape for embedding (App → resources + tools → simulations).\nexport type {\n InspectorApp,\n InspectorAppResource,\n InspectorAppTool,\n InspectorAppSimulation,\n} from './app-types';\nexport { flattenAppToSimulations } from './app-flatten';\n\n// State hook (for custom inspector builds)\nexport { useInspectorState } from './use-inspector-state';\nexport type { UseInspectorStateOptions, InspectorState } from './use-inspector-state';\n\n// Host shell system\nexport { registerHostShell, getHostShell, getRegisteredHosts } from './hosts';\nexport type { HostConversationProps, HostShell, HostId } from './hosts';\n\n// Infrastructure\nexport { McpAppHost } from './mcp-app-host';\nexport type { McpAppHostOptions } from './mcp-app-host';\nexport { IframeResource, extractResourceCSP } from './iframe-resource';\nexport type { ResourceCSP } from './iframe-resource';\nexport { ThemeProvider, useThemeContext } from './theme-provider';\n\n// MCP connection\nexport { useMcpConnection } from './use-mcp-connection';\nexport type { McpConnectionState } from './use-mcp-connection';\n\n// Simulation types & resolution\nexport type { Simulation, ServerToolMock } from '../types/simulation';\nexport { resolveServerToolResult } from '../types/simulation';\n\n// Types & URL helpers\nexport type { ScreenWidth, InspectorConfig } from './inspector-types';\nexport { SCREEN_WIDTHS } from './inspector-types';\nexport { createInspectorUrl } from './inspector-url';\nexport type { InspectorUrlParams } from './inspector-url';\n\n// Sidebar components (for building custom inspectors)\nexport {\n SimpleSidebar,\n SidebarControl,\n SidebarCollapsibleControl,\n SidebarSelect,\n SidebarInput,\n SidebarCheckbox,\n SidebarTextarea,\n SidebarToggle,\n} from './simple-sidebar';\n\n// Discovery utilities\nexport {\n toPascalCase,\n extractResourceKey,\n extractSimulationKey,\n findResourceKey,\n getComponentName,\n findResourceDirs,\n} from '../lib/discovery';\nexport type { ResourceDirInfo, FsOps } from '../lib/discovery';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/inspector/index.ts"],"sourcesContent":["/**\n * Generic multi-host inspector for Sunpeak MCP Apps.\n *\n * The Inspector component provides a dev environment for testing MCP Apps\n * against multiple host platforms (ChatGPT, Claude, etc.).\n *\n * @example\n * ```tsx\n * import { inspector } from 'sunpeak';\n * const { Inspector } = inspector;\n *\n * <Inspector simulations={simulations} appName=\"My App\" />\n * ```\n *\n * @module sunpeak/inspector\n */\n\n// Register built-in host shells\nimport '../chatgpt/chatgpt-host';\nimport '../claude/claude-host';\n\n// Core inspector component\nexport { Inspector } from './inspector';\nexport type {\n InspectorModelApiKeyController,\n InspectorModelAppContext,\n InspectorModelChatMessage,\n InspectorModelChatOptions,\n InspectorModelChatRequest,\n InspectorModelChatResponse,\n InspectorModelChatToolCall,\n InspectorModelKeyStatus,\n InspectorModelProvider,\n InspectorProps,\n} from './inspector';\n\n// Public input shape for embedding (App → resources + tools → simulations).\nexport type {\n InspectorApp,\n InspectorAppResource,\n InspectorAppTool,\n InspectorAppSimulation,\n} from './app-types';\nexport { flattenAppToSimulations } from './app-flatten';\n\n// State hook (for custom inspector builds)\nexport { useInspectorState } from './use-inspector-state';\nexport type { UseInspectorStateOptions, InspectorState } from './use-inspector-state';\n\n// Host shell system\nexport { registerHostShell, getHostShell, getRegisteredHosts } from './hosts';\nexport type { HostConversationProps, HostShell, HostId } from './hosts';\n\n// Infrastructure\nexport { McpAppHost } from './mcp-app-host';\nexport type { McpAppHostOptions } from './mcp-app-host';\nexport { IframeResource, extractResourceCSP } from './iframe-resource';\nexport type { ResourceCSP } from './iframe-resource';\nexport { ThemeProvider, useThemeContext } from './theme-provider';\n\n// MCP connection\nexport { useMcpConnection } from './use-mcp-connection';\nexport type { McpConnectionState } from './use-mcp-connection';\n\n// Simulation types & resolution\nexport type { Simulation, ServerToolMock } from '../types/simulation';\nexport { resolveServerToolResult } from '../types/simulation';\n\n// Types & URL helpers\nexport type { ScreenWidth, InspectorConfig } from './inspector-types';\nexport { SCREEN_WIDTHS } from './inspector-types';\nexport { createInspectorUrl } from './inspector-url';\nexport type { InspectorUrlParams } from './inspector-url';\n\n// Sidebar components (for building custom inspectors)\nexport {\n SimpleSidebar,\n SidebarControl,\n SidebarCollapsibleControl,\n SidebarSelect,\n SidebarInput,\n SidebarCheckbox,\n SidebarTextarea,\n SidebarToggle,\n} from './simple-sidebar';\n\n// Discovery utilities\nexport {\n toPascalCase,\n extractResourceKey,\n extractSimulationKey,\n findResourceKey,\n getComponentName,\n findResourceDirs,\n} from '../lib/discovery';\nexport type { ResourceDirInfo, FsOps } from '../lib/discovery';\n"],"mappings":""}
|
|
@@ -19,6 +19,10 @@ export interface InspectorModelChatToolCall {
|
|
|
19
19
|
result?: CallToolResult;
|
|
20
20
|
isError?: boolean;
|
|
21
21
|
}
|
|
22
|
+
export interface InspectorModelAppContext {
|
|
23
|
+
content?: unknown[];
|
|
24
|
+
structuredContent?: unknown;
|
|
25
|
+
}
|
|
22
26
|
export interface InspectorModelChatResponse {
|
|
23
27
|
text?: string;
|
|
24
28
|
toolCalls?: InspectorModelChatToolCall[];
|
|
@@ -34,6 +38,7 @@ export interface InspectorModelChatRequest {
|
|
|
34
38
|
modelId: string;
|
|
35
39
|
messages: InspectorModelChatMessage[];
|
|
36
40
|
tools: Simulation['tool'][];
|
|
41
|
+
appContext?: InspectorModelAppContext;
|
|
37
42
|
}
|
|
38
43
|
export interface InspectorModelApiKeyController {
|
|
39
44
|
/**
|
|
@@ -5,6 +5,10 @@ import { ScreenWidth } from './inspector-types';
|
|
|
5
5
|
import { HostId } from './hosts';
|
|
6
6
|
import { ResourceCSP } from './iframe-resource';
|
|
7
7
|
type Platform = NonNullable<McpUiHostContext['platform']>;
|
|
8
|
+
interface ModelAppContext {
|
|
9
|
+
content?: unknown[];
|
|
10
|
+
structuredContent?: unknown;
|
|
11
|
+
}
|
|
8
12
|
export interface UseInspectorStateOptions {
|
|
9
13
|
simulations: Record<string, Simulation>;
|
|
10
14
|
defaultHost?: HostId;
|
|
@@ -62,6 +66,8 @@ export interface InspectorState {
|
|
|
62
66
|
effectiveToolResult: CallToolResult | undefined;
|
|
63
67
|
modelContext: Record<string, unknown> | null;
|
|
64
68
|
setModelContext: (ctx: Record<string, unknown> | null) => void;
|
|
69
|
+
modelAppContext: ModelAppContext | null;
|
|
70
|
+
setModelAppContext: (ctx: ModelAppContext | null) => void;
|
|
65
71
|
toolInputJson: string;
|
|
66
72
|
setToolInputJson: (json: string) => void;
|
|
67
73
|
toolInputError: string;
|
|
@@ -6731,6 +6731,7 @@ function useInspectorState({ simulations, defaultHost = "chatgpt", preserveToolD
|
|
|
6731
6731
|
const [toolResultJson, setToolResultJson] = useState(() => JSON.stringify(toolResult ?? null, null, 2));
|
|
6732
6732
|
const [modelContextJson, setModelContextJson] = useState("null");
|
|
6733
6733
|
const [modelContext, setModelContext] = useState(null);
|
|
6734
|
+
const [modelAppContext, setModelAppContext] = useState(null);
|
|
6734
6735
|
const [editingField, setEditingField] = useState(null);
|
|
6735
6736
|
const [toolInputError, setToolInputError] = useState("");
|
|
6736
6737
|
const [toolResultError, setToolResultError] = useState("");
|
|
@@ -6750,7 +6751,6 @@ function useInspectorState({ simulations, defaultHost = "chatgpt", preserveToolD
|
|
|
6750
6751
|
setToolResultError("");
|
|
6751
6752
|
}
|
|
6752
6753
|
if (editingField !== "modelContext") {
|
|
6753
|
-
setModelContextJson("null");
|
|
6754
6754
|
setModelContext(null);
|
|
6755
6755
|
setModelContextError("");
|
|
6756
6756
|
}
|
|
@@ -6776,6 +6776,10 @@ function useInspectorState({ simulations, defaultHost = "chatgpt", preserveToolD
|
|
|
6776
6776
|
};
|
|
6777
6777
|
const handleUpdateModelContext = (content, structuredContent) => {
|
|
6778
6778
|
setModelContextJson(JSON.stringify(structuredContent ?? content, null, 2));
|
|
6779
|
+
setModelAppContext(structuredContent === void 0 && content.length === 0 ? null : {
|
|
6780
|
+
content,
|
|
6781
|
+
...structuredContent !== void 0 ? { structuredContent } : {}
|
|
6782
|
+
});
|
|
6779
6783
|
};
|
|
6780
6784
|
const validateJSON = (json, setJson, setError) => {
|
|
6781
6785
|
setJson(json);
|
|
@@ -6857,6 +6861,8 @@ function useInspectorState({ simulations, defaultHost = "chatgpt", preserveToolD
|
|
|
6857
6861
|
effectiveToolResult,
|
|
6858
6862
|
modelContext,
|
|
6859
6863
|
setModelContext,
|
|
6864
|
+
modelAppContext,
|
|
6865
|
+
setModelAppContext,
|
|
6860
6866
|
toolInputJson,
|
|
6861
6867
|
setToolInputJson,
|
|
6862
6868
|
toolInputError,
|
|
@@ -8042,7 +8048,8 @@ function Inspector({ children, app, simulations: initialSimulationsProp = EMPTY_
|
|
|
8042
8048
|
provider: modelProvider,
|
|
8043
8049
|
modelId,
|
|
8044
8050
|
messages,
|
|
8045
|
-
tools: modelCallableTools
|
|
8051
|
+
tools: modelCallableTools,
|
|
8052
|
+
appContext: state.modelAppContext ?? void 0
|
|
8046
8053
|
});
|
|
8047
8054
|
else {
|
|
8048
8055
|
const endpoint = inspectorApiEndpoint("/__sunpeak/model-chat", inspectorApiBaseUrl);
|
|
@@ -8052,7 +8059,8 @@ function Inspector({ children, app, simulations: initialSimulationsProp = EMPTY_
|
|
|
8052
8059
|
body: JSON.stringify({
|
|
8053
8060
|
provider: modelProvider,
|
|
8054
8061
|
modelId,
|
|
8055
|
-
messages
|
|
8062
|
+
messages,
|
|
8063
|
+
appContext: state.modelAppContext ?? void 0
|
|
8056
8064
|
})
|
|
8057
8065
|
});
|
|
8058
8066
|
data = await readInspectorJson(res, endpoint);
|
|
@@ -9039,7 +9047,11 @@ function Inspector({ children, app, simulations: initialSimulationsProp = EMPTY_
|
|
|
9039
9047
|
onChange: (json) => state.validateJSON(json, state.setModelContextJson, state.setModelContextError),
|
|
9040
9048
|
onFocus: () => state.setEditingField("modelContext"),
|
|
9041
9049
|
onBlur: () => state.commitJSON(state.modelContextJson, state.setModelContextError, (parsed) => {
|
|
9042
|
-
state.setModelContext(parsed);
|
|
9050
|
+
state.setModelContext(parsed != null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null);
|
|
9051
|
+
state.setModelAppContext(parsed == null ? null : {
|
|
9052
|
+
content: [],
|
|
9053
|
+
structuredContent: parsed
|
|
9054
|
+
});
|
|
9043
9055
|
}),
|
|
9044
9056
|
error: state.modelContextError,
|
|
9045
9057
|
maxRows: 8
|
|
@@ -9102,4 +9114,4 @@ function Inspector({ children, app, simulations: initialSimulationsProp = EMPTY_
|
|
|
9102
9114
|
//#endregion
|
|
9103
9115
|
export { cn as C, registerHostShell as S, extractResourceCSP as _, SidebarCollapsibleControl as a, getHostShell as b, SidebarSelect as c, SimpleSidebar as d, ThemeProvider as f, IframeResource as g, useInspectorState as h, SidebarCheckbox as i, SidebarTextarea as l, useMcpConnection as m, flattenAppToSimulations as n, SidebarControl as o, useThemeContext as p, resolveServerToolResult as r, SidebarInput as s, Inspector as t, SidebarToggle as u, McpAppHost as v, DEFAULT_STYLE_VARIABLES as w, getRegisteredHosts as x, SCREEN_WIDTHS as y };
|
|
9104
9116
|
|
|
9105
|
-
//# sourceMappingURL=inspector-
|
|
9117
|
+
//# sourceMappingURL=inspector-D0TWNx_T.js.map
|