@g2e/agent-bridge 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw.js","sourceRoot":"","sources":["../../src/sinks/openclaw.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGhC,MAAM,UAAU,kBAAkB,CAAC,MAA0B;IAC3D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IAErC,OAAO;QACL,IAAI,EAAE,UAAU;QAEhB,KAAK,CAAC,OAAO,CAAC,KAAkB,EAAE,OAAe,EAAE,KAAe;YAChE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,IAAI,iHAAiH,CAAC,CAAC;YACzJ,CAAC;YAED,MAAM,cAAc,GAAG,cAAc,KAAK,CAAC,EAAE,EAAE,CAAC;YAEhD,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;YAC9E,CAAC;iBAAM,CAAC;gBACN,MAAM,aAAa,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,aAAa,CAC1B,UAAkB,EAClB,OAAe,EACf,cAAsB,EACtB,OAAgB;IAEhB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;QAC5B,UAAU;QACV,OAAO;QACP,cAAc;KACf,CAAC,CAAC;IAEH,MAAM,IAAI,GAA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CAAC,OAAO,EAAE,CAAC,CAAC;YAC7D,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,cAAc,CAC3B,UAAkB,EAClB,UAAkB,EAClB,OAAe,EACf,cAAsB;IAEtB,MAAM,IAAI,GAAG;QACX,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE;KAChD,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,UAAU,EAAE;QACnC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAC1B,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC;KACpC,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,GAAG,CAAC,OAAO,EAAE,iCAAiC,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;AACnG,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Stdout Sink
3
+ *
4
+ * Writes formatted messages to stdout. Useful for piping to other tools
5
+ * or for simple debugging.
6
+ */
7
+ import type { Sink } from '../types.js';
8
+ export declare function createStdoutSink(): Sink;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Stdout Sink
3
+ *
4
+ * Writes formatted messages to stdout. Useful for piping to other tools
5
+ * or for simple debugging.
6
+ */
7
+ export function createStdoutSink() {
8
+ return {
9
+ name: 'stdout',
10
+ async deliver(agent, message, _event) {
11
+ const separator = '='.repeat(60);
12
+ process.stdout.write(`\n${separator}\n[${agent.name}]\n${separator}\n${message}\n`);
13
+ },
14
+ };
15
+ }
16
+ //# sourceMappingURL=stdout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdout.js","sourceRoot":"","sources":["../../src/sinks/stdout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,IAAI,EAAE,QAAQ;QAEd,KAAK,CAAC,OAAO,CAAC,KAAkB,EAAE,OAAe,EAAE,MAAgB;YACjE,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,KAAK,CAAC,IAAI,MAAM,SAAS,KAAK,OAAO,IAAI,CAAC,CAAC;QACtF,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Webhook Sink
3
+ *
4
+ * Delivers events as JSON POST to a configured URL.
5
+ */
6
+ import type { Sink, WebhookSinkConfig } from '../types.js';
7
+ export declare function createWebhookSink(config: WebhookSinkConfig): Sink;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Webhook Sink
3
+ *
4
+ * Delivers events as JSON POST to a configured URL.
5
+ */
6
+ import { log } from '../log.js';
7
+ export function createWebhookSink(config) {
8
+ return {
9
+ name: 'webhook',
10
+ async deliver(agent, message, event) {
11
+ const body = {
12
+ agent: agent.name,
13
+ event: {
14
+ id: event.id,
15
+ type: event.type,
16
+ timestamp: event.timestamp,
17
+ data: event.data,
18
+ },
19
+ formattedMessage: message,
20
+ };
21
+ const headers = {
22
+ 'Content-Type': 'application/json',
23
+ ...config.headers,
24
+ };
25
+ const resp = await fetch(config.url, {
26
+ method: 'POST',
27
+ headers,
28
+ body: JSON.stringify(body),
29
+ signal: AbortSignal.timeout(15_000),
30
+ });
31
+ if (!resp.ok) {
32
+ const text = await resp.text().catch(() => '');
33
+ throw new Error(`Webhook POST ${resp.status}: ${text.slice(0, 200)}`);
34
+ }
35
+ log('debug', 'Webhook delivery succeeded', { agent: agent.name, url: config.url });
36
+ },
37
+ };
38
+ }
39
+ //# sourceMappingURL=webhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/sinks/webhook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGhC,MAAM,UAAU,iBAAiB,CAAC,MAAyB;IACzD,OAAO;QACL,IAAI,EAAE,SAAS;QAEf,KAAK,CAAC,OAAO,CAAC,KAAkB,EAAE,OAAe,EAAE,KAAe;YAChE,MAAM,IAAI,GAAG;gBACX,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,KAAK,EAAE;oBACL,EAAE,EAAE,KAAK,CAAC,EAAE;oBACZ,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,SAAS,EAAE,KAAK,CAAC,SAAS;oBAC1B,IAAI,EAAE,KAAK,CAAC,IAAI;iBACjB;gBACD,gBAAgB,EAAE,OAAO;aAC1B,CAAC;YAEF,MAAM,OAAO,GAA2B;gBACtC,cAAc,EAAE,kBAAkB;gBAClC,GAAG,MAAM,CAAC,OAAO;aAClB,CAAC;YAEF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE;gBACnC,MAAM,EAAE,MAAM;gBACd,OAAO;gBACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAC1B,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC;aACpC,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;gBACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC/C,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YACxE,CAAC;YAED,GAAG,CAAC,OAAO,EAAE,4BAA4B,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACrF,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @g2e/agent-bridge types
3
+ *
4
+ * Standalone type definitions. Does NOT import from the main G2E codebase.
5
+ */
6
+ export type AgentEventType = 'decision_request' | 'decision_expired' | 'session_started' | 'session_ended' | 'poll_opened' | 'poll_closed' | 'bribe_accepted' | 'roulette_selected' | 'roulette_ended' | 'balance_update' | 'inactivity_nudge' | 'error';
7
+ export declare const ALL_EVENT_TYPES: AgentEventType[];
8
+ export interface SSEEvent {
9
+ id: string;
10
+ type: AgentEventType;
11
+ target: 'broadcast' | 'targeted';
12
+ agentId?: string;
13
+ timestamp: number;
14
+ data: Record<string, unknown>;
15
+ expiresAt?: number;
16
+ }
17
+ export interface AgentConfig {
18
+ name: string;
19
+ apiKey: string;
20
+ sessionKey?: string;
21
+ events: AgentEventType[] | 'all';
22
+ }
23
+ export interface Sink {
24
+ readonly name: string;
25
+ deliver(agent: AgentConfig, message: string, event: SSEEvent): Promise<void>;
26
+ close?(): Promise<void>;
27
+ }
28
+ export interface BridgeConfig {
29
+ g2eApiUrl: string;
30
+ agents: AgentConfig[];
31
+ sink: SinkConfig;
32
+ reconnectMs: number;
33
+ maxReconnectMs: number;
34
+ }
35
+ export type SinkConfig = OpenClawSinkConfig | WebhookSinkConfig | FileSinkConfig | StdoutSinkConfig;
36
+ export interface OpenClawSinkConfig {
37
+ type: 'openclaw';
38
+ profile?: string;
39
+ gatewayUrl?: string;
40
+ }
41
+ export interface WebhookSinkConfig {
42
+ type: 'webhook';
43
+ url: string;
44
+ headers?: Record<string, string>;
45
+ }
46
+ export interface FileSinkConfig {
47
+ type: 'file';
48
+ path: string;
49
+ }
50
+ export interface StdoutSinkConfig {
51
+ type: 'stdout';
52
+ }
53
+ export declare const DEFAULT_CONFIG: Omit<BridgeConfig, 'agents'>;
package/dist/types.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @g2e/agent-bridge types
3
+ *
4
+ * Standalone type definitions. Does NOT import from the main G2E codebase.
5
+ */
6
+ export const ALL_EVENT_TYPES = [
7
+ 'decision_request',
8
+ 'decision_expired',
9
+ 'session_started',
10
+ 'session_ended',
11
+ 'poll_opened',
12
+ 'poll_closed',
13
+ 'bribe_accepted',
14
+ 'roulette_selected',
15
+ 'roulette_ended',
16
+ 'balance_update',
17
+ 'inactivity_nudge',
18
+ 'error',
19
+ ];
20
+ // ============================================================================
21
+ // Defaults
22
+ // ============================================================================
23
+ export const DEFAULT_CONFIG = {
24
+ g2eApiUrl: 'https://api.g2e.io',
25
+ sink: { type: 'openclaw' },
26
+ reconnectMs: 5000,
27
+ maxReconnectMs: 60000,
28
+ };
29
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoBH,MAAM,CAAC,MAAM,eAAe,GAAqB;IAC/C,kBAAkB;IAClB,kBAAkB;IAClB,iBAAiB;IACjB,eAAe;IACf,aAAa;IACb,aAAa;IACb,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,gBAAgB;IAChB,kBAAkB;IAClB,OAAO;CACR,CAAC;AAwEF,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E,MAAM,CAAC,MAAM,cAAc,GAAiC;IAC1D,SAAS,EAAE,oBAAoB;IAC/B,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;IAC1B,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE,KAAK;CACtB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@g2e/agent-bridge",
3
+ "version": "0.1.0",
4
+ "description": "Bridge G2E platform SSE events into agent sessions (OpenClaw, webhooks, files)",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "g2e-bridge": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist/",
12
+ "README.md",
13
+ "GUIDE.md",
14
+ "LICENSE"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/gamble-to-earn/gamble_to_earn.git",
19
+ "directory": "packages/agent-bridge"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/gamble-to-earn/gamble_to_earn/issues"
23
+ },
24
+ "scripts": {
25
+ "build": "tsc",
26
+ "dev": "tsc --watch",
27
+ "start": "node dist/index.js"
28
+ },
29
+ "keywords": [
30
+ "g2e",
31
+ "gamble-to-earn",
32
+ "sse",
33
+ "agent-bridge",
34
+ "openclaw",
35
+ "ai-agent",
36
+ "event-stream"
37
+ ],
38
+ "license": "MIT",
39
+ "homepage": "https://g2e.io",
40
+ "author": "G2E <dev@g2e.io>",
41
+ "engines": {
42
+ "node": ">=18.0.0"
43
+ },
44
+ "dependencies": {
45
+ "commander": "^12.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "typescript": "^5.3.0",
49
+ "@types/node": "^20.0.0"
50
+ }
51
+ }