@womp/spark-agent 15.0.1 → 15.0.3
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/CHANGELOG.md +22 -0
- package/dist/server/express.js +27 -7
- package/dist/server/service.js +6 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,28 @@ Notable changes to `@womp/spark-agent`, newest first. Versions follow
|
|
|
4
4
|
[Semantic Versioning](https://semver.org/). Add an entry with each version bump; describe what
|
|
5
5
|
changed for hosts and users, and how to migrate across breaking changes.
|
|
6
6
|
|
|
7
|
+
## 15.0.3 — 2026-10-22
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Depends on `@womp/kakapo-sdk` 0.10.1. A Kakapo result that arrives after its wait timed out,
|
|
12
|
+
such as a slow `capture_screenshot` frame, is dropped instead of kept for the life of the
|
|
13
|
+
connection. Early results are held briefly and capped.
|
|
14
|
+
|
|
15
|
+
## 15.0.2 — 2026-10-22
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- The Express `/runs/:runId/stream` route ends when its client disconnects. A write waiting for
|
|
20
|
+
`drain` on a backed-up response waited forever once the client left, because a closed response
|
|
21
|
+
emits `close`, not `drain`. That covers a large chunk, or the closing `[DONE]` written after the
|
|
22
|
+
client has already gone. The route never reached its cleanup, so it kept its request, response and
|
|
23
|
+
socket, and, when stuck mid-stream, its `streamRun` listener and every later chunk of the run. The
|
|
24
|
+
route now also listens for `close` before its first lookup, so a client that leaves during it is
|
|
25
|
+
noticed.
|
|
26
|
+
- `SparkAgentService.streamRun` ends when its signal aborts while it is reading the run. Before, it
|
|
27
|
+
then waited for the run's next chunk, or forever for a run waiting on the user.
|
|
28
|
+
|
|
7
29
|
## 15.0.1 — 2026-10-21
|
|
8
30
|
|
|
9
31
|
### Fixed
|
package/dist/server/express.js
CHANGED
|
@@ -33,10 +33,26 @@ function parseSequence(value) {
|
|
|
33
33
|
function encodeFilename(value) {
|
|
34
34
|
return encodeURIComponent(value).replace(/[!'()*]/gu, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Writes one SSE frame, waiting for `drain` when the socket is backed up.
|
|
38
|
+
* `drain` never fires once the client is gone, so the wait also ends when
|
|
39
|
+
* `signal` aborts (the response closed). Without that, a client that
|
|
40
|
+
* disconnected mid-backpressure left the stream route waiting forever, and its
|
|
41
|
+
* `streamRun` listener collecting the rest of the run's chunks for good.
|
|
42
|
+
*/
|
|
43
|
+
async function write(response, value, signal) {
|
|
44
|
+
if (signal.aborted || response.destroyed)
|
|
45
|
+
return;
|
|
37
46
|
if (response.write(value))
|
|
38
47
|
return;
|
|
39
|
-
|
|
48
|
+
try {
|
|
49
|
+
await once(response, "drain", { signal });
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (signal.aborted)
|
|
53
|
+
return;
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
40
56
|
}
|
|
41
57
|
export function createSparkAgentRouter(options) {
|
|
42
58
|
const router = express.Router();
|
|
@@ -118,10 +134,14 @@ export function createSparkAgentRouter(options) {
|
|
|
118
134
|
response.json({ run: await options.service.cancelRun(ownerId, request.params.runId) });
|
|
119
135
|
});
|
|
120
136
|
router.get("/runs/:runId/stream", async (request, response) => {
|
|
121
|
-
|
|
122
|
-
|
|
137
|
+
// Listening for `close` before the first await: a client that leaves
|
|
138
|
+
// while the owner or run is being looked up still ends this stream.
|
|
123
139
|
const abortController = new AbortController();
|
|
124
140
|
response.on("close", () => abortController.abort());
|
|
141
|
+
const ownerId = await resolveOwnerId(request);
|
|
142
|
+
await options.service.getRun(ownerId, request.params.runId);
|
|
143
|
+
if (response.destroyed)
|
|
144
|
+
abortController.abort();
|
|
125
145
|
response.status(200);
|
|
126
146
|
response.set({
|
|
127
147
|
"Cache-Control": "no-cache, no-transform",
|
|
@@ -144,16 +164,16 @@ export function createSparkAgentRouter(options) {
|
|
|
144
164
|
if (heartbeatTimer !== undefined)
|
|
145
165
|
clearTimeout(heartbeatTimer);
|
|
146
166
|
if (next.type === "heartbeat") {
|
|
147
|
-
await write(response, ": ping\n\n");
|
|
167
|
+
await write(response, ": ping\n\n", abortController.signal);
|
|
148
168
|
continue;
|
|
149
169
|
}
|
|
150
170
|
if (next.result.done)
|
|
151
171
|
break;
|
|
152
172
|
const chunk = next.result.value;
|
|
153
|
-
await write(response, `id: ${chunk.sequence}\ndata: ${JSON.stringify(chunk)}\n\n
|
|
173
|
+
await write(response, `id: ${chunk.sequence}\ndata: ${JSON.stringify(chunk)}\n\n`, abortController.signal);
|
|
154
174
|
pending = chunks.next();
|
|
155
175
|
}
|
|
156
|
-
await write(response, "data: [DONE]\n\n");
|
|
176
|
+
await write(response, "data: [DONE]\n\n", abortController.signal);
|
|
157
177
|
}
|
|
158
178
|
finally {
|
|
159
179
|
await chunks.return(undefined);
|
package/dist/server/service.js
CHANGED
|
@@ -518,7 +518,12 @@ export class SparkAgentService {
|
|
|
518
518
|
resolve();
|
|
519
519
|
};
|
|
520
520
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
521
|
-
|
|
521
|
+
// An abort while the run was being read has already fired, so the
|
|
522
|
+
// listener above never would: without this the stream waited for
|
|
523
|
+
// the run's next chunk, or forever for a run parked on the user.
|
|
524
|
+
if (signal.aborted)
|
|
525
|
+
onAbort();
|
|
526
|
+
else if (notification !== observedNotification || queue.length > 0)
|
|
522
527
|
wake?.();
|
|
523
528
|
});
|
|
524
529
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@womp/spark-agent",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.3",
|
|
4
4
|
"description": "Portable skills-based AI agent with local and durable chat transports for Womp",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"@ai-sdk/openai": "4.0.63",
|
|
117
117
|
"@jitl/quickjs-wasmfile-release-sync": "0.32.0",
|
|
118
118
|
"@womp/flowir": "0.5.0",
|
|
119
|
-
"@womp/kakapo-sdk": "0.10.
|
|
119
|
+
"@womp/kakapo-sdk": "0.10.1",
|
|
120
120
|
"ai": "7.0.95",
|
|
121
121
|
"eventsource-parser": "^3.0.6",
|
|
122
122
|
"express": "^5.2.1",
|