mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-18 02:03:09 +00:00
Rename Foundry handoffs to tasks (#239)
* Restore foundry onboarding stack * Consolidate foundry rename * Create foundry tasks without prompts * Rename Foundry handoffs to tasks
This commit is contained in:
parent
d30cc0bcc8
commit
d75e8c31d1
281 changed files with 9242 additions and 4356 deletions
67
foundry/packages/client/src/app-client.ts
Normal file
67
foundry/packages/client/src/app-client.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import type {
|
||||
FoundryAppSnapshot,
|
||||
FoundryBillingPlanId,
|
||||
FoundryOrganization,
|
||||
FoundryUser,
|
||||
UpdateFoundryOrganizationProfileInput,
|
||||
} from "@sandbox-agent/foundry-shared";
|
||||
import type { BackendClient } from "./backend-client.js";
|
||||
import { getMockFoundryAppClient } from "./mock-app.js";
|
||||
import { createRemoteFoundryAppClient } from "./remote/app-client.js";
|
||||
|
||||
export interface FoundryAppClient {
|
||||
getSnapshot(): FoundryAppSnapshot;
|
||||
subscribe(listener: () => void): () => void;
|
||||
signInWithGithub(userId?: string): Promise<void>;
|
||||
signOut(): Promise<void>;
|
||||
skipStarterRepo(): Promise<void>;
|
||||
starStarterRepo(organizationId: string): Promise<void>;
|
||||
selectOrganization(organizationId: string): Promise<void>;
|
||||
updateOrganizationProfile(input: UpdateFoundryOrganizationProfileInput): Promise<void>;
|
||||
triggerGithubSync(organizationId: string): Promise<void>;
|
||||
completeHostedCheckout(organizationId: string, planId: FoundryBillingPlanId): Promise<void>;
|
||||
openBillingPortal(organizationId: string): Promise<void>;
|
||||
cancelScheduledRenewal(organizationId: string): Promise<void>;
|
||||
resumeSubscription(organizationId: string): Promise<void>;
|
||||
reconnectGithub(organizationId: string): Promise<void>;
|
||||
recordSeatUsage(workspaceId: string): Promise<void>;
|
||||
}
|
||||
|
||||
export interface CreateFoundryAppClientOptions {
|
||||
mode: "mock" | "remote";
|
||||
backend?: BackendClient;
|
||||
}
|
||||
|
||||
export function createFoundryAppClient(options: CreateFoundryAppClientOptions): FoundryAppClient {
|
||||
if (options.mode === "mock") {
|
||||
return getMockFoundryAppClient() as unknown as FoundryAppClient;
|
||||
}
|
||||
if (!options.backend) {
|
||||
throw new Error("Remote app client requires a backend client");
|
||||
}
|
||||
return createRemoteFoundryAppClient({ backend: options.backend });
|
||||
}
|
||||
|
||||
export function currentFoundryUser(snapshot: FoundryAppSnapshot): FoundryUser | null {
|
||||
if (!snapshot.auth.currentUserId) {
|
||||
return null;
|
||||
}
|
||||
return snapshot.users.find((candidate) => candidate.id === snapshot.auth.currentUserId) ?? null;
|
||||
}
|
||||
|
||||
export function currentFoundryOrganization(snapshot: FoundryAppSnapshot): FoundryOrganization | null {
|
||||
if (!snapshot.activeOrganizationId) {
|
||||
return null;
|
||||
}
|
||||
return snapshot.organizations.find((candidate) => candidate.id === snapshot.activeOrganizationId) ?? null;
|
||||
}
|
||||
|
||||
export function eligibleFoundryOrganizations(snapshot: FoundryAppSnapshot): FoundryOrganization[] {
|
||||
const user = currentFoundryUser(snapshot);
|
||||
if (!user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const eligible = new Set(user.eligibleOrganizationIds);
|
||||
return snapshot.organizations.filter((organization) => eligible.has(organization.id));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue