Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
feat(teamhub-cli): add Outlook Calendar connector commands
LeoXing786f2f46ef1c
diff --git a/apps/node-services/src/agent/prompt/compact-meta-instructions.ts b/apps/node-services/src/agent/prompt/compact-meta-instructions.tsindex 9f402ff3..87170d78 100644--- a/apps/node-services/src/agent/prompt/compact-meta-instructions.ts+++ b/apps/node-services/src/agent/prompt/compact-meta-instructions.ts@@ -159,7 +159,7 @@ const connectedAppsCommands = (connectedAppKeys: readonly string[],connectableAppKeys: readonly string[],): string => `-- Connected apps: gmail, outlook, gcal, gdrive, slack, notion, and figma have their own commands (teamhub gmail --help). For other apps, find the tool with teamhub apps search "<the action in English, with the app name>", then run teamhub apps execute --connectionId <id> --toolSlug <slug> --toolVersion <version> --arguments '<json>'. When this Run started, ${connectedAppsAtRunStart(connectedAppKeys)}; use them without checking first, and check teamhub apps list only when the Human says they connected or disconnected an app during this conversation or a command reports that the account is not connected. Never resend a write whose outcome is unknown; check the app first.${connectableAppsRule(connectableAppKeys)}`;+- Connected apps: gmail, outlook, outlook-calendar, gcal, gdrive, slack, notion, and figma have their own commands (teamhub gmail --help). For other apps, find the tool with teamhub apps search "<the action in English, with the app name>", then run teamhub apps execute --connectionId <id> --toolSlug <slug> --toolVersion <version> --arguments '<json>'. When this Run started, ${connectedAppsAtRunStart(connectedAppKeys)}; use them without checking first, and check teamhub apps list only when the Human says they connected or disconnected an app during this conversation or a command reports that the account is not connected. Never resend a write whose outcome is unknown; check the app first.${connectableAppsRule(connectableAppKeys)}`;const commands = (agentType: AgentType,diff --git a/apps/node-services/src/agent/prompt/personal-context-method.ts b/apps/node-services/src/agent/prompt/personal-context-method.tsindex 213e9ab5..dc4dce5e 100644--- a/apps/node-services/src/agent/prompt/personal-context-method.ts+++ b/apps/node-services/src/agent/prompt/personal-context-method.ts@@ -39,6 +39,10 @@ A record of a past event does not by itself prove a present status. Where sourceconst INTRO ="What each source you can query here can tell you. When none of them holds a changing fact, say it is unconfirmed rather than presenting it as current.";+const CALENDAR_COMMANDS: Record<string, string> = {+ google_calendar: "teamhub gcal",+ outlook: "teamhub outlook-calendar",+};const MAIL_COMMANDS: Record<string, string> = {gmail: "teamhub gmail",outlook: "teamhub outlook",@@ -54,9 +58,9 @@ const APP_SOURCES: readonly {readonly render: (present: readonly string[]) => string;}[] = [{- keys: ["google_calendar"],- render: () =>- "- calendar (teamhub gcal list / free / read): scheduled meetings and events, attendees, free time.",+ keys: ["google_calendar", "outlook"],+ render: (present) =>+ `- calendar (${present.map((key) => CALENDAR_COMMANDS[key]).join(" or ")} list / free / read): scheduled meetings and events, attendees, free time.`,},{keys: ["gmail", "outlook"],diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-compact.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-compact.txtindex 52627066..fc54d744 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-compact.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-compact.txt@@ -81,7 +81,7 @@ TeamHub commands, all run through your shell tool (teamhub <domain> <action> --h- To show something the person looks at or uses here and now (a quick chart, dashboard, checklist or small tool), send it inline as a chat card (read the chat-card skill first); use the artifact skill only for a file to share, print, present or keep, or when a file is asked for.- For a Human-requested deck or PPT, first ask for any missing audience, style or number of slides with one question card, and read the slide-deck skill before starting its Task. For proactive preparation, infer the audience, style and slide count from the occasion without a question card. Build new .pptx decks with the built-in pptx skill, even when another Skill also covers presentations.- Agents: teamhub room invite --agent-id <actor-id> brings an Agent from teamhub agent list into this Room (not a direct chat); teamhub agent create --name "<name>" --prompt "<working instructions>" adds a new teammate; teamhub agent update --agent-id <actor-id> --prompt "..." changes an Agent you manage. A change to an established Agent waits for approval.-- Connected apps: gmail, outlook, gcal, gdrive, slack, notion, and figma have their own commands (teamhub gmail --help). For other apps, find the tool with teamhub apps search "<the action in English, with the app name>", then run teamhub apps execute --connectionId <id> --toolSlug <slug> --toolVersion <version> --arguments '<json>'. When this Run started, these apps had an account you can use: gmail, google_calendar; use them without checking first, and check teamhub apps list only when the Human says they connected or disconnected an app during this conversation or a command reports that the account is not connected. Never resend a write whose outcome is unknown; check the app first. Apps the Human can connect: gmail, google_calendar, linear. When a request needs the Human's account in one of these apps, to create or change something there or to read data that is not public, use teamhub apps, not the browser: with no account, run teamhub apps connect <app-key> to post an authorization card instead of asking for credentials, and end your turn; the card result wakes you. Then find the tool with teamhub apps search and run it with teamhub apps execute. Read a public page the usual way.+- Connected apps: gmail, outlook, outlook-calendar, gcal, gdrive, slack, notion, and figma have their own commands (teamhub gmail --help). For other apps, find the tool with teamhub apps search "<the action in English, with the app name>", then run teamhub apps execute --connectionId <id> --toolSlug <slug> --toolVersion <version> --arguments '<json>'. When this Run started, these apps had an account you can use: gmail, google_calendar; use them without checking first, and check teamhub apps list only when the Human says they connected or disconnected an app during this conversation or a command reports that the account is not connected. Never resend a write whose outcome is unknown; check the app first. Apps the Human can connect: gmail, google_calendar, linear. When a request needs the Human's account in one of these apps, to create or change something there or to read data that is not public, use teamhub apps, not the browser: with no account, run teamhub apps connect <app-key> to post an authorization card instead of asking for credentials, and end your turn; the card result wakes you. Then find the tool with teamhub apps search and run it with teamhub apps execute. Read a public page the usual way.- With --operation-id, use a unique id per write; after an unknown outcome, rerun the same command with the id the error printed.<personal-context-method>diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-compact.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-compact.txtindex 68766317..b7ba5824 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-compact.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-compact.txt@@ -72,7 +72,7 @@ TeamHub commands, all run through your shell tool (teamhub <domain> <action> --h- To show something the person looks at or uses here and now (a quick chart, dashboard, checklist or small tool), send it inline as a chat card (read the chat-card skill first); use the artifact skill only for a file to share, print, present or keep, or when a file is asked for.- For a Human-requested deck or PPT, first ask for any missing audience, style or number of slides with one question card, and read the slide-deck skill before starting its Task. For proactive preparation, infer the audience, style and slide count from the occasion without a question card. Build new .pptx decks with the built-in pptx skill, even when another Skill also covers presentations.- Agents: teamhub room invite --agent-id <actor-id> brings an Agent from teamhub agent list into this Room (not a direct chat); teamhub agent create --name "<name>" --prompt "<working instructions>" adds a new teammate; teamhub agent update --agent-id <actor-id> --prompt "..." changes an Agent you manage. A change to an established Agent waits for approval.-- Connected apps: gmail, outlook, gcal, gdrive, slack, notion, and figma have their own commands (teamhub gmail --help). For other apps, find the tool with teamhub apps search "<the action in English, with the app name>", then run teamhub apps execute --connectionId <id> --toolSlug <slug> --toolVersion <version> --arguments '<json>'. When this Run started, these apps had an account you can use: gmail, google_calendar; use them without checking first, and check teamhub apps list only when the Human says they connected or disconnected an app during this conversation or a command reports that the account is not connected. Never resend a write whose outcome is unknown; check the app first. Apps the Human can connect: gmail, google_calendar, linear. When a request needs the Human's account in one of these apps, to create or change something there or to read data that is not public, use teamhub apps, not the browser: with no account, run teamhub apps connect <app-key> to post an authorization card instead of asking for credentials, and end your turn; the card result wakes you. Then find the tool with teamhub apps search and run it with teamhub apps execute. Read a public page the usual way.+- Connected apps: gmail, outlook, outlook-calendar, gcal, gdrive, slack, notion, and figma have their own commands (teamhub gmail --help). For other apps, find the tool with teamhub apps search "<the action in English, with the app name>", then run teamhub apps execute --connectionId <id> --toolSlug <slug> --toolVersion <version> --arguments '<json>'. When this Run started, these apps had an account you can use: gmail, google_calendar; use them without checking first, and check teamhub apps list only when the Human says they connected or disconnected an app during this conversation or a command reports that the account is not connected. Never resend a write whose outcome is unknown; check the app first. Apps the Human can connect: gmail, google_calendar, linear. When a request needs the Human's account in one of these apps, to create or change something there or to read data that is not public, use teamhub apps, not the browser: with no account, run teamhub apps connect <app-key> to post an authorization card instead of asking for credentials, and end your turn; the card result wakes you. Then find the tool with teamhub apps search and run it with teamhub apps execute. Read a public page the usual way.- With --operation-id, use a unique id per write; after an unknown outcome, rerun the same command with the id the error printed.<personal-context-method>diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-compact.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-compact.txtindex 2124c7b5..35acd43d 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-compact.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-compact.txt@@ -77,7 +77,7 @@ TeamHub commands, all run through your shell tool (teamhub <domain> <action> --h- To show something the person looks at or uses here and now (a quick chart, dashboard, checklist or small tool), send it inline as a chat card (read the chat-card skill first); use the artifact skill only for a file to share, print, present or keep, or when a file is asked for.- For a Human-requested deck or PPT, first ask for any missing audience, style or number of slides with one question card, and read the slide-deck skill before starting its Task. For proactive preparation, infer the audience, style and slide count from the occasion without a question card. Build new .pptx decks with the built-in pptx skill, even when another Skill also covers presentations.- Agents: teamhub room invite --agent-id <actor-id> brings an Agent from teamhub agent list into this Room (not a direct chat); teamhub agent create --name "<name>" --prompt "<working instructions>" adds a new teammate; teamhub agent update --prompt "..." changes you, or add --agent-id <actor-id> for an Agent you manage. A change to an established Agent waits for approval.-- Connected apps: gmail, outlook, gcal, gdrive, slack, notion, and figma have their own commands (teamhub gmail --help). For other apps, find the tool with teamhub apps search "<the action in English, with the app name>", then run teamhub apps execute --connectionId <id> --toolSlug <slug> --toolVersion <version> --arguments '<json>'. When this Run started, these apps had an account you can use: gmail, google_calendar; use them without checking first, and check teamhub apps list only when the Human says they connected or disconnected an app during this conversation or a command reports that the account is not connected. Never resend a write whose outcome is unknown; check the app first. Apps the Human can connect: gmail, google_calendar, linear. When a request needs the Human's account in one of these apps, to create or change something there or to read data that is not public, use teamhub apps, not the browser: with no account, run teamhub apps connect <app-key> to post an authorization card instead of asking for credentials, and end your turn; the card result wakes you. Then find the tool with teamhub apps search and run it with teamhub apps execute. Read a public page the usual way.+- Connected apps: gmail, outlook, outlook-calendar, gcal, gdrive, slack, notion, and figma have their own commands (teamhub gmail --help). For other apps, find the tool with teamhub apps search "<the action in English, with the app name>", then run teamhub apps execute --connectionId <id> --toolSlug <slug> --toolVersion <version> --arguments '<json>'. When this Run started, these apps had an account you can use: gmail, google_calendar; use them without checking first, and check teamhub apps list only when the Human says they connected or disconnected an app during this conversation or a command reports that the account is not connected. Never resend a write whose outcome is unknown; check the app first. Apps the Human can connect: gmail, google_calendar, linear. When a request needs the Human's account in one of these apps, to create or change something there or to read data that is not public, use teamhub apps, not the browser: with no account, run teamhub apps connect <app-key> to post an authorization card instead of asking for credentials, and end your turn; the card result wakes you. Then find the tool with teamhub apps search and run it with teamhub apps execute. Read a public page the usual way.- With --operation-id, use a unique id per write; after an unknown outcome, rerun the same command with the id the error printed.<personal-context-method>diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-compact.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-compact.txtindex cf707b8a..801d9bba 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-compact.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-compact.txt@@ -69,7 +69,7 @@ TeamHub commands, all run through your shell tool (teamhub <domain> <action> --h- To show something the person looks at or uses here and now (a quick chart, dashboard, checklist or small tool), send it inline as a chat card (read the chat-card skill first); use the artifact skill only for a file to share, print, present or keep, or when a file is asked for.- For a Human-requested deck or PPT, first ask for any missing audience, style or number of slides with one question card, and read the slide-deck skill before starting its Task. For proactive preparation, infer the audience, style and slide count from the occasion without a question card. Build new .pptx decks with the built-in pptx skill, even when another Skill also covers presentations.- Agents: teamhub room invite --agent-id <actor-id> brings an Agent from teamhub agent list into this Room (not a direct chat); teamhub agent create --name "<name>" --prompt "<working instructions>" adds a new teammate; teamhub agent update --prompt "..." changes you, or add --agent-id <actor-id> for an Agent you manage. A change to an established Agent waits for approval.-- Connected apps: gmail, outlook, gcal, gdrive, slack, notion, and figma have their own commands (teamhub gmail --help). For other apps, find the tool with teamhub apps search "<the action in English, with the app name>", then run teamhub apps execute --connectionId <id> --toolSlug <slug> --toolVersion <version> --arguments '<json>'. When this Run started, these apps had an account you can use: gmail, google_calendar; use them without checking first, and check teamhub apps list only when the Human says they connected or disconnected an app during this conversation or a command reports that the account is not connected. Never resend a write whose outcome is unknown; check the app first. Apps the Human can connect: gmail, google_calendar, linear. When a request needs the Human's account in one of these apps, to create or change something there or to read data that is not public, use teamhub apps, not the browser: with no account, run teamhub apps connect <app-key> to post an authorization card instead of asking for credentials, and end your turn; the card result wakes you. Then find the tool with teamhub apps search and run it with teamhub apps execute. Read a public page the usual way.+- Connected apps: gmail, outlook, outlook-calendar, gcal, gdrive, slack, notion, and figma have their own commands (teamhub gmail --help). For other apps, find the tool with teamhub apps search "<the action in English, with the app name>", then run teamhub apps execute --connectionId <id> --toolSlug <slug> --toolVersion <version> --arguments '<json>'. When this Run started, these apps had an account you can use: gmail, google_calendar; use them without checking first, and check teamhub apps list only when the Human says they connected or disconnected an app during this conversation or a command reports that the account is not connected. Never resend a write whose outcome is unknown; check the app first. Apps the Human can connect: gmail, google_calendar, linear. When a request needs the Human's account in one of these apps, to create or change something there or to read data that is not public, use teamhub apps, not the browser: with no account, run teamhub apps connect <app-key> to post an authorization card instead of asking for credentials, and end your turn; the card result wakes you. Then find the tool with teamhub apps search and run it with teamhub apps execute. Read a public page the usual way.- With --operation-id, use a unique id per write; after an unknown outcome, rerun the same command with the id the error printed.<personal-context-method>diff --git a/apps/node-services/tests/agent/agent-features/context-instructions.test.ts b/apps/node-services/tests/agent/agent-features/context-instructions.test.tsindex ce77bf5a..0d53ba45 100644--- a/apps/node-services/tests/agent/agent-features/context-instructions.test.ts+++ b/apps/node-services/tests/agent/agent-features/context-instructions.test.ts@@ -243,6 +243,14 @@ describe("execution Context instructions", () => {expect(gmailOnly).not.toContain("teamhub gcal");expect(gmailOnly).not.toContain("teamhub slack");expect(gmailOnly).not.toContain("other connected apps");+ const outlookOnly = renderComposed(scene, {+ ...fullDeployment,+ connectedAppKeys: ["outlook"],+ })!;+ expect(outlookOnly).toContain(+ "- calendar (teamhub outlook-calendar list / free / read)",+ );+ expect(outlookOnly).toContain("- mail (teamhub outlook list / read)");const outlookCalendar = renderComposed(scene, {...fullDeployment,connectedAppKeys: ["outlook_calendar"],diff --git a/apps/teamhub-cli/README.md b/apps/teamhub-cli/README.mdindex 07a3e6cd..3792c6d4 100644--- a/apps/teamhub-cli/README.md+++ b/apps/teamhub-cli/README.md@@ -64,7 +64,7 @@ Connected application commands may have their own file options. For those option## Connected applications-Eight applications have dedicated commands: Gmail, Outlook, Slack, Google Calendar, Notion, Google Drive, Figma and GitHub, with 50 Connector leaf commands. `teamhub gmail --help` and `teamhub gdrive --help` discover them offline, and each command keeps its own help, examples and Composio support boundary.+Eight applications have dedicated commands: Gmail, Outlook (mail via `teamhub outlook` and calendar via `teamhub outlook-calendar`), Slack, Google Calendar, Notion, Google Drive, Figma and GitHub, with 57 Connector leaf commands. `teamhub gmail --help` and `teamhub outlook-calendar --help` discover them offline, and each command keeps its own help, examples and Composio support boundary.Choose an account with `--account <connection ID|full label>`; labels match case-insensitively, connection IDs exactly. A connection ID that no longer matches a delegated account returns `account_ambiguous` with the delegated candidates instead of switching accounts. Without a delegation, the command posts an authorization card in an allowed chat that names the requested label and exits with `authorization_required`; the Agent ends its turn, and the card's result wakes it to run the original command again.Mail `--markdown` is converted to HTML by TeamHub; only `--attach` adds attachments.diff --git a/apps/teamhub-cli/src/__snapshots__/cli.help-snapshot.test.ts.snap b/apps/teamhub-cli/src/__snapshots__/cli.help-snapshot.test.ts.snapindex 83a52d06..171d530b 100644--- a/apps/teamhub-cli/src/__snapshots__/cli.help-snapshot.test.ts.snap+++ b/apps/teamhub-cli/src/__snapshots__/cli.help-snapshot.test.ts.snap@@ -2469,6 +2469,268 @@ LEARN MORE","schema": "exit 0{"command":["outlook","send"],"description":"Send a new message or an existing draft.","read_only":false,"input_schema":{"type":"object","additionalProperties":false,"properties":{"content":{"type":"string","minLength":1,"maxLength":1048576},"bodyFormat":{"enum":["text","markdown","html"]},"attachments":{"type":"array","items":{"type":"string","minLength":1},"minItems":1,"maxItems":20},"to":{"type":"array","items":{"type":"string","format":"email"},"minItems":1,"maxItems":100},"cc":{"type":"array","items":{"type":"string","format":"email"},"minItems":1,"maxItems":100},"bcc":{"type":"array","items":{"type":"string","format":"email"},"minItems":1,"maxItems":100},"subject":{"type":"string","minLength":1},"draftId":{"type":"string","minLength":1},"account":{"type":"string","minLength":1,"maxLength":240}}},"output_schema":{"anyOf":[{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"result":{"type":"object","additionalProperties":false,"properties":{"action":{"enum":["sent","drafted","draft_updated","archived"]},"acknowledged":{"const":true},"messageId":{"type":"string","minLength":1},"threadId":{"type":"string","minLength":1},"draftId":{"type":"string","minLength":1},"url":{"type":"string","minLength":1}},"required":["action","acknowledged"]}},"required":["account","result"]},{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"result":{"type":"object","additionalProperties":false,"properties":{"action":{"const":"confirmation_requested"},"confirmation":{"type":"object","additionalProperties":false,"properties":{"status":{"const":"pending"},"interactionId":{"type":"string","minLength":1},"messageId":{"type":"string","minLength":1},"roomId":{"type":"string","minLength":1}},"required":["status","interactionId","messageId","roomId"]}},"required":["action","confirmation"]}},"required":["account","result"]}]},"cli":{"usage":["teamhub outlook send --to <email> --subject <text> (--content <text> | --file <path|->) [--markdown | --html] [--attach <path>] [flags]","teamhub outlook send --draft <draft-id> [flags]"],"arguments":[],"options":{"--attach":{"description":"Attach a local regular file; repeatable; stdin is rejected.","repeatable":true},"--content":{"description":"Body text; exclusive with --file."},"--file":{"description":"UTF-8 body file; - reads stdin, not an attachment."},"--markdown":{"description":"TeamHub converts Markdown to HTML on the backend.","boolean":true},"--html":{"description":"Use HTML body text as-is.","boolean":true},"--to":{"description":"One bare email address; repeatable.","repeatable":true},"--cc":{"description":"One Cc email address; repeatable.","repeatable":true},"--bcc":{"description":"One Bcc email address; repeatable.","repeatable":true},"--subject":{"description":"Subject with no line breaks."},"--draft":{"description":"Send a saved draft; exclusive with body, recipients, and format flags."},"--account":{"description":"Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat."},"--json":{"description":"Return machine-readable JSON.","boolean":true},"--help":{"description":"Show this offline command reference.","boolean":true},"-h":{"description":"Show help.","boolean":true},"--schema":{"description":"Show offline input and output schemas.","boolean":true},"--operation-id":{"description":"Stable operation identity for recovery."}},"notes":["The external write waits for the sponsor to approve a confirmation card in the chat; TeamHub then runs it and sends you the result, or the denial and its reason.","Help and schema are available offline; TeamHub checks current access at execution time."]}}+",+ },+ "outlook-calendar calendars": {+ "help": "exit 0+List available Outlook calendars.++USAGE+ teamhub outlook-calendar calendars [flags]+ teamhub outlook-calendar calendars --schema [--json]++FLAGS+ --limit <value> 1–100 items per page; default 20.+ --cursor <value> Cursor from the previous page; keep the same account and filters.+ --account <value> Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat.+ --json Print complete JSON instead of the default readable text.+ --schema Show offline input and output schemas without business arguments.++INHERITED FLAGS+ -h, --help Show help.++OUTPUT+ Shows the actual account, plus Calendar IDs, names, time zones, access roles, and next-page cursor.++Help and schema are available offline; TeamHub checks current access at execution time.++EXAMPLES+ teamhub outlook-calendar calendars++LEARN MORE+ teamhub outlook-calendar --help+ teamhub outlook-calendar calendars --schema --json+",+ "schema": "exit 0+{"command":["outlook-calendar","calendars"],"description":"List available Outlook calendars.","read_only":true,"input_schema":{"type":"object","additionalProperties":false,"properties":{"limit":{"type":"integer","minimum":1,"maximum":100,"default":20},"cursor":{"type":"string","minLength":1},"account":{"type":"string","minLength":1,"maxLength":240}}},"output_schema":{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"calendars":{"type":"array","items":{"type":"object","additionalProperties":false,"properties":{"calendarId":{"type":"string","minLength":1},"name":{"type":"string"},"timeZone":{"type":"string"},"accessRole":{"type":"string"},"primary":{"type":"boolean"}},"required":["calendarId"]}},"hasMore":{"type":"boolean"},"nextCursor":{"type":"string","minLength":1}},"required":["account","calendars","hasMore"]},"cli":{"usage":["teamhub outlook-calendar calendars [flags]"],"arguments":[],"options":{"--limit":{"description":"1–100 items per page; default 20."},"--cursor":{"description":"Cursor from the previous page; keep the same account and filters."},"--account":{"description":"Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat."},"--json":{"description":"Return machine-readable JSON.","boolean":true},"--help":{"description":"Show this offline command reference.","boolean":true},"-h":{"description":"Show help.","boolean":true},"--schema":{"description":"Show offline input and output schemas.","boolean":true}},"notes":["Help and schema are available offline; TeamHub checks current access at execution time."]}}+",+ },+ "outlook-calendar cancel": {+ "help": "exit 0+Cancel an Outlook meeting as the organizer and notify attendees.++USAGE+ teamhub outlook-calendar cancel <event-id> [flags]+ teamhub outlook-calendar cancel --schema [--json]++FLAGS+ --calendar <value> Calendar ID; default primary.+ --account <value> Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat.+ --json Print complete JSON instead of the default readable text.+ --schema Show offline input and output schemas without business arguments.+ --operation-id <value> Stable identity for this operation; keep it when the outcome is unknown and do not blindly resend.++INHERITED FLAGS+ -h, --help Show help.++OUTPUT+ Shows the actual account, plus The actual event ID and cancel receipt.++Help and schema are available offline; TeamHub checks current access at execution time.++EXAMPLES+ teamhub outlook-calendar cancel event_example++LEARN MORE+ teamhub outlook-calendar --help+ teamhub outlook-calendar cancel --schema --json+",+ "schema": "exit 0+{"command":["outlook-calendar","cancel"],"description":"Cancel an Outlook meeting as the organizer and notify attendees.","read_only":false,"input_schema":{"type":"object","additionalProperties":false,"properties":{"calendarId":{"type":"string","minLength":1,"default":"primary"},"eventId":{"type":"string","minLength":1},"account":{"type":"string","minLength":1,"maxLength":240}}},"output_schema":{"anyOf":[{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"result":{"type":"object","additionalProperties":false,"properties":{"action":{"enum":["created","updated","canceled"]},"acknowledged":{"const":true},"event":{"type":"object","additionalProperties":false,"properties":{"eventId":{"type":"string","minLength":1},"calendarId":{"type":"string","minLength":1},"title":{"type":"string"},"description":{"type":"string"},"location":{"type":"string"},"status":{"type":"string"},"organizerEmail":{"type":"string"},"url":{"type":"string"},"meetingUrl":{"type":"string"},"recurringEventId":{"type":"string"},"start":{"oneOf":[{"type":"object","additionalProperties":false,"properties":{"date":{"type":"string","format":"date"}},"required":["date"]},{"type":"object","additionalProperties":false,"properties":{"dateTime":{"type":"string","format":"date-time"},"timeZone":{"type":"string","minLength":1}},"required":["dateTime"]}]},"end":{"oneOf":[{"type":"object","additionalProperties":false,"properties":{"date":{"type":"string","format":"date"}},"required":["date"]},{"type":"object","additionalProperties":false,"properties":{"dateTime":{"type":"string","format":"date-time"},"timeZone":{"type":"string","minLength":1}},"required":["dateTime"]}]},"attendees":{"type":"array","items":{"type":"object","additionalProperties":false,"properties":{"email":{"type":"string","minLength":1},"responseStatus":{"type":"string"}},"required":["email"]}}},"required":["eventId"]},"eventId":{"type":"string","minLength":1}},"required":["action","acknowledged"]}},"required":["account","result"]},{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"result":{"type":"object","additionalProperties":false,"properties":{"action":{"const":"confirmation_requested"},"confirmation":{"type":"object","additionalProperties":false,"properties":{"status":{"const":"pending"},"interactionId":{"type":"string","minLength":1},"messageId":{"type":"string","minLength":1},"roomId":{"type":"string","minLength":1}},"required":["status","interactionId","messageId","roomId"]}},"required":["action","confirmation"]}},"required":["account","result"]}]},"cli":{"usage":["teamhub outlook-calendar cancel <event-id> [flags]"],"arguments":[],"options":{"--calendar":{"description":"Calendar ID; default primary."},"--account":{"description":"Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat."},"--json":{"description":"Return machine-readable JSON.","boolean":true},"--help":{"description":"Show this offline command reference.","boolean":true},"-h":{"description":"Show help.","boolean":true},"--schema":{"description":"Show offline input and output schemas.","boolean":true},"--operation-id":{"description":"Stable operation identity for recovery."}},"notes":["Help and schema are available offline; TeamHub checks current access at execution time."]}}+",+ },+ "outlook-calendar create": {+ "help": "exit 0+Create an Outlook meeting and notify attendees.++USAGE+ teamhub outlook-calendar create <title> --start <RFC3339> [--end <RFC3339> | --duration <minutes>] [flags]+ teamhub outlook-calendar create --schema [--json]++FLAGS+ --calendar <value> Calendar ID; default primary.+ --content <value> Event description; exclusive with --file.+ --file <value> UTF-8 description file; - reads stdin.+ --start <value> RFC3339 start time.+ --end <value> RFC3339 end time; exclusive with --duration.+ --duration <value> Duration in minutes, 1–1440; default 30.+ --attendee <value> Attendee email; repeatable; at most 50.+ --location <value> Location; at most 1000 characters.+ --teams Request a Microsoft Teams meeting link (requires Microsoft 365 Teams).+ --account <value> Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat.+ --json Print complete JSON instead of the default readable text.+ --schema Show offline input and output schemas without business arguments.+ --operation-id <value> Stable identity for this operation; keep it when the outcome is unknown and do not blindly resend.++INHERITED FLAGS+ -h, --help Show help.++OUTPUT+ Shows the actual account, plus The event after create, plus a meeting link when the provider returns one.++Help and schema are available offline; TeamHub checks current access at execution time.++EXAMPLES+ teamhub outlook-calendar create 'Project sync' --start 2026-10-19T10:00:00-04:00 --duration 30 --attendee [email protected] --teams++LEARN MORE+ teamhub outlook-calendar --help+ teamhub outlook-calendar create --schema --json+",+ "schema": "exit 0+{"command":["outlook-calendar","create"],"description":"Create an Outlook meeting and notify attendees.","read_only":false,"input_schema":{"type":"object","additionalProperties":false,"properties":{"calendarId":{"type":"string","minLength":1,"default":"primary"},"eventId":{"type":"string","minLength":1},"title":{"type":"string","minLength":1},"start":{"type":"string","format":"date-time"},"end":{"type":"string","format":"date-time"},"description":{"type":"string"},"location":{"type":"string","minLength":1},"attendees":{"type":"array","items":{"type":"string","format":"email"},"maxItems":50},"addAttendees":{"type":"array","items":{"type":"string","format":"email"},"maxItems":50},"removeAttendees":{"type":"array","items":{"type":"string","format":"email"},"maxItems":50},"teams":{"type":"boolean"},"account":{"type":"string","minLength":1,"maxLength":240}}},"output_schema":{"anyOf":[{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"result":{"type":"object","additionalProperties":false,"properties":{"action":{"enum":["created","updated","canceled"]},"acknowledged":{"const":true},"event":{"type":"object","additionalProperties":false,"properties":{"eventId":{"type":"string","minLength":1},"calendarId":{"type":"string","minLength":1},"title":{"type":"string"},"description":{"type":"string"},"location":{"type":"string"},"status":{"type":"string"},"organizerEmail":{"type":"string"},"url":{"type":"string"},"meetingUrl":{"type":"string"},"recurringEventId":{"type":"string"},"start":{"oneOf":[{"type":"object","additionalProperties":false,"properties":{"date":{"type":"string","format":"date"}},"required":["date"]},{"type":"object","additionalProperties":false,"properties":{"dateTime":{"type":"string","format":"date-time"},"timeZone":{"type":"string","minLength":1}},"required":["dateTime"]}]},"end":{"oneOf":[{"type":"object","additionalProperties":false,"properties":{"date":{"type":"string","format":"date"}},"required":["date"]},{"type":"object","additionalProperties":false,"properties":{"dateTime":{"type":"string","format":"date-time"},"timeZone":{"type":"string","minLength":1}},"required":["dateTime"]}]},"attendees":{"type":"array","items":{"type":"object","additionalProperties":false,"properties":{"email":{"type":"string","minLength":1},"responseStatus":{"type":"string"}},"required":["email"]}}},"required":["eventId"]},"eventId":{"type":"string","minLength":1}},"required":["action","acknowledged"]}},"required":["account","result"]},{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"result":{"type":"object","additionalProperties":false,"properties":{"action":{"const":"confirmation_requested"},"confirmation":{"type":"object","additionalProperties":false,"properties":{"status":{"const":"pending"},"interactionId":{"type":"string","minLength":1},"messageId":{"type":"string","minLength":1},"roomId":{"type":"string","minLength":1}},"required":["status","interactionId","messageId","roomId"]}},"required":["action","confirmation"]}},"required":["account","result"]}]},"cli":{"usage":["teamhub outlook-calendar create <title> --start <RFC3339> [--end <RFC3339> | --duration <minutes>] [flags]"],"arguments":[],"options":{"--calendar":{"description":"Calendar ID; default primary."},"--content":{"description":"Event description; exclusive with --file."},"--file":{"description":"UTF-8 description file; - reads stdin."},"--start":{"description":"RFC3339 start time."},"--end":{"description":"RFC3339 end time; exclusive with --duration."},"--duration":{"description":"Duration in minutes, 1–1440; default 30."},"--attendee":{"description":"Attendee email; repeatable; at most 50.","repeatable":true},"--location":{"description":"Location; at most 1000 characters."},"--teams":{"description":"Request a Microsoft Teams meeting link (requires Microsoft 365 Teams).","boolean":true},"--account":{"description":"Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat."},"--json":{"description":"Return machine-readable JSON.","boolean":true},"--help":{"description":"Show this offline command reference.","boolean":true},"-h":{"description":"Show help.","boolean":true},"--schema":{"description":"Show offline input and output schemas.","boolean":true},"--operation-id":{"description":"Stable operation identity for recovery."}},"notes":["Help and schema are available offline; TeamHub checks current access at execution time."]}}+",+ },+ "outlook-calendar free": {+ "help": "exit 0+Find shared free time across Outlook calendars; query only, does not book.++USAGE+ teamhub outlook-calendar free --from <RFC3339> --to <RFC3339> [--with <email>] [--calendar <id>] [flags]+ teamhub outlook-calendar free --schema [--json]++FLAGS+ --from <value> RFC3339 start of the time window.+ --to <value> RFC3339 end of the time window; at most 31 days.+ --with <value> Email of another person or room to check availability; repeatable.+ --calendar <value> Calendar ID in this mailbox; repeatable; includes primary when omitted.+ --duration <value> Minimum consecutive free minutes, 1–1440; default 30.+ --account <value> Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat.+ --json Print complete JSON instead of the default readable text.+ --schema Show offline input and output schemas without business arguments.++INHERITED FLAGS+ -h, --help Show help.++OUTPUT+ Shows the actual account, plus Time ranges that are free on every selected calendar; does not create events.++Help and schema are available offline; TeamHub checks current access at execution time.++EXAMPLES+ teamhub outlook-calendar free --from 2026-10-19T09:00:00-04:00 --to 2026-10-19T18:00:00-04:00 --with [email protected]++LEARN MORE+ teamhub outlook-calendar --help+ teamhub outlook-calendar free --schema --json+",+ "schema": "exit 0+{"command":["outlook-calendar","free"],"description":"Find shared free time across Outlook calendars; query only, does not book.","read_only":true,"input_schema":{"type":"object","additionalProperties":false,"properties":{"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"},"calendarIds":{"type":"array","items":{"type":"string","minLength":1},"minItems":1,"maxItems":20},"withEmails":{"type":"array","items":{"type":"string","format":"email"},"maxItems":20},"durationMinutes":{"type":"integer","minimum":1,"maximum":1440,"default":30},"account":{"type":"string","minLength":1,"maxLength":240}}},"output_schema":{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"calendarIds":{"type":"array","items":{"type":"string","minLength":1}},"window":{"type":"object","additionalProperties":false,"properties":{"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"}},"required":["from","to"]},"durationMinutes":{"type":"integer"},"slots":{"type":"array","items":{"type":"object","additionalProperties":false,"properties":{"start":{"type":"string","format":"date-time"},"end":{"type":"string","format":"date-time"},"durationMinutes":{"type":"integer"}},"required":["start","end","durationMinutes"]}}},"required":["account","calendarIds","window","durationMinutes","slots"]},"cli":{"usage":["teamhub outlook-calendar free --from <RFC3339> --to <RFC3339> [--with <email>] [--calendar <id>] [flags]"],"arguments":[],"options":{"--from":{"description":"RFC3339 start of the time window."},"--to":{"description":"RFC3339 end of the time window; at most 31 days."},"--with":{"description":"Email of another person or room to check availability; repeatable.","repeatable":true},"--calendar":{"description":"Calendar ID in this mailbox; repeatable; includes primary when omitted.","repeatable":true},"--duration":{"description":"Minimum consecutive free minutes, 1–1440; default 30."},"--account":{"description":"Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat."},"--json":{"description":"Return machine-readable JSON.","boolean":true},"--help":{"description":"Show this offline command reference.","boolean":true},"-h":{"description":"Show help.","boolean":true},"--schema":{"description":"Show offline input and output schemas.","boolean":true}},"notes":["Help and schema are available offline; TeamHub checks current access at execution time."]}}+",+ },+ "outlook-calendar list": {+ "help": "exit 0+List Outlook events for a day or a time window.++USAGE+ teamhub outlook-calendar list [flags]+ teamhub outlook-calendar list --schema [--json]++FLAGS+ --calendar <value> Calendar ID; default primary.+ --limit <value> 1–100 items per page; default 20.+ --cursor <value> Cursor from the previous page; keep the same account and filters.+ --date <value> today / tomorrow / YYYY-MM-DD; default today.+ --from <value> RFC3339 start time; use together with --to.+ --to <value> RFC3339 end time, exclusive of this instant.+ --timezone <value> IANA time zone for date mode; default mailbox time zone.+ --query <value> Event subject keyword; at most 1000 characters.+ --account <value> Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat.+ --json Print complete JSON instead of the default readable text.+ --schema Show offline input and output schemas without business arguments.++INHERITED FLAGS+ -h, --help Show help.++OUTPUT+ Shows the actual account, plus Event IDs, titles, start/end times, and next-page cursor.++Help and schema are available offline; TeamHub checks current access at execution time.++EXAMPLES+ teamhub outlook-calendar list --date tomorrow --timezone America/New_York++LEARN MORE+ teamhub outlook-calendar --help+ teamhub outlook-calendar list --schema --json+",+ "schema": "exit 0+{"command":["outlook-calendar","list"],"description":"List Outlook events for a day or a time window.","read_only":true,"input_schema":{"type":"object","additionalProperties":false,"properties":{"calendarId":{"type":"string","minLength":1,"default":"primary"},"limit":{"type":"integer","minimum":1,"maximum":100,"default":20},"cursor":{"type":"string","minLength":1},"date":{"type":"string","minLength":1},"timeZone":{"type":"string","minLength":1},"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"},"query":{"type":"string","minLength":1},"account":{"type":"string","minLength":1,"maxLength":240}}},"output_schema":{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"events":{"type":"array","items":{"type":"object","additionalProperties":false,"properties":{"eventId":{"type":"string","minLength":1},"calendarId":{"type":"string","minLength":1},"title":{"type":"string"},"description":{"type":"string"},"location":{"type":"string"},"status":{"type":"string"},"organizerEmail":{"type":"string"},"url":{"type":"string"},"meetingUrl":{"type":"string"},"recurringEventId":{"type":"string"},"start":{"oneOf":[{"type":"object","additionalProperties":false,"properties":{"date":{"type":"string","format":"date"}},"required":["date"]},{"type":"object","additionalProperties":false,"properties":{"dateTime":{"type":"string","format":"date-time"},"timeZone":{"type":"string","minLength":1}},"required":["dateTime"]}]},"end":{"oneOf":[{"type":"object","additionalProperties":false,"properties":{"date":{"type":"string","format":"date"}},"required":["date"]},{"type":"object","additionalProperties":false,"properties":{"dateTime":{"type":"string","format":"date-time"},"timeZone":{"type":"string","minLength":1}},"required":["dateTime"]}]},"attendees":{"type":"array","items":{"type":"object","additionalProperties":false,"properties":{"email":{"type":"string","minLength":1},"responseStatus":{"type":"string"}},"required":["email"]}}},"required":["eventId"]}},"hasMore":{"type":"boolean"},"nextCursor":{"type":"string","minLength":1}},"required":["account","events","hasMore"]},"cli":{"usage":["teamhub outlook-calendar list [flags]"],"arguments":[],"options":{"--calendar":{"description":"Calendar ID; default primary."},"--limit":{"description":"1–100 items per page; default 20."},"--cursor":{"description":"Cursor from the previous page; keep the same account and filters."},"--date":{"description":"today / tomorrow / YYYY-MM-DD; default today."},"--from":{"description":"RFC3339 start time; use together with --to."},"--to":{"description":"RFC3339 end time, exclusive of this instant."},"--timezone":{"description":"IANA time zone for date mode; default mailbox time zone."},"--query":{"description":"Event subject keyword; at most 1000 characters."},"--account":{"description":"Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat."},"--json":{"description":"Return machine-readable JSON.","boolean":true},"--help":{"description":"Show this offline command reference.","boolean":true},"-h":{"description":"Show help.","boolean":true},"--schema":{"description":"Show offline input and output schemas.","boolean":true}},"notes":["Help and schema are available offline; TeamHub checks current access at execution time."]}}+",+ },+ "outlook-calendar read": {+ "help": "exit 0+Read Outlook event details and attendees.++USAGE+ teamhub outlook-calendar read <event-id> [flags]+ teamhub outlook-calendar read --schema [--json]++FLAGS+ --calendar <value> Calendar ID; default primary.+ --account <value> Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat.+ --json Print complete JSON instead of the default readable text.+ --schema Show offline input and output schemas without business arguments.++INHERITED FLAGS+ -h, --help Show help.++OUTPUT+ Shows the actual account, plus Event details, organizer, attendees, and any available meeting link.++Help and schema are available offline; TeamHub checks current access at execution time.++EXAMPLES+ teamhub outlook-calendar read event_example++LEARN MORE+ teamhub outlook-calendar --help+ teamhub outlook-calendar read --schema --json+",+ "schema": "exit 0+{"command":["outlook-calendar","read"],"description":"Read Outlook event details and attendees.","read_only":true,"input_schema":{"type":"object","additionalProperties":false,"properties":{"calendarId":{"type":"string","minLength":1,"default":"primary"},"eventId":{"type":"string","minLength":1},"account":{"type":"string","minLength":1,"maxLength":240}}},"output_schema":{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"event":{"type":"object","additionalProperties":false,"properties":{"eventId":{"type":"string","minLength":1},"calendarId":{"type":"string","minLength":1},"title":{"type":"string"},"description":{"type":"string"},"location":{"type":"string"},"status":{"type":"string"},"organizerEmail":{"type":"string"},"url":{"type":"string"},"meetingUrl":{"type":"string"},"recurringEventId":{"type":"string"},"start":{"oneOf":[{"type":"object","additionalProperties":false,"properties":{"date":{"type":"string","format":"date"}},"required":["date"]},{"type":"object","additionalProperties":false,"properties":{"dateTime":{"type":"string","format":"date-time"},"timeZone":{"type":"string","minLength":1}},"required":["dateTime"]}]},"end":{"oneOf":[{"type":"object","additionalProperties":false,"properties":{"date":{"type":"string","format":"date"}},"required":["date"]},{"type":"object","additionalProperties":false,"properties":{"dateTime":{"type":"string","format":"date-time"},"timeZone":{"type":"string","minLength":1}},"required":["dateTime"]}]},"attendees":{"type":"array","items":{"type":"object","additionalProperties":false,"properties":{"email":{"type":"string","minLength":1},"responseStatus":{"type":"string"}},"required":["email"]}}},"required":["eventId"]}},"required":["account","event"]},"cli":{"usage":["teamhub outlook-calendar read <event-id> [flags]"],"arguments":[],"options":{"--calendar":{"description":"Calendar ID; default primary."},"--account":{"description":"Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat."},"--json":{"description":"Return machine-readable JSON.","boolean":true},"--help":{"description":"Show this offline command reference.","boolean":true},"-h":{"description":"Show help.","boolean":true},"--schema":{"description":"Show offline input and output schemas.","boolean":true}},"notes":["Help and schema are available offline; TeamHub checks current access at execution time."]}}+",+ },+ "outlook-calendar update": {+ "help": "exit 0+Update a single Outlook meeting and notify attendees.++USAGE+ teamhub outlook-calendar update <event-id> [flags]+ teamhub outlook-calendar update --schema [--json]++FLAGS+ --calendar <value> Calendar ID; default primary.+ --content <value> Event description; exclusive with --file.+ --file <value> UTF-8 description file; - reads stdin.+ --title <value> New title; at most 500 characters.+ --start <value> New start time; must be used with --end.+ --end <value> New end time; must be used with --start.+ --add-attendee <value> Add one email; repeatable.+ --remove-attendee <value> Remove one email; repeatable; cannot remove the organizer.+ --location <value> New location.+ --account <value> Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat.+ --json Print complete JSON instead of the default readable text.+ --schema Show offline input and output schemas without business arguments.+ --operation-id <value> Stable identity for this operation; keep it when the outcome is unknown and do not blindly resend.++INHERITED FLAGS+ -h, --help Show help.++OUTPUT+ Shows the actual account, plus The event and attendees after update.++Help and schema are available offline; TeamHub checks current access at execution time.++EXAMPLES+ teamhub outlook-calendar update event_example --title 'Project sync (rescheduled)' --add-attendee [email protected]++LEARN MORE+ teamhub outlook-calendar --help+ teamhub outlook-calendar update --schema --json+",+ "schema": "exit 0+{"command":["outlook-calendar","update"],"description":"Update a single Outlook meeting and notify attendees.","read_only":false,"input_schema":{"type":"object","additionalProperties":false,"properties":{"calendarId":{"type":"string","minLength":1,"default":"primary"},"eventId":{"type":"string","minLength":1},"title":{"type":"string","minLength":1},"start":{"type":"string","format":"date-time"},"end":{"type":"string","format":"date-time"},"description":{"type":"string"},"location":{"type":"string","minLength":1},"attendees":{"type":"array","items":{"type":"string","format":"email"},"maxItems":50},"addAttendees":{"type":"array","items":{"type":"string","format":"email"},"maxItems":50},"removeAttendees":{"type":"array","items":{"type":"string","format":"email"},"maxItems":50},"teams":{"type":"boolean"},"account":{"type":"string","minLength":1,"maxLength":240}}},"output_schema":{"anyOf":[{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"result":{"type":"object","additionalProperties":false,"properties":{"action":{"enum":["created","updated","canceled"]},"acknowledged":{"const":true},"event":{"type":"object","additionalProperties":false,"properties":{"eventId":{"type":"string","minLength":1},"calendarId":{"type":"string","minLength":1},"title":{"type":"string"},"description":{"type":"string"},"location":{"type":"string"},"status":{"type":"string"},"organizerEmail":{"type":"string"},"url":{"type":"string"},"meetingUrl":{"type":"string"},"recurringEventId":{"type":"string"},"start":{"oneOf":[{"type":"object","additionalProperties":false,"properties":{"date":{"type":"string","format":"date"}},"required":["date"]},{"type":"object","additionalProperties":false,"properties":{"dateTime":{"type":"string","format":"date-time"},"timeZone":{"type":"string","minLength":1}},"required":["dateTime"]}]},"end":{"oneOf":[{"type":"object","additionalProperties":false,"properties":{"date":{"type":"string","format":"date"}},"required":["date"]},{"type":"object","additionalProperties":false,"properties":{"dateTime":{"type":"string","format":"date-time"},"timeZone":{"type":"string","minLength":1}},"required":["dateTime"]}]},"attendees":{"type":"array","items":{"type":"object","additionalProperties":false,"properties":{"email":{"type":"string","minLength":1},"responseStatus":{"type":"string"}},"required":["email"]}}},"required":["eventId"]},"eventId":{"type":"string","minLength":1}},"required":["action","acknowledged"]}},"required":["account","result"]},{"type":"object","additionalProperties":false,"properties":{"account":{"type":"object","additionalProperties":false,"properties":{"connectionId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"displayName":{"type":"string"},"identityLabel":{"type":"string"}},"required":["connectionId","name","displayName","identityLabel"]},"result":{"type":"object","additionalProperties":false,"properties":{"action":{"const":"confirmation_requested"},"confirmation":{"type":"object","additionalProperties":false,"properties":{"status":{"const":"pending"},"interactionId":{"type":"string","minLength":1},"messageId":{"type":"string","minLength":1},"roomId":{"type":"string","minLength":1}},"required":["status","interactionId","messageId","roomId"]}},"required":["action","confirmation"]}},"required":["account","result"]}]},"cli":{"usage":["teamhub outlook-calendar update <event-id> [flags]"],"arguments":[],"options":{"--calendar":{"description":"Calendar ID; default primary."},"--content":{"description":"Event description; exclusive with --file."},"--file":{"description":"UTF-8 description file; - reads stdin."},"--title":{"description":"New title; at most 500 characters."},"--start":{"description":"New start time; must be used with --end."},"--end":{"description":"New end time; must be used with --start."},"--add-attendee":{"description":"Add one email; repeatable.","repeatable":true},"--remove-attendee":{"description":"Remove one email; repeatable; cannot remove the organizer.","repeatable":true},"--location":{"description":"New location."},"--account":{"description":"Select a connection ID or complete account label; when authorization is missing, an authorization card is shown in the chat."},"--json":{"description":"Return machine-readable JSON.","boolean":true},"--help":{"description":"Show this offline command reference.","boolean":true},"-h":{"description":"Show help.","boolean":true},"--schema":{"description":"Show offline input and output schemas.","boolean":true},"--operation-id":{"description":"Stable operation identity for recovery."}},"notes":["Help and schema are available offline; TeamHub checks current access at execution time."]}}",},"personal-profile show": {@@ -3318,6 +3580,7 @@ Commands:messagenotionoutlook+ outlook-calendarpersonal-profileprofileroom@@ -4090,6 +4353,27 @@ INHERITED FLAGSEXAMPLESteamhub outlook list --help+",+ "outlook-calendar": "exit 0+outlook-calendar common operations.++USAGE+ teamhub outlook-calendar <command> [flags]++COMMANDS+ calendars List available Outlook calendars.+ list List Outlook events for a day or a time window.+ read Read Outlook event details and attendees.+ free Find shared free time across Outlook calendars; query only, does not book.+ create Create an Outlook meeting and notify attendees.+ update Update a single Outlook meeting and notify attendees.+ cancel Cancel an Outlook meeting as the organizer and notify attendees.++INHERITED FLAGS+ -h, --help Show help++EXAMPLES+ teamhub outlook-calendar calendars --help","personal-profile": "exit 0teamhub personal-profile show [flags]diff --git a/apps/teamhub-cli/src/command-manifest.test.ts b/apps/teamhub-cli/src/command-manifest.test.tsindex 7657e0b3..911de257 100644--- a/apps/teamhub-cli/src/command-manifest.test.ts+++ b/apps/teamhub-cli/src/command-manifest.test.ts@@ -25,6 +25,11 @@ describe("command manifest", () => {expect(find("gmail", "send")?.approval).toBe("confirm");expect(find("gmail", "draft")?.approval).toBe("allow");expect(find("gcal", "create")?.approval).toBe("judge");+ expect(find("outlook-calendar", "list")?.approval).toBe("allow");+ expect(find("outlook-calendar", "free")?.approval).toBe("allow");+ expect(find("outlook-calendar", "create")?.approval).toBe("judge");+ expect(find("outlook-calendar", "update")?.approval).toBe("judge");+ expect(find("outlook-calendar", "cancel")?.approval).toBe("judge");expect(find("slack", "react")?.approval).toBe("judge");expect(find("apps", "execute")?.approval).toBe("judge");expect(find("apps", "search")?.approval).toBe("allow");diff --git a/apps/teamhub-cli/src/connector-approval.ts b/apps/teamhub-cli/src/connector-approval.tsindex 393347ed..929cb35b 100644--- a/apps/teamhub-cli/src/connector-approval.ts+++ b/apps/teamhub-cli/src/connector-approval.ts@@ -22,6 +22,9 @@ export const connectorWriteApproval: Readonly<Record<string, CommandApproval>> ="gcal create": "judge","gcal update": "judge","gcal cancel": "judge",+ "outlook-calendar create": "judge",+ "outlook-calendar update": "judge",+ "outlook-calendar cancel": "judge","notion create": "confirm","notion append": "confirm","notion edit": "confirm",diff --git a/apps/teamhub-cli/src/connector-behavior.test.ts b/apps/teamhub-cli/src/connector-behavior.test.tsindex 4903876c..c175acac 100644--- a/apps/teamhub-cli/src/connector-behavior.test.ts+++ b/apps/teamhub-cli/src/connector-behavior.test.ts@@ -152,7 +152,7 @@ const mail = {},};describe("reviewed Connector command boundaries", () => {- it("provides all 52 reviewed leaves as offline help and schemas, excluding removed apps", async () => {+ it("provides all 59 reviewed leaves as offline help and schemas, excluding removed apps", async () => {const f = await fixture("gmail", () => {throw new Error("offline must not call provider");});@@ -160,7 +160,7 @@ describe("reviewed Connector command boundaries", () => {x.toolName.startsWith("connector_"),);// Includes the two provider-independent generation commands.- expect(commands.length).toBe(52);+ expect(commands.length).toBe(59);for (const command of commands) {expect(await runCli([...command.command, "--help"], { ...f.deps, env: {} }),@@ -2269,3 +2269,399 @@ describe("GitHub commands", () => {expect(f.calls).toEqual([]);});});++describe("outlook-calendar connector", () => {+ it("lists calendars, queries by mailbox Windows timezone, and searches with OData filter", async () => {+ const f = await fixture("outlook", (slug, args) => {+ if (slug === "OUTLOOK_LIST_CALENDARS") {+ expect(args).toEqual({ top: 10 });+ return {+ value: [+ {+ id: "cal_primary",+ name: "Calendar",+ canEdit: true,+ isDefaultCalendar: true,+ },+ {+ id: "cal_team",+ name: "Team",+ canEdit: false,+ isDefaultCalendar: false,+ },+ ],+ next_page_token: "tok_2",+ };+ }+ if (slug === "OUTLOOK_GET_MAILBOX_SETTINGS") {+ expect(args).toEqual({ select: ["timeZone"] });+ return { timeZone: "China Standard Time" };+ }+ if (slug === "OUTLOOK_GET_CALENDAR_VIEW") {+ expect(args).toEqual({+ start_datetime: "2026-11-20T16:00:00.000Z",+ end_datetime: "2026-11-21T16:00:00.000Z",+ top: 20,+ orderby: "start/dateTime asc",+ timezone: "Asia/Shanghai",+ });+ return {+ value: [+ {+ id: "evt_day",+ subject: "Morning standup",+ showAs: "busy",+ isCancelled: false,+ start: {+ dateTime: "2026-11-21T09:30:00.0000000",+ timeZone: "China Standard Time",+ },+ end: {+ dateTime: "2026-11-21T10:00:00.0000000",+ timeZone: "China Standard Time",+ },+ organizer: { emailAddress: { address: "[email protected]" } },+ },+ ],+ };+ }+ if (slug === "OUTLOOK_LIST_EVENTS") {+ expect(args).toEqual({+ calendar_id: "cal_team",+ top: 20,+ expand_recurring_events: true,+ filter:+ "start/dateTime lt '2026-11-22T00:00:00Z' and end/dateTime gt '2026-11-21T00:00:00Z' and contains(subject,'O''Reilly') and isCancelled eq false",+ orderby: ["start/dateTime asc"],+ timezone: "UTC",+ });+ return {+ value: [+ {+ id: "evt_query",+ subject: "O'Reilly review",+ type: "occurrence",+ seriesMasterId: "master_1",+ start: { dateTime: "2026-11-21T10:00:00", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T11:00:00", timeZone: "UTC" },+ },+ ],+ };+ }+ throw new Error(`Unexpected tool ${slug}`);+ });++ const cals = await f.run([+ "outlook-calendar",+ "calendars",+ "--limit",+ "10",+ ]);+ expect(cals.code).toBe(0);+ expect(cals.result.calendars).toEqual([+ {+ calendarId: "cal_primary",+ name: "Calendar",+ accessRole: "writer",+ primary: true,+ },+ {+ calendarId: "cal_team",+ name: "Team",+ accessRole: "reader",+ primary: false,+ },+ ]);+ expect(cals.result.hasMore).toBe(true);+ expect(cals.result.nextCursor).toBeTruthy();++ const byDate = await f.run([+ "outlook-calendar",+ "list",+ "--date",+ "2026-11-21",+ ]);+ expect(byDate.code).toBe(0);+ expect(byDate.result.events).toEqual([+ {+ eventId: "evt_day",+ calendarId: "primary",+ title: "Morning standup",+ status: "busy",+ start: {+ dateTime: "2026-11-21T09:30:00+08:00",+ timeZone: "Asia/Shanghai",+ },+ end: {+ dateTime: "2026-11-21T10:00:00+08:00",+ timeZone: "Asia/Shanghai",+ },+ organizerEmail: "[email protected]",+ },+ ]);++ const byQuery = await f.run([+ "outlook-calendar",+ "list",+ "--calendar",+ "cal_team",+ "--from",+ "2026-11-21T00:00:00Z",+ "--to",+ "2026-11-22T00:00:00Z",+ "--query",+ "O'Reilly",+ ]);+ expect(byQuery.code).toBe(0);+ expect(byQuery.result.events).toHaveLength(1);+ expect(byQuery.result.events[0]).toMatchObject({+ eventId: "evt_query",+ calendarId: "cal_team",+ title: "O'Reilly review",+ });+ });++ it("finds shared free time across own calendar view and --with schedule, failing closed on incomplete data", async () => {+ let scheduleResponse: Json = {+ value: [+ {+ scheduleId: "[email protected]",+ scheduleItems: [+ {+ status: "busy",+ start: { dateTime: "2026-11-21T10:00:00", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T11:30:00", timeZone: "UTC" },+ },+ {+ status: "free",+ start: { dateTime: "2026-11-21T12:00:00", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T13:00:00", timeZone: "UTC" },+ },+ ],+ },+ ],+ };+ const f = await fixture("outlook", (slug, args) => {+ if (slug === "OUTLOOK_GET_CALENDAR_VIEW") {+ return {+ value: [+ {+ id: "evt_own",+ isCancelled: false,+ showAs: "busy",+ start: { dateTime: "2026-11-21T09:00:00", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T10:30:00", timeZone: "UTC" },+ },+ ],+ };+ }+ if (slug === "OUTLOOK_GET_CALENDAR_SCHEDULE") {+ expect(args).toEqual({+ schedules: ["[email protected]"],+ start_time: { dateTime: "2026-11-21T09:00:00", timeZone: "UTC" },+ end_time: { dateTime: "2026-11-21T14:00:00", timeZone: "UTC" },+ availability_view_interval: 30,+ });+ return scheduleResponse;+ }+ throw new Error(`Unexpected tool ${slug}`);+ });++ const args = [+ "outlook-calendar",+ "free",+ "--from",+ "2026-11-21T09:00:00Z",+ "--to",+ "2026-11-21T14:00:00Z",+ "--with",+ "[email protected]",+ "--duration",+ "45",+ ];+ const ok = await f.run(args);+ expect(ok.code).toBe(0);+ expect(ok.result.calendarIds).toEqual(["primary", "[email protected]"]);+ expect(ok.result.slots).toEqual([+ {+ start: "2026-11-21T11:30:00Z",+ end: "2026-11-21T14:00:00Z",+ durationMinutes: 150,+ },+ ]);++ for (const broken of [+ { value: [] },+ {+ value: [+ {+ scheduleId: "[email protected]",+ error: { message: "No access" },+ scheduleItems: [],+ },+ ],+ },+ {+ value: [+ {+ scheduleId: "[email protected]",+ scheduleItems: [+ { status: "busy", start: { dateTime: "bad" }, end: {} },+ ],+ },+ ],+ },+ ]) {+ scheduleResponse = broken;+ expect((await f.run(args)).error.error.code).toBe("incomplete_response");+ }+ });++ it("creates with --teams, updates attendees, rejects recurring/non-organizer writes, and cancels or deletes appropriately", async () => {+ let currentEvent: Json = {+ id: "evt_1",+ subject: "Project sync",+ isOrganizer: true,+ type: "singleInstance",+ organizer: { emailAddress: { address: "[email protected]" } },+ attendees: [+ {+ type: "required",+ status: { response: "accepted" },+ emailAddress: { name: "Alice", address: "[email protected]" },+ },+ {+ type: "optional",+ status: { response: "tentative" },+ emailAddress: { address: "[email protected]" },+ },+ ],+ };+ const executed: string[] = [];+ const f = await fixture("outlook", (slug, args) => {+ executed.push(slug);+ if (slug === "OUTLOOK_CALENDAR_CREATE_EVENT") {+ expect(args).toEqual({+ subject: "Project sync",+ start_datetime: "2026-11-21T02:00:00",+ end_datetime: "2026-11-21T02:30:00",+ time_zone: "UTC",+ attendees_info: [{ email: "[email protected]", type: "required" }],+ is_online_meeting: true,+ online_meeting_provider: "teamsForBusiness",+ });+ return {+ id: "evt_1",+ subject: "Project sync",+ onlineMeeting: {+ joinUrl: "https://teams.microsoft.com/l/meetup-join/demo",+ },+ start: { dateTime: "2026-11-21T02:00:00", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T02:30:00", timeZone: "UTC" },+ };+ }+ if (slug === "OUTLOOK_GET_EVENT" || slug === "OUTLOOK_GET_CALENDAR_EVENT")+ return currentEvent;+ if (slug === "OUTLOOK_UPDATE_CALENDAR_EVENT") {+ expect(args).toEqual({+ event_id: "evt_1",+ attendees: [+ {+ type: "required",+ emailAddress: { address: "[email protected]", name: "Alice" },+ },+ {+ type: "required",+ emailAddress: { address: "[email protected]" },+ },+ ],+ });+ return { id: "evt_1", subject: "Project sync" };+ }+ if (slug === "OUTLOOK_CANCEL_EVENT") {+ expect(args).toEqual({ user_id: "me", event_id: "evt_1" });+ return {};+ }+ if (slug === "OUTLOOK_DELETE_CALENDAR_EVENT_FROM_SPECIFIC_CALENDAR") {+ expect(args).toEqual({ calendar_id: "cal_work", event_id: "evt_solo" });+ return {};+ }+ throw new Error(`Unexpected tool ${slug}`);+ });++ const created = await f.run([+ "outlook-calendar",+ "create",+ "Project sync",+ "--start",+ "2026-11-21T10:00:00+08:00",+ "--duration",+ "30",+ "--attendee",+ "[email protected]",+ "--teams",+ ]);+ expect(created.code).toBe(0);+ expect(created.result.result.event.meetingUrl).toBe(+ "https://teams.microsoft.com/l/meetup-join/demo",+ );++ const updated = await f.run([+ "outlook-calendar",+ "update",+ "evt_1",+ "--add-attendee",+ "[email protected]",+ "--remove-attendee",+ "[email protected]",+ ]);+ expect(updated.code).toBe(0);++ const canceledMeeting = await f.run([+ "outlook-calendar",+ "cancel",+ "evt_1",+ ]);+ expect(canceledMeeting.code).toBe(0);+ expect(executed).toContain("OUTLOOK_CANCEL_EVENT");++ currentEvent = {+ id: "evt_solo",+ isOrganizer: true,+ type: "singleInstance",+ attendees: [],+ };+ const canceledSolo = await f.run([+ "outlook-calendar",+ "cancel",+ "evt_solo",+ "--calendar",+ "cal_work",+ ]);+ expect(canceledSolo.code).toBe(0);+ expect(executed).toContain(+ "OUTLOOK_DELETE_CALENDAR_EVENT_FROM_SPECIFIC_CALENDAR",+ );++ currentEvent = {+ id: "evt_rec",+ isOrganizer: true,+ seriesMasterId: "master_1",+ type: "occurrence",+ };+ expect(+ (await f.run(["outlook-calendar", "update", "evt_rec", "--title", "New"]))+ .error.error.code,+ ).toBe("unsupported_combination");++ currentEvent = {+ id: "evt_other",+ isOrganizer: false,+ type: "singleInstance",+ };+ expect(+ (await f.run(["outlook-calendar", "cancel", "evt_other"])).error.error+ .code,+ ).toBe("forbidden");+ });+});diff --git a/apps/teamhub-cli/src/connector-calendar.ts b/apps/teamhub-cli/src/connector-calendar.tsindex 85dad759..91c3bc79 100644--- a/apps/teamhub-cli/src/connector-calendar.ts+++ b/apps/teamhub-cli/src/connector-calendar.ts@@ -505,7 +505,15 @@ export function commonFreeSlots(busy.push([Math.max(a, start), Math.min(b, end)]);}}- busy.sort((x, y) => x[0] - y[0]);+ return freeSlotsFromBusy(busy, start, end, minutes);+}+export function freeSlotsFromBusy(+ busy: readonly [number, number][],+ start: number,+ end: number,+ minutes: number,+): Json[] {+ const sorted = [...busy].sort((x, y) => x[0] - y[0]);const slots: Json[] = [];const add = (a: number, b: number) => {if (b - a >= minutes * 60000)@@ -516,15 +524,17 @@ export function commonFreeSlots(});};let position = start;- for (const [a, b] of busy) {+ for (const [a, b] of sorted) {if (a > position) add(position, a);position = Math.max(position, b);}add(position, end);return slots;}-const utc = (ms: number) => new Date(ms).toISOString().replace(".000Z", "Z");-function validDate(v: string): boolean {+export function utc(ms: number): string {+ return new Date(ms).toISOString().replace(".000Z", "Z");+}+export function validDate(v: string): boolean {const date = new Date(v + "T00:00:00Z");return (/^\d{4}-\d{2}-\d{2}$/u.test(v) &&@@ -532,7 +542,7 @@ function validDate(v: string): boolean {date.toISOString().slice(0, 10) === v);}-function timeWindow(from: unknown, to: unknown, days: number): Json {+export function timeWindow(from: unknown, to: unknown, days: number): Json {const start = rfc3339(from, "--from"),end = rfc3339(to, "--to");const duration = Date.parse(end) - Date.parse(start);@@ -540,14 +550,14 @@ function timeWindow(from: unknown, to: unknown, days: number): Json {usage(`The time window must be positive and no longer than ${days} days.`);return { from: start, to: end };}-function validateTimeZone(zone: string): void {+export function validateTimeZone(zone: string): void {try {new Intl.DateTimeFormat("en", { timeZone: zone }).format();} catch {usage("--timezone requires a valid IANA time zone.");}}-function dateInZone(instant: Date, zone: string): string {+export function dateInZone(instant: Date, zone: string): string {return new Intl.DateTimeFormat("en-CA", {timeZone: zone,year: "numeric",@@ -555,8 +565,12 @@ function dateInZone(instant: Date, zone: string): string {day: "2-digit",}).format(instant);}-function midnight(date: string, zone: string): string {- const target = Date.parse(date + "T00:00:00Z");+export function wallTimeToInstant(+ localIso: string,+ zone: string,+): number | undefined {+ const target = Date.parse(`${localIso}Z`);+ if (!Number.isFinite(target)) return undefined;let guess = target;const formatter = new Intl.DateTimeFormat("en-CA", {timeZone: zone,@@ -575,13 +589,19 @@ function midnight(date: string, zone: string): string {const wall = Date.parse(`${p.year}-${p.month}-${p.day}T${p.hour}:${p.minute}:${p.second}Z`,);- if (wall === target) return new Date(guess).toISOString();+ if (wall === target) return guess;guess += target - wall;}- throw new CliError(- "unsupported_combination",- "This local date has no representable midnight; use an explicit time window.",- );+ return undefined;+}+export function midnight(date: string, zone: string): string {+ const instant = wallTimeToInstant(`${date}T00:00:00`, zone);+ if (instant === undefined)+ throw new CliError(+ "unsupported_combination",+ "This local date has no representable midnight; use an explicit time window.",+ );+ return new Date(instant).toISOString();}async function executeCalendar(action: Action,diff --git a/apps/teamhub-cli/src/connector-outlook-calendar.test.ts b/apps/teamhub-cli/src/connector-outlook-calendar.test.tsnew file mode 100644index 00000000..b01bc269--- /dev/null+++ b/apps/teamhub-cli/src/connector-outlook-calendar.test.ts@@ -0,0 +1,226 @@+import { describe, expect, it } from "vitest";+import {+ decodeOutlookCalendar,+ decodeOutlookEvent,+ outlookBusyFromEvents,+ outlookBusyFromSchedule,+ outlookCalendarBindings,+ outlookCalendarCommandDefinitions,+ outlookDateTimeToRfc3339,+ resolveOutlookTimeZone,+ toOutlookNaiveUtc,+} from "./connector-outlook-calendar.js";++describe("connector-outlook-calendar helpers", () => {+ it("resolves Windows and IANA timezones", () => {+ expect(resolveOutlookTimeZone("China Standard Time")).toBe("Asia/Shanghai");+ expect(resolveOutlookTimeZone("Pacific Standard Time")).toBe(+ "America/Los_Angeles",+ );+ expect(resolveOutlookTimeZone("UTC")).toBe("UTC");+ expect(resolveOutlookTimeZone("America/New_York")).toBe("America/New_York");+ expect(() => resolveOutlookTimeZone("Not A Real Zone")).toThrow(+ /Unsupported Outlook time zone/,+ );+ });++ it("converts RFC3339 timestamps to naive UTC for Outlook write schemas", () => {+ expect(toOutlookNaiveUtc("2026-11-21T10:30:00+08:00")).toBe(+ "2026-11-21T02:30:00",+ );+ expect(toOutlookNaiveUtc("2026-11-21T10:30:00Z")).toBe(+ "2026-11-21T10:30:00",+ );+ });++ it("normalizes Microsoft Graph naive dateTimeTimeZone into RFC3339", () => {+ expect(+ outlookDateTimeToRfc3339("2026-11-21T02:30:00.0000000", "UTC"),+ ).toEqual({+ dateTime: "2026-11-21T02:30:00Z",+ timeZone: "UTC",+ });+ expect(+ outlookDateTimeToRfc3339(+ "2026-11-21T10:30:00.0000000",+ "China Standard Time",+ ),+ ).toEqual({+ dateTime: "2026-11-21T10:30:00+08:00",+ timeZone: "Asia/Shanghai",+ });+ expect(() =>+ outlookDateTimeToRfc3339("2026-03-08T02:30:00", "America/New_York"),+ ).toThrow(/non-existent local date-time/);+ });++ it("decodes Outlook calendar and event payloads into canonical schema", () => {+ expect(+ decodeOutlookCalendar({+ id: "cal_1",+ name: "Calendar",+ canEdit: true,+ isDefaultCalendar: true,+ }),+ ).toEqual({+ calendarId: "cal_1",+ name: "Calendar",+ accessRole: "writer",+ primary: true,+ });++ expect(+ decodeOutlookEvent(+ {+ id: "evt_1",+ subject: "Weekly sync",+ body: { contentType: "text", content: "Agenda items" },+ location: { displayName: "Room 3B" },+ showAs: "busy",+ isCancelled: false,+ isAllDay: false,+ start: { dateTime: "2026-11-21T02:00:00.0000000", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T02:30:00.0000000", timeZone: "UTC" },+ organizer: {+ emailAddress: { name: "Owner", address: "[email protected]" },+ },+ webLink: "https://outlook.office365.com/calendar/item/evt_1",+ onlineMeeting: {+ joinUrl: "https://teams.microsoft.com/l/meetup-join/example",+ },+ attendees: [+ {+ type: "required",+ status: { response: "accepted" },+ emailAddress: { name: "Alice", address: "[email protected]" },+ },+ ],+ },+ "primary",+ ),+ ).toEqual({+ eventId: "evt_1",+ calendarId: "primary",+ title: "Weekly sync",+ description: "Agenda items",+ location: "Room 3B",+ status: "busy",+ start: { dateTime: "2026-11-21T02:00:00Z", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T02:30:00Z", timeZone: "UTC" },+ organizerEmail: "[email protected]",+ url: "https://outlook.office365.com/calendar/item/evt_1",+ meetingUrl: "https://teams.microsoft.com/l/meetup-join/example",+ attendees: [{ email: "[email protected]", responseStatus: "accepted" }],+ });+ });++ it("extracts busy intervals from calendar view and fails closed on incomplete schedules", () => {+ const start = Date.parse("2026-11-21T09:00:00Z");+ const end = Date.parse("2026-11-21T12:00:00Z");+ expect(+ outlookBusyFromEvents(+ [+ {+ isCancelled: false,+ showAs: "busy",+ start: { dateTime: "2026-11-21T10:00:00", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T11:00:00", timeZone: "UTC" },+ },+ {+ isCancelled: false,+ showAs: "free",+ start: { dateTime: "2026-11-21T09:00:00", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T09:30:00", timeZone: "UTC" },+ },+ {+ isCancelled: true,+ showAs: "busy",+ start: { dateTime: "2026-11-21T11:00:00", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T11:30:00", timeZone: "UTC" },+ },+ ],+ start,+ end,+ ),+ ).toEqual([+ [Date.parse("2026-11-21T10:00:00Z"), Date.parse("2026-11-21T11:00:00Z")],+ ]);++ expect(+ outlookBusyFromSchedule(+ {+ value: [+ {+ scheduleId: "[email protected]",+ scheduleItems: [+ {+ status: "busy",+ start: { dateTime: "2026-11-21T09:30:00", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T10:00:00", timeZone: "UTC" },+ },+ {+ status: "free",+ start: { dateTime: "2026-11-21T10:00:00", timeZone: "UTC" },+ end: { dateTime: "2026-11-21T10:30:00", timeZone: "UTC" },+ },+ ],+ },+ ],+ },+ ["[email protected]"],+ start,+ end,+ ),+ ).toEqual([+ [Date.parse("2026-11-21T09:30:00Z"), Date.parse("2026-11-21T10:00:00Z")],+ ]);++ expect(() =>+ outlookBusyFromSchedule(+ {+ value: [+ {+ scheduleId: "[email protected]",+ error: { message: "No access" },+ scheduleItems: [],+ },+ ],+ },+ ["[email protected]"],+ start,+ end,+ ),+ ).toThrow(/availability is unknown/);+ });++ it("defines all 7 subcommands and exact bindings", () => {+ expect(+ outlookCalendarCommandDefinitions.map((d) => d.command.join(" ")),+ ).toEqual([+ "outlook-calendar calendars",+ "outlook-calendar list",+ "outlook-calendar read",+ "outlook-calendar free",+ "outlook-calendar create",+ "outlook-calendar update",+ "outlook-calendar cancel",+ ]);+ expect(outlookCalendarBindings("list", { date: "today" })).toEqual([+ "OUTLOOK_GET_CALENDAR_VIEW",+ "OUTLOOK_GET_MAILBOX_SETTINGS",+ ]);+ expect(+ outlookCalendarBindings("list", {+ from: "2026-11-21T00:00:00Z",+ to: "2026-11-22T00:00:00Z",+ query: "sync",+ }),+ ).toEqual(["OUTLOOK_LIST_EVENTS"]);+ expect(+ outlookCalendarBindings("update", { calendarId: "cal_secondary" }),+ ).toEqual([+ "OUTLOOK_GET_CALENDAR_EVENT",+ "OUTLOOK_UPDATE_CALENDAR_EVENT_IN_CALENDAR",+ ]);+ });+});diff --git a/apps/teamhub-cli/src/connector-outlook-calendar.ts b/apps/teamhub-cli/src/connector-outlook-calendar.tsnew file mode 100644index 00000000..c0343ff3--- /dev/null+++ b/apps/teamhub-cli/src/connector-outlook-calendar.ts@@ -0,0 +1,1390 @@+import type { CommandDefinition } from "./command-definition.js";+import {+ assertPositionals,+ bodySource,+ option,+ values,+} from "./command-input.js";+import {+ booleanSchema,+ email,+ number,+ pageInput,+ pageSchema,+ schema,+ stringSchema,+ text,+ usage,+} from "./connector-input.js";+import {+ connectorDefinition,+ cursor,+ nextCursor,+ optionalFields,+ record,+ requiredString,+ toggle,+ value,+ type ConnectorRuntime,+ type Json,+} from "./connector-runtime.js";+import { ConnectorError as CliError } from "./errors.js";+import {+ array,+ calendarWriteSchema,+ eventSchema,+ id,+ object,+ pageOutput,+ rootSchema,+ str,+} from "./connector-schemas.js";+import { displayText } from "./display-text.js";+import {+ dateInZone,+ freeSlotsFromBusy,+ midnight,+ rfc3339,+ timeWindow,+ utc,+ validateTimeZone,+ validDate,+ wallTimeToInstant,+} from "./connector-calendar.js";++const PRIMARY_CALENDAR = "primary";+const MAX_FREE_CALENDAR_PAGES = 50;++// Standard CLDR Windows-to-IANA timezone mapping for Microsoft Graph+// mailboxSettings.timeZone and event dateTimeTimeZone responses.+const WINDOWS_TO_IANA: Readonly<Record<string, string>> = {+ "Dateline Standard Time": "Etc/GMT+12",+ "UTC-11": "Etc/GMT+11",+ "Aleutian Standard Time": "America/Adak",+ "Hawaiian Standard Time": "Pacific/Honolulu",+ "Marquesas Standard Time": "Pacific/Marquesas",+ "Alaskan Standard Time": "America/Anchorage",+ "UTC-09": "Etc/GMT+9",+ "Pacific Standard Time (Mexico)": "America/Tijuana",+ "UTC-08": "Etc/GMT+8",+ "Pacific Standard Time": "America/Los_Angeles",+ "US Mountain Standard Time": "America/Phoenix",+ "Mountain Standard Time (Mexico)": "America/Mazatlan",+ "Mountain Standard Time": "America/Denver",+ "Yukon Standard Time": "America/Whitehorse",+ "Central America Standard Time": "America/Guatemala",+ "Central Standard Time": "America/Chicago",+ "Easter Island Standard Time": "Pacific/Easter",+ "Central Standard Time (Mexico)": "America/Mexico_City",+ "Canada Central Standard Time": "America/Regina",+ "SA Pacific Standard Time": "America/Bogota",+ "Eastern Standard Time (Mexico)": "America/Cancun",+ "Eastern Standard Time": "America/New_York",+ "Haiti Standard Time": "America/Port-au-Prince",+ "Cuba Standard Time": "America/Havana",+ "US Eastern Standard Time": "America/Indiana/Indianapolis",+ "Turks And Caicos Standard Time": "America/Grand_Turk",+ "Paraguay Standard Time": "America/Asuncion",+ "Atlantic Standard Time": "America/Halifax",+ "Venezuela Standard Time": "America/Caracas",+ "Central Brazilian Standard Time": "America/Cuiaba",+ "SA Western Standard Time": "America/La_Paz",+ "Pacific SA Standard Time": "America/Santiago",+ "Newfoundland Standard Time": "America/St_Johns",+ "Tocantins Standard Time": "America/Araguaina",+ "E. South America Standard Time": "America/Sao_Paulo",+ "SA Eastern Standard Time": "America/Cayenne",+ "Argentina Standard Time": "America/Argentina/Buenos_Aires",+ "Greenland Standard Time": "America/Nuuk",+ "Montevideo Standard Time": "America/Montevideo",+ "Magallanes Standard Time": "America/Punta_Arenas",+ "Saint Pierre Standard Time": "America/Miquelon",+ "Bahia Standard Time": "America/Bahia",+ "UTC-02": "Etc/GMT+2",+ "Azores Standard Time": "Atlantic/Azores",+ "Cape Verde Standard Time": "Atlantic/Cape_Verde",+ UTC: "UTC",+ "Coordinated Universal Time": "UTC",+ "GMT Standard Time": "Europe/London",+ "Greenwich Standard Time": "Atlantic/Reykjavik",+ "Sao Tome Standard Time": "Africa/Sao_Tome",+ "Morocco Standard Time": "Africa/Casablanca",+ "W. Europe Standard Time": "Europe/Berlin",+ "Central Europe Standard Time": "Europe/Budapest",+ "Romance Standard Time": "Europe/Paris",+ "Central European Standard Time": "Europe/Warsaw",+ "W. Central Africa Standard Time": "Africa/Lagos",+ "Jordan Standard Time": "Asia/Amman",+ "GTB Standard Time": "Europe/Bucharest",+ "Middle East Standard Time": "Asia/Beirut",+ "Egypt Standard Time": "Africa/Cairo",+ "E. Europe Standard Time": "Europe/Chisinau",+ "Syria Standard Time": "Asia/Damascus",+ "West Bank Standard Time": "Asia/Hebron",+ "South Africa Standard Time": "Africa/Johannesburg",+ "FLE Standard Time": "Europe/Kiev",+ "Israel Standard Time": "Asia/Jerusalem",+ "South Sudan Standard Time": "Africa/Juba",+ "Kaliningrad Standard Time": "Europe/Kaliningrad",+ "Sudan Standard Time": "Africa/Khartoum",+ "Libya Standard Time": "Africa/Tripoli",+ "Namibia Standard Time": "Africa/Windhoek",+ "Arabic Standard Time": "Asia/Baghdad",+ "Turkey Standard Time": "Europe/Istanbul",+ "Arab Standard Time": "Asia/Riyadh",+ "Belarus Standard Time": "Europe/Minsk",+ "Russian Standard Time": "Europe/Moscow",+ "E. Africa Standard Time": "Africa/Nairobi",+ "Iran Standard Time": "Asia/Tehran",+ "Arabian Standard Time": "Asia/Dubai",+ "Astrakhan Standard Time": "Europe/Astrakhan",+ "Azerbaijan Standard Time": "Asia/Baku",+ "Russia Time Zone 3": "Europe/Samara",+ "Mauritius Standard Time": "Indian/Mauritius",+ "Saratov Standard Time": "Europe/Saratov",+ "Georgian Standard Time": "Asia/Tbilisi",+ "Volgograd Standard Time": "Europe/Volgograd",+ "Caucasus Standard Time": "Asia/Yerevan",+ "Afghanistan Standard Time": "Asia/Kabul",+ "West Asia Standard Time": "Asia/Tashkent",+ "Ekaterinburg Standard Time": "Asia/Yekaterinburg",+ "Pakistan Standard Time": "Asia/Karachi",+ "Qyzylorda Standard Time": "Asia/Qyzylorda",+ "India Standard Time": "Asia/Kolkata",+ "Sri Lanka Standard Time": "Asia/Colombo",+ "Nepal Standard Time": "Asia/Kathmandu",+ "Central Asia Standard Time": "Asia/Almaty",+ "Bangladesh Standard Time": "Asia/Dhaka",+ "Omsk Standard Time": "Asia/Omsk",+ "Myanmar Standard Time": "Asia/Yangon",+ "SE Asia Standard Time": "Asia/Bangkok",+ "Altai Standard Time": "Asia/Barnaul",+ "W. Mongolia Standard Time": "Asia/Hovd",+ "North Asia Standard Time": "Asia/Krasnoyarsk",+ "N. Central Asia Standard Time": "Asia/Novosibirsk",+ "Tomsk Standard Time": "Asia/Tomsk",+ "China Standard Time": "Asia/Shanghai",+ "North Asia East Standard Time": "Asia/Irkutsk",+ "Singapore Standard Time": "Asia/Singapore",+ "W. Australia Standard Time": "Australia/Perth",+ "Taipei Standard Time": "Asia/Taipei",+ "Ulaanbaatar Standard Time": "Asia/Ulaanbaatar",+ "Aus Central W. Standard Time": "Australia/Eucla",+ "Transbaikal Standard Time": "Asia/Chita",+ "Tokyo Standard Time": "Asia/Tokyo",+ "North Korea Standard Time": "Asia/Pyongyang",+ "Korea Standard Time": "Asia/Seoul",+ "Yakutsk Standard Time": "Asia/Yakutsk",+ "Cen. Australia Standard Time": "Australia/Adelaide",+ "AUS Central Standard Time": "Australia/Darwin",+ "E. Australia Standard Time": "Australia/Brisbane",+ "AUS Eastern Standard Time": "Australia/Sydney",+ "West Pacific Standard Time": "Pacific/Port_Moresby",+ "Tasmania Standard Time": "Australia/Hobart",+ "Vladivostok Standard Time": "Asia/Vladivostok",+ "Lord Howe Standard Time": "Australia/Lord_Howe",+ "Bougainville Standard Time": "Pacific/Bougainville",+ "Russia Time Zone 10": "Asia/Srednekolymsk",+ "Magadan Standard Time": "Asia/Magadan",+ "Norfolk Standard Time": "Pacific/Norfolk",+ "Sakhalin Standard Time": "Asia/Sakhalin",+ "Central Pacific Standard Time": "Pacific/Guadalcanal",+ "Russia Time Zone 11": "Asia/Kamchatka",+ "New Zealand Standard Time": "Pacific/Auckland",+ "UTC+12": "Etc/GMT-12",+ "Fiji Standard Time": "Pacific/Fiji",+ "Chatham Islands Standard Time": "Pacific/Chatham",+ "UTC+13": "Etc/GMT-13",+ "Tonga Standard Time": "Pacific/Tongatapu",+ "Samoa Standard Time": "Pacific/Apia",+ "Line Islands Standard Time": "Pacific/Kiritimati",+};++const pageOptions = {+ "--limit": value("1–100 items per page; default 20."),+ "--cursor": value(+ "Cursor from the previous page; keep the same account and filters.",+ ),+};+const calendarOption = { "--calendar": value("Calendar ID; default primary.") };+const bodyOptions = {+ "--content": value("Event description; exclusive with --file."),+ "--file": value("UTF-8 description file; - reads stdin."),+};+const options = {+ calendars: pageOptions,+ list: {+ ...calendarOption,+ ...pageOptions,+ "--date": value("today / tomorrow / YYYY-MM-DD; default today."),+ "--from": value("RFC3339 start time; use together with --to."),+ "--to": value("RFC3339 end time, exclusive of this instant."),+ "--timezone": value(+ "IANA time zone for date mode; default mailbox time zone.",+ ),+ "--query": value("Event subject keyword; at most 1000 characters."),+ },+ read: calendarOption,+ free: {+ "--from": value("RFC3339 start of the time window."),+ "--to": value("RFC3339 end of the time window; at most 31 days."),+ "--with": value(+ "Email of another person or room to check availability; repeatable.",+ true,+ ),+ "--calendar": value(+ "Calendar ID in this mailbox; repeatable; includes primary when omitted.",+ true,+ ),+ "--duration": value(+ "Minimum consecutive free minutes, 1–1440; default 30.",+ ),+ },+ create: {+ ...calendarOption,+ ...bodyOptions,+ "--start": value("RFC3339 start time."),+ "--end": value("RFC3339 end time; exclusive with --duration."),+ "--duration": value("Duration in minutes, 1–1440; default 30."),+ "--attendee": value("Attendee email; repeatable; at most 50.", true),+ "--location": value("Location; at most 1000 characters."),+ "--teams": toggle(+ "Request a Microsoft Teams meeting link (requires Microsoft 365 Teams).",+ ),+ },+ update: {+ ...calendarOption,+ ...bodyOptions,+ "--title": value("New title; at most 500 characters."),+ "--start": value("New start time; must be used with --end."),+ "--end": value("New end time; must be used with --start."),+ "--add-attendee": value("Add one email; repeatable.", true),+ "--remove-attendee": value(+ "Remove one email; repeatable; cannot remove the organizer.",+ true,+ ),+ "--location": value("New location."),+ },+ cancel: calendarOption,+};++type Action = keyof typeof options;++const descriptions: Record<Action, string> = {+ calendars: "List available Outlook calendars.",+ list: "List Outlook events for a day or a time window.",+ read: "Read Outlook event details and attendees.",+ free: "Find shared free time across Outlook calendars; query only, does not book.",+ create: "Create an Outlook meeting and notify attendees.",+ update: "Update a single Outlook meeting and notify attendees.",+ cancel: "Cancel an Outlook meeting as the organizer and notify attendees.",+};++export const outlookCalendarCommandDefinitions: CommandDefinition[] = (+ Object.keys(options) as Action[]+).map((action) =>+ connectorDefinition({+ command: ["outlook-calendar", action],+ app: () => "outlook",+ description: descriptions[action],+ readOnly: ["calendars", "list", "read", "free"].includes(action),+ options: options[action],+ usage:+ action === "free"+ ? [+ "teamhub outlook-calendar free --from <RFC3339> --to <RFC3339> [--with <email>] [--calendar <id>] [flags]",+ ]+ : action === "create"+ ? [+ "teamhub outlook-calendar create <title> --start <RFC3339> [--end <RFC3339> | --duration <minutes>] [flags]",+ ]+ : [+ `teamhub outlook-calendar ${action}${["read", "update", "cancel"].includes(action) ? " <event-id>" : ""} [flags]`,+ ],+ examples:+ action === "calendars"+ ? ["teamhub outlook-calendar calendars"]+ : action === "list"+ ? [+ "teamhub outlook-calendar list --date tomorrow --timezone America/New_York",+ ]+ : action === "free"+ ? [+ "teamhub outlook-calendar free --from 2026-10-19T09:00:00-04:00 --to 2026-10-19T18:00:00-04:00 --with [email protected]",+ ]+ : action === "create"+ ? [+ "teamhub outlook-calendar create 'Project sync' --start 2026-10-19T10:00:00-04:00 --duration 30 --attendee [email protected] --teams",+ ]+ : action === "update"+ ? [+ "teamhub outlook-calendar update event_example --title 'Project sync (rescheduled)' --add-attendee [email protected]",+ ]+ : action === "read"+ ? ["teamhub outlook-calendar read event_example"]+ : ["teamhub outlook-calendar cancel event_example"],+ inputSchema: outlookCalendarSchema(action),+ outputSchema:+ action === "calendars"+ ? rootSchema(+ {+ calendars: array(+ object(+ {+ calendarId: id,+ name: str,+ timeZone: str,+ accessRole: str,+ primary: { type: "boolean" },+ },+ ["calendarId"],+ ),+ ),+ ...pageOutput,+ },+ ["calendars", "hasMore"],+ )+ : action === "list"+ ? rootSchema({ events: array(eventSchema), ...pageOutput }, [+ "events",+ "hasMore",+ ])+ : action === "read"+ ? rootSchema({ event: eventSchema })+ : action === "free"+ ? rootSchema({+ calendarIds: array(id),+ window: object({+ from: { type: "string", format: "date-time" },+ to: { type: "string", format: "date-time" },+ }),+ durationMinutes: { type: "integer" },+ slots: array(+ object({+ start: { type: "string", format: "date-time" },+ end: { type: "string", format: "date-time" },+ durationMinutes: { type: "integer" },+ }),+ ),+ })+ : rootSchema({ result: calendarWriteSchema }),+ normalize: async (args, reader) => {+ const input: Json = {};+ assertPositionals(+ args,+ ["read", "update", "cancel", "create"].includes(action) ? 1 : 0,+ );+ if (["read", "update", "cancel"].includes(action))+ input.eventId = text(args.positionals[0], "event ID", 1024);+ if (action !== "calendars" && action !== "free")+ input.calendarId =+ option(args, "--calendar") === undefined+ ? PRIMARY_CALENDAR+ : text(option(args, "--calendar"), "--calendar", 1024);+ if (["calendars", "list"].includes(action))+ Object.assign(input, pageInput(args));+ if (action === "list") {+ const from = option(args, "--from"),+ to = option(args, "--to"),+ date = option(args, "--date"),+ zone = option(args, "--timezone");+ if ((from === undefined) !== (to === undefined))+ usage("Provide --from and --to together.");+ if (from !== undefined) {+ if (date !== undefined || zone !== undefined)+ usage(+ "A time window cannot be combined with --date or --timezone.",+ );+ Object.assign(input, timeWindow(from, to!, 366));+ } else {+ input.date = date ?? "today";+ if (+ !["today", "tomorrow"].includes(String(input.date)) &&+ !validDate(String(input.date))+ )+ usage(+ "--date requires today, tomorrow, or a valid YYYY-MM-DD date.",+ );+ if (zone !== undefined) {+ validateTimeZone(zone);+ input.timeZone = zone;+ }+ }+ if (option(args, "--query") !== undefined)+ input.query = text(option(args, "--query"), "--query", 1000);+ }+ if (action === "free") {+ Object.assign(+ input,+ timeWindow(option(args, "--from"), option(args, "--to"), 31),+ );+ input.durationMinutes = number(+ option(args, "--duration"),+ "--duration",+ 1,+ 1440,+ 30,+ );+ if (+ Number(input.durationMinutes) * 60000 >+ Date.parse(String(input.to)) - Date.parse(String(input.from))+ )+ usage("--duration exceeds the query window.");+ const explicit = values(args, "--calendar").map((x) =>+ text(x, "--calendar", 1024),+ );+ const calendarIds = [+ ...new Set(explicit.length ? explicit : [PRIMARY_CALENDAR]),+ ];+ const withEmails = [...new Set(values(args, "--with").map(email))];+ if (calendarIds.length + withEmails.length > 20)+ usage("At most 20 calendars may be queried.");+ input.calendarIds = calendarIds;+ if (withEmails.length) input.withEmails = withEmails;+ }+ if (action === "create" || action === "update") {+ const title =+ action === "create" ? args.positionals[0] : option(args, "--title");+ if (title !== undefined) input.title = text(title, "title", 500);+ const location = option(args, "--location");+ if (location !== undefined)+ input.location = text(location, "--location", 1000);+ const content = await bodySource(args, reader, false);+ if (content !== undefined) {+ if (Buffer.byteLength(content) > 1 << 20)+ usage("The description exceeds 1 MiB.");+ input.description = content;+ }+ const start = option(args, "--start"),+ end = option(args, "--end"),+ duration = option(args, "--duration");+ if (action === "create") {+ input.start = rfc3339(start, "--start");+ if (end !== undefined && duration !== undefined)+ usage("Choose --end or --duration.");+ input.end =+ end === undefined+ ? new Date(+ Date.parse(String(input.start)) ++ number(duration, "--duration", 1, 1440, 30)! * 60000,+ ).toISOString()+ : rfc3339(end, "--end");+ if (option(args, "--teams")) input.teams = true;+ } else if (start !== undefined || end !== undefined) {+ if (start === undefined || end === undefined)+ usage("Provide --start and --end together.");+ input.start = rfc3339(start, "--start");+ input.end = rfc3339(end, "--end");+ }+ if (+ input.start !== undefined &&+ Date.parse(String(input.end)) <= Date.parse(displayText(input.start))+ )+ usage("--end must be later than --start.");+ for (const [flag, key] of action === "create"+ ? [["--attendee", "attendees"]]+ : [+ ["--add-attendee", "addAttendees"],+ ["--remove-attendee", "removeAttendees"],+ ]) {+ const list = [...new Set(values(args, flag!).map(email))];+ if (list.length > 50) usage("At most 50 attendees are allowed.");+ if (list.length) input[key!] = list;+ }+ if (+ (input.addAttendees as string[] | undefined)?.some((x) =>+ (input.removeAttendees as string[] | undefined)?.includes(x),+ )+ )+ usage("The same attendee cannot be added and removed.");+ if (+ action === "update" &&+ ![+ "title",+ "location",+ "description",+ "start",+ "addAttendees",+ "removeAttendees",+ ].some((x) => input[x] !== undefined)+ )+ usage("Provide at least one event change.");+ }+ return { input };+ },+ bindings: (input) => outlookCalendarBindings(action, input),+ execute: async (input, runtime) => {+ const result = await executeOutlookCalendar(action, input, runtime);+ return ["create", "update", "cancel"].includes(action)+ ? { result }+ : result;+ },+ }),+);++export function outlookCalendarBindings(+ action: Action,+ input: Json,+): readonly string[] {+ const specific = !isDefaultCalendar(input.calendarId);+ if (action === "calendars") return ["OUTLOOK_LIST_CALENDARS"];+ if (action === "list")+ return [+ input.query !== undefined+ ? "OUTLOOK_LIST_EVENTS"+ : "OUTLOOK_GET_CALENDAR_VIEW",+ ...(input.date !== undefined && input.timeZone === undefined+ ? ["OUTLOOK_GET_MAILBOX_SETTINGS"]+ : []),+ ];+ if (action === "read")+ return [specific ? "OUTLOOK_GET_CALENDAR_EVENT" : "OUTLOOK_GET_EVENT"];+ if (action === "free") {+ const withEmails = (input.withEmails as string[] | undefined) ?? [];+ return [+ "OUTLOOK_GET_CALENDAR_VIEW",+ ...(withEmails.length ? ["OUTLOOK_GET_CALENDAR_SCHEDULE"] : []),+ ];+ }+ if (action === "create") return ["OUTLOOK_CALENDAR_CREATE_EVENT"];+ if (action === "update")+ return [+ specific ? "OUTLOOK_GET_CALENDAR_EVENT" : "OUTLOOK_GET_EVENT",+ specific+ ? "OUTLOOK_UPDATE_CALENDAR_EVENT_IN_CALENDAR"+ : "OUTLOOK_UPDATE_CALENDAR_EVENT",+ ];+ return [+ specific ? "OUTLOOK_GET_CALENDAR_EVENT" : "OUTLOOK_GET_EVENT",+ specific ? "OUTLOOK_CANCEL_CALENDAR_EVENT" : "OUTLOOK_CANCEL_EVENT",+ specific+ ? "OUTLOOK_DELETE_CALENDAR_EVENT_FROM_SPECIFIC_CALENDAR"+ : "OUTLOOK_DELETE_CALENDAR_EVENT",+ ];+}++function outlookCalendarSchema(action: Action): Json {+ const time = { type: "string", format: "date-time" };+ const list = {+ type: "array",+ items: { type: "string", format: "email" },+ maxItems: 50,+ };+ return schema(+ action === "calendars"+ ? pageSchema+ : action === "free"+ ? {+ from: time,+ to: time,+ calendarIds: {+ type: "array",+ items: stringSchema,+ minItems: 1,+ maxItems: 20,+ },+ withEmails: {+ type: "array",+ items: { type: "string", format: "email" },+ maxItems: 20,+ },+ durationMinutes: {+ type: "integer",+ minimum: 1,+ maximum: 1440,+ default: 30,+ },+ }+ : {+ calendarId: { ...stringSchema, default: PRIMARY_CALENDAR },+ ...(action === "list"+ ? {+ ...pageSchema,+ date: stringSchema,+ timeZone: stringSchema,+ from: time,+ to: time,+ query: stringSchema,+ }+ : action === "read" || action === "cancel"+ ? { eventId: stringSchema }+ : {+ eventId: stringSchema,+ title: stringSchema,+ start: time,+ end: time,+ description: { type: "string" },+ location: stringSchema,+ attendees: list,+ addAttendees: list,+ removeAttendees: list,+ teams: booleanSchema,+ }),+ },+ );+}++function isDefaultCalendar(calendarId: unknown): boolean {+ return calendarId === undefined || calendarId === PRIMARY_CALENDAR;+}++/**+ * Resolves an IANA or Windows timezone name from Microsoft Graph into a valid+ * IANA timezone identifier usable by Intl.DateTimeFormat.+ */+export function resolveOutlookTimeZone(raw: string): string {+ const trimmed = raw.trim();+ const candidate = WINDOWS_TO_IANA[trimmed] ?? trimmed;+ try {+ new Intl.DateTimeFormat("en", { timeZone: candidate }).format();+ return candidate;+ } catch {+ throw new CliError(+ "incomplete_response",+ `Unsupported Outlook time zone: ${trimmed}.`,+ );+ }+}++/**+ * Converts an RFC3339 timestamp to naive UTC YYYY-MM-DDTHH:MM:SS(.sss) as+ * required by OUTLOOK_CALENDAR_CREATE_EVENT and OUTLOOK_UPDATE_CALENDAR_EVENT.+ */+export function toOutlookNaiveUtc(rfc: string): string {+ return new Date(Date.parse(rfc))+ .toISOString()+ .replace(/\.000Z$/u, "")+ .replace(/Z$/u, "");+}++function formatOffset(minutes: number): string {+ if (minutes === 0) return "Z";+ const sign = minutes > 0 ? "+" : "-";+ const abs = Math.abs(minutes);+ const hh = String(Math.floor(abs / 60)).padStart(2, "0");+ const mm = String(abs % 60).padStart(2, "0");+ return `${sign}${hh}:${mm}`;+}++/**+ * Converts a Microsoft Graph dateTimeTimeZone object (whose dateTime typically+ * lacks a timezone suffix and may carry 7 fractional digits) into valid RFC3339.+ */+export function outlookDateTimeToRfc3339(+ dateTime: string,+ timeZone?: string,+): { dateTime: string; timeZone?: string } {+ const trimmed = dateTime.trim();+ const withOffset =+ /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d+))?(Z|[+-]\d{2}:\d{2})$/u.exec(+ trimmed,+ );+ if (withOffset) {+ const frac = withOffset[2]?.replace(/0+$/u, "") ?? "";+ const normalized = `${withOffset[1]}${frac ? `.${frac.slice(0, 3)}` : ""}${withOffset[3]}`;+ const resolvedZone =+ typeof timeZone === "string" && timeZone.trim()+ ? resolveOutlookTimeZone(timeZone)+ : undefined;+ return optionalFields({+ dateTime: normalized,+ timeZone: resolvedZone,+ }) as { dateTime: string; timeZone?: string };+ }+ const naive = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d+))?$/u.exec(+ trimmed,+ );+ if (!naive)+ throw new CliError(+ "incomplete_response",+ `Unrecognized Outlook date-time: ${trimmed}.`,+ );+ const base = naive[1]!;+ const frac = naive[2]?.replace(/0+$/u, "") ?? "";+ const cleanFrac = frac ? `.${frac.slice(0, 3)}` : "";+ const zone =+ typeof timeZone === "string" && timeZone.trim()+ ? resolveOutlookTimeZone(timeZone)+ : "UTC";+ if (zone === "UTC" || zone === "Etc/UTC") {+ return { dateTime: `${base}${cleanFrac}Z`, timeZone: "UTC" };+ }+ const instant = wallTimeToInstant(base, zone);+ if (instant === undefined)+ throw new CliError(+ "incomplete_response",+ `Outlook returned a non-existent local date-time in ${zone}: ${trimmed}.`,+ );+ const offsetMinutes = Math.round((Date.parse(`${base}Z`) - instant) / 60000);+ return {+ dateTime: `${base}${cleanFrac}${formatOffset(offsetMinutes)}`,+ timeZone: zone,+ };+}++function unwrapOutlookPayload(raw: Json): Json {+ if (+ raw.response_data &&+ typeof raw.response_data === "object" &&+ !Array.isArray(raw.response_data)+ )+ return raw.response_data as Json;+ if (raw.event && typeof raw.event === "object" && !Array.isArray(raw.event))+ return raw.event as Json;+ return raw;+}++function extractOutlookList(+ raw: Json,+ fallbackKey: string,+): {+ rows: unknown[];+ token: unknown;+} {+ const payload = unwrapOutlookPayload(raw);+ const rows =+ payload.value ?? payload[fallbackKey] ?? payload.items ?? raw.value;+ if (!Array.isArray(rows))+ throw new CliError(+ "incomplete_response",+ "The Outlook calendar page is incomplete.",+ );+ const token = raw.next_page_token ?? payload.next_page_token;+ if (!token && (payload["@odata.nextLink"] || raw["@odata.nextLink"]))+ throw new CliError(+ "incomplete_response",+ "The selected tool did not provide a usable continuation token.",+ );+ return { rows, token };+}++function parseOutlookTimeInstant(raw: unknown, label: string): number {+ const entry = record(raw, label);+ const dt = requiredString(entry.dateTime, `${label} dateTime`);+ const tz = typeof entry.timeZone === "string" ? entry.timeZone : undefined;+ const normalized = outlookDateTimeToRfc3339(dt, tz).dateTime;+ const ms = Date.parse(normalized);+ if (!Number.isFinite(ms))+ throw new CliError("incomplete_response", `Invalid ${label} timestamp.`);+ return ms;+}++/**+ * Extracts busy intervals from OUTLOOK_GET_CALENDAR_SCHEDULE for every+ * requested email address. Missing or errored schedules fail closed.+ */+export function outlookBusyFromSchedule(+ raw: Json,+ emails: readonly string[],+ start: number,+ end: number,+): [number, number][] {+ function unknown(): never {+ throw new CliError(+ "incomplete_response",+ "A requested schedule is missing, inaccessible, or incomplete; availability is unknown.",+ );+ }+ const payload = unwrapOutlookPayload(raw);+ const entries = payload.value ?? raw.value ?? payload.items;+ if (!Array.isArray(entries)) unknown();+ const byEmail = new Map<string, Json>();+ for (const item of entries) {+ const entry =+ item && typeof item === "object" && !Array.isArray(item)+ ? (item as Json)+ : unknown();+ if (typeof entry.scheduleId === "string" && entry.scheduleId.trim())+ byEmail.set(entry.scheduleId.trim().toLowerCase(), entry);+ }+ const busy: [number, number][] = [];+ for (const address of emails) {+ const entry = byEmail.get(address.toLowerCase());+ if (!entry) unknown();+ if (entry.error !== undefined && entry.error !== null) unknown();+ const scheduleItems = entry.scheduleItems;+ if (!Array.isArray(scheduleItems)) unknown();+ for (const item of scheduleItems) {+ const slot =+ item && typeof item === "object" && !Array.isArray(item)+ ? (item as Json)+ : unknown();+ const status =+ typeof slot.status === "string" ? slot.status.toLowerCase() : "";+ if (status === "free") continue;+ let a: number;+ let b: number;+ try {+ a = parseOutlookTimeInstant(slot.start, "schedule item start");+ b = parseOutlookTimeInstant(slot.end, "schedule item end");+ } catch {+ unknown();+ }+ if (b <= a) unknown();+ if (Math.min(b, end) > Math.max(a, start))+ busy.push([Math.max(a, start), Math.min(b, end)]);+ }+ }+ return busy;+}++/**+ * Extracts busy intervals from calendarView event objects. Cancelled events and+ * events marked showAs="free" do not block availability.+ */+export function outlookBusyFromEvents(+ events: readonly unknown[],+ start: number,+ end: number,+): [number, number][] {+ const busy: [number, number][] = [];+ for (const item of events) {+ const event = record(item, "calendar event");+ if (event.isCancelled === true) continue;+ const showAs =+ typeof event.showAs === "string" ? event.showAs.toLowerCase() : "busy";+ if (showAs === "free") continue;+ const a = parseOutlookTimeInstant(event.start, "event start");+ const b = parseOutlookTimeInstant(event.end, "event end");+ if (b <= a)+ throw new CliError(+ "incomplete_response",+ "An Outlook event has an invalid start/end range.",+ );+ if (Math.min(b, end) > Math.max(a, start))+ busy.push([Math.max(a, start), Math.min(b, end)]);+ }+ return busy;+}++async function readOutlookEvent(+ runtime: ConnectorRuntime,+ calendarId: string,+ eventId: unknown,+): Promise<Json> {+ const raw = isDefaultCalendar(calendarId)+ ? await runtime.call("OUTLOOK_GET_EVENT", {+ event_id: eventId,+ })+ : await runtime.call("OUTLOOK_GET_CALENDAR_EVENT", {+ calendar_id: calendarId,+ event_id: eventId,+ });+ return unwrapOutlookPayload(raw);+}++export async function executeOutlookCalendar(+ action: Action,+ input: Json,+ runtime: ConnectorRuntime,+): Promise<Json> {+ const calendarId = displayText(input.calendarId ?? PRIMARY_CALENDAR);++ if (action === "free") {+ const ownCalendars = input.calendarIds as string[];+ const withEmails = (input.withEmails as string[] | undefined) ?? [];+ const from = displayText(input.from);+ const to = displayText(input.to);+ const startMs = Date.parse(from);+ const endMs = Date.parse(to);+ const busy: [number, number][] = [];++ for (const calId of ownCalendars) {+ let pageToken: unknown = undefined;+ for (let page = 0; page < MAX_FREE_CALENDAR_PAGES; page++) {+ const raw = await runtime.call(+ "OUTLOOK_GET_CALENDAR_VIEW",+ optionalFields({+ calendar_id: isDefaultCalendar(calId) ? undefined : calId,+ start_datetime: from,+ end_datetime: to,+ top: 250,+ timezone: "UTC",+ page_token: pageToken,+ }),+ );+ const { rows, token } = extractOutlookList(raw, "events");+ busy.push(...outlookBusyFromEvents(rows, startMs, endMs));+ if (!token) break;+ if (page === MAX_FREE_CALENDAR_PAGES - 1)+ throw new CliError(+ "incomplete_response",+ "Calendar availability exceeded the page limit; shorten the query window.",+ );+ pageToken = token;+ }+ }++ if (withEmails.length) {+ const raw = await runtime.call("OUTLOOK_GET_CALENDAR_SCHEDULE", {+ schedules: withEmails,+ start_time: { dateTime: toOutlookNaiveUtc(from), timeZone: "UTC" },+ end_time: { dateTime: toOutlookNaiveUtc(to), timeZone: "UTC" },+ availability_view_interval: 30,+ });+ busy.push(...outlookBusyFromSchedule(raw, withEmails, startMs, endMs));+ }++ return {+ calendarIds: [...ownCalendars, ...withEmails],+ window: { from, to },+ durationMinutes: input.durationMinutes,+ slots: freeSlotsFromBusy(+ busy,+ startMs,+ endMs,+ Number(input.durationMinutes),+ ),+ };+ }++ if (action === "calendars") {+ const fingerprint = {+ account: runtime.account.connection_id,+ action,+ limit: input.limit,+ };+ const state = cursor(input.cursor, fingerprint);+ const raw = await runtime.call(+ "OUTLOOK_LIST_CALENDARS",+ optionalFields({+ top: input.limit,+ page_token: state.token,+ }),+ );+ const { rows, token } = extractOutlookList(raw, "calendars");+ return {+ calendars: rows.map((x) => decodeOutlookCalendar(record(x))),+ hasMore: Boolean(token),+ ...(token+ ? { nextCursor: nextCursor(optionalFields({ token }), fingerprint) }+ : {}),+ };+ }++ if (action === "list") {+ const fingerprint = {+ account: runtime.account.connection_id,+ action,+ calendarId,+ limit: input.limit,+ query: input.query ?? "",+ date: input.date ?? "",+ timeZone: input.timeZone ?? "",+ from: input.from ?? "",+ to: input.to ?? "",+ };+ const state = cursor(input.cursor, fingerprint);+ let from = input.from ?? state.from;+ let to = input.to ?? state.to;+ let zone =+ typeof state.zone === "string"+ ? state.zone+ : typeof input.timeZone === "string"+ ? input.timeZone+ : undefined;++ if (input.date && from === undefined) {+ if (zone === undefined) {+ const settingsRaw = await runtime.call("OUTLOOK_GET_MAILBOX_SETTINGS", {+ select: ["timeZone"],+ });+ const settings = unwrapOutlookPayload(settingsRaw);+ const mailboxZone = requiredString(+ settings.timeZone,+ "mailbox time zone",+ );+ zone = resolveOutlookTimeZone(mailboxZone);+ } else {+ validateTimeZone(zone);+ }+ let date = ["today", "tomorrow"].includes(displayText(input.date))+ ? dateInZone(new Date(), zone)+ : displayText(input.date);+ if (input.date === "tomorrow")+ date = new Date(Date.parse(date + "T12:00:00Z") + 86400000)+ .toISOString()+ .slice(0, 10);+ const next = new Date(Date.parse(date + "T12:00:00Z") + 86400000)+ .toISOString()+ .slice(0, 10);+ from = midnight(date, zone);+ to = midnight(next, zone);+ }++ const fromStr = displayText(from);+ const toStr = displayText(to);+ const responseZone = zone ?? "UTC";++ const raw =+ input.query !== undefined+ ? await runtime.call(+ "OUTLOOK_LIST_EVENTS",+ optionalFields({+ calendar_id: isDefaultCalendar(calendarId)+ ? undefined+ : calendarId,+ top: input.limit,+ page_token: state.token,+ expand_recurring_events: true,+ filter: `start/dateTime lt '${utc(Date.parse(toStr))}' and end/dateTime gt '${utc(Date.parse(fromStr))}' and contains(subject,'${displayText(input.query).replaceAll("'", "''")}') and isCancelled eq false`,+ orderby: ["start/dateTime asc"],+ timezone: responseZone,+ }),+ )+ : await runtime.call(+ "OUTLOOK_GET_CALENDAR_VIEW",+ optionalFields({+ calendar_id: isDefaultCalendar(calendarId)+ ? undefined+ : calendarId,+ start_datetime: fromStr,+ end_datetime: toStr,+ top: input.limit,+ page_token: state.token,+ orderby: "start/dateTime asc",+ timezone: responseZone,+ }),+ );++ const { rows, token } = extractOutlookList(raw, "events");+ return {+ events: rows.map((x) => decodeOutlookEvent(record(x), calendarId)),+ hasMore: Boolean(token),+ ...(token+ ? {+ nextCursor: nextCursor(+ optionalFields({ token, from: fromStr, to: toStr, zone }),+ fingerprint,+ ),+ }+ : {}),+ };+ }++ if (action === "read") {+ const current = await readOutlookEvent(runtime, calendarId, input.eventId);+ return { event: decodeOutlookEvent(current, calendarId) };+ }++ if (action === "create") {+ const attendees = input.attendees as string[] | undefined;+ const raw = await runtime.call(+ "OUTLOOK_CALENDAR_CREATE_EVENT",+ optionalFields({+ calendar_id: isDefaultCalendar(calendarId) ? undefined : calendarId,+ subject: input.title,+ start_datetime: toOutlookNaiveUtc(displayText(input.start)),+ end_datetime: toOutlookNaiveUtc(displayText(input.end)),+ time_zone: "UTC",+ body: input.description,+ is_html: input.description !== undefined ? false : undefined,+ location: input.location,+ attendees_info: attendees?.map((address) => ({+ email: address,+ type: "required",+ })),+ is_online_meeting: input.teams === true ? true : undefined,+ online_meeting_provider:+ input.teams === true ? "teamsForBusiness" : undefined,+ }),+ true,+ );+ const event = decodeOutlookEvent(raw, calendarId);+ if (input.teams && !event.meetingUrl)+ throw new CliError(+ "outcome_unknown",+ "The event exists, but its requested Teams link was not confirmed.",+ { event_id: event.eventId },+ );+ return { action: "created", acknowledged: true, event };+ }++ const current = await readOutlookEvent(runtime, calendarId, input.eventId);+ const eventType = typeof current.type === "string" ? current.type : undefined;+ if (+ current.recurrence ||+ current.seriesMasterId ||+ (eventType !== undefined && eventType !== "singleInstance")+ )+ throw new CliError(+ "unsupported_combination",+ "Recurring event writes are pending; select a single nonrecurring event.",+ { operation_rejected: true },+ );+ if (current.isOrganizer !== true)+ throw new CliError(+ "forbidden",+ "Only the event organizer can modify or cancel this meeting.",+ { operation_rejected: true },+ );++ if (action === "cancel") {+ const hasAttendees =+ Array.isArray(current.attendees) && current.attendees.length > 0;+ if (hasAttendees) {+ await runtime.call(+ isDefaultCalendar(calendarId)+ ? "OUTLOOK_CANCEL_EVENT"+ : "OUTLOOK_CANCEL_CALENDAR_EVENT",+ optionalFields({+ user_id: "me",+ calendar_id: isDefaultCalendar(calendarId) ? undefined : calendarId,+ event_id: input.eventId,+ }),+ true,+ );+ } else {+ await runtime.call(+ isDefaultCalendar(calendarId)+ ? "OUTLOOK_DELETE_CALENDAR_EVENT"+ : "OUTLOOK_DELETE_CALENDAR_EVENT_FROM_SPECIFIC_CALENDAR",+ optionalFields({+ calendar_id: isDefaultCalendar(calendarId) ? undefined : calendarId,+ event_id: input.eventId,+ }),+ true,+ );+ }+ return {+ action: "canceled",+ acknowledged: true,+ eventId: requiredString(current.id, "canceled event ID"),+ };+ }++ let mergedAttendees: Json[] | undefined;+ if (input.addAttendees || input.removeAttendees) {+ if (current.attendees !== undefined && !Array.isArray(current.attendees))+ throw new CliError(+ "incomplete_response",+ "The full attendee list is unavailable.",+ { operation_rejected: true },+ );+ const organizerEmail = extractEmailAddress(current.organizer);+ const remove = (input.removeAttendees ?? []) as string[];+ const add = (input.addAttendees ?? []) as string[];+ const same = (a: unknown, b: string) =>+ String(a).toLowerCase() === b.toLowerCase();+ if (organizerEmail && remove.some((x) => same(organizerEmail, x)))+ usage("The organizer cannot be removed.");+ const existing = ((current.attendees ?? []) as unknown[]).map((x) => {+ const entry = record(x, "existing attendee");+ const emailObj = record(entry.emailAddress, "attendee emailAddress");+ const address = requiredString(+ emailObj.address,+ "existing attendee email",+ );+ const name =+ typeof emailObj.name === "string" && emailObj.name.trim()+ ? emailObj.name+ : undefined;+ const type =+ typeof entry.type === "string" && entry.type.trim()+ ? entry.type+ : "required";+ return {+ type,+ emailAddress: optionalFields({ address, name }),+ };+ });+ const merged = existing.filter(+ (x) => !remove.some((a) => same(record(x.emailAddress).address, a)),+ );+ for (const address of add) {+ if (!merged.some((x) => same(record(x.emailAddress).address, address)))+ merged.push({+ type: "required",+ emailAddress: { address },+ });+ }+ if (merged.length > 50)+ usage("The resulting meeting exceeds 50 attendees.");+ mergedAttendees = merged;+ }++ const raw = await runtime.call(+ isDefaultCalendar(calendarId)+ ? "OUTLOOK_UPDATE_CALENDAR_EVENT"+ : "OUTLOOK_UPDATE_CALENDAR_EVENT_IN_CALENDAR",+ optionalFields({+ calendar_id: isDefaultCalendar(calendarId) ? undefined : calendarId,+ event_id: input.eventId,+ subject: input.title,+ location: input.location,+ body:+ input.description !== undefined+ ? { contentType: "Text", content: input.description }+ : undefined,+ start_datetime: input.start+ ? toOutlookNaiveUtc(displayText(input.start))+ : undefined,+ end_datetime: input.end+ ? toOutlookNaiveUtc(displayText(input.end))+ : undefined,+ time_zone: input.start ? "UTC" : undefined,+ attendees: mergedAttendees,+ }),+ true,+ );+ return {+ action: "updated",+ acknowledged: true,+ event: decodeOutlookEvent(raw, calendarId),+ };+}++function extractEmailAddress(container: unknown): string | undefined {+ if (!container || typeof container !== "object" || Array.isArray(container))+ return undefined;+ const obj = container as Json;+ if (+ obj.emailAddress &&+ typeof obj.emailAddress === "object" &&+ !Array.isArray(obj.emailAddress)+ ) {+ const addr = (obj.emailAddress as Json).address;+ if (typeof addr === "string" && addr.trim()) return addr;+ }+ if (typeof obj.address === "string" && obj.address.trim()) return obj.address;+ return undefined;+}++export function decodeOutlookCalendar(raw: Json): Json {+ const canEdit = raw.canEdit;+ const accessRole =+ canEdit === true ? "writer" : canEdit === false ? "reader" : undefined;+ return optionalFields({+ calendarId: requiredString(raw.id, "calendar ID"),+ name: typeof raw.name === "string" ? raw.name : undefined,+ timeZone: typeof raw.timeZone === "string" ? raw.timeZone : undefined,+ accessRole,+ primary:+ typeof raw.isDefaultCalendar === "boolean"+ ? raw.isDefaultCalendar+ : undefined,+ });+}++function decodeOutlookEventTime(+ raw: unknown,+ isAllDay: boolean,+): Json | undefined {+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return undefined;+ const entry = raw as Json;+ if (typeof entry.dateTime !== "string" || !entry.dateTime.trim())+ return undefined;+ if (+ isAllDay &&+ /^\d{4}-\d{2}-\d{2}T00:00:00(?:\.0+)?(?:Z)?$/u.test(entry.dateTime.trim())+ ) {+ return { date: entry.dateTime.trim().slice(0, 10) };+ }+ const timeZone =+ typeof entry.timeZone === "string" ? entry.timeZone : undefined;+ return outlookDateTimeToRfc3339(entry.dateTime, timeZone);+}++export function decodeOutlookEvent(raw: Json, calendarId: string): Json {+ const event = unwrapOutlookPayload(raw);+ const isAllDay = event.isAllDay === true;+ const body =+ event.body && typeof event.body === "object" && !Array.isArray(event.body)+ ? (event.body as Json)+ : undefined;+ const rawBodyContent =+ typeof body?.content === "string" && body.content.length > 0+ ? body.content+ : undefined;+ const isEmptyExchangeHtml =+ rawBodyContent !== undefined &&+ event.bodyPreview === "" &&+ typeof body?.contentType === "string" &&+ body.contentType.toLowerCase() === "html" &&+ rawBodyContent+ .replace(/<style[\s\S]*?<\/style>/giu, "")+ .replace(/<[^>]+>/gu, "")+ .replace(/ /giu, " ")+ .trim() === "";+ const bodyContent =+ rawBodyContent !== undefined && !isEmptyExchangeHtml+ ? rawBodyContent+ : typeof event.bodyPreview === "string" && event.bodyPreview.length > 0+ ? event.bodyPreview+ : undefined;+ const locationObj =+ event.location &&+ typeof event.location === "object" &&+ !Array.isArray(event.location)+ ? (event.location as Json)+ : undefined;+ const location =+ typeof locationObj?.displayName === "string" &&+ locationObj.displayName.length > 0+ ? locationObj.displayName+ : typeof event.location === "string" && event.location.length > 0+ ? event.location+ : undefined;+ const onlineMeeting =+ event.onlineMeeting &&+ typeof event.onlineMeeting === "object" &&+ !Array.isArray(event.onlineMeeting)+ ? (event.onlineMeeting as Json)+ : undefined;+ const meetingUrl =+ typeof onlineMeeting?.joinUrl === "string" && onlineMeeting.joinUrl.trim()+ ? onlineMeeting.joinUrl+ : typeof event.onlineMeetingUrl === "string" &&+ event.onlineMeetingUrl.trim()+ ? event.onlineMeetingUrl+ : undefined;+ const status =+ event.isCancelled === true+ ? "cancelled"+ : typeof event.showAs === "string" && event.showAs.trim()+ ? event.showAs+ : undefined;++ return optionalFields({+ eventId: requiredString(event.id, "event ID"),+ calendarId,+ title: typeof event.subject === "string" ? event.subject : undefined,+ description: bodyContent,+ location,+ status,+ start: decodeOutlookEventTime(event.start, isAllDay),+ end: decodeOutlookEventTime(event.end, isAllDay),+ organizerEmail: extractEmailAddress(event.organizer),+ url:+ typeof event.webLink === "string" && event.webLink.trim()+ ? event.webLink+ : undefined,+ meetingUrl,+ recurringEventId:+ typeof event.seriesMasterId === "string" && event.seriesMasterId.trim()+ ? event.seriesMasterId+ : undefined,+ attendees: Array.isArray(event.attendees)+ ? event.attendees+ .map((x) => {+ const a = record(x, "attendee");+ const address = extractEmailAddress(a);+ if (!address) return undefined;+ const statusObj =+ a.status &&+ typeof a.status === "object" &&+ !Array.isArray(a.status)+ ? (a.status as Json)+ : undefined;+ return optionalFields({+ email: address,+ responseStatus:+ typeof statusObj?.response === "string"+ ? statusObj.response+ : undefined,+ });+ })+ .filter((x): x is Json => x !== undefined)+ : undefined,+ });+}diff --git a/apps/teamhub-cli/src/connector-output.ts b/apps/teamhub-cli/src/connector-output.tsindex 52366b9a..6cfcfd18 100644--- a/apps/teamhub-cli/src/connector-output.ts+++ b/apps/teamhub-cli/src/connector-output.ts@@ -310,7 +310,7 @@ export function connectorOutputDescription(command: readonly string[]): string {archive: "The actual message ID and archive receipt.",} as Record<string, string>)[action]!;- if (app === "gcal")+ if (app === "gcal" || app === "outlook-calendar")return ({calendars:diff --git a/apps/teamhub-cli/src/domain-commands.ts b/apps/teamhub-cli/src/domain-commands.tsindex d8910329..d8fd771c 100644--- a/apps/teamhub-cli/src/domain-commands.ts+++ b/apps/teamhub-cli/src/domain-commands.ts@@ -22,6 +22,7 @@ import { businessCommandDefinitions } from "./business-commands.js";import { mailCommandDefinitions } from "./connector-mail.js";import { gmailCanvasCommandDefinitions } from "./connector-gmail-canvas.js";import { calendarCommandDefinitions } from "./connector-calendar.js";+import { outlookCalendarCommandDefinitions } from "./connector-outlook-calendar.js";import { webCommandDefinitions } from "./web-commands.js";import { publicBusinessSchemas } from "./business-schemas.js";import { CliError } from "./errors.js";@@ -40,6 +41,7 @@ export const commandDefinitions: readonly CommandDefinition[] = [...notionCommandDefinitions,...slackCommandDefinitions,...calendarCommandDefinitions,+ ...outlookCalendarCommandDefinitions,...webCommandDefinitions,];export interface DomainCommand {@@ -113,6 +115,7 @@ export function domainHelp(prefix: readonly string[] = []): string {["gmail","outlook",+ "outlook-calendar","slack","gcal","notion",diff --git a/apps/teamhub-cli/src/test-support/connector-tool-inputs.json b/apps/teamhub-cli/src/test-support/connector-tool-inputs.jsonindex 3a0a116f..b9712bdb 100644--- a/apps/teamhub-cli/src/test-support/connector-tool-inputs.json+++ b/apps/teamhub-cli/src/test-support/connector-tool-inputs.json@@ -1444,21 +1444,6 @@}}},- "GITHUB_GET_AN_ISSUE": {- "type": "object",- "required": ["owner", "repo", "issue_number"],- "properties": {- "repo": {- "type": "string"- },- "owner": {- "type": "string"- },- "issue_number": {- "type": "integer"- }- }- },"GITHUB_GET_A_PULL_REQUEST": {"type": "object","required": ["owner", "repo", "pull_number"],@@ -1503,6 +1488,21 @@}}},+ "GITHUB_GET_AN_ISSUE": {+ "type": "object",+ "required": ["owner", "repo", "issue_number"],+ "properties": {+ "repo": {+ "type": "string"+ },+ "owner": {+ "type": "string"+ },+ "issue_number": {+ "type": "integer"+ }+ }+ },"GITHUB_GET_THE_AUTHENTICATED_USER": {"type": "object","properties": {}@@ -3728,6 +3728,173 @@}}},+ "OUTLOOK_CALENDAR_CREATE_EVENT": {+ "type": "object",+ "required": ["subject", "start_datetime", "end_datetime", "time_zone"],+ "properties": {+ "body": {+ "type": "string",+ "default": ""+ },+ "is_html": {+ "type": "boolean",+ "default": false+ },+ "show_as": {+ "type": "string",+ "default": "busy"+ },+ "subject": {+ "type": "string"+ },+ "user_id": {+ "type": "string",+ "default": "me"+ },+ "location": {+ "type": "string",+ "default": ""+ },+ "time_zone": {+ "type": "string"+ },+ "categories": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "default": []+ },+ "importance": {+ "type": "string",+ "default": "normal"+ },+ "is_all_day": {+ "type": "boolean",+ "default": false+ },+ "recurrence": {+ "type": "object",+ "properties": {+ "range": {+ "type": "object",+ "required": ["type", "startDate"],+ "properties": {+ "type": {+ "type": "string"+ },+ "endDate": {+ "type": "string"+ },+ "startDate": {+ "type": "string"+ },+ "recurrenceTimeZone": {+ "type": "string"+ },+ "numberOfOccurrences": {+ "type": "integer"+ }+ },+ "additionalProperties": false+ },+ "pattern": {+ "type": "object",+ "required": ["type", "interval"],+ "properties": {+ "type": {+ "type": "string"+ },+ "index": {+ "type": "string"+ },+ "month": {+ "type": "integer"+ },+ "interval": {+ "type": "integer"+ },+ "dayOfMonth": {+ "type": "integer"+ },+ "daysOfWeek": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "firstDayOfWeek": {+ "type": "string"+ }+ },+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ },+ "calendar_id": {+ "type": "string"+ },+ "end_datetime": {+ "type": "string",+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d{1,7})?$"+ },+ "attendees_info": {+ "type": "array",+ "items": {+ "type": "object",+ "additionalProperties": {+ "type": "string"+ }+ },+ "default": []+ },+ "start_datetime": {+ "type": "string",+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d{1,7})?$"+ },+ "is_online_meeting": {+ "type": "boolean",+ "default": false+ },+ "online_meeting_provider": {+ "type": "string"+ }+ }+ },+ "OUTLOOK_CANCEL_CALENDAR_EVENT": {+ "type": "object",+ "required": ["user_id", "calendar_id", "event_id"],+ "properties": {+ "Comment": {+ "type": "string"+ },+ "user_id": {+ "type": "string"+ },+ "event_id": {+ "type": "string"+ },+ "calendar_id": {+ "type": "string"+ }+ }+ },+ "OUTLOOK_CANCEL_EVENT": {+ "type": "object",+ "required": ["user_id", "event_id"],+ "properties": {+ "Comment": {+ "type": "string"+ },+ "user_id": {+ "type": "string"+ },+ "event_id": {+ "type": "string"+ }+ }+ },"OUTLOOK_CREATE_ATTACHMENT_UPLOAD_SESSION": {"type": "object","required": ["message_id", "attachment_item"],@@ -3898,6 +4065,34 @@}}},+ "OUTLOOK_DELETE_CALENDAR_EVENT": {+ "type": "object",+ "required": ["event_id"],+ "properties": {+ "user_id": {+ "type": "string",+ "default": "me"+ },+ "event_id": {+ "type": "string"+ }+ }+ },+ "OUTLOOK_DELETE_CALENDAR_EVENT_FROM_SPECIFIC_CALENDAR": {+ "type": "object",+ "required": ["calendar_id", "event_id"],+ "properties": {+ "user_id": {+ "type": "string"+ },+ "event_id": {+ "type": "string"+ },+ "calendar_id": {+ "type": "string"+ }+ }+ },"OUTLOOK_DOWNLOAD_OUTLOOK_ATTACHMENT": {"type": "object","required": ["message_id", "attachment_id", "file_name"],@@ -3920,21 +4115,17 @@}}},- "OUTLOOK_GET_MESSAGE": {+ "OUTLOOK_GET_CALENDAR_EVENT": {"type": "object",- "required": ["message_id"],+ "required": ["calendar_id", "event_id"],"properties": {- "select": {- "type": "array",- "items": {- "type": "string"- }- },"user_id": {- "type": "string",- "default": "me"+ "type": "string"},- "message_id": {+ "event_id": {+ "type": "string"+ },+ "calendar_id": {"type": "string"},"include_sensitivity_label": {@@ -3943,49 +4134,311 @@}}},- "OUTLOOK_LIST_MESSAGES": {+ "OUTLOOK_GET_CALENDAR_SCHEDULE": {"type": "object",+ "required": ["schedules", "start_time", "end_time"],"properties": {- "top": {- "type": "integer",- "default": 10- },- "skip": {- "type": "integer",- "default": 0- },- "filter": {+ "user_id": {"type": "string"},- "folder": {- "type": "string",- "default": "inbox"- },- "search": {- "type": "string"+ "end_time": {+ "type": "object",+ "required": ["dateTime", "timeZone"],+ "properties": {+ "dateTime": {+ "type": "string"+ },+ "timeZone": {+ "type": "string"+ }+ },+ "additionalProperties": false},- "select": {+ "schedules": {"type": "array","items": {"type": "string"}},- "is_read": {- "type": "boolean"- },- "orderby": {- "type": "array",- "items": {- "type": "string"+ "start_time": {+ "type": "object",+ "required": ["dateTime", "timeZone"],+ "properties": {+ "dateTime": {+ "type": "string"+ },+ "timeZone": {+ "type": "string"+ }},- "default": ["receivedDateTime desc"]- },- "subject": {- "type": "string"- },- "user_id": {- "type": "string",- "default": "me"+ "additionalProperties": false+ },+ "availability_view_interval": {+ "type": "integer",+ "default": 30,+ "maximum": 1440,+ "minimum": 5+ }+ }+ },+ "OUTLOOK_GET_CALENDAR_VIEW": {+ "type": "object",+ "required": ["start_datetime", "end_datetime"],+ "properties": {+ "top": {+ "type": "integer",+ "default": 20,+ "maximum": 1000,+ "minimum": 1+ },+ "skip": {+ "type": "integer",+ "minimum": 0+ },+ "select": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "default": [+ "id",+ "subject",+ "start",+ "end",+ "location",+ "attendees",+ "organizer",+ "isAllDay",+ "isCancelled",+ "showAs",+ "onlineMeeting",+ "onlineMeetingProvider",+ "importance",+ "responseStatus",+ "isOnlineMeeting",+ "webLink",+ "bodyPreview",+ "recurrence",+ "categories",+ "sensitivity"+ ]+ },+ "orderby": {+ "type": "string"+ },+ "user_id": {+ "type": "string",+ "default": "me"+ },+ "timezone": {+ "type": "string",+ "default": "UTC"+ },+ "page_token": {+ "type": "string"+ },+ "calendar_id": {+ "type": "string"+ },+ "end_datetime": {+ "type": "string"+ },+ "start_datetime": {+ "type": "string"+ },+ "include_sensitivity_label": {+ "type": "boolean",+ "default": false+ }+ }+ },+ "OUTLOOK_GET_EVENT": {+ "type": "object",+ "required": ["event_id"],+ "properties": {+ "user_id": {+ "type": "string",+ "default": "me"+ },+ "event_id": {+ "type": "string"+ },+ "include_sensitivity_label": {+ "type": "boolean",+ "default": false+ }+ }+ },+ "OUTLOOK_GET_MAILBOX_SETTINGS": {+ "type": "object",+ "properties": {+ "select": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "user_id": {+ "type": "string",+ "default": "me"+ }+ }+ },+ "OUTLOOK_GET_MESSAGE": {+ "type": "object",+ "required": ["message_id"],+ "properties": {+ "select": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "user_id": {+ "type": "string",+ "default": "me"+ },+ "message_id": {+ "type": "string"+ },+ "include_sensitivity_label": {+ "type": "boolean",+ "default": false+ }+ }+ },+ "OUTLOOK_LIST_CALENDARS": {+ "type": "object",+ "properties": {+ "top": {+ "type": "integer",+ "minimum": 1+ },+ "skip": {+ "type": "integer",+ "minimum": 0+ },+ "filter": {+ "type": "string"+ },+ "select": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "orderby": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "user_id": {+ "type": "string",+ "default": "me"+ },+ "page_token": {+ "type": "string"+ }+ }+ },+ "OUTLOOK_LIST_EVENTS": {+ "type": "object",+ "properties": {+ "top": {+ "type": "integer",+ "default": 10,+ "maximum": 999,+ "minimum": 1+ },+ "skip": {+ "type": "integer",+ "default": 0,+ "minimum": 0+ },+ "filter": {+ "type": "string",+ "default": ""+ },+ "select": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "orderby": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "user_id": {+ "type": "string",+ "default": "me"+ },+ "timezone": {+ "type": "string",+ "default": "UTC"+ },+ "page_token": {+ "type": "string"+ },+ "calendar_id": {+ "type": "string"+ },+ "expand_recurring_events": {+ "type": "boolean",+ "default": false+ },+ "include_sensitivity_label": {+ "type": "boolean",+ "default": false+ }+ }+ },+ "OUTLOOK_LIST_MESSAGES": {+ "type": "object",+ "properties": {+ "top": {+ "type": "integer",+ "default": 10+ },+ "skip": {+ "type": "integer",+ "default": 0+ },+ "filter": {+ "type": "string"+ },+ "folder": {+ "type": "string",+ "default": "inbox"+ },+ "search": {+ "type": "string"+ },+ "select": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "is_read": {+ "type": "boolean"+ },+ "orderby": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "default": ["receivedDateTime desc"]+ },+ "subject": {+ "type": "string"+ },+ "user_id": {+ "type": "string",+ "default": "me"},"categories": {"type": "array",@@ -4229,6 +4682,316 @@}}},+ "OUTLOOK_UPDATE_CALENDAR_EVENT": {+ "type": "object",+ "required": ["event_id"],+ "properties": {+ "body": {+ "type": "object",+ "required": ["contentType", "content"],+ "properties": {+ "content": {+ "type": "string"+ },+ "contentType": {+ "type": "string"+ }+ },+ "additionalProperties": false+ },+ "show_as": {+ "type": "string"+ },+ "subject": {+ "type": "string"+ },+ "user_id": {+ "type": "string",+ "default": "me"+ },+ "event_id": {+ "type": "string"+ },+ "location": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "object",+ "additionalProperties": true+ }+ ]+ },+ "attendees": {+ "type": "array",+ "items": {+ "type": "object",+ "required": ["emailAddress", "type"],+ "properties": {+ "type": {+ "type": "string"+ },+ "emailAddress": {+ "type": "object",+ "required": ["address"],+ "properties": {+ "name": {+ "type": "string",+ "default": ""+ },+ "address": {+ "type": "string"+ }+ },+ "additionalProperties": false+ }+ }+ }+ },+ "time_zone": {+ "type": "string"+ },+ "categories": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "recurrence": {+ "type": "object",+ "properties": {+ "range": {+ "type": "object",+ "required": ["type", "startDate"],+ "properties": {+ "type": {+ "type": "string"+ },+ "endDate": {+ "type": "string"+ },+ "startDate": {+ "type": "string"+ },+ "recurrenceTimeZone": {+ "type": "string"+ },+ "numberOfOccurrences": {+ "type": "integer"+ }+ },+ "additionalProperties": false+ },+ "pattern": {+ "type": "object",+ "required": ["type", "interval"],+ "properties": {+ "type": {+ "type": "string"+ },+ "index": {+ "type": "string"+ },+ "month": {+ "type": "integer"+ },+ "interval": {+ "type": "integer"+ },+ "dayOfMonth": {+ "type": "integer"+ },+ "daysOfWeek": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "firstDayOfWeek": {+ "type": "string"+ }+ },+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ },+ "end_datetime": {+ "type": "string",+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d{1,7})?$"+ },+ "start_datetime": {+ "type": "string",+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d{1,7})?$"+ }+ }+ },+ "OUTLOOK_UPDATE_CALENDAR_EVENT_IN_CALENDAR": {+ "type": "object",+ "required": ["calendar_id", "event_id"],+ "properties": {+ "body": {+ "type": "object",+ "required": ["contentType", "content"],+ "properties": {+ "content": {+ "type": "string"+ },+ "contentType": {+ "type": "string"+ }+ },+ "additionalProperties": false+ },+ "show_as": {+ "type": "string"+ },+ "subject": {+ "type": "string"+ },+ "user_id": {+ "type": "string"+ },+ "event_id": {+ "type": "string"+ },+ "location": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "object",+ "additionalProperties": true+ }+ ]+ },+ "attendees": {+ "type": "array",+ "items": {+ "type": "object",+ "required": ["emailAddress", "type"],+ "properties": {+ "type": {+ "type": "string"+ },+ "emailAddress": {+ "type": "object",+ "required": ["address"],+ "properties": {+ "name": {+ "type": "string",+ "default": ""+ },+ "address": {+ "type": "string"+ }+ },+ "additionalProperties": false+ }+ }+ }+ },+ "time_zone": {+ "type": "string"+ },+ "categories": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "importance": {+ "type": "string"+ },+ "is_all_day": {+ "type": "boolean"+ },+ "recurrence": {+ "type": "object",+ "properties": {+ "range": {+ "type": "object",+ "required": ["type", "startDate"],+ "properties": {+ "type": {+ "type": "string"+ },+ "endDate": {+ "type": "string"+ },+ "startDate": {+ "type": "string"+ },+ "recurrenceTimeZone": {+ "type": "string"+ },+ "numberOfOccurrences": {+ "type": "integer"+ }+ },+ "additionalProperties": false+ },+ "pattern": {+ "type": "object",+ "required": ["type", "interval"],+ "properties": {+ "type": {+ "type": "string"+ },+ "index": {+ "type": "string"+ },+ "month": {+ "type": "integer"+ },+ "interval": {+ "type": "integer"+ },+ "dayOfMonth": {+ "type": "integer"+ },+ "daysOfWeek": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "firstDayOfWeek": {+ "type": "string"+ }+ },+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ },+ "calendar_id": {+ "type": "string"+ },+ "sensitivity": {+ "type": "string"+ },+ "end_datetime": {+ "type": "string",+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d{1,7})?$"+ },+ "is_reminder_on": {+ "type": "boolean"+ },+ "start_datetime": {+ "type": "string",+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d{1,7})?$"+ },+ "is_online_meeting": {+ "type": "boolean"+ },+ "reminder_minutes_before_start": {+ "type": "integer"+ }+ }+ },"OUTLOOK_UPDATE_EMAIL": {"type": "object","required": ["message_id"],diff --git a/apps/teamhub/internal/agentconnectedapps/access.go b/apps/teamhub/internal/agentconnectedapps/access.goindex ee85c57e..39b3a0b8 100644--- a/apps/teamhub/internal/agentconnectedapps/access.go+++ b/apps/teamhub/internal/agentconnectedapps/access.go@@ -144,7 +144,14 @@ var readTools = map[string]bool{"NOTION_RETRIEVE_PAGE": true,"NOTION_SEARCH_NOTION_PAGE": true,"OUTLOOK_DOWNLOAD_OUTLOOK_ATTACHMENT": true,+ "OUTLOOK_GET_CALENDAR_EVENT": true,+ "OUTLOOK_GET_CALENDAR_SCHEDULE": true,+ "OUTLOOK_GET_CALENDAR_VIEW": true,+ "OUTLOOK_GET_EVENT": true,+ "OUTLOOK_GET_MAILBOX_SETTINGS": true,"OUTLOOK_GET_MESSAGE": true,+ "OUTLOOK_LIST_CALENDARS": true,+ "OUTLOOK_LIST_EVENTS": true,"OUTLOOK_LIST_MESSAGES": true,"OUTLOOK_LIST_OUTLOOK_ATTACHMENTS": true,"OUTLOOK_QUERY_EMAILS": true,@@ -173,30 +180,37 @@ var readTools = map[string]bool{// permission reviewer ("judge" in the CLI's connectorWriteApproval), which// include paid media generation.var directWriteTools = map[string]bool{- "FAL_AI_SUBMIT_ASYNC_JOB": true,- "FAL_AI_UPLOAD_FILE": true,- "FIGMA_ADD_A_COMMENT_TO_A_FILE": true,- "GMAIL_BATCH_MODIFY_MESSAGES": true,- "GMAIL_CREATE_EMAIL_DRAFT": true,- "GMAIL_UPDATE_DRAFT": true,- "GOOGLECALENDAR_BATCH_EVENTS": true,- "GOOGLECALENDAR_CREATE_EVENT": true,- "GOOGLECALENDAR_DELETE_EVENT": true,- "GOOGLECALENDAR_PATCH_EVENT": true,- "GOOGLEDRIVE_CREATE_FOLDER": true,- "GOOGLEDRIVE_RESUMABLE_UPLOAD": true,- "HIGGSFIELD_MCP_GENERATE_IMAGE": true,- "HIGGSFIELD_MCP_GENERATE_VIDEO": true,- "HIGGSFIELD_MCP_MEDIA_CONFIRM": true,- "HIGGSFIELD_MCP_MEDIA_UPLOAD": true,- "OUTLOOK_ADD_MAIL_ATTACHMENT": true,- "OUTLOOK_CREATE_ATTACHMENT_UPLOAD_SESSION": true,- "OUTLOOK_CREATE_DRAFT": true,- "OUTLOOK_CREATE_DRAFT_REPLY": true,- "OUTLOOK_CREATE_REPLY_ALL_DRAFT": true,- "OUTLOOK_MOVE_MESSAGE": true,- "OUTLOOK_UPDATE_EMAIL": true,- "SLACK_ADD_REACTION_TO_AN_ITEM": true,- "SLACK_OPEN_DM": true,- "SLACK_REMOVE_REACTION_FROM_ITEM": true,+ "FAL_AI_SUBMIT_ASYNC_JOB": true,+ "FAL_AI_UPLOAD_FILE": true,+ "FIGMA_ADD_A_COMMENT_TO_A_FILE": true,+ "GMAIL_BATCH_MODIFY_MESSAGES": true,+ "GMAIL_CREATE_EMAIL_DRAFT": true,+ "GMAIL_UPDATE_DRAFT": true,+ "GOOGLECALENDAR_BATCH_EVENTS": true,+ "GOOGLECALENDAR_CREATE_EVENT": true,+ "GOOGLECALENDAR_DELETE_EVENT": true,+ "GOOGLECALENDAR_PATCH_EVENT": true,+ "GOOGLEDRIVE_CREATE_FOLDER": true,+ "GOOGLEDRIVE_RESUMABLE_UPLOAD": true,+ "HIGGSFIELD_MCP_GENERATE_IMAGE": true,+ "HIGGSFIELD_MCP_GENERATE_VIDEO": true,+ "HIGGSFIELD_MCP_MEDIA_CONFIRM": true,+ "HIGGSFIELD_MCP_MEDIA_UPLOAD": true,+ "OUTLOOK_ADD_MAIL_ATTACHMENT": true,+ "OUTLOOK_CALENDAR_CREATE_EVENT": true,+ "OUTLOOK_CANCEL_CALENDAR_EVENT": true,+ "OUTLOOK_CANCEL_EVENT": true,+ "OUTLOOK_CREATE_ATTACHMENT_UPLOAD_SESSION": true,+ "OUTLOOK_CREATE_DRAFT": true,+ "OUTLOOK_CREATE_DRAFT_REPLY": true,+ "OUTLOOK_CREATE_REPLY_ALL_DRAFT": true,+ "OUTLOOK_DELETE_CALENDAR_EVENT": true,+ "OUTLOOK_DELETE_CALENDAR_EVENT_FROM_SPECIFIC_CALENDAR": true,+ "OUTLOOK_MOVE_MESSAGE": true,+ "OUTLOOK_UPDATE_CALENDAR_EVENT": true,+ "OUTLOOK_UPDATE_CALENDAR_EVENT_IN_CALENDAR": true,+ "OUTLOOK_UPDATE_EMAIL": true,+ "SLACK_ADD_REACTION_TO_AN_ITEM": true,+ "SLACK_OPEN_DM": true,+ "SLACK_REMOVE_REACTION_FROM_ITEM": true,}diff --git a/apps/teamhub/internal/agentconnectedapps/access_test.go b/apps/teamhub/internal/agentconnectedapps/access_test.goindex 980467fc..ef97c65d 100644--- a/apps/teamhub/internal/agentconnectedapps/access_test.go+++ b/apps/teamhub/internal/agentconnectedapps/access_test.go@@ -239,6 +239,45 @@ func TestAccessRunsDiscordReadsAndHoldsDiscordSends(t *testing.T) {}}+func TestExecuteRunsOutlookCalendarReadsAndDirectWritesAtOnce(t *testing.T) {+ readSlugs := []string{+ "OUTLOOK_LIST_CALENDARS",+ "OUTLOOK_GET_MAILBOX_SETTINGS",+ "OUTLOOK_GET_CALENDAR_VIEW",+ "OUTLOOK_LIST_EVENTS",+ "OUTLOOK_GET_EVENT",+ "OUTLOOK_GET_CALENDAR_EVENT",+ "OUTLOOK_GET_CALENDAR_SCHEDULE",+ }+ for _, slug := range readSlugs {+ if accessOf(slug, nil) != accessRead {+ t.Errorf("%s must be classified as accessRead", slug)+ }+ provider, ran, err := executeForTest(t, slug, "outlook", map[string]any{})+ if err != nil || ran.Confirmation != nil || len(provider.executed) != 1 {+ t.Fatalf("%s: result=%+v err=%v executed=%v", slug, ran, err, provider.executed)+ }+ }+ writeSlugs := []string{+ "OUTLOOK_CALENDAR_CREATE_EVENT",+ "OUTLOOK_UPDATE_CALENDAR_EVENT",+ "OUTLOOK_UPDATE_CALENDAR_EVENT_IN_CALENDAR",+ "OUTLOOK_CANCEL_EVENT",+ "OUTLOOK_CANCEL_CALENDAR_EVENT",+ "OUTLOOK_DELETE_CALENDAR_EVENT",+ "OUTLOOK_DELETE_CALENDAR_EVENT_FROM_SPECIFIC_CALENDAR",+ }+ for _, slug := range writeSlugs {+ if accessOf(slug, nil) != accessWrite {+ t.Errorf("%s must be classified as accessWrite", slug)+ }+ provider, ran, err := executeForTest(t, slug, "outlook", map[string]any{})+ if err != nil || ran.Confirmation != nil || len(provider.executed) != 1 {+ t.Fatalf("%s: result=%+v err=%v executed=%v", slug, ran, err, provider.executed)+ }+ }+}+func TestExecuteRefusesAnUnknownCallTooLargeForItsCard(t *testing.T) {provider, held, err := executeForTest(t, "GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER", "github", map[string]any{"repo": strings.Repeat("x", maxCardInput)})var domain *Error