The owner's AI and the Morning Review

3 entries

Markdown

m.tool

A question the owner's AI may ask the machine.

Signature
m.tool(name, *, fn, description, args=None, title=None, render=None)
Example · Where the machine is defined
def open_quotes(limit=5):
    return {"quotes": ["Gutter repair", "Roof check"][:int(limit)]}

m.tool("open_quotes", fn=open_quotes, description="The quotes still waiting for an answer.",
       args={"limit": {"type": "integer", "required": False, "description": "How many, at most."}},
       render=lambda r: "\n".join(f"- {q}" for q in r["quotes"]) or "None waiting.")

fn(**args) answers it, and render(result) writes the answer in words, which reach the owner's AI quoted, as the machine's own. args describes each argument: {"type": "string" | "integer" | "boolean", "required", "description"}, at most 10. The name is lowercase letters, digits and underscores.

Needs in machine.yaml
Nothing

m.reporter

The machine's part of the owner's Morning Review.

Signature
m.reporter(title, fn)
Example · Where the machine is defined
def morning(day):
    sent = int(m.setting("sent_" + day.isoformat(), default=0) or 0)
    if not sent:
        return {}
    return {"title": "Quote Follow Up", "headline": {"value": sent, "label": "quotes followed up"}}

m.reporter("Quote Follow Up", morning)

fn(day) answers for that day (a datetime.date). Your Ownbox asks once a pass and shows the latest answer, so a slow part never holds the review up. An empty answer shows nothing.

Needs in machine.yaml
Nothing

m.day_window

The UTC bounds of one of the Ownbox's local days.

Signature
m.day_window(day)
Example · Inside a job
import datetime

start, end = m.day_window(datetime.date.today())

In the Ownbox's own time zone, as its Morning Review counts a day.

Needs in machine.yaml
Nothing
Returns
(start, end), as ISO 8601 text.