-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayload.py
More file actions
56 lines (42 loc) · 1.77 KB
/
payload.py
File metadata and controls
56 lines (42 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""CuePayload builder — standard agent scheduling payloads."""
from __future__ import annotations
class CuePayload:
"""Builder for standard agent scheduling payloads.
Usage::
payload = CuePayload()
payload.task("morning-brief").kind("content_generation").agent("socrates")
client.cues.create(name="morning-brief", cron="0 9 * * *", payload=payload.build())
"""
def __init__(self):
self._data = {}
def task(self, task_name: str) -> CuePayload:
"""Set the task name (used for worker routing via ?task= filter)."""
self._data["task"] = task_name
return self
def kind(self, kind: str) -> CuePayload:
"""Set the task kind (e.g., 'content_generation', 'data_sync', 'agent_turn')."""
self._data["kind"] = kind
return self
def instruction(self, text: str) -> CuePayload:
"""Set the instruction text for the agent."""
self._data["instruction"] = text
return self
def context_ref(self, ref: str) -> CuePayload:
"""Set a reference to the context (e.g., memory block ID)."""
self._data["context_ref"] = ref
return self
def context_mode(self, mode: str) -> CuePayload:
"""Set context mode: 'full', 'summary', 'ref_only'."""
self._data["context_mode"] = mode
return self
def agent(self, agent_name: str) -> CuePayload:
"""Set the agent name (metadata only -- not enforced in routing)."""
self._data["agent"] = agent_name
return self
def extra(self, key: str, value) -> CuePayload:
"""Set an arbitrary extra field."""
self._data[key] = value
return self
def build(self) -> dict:
"""Return the payload as a dictionary."""
return dict(self._data)