create-windy 0.6.20 → 0.6.21
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/cli.js
CHANGED
|
@@ -8507,6 +8507,11 @@ var recipes = [
|
|
|
8507
8507
|
id: "starter-0.6.19-to-0.6.20",
|
|
8508
8508
|
from: "0.6.19",
|
|
8509
8509
|
to: "0.6.20"
|
|
8510
|
+
},
|
|
8511
|
+
{
|
|
8512
|
+
id: "starter-0.6.20-to-0.6.21",
|
|
8513
|
+
from: "0.6.20",
|
|
8514
|
+
to: "0.6.21"
|
|
8510
8515
|
}
|
|
8511
8516
|
];
|
|
8512
8517
|
function resolveRecipeChain(sourceVersion, targetVersion) {
|
package/package.json
CHANGED
|
@@ -9,6 +9,42 @@ afterEach(() => {
|
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
describe("RemoteAgentRuntime", () => {
|
|
12
|
+
test("SSE 首帧晚于普通请求超时仍可读取", async () => {
|
|
13
|
+
const server = Bun.serve({
|
|
14
|
+
port: 0,
|
|
15
|
+
fetch(request) {
|
|
16
|
+
if (new URL(request.url).pathname.endsWith("/events")) {
|
|
17
|
+
return new Response(
|
|
18
|
+
new ReadableStream<Uint8Array>({
|
|
19
|
+
async start(controller) {
|
|
20
|
+
await Bun.sleep(40);
|
|
21
|
+
controller.enqueue(
|
|
22
|
+
new TextEncoder().encode(
|
|
23
|
+
'id: 1\nevent: run.started\ndata: {"runId":"run_slow","sequence":1}\n\n',
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
controller.close();
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
{ headers: { "content-type": "text/event-stream" } },
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return Bun.sleep(40).then(() => Response.json({ status: "late" }));
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
servers.push(server);
|
|
36
|
+
const runtime = new RemoteAgentRuntime({
|
|
37
|
+
baseUrl: server.url.toString(),
|
|
38
|
+
internalToken: "test-token",
|
|
39
|
+
toolHostUrl: "http://server.internal/api/agent/tools",
|
|
40
|
+
timeoutMs: 10,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const stream = await runtime.events("run_slow", 0);
|
|
44
|
+
await expect(stream.text()).resolves.toContain("run.started");
|
|
45
|
+
await expect(runtime.health()).rejects.toThrow();
|
|
46
|
+
});
|
|
47
|
+
|
|
12
48
|
test("读取可恢复 Run 状态和终态事件", async () => {
|
|
13
49
|
const server = Bun.serve({
|
|
14
50
|
port: 0,
|
|
@@ -126,7 +126,7 @@ export class RemoteAgentRuntime implements AgentRuntimePort {
|
|
|
126
126
|
return this.request(
|
|
127
127
|
`/api/agent/runs/${encodeURIComponent(runId)}/events?after=${cursor}`,
|
|
128
128
|
{ signal },
|
|
129
|
-
|
|
129
|
+
"stream",
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -207,12 +207,12 @@ export class RemoteAgentRuntime implements AgentRuntimePort {
|
|
|
207
207
|
private async request(
|
|
208
208
|
path: string,
|
|
209
209
|
init: RequestInit = {},
|
|
210
|
-
bounded =
|
|
210
|
+
mode: "bounded" | "stream" = "bounded",
|
|
211
211
|
): Promise<Response> {
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
const signal =
|
|
213
|
+
mode === "stream"
|
|
214
|
+
? init.signal
|
|
215
|
+
: combineSignalWithTimeout(init.signal, this.#timeoutMs);
|
|
216
216
|
const response = await fetch(`${this.#baseUrl}${path}`, {
|
|
217
217
|
...init,
|
|
218
218
|
signal,
|
|
@@ -221,7 +221,7 @@ export class RemoteAgentRuntime implements AgentRuntimePort {
|
|
|
221
221
|
...init.headers,
|
|
222
222
|
},
|
|
223
223
|
});
|
|
224
|
-
if (bounded) {
|
|
224
|
+
if (mode === "bounded") {
|
|
225
225
|
const length = Number(response.headers.get("content-length") || "0");
|
|
226
226
|
if (length > 2 * 1_024 * 1_024) {
|
|
227
227
|
throw new Error("Agent Server 响应超过上限");
|
|
@@ -231,6 +231,14 @@ export class RemoteAgentRuntime implements AgentRuntimePort {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
function combineSignalWithTimeout(
|
|
235
|
+
signal: AbortSignal | null | undefined,
|
|
236
|
+
timeoutMs: number,
|
|
237
|
+
): AbortSignal {
|
|
238
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
239
|
+
return signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
240
|
+
}
|
|
241
|
+
|
|
234
242
|
function incompatibleRuntime(code: string): AgentRuntimeError {
|
|
235
243
|
return new AgentRuntimeError(
|
|
236
244
|
"RUNTIME_UNAVAILABLE",
|