palz-connector 1.6.8 → 1.6.9
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/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/control-server.js +33 -10
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
package/src/control-server.js
CHANGED
|
@@ -74,6 +74,9 @@ export function startControlServer(opts) {
|
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
if (path === "/admin/kb-ingest/callback") {
|
|
77
|
+
const contentType = String(req.headers["content-type"] || "");
|
|
78
|
+
const contentLength = String(req.headers["content-length"] || "?");
|
|
79
|
+
log(`palz-kb-callback: [recv] method=${method} contentType=${contentType} contentLength=${contentLength} remote=${req.socket.remoteAddress ?? "?"}`);
|
|
77
80
|
if (method !== "POST") {
|
|
78
81
|
sendJson(res, { code: 405, err_message: "method not allowed", data: {} });
|
|
79
82
|
return;
|
|
@@ -83,19 +86,39 @@ export function startControlServer(opts) {
|
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
85
88
|
const rawBody = await readRequestBody(req);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
error
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
log(`palz-kb-callback: [recv body] len=${rawBody.length} preview=${JSON.stringify(rawBody.slice(0, 500))}`);
|
|
90
|
+
let body;
|
|
91
|
+
try {
|
|
92
|
+
body = parseCallbackBody(req, rawBody);
|
|
93
|
+
}
|
|
94
|
+
catch (parseErr) {
|
|
95
|
+
error(`palz-kb-callback: [recv] body parse failed: ${parseErr?.message ?? parseErr}`);
|
|
96
|
+
sendJson(res, { code: 400, err_message: `invalid callback body: ${String(parseErr?.message ?? parseErr)}`, data: {} });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
let result;
|
|
100
|
+
try {
|
|
101
|
+
result = await handleKbTaskCallback({
|
|
102
|
+
cfg: opts.cfg,
|
|
103
|
+
runtime: opts.runtime,
|
|
104
|
+
body,
|
|
105
|
+
log,
|
|
106
|
+
error,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
catch (dispatchErr) {
|
|
110
|
+
const resp = { code: 500, err_message: String(dispatchErr?.message ?? dispatchErr), data: {} };
|
|
111
|
+
error(`palz-kb-callback: [resp] handle failed, response=${JSON.stringify(resp)}`);
|
|
112
|
+
sendJson(res, resp);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const resp = {
|
|
95
116
|
code: result.handled ? 0 : 404,
|
|
96
117
|
err_message: result.handled ? "" : (result.reason ?? "not handled"),
|
|
97
118
|
data: result,
|
|
98
|
-
}
|
|
119
|
+
};
|
|
120
|
+
log(`palz-kb-callback: [resp] handled=${result.handled} response=${JSON.stringify(resp)}`);
|
|
121
|
+
sendJson(res, resp);
|
|
99
122
|
return;
|
|
100
123
|
}
|
|
101
124
|
sendJson(res, { code: 404, err_message: "not found", data: {} });
|