search1api 0.1.1: Magpie attribution, reused OAuth client, send_feedback through Search1API (#424)
search1api 0.1.1 (fatwang2):
- Sign-ins carry utm_source=magpie and API requests send User-Agent search1api-magpie/0.1.1.
- The registered public OAuth client and its loopback port are saved in search1api-oauth-client.json (mode 600) and reused. A busy port, another issuer, or a sign-in that doesn't finish leads to a new registration.
- A send_feedback tool posts to Search1API's own POST /feedback with the caller's credential, on the same request path as the other tools, including the OAuth refresh on 401. Its description lists what is sent (message, intent, category, request_id, model) and says Search1API stores it on agentback.app, linked to the signed-in account. The plugin contacts no other host. A report that can't be sent returns a note and doesn't fail the task.
Run at the reviewed head d48c8c8 (sandbox HOME/TMPDIR, Bun 1.4.2):
- bun test packages/search1api/tests: 23 pass, 0 fail
- bun scripts/check.mjs search1api: ok
- PR CI (test, on-npm): pass
- grep of the package: the only host is api.search1api.com (plus 127.0.0.1 for the callback). No hard-coded keys. agentback.app appears only in the description, the README and a test.
- Drove the built plugin against my own loopback fake API:
- OAuth access revoked (401): POST /feedback with the old bearer, then /token refresh_token, then POST /feedback with the new bearer. Got "Feedback recorded (fb_1)" and auth.set with the new token.
- Bad API key: a 401 gives "not recorded ... (401)" with no refresh, and the error body is not echoed.
- Body is exactly {message, intent, category, request_id, agent:{name:"Magpie", model}}, with UA search1api-magpie/0.1.1.
- Unknown args and a non-string model are refused before any request.
- An unauthenticated probe of the real api.search1api.com: POST /feedback gives 401, and an unknown path gives 404. So the endpoint exists.
- The OAuth client reuse (unchanged since 95f236f) was run by hand in the previous review.
Not tried: a real Search1API account (none available).
This commit is contained in:
@@ -87,6 +87,14 @@ test("fetch stub: all six tools preserve wire bodies, defaults and complete JSON
|
||||
assert.deepEqual(plugin.auth.methods.map((m) => m.type), ["oauth", "api"]);
|
||||
});
|
||||
|
||||
test("fetch stub: API requests identify the plugin version", async (t) => {
|
||||
const f = await stub(t, () => json({ results: [] }));
|
||||
const plugin = await Search1APIPlugin(f.input, { baseUrl, apiKey: "fixture-key" });
|
||||
await plugin.tool.search.execute({ query: "fixture" }, context());
|
||||
const { version } = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
|
||||
assert.equal(new Headers(f.calls[0].headers).get("user-agent"), `search1api-magpie/${version}`);
|
||||
});
|
||||
|
||||
test("fetch stub: invalid arguments are refused before any request", async (t) => {
|
||||
const f = await stub(t, () => { throw new Error("must not fetch"); });
|
||||
const plugin = await Search1APIPlugin(f.input, { baseUrl, apiKey: "fixture-key" });
|
||||
|
||||
Reference in New Issue
Block a user