chitin-openclaw-plugin 0.2.2 → 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.
Files changed (2) hide show
  1. package/dist/index.js +49 -2
  2. package/package.json +6 -1
package/dist/index.js CHANGED
@@ -12,6 +12,12 @@ import { privateKeyToAccount } from "viem/accounts";
12
12
  import { baseSepolia } from "viem/chains";
13
13
  import WebSocket from "ws";
14
14
  import { execFile } from "child_process";
15
+ import { trace, SpanStatusCode } from "@opentelemetry/api";
16
+ import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
17
+ import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node";
18
+ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
19
+ import { Resource } from "@opentelemetry/resources";
20
+ import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
15
21
  var ERC20_ABI = parseAbi([
16
22
  "function balanceOf(address) view returns (uint256)",
17
23
  "function transferAndCall(address to, uint256 amount, bytes data) returns (bool)",
@@ -100,12 +106,18 @@ function connectToTable(gameServerUrl, roomCode, playerId, name, walletAddress,
100
106
  }
101
107
  function promptAgent(text, logger2) {
102
108
  logger2.info(`[chitin] Prompting agent: ${text.slice(0, 100)}...`);
103
- execFile("openclaw", ["agent", "--local", "--message", text], (err, _stdout, stderr) => {
109
+ const child = execFile("openclaw", ["agent", "--local", "--message", text], {
110
+ timeout: 12e4,
111
+ env: process.env
112
+ // Inherit HOME pointing to workspace
113
+ }, (err, stdout, stderr) => {
104
114
  if (err) {
105
115
  logger2.error(`[chitin] Agent prompt failed: ${err.message}`);
116
+ if (stderr) logger2.error(`[chitin] Agent stderr: ${stderr.slice(0, 500)}`);
106
117
  return;
107
118
  }
108
- if (stderr) logger2.warn(`[chitin] Agent stderr: ${stderr.slice(0, 200)}`);
119
+ if (stdout) logger2.info(`[chitin] Agent response: ${stdout.slice(0, 300)}`);
120
+ if (stderr) logger2.warn(`[chitin] Agent stderr: ${stderr.slice(0, 300)}`);
109
121
  logger2.info(`[chitin] Agent prompted ok`);
110
122
  });
111
123
  }
@@ -126,6 +138,41 @@ var plugin = {
126
138
  },
127
139
  register(api) {
128
140
  api.logger.info("[chitin] Chitin Casino plugin loaded");
141
+ let tracer = trace.getTracer("chitin-plugin");
142
+ try {
143
+ const endpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
144
+ const headers = process.env.OTEL_EXPORTER_OTLP_HEADERS;
145
+ if (endpoint) {
146
+ const headerObj = {};
147
+ if (headers) {
148
+ for (const pair of headers.split(",")) {
149
+ const [k, ...v] = pair.split("=");
150
+ if (k) headerObj[k.trim()] = v.join("=").trim();
151
+ }
152
+ }
153
+ const provider = new NodeTracerProvider({
154
+ resource: new Resource({ [ATTR_SERVICE_NAME]: "chitin-plugin" }),
155
+ spanProcessors: [
156
+ new BatchSpanProcessor(new OTLPTraceExporter({
157
+ url: `${endpoint}/v1/traces`,
158
+ headers: headerObj
159
+ }))
160
+ ]
161
+ });
162
+ provider.register();
163
+ tracer = trace.getTracer("chitin-plugin");
164
+ api.logger.info(`[chitin] OTel initialized \u2014 endpoint=${endpoint}`);
165
+ const span = tracer.startSpan("plugin.loaded");
166
+ span.setAttributes({ "plugin.name": "chitin-openclaw-plugin" });
167
+ span.setStatus({ code: SpanStatusCode.OK });
168
+ span.end();
169
+ api.logger.info("[chitin] OTel test span emitted: plugin.loaded");
170
+ } else {
171
+ api.logger.info("[chitin] OTel skipped \u2014 no OTEL_EXPORTER_OTLP_ENDPOINT");
172
+ }
173
+ } catch (err) {
174
+ api.logger.warn(`[chitin] OTel init failed (non-fatal): ${err.message}`);
175
+ }
129
176
  const gameServerUrl = process.env.GAME_SERVER_URL || "http://localhost:3665";
130
177
  const adminServerUrl = process.env.ADMIN_SERVER_URL || "http://localhost:3667";
131
178
  const activeConnections = /* @__PURE__ */ new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chitin-openclaw-plugin",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "OpenClaw plugin for Chitin Casino — wallet management and poker game connection",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,6 +30,11 @@
30
30
  "prepublishOnly": "npm run build"
31
31
  },
32
32
  "dependencies": {
33
+ "@opentelemetry/api": "^1.9.0",
34
+ "@opentelemetry/exporter-trace-otlp-http": "^0.57.0",
35
+ "@opentelemetry/resources": "^1.30.0",
36
+ "@opentelemetry/sdk-trace-node": "^1.30.0",
37
+ "@opentelemetry/semantic-conventions": "^1.28.0",
33
38
  "viem": "^2.0.0",
34
39
  "ws": "^8.0.0"
35
40
  },