Skip to content

Feature 1 (Stage 5): agent artifact-publish tool + teardown cleanup#56

Open
obaid wants to merge 1 commit into
feature/artifact-gatedfrom
feature/artifact-agent-tool
Open

Feature 1 (Stage 5): agent artifact-publish tool + teardown cleanup#56
obaid wants to merge 1 commit into
feature/artifact-gatedfrom
feature/artifact-agent-tool

Conversation

@obaid

@obaid obaid commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Final stage of Feature 1 (Artifact Publishing). Gives agents the tool to publish web artifacts themselves, and cleans up all server-side state on agent deletion.

Stacked on #55 (base feature/artifact-gated).

What's here

provision-artifacts OpenClaw skill (core-owned)

resources/skills/provision-artifacts/{SKILL.md, skill.json, provision_artifacts_tool.js} — an agent tool with three commands hitting the /api/artifacts agent-token API:

  • publish — static site or running app, public or gated
  • list — the agent's published artifacts + public URLs
  • unpublish — take one offline

Mirrors the provision-publish skill pattern exactly (env-reading tool JS; apiUrl/token hardcoded at install time via str_replace).

Deploy wiring

Deployed + enabled on every agent (always-on core skill), in all three paths:

  • AgentInstallScriptService::buildProvisionArtifactsSkillLines() (install)
  • AgentUpdateScriptService (update + skills.entries.provision-artifacts.enabled)
  • OpenClawDriver::deployArtifactsSkill() + config enable

Lifecycle cleanup on teardown

PublishArtifactService::teardownAgent(Agent):

  • stops + removes each app artifact's systemd unit
  • removes the agent's Caddy site file
  • deletes the Cloudflare DNS record (when configured)

Called from AgentController::destroy before $agent->delete(), guarded (try/catch + log) and short-circuited when the agent never published anything — so it never adds SSH work to deletions of non-publishing agents.

Tests

  • install script hardcodes creds into the artifacts tool (no process.env placeholder shipped)
  • teardownAgent stops apps, removes Caddy site, drops DNS — and skips DNS when Cloudflare unconfigured
  • Full suite: 767 passed, 106 skipped

Feature 1 is now complete across the stack (#52#56)

  1. Artifact publishing foundations (slug, artifacts table, DNS + Caddy TLS) #52 — slug + agent_artifacts table, Cloudflare DNS service, Caddy on-demand-TLS ask endpoint, server setup
  2. Static artifact publishing end-to-end #53 — static publishing (Caddy site sync + dashboard Apps tab)
  3. Running-app artifacts (systemd + port + reverse_proxy) #54 — running apps (per-artifact systemd unit + reverse proxy)
  4. Gated artifacts (per-artifact shared-link token) #55 — gated artifacts (Caddy query-token gate)
  5. Feature 1 (Stage 5): agent artifact-publish tool + teardown cleanup #56 (this) — agent publish tool + teardown cleanup

To go live in prod: set CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID, and ARTIFACT_DOMAIN (e.g. provisionagents.com) on Forge, and point the *.provisionagents.com wildcard (or per-agent records — the service creates them) at Cloudflare. Without those env vars the feature stays dormant (DNS steps no-op).

…n cleanup

Add the core-owned provision-artifacts OpenClaw skill so agents can publish
web artifacts (static sites or running apps) to their public subdomain from the
box, and clean up all artifact server-side state when an agent is deleted.

- resources/skills/provision-artifacts/{SKILL.md,skill.json,tool.js}: publish/
  list/unpublish via the /api/artifacts agent-token API
- Wire deploy + enable into AgentInstallScriptService, AgentUpdateScriptService,
  and OpenClawDriver (mirrors provision-publish; creds hardcoded at install)
- PublishArtifactService::teardownAgent() stops app systemd units, removes the
  Caddy site, and drops the Cloudflare DNS record; called from AgentController
  ::destroy (guarded, best-effort) before the agent row is deleted
- Tests: install-script hardcoding, teardown (with/without Cloudflare)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant