@memberjunction/ai-bridge-server 0.0.1 → 5.41.0
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/README.md +120 -42
- package/dist/ai-bridge-engine.d.ts +505 -0
- package/dist/ai-bridge-engine.d.ts.map +1 -0
- package/dist/ai-bridge-engine.js +833 -0
- package/dist/ai-bridge-engine.js.map +1 -0
- package/dist/calendar-source.d.ts +142 -0
- package/dist/calendar-source.d.ts.map +1 -0
- package/dist/calendar-source.js +63 -0
- package/dist/calendar-source.js.map +1 -0
- package/dist/calendar-watcher.d.ts +174 -0
- package/dist/calendar-watcher.d.ts.map +1 -0
- package/dist/calendar-watcher.js +248 -0
- package/dist/calendar-watcher.js.map +1 -0
- package/dist/identity-provisioner.d.ts +109 -0
- package/dist/identity-provisioner.d.ts.map +1 -0
- package/dist/identity-provisioner.js +71 -0
- package/dist/identity-provisioner.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/join-url-resolver.d.ts +37 -0
- package/dist/join-url-resolver.d.ts.map +1 -0
- package/dist/join-url-resolver.js +102 -0
- package/dist/join-url-resolver.js.map +1 -0
- package/dist/loopback-bridge.d.ts +165 -0
- package/dist/loopback-bridge.d.ts.map +1 -0
- package/dist/loopback-bridge.js +255 -0
- package/dist/loopback-bridge.js.map +1 -0
- package/dist/multi-agent-room-coordinator.d.ts +198 -0
- package/dist/multi-agent-room-coordinator.d.ts.map +1 -0
- package/dist/multi-agent-room-coordinator.js +296 -0
- package/dist/multi-agent-room-coordinator.js.map +1 -0
- package/dist/scheduled-bridge-runner.d.ts +126 -0
- package/dist/scheduled-bridge-runner.d.ts.map +1 -0
- package/dist/scheduled-bridge-runner.js +140 -0
- package/dist/scheduled-bridge-runner.js.map +1 -0
- package/package.json +34 -7
package/README.md
CHANGED
|
@@ -1,45 +1,123 @@
|
|
|
1
1
|
# @memberjunction/ai-bridge-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Server-tier **coordination + execution** for MemberJunction Realtime Bridges. This package completes
|
|
4
|
+
the realtime engine's long-deferred **unified media-transport seam** — the pipe that connects a
|
|
5
|
+
bridge driver's media plane to a realtime agent session — and adds the bot-session lifecycle, host
|
|
6
|
+
affinity + janitor, participant tracking, and turn-taking integration around it.
|
|
7
|
+
|
|
8
|
+
It is the server half of the `AIBridgeEngineBase` / `AIBridgeEngine` pair, exactly mirroring how
|
|
9
|
+
`@memberjunction/aiengine`'s `AIEngine` builds on `@memberjunction/ai-engine-base`'s `AIEngineBase`.
|
|
10
|
+
The cross-platform, metadata-only base (provider/identity/channel cache, the abstract
|
|
11
|
+
`BaseRealtimeBridge` driver, `TurnTakingPolicy`, media-track types) lives in
|
|
12
|
+
[`@memberjunction/ai-bridge-base`](../BridgeBase); this package adds everything that actually *runs* a
|
|
13
|
+
bridged session.
|
|
14
|
+
|
|
15
|
+
> See the architecture plan at `/plans/realtime/realtime-bridges-architecture.md` (§1 transport seam,
|
|
16
|
+
> §2 layer cake, §7 lifecycle, §10 security/janitor) for the full design.
|
|
17
|
+
|
|
18
|
+
## What's in the box
|
|
19
|
+
|
|
20
|
+
| Export | Purpose |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `AIBridgeEngine` | The server engine. Extends `AIBridgeEngineBase`; starts/stops bridged sessions, **wires the transport seam**, tracks participants, integrates turn-taking, reconciles orphans. Singleton via `AIBridgeEngine.Instance`. |
|
|
23
|
+
| `LoopbackBridge` | An in-memory, platform-free bridge driver (`@RegisterClass(BaseRealtimeBridge, 'LoopbackBridge')`) that echoes outbound media back inbound — proves the seam round-trips with zero external infrastructure. |
|
|
24
|
+
| `StartBridgeSessionParams` / `ActiveBridgeSession` | The start contract + the live in-memory session handle. |
|
|
25
|
+
| `IHostInstanceIdentity` / `DefaultHostInstanceIdentity` | The injectable host-instance identity used for `HostInstanceID` stamping + janitor affinity (host apps inject the real one; a default is provided for standalone use). |
|
|
26
|
+
| `LoadLoopbackBridge` | Tree-shaking-prevention loader for the loopback driver. |
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @memberjunction/ai-bridge-server
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## The transport seam (the heart)
|
|
35
|
+
|
|
36
|
+
The realtime session contract (`IRealtimeSession` in `@memberjunction/ai`) is already
|
|
37
|
+
media-agnostic — `SendInput(chunk)` is what the agent hears, `OnOutput(handler)` is what it says —
|
|
38
|
+
but it had **no client-facing pipe**. A bridge *is* that pipe. `AIBridgeEngine.wireTransportSeam`
|
|
39
|
+
connects the two directions:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// Inbound: endpoint media → the agent hears it.
|
|
43
|
+
bridge.OnMedia((frame) => {
|
|
44
|
+
const chunk = frameToArrayBuffer(frame); // unwrap BridgeMediaFrame → ArrayBuffer
|
|
45
|
+
if (chunk) realtimeSession.SendInput(chunk);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Outbound: the agent speaks → into the meeting/call.
|
|
49
|
+
realtimeSession.OnOutput((chunk) => {
|
|
50
|
+
bridge.SendMedia('audio-out', arrayBufferToFrame(chunk, 'audio-out'));
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Audio is the first track lit up; video/screen ride the same two methods unchanged once the model
|
|
55
|
+
emits them. The engine never constructs the realtime model — the `IRealtimeSession` is **injected**
|
|
56
|
+
via `StartBridgeSessionParams.RealtimeSession`, so the only coupling is the seam itself.
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { AIBridgeEngine } from '@memberjunction/ai-bridge-server';
|
|
62
|
+
import { RegexAddressedMatcher } from '@memberjunction/ai-bridge-base';
|
|
63
|
+
|
|
64
|
+
const engine = AIBridgeEngine.Instance;
|
|
65
|
+
await engine.Config(false, contextUser, provider); // load the bridge registry (inherited from base)
|
|
66
|
+
|
|
67
|
+
// `realtimeSession` is an already-open IRealtimeSession from the agent/session layer.
|
|
68
|
+
const active = await engine.StartBridgeSession({
|
|
69
|
+
AgentSessionID: existingAgentSessionId,
|
|
70
|
+
Provider: zoomProviderRow, // MJAIBridgeProviderEntity (DriverClass resolves the driver)
|
|
71
|
+
RealtimeSession: realtimeSession, // injected — the engine wires its media plane
|
|
72
|
+
Address: 'https://zoom.us/j/123456789',
|
|
73
|
+
TurnMode: 'Passive',
|
|
74
|
+
TurnMatcher: new RegexAddressedMatcher(['Sage']),
|
|
75
|
+
ContextUser: contextUser,
|
|
76
|
+
MetadataProvider: provider,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// ...later, on hang-up / host-ended:
|
|
80
|
+
await engine.StopBridgeSession(active.SessionBridgeID, 'Explicit');
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Lifecycle
|
|
84
|
+
|
|
85
|
+
`StartBridgeSession` drives the `AIAgentSessionBridge` status state machine
|
|
86
|
+
`Pending → Connecting → Connected` (and `→ Failed` on any error), stamps `HostInstanceID` for node
|
|
87
|
+
affinity, resolves the driver via `ClassFactory.CreateInstance(BaseRealtimeBridge, provider.DriverClass)`,
|
|
88
|
+
then wires the transport seam + participant tracking + turn-taking. `StopBridgeSession` disconnects the
|
|
89
|
+
driver and transitions the row to `Disconnected` with a `CloseReason`. Both are idempotent.
|
|
90
|
+
|
|
91
|
+
### Host affinity & janitor
|
|
92
|
+
|
|
93
|
+
Every bridge row is stamped with `HostInstanceID`. `ReconcileOrphans(contextUser, provider)`
|
|
94
|
+
force-closes `Connected`/`Connecting` bridges left by a **prior boot of this host** (matching hostname
|
|
95
|
+
prefix, differing instance id) with `CloseReason = 'Janitor'` — mirroring `SessionJanitor`. The
|
|
96
|
+
*scheduling* (run-once-at-boot + periodic sweep) is a host-provided hook so this package carries no
|
|
97
|
+
timer/IO of its own; call `ReconcileOrphans` from the host's janitor.
|
|
98
|
+
|
|
99
|
+
### Turn-taking
|
|
100
|
+
|
|
101
|
+
A `TurnTakingPolicy` is built per session from `TurnMode` (`Passive` default / `Active` / `Hybrid`)
|
|
102
|
+
and fed the session's diarized **user** transcript segments. `Speak` requests a spoken update on the
|
|
103
|
+
session (when the provider supports `RequestSpokenUpdate`), `PostToChat` is a documented hook for the
|
|
104
|
+
Phase-2 bridge-chat channel, and `Silent` does nothing.
|
|
105
|
+
|
|
106
|
+
## Testing the seam without a platform
|
|
107
|
+
|
|
108
|
+
`LoopbackBridge` echoes every outbound frame back inbound, so with a mock `IRealtimeSession` you can
|
|
109
|
+
assert media flows **bridge → session** and **session → bridge** with no external service. See
|
|
110
|
+
`src/__tests__/transport-seam.test.ts` for the round-trip, lifecycle, turn-taking, participant, and
|
|
111
|
+
janitor tests.
|
|
112
|
+
|
|
113
|
+
## Composition with the realtime engine
|
|
4
114
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|
|
115
|
+
| Layer | Package | Role |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| Metadata cache + abstract driver + turn policy | `@memberjunction/ai-bridge-base` | provider/identity/channel cache, `BaseRealtimeBridge`, `TurnTakingPolicy`, media-track types |
|
|
118
|
+
| **Coordination + execution + transport seam** | **`@memberjunction/ai-bridge-server`** (this) | bot lifecycle, seam wiring, participant tracking, janitor |
|
|
119
|
+
| Realtime session contract | `@memberjunction/ai` | `IRealtimeSession` / `BaseRealtimeModel` (injected, never constructed here) |
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
ISC
|