eve-hub 0.6.59 → 0.6.60
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/CHANGELOG.md +6 -0
- package/hooks/mention-gate.js +7 -3
- package/mention-gate.d.mts +1 -1
- package/mention-gate.mjs +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/hooks/mention-gate.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getVercelOidcToken } from "@vercel/oidc";
|
|
1
2
|
import { defineHook } from "eve/hooks";
|
|
2
3
|
import { registryBase, registryFetch } from "../registry-fetch.mjs";
|
|
3
4
|
import { credentialCache, hubCredentialLoader, screenInbound } from "../mention-gate.mjs";
|
|
@@ -6,9 +7,12 @@ import { credentialCache, hubCredentialLoader, screenInbound } from "../mention-
|
|
|
6
7
|
// and the delivery whether a reply is needed. On a skip the hub posts
|
|
7
8
|
// "<bot> skipped: <reason>" and the turn is cancelled before any model call.
|
|
8
9
|
// Any failure answers. The hub names the bot from its session and serves its
|
|
9
|
-
// instructions
|
|
10
|
-
// the
|
|
11
|
-
|
|
10
|
+
// instructions, so a deployed bot and a Mac bot run the same code. Its AI Gateway
|
|
11
|
+
// credential is an OIDC token for the workspace's bots project: a deployed bot
|
|
12
|
+
// carries its own, and a Mac bot has none, so it asks the hub for one.
|
|
13
|
+
// See packages/agent-kit/mention-gate.mjs.
|
|
14
|
+
const deploymentToken = async () => ({ ok: true, token: await getVercelOidcToken() });
|
|
15
|
+
const credential = credentialCache(process.env.VERCEL ? deploymentToken : hubCredentialLoader(registryFetch));
|
|
12
16
|
export default defineHook({
|
|
13
17
|
events: {
|
|
14
18
|
async "message.received"(event, ctx) {
|
package/mention-gate.d.mts
CHANGED
|
@@ -3,4 +3,4 @@ export function gateConfig(env?: Record<string, string | undefined>, file?: unkn
|
|
|
3
3
|
export function opensWithHandle(text: string, agent: string): boolean;
|
|
4
4
|
export function cleanReason(reason: unknown): string;
|
|
5
5
|
export function screenInbound(input: { text: string; sessionId: string; agent?: string; registryUrl: string; credential: (opts?: { refresh?: boolean }) => Promise<{ token: string; teamId?: string | null } | null>; instructions?: string; fetchImpl?: typeof fetch; log?: ((line: string) => void) | null }): Promise<{ cancel: boolean; result?: unknown }>;
|
|
6
|
-
export function hubCredentialLoader(fetchHub: (path: string, init: { headers?: Record<string, string> }) => Promise<Response>): (opts?: { refresh?: boolean }) => Promise<{ ok: boolean; token?: string;
|
|
6
|
+
export function hubCredentialLoader(fetchHub: (path: string, init: { headers?: Record<string, string> }) => Promise<Response>): (opts?: { refresh?: boolean }) => Promise<{ ok: boolean; token?: string; error?: string }>;
|
package/mention-gate.mjs
CHANGED
|
@@ -434,7 +434,7 @@ export async function screenInbound({ text, sessionId, agent, registryUrl, instr
|
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
-
// A
|
|
437
|
+
// A Mac bot's AI Gateway credential: the hub mints an OIDC token for the workspace's bots project, asked for with the bot's HUB_TOKEN.
|
|
438
438
|
// `fetchHub(path, init)` is registryFetch. On a refresh it names the token AI Gateway refused, as eve's served credential does.
|
|
439
439
|
export function hubCredentialLoader(fetchHub) {
|
|
440
440
|
let last = null;
|
|
@@ -443,6 +443,6 @@ export function hubCredentialLoader(fetchHub) {
|
|
|
443
443
|
if (!res.ok) return { ok: false, error: `model credential ${res.status}` };
|
|
444
444
|
const c = await res.json();
|
|
445
445
|
last = c.token ?? null;
|
|
446
|
-
return { ok: Boolean(c.token), token: c.token
|
|
446
|
+
return { ok: Boolean(c.token), token: c.token };
|
|
447
447
|
};
|
|
448
448
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eve-hub",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.60",
|
|
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",
|