Theia API Documentation v1.73.0
    Preparing search index...

    Backend service that performs all skill filesystem and network work. The browser only triggers actions and renders results - ~/.agents/skills is outside the browser FileService sandbox, so all fetch + filesystem writes happen here.

    Implements

    Index

    Constructors

    Properties

    clients: Set<SkillInstallClient> = ...
    hashCache: Map<string, { contentHash: string; signature: string }> = ...

    Caches each skill folder's content hash keyed on a cheap stat signature, so drift detection avoids re-reading unchanged files.

    logger: ILogger
    notifyTimeout: undefined | Timeout
    preferenceService: PreferenceService
    requestService: RequestService
    subscription: undefined | AsyncSubscription
    watching: boolean = false

    Methods

    • Rejects skill names that are not a single, safe path segment. The name originates from registry JSON, so guarding here prevents a .. or separator from escaping the skills root when it is joined into a filesystem path.

      Parameters

      • name: string

      Returns void

    • Content hash of a skill folder, reusing the cached result while the folder's file stats (size + mtime of the hash-relevant files) are unchanged. Any install, update, fix, or external edit changes those stats and invalidates the cache automatically.

      A single recursive traversal collects the stats that form the cheap drift signature; the file contents are read (and hashed) only on a cache miss, so an unchanged folder is walked once and never re-read.

      Parameters

      • dir: string

      Returns Promise<string>

    • Lazily starts a debounced recursive watch on ~/.agents/skills, notifying clients on change. Uses @parcel/watcher (the same backend as Theia's filesystem watcher) so additions and removals - including bare directory deletions - are reported reliably across platforms.

      Returns void

    • Runs once after construction to sweep any stale staging folders left behind by a backend crash mid-install (see writeSkill). Best-effort: failures are logged and swallowed so an unreachable skills root never blocks the service from starting.

      Returns void

    • Single recursive traversal of the hash-relevant files under dir, capturing each file's POSIX relative path, absolute path, size and mtime. Dot-prefixed entries are skipped at every level, matching computeSkillContentHash.

      Parameters

      • dir: string
      • relativeBase: string = ''

      Returns Promise<SkillStatEntry[]>

    • Removes any .installing-* staging folders left under the skills root by a backend crash mid-install. Same-process installs always clean their own staging in the finally of writeSkill; this sweep handles the cross-process-crash case so those folders do not accumulate forever.

      Returns Promise<void>

    • Writes a freshly-downloaded skill plus its registry metadata into a sibling staging folder and then atomically swaps it into place, so an interrupted download never leaves a partially-written skill folder behind.

      replaceExisting controls whether an existing target folder is removed first:

      • false (install): the target must not exist; the staging rename surfaces the race if a concurrent install or external mkdir wins between the caller's existence check and the rename, instead of silently clobbering that folder.
      • true (update/fix): the user explicitly asked us to replace the folder.

      The staging folder is always cleaned up in finally, so a thrown error or an already-existing target never leaves an orphan .installing-* folder behind.

      Parameters

      Returns Promise<void>