pi-dent-office0.2.0
A pi extension whose Office tool reads and writes Microsoft 365 (Outlook mail, calendar, Teams and SharePoint) through Microsoft Graph, signed in with the device code flow
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-dent-office
A pi extension that gives the agent one tool, Office, for the user's Microsoft 365 data through
Microsoft Graph: Outlook mail, the calendar, Teams chats and channels, and SharePoint files.
How it works
One tool, four services.
serviceisoutlook,calendar,teamsorsharepoint;actionpicks what to do. List actions return ids that the get, reply, update and read actions take.Service Actions outlooklist_messages,get_message,send_message,reply_messagecalendarlist_events,get_event,create_event,update_event,delete_event,respond_eventteamslist_teams,list_channels,list_channel_messages,send_channel_message,list_chats,list_chat_messages,send_chat_messagesharepointsearch,list_sites,list_files,read_file,upload_fileWork and personal accounts. A work or school account (Microsoft 365) and a personal Microsoft account (Outlook.com, Hotmail, Live) can be signed in side by side; the tool's
accountparameter picks one (workorpersonal). Without it, the tool usesoffice.defaultAccount, else the only signed-in kind, elsework. Personal accounts have mail, calendar and OneDrive, but no Teams and no SharePoint sites or search: the tool says so instead of calling Graph.Files.
list_files,read_fileandupload_fileuse the user's OneDrive unless adriveIdorsiteIdis given.Writes are immediate. Sending mail, posting to Teams, changing events and uploading files happen as soon as the agent calls the action.
Sign-in with a device code. The first call (or
/office login) shows a code and the URLhttps://microsoft.com/devicelogin; sign in there in any browser. With a UI the call waits; without one, the tool error carries the code for the agent to relay, and the next call proceeds once you signed in. Tokens are kept in~/.pi/pi-dent/office/tokens.json(mode0600) and refreshed automatically.Untrusted text. Mail, chat and file contents are reduced to plain text with invisible characters removed, and long bodies are cut.
The exact rules are in specs/office.md.
Using it
pi install npm:pi-dent-office
Then /office login work or /office login personal (or both), /office status, and
/office logout work|personal. No app registration is needed: the
default client is Microsoft's public "Microsoft Graph Command Line Tools" app. To use your own app
registration (a public client with the device code flow allowed), or a specific tenant, set them
in pi-dent.conf (~/.pi/pi-dent/, or .pi/pi-dent/ in a project) or in
PI_DENT_OFFICE_WORK_CLIENT_ID, PI_DENT_OFFICE_WORK_TENANT, PI_DENT_OFFICE_PERSONAL_CLIENT_ID
and PI_DENT_OFFICE_ACCOUNT (the default kind). Each kind can use its own app registration:
office.work and office.personal each take a clientId and scopes (work also a tenant),
and a kind left out uses the default client:
{
"office": {
"work": {
"clientId": "00000000-0000-0000-0000-000000000000",
"tenant": "contoso.onmicrosoft.com",
"scopes": ["User.Read", "Mail.ReadWrite", "Mail.Send", "ChannelMessage.Read.All"],
},
"defaultAccount": "work",
"confirmWrites": true,
},
}
The work tenant cannot be consumers: that tenant is for personal accounts only.
Accounts stored under the old shared client ID are no longer used once you set a per-kind
clientId: run /office logout work and /office logout personal before changing a client ID.
With confirmWrites true, every write asks you to confirm in the UI before signing in, and fails
without a UI; the default is false.
Reading Teams channel messages needs ChannelMessage.Read.All, which an admin must consent to; it
is not in the default scopes. Requires Node 26 or later.
Documentation
specs/office.md: what the tool and command do, and their settings.docs/graph.md: the Graph and sign-in facts, with links.AGENTS.md: how to work on the repository.
License
MIT, see LICENSE.