Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| The Marketplace is where a workspace finds what to add, reached from Apps: the agent catalog of roles with who already does each job and Add to workspace; every integration with whether it's connected; g1t's own extensions, listed as Soon; and requests, where members ask and owners add or turn down, each told by a notification. Underneath, an extension is a manifest (publisher and tier, source and version from a tag, scopes, the domains its data goes to, its page on g1tusercontent.com, no price) and an install pins its version with an off switch, a budget and the audit log. Apps lists only what was added from the Marketplace, with pins; g1t's own pages stay in their sidebars, and AI Gateway joins Workspace's. The marketplace guide says how. | 1 | /** |
| 2 | * What a workspace has connected, by connector id (@g1t/contracts/connectors): | |
| 3 | * its provider connections from the integrations service, the GitHub App's | |
| 4 | * installations and its own webhooks, each with how it is doing. The | |
| 5 | * Integrations directory and the Marketplace both read it. | |
| 6 | */ | |
| 7 | import type { User } from "@g1t/contracts"; | |
| 8 | import { PROVIDERS } from "@g1t/contracts"; | |
| 9 | import { CONNECTORS } from "@g1t/contracts/connectors"; | |
| 10 | ||
| 11 | import type { ConnectedState } from "./connectors"; | |
| A GitHub App installed straight on GitHub can be added to a workspace: Import from GitHub lists the installations your GitHub account can see that this workspace hasn't added, each with Add for owners, and coming back from GitHub without g1t's own start asks which of your workspaces to add it to instead of stopping; the GitHub guide says how. | 12 | import { githubConnected } from "./github"; |
| The Marketplace is where a workspace finds what to add, reached from Apps: the agent catalog of roles with who already does each job and Add to workspace; every integration with whether it's connected; g1t's own extensions, listed as Soon; and requests, where members ask and owners add or turn down, each told by a notification. Underneath, an extension is a manifest (publisher and tier, source and version from a tag, scopes, the domains its data goes to, its page on g1tusercontent.com, no price) and an install pins its version with an off switch, a budget and the audit log. Apps lists only what was added from the Marketplace, with pins; g1t's own pages stay in their sidebars, and AI Gateway joins Workspace's. The marketplace guide says how. | 13 | import { githubApp } from "./github.server"; |
| 14 | import { integrationsSection } from "./integration-sections"; | |
| 15 | import { integrations, webhooks } from "./services.server"; | |
| 16 | ||
| 17 | /** What the workspace `slug` has connected, as `viewer` may see it. Each source that does not answer counts as nothing connected. */ | |
| 18 | export async function connectedStates(slug: string, viewer: User): Promise<Record<string, ConnectedState>> { | |
| 19 | const [connections, github, hooks] = await Promise.all([ | |
| 20 | integrations.list(slug, viewer).catch(() => null), | |
| 21 | githubApp.status(viewer, slug).catch(() => null), | |
| 22 | webhooks.list(viewer, { workspace: slug }).catch(() => null), | |
| 23 | ]); | |
| 24 | ||
| 25 | const connected: Record<string, ConnectedState> = {}; | |
| 26 | if (connections?.ok) { | |
| 27 | for (const connector of CONNECTORS) { | |
| 28 | if (!connector.provider) continue; | |
| 29 | const mine = connections.value.filter((connection) => connection.provider === connector.provider); | |
| 30 | if (mine.length === 0) continue; | |
| 31 | const broken = mine.find((connection) => connection.lastError); | |
| 32 | connected[connector.id] = { | |
| 33 | detail: mine.length === 1 ? mine[0]!.name : `${mine.length} connections: ${mine.map((c) => c.name).join(", ")}`, | |
| 34 | problem: broken ? `${broken.name}: ${broken.lastError}` : null, | |
| 35 | manage: `/${slug}/-/integrations/${integrationsSection(PROVIDERS[connector.provider].kind)}`, | |
| 36 | }; | |
| 37 | } | |
| 38 | } | |
| A GitHub App installed straight on GitHub can be added to a workspace: Import from GitHub lists the installations your GitHub account can see that this workspace hasn't added, each with Add for owners, and coming back from GitHub without g1t's own start asks which of your workspaces to add it to instead of stopping; the GitHub guide says how. | 39 | const fromGithub = github?.ok ? githubConnected(github.value.installations) : null; |
| 40 | if (fromGithub) connected.github = fromGithub; | |
| The Marketplace is where a workspace finds what to add, reached from Apps: the agent catalog of roles with who already does each job and Add to workspace; every integration with whether it's connected; g1t's own extensions, listed as Soon; and requests, where members ask and owners add or turn down, each told by a notification. Underneath, an extension is a manifest (publisher and tier, source and version from a tag, scopes, the domains its data goes to, its page on g1tusercontent.com, no price) and an install pins its version with an off switch, a budget and the audit log. Apps lists only what was added from the Marketplace, with pins; g1t's own pages stay in their sidebars, and AI Gateway joins Workspace's. The marketplace guide says how. | 41 | const ours = hooks?.ok ? hooks.value.filter((hook) => hook.scope === "workspace") : []; |
| 42 | if (ours.length > 0) { | |
| 43 | const failing = ours.filter((hook) => hook.lastStatus === "failed"); | |
| 44 | connected.webhooks = { | |
| 45 | detail: ours.length === 1 ? ours[0]!.url : `${ours.length} webhooks`, | |
| 46 | problem: failing.length > 0 ? `The last delivery to ${failing[0]!.url} failed.` : null, | |
| 47 | manage: null, | |
| 48 | }; | |
| 49 | } | |
| 50 | return connected; | |
| 51 | } |