Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ openclaw config set channels.helloagent.allowFrom.0 alice
| `allow-all` | Any HelloAgent peer can DM (a warning is logged) |
| `deny-all` | Inbound DMs are dropped |

## Uninstalling

`openclaw plugins uninstall helloagent` removes the cfg entry, install record, and load path — but it does **not** wipe credentials. Log out each account first so the live WebSocket session is torn down and the `creds.json` files are deleted:

```bash
openclaw channels logout --channel helloagent # repeat per --account <id> if you have several
openclaw plugins uninstall helloagent
```

Or, if you've already uninstalled and want to scrub leftover tokens:

```bash
rm -rf ~/.openclaw/credentials/helloagent
```

## Capabilities

| | |
Expand Down
38 changes: 38 additions & 0 deletions openclaw.plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,44 @@
"type": "string",
"enum": ["allowlist", "allow-all", "deny-all", "pairing"],
"description": "Direct-message gating policy."
},
"accounts": {
"type": "object",
"description": "Per-account overrides keyed by accountId.",
"additionalProperties": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean",
"description": "Set false to keep paired creds on disk but prevent OpenClaw from starting this account."
},
"name": {
"type": "string",
"description": "Display name for this account."
},
"apiUrl": {
"type": "string",
"format": "uri",
"description": "Per-account HelloAgent REST base URL override."
},
"relayWs": {
"type": "string",
"format": "uri",
"description": "Per-account relay WebSocket URL override."
},
"allowFrom": {
"type": "array",
"items": { "type": "string" },
"description": "Per-account allowlist of peer handles permitted to DM."
},
"dmPolicy": {
"type": "string",
"enum": ["allowlist", "allow-all", "deny-all", "pairing"],
"description": "Per-account direct-message gating policy."
}
}
}
}
}
},
Expand Down
12 changes: 11 additions & 1 deletion src/channel/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import type { HelloAgentAccount, ResolvedHelloAgentAccount } from "../core/types
import { sendText } from "../messaging/outbound/send.js";
import { helloAgentOutbound } from "../messaging/outbound/outbound.js";
import { loginHelloAgent } from "../commands/auth-login.js";
import { logoutHelloAgent } from "../commands/auth-logout.js";
import { logoutHelloAgent, onHelloAgentAccountRemoved } from "../commands/auth-logout.js";
import {
applyAccountConfig,
collectHelloAgentSecurityWarnings,
Expand Down Expand Up @@ -380,6 +380,16 @@ export const helloAgentPlugin: ChannelPlugin<ResolvedHelloAgentAccount> = {
logoutAccount: logoutHelloAgent,
},

// -------------------------------------------------------------------------
// Lifecycle — react to account removal from cfg (covers `channels logout`
// and the cascade from `plugins uninstall helloagent`). Deletes the
// on-disk creds so sensitive ha_* tokens don't outlive the install.
// -------------------------------------------------------------------------

lifecycle: {
onAccountRemoved: onHelloAgentAccountRemoved,
},

// -------------------------------------------------------------------------
// Auth — channels login dispatch (oauth/device/import).
// -------------------------------------------------------------------------
Expand Down
38 changes: 29 additions & 9 deletions src/commands/auth-logout.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
/**
* `gateway.logoutAccount` adapter — invoked by OpenClaw when the user runs
* `openclaw channels logout --channel helloagent [--account <id>]`.
* Account-teardown adapters.
*
* Behavior: stop the live WS session (if any) and delete the credentials
* file from disk. Returns `{ cleared: true, loggedOut: true }`.
* Two entry points share one cleanup routine:
*
* - `logoutHelloAgent` — `gateway.logoutAccount`, invoked by
* `openclaw channels logout --channel helloagent [--account <id>]`.
* - `onHelloAgentAccountRemoved` — `lifecycle.onAccountRemoved`, invoked
* whenever an account leaves the cfg (per-account removal, or as a
* side-effect of `openclaw plugins uninstall helloagent` blowing away
* the entire `channels.helloagent` block).
*
* Cleanup is best-effort and idempotent: stops the live WS session if any,
* then deletes the on-disk `creds.json`. Both steps tolerate "already gone".
*/
import type { ChannelPlugin } from "openclaw/plugin-sdk/channel-core";

Expand All @@ -17,11 +25,23 @@ type LogoutAccountFn = NonNullable<
type LogoutCtx = Parameters<LogoutAccountFn>[0];
type LogoutResult = Awaited<ReturnType<LogoutAccountFn>>;

type LifecycleAdapter = NonNullable<ChannelPlugin<ResolvedHelloAgentAccount>["lifecycle"]>;
type OnAccountRemovedFn = NonNullable<LifecycleAdapter["onAccountRemoved"]>;
type OnAccountRemovedParams = Parameters<OnAccountRemovedFn>[0];

async function cleanupAccount(accountId: string, log: (s: string) => void): Promise<void> {
log(`[helloagent] cleaning up account ${accountId}`);
await stopAccount(accountId).catch(() => undefined);
await deleteCreds(accountId).catch(() => undefined);
}

export async function logoutHelloAgent(ctx: LogoutCtx): Promise<LogoutResult> {
const accountId = ctx.accountId;
ctx.runtime.log(`[helloagent] logout: stopping session for ${accountId}`);
await stopAccount(accountId);
await deleteCreds(accountId);
ctx.runtime.log(`[helloagent] logout: creds removed for ${accountId}`);
await cleanupAccount(ctx.accountId, (s) => ctx.runtime.log(s));
return { cleared: true, loggedOut: true };
}

export async function onHelloAgentAccountRemoved(
params: OnAccountRemovedParams,
): Promise<void> {
await cleanupAccount(params.accountId, (s) => params.runtime.log(s));
}
Loading