@slatesvideo/shared 0.7.24 → 0.7.25

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.
@@ -21,7 +21,7 @@ export declare class SlatesDesktopClient {
21
21
  });
22
22
  private get baseUrl();
23
23
  healthz(): Promise<DesktopHealth>;
24
- requireCapability(cap: string, friendlyFeature: string): Promise<void>;
24
+ requireCapability(cap: string, friendlyFeature: string, minimumVersion?: string): Promise<void>;
25
25
  /** Whether this desktop advertises `cap`: for an op that has an older route to fall back to. */
26
26
  hasCapability(cap: string): Promise<boolean>;
27
27
  private cachedHealth;
@@ -1,5 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { DesktopUnreachableError, requireDesktop } from '../auth.js';
3
+ import { compareVersions } from '../update-check.js';
3
4
  // One agent session per process (an MCP server's connection, or one CLI run): the desktop counts
4
5
  // what it spends against the person's per-session spend limit (`slates_get_spend_limits`).
5
6
  const AGENT_SESSION = randomUUID();
@@ -92,13 +93,17 @@ export class SlatesDesktopClient {
92
93
  // Calling a missing route on an old desktop would 404 with an opaque
93
94
  // error — this check turns that into an actionable "update Slates"
94
95
  // message BEFORE the op's first real request.
95
- async requireCapability(cap, friendlyFeature) {
96
+ async requireCapability(cap, friendlyFeature, minimumVersion) {
96
97
  const health = await this.cachedHealth();
97
98
  if (health.agentApiVersion === undefined || !health.capabilities?.includes(cap)) {
98
99
  throw new Error(`Your Slates desktop app doesn't support ${friendlyFeature} yet ` +
99
100
  `(agent API v${health.agentApiVersion ?? 1}, need v2 with '${cap}'). ` +
100
101
  `Update Slates (Settings → Check for Updates) and retry.`);
101
102
  }
103
+ if (minimumVersion && (!health.version || compareVersions(health.version, minimumVersion) < 0)) {
104
+ throw new Error(`${friendlyFeature} requires Slates ${minimumVersion} or later. ` +
105
+ `Update Slates (Settings → Check for Updates) and retry.`);
106
+ }
102
107
  }
103
108
  /** Whether this desktop advertises `cap`: for an op that has an older route to fall back to. */
104
109
  async hasCapability(cap) {