Files
Tim O'Farrell bee6cee418 fix: set bundled skill source to real filesystem path (#1310)
* fix: set bundled skill source to real filesystem path

Bundled public skills were sent to the Python agent-server with
`source: "public"`, which the SDK uses as the skill's `location` in
SkillKnowledge. Any skill whose SKILL.md references bundled resources
(scripts/, references/) is therefore unable to resolve those files —
the agent sees 'Skill location: public' instead of an actual path.

Fix: compute the absolute path to the skills directory inside the
`@openhands/extensions` node_modules package at Vite build/serve time
and inject it as `__EXTENSIONS_SKILLS_DIR__` via Vite's `define`.
`buildBundledSkills()` now sets `source` to:
  `${__EXTENSIONS_SKILLS_DIR__}/${name}/SKILL.md`

Library builds receive an empty string so consumers are not bound to
this machine's node_modules path; the adapter falls back to 'public'
when the value is falsy.

Co-authored-by: openhands <openhands@all-hands.dev>

* fix: declare __EXTENSIONS_SKILLS_DIR__ global for TypeScript

Add missing 'declare const __EXTENSIONS_SKILLS_DIR__: string' to
src/react-app-env.d.ts so tsc can resolve the Vite-injected constant
used in buildBundledSkills().

Co-authored-by: openhands <openhands@all-hands.dev>

* test: assert skill source is absolute path ending in /<name>/SKILL.md

Replace the loose 'typeof === string' / toBeTruthy checks with two specific
assertions that directly verify the intent of buildBundledSkills():
- source starts with '/' (absolute path the agent-server can resolve)
- source ends with '/<name>/SKILL.md' (points to the right file)

Co-authored-by: openhands <openhands@all-hands.dev>

---------

Co-authored-by: openhands <openhands@all-hands.dev>
2026-06-11 09:23:45 -06:00

9 lines
307 B
TypeScript

/// <reference types="vite/client" />
/**
* Absolute filesystem path to the bundled extensions skills directory,
* injected by Vite at build time via `define` in vite.config.ts.
* Empty string in library builds; always a real path in app/dev builds.
*/
declare const __EXTENSIONS_SKILLS_DIR__: string;