-
Notifications
You must be signed in to change notification settings - Fork 13
feat: Add tool to read a user's manager from Google Contacts #59
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
Changes from all commits
4a7fd88
9bdc745
20845db
3040b5c
8e8bde3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| import { | ||
| getUserProfile, | ||
| getMe, | ||
| getUserManager, | ||
| } from '../../workspace-server/src/services/PeopleService'; | ||
|
|
||
| export const get_user_profile = { | ||
| name: 'get_user_profile', | ||
| description: 'Get a user\'s profile by ID, email, or name.', | ||
| parameters: { | ||
| type: 'object', | ||
| properties: { | ||
| userId: { | ||
| type: 'string', | ||
| description: 'The ID of the user.', | ||
| }, | ||
| email: { | ||
| type: 'string', | ||
| description: 'The email address of the user.', | ||
| }, | ||
| name: { | ||
| type: 'string', | ||
| description: 'The name of the user.', | ||
| }, | ||
| }, | ||
| }, | ||
| function: getUserProfile, | ||
| }; | ||
|
|
||
| export const get_me = { | ||
| name: 'get_me', | ||
| description: 'Get the user\'s profile.', | ||
| parameters: { | ||
| type: 'object', | ||
| properties: {}, | ||
| }, | ||
| function: getMe, | ||
| }; | ||
|
|
||
| export const get_user_manager = { | ||
| name: 'get_user_manager', | ||
| description: 'Get the user\'s manager.', | ||
| parameters: { | ||
| type: 'object', | ||
| properties: { | ||
| userId: { | ||
| type: 'string', | ||
| description: 'The ID of the user.', | ||
| }, | ||
| }, | ||
| }, | ||
| function: getUserManager, | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,35 @@ export class PeopleService { | |||||
| return google.people({ version: 'v1', ...options }); | ||||||
| } | ||||||
|
|
||||||
| public getUserManager = async ({ userId }: { userId: string; }) => { | ||||||
| logToFile(`[PeopleService] Starting getUserManager with: userId=${userId}`); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than a specific function to get a manager, it would be better to have a function that interacts with the relations object overall. Where finding the manager could be one of many data items returned from that function. See: https://developers.google.com/people/api/rest/v1/people#Person.Relation for the full details. |
||||||
| try { | ||||||
| const people = await this.getPeopleClient(); | ||||||
| const resourceName = userId.startsWith('people/') ? userId : `people/${userId}`; | ||||||
| const res = await people.people.get({ | ||||||
| resourceName, | ||||||
| personFields: 'relations', | ||||||
| }); | ||||||
| const manager = res.data.relations?.find((r: { type: string; }) => r.type === 'manager')?.person || null; | ||||||
| logToFile(`[PeopleService] Finished getUserManager for user: ${userId}`); | ||||||
| return { | ||||||
| content: [{ | ||||||
| type: "text" as const, | ||||||
| text: JSON.stringify({ manager }) | ||||||
| }] | ||||||
| }; | ||||||
| } catch (error) { | ||||||
| const errorMessage = error instanceof Error ? error.message : String(error); | ||||||
| logToFile(`[PeopleService] Error during people.getUserManager: ${errorMessage}`); | ||||||
| return { | ||||||
| content: [{ | ||||||
| type: "text" as const, | ||||||
| text: JSON.stringify({ error: errorMessage }) | ||||||
| }] | ||||||
| }; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| public getUserProfile = async ({ userId, email, name }: { userId?: string, email?: string, name?: string }) => { | ||||||
| logToFile(`[PeopleService] Starting getUserProfile with: userId=${userId}, email=${email}, name=${name}`); | ||||||
| try { | ||||||
|
|
@@ -30,7 +59,7 @@ export class PeopleService { | |||||
| const resourceName = userId.startsWith('people/') ? userId : `people/${userId}`; | ||||||
| const res = await people.people.get({ | ||||||
| resourceName, | ||||||
| personFields: 'names,emailAddresses', | ||||||
| personFields: 'names,emailAddresses,relations', | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| }); | ||||||
| logToFile(`[PeopleService] Finished getUserProfile for user: ${userId}`); | ||||||
| return { | ||||||
|
|
||||||
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.
This entire file appears to be a hallucination. It shouldn't be here, only toml files should be in the command directory.