@relaymessenger/openclaw-plugin 0.3.4 → 0.4.0-staging.1

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.
Files changed (61) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +162 -123
  3. package/contracts/relay-sdk-0.3.0-staging.5.registry.json +69 -0
  4. package/contracts/relay-v1.lock.json +77 -0
  5. package/dist/index.js +2 -2
  6. package/dist/setup-entry.js +1 -2
  7. package/dist/src/accounts.js +63 -34
  8. package/dist/src/channel.js +144 -533
  9. package/dist/src/dispatch.js +257 -0
  10. package/dist/src/full-sync.js +24 -0
  11. package/dist/src/gateway.js +171 -0
  12. package/dist/src/inbound.js +54 -85
  13. package/dist/src/ingress.js +64 -0
  14. package/dist/src/outbound.js +48 -111
  15. package/dist/src/runtime.js +2 -3
  16. package/dist/src/state.js +492 -0
  17. package/dist/src/types.js +1 -3
  18. package/index.ts +1 -2
  19. package/openclaw.plugin.json +15 -18
  20. package/package.json +114 -40
  21. package/setup-entry.ts +0 -2
  22. package/src/accounts.ts +95 -51
  23. package/src/channel.ts +271 -646
  24. package/src/dispatch.ts +324 -0
  25. package/src/full-sync.ts +47 -0
  26. package/src/gateway.ts +216 -0
  27. package/src/inbound.ts +71 -122
  28. package/src/ingress.ts +123 -0
  29. package/src/outbound.ts +70 -149
  30. package/src/runtime.ts +4 -4
  31. package/src/state.ts +609 -0
  32. package/src/types.ts +51 -162
  33. package/dist/src/account-lock.js +0 -91
  34. package/dist/src/client.js +0 -13
  35. package/dist/src/cursor-store.js +0 -136
  36. package/dist/src/inbound-dedupe.js +0 -175
  37. package/dist/src/invocations.js +0 -47
  38. package/dist/src/lifecycle.js +0 -35
  39. package/dist/src/poll-loop.js +0 -137
  40. package/dist/src/responding.js +0 -36
  41. package/dist/src/security.js +0 -26
  42. package/dist/src/state-files.js +0 -243
  43. package/dist/src/vendor/relay-sdk/client.js +0 -163
  44. package/dist/src/vendor/relay-sdk/errors.js +0 -45
  45. package/dist/src/vendor/relay-sdk/types.js +0 -2
  46. package/dist/src/vendor/relay-sdk/url.js +0 -39
  47. package/src/account-lock.ts +0 -108
  48. package/src/client.ts +0 -51
  49. package/src/cursor-store.ts +0 -186
  50. package/src/inbound-dedupe.ts +0 -241
  51. package/src/invocations.ts +0 -58
  52. package/src/lifecycle.ts +0 -42
  53. package/src/poll-loop.ts +0 -173
  54. package/src/responding.ts +0 -52
  55. package/src/security.ts +0 -36
  56. package/src/state-files.ts +0 -298
  57. package/src/vendor/relay-sdk/README.md +0 -28
  58. package/src/vendor/relay-sdk/client.ts +0 -293
  59. package/src/vendor/relay-sdk/errors.ts +0 -61
  60. package/src/vendor/relay-sdk/types.ts +0 -82
  61. package/src/vendor/relay-sdk/url.ts +0 -43
