@mupt-ai/dari-gateway 1.0.363 → 1.0.364

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.
@@ -38,6 +38,7 @@ export declare class HostedSync {
38
38
  snapshot(): Record<string, unknown>;
39
39
  private scheduleSnapshot;
40
40
  private putSnapshot;
41
+ private dropPlansOnDari;
41
42
  /** Send the queued request rows a batch at a time, unless hosted failed lately. */
42
43
  drain(): Promise<void>;
43
44
  private drainDue;
@@ -115,8 +115,10 @@ export class HostedSync {
115
115
  const response = await this.call("PUT", "/v1/gateway/subscriptions", this.snapshot());
116
116
  if (!response.ok)
117
117
  throw new Error(`HTTP ${response.status}: ${(await response.text()).slice(0, 300)}`);
118
+ const body = await response.json();
118
119
  this.snapshotFailures = 0;
119
120
  this.scheduleSnapshot(HEARTBEAT_MS);
121
+ this.dropPlansOnDari(body.on_dari);
120
122
  }
121
123
  catch (error) {
122
124
  this.snapshotFailures += 1;
@@ -124,6 +126,20 @@ export class HostedSync {
124
126
  this.scheduleSnapshot(backoff(this.snapshotFailures));
125
127
  }
126
128
  }
129
+ // Hosted Dari names the reported plans whose account was since connected on
130
+ // Dari. Dari's plan serves this computer too, so the copy here goes, and
131
+ // disconnecting it reports the plans again.
132
+ dropPlansOnDari(localIds) {
133
+ if (!Array.isArray(localIds))
134
+ return;
135
+ for (const id of localIds) {
136
+ const plan = typeof id === "string" ? this.subscriptions.get(id) : null;
137
+ if (plan === null || plan.owner !== null || plan.private)
138
+ continue;
139
+ this.subscriptions.disconnect(plan.name);
140
+ console.error(`${plan.name} is now connected on Dari; removed it from this computer`);
141
+ }
142
+ }
127
143
  /** Send the queued request rows a batch at a time, unless hosted failed lately. */
128
144
  drain() {
129
145
  this.draining ??= this.drainDue().finally(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mupt-ai/dari-gateway",
3
- "version": "1.0.363",
3
+ "version": "1.0.364",
4
4
  "description": "Self-hostable LLM gateway for coding agents and APIs: one endpoint for Anthropic Messages, OpenAI Chat Completions, and OpenAI Responses, with subscription pooling, failover, and prompt-cache-aware routing.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@aws-sdk/client-sts": "3.1063.0",
55
- "@mupt-ai/dari-router": "1.0.363",
55
+ "@mupt-ai/dari-router": "1.0.364",
56
56
  "@mupt-ai/pi-ai": "1.5.2-mupt.3"
57
57
  },
58
58
  "devDependencies": {
@@ -130,8 +130,10 @@ export class HostedSync {
130
130
  try {
131
131
  const response = await this.call("PUT", "/v1/gateway/subscriptions", this.snapshot());
132
132
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${(await response.text()).slice(0, 300)}`);
133
+ const body = await response.json() as { on_dari?: unknown };
133
134
  this.snapshotFailures = 0;
134
135
  this.scheduleSnapshot(HEARTBEAT_MS);
136
+ this.dropPlansOnDari(body.on_dari);
135
137
  } catch (error) {
136
138
  this.snapshotFailures += 1;
137
139
  console.error("hosted plan sync failed", error instanceof Error ? error.message : String(error));
@@ -139,6 +141,19 @@ export class HostedSync {
139
141
  }
140
142
  }
141
143
 
144
+ // Hosted Dari names the reported plans whose account was since connected on
145
+ // Dari. Dari's plan serves this computer too, so the copy here goes, and
146
+ // disconnecting it reports the plans again.
147
+ private dropPlansOnDari(localIds: unknown): void {
148
+ if (!Array.isArray(localIds)) return;
149
+ for (const id of localIds) {
150
+ const plan = typeof id === "string" ? this.subscriptions.get(id) : null;
151
+ if (plan === null || plan.owner !== null || plan.private) continue;
152
+ this.subscriptions.disconnect(plan.name);
153
+ console.error(`${plan.name} is now connected on Dari; removed it from this computer`);
154
+ }
155
+ }
156
+
142
157
  /** Send the queued request rows a batch at a time, unless hosted failed lately. */
143
158
  drain(): Promise<void> {
144
159
  this.draining ??= this.drainDue().finally(() => {