Skip to content

feat(viewer-server): add /api/pi-hooks alias and memory tool routes - #1678

Open
ZeR020 wants to merge 8 commits into
kunickiaj:mainfrom
ZeR020:stack/3-viewer-routes
Open

feat(viewer-server): add /api/pi-hooks alias and memory tool routes#1678
ZeR020 wants to merge 8 commits into
kunickiaj:mainfrom
ZeR020:stack/3-viewer-routes

Conversation

@ZeR020

@ZeR020 ZeR020 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

@kunickiaj Third stacked PR for pi support (#1430). Layers 1–2 are merged (#1473, #1546), so this now sits directly on main.

Why

Pi needs a dedicated ingest URL that lands on the 0.41 canonical seam, plus the missing HTTP memory-tool routes thin clients use.

What

  • POST /api/pi-hooks: bounded parse → buildRawEventEnvelopeFromPiEvent → force source: "pi" → awaited ingestNormalizedEnvelope. No recordRawEvent / stripPrivateObj.
  • Memory-tool routes (remember, timeline, expand, schema, search_index, explain, distill_candidates).
  • POSTs use the shared bounded JSON parser; kinds from core REMEMBER_MEMORY_KINDS; string "false" is false.
  • Adjusted for feat(core): add pi event adapter for 0.41 ingest #1546's hardened contract: pi event ids asserted in the pi_evt_ hashed form, ingest awaited, and the remember-kinds set widened to Set<string> for filter checks.

Deliberate: MCP helper bodies stay copied in this layer. Extracting them into core is a follow-up (tracked in ZeR020#8), not this PR. Docs arrive on the final layer of this track.

Test plan

  • vitest run packages/viewer-server/src/routes/memory-tools.test.ts — 23/23
  • pnpm build, pnpm run lint, pnpm run tsc, full vitest run — green

Related: #1430, #1429

Pi events enter the 0.41 ingest seam through a dedicated compat route
that forces source "pi". Memory-tool POSTs reuse the bounded JSON
parser and the shared remember-kind catalog.
POST expand/explain/distill copied raw filter values into store queries.
Objects such as include_scope_ids:{x:1} were coerced to "[object Object]".
Validate scalar or scalar-array types and return 400 before SQLite.
Copilot AI lite review requested due to automatic review settings September 10, 2026 11:44
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

tsc --build --force on core/embeddings/mcp-server/viewer-server re-emits
packages/embeddings/dist/*.d.ts from every parallel pnpm lane. A sibling
lane then reads the file mid-write (TS2306 "is not a module") — the
TypeScript Test build step on kunickiaj#1678. Clean already deletes dist and
tsbuildinfo, which is why --force was added in kunickiaj#650.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants