eve-hub 0.4.2 → 0.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve-hub",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Bot-side code shared by every hub agent: registry tools, the roster hook, the eve channel, the host sandbox and browser, and model helpers.",
6
6
  "type": "module",
@@ -28,8 +28,6 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "eve": "*",
31
- "ai": "^7.0.105",
32
- "@ai-sdk/gateway": "^4.0.100",
33
31
  "zod": "4.5.4",
34
32
  "@vercel/connect": "^2.4.1",
35
33
  "@vercel/oidc": "4.0.0"
package/roster-model.mjs CHANGED
@@ -17,15 +17,6 @@ import { CONTEXT_WINDOW, selectModel } from "./bot-model.mjs";
17
17
  import { DEFAULT_SUBAGENT_CAP } from "./subagent-cap.mjs";
18
18
  import { sessionLimits } from "./session-limits.mjs";
19
19
  import { findWorkspaceRoot, loadWorkspace, parseWorkspace } from "./workspace.mjs";
20
- import { createGateway } from "ai";
21
- import { hubGatewayFetch } from "./model-credential.mjs";
22
- import { registryBase } from "./registry-fetch.mjs";
23
-
24
- // Hosted, a bot's model ids resolve through the owner's sign-in from the hub
25
- // (model-credential.mjs); elsewhere through the default gateway.
26
- if (process.env.HUB_TOKEN)
27
- globalThis.AI_SDK_DEFAULT_PROVIDER = createGateway({ apiKey: "hub-owner-sign-in", fetch: hubGatewayFetch(`${registryBase().replace(/\/$/, "")}/api/model-credential`) });
28
-
29
20
  const real = process.env.ROSTER_MODELS !== "mock";
30
21
 
31
22
  export function createRosterModel({ agents, subagentCap }) {
@@ -1,44 +0,0 @@
1
- // Hosted bots resolve model ids through the owner's refreshable Vercel sign-in.
2
- // HUB_TOKEN identifies a hosted bot; the credential endpoint is on its registry.
3
- // The hub owns expiration and refresh; Gateway rejection invalidates our cache.
4
- import { createHash } from "node:crypto";
5
- import { GatewayAuthenticationError } from "@ai-sdk/gateway";
6
- import { registryHeaders } from "./registry-fetch.mjs";
7
-
8
- /**
9
- * The fetch the gateway sends through: the hub's current token and team on
10
- * each request, and on a 401, one more try with the token the hub hands out
11
- * after it is told (by sha256) which token Gateway refused.
12
- */
13
- export function hubGatewayFetch(credentialUrl, fetchFn = (...a) => globalThis.fetch(...a), now = Date.now) {
14
- let current;
15
- const credential = async (rejected) => {
16
- if (!rejected && current && now() < current.expiresAt) return current;
17
- const headers = registryHeaders();
18
- if (rejected) headers["x-rejected-token-sha256"] = createHash("sha256").update(rejected).digest("hex");
19
- const response = await fetchFn(credentialUrl, { headers });
20
- if (response.status === 401) {
21
- const { error } = await response.json();
22
- throw new GatewayAuthenticationError({ message: error });
23
- }
24
- if (!response.ok) throw new Error(`model credential from the hub: HTTP ${response.status} ${await response.text()}`);
25
- return (current = await response.json());
26
- };
27
- return async (input, init) => {
28
- const headers = new Headers(init?.headers);
29
- const send = async (c) => {
30
- headers.set("authorization", `Bearer ${c.token}`);
31
- headers.set("x-vercel-ai-gateway-team", c.teamId);
32
- const response = await fetchFn(input, { ...init, headers });
33
- if (response.status === 401) current = undefined;
34
- return response;
35
- };
36
- const first = await credential();
37
- const response = await send(first);
38
- if (response.status !== 401) return response;
39
- // A streamed body can't be sent twice, but its rejected token is dropped.
40
- if (init?.body != null && typeof init.body !== "string") return response;
41
- await response.body?.cancel();
42
- return send(await credential(first.token));
43
- };
44
- }