@@ -1,82 +0,0 @@
1
- /** Wire types for the Relay v1 developer API used by plugins and examples. */
2
-
3
- export type RelaySender = {
4
- kind: "user" | "agent" | "system";
5
- id: string;
6
- display_name?: string;
7
- };
8
-
9
- export type RelayOutgoingPart =
10
- | { type: "text"; text: string }
11
- | { type: "media"; attachment_id?: string; url?: string }
12
- | { type: "voice_memo"; attachment_id?: string; url?: string; duration_ms?: number }
13
- | { type: "link_preview"; url: string }
14
- | { type: "data"; data: Record<string, unknown> };
15
-
16
- export type RelayPart = {
17
- type: string;
18
- part_index?: number;
19
- text?: string;
20
- url?: string;
21
- attachment_id?: string;
22
- duration_ms?: number;
23
- data?: Record<string, unknown>;
24
- [key: string]: unknown;
25
- };
26
-
27
- export type RelayReplyRef = {
28
- message_id: string;
29
- };
30
-
31
- export type RelayMessage = {
32
- id: string;
33
- conversation_id: string;
34
- sequence: number;
35
- sender: RelaySender;
36
- parts: RelayPart[];
37
- reply_to?: RelayReplyRef | null;
38
- fallback_text?: string;
39
- status?: string;
40
- created_at: string;
41
- };
42
-
43
- export type RelayEventEnvelope<TData = Record<string, unknown>> = {
44
- event_id: string;
45
- event_type: string;
46
- agent_id: string;
47
- created_at: string;
48
- data: TData;
49
- };
50
-
51
- export type MessageReceivedData = {
52
- message: RelayMessage;
53
- invocation_id?: string;
54
- };
55
-
56
- export type MessageReceivedEvent = RelayEventEnvelope<MessageReceivedData>;
57
-
58
- export type RelayAgentProfile = {
59
- id: string;
60
- owner_user_id?: string;
61
- handle: string;
62
- display_name: string;
63
- tagline?: string;
64
- avatar_url?: string | null;
65
- visibility?: "private" | "unlisted" | "public";
66
- created_at?: string;
67
- };
68
-
69
- export type RelayEventsPage = {
70
- events: RelayEventEnvelope[];
71
- nextCursor: number;
72
- };
73
-
74
- /**
75
- * The 202 from `POST /v1/messages`. The server splits the accepted parts at
76
- * ingest: each visible non-media part becomes its own message, contiguous
77
- * media parts stay one media message, and a voice memo always commits alone,
78
- * so one send commits one or more messages, in display order.
79
- */
80
- export type RelaySendResult = {
81
- messages: RelayMessage[];
82
- };
@@ -1,43 +0,0 @@
1
- import { isIP } from "node:net";
2
-
3
- export const DEFAULT_RELAY_BASE_URL = "https://api.relayapp.im";
4
-
5
- function isLoopbackHostname(hostname: string): boolean {
6
- const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, "");
7
- const ipVersion = isIP(normalized);
8
- if (ipVersion === 4) return normalized.split(".")[0] === "127";
9
- if (ipVersion === 6) return normalized === "::1";
10
- return normalized === "localhost" || normalized.endsWith(".localhost");
11
- }
12
-
13
- /**
14
- * Validate and canonicalize the API origin before a bearer token can be sent.
15
- * Remote origins must use HTTPS. Plain HTTP is allowed only on loopback.
16
- */
17
- export function normalizeRelayBaseUrl(raw?: string): string {
18
- const candidate = raw?.trim() || DEFAULT_RELAY_BASE_URL;
19
- let url: URL;
20
- try {
21
- url = new URL(candidate);
22
- } catch {
23
- throw new Error(`relay: invalid baseUrl ${JSON.stringify(candidate)}`);
24
- }
25
- if (url.username || url.password) {
26
- throw new Error("relay: baseUrl must not contain credentials");
27
- }
28
- if (url.search || url.hash) {
29
- throw new Error("relay: baseUrl must not contain a query or fragment");
30
- }
31
- if (!/^\/+$/u.test(url.pathname)) {
32
- throw new Error("relay: baseUrl must be an origin without a path");
33
- }
34
- if (
35
- url.protocol !== "https:" &&
36
- !(url.protocol === "http:" && isLoopbackHostname(url.hostname))
37
- ) {
38
- throw new Error(
39
- "relay: baseUrl must use HTTPS (HTTP is allowed only for loopback development)",
40
- );
41
- }
42
- return url.origin;
43
- }