@agentuity/core 3.0.0-alpha.5 → 3.0.0-alpha.7

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.
Files changed (110) hide show
  1. package/AGENTS.md +0 -1
  2. package/dist/index.d.ts +0 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +0 -3
  5. package/dist/index.js.map +1 -1
  6. package/dist/services/coder/api-reference.d.ts.map +1 -1
  7. package/dist/services/coder/api-reference.js +30 -1
  8. package/dist/services/coder/api-reference.js.map +1 -1
  9. package/dist/services/coder/client.d.ts +5 -1
  10. package/dist/services/coder/client.d.ts.map +1 -1
  11. package/dist/services/coder/client.js +8 -1
  12. package/dist/services/coder/client.js.map +1 -1
  13. package/dist/services/coder/index.d.ts +2 -2
  14. package/dist/services/coder/index.d.ts.map +1 -1
  15. package/dist/services/coder/index.js +1 -1
  16. package/dist/services/coder/index.js.map +1 -1
  17. package/dist/services/coder/protocol.d.ts +65 -0
  18. package/dist/services/coder/protocol.d.ts.map +1 -1
  19. package/dist/services/coder/protocol.js +8 -0
  20. package/dist/services/coder/protocol.js.map +1 -1
  21. package/dist/services/coder/sessions.d.ts +22 -0
  22. package/dist/services/coder/sessions.d.ts.map +1 -1
  23. package/dist/services/coder/sessions.js +10 -1
  24. package/dist/services/coder/sessions.js.map +1 -1
  25. package/dist/services/coder/sse.d.ts +2 -2
  26. package/dist/services/coder/sse.d.ts.map +1 -1
  27. package/dist/services/coder/sse.js +290 -178
  28. package/dist/services/coder/sse.js.map +1 -1
  29. package/dist/services/coder/types.d.ts +554 -0
  30. package/dist/services/coder/types.d.ts.map +1 -1
  31. package/dist/services/coder/types.js +138 -0
  32. package/dist/services/coder/types.js.map +1 -1
  33. package/dist/services/index.d.ts +0 -2
  34. package/dist/services/index.d.ts.map +1 -1
  35. package/dist/services/index.js +0 -2
  36. package/dist/services/index.js.map +1 -1
  37. package/dist/services/sandbox/run.d.ts.map +1 -1
  38. package/dist/services/sandbox/run.js +15 -2
  39. package/dist/services/sandbox/run.js.map +1 -1
  40. package/package.json +2 -16
  41. package/src/index.ts +0 -15
  42. package/src/services/coder/api-reference.ts +31 -0
  43. package/src/services/coder/client.ts +12 -0
  44. package/src/services/coder/index.ts +3 -0
  45. package/src/services/coder/protocol.ts +12 -0
  46. package/src/services/coder/sessions.ts +26 -0
  47. package/src/services/coder/sse.ts +343 -184
  48. package/src/services/coder/types.ts +179 -0
  49. package/src/services/index.ts +0 -2
  50. package/src/services/sandbox/run.ts +13 -2
  51. package/dist/services/auth/index.d.ts +0 -7
  52. package/dist/services/auth/index.d.ts.map +0 -1
  53. package/dist/services/auth/index.js +0 -7
  54. package/dist/services/auth/index.js.map +0 -1
  55. package/dist/services/auth/types.d.ts +0 -192
  56. package/dist/services/auth/types.d.ts.map +0 -1
  57. package/dist/services/auth/types.js +0 -11
  58. package/dist/services/auth/types.js.map +0 -1
  59. package/dist/services/eval/api-reference.d.ts +0 -4
  60. package/dist/services/eval/api-reference.d.ts.map +0 -1
  61. package/dist/services/eval/api-reference.js +0 -121
  62. package/dist/services/eval/api-reference.js.map +0 -1
  63. package/dist/services/eval/events.d.ts +0 -93
  64. package/dist/services/eval/events.d.ts.map +0 -1
  65. package/dist/services/eval/events.js +0 -24
  66. package/dist/services/eval/events.js.map +0 -1
  67. package/dist/services/eval/get.d.ts +0 -36
  68. package/dist/services/eval/get.d.ts.map +0 -1
  69. package/dist/services/eval/get.js +0 -23
  70. package/dist/services/eval/get.js.map +0 -1
  71. package/dist/services/eval/index.d.ts +0 -6
  72. package/dist/services/eval/index.d.ts.map +0 -1
  73. package/dist/services/eval/index.js +0 -6
  74. package/dist/services/eval/index.js.map +0 -1
  75. package/dist/services/eval/list.d.ts +0 -50
  76. package/dist/services/eval/list.d.ts.map +0 -1
  77. package/dist/services/eval/list.js +0 -32
  78. package/dist/services/eval/list.js.map +0 -1
  79. package/dist/services/eval/run-get.d.ts +0 -48
  80. package/dist/services/eval/run-get.d.ts.map +0 -1
  81. package/dist/services/eval/run-get.js +0 -29
  82. package/dist/services/eval/run-get.js.map +0 -1
  83. package/dist/services/eval/run-list.d.ts +0 -70
  84. package/dist/services/eval/run-list.d.ts.map +0 -1
  85. package/dist/services/eval/run-list.js +0 -42
  86. package/dist/services/eval/run-list.js.map +0 -1
  87. package/dist/webrtc.d.ts +0 -243
  88. package/dist/webrtc.d.ts.map +0 -1
  89. package/dist/webrtc.js +0 -5
  90. package/dist/webrtc.js.map +0 -1
  91. package/dist/workbench-config.d.ts +0 -62
  92. package/dist/workbench-config.d.ts.map +0 -1
  93. package/dist/workbench-config.js +0 -58
  94. package/dist/workbench-config.js.map +0 -1
  95. package/dist/workbench.d.ts +0 -2
  96. package/dist/workbench.d.ts.map +0 -1
  97. package/dist/workbench.js +0 -2
  98. package/dist/workbench.js.map +0 -1
  99. package/src/services/auth/index.ts +0 -19
  100. package/src/services/auth/types.ts +0 -223
  101. package/src/services/eval/api-reference.ts +0 -124
  102. package/src/services/eval/events.ts +0 -92
  103. package/src/services/eval/get.ts +0 -33
  104. package/src/services/eval/index.ts +0 -29
  105. package/src/services/eval/list.ts +0 -49
  106. package/src/services/eval/run-get.ts +0 -39
  107. package/src/services/eval/run-list.ts +0 -59
  108. package/src/webrtc.ts +0 -259
  109. package/src/workbench-config.ts +0 -79
  110. package/src/workbench.ts +0 -1
