@agentstep/gateway 0.5.15 → 0.5.16

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 (2) hide show
  1. package/dist/gateway.js +26 -2
  2. package/package.json +3 -3
package/dist/gateway.js CHANGED
@@ -239102,6 +239102,7 @@ var init_src = __esm({
239102
239102
  init_cors();
239103
239103
  init_streaming4();
239104
239104
  init_handlers3();
239105
+ init_dist2();
239105
239106
  app = new Hono2();
239106
239107
  app.use("/v1/*", cors({ origin: (origin) => origin, credentials: true }));
239107
239108
  app.use("*", async (c2, next) => {
@@ -239161,14 +239162,37 @@ var init_src = __esm({
239161
239162
  sub.unsubscribe();
239162
239163
  });
239163
239164
  let lastPing = Date.now();
239165
+ let lastDbPoll = Date.now();
239166
+ let highestSeq = afterSeq;
239167
+ const DB_POLL_INTERVAL = 2e3;
239164
239168
  while (!c2.req.raw.signal.aborted) {
239165
239169
  while (pending.length > 0) {
239166
239170
  const evt = pending.shift();
239167
239171
  await stream2.writeSSE({ id: String(evt.seq), event: evt.type, data: evt.data });
239172
+ if (evt.seq > highestSeq) highestSeq = evt.seq;
239168
239173
  }
239169
- if (Date.now() - lastPing > 15e3) {
239174
+ const now = Date.now();
239175
+ if (now - lastDbPoll >= DB_POLL_INTERVAL) {
239176
+ try {
239177
+ const newEvents = listEvents(sessionId, { limit: 100, order: "asc", afterSeq: highestSeq });
239178
+ for (const row of newEvents) {
239179
+ if (row.seq > highestSeq) {
239180
+ const evt = rowToManagedEvent(row);
239181
+ await stream2.writeSSE({
239182
+ id: String(evt.seq),
239183
+ event: evt.type,
239184
+ data: JSON.stringify(evt)
239185
+ });
239186
+ highestSeq = evt.seq;
239187
+ }
239188
+ }
239189
+ } catch {
239190
+ }
239191
+ lastDbPoll = now;
239192
+ }
239193
+ if (now - lastPing > 15e3) {
239170
239194
  await stream2.writeSSE({ data: JSON.stringify({ type: "ping" }), event: "ping" });
239171
- lastPing = Date.now();
239195
+ lastPing = now;
239172
239196
  }
239173
239197
  await stream2.sleep(500);
239174
239198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentstep/gateway",
3
- "version": "0.5.15",
3
+ "version": "0.5.16",
4
4
  "description": "Self-hosted, open-source, Anthropic Managed Agents-compatible. CLI + web UI for running AI agents in sandboxed environments.",
5
5
  "keywords": [
6
6
  "anthropic",
@@ -28,12 +28,12 @@
28
28
  },
29
29
  "homepage": "https://www.agentstep.com",
30
30
  "bugs": {
31
- "url": "https://github.com/agentstep/gateway/issues"
31
+ "url": "https://github.com/paulmeller/gateway/issues"
32
32
  },
33
33
  "author": "AgentStep",
34
34
  "repository": {
35
35
  "type": "git",
36
- "url": "https://github.com/agentstep/gateway.git",
36
+ "url": "https://github.com/paulmeller/gateway.git",
37
37
  "directory": "packages/gateway"
38
38
  },
39
39
  "license": "Apache-2.0",