@nextclaw/ncp-http-agent-server 0.2.0 → 0.3.0

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/README.md CHANGED
@@ -16,6 +16,6 @@ pnpm -C packages/ncp-packages/nextclaw-ncp-http-agent-server build
16
16
  **Options:**
17
17
  - `agentClientEndpoint` — client endpoint to forward requests to (in-process adapter or remote HTTP client)
18
18
  - `streamProvider` (optional) — When set, `/stream` serves stored events instead of forwarding to the agent. Scenario: user reconnects after network drop and wants to continue watching the previous reply; with `streamProvider` we stream from persistence, without it we forward to the agent.
19
- - `basePath`, `requestTimeoutMs` — path and timeout
19
+ - `basePath`, `requestTimeoutMs` — path and optional forward-stream timeout. By default no server-side timeout is applied; set a positive value only if you explicitly want the server to cut off long-running forward streams.
20
20
 
21
21
  For in-process agent (`NcpAgentServerEndpoint`), use `createAgentClientFromServer` from `@nextclaw/ncp-toolkit` to wrap it.
package/dist/index.d.ts CHANGED
@@ -27,7 +27,11 @@ type NcpHttpAgentServerOptions = {
27
27
  /** Client endpoint to forward requests to (in-process adapter or remote HTTP client). */
28
28
  agentClientEndpoint: NcpAgentClientEndpoint;
29
29
  basePath?: string;
30
- requestTimeoutMs?: number;
30
+ /**
31
+ * Optional forward-stream timeout in milliseconds.
32
+ * When omitted or set to a non-positive value, no server-side timeout is applied.
33
+ */
34
+ requestTimeoutMs?: number | null;
31
35
  /**
32
36
  * Optional. When set, `/stream` serves live session events from streamProvider instead of
33
37
  * forwarding to the agent.
@@ -49,7 +53,7 @@ type NcpHttpAgentHandlerOptions = {
49
53
  * See NcpHttpAgentStreamProvider for details.
50
54
  */
51
55
  streamProvider?: NcpHttpAgentStreamProvider;
52
- timeoutMs: number;
56
+ timeoutMs: number | null;
53
57
  };
54
58
 
55
59
  /**
package/dist/index.js CHANGED
@@ -3,7 +3,6 @@ import { NcpEventType } from "@nextclaw/ncp";
3
3
 
4
4
  // src/types.ts
5
5
  var DEFAULT_BASE_PATH = "/ncp/agent";
6
- var DEFAULT_REQUEST_TIMEOUT_MS = 12e4;
7
6
 
8
7
  // src/parsers.ts
9
8
  function normalizeBasePath(basePath) {
@@ -16,7 +15,10 @@ function normalizeBasePath(basePath) {
16
15
  }
17
16
  function sanitizeTimeout(timeoutMs) {
18
17
  if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs)) {
19
- return DEFAULT_REQUEST_TIMEOUT_MS;
18
+ return null;
19
+ }
20
+ if (timeoutMs <= 0) {
21
+ return null;
20
22
  }
21
23
  return Math.max(1e3, Math.trunc(timeoutMs));
22
24
  }
@@ -296,10 +298,12 @@ async function* createForwardSseEvents(options) {
296
298
  queue.close();
297
299
  };
298
300
  requestSignal.addEventListener("abort", stop, { once: true });
299
- timeoutId = setTimeout(() => {
300
- push(toErrorFrame("TIMEOUT", "NCP HTTP stream timed out before terminal event."));
301
- stop();
302
- }, timeoutMs);
301
+ if (timeoutMs !== null) {
302
+ timeoutId = setTimeout(() => {
303
+ push(toErrorFrame("TIMEOUT", "NCP HTTP stream timed out before terminal event."));
304
+ stop();
305
+ }, timeoutMs);
306
+ }
303
307
  unsubscribe = endpoint.subscribe((event) => {
304
308
  if (!matchesScope(scope, event)) {
305
309
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/ncp-http-agent-server",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "description": "HTTP/SSE server transport adapter for NCP agent endpoints.",
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "hono": "^4.9.8",
19
- "@nextclaw/ncp": "0.2.0"
19
+ "@nextclaw/ncp": "0.3.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/node": "^20.17.6",