-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Adding a handful of Get Current User actions #18774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
31b152d
Get Current User actions
dannyroosevelt b77208e
Merge branch 'master' into danny/authed-user-actions
dannyroosevelt 26d4070
Update get-current-user.mjs
dannyroosevelt fa9706c
Merge branch 'danny/authed-user-actions' of github.com:PipedreamHQ/pi…
dannyroosevelt ed7e235
Merge branch 'danny/authed-user-actions' of github.com:PipedreamHQ/pi…
dannyroosevelt 9beca8e
Update get-current-user.mjs
dannyroosevelt b4224b6
Cleaning up the descriptions
dannyroosevelt ed3f47d
Cleaning up the code
dannyroosevelt eade12d
Merge branch 'master' into danny/authed-user-actions
dannyroosevelt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
components/github/actions/get-current-user/get-current-user.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import github from "../../github.app.mjs"; | ||
|
|
||
| const DEFAULT_ORGS_LIMIT = 20; | ||
| const DEFAULT_TEAMS_LIMIT = 20; | ||
|
|
||
| export default { | ||
| key: "github-get-current-user", | ||
| name: "Get Current User", | ||
| description: "Gather a full snapshot of the authenticated GitHub actor, combining `/user`, `/user/orgs`, and `/user/teams`. Returns profile metadata (login, name, email, company, plan, creation timestamps) and trimmed lists of organizations and teams for quick role awareness. Helpful when you need to validate which user is calling the API, adapt behavior based on their org/team memberships, or provide LLMs with grounding before repository operations. [See the documentation](https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| github, | ||
| }, | ||
| async run({ $ }) { | ||
| const [ | ||
| user, | ||
| organizations, | ||
| teams, | ||
| ] = await Promise.all([ | ||
| this.github.getAuthenticatedUser(), | ||
| this.github.getOrganizations() | ||
| .then((orgs) => orgs.slice(0, DEFAULT_ORGS_LIMIT)), | ||
| this.github.getTeams() | ||
| .then((teamsResponse) => teamsResponse.slice(0, DEFAULT_TEAMS_LIMIT)), | ||
| ]); | ||
|
|
||
| $.export("$summary", `Retrieved GitHub user ${user.login}`); | ||
|
|
||
| return { | ||
| user, | ||
| organizations, | ||
| teams, | ||
| }; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
components/google_calendar/actions/get-current-user/get-current-user.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import googleCalendar from "../../google_calendar.app.mjs"; | ||
| import constants from "../../common/constants.mjs"; | ||
|
|
||
| const DEFAULT_CALENDAR_SAMPLE_LIMIT = 25; | ||
|
|
||
| export default { | ||
| key: "google_calendar-get-current-user", | ||
| name: "Get Current User", | ||
| description: "Retrieve information about the authenticated Google Calendar account, including the primary calendar (summary, timezone, ACL flags), a list of accessible calendars, user-level settings (timezone, locale, week start), and the color palette that controls events and calendars. Ideal for confirming which calendar account is in use, customizing downstream scheduling, or equipping LLMs with the user’s context (timezones, available calendars) prior to creating or updating events. [See the documentation](https://developers.google.com/calendar/api/v3/reference/calendars/get).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| googleCalendar, | ||
| }, | ||
| async run({ $ }) { | ||
| const [ | ||
| primaryCalendar, | ||
| calendarList, | ||
| settings, | ||
| colors, | ||
| ] = await Promise.all([ | ||
| this.googleCalendar.getCalendar({ | ||
| calendarId: "primary", | ||
| }), | ||
| this.googleCalendar.listCalendars({ | ||
| maxResults: DEFAULT_CALENDAR_SAMPLE_LIMIT, | ||
| }), | ||
| this.googleCalendar.requestHandler({ | ||
| api: constants.API.SETTINGS.NAME, | ||
| method: constants.API.SETTINGS.METHOD.LIST, | ||
| }), | ||
| this.googleCalendar.requestHandler({ | ||
| api: constants.API.COLORS.NAME, | ||
| method: constants.API.COLORS.METHOD.GET, | ||
| }), | ||
| ]); | ||
|
|
||
| const timezoneSetting = settings?.items?.find?.((setting) => setting.id === "timezone")?.value; | ||
| const localeSetting = settings?.items?.find?.((setting) => setting.id === "locale")?.value; | ||
|
|
||
| const summaryName = primaryCalendar?.summary || primaryCalendar?.id; | ||
| $.export("$summary", `Retrieved Google Calendar user ${summaryName}`); | ||
|
|
||
| return { | ||
| primaryCalendar, | ||
| calendars: calendarList?.items ?? [], | ||
| settings: settings?.items ?? [], | ||
| timezone: timezoneSetting || primaryCalendar?.timeZone, | ||
| locale: localeSetting, | ||
| colors, | ||
| }; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
components/google_drive/actions/get-current-user/get-current-user.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import googleDrive from "../../google_drive.app.mjs"; | ||
|
|
||
| const ABOUT_FIELDS = "user,storageQuota"; | ||
|
|
||
| export default { | ||
| key: "google_drive-get-current-user", | ||
| name: "Get Current User", | ||
| description: "Retrieve Google Drive account metadata for the authenticated user via `about.get`, including display name, email, permission ID, and storage quota. Useful when flows or agents need to confirm the active Google identity or understand available storage. [See the documentation](https://developers.google.com/drive/api/v3/reference/about/get).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| googleDrive, | ||
| }, | ||
| async run({ $ }) { | ||
| const about = await this.googleDrive.getAbout(ABOUT_FIELDS); | ||
|
|
||
| const summaryName = | ||
| about?.user?.displayName | ||
| || about?.user?.emailAddress | ||
| || about?.user?.permissionId; | ||
| $.export("$summary", `Retrieved Google Drive user ${summaryName}`); | ||
|
|
||
| return { | ||
| about, | ||
| }; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
components/google_sheets/actions/get-current-user/get-current-user.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import googleSheets from "../../google_sheets.app.mjs"; | ||
|
|
||
| const ABOUT_FIELDS = "user,storageQuota"; | ||
|
|
||
| export default { | ||
| key: "google_sheets-get-current-user", | ||
| name: "Get Current User", | ||
| description: "Retrieve Google Sheets account metadata for the authenticated user by calling Drive's `about.get`, returning the user profile (display name, email, permission ID) and storage quota information. Helpful when you need to verify which Google account is active, tailor sheet operations to available storage, or give an LLM clear context about the user identity before composing read/write actions. [See the Drive API documentation](https://developers.google.com/drive/api/v3/reference/about/get).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| googleSheets, | ||
| }, | ||
| async run({ $ }) { | ||
| const about = await this.googleSheets.getAbout(ABOUT_FIELDS); | ||
|
|
||
| const summaryName = | ||
| about?.user?.displayName | ||
| || about?.user?.emailAddress | ||
| || about?.user?.permissionId; | ||
| $.export("$summary", `Retrieved Google Sheets user ${summaryName}`); | ||
|
|
||
| return { | ||
| about, | ||
| }; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
components/linear/actions/get-current-user/get-current-user.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| import linearApp from "../../linear.app.mjs"; | ||
|
|
||
| const DEFAULT_CONNECTION_LIMIT = 50; | ||
|
|
||
| const toIsoString = (value) => value?.toISOString?.() ?? null; | ||
| const toPageInfo = (pageInfo) => pageInfo && ({ | ||
| endCursor: pageInfo.endCursor, | ||
| hasNextPage: pageInfo.hasNextPage, | ||
| hasPreviousPage: pageInfo.hasPreviousPage, | ||
| startCursor: pageInfo.startCursor, | ||
| }); | ||
|
|
||
| export default { | ||
| key: "linear-get-current-user", | ||
| name: "Get Current User", | ||
| description: "Retrieve rich context about the authenticated Linear user, including core profile fields, recent timestamps, direct team memberships, and high-level organization settings. Returns the user object, a paginated team list (with names, keys, cycle configs, etc.), associated team memberships, and organization metadata such as auth defaults and SCIM/SAML flags. Use this when your workflow or agent needs to understand who is currently authenticated, which teams they belong to, or what workspace policies might influence subsequent Linear actions. See Linear's GraphQL viewer docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| linearApp, | ||
| }, | ||
| async run({ $ }) { | ||
| const client = this.linearApp.client(); | ||
| const viewer = await client.viewer; | ||
|
|
||
| const [ | ||
| organization, | ||
| teamsConnection, | ||
| teamMembershipsConnection, | ||
| ] = await Promise.all([ | ||
| viewer.organization, | ||
| viewer.teams({ | ||
| first: DEFAULT_CONNECTION_LIMIT, | ||
| }), | ||
| viewer.teamMemberships({ | ||
| first: DEFAULT_CONNECTION_LIMIT, | ||
| }), | ||
| ]); | ||
|
|
||
| const teams = teamsConnection?.nodes?.map((team) => ({ | ||
| id: team.id, | ||
| key: team.key, | ||
| name: team.name, | ||
| displayName: team.displayName, | ||
| description: team.description, | ||
| icon: team.icon, | ||
| color: team.color, | ||
| private: team.private, | ||
| timezone: team.timezone, | ||
| inviteHash: team.inviteHash, | ||
| issueCount: team.issueCount, | ||
| cycleDuration: team.cycleDuration, | ||
| cyclesEnabled: team.cyclesEnabled, | ||
| triageEnabled: team.triageEnabled, | ||
| createdAt: toIsoString(team.createdAt), | ||
| updatedAt: toIsoString(team.updatedAt), | ||
| })) ?? []; | ||
|
|
||
| const user = { | ||
| id: viewer.id, | ||
| name: viewer.name, | ||
| displayName: viewer.displayName, | ||
| email: viewer.email, | ||
| active: viewer.active, | ||
| admin: viewer.admin, | ||
| guest: viewer.guest, | ||
| description: viewer.description, | ||
| disableReason: viewer.disableReason, | ||
| timezone: viewer.timezone, | ||
| statusEmoji: viewer.statusEmoji, | ||
| statusLabel: viewer.statusLabel, | ||
| isAssignable: viewer.isAssignable, | ||
| isMentionable: viewer.isMentionable, | ||
| avatarUrl: viewer.avatarUrl, | ||
| url: viewer.url, | ||
| calendarHash: viewer.calendarHash, | ||
| inviteHash: viewer.inviteHash, | ||
| initials: viewer.initials, | ||
| createdIssueCount: viewer.createdIssueCount, | ||
| createdAt: toIsoString(viewer.createdAt), | ||
| updatedAt: toIsoString(viewer.updatedAt), | ||
| archivedAt: toIsoString(viewer.archivedAt), | ||
| lastSeen: toIsoString(viewer.lastSeen), | ||
| statusUntilAt: toIsoString(viewer.statusUntilAt), | ||
| }; | ||
|
|
||
| const teamMemberships = teamMembershipsConnection?.nodes?.map((membership) => ({ | ||
| id: membership.id, | ||
| owner: membership.owner, | ||
| sortOrder: membership.sortOrder, | ||
| teamId: membership.teamId, | ||
| userId: membership.userId, | ||
| createdAt: toIsoString(membership.createdAt), | ||
| updatedAt: toIsoString(membership.updatedAt), | ||
| archivedAt: toIsoString(membership.archivedAt), | ||
| })) ?? []; | ||
|
|
||
| const organizationData = organization && { | ||
| id: organization.id, | ||
| name: organization.name, | ||
| urlKey: organization.urlKey, | ||
| allowedAuthServices: organization.allowedAuthServices, | ||
| allowMembersToInvite: organization.allowMembersToInvite, | ||
| customersEnabled: organization.customersEnabled, | ||
| feedEnabled: organization.feedEnabled, | ||
| gitBranchFormat: organization.gitBranchFormat, | ||
| gitLinkbackMessagesEnabled: organization.gitLinkbackMessagesEnabled, | ||
| gitPublicLinkbackMessagesEnabled: organization.gitPublicLinkbackMessagesEnabled, | ||
| initiativeUpdateReminderFrequencyInWeeks: | ||
| organization.initiativeUpdateReminderFrequencyInWeeks, | ||
| initiativeUpdateRemindersDay: organization.initiativeUpdateRemindersDay, | ||
| initiativeUpdateRemindersHour: organization.initiativeUpdateRemindersHour, | ||
| projectUpdateReminderFrequencyInWeeks: | ||
| organization.projectUpdateReminderFrequencyInWeeks, | ||
| projectUpdateRemindersDay: organization.projectUpdateRemindersDay, | ||
| projectUpdateRemindersHour: organization.projectUpdateRemindersHour, | ||
| projectUpdatesReminderFrequency: organization.projectUpdatesReminderFrequency, | ||
| restrictLabelManagementToAdmins: organization.restrictLabelManagementToAdmins, | ||
| restrictTeamCreationToAdmins: organization.restrictTeamCreationToAdmins, | ||
| roadmapEnabled: organization.roadmapEnabled, | ||
| samlEnabled: organization.samlEnabled, | ||
| scimEnabled: organization.scimEnabled, | ||
| releaseChannel: organization.releaseChannel, | ||
| fiscalYearStartMonth: organization.fiscalYearStartMonth, | ||
| slaDayCount: organization.slaDayCount, | ||
| previousUrlKeys: organization.previousUrlKeys, | ||
| logoUrl: organization.logoUrl, | ||
| createdIssueCount: organization.createdIssueCount, | ||
| customerCount: organization.customerCount, | ||
| periodUploadVolume: organization.periodUploadVolume, | ||
| userCount: organization.userCount, | ||
| trialEndsAt: toIsoString(organization.trialEndsAt), | ||
| deletionRequestedAt: toIsoString(organization.deletionRequestedAt), | ||
| archivedAt: toIsoString(organization.archivedAt), | ||
| createdAt: toIsoString(organization.createdAt), | ||
| updatedAt: toIsoString(organization.updatedAt), | ||
| }; | ||
|
|
||
| const summaryIdentifier = user.name || user.displayName || user.email || user.id; | ||
| $.export("$summary", `Retrieved Linear user ${summaryIdentifier}`); | ||
|
|
||
| return { | ||
| user, | ||
| organization: organizationData, | ||
| teams: { | ||
| nodes: teams, | ||
| pageInfo: toPageInfo(teamsConnection?.pageInfo), | ||
| }, | ||
| teamMemberships: { | ||
| nodes: teamMemberships, | ||
| pageInfo: toPageInfo(teamMembershipsConnection?.pageInfo), | ||
| }, | ||
| }; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove email from summary to avoid logging PII.
The summary includes
user.emailas a fallback identifier, which logs personally identifiable information (PII). Workflow summaries can be stored in logs, monitoring systems, or other persistence layers, creating compliance risks under GDPR/CCPA.Apply this diff to remove email from the summary identifier:
📝 Committable suggestion
🤖 Prompt for AI Agents