@agentuity/core 1.0.1 → 1.0.2
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/AGENTS.md +75 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/_util.d.ts.map +1 -1
- package/dist/services/_util.js +8 -0
- package/dist/services/_util.js.map +1 -1
- package/dist/webrtc.d.ts +243 -0
- package/dist/webrtc.d.ts.map +1 -0
- package/dist/webrtc.js +5 -0
- package/dist/webrtc.js.map +1 -0
- package/package.json +2 -2
- package/src/env.d.ts +229 -0
- package/src/index.ts +19 -0
- package/src/services/_util.ts +9 -0
- package/src/webrtc.ts +259 -0
package/AGENTS.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Package Overview
|
|
4
4
|
|
|
5
|
-
Core utilities and shared types for the Agentuity framework. This package provides foundational types, schemas, and
|
|
5
|
+
Core utilities and shared types for the Agentuity framework. This package provides foundational types, schemas, error handling, and service interfaces used across all Agentuity packages.
|
|
6
6
|
|
|
7
7
|
## Commands
|
|
8
8
|
|
|
@@ -15,17 +15,85 @@ Core utilities and shared types for the Agentuity framework. This package provid
|
|
|
15
15
|
- **Runtime**: Browser and Node/Bun compatible, no runtime-specific code. Must work in all JavaScript environments
|
|
16
16
|
- **Build target**: ESNext with TypeScript declaration files
|
|
17
17
|
- **Exports**: All public APIs exported from `src/index.ts`
|
|
18
|
-
- **No dependencies**: This is a foundational package with zero runtime dependencies
|
|
18
|
+
- **No runtime dependencies**: This is a foundational package with zero runtime dependencies
|
|
19
19
|
|
|
20
20
|
## Structure
|
|
21
21
|
|
|
22
22
|
```text
|
|
23
23
|
src/
|
|
24
24
|
├── index.ts # Main entry point, exports all modules
|
|
25
|
-
├──
|
|
26
|
-
├──
|
|
27
|
-
├──
|
|
28
|
-
|
|
25
|
+
├── error.ts # RichError, StructuredError, isStructuredError
|
|
26
|
+
├── json.ts # safeStringify utility
|
|
27
|
+
├── logger.ts # Logger interface and LogLevel type
|
|
28
|
+
├── standard_schema.ts # StandardSchemaV1 interface
|
|
29
|
+
├── string.ts # toCamelCase, toPascalCase utilities
|
|
30
|
+
├── typehelper.ts # InferInput, InferOutput type utilities
|
|
31
|
+
├── workbench-config.ts # Workbench configuration encoding/decoding
|
|
32
|
+
└── services/
|
|
33
|
+
├── _util.ts # buildUrl, toServiceException, toPayload, fromResponse
|
|
34
|
+
├── adapter.ts # FetchAdapter, FetchRequest/Response types
|
|
35
|
+
├── exception.ts # ServiceException class
|
|
36
|
+
├── evalrun.ts # Eval run event types and schemas
|
|
37
|
+
├── keyvalue.ts # KeyValueStorage interface and KeyValueStorageService
|
|
38
|
+
├── queue.ts # QueueService interface and QueueStorageService
|
|
39
|
+
├── sandbox.ts # Sandbox and Snapshot service interfaces
|
|
40
|
+
├── session.ts # Session event types and schemas
|
|
41
|
+
├── stream.ts # StreamStorage interface and StreamStorageService
|
|
42
|
+
└── vector.ts # VectorStorage interface and VectorStorageService
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Key Exports
|
|
46
|
+
|
|
47
|
+
### Error Handling
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { RichError, StructuredError, isStructuredError } from '@agentuity/core';
|
|
51
|
+
|
|
52
|
+
// StructuredError - error with code and metadata
|
|
53
|
+
throw new StructuredError('NOT_FOUND', 'User not found', { userId: '123' });
|
|
54
|
+
|
|
55
|
+
// RichError - error with rich formatting
|
|
56
|
+
throw new RichError('Operation failed', { cause: originalError });
|
|
57
|
+
|
|
58
|
+
// Type guard
|
|
59
|
+
if (isStructuredError(error)) {
|
|
60
|
+
console.log(error.code, error.metadata);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Type Utilities
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import type { InferInput, InferOutput, StandardSchemaV1 } from '@agentuity/core';
|
|
68
|
+
|
|
69
|
+
// Infer schema input/output types (works with Zod, Valibot, ArkType, etc.)
|
|
70
|
+
type Input = InferInput<typeof mySchema>;
|
|
71
|
+
type Output = InferOutput<typeof mySchema>;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Service Interfaces
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import {
|
|
78
|
+
KeyValueStorageService,
|
|
79
|
+
VectorStorageService,
|
|
80
|
+
StreamStorageService,
|
|
81
|
+
QueueStorageService,
|
|
82
|
+
} from '@agentuity/core';
|
|
83
|
+
|
|
84
|
+
// All storage services follow the same pattern:
|
|
85
|
+
// - Interface defines the contract
|
|
86
|
+
// - *Service class provides default implementation with FetchAdapter
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### String Utilities
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { toCamelCase, toPascalCase, safeStringify } from '@agentuity/core';
|
|
93
|
+
|
|
94
|
+
toCamelCase('hello-world'); // 'helloWorld'
|
|
95
|
+
toPascalCase('hello-world'); // 'HelloWorld'
|
|
96
|
+
safeStringify(circularObject); // Safe JSON stringification
|
|
29
97
|
```
|
|
30
98
|
|
|
31
99
|
## Code Style
|
|
@@ -42,10 +110,10 @@ src/
|
|
|
42
110
|
- **Type-only exports** - Many exports are `type` or `interface` only
|
|
43
111
|
- **Standard Schema compatibility** - Follow StandardSchemaV1 spec for validation interfaces
|
|
44
112
|
- **No side effects** - All exports must be pure (no global mutations)
|
|
113
|
+
- **Service pattern** - Storage services take a FetchAdapter for HTTP abstraction
|
|
45
114
|
|
|
46
115
|
## Testing
|
|
47
116
|
|
|
48
|
-
- No test framework configured yet
|
|
49
117
|
- When adding tests, use Bun's built-in test runner: `bun test`
|
|
50
118
|
- When running tests, prefer using a subagent (Task tool) to avoid context bloat from test output
|
|
51
119
|
|
package/dist/index.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ export type { StandardSchemaV1 } from './standard_schema';
|
|
|
15
15
|
export { toCamelCase, toPascalCase } from './string';
|
|
16
16
|
export type { InferInput, InferOutput } from './typehelper';
|
|
17
17
|
export { WorkbenchConfigError, WorkbenchNotFoundError, encodeWorkbenchConfig, decodeWorkbenchConfig, getWorkbenchConfig, type WorkbenchConfig, } from './workbench-config';
|
|
18
|
+
export type { SDPDescription, ICECandidate, SignalMessage, SignalMsg, WebRTCConnectionState, WebRTCDisconnectReason, DataChannelConfig, DataChannelMessage, DataChannelState, WebRTCSignalingCallbacks, ConnectionQualitySummary, RecordingOptions, RecordingHandle, RecordingState, TrackSource, } from './webrtc';
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGxE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGjD,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,IAAI,EACJ,UAAU,GACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACN,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,oBAAoB,EACzB,uBAAuB,EACvB,0BAA0B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KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,YAAY,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGzF,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGrD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG5D,OAAO,EACN,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,eAAe,GACpB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACX,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,WAAW,GACX,MAAM,UAAU,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAExE,kBAAkB;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAevC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAWN,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEN,uBAAuB,EACvB,0BAA0B,EAC1B,8BAA8B,EAC9B,iCAAiC,GAGj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BAAgB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"_util.d.ts","sourceRoot":"","sources":["../../src/services/_util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,QAAQ,GACpB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,QAAQ,eAAe,KACrB,MAWF,CAAC;AAEF,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,GAChB,OAAO,CAAC,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAoFhD;AAMD,wBAAsB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CA0CtE;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAsBpE"}
|
package/dist/services/_util.js
CHANGED
|
@@ -24,6 +24,14 @@ export async function toServiceException(method, url, response) {
|
|
|
24
24
|
statusCode: response.status,
|
|
25
25
|
sessionId,
|
|
26
26
|
});
|
|
27
|
+
case 402:
|
|
28
|
+
return new ServiceException({
|
|
29
|
+
message: 'This action requires a paid plan. Please upgrade your account at https://app.agentuity.com/billing to continue.',
|
|
30
|
+
method,
|
|
31
|
+
url,
|
|
32
|
+
statusCode: response.status,
|
|
33
|
+
sessionId,
|
|
34
|
+
});
|
|
27
35
|
case 404:
|
|
28
36
|
return new ServiceException({
|
|
29
37
|
message: 'Not Found',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_util.js","sourceRoot":"","sources":["../../src/services/_util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC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AAI,CAAC,EAAE,eAAe,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC;IACD,OAAO,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,QAAkB;IACvD,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAClE,MAAM,WAAW,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IAEjD,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;IACrC,CAAC;IAED,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,uEAAuE;QACvE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC;gBACJ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;YAC9B,CAAC;YAAC,MAAM,CAAC;gBACR,2BAA2B;YAC5B,CAAC;QACF,CAAC;QACD,OAAO,IAAS,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAM,CAAC;AAC5C,CAAC"}
|
package/dist/webrtc.d.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebRTC signaling types shared between server and client.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* SDP (Session Description Protocol) description for WebRTC negotiation.
|
|
6
|
+
*/
|
|
7
|
+
export interface SDPDescription {
|
|
8
|
+
type: 'offer' | 'answer' | 'pranswer' | 'rollback';
|
|
9
|
+
sdp?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* ICE (Interactive Connectivity Establishment) candidate for NAT traversal.
|
|
13
|
+
*/
|
|
14
|
+
export interface ICECandidate {
|
|
15
|
+
candidate?: string;
|
|
16
|
+
sdpMid?: string | null;
|
|
17
|
+
sdpMLineIndex?: number | null;
|
|
18
|
+
usernameFragment?: string | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Signaling message protocol for WebRTC peer communication.
|
|
22
|
+
*
|
|
23
|
+
* Message types:
|
|
24
|
+
* - `join`: Client requests to join a room
|
|
25
|
+
* - `joined`: Server confirms join with peer ID and existing peers
|
|
26
|
+
* - `peer-joined`: Server notifies when another peer joins the room
|
|
27
|
+
* - `peer-left`: Server notifies when a peer leaves the room
|
|
28
|
+
* - `sdp`: SDP offer/answer exchange between peers
|
|
29
|
+
* - `ice`: ICE candidate exchange between peers
|
|
30
|
+
* - `error`: Error message from server
|
|
31
|
+
*/
|
|
32
|
+
export type SignalMessage = {
|
|
33
|
+
t: 'join';
|
|
34
|
+
roomId: string;
|
|
35
|
+
} | {
|
|
36
|
+
t: 'joined';
|
|
37
|
+
peerId: string;
|
|
38
|
+
roomId: string;
|
|
39
|
+
peers: string[];
|
|
40
|
+
} | {
|
|
41
|
+
t: 'peer-joined';
|
|
42
|
+
peerId: string;
|
|
43
|
+
} | {
|
|
44
|
+
t: 'peer-left';
|
|
45
|
+
peerId: string;
|
|
46
|
+
} | {
|
|
47
|
+
t: 'sdp';
|
|
48
|
+
from: string;
|
|
49
|
+
to?: string;
|
|
50
|
+
description: SDPDescription;
|
|
51
|
+
} | {
|
|
52
|
+
t: 'ice';
|
|
53
|
+
from: string;
|
|
54
|
+
to?: string;
|
|
55
|
+
candidate: ICECandidate;
|
|
56
|
+
} | {
|
|
57
|
+
t: 'error';
|
|
58
|
+
message: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use `SignalMessage` instead. Alias for backwards compatibility.
|
|
62
|
+
*/
|
|
63
|
+
export type SignalMsg = SignalMessage;
|
|
64
|
+
/**
|
|
65
|
+
* WebRTC connection states for the frontend state machine.
|
|
66
|
+
*
|
|
67
|
+
* State transitions:
|
|
68
|
+
* - idle → connecting: connect() called
|
|
69
|
+
* - connecting → signaling: WebSocket opened, joined room
|
|
70
|
+
* - connecting → idle: error or cancel
|
|
71
|
+
* - signaling → negotiating: peer joined, SDP exchange started
|
|
72
|
+
* - signaling → idle: hangup or WebSocket closed
|
|
73
|
+
* - negotiating → connected: ICE complete, media flowing
|
|
74
|
+
* - negotiating → signaling: peer left during negotiation
|
|
75
|
+
* - negotiating → idle: error or hangup
|
|
76
|
+
* - connected → negotiating: renegotiation needed
|
|
77
|
+
* - connected → signaling: peer left
|
|
78
|
+
* - connected → idle: hangup or WebSocket closed
|
|
79
|
+
*/
|
|
80
|
+
export type WebRTCConnectionState = 'idle' | 'connecting' | 'signaling' | 'negotiating' | 'connected';
|
|
81
|
+
/**
|
|
82
|
+
* Reasons for disconnection.
|
|
83
|
+
*/
|
|
84
|
+
export type WebRTCDisconnectReason = 'hangup' | 'error' | 'peer-left' | 'timeout';
|
|
85
|
+
/**
|
|
86
|
+
* Configuration for creating a data channel.
|
|
87
|
+
*/
|
|
88
|
+
export interface DataChannelConfig {
|
|
89
|
+
/** Unique label for the channel */
|
|
90
|
+
label: string;
|
|
91
|
+
/** Whether messages are ordered (default: true) */
|
|
92
|
+
ordered?: boolean;
|
|
93
|
+
/** Maximum retransmit time in milliseconds */
|
|
94
|
+
maxPacketLifeTime?: number;
|
|
95
|
+
/** Maximum number of retransmissions */
|
|
96
|
+
maxRetransmits?: number;
|
|
97
|
+
/** Sub-protocol name */
|
|
98
|
+
protocol?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Message types for data channel communication.
|
|
102
|
+
*/
|
|
103
|
+
export type DataChannelMessage = {
|
|
104
|
+
type: 'string';
|
|
105
|
+
data: string;
|
|
106
|
+
} | {
|
|
107
|
+
type: 'binary';
|
|
108
|
+
data: ArrayBuffer;
|
|
109
|
+
} | {
|
|
110
|
+
type: 'json';
|
|
111
|
+
data: unknown;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Data channel state.
|
|
115
|
+
*/
|
|
116
|
+
export type DataChannelState = 'connecting' | 'open' | 'closing' | 'closed';
|
|
117
|
+
/**
|
|
118
|
+
* Normalized connection quality summary.
|
|
119
|
+
* Derived from RTCPeerConnection.getStats() for easy consumption.
|
|
120
|
+
*/
|
|
121
|
+
export interface ConnectionQualitySummary {
|
|
122
|
+
/** Round-trip time in milliseconds */
|
|
123
|
+
rtt?: number;
|
|
124
|
+
/** Packet loss percentage (0-100) */
|
|
125
|
+
packetLossPercent?: number;
|
|
126
|
+
/** Jitter in milliseconds (audio) */
|
|
127
|
+
jitter?: number;
|
|
128
|
+
/** Current bitrate in bits per second */
|
|
129
|
+
bitrate?: {
|
|
130
|
+
audio?: {
|
|
131
|
+
inbound?: number;
|
|
132
|
+
outbound?: number;
|
|
133
|
+
};
|
|
134
|
+
video?: {
|
|
135
|
+
inbound?: number;
|
|
136
|
+
outbound?: number;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/** Video metrics */
|
|
140
|
+
video?: {
|
|
141
|
+
framesPerSecond?: number;
|
|
142
|
+
framesDropped?: number;
|
|
143
|
+
frameWidth?: number;
|
|
144
|
+
frameHeight?: number;
|
|
145
|
+
};
|
|
146
|
+
/** ICE candidate pair info */
|
|
147
|
+
candidatePair?: {
|
|
148
|
+
localType?: string;
|
|
149
|
+
remoteType?: string;
|
|
150
|
+
protocol?: string;
|
|
151
|
+
usingRelay?: boolean;
|
|
152
|
+
};
|
|
153
|
+
/** Timestamp when stats were collected */
|
|
154
|
+
timestamp: number;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Recording options for MediaRecorder.
|
|
158
|
+
*/
|
|
159
|
+
export interface RecordingOptions {
|
|
160
|
+
/** MIME type for recording (default: 'video/webm;codecs=vp9,opus' or 'audio/webm;codecs=opus') */
|
|
161
|
+
mimeType?: string;
|
|
162
|
+
/** Audio bits per second */
|
|
163
|
+
audioBitsPerSecond?: number;
|
|
164
|
+
/** Video bits per second */
|
|
165
|
+
videoBitsPerSecond?: number;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Recording handle for controlling an active recording.
|
|
169
|
+
*/
|
|
170
|
+
export interface RecordingHandle {
|
|
171
|
+
/** Stop recording and get the blob */
|
|
172
|
+
stop(): Promise<Blob>;
|
|
173
|
+
/** Pause recording */
|
|
174
|
+
pause(): void;
|
|
175
|
+
/** Resume recording */
|
|
176
|
+
resume(): void;
|
|
177
|
+
/** Current recording state */
|
|
178
|
+
readonly state: RecordingState;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Recording state.
|
|
182
|
+
*/
|
|
183
|
+
export type RecordingState = 'inactive' | 'recording' | 'paused';
|
|
184
|
+
/**
|
|
185
|
+
* Abstract track source interface for custom media sources.
|
|
186
|
+
* Implementations can provide camera, screen share, or custom tracks.
|
|
187
|
+
*
|
|
188
|
+
* Note: This interface is implemented in @agentuity/frontend where
|
|
189
|
+
* browser APIs (MediaStream) are available.
|
|
190
|
+
*/
|
|
191
|
+
export interface TrackSource {
|
|
192
|
+
/** Get the media stream from this source (returns browser MediaStream) */
|
|
193
|
+
getStream(): Promise<unknown>;
|
|
194
|
+
/** Stop the source and release resources */
|
|
195
|
+
stop(): void;
|
|
196
|
+
/** Source type identifier */
|
|
197
|
+
readonly type: 'user-media' | 'display-media' | 'custom';
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Callbacks for WebRTC signaling server events.
|
|
201
|
+
* All callbacks are optional - only subscribe to events you care about.
|
|
202
|
+
*/
|
|
203
|
+
export interface WebRTCSignalingCallbacks {
|
|
204
|
+
/**
|
|
205
|
+
* Called when a new room is created.
|
|
206
|
+
* @param roomId - The room ID
|
|
207
|
+
*/
|
|
208
|
+
onRoomCreated?: (roomId: string) => void;
|
|
209
|
+
/**
|
|
210
|
+
* Called when a room is destroyed (last peer left).
|
|
211
|
+
* @param roomId - The room ID
|
|
212
|
+
*/
|
|
213
|
+
onRoomDestroyed?: (roomId: string) => void;
|
|
214
|
+
/**
|
|
215
|
+
* Called when a peer joins a room.
|
|
216
|
+
* @param peerId - The peer's ID
|
|
217
|
+
* @param roomId - The room ID
|
|
218
|
+
*/
|
|
219
|
+
onPeerJoin?: (peerId: string, roomId: string) => void;
|
|
220
|
+
/**
|
|
221
|
+
* Called when a peer leaves a room.
|
|
222
|
+
* @param peerId - The peer's ID
|
|
223
|
+
* @param roomId - The room ID
|
|
224
|
+
* @param reason - Why the peer left
|
|
225
|
+
*/
|
|
226
|
+
onPeerLeave?: (peerId: string, roomId: string, reason: 'disconnect' | 'kicked') => void;
|
|
227
|
+
/**
|
|
228
|
+
* Called when a signaling message is relayed.
|
|
229
|
+
* @param type - Message type ('sdp' or 'ice')
|
|
230
|
+
* @param from - Sender peer ID
|
|
231
|
+
* @param to - Target peer ID (undefined for broadcast)
|
|
232
|
+
* @param roomId - The room ID
|
|
233
|
+
*/
|
|
234
|
+
onMessage?: (type: 'sdp' | 'ice', from: string, to: string | undefined, roomId: string) => void;
|
|
235
|
+
/**
|
|
236
|
+
* Called when an error occurs.
|
|
237
|
+
* @param error - The error that occurred
|
|
238
|
+
* @param peerId - The peer ID if applicable
|
|
239
|
+
* @param roomId - The room ID if applicable
|
|
240
|
+
*/
|
|
241
|
+
onError?: (error: Error, peerId?: string, roomId?: string) => void;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=webrtc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webrtc.d.ts","sourceRoot":"","sources":["../src/webrtc.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI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GG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAEzC;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAE3C;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtD;;;;;OAKG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,QAAQ,KAAK,IAAI,CAAC;IAExF;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAEhG;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACnE"}
|
package/dist/webrtc.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webrtc.js","sourceRoot":"","sources":["../src/webrtc.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentuity/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "Agentuity employees and contributors",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"zod": "^4.3.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@agentuity/test-utils": "1.0.
|
|
40
|
+
"@agentuity/test-utils": "1.0.2",
|
|
41
41
|
"@types/bun": "latest",
|
|
42
42
|
"bun-types": "latest",
|
|
43
43
|
"esbuild": "^0.25.0",
|
package/src/env.d.ts
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Environment Variable Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This file augments NodeJS.ProcessEnv with all Agentuity SDK environment variables.
|
|
5
|
+
* All variables are optional (may or may not be set at runtime).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
namespace NodeJS {
|
|
10
|
+
interface ProcessEnv {
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Authentication & Secrets
|
|
13
|
+
// ============================================================================
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* SDK authentication key for Agentuity services.
|
|
17
|
+
* Used by the runtime to authenticate API requests.
|
|
18
|
+
*/
|
|
19
|
+
AGENTUITY_SDK_KEY?: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Auth secret for session signing and encryption.
|
|
23
|
+
* Falls back to BETTER_AUTH_SECRET if not set.
|
|
24
|
+
*/
|
|
25
|
+
AGENTUITY_AUTH_SECRET?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Cloud base URL for authentication.
|
|
29
|
+
* Fallback chain: AGENTUITY_BASE_URL → BETTER_AUTH_URL
|
|
30
|
+
*/
|
|
31
|
+
AGENTUITY_CLOUD_BASE_URL?: string;
|
|
32
|
+
|
|
33
|
+
/** Base URL fallback for cloud services */
|
|
34
|
+
AGENTUITY_BASE_URL?: string;
|
|
35
|
+
|
|
36
|
+
/** User ID for authentication context */
|
|
37
|
+
AGENTUITY_USER_ID?: string;
|
|
38
|
+
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Service URLs & Endpoints
|
|
41
|
+
// ============================================================================
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Region identifier for service URL construction.
|
|
45
|
+
* Values: 'usc' (US Central), 'local', etc.
|
|
46
|
+
*/
|
|
47
|
+
AGENTUITY_REGION?: string;
|
|
48
|
+
|
|
49
|
+
/** Transport service URL for agent communication */
|
|
50
|
+
AGENTUITY_TRANSPORT_URL?: string;
|
|
51
|
+
|
|
52
|
+
/** Catalyst service URL for AI model access */
|
|
53
|
+
AGENTUITY_CATALYST_URL?: string;
|
|
54
|
+
|
|
55
|
+
/** Key-value storage service URL */
|
|
56
|
+
AGENTUITY_KEYVALUE_URL?: string;
|
|
57
|
+
|
|
58
|
+
/** Vector storage service URL */
|
|
59
|
+
AGENTUITY_VECTOR_URL?: string;
|
|
60
|
+
|
|
61
|
+
/** Sandbox execution service URL */
|
|
62
|
+
AGENTUITY_SANDBOX_URL?: string;
|
|
63
|
+
|
|
64
|
+
/** Stream storage service URL */
|
|
65
|
+
AGENTUITY_STREAM_URL?: string;
|
|
66
|
+
|
|
67
|
+
/** OpenTelemetry Protocol endpoint URL */
|
|
68
|
+
AGENTUITY_OTLP_URL?: string;
|
|
69
|
+
|
|
70
|
+
/** AI Gateway URL for model routing */
|
|
71
|
+
AGENTUITY_AIGATEWAY_URL?: string;
|
|
72
|
+
|
|
73
|
+
/** Main API URL for Agentuity services */
|
|
74
|
+
AGENTUITY_API_URL?: string;
|
|
75
|
+
|
|
76
|
+
/** App/dashboard URL */
|
|
77
|
+
AGENTUITY_APP_URL?: string;
|
|
78
|
+
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// Logging & Observability
|
|
81
|
+
// ============================================================================
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Log level for application logging.
|
|
85
|
+
* Values: 'trace', 'debug', 'info', 'warn', 'error'
|
|
86
|
+
*/
|
|
87
|
+
AGENTUITY_LOG_LEVEL?: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* SDK-specific log level (overrides AGENTUITY_LOG_LEVEL for SDK internals).
|
|
91
|
+
* Values: 'trace', 'debug', 'info', 'warn', 'error'
|
|
92
|
+
*/
|
|
93
|
+
AGENTUITY_SDK_LOG_LEVEL?: string;
|
|
94
|
+
|
|
95
|
+
/** Enable OpenTelemetry debug output to console */
|
|
96
|
+
AGENTUITY_DEBUG_OTEL_CONSOLE?: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Bearer token for OTLP authentication.
|
|
100
|
+
* Falls back to AGENTUITY_SDK_KEY if not set.
|
|
101
|
+
*/
|
|
102
|
+
AGENTUITY_OTLP_BEARER_TOKEN?: string;
|
|
103
|
+
|
|
104
|
+
/** Directory for cloud telemetry export */
|
|
105
|
+
AGENTUITY_CLOUD_EXPORT_DIR?: string;
|
|
106
|
+
|
|
107
|
+
/** Log level for Gravity logging subsystem */
|
|
108
|
+
AGENTUITY_GRAVITY_LOG_LEVEL?: string;
|
|
109
|
+
|
|
110
|
+
/** File path for clean/structured log output */
|
|
111
|
+
AGENTUITY_CLEAN_LOGS_FILE?: string;
|
|
112
|
+
|
|
113
|
+
/** Internal session ID for request correlation */
|
|
114
|
+
AGENTUITY_INTERNAL_SESSION_ID?: string;
|
|
115
|
+
|
|
116
|
+
// ============================================================================
|
|
117
|
+
// Build & Runtime Configuration
|
|
118
|
+
// ============================================================================
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Environment name for the application.
|
|
122
|
+
* Falls back to NODE_ENV if not set.
|
|
123
|
+
*/
|
|
124
|
+
AGENTUITY_ENVIRONMENT?: string;
|
|
125
|
+
|
|
126
|
+
/** Node.js environment (development, production, test) */
|
|
127
|
+
NODE_ENV?: string;
|
|
128
|
+
|
|
129
|
+
/** Enable SDK development mode with additional debugging */
|
|
130
|
+
AGENTUITY_SDK_DEV_MODE?: string;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Flag indicating code is running inside the Agentuity agent runtime.
|
|
134
|
+
* Set automatically by the runtime.
|
|
135
|
+
*/
|
|
136
|
+
AGENTUITY_RUNTIME?: string;
|
|
137
|
+
|
|
138
|
+
/** Environment shorthand (dev, staging, prod) */
|
|
139
|
+
AGENTUITY_ENV?: string;
|
|
140
|
+
|
|
141
|
+
/** HTTP server port */
|
|
142
|
+
PORT?: string;
|
|
143
|
+
|
|
144
|
+
/** Agentuity-specific server port (overrides PORT) */
|
|
145
|
+
AGENTUITY_PORT?: string;
|
|
146
|
+
|
|
147
|
+
/** Vite development server port */
|
|
148
|
+
VITE_PORT?: string;
|
|
149
|
+
|
|
150
|
+
/** Development mode flag */
|
|
151
|
+
DEV?: string;
|
|
152
|
+
|
|
153
|
+
// ============================================================================
|
|
154
|
+
// Cloud Deployment & Metadata
|
|
155
|
+
// ============================================================================
|
|
156
|
+
|
|
157
|
+
/** SDK version deployed to cloud */
|
|
158
|
+
AGENTUITY_CLOUD_SDK_VERSION?: string;
|
|
159
|
+
|
|
160
|
+
/** CLI version used for deployment */
|
|
161
|
+
AGENTUITY_CLI_VERSION?: string;
|
|
162
|
+
|
|
163
|
+
/** Organization ID in Agentuity Cloud */
|
|
164
|
+
AGENTUITY_CLOUD_ORG_ID?: string;
|
|
165
|
+
|
|
166
|
+
/** Project ID in Agentuity Cloud */
|
|
167
|
+
AGENTUITY_CLOUD_PROJECT_ID?: string;
|
|
168
|
+
|
|
169
|
+
/** Deployment ID in Agentuity Cloud */
|
|
170
|
+
AGENTUITY_CLOUD_DEPLOYMENT_ID?: string;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Cloud domains configuration.
|
|
174
|
+
* JSON array of domain strings.
|
|
175
|
+
*/
|
|
176
|
+
AGENTUITY_CLOUD_DOMAINS?: string;
|
|
177
|
+
|
|
178
|
+
/** Local project directory path */
|
|
179
|
+
AGENTUITY_PROJECT_DIR?: string;
|
|
180
|
+
|
|
181
|
+
/** Configuration profile name */
|
|
182
|
+
AGENTUITY_PROFILE?: string;
|
|
183
|
+
|
|
184
|
+
/** Deployment name/identifier */
|
|
185
|
+
AGENTUITY_DEPLOYMENT?: string;
|
|
186
|
+
|
|
187
|
+
// ============================================================================
|
|
188
|
+
// Database
|
|
189
|
+
// ============================================================================
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Database connection URL.
|
|
193
|
+
* Standard connection string format: protocol://user:pass@host:port/db
|
|
194
|
+
*/
|
|
195
|
+
DATABASE_URL?: string;
|
|
196
|
+
|
|
197
|
+
// ============================================================================
|
|
198
|
+
// Development & Testing
|
|
199
|
+
// ============================================================================
|
|
200
|
+
|
|
201
|
+
/** CI environment flag (set in CI/CD pipelines) */
|
|
202
|
+
CI?: string;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Sandbox ID when running in an Agentuity sandbox environment.
|
|
206
|
+
* Set automatically by the sandbox runtime.
|
|
207
|
+
*/
|
|
208
|
+
AGENTUITY_SANDBOX_ID?: string;
|
|
209
|
+
|
|
210
|
+
// ============================================================================
|
|
211
|
+
// Third-Party & System
|
|
212
|
+
// ============================================================================
|
|
213
|
+
|
|
214
|
+
/** S3-compatible endpoint URL */
|
|
215
|
+
S3_ENDPOINT?: string;
|
|
216
|
+
|
|
217
|
+
/** AWS endpoint URL override */
|
|
218
|
+
AWS_ENDPOINT?: string;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Trusted domains for authentication.
|
|
222
|
+
* Comma-separated list of domain patterns.
|
|
223
|
+
*/
|
|
224
|
+
AUTH_TRUSTED_DOMAINS?: string;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export {};
|
package/src/index.ts
CHANGED
|
@@ -162,4 +162,23 @@ export {
|
|
|
162
162
|
type WorkbenchConfig,
|
|
163
163
|
} from './workbench-config';
|
|
164
164
|
|
|
165
|
+
// webrtc.ts exports
|
|
166
|
+
export type {
|
|
167
|
+
SDPDescription,
|
|
168
|
+
ICECandidate,
|
|
169
|
+
SignalMessage,
|
|
170
|
+
SignalMsg,
|
|
171
|
+
WebRTCConnectionState,
|
|
172
|
+
WebRTCDisconnectReason,
|
|
173
|
+
DataChannelConfig,
|
|
174
|
+
DataChannelMessage,
|
|
175
|
+
DataChannelState,
|
|
176
|
+
WebRTCSignalingCallbacks,
|
|
177
|
+
ConnectionQualitySummary,
|
|
178
|
+
RecordingOptions,
|
|
179
|
+
RecordingHandle,
|
|
180
|
+
RecordingState,
|
|
181
|
+
TrackSource,
|
|
182
|
+
} from './webrtc';
|
|
183
|
+
|
|
165
184
|
// Client code moved to @agentuity/frontend for better bundler compatibility
|
package/src/services/_util.ts
CHANGED
|
@@ -36,6 +36,15 @@ export async function toServiceException(
|
|
|
36
36
|
statusCode: response.status,
|
|
37
37
|
sessionId,
|
|
38
38
|
});
|
|
39
|
+
case 402:
|
|
40
|
+
return new ServiceException({
|
|
41
|
+
message:
|
|
42
|
+
'This action requires a paid plan. Please upgrade your account at https://app.agentuity.com/billing to continue.',
|
|
43
|
+
method,
|
|
44
|
+
url,
|
|
45
|
+
statusCode: response.status,
|
|
46
|
+
sessionId,
|
|
47
|
+
});
|
|
39
48
|
case 404:
|
|
40
49
|
return new ServiceException({
|
|
41
50
|
message: 'Not Found',
|
package/src/webrtc.ts
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebRTC signaling types shared between server and client.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// Signaling Protocol Types
|
|
7
|
+
// =============================================================================
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* SDP (Session Description Protocol) description for WebRTC negotiation.
|
|
11
|
+
*/
|
|
12
|
+
export interface SDPDescription {
|
|
13
|
+
type: 'offer' | 'answer' | 'pranswer' | 'rollback';
|
|
14
|
+
sdp?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* ICE (Interactive Connectivity Establishment) candidate for NAT traversal.
|
|
19
|
+
*/
|
|
20
|
+
export interface ICECandidate {
|
|
21
|
+
candidate?: string;
|
|
22
|
+
sdpMid?: string | null;
|
|
23
|
+
sdpMLineIndex?: number | null;
|
|
24
|
+
usernameFragment?: string | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Signaling message protocol for WebRTC peer communication.
|
|
29
|
+
*
|
|
30
|
+
* Message types:
|
|
31
|
+
* - `join`: Client requests to join a room
|
|
32
|
+
* - `joined`: Server confirms join with peer ID and existing peers
|
|
33
|
+
* - `peer-joined`: Server notifies when another peer joins the room
|
|
34
|
+
* - `peer-left`: Server notifies when a peer leaves the room
|
|
35
|
+
* - `sdp`: SDP offer/answer exchange between peers
|
|
36
|
+
* - `ice`: ICE candidate exchange between peers
|
|
37
|
+
* - `error`: Error message from server
|
|
38
|
+
*/
|
|
39
|
+
export type SignalMessage =
|
|
40
|
+
| { t: 'join'; roomId: string }
|
|
41
|
+
| { t: 'joined'; peerId: string; roomId: string; peers: string[] }
|
|
42
|
+
| { t: 'peer-joined'; peerId: string }
|
|
43
|
+
| { t: 'peer-left'; peerId: string }
|
|
44
|
+
| { t: 'sdp'; from: string; to?: string; description: SDPDescription }
|
|
45
|
+
| { t: 'ice'; from: string; to?: string; candidate: ICECandidate }
|
|
46
|
+
| { t: 'error'; message: string };
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Use `SignalMessage` instead. Alias for backwards compatibility.
|
|
50
|
+
*/
|
|
51
|
+
export type SignalMsg = SignalMessage;
|
|
52
|
+
|
|
53
|
+
// =============================================================================
|
|
54
|
+
// Frontend State Machine Types
|
|
55
|
+
// =============================================================================
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* WebRTC connection states for the frontend state machine.
|
|
59
|
+
*
|
|
60
|
+
* State transitions:
|
|
61
|
+
* - idle → connecting: connect() called
|
|
62
|
+
* - connecting → signaling: WebSocket opened, joined room
|
|
63
|
+
* - connecting → idle: error or cancel
|
|
64
|
+
* - signaling → negotiating: peer joined, SDP exchange started
|
|
65
|
+
* - signaling → idle: hangup or WebSocket closed
|
|
66
|
+
* - negotiating → connected: ICE complete, media flowing
|
|
67
|
+
* - negotiating → signaling: peer left during negotiation
|
|
68
|
+
* - negotiating → idle: error or hangup
|
|
69
|
+
* - connected → negotiating: renegotiation needed
|
|
70
|
+
* - connected → signaling: peer left
|
|
71
|
+
* - connected → idle: hangup or WebSocket closed
|
|
72
|
+
*/
|
|
73
|
+
export type WebRTCConnectionState =
|
|
74
|
+
| 'idle'
|
|
75
|
+
| 'connecting'
|
|
76
|
+
| 'signaling'
|
|
77
|
+
| 'negotiating'
|
|
78
|
+
| 'connected';
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Reasons for disconnection.
|
|
82
|
+
*/
|
|
83
|
+
export type WebRTCDisconnectReason = 'hangup' | 'error' | 'peer-left' | 'timeout';
|
|
84
|
+
|
|
85
|
+
// =============================================================================
|
|
86
|
+
// Data Channel Types
|
|
87
|
+
// =============================================================================
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Configuration for creating a data channel.
|
|
91
|
+
*/
|
|
92
|
+
export interface DataChannelConfig {
|
|
93
|
+
/** Unique label for the channel */
|
|
94
|
+
label: string;
|
|
95
|
+
/** Whether messages are ordered (default: true) */
|
|
96
|
+
ordered?: boolean;
|
|
97
|
+
/** Maximum retransmit time in milliseconds */
|
|
98
|
+
maxPacketLifeTime?: number;
|
|
99
|
+
/** Maximum number of retransmissions */
|
|
100
|
+
maxRetransmits?: number;
|
|
101
|
+
/** Sub-protocol name */
|
|
102
|
+
protocol?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Message types for data channel communication.
|
|
107
|
+
*/
|
|
108
|
+
export type DataChannelMessage =
|
|
109
|
+
| { type: 'string'; data: string }
|
|
110
|
+
| { type: 'binary'; data: ArrayBuffer }
|
|
111
|
+
| { type: 'json'; data: unknown };
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Data channel state.
|
|
115
|
+
*/
|
|
116
|
+
export type DataChannelState = 'connecting' | 'open' | 'closing' | 'closed';
|
|
117
|
+
|
|
118
|
+
// =============================================================================
|
|
119
|
+
// Connection Quality / Stats Types
|
|
120
|
+
// =============================================================================
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Normalized connection quality summary.
|
|
124
|
+
* Derived from RTCPeerConnection.getStats() for easy consumption.
|
|
125
|
+
*/
|
|
126
|
+
export interface ConnectionQualitySummary {
|
|
127
|
+
/** Round-trip time in milliseconds */
|
|
128
|
+
rtt?: number;
|
|
129
|
+
/** Packet loss percentage (0-100) */
|
|
130
|
+
packetLossPercent?: number;
|
|
131
|
+
/** Jitter in milliseconds (audio) */
|
|
132
|
+
jitter?: number;
|
|
133
|
+
/** Current bitrate in bits per second */
|
|
134
|
+
bitrate?: {
|
|
135
|
+
audio?: { inbound?: number; outbound?: number };
|
|
136
|
+
video?: { inbound?: number; outbound?: number };
|
|
137
|
+
};
|
|
138
|
+
/** Video metrics */
|
|
139
|
+
video?: {
|
|
140
|
+
framesPerSecond?: number;
|
|
141
|
+
framesDropped?: number;
|
|
142
|
+
frameWidth?: number;
|
|
143
|
+
frameHeight?: number;
|
|
144
|
+
};
|
|
145
|
+
/** ICE candidate pair info */
|
|
146
|
+
candidatePair?: {
|
|
147
|
+
localType?: string;
|
|
148
|
+
remoteType?: string;
|
|
149
|
+
protocol?: string;
|
|
150
|
+
usingRelay?: boolean;
|
|
151
|
+
};
|
|
152
|
+
/** Timestamp when stats were collected */
|
|
153
|
+
timestamp: number;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Recording options for MediaRecorder.
|
|
158
|
+
*/
|
|
159
|
+
export interface RecordingOptions {
|
|
160
|
+
/** MIME type for recording (default: 'video/webm;codecs=vp9,opus' or 'audio/webm;codecs=opus') */
|
|
161
|
+
mimeType?: string;
|
|
162
|
+
/** Audio bits per second */
|
|
163
|
+
audioBitsPerSecond?: number;
|
|
164
|
+
/** Video bits per second */
|
|
165
|
+
videoBitsPerSecond?: number;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Recording handle for controlling an active recording.
|
|
170
|
+
*/
|
|
171
|
+
export interface RecordingHandle {
|
|
172
|
+
/** Stop recording and get the blob */
|
|
173
|
+
stop(): Promise<Blob>;
|
|
174
|
+
/** Pause recording */
|
|
175
|
+
pause(): void;
|
|
176
|
+
/** Resume recording */
|
|
177
|
+
resume(): void;
|
|
178
|
+
/** Current recording state */
|
|
179
|
+
readonly state: RecordingState;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Recording state.
|
|
184
|
+
*/
|
|
185
|
+
export type RecordingState = 'inactive' | 'recording' | 'paused';
|
|
186
|
+
|
|
187
|
+
// =============================================================================
|
|
188
|
+
// Track Source Types
|
|
189
|
+
// =============================================================================
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Abstract track source interface for custom media sources.
|
|
193
|
+
* Implementations can provide camera, screen share, or custom tracks.
|
|
194
|
+
*
|
|
195
|
+
* Note: This interface is implemented in @agentuity/frontend where
|
|
196
|
+
* browser APIs (MediaStream) are available.
|
|
197
|
+
*/
|
|
198
|
+
export interface TrackSource {
|
|
199
|
+
/** Get the media stream from this source (returns browser MediaStream) */
|
|
200
|
+
getStream(): Promise<unknown>;
|
|
201
|
+
/** Stop the source and release resources */
|
|
202
|
+
stop(): void;
|
|
203
|
+
/** Source type identifier */
|
|
204
|
+
readonly type: 'user-media' | 'display-media' | 'custom';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// =============================================================================
|
|
208
|
+
// Backend Signaling Callbacks
|
|
209
|
+
// =============================================================================
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Callbacks for WebRTC signaling server events.
|
|
213
|
+
* All callbacks are optional - only subscribe to events you care about.
|
|
214
|
+
*/
|
|
215
|
+
export interface WebRTCSignalingCallbacks {
|
|
216
|
+
/**
|
|
217
|
+
* Called when a new room is created.
|
|
218
|
+
* @param roomId - The room ID
|
|
219
|
+
*/
|
|
220
|
+
onRoomCreated?: (roomId: string) => void;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Called when a room is destroyed (last peer left).
|
|
224
|
+
* @param roomId - The room ID
|
|
225
|
+
*/
|
|
226
|
+
onRoomDestroyed?: (roomId: string) => void;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Called when a peer joins a room.
|
|
230
|
+
* @param peerId - The peer's ID
|
|
231
|
+
* @param roomId - The room ID
|
|
232
|
+
*/
|
|
233
|
+
onPeerJoin?: (peerId: string, roomId: string) => void;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Called when a peer leaves a room.
|
|
237
|
+
* @param peerId - The peer's ID
|
|
238
|
+
* @param roomId - The room ID
|
|
239
|
+
* @param reason - Why the peer left
|
|
240
|
+
*/
|
|
241
|
+
onPeerLeave?: (peerId: string, roomId: string, reason: 'disconnect' | 'kicked') => void;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Called when a signaling message is relayed.
|
|
245
|
+
* @param type - Message type ('sdp' or 'ice')
|
|
246
|
+
* @param from - Sender peer ID
|
|
247
|
+
* @param to - Target peer ID (undefined for broadcast)
|
|
248
|
+
* @param roomId - The room ID
|
|
249
|
+
*/
|
|
250
|
+
onMessage?: (type: 'sdp' | 'ice', from: string, to: string | undefined, roomId: string) => void;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Called when an error occurs.
|
|
254
|
+
* @param error - The error that occurred
|
|
255
|
+
* @param peerId - The peer ID if applicable
|
|
256
|
+
* @param roomId - The room ID if applicable
|
|
257
|
+
*/
|
|
258
|
+
onError?: (error: Error, peerId?: string, roomId?: string) => void;
|
|
259
|
+
}
|