@openclaw/teams-meetings 2026.8.1-beta.2 → 2026.8.1-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { MeetingPlatformAdapter } from "openclaw/plugin-sdk/meeting-runtime";
3
3
  import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
4
4
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  import { Type } from "typebox";
6
+ import { createMeetingLeaveSource, createMeetingTranscriptSource } from "openclaw/plugin-sdk/meeting-page-script-runtime";
6
7
  //#region extensions/teams-meetings/src/errors.ts
7
8
  var TeamsMeetingsInvalidRequestError = class extends Error {};
8
9
  function teamsMeetingsInvalidRequest(message) {
@@ -565,7 +566,6 @@ function isRecoverableTeamsMeetingTab(tab, url) {
565
566
  }
566
567
  //#endregion
567
568
  //#region extensions/teams-meetings/src/transports/teams-meetings-page-scripts.ts
568
- const TEAMS_MEETING_TRANSCRIPT_MAX_LINES = 500;
569
569
  function pageIdentityFunctionSource() {
570
570
  return `const meetingIdentity = (rawUrl) => {
571
571
  try {
@@ -651,158 +651,23 @@ function teamsMeetingStatusScript(params) {
651
651
  }) + teamsMeetingStatusCallSource();
652
652
  }
653
653
  function teamsMeetingTranscriptScript(meetingUrl, meetingSessionId, finalize) {
654
- const expectedIdentity = normalizeTeamsMeetingUrlForReuse(meetingUrl);
655
- return `() => {
656
- ${pageIdentityFunctionSource()}
657
- const expectedIdentity = ${JSON.stringify(expectedIdentity)};
658
- const expectedSessionId = ${JSON.stringify(meetingSessionId)};
659
- const currentIdentity = meetingIdentity(location.href);
660
- const state = window.__openclawTeamsMeeting;
661
- const activeCaptions = window.__openclawTeamsCaptions;
662
- const archivedCaptions = window.__openclawTeamsCaptionArchive?.[expectedSessionId];
663
- const captions = activeCaptions &&
664
- (!activeCaptions.sessionId || activeCaptions.sessionId === expectedSessionId)
665
- ? activeCaptions
666
- : archivedCaptions;
667
- // A same-session finalized buffer belongs to the departed call even if Teams
668
- // immediately navigated this tab into another meeting before transcript pickup.
669
- const useFinalizedCaptions = Boolean(
670
- captions?.finalized === true &&
671
- captions?.identity === expectedIdentity &&
672
- (!captions?.sessionId || captions.sessionId === expectedSessionId)
673
- );
674
- const effectiveIdentity = useFinalizedCaptions
675
- ? captions.identity
676
- : currentIdentity || state?.identity || captions?.identity;
677
- if (!expectedIdentity || effectiveIdentity !== expectedIdentity) {
678
- return JSON.stringify({ urlMatched: false, droppedLines: 0, lines: [] });
679
- }
680
- if (!useFinalizedCaptions && state?.sessionId && state.sessionId !== expectedSessionId) {
681
- return JSON.stringify({ urlMatched: true, sessionMatched: false, droppedLines: 0, lines: [] });
682
- }
683
- if (captions?.sessionId && captions.sessionId !== expectedSessionId) {
684
- return JSON.stringify({ urlMatched: true, sessionMatched: false, droppedLines: 0, lines: [] });
685
- }
686
- if (${JSON.stringify(finalize)} && Array.isArray(captions?.visible) && captions.visible.length > 0) {
687
- if (captions.settleTimer !== undefined) clearTimeout(captions.settleTimer);
688
- captions.settleTimer = undefined;
689
- captions.lines = Array.isArray(captions.lines) ? captions.lines : [];
690
- captions.lines.push(...captions.visible.map((entry) => ({
691
- at: entry.at,
692
- speaker: entry.speaker,
693
- text: entry.text,
694
- })));
695
- captions.visible = [];
696
- const excess = captions.lines.length - ${TEAMS_MEETING_TRANSCRIPT_MAX_LINES};
697
- if (excess > 0) {
698
- captions.lines.splice(0, excess);
699
- captions.droppedLines = (captions.droppedLines || 0) + excess;
700
- }
701
- }
702
- if (${JSON.stringify(finalize)} && captions) {
703
- if (captions.settleTimer !== undefined) clearTimeout(captions.settleTimer);
704
- captions.settleTimer = undefined;
705
- captions.observer?.disconnect?.();
706
- captions.observer = undefined;
707
- captions.observerInstalled = false;
708
- captions.identity = expectedIdentity;
709
- captions.finalized = true;
710
- captions.finalizedAt = Date.now();
711
- }
712
- const allLines = [
713
- ...(Array.isArray(captions?.lines) ? captions.lines : []),
714
- ...(${JSON.stringify(finalize)} || !Array.isArray(captions?.visible) ? [] : captions.visible),
715
- ];
716
- const visibleOverflow = Math.max(0, allLines.length - ${TEAMS_MEETING_TRANSCRIPT_MAX_LINES});
717
- const lines = allLines.slice(-${TEAMS_MEETING_TRANSCRIPT_MAX_LINES});
718
- const result = {
719
- urlMatched: true,
720
- sessionMatched: true,
721
- epoch: typeof captions?.epoch === "string" ? captions.epoch : undefined,
722
- droppedLines: (Number.isFinite(captions?.droppedLines)
723
- ? Math.max(0, Math.trunc(captions.droppedLines))
724
- : 0) + visibleOverflow,
725
- lines: lines.map((line) => ({
726
- at: typeof line?.at === "string" ? line.at : undefined,
727
- speaker: typeof line?.speaker === "string" ? line.speaker : undefined,
728
- text: typeof line?.text === "string" ? line.text : "",
729
- })).filter((line) => line.text),
730
- };
731
- return JSON.stringify(result);
732
- }`;
654
+ return createMeetingTranscriptSource({
655
+ expectedIdentity: normalizeTeamsMeetingUrlForReuse(meetingUrl),
656
+ finalize,
657
+ globals: {
658
+ captionArchive: "__openclawTeamsCaptionArchive",
659
+ captions: "__openclawTeamsCaptions",
660
+ meeting: "__openclawTeamsMeeting"
661
+ },
662
+ meetingSessionId,
663
+ pageIdentitySource: pageIdentityFunctionSource(),
664
+ platformDisplayName: "Teams"
665
+ });
733
666
  }
734
667
  function teamsMeetingLeaveScript(params) {
735
668
  const selectors = JSON.stringify(TEAMS_MEETING_SELECTORS);
736
- const expectedIdentity = normalizeTeamsMeetingUrlForReuse(params.meetingUrl);
737
- return `() => {
738
- ${pageIdentityFunctionSource()}
739
- const selectors = ${selectors};
740
- const expectedIdentity = ${JSON.stringify(expectedIdentity)};
741
- const expectedSessionId = ${JSON.stringify(params.meetingSessionId)};
742
- const leaveInitiated = ${JSON.stringify(params.leaveInitiated)};
743
- const currentIdentity = meetingIdentity(location.href);
744
- const state = window.__openclawTeamsMeeting;
745
- const enforceSessionOwnership = Boolean(expectedSessionId);
746
- if (enforceSessionOwnership && state?.sessionId && state.sessionId !== expectedSessionId) {
747
- return JSON.stringify({ departed: false, sessionConflict: true, sessionMatched: false, urlMatched: true });
748
- }
749
- const sessionMatched = !enforceSessionOwnership || state?.sessionId === expectedSessionId;
750
- const retainedLeaveOwnership = Boolean(!sessionMatched && leaveInitiated);
751
- if (!sessionMatched && !retainedLeaveOwnership) {
752
- return JSON.stringify({ departed: false, sessionMatched: false, urlMatched: true });
753
- }
754
- const retireOwnedAudioBridges = () => {
755
- const entries = Array.isArray(window.__openclawTeamsAudioOutputs)
756
- ? window.__openclawTeamsAudioOutputs
757
- : [];
758
- const retained = [];
759
- const activeSessionId = expectedSessionId || state?.sessionId;
760
- for (const entry of entries) {
761
- const ownedByActiveSession = Boolean(
762
- !entry?.sessionId || (activeSessionId && entry.sessionId === activeSessionId)
763
- );
764
- if (!ownedByActiveSession) {
765
- retained.push(entry);
766
- continue;
767
- }
768
- const mediaSourceUrl = (element) => String(element?.currentSrc || element?.src || "");
769
- const sources = Array.isArray(entry?.sources)
770
- ? entry.sources
771
- : entry?.source
772
- ? [{ element: entry.source, muted: Boolean(entry.sourceMuted), stream: entry.stream, url: entry.sourceUrl }]
773
- : [];
774
- for (const source of sources) {
775
- const element = source?.element;
776
- const sourceMatches = source?.stream || element?.srcObject
777
- ? element?.srcObject === source?.stream
778
- : Boolean(source?.url && mediaSourceUrl(element) === source.url);
779
- const sourceIsEmpty = Boolean(element && !element.srcObject && !mediaSourceUrl(element));
780
- if (!element) continue;
781
- if (sourceIsEmpty) {
782
- element.muted = true;
783
- continue;
784
- }
785
- if (!sourceMatches) continue;
786
- const detachedLiveSource = Boolean(
787
- element.isConnected === false &&
788
- element.srcObject?.getAudioTracks?.().some((track) => track.readyState === "live")
789
- );
790
- if (detachedLiveSource) {
791
- element.muted = true;
792
- element.pause?.();
793
- element.srcObject = null;
794
- } else {
795
- element.muted = Boolean(source.muted);
796
- }
797
- }
798
- entry?.bridge?.pause?.();
799
- if (entry?.bridge) entry.bridge.srcObject = null;
800
- entry?.bridge?.remove?.();
801
- }
802
- if (retained.length > 0) window.__openclawTeamsAudioOutputs = retained;
803
- else delete window.__openclawTeamsAudioOutputs;
804
- };
805
- const first = (list) => {
669
+ return createMeetingLeaveSource({
670
+ controlSource: `const first = (list) => {
806
671
  for (const selector of list) {
807
672
  const node = document.querySelector(selector);
808
673
  if (!node) continue;
@@ -813,72 +678,22 @@ function teamsMeetingLeaveScript(params) {
813
678
  const leave = first(selectors.leave);
814
679
  const confirmation = first(selectors.leaveConfirmation);
815
680
  const postCall = first(selectors.postCall);
816
- const currentUrlMatches = Boolean(expectedIdentity && currentIdentity === expectedIdentity);
817
- const preservedCallMatches = Boolean(
818
- expectedIdentity &&
819
- !currentIdentity &&
820
- state?.identity === expectedIdentity &&
821
- state?.inCallControl === leave &&
822
- state?.inCallUrl === location.href &&
823
- leave &&
824
- leave.isConnected !== false
825
- );
826
- const pendingLeaveMatches = Boolean(
827
- expectedIdentity &&
828
- state?.identity === expectedIdentity &&
829
- state?.leavePending === true &&
830
- state?.inCallUrl === location.href &&
831
- Date.now() - state?.leavePendingAt < 10_000
832
- );
833
- const rerenderPendingMatches = Boolean(
834
- expectedIdentity &&
835
- !currentIdentity &&
836
- state?.identity === expectedIdentity &&
837
- state?.inCallControl?.isConnected === false &&
838
- state?.inCallUrl === location.href &&
839
- Date.now() - state?.verifiedAt < 5_000 &&
840
- !leave
841
- );
842
- const meetingIdentityMatches = Boolean(
843
- currentUrlMatches || preservedCallMatches || pendingLeaveMatches || rerenderPendingMatches
844
- );
845
- // Teams can replace the document between our Leave click and its post-call marker.
846
- // Retain request ownership only while no identity or live-call control contradicts it.
847
- const initiatedLeaveTransitionMatches = Boolean(
848
- leaveInitiated &&
849
- !currentIdentity &&
850
- !leave &&
851
- (!state?.identity || state.identity === expectedIdentity)
852
- );
853
- if (postCall && (meetingIdentityMatches || initiatedLeaveTransitionMatches)) {
854
- retireOwnedAudioBridges();
855
- if (sessionMatched) delete window.__openclawTeamsMeeting;
856
- return JSON.stringify({ departed: true, sessionMatched: true, urlMatched: true });
857
- }
858
- if (!meetingIdentityMatches && !initiatedLeaveTransitionMatches) {
859
- return JSON.stringify({ departed: false, urlMatched: false });
860
- }
861
- if (!sessionMatched) {
862
- return JSON.stringify({ departed: false, urlMatched: true });
863
- }
864
- if (confirmation) {
865
- confirmation.click();
866
- return JSON.stringify({ departed: false, leaveAction: "confirm", urlMatched: true });
867
- }
868
- if (leave) {
869
- window.__openclawTeamsMeeting = {
870
- ...state,
871
- identity: expectedIdentity,
872
- inCallControl: leave,
873
- inCallUrl: location.href,
874
- leavePending: true,
875
- leavePendingAt: Date.now(),
876
- };
877
- leave.click();
878
- return JSON.stringify({ departed: false, leaveAction: "leave", urlMatched: true });
879
- }
880
- return JSON.stringify({ departed: false, urlMatched: true });
881
- }`;
681
+ const currentUrlMatches = Boolean(expectedIdentity && currentIdentity === expectedIdentity);`,
682
+ departedMarkerSource: "postCall",
683
+ expectedIdentity: normalizeTeamsMeetingUrlForReuse(params.meetingUrl),
684
+ leaveInitiated: params.leaveInitiated,
685
+ meetingSessionId: params.meetingSessionId,
686
+ pageIdentitySource: pageIdentityFunctionSource(),
687
+ platform: {
688
+ displayName: "Teams",
689
+ globals: {
690
+ audioOutputs: "__openclawTeamsAudioOutputs",
691
+ meeting: "__openclawTeamsMeeting"
692
+ }
693
+ },
694
+ selectors,
695
+ sessionMatchSource: "const sessionMatched = !enforceSessionOwnership || state?.sessionId === expectedSessionId;"
696
+ });
882
697
  }
883
698
  //#endregion
884
699
  //#region extensions/teams-meetings/src/transports/teams-meetings-platform-constants.ts
@@ -2,6 +2,13 @@
2
2
  "id": "teams-meetings",
3
3
  "name": "Microsoft Teams meetings",
4
4
  "description": "Join Microsoft Teams meetings as a Chrome browser guest.",
5
+ "cliCommands": [
6
+ {
7
+ "name": "teamsmeetings",
8
+ "description": "Join and manage Microsoft Teams meeting guests",
9
+ "hasSubcommands": true
10
+ }
11
+ ],
5
12
  "icon": "https://res.cdn.office.net/files/fabric-cdn-prod_20230815.001/assets/brand-icons/product/svg/teams_48x1.svg",
6
13
  "enabledByDefault": true,
7
14
  "commandAliases": [{ "name": "teamsmeetings" }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/teams-meetings",
3
- "version": "2026.8.1-beta.2",
3
+ "version": "2026.8.1-beta.3",
4
4
  "description": "OpenClaw Microsoft Teams browser meeting participant plugin.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,7 @@
11
11
  "typebox": "1.3.6"
12
12
  },
13
13
  "peerDependencies": {
14
- "openclaw": ">=2026.8.1-beta.2"
14
+ "openclaw": ">=2026.8.1-beta.3"
15
15
  },
16
16
  "peerDependenciesMeta": {
17
17
  "openclaw": {
@@ -29,10 +29,10 @@
29
29
  "minHostVersion": ">=2026.7.2"
30
30
  },
31
31
  "compat": {
32
- "pluginApi": ">=2026.8.1-beta.2"
32
+ "pluginApi": ">=2026.8.1-beta.3"
33
33
  },
34
34
  "build": {
35
- "openclawVersion": "2026.8.1-beta.2",
35
+ "openclawVersion": "2026.8.1-beta.3",
36
36
  "bundledDist": false
37
37
  },
38
38
  "release": {