the-campfire 0.1.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/bin/cli.ts +182 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/assets/MermaidDiagram-By1J3Whj.js +2 -0
- package/dist/assets/_basePickBy-Dq6gnD-p.js +1 -0
- package/dist/assets/_baseUniq-SpgN6cGc.js +1 -0
- package/dist/assets/arc-D9SEA8dX.js +1 -0
- package/dist/assets/architectureDiagram-VXUJARFQ-CoTcwLeR.js +36 -0
- package/dist/assets/blockDiagram-VD42YOAC-Dvc63voV.js +122 -0
- package/dist/assets/c4Diagram-YG6GDRKO-tuDcG4_4.js +10 -0
- package/dist/assets/channel-CxhcHn7S.js +1 -0
- package/dist/assets/chunk-4BX2VUAB-x1hChYu9.js +1 -0
- package/dist/assets/chunk-55IACEB6-BX6HWnWP.js +1 -0
- package/dist/assets/chunk-B4BG7PRW-B4IlF03G.js +165 -0
- package/dist/assets/chunk-DI55MBZ5-TpYb5rLg.js +220 -0
- package/dist/assets/chunk-FMBD7UC4-DZX4LUPx.js +15 -0
- package/dist/assets/chunk-QN33PNHL-CuQs0NDY.js +1 -0
- package/dist/assets/chunk-QZHKN3VN-CygWwVx8.js +1 -0
- package/dist/assets/chunk-TZMSLE5B-CtI-IdKV.js +1 -0
- package/dist/assets/classDiagram-2ON5EDUG-BM0LptJF.js +1 -0
- package/dist/assets/classDiagram-v2-WZHVMYZB-BM0LptJF.js +1 -0
- package/dist/assets/clone-C6kt1rE7.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-PdySs991.js +1 -0
- package/dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
- package/dist/assets/dagre-6UL2VRFP-J0SxEiEu.js +4 -0
- package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/assets/diagram-PSM6KHXK-CW0HLXaH.js +24 -0
- package/dist/assets/diagram-QEK2KX5R-DADHF-k4.js +43 -0
- package/dist/assets/diagram-S2PKOQOG-9S0-PC3S.js +24 -0
- package/dist/assets/erDiagram-Q2GNP2WA-BEHAiY_q.js +60 -0
- package/dist/assets/flowDiagram-NV44I4VS-Cu6n9Xnd.js +162 -0
- package/dist/assets/ganttDiagram-JELNMOA3-Cr_BHryu.js +267 -0
- package/dist/assets/gitGraphDiagram-V2S2FVAM-D5pT35v5.js +65 -0
- package/dist/assets/graph-DKRbrxcs.js +1 -0
- package/dist/assets/index-Byjg9zgI.css +32 -0
- package/dist/assets/index-Cwj3m0hT.js +284 -0
- package/dist/assets/infoDiagram-HS3SLOUP-BaJlrgKV.js +2 -0
- package/dist/assets/init-Gi6I4Gst.js +1 -0
- package/dist/assets/journeyDiagram-XKPGCS4Q-CXC4-DJv.js +139 -0
- package/dist/assets/kanban-definition-3W4ZIXB7-BtHBu9cx.js +89 -0
- package/dist/assets/katex-BlHpptmG.js +261 -0
- package/dist/assets/layout-DnxSwLDJ.js +1 -0
- package/dist/assets/linear-CWbbIT8l.js +1 -0
- package/dist/assets/mermaid.core-DXn1cFAK.js +256 -0
- package/dist/assets/mindmap-definition-VGOIOE7T-BR8br1hs.js +68 -0
- package/dist/assets/ordinal-BENe2yWM.js +1 -0
- package/dist/assets/pieDiagram-ADFJNKIX-B7RmXV7I.js +30 -0
- package/dist/assets/quadrantDiagram-AYHSOK5B-DK0FhyV_.js +7 -0
- package/dist/assets/requirementDiagram-UZGBJVZJ-3zAGxSpL.js +64 -0
- package/dist/assets/sankeyDiagram-TZEHDZUN-DZppKtjc.js +10 -0
- package/dist/assets/sequenceDiagram-WL72ISMW-D1x3r3wV.js +145 -0
- package/dist/assets/stateDiagram-FKZM4ZOC-2ByD08Vq.js +1 -0
- package/dist/assets/stateDiagram-v2-4FDKWEC3-Vm1cYjgV.js +1 -0
- package/dist/assets/timeline-definition-IT6M3QCI-l5S35biR.js +61 -0
- package/dist/assets/treemap-GDKQZRPO-DIPadPiF.js +162 -0
- package/dist/assets/xychartDiagram-PRI3JC2R-9GUvwS2b.js +7 -0
- package/dist/favicon.svg +3 -0
- package/dist/fonts/Geist-Variable.woff2 +0 -0
- package/dist/fonts/GeistMono-Variable.woff2 +0 -0
- package/dist/icon-192.png +0 -0
- package/dist/icon-512.png +0 -0
- package/dist/index.html +33 -0
- package/dist/logo-codex.svg +14 -0
- package/dist/logo.svg +3 -0
- package/dist/manifest.json +26 -0
- package/dist/og-image.png +0 -0
- package/dist/sw.js +130 -0
- package/package.json +92 -0
- package/server/ADAPTERS.md +121 -0
- package/server/adapter-registry-types.ts +28 -0
- package/server/adapter-registry.ts +293 -0
- package/server/adapter-types.ts +51 -0
- package/server/agent-executor.ts +249 -0
- package/server/agent-mcp-bridge.ts +148 -0
- package/server/agent-mcp-stdio.ts +171 -0
- package/server/agent-mcp-tools.ts +76 -0
- package/server/agent-store.ts +183 -0
- package/server/agent-types.ts +79 -0
- package/server/aider-adapter.ts +525 -0
- package/server/auth.ts +153 -0
- package/server/auto-namer.ts +132 -0
- package/server/capability-discovery.ts +431 -0
- package/server/claude-container-auth.ts +40 -0
- package/server/claude-stdio-adapter.ts +452 -0
- package/server/clawhub-export.ts +218 -0
- package/server/cli-launcher.ts +1613 -0
- package/server/codex-adapter.ts +1987 -0
- package/server/codex-container-auth.ts +40 -0
- package/server/codex-home.ts +26 -0
- package/server/collective-intelligence.ts +401 -0
- package/server/commands-discovery.ts +160 -0
- package/server/constants.ts +5 -0
- package/server/container-manager.ts +328 -0
- package/server/cron-scheduler.ts +243 -0
- package/server/cron-store.ts +149 -0
- package/server/cron-types.ts +63 -0
- package/server/deliberation-engine.ts +323 -0
- package/server/embedding.ts +89 -0
- package/server/env-manager.ts +146 -0
- package/server/environment-detector.ts +106 -0
- package/server/environment-rules.ts +106 -0
- package/server/gallery-store.ts +216 -0
- package/server/gallery-types.ts +52 -0
- package/server/gallery-votes.ts +101 -0
- package/server/git-utils.ts +384 -0
- package/server/github-pr.ts +379 -0
- package/server/goose-adapter.ts +929 -0
- package/server/image-pull-manager.ts +144 -0
- package/server/index.ts +363 -0
- package/server/linear-project-manager.ts +78 -0
- package/server/moltbook-client.ts +160 -0
- package/server/openclaw-adapter.ts +916 -0
- package/server/openclaw-channel/channel.ts +188 -0
- package/server/openclaw-channel/index.ts +68 -0
- package/server/openclaw-channel/package.json +19 -0
- package/server/openclaw-channel/types.ts +93 -0
- package/server/opencode-adapter.ts +951 -0
- package/server/openhands-adapter.ts +775 -0
- package/server/orchestrator-executor.ts +184 -0
- package/server/orchestrator-store.ts +106 -0
- package/server/orchestrator-types.ts +86 -0
- package/server/path-resolver.ts +168 -0
- package/server/pr-poller.ts +162 -0
- package/server/proactive-keepalive.ts +121 -0
- package/server/prompt-manager.ts +103 -0
- package/server/protocol-monitor.ts +197 -0
- package/server/race-controller.ts +295 -0
- package/server/race-store.ts +82 -0
- package/server/recorder.ts +359 -0
- package/server/recording-hub/compat-validator.ts +122 -0
- package/server/recording-hub/diagnostics.ts +289 -0
- package/server/recording-hub/hub-routes.ts +146 -0
- package/server/recording-hub/hub-store.ts +224 -0
- package/server/replay.ts +78 -0
- package/server/routes/adapter-routes.ts +31 -0
- package/server/routes/agent-mcp-routes.ts +35 -0
- package/server/routes/agent-routes.ts +185 -0
- package/server/routes/auth-routes.ts +101 -0
- package/server/routes/ci-routes.ts +165 -0
- package/server/routes/commands-routes.ts +94 -0
- package/server/routes/cron-routes.ts +100 -0
- package/server/routes/env-routes.ts +50 -0
- package/server/routes/folder-routes.ts +56 -0
- package/server/routes/fs-routes.ts +403 -0
- package/server/routes/gallery-routes.ts +410 -0
- package/server/routes/git-routes.ts +108 -0
- package/server/routes/index.ts +62 -0
- package/server/routes/linear-routes.ts +254 -0
- package/server/routes/monitor-routes.ts +11 -0
- package/server/routes/orchestrator-routes.ts +210 -0
- package/server/routes/prompt-routes.ts +47 -0
- package/server/routes/race-routes.ts +103 -0
- package/server/routes/recording-routes.ts +101 -0
- package/server/routes/route-deps.ts +32 -0
- package/server/routes/session-routes.ts +560 -0
- package/server/routes/settings-routes.ts +108 -0
- package/server/routes/skills-routes.ts +52 -0
- package/server/routes/system-routes.ts +243 -0
- package/server/routes/webhook-routes.ts +135 -0
- package/server/routes.ts +44 -0
- package/server/security-middleware.ts +100 -0
- package/server/semantic-memory.ts +389 -0
- package/server/service.ts +733 -0
- package/server/session-folders.ts +107 -0
- package/server/session-git-info.ts +89 -0
- package/server/session-linear-issues.ts +94 -0
- package/server/session-names.ts +67 -0
- package/server/session-store.ts +169 -0
- package/server/session-types.ts +415 -0
- package/server/settings-manager.ts +120 -0
- package/server/shared-context.ts +401 -0
- package/server/skills-manager.ts +250 -0
- package/server/sub-session-manager.ts +263 -0
- package/server/terminal-manager.ts +185 -0
- package/server/update-checker.ts +114 -0
- package/server/usage-limits.ts +192 -0
- package/server/webhook-manager.ts +228 -0
- package/server/webhook-store.ts +168 -0
- package/server/webhook-types.ts +66 -0
- package/server/worktree-tracker.ts +84 -0
- package/server/ws-bridge.ts +2322 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Campfire channel plugin for OpenClaw.
|
|
3
|
+
*
|
|
4
|
+
* This plugin enables OpenClaw users to interact with their agents
|
|
5
|
+
* through Campfire's rich web UI — with cost tracking, session replay,
|
|
6
|
+
* permission voting, session gallery, and collaboration features
|
|
7
|
+
* that OpenClaw's native UI doesn't have.
|
|
8
|
+
*
|
|
9
|
+
* Architecture:
|
|
10
|
+
* Browser (Campfire React UI)
|
|
11
|
+
* ↕ WebSocket
|
|
12
|
+
* Campfire Server (Hono/Bun)
|
|
13
|
+
* ↕ HTTP webhook + outbound API
|
|
14
|
+
* OpenClaw Gateway
|
|
15
|
+
* ↕ Agent runtime
|
|
16
|
+
* AI Agent (Claude, GPT, Gemini, etc.)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type {
|
|
20
|
+
ChannelPlugin,
|
|
21
|
+
InboundMessage,
|
|
22
|
+
} from "./types.js";
|
|
23
|
+
|
|
24
|
+
// ─── Active account tracking ────────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
interface ActiveAccount {
|
|
27
|
+
accountId: string;
|
|
28
|
+
campfireUrl: string;
|
|
29
|
+
onMessage: (msg: InboundMessage) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const activeAccounts = new Map<string, ActiveAccount>();
|
|
33
|
+
|
|
34
|
+
// ─── Channel Plugin implementation ─────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
export const campfirePlugin: ChannelPlugin = {
|
|
37
|
+
meta: {
|
|
38
|
+
id: "campfire",
|
|
39
|
+
label: "Campfire",
|
|
40
|
+
icon: "🔥",
|
|
41
|
+
docsPath: "/channels/campfire",
|
|
42
|
+
blurb: "Rich web UI with cost tracking, session replay, and collaboration",
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
capabilities: {
|
|
46
|
+
chatTypes: ["direct"],
|
|
47
|
+
media: true,
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
config: {
|
|
51
|
+
fields: [
|
|
52
|
+
{
|
|
53
|
+
key: "campfireUrl",
|
|
54
|
+
label: "Campfire Server URL",
|
|
55
|
+
type: "url",
|
|
56
|
+
required: true,
|
|
57
|
+
placeholder: "http://localhost:4567",
|
|
58
|
+
help: "The URL of your running Campfire server",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "campfirePort",
|
|
62
|
+
label: "Campfire Port",
|
|
63
|
+
type: "number",
|
|
64
|
+
required: false,
|
|
65
|
+
placeholder: "4567",
|
|
66
|
+
help: "Port number (default: 4567)",
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
|
|
70
|
+
validate(values: Record<string, string>): { valid: boolean; error?: string } {
|
|
71
|
+
const url = values.campfireUrl;
|
|
72
|
+
if (!url) {
|
|
73
|
+
return { valid: false, error: "Campfire Server URL is required" };
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
new URL(url);
|
|
77
|
+
return { valid: true };
|
|
78
|
+
} catch {
|
|
79
|
+
return { valid: false, error: "Invalid URL format" };
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
outbound: {
|
|
85
|
+
/**
|
|
86
|
+
* Send a text message from the OpenClaw agent to Campfire.
|
|
87
|
+
* Posts to Campfire's inbound webhook endpoint.
|
|
88
|
+
*/
|
|
89
|
+
async sendText(opts: {
|
|
90
|
+
accountId: string;
|
|
91
|
+
recipientId: string;
|
|
92
|
+
text: string;
|
|
93
|
+
metadata?: Record<string, unknown>;
|
|
94
|
+
}): Promise<{ success: boolean; error?: string }> {
|
|
95
|
+
const account = activeAccounts.get(opts.accountId);
|
|
96
|
+
if (!account) {
|
|
97
|
+
return { success: false, error: `Account ${opts.accountId} is not active` };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
const res = await fetch(`${account.campfireUrl}/api/openclaw/inbound`, {
|
|
102
|
+
method: "POST",
|
|
103
|
+
headers: { "Content-Type": "application/json" },
|
|
104
|
+
body: JSON.stringify({
|
|
105
|
+
senderId: "openclaw-agent",
|
|
106
|
+
sessionId: opts.recipientId,
|
|
107
|
+
text: opts.text,
|
|
108
|
+
metadata: opts.metadata,
|
|
109
|
+
}),
|
|
110
|
+
signal: AbortSignal.timeout(10_000),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (!res.ok) {
|
|
114
|
+
const body = await res.text().catch(() => "unknown error");
|
|
115
|
+
return { success: false, error: `HTTP ${res.status}: ${body}` };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return { success: true };
|
|
119
|
+
} catch (err) {
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
error: err instanceof Error ? err.message : String(err),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
gateway: {
|
|
129
|
+
/**
|
|
130
|
+
* Start an account: register with Campfire for inbound messages.
|
|
131
|
+
* When a user sends a message in Campfire, Campfire will POST
|
|
132
|
+
* to the OpenClaw webhook to route it to the agent.
|
|
133
|
+
*/
|
|
134
|
+
async startAccount(opts: {
|
|
135
|
+
accountId: string;
|
|
136
|
+
config: Record<string, string>;
|
|
137
|
+
onMessage: (msg: InboundMessage) => void;
|
|
138
|
+
}): Promise<void> {
|
|
139
|
+
const campfireUrl = opts.config.campfireUrl || "http://localhost:4567";
|
|
140
|
+
|
|
141
|
+
activeAccounts.set(opts.accountId, {
|
|
142
|
+
accountId: opts.accountId,
|
|
143
|
+
campfireUrl,
|
|
144
|
+
onMessage: opts.onMessage,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
console.log(`[campfire-channel] Started account ${opts.accountId} → ${campfireUrl}`);
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Stop an account: unregister from Campfire.
|
|
152
|
+
*/
|
|
153
|
+
async stopAccount(accountId: string): Promise<void> {
|
|
154
|
+
activeAccounts.delete(accountId);
|
|
155
|
+
console.log(`[campfire-channel] Stopped account ${accountId}`);
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Handle an inbound webhook from Campfire.
|
|
162
|
+
* Called when a user sends a message in the Campfire UI
|
|
163
|
+
* and it needs to be routed to the OpenClaw agent.
|
|
164
|
+
*/
|
|
165
|
+
export function handleCampfireWebhook(body: {
|
|
166
|
+
accountId: string;
|
|
167
|
+
senderId: string;
|
|
168
|
+
text: string;
|
|
169
|
+
metadata?: Record<string, unknown>;
|
|
170
|
+
}): { ok: boolean; error?: string } {
|
|
171
|
+
const account = activeAccounts.get(body.accountId);
|
|
172
|
+
if (!account) {
|
|
173
|
+
return { ok: false, error: `Account ${body.accountId} not found` };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
account.onMessage({
|
|
177
|
+
senderId: body.senderId,
|
|
178
|
+
text: body.text,
|
|
179
|
+
metadata: body.metadata,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
return { ok: true };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Get the list of active account IDs (for status checking). */
|
|
186
|
+
export function getActiveAccounts(): string[] {
|
|
187
|
+
return Array.from(activeAccounts.keys());
|
|
188
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Campfire Channel Plugin for OpenClaw
|
|
3
|
+
*
|
|
4
|
+
* When installed in OpenClaw (~/.openclaw/extensions/campfire/),
|
|
5
|
+
* this plugin:
|
|
6
|
+
* 1. Registers a "Campfire" channel in OpenClaw's channel list
|
|
7
|
+
* 2. Routes messages between OpenClaw agents and Campfire's browser UI
|
|
8
|
+
* 3. Exposes an HTTP webhook route for inbound messages from Campfire
|
|
9
|
+
*
|
|
10
|
+
* Install: Copy this directory to ~/.openclaw/extensions/campfire/
|
|
11
|
+
* or: npm install @campfire/openclaw-channel
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { OpenClawPluginApi, HttpRouteHandler } from "./types.js";
|
|
15
|
+
import { campfirePlugin, handleCampfireWebhook, getActiveAccounts } from "./channel.js";
|
|
16
|
+
|
|
17
|
+
const webhookHandler: HttpRouteHandler = async (req) => {
|
|
18
|
+
if (req.method !== "POST") {
|
|
19
|
+
return { status: 405, body: { ok: false, error: "Method not allowed" } };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const body = req.body as {
|
|
23
|
+
accountId?: string;
|
|
24
|
+
senderId?: string;
|
|
25
|
+
text?: string;
|
|
26
|
+
metadata?: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
if (!body.accountId || !body.text) {
|
|
30
|
+
return {
|
|
31
|
+
status: 400,
|
|
32
|
+
body: { ok: false, error: "accountId and text are required" },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const result = handleCampfireWebhook({
|
|
37
|
+
accountId: body.accountId,
|
|
38
|
+
senderId: body.senderId || "campfire-user",
|
|
39
|
+
text: body.text,
|
|
40
|
+
metadata: body.metadata,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
status: result.ok ? 200 : 404,
|
|
45
|
+
body: result,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default {
|
|
50
|
+
id: "campfire",
|
|
51
|
+
name: "Campfire",
|
|
52
|
+
description: "Rich web UI for OpenClaw agents with cost tracking, session replay, and collaboration",
|
|
53
|
+
|
|
54
|
+
register(api: OpenClawPluginApi) {
|
|
55
|
+
// Register the Campfire channel with OpenClaw
|
|
56
|
+
api.registerChannel({ plugin: campfirePlugin });
|
|
57
|
+
|
|
58
|
+
// Register the inbound webhook route for Campfire → OpenClaw messages
|
|
59
|
+
api.registerHttpRoute({
|
|
60
|
+
path: "/webhook/campfire",
|
|
61
|
+
handler: webhookHandler,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Re-export for direct usage
|
|
67
|
+
export { campfirePlugin, handleCampfireWebhook, getActiveAccounts };
|
|
68
|
+
export type { OpenClawPluginApi } from "./types.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@campfire/openclaw-channel",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Campfire web UI channel plugin for OpenClaw",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"openclaw": {
|
|
8
|
+
"extensions": ["./index.ts"],
|
|
9
|
+
"channel": {
|
|
10
|
+
"id": "campfire",
|
|
11
|
+
"label": "Campfire",
|
|
12
|
+
"docsPath": "/channels/campfire",
|
|
13
|
+
"blurb": "Rich web UI with cost tracking, session replay, and collaboration",
|
|
14
|
+
"order": 100
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"keywords": ["openclaw", "channel", "campfire", "ai-assistant"],
|
|
18
|
+
"license": "MIT"
|
|
19
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Campfire OpenClaw channel plugin.
|
|
3
|
+
*
|
|
4
|
+
* These are simplified versions of the OpenClaw plugin SDK types
|
|
5
|
+
* that define the contract between Campfire and OpenClaw.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ─── Plugin SDK types (subset) ──────────────────────────────────────────────
|
|
9
|
+
|
|
10
|
+
export interface OpenClawPluginApi {
|
|
11
|
+
registerChannel(opts: { plugin: ChannelPlugin }): void;
|
|
12
|
+
registerHttpRoute(opts: { path: string; handler: HttpRouteHandler }): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type HttpRouteHandler = (req: InboundRequest) => Promise<HttpResponse> | HttpResponse;
|
|
16
|
+
|
|
17
|
+
export interface InboundRequest {
|
|
18
|
+
method: string;
|
|
19
|
+
path: string;
|
|
20
|
+
headers: Record<string, string>;
|
|
21
|
+
body: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface HttpResponse {
|
|
25
|
+
status: number;
|
|
26
|
+
body: unknown;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ─── Channel Plugin interface ───────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
export interface ChannelPlugin {
|
|
32
|
+
meta: ChannelMeta;
|
|
33
|
+
capabilities: ChannelCapabilities;
|
|
34
|
+
config: ChannelConfig;
|
|
35
|
+
outbound: ChannelOutbound;
|
|
36
|
+
gateway: ChannelGateway;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ChannelMeta {
|
|
40
|
+
id: string;
|
|
41
|
+
label: string;
|
|
42
|
+
icon: string;
|
|
43
|
+
docsPath: string;
|
|
44
|
+
blurb: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ChannelCapabilities {
|
|
48
|
+
chatTypes: ("direct" | "group")[];
|
|
49
|
+
media: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ChannelConfig {
|
|
53
|
+
/** Define the fields required to configure an account for this channel. */
|
|
54
|
+
fields: ChannelConfigField[];
|
|
55
|
+
/** Validate an account configuration. */
|
|
56
|
+
validate(values: Record<string, string>): { valid: boolean; error?: string };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ChannelConfigField {
|
|
60
|
+
key: string;
|
|
61
|
+
label: string;
|
|
62
|
+
type: "text" | "url" | "number";
|
|
63
|
+
required: boolean;
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
help?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ChannelOutbound {
|
|
69
|
+
/** Send a text message from the agent to the channel. */
|
|
70
|
+
sendText(opts: {
|
|
71
|
+
accountId: string;
|
|
72
|
+
recipientId: string;
|
|
73
|
+
text: string;
|
|
74
|
+
metadata?: Record<string, unknown>;
|
|
75
|
+
}): Promise<{ success: boolean; error?: string }>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ChannelGateway {
|
|
79
|
+
/** Start an account: register webhooks, open connections, etc. */
|
|
80
|
+
startAccount(opts: {
|
|
81
|
+
accountId: string;
|
|
82
|
+
config: Record<string, string>;
|
|
83
|
+
onMessage: (msg: InboundMessage) => void;
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
/** Stop an account: unregister webhooks, close connections. */
|
|
86
|
+
stopAccount(accountId: string): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface InboundMessage {
|
|
90
|
+
senderId: string;
|
|
91
|
+
text: string;
|
|
92
|
+
metadata?: Record<string, unknown>;
|
|
93
|
+
}
|