@mindstudio-ai/local-model-tunnel 0.3.4 → 0.4.0

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.
@@ -10,6 +10,7 @@ var config = new Conf({
10
10
  environment: "prod",
11
11
  providerBaseUrls: {},
12
12
  providerInstallPaths: {},
13
+ localInterfaces: {},
13
14
  environments: {
14
15
  prod: {
15
16
  apiBaseUrl: "https://api.mindstudio.ai"
@@ -37,6 +38,12 @@ function getApiKey() {
37
38
  function setApiKey(key) {
38
39
  setEnvConfig("apiKey", key);
39
40
  }
41
+ function getUserId() {
42
+ return getEnvConfig().userId;
43
+ }
44
+ function setUserId(id) {
45
+ setEnvConfig("userId", id);
46
+ }
40
47
  function getApiBaseUrl() {
41
48
  return getEnvConfig().apiBaseUrl;
42
49
  }
@@ -61,6 +68,23 @@ function setProviderInstallPath(name, installPath) {
61
68
  paths[name] = installPath;
62
69
  config.set("providerInstallPaths", paths);
63
70
  }
71
+ function getLocalInterfacesDir() {
72
+ return path.join(os.homedir(), ".mindstudio-local-tunnel", "interfaces");
73
+ }
74
+ function getLocalInterfacePath(key) {
75
+ const interfaces = config.get("localInterfaces");
76
+ return interfaces[key];
77
+ }
78
+ function setLocalInterfacePath(key, dirPath) {
79
+ const interfaces = config.get("localInterfaces");
80
+ interfaces[key] = dirPath;
81
+ config.set("localInterfaces", interfaces);
82
+ }
83
+ function deleteLocalInterfacePath(key) {
84
+ const interfaces = config.get("localInterfaces");
85
+ delete interfaces[key];
86
+ config.set("localInterfaces", interfaces);
87
+ }
64
88
 
65
89
  // src/api.ts
66
90
  function getHeaders() {
@@ -68,10 +92,15 @@ function getHeaders() {
68
92
  if (!apiKey) {
69
93
  throw new Error("Not authenticated. Run: mindstudio-local auth");
70
94
  }
71
- return {
95
+ const headers = {
72
96
  Authorization: `Bearer ${apiKey}`,
73
97
  "Content-Type": "application/json"
74
98
  };
99
+ const userId = getUserId();
100
+ if (userId) {
101
+ headers["x-user-id"] = userId;
102
+ }
103
+ return headers;
75
104
  }
76
105
  async function pollForRequest(modelIds) {
77
106
  const baseUrl = getApiBaseUrl();
@@ -190,6 +219,21 @@ async function pollDeviceAuth(token) {
190
219
  const data = await response.json();
191
220
  return data;
192
221
  }
222
+ async function getEditorSessions() {
223
+ const baseUrl = getApiBaseUrl();
224
+ const response = await fetch(`${baseUrl}/v1/local-editor/sessions`, {
225
+ method: "GET",
226
+ headers: getHeaders()
227
+ });
228
+ if (!response.ok) {
229
+ const errorText = await response.text();
230
+ throw new Error(
231
+ `Failed to fetch editor sessions: ${response.status} ${errorText}`
232
+ );
233
+ }
234
+ const data = await response.json();
235
+ return data.editors;
236
+ }
193
237
  async function disconnectHeartbeat() {
194
238
  const baseUrl = getApiBaseUrl();
195
239
  const response = await fetch(`${baseUrl}/v1/local-models/disconnect`, {
@@ -1584,15 +1628,23 @@ export {
1584
1628
  getEnvironment,
1585
1629
  getApiKey,
1586
1630
  setApiKey,
1631
+ getUserId,
1632
+ setUserId,
1633
+ getApiBaseUrl,
1587
1634
  getConfigPath,
1635
+ getLocalInterfacesDir,
1636
+ getLocalInterfacePath,
1637
+ setLocalInterfacePath,
1638
+ deleteLocalInterfacePath,
1588
1639
  verifyApiKey,
1589
1640
  syncModels,
1590
1641
  getSyncedModels,
1591
1642
  requestDeviceAuth,
1592
1643
  pollDeviceAuth,
1644
+ getEditorSessions,
1593
1645
  detectAllProviderStatuses,
1594
1646
  discoverAllModelsWithParameters,
1595
1647
  requestEvents,
1596
1648
  TunnelRunner
1597
1649
  };
1598
- //# sourceMappingURL=chunk-PPP2FEIN.js.map
1650
+ //# sourceMappingURL=chunk-44NXQXRB.js.map