HarborHarbor
DocumentationGuidesPlugins
Get Started

Your first Function (Beta)

Promote a working exec snippet into a reusable Harbor Function with defineJob.

Beta

Functions are in beta. Use the defineJob authoring global with hrbr inspect or hrbr exec; do not add legacy Orbit package imports to new examples.

A Function is a reusable Harbor job version. Prototype with hrbr exec, publish with a top-level defineJob(...), then inspect or run it through the Harbor control plane.

Prototype in exec

stale-issues.exec.ts
const issues = await linearMcp.listIssues({
  filter: { state: { type: { eq: "started" } } },
  limit: 10,
})

const stale = issues.filter((issue) =>
  (Date.now() - new Date(issue.updatedAt).getTime()) / 86_400_000 > 7
)

return { stale: stale.length, titles: stale.map((issue) => issue.title) }
hrbr exec -f ./stale-issues.exec.ts

Publish with defineJob

stale-issues.job.ts
defineJob({
  name: "staleIssues",
  description: "Find started Linear issues with no activity.",
  input: {
    thresholdDays: "number?",
  },
  output: {
    stale: "number",
    titles: { type: "array", items: { type: "string" } },
  },
  async run(input) {
    const thresholdDays = input.thresholdDays ?? 7
    const issues = await linearMcp.listIssues({
      filter: { state: { type: { eq: "started" } } },
      limit: 10,
    })
    const stale = issues.filter((issue) =>
      (Date.now() - new Date(issue.updatedAt).getTime()) / 86_400_000 > thresholdDays
    )
    return { stale: stale.length, titles: stale.map((issue) => issue.title) }
  },
})

Publish it with inspect when you only need the control-plane result:

hrbr inspect -f ./stale-issues.job.ts

Use hrbr exec -f ./stale-issues.job.ts when you also want a traced execution run around the publish path.

Inspect and run

hrbr inspect 'return await hrbr.jobs.inspect({ name: "stale-issues" })'
hrbr inspect 'return await hrbr.jobs.versions({ name: "stale-issues" })'

Invoke published Functions from the dashboard or SDK clients. Every invocation is still a Harbor run and can be inspected through traces.

SDK relationship

defineJob is a Harbor runtime authoring global. It is separate from installable clients:

SurfaceUse
@hrbr/clientApp/client code that calls Harbor APIs and runtime.execute.
@hrbr/sdkHarbor system contracts, generated protocol, runtime/platform namespaces.
harbor-sdkPython sync/async client for the same API.