agents 0.0.0-e416962 → 0.0.0-e48e5f9

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 (47) hide show
  1. package/README.md +22 -22
  2. package/dist/ai-chat-agent.d.ts +32 -5
  3. package/dist/ai-chat-agent.js +149 -115
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-react.d.ts +18 -5
  6. package/dist/ai-react.js +28 -29
  7. package/dist/ai-react.js.map +1 -1
  8. package/dist/chunk-5YIRLLUX.js +1264 -0
  9. package/dist/chunk-5YIRLLUX.js.map +1 -0
  10. package/dist/chunk-KUH345EY.js +116 -0
  11. package/dist/chunk-KUH345EY.js.map +1 -0
  12. package/dist/{chunk-Q5ZBHY4Z.js → chunk-MW5BQ2FW.js} +49 -36
  13. package/dist/chunk-MW5BQ2FW.js.map +1 -0
  14. package/dist/chunk-PVQZBKN7.js +106 -0
  15. package/dist/chunk-PVQZBKN7.js.map +1 -0
  16. package/dist/client.d.ts +16 -2
  17. package/dist/client.js +6 -126
  18. package/dist/client.js.map +1 -1
  19. package/dist/index-BIJvkfYt.d.ts +614 -0
  20. package/dist/index.d.ts +33 -308
  21. package/dist/index.js +10 -3
  22. package/dist/mcp/client.d.ts +301 -23
  23. package/dist/mcp/client.js +1 -2
  24. package/dist/mcp/do-oauth-client-provider.d.ts +3 -3
  25. package/dist/mcp/do-oauth-client-provider.js +3 -103
  26. package/dist/mcp/do-oauth-client-provider.js.map +1 -1
  27. package/dist/mcp/index.d.ts +23 -13
  28. package/dist/mcp/index.js +150 -175
  29. package/dist/mcp/index.js.map +1 -1
  30. package/dist/observability/index.d.ts +12 -0
  31. package/dist/observability/index.js +10 -0
  32. package/dist/react.d.ts +85 -5
  33. package/dist/react.js +20 -8
  34. package/dist/react.js.map +1 -1
  35. package/dist/schedule.d.ts +6 -6
  36. package/dist/schedule.js +4 -6
  37. package/dist/schedule.js.map +1 -1
  38. package/dist/serializable.d.ts +32 -0
  39. package/dist/serializable.js +1 -0
  40. package/dist/serializable.js.map +1 -0
  41. package/package.json +76 -68
  42. package/src/index.ts +1078 -140
  43. package/dist/chunk-HMLY7DHA.js +0 -16
  44. package/dist/chunk-HN5JVKAZ.js +0 -606
  45. package/dist/chunk-HN5JVKAZ.js.map +0 -1
  46. package/dist/chunk-Q5ZBHY4Z.js.map +0 -1
  47. /package/dist/{chunk-HMLY7DHA.js.map → observability/index.js.map} +0 -0
@@ -1,16 +0,0 @@
1
- var __typeError = (msg) => {
2
- throw TypeError(msg);
3
- };
4
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
-
10
- export {
11
- __privateGet,
12
- __privateAdd,
13
- __privateSet,
14
- __privateMethod
15
- };
16
- //# sourceMappingURL=chunk-HMLY7DHA.js.map
@@ -1,606 +0,0 @@
1
- import {
2
- MCPClientManager
3
- } from "./chunk-Q5ZBHY4Z.js";
4
- import {
5
- __privateAdd,
6
- __privateGet,
7
- __privateMethod,
8
- __privateSet
9
- } from "./chunk-HMLY7DHA.js";
10
-
11
- // src/index.ts
12
- import {
13
- Server,
14
- routePartykitRequest,
15
- getServerByName
16
- } from "partyserver";
17
- import { parseCronExpression } from "cron-schedule";
18
- import { nanoid } from "nanoid";
19
- import { AsyncLocalStorage } from "node:async_hooks";
20
- function isRPCRequest(msg) {
21
- return typeof msg === "object" && msg !== null && "type" in msg && msg.type === "rpc" && "id" in msg && typeof msg.id === "string" && "method" in msg && typeof msg.method === "string" && "args" in msg && Array.isArray(msg.args);
22
- }
23
- function isStateUpdateMessage(msg) {
24
- return typeof msg === "object" && msg !== null && "type" in msg && msg.type === "cf_agent_state" && "state" in msg;
25
- }
26
- var callableMetadata = /* @__PURE__ */ new Map();
27
- function unstable_callable(metadata = {}) {
28
- return function callableDecorator(target, context) {
29
- if (!callableMetadata.has(target)) {
30
- callableMetadata.set(target, metadata);
31
- }
32
- return target;
33
- };
34
- }
35
- function getNextCronTime(cron) {
36
- const interval = parseCronExpression(cron);
37
- return interval.getNextDate();
38
- }
39
- var STATE_ROW_ID = "cf_state_row_id";
40
- var STATE_WAS_CHANGED = "cf_state_was_changed";
41
- var DEFAULT_STATE = {};
42
- var agentContext = new AsyncLocalStorage();
43
- function getCurrentAgent() {
44
- const store = agentContext.getStore();
45
- if (!store) {
46
- throw new Error(
47
- "No agent context found, this means you're trying to access the current agent when none of them are running."
48
- );
49
- }
50
- return store;
51
- }
52
- var _state, _ParentClass, _Agent_instances, setStateInternal_fn, tryCatch_fn, scheduleNextAlarm_fn, isCallable_fn;
53
- var Agent = class extends Server {
54
- constructor(ctx, env) {
55
- super(ctx, env);
56
- __privateAdd(this, _Agent_instances);
57
- __privateAdd(this, _state, DEFAULT_STATE);
58
- __privateAdd(this, _ParentClass, Object.getPrototypeOf(this).constructor);
59
- this.mcp = new MCPClientManager(__privateGet(this, _ParentClass).name, "0.0.1");
60
- /**
61
- * Initial state for the Agent
62
- * Override to provide default state values
63
- */
64
- this.initialState = DEFAULT_STATE;
65
- this.sql`
66
- CREATE TABLE IF NOT EXISTS cf_agents_state (
67
- id TEXT PRIMARY KEY NOT NULL,
68
- state TEXT
69
- )
70
- `;
71
- void this.ctx.blockConcurrencyWhile(async () => {
72
- return __privateMethod(this, _Agent_instances, tryCatch_fn).call(this, async () => {
73
- this.sql`
74
- CREATE TABLE IF NOT EXISTS cf_agents_schedules (
75
- id TEXT PRIMARY KEY NOT NULL DEFAULT (randomblob(9)),
76
- callback TEXT,
77
- payload TEXT,
78
- type TEXT NOT NULL CHECK(type IN ('scheduled', 'delayed', 'cron')),
79
- time INTEGER,
80
- delayInSeconds INTEGER,
81
- cron TEXT,
82
- created_at INTEGER DEFAULT (unixepoch())
83
- )
84
- `;
85
- await this.alarm();
86
- });
87
- });
88
- const _onMessage = this.onMessage.bind(this);
89
- this.onMessage = async (connection, message) => {
90
- return agentContext.run(
91
- { agent: this, connection, request: void 0 },
92
- async () => {
93
- if (typeof message !== "string") {
94
- return __privateMethod(this, _Agent_instances, tryCatch_fn).call(this, () => _onMessage(connection, message));
95
- }
96
- let parsed;
97
- try {
98
- parsed = JSON.parse(message);
99
- } catch (e) {
100
- return __privateMethod(this, _Agent_instances, tryCatch_fn).call(this, () => _onMessage(connection, message));
101
- }
102
- if (isStateUpdateMessage(parsed)) {
103
- __privateMethod(this, _Agent_instances, setStateInternal_fn).call(this, parsed.state, connection);
104
- return;
105
- }
106
- if (isRPCRequest(parsed)) {
107
- try {
108
- const { id, method, args } = parsed;
109
- const methodFn = this[method];
110
- if (typeof methodFn !== "function") {
111
- throw new Error(`Method ${method} does not exist`);
112
- }
113
- if (!__privateMethod(this, _Agent_instances, isCallable_fn).call(this, method)) {
114
- throw new Error(`Method ${method} is not callable`);
115
- }
116
- const metadata = callableMetadata.get(methodFn);
117
- if (metadata?.streaming) {
118
- const stream = new StreamingResponse(connection, id);
119
- await methodFn.apply(this, [stream, ...args]);
120
- return;
121
- }
122
- const result = await methodFn.apply(this, args);
123
- const response = {
124
- type: "rpc",
125
- id,
126
- success: true,
127
- result,
128
- done: true
129
- };
130
- connection.send(JSON.stringify(response));
131
- } catch (e) {
132
- const response = {
133
- type: "rpc",
134
- id: parsed.id,
135
- success: false,
136
- error: e instanceof Error ? e.message : "Unknown error occurred"
137
- };
138
- connection.send(JSON.stringify(response));
139
- console.error("RPC error:", e);
140
- }
141
- return;
142
- }
143
- return __privateMethod(this, _Agent_instances, tryCatch_fn).call(this, () => _onMessage(connection, message));
144
- }
145
- );
146
- };
147
- const _onConnect = this.onConnect.bind(this);
148
- this.onConnect = (connection, ctx2) => {
149
- return agentContext.run(
150
- { agent: this, connection, request: ctx2.request },
151
- async () => {
152
- setTimeout(() => {
153
- if (this.state) {
154
- connection.send(
155
- JSON.stringify({
156
- type: "cf_agent_state",
157
- state: this.state
158
- })
159
- );
160
- }
161
- return __privateMethod(this, _Agent_instances, tryCatch_fn).call(this, () => _onConnect(connection, ctx2));
162
- }, 20);
163
- }
164
- );
165
- };
166
- }
167
- /**
168
- * Current state of the Agent
169
- */
170
- get state() {
171
- if (__privateGet(this, _state) !== DEFAULT_STATE) {
172
- return __privateGet(this, _state);
173
- }
174
- const wasChanged = this.sql`
175
- SELECT state FROM cf_agents_state WHERE id = ${STATE_WAS_CHANGED}
176
- `;
177
- const result = this.sql`
178
- SELECT state FROM cf_agents_state WHERE id = ${STATE_ROW_ID}
179
- `;
180
- if (wasChanged[0]?.state === "true" || // we do this check for people who updated their code before we shipped wasChanged
181
- result[0]?.state) {
182
- const state = result[0]?.state;
183
- __privateSet(this, _state, JSON.parse(state));
184
- return __privateGet(this, _state);
185
- }
186
- if (this.initialState === DEFAULT_STATE) {
187
- return void 0;
188
- }
189
- this.setState(this.initialState);
190
- return this.initialState;
191
- }
192
- /**
193
- * Execute SQL queries against the Agent's database
194
- * @template T Type of the returned rows
195
- * @param strings SQL query template strings
196
- * @param values Values to be inserted into the query
197
- * @returns Array of query results
198
- */
199
- sql(strings, ...values) {
200
- let query = "";
201
- try {
202
- query = strings.reduce(
203
- (acc, str, i) => acc + str + (i < values.length ? "?" : ""),
204
- ""
205
- );
206
- return [...this.ctx.storage.sql.exec(query, ...values)];
207
- } catch (e) {
208
- console.error(`failed to execute sql query: ${query}`, e);
209
- throw this.onError(e);
210
- }
211
- }
212
- /**
213
- * Update the Agent's state
214
- * @param state New state to set
215
- */
216
- setState(state) {
217
- __privateMethod(this, _Agent_instances, setStateInternal_fn).call(this, state, "server");
218
- }
219
- /**
220
- * Called when the Agent's state is updated
221
- * @param state Updated state
222
- * @param source Source of the state update ("server" or a client connection)
223
- */
224
- onStateUpdate(state, source) {
225
- }
226
- /**
227
- * Called when the Agent receives an email
228
- * @param email Email message to process
229
- */
230
- onEmail(email) {
231
- return agentContext.run(
232
- { agent: this, connection: void 0, request: void 0 },
233
- async () => {
234
- console.error("onEmail not implemented");
235
- }
236
- );
237
- }
238
- onError(connectionOrError, error) {
239
- let theError;
240
- if (connectionOrError && error) {
241
- theError = error;
242
- console.error(
243
- "Error on websocket connection:",
244
- connectionOrError.id,
245
- theError
246
- );
247
- console.error(
248
- "Override onError(connection, error) to handle websocket connection errors"
249
- );
250
- } else {
251
- theError = connectionOrError;
252
- console.error("Error on server:", theError);
253
- console.error("Override onError(error) to handle server errors");
254
- }
255
- throw theError;
256
- }
257
- /**
258
- * Render content (not implemented in base class)
259
- */
260
- render() {
261
- throw new Error("Not implemented");
262
- }
263
- /**
264
- * Schedule a task to be executed in the future
265
- * @template T Type of the payload data
266
- * @param when When to execute the task (Date, seconds delay, or cron expression)
267
- * @param callback Name of the method to call
268
- * @param payload Data to pass to the callback
269
- * @returns Schedule object representing the scheduled task
270
- */
271
- async schedule(when, callback, payload) {
272
- const id = nanoid(9);
273
- if (typeof callback !== "string") {
274
- throw new Error("Callback must be a string");
275
- }
276
- if (typeof this[callback] !== "function") {
277
- throw new Error(`this.${callback} is not a function`);
278
- }
279
- if (when instanceof Date) {
280
- const timestamp = Math.floor(when.getTime() / 1e3);
281
- this.sql`
282
- INSERT OR REPLACE INTO cf_agents_schedules (id, callback, payload, type, time)
283
- VALUES (${id}, ${callback}, ${JSON.stringify(
284
- payload
285
- )}, 'scheduled', ${timestamp})
286
- `;
287
- await __privateMethod(this, _Agent_instances, scheduleNextAlarm_fn).call(this);
288
- return {
289
- id,
290
- callback,
291
- payload,
292
- time: timestamp,
293
- type: "scheduled"
294
- };
295
- }
296
- if (typeof when === "number") {
297
- const time = new Date(Date.now() + when * 1e3);
298
- const timestamp = Math.floor(time.getTime() / 1e3);
299
- this.sql`
300
- INSERT OR REPLACE INTO cf_agents_schedules (id, callback, payload, type, delayInSeconds, time)
301
- VALUES (${id}, ${callback}, ${JSON.stringify(
302
- payload
303
- )}, 'delayed', ${when}, ${timestamp})
304
- `;
305
- await __privateMethod(this, _Agent_instances, scheduleNextAlarm_fn).call(this);
306
- return {
307
- id,
308
- callback,
309
- payload,
310
- delayInSeconds: when,
311
- time: timestamp,
312
- type: "delayed"
313
- };
314
- }
315
- if (typeof when === "string") {
316
- const nextExecutionTime = getNextCronTime(when);
317
- const timestamp = Math.floor(nextExecutionTime.getTime() / 1e3);
318
- this.sql`
319
- INSERT OR REPLACE INTO cf_agents_schedules (id, callback, payload, type, cron, time)
320
- VALUES (${id}, ${callback}, ${JSON.stringify(
321
- payload
322
- )}, 'cron', ${when}, ${timestamp})
323
- `;
324
- await __privateMethod(this, _Agent_instances, scheduleNextAlarm_fn).call(this);
325
- return {
326
- id,
327
- callback,
328
- payload,
329
- cron: when,
330
- time: timestamp,
331
- type: "cron"
332
- };
333
- }
334
- throw new Error("Invalid schedule type");
335
- }
336
- /**
337
- * Get a scheduled task by ID
338
- * @template T Type of the payload data
339
- * @param id ID of the scheduled task
340
- * @returns The Schedule object or undefined if not found
341
- */
342
- async getSchedule(id) {
343
- const result = this.sql`
344
- SELECT * FROM cf_agents_schedules WHERE id = ${id}
345
- `;
346
- if (!result) {
347
- console.error(`schedule ${id} not found`);
348
- return void 0;
349
- }
350
- return { ...result[0], payload: JSON.parse(result[0].payload) };
351
- }
352
- /**
353
- * Get scheduled tasks matching the given criteria
354
- * @template T Type of the payload data
355
- * @param criteria Criteria to filter schedules
356
- * @returns Array of matching Schedule objects
357
- */
358
- getSchedules(criteria = {}) {
359
- let query = "SELECT * FROM cf_agents_schedules WHERE 1=1";
360
- const params = [];
361
- if (criteria.id) {
362
- query += " AND id = ?";
363
- params.push(criteria.id);
364
- }
365
- if (criteria.type) {
366
- query += " AND type = ?";
367
- params.push(criteria.type);
368
- }
369
- if (criteria.timeRange) {
370
- query += " AND time >= ? AND time <= ?";
371
- const start = criteria.timeRange.start || /* @__PURE__ */ new Date(0);
372
- const end = criteria.timeRange.end || /* @__PURE__ */ new Date(999999999999999);
373
- params.push(
374
- Math.floor(start.getTime() / 1e3),
375
- Math.floor(end.getTime() / 1e3)
376
- );
377
- }
378
- const result = this.ctx.storage.sql.exec(query, ...params).toArray().map((row) => ({
379
- ...row,
380
- payload: JSON.parse(row.payload)
381
- }));
382
- return result;
383
- }
384
- /**
385
- * Cancel a scheduled task
386
- * @param id ID of the task to cancel
387
- * @returns true if the task was cancelled, false otherwise
388
- */
389
- async cancelSchedule(id) {
390
- this.sql`DELETE FROM cf_agents_schedules WHERE id = ${id}`;
391
- await __privateMethod(this, _Agent_instances, scheduleNextAlarm_fn).call(this);
392
- return true;
393
- }
394
- /**
395
- * Method called when an alarm fires
396
- * Executes any scheduled tasks that are due
397
- */
398
- async alarm() {
399
- const now = Math.floor(Date.now() / 1e3);
400
- const result = this.sql`
401
- SELECT * FROM cf_agents_schedules WHERE time <= ${now}
402
- `;
403
- for (const row of result || []) {
404
- const callback = this[row.callback];
405
- if (!callback) {
406
- console.error(`callback ${row.callback} not found`);
407
- continue;
408
- }
409
- await agentContext.run(
410
- { agent: this, connection: void 0, request: void 0 },
411
- async () => {
412
- try {
413
- await callback.bind(this)(JSON.parse(row.payload), row);
414
- } catch (e) {
415
- console.error(`error executing callback "${row.callback}"`, e);
416
- }
417
- }
418
- );
419
- if (row.type === "cron") {
420
- const nextExecutionTime = getNextCronTime(row.cron);
421
- const nextTimestamp = Math.floor(nextExecutionTime.getTime() / 1e3);
422
- this.sql`
423
- UPDATE cf_agents_schedules SET time = ${nextTimestamp} WHERE id = ${row.id}
424
- `;
425
- } else {
426
- this.sql`
427
- DELETE FROM cf_agents_schedules WHERE id = ${row.id}
428
- `;
429
- }
430
- }
431
- await __privateMethod(this, _Agent_instances, scheduleNextAlarm_fn).call(this);
432
- }
433
- /**
434
- * Destroy the Agent, removing all state and scheduled tasks
435
- */
436
- async destroy() {
437
- this.sql`DROP TABLE IF EXISTS cf_agents_state`;
438
- this.sql`DROP TABLE IF EXISTS cf_agents_schedules`;
439
- await this.ctx.storage.deleteAlarm();
440
- await this.ctx.storage.deleteAll();
441
- }
442
- };
443
- _state = new WeakMap();
444
- _ParentClass = new WeakMap();
445
- _Agent_instances = new WeakSet();
446
- setStateInternal_fn = function(state, source = "server") {
447
- __privateSet(this, _state, state);
448
- this.sql`
449
- INSERT OR REPLACE INTO cf_agents_state (id, state)
450
- VALUES (${STATE_ROW_ID}, ${JSON.stringify(state)})
451
- `;
452
- this.sql`
453
- INSERT OR REPLACE INTO cf_agents_state (id, state)
454
- VALUES (${STATE_WAS_CHANGED}, ${JSON.stringify(true)})
455
- `;
456
- this.broadcast(
457
- JSON.stringify({
458
- type: "cf_agent_state",
459
- state
460
- }),
461
- source !== "server" ? [source.id] : []
462
- );
463
- return __privateMethod(this, _Agent_instances, tryCatch_fn).call(this, () => {
464
- const { connection, request } = agentContext.getStore() || {};
465
- return agentContext.run(
466
- { agent: this, connection, request },
467
- async () => {
468
- return this.onStateUpdate(state, source);
469
- }
470
- );
471
- });
472
- };
473
- tryCatch_fn = async function(fn) {
474
- try {
475
- return await fn();
476
- } catch (e) {
477
- throw this.onError(e);
478
- }
479
- };
480
- scheduleNextAlarm_fn = async function() {
481
- const result = this.sql`
482
- SELECT time FROM cf_agents_schedules
483
- WHERE time > ${Math.floor(Date.now() / 1e3)}
484
- ORDER BY time ASC
485
- LIMIT 1
486
- `;
487
- if (!result) return;
488
- if (result.length > 0 && "time" in result[0]) {
489
- const nextTime = result[0].time * 1e3;
490
- await this.ctx.storage.setAlarm(nextTime);
491
- }
492
- };
493
- /**
494
- * Get all methods marked as callable on this Agent
495
- * @returns A map of method names to their metadata
496
- */
497
- isCallable_fn = function(method) {
498
- return callableMetadata.has(this[method]);
499
- };
500
- /**
501
- * Agent configuration options
502
- */
503
- Agent.options = {
504
- /** Whether the Agent should hibernate when inactive */
505
- hibernate: true
506
- // default to hibernate
507
- };
508
- async function routeAgentRequest(request, env, options) {
509
- const corsHeaders = options?.cors === true ? {
510
- "Access-Control-Allow-Origin": "*",
511
- "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS",
512
- "Access-Control-Allow-Credentials": "true",
513
- "Access-Control-Max-Age": "86400"
514
- } : options?.cors;
515
- if (request.method === "OPTIONS") {
516
- if (corsHeaders) {
517
- return new Response(null, {
518
- headers: corsHeaders
519
- });
520
- }
521
- console.warn(
522
- "Received an OPTIONS request, but cors was not enabled. Pass `cors: true` or `cors: { ...custom cors headers }` to routeAgentRequest to enable CORS."
523
- );
524
- }
525
- let response = await routePartykitRequest(
526
- request,
527
- env,
528
- {
529
- prefix: "agents",
530
- ...options
531
- }
532
- );
533
- if (response && corsHeaders && request.headers.get("upgrade")?.toLowerCase() !== "websocket" && request.headers.get("Upgrade")?.toLowerCase() !== "websocket") {
534
- response = new Response(response.body, {
535
- headers: {
536
- ...response.headers,
537
- ...corsHeaders
538
- }
539
- });
540
- }
541
- return response;
542
- }
543
- async function routeAgentEmail(email, env, options) {
544
- }
545
- function getAgentByName(namespace, name, options) {
546
- return getServerByName(namespace, name, options);
547
- }
548
- var _connection, _id, _closed;
549
- var StreamingResponse = class {
550
- constructor(connection, id) {
551
- __privateAdd(this, _connection);
552
- __privateAdd(this, _id);
553
- __privateAdd(this, _closed, false);
554
- __privateSet(this, _connection, connection);
555
- __privateSet(this, _id, id);
556
- }
557
- /**
558
- * Send a chunk of data to the client
559
- * @param chunk The data to send
560
- */
561
- send(chunk) {
562
- if (__privateGet(this, _closed)) {
563
- throw new Error("StreamingResponse is already closed");
564
- }
565
- const response = {
566
- type: "rpc",
567
- id: __privateGet(this, _id),
568
- success: true,
569
- result: chunk,
570
- done: false
571
- };
572
- __privateGet(this, _connection).send(JSON.stringify(response));
573
- }
574
- /**
575
- * End the stream and send the final chunk (if any)
576
- * @param finalChunk Optional final chunk of data to send
577
- */
578
- end(finalChunk) {
579
- if (__privateGet(this, _closed)) {
580
- throw new Error("StreamingResponse is already closed");
581
- }
582
- __privateSet(this, _closed, true);
583
- const response = {
584
- type: "rpc",
585
- id: __privateGet(this, _id),
586
- success: true,
587
- result: finalChunk,
588
- done: true
589
- };
590
- __privateGet(this, _connection).send(JSON.stringify(response));
591
- }
592
- };
593
- _connection = new WeakMap();
594
- _id = new WeakMap();
595
- _closed = new WeakMap();
596
-
597
- export {
598
- unstable_callable,
599
- getCurrentAgent,
600
- Agent,
601
- routeAgentRequest,
602
- routeAgentEmail,
603
- getAgentByName,
604
- StreamingResponse
605
- };
606
- //# sourceMappingURL=chunk-HN5JVKAZ.js.map