@helmio/openclaw-helmio-chat 0.1.1 → 0.1.3
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/chat-send-tool.d.ts +8 -1
- package/dist/chat-send-tool.js +58 -15
- package/dist/chat-send-tool.js.map +1 -1
- package/dist/inbound-router.d.ts +3 -1
- package/dist/inbound-router.js +28 -12
- package/dist/inbound-router.js.map +1 -1
- package/dist/index.js +12 -14
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +3 -0
- package/package.json +1 -1
package/dist/chat-send-tool.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { PluginApi, PluginLogger } from "openclaw/plugin-sdk/plugin-entry";
|
|
1
|
+
import type { OpenClawPluginToolFactory, PluginApi, PluginLogger } from "openclaw/plugin-sdk/plugin-entry";
|
|
2
|
+
export declare const HELMIO_CHAT_SEND_TOOL_NAME = "helmio_chat_send";
|
|
2
3
|
export interface ChatSendToolOptions {
|
|
3
4
|
helmioApiUrl: string;
|
|
4
5
|
bridgeToken: string;
|
|
@@ -11,4 +12,10 @@ export interface ChatSendResult {
|
|
|
11
12
|
messageId: number;
|
|
12
13
|
deduplicated?: true;
|
|
13
14
|
}
|
|
15
|
+
export declare function buildChatSendToolFactory(opts: ChatSendToolOptions): OpenClawPluginToolFactory;
|
|
16
|
+
export declare function executeChatSend(ctx: {
|
|
17
|
+
agentId?: string;
|
|
18
|
+
}, args: {
|
|
19
|
+
body: string;
|
|
20
|
+
}, opts: ChatSendToolOptions): Promise<ChatSendResult>;
|
|
14
21
|
export declare function registerChatSendTool(api: PluginApi, opts: ChatSendToolOptions): void;
|
package/dist/chat-send-tool.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Outbound chat-send tool. Registered
|
|
2
|
-
//
|
|
3
|
-
// Helmio Agent.Id (CanonicalAgentList.Build sets
|
|
4
|
-
// Agent.Id.ToString()).
|
|
1
|
+
// Outbound chat-send tool. Registered as a FACTORY so the runtime injects
|
|
2
|
+
// ctx.agentId at tool-resolve time (closure captures it for the POST). The
|
|
3
|
+
// agentId is parsed as the Helmio Agent.Id (CanonicalAgentList.Build sets the
|
|
4
|
+
// openclaw agent id = Agent.Id.ToString()).
|
|
5
5
|
//
|
|
6
6
|
// Wire format matches ChatMessagesController.cs InboundMessageRequest:
|
|
7
7
|
// { clientMsgId, agentId, conversationKindCode: 1, body }
|
|
@@ -11,6 +11,7 @@ import { ulid } from "ulid";
|
|
|
11
11
|
import { ConversationKind } from "./events.js";
|
|
12
12
|
import { parseHelmioAgentId } from "./agent-resolver.js";
|
|
13
13
|
import { trimTrailingSlash } from "./url.js";
|
|
14
|
+
export const HELMIO_CHAT_SEND_TOOL_NAME = "helmio_chat_send";
|
|
14
15
|
class ChatHttpError extends Error {
|
|
15
16
|
status;
|
|
16
17
|
constructor(status, body) {
|
|
@@ -23,12 +24,13 @@ class ChatHttpError extends Error {
|
|
|
23
24
|
}
|
|
24
25
|
const MAX_RETRIES = 3;
|
|
25
26
|
const BASE_BACKOFF_MS = 250;
|
|
26
|
-
export function
|
|
27
|
+
export function buildChatSendToolFactory(opts) {
|
|
27
28
|
const fetchFn = opts.fetchFn ?? globalThis.fetch;
|
|
28
29
|
const newId = opts.idFactory ?? ulid;
|
|
29
30
|
const endpoint = `${trimTrailingSlash(opts.helmioApiUrl)}/api/chat/messages`;
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
return (ctx) => ({
|
|
32
|
+
label: "Chat: Send",
|
|
33
|
+
name: HELMIO_CHAT_SEND_TOOL_NAME,
|
|
32
34
|
description: "Send a message to the Company's Team conversation. The message appears to all participants (the Company owner and every active agent). Use this to reply to user messages.",
|
|
33
35
|
parameters: {
|
|
34
36
|
type: "object",
|
|
@@ -41,24 +43,65 @@ export function registerChatSendTool(api, opts) {
|
|
|
41
43
|
required: ["body"],
|
|
42
44
|
additionalProperties: false,
|
|
43
45
|
},
|
|
44
|
-
async execute(
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
throw new Error(`helmio_chat_send: cannot derive Helmio agent id from openclaw agentId=${ctx.agentId}`);
|
|
48
|
-
}
|
|
49
|
-
if (!args.body || args.body.trim().length === 0) {
|
|
46
|
+
async execute(_toolCallId, params) {
|
|
47
|
+
const body = readBody(params);
|
|
48
|
+
if (body === null) {
|
|
50
49
|
throw new Error("helmio_chat_send: body must be non-empty");
|
|
51
50
|
}
|
|
51
|
+
const helmioAgentId = parseHelmioAgentId(ctx.agentId ?? "");
|
|
52
|
+
if (helmioAgentId === null) {
|
|
53
|
+
throw new Error(`helmio_chat_send: cannot derive Helmio agent id from openclaw agentId=${ctx.agentId ?? "<none>"}`);
|
|
54
|
+
}
|
|
52
55
|
const payload = {
|
|
53
56
|
clientMsgId: newId(),
|
|
54
57
|
agentId: helmioAgentId,
|
|
55
58
|
conversationKindCode: ConversationKind.TeamDefault,
|
|
56
|
-
body
|
|
59
|
+
body,
|
|
57
60
|
};
|
|
58
|
-
|
|
61
|
+
const send = await postWithRetry(fetchFn, endpoint, opts.bridgeToken, payload, opts.logger);
|
|
62
|
+
return toolResult(send);
|
|
59
63
|
},
|
|
60
64
|
});
|
|
61
65
|
}
|
|
66
|
+
// Internal: returns the typed POST result for tests / non-tool callers.
|
|
67
|
+
export async function executeChatSend(ctx, args, opts) {
|
|
68
|
+
const fetchFn = opts.fetchFn ?? globalThis.fetch;
|
|
69
|
+
const newId = opts.idFactory ?? ulid;
|
|
70
|
+
const endpoint = `${trimTrailingSlash(opts.helmioApiUrl)}/api/chat/messages`;
|
|
71
|
+
if (!args.body || args.body.trim().length === 0) {
|
|
72
|
+
throw new Error("helmio_chat_send: body must be non-empty");
|
|
73
|
+
}
|
|
74
|
+
const helmioAgentId = parseHelmioAgentId(ctx.agentId ?? "");
|
|
75
|
+
if (helmioAgentId === null) {
|
|
76
|
+
throw new Error(`helmio_chat_send: cannot derive Helmio agent id from openclaw agentId=${ctx.agentId ?? "<none>"}`);
|
|
77
|
+
}
|
|
78
|
+
const payload = {
|
|
79
|
+
clientMsgId: newId(),
|
|
80
|
+
agentId: helmioAgentId,
|
|
81
|
+
conversationKindCode: ConversationKind.TeamDefault,
|
|
82
|
+
body: args.body,
|
|
83
|
+
};
|
|
84
|
+
return await postWithRetry(fetchFn, endpoint, opts.bridgeToken, payload, opts.logger);
|
|
85
|
+
}
|
|
86
|
+
export function registerChatSendTool(api, opts) {
|
|
87
|
+
const factory = buildChatSendToolFactory(opts);
|
|
88
|
+
api.registerTool(factory, { name: HELMIO_CHAT_SEND_TOOL_NAME });
|
|
89
|
+
}
|
|
90
|
+
function readBody(params) {
|
|
91
|
+
if (!params || typeof params !== "object")
|
|
92
|
+
return null;
|
|
93
|
+
const body = params.body;
|
|
94
|
+
if (typeof body !== "string" || body.trim().length === 0)
|
|
95
|
+
return null;
|
|
96
|
+
return body;
|
|
97
|
+
}
|
|
98
|
+
function toolResult(send) {
|
|
99
|
+
const tail = send.deduplicated ? " (deduplicated)" : "";
|
|
100
|
+
return {
|
|
101
|
+
content: [{ type: "text", text: `Sent (messageId=${send.messageId})${tail}` }],
|
|
102
|
+
details: send,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
62
105
|
async function postWithRetry(fetchFn, endpoint, bridgeToken, payload, logger) {
|
|
63
106
|
const body = JSON.stringify(payload);
|
|
64
107
|
const init = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-send-tool.js","sourceRoot":"","sources":["../src/chat-send-tool.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"chat-send-tool.js","sourceRoot":"","sources":["../src/chat-send-tool.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,8EAA8E;AAC9E,4CAA4C;AAC5C,EAAE;AACF,uEAAuE;AACvE,4DAA4D;AAC5D,sEAAsE;AACtE,oDAAoD;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OA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YAAY,aAAa,IAAI,CAAC,GAAG,CAAC,SAAS;gBAAE,MAAM,GAAG,CAAC;YAC9D,OAAO,GAAG,GAAG,CAAC;YACd,MAAM,CAAC,IAAI,CACT,6BAA6B,OAAO,IAAI,WAAW,YAAa,GAAa,CAAC,OAAO,EAAE,CACxF,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,GAAG,WAAW,EAAE,CAAC;YAC1B,MAAM,KAAK,CAAC,eAAe,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IACD,MAAM,OAAO,YAAY,KAAK;QAC5B,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
package/dist/inbound-router.d.ts
CHANGED
|
@@ -6,4 +6,6 @@ export interface InboundRouterDeps {
|
|
|
6
6
|
logger: PluginLogger;
|
|
7
7
|
ceo: ResolvedAgent | undefined;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type InboundVerdict = "dispatched" | "ignored-agent" | "ignored-no-ceo" | "ignored-no-runtime";
|
|
10
|
+
export declare function routeInbound(msg: ChatMessageDto, deps: InboundRouterDeps): Promise<InboundVerdict>;
|
|
11
|
+
export declare function buildAgentMainSessionKey(openclawAgentId: string): string;
|
package/dist/inbound-router.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
// Routes inbound chat messages to agents. Phase 1: CEO-only — every
|
|
2
2
|
// user-typed message in the Team conversation dispatches a turn to the
|
|
3
|
-
// CEO agent. Agent-typed messages
|
|
4
|
-
// to prevent self-loops (the CEO's
|
|
5
|
-
// to the plugin's connection).
|
|
3
|
+
// CEO agent via runtime.subagent.run(). Agent-typed messages
|
|
4
|
+
// (participantTypeId === 2) are dropped to prevent self-loops (the CEO's
|
|
5
|
+
// own outbound reply is broadcast back to the plugin's connection).
|
|
6
|
+
//
|
|
7
|
+
// The agent processes the message inside its main session and emits the
|
|
8
|
+
// reply by calling the registered `helmio_chat_send` tool — no channel
|
|
9
|
+
// kernel involvement needed for phase 1.
|
|
6
10
|
//
|
|
7
11
|
// Phase 2 will replace this with @mention parsing + AgentRouteBinding[]
|
|
8
|
-
// fan-out per ADR-0008 probe C3 findings.
|
|
12
|
+
// fan-out per ADR-0008 probe C3 findings (runtime.channel.turn.run path).
|
|
9
13
|
import { ParticipantType } from "./events.js";
|
|
10
14
|
export async function routeInbound(msg, deps) {
|
|
11
15
|
if (msg.participantTypeId !== ParticipantType.User) {
|
|
@@ -15,15 +19,27 @@ export async function routeInbound(msg, deps) {
|
|
|
15
19
|
deps.logger.warn(`helmio-chat: dropped messageId=${msg.id} — no CEO agent found in runtime config`);
|
|
16
20
|
return "ignored-no-ceo";
|
|
17
21
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const subagent = deps.runtime?.subagent;
|
|
23
|
+
if (!subagent || typeof subagent.run !== "function") {
|
|
24
|
+
deps.logger.warn(`helmio-chat: messageId=${msg.id} not dispatched — runtime.subagent.run unavailable`);
|
|
25
|
+
return "ignored-no-runtime";
|
|
26
|
+
}
|
|
27
|
+
const sessionKey = buildAgentMainSessionKey(deps.ceo.openclawAgentId);
|
|
28
|
+
await subagent.run({
|
|
29
|
+
sessionKey,
|
|
30
|
+
message: msg.body,
|
|
31
|
+
// idempotencyKey suppresses duplicate dispatches if the same SignalR
|
|
32
|
+
// event fires twice (server-reconnect replay). Helmio's MessageId is
|
|
33
|
+
// globally unique per Company DB.
|
|
34
|
+
idempotencyKey: `helmio-chat:msg:${msg.id}`,
|
|
26
35
|
});
|
|
27
36
|
return "dispatched";
|
|
28
37
|
}
|
|
38
|
+
// Mirrors openclaw/src/config/sessions/main-session.ts buildMainSessionKey:
|
|
39
|
+
// `agent:${normalizeAgentId(agentId)}:${normalizeMainKey(mainKey)}`
|
|
40
|
+
// Default mainKey is "main". OpenClaw normalizes agentId lowercase + trims.
|
|
41
|
+
export function buildAgentMainSessionKey(openclawAgentId) {
|
|
42
|
+
const normalized = openclawAgentId.trim().toLowerCase();
|
|
43
|
+
return `agent:${normalized}:main`;
|
|
44
|
+
}
|
|
29
45
|
//# sourceMappingURL=inbound-router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbound-router.js","sourceRoot":"","sources":["../src/inbound-router.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,uEAAuE;AACvE,
|
|
1
|
+
{"version":3,"file":"inbound-router.js","sourceRoot":"","sources":["../src/inbound-router.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,uEAAuE;AACvE,6DAA6D;AAC7D,yEAAyE;AACzE,oEAAoE;AACpE,EAAE;AACF,wEAAwE;AACxE,uEAAuE;AACvE,yCAAyC;AACzC,EAAE;AACF,wEAAwE;AACxE,0EAA0E;AAE1E,OAAO,EAAuB,eAAe,EAAE,MAAM,aAAa,CAAC;AAgBnE,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAmB,EACnB,IAAuB;IAEvB,IAAI,GAAG,CAAC,iBAAiB,KAAK,eAAe,CAAC,IAAI,EAAE,CAAC;QACnD,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,kCAAkC,GAAG,CAAC,EAAE,yCAAyC,CAClF,CAAC;QACF,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC;IACxC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;QACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,0BAA0B,GAAG,CAAC,EAAE,oDAAoD,CACrF,CAAC;QACF,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,MAAM,UAAU,GAAG,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACtE,MAAM,QAAQ,CAAC,GAAG,CAAC;QACjB,UAAU;QACV,OAAO,EAAE,GAAG,CAAC,IAAI;QACjB,qEAAqE;QACrE,qEAAqE;QACrE,kCAAkC;QAClC,cAAc,EAAE,mBAAmB,GAAG,CAAC,EAAE,EAAE;KAC5C,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,4EAA4E;AAC5E,sEAAsE;AACtE,4EAA4E;AAC5E,MAAM,UAAU,wBAAwB,CAAC,eAAuB;IAC9D,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxD,OAAO,SAAS,UAAU,OAAO,CAAC;AACpC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,19 +5,22 @@
|
|
|
5
5
|
// env). Hub auto-joins us to the Company's Team conversation.
|
|
6
6
|
// 2. Outbound chat-send tool registered globally; agents call it to reply,
|
|
7
7
|
// tool POSTs to /api/chat/messages.
|
|
8
|
-
// 3. Inbound router: user-typed messages dispatch a turn to the CEO agent
|
|
9
|
-
// (
|
|
8
|
+
// 3. Inbound router: user-typed messages dispatch a turn to the CEO agent
|
|
9
|
+
// via runtime.subagent.run({ sessionKey, message }). The agent runs in
|
|
10
|
+
// its main session and emits the reply through helmio_chat_send.
|
|
11
|
+
// (Phase 2 will add @mention parsing + multi-agent fan-out using the
|
|
12
|
+
// runtime.channel.turn.run kernel call.)
|
|
10
13
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
11
14
|
import { resolveAgents } from "./agent-resolver.js";
|
|
12
|
-
import { startChatConnection } from "./chat-connection.js";
|
|
13
15
|
import { registerChatSendTool } from "./chat-send-tool.js";
|
|
16
|
+
import { startChatConnection } from "./chat-connection.js";
|
|
14
17
|
import { routeInbound } from "./inbound-router.js";
|
|
15
18
|
import { trimTrailingSlash } from "./url.js";
|
|
16
19
|
let connection;
|
|
17
20
|
export default definePluginEntry({
|
|
18
21
|
id: "helmio-chat",
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
name: "Helmio Chat",
|
|
23
|
+
description: "Bridges Helmio's SignalR ChatHub to per-agent turns. Inbound user messages dispatch to the CEO agent via runtime.subagent.run(); agent replies emit through the helmio_chat_send tool which POSTs to /api/chat/messages. ADR-0008.",
|
|
21
24
|
register(api) {
|
|
22
25
|
const helmioApiUrl = process.env.HELMIO_API_URL;
|
|
23
26
|
const bridgeToken = process.env.HELMIO_CHAT_BRIDGE_TOKEN;
|
|
@@ -25,10 +28,9 @@ export default definePluginEntry({
|
|
|
25
28
|
api.logger.error("helmio-chat: HELMIO_API_URL or HELMIO_CHAT_BRIDGE_TOKEN not set; plugin loaded but disabled.");
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
const initial = resolveAgents(api.runtime.agents.list());
|
|
31
|
+
// Agent roster comes from the parsed openclaw.json (api.config.agents.list).
|
|
32
|
+
// PluginRuntime has subagent / nodes / channel — NOT an agents namespace.
|
|
33
|
+
const initial = resolveAgents(api.config.agents?.list ?? []);
|
|
32
34
|
api.logger.info(`helmio-chat: register-time agents=${initial.agents.length} ceo=${initial.ceo?.openclawAgentId ?? "<none>"}`);
|
|
33
35
|
registerChatSendTool(api, {
|
|
34
36
|
helmioApiUrl,
|
|
@@ -41,7 +43,7 @@ export default definePluginEntry({
|
|
|
41
43
|
bridgeToken,
|
|
42
44
|
logger: api.logger,
|
|
43
45
|
onMessage: async (msg) => {
|
|
44
|
-
const { ceo } = resolveAgents(api.
|
|
46
|
+
const { ceo } = resolveAgents(api.config.agents?.list ?? []);
|
|
45
47
|
const verdict = await routeInbound(msg, {
|
|
46
48
|
runtime: api.runtime,
|
|
47
49
|
logger: api.logger,
|
|
@@ -51,9 +53,5 @@ export default definePluginEntry({
|
|
|
51
53
|
},
|
|
52
54
|
});
|
|
53
55
|
},
|
|
54
|
-
async dispose() {
|
|
55
|
-
await connection?.stop();
|
|
56
|
-
connection = undefined;
|
|
57
|
-
},
|
|
58
56
|
});
|
|
59
57
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,sBAAsB;AACtB,6EAA6E;AAC7E,mEAAmE;AACnE,6EAA6E;AAC7E,yCAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,sBAAsB;AACtB,6EAA6E;AAC7E,mEAAmE;AACnE,6EAA6E;AAC7E,yCAAyC;AACzC,4EAA4E;AAC5E,4EAA4E;AAC5E,sEAAsE;AACtE,0EAA0E;AAC1E,8CAA8C;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAuB,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,IAAI,UAAsC,CAAC;AAE3C,eAAe,iBAAiB,CAAC;IAC/B,EAAE,EAAE,aAAa;IACjB,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,oOAAoO;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oBAAoB,GAAG,CAAC,iBAAiB,YAAY,OAAO,EAAE,CAC/F,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helmio/openclaw-helmio-chat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "OpenClaw plugin that bridges Helmio's SignalR ChatHub to per-agent turns inside the Company VM. Installed at cloud-init via `openclaw plugins install npm:@helmio/openclaw-helmio-chat@<pinned>`. ADR-0008.",
|
|
6
6
|
"type": "module",
|