Skip to content

Latest commit

 

History

History
69 lines (52 loc) · 1.88 KB

File metadata and controls

69 lines (52 loc) · 1.88 KB

Agent Instructions

Use this package when code needs to render HTML to a PDF through the Puppet Master server.

Package

  • Install: npm install @codebucket/puppet-master
  • Import: import { PuppetMaster } from "@codebucket/puppet-master";

Public API

This package currently exposes one public method only:

new PuppetMaster({
  baseUrl: string,
  apiKey: string,
})

await client.pdf({
  pdfPath: string,
  content: string,
  launchOptions?: Record<string, unknown>,
  pageOptions?: Record<string, unknown>,
  pdfOptions?: Record<string, unknown>,
  otherPageFunctions?: Array<
    [methodName: string] | [methodName: string, args: unknown[]]
  >,
})

Required Behavior

  • Always pass baseUrl and apiKey when constructing the client.
  • Always pass both pdfPath and content when calling pdf.
  • Treat pdfPath as a local output path only. It is not part of the server task payload.
  • Treat launchOptions, pageOptions, and pdfOptions as pass-through Puppeteer option objects.
  • Model otherPageFunctions as an ordered tuple array of page method calls.

Wire Contract

The client sends:

{
  "task": {
    "content": "<html>...</html>",
    "launchOptions": {},
    "pageOptions": {},
    "pdfOptions": {},
    "otherPageFunctions": [
      ["waitForNetworkIdle", [{ "idleTime": 500 }]]
    ]
  }
}

The client also sends the x-api-key header.

Constraints

  • Do not invent extra public methods.
  • Do not model otherPageFunctions as an object.
  • Do not call the server directly if this package is already available.
  • Prefer the exported PuppetMasterClientOptions, RemotePdfTaskOptions, PdfTaskOptions, and PageFunctionCall types in TypeScript.

Current Server Caveat

  • The uploaded server currently executes otherPageFunctions after page.pdf(). Do not rely on those calls to affect the generated PDF unless the server implementation changes.