Skip to content

fix(plugins): swap speculative Remote backends for real ActivepiecesMemoryBackend - #36

Merged
rrader26 merged 1 commit into
mainfrom
fix/remove-stub-remote-backends
May 12, 2026
Merged

fix(plugins): swap speculative Remote backends for real ActivepiecesMemoryBackend#36
rrader26 merged 1 commit into
mainfrom
fix/remove-stub-remote-backends

Conversation

@rrader26

Copy link
Copy Markdown
Contributor

Summary

PR #35 shipped `RemoteMemoryBackend` + `RemoteRecipeBackend` against a REST contract we never built. They were marked "v1 proposal" — pure stubs. This PR removes them and replaces with a real production-ready `ActivepiecesMemoryBackend` that hits live endpoints.

What changes

Removed (stubs):

  • `src/plugins/memory/remote-backend.ts`
  • `src/plugins/recipes/remote-backend.ts`
  • both stub test files

Added (real):

  • `src/plugins/memory/activepieces-backend.ts` — hits the actual Activepieces `/v1/projects/:projectId/[chatbots/:chatbotId/]memory` endpoints
  • `test/memory/activepieces-backend.test.ts` — 20 tests against mocked fetch

What ActivepiecesMemoryBackend does

  • Auth: `Authorization: Bearer sk-` against the Activepieces Service-principal flow
  • Search: routes `agentmark_memory_search` to Activepieces' hybrid vector + BM25 endpoint — Claude Code / Cursor / Codex agents get semantic memory search for free
  • Scope-aware: all five agentmark scopes (platform/project/agent/user/session) map directly to Activepieces' same enum
  • No data collision: stamps every write with `source: "agentmark"` and filters every read by the same — agentmark records don't mix with manually-created Activepieces memories

Mapping

agentmark Activepieces
`key` `metadata.agentmark_key`
`value` `content` (string-coerced) + `metadata.raw_value` (preserves type)
`scope.type` `scope` (same five-level enum)
`scope.id` `metadata.scope_id`
`tags` `metadata.tags`

Recipes

NO `ActivepiecesRecipeBackend` ships in this PR. Activepieces has no recipes endpoints yet; we don't ship a stub. The `RecipeBackend` interface + `LocalFileRecipeBackend` remain — when the service ships, the real backend lands then.

Usage (post-merge)

```ts
import { createMemoryPlugin, ActivepiecesMemoryBackend } from '@thinkfleet/agentmark'

const memory = createMemoryPlugin({
backend: new ActivepiecesMemoryBackend({
baseUrl: 'https://app.thinkfleet.ai',
apiKey: process.env.AP_API_KEY, // sk-...
projectId: process.env.AP_PROJECT_ID,
chatbotId: process.env.AP_CHATBOT_ID, // optional
}),
})
```

Test plan

  • `pnpm build` clean
  • `pnpm test` — 491 pass / 10 skip (20 new for Activepieces backend; all 471 prior tests still pass)
  • Manual: configure with a real Activepieces API key + project, store a memory from Claude Code, verify via Activepieces UI that the record appears with `source=agentmark`

🤖 Generated with Claude Code

…emoryBackend

PR #35 shipped Remote{Memory,Recipe}Backend classes that targeted REST
endpoints we never built — pure stubs. They were marked "v1 proposal"
in their headers, which is the kind of speculative interface we don't
want in production code.

This PR removes the stubs and replaces them with a REAL
ActivepiecesMemoryBackend that hits live endpoints in the user's
Activepieces deployment:

  /v1/projects/:projectId/memory                               (project-scoped)
  /v1/projects/:projectId/chatbots/:chatbotId/memory          (chatbot-scoped)
  /v1/projects/:projectId/chatbots/:chatbotId/memory/search   (hybrid search)

Auth: `Authorization: Bearer sk-<api-key>` against the existing
Activepieces Service-principal flow. The same Claude Code / Cursor /
Codex agent connecting to agentmark now writes to **real Activepieces
memory** instead of a speculative service — and gets hybrid vector +
BM25 semantic search for free since agentmark_memory_search routes
to /memory/search.

Mapping (agentmark K/V → Activepieces rich shape):
  - agentmark `key`   → metadata.agentmark_key
  - agentmark `value` → content + metadata.raw_value (preserves type)
  - agentmark `scope` → Activepieces scope (same five-level enum)
  - agentmark `scope.id` → metadata.scope_id
  - agentmark `tags`  → metadata.tags
  - source stamp = "agentmark" (filterable; backends only see records
    they wrote)

Recipes: NO ActivepiecesRecipeBackend ships in this PR because
Activepieces has no recipes endpoints yet. RecipeBackend interface +
LocalFileRecipeBackend remain; when the recipes service ships, a
real implementation lands then.

Removed (the stubs):
  - src/plugins/memory/remote-backend.ts
  - src/plugins/recipes/remote-backend.ts
  - test/memory/remote-backend.test.ts
  - test/recipes/remote-backend.test.ts

Added:
  - src/plugins/memory/activepieces-backend.ts  (real impl)
  - test/memory/activepieces-backend.test.ts    (20 tests)

Tests: 491 pass / 10 skip. Build clean. All prior tests pass unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rrader26
rrader26 merged commit 7385c53 into main May 12, 2026
5 checks passed
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