feat: initial Dialectic.OpenclawPlugin — agent tools for Dialectic v2

Phase 3 of DIALECTIC-V2. Six tools wired to the Go backend running on
server.t3:

- dialectic_list_topics      GET  /api/topics
- dialectic_topic_detail     GET  /api/topics/{id}
- dialectic_propose_topic    POST /api/topics
- dialectic_signup           POST /api/topics/{id}/signups (HF pre-check)
- dialectic_post_argument    POST /api/topics/{id}/arguments
- dialectic_view_verdict     GET  /api/topics/{id}/verdict

All tools return MCP {content:[{type:text,text}]} shape. Errors caught
and surfaced as text payload so agents see actionable failure messages.

Per-agent API key resolved via secret-mgr key dialectic-agent-apikey
(cached in memory; AGENT_VERIFY env required). HF on_call coverage
check degrades gracefully to skipped if HarborForge.OpenclawPlugin
does not yet expose hasOnCallCovering() — backend stores pre_validated
flag as audit signal.

openclaw.plugin.json declares both contracts.tools (the 6 names) AND
activation.onStartup:true per loader gotchas memory; missing either
silently drops the plugin.

Plain export default {id, name, register} entry shape matching
prism-facet. No openclaw SDK imports (jiti runtime resolution of
openclaw was flaky in HF-style entries; structurally simpler avoids
the lookup entirely).

Defaults backendUrl to https://dialectic-api.hangman-lab.top; override
via openclaw.json plugins.entries.dialectic.config.backendUrl for sim.

Phase 3 deferred items (in README): agent key provisioning workflow,
HF window-coverage accessor, SSE subscription tool, token-cost
reporting.
This commit is contained in:
h z
2026-05-23 13:04:12 +01:00
commit db85d7dc69
15 changed files with 996 additions and 0 deletions

40
plugin/index.ts Normal file
View File

@@ -0,0 +1,40 @@
/**
* Dialectic — OpenClaw plugin entry.
*
* Tools: dialectic_list_topics, dialectic_topic_detail,
* dialectic_propose_topic, dialectic_signup,
* dialectic_post_argument, dialectic_view_verdict
*
* Loader gotchas (per [[reference-meridian-plugin-contract]]):
* - openclaw.plugin.json MUST declare `activation.onStartup: true`
* or this plugin is silently treated as lazy/on-demand and
* register() is never called.
* - Every tool name MUST appear in contracts.tools or the tool
* never surfaces to agents.
* - Plain `export default { id, name, register }` works in jiti
* (matches prism-facet); don't pull SDK helpers without
* `openclaw` actually being resolvable at runtime.
*/
import { registerDialecticTools } from './src/tools.js';
interface PluginApi {
logger: {
info(msg: string): void;
warn(msg: string): void;
error(msg: string): void;
};
on(hook: string, handler: (...args: any[]) => any): void;
registerTool(def: any): void;
config?: { backendUrl?: string };
}
export default {
id: 'dialectic',
name: 'Dialectic',
register(api: PluginApi) {
registerDialecticTools(api);
api.logger.info('[dialectic] plugin registered');
},
};