π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(sandbox): take the market SDK that actually sends the persistence fields (#20477)
Rdmclin2489c92a070eb
diff --git a/apps/desktop/pnpm-lock.yaml b/apps/desktop/pnpm-lock.yamlindex 296140b7fe5..abae493ccd1 100644--- a/apps/desktop/pnpm-lock.yaml+++ b/apps/desktop/pnpm-lock.yaml@@ -641,8 +641,8 @@ importers:../../packages/types:dependencies:'@lobehub/market-sdk':- specifier: 0.41.0- version: 0.41.0([email protected])([email protected])+ specifier: 0.42.0+ version: 0.42.0([email protected])([email protected])'@lobehub/market-types':specifier: ^1.17.1version: 1.17.1@@ -2184,14 +2184,17 @@ packages:react: 19.2.7react-dom: 19.2.7- '@lobehub/[email protected]':- resolution: {integrity: sha512-zrzOWVf/aIECfW5w3ZbiV+swPNdeSxpbiSQG6uOLq7G53QKfDm/VNcOWqrZFO+zNMWwXYtJp7BgB9hXVL6tmxg==}+ '@lobehub/[email protected]':+ resolution: {integrity: sha512-1c+hf2lP9tqX9qyg6+J5Q90dYqvdZz7agrYWB9h9tiEJdIS57bzFcSRJZzxUiesbQ7jmvS5a7kBMUwsd9kxzKw==}peerDependencies:zod: ^3.24.4'@lobehub/[email protected]':resolution: {integrity: sha512-jwY3nXyJaP4V3kBYQpnPMYgWC4LWW03g1BP+s43p4d7SMWJ/wlDwfENoIyDP5p9NFZPIPV4ajaWpidcW7iENOg==}+ '@lobehub/[email protected]':+ resolution: {integrity: sha512-1xx+y4rtRpN0oplvJEC1WvmCymJoUNUJIR8wr/U+d/jgrPvJSb3as/NZRCUrxeFd6BDSlQHyJl12CwzFNA6ZAw==}+'@lobehub/[email protected]':resolution: {integrity: sha512-kkqq2nqwcqz+rV/eUPQ7vY1TQWHWZE3kQt1MsSLtNFLNXMoKYPiF+cdahP97uunWKtf2dB48q/nkSWaZzEKRSw==}engines: {node: '>=22.0.0'}@@ -9998,9 +10001,10 @@ snapshots:- '@types/react'- supports-colordependencies:- '@lobehub/market-types': 1.17.1+ '@lobehub/market-types': 1.18.0+ '@opentelemetry/api': 1.9.1debug: 4.4.3([email protected])jose: 6.2.12url-join: 5.0.0@@ -10012,6 +10016,10 @@ snapshots:dependencies:zod: 3.25.76+ '@lobehub/[email protected]':+ dependencies:+ zod: 3.25.76+'@lobehub/[email protected](@types/[email protected])([email protected]([email protected]))([email protected])([email protected])':dependencies:'@types/hast': 3.0.5diff --git a/apps/server/src/services/discover/index.ts b/apps/server/src/services/discover/index.tsindex 026c5633654..a05e4118702 100644--- a/apps/server/src/services/discover/index.ts+++ b/apps/server/src/services/discover/index.ts@@ -580,7 +580,9 @@ export class DiscoverService {normalizedAuthor.name || (data.ownerId !== null ? `User${data.ownerId}` : 'Unknown'),avatar: data.avatar || normalizedAuthor.name || '',category: (data as any).category || 'general',- config: data.config || {},+ // The market SDK types this as a bare record; the detail shape this+ // builds declares the agent config it actually carries.+ config: (data.config || {}) as unknown as DiscoverAssistantDetail['config'],createdAt: (data as any).createdAt,currentVersion: data.version,description: (data as any).description || data.summary,diff --git a/apps/server/src/services/sandbox/providers/market.test.ts b/apps/server/src/services/sandbox/providers/market.test.tsindex 337b58d1d92..cc4f270da13 100644--- a/apps/server/src/services/sandbox/providers/market.test.ts+++ b/apps/server/src/services/sandbox/providers/market.test.ts@@ -227,3 +227,57 @@ describe('MarketSandboxProvider', () => {});});});++/**+ * The provider tests above mock `runBuildInTool`, so they prove only that the+ * provider hands the persistence fields over β they pass against an SDK that+ * then drops every one of them on the floor, which is exactly what shipped and+ * sent weeks of persistent runs into a throwaway sandbox.+ *+ * This one drives the REAL SDK with only its transport replaced, so it asserts+ * the thing that actually broke: that the fields survive serialization and+ * reach Market in the request body.+ */+describe('MarketSandboxProvider Β· persistence fields on the wire', () => {+ const callWithRealSDK = async () => {+ const { MarketSDK } = await import('@lobehub/market-sdk');+ const fetchMock = vi.fn(async () => ({+ headers: new Headers({ 'content-type': 'application/json' }),+ json: async () => ({ data: { result: { exitCode: 0, stdout: '' } }, success: true }),+ ok: true,+ status: 200,+ text: async () => JSON.stringify({ data: {}, success: true }),+ }));+ vi.stubGlobal('fetch', fetchMock);++ const sdk = new MarketSDK({ baseURL: 'https://market.test' });+ const provider = new MarketSandboxProvider({+ marketService: { getSDK: () => sdk } as unknown as MarketService,+ sandboxCwd: 'inst-a',+ sandboxInstanceId: 'env-abc',+ sandboxMode: 'persistent',+ topicId: 'tpc_1',+ userId: 'user_1',+ } as never);++ await provider.callTool('runCommand', { command: 'pwd' }).catch(() => undefined);+ vi.unstubAllGlobals();++ const call = fetchMock.mock.calls.find(([url]) =>+ String(url).includes('/v1/plugins/run-buildin-tools'),+ );+ return call ? JSON.parse(String((call[1] as RequestInit).body)) : undefined;+ };++ it('sends sandboxMode, sandboxInstanceId and sandboxCwd in the request body', async () => {+ const body = await callWithRealSDK();++ // Without these the execution plane reads the call as ephemeral, mounts no+ // volume, and reports success anyway.+ expect(body).toMatchObject({+ sandboxCwd: 'inst-a',+ sandboxInstanceId: 'env-abc',+ sandboxMode: 'persistent',+ });+ });+});diff --git a/apps/server/src/services/sandbox/providers/market.ts b/apps/server/src/services/sandbox/providers/market.tsindex 8698bd21d5f..7d3e028e7f2 100644--- a/apps/server/src/services/sandbox/providers/market.ts+++ b/apps/server/src/services/sandbox/providers/market.ts@@ -72,23 +72,32 @@ export class MarketSandboxProvider implements SandboxProvider {);try {- const response = await marketService.getSDK().plugins.runBuildInTool(- toolName as CodeInterpreterToolName,- params as never,- {- // Cast: the published SDK's context type predates both fields. Market- // validates the request body with a non-strict schema, so a field it- // does not know yet is dropped rather than rejected β which is what- // `sandboxCwd` relies on until the execution plane consumes it.- ...(sandboxMode && { sandboxMode }),- ...(sandboxCwd && { sandboxCwd }),- ...(sandboxWorkingDir && { sandboxWorkingDir }),- ...(sandboxInstanceId && { sandboxInstanceId }),- ...(sandboxSpecification && { sandboxSpecification }),+ const response = await marketService+ .getSDK()+ .plugins.runBuildInTool(toolName as CodeInterpreterToolName, params as never, {+ // Named one by one, and deliberately NOT cast. Market validates this+ // body with a non-strict schema, so an SDK that predates these fields+ // drops them silently and the call runs in a throwaway sandbox while+ // reporting success β which is exactly what shipped: the package was+ // bumped in the cloud superproject only, this workspace resolved the+ // older SDK, and every persistent run landed in /tmp without one+ // error. Excess-property checking is what turns that into a build+ // failure, and it does NOT see properties contributed by a+ // conditional spread β `...(sandboxMode && { sandboxMode })` compiles+ // happily against a context type that has no such field. Each one is+ // written out so that it does. The SDK omits an undefined field from+ // the request body itself, so naming them costs nothing on the wire.+ sandboxCwd,+ sandboxInstanceId,+ sandboxMode,+ // The SDK types this one loosely (`Record<string, unknown>`) while+ // ours is a named shape, so only this field is widened β the rest+ // stay checked, which is the point of dropping the blanket cast.+ sandboxSpecification: sandboxSpecification as Record<string, unknown> | undefined,+ sandboxWorkingDir,topicId,userId,- } as never,- );+ });log('Sandbox tool %s response: %O', toolName, response);diff --git a/package.json b/package.jsonindex 06780868243..c9bddbab968 100644--- a/package.json+++ b/package.json@@ -324,7 +324,7 @@"@lobehub/desktop-ipc-typings": "workspace:*","@lobehub/editor": "^4.27.3","@lobehub/icons": "^5.18.0",- "@lobehub/market-sdk": "0.41.0",+ "@lobehub/market-sdk": "0.42.0","@lobehub/tts": "^5.1.2","@lobehub/ui": "^5.56.0","@modelcontextprotocol/sdk": "^1.30.0",diff --git a/packages/types/package.json b/packages/types/package.jsonindex 1bb1ca3d815..ecdb84f3a9a 100644--- a/packages/types/package.json+++ b/packages/types/package.json@@ -15,7 +15,7 @@"test:update": "vitest -u"},"dependencies": {- "@lobehub/market-sdk": "0.41.0",+ "@lobehub/market-sdk": "0.42.0","@lobehub/market-types": "^1.17.1","ajv": "^8.20.0","model-bank": "workspace:*",diff --git a/src/store/tool/slices/mcpStore/action.ts b/src/store/tool/slices/mcpStore/action.tsindex 51a853a5775..6d4b3b7f12e 100644--- a/src/store/tool/slices/mcpStore/action.ts+++ b/src/store/tool/slices/mcpStore/action.ts@@ -213,7 +213,6 @@ export class PluginMCPStoreActionImpl {if (!plugin) return;// Extract haveCloudEndpoint after plugin is loaded- // @ts-expect-errorconst { haveCloudEndpoint } = plugin || {};const { updateInstallLoadingState, refreshPlugins, updateMCPInstallProgress } = this.#get();