Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

[1/3] feat(eve): define external resource snapshot (#3468)

Ben Pankow0b49e3f1260a
diff --git a/.changeset/curvy-spoons-build.md b/.changeset/curvy-spoons-build.md
new file mode 100644
index 000000000..30476e076
--- /dev/null
+++ b/.changeset/curvy-spoons-build.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Define the versioned internal snapshot used to hand compiled external resource requirements to build integrations.
diff --git a/packages/eve/src/internal/external-resources-snapshot.test.ts b/packages/eve/src/internal/external-resources-snapshot.test.ts
new file mode 100644
index 000000000..2618607a8
--- /dev/null
+++ b/packages/eve/src/internal/external-resources-snapshot.test.ts
@@ -0,0 +1,45 @@
+import { describe, expect, it } from "vitest";
+
+import {
+ createExternalResourcesSnapshot,
+ type ExternalResource,
+} from "#internal/external-resources-snapshot.js";
+
+const resources: readonly ExternalResource[] = [
+ {
+ credentials: {
+ method: "oauth",
+ reference: "connector:oauth/linear",
+ service: "linear",
+ subjectTypes: ["user"],
+ },
+ kind: "connection",
+ logicalPath: "connections/linear.ts",
+ name: "linear",
+ protocol: { type: "mcp", url: "https://mcp.linear.app/mcp" },
+ },
+ {
+ credentials: {
+ method: "slack",
+ reference: "connector:slack/support",
+ service: "slack",
+ subjectTypes: ["app"],
+ },
+ kind: "channel",
+ logicalPath: "channels/slack.ts",
+ manifest: { display_information: { name: "Support" } },
+ name: "slack",
+ route: { path: "/eve/v1/slack" },
+ },
+];
+
+describe("external resources snapshot", () => {
+ it("wraps generic resources in a versioned eve snapshot", () => {
+ expect(createExternalResourcesSnapshot({ generatorVersion: "1.2.3", resources })).toEqual({
+ generator: { name: "eve", version: "1.2.3" },
+ kind: "eve-external-resources",
+ resources,
+ schemaVersion: 1,
+ });
+ });
+});
diff --git a/packages/eve/src/internal/external-resources-snapshot.ts b/packages/eve/src/internal/external-resources-snapshot.ts
new file mode 100644
index 000000000..18dc84e6f
--- /dev/null
+++ b/packages/eve/src/internal/external-resources-snapshot.ts
@@ -0,0 +1,51 @@
+import type { JsonObject } from "#shared/json.js";
+
+export const EXTERNAL_RESOURCES_SNAPSHOT_KIND = "eve-external-resources";
+export const EXTERNAL_RESOURCES_SNAPSHOT_VERSION = 1;
+
+export interface ExternalCredentialRequirement {
+ readonly method?: string;
+ readonly reference: string;
+ readonly service: string;
+ readonly subjectTypes: readonly ("app" | "user")[];
+}
+
+interface ExternalResourceBase {
+ readonly credentials: ExternalCredentialRequirement;
+ readonly logicalPath: string;
+ readonly name: string;
+}
+
+export interface ExternalConnectionResource extends ExternalResourceBase {
+ readonly kind: "connection";
+ readonly protocol:
+ | { readonly type: "mcp"; readonly url: string }
+ | { readonly type: "openapi"; readonly url: string };
+}
+
+export interface ExternalChannelResource extends ExternalResourceBase {
+ readonly kind: "channel";
+ readonly manifest: JsonObject;
+ readonly route: { readonly path: string };
+}
+
+export type ExternalResource = ExternalConnectionResource | ExternalChannelResource;
+
+export interface ExternalResourcesSnapshot {
+ readonly generator: { readonly name: "eve"; readonly version: string };
+ readonly kind: typeof EXTERNAL_RESOURCES_SNAPSHOT_KIND;
+ readonly resources: readonly ExternalResource[];
+ readonly schemaVersion: typeof EXTERNAL_RESOURCES_SNAPSHOT_VERSION;
+}
+
+export function createExternalResourcesSnapshot(input: {
+ readonly generatorVersion: string;
+ readonly resources: readonly ExternalResource[];
+}): ExternalResourcesSnapshot {
+ return {
+ generator: { name: "eve", version: input.generatorVersion },
+ kind: EXTERNAL_RESOURCES_SNAPSHOT_KIND,
+ resources: input.resources,
+ schemaVersion: EXTERNAL_RESOURCES_SNAPSHOT_VERSION,
+ };
+}