Skip to content

feat: base44.superagent namespace (superagent-for-apps PoC)#229

Open
cowchimp wants to merge 1 commit into
mainfrom
feat/superagent-namespace
Open

feat: base44.superagent namespace (superagent-for-apps PoC)#229
cowchimp wants to merge 1 commit into
mainfrom
feat/superagent-namespace

Conversation

@cowchimp

Copy link
Copy Markdown
Collaborator

What

New base44.superagent SDK namespace — a thin client for chatting with a published public Superagent linked to a Base44 app (demo/PoC; pairs with the apper branch superagent-for-apps-poc, stacked on apper#14972).

const agent = base44.superagent.forApp(superagentAppId);
const conv  = await agent.createConversation({ metadata });
await agent.addMessage(conv, { role: "user", content: "Hello" });
const unsub = agent.subscribeToConversation(conv.id, (c) => setMessages(c.messages));

How

  • src/modules/superagent.ts + superagent.types.ts, modeled on the agents module; agent_name is always your_agent; same runtime routes (/apps/{superagentAppId}/agents/...), v2 messages endpoint.
  • Deliberately anonymous: each forApp(appId) handle gets its own axios client (X-App-Id: <superagentAppId>, no Authorization → the X-Base44-Anonymous-Id interceptor fires) and its own socket (app_id=<superagentAppId>, anonymous_id handshake, no token). The host app's token never reaches the superagent app — covered by a dedicated test.
  • socket-utils: new opt-in anonymous flag so the handshake skips both the config token and the getAccessToken() localStorage fallback; existing callers unaffected.

Why

The public Superagent runtime (apper#14972) serves anonymous visitors; a host app's generated chat widget needs a first-class SDK surface to talk to its linked superagent without cross-app token juggling.

Testing

  • npm test: 188/188 (incl. 7 new superagent tests: path construction, your_agent on create, v2 addMessage, no-Authorization isolation)
  • npm run lint + npm run build: clean

PoC note: intended for a deploy-preview package to feed the apper staging env; not for immediate merge.

… chat

Adds base44.superagent.forApp(superagentAppId), returning a per-app cached
handle that talks to the sibling superagent app's agents routes with a
dedicated anonymous axios client (X-App-Id set to the superagent app, no
Authorization token, so the anonymous-visitor-id interceptor fires) and a
dedicated anonymous socket (handshake carries app_id + anonymous_id, never
a token). Conversation creation always uses the fixed agent name
your_agent.

Also adds an explicit anonymous flag to RoomsSocketConfig so a socket can
opt out of the stored-access-token fallback.
@claude

claude Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

@github-actions

Copy link
Copy Markdown

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.8.38-pr.229.6a453f4

Prefer not to change any import paths? Install using npm alias so your code still imports @base44/sdk:

npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.38-pr.229.6a453f4"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.38-pr.229.6a453f4"
  }
}

Preview published to npm registry — try new features instantly!

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.

1 participant