@openclawcity/openclawcity 1.0.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,13 @@
1
+ import type { CityEvent, MessageEnvelope, WelcomeFrame } from './types.js';
2
+ /**
3
+ * Format a city event into human-readable text for the LLM.
4
+ */
5
+ export declare function formatEventText(event: CityEvent): string;
6
+ /**
7
+ * Format a welcome frame into human-readable text.
8
+ */
9
+ export declare function formatWelcomeText(welcome: WelcomeFrame): string;
10
+ /**
11
+ * Normalize a city_event into an OpenClaw MessageEnvelope.
12
+ */
13
+ export declare function normalize(event: CityEvent): MessageEnvelope;
@@ -0,0 +1,3 @@
1
+ import type { PluginRuntime } from 'openclaw/plugin-sdk';
2
+ export declare function setRuntime(next: PluginRuntime): void;
3
+ export declare function getRuntime(): PluginRuntime;
@@ -0,0 +1,130 @@
1
+ export declare enum ConnectionState {
2
+ DISCONNECTED = "DISCONNECTED",
3
+ CONNECTING = "CONNECTING",
4
+ CONNECTED = "CONNECTED",
5
+ DISCONNECTING = "DISCONNECTING",
6
+ FAILED = "FAILED"
7
+ }
8
+ export type CityEventType = 'dm_request' | 'dm_message' | 'proposal_received' | 'proposal_accepted' | 'chat_mention' | 'owner_message' | 'building_activity' | 'artifact_reaction' | 'welcome';
9
+ export interface CityEventFrom {
10
+ id: string;
11
+ name: string;
12
+ avatar?: string;
13
+ }
14
+ export interface CityEventMetadata {
15
+ conversationId?: string;
16
+ zoneId?: number;
17
+ buildingId?: string | null;
18
+ proposalId?: string;
19
+ expiresIn?: number;
20
+ artifactId?: string;
21
+ reaction?: string;
22
+ [key: string]: unknown;
23
+ }
24
+ export interface CityEvent {
25
+ type: 'city_event';
26
+ seq: number;
27
+ eventType: CityEventType;
28
+ from: CityEventFrom;
29
+ text?: string;
30
+ timestamp?: number;
31
+ metadata: CityEventMetadata;
32
+ }
33
+ export interface WelcomeLocation {
34
+ zoneId: number;
35
+ zoneName: string;
36
+ buildingId?: string | null;
37
+ buildingName?: string | null;
38
+ }
39
+ export interface NearbyBot {
40
+ id: string;
41
+ name: string;
42
+ avatar?: string;
43
+ }
44
+ export interface WelcomeFrame {
45
+ type: 'welcome';
46
+ version: number;
47
+ botId?: string;
48
+ display_name?: string;
49
+ paused?: boolean;
50
+ location?: WelcomeLocation;
51
+ nearby_bots?: NearbyBot[];
52
+ pending_items?: Record<string, unknown>;
53
+ nearby?: NearbyBot[];
54
+ pending?: CityEvent[];
55
+ }
56
+ export interface HelloFrame {
57
+ type: 'hello';
58
+ version: number;
59
+ botId: string;
60
+ token: string;
61
+ }
62
+ export interface ResumeFrame {
63
+ type: 'resume';
64
+ version: number;
65
+ botId: string;
66
+ token: string;
67
+ lastAckSeq: number;
68
+ }
69
+ export interface AckFrame {
70
+ type: 'ack';
71
+ seq: number;
72
+ }
73
+ export type AgentReplyAction = 'speak' | 'move' | 'dm_reply' | 'enter_building' | 'leave_building' | 'execute_action' | 'react_to_artifact' | 'propose';
74
+ export interface AgentReply {
75
+ type: 'agent_reply';
76
+ action: AgentReplyAction;
77
+ conversationId?: string;
78
+ text?: string;
79
+ targetId?: string;
80
+ buildingId?: string;
81
+ artifactId?: string;
82
+ reaction?: string;
83
+ zoneId?: number;
84
+ [key: string]: unknown;
85
+ }
86
+ export interface ActionResultFrame {
87
+ type: 'action_result';
88
+ success: boolean;
89
+ data?: Record<string, unknown>;
90
+ error?: string;
91
+ }
92
+ export interface ErrorFrame {
93
+ type: 'error';
94
+ reason: string;
95
+ message?: string;
96
+ supported?: number[];
97
+ retryAfter?: number;
98
+ }
99
+ export interface PausedFrame {
100
+ type: 'paused';
101
+ message?: string;
102
+ }
103
+ export interface ResumedFrame {
104
+ type: 'resumed';
105
+ }
106
+ export type ServerFrame = WelcomeFrame | CityEvent | ActionResultFrame | ErrorFrame | PausedFrame | ResumedFrame;
107
+ export type ClientFrame = HelloFrame | ResumeFrame | AckFrame | AgentReply;
108
+ export interface OpenClawCityAccountConfig {
109
+ gatewayUrl?: string;
110
+ apiKey: string;
111
+ botId: string;
112
+ reconnectBaseMs?: number;
113
+ reconnectMaxMs?: number;
114
+ pingIntervalMs?: number;
115
+ enabled?: boolean;
116
+ }
117
+ export interface MessageEnvelope {
118
+ id: string;
119
+ timestamp: number;
120
+ channelId: string;
121
+ sender: {
122
+ id: string;
123
+ name: string;
124
+ avatar?: string;
125
+ };
126
+ content: {
127
+ text: string;
128
+ };
129
+ metadata: Record<string, unknown>;
130
+ }
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@openclawcity/openclawcity",
3
+ "version": "1.0.0",
4
+ "description": "OpenClawCity channel plugin for OpenClaw — live city events for AI agents",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist/",
10
+ "package.json"
11
+ ],
12
+ "scripts": {
13
+ "build": "rm -rf dist .tsc-out && tsc && node esbuild.config.mjs",
14
+ "prepublishOnly": "npm run build",
15
+ "test": "vitest run",
16
+ "dev": "tsc --watch"
17
+ },
18
+ "openclaw": {
19
+ "extensions": [
20
+ "./dist/index.js"
21
+ ],
22
+ "channel": {
23
+ "id": "openclawcity",
24
+ "label": "OpenClawCity",
25
+ "selectionLabel": "OpenClawCity (Live City)",
26
+ "docsPath": "/channels/openclawcity",
27
+ "docsLabel": "openclawcity",
28
+ "blurb": "Live connection to OpenClawCity — AI agent city with real-time events.",
29
+ "order": 50,
30
+ "aliases": [
31
+ "occ",
32
+ "openclawcity"
33
+ ]
34
+ },
35
+ "install": {
36
+ "npmSpec": "@openclawcity/openclawcity",
37
+ "localPath": ".",
38
+ "defaultChoice": "npm"
39
+ }
40
+ },
41
+ "peerDependencies": {
42
+ "openclaw": ">=1.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^20.0.0",
46
+ "@types/ws": "^8.5.0",
47
+ "esbuild": "^0.27.3",
48
+ "typescript": "^5.0.0",
49
+ "vitest": "^3.0.0",
50
+ "ws": "^8.13.0",
51
+ "zod": "^4.3.0"
52
+ },
53
+ "keywords": [
54
+ "openclaw",
55
+ "channel",
56
+ "openclawcity",
57
+ "ai-agent"
58
+ ],
59
+ "license": "MIT",
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "https://github.com/openclawcity/openclaw-channel"
63
+ }
64
+ }