feat: Implement context detection and onboarding tools for DevClaw

- Add context-guard.ts to detect interaction context (via-agent, direct, group) and generate guardrails.
- Introduce onboarding.ts for conversational onboarding context templates and workspace file checks.
- Enhance setup.ts to support new agent creation with channel binding and migration of existing bindings.
- Create analyze-channel-bindings.ts to analyze channel availability and detect binding conflicts.
- Implement context-test.ts for debugging context detection.
- Develop devclaw_onboard.ts for explicit onboarding tool that guides users through setup.
- Update devclaw_setup.ts to include channel binding and migration support in setup process.
- Modify project-register.ts to enforce project registration from group context and auto-populate group ID.
- Enhance queue-status.ts to provide context-aware status checks and recommendations.
- Update task tools (task-complete, task-create, task-pickup) to clarify group ID usage for Telegram/WhatsApp.
This commit is contained in:
Lauren ten Hoor
2026-02-09 18:34:45 +08:00
parent 32eb079521
commit a9a3fc3f1f
18 changed files with 1532 additions and 44 deletions

View File

@@ -14,7 +14,7 @@ export function createSetupTool(api: OpenClawPluginApi) {
return (ctx: ToolContext) => ({
name: "devclaw_setup",
label: "DevClaw Setup",
description: `Set up DevClaw in an agent's workspace. Creates AGENTS.md, HEARTBEAT.md, role templates, memory/projects.json, and writes model tier config to openclaw.json. Optionally creates a new agent. Backs up existing files before overwriting.`,
description: `Execute DevClaw setup with collected configuration. Creates AGENTS.md, HEARTBEAT.md, role templates, memory/projects.json, and writes model tier config to openclaw.json. Optionally creates a new agent with channel binding and migration support. Backs up existing files before overwriting. This tool is typically called AFTER devclaw_onboard guides the conversation, but can be called directly if the user provides explicit configuration parameters.`,
parameters: {
type: "object",
properties: {
@@ -22,6 +22,15 @@ export function createSetupTool(api: OpenClawPluginApi) {
type: "string",
description: "Create a new agent with this name. If omitted, configures the current agent's workspace.",
},
channelBinding: {
type: "string",
enum: ["telegram", "whatsapp"],
description: "Channel to bind the new agent to (optional). Only used when newAgentName is specified. If omitted, no binding is created.",
},
migrateFrom: {
type: "string",
description: "Agent ID to migrate channel binding from (optional). Use when replacing an existing agent's channel-wide binding. Call analyze_channel_bindings first to detect conflicts.",
},
models: {
type: "object",
description: `Model overrides per tier. Missing tiers use defaults. Example: { "junior": "anthropic/claude-haiku-4-5", "senior": "anthropic/claude-opus-4-5" }`,
@@ -37,11 +46,15 @@ export function createSetupTool(api: OpenClawPluginApi) {
async execute(_id: string, params: Record<string, unknown>) {
const newAgentName = params.newAgentName as string | undefined;
const channelBinding = params.channelBinding as "telegram" | "whatsapp" | undefined;
const migrateFrom = params.migrateFrom as string | undefined;
const modelsParam = params.models as Partial<Record<Tier, string>> | undefined;
const workspaceDir = ctx.workspaceDir;
const result = await runSetup({
newAgentName,
channelBinding: channelBinding ?? null,
migrateFrom,
// If no new agent name, use the current agent's workspace
agentId: newAgentName ? undefined : ctx.agentId,
workspacePath: newAgentName ? undefined : workspaceDir,
@@ -53,12 +66,23 @@ export function createSetupTool(api: OpenClawPluginApi) {
? `Agent "${result.agentId}" created`
: `Configured workspace for agent "${result.agentId}"`,
``,
];
if (result.bindingMigrated) {
lines.push(
`✅ Channel binding migrated:`,
` ${result.bindingMigrated.channel} (from "${result.bindingMigrated.from}" → "${result.agentId}")`,
``,
);
}
lines.push(
`Models:`,
...ALL_TIERS.map((t) => ` ${t}: ${result.models[t]}`),
``,
`Files written:`,
...result.filesWritten.map((f) => ` ${f}`),
];
);
if (result.warnings.length > 0) {
lines.push(``, `Warnings:`, ...result.warnings.map((w) => ` ${w}`));
@@ -67,7 +91,7 @@ export function createSetupTool(api: OpenClawPluginApi) {
lines.push(
``,
`Next steps:`,
` 1. Add bot to a Telegram group`,
` 1. Add bot to a Telegram/WhatsApp group`,
` 2. Register a project: "Register project <name> at <repo> for group <id>"`,
` 3. Create your first issue and pick it up`,
);