@agentvault/agentvault 0.15.2 → 0.16.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.
- package/dist/channel.d.ts +10 -1
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +401 -36
- package/dist/cli.js.map +4 -4
- package/dist/gateway-send.d.ts +34 -0
- package/dist/gateway-send.d.ts.map +1 -1
- package/dist/http-handlers.d.ts +10 -0
- package/dist/http-handlers.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +428 -35
- package/dist/index.js.map +4 -4
- package/dist/openclaw-entry.d.ts.map +1 -1
- package/dist/openclaw-entry.js +153 -82
- package/dist/openclaw-entry.js.map +4 -4
- package/dist/types.d.ts +80 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/channel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import { TelemetryReporter } from "@agentvault/crypto";
|
|
3
|
-
import type { SecureChannelConfig, ChannelState, SendOptions, DecisionRequest, DecisionResponse, HeartbeatStatus, StatusAlert, RoomMemberInfo, RoomConversationInfo, RoomInfo, A2AChannel } from "./types.js";
|
|
3
|
+
import type { SecureChannelConfig, ChannelState, SendOptions, DecisionRequest, DecisionResponse, HeartbeatStatus, StatusAlert, RoomMemberInfo, RoomConversationInfo, RoomInfo, A2AChannel, DeliveryTarget, DeliveryContent, DeliveryOptions, DeliveryReceipt, TargetInfo } from "./types.js";
|
|
4
4
|
export declare class SecureChannel extends EventEmitter {
|
|
5
5
|
private config;
|
|
6
6
|
private _state;
|
|
@@ -166,6 +166,15 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
166
166
|
detail?: string;
|
|
167
167
|
estimated_cost?: number;
|
|
168
168
|
}): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Canonical message dispatcher. ALL outbound messages should flow through this method.
|
|
171
|
+
* Routes based on explicit target — never silently falls back to a room.
|
|
172
|
+
*/
|
|
173
|
+
deliver(target: DeliveryTarget, content: DeliveryContent, options?: DeliveryOptions): Promise<DeliveryReceipt>;
|
|
174
|
+
/**
|
|
175
|
+
* Returns all available delivery destinations with availability status.
|
|
176
|
+
*/
|
|
177
|
+
listTargets(): TargetInfo[];
|
|
169
178
|
private _sendHeartbeat;
|
|
170
179
|
stop(): Promise<void>;
|
|
171
180
|
startHttpServer(port: number): void;
|
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQ3C,OAAO,EAWL,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAMZ,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,QAAQ,EAER,UAAU,
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQ3C,OAAO,EAWL,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAMZ,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,QAAQ,EAER,UAAU,EAEV,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,UAAU,EACX,MAAM,YAAY,CAAC;AA6DpB,qBAAa,aAAc,SAAQ,YAAY;IAkEjC,OAAO,CAAC,MAAM;IAjE1B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,C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GG;IACH;;;OAGG;YACW,mBAAmB;IAsKjC,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,UAAU;YAMJ,mBAAmB;IAmCjC,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,gBAAgB;YAOV,qBAAqB;IAuCnC,OAAO,CAAC,kBAAkB;IA4C1B,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,kBAAkB;IA2H1B,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,YAAY;IAKpB;;;OAGG;YACW,aAAa;IAyB3B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;CAqB9B"}
|
package/dist/cli.js
CHANGED
|
@@ -45349,6 +45349,50 @@ var init_scan_engine = __esm({
|
|
|
45349
45349
|
* Runs api_keys, pii_*, prompt_injection, and shell_injection checks
|
|
45350
45350
|
* regardless of rule direction.
|
|
45351
45351
|
*/
|
|
45352
|
+
/**
|
|
45353
|
+
* Scan a SKILL.md file for policy violations.
|
|
45354
|
+
* Like scanWorkspaceFile but skips prompt_injection on instruction body
|
|
45355
|
+
* (skills legitimately describe AI behaviors that look like injection).
|
|
45356
|
+
* Checks: api_keys (block), shell_injection (block), pii (flag).
|
|
45357
|
+
*/
|
|
45358
|
+
static scanSkillMd(content) {
|
|
45359
|
+
const violations = [];
|
|
45360
|
+
let blocked = false;
|
|
45361
|
+
let flagged = false;
|
|
45362
|
+
const checks = [
|
|
45363
|
+
{ id: "api_keys", action: "block" },
|
|
45364
|
+
{ id: "shell_injection", action: "block" },
|
|
45365
|
+
{ id: "pii_ssn", action: "flag" },
|
|
45366
|
+
{ id: "pii_credit_card", action: "flag" },
|
|
45367
|
+
{ id: "pii_email", action: "flag" }
|
|
45368
|
+
// Intentionally omits prompt_injection — SKILL.md instruction body
|
|
45369
|
+
// legitimately contains phrases like "you are now a..."
|
|
45370
|
+
];
|
|
45371
|
+
for (const check2 of checks) {
|
|
45372
|
+
const patterns = BUILTIN_PATTERNS[check2.id];
|
|
45373
|
+
if (!patterns)
|
|
45374
|
+
continue;
|
|
45375
|
+
for (const p2 of patterns) {
|
|
45376
|
+
const regex = new RegExp(p2.source, p2.flags);
|
|
45377
|
+
if (regex.test(content)) {
|
|
45378
|
+
violations.push({
|
|
45379
|
+
rule_id: `skill_${check2.id}`,
|
|
45380
|
+
rule_name: check2.id,
|
|
45381
|
+
action: check2.action,
|
|
45382
|
+
scanner_type: "builtin",
|
|
45383
|
+
match_summary: `builtin:${check2.id}`
|
|
45384
|
+
});
|
|
45385
|
+
if (check2.action === "block")
|
|
45386
|
+
blocked = true;
|
|
45387
|
+
if (check2.action === "flag")
|
|
45388
|
+
flagged = true;
|
|
45389
|
+
break;
|
|
45390
|
+
}
|
|
45391
|
+
}
|
|
45392
|
+
}
|
|
45393
|
+
const status = blocked ? "blocked" : flagged ? "flagged" : "clean";
|
|
45394
|
+
return { status, violations };
|
|
45395
|
+
}
|
|
45352
45396
|
static scanWorkspaceFile(content) {
|
|
45353
45397
|
const violations = [];
|
|
45354
45398
|
let blocked = false;
|
|
@@ -46419,7 +46463,8 @@ __export(http_handlers_exports, {
|
|
|
46419
46463
|
handleActionRequest: () => handleActionRequest,
|
|
46420
46464
|
handleDecisionRequest: () => handleDecisionRequest,
|
|
46421
46465
|
handleSendRequest: () => handleSendRequest,
|
|
46422
|
-
handleStatusRequest: () => handleStatusRequest
|
|
46466
|
+
handleStatusRequest: () => handleStatusRequest,
|
|
46467
|
+
handleTargetsRequest: () => handleTargetsRequest
|
|
46423
46468
|
});
|
|
46424
46469
|
async function handleSendRequest(parsed, channel2) {
|
|
46425
46470
|
const text = parsed.text;
|
|
@@ -46427,32 +46472,55 @@ async function handleSendRequest(parsed, channel2) {
|
|
|
46427
46472
|
return { status: 400, body: { ok: false, error: "Missing 'text' field" } };
|
|
46428
46473
|
}
|
|
46429
46474
|
try {
|
|
46475
|
+
let target;
|
|
46430
46476
|
let a2aTarget = parsed.hub_address ?? parsed.a2a_address ?? parsed.a2aAddress;
|
|
46431
46477
|
if (!a2aTarget && parsed.channel_id && typeof parsed.channel_id === "string") {
|
|
46432
46478
|
const hubAddr = channel2.resolveA2AChannelHub(parsed.channel_id);
|
|
46433
46479
|
if (hubAddr) a2aTarget = hubAddr;
|
|
46434
46480
|
}
|
|
46435
|
-
const roomId = (typeof parsed.room_id === "string" ? parsed.room_id : void 0) ?? channel2.lastInboundRoomId;
|
|
46436
46481
|
if (a2aTarget && typeof a2aTarget === "string") {
|
|
46437
|
-
|
|
46438
|
-
} else if (
|
|
46439
|
-
|
|
46440
|
-
|
|
46441
|
-
|
|
46442
|
-
metadata: parsed.metadata
|
|
46443
|
-
});
|
|
46482
|
+
target = { kind: "a2a", hubAddress: a2aTarget };
|
|
46483
|
+
} else if (typeof parsed.room_id === "string") {
|
|
46484
|
+
target = { kind: "room", roomId: parsed.room_id };
|
|
46485
|
+
} else if (parsed.target === "context") {
|
|
46486
|
+
target = { kind: "context" };
|
|
46444
46487
|
} else if (parsed.file_path && typeof parsed.file_path === "string") {
|
|
46445
|
-
await channel2.
|
|
46446
|
-
|
|
46447
|
-
|
|
46488
|
+
const receipt2 = await channel2.deliver(
|
|
46489
|
+
{ kind: "owner" },
|
|
46490
|
+
{ type: "attachment", text, filePath: parsed.file_path },
|
|
46491
|
+
{ topicId: parsed.topicId }
|
|
46492
|
+
);
|
|
46493
|
+
return {
|
|
46494
|
+
status: receipt2.ok ? 200 : 500,
|
|
46495
|
+
body: {
|
|
46496
|
+
ok: receipt2.ok,
|
|
46497
|
+
destination: receipt2.destination,
|
|
46498
|
+
...receipt2.error ? { error: receipt2.error } : {}
|
|
46499
|
+
}
|
|
46500
|
+
};
|
|
46448
46501
|
} else {
|
|
46449
|
-
|
|
46450
|
-
topicId: parsed.topicId,
|
|
46451
|
-
messageType: parsed.message_type,
|
|
46452
|
-
metadata: parsed.metadata
|
|
46453
|
-
});
|
|
46502
|
+
target = { kind: "owner" };
|
|
46454
46503
|
}
|
|
46455
|
-
|
|
46504
|
+
const receipt = await channel2.deliver(
|
|
46505
|
+
target,
|
|
46506
|
+
{ type: "text", text },
|
|
46507
|
+
{
|
|
46508
|
+
topicId: parsed.topicId,
|
|
46509
|
+
priority: parsed.priority,
|
|
46510
|
+
metadata: {
|
|
46511
|
+
...parsed.metadata,
|
|
46512
|
+
...parsed.message_type ? { message_type: parsed.message_type } : {}
|
|
46513
|
+
}
|
|
46514
|
+
}
|
|
46515
|
+
);
|
|
46516
|
+
return {
|
|
46517
|
+
status: receipt.ok ? 200 : 500,
|
|
46518
|
+
body: {
|
|
46519
|
+
ok: receipt.ok,
|
|
46520
|
+
destination: receipt.destination,
|
|
46521
|
+
...receipt.error ? { error: receipt.error } : {}
|
|
46522
|
+
}
|
|
46523
|
+
};
|
|
46456
46524
|
} catch (err) {
|
|
46457
46525
|
return { status: 500, body: { ok: false, error: String(err) } };
|
|
46458
46526
|
}
|
|
@@ -46469,12 +46537,19 @@ async function handleActionRequest(parsed, channel2) {
|
|
|
46469
46537
|
detail: parsed.detail,
|
|
46470
46538
|
estimated_cost: parsed.estimated_cost
|
|
46471
46539
|
};
|
|
46472
|
-
|
|
46473
|
-
|
|
46474
|
-
|
|
46475
|
-
|
|
46476
|
-
|
|
46477
|
-
return {
|
|
46540
|
+
const target = parsed.room_id && typeof parsed.room_id === "string" ? { kind: "room", roomId: parsed.room_id } : { kind: "owner" };
|
|
46541
|
+
const receipt = await channel2.deliver(
|
|
46542
|
+
target,
|
|
46543
|
+
{ type: "action_confirmation", confirmation }
|
|
46544
|
+
);
|
|
46545
|
+
return {
|
|
46546
|
+
status: receipt.ok ? 200 : 500,
|
|
46547
|
+
body: {
|
|
46548
|
+
ok: receipt.ok,
|
|
46549
|
+
destination: receipt.destination,
|
|
46550
|
+
...receipt.error ? { error: receipt.error } : {}
|
|
46551
|
+
}
|
|
46552
|
+
};
|
|
46478
46553
|
} catch (err) {
|
|
46479
46554
|
return { status: 500, body: { ok: false, error: String(err) } };
|
|
46480
46555
|
}
|
|
@@ -46518,6 +46593,16 @@ function handleStatusRequest(channel2) {
|
|
|
46518
46593
|
}
|
|
46519
46594
|
};
|
|
46520
46595
|
}
|
|
46596
|
+
function handleTargetsRequest(channel2) {
|
|
46597
|
+
return {
|
|
46598
|
+
status: 200,
|
|
46599
|
+
body: {
|
|
46600
|
+
ok: true,
|
|
46601
|
+
targets: channel2.listTargets(),
|
|
46602
|
+
context: channel2.lastInboundRoomId ? { kind: "room", roomId: channel2.lastInboundRoomId } : { kind: "owner" }
|
|
46603
|
+
}
|
|
46604
|
+
};
|
|
46605
|
+
}
|
|
46521
46606
|
var init_http_handlers = __esm({
|
|
46522
46607
|
"src/http-handlers.ts"() {
|
|
46523
46608
|
"use strict";
|
|
@@ -46694,7 +46779,7 @@ function migratePersistedState(raw) {
|
|
|
46694
46779
|
messageHistory: []
|
|
46695
46780
|
};
|
|
46696
46781
|
}
|
|
46697
|
-
var POLL_INTERVAL_MS, RECONNECT_BASE_MS, RECONNECT_MAX_MS, PENDING_POLL_INTERVAL_MS, SecureChannel;
|
|
46782
|
+
var ROOM_AGENT_TYPES, POLL_INTERVAL_MS, RECONNECT_BASE_MS, RECONNECT_MAX_MS, PENDING_POLL_INTERVAL_MS, SecureChannel;
|
|
46698
46783
|
var init_channel = __esm({
|
|
46699
46784
|
async "src/channel.ts"() {
|
|
46700
46785
|
"use strict";
|
|
@@ -46703,6 +46788,13 @@ var init_channel = __esm({
|
|
|
46703
46788
|
await init_crypto_helpers();
|
|
46704
46789
|
await init_state();
|
|
46705
46790
|
init_transport2();
|
|
46791
|
+
ROOM_AGENT_TYPES = /* @__PURE__ */ new Set([
|
|
46792
|
+
"message",
|
|
46793
|
+
"text",
|
|
46794
|
+
"decision_request",
|
|
46795
|
+
"decision_response",
|
|
46796
|
+
"artifact_share"
|
|
46797
|
+
]);
|
|
46706
46798
|
POLL_INTERVAL_MS = 6e3;
|
|
46707
46799
|
RECONNECT_BASE_MS = 1e3;
|
|
46708
46800
|
RECONNECT_MAX_MS = 3e4;
|
|
@@ -47490,6 +47582,171 @@ var init_channel = __esm({
|
|
|
47490
47582
|
metadata
|
|
47491
47583
|
});
|
|
47492
47584
|
}
|
|
47585
|
+
// --- Unified Delivery Protocol ---
|
|
47586
|
+
/**
|
|
47587
|
+
* Canonical message dispatcher. ALL outbound messages should flow through this method.
|
|
47588
|
+
* Routes based on explicit target — never silently falls back to a room.
|
|
47589
|
+
*/
|
|
47590
|
+
async deliver(target, content, options) {
|
|
47591
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
47592
|
+
if (this._state === "idle" || this._state === "error") {
|
|
47593
|
+
return {
|
|
47594
|
+
ok: false,
|
|
47595
|
+
destination: { kind: "owner" },
|
|
47596
|
+
error: `Channel is in ${this._state} state`,
|
|
47597
|
+
timestamp: ts
|
|
47598
|
+
};
|
|
47599
|
+
}
|
|
47600
|
+
let resolved;
|
|
47601
|
+
if (target.kind === "context") {
|
|
47602
|
+
if (this._lastInboundRoomId) {
|
|
47603
|
+
resolved = { kind: "room", id: this._lastInboundRoomId };
|
|
47604
|
+
console.log(`[deliver] target=context\u2192room:${this._lastInboundRoomId.slice(0, 8)}...`);
|
|
47605
|
+
} else {
|
|
47606
|
+
resolved = { kind: "owner" };
|
|
47607
|
+
console.log(`[deliver] target=context\u2192owner`);
|
|
47608
|
+
}
|
|
47609
|
+
} else if (target.kind === "owner") {
|
|
47610
|
+
resolved = { kind: "owner" };
|
|
47611
|
+
} else if (target.kind === "room") {
|
|
47612
|
+
if (!this._persisted?.rooms?.[target.roomId]) {
|
|
47613
|
+
const err = `Room ${target.roomId} not found`;
|
|
47614
|
+
console.log(`[deliver] target=room:${target.roomId.slice(0, 8)}... content=${content.type} result=FAIL: ${err}`);
|
|
47615
|
+
return { ok: false, destination: { kind: "room", id: target.roomId }, error: err, timestamp: ts };
|
|
47616
|
+
}
|
|
47617
|
+
resolved = { kind: "room", id: target.roomId };
|
|
47618
|
+
} else if (target.kind === "a2a") {
|
|
47619
|
+
const channelEntry = this._persisted?.a2aChannels ? Object.values(this._persisted.a2aChannels).find((ch) => ch.hubAddress === target.hubAddress) : void 0;
|
|
47620
|
+
if (!channelEntry) {
|
|
47621
|
+
const err = `No A2A channel found for hub address: ${target.hubAddress}`;
|
|
47622
|
+
console.log(`[deliver] target=a2a:${target.hubAddress} content=${content.type} result=FAIL: ${err}`);
|
|
47623
|
+
return { ok: false, destination: { kind: "a2a", id: target.hubAddress }, error: err, timestamp: ts };
|
|
47624
|
+
}
|
|
47625
|
+
resolved = { kind: "a2a", id: target.hubAddress };
|
|
47626
|
+
} else {
|
|
47627
|
+
return { ok: false, destination: { kind: "owner" }, error: "Unknown target kind", timestamp: ts };
|
|
47628
|
+
}
|
|
47629
|
+
try {
|
|
47630
|
+
let decisionId;
|
|
47631
|
+
if (content.type === "text") {
|
|
47632
|
+
if (resolved.kind === "room") {
|
|
47633
|
+
await this.sendToRoom(resolved.id, content.text, {
|
|
47634
|
+
messageType: options?.metadata?.message_type,
|
|
47635
|
+
priority: options?.priority,
|
|
47636
|
+
metadata: options?.metadata
|
|
47637
|
+
});
|
|
47638
|
+
} else if (resolved.kind === "a2a") {
|
|
47639
|
+
await this.sendToAgent(resolved.id, content.text, {
|
|
47640
|
+
parentSpanId: options?.parentSpanId
|
|
47641
|
+
});
|
|
47642
|
+
} else {
|
|
47643
|
+
await this.send(content.text, {
|
|
47644
|
+
conversationId: options?.conversationId,
|
|
47645
|
+
topicId: options?.topicId,
|
|
47646
|
+
messageType: options?.metadata?.message_type,
|
|
47647
|
+
priority: options?.priority,
|
|
47648
|
+
metadata: options?.metadata
|
|
47649
|
+
});
|
|
47650
|
+
}
|
|
47651
|
+
} else if (content.type === "decision_request") {
|
|
47652
|
+
if (resolved.kind !== "owner") {
|
|
47653
|
+
const err = "Decision requests can only be sent to owner";
|
|
47654
|
+
console.log(`[deliver] target=${resolved.kind}:${resolved.id} content=decision_request result=FAIL: ${err}`);
|
|
47655
|
+
return { ok: false, destination: resolved, error: err, timestamp: ts };
|
|
47656
|
+
}
|
|
47657
|
+
decisionId = await this.sendDecisionRequest(content.request);
|
|
47658
|
+
} else if (content.type === "status_alert") {
|
|
47659
|
+
if (resolved.kind === "room") {
|
|
47660
|
+
const envelope = {
|
|
47661
|
+
title: content.alert.title,
|
|
47662
|
+
message: content.alert.message,
|
|
47663
|
+
severity: content.alert.severity,
|
|
47664
|
+
timestamp: ts
|
|
47665
|
+
};
|
|
47666
|
+
if (content.alert.detail !== void 0) envelope.detail = content.alert.detail;
|
|
47667
|
+
if (content.alert.detailFormat !== void 0) envelope.detail_format = content.alert.detailFormat;
|
|
47668
|
+
if (content.alert.category !== void 0) envelope.category = content.alert.category;
|
|
47669
|
+
await this.sendToRoom(resolved.id, JSON.stringify(envelope), {
|
|
47670
|
+
messageType: "status_alert",
|
|
47671
|
+
priority: content.alert.severity === "error" || content.alert.severity === "critical" ? "high" : "normal",
|
|
47672
|
+
metadata: { severity: content.alert.severity }
|
|
47673
|
+
});
|
|
47674
|
+
} else if (resolved.kind === "owner") {
|
|
47675
|
+
await this.sendStatusAlert(content.alert);
|
|
47676
|
+
} else {
|
|
47677
|
+
return { ok: false, destination: resolved, error: "Status alerts cannot be sent to A2A targets", timestamp: ts };
|
|
47678
|
+
}
|
|
47679
|
+
} else if (content.type === "action_confirmation") {
|
|
47680
|
+
if (resolved.kind === "room") {
|
|
47681
|
+
await this.sendActionConfirmationToRoom(resolved.id, content.confirmation);
|
|
47682
|
+
} else if (resolved.kind === "owner") {
|
|
47683
|
+
await this.sendActionConfirmation(content.confirmation);
|
|
47684
|
+
} else {
|
|
47685
|
+
return { ok: false, destination: resolved, error: "Action confirmations cannot be sent to A2A targets", timestamp: ts };
|
|
47686
|
+
}
|
|
47687
|
+
} else if (content.type === "artifact") {
|
|
47688
|
+
if (resolved.kind !== "owner") {
|
|
47689
|
+
return { ok: false, destination: resolved, error: "Artifacts can only be sent to owner", timestamp: ts };
|
|
47690
|
+
}
|
|
47691
|
+
await this.sendArtifact(content.artifact);
|
|
47692
|
+
} else if (content.type === "attachment") {
|
|
47693
|
+
if (resolved.kind !== "owner") {
|
|
47694
|
+
return { ok: false, destination: resolved, error: "Attachments can only be sent to owner", timestamp: ts };
|
|
47695
|
+
}
|
|
47696
|
+
await this.sendWithAttachment(content.text, content.filePath, {
|
|
47697
|
+
topicId: options?.topicId
|
|
47698
|
+
});
|
|
47699
|
+
}
|
|
47700
|
+
const targetLabel = resolved.kind === "owner" ? "owner" : `${resolved.kind}:${resolved.id?.slice(0, 8)}...`;
|
|
47701
|
+
console.log(`[deliver] target=${targetLabel} content=${content.type} result=ok`);
|
|
47702
|
+
return {
|
|
47703
|
+
ok: true,
|
|
47704
|
+
destination: resolved,
|
|
47705
|
+
queued: this._state !== "ready",
|
|
47706
|
+
decisionId,
|
|
47707
|
+
timestamp: ts
|
|
47708
|
+
};
|
|
47709
|
+
} catch (err) {
|
|
47710
|
+
const targetLabel = resolved.kind === "owner" ? "owner" : `${resolved.kind}:${resolved.id?.slice(0, 8)}...`;
|
|
47711
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
47712
|
+
console.log(`[deliver] target=${targetLabel} content=${content.type} result=FAIL: ${errMsg}`);
|
|
47713
|
+
return { ok: false, destination: resolved, error: errMsg, timestamp: ts };
|
|
47714
|
+
}
|
|
47715
|
+
}
|
|
47716
|
+
/**
|
|
47717
|
+
* Returns all available delivery destinations with availability status.
|
|
47718
|
+
*/
|
|
47719
|
+
listTargets() {
|
|
47720
|
+
const targets = [
|
|
47721
|
+
{
|
|
47722
|
+
kind: "owner",
|
|
47723
|
+
id: "owner",
|
|
47724
|
+
label: "Owner (direct)",
|
|
47725
|
+
available: this._state === "ready" && this._sessions.size > 0
|
|
47726
|
+
}
|
|
47727
|
+
];
|
|
47728
|
+
if (this._persisted?.rooms) {
|
|
47729
|
+
for (const room of Object.values(this._persisted.rooms)) {
|
|
47730
|
+
targets.push({
|
|
47731
|
+
kind: "room",
|
|
47732
|
+
id: room.roomId,
|
|
47733
|
+
label: room.name || `Room ${room.roomId.slice(0, 8)}`,
|
|
47734
|
+
available: this._state === "ready" && room.conversationIds.length > 0
|
|
47735
|
+
});
|
|
47736
|
+
}
|
|
47737
|
+
}
|
|
47738
|
+
if (this._persisted?.a2aChannels) {
|
|
47739
|
+
for (const ch of Object.values(this._persisted.a2aChannels)) {
|
|
47740
|
+
targets.push({
|
|
47741
|
+
kind: "a2a",
|
|
47742
|
+
id: ch.hubAddress,
|
|
47743
|
+
label: `A2A: ${ch.hubAddress}`,
|
|
47744
|
+
available: this._state === "ready" && !!ch.session?.ratchetState
|
|
47745
|
+
});
|
|
47746
|
+
}
|
|
47747
|
+
}
|
|
47748
|
+
return targets;
|
|
47749
|
+
}
|
|
47493
47750
|
_sendHeartbeat() {
|
|
47494
47751
|
if (this._state !== "ready" || !this._heartbeatCallback) return;
|
|
47495
47752
|
const status = this._heartbeatCallback();
|
|
@@ -47608,9 +47865,13 @@ var init_channel = __esm({
|
|
|
47608
47865
|
const result = handlers.handleStatusRequest(this);
|
|
47609
47866
|
res.writeHead(result.status, { "Content-Type": "application/json" });
|
|
47610
47867
|
res.end(JSON.stringify(result.body));
|
|
47868
|
+
} else if (req.method === "GET" && req.url === "/targets") {
|
|
47869
|
+
const result = handlers.handleTargetsRequest(this);
|
|
47870
|
+
res.writeHead(result.status, { "Content-Type": "application/json" });
|
|
47871
|
+
res.end(JSON.stringify(result.body));
|
|
47611
47872
|
} else {
|
|
47612
47873
|
res.writeHead(404, { "Content-Type": "application/json" });
|
|
47613
|
-
res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send, POST /decision, POST /action, or GET /
|
|
47874
|
+
res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send, POST /decision, POST /action, GET /status, or GET /targets" }));
|
|
47614
47875
|
}
|
|
47615
47876
|
});
|
|
47616
47877
|
this._httpServer.listen(port, "127.0.0.1", () => {
|
|
@@ -49246,6 +49507,9 @@ ${messageText}`;
|
|
|
49246
49507
|
messageType = "message";
|
|
49247
49508
|
messageText = plaintext;
|
|
49248
49509
|
}
|
|
49510
|
+
if (!ROOM_AGENT_TYPES.has(messageType)) {
|
|
49511
|
+
return;
|
|
49512
|
+
}
|
|
49249
49513
|
if (!session.activated) {
|
|
49250
49514
|
session.activated = true;
|
|
49251
49515
|
console.log(
|
|
@@ -49264,7 +49528,9 @@ ${messageText}`;
|
|
|
49264
49528
|
conversationId: convId,
|
|
49265
49529
|
timestamp: msgData.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
49266
49530
|
messageType,
|
|
49267
|
-
roomId: msgData.room_id
|
|
49531
|
+
roomId: msgData.room_id,
|
|
49532
|
+
senderDeviceId: msgData.sender_device_id,
|
|
49533
|
+
roomName: this._persisted?.rooms?.[msgData.room_id]?.name
|
|
49268
49534
|
};
|
|
49269
49535
|
this.emit("room_message", {
|
|
49270
49536
|
roomId: msgData.room_id,
|
|
@@ -49439,6 +49705,9 @@ ${messageText}`;
|
|
|
49439
49705
|
messageType = "message";
|
|
49440
49706
|
messageText = plaintext;
|
|
49441
49707
|
}
|
|
49708
|
+
if (!ROOM_AGENT_TYPES.has(messageType)) {
|
|
49709
|
+
return;
|
|
49710
|
+
}
|
|
49442
49711
|
if (msgData.message_id) {
|
|
49443
49712
|
this._sendAck(msgData.message_id);
|
|
49444
49713
|
}
|
|
@@ -49451,7 +49720,9 @@ ${messageText}`;
|
|
|
49451
49720
|
conversationId: "",
|
|
49452
49721
|
timestamp: msgData.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
49453
49722
|
messageType,
|
|
49454
|
-
roomId: msgData.room_id
|
|
49723
|
+
roomId: msgData.room_id,
|
|
49724
|
+
senderDeviceId: msgData.sender_device_id,
|
|
49725
|
+
roomName: this._persisted?.rooms?.[msgData.room_id]?.name
|
|
49455
49726
|
};
|
|
49456
49727
|
this.emit("room_message", {
|
|
49457
49728
|
roomId: msgData.room_id,
|
|
@@ -49940,6 +50211,13 @@ var init_cp = __esm({
|
|
|
49940
50211
|
}
|
|
49941
50212
|
});
|
|
49942
50213
|
|
|
50214
|
+
// src/types.ts
|
|
50215
|
+
var init_types = __esm({
|
|
50216
|
+
"src/types.ts"() {
|
|
50217
|
+
"use strict";
|
|
50218
|
+
}
|
|
50219
|
+
});
|
|
50220
|
+
|
|
49943
50221
|
// src/account-config.ts
|
|
49944
50222
|
var init_account_config = __esm({
|
|
49945
50223
|
"src/account-config.ts"() {
|
|
@@ -49961,8 +50239,11 @@ var init_openclaw_plugin = __esm({
|
|
|
49961
50239
|
var gateway_send_exports = {};
|
|
49962
50240
|
__export(gateway_send_exports, {
|
|
49963
50241
|
checkGateway: () => checkGateway,
|
|
50242
|
+
listTargets: () => listTargets,
|
|
49964
50243
|
sendDecisionToOwner: () => sendDecisionToOwner,
|
|
49965
|
-
sendToOwner: () => sendToOwner
|
|
50244
|
+
sendToOwner: () => sendToOwner,
|
|
50245
|
+
sendToRoom: () => sendToRoom,
|
|
50246
|
+
sendToTarget: () => sendToTarget
|
|
49966
50247
|
});
|
|
49967
50248
|
function resolveBaseUrl(options) {
|
|
49968
50249
|
const host = options?.host ?? "127.0.0.1";
|
|
@@ -50030,6 +50311,88 @@ async function sendDecisionToOwner(request, options) {
|
|
|
50030
50311
|
return { ok: false, error: friendlyError(err) };
|
|
50031
50312
|
}
|
|
50032
50313
|
}
|
|
50314
|
+
async function sendToRoom(roomId, text, options) {
|
|
50315
|
+
if (typeof text !== "string" || text.trim().length === 0) {
|
|
50316
|
+
return { ok: false, error: "Message text must be a non-empty string" };
|
|
50317
|
+
}
|
|
50318
|
+
if (!roomId) {
|
|
50319
|
+
return { ok: false, error: "Room ID is required" };
|
|
50320
|
+
}
|
|
50321
|
+
requestHeartbeatNow({ reason: "proactive-room-send" }).catch(() => {
|
|
50322
|
+
});
|
|
50323
|
+
try {
|
|
50324
|
+
const base = resolveBaseUrl(options);
|
|
50325
|
+
const sendPath = process.env.OPENCLAW_GATEWAY_URL ? "/agentvault/send" : "/send";
|
|
50326
|
+
const res = await fetch(`${base}${sendPath}`, {
|
|
50327
|
+
method: "POST",
|
|
50328
|
+
headers: { "Content-Type": "application/json" },
|
|
50329
|
+
body: JSON.stringify({ text, room_id: roomId }),
|
|
50330
|
+
signal: options?.signal
|
|
50331
|
+
});
|
|
50332
|
+
if (!res.ok) {
|
|
50333
|
+
const body = await res.text().catch(() => "");
|
|
50334
|
+
return { ok: false, error: `HTTP ${res.status}${body ? `: ${body}` : ""}` };
|
|
50335
|
+
}
|
|
50336
|
+
const data = await res.json();
|
|
50337
|
+
return { ok: data.ok ?? true };
|
|
50338
|
+
} catch (err) {
|
|
50339
|
+
return { ok: false, error: friendlyError(err) };
|
|
50340
|
+
}
|
|
50341
|
+
}
|
|
50342
|
+
async function sendToTarget(target, text, options) {
|
|
50343
|
+
if (typeof text !== "string" || text.trim().length === 0) {
|
|
50344
|
+
return { ok: false, error: "Message text must be a non-empty string" };
|
|
50345
|
+
}
|
|
50346
|
+
requestHeartbeatNow({ reason: "proactive-target-send" }).catch(() => {
|
|
50347
|
+
});
|
|
50348
|
+
try {
|
|
50349
|
+
const base = resolveBaseUrl(options);
|
|
50350
|
+
const sendPath = process.env.OPENCLAW_GATEWAY_URL ? "/agentvault/send" : "/send";
|
|
50351
|
+
const body = { text };
|
|
50352
|
+
if (target.startsWith("room:")) {
|
|
50353
|
+
body.room_id = target.slice(5);
|
|
50354
|
+
} else if (target.startsWith("a2a:")) {
|
|
50355
|
+
body.hub_address = target.slice(4);
|
|
50356
|
+
} else if (target === "context") {
|
|
50357
|
+
body.target = "context";
|
|
50358
|
+
}
|
|
50359
|
+
const res = await fetch(`${base}${sendPath}`, {
|
|
50360
|
+
method: "POST",
|
|
50361
|
+
headers: { "Content-Type": "application/json" },
|
|
50362
|
+
body: JSON.stringify(body),
|
|
50363
|
+
signal: options?.signal
|
|
50364
|
+
});
|
|
50365
|
+
if (!res.ok) {
|
|
50366
|
+
const respBody = await res.text().catch(() => "");
|
|
50367
|
+
return { ok: false, error: `HTTP ${res.status}${respBody ? `: ${respBody}` : ""}` };
|
|
50368
|
+
}
|
|
50369
|
+
const data = await res.json();
|
|
50370
|
+
return {
|
|
50371
|
+
ok: data.ok ?? true,
|
|
50372
|
+
destination: data.destination
|
|
50373
|
+
};
|
|
50374
|
+
} catch (err) {
|
|
50375
|
+
return { ok: false, error: friendlyError(err) };
|
|
50376
|
+
}
|
|
50377
|
+
}
|
|
50378
|
+
async function listTargets(options) {
|
|
50379
|
+
try {
|
|
50380
|
+
const base = resolveBaseUrl(options);
|
|
50381
|
+
const targetsPath = process.env.OPENCLAW_GATEWAY_URL ? "/agentvault/targets" : "/targets";
|
|
50382
|
+
const res = await fetch(`${base}${targetsPath}`, { signal: options?.signal });
|
|
50383
|
+
if (!res.ok) {
|
|
50384
|
+
return { ok: false, error: `HTTP ${res.status}` };
|
|
50385
|
+
}
|
|
50386
|
+
const data = await res.json();
|
|
50387
|
+
return {
|
|
50388
|
+
ok: true,
|
|
50389
|
+
targets: data.targets,
|
|
50390
|
+
context: data.context
|
|
50391
|
+
};
|
|
50392
|
+
} catch (err) {
|
|
50393
|
+
return { ok: false, error: friendlyError(err) };
|
|
50394
|
+
}
|
|
50395
|
+
}
|
|
50033
50396
|
async function checkGateway(options) {
|
|
50034
50397
|
try {
|
|
50035
50398
|
const base = resolveBaseUrl(options);
|
|
@@ -50074,6 +50437,7 @@ var init_openclaw_entry = __esm({
|
|
|
50074
50437
|
init_fetch_interceptor();
|
|
50075
50438
|
init_http_handlers();
|
|
50076
50439
|
init_openclaw_compat();
|
|
50440
|
+
init_types();
|
|
50077
50441
|
}
|
|
50078
50442
|
});
|
|
50079
50443
|
|
|
@@ -50755,7 +51119,7 @@ function createZodEnum(values, params) {
|
|
|
50755
51119
|
});
|
|
50756
51120
|
}
|
|
50757
51121
|
var ParseInputLazyPath, handleResult, ZodType, cuidRegex, cuid2Regex, ulidRegex, uuidRegex, nanoidRegex, jwtRegex, durationRegex, emailRegex, _emojiRegex, emojiRegex, ipv4Regex, ipv4CidrRegex, ipv6Regex, ipv6CidrRegex, base64Regex, base64urlRegex, dateRegexSource, dateRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, ZodBranded, ZodPipeline, ZodReadonly, late, ZodFirstPartyTypeKind, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType;
|
|
50758
|
-
var
|
|
51122
|
+
var init_types2 = __esm({
|
|
50759
51123
|
"../../node_modules/zod/v3/types.js"() {
|
|
50760
51124
|
init_ZodError();
|
|
50761
51125
|
init_errors();
|
|
@@ -54007,7 +54371,7 @@ var init_external = __esm({
|
|
|
54007
54371
|
init_parseUtil();
|
|
54008
54372
|
init_typeAliases();
|
|
54009
54373
|
init_util();
|
|
54010
|
-
|
|
54374
|
+
init_types2();
|
|
54011
54375
|
init_ZodError();
|
|
54012
54376
|
}
|
|
54013
54377
|
});
|
|
@@ -61507,7 +61871,7 @@ var init_v4 = __esm({
|
|
|
61507
61871
|
|
|
61508
61872
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
61509
61873
|
var RELATED_TASK_META_KEY, JSONRPC_VERSION, AssertObjectSchema, ProgressTokenSchema, CursorSchema, TaskCreationParamsSchema, TaskMetadataSchema, RelatedTaskMetadataSchema, RequestMetaSchema, BaseRequestParamsSchema, TaskAugmentedRequestParamsSchema, RequestSchema, NotificationsParamsSchema, NotificationSchema, ResultSchema, RequestIdSchema, JSONRPCRequestSchema, JSONRPCNotificationSchema, JSONRPCResultResponseSchema, ErrorCode, JSONRPCErrorResponseSchema, JSONRPCMessageSchema, JSONRPCResponseSchema, EmptyResultSchema, CancelledNotificationParamsSchema, CancelledNotificationSchema, IconSchema, IconsSchema, BaseMetadataSchema, ImplementationSchema, FormElicitationCapabilitySchema, ElicitationCapabilitySchema, ClientTasksCapabilitySchema, ServerTasksCapabilitySchema, ClientCapabilitiesSchema, InitializeRequestParamsSchema, InitializeRequestSchema, ServerCapabilitiesSchema, InitializeResultSchema, InitializedNotificationSchema, PingRequestSchema, ProgressSchema, ProgressNotificationParamsSchema, ProgressNotificationSchema, PaginatedRequestParamsSchema, PaginatedRequestSchema, PaginatedResultSchema, TaskStatusSchema, TaskSchema, CreateTaskResultSchema, TaskStatusNotificationParamsSchema, TaskStatusNotificationSchema, GetTaskRequestSchema, GetTaskResultSchema, GetTaskPayloadRequestSchema, GetTaskPayloadResultSchema, ListTasksRequestSchema, ListTasksResultSchema, CancelTaskRequestSchema, CancelTaskResultSchema, ResourceContentsSchema, TextResourceContentsSchema, Base64Schema, BlobResourceContentsSchema, RoleSchema, AnnotationsSchema, ResourceSchema, ResourceTemplateSchema, ListResourcesRequestSchema, ListResourcesResultSchema, ListResourceTemplatesRequestSchema, ListResourceTemplatesResultSchema, ResourceRequestParamsSchema, ReadResourceRequestParamsSchema, ReadResourceRequestSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, SubscribeRequestParamsSchema, SubscribeRequestSchema, UnsubscribeRequestParamsSchema, UnsubscribeRequestSchema, ResourceUpdatedNotificationParamsSchema, ResourceUpdatedNotificationSchema, PromptArgumentSchema, PromptSchema, ListPromptsRequestSchema, ListPromptsResultSchema, GetPromptRequestParamsSchema, GetPromptRequestSchema, TextContentSchema, ImageContentSchema, AudioContentSchema, ToolUseContentSchema, EmbeddedResourceSchema, ResourceLinkSchema, ContentBlockSchema, PromptMessageSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ToolAnnotationsSchema, ToolExecutionSchema, ToolSchema, ListToolsRequestSchema, ListToolsResultSchema, CallToolResultSchema, CompatibilityCallToolResultSchema, CallToolRequestParamsSchema, CallToolRequestSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, LoggingLevelSchema, SetLevelRequestParamsSchema, SetLevelRequestSchema, LoggingMessageNotificationParamsSchema, LoggingMessageNotificationSchema, ModelHintSchema, ModelPreferencesSchema, ToolChoiceSchema, ToolResultContentSchema, SamplingContentSchema, SamplingMessageContentBlockSchema, SamplingMessageSchema, CreateMessageRequestParamsSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema, LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema, EnumSchemaSchema, PrimitiveSchemaDefinitionSchema, ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema, ElicitRequestParamsSchema, ElicitRequestSchema, ElicitationCompleteNotificationParamsSchema, ElicitationCompleteNotificationSchema, ElicitResultSchema, ResourceTemplateReferenceSchema, PromptReferenceSchema, CompleteRequestParamsSchema, CompleteRequestSchema, CompleteResultSchema, RootSchema, ListRootsRequestSchema, ListRootsResultSchema, RootsListChangedNotificationSchema, ClientRequestSchema, ClientNotificationSchema, ClientResultSchema, ServerRequestSchema, ServerNotificationSchema, ServerResultSchema;
|
|
61510
|
-
var
|
|
61874
|
+
var init_types3 = __esm({
|
|
61511
61875
|
"../../node_modules/@modelcontextprotocol/sdk/dist/esm/types.js"() {
|
|
61512
61876
|
init_v4();
|
|
61513
61877
|
RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
@@ -63349,7 +63713,7 @@ var init_zod_json_schema_compat = __esm({
|
|
|
63349
63713
|
var init_protocol = __esm({
|
|
63350
63714
|
"../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js"() {
|
|
63351
63715
|
init_zod_compat();
|
|
63352
|
-
|
|
63716
|
+
init_types3();
|
|
63353
63717
|
init_interfaces();
|
|
63354
63718
|
init_zod_json_schema_compat();
|
|
63355
63719
|
}
|
|
@@ -70148,7 +70512,7 @@ var init_helpers = __esm({
|
|
|
70148
70512
|
var init_server2 = __esm({
|
|
70149
70513
|
"../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js"() {
|
|
70150
70514
|
init_protocol();
|
|
70151
|
-
|
|
70515
|
+
init_types3();
|
|
70152
70516
|
init_ajv_provider();
|
|
70153
70517
|
init_zod_compat();
|
|
70154
70518
|
init_server();
|
|
@@ -70190,7 +70554,7 @@ var init_mcp = __esm({
|
|
|
70190
70554
|
init_server2();
|
|
70191
70555
|
init_zod_compat();
|
|
70192
70556
|
init_zod_json_schema_compat();
|
|
70193
|
-
|
|
70557
|
+
init_types3();
|
|
70194
70558
|
init_completable();
|
|
70195
70559
|
init_uriTemplate();
|
|
70196
70560
|
init_toolNameValidation();
|
|
@@ -70412,7 +70776,7 @@ var init_dist2 = __esm({
|
|
|
70412
70776
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
|
|
70413
70777
|
var init_webStandardStreamableHttp = __esm({
|
|
70414
70778
|
"../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js"() {
|
|
70415
|
-
|
|
70779
|
+
init_types3();
|
|
70416
70780
|
}
|
|
70417
70781
|
});
|
|
70418
70782
|
|
|
@@ -70572,6 +70936,7 @@ var init_index = __esm({
|
|
|
70572
70936
|
async "src/index.ts"() {
|
|
70573
70937
|
"use strict";
|
|
70574
70938
|
await init_channel();
|
|
70939
|
+
init_types();
|
|
70575
70940
|
init_account_config();
|
|
70576
70941
|
await init_openclaw_plugin();
|
|
70577
70942
|
init_gateway_send();
|