Skip to content

🀯 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.

πŸ› fix(skills): hide sandbox runCommand / exportFile when the caller desktop is routed (#22303)

Mochac2b890161493
diff --git a/packages/builtin-tool-skills/src/resolveManifest.test.ts b/packages/builtin-tool-skills/src/resolveManifest.test.ts
index 2a212aca131..b94f78f64bf 100644
--- a/packages/builtin-tool-skills/src/resolveManifest.test.ts
+++ b/packages/builtin-tool-skills/src/resolveManifest.test.ts
@@ -19,37 +19,41 @@ describe('resolveSkillsManifest', () => {
expect(resolveSkillsManifest({ isSubAgent: true, scope: 'main' })).toBe(SkillsManifest);
});
- it.each(['local', 'none'] as const)(
- 'returns the static manifest reference for executionEnv %s',
- (executionEnv) => {
- expect(resolveSkillsManifest({ executionEnv })).toBe(SkillsManifest);
- },
- );
+ it('returns the static manifest reference for executionEnv none', () => {
+ expect(resolveSkillsManifest({ executionEnv: 'none' })).toBe(SkillsManifest);
+ });
// Device runs execute execScript ON the device (serverRuntimes/skills.ts
// device branch) β€” the description must say so, and the sandbox-only APIs
// (runCommand / exportFile) are dropped, restoring the original desktop
- // manifest shape.
- it('declares device execution and hides sandbox-only APIs when a device is routed', () => {
- const result = resolveSkillsManifest({ executionEnv: 'device' })!;
+ // manifest shape. `local` is the same routed device (the user's own desktop,
+ // kept distinct only for local-system image reads): the server runtime still
+ // takes the device branch and refuses sandbox runCommand / exportFile.
+ it.each(['device', 'local'] as const)(
+ 'declares device execution and hides sandbox-only APIs for executionEnv %s',
+ (executionEnv) => {
+ const result = resolveSkillsManifest({ executionEnv })!;
- const description = apiByName(result, SkillsApiName.execScript).description;
- expect(description).toMatch(/^Execution environment: the user's selected device/);
- expect(description).toContain('NOT injected');
- // the original mechanics stay after the preamble
- expect(description).toContain(apiByName(SkillsManifest, SkillsApiName.execScript).description);
-
- const apiNames = result.api.map((a) => a.name);
- expect(apiNames).not.toContain(SkillsApiName.runCommand);
- expect(apiNames).not.toContain(SkillsApiName.exportFile);
- expect(apiNames).toContain(SkillsApiName.activateSkill);
- expect(apiNames).toContain(SkillsApiName.readReference);
-
- // cross-tool arbitration rides the tool systemRole, not the descriptions
- expect(result.systemRole).toContain(systemPrompt);
- expect(result.systemRole).toContain('`execScript` runs skill scripts on the device');
- expect(result.systemRole).toContain('`lobe-local-system` runCommand');
- });
+ const description = apiByName(result, SkillsApiName.execScript).description;
+ expect(description).toMatch(/^Execution environment: the user's selected device/);
+ expect(description).toContain('NOT injected');
+ // the original mechanics stay after the preamble
+ expect(description).toContain(
+ apiByName(SkillsManifest, SkillsApiName.execScript).description,
+ );
+
+ const apiNames = result.api.map((a) => a.name);
+ expect(apiNames).not.toContain(SkillsApiName.runCommand);
+ expect(apiNames).not.toContain(SkillsApiName.exportFile);
+ expect(apiNames).toContain(SkillsApiName.activateSkill);
+ expect(apiNames).toContain(SkillsApiName.readReference);
+
+ // cross-tool arbitration rides the tool systemRole, not the descriptions
+ expect(result.systemRole).toContain(systemPrompt);
+ expect(result.systemRole).toContain('`execScript` runs skill scripts on the device');
+ expect(result.systemRole).toContain('`lobe-local-system` runCommand');
+ },
+ );
it.each(['bound-device-offline', 'no-online-device'] as const)(
'warns about the offline device when device-unrouted for %s',
diff --git a/packages/builtin-tool-skills/src/resolveManifest.ts b/packages/builtin-tool-skills/src/resolveManifest.ts
index 2d872189b8a..54f88ea69be 100644
--- a/packages/builtin-tool-skills/src/resolveManifest.ts
+++ b/packages/builtin-tool-skills/src/resolveManifest.ts
@@ -122,7 +122,12 @@ const resolveUnroutedTexts = (
* additionally drop the sandbox-only APIs (`runCommand` / `exportFile`).
*/
export const resolveSkillsManifest: BuiltinManifestResolver = (context) => {
- const basePreamble = context.executionEnv && EXEC_ENV_PREAMBLES[context.executionEnv];
+ // `local` is a routed device too β€” the user's own desktop, kept distinct
+ // only so local-system can return images (`executionPlanToManifestExecutionEnv`).
+ // The server runtime gets the same `activeDeviceId` and refuses sandbox
+ // runCommand / exportFile, so the manifest must not offer them either.
+ const executionEnv = context.executionEnv === 'local' ? 'device' : context.executionEnv;
+ const basePreamble = executionEnv && EXEC_ENV_PREAMBLES[executionEnv];
const isPageScope = context.scope === 'page';
if (!basePreamble) {
return isPageScope
@@ -133,16 +138,16 @@ export const resolveSkillsManifest: BuiltinManifestResolver = (context) => {
: SkillsManifest;
}
- const isDeviceRun = context.executionEnv === 'device';
+ const isDeviceRun = executionEnv === 'device';
const isHidden = (name: string) =>
(isDeviceRun && DEVICE_HIDDEN_API_NAMES.has(name)) ||
(isPageScope && PAGE_HIDDEN_API_NAMES.has(name));
const unrouted =
- context.executionEnv === 'device-unrouted'
+ executionEnv === 'device-unrouted'
? resolveUnroutedTexts(context.executionEnvUnroutedReason)
: {};
const preamble = unrouted.preamble ?? basePreamble;
- const fact = unrouted.fact ?? (context.executionEnv && EXEC_ENV_FACTS[context.executionEnv]);
+ const fact = unrouted.fact ?? (executionEnv && EXEC_ENV_FACTS[executionEnv]);
return {
...SkillsManifest,