@skein-js/fetch 0.15.0 → 0.17.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.
Files changed (2) hide show
  1. package/dist/index.js +14 -6
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -46,14 +46,18 @@ async function readBoundedText(request, maxBodyBytes) {
46
46
  }
47
47
  return text + decoder.decode();
48
48
  }
49
- async function toProtocolRequest(request, url, skeinPathname, params, maxBodyBytes) {
49
+ async function toProtocolRequest(request, url, skeinPathname, params, maxBodyBytes, retainRawBody = false) {
50
50
  let body;
51
51
  if (request.method !== "GET" && request.method !== "HEAD") {
52
52
  const text = await readBoundedText(request, maxBodyBytes);
53
- try {
54
- body = text ? JSON.parse(text) : {};
55
- } catch {
56
- throw SkeinHttpError.badRequest("Request body is not valid JSON.");
53
+ if (retainRawBody) {
54
+ body = text;
55
+ } else {
56
+ try {
57
+ body = text ? JSON.parse(text) : {};
58
+ } catch {
59
+ throw SkeinHttpError.badRequest("Request body is not valid JSON.");
60
+ }
57
61
  }
58
62
  }
59
63
  return {
@@ -119,6 +123,9 @@ function toFetchResponse(response, extraHeaders = {}) {
119
123
  function errorResponse(error, extraHeaders, logger) {
120
124
  const headers = { "content-type": "application/json", ...extraHeaders };
121
125
  if (isSkeinHttpError(error)) {
126
+ if (error.status >= 500) {
127
+ logger?.error(`Request failed: ${error.message}`, error);
128
+ }
122
129
  return new Response(
123
130
  JSON.stringify({
124
131
  status: error.status,
@@ -175,7 +182,8 @@ function createFetchHandler(resolved, options) {
175
182
  url,
176
183
  skeinPathname,
177
184
  match.params,
178
- maxBodyBytes
185
+ maxBodyBytes,
186
+ match.binding.retainRawBody ?? false
179
187
  );
180
188
  const invoke = resolved.runtime.handlers[match.binding.handler];
181
189
  const response = await invoke(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skein-js/fetch",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "Runtime-neutral Fetch adapter for serving the Skein Agent Protocol on Bun and Deno.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Maina Wycliffe <wmmaina7@gmail.com>",
@@ -40,9 +40,9 @@
40
40
  ],
41
41
  "sideEffects": false,
42
42
  "dependencies": {
43
- "@skein-js/core": "0.15.0",
44
- "@skein-js/server-kit": "0.15.0",
45
- "@skein-js/agent-protocol": "0.15.0"
43
+ "@skein-js/agent-protocol": "0.17.0",
44
+ "@skein-js/server-kit": "0.17.0",
45
+ "@skein-js/core": "0.17.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@langchain/langgraph": "^1.4.0"