@@ -1,124 +0,0 @@
1
- import type { Service } from '../api-reference.ts';
2
- import { EvaluationSchema } from './list.ts';
3
- import { EvalRunSchema } from './run-list.ts';
4
-
5
- const service: Service = {
6
- name: 'Evaluations',
7
- slug: 'evaluations',
8
- description: 'List and retrieve evaluations and their run history',
9
- endpoints: [
10
- {
11
- id: 'list-evaluations',
12
- title: 'List Evaluations',
13
- method: 'GET',
14
- path: '/cli/eval',
15
- description:
16
- 'List evaluations with optional filtering by organization, project, or agent.',
17
- pathParams: [],
18
- queryParams: [
19
- {
20
- name: 'orgId',
21
- type: 'string',
22
- description: 'Filter by organization ID',
23
- required: false,
24
- },
25
- {
26
- name: 'projectId',
27
- type: 'string',
28
- description: 'Filter by project ID',
29
- required: false,
30
- },
31
- { name: 'agentId', type: 'string', description: 'Filter by agent ID', required: false },
32
- ],
33
- requestBody: null,
34
- responseDescription: 'Array of evaluation objects.',
35
- responseFields: { schema: EvaluationSchema },
36
- statuses: [
37
- { code: 200, description: 'Evaluations returned' },
38
- { code: 401, description: 'Unauthorized — invalid or missing Bearer token' },
39
- ],
40
- examplePath: '/cli/eval',
41
- },
42
- {
43
- id: 'get-evaluation',
44
- title: 'Get Evaluation',
45
- method: 'GET',
46
- path: '/cli/eval/{id}',
47
- description: 'Get a specific evaluation by ID.',
48
- pathParams: [{ name: 'id', type: 'string', description: 'Evaluation ID', required: true }],
49
- queryParams: [],
50
- requestBody: null,
51
- responseDescription: 'Evaluation object.',
52
- statuses: [
53
- { code: 200, description: 'Evaluation returned' },
54
- { code: 401, description: 'Unauthorized — invalid or missing Bearer token' },
55
- { code: 404, description: 'Evaluation not found' },
56
- ],
57
- examplePath: '/cli/eval/eval_abc123',
58
- },
59
- {
60
- id: 'list-eval-runs',
61
- title: 'List Eval Runs',
62
- sectionTitle: 'Eval Runs',
63
- method: 'GET',
64
- path: '/cli/eval-run',
65
- description: 'List evaluation runs with optional filtering.',
66
- pathParams: [],
67
- queryParams: [
68
- {
69
- name: 'orgId',
70
- type: 'string',
71
- description: 'Filter by organization ID',
72
- required: false,
73
- },
74
- {
75
- name: 'projectId',
76
- type: 'string',
77
- description: 'Filter by project ID',
78
- required: false,
79
- },
80
- { name: 'agentId', type: 'string', description: 'Filter by agent ID', required: false },
81
- {
82
- name: 'evalId',
83
- type: 'string',
84
- description: 'Filter by evaluation ID',
85
- required: false,
86
- },
87
- {
88
- name: 'sessionId',
89
- type: 'string',
90
- description: 'Filter by session ID',
91
- required: false,
92
- },
93
- ],
94
- requestBody: null,
95
- responseDescription: 'Array of evaluation run objects.',
96
- responseFields: { schema: EvalRunSchema },
97
- statuses: [
98
- { code: 200, description: 'Eval runs returned' },
99
- { code: 401, description: 'Unauthorized — invalid or missing Bearer token' },
100
- ],
101
- examplePath: '/cli/eval-run',
102
- },
103
- {
104
- id: 'get-eval-run',
105
- title: 'Get Eval Run',
106
- sectionTitle: 'Eval Runs',
107
- method: 'GET',
108
- path: '/cli/eval-run/{id}',
109
- description: 'Get a specific evaluation run by ID.',
110
- pathParams: [{ name: 'id', type: 'string', description: 'Eval run ID', required: true }],
111
- queryParams: [],
112
- requestBody: null,
113
- responseDescription: 'Evaluation run object.',
114
- statuses: [
115
- { code: 200, description: 'Eval run returned' },
116
- { code: 401, description: 'Unauthorized — invalid or missing Bearer token' },
117
- { code: 404, description: 'Eval run not found' },
118
- ],
119
- examplePath: '/cli/eval-run/er_abc123',
120
- },
121
- ],
122
- };
123
-
124
- export default service;
@@ -1,92 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- export const EvalRunStartEventSchema = z
4
- .object({
5
- id: z.string().describe('the eval run id'),
6
- sessionId: z.string().describe('the session id'),
7
- evalId: z.string().describe('the evaluation record id (evalid_...)'),
8
- evalIdentifier: z.string().describe('the stable eval identifier (eval_...)'),
9
- orgId: z.string().describe('the organization id'),
10
- projectId: z.string().describe('the project id'),
11
- devmode: z.boolean().describe('true if running in devmode'),
12
- deploymentId: z.string().optional().describe('the deployment id'),
13
- spanId: z.string().optional().describe('the span id'),
14
- })
15
- .describe('The event to record an eval run started');
16
-
17
- export type EvalRunStartEvent = z.infer<typeof EvalRunStartEventSchema>;
18
-
19
- export const EvalRunCompleteEventSchema = z
20
- .object({
21
- id: z.string().describe('the eval run id'),
22
- error: z.string().optional().describe('the optional error message if the eval run failed'),
23
- result: z.any().optional().describe('the eval run result'),
24
- })
25
- .describe('The event to record an eval run completed');
26
-
27
- export type EvalRunCompleteEvent = z.infer<typeof EvalRunCompleteEventSchema>;
28
-
29
- export const EvalRunStartEventDelayedSchema = z.intersection(
30
- EvalRunStartEventSchema,
31
- z.object({ timestamp: z.number().describe('the event timestamp in epoch') })
32
- );
33
-
34
- export const EvalRunCompleteEventDelayedSchema = z.intersection(
35
- EvalRunCompleteEventSchema,
36
- z.object({ timestamp: z.number().describe('the event timestamp in epoch') })
37
- );
38
-
39
- /**
40
- * EvalRunEventProvider is a provider for logging and tracking agent evaluation run lifecycle events.
41
- * Eval runs represent test executions of agents for quality assurance and performance monitoring.
42
- */
43
- export interface EvalRunEventProvider {
44
- /**
45
- * Called when an agent evaluation run starts. Records the initial context including
46
- * the evaluation ID, associated session, and organization/project metadata.
47
- *
48
- * @param event - EvalRunStartEvent containing evaluation initialization data
49
- *
50
- * @example
51
- * ```typescript
52
- * await evalProvider.start({
53
- * id: 'evalrun_abc123',
54
- * sessionId: 'sess_abc123',
55
- * evalId: 'evalid_abc123',
56
- * evalIdentifier: 'eval_abc123',
57
- * orgId: 'org_456',
58
- * projectId: 'proj_789',
59
- * devmode: true
60
- * });
61
- * ```
62
- */
63
- start(event: EvalRunStartEvent): Promise<void>;
64
-
65
- /**
66
- * Called when an agent evaluation run completes (successfully or with error).
67
- * Records final results, metrics, and any errors encountered during evaluation.
68
- *
69
- * @param event - EvalRunCompleteEvent containing evaluation results and status
70
- *
71
- * @example
72
- * ```typescript
73
- * // Successful evaluation completion
74
- * await evalProvider.complete({
75
- * id: 'eval-run-123',
76
- * result: {
77
- * passed: true,
78
- * score: 0.95,
79
- * metrics: { latency: 250, accuracy: 0.98 }
80
- * }
81
- * });
82
- *
83
- * // Evaluation with error
84
- * await evalProvider.complete({
85
- * id: 'eval-run-123',
86
- * error: 'Agent timeout after 30 seconds',
87
- * result: { passed: false }
88
- * });
89
- * ```
90
- */
91
- complete(event: EvalRunCompleteEvent): Promise<void>;
92
- }
@@ -1,33 +0,0 @@
1
- import { z } from 'zod';
2
- import { type APIClient, APIResponseSchema } from '../api.ts';
3
-
4
- export const EvaluationDetailSchema = z.object({
5
- id: z.string().describe('Evaluation ID'),
6
- name: z.string().describe('Evaluation name'),
7
- description: z.string().nullable().describe('Evaluation description'),
8
- identifier: z.string().nullable().describe('Stable evaluation identifier'),
9
- agentIdentifier: z.string().describe('Agent identifier'),
10
- projectId: z.string().describe('Project ID'),
11
- orgId: z.string().describe('Organization ID'),
12
- devmode: z.boolean().describe('Whether this is a devmode evaluation'),
13
- createdAt: z.string().describe('Creation timestamp'),
14
- updatedAt: z.string().describe('Last updated timestamp'),
15
- });
16
-
17
- export const EvalGetResponseSchema = APIResponseSchema(EvaluationDetailSchema);
18
-
19
- export type EvaluationDetail = z.infer<typeof EvaluationDetailSchema>;
20
-
21
- export async function evalGet(client: APIClient, id: string): Promise<EvaluationDetail> {
22
- const resp = await client.request<z.infer<typeof EvalGetResponseSchema>>(
23
- 'GET',
24
- `/cli/eval/${encodeURIComponent(id)}`,
25
- EvalGetResponseSchema
26
- );
27
-
28
- if (resp.success) {
29
- return resp.data;
30
- }
31
-
32
- throw new Error(resp.message || 'Failed to get evaluation');
33
- }
@@ -1,29 +0,0 @@
1
- export * from './events.ts';
2
- export {
3
- EvalGetResponseSchema,
4
- type EvaluationDetail,
5
- EvaluationDetailSchema,
6
- evalGet,
7
- } from './get.ts';
8
- export {
9
- EvalListResponseData,
10
- EvalListResponseSchema,
11
- type Evaluation,
12
- type EvaluationListRequest,
13
- EvaluationSchema,
14
- evalList,
15
- } from './list.ts';
16
- export {
17
- type EvalRunDetail,
18
- EvalRunDetailSchema,
19
- EvalRunGetResponseSchema,
20
- evalRunGet,
21
- } from './run-get.ts';
22
- export {
23
- type EvalRunListItem,
24
- type EvalRunListRequest,
25
- EvalRunListResponseData,
26
- EvalRunListResponseSchema,
27
- EvalRunSchema,
28
- evalRunList,
29
- } from './run-list.ts';
@@ -1,49 +0,0 @@
1
- import { z } from 'zod';
2
- import { type APIClient, APIResponseSchema } from '../api.ts';
3
-
4
- export const EvaluationSchema = z.object({
5
- id: z.string().describe('Evaluation ID'),
6
- name: z.string().describe('Evaluation name'),
7
- description: z.string().nullable().describe('Evaluation description'),
8
- identifier: z.string().nullable().describe('Stable evaluation identifier'),
9
- agentIdentifier: z.string().describe('Agent identifier'),
10
- projectId: z.string().describe('Project ID'),
11
- devmode: z.boolean().describe('Whether this is a devmode evaluation'),
12
- createdAt: z.string().describe('Creation timestamp'),
13
- updatedAt: z.string().describe('Last updated timestamp'),
14
- });
15
-
16
- export const EvalListResponseData = z.array(EvaluationSchema);
17
- export const EvalListResponseSchema = APIResponseSchema(EvalListResponseData);
18
-
19
- export type Evaluation = z.infer<typeof EvaluationSchema>;
20
- export type EvaluationListRequest = {
21
- projectId?: string;
22
- agentId?: string;
23
- orgId?: string;
24
- };
25
-
26
- export async function evalList(
27
- client: APIClient,
28
- request: EvaluationListRequest = {}
29
- ): Promise<Evaluation[]> {
30
- const params = new URLSearchParams();
31
- if (request.orgId) params.set('orgId', request.orgId);
32
- if (request.projectId) params.set('projectId', request.projectId);
33
- if (request.agentId) params.set('agentId', request.agentId);
34
-
35
- const queryString = params.toString();
36
- const url = `/cli/eval${queryString ? `?${queryString}` : ''}`;
37
-
38
- const resp = await client.request<z.infer<typeof EvalListResponseSchema>>(
39
- 'GET',
40
- url,
41
- EvalListResponseSchema
42
- );
43
-
44
- if (resp.success) {
45
- return resp.data;
46
- }
47
-
48
- throw new Error(resp.message || 'Failed to list evaluations');
49
- }
@@ -1,39 +0,0 @@
1
- import { z } from 'zod';
2
- import { type APIClient, APIResponseSchema } from '../api.ts';
3
-
4
- export const EvalRunDetailSchema = z.object({
5
- id: z.string().describe('Eval run ID'),
6
- sessionId: z.string().describe('Session ID'),
7
- evalId: z.string().describe('Evaluation record ID'),
8
- evalIdentifier: z.string().nullable().describe('Stable evaluation identifier'),
9
- evalName: z.string().nullable().describe('Evaluation name'),
10
- agentIdentifier: z.string().nullable().describe('Agent identifier'),
11
- projectId: z.string().describe('Project ID'),
12
- orgId: z.string().describe('Organization ID'),
13
- deploymentId: z.string().nullable().describe('Deployment ID'),
14
- devmode: z.boolean().describe('Whether this is a devmode run'),
15
- pending: z.boolean().describe('Whether the eval run is pending'),
16
- success: z.boolean().describe('Whether the eval run succeeded'),
17
- error: z.string().nullable().describe('Error message if failed'),
18
- result: z.any().nullable().describe('Eval run result'),
19
- createdAt: z.string().describe('Creation timestamp'),
20
- updatedAt: z.string().describe('Last updated timestamp'),
21
- });
22
-
23
- export const EvalRunGetResponseSchema = APIResponseSchema(EvalRunDetailSchema);
24
-
25
- export type EvalRunDetail = z.infer<typeof EvalRunDetailSchema>;
26
-
27
- export async function evalRunGet(client: APIClient, id: string): Promise<EvalRunDetail> {
28
- const resp = await client.request<z.infer<typeof EvalRunGetResponseSchema>>(
29
- 'GET',
30
- `/cli/eval-run/${encodeURIComponent(id)}`,
31
- EvalRunGetResponseSchema
32
- );
33
-
34
- if (resp.success) {
35
- return resp.data;
36
- }
37
-
38
- throw new Error(resp.message || 'Failed to get eval run');
39
- }
@@ -1,59 +0,0 @@
1
- import { z } from 'zod';
2
- import { type APIClient, APIResponseSchema } from '../api.ts';
3
-
4
- export const EvalRunSchema = z.object({
5
- id: z.string().describe('Eval run ID'),
6
- sessionId: z.string().describe('Session ID'),
7
- evalId: z.string().describe('Evaluation record ID'),
8
- evalIdentifier: z.string().nullable().describe('Stable evaluation identifier'),
9
- evalName: z.string().nullable().describe('Evaluation name'),
10
- agentIdentifier: z.string().nullable().describe('Agent identifier'),
11
- projectId: z.string().describe('Project ID'),
12
- deploymentId: z.string().nullable().describe('Deployment ID'),
13
- devmode: z.boolean().describe('Whether this is a devmode run'),
14
- pending: z.boolean().describe('Whether the eval run is pending'),
15
- success: z.boolean().describe('Whether the eval run succeeded'),
16
- error: z.string().nullable().describe('Error message if failed'),
17
- result: z.any().nullable().describe('Eval run result'),
18
- createdAt: z.string().describe('Creation timestamp'),
19
- updatedAt: z.string().describe('Last updated timestamp'),
20
- });
21
-
22
- export const EvalRunListResponseData = z.array(EvalRunSchema);
23
- export const EvalRunListResponseSchema = APIResponseSchema(EvalRunListResponseData);
24
-
25
- export type EvalRunListItem = z.infer<typeof EvalRunSchema>;
26
- export type EvalRunListRequest = {
27
- projectId?: string;
28
- agentId?: string;
29
- evalId?: string;
30
- sessionId?: string;
31
- orgId?: string;
32
- };
33
-
34
- export async function evalRunList(
35
- client: APIClient,
36
- request: EvalRunListRequest = {}
37
- ): Promise<EvalRunListItem[]> {
38
- const params = new URLSearchParams();
39
- if (request.orgId) params.set('orgId', request.orgId);
40
- if (request.projectId) params.set('projectId', request.projectId);
41
- if (request.agentId) params.set('agentId', request.agentId);
42
- if (request.evalId) params.set('evalId', request.evalId);
43
- if (request.sessionId) params.set('sessionId', request.sessionId);
44
-
45
- const queryString = params.toString();
46
- const url = `/cli/eval-run${queryString ? `?${queryString}` : ''}`;
47
-
48
- const resp = await client.request<z.infer<typeof EvalRunListResponseSchema>>(
49
- 'GET',
50
- url,
51
- EvalRunListResponseSchema
52
- );
53
-
54
- if (resp.success) {
55
- return resp.data;
56
- }
57
-
58
- throw new Error(resp.message || 'Failed to list eval runs');
59
- }
package/src/webrtc.ts DELETED
@@ -1,259 +0,0 @@
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
- }