@mupt-ai/dari-gateway 1.0.361 → 1.0.362

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.
@@ -139,7 +139,7 @@ async function startSession(deps, body, now) {
139
139
  const isPrivate = body.private ?? reconnecting?.private ?? false;
140
140
  if (typeof isPrivate !== "boolean")
141
141
  throw new HttpError(400, "private must be true or false.");
142
- // `dari accounts subscription move` names the hosted plan it moves here.
142
+ // `dari accounts subscription connect` names the hosted plan it moves here.
143
143
  const movingFrom = body.moving_from ?? null;
144
144
  if (movingFrom !== null && (typeof movingFrom !== "string" || !movingFrom.trim())) {
145
145
  throw new HttpError(400, "moving_from must be a non-empty string.");
@@ -265,13 +265,23 @@ function usageBody(credential, now) {
265
265
  })),
266
266
  };
267
267
  }
268
+ function safeMetadata(credential) {
269
+ const metadata = {};
270
+ if (credential.accountEmail !== null)
271
+ metadata.account_email = credential.accountEmail;
272
+ if (credential.accountId !== null)
273
+ metadata.account_id = credential.accountId;
274
+ return metadata;
275
+ }
268
276
  function credentialBody(credential, active, now) {
269
277
  const held = isHeld(credential, now);
270
278
  return {
271
279
  id: credential.id,
272
280
  name: credential.name,
273
281
  label: credential.label,
274
- safe_metadata: credential.accountEmail === null ? {} : { account_email: credential.accountEmail },
282
+ // The account, as hosted Dari shows a plan's: its email and, where the
283
+ // provider names one, its account (a ChatGPT workspace).
284
+ safe_metadata: safeMetadata(credential),
275
285
  // Hosted organizations also hold organization-scoped secrets; every
276
286
  // subscription here belongs to the gateway's one user.
277
287
  credential_scope: "user",
@@ -29,18 +29,14 @@ const PROVIDER_LABELS = {
29
29
  xai_grok: "Grok",
30
30
  vercel_token_pass: "Vercel Token Pass",
31
31
  };
32
+ const PLACE_NAMES = {
33
+ dari: "on Dari",
34
+ this_computer: "on This Computer",
35
+ private: "Private on This Computer",
36
+ };
32
37
  function connectedAccountMessage(account) {
33
- const label = PROVIDER_LABELS[account.provider];
34
- const handle = account.name ?? "NAME";
35
- const asName = account.name === null ? "" : ` as ${handle}`;
36
- switch (account.place) {
37
- case "dari":
38
- return `This ${label} account is already connected on Dari${asName}. Move it with \`dari accounts subscription move ${handle} --on computer\`, or disconnect it first.`;
39
- case "this_computer":
40
- return `This ${label} account is already connected on This Computer${asName}. Move it with \`dari accounts subscription move ${handle} --on dari\`, or disconnect it first.`;
41
- case "private":
42
- return `This ${label} account is already connected Private on This Computer${asName}. Move it with \`dari accounts subscription move ${handle} --on dari\` or \`--on computer\`, or disconnect it first.`;
43
- }
38
+ const asName = account.name === null ? "" : ` as ${account.name}`;
39
+ return `This ${PROVIDER_LABELS[account.provider]} account is already connected ${PLACE_NAMES[account.place]}${asName}. Run \`dari accounts subscription connect\` again and choose Move, or disconnect it first.`;
44
40
  }
45
41
  const BASE_NAMES = {
46
42
  anthropic_claude_code: "ANTHROPIC_CLAUDE_CODE_OAUTH_TOKEN",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mupt-ai/dari-gateway",
3
- "version": "1.0.361",
3
+ "version": "1.0.362",
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.361",
55
+ "@mupt-ai/dari-router": "1.0.362",
56
56
  "@mupt-ai/pi-ai": "1.5.2-mupt.3"
57
57
  },
58
58
  "devDependencies": {
@@ -164,7 +164,7 @@ async function startSession(deps: SubscriptionHttpDeps, body: Record<string, unk
164
164
  // A reconnected plan stays where it was unless the caller says otherwise.
165
165
  const isPrivate = body.private ?? reconnecting?.private ?? false;
166
166
  if (typeof isPrivate !== "boolean") throw new HttpError(400, "private must be true or false.");
167
- // `dari accounts subscription move` names the hosted plan it moves here.
167
+ // `dari accounts subscription connect` names the hosted plan it moves here.
168
168
  const movingFrom = body.moving_from ?? null;
169
169
  if (movingFrom !== null && (typeof movingFrom !== "string" || !movingFrom.trim())) {
170
170
  throw new HttpError(400, "moving_from must be a non-empty string.");
@@ -297,13 +297,22 @@ function usageBody(credential: SubscriptionCredential, now: Date) {
297
297
  };
298
298
  }
299
299
 
300
+ function safeMetadata(credential: SubscriptionCredential): Record<string, string> {
301
+ const metadata: Record<string, string> = {};
302
+ if (credential.accountEmail !== null) metadata.account_email = credential.accountEmail;
303
+ if (credential.accountId !== null) metadata.account_id = credential.accountId;
304
+ return metadata;
305
+ }
306
+
300
307
  function credentialBody(credential: SubscriptionCredential, active: boolean, now: Date) {
301
308
  const held = isHeld(credential, now);
302
309
  return {
303
310
  id: credential.id,
304
311
  name: credential.name,
305
312
  label: credential.label,
306
- safe_metadata: credential.accountEmail === null ? {} : { account_email: credential.accountEmail },
313
+ // The account, as hosted Dari shows a plan's: its email and, where the
314
+ // provider names one, its account (a ChatGPT workspace).
315
+ safe_metadata: safeMetadata(credential),
307
316
  // Hosted organizations also hold organization-scoped secrets; every
308
317
  // subscription here belongs to the gateway's one user.
309
318
  credential_scope: "user",
@@ -130,18 +130,15 @@ const PROVIDER_LABELS: Record<SubscriptionProvider, string> = {
130
130
  vercel_token_pass: "Vercel Token Pass",
131
131
  };
132
132
 
133
+ const PLACE_NAMES: Record<ConnectedAccount["place"], string> = {
134
+ dari: "on Dari",
135
+ this_computer: "on This Computer",
136
+ private: "Private on This Computer",
137
+ };
138
+
133
139
  function connectedAccountMessage(account: ConnectedAccount): string {
134
- const label = PROVIDER_LABELS[account.provider];
135
- const handle = account.name ?? "NAME";
136
- const asName = account.name === null ? "" : ` as ${handle}`;
137
- switch (account.place) {
138
- case "dari":
139
- return `This ${label} account is already connected on Dari${asName}. Move it with \`dari accounts subscription move ${handle} --on computer\`, or disconnect it first.`;
140
- case "this_computer":
141
- return `This ${label} account is already connected on This Computer${asName}. Move it with \`dari accounts subscription move ${handle} --on dari\`, or disconnect it first.`;
142
- case "private":
143
- return `This ${label} account is already connected Private on This Computer${asName}. Move it with \`dari accounts subscription move ${handle} --on dari\` or \`--on computer\`, or disconnect it first.`;
144
- }
140
+ const asName = account.name === null ? "" : ` as ${account.name}`;
141
+ return `This ${PROVIDER_LABELS[account.provider]} account is already connected ${PLACE_NAMES[account.place]}${asName}. Run \`dari accounts subscription connect\` again and choose Move, or disconnect it first.`;
145
142
  }
146
143
 
147
144
  const BASE_NAMES: Record<SubscriptionProvider, string> = {