@agentmessier/openclaw-agent-messier 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/index.ts +121 -0
- package/openclaw.plugin.json +110 -0
- package/package.json +36 -0
- package/src/format.ts +173 -0
- package/src/spec.test.ts +106 -0
- package/src/state.ts +23 -0
- package/src/tools.test.ts +55 -0
- package/src/tools.ts +757 -0
- package/src/venues.test.ts +67 -0
- package/src/watcher.test.ts +121 -0
- package/src/watcher.ts +216 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
|
2
|
+
import { pitchClient, agentIdOf, apiKeyOf, type PluginCfg } from "./tools.js";
|
|
3
|
+
import { session } from "./state.js";
|
|
4
|
+
|
|
5
|
+
// A config whose sessionKey is unique per test so the cross-process tmp caches
|
|
6
|
+
// (token/did) never collide between cases.
|
|
7
|
+
function cfg(extra: Partial<PluginCfg> = {}): PluginCfg {
|
|
8
|
+
return { serverUrl: "http://pitch.test", sessionKey: `t-${Math.random().toString(36).slice(2)}`, ...extra };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe("soccer extension join auth", () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
session.did = null;
|
|
14
|
+
session.token = null;
|
|
15
|
+
session.matchId = null;
|
|
16
|
+
});
|
|
17
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
18
|
+
|
|
19
|
+
it("apiKeyOf prefers config, falls back to AGENTNET_API_KEY", () => {
|
|
20
|
+
expect(apiKeyOf(cfg({ apiKey: "from-cfg" }))).toBe("from-cfg");
|
|
21
|
+
vi.stubEnv("AGENTNET_API_KEY", "from-env");
|
|
22
|
+
expect(apiKeyOf(cfg())).toBe("from-env");
|
|
23
|
+
vi.unstubAllEnvs();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("quickMatch sends the Bearer key and learns the returned DID", async () => {
|
|
27
|
+
const seen: { auth?: string } = {};
|
|
28
|
+
vi.stubGlobal("fetch", vi.fn(async (_url: any, init: any) => {
|
|
29
|
+
seen.auth = init?.headers?.Authorization;
|
|
30
|
+
return { ok: true, json: async () => ({ matchId: "m1", team: "home", playerIds: ["h1"], started: false, did: "did:wba:tester", token: "seat-tok" }) } as any;
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
const c = cfg({ apiKey: "good-key" });
|
|
34
|
+
const data = await pitchClient(c).quickMatch(agentIdOf(c), { teamSize: 5 });
|
|
35
|
+
|
|
36
|
+
expect(seen.auth).toBe("Bearer good-key");
|
|
37
|
+
expect(data.did).toBe("did:wba:tester");
|
|
38
|
+
// DID is now this agent's identity for subsequent seat lookups + calls.
|
|
39
|
+
expect(session.did).toBe("did:wba:tester");
|
|
40
|
+
expect(agentIdOf(c)).toBe("did:wba:tester");
|
|
41
|
+
expect(session.token).toBe("seat-tok");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("omits the Authorization header when no key is configured (dev mode)", async () => {
|
|
45
|
+
const seen: { auth?: string } = {};
|
|
46
|
+
vi.stubGlobal("fetch", vi.fn(async (_url: any, init: any) => {
|
|
47
|
+
seen.auth = init?.headers?.Authorization;
|
|
48
|
+
return { ok: true, json: async () => ({ matchId: "m1", team: "home", playerIds: ["h1"], started: false, token: "seat-tok" }) } as any;
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
const c = cfg(); // no apiKey, no env
|
|
52
|
+
await pitchClient(c).quickMatch(agentIdOf(c), {});
|
|
53
|
+
expect(seen.auth).toBeUndefined();
|
|
54
|
+
});
|
|
55
|
+
});
|