eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
127 lines (126 loc) • 5.39 kB
TypeScript
import { createPromptCommandOutput, type ChannelSetupLog } from "#setup/cli/index.js";
import { captureVercel, runVercel } from "#setup/primitives/run-vercel.js";
import { z } from "zod";
import { type RawSlackConnector, type SlackConnectorDetails, type SlackConnectorRef, type SlackWorkspaceConnection } from "./slack-connect.js";
export declare const CONNECT_LOOKUP_TIMEOUT_MS = 60000;
export declare const CONNECT_MUTATION_TIMEOUT_MS: number;
declare const VercelProjectLinkSchema: z.ZodObject<{
projectId: z.ZodString;
orgId: z.ZodString;
}, z.core.$strip>;
/** Connect subprocess operations needed to inventory and remove Slack connectors. */
export interface SlackConnectLifecycleDeps {
captureVercel: typeof captureVercel;
runVercel: typeof runVercel;
}
export type SlackConnectorInventory = {
state: "ok";
body: unknown;
connectors: readonly RawSlackConnector[];
} | {
state: "failed";
message: string;
};
export type SlackConnectorCleanupResult = {
state: "clean";
} | {
state: "failed";
connectorUids: readonly string[];
};
type CommandOutput = ReturnType<typeof createPromptCommandOutput>;
/** Shared dependencies and output routing for one connector cleanup operation. */
export interface SlackConnectorCleanupContext {
log: ChannelSetupLog;
deps: SlackConnectLifecycleDeps;
projectRoot: string;
onOutput: CommandOutput;
}
/** Reads and validates the account-level Slack connector inventory. */
export declare function listSlackConnectors(deps: SlackConnectLifecycleDeps, projectRoot: string, onOutput: CommandOutput, signal?: AbortSignal): Promise<SlackConnectorInventory>;
/** Project and team identifiers from a valid on-disk Vercel link. */
export type VercelProjectLink = z.infer<typeof VercelProjectLinkSchema>;
/** Reads the linked Vercel project and team ids from `.vercel/project.json`. */
export declare function readProjectLink(projectRoot: string): Promise<VercelProjectLink | undefined>;
export type SlackConnectorLookup = {
state: "found";
connector: SlackConnectorRef;
connectorUids: ReadonlySet<string>;
} | {
state: "not-found";
connectorUids: ReadonlySet<string>;
} | {
state: "failed";
message: string;
};
/** Resolves the expected (or newest project-attached) Slack connector from the inventory. */
export declare function findSlackConnector(deps: SlackConnectLifecycleDeps, projectRoot: string, projectId: string | undefined, expectedUid: string | undefined, onOutput: CommandOutput, signal?: AbortSignal): Promise<SlackConnectorLookup>;
/**
* Outcome of pointing a connector's trigger destination at this project's eve
* route. Detach and attach are reported separately because attach must not run
* while an old trigger destination may still exist. A `detach-failed` connector
* is left in a known-stale state the caller surfaces with manual recovery steps.
*/
export type SlackConnectorAttachmentResult = {
state: "attached";
} | {
state: "detach-failed";
} | {
state: "attach-failed";
};
/**
* Replaces the connector's default trigger destination with the eve route:
* detach the existing destination first, then attach this project. Either
* subprocess failing short-circuits so a half-configured connector is reported
* rather than silently left pointing at the wrong place.
*/
export declare function attachSlackConnector(deps: SlackConnectLifecycleDeps, projectRoot: string, ref: SlackConnectorRef, onOutput: CommandOutput, signal?: AbortSignal): Promise<SlackConnectorAttachmentResult>;
export type SlackWorkspaceLookup = {
state: "connected";
workspace: SlackWorkspaceConnection;
} | {
state: "pending";
} | {
state: "failed";
message: string;
};
export type SlackConnectorDetailsLookup = {
state: "found";
details: SlackConnectorDetails;
} | {
state: "failed";
message: string;
};
/** Fetches and validates one team-scoped connector detail payload. */
export declare function fetchSlackConnectorDetails(input: {
deps: Pick<SlackConnectLifecycleDeps, "captureVercel">;
projectRoot: string;
connectorId: string;
orgId: string | undefined;
onOutput: CommandOutput;
timeoutMs: number;
signal?: AbortSignal;
}): Promise<SlackConnectorDetailsLookup>;
/** Fetches the Slack workspace connected to a connector, if one exists yet. */
export declare function fetchSlackWorkspace(input: {
deps: Pick<SlackConnectLifecycleDeps, "captureVercel">;
projectRoot: string;
connectorId: string;
orgId: string | undefined;
onOutput: CommandOutput;
timeoutMs: number;
signal?: AbortSignal;
}): Promise<SlackWorkspaceLookup>;
/**
* Removes the exact connector returned by `connect create`. When no UID was
* returned, ownership cannot be proven: a concurrent or eventually-consistent
* connector looks the same as this attempt's. So cleanup fails closed. It
* removes nothing and instead surfaces the connectors that look like this
* attempt's, matching `expectedUid` and absent from the pre-create snapshot, so
* the caller can stop rather than risk removing a bystander's connector.
*/
export declare function cleanupCreatedAttempt(context: SlackConnectorCleanupContext, input: {
expectedUid: string;
baselineConnectorUids: ReadonlySet<string>;
createdRef: SlackConnectorRef | undefined;
}): Promise<SlackConnectorCleanupResult>;
export {};