@nextclaw/ncp-http-agent-client 0.3.20 → 0.3.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NcpAgentClientEndpoint, NcpEndpointEvent, NcpEndpointManifest, NcpEndpointSubscriber, NcpMessageAbortPayload, NcpRequestEnvelope, NcpStreamRequestPayload } from "@nextclaw/ncp";
1
+ import { NcpAgentClientEndpoint, NcpAgentSendEnvelope, NcpEndpointEvent, NcpEndpointManifest, NcpEndpointSubscriber, NcpMessageAbortPayload, NcpStreamRequestPayload } from "@nextclaw/ncp";
2
2
 
3
3
  //#region src/utils.d.ts
4
4
  type FetchLike = (input: URL | string | Request, init?: RequestInit) => Promise<Response>;
@@ -25,13 +25,12 @@ declare class NcpHttpAgentClientEndpoint implements NcpAgentClientEndpoint {
25
25
  stop(): Promise<void>;
26
26
  emit(event: NcpEndpointEvent): Promise<void>;
27
27
  subscribe(listener: NcpEndpointSubscriber): () => void;
28
- send(envelope: NcpRequestEnvelope): Promise<void>;
28
+ send(envelope: NcpAgentSendEnvelope): Promise<void>;
29
29
  stream(payload: NcpStreamRequestPayload): Promise<void>;
30
30
  abort(payload: NcpMessageAbortPayload): Promise<void>;
31
31
  private ensureStarted;
32
32
  private publish;
33
33
  private resolveUrl;
34
- private jsonRequest;
35
34
  private streamRequest;
36
35
  private handleSseFrame;
37
36
  }
package/dist/index.js CHANGED
@@ -247,7 +247,7 @@ var NcpHttpAgentClientEndpoint = class {
247
247
  }
248
248
  async send(envelope) {
249
249
  await this.ensureStarted();
250
- await this.jsonRequest({
250
+ await this.streamRequest({
251
251
  path: "/send",
252
252
  method: "POST",
253
253
  body: envelope
@@ -298,34 +298,6 @@ var NcpHttpAgentClientEndpoint = class {
298
298
  resolveUrl(path) {
299
299
  return new URL(`${this.basePath}${path}`, this.baseUrl);
300
300
  }
301
- async jsonRequest(options) {
302
- const controller = new AbortController();
303
- this.activeControllers.add(controller);
304
- try {
305
- const response = await this.fetchImpl(this.resolveUrl(options.path), {
306
- method: options.method,
307
- headers: {
308
- ...this.defaultHeaders,
309
- "content-type": "application/json",
310
- accept: "application/json"
311
- },
312
- body: options.body === void 0 ? void 0 : JSON.stringify(options.body),
313
- signal: controller.signal
314
- });
315
- if (!response.ok) throw new Error(`NCP request failed with HTTP ${response.status}: ${await safeReadText(response)}`);
316
- } catch (error) {
317
- if (controller.signal.aborted) return;
318
- if (isNcpHttpAgentClientError(error)) throw error;
319
- const ncpError = toNcpError(error);
320
- this.publish({
321
- type: NcpEventType.EndpointError,
322
- payload: ncpError
323
- });
324
- throw ncpErrorToError(ncpError);
325
- } finally {
326
- this.activeControllers.delete(controller);
327
- }
328
- }
329
301
  async streamRequest(options) {
330
302
  const controller = new AbortController();
331
303
  this.activeControllers.add(controller);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/ncp-http-agent-client",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "private": false,
5
5
  "description": "HTTP/SSE client transport adapter for NCP agent endpoints.",
6
6
  "type": "module",
@@ -15,7 +15,7 @@
15
15
  "dist"
16
16
  ],
17
17
  "dependencies": {
18
- "@nextclaw/ncp": "0.5.8"
18
+ "@nextclaw/ncp": "0.5.9"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "^20.17.6",