@agentuity/runtime 1.0.0 → 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/dist/handlers/cron.d.ts +32 -6
- package/dist/handlers/cron.d.ts.map +1 -1
- package/dist/handlers/cron.js +64 -30
- package/dist/handlers/cron.js.map +1 -1
- package/dist/handlers/index.d.ts +2 -1
- package/dist/handlers/index.d.ts.map +1 -1
- package/dist/handlers/index.js +1 -0
- package/dist/handlers/index.js.map +1 -1
- package/dist/handlers/sse.d.ts +73 -1
- package/dist/handlers/sse.d.ts.map +1 -1
- package/dist/handlers/sse.js +14 -40
- package/dist/handlers/sse.js.map +1 -1
- package/dist/handlers/webrtc.d.ts +49 -0
- package/dist/handlers/webrtc.d.ts.map +1 -0
- package/dist/handlers/webrtc.js +109 -0
- package/dist/handlers/webrtc.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/router.d.ts +1 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +1 -0
- package/dist/router.js.map +1 -1
- package/dist/webrtc-signaling.d.ts +80 -0
- package/dist/webrtc-signaling.d.ts.map +1 -0
- package/dist/webrtc-signaling.js +237 -0
- package/dist/webrtc-signaling.js.map +1 -0
- package/package.json +7 -7
- package/src/handlers/cron.ts +129 -7
- package/src/handlers/index.ts +2 -0
- package/src/handlers/sse.ts +102 -2
- package/src/handlers/webrtc.ts +125 -0
- package/src/index.ts +14 -1
- package/src/router.ts +1 -0
- package/src/webrtc-signaling.ts +288 -0
package/dist/handlers/cron.d.ts
CHANGED
|
@@ -5,34 +5,60 @@ import type { Env } from '../app';
|
|
|
5
5
|
* Receives the Hono context and can return any response.
|
|
6
6
|
*/
|
|
7
7
|
export type CronHandler<E extends Env = Env> = (c: Context<E>) => unknown | Promise<unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Options for the cron middleware.
|
|
10
|
+
*/
|
|
11
|
+
export interface CronOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Whether to require signature authentication for cron requests.
|
|
14
|
+
* When true, requests must include valid X-Agentuity-Cron-Signature
|
|
15
|
+
* and X-Agentuity-Cron-Timestamp headers signed with the project's SDK key.
|
|
16
|
+
* Signatures are valid for 5 minutes.
|
|
17
|
+
*/
|
|
18
|
+
auth: boolean;
|
|
19
|
+
}
|
|
8
20
|
/**
|
|
9
21
|
* Creates a cron middleware for scheduled task endpoints.
|
|
10
22
|
*
|
|
11
23
|
* **Important:** Cron endpoints must use POST method. The middleware will throw
|
|
12
24
|
* an error if called with any other HTTP method.
|
|
13
25
|
*
|
|
14
|
-
* Use with router.post() to create a cron endpoint:
|
|
15
|
-
*
|
|
16
26
|
* @example
|
|
17
27
|
* ```typescript
|
|
18
28
|
* import { createRouter, cron } from '@agentuity/runtime';
|
|
19
29
|
*
|
|
20
30
|
* const router = createRouter();
|
|
21
31
|
*
|
|
22
|
-
* //
|
|
23
|
-
* router.post('/daily-cleanup', cron('0 0 * * *', (c) => {
|
|
32
|
+
* // With authentication (recommended)
|
|
33
|
+
* router.post('/daily-cleanup', cron('0 0 * * *', { auth: true }, (c) => {
|
|
24
34
|
* c.var.logger.info('Running daily cleanup');
|
|
25
35
|
* return { status: 'cleanup complete' };
|
|
26
36
|
* }));
|
|
27
37
|
*
|
|
28
|
-
* //
|
|
29
|
-
* router.post('/health-check', cron('0 * * * *', (c) => {
|
|
38
|
+
* // Without authentication (not recommended for production)
|
|
39
|
+
* router.post('/health-check', cron('0 * * * *', { auth: false }, (c) => {
|
|
30
40
|
* c.var.logger.info('Running hourly health check');
|
|
31
41
|
* return c.text('OK');
|
|
32
42
|
* }));
|
|
33
43
|
* ```
|
|
34
44
|
*
|
|
35
45
|
* @param schedule - Cron expression (e.g., '0 0 * * *' for daily at midnight)
|
|
46
|
+
* @param options - Configuration options including auth requirement
|
|
47
|
+
* @param handler - Handler function to run on schedule
|
|
48
|
+
* @returns Hono handler for cron endpoint
|
|
49
|
+
*/
|
|
50
|
+
export declare function cron<E extends Env = Env>(schedule: string, options: CronOptions, handler: CronHandler<E>): Handler<E>;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a cron middleware for scheduled task endpoints.
|
|
53
|
+
*
|
|
54
|
+
* @deprecated Use the overload with explicit `options` parameter: `cron(schedule, { auth: true }, handler)`
|
|
55
|
+
*
|
|
56
|
+
* **Important:** Cron endpoints must use POST method. The middleware will throw
|
|
57
|
+
* an error if called with any other HTTP method.
|
|
58
|
+
*
|
|
59
|
+
* This deprecated overload defaults to `auth: false` for backwards compatibility.
|
|
60
|
+
*
|
|
61
|
+
* @param schedule - Cron expression (e.g., '0 0 * * *' for daily at midnight)
|
|
36
62
|
* @param handler - Handler function to run on schedule
|
|
37
63
|
* @returns Hono handler for cron endpoint
|
|
38
64
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../src/handlers/cron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE7C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7F
|
|
1
|
+
{"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../src/handlers/cron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE7C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B;;;;;OAKG;IACH,IAAI,EAAE,OAAO,CAAC;CACd;AA6DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,EACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CAAC;AAEd;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAqDjG;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACb"}
|
package/dist/handlers/cron.js
CHANGED
|
@@ -1,41 +1,75 @@
|
|
|
1
1
|
import { returnResponse } from '../_util';
|
|
2
|
+
// Maximum age for cron signatures (5 minutes)
|
|
3
|
+
const MAX_SIGNATURE_AGE_SECONDS = 300;
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* **Important:** Cron endpoints must use POST method. The middleware will throw
|
|
6
|
-
* an error if called with any other HTTP method.
|
|
7
|
-
*
|
|
8
|
-
* Use with router.post() to create a cron endpoint:
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import { createRouter, cron } from '@agentuity/runtime';
|
|
13
|
-
*
|
|
14
|
-
* const router = createRouter();
|
|
15
|
-
*
|
|
16
|
-
* // Daily cleanup at midnight
|
|
17
|
-
* router.post('/daily-cleanup', cron('0 0 * * *', (c) => {
|
|
18
|
-
* c.var.logger.info('Running daily cleanup');
|
|
19
|
-
* return { status: 'cleanup complete' };
|
|
20
|
-
* }));
|
|
21
|
-
*
|
|
22
|
-
* // Hourly health check
|
|
23
|
-
* router.post('/health-check', cron('0 * * * *', (c) => {
|
|
24
|
-
* c.var.logger.info('Running hourly health check');
|
|
25
|
-
* return c.text('OK');
|
|
26
|
-
* }));
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @param schedule - Cron expression (e.g., '0 0 * * *' for daily at midnight)
|
|
30
|
-
* @param handler - Handler function to run on schedule
|
|
31
|
-
* @returns Hono handler for cron endpoint
|
|
5
|
+
* Verifies the cron request signature from Catalyst.
|
|
6
|
+
* Returns true if signature is valid or if running in local dev mode (no SDK key).
|
|
32
7
|
*/
|
|
33
|
-
|
|
8
|
+
async function verifyCronSignature(c, body) {
|
|
9
|
+
const sdkKey = process.env.AGENTUITY_SDK_KEY;
|
|
10
|
+
// In local dev mode (no SDK key), allow all requests
|
|
11
|
+
if (!sdkKey) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
const signature = c.req.header('X-Agentuity-Cron-Signature');
|
|
15
|
+
const timestampStr = c.req.header('X-Agentuity-Cron-Timestamp');
|
|
16
|
+
// If no signature headers, reject the request
|
|
17
|
+
if (!signature || !timestampStr) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
// Verify timestamp is within acceptable range (prevent replay attacks)
|
|
21
|
+
const timestamp = parseInt(timestampStr, 10);
|
|
22
|
+
const now = Math.floor(Date.now() / 1000);
|
|
23
|
+
if (isNaN(timestamp) || Math.abs(now - timestamp) > MAX_SIGNATURE_AGE_SECONDS) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
// Validate signature format: must be 'v1=' followed by valid hex (64 chars for SHA-256)
|
|
27
|
+
if (!signature.startsWith('v1=')) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const hexPayload = signature.slice(3);
|
|
31
|
+
if (!/^[0-9a-f]{64}$/i.test(hexPayload)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
// Decode hex payload into Uint8Array
|
|
35
|
+
const incomingSigBytes = new Uint8Array(32);
|
|
36
|
+
for (let i = 0; i < 32; i++) {
|
|
37
|
+
incomingSigBytes[i] = parseInt(hexPayload.slice(i * 2, i * 2 + 2), 16);
|
|
38
|
+
}
|
|
39
|
+
// Verify the signature using constant-time comparison
|
|
40
|
+
const message = `${timestamp}.${body}`;
|
|
41
|
+
const encoder = new TextEncoder();
|
|
42
|
+
const key = await crypto.subtle.importKey('raw', encoder.encode(sdkKey), { name: 'HMAC', hash: 'SHA-256' }, false, ['verify']);
|
|
43
|
+
return crypto.subtle.verify('HMAC', key, incomingSigBytes, encoder.encode(message));
|
|
44
|
+
}
|
|
45
|
+
export function cron(schedule, optionsOrHandler, maybeHandler) {
|
|
46
|
+
let options;
|
|
47
|
+
let handler;
|
|
48
|
+
if (typeof optionsOrHandler === 'function') {
|
|
49
|
+
// Deprecated: cron(schedule, handler) - defaults to auth: false
|
|
50
|
+
options = { auth: false };
|
|
51
|
+
handler = optionsOrHandler;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// New: cron(schedule, options, handler)
|
|
55
|
+
options = optionsOrHandler;
|
|
56
|
+
handler = maybeHandler;
|
|
57
|
+
}
|
|
34
58
|
return async (c) => {
|
|
35
59
|
if (c.req.method !== 'POST') {
|
|
36
60
|
throw new Error(`Cron endpoint must use POST method, but received ${c.req.method}. ` +
|
|
37
61
|
`Use router.post() instead of router.${c.req.method.toLowerCase()}().`);
|
|
38
62
|
}
|
|
63
|
+
if (options.auth) {
|
|
64
|
+
// Clone the request to read body for signature verification without consuming it
|
|
65
|
+
const clonedReq = c.req.raw.clone();
|
|
66
|
+
const body = await clonedReq.text();
|
|
67
|
+
// Verify the cron signature
|
|
68
|
+
const isValid = await verifyCronSignature(c, body);
|
|
69
|
+
if (!isValid) {
|
|
70
|
+
return c.json({ error: 'Unauthorized' }, 401);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
39
73
|
let result = handler(c);
|
|
40
74
|
if (result instanceof Promise) {
|
|
41
75
|
result = await result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron.js","sourceRoot":"","sources":["../../src/handlers/cron.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"cron.js","sourceRoot":"","sources":["../../src/handlers/cron.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAsB1C,8CAA8C;AAC9C,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAEtC;;;GAGG;AACH,KAAK,UAAU,mBAAmB,CAAC,CAAU,EAAE,IAAY;IAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAE7C,qDAAqD;IACrD,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC;IAEhE,8CAA8C;IAC9C,IAAI,CAAC,SAAS,IAAI,CAAC,YAAY,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,uEAAuE;IACvE,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1C,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,yB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MAAM,CAAC;QACf,CAAC;QAED,OAAO,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC;AACH,CAAC"}
|
package/dist/handlers/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { websocket, type WebSocketConnection, type WebSocketHandler } from './websocket';
|
|
2
|
-
export { sse, type SSEMessage, type SSEStream, type SSEHandler, STREAM_DONE_PROMISE_KEY, IS_STREAMING_RESPONSE_KEY, } from './sse';
|
|
2
|
+
export { sse, type SSEMessage, type SSEStream, type SSEHandler, type SSEOptions, STREAM_DONE_PROMISE_KEY, IS_STREAMING_RESPONSE_KEY, } from './sse';
|
|
3
3
|
export { stream, type StreamHandler } from './stream';
|
|
4
4
|
export { cron, type CronHandler, type CronMetadata } from './cron';
|
|
5
|
+
export { webrtc, type WebRTCHandler, type WebRTCOptions } from './webrtc';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EACN,GAAG,EACH,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,EACf,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EACN,GAAG,EACH,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,UAAU,EACf,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/handlers/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmD,MAAM,aAAa,CAAC;AACzF,OAAO,EACN,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmD,MAAM,aAAa,CAAC;AACzF,OAAO,EACN,GAAG,EAKH,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,MAAM,EAAsB,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,IAAI,EAAuC,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,MAAM,EAA0C,MAAM,UAAU,CAAC"}
|
package/dist/handlers/sse.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Context, Handler } from 'hono';
|
|
2
|
+
import type { Schema } from '@agentuity/schema';
|
|
2
3
|
import type { Env } from '../app';
|
|
3
4
|
/**
|
|
4
5
|
* Context variable key for stream completion promise.
|
|
@@ -48,6 +49,42 @@ export interface SSEStream {
|
|
|
48
49
|
* Receives the Hono context and SSE stream with a flattened signature.
|
|
49
50
|
*/
|
|
50
51
|
export type SSEHandler<E extends Env = Env> = (c: Context<E>, stream: SSEStream) => void | Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Options for configuring SSE middleware.
|
|
54
|
+
*
|
|
55
|
+
* @template TOutput - The type of data that will be sent through the SSE stream.
|
|
56
|
+
* This is used for type inference in generated route registries and does not
|
|
57
|
+
* perform runtime validation (SSE data is serialized via JSON.stringify).
|
|
58
|
+
*/
|
|
59
|
+
export interface SSEOptions<TOutput = unknown> {
|
|
60
|
+
/**
|
|
61
|
+
* Schema defining the output type for SSE events.
|
|
62
|
+
*
|
|
63
|
+
* This schema is used for:
|
|
64
|
+
* - Type inference in generated `routes.ts` registry
|
|
65
|
+
* - Automatic typing of `useEventStream` hook's `data` property
|
|
66
|
+
*
|
|
67
|
+
* The schema is NOT used for runtime validation - SSE messages are sent
|
|
68
|
+
* as-is through the stream. Use this for TypeScript type safety only.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { s } from '@agentuity/schema';
|
|
73
|
+
*
|
|
74
|
+
* const StreamEventSchema = s.object({
|
|
75
|
+
* type: s.enum(['token', 'complete', 'error']),
|
|
76
|
+
* content: s.optional(s.string()),
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* router.get('/stream', sse({ output: StreamEventSchema }, async (c, stream) => {
|
|
80
|
+
* await stream.writeSSE({ data: JSON.stringify({ type: 'token', content: 'Hello' }) });
|
|
81
|
+
* await stream.writeSSE({ data: JSON.stringify({ type: 'complete' }) });
|
|
82
|
+
* stream.close();
|
|
83
|
+
* }));
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
output: Schema<TOutput, TOutput>;
|
|
87
|
+
}
|
|
51
88
|
/**
|
|
52
89
|
* Creates an SSE (Server-Sent Events) middleware for streaming updates to clients.
|
|
53
90
|
*
|
|
@@ -58,7 +95,7 @@ export type SSEHandler<E extends Env = Env> = (c: Context<E>, stream: SSEStream)
|
|
|
58
95
|
*
|
|
59
96
|
* Use with router.get() to create an SSE endpoint:
|
|
60
97
|
*
|
|
61
|
-
* @example
|
|
98
|
+
* @example Basic SSE without typed output
|
|
62
99
|
* ```typescript
|
|
63
100
|
* import { createRouter, sse } from '@agentuity/runtime';
|
|
64
101
|
*
|
|
@@ -83,9 +120,44 @@ export type SSEHandler<E extends Env = Env> = (c: Context<E>, stream: SSEStream)
|
|
|
83
120
|
* }));
|
|
84
121
|
* ```
|
|
85
122
|
*
|
|
123
|
+
* @example SSE with typed output schema
|
|
124
|
+
* ```typescript
|
|
125
|
+
* import { createRouter, sse } from '@agentuity/runtime';
|
|
126
|
+
* import { s } from '@agentuity/schema';
|
|
127
|
+
*
|
|
128
|
+
* // Define your SSE event schema
|
|
129
|
+
* export const outputSchema = s.object({
|
|
130
|
+
* type: s.enum(['token', 'complete', 'error']),
|
|
131
|
+
* content: s.optional(s.string()),
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* const router = createRouter();
|
|
135
|
+
*
|
|
136
|
+
* // Pass schema as first argument for typed SSE routes
|
|
137
|
+
* router.get('/stream', sse({ output: outputSchema }, async (c, stream) => {
|
|
138
|
+
* await stream.writeSSE({ data: JSON.stringify({ type: 'token', content: 'Hello' }) });
|
|
139
|
+
* await stream.writeSSE({ data: JSON.stringify({ type: 'complete' }) });
|
|
140
|
+
* stream.close();
|
|
141
|
+
* }));
|
|
142
|
+
*
|
|
143
|
+
* // On the frontend, useEventStream will now have typed data:
|
|
144
|
+
* // const { data } = useEventStream('/api/stream');
|
|
145
|
+
* // data.type is 'token' | 'complete' | 'error'
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
86
148
|
* @param handler - Handler function receiving context and SSE stream
|
|
149
|
+
* @param options - Optional configuration with output schema for type inference
|
|
87
150
|
* @returns Hono handler for SSE streaming
|
|
88
151
|
* @see https://github.com/agentuity/sdk/issues/471
|
|
152
|
+
* @see https://github.com/agentuity/sdk/issues/855
|
|
89
153
|
*/
|
|
90
154
|
export declare function sse<E extends Env = Env>(handler: SSEHandler<E>): Handler<E>;
|
|
155
|
+
/**
|
|
156
|
+
* Creates an SSE middleware with typed output schema.
|
|
157
|
+
*
|
|
158
|
+
* @param options - Configuration object containing the output schema
|
|
159
|
+
* @param handler - Handler function receiving context and SSE stream
|
|
160
|
+
* @returns Hono handler for SSE streaming
|
|
161
|
+
*/
|
|
162
|
+
export declare function sse<E extends Env = Env, TOutput = unknown>(options: SSEOptions<TOutput>, handler: SSEHandler<E>): Handler<E>;
|
|
91
163
|
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/handlers/sse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAI7C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/handlers/sse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAI7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAUlC;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB;;;;OAIG;IACH,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE;;OAEG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD;;OAEG;IACH,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IACxC;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAC7C,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EACb,MAAM,EAAE,SAAS,KACb,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,OAAO,GAAG,OAAO;IAC5C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;CACjC;AA2BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC7E;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,OAAO,GAAG,OAAO,EACzD,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,EAC5B,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/handlers/sse.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { stream as honoStream } from 'hono/streaming';
|
|
2
2
|
import { context as otelContext, ROOT_CONTEXT } from '@opentelemetry/api';
|
|
3
|
+
import { StructuredError } from '@agentuity/core';
|
|
3
4
|
import { getAgentAsyncLocalStorage } from '../_context';
|
|
5
|
+
/**
|
|
6
|
+
* Error thrown when sse() is called without a handler function.
|
|
7
|
+
*/
|
|
8
|
+
const SSEHandlerMissingError = StructuredError('SSEHandlerMissingError', 'An SSE handler function is required. Use sse(handler) or sse({ output: schema }, handler).');
|
|
4
9
|
/**
|
|
5
10
|
* Context variable key for stream completion promise.
|
|
6
11
|
* Used by middleware to defer session/thread saving until stream completes.
|
|
@@ -36,46 +41,15 @@ function formatSSEMessage(message) {
|
|
|
36
41
|
text += '\n';
|
|
37
42
|
return text;
|
|
38
43
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* import { createRouter, sse } from '@agentuity/runtime';
|
|
52
|
-
*
|
|
53
|
-
* const router = createRouter();
|
|
54
|
-
*
|
|
55
|
-
* router.get('/events', sse((c, stream) => {
|
|
56
|
-
* let count = 0;
|
|
57
|
-
* const interval = setInterval(() => {
|
|
58
|
-
* stream.writeSSE({
|
|
59
|
-
* data: `Event ${++count}`,
|
|
60
|
-
* event: 'update'
|
|
61
|
-
* });
|
|
62
|
-
* if (count >= 10) {
|
|
63
|
-
* clearInterval(interval);
|
|
64
|
-
* stream.close();
|
|
65
|
-
* }
|
|
66
|
-
* }, 1000);
|
|
67
|
-
*
|
|
68
|
-
* stream.onAbort(() => {
|
|
69
|
-
* clearInterval(interval);
|
|
70
|
-
* });
|
|
71
|
-
* }));
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
* @param handler - Handler function receiving context and SSE stream
|
|
75
|
-
* @returns Hono handler for SSE streaming
|
|
76
|
-
* @see https://github.com/agentuity/sdk/issues/471
|
|
77
|
-
*/
|
|
78
|
-
export function sse(handler) {
|
|
44
|
+
export function sse(handlerOrOptions, maybeHandler) {
|
|
45
|
+
// Determine if first arg is options or handler
|
|
46
|
+
const handler = typeof handlerOrOptions === 'function' ? handlerOrOptions : maybeHandler;
|
|
47
|
+
// Validate handler is provided - catches sse({ output }) without handler
|
|
48
|
+
if (!handler) {
|
|
49
|
+
throw new SSEHandlerMissingError();
|
|
50
|
+
}
|
|
51
|
+
// Note: options.output is captured for type inference but not used at runtime
|
|
52
|
+
// The CLI extracts this during build to generate typed route registries
|
|
79
53
|
return (c) => {
|
|
80
54
|
const asyncLocalStorage = getAgentAsyncLocalStorage();
|
|
81
55
|
const capturedContext = asyncLocalStorage.getStore();
|
package/dist/handlers/sse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/handlers/sse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAGxD;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/handlers/sse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAGxD;;GAEG;AACH,MAAM,sBAAsB,GAAG,eAAe,CAC7C,wBAAwB,E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YACF,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Context, MiddlewareHandler } from 'hono';
|
|
2
|
+
import type { Env } from '../app';
|
|
3
|
+
import { WebRTCRoomManager, type WebRTCOptions } from '../webrtc-signaling';
|
|
4
|
+
export type { WebRTCOptions };
|
|
5
|
+
/**
|
|
6
|
+
* Handler function for WebRTC signaling connections.
|
|
7
|
+
* Receives the Hono context and WebRTCRoomManager.
|
|
8
|
+
*/
|
|
9
|
+
export type WebRTCHandler<E extends Env = Env> = (c: Context<E>, roomManager: WebRTCRoomManager) => void | Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a WebRTC signaling middleware for peer-to-peer communication.
|
|
12
|
+
*
|
|
13
|
+
* This middleware sets up a WebSocket-based signaling server that handles:
|
|
14
|
+
* - Room membership and peer discovery
|
|
15
|
+
* - SDP offer/answer relay
|
|
16
|
+
* - ICE candidate relay
|
|
17
|
+
*
|
|
18
|
+
* Use with router.get() to create a WebRTC signaling endpoint:
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { createRouter, webrtc } from '@agentuity/runtime';
|
|
23
|
+
*
|
|
24
|
+
* const router = createRouter();
|
|
25
|
+
*
|
|
26
|
+
* // Basic signaling endpoint
|
|
27
|
+
* router.get('/call/signal', webrtc());
|
|
28
|
+
*
|
|
29
|
+
* // With options
|
|
30
|
+
* router.get('/call/signal', webrtc({ maxPeers: 4 }));
|
|
31
|
+
*
|
|
32
|
+
* // With callbacks for monitoring
|
|
33
|
+
* router.get('/call/signal', webrtc({
|
|
34
|
+
* maxPeers: 2,
|
|
35
|
+
* callbacks: {
|
|
36
|
+
* onRoomCreated: (roomId) => console.log(`Room ${roomId} created`),
|
|
37
|
+
* onPeerJoin: (peerId, roomId) => console.log(`${peerId} joined ${roomId}`),
|
|
38
|
+
* onPeerLeave: (peerId, roomId, reason) => {
|
|
39
|
+
* console.log(`${peerId} left ${roomId}: ${reason}`);
|
|
40
|
+
* },
|
|
41
|
+
* },
|
|
42
|
+
* }));
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @param options - Configuration options for WebRTC signaling
|
|
46
|
+
* @returns Hono middleware handler for WebSocket upgrade
|
|
47
|
+
*/
|
|
48
|
+
export declare function webrtc<E extends Env = Env>(options?: WebRTCOptions): MiddlewareHandler<E>;
|
|
49
|
+
//# sourceMappingURL=webrtc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webrtc.d.ts","sourceRoot":"","sources":["../../src/handlers/webrtc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAIvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG5E,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAChD,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EACb,WAAW,EAAE,iBAAiB,KAC1B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAmEzF"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { upgradeWebSocket } from 'hono/bun';
|
|
2
|
+
import { context as otelContext, ROOT_CONTEXT } from '@opentelemetry/api';
|
|
3
|
+
import { getAgentAsyncLocalStorage } from '../_context';
|
|
4
|
+
import { WebRTCRoomManager } from '../webrtc-signaling';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a WebRTC signaling middleware for peer-to-peer communication.
|
|
7
|
+
*
|
|
8
|
+
* This middleware sets up a WebSocket-based signaling server that handles:
|
|
9
|
+
* - Room membership and peer discovery
|
|
10
|
+
* - SDP offer/answer relay
|
|
11
|
+
* - ICE candidate relay
|
|
12
|
+
*
|
|
13
|
+
* Use with router.get() to create a WebRTC signaling endpoint:
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { createRouter, webrtc } from '@agentuity/runtime';
|
|
18
|
+
*
|
|
19
|
+
* const router = createRouter();
|
|
20
|
+
*
|
|
21
|
+
* // Basic signaling endpoint
|
|
22
|
+
* router.get('/call/signal', webrtc());
|
|
23
|
+
*
|
|
24
|
+
* // With options
|
|
25
|
+
* router.get('/call/signal', webrtc({ maxPeers: 4 }));
|
|
26
|
+
*
|
|
27
|
+
* // With callbacks for monitoring
|
|
28
|
+
* router.get('/call/signal', webrtc({
|
|
29
|
+
* maxPeers: 2,
|
|
30
|
+
* callbacks: {
|
|
31
|
+
* onRoomCreated: (roomId) => console.log(`Room ${roomId} created`),
|
|
32
|
+
* onPeerJoin: (peerId, roomId) => console.log(`${peerId} joined ${roomId}`),
|
|
33
|
+
* onPeerLeave: (peerId, roomId, reason) => {
|
|
34
|
+
* console.log(`${peerId} left ${roomId}: ${reason}`);
|
|
35
|
+
* },
|
|
36
|
+
* },
|
|
37
|
+
* }));
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param options - Configuration options for WebRTC signaling
|
|
41
|
+
* @returns Hono middleware handler for WebSocket upgrade
|
|
42
|
+
*/
|
|
43
|
+
export function webrtc(options) {
|
|
44
|
+
const roomManager = new WebRTCRoomManager(options);
|
|
45
|
+
const wsHandler = upgradeWebSocket((_c) => {
|
|
46
|
+
let currentWs;
|
|
47
|
+
// we need a Privder interface here with AsyncLocalStorage and KV
|
|
48
|
+
const asyncLocalStorage = getAgentAsyncLocalStorage();
|
|
49
|
+
const capturedContext = asyncLocalStorage.getStore();
|
|
50
|
+
return {
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
onOpen: (_event, ws) => {
|
|
53
|
+
otelContext.with(ROOT_CONTEXT, () => {
|
|
54
|
+
if (capturedContext) {
|
|
55
|
+
asyncLocalStorage.run(capturedContext, () => {
|
|
56
|
+
currentWs = {
|
|
57
|
+
onOpen: () => { },
|
|
58
|
+
onMessage: () => { },
|
|
59
|
+
onClose: () => { },
|
|
60
|
+
send: (data) => ws.send(data),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
currentWs = {
|
|
66
|
+
onOpen: () => { },
|
|
67
|
+
onMessage: () => { },
|
|
68
|
+
onClose: () => { },
|
|
69
|
+
send: (data) => ws.send(data),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
onMessage: (event, _ws) => {
|
|
76
|
+
if (currentWs) {
|
|
77
|
+
otelContext.with(ROOT_CONTEXT, () => {
|
|
78
|
+
if (capturedContext) {
|
|
79
|
+
asyncLocalStorage.run(capturedContext, () => {
|
|
80
|
+
roomManager.handleMessage(currentWs, String(event.data));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
roomManager.handleMessage(currentWs, String(event.data));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
+
onClose: (_event, _ws) => {
|
|
91
|
+
if (currentWs) {
|
|
92
|
+
otelContext.with(ROOT_CONTEXT, () => {
|
|
93
|
+
if (capturedContext) {
|
|
94
|
+
asyncLocalStorage.run(capturedContext, () => {
|
|
95
|
+
roomManager.handleDisconnect(currentWs);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
roomManager.handleDisconnect(currentWs);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
const middleware = (c, next) => wsHandler(c, next);
|
|
107
|
+
return middleware;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=webrtc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webrtc.js","sourceRoot":"","sources":["../../src/handlers/webrtc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAsB,MAAM,qBAAqB,CAAC;AAc5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,MAAM,CAAsB,OAAuB;IAClE,MAAM,WAAW,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAEnD,MAAM,SAAS,GAAG,gBAAgB,CAAC,CAAC,EAAc,EAAE,EAAE;QACrD,IAAI,SAA0C,CAAC;QAC/C,iEAAiE;QACjE,MAAM,iBAAiB,GAAG,yBAAyB,EAAE,CAAC;QACtD,MAAM,eAAe,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;QAErD,OAAO;YACN,8DAA8D;YAC9D,MAAM,EAAE,CAAC,MAAa,EAAE,EAAO,EAAE,EAAE;gBAClC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;oBACnC,IAAI,eAAe,EAAE,CAAC;wBACrB,iBAAiB,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,EAAE;4BAC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AAC;oBACf,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;wBACnC,IAAI,eAAe,EAAE,CAAC;4BACrB,iBAAiB,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,EAAE;gCAC3C,WAAW,CAAC,gBAAgB,CAAC,SAAU,CAAC,CAAC;4BAC1C,CAAC,CAAC,CAAC;wBACJ,CAAC;6BAAM,CAAC;4BACP,WAAW,CAAC,gBAAgB,CAAC,SAAU,CAAC,CAAC;wBAC1C,CAAC;oBACF,CAAC,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;SACD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAyB,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CACnD,SAA6C,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAEzD,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export { BEACON_SCRIPT, validateBeaconScript } from '@agentuity/frontend';
|
|
|
10
10
|
export { internalExit } from './_process-protection';
|
|
11
11
|
export { registerDevModeRoutes } from './devmode';
|
|
12
12
|
export { type HonoEnv, type WebSocketConnection, createRouter } from './router';
|
|
13
|
-
export { websocket, type WebSocketHandler, sse, type SSEMessage, type SSEStream, type SSEHandler, stream, type StreamHandler, cron, type CronHandler, type CronMetadata, } from './handlers';
|
|
13
|
+
export { websocket, type WebSocketHandler, sse, type SSEMessage, type SSEStream, type SSEHandler, type SSEOptions, stream, type StreamHandler, cron, type CronHandler, type CronMetadata, webrtc, type WebRTCHandler, } from './handlers';
|
|
14
|
+
export { type SignalMessage, type SDPDescription, type ICECandidate, type WebRTCOptions, type WebRTCSignalingCallbacks, WebRTCRoomManager, } from './webrtc-signaling';
|
|
14
15
|
export { EvalHandlerResultSchema, type EvalContext, type EvalRunResultMetadata, type EvalHandlerResult, type EvalRunResultSuccess, type EvalRunResultError, type EvalRunResult, type CreateEvalRunRequest, type ExternalEvalMetadata, type EvalMetadata, type EvalFunction, type Eval, } from './eval';
|
|
15
16
|
export { type ThreadEventName, type SessionEventName, type ThreadState, type MergeOperation, type Thread, type Session, type ThreadIDProvider, type ThreadProvider, type SessionProvider, generateId, DefaultThreadIDProvider, DefaultThread, LazyThreadState, } from './session';
|
|
16
17
|
export { LocalThreadProvider } from './services/thread/local';
|
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,EACN,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,qBAAqB,EACrB,eAAe,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,aAAa,EACb,cAAc,EACd,cAAc,EACd,KAAK,yBAAyB,EAC9B,WAAW,EACX,sBAAsB,EACtB,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,GAAG,EACR,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,SAAS,EACT,MAAM,EACN,WAAW,EACX,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,SAAS,GACT,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,uBAAuB,EAAE,KAAK,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGlE,OAAO,EACN,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,2BA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AAwB,EAC7B,KAAK,aAAa,GAClB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,GAC7B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EACN,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,SAAS,EACT,YAAY,EACZ,oBAAoB,GACpB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAG7F,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,MAAM,WAAW,QAAQ;CAAG;AAK5B,OAAO,EAAE,mBAAmB,EAAE,KAAK,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAGtF,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,8 +19,10 @@ export { internalExit } from './_process-protection';
|
|
|
19
19
|
export { registerDevModeRoutes } from './devmode';
|
|
20
20
|
// router.ts exports
|
|
21
21
|
export { createRouter } from './router';
|
|
22
|
-
// protocol handler exports (websocket, sse, stream, cron)
|
|
23
|
-
export { websocket, sse, stream, cron, } from './handlers';
|
|
22
|
+
// protocol handler exports (websocket, sse, stream, cron, webrtc)
|
|
23
|
+
export { websocket, sse, stream, cron, webrtc, } from './handlers';
|
|
24
|
+
// webrtc-signaling.ts exports
|
|
25
|
+
export { WebRTCRoomManager, } from './webrtc-signaling';
|
|
24
26
|
// eval.ts exports
|
|
25
27
|
export { EvalHandlerResultSchema, } from './eval';
|
|
26
28
|
// session.ts exports
|