feat(sdk): Add Teams communication adapter#768
Conversation
eefd146 to
7c4791b
Compare
🛫 PR Readiness Check
|
| Status | Check | Details |
|---|---|---|
| ❌ | Single commit | 6 commits — consider squashing before review |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | Changeset file found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ❌ | Copilot threads resolved | 3 unresolved Copilot thread(s) — fix and resolve before merging |
| ❌ | CI passing | 13 check(s) still running |
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
|
Files in this PR:
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
7c4791b to
2217f2a
Compare
There was a problem hiding this comment.
Pull request overview
Adds a Microsoft Teams communication adapter to the SDK (Graph API-based) and wires it into the communication-adapter factory with lazy-loading and new config plumbing.
Changes:
- Introduces
TeamsCommunicationAdapter(Graph API auth + post + poll) and exports pure helper utilities with unit tests. - Updates the comms factory to lazy-load the Teams adapter and makes
createCommunicationAdapter()async. - Extends
CommunicationConfigwithadapterConfigand adds a changeset for an SDK minor release.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
packages/squad-sdk/src/platform/comms-teams.ts |
New Teams (Graph API) communication adapter + helper utilities + token storage/auth flows. |
packages/squad-sdk/src/platform/comms.ts |
Makes adapter factory async; adds lazy dynamic import for Teams adapter + config plumbing. |
packages/squad-sdk/src/platform/types.ts |
Adds CommunicationConfig.adapterConfig escape hatch for adapter-specific settings. |
test/comms-teams.test.ts |
Unit tests for Teams adapter pure helper functions (formatting/encoding/validation). |
.changeset/teams-comms-adapter.md |
Changeset documenting the new adapter and the async factory breaking change. |
Add Teams comms adapter with Graph API integration, PKCE auth flow, deep-link URL generation, and message card formatting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
89a28ea to
2113a4f
Compare
Add Teams comms adapter with Graph API integration, PKCE auth flow, deep-link URL generation, and message card formatting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2113a4f to
91200c9
Compare
Add Teams comms adapter with Graph API integration, PKCE auth flow, deep-link URL generation, and message card formatting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
91200c9 to
6816bf2
Compare
Add Teams comms adapter with Graph API integration, PKCE auth flow, deep-link URL generation, and message card formatting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
6816bf2 to
ee40621
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e8bf52b to
0004a38
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0004a38 to
a650e0e
Compare
🟡 Impact Analysis — PR #768Risk tier: 🟡 MEDIUM 📊 Summary
🎯 Risk Factors
📦 Modules Affecteddocs (1 file)
root (1 file)
squad-sdk (3 files)
tests (1 file)
This report is generated automatically for every PR. See #733 for details. |
| case 'file-log': | ||
| return new FileLogCommunicationAdapter(repoRoot); | ||
| default: | ||
| return new FileLogCommunicationAdapter(repoRoot); | ||
| } |
There was a problem hiding this comment.
createAdapterByChannel falls back to file-log for any unknown communications.channel. Because readCommsConfig() type-asserts JSON, a legacy config value like the previous teams-webhook will silently route to FileLog instead of surfacing a migration/error, effectively breaking existing Teams setups. Add runtime validation (and/or an explicit legacy mapping from teams-webhook → teams-graph) so misconfigurations are obvious.
| // Ensure permissions are correct even if file already existed | ||
| if (platform() === 'win32') { | ||
| execFile('icacls', [TOKEN_PATH, '/inheritance:r', '/grant:r', `${process.env.USERNAME ?? 'CURRENT_USER'}:(R,W)`], () => {}); | ||
| } else { |
There was a problem hiding this comment.
On Windows, saveTokens() shells out to icacls and ignores all errors (empty callback). If icacls fails (missing on PATH, permission issues, localized output, etc.), the token file may retain inherited ACLs and be more broadly readable than intended. Handle the callback error (or use execFileSync with try/catch) and surface a warning/error so the security guarantee is enforceable.
| function escapeHtml(s: string): string { | ||
| return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, '''); | ||
| } | ||
|
|
||
| function stripHtml(html: string): string { | ||
| return html.replace(/<[^>]+>/g, '').replace(/ /g, ' ').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').trim(); | ||
| } |
There was a problem hiding this comment.
escapeHtml() encodes single quotes as ', but stripHtml() doesn't decode ' (or '). This means messages posted by Squad may be returned via pollForReplies() with literal entity text instead of apostrophes. Update stripHtml() to decode these entities and add a unit test to lock it in.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a650e0e to
69ec9dd
Compare
tamirdresher
left a comment
There was a problem hiding this comment.
✅ LGTM — Well-structured Teams adapter: lazy import, 4-tier auth cascade, Graph ID validation, token security. BREAKING async change documented. Tests cover pure helpers.
Summary
Split from PR #765 — Teams communication adapter only, loop command extracted to PR #767.
Adds Microsoft Teams communication adapter for bidirectional chat via Microsoft Graph API.
Review findings addressed