Skip to content

Commit 5dc17b4

Browse files
fix(proxy): add KG endpoint + GET query-param agent_id namespacing (DAK-6899) (#216)
Two proxy fixes to unblock playground Mode 9 (KG Explorer): 1. allowlist.js: add POST /v1/knowledge/graph/full to the sandbox allow-list. The playground KG Explorer calls this endpoint (not /knowledge/graph which requires a single memory_id). full_knowledge_graph accepts agent_id and builds the graph from all memories in that agent's namespace. 2. server.js: rewrite agent_id in GET URL query parameters (same session namespace as POST body rewriting). Without this, GET /v1/knowledge/query and GET /v1/knowledge/path land in a different namespace than the memories that were seeded via POST store — making KG traversal always return empty. All 9 playground modes now validated end-to-end. Co-authored-by: Paperclip <noreply@paperclip.ing>
1 parent cd401d7 commit 5dc17b4

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

docker/playground/proxy/allowlist.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const ALLOW = [
7474
// /v1/knowledge/graph is POST-only in the engine (lib.rs:483 post). The dead
7575
// GET entry was removed (it could only ever 405).
7676
compile('POST', '/v1/knowledge/graph'),
77+
compile('POST', '/v1/knowledge/graph/full'), // DAK-6899: KG Explorer
7778
compile('GET', '/v1/memories/{seg}/graph'),
7879
compile('GET', '/v1/memories/{seg}/path'),
7980
// NOTE: /v1/memories/{seg}/links is POST-only in the engine (link creation,

docker/playground/proxy/server.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,19 @@ function createServer(config, store) {
416416
};
417417
}
418418

419-
forward(config, req, res, path, bodyBuf, outHeaders, rewrite);
419+
// Also rewrite agent_id in URL query params for GET endpoints (DAK-6899)
420+
let forwardPath = path;
421+
try {
422+
const qUrl = new URL(req.url, "http://localhost");
423+
if (qUrl.searchParams.has("agent_id")) {
424+
const namespace = sessionNamespace(resolved.id);
425+
const qAgentId = qUrl.searchParams.get("agent_id");
426+
qUrl.searchParams.set("agent_id", namespace);
427+
forwardPath = qUrl.pathname + "?" + qUrl.searchParams.toString();
428+
if (!rewrite) rewrite = { namespace, restoreTo: qAgentId };
429+
}
430+
} catch (_) {}
431+
forward(config, req, res, forwardPath, bodyBuf, outHeaders, rewrite);
420432
});
421433
}
422434

0 commit comments

Comments
 (0)