@deslop/gateway 0.1.1258 → 0.1.1260

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.
package/README.md CHANGED
@@ -1,27 +1,16 @@
1
1
  # Gateway
2
2
 
3
- One MCP endpoint for every MCP server you connect; add servers on its page.
4
-
5
3
  ```bash
6
4
  npm install --global @deslop/gateway
7
5
  gateway service install --url https://gateway.mp281x.xyz --auth https://auth.mp281x.xyz --admins <github-id>
8
6
  ```
9
7
 
10
- - **Register** only `https://<gateway>/mcp` in each harness; tools are named `<server>__<tool>`.
11
- - **Admins** (`--admins`) add and connect servers; everyone signed in shares them.
12
- - **Deslop servers** name Auth in their protected-resource metadata and take the caller's own access token for discovery and calls, without Connect or stored tokens. Only third-party OAuth servers keep the Connect flow.
13
- - **Own tool**: `list_mcp_connections` explains a missing or failing server.
8
+ Register only `https://<gateway>/mcp` in each harness. Admins add and connect servers; everyone signed in shares them. AI keys and usage belong to each person, as described in this app's `AGENTS.md`.
14
9
 
15
10
  ## AI proxy
16
11
 
17
- Each person manages their own Anthropic, OpenRouter, OpenCode Zen and OpenCode Go keys. Keys stay in Gateway's owner-only data files; only their last four characters and last upstream status leave the server.
18
-
19
- App servers start with `--gateway https://gateway.mp281x.xyz`. Every AI call sends the person's signed access JWT; Gateway verifies it and records its `azp` client label as the app. No app-specific credential is issued. Without `--auth`, calls use the local developer.
20
-
21
- Use `AiGateway` from `@deslop/runtime/ai`: `yield* gateway.apiUrl(provider)` and pass `yield* gateway.authorize(userId)` as the provider client's **construction-time** `transformClient`. The runtime prefers the person's freshest server-side session, refreshing it when needed, then a recently verified bearer with at least 60 seconds left. Otherwise it asks the person to open the app once. OpenRouter's scoped `withClientTransform` does not cover streaming chat completions. OpenRouter's base includes `/v1`; its Decisions client derives `/alpha/decisions` correctly. OpenCode bases expose protocol-family paths such as `/openai/v1/chat/completions` and `/anthropic/v1/messages` without translating them.
22
-
23
- `/ai/<provider>/<rest>` forwards method, query, body and upstream status. Fetch decodes compressed responses; stale encoding and length headers, hop-by-hop headers and headers nominated by `Connection` are removed from the streamed answer. Caller credentials and hop-by-hop headers are removed before inserting the person's provider key. Missing keys return HTTP 402 with instructions to add a key in Gateway. JSON and SSE usage is metered asynchronously; provider-reported cost wins, then daily-cached models.dev prices, otherwise cost remains unknown. Usage is stored per person and UTC month.
12
+ App servers start with `--gateway https://gateway.mp281x.xyz`.
24
13
 
25
- Person-scoped RPCs: `ai.keys`, `ai.setKey`, `ai.removeKey`, `ai.usage`. Usage queries take epoch-millisecond `from` (inclusive), `to` (exclusive), and `bucket` (`hour` or `day`); `AiUsageReport` returns token/cost totals, UTC buckets split by app and model, and breakdowns by app, model and provider. `unknownCostCalls` distinguishes unknown cost from zero cost.
14
+ Use `AiGateway` from `@deslop/runtime/ai`: `yield* gateway.apiUrl(provider)` and pass `yield* gateway.authorize(userId)` as the provider client's **construction-time** `transformClient`. OpenRouter's scoped `withClientTransform` does not cover streaming chat completions.
26
15
 
27
16
  Common flags and service commands: [Deslop app runtime](https://github.com/MP281X/deslop/blob/main/packages/runtime/README.md).
package/dist/server.js CHANGED
@@ -91556,7 +91556,6 @@ var AiGateway = class AiGateway extends Service$1()("@deslop/runtime/ai/service/
91556
91556
  const gateway = yield* option(String$5("GATEWAY_URL"));
91557
91557
  const local = yield* localAuth;
91558
91558
  const sessions = yield* Sessions;
91559
- yield* (yield* KeyValueStore).remove("ai-gateway-grants");
91560
91559
  return AiGateway.of({
91561
91560
  apiUrl: (provider) => match$8(gateway, {
91562
91561
  onNone: () => fail$7(AiUnavailable.make({ message: "Start the app with --gateway" })),
@@ -92037,7 +92036,6 @@ const failed$1 = mapError$2((cause) => AuthError.make({
92037
92036
  const make = gen(function* () {
92038
92037
  const kv = yield* KeyValueStore;
92039
92038
  const keys = toSchemaStore(kv, ArraySchema(AiStoredKey));
92040
- yield* kv.remove("ai-grants");
92041
92039
  const usage = toSchemaStore(kv, ArraySchema(AiUsageEntry));
92042
92040
  const auth = yield* Auth;
92043
92041
  const local = yield* localAuth;
@@ -118989,16 +118987,7 @@ var Connections = class Connections extends Service$1()("@deslop/gateway/service
118989
118987
  return exists(authUrl, (issuer) => target.protocol === "https:" && isEmpty$1(target.port) && siteOf(target) === siteOf(issuer) && contains$1(authorizationServers, new URL("/api/auth", issuer).href));
118990
118988
  }
118991
118989
  const store = toSchemaStore(yield* KeyValueStore, ConnectionStore);
118992
- const cleaned = map$9(getOrElse(yield* store.get("servers"), () => ({})), (connection) => {
118993
- if (!deslop(connection.url, toArray$2(fromUndefinedOr(connection.oauth?.metadata.issuer)))) return connection;
118994
- return {
118995
- ...omit$1(connection, ["oauth", "error"]),
118996
- link: { _tag: "Connected" },
118997
- mode: "deslop"
118998
- };
118999
- });
119000
- yield* store.set("servers", cleaned);
119001
- const state = yield* make$42(cleaned);
118990
+ const state = yield* make$42(getOrElse(yield* store.get("servers"), () => ({})));
119002
118991
  const admins = yield* adminIds;
119003
118992
  const traffic = yield* sliding(64);
119004
118993
  const admin = fnUntraced(function* (user) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/gateway",
3
- "version": "0.1.1258",
3
+ "version": "0.1.1260",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/MP281X/deslop.git",
@@ -33,5 +33,5 @@
33
33
  "engines": {
34
34
  "node": ">=26"
35
35
  },
36
- "fingerprint": "e82f9750b02cc65bf7afc26a1dea9f7bf14854db99a187c2740d20d54b400727"
36
+ "fingerprint": "c24d4a97778975903d7919c24db6d9b7a3c8c821e90dfe152782f4652da7efdc"
37
37
  }