buyprompts

package
v0.12.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package buyprompts is the single authoring point for buyer-facing "how to buy" instructions. Three surfaces show a buyer how to pay for a service — the 402 paywall page (internal/x402/paymentrequired.go), the public storefront (web/public-storefront), and the machine-readable catalog (/api/services.json via internal/serviceoffercontroller) — and when each composed its own copy they drifted: the 402 page taught agent buyers a call path that 404'd while every other surface taught the right one.

The controller publishes the output of this package in each catalog entry's `buy` block; the storefront renders that block verbatim; the 402 page builds its prompt cards from the same functions. Adding support for a new kind of buying software means adding one prompt key here — not forking a fourth copy of the instructions.

Index

Constants

View Source
const (
	// PromptObolAgent is pasted into an Obol Stack agent (Hermes/OpenClaw)
	// that has the buy-x402 skill.
	PromptObolAgent = "obol-agent"
	// PromptGenericLLM is pasted into any other AI agent (Claude, ChatGPT,
	// Gemini, ...) with tool access but no Obol tooling.
	PromptGenericLLM = "generic-llm"
	// PromptCLI is the shell command a human runs from an obol-stack host.
	PromptCLI = "cli"
)

Prompt keys published in the catalog `buy.prompts` map. Stable API for storefront and downstream consumers.

View Source
const DefaultTaskExample = "Summarise the README and list the top 3 risks."

DefaultTaskExample is the placeholder task used in copy-paste prompts and wire examples wherever the buyer hasn't supplied a real one.

Variables

This section is empty.

Functions

func ChatCompletionsURL

func ChatCompletionsURL(baseURL string) string

ChatCompletionsURL is the canonical paid-call URL for chat-shaped offers (inference and agent). Must stay in lockstep with the gateway's tolerant path rewrite (internal/x402/verifier.go normalizeChatCompletionsPath) and buy.py's target construction.

func ChatExample

func ChatExample(url, model, task string) string

ChatExample renders the wire example of one paid chat-completions call.

func GuideRef

func GuideRef(siteURL string) string

GuideRef is the discovery reference woven into generic-LLM prompts: it tells a buyer with no Obol tooling where the full payment recipe lives.

Types

type Block

type Block struct {
	CallShape CallShape         `json:"callShape"`
	Prompts   map[string]string `json:"prompts"`
	// Example is a copy-pasteable wire example of one paid request.
	Example string `json:"example,omitempty"`
}

Block is the full buyer-instruction block for one service, published as the catalog entry's `buy` field.

func Build

func Build(in Input) Block

Build assembles the canonical Block for a service.

type CallShape

type CallShape struct {
	Method string `json:"method"`
	// Path is relative to the service base URL ("" = the base itself).
	Path string `json:"path,omitempty"`
	// BodyKind: "openai-chat" (chat-completions JSON), "json" (operator-
	// defined JSON), "multipart" (fine-tuning), or "none".
	BodyKind string `json:"bodyKind"`
	// Streaming reports whether the endpoint supports (and slow calls
	// should use) `"stream": true`.
	Streaming bool `json:"streaming"`
}

CallShape is the machine-readable request recipe for a service. Buying software uses it instead of guessing the path/method/streaming mode.

type Input

type Input struct {
	// Type is the ServiceOffer type: inference, agent, http, fine-tuning.
	// Unknown/empty values get http (single-shot pay) semantics.
	Type string
	// URL is the service base URL (e.g. https://host/services/<name>).
	URL string
	// SiteURL is the storefront origin used for discovery references
	// (skill.md / openapi.json links). Empty falls back to x402.org.
	SiteURL string
	// Model is the model id for inference/agent offers ("" when unknown).
	Model string
	// PriceDisplay is the formatted price (e.g. "0.001 USDC per request").
	PriceDisplay string
	// NetworkLabel is the human-friendly chain name (e.g. "Base Sepolia").
	NetworkLabel string
	// TaskExample overrides DefaultTaskExample in prompts and examples.
	TaskExample string
}

Input describes one purchasable service. All fields are display-ready strings; zero values degrade gracefully (placeholders, omitted clauses).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL