@ray-js/t-agent 0.2.0-beta-3 → 0.2.0-beta-5

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.
@@ -0,0 +1,14 @@
1
+ import { InputBlock, StreamRequestInstance } from './types';
2
+ export default class StreamRequest implements StreamRequestInstance {
3
+ readonly blocks: InputBlock[];
4
+ private aborted;
5
+ constructor(blocks: InputBlock[]);
6
+ sent(): void;
7
+ parts(): void;
8
+ /**
9
+ * Cancel the request stream.
10
+ *
11
+ * @param reason
12
+ */
13
+ cancel(reason: any): Promise<void>;
14
+ }
@@ -0,0 +1,19 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ export default class StreamRequest {
3
+ constructor(blocks) {
4
+ _defineProperty(this, "aborted", false);
5
+ this.blocks = blocks;
6
+ }
7
+ sent() {}
8
+ parts() {}
9
+
10
+ /**
11
+ * Cancel the request stream.
12
+ *
13
+ * @param reason
14
+ */
15
+ cancel() {
16
+ this.aborted = true;
17
+ throw new Error('cancel() can only be called after parts()');
18
+ }
19
+ }
@@ -177,6 +177,9 @@ export declare enum FinishReason {
177
177
  ABORT = "abort",
178
178
  ERROR = "error"
179
179
  }
180
+ export type StreamRequestInstance = {
181
+ blocks: InputBlock[];
182
+ };
180
183
  export type StreamResponseInstance = {
181
184
  parts: () => AsyncIterable<MessagePart>;
182
185
  cancel: (reason: any) => Promise<void>;
@@ -26,7 +26,6 @@ export interface UIEventMap {
26
26
  export interface UIHooksContext<P = any, R = any> {
27
27
  payload: P;
28
28
  result: R | null;
29
- error?: Error;
30
29
  }
31
30
  export interface UIHooks {
32
31
  onMessageFeedback: (context: UIHooksContext<{
@@ -53,19 +53,10 @@ export function withUI() {
53
53
  result: null
54
54
  };
55
55
  await hooks.callHook(hookName, context);
56
- if (context.error) {
57
- throw context.error;
58
- }
59
56
  return context.result;
60
57
  },
61
58
  hook: (hookName, fn) => {
62
- return hooks.hook(hookName, async context => {
63
- try {
64
- await fn(context);
65
- } catch (error) {
66
- context.error = error;
67
- }
68
- });
59
+ return hooks.hook(hookName, fn);
69
60
  },
70
61
  emitter,
71
62
  emitEvent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent",
3
- "version": "0.2.0-beta-3",
3
+ "version": "0.2.0-beta-5",
4
4
  "author": "Tuya.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -26,5 +26,5 @@
26
26
  "build": "ray build --type=component --output dist",
27
27
  "clean": "rimraf ./dist"
28
28
  },
29
- "gitHead": "03c4af7fe4cfe27069db83d99a61042c8053399e"
29
+ "gitHead": "a0beda17c8e1c3ef81c718300c02a23d88a3ee4a"
30
30
  }