@openclawcity/openclawcity 1.0.7 → 1.0.9
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/dist/index.js +37 -12
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3869,7 +3869,7 @@ var OpenClawCityAdapter = class {
|
|
|
3869
3869
|
const raw = data.toString();
|
|
3870
3870
|
if (raw === "pong")
|
|
3871
3871
|
return;
|
|
3872
|
-
this.logger.
|
|
3872
|
+
this.logger.info?.(`[OCC] Raw frame received (${raw.length} bytes): ${raw.slice(0, 300)}`);
|
|
3873
3873
|
const frame = this.parseFrame(data);
|
|
3874
3874
|
if (!frame)
|
|
3875
3875
|
return;
|
|
@@ -3951,6 +3951,7 @@ var OpenClawCityAdapter = class {
|
|
|
3951
3951
|
handleFrame(frame) {
|
|
3952
3952
|
switch (frame.type) {
|
|
3953
3953
|
case "city_event":
|
|
3954
|
+
this.logger.info?.(`[OCC] city_event frame: seq=${frame.seq} eventType=${frame.eventType} from=${frame.from?.name ?? "?"}`);
|
|
3954
3955
|
void this.handleCityEvent(frame);
|
|
3955
3956
|
break;
|
|
3956
3957
|
case "action_result":
|
|
@@ -3968,16 +3969,19 @@ var OpenClawCityAdapter = class {
|
|
|
3968
3969
|
this.logger.info?.("Bot resumed");
|
|
3969
3970
|
break;
|
|
3970
3971
|
default:
|
|
3971
|
-
this.logger.
|
|
3972
|
+
this.logger.info?.(`[OCC] Unknown frame type: ${frame.type}`);
|
|
3972
3973
|
}
|
|
3973
3974
|
}
|
|
3974
3975
|
async handleCityEvent(event) {
|
|
3976
|
+
this.logger.info?.(`[OCC] handleCityEvent ENTER: seq=${event.seq} eventType=${event.eventType}`);
|
|
3975
3977
|
try {
|
|
3976
3978
|
const envelope = normalize(event);
|
|
3979
|
+
this.logger.info?.(`[OCC] handleCityEvent normalized: id=${envelope.id} text=${envelope.content.text.slice(0, 80)}`);
|
|
3977
3980
|
await this.onMessage(envelope);
|
|
3981
|
+
this.logger.info?.(`[OCC] handleCityEvent onMessage OK: seq=${event.seq}`);
|
|
3978
3982
|
this.sendAck(event.seq);
|
|
3979
3983
|
} catch (err) {
|
|
3980
|
-
this.logger.error?.(
|
|
3984
|
+
this.logger.error?.(`[OCC] handleCityEvent FAILED: seq=${event.seq} error=${String(err)}`);
|
|
3981
3985
|
this.sendAck(event.seq);
|
|
3982
3986
|
}
|
|
3983
3987
|
}
|
|
@@ -3996,8 +4000,9 @@ var OpenClawCityAdapter = class {
|
|
|
3996
4000
|
}
|
|
3997
4001
|
}
|
|
3998
4002
|
sendAck(seq) {
|
|
3999
|
-
|
|
4000
|
-
this.
|
|
4003
|
+
const seqNum = Number(seq);
|
|
4004
|
+
this.lastAckSeq = seqNum;
|
|
4005
|
+
this.send({ type: "ack", seq: seqNum });
|
|
4001
4006
|
}
|
|
4002
4007
|
// ── Internal: Reconnection ──
|
|
4003
4008
|
scheduleReconnect() {
|
|
@@ -4211,13 +4216,33 @@ var occPlugin = {
|
|
|
4211
4216
|
log?.info?.(`[OCC] Deliver callback: text=${text ? text.slice(0, 80) + "..." : "(empty)"}`);
|
|
4212
4217
|
if (!text)
|
|
4213
4218
|
return;
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4219
|
+
const eventType = envelope.metadata.eventType;
|
|
4220
|
+
const conversationId = envelope.metadata.conversationId;
|
|
4221
|
+
let action;
|
|
4222
|
+
if (eventType === "owner_message") {
|
|
4223
|
+
action = "owner_reply";
|
|
4224
|
+
adapter.sendReply({
|
|
4225
|
+
type: "agent_reply",
|
|
4226
|
+
action: "owner_reply",
|
|
4227
|
+
message: text
|
|
4228
|
+
});
|
|
4229
|
+
} else if (eventType === "dm_message" && conversationId) {
|
|
4230
|
+
action = "dm_reply";
|
|
4231
|
+
adapter.sendReply({
|
|
4232
|
+
type: "agent_reply",
|
|
4233
|
+
action: "dm_reply",
|
|
4234
|
+
message: text,
|
|
4235
|
+
conversation_id: conversationId
|
|
4236
|
+
});
|
|
4237
|
+
} else {
|
|
4238
|
+
action = "speak";
|
|
4239
|
+
adapter.sendReply({
|
|
4240
|
+
type: "agent_reply",
|
|
4241
|
+
action: "speak",
|
|
4242
|
+
text
|
|
4243
|
+
});
|
|
4244
|
+
}
|
|
4245
|
+
log?.info?.(`[OCC] Reply sent via WebSocket (action=${action}, eventType=${eventType})`);
|
|
4221
4246
|
},
|
|
4222
4247
|
onError: (err, info) => {
|
|
4223
4248
|
log?.error?.(`[OCC] Step 5 onError (${info.kind}): ${String(err)}`);
|
package/dist/types.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export interface AckFrame {
|
|
|
70
70
|
type: 'ack';
|
|
71
71
|
seq: number;
|
|
72
72
|
}
|
|
73
|
-
export type AgentReplyAction = 'speak' | 'move' | 'dm_reply' | 'enter_building' | 'leave_building' | 'execute_action' | 'react_to_artifact' | 'propose';
|
|
73
|
+
export type AgentReplyAction = 'speak' | 'move' | 'dm_reply' | 'owner_reply' | 'enter_building' | 'leave_building' | 'execute_action' | 'react_to_artifact' | 'propose';
|
|
74
74
|
export interface AgentReply {
|
|
75
75
|
type: 'agent_reply';
|
|
76
76
|
action: AgentReplyAction;
|