- Migrate src/ → plugin/ (plugin/core/, plugin/web/, plugin/commands/)
and src/mcp/ → services/ per OpenClaw plugin dev spec
- Add Gemini CLI backend (plugin/core/gemini/sdk-adapter.ts) with GEMINI.md
system-prompt injection
- Inject bootstrap as stateless system prompt on every turn instead of
first turn only: Claude via --system-prompt, Gemini via workspace/GEMINI.md;
eliminates isFirstTurn branch, keeps skills in sync with OpenClaw snapshots
- Fix session-map-store defensive parsing (sessions ?? []) to handle bare {}
reset files without crashing on .find()
- Add docs/TEST_FLOW.md with E2E test scenarios and expected outcomes
- Add docs/claude/BRIDGE_MODEL_FINDINGS.md with contractor-probe results
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import fs from "node:fs";
|
|
import { createBaseAgent } from "../core/openclaw/agents-add-runner.js";
|
|
import { markAgentAsClaudeContractor, markAgentAsGeminiContractor } from "../core/openclaw/agent-config-writer.js";
|
|
import { ensureContractorStateDir } from "../core/contractor/runtime-state.js";
|
|
import { initEmptySessionMap } from "../core/contractor/session-map-store.js";
|
|
|
|
export type AddArgs = {
|
|
agentId: string;
|
|
workspace: string;
|
|
contractor: string;
|
|
};
|
|
|
|
export async function runContractorAgentsAdd(args: AddArgs): Promise<void> {
|
|
const { agentId, workspace, contractor } = args;
|
|
|
|
// Validate
|
|
if (!agentId) throw new Error("--agent-id is required");
|
|
if (!workspace) throw new Error("--workspace is required");
|
|
if (!contractor) throw new Error("--contractor is required");
|
|
if (contractor !== "claude" && contractor !== "gemini") {
|
|
throw new Error(`--contractor ${contractor}: must be 'claude' or 'gemini'`);
|
|
}
|
|
|
|
const bridgeModel =
|
|
contractor === "gemini"
|
|
? "contractor-agent/contractor-gemini-bridge"
|
|
: "contractor-agent/contractor-claude-bridge";
|
|
|
|
// Ensure workspace exists
|
|
if (!fs.existsSync(workspace)) {
|
|
fs.mkdirSync(workspace, { recursive: true });
|
|
}
|
|
|
|
console.log(`[contractor-agent] Creating base OpenClaw agent: ${agentId}`);
|
|
createBaseAgent({ agentId, workspace, bridgeModel });
|
|
|
|
console.log(`[contractor-agent] Writing contractor metadata`);
|
|
if (contractor === "gemini") {
|
|
markAgentAsGeminiContractor(agentId, workspace);
|
|
} else {
|
|
markAgentAsClaudeContractor(agentId, workspace);
|
|
}
|
|
|
|
console.log(`[contractor-agent] Initializing runtime state`);
|
|
ensureContractorStateDir(workspace);
|
|
initEmptySessionMap(workspace);
|
|
|
|
console.log(`[contractor-agent] Done.`);
|
|
console.log(` Agent: ${agentId}`);
|
|
console.log(` Workspace: ${workspace}`);
|
|
console.log(` Model: ${bridgeModel}`);
|
|
console.log(` State dir: ${workspace}/.openclaw/contractor-agent/`);
|
|
}
|