veryfront 0.1.226 → 0.1.227
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/esm/deno.js +1 -1
- package/esm/src/agent/ag-ui-browser-response-stream.d.ts.map +1 -1
- package/esm/src/agent/ag-ui-browser-response-stream.js +34 -9
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/src/agent/ag-ui-browser-response-stream.ts +55 -22
- package/src/src/utils/version-constant.ts +1 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ag-ui-browser-response-stream.d.ts","sourceRoot":"","sources":["../../../src/src/agent/ag-ui-browser-response-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAkB5D,MAAM,WAAW,+BAA+B;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,4BAA4B,CAAC,MAAM;IAClD,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,0BAA0B,CAAC,MAAM;IAChD,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,YAAY,EAAE,CAAC;IAC1C,QAAQ,EAAE,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,KAAK,YAAY,EAAE,CAAC;CAC9D;AAED,MAAM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;AAED,MAAM,WAAW,oCAAoC,CAAC,MAAM,EAAE,MAAM;IAClE,SAAS,EAAE,+BAA+B,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAChD,OAAO,EAAE,0BAA0B,CAAC,MAAM,CAAC,CAAC;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,GAAG,IAAI,CAAC;CAC5D;AAUD,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAC5D,KAAK,EAAE,oCAAoC,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1D,cAAc,CAAC,UAAU,CAAC,CAqH5B"}
|
|
@@ -6,6 +6,12 @@ function formatAgUiSseEventWithId(event, eventId) {
|
|
|
6
6
|
function invokeFailWithoutLeaking(fail, error) {
|
|
7
7
|
return fail(error).catch(() => undefined);
|
|
8
8
|
}
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
function normalizeSnapshot(snapshot) {
|
|
13
|
+
return isRecord(snapshot) ? snapshot : {};
|
|
14
|
+
}
|
|
9
15
|
export function createAgUiBrowserResponseStream(input) {
|
|
10
16
|
let streamClosed = false;
|
|
11
17
|
let nextEventId = 1;
|
|
@@ -39,35 +45,54 @@ export function createAgUiBrowserResponseStream(input) {
|
|
|
39
45
|
void (async () => {
|
|
40
46
|
const state = input.initialState;
|
|
41
47
|
try {
|
|
42
|
-
writeEvent({
|
|
48
|
+
if (!writeEvent({
|
|
43
49
|
event: "RunStarted",
|
|
44
50
|
payload: {
|
|
45
51
|
runId: input.agUiInput.runId,
|
|
46
52
|
threadId: input.agUiInput.threadId,
|
|
47
53
|
agentId: input.agentId,
|
|
48
54
|
},
|
|
49
|
-
})
|
|
50
|
-
|
|
55
|
+
})) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!writeEvent({
|
|
51
59
|
event: "StateSnapshot",
|
|
52
60
|
payload: {
|
|
53
|
-
snapshot: input.agUiInput.state,
|
|
61
|
+
snapshot: normalizeSnapshot(input.agUiInput.state),
|
|
54
62
|
},
|
|
55
|
-
})
|
|
56
|
-
|
|
63
|
+
})) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!writeEvent({
|
|
57
67
|
event: "MessagesSnapshot",
|
|
58
68
|
payload: {
|
|
59
69
|
messages: input.agUiInput.messages,
|
|
60
70
|
},
|
|
61
|
-
})
|
|
71
|
+
})) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
62
74
|
for await (const chunk of input.execution.agentUIStream) {
|
|
75
|
+
if (streamClosed) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
63
78
|
input.onChunk?.(state, chunk);
|
|
64
79
|
for (const event of input.encoder.encode(chunk)) {
|
|
65
|
-
writeEvent(event)
|
|
80
|
+
if (!writeEvent(event)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
66
83
|
}
|
|
67
84
|
}
|
|
85
|
+
if (streamClosed) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
68
88
|
await input.execution.waitForFinish();
|
|
89
|
+
if (streamClosed) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
69
92
|
for (const event of input.encoder.finalize(input.getFinalResponse?.(state) ?? null)) {
|
|
70
|
-
writeEvent(event)
|
|
93
|
+
if (!writeEvent(event)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
71
96
|
}
|
|
72
97
|
}
|
|
73
98
|
catch (error) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.227";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
package/src/deno.js
CHANGED
|
@@ -45,6 +45,14 @@ export interface CreateAgUiBrowserResponseStreamInput<TChunk, TState> {
|
|
|
45
45
|
getFinalResponse?: (state: TState) => AgentResponse | null;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
49
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function normalizeSnapshot(snapshot: unknown): Record<string, unknown> {
|
|
53
|
+
return isRecord(snapshot) ? snapshot : {};
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
export function createAgUiBrowserResponseStream<TChunk, TState>(
|
|
49
57
|
input: CreateAgUiBrowserResponseStreamInput<TChunk, TState>,
|
|
50
58
|
): ReadableStream<Uint8Array> {
|
|
@@ -86,40 +94,65 @@ export function createAgUiBrowserResponseStream<TChunk, TState>(
|
|
|
86
94
|
const state = input.initialState;
|
|
87
95
|
|
|
88
96
|
try {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
if (
|
|
98
|
+
!writeEvent({
|
|
99
|
+
event: "RunStarted",
|
|
100
|
+
payload: {
|
|
101
|
+
runId: input.agUiInput.runId,
|
|
102
|
+
threadId: input.agUiInput.threadId,
|
|
103
|
+
agentId: input.agentId,
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
97
109
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
if (
|
|
111
|
+
!writeEvent({
|
|
112
|
+
event: "StateSnapshot",
|
|
113
|
+
payload: {
|
|
114
|
+
snapshot: normalizeSnapshot(input.agUiInput.state),
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
104
120
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
if (
|
|
122
|
+
!writeEvent({
|
|
123
|
+
event: "MessagesSnapshot",
|
|
124
|
+
payload: {
|
|
125
|
+
messages: input.agUiInput.messages,
|
|
126
|
+
},
|
|
127
|
+
})
|
|
128
|
+
) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
111
131
|
|
|
112
132
|
for await (const chunk of input.execution.agentUIStream) {
|
|
133
|
+
if (streamClosed) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
113
136
|
input.onChunk?.(state, chunk);
|
|
114
137
|
for (const event of input.encoder.encode(chunk)) {
|
|
115
|
-
writeEvent(event)
|
|
138
|
+
if (!writeEvent(event)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
116
141
|
}
|
|
117
142
|
}
|
|
118
143
|
|
|
144
|
+
if (streamClosed) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
119
147
|
await input.execution.waitForFinish();
|
|
120
148
|
|
|
149
|
+
if (streamClosed) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
121
152
|
for (const event of input.encoder.finalize(input.getFinalResponse?.(state) ?? null)) {
|
|
122
|
-
writeEvent(event)
|
|
153
|
+
if (!writeEvent(event)) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
123
156
|
}
|
|
124
157
|
} catch (error) {
|
|
125
158
|
await invokeFailWithoutLeaking(input.execution.fail, error);
|