forkbase 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
forkbase-0.1.0/LICENSE ADDED
@@ -0,0 +1,105 @@
1
+ # Functional Source License, Version 1.1, ALv2 Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-ALv2
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Abhishek DG
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: forkbase
3
+ Version: 0.1.0
4
+ Summary: Forkbase for Python: agents' runs (worlds, propose, review), jobs, and the job runtime's helpers.
5
+ License: FSL-1.1-ALv2
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Provides-Extra: supabase
10
+ Requires-Dist: supabase>=2; extra == "supabase"
11
+ Dynamic: license-file
12
+
13
+ # forkbase
14
+
15
+ Forkbase for Python (3.9+, standard library only): agents' runs (a world per run, propose, review) and jobs.
16
+ Tables, auth, storage and realtime speak Supabase's APIs: `client.supabase()` returns a supabase-py client for them
17
+ (`pip install "forkbase[supabase]"`).
18
+
19
+ ```python
20
+ from forkbase import create_client
21
+
22
+ fb = create_client("https://api.example.com", agent_token)
23
+ scope = fb.agents.with_run("close stale carts")
24
+ with scope as run:
25
+ run.sql("update carts set closed = true where updated_at < now() - interval '30 days'")
26
+ print(scope.outcome["status"]) # merged | held | conflict
27
+ ```
28
+
29
+ - `fb.agents`: `run(intent)`, `with_run(intent)` (proposes on success, discards on an exception), `get`, `list_runs`;
30
+ with the service key also `create`, `approve`, `reject`, `undo`.
31
+ - `run`: `sql(query, params)`, `changes()`, `propose()`, `discard()`, `refresh()`.
32
+ - `fb.jobs` (service key): `deploy`, `functions`, `invoke(name, payload, wait=..., delay_s=..., run_at=...,
33
+ idempotency_key=...)`, `get`, `list`, `cancel`, `retry`, `schedule`.
34
+ - Inside a job: `step(name, fn)`, `sleep(name, seconds)`, `sql(query, params)`, `context()`. The job runtime ships
35
+ this module, so functions import it without installing it.
36
+
37
+ Errors are `ForkbaseError` with `status`, `code` and `body`.
@@ -0,0 +1,25 @@
1
+ # forkbase
2
+
3
+ Forkbase for Python (3.9+, standard library only): agents' runs (a world per run, propose, review) and jobs.
4
+ Tables, auth, storage and realtime speak Supabase's APIs: `client.supabase()` returns a supabase-py client for them
5
+ (`pip install "forkbase[supabase]"`).
6
+
7
+ ```python
8
+ from forkbase import create_client
9
+
10
+ fb = create_client("https://api.example.com", agent_token)
11
+ scope = fb.agents.with_run("close stale carts")
12
+ with scope as run:
13
+ run.sql("update carts set closed = true where updated_at < now() - interval '30 days'")
14
+ print(scope.outcome["status"]) # merged | held | conflict
15
+ ```
16
+
17
+ - `fb.agents`: `run(intent)`, `with_run(intent)` (proposes on success, discards on an exception), `get`, `list_runs`;
18
+ with the service key also `create`, `approve`, `reject`, `undo`.
19
+ - `run`: `sql(query, params)`, `changes()`, `propose()`, `discard()`, `refresh()`.
20
+ - `fb.jobs` (service key): `deploy`, `functions`, `invoke(name, payload, wait=..., delay_s=..., run_at=...,
21
+ idempotency_key=...)`, `get`, `list`, `cancel`, `retry`, `schedule`.
22
+ - Inside a job: `step(name, fn)`, `sleep(name, seconds)`, `sql(query, params)`, `context()`. The job runtime ships
23
+ this module, so functions import it without installing it.
24
+
25
+ Errors are `ForkbaseError` with `status`, `code` and `body`.
@@ -0,0 +1,346 @@
1
+ """Forkbase for Python, standard library only.
2
+
3
+ - ``create_client(url, key)``: agents' runs (each a world of its own; propose; review) and jobs. The key is the
4
+ service_role key (servers only) or an agent's ``fba_`` token. Tables, auth, storage and realtime speak Supabase's
5
+ APIs: ``client.supabase()`` gives a supabase-py client for them (``pip install supabase``).
6
+ - Inside a job (a function Forkbase runs), ``step``, ``sleep``, ``sql`` and ``context`` are the job's own helpers.
7
+ """
8
+ import json, os, time, urllib.error, urllib.parse, urllib.request
9
+
10
+ __all__ = ["create_client", "Client", "Run", "ForkbaseError", "Suspend", "step", "sleep", "sql", "context"]
11
+ __version__ = "0.1.0"
12
+
13
+ _env = os.environ
14
+
15
+
16
+ class ForkbaseError(Exception):
17
+ def __init__(self, status, code, message, body=None):
18
+ super().__init__(message)
19
+ self.status = status
20
+ self.code = code
21
+ self.body = body
22
+
23
+
24
+ def _q(s):
25
+ return urllib.parse.quote(str(s), safe="")
26
+
27
+
28
+ def _request(base, token, method, path, body=None, headers=None, timeout=120):
29
+ h = {"authorization": f"Bearer {token}", **(headers or {})}
30
+ if token and not str(token).startswith("fb"):
31
+ h["apikey"] = token
32
+ data = None
33
+ if body is not None:
34
+ data = json.dumps(body).encode()
35
+ h["content-type"] = "application/json"
36
+ req = urllib.request.Request(base + path, data=data, method=method, headers=h)
37
+ try:
38
+ with urllib.request.urlopen(req, timeout=timeout) as r:
39
+ text = r.read().decode()
40
+ status = r.status
41
+ except urllib.error.HTTPError as e:
42
+ text = e.read().decode()
43
+ status = e.code
44
+ try:
45
+ v = json.loads(text) if text else None
46
+ except ValueError:
47
+ v = text
48
+ return status, v
49
+
50
+
51
+ def _fail(method, path, status, v):
52
+ d = v if isinstance(v, dict) else {}
53
+ msg = d.get("message") or d.get("error_description") or (v if isinstance(v, str) else "")
54
+ return ForkbaseError(status, d.get("code") or d.get("error") or "error", f"{method} {path}: {status} {msg}".strip(), v)
55
+
56
+
57
+ class Run:
58
+ """A run: a world of its own where an agent reads and writes; nothing reaches the data until ``propose()``."""
59
+
60
+ def __init__(self, client, data):
61
+ self._client = client
62
+ self.token = None
63
+ self.database_url = None
64
+ self._set(data)
65
+
66
+ def _set(self, data):
67
+ self.data = data
68
+ self.id = data["id"]
69
+ self.status = data.get("status")
70
+ if data.get("token"):
71
+ self.token = data["token"]
72
+ if data.get("database_url"):
73
+ self.database_url = data["database_url"]
74
+
75
+ def _call(self, method, path, body=None):
76
+ return self._client._do(method, f"/agents/v1/runs/{_q(self.id)}{path}", body, self.token)
77
+
78
+ def sql(self, query, params=None):
79
+ """One SQL statement in this run's world: ``{"columns", "rows", ...}``."""
80
+ return self._call("POST", "/sql", {"sql": query, "params": params or []})
81
+
82
+ def changes(self, limit=None):
83
+ return self._call("GET", f"/changes?limit={int(limit)}" if limit else "/changes")
84
+
85
+ def propose(self):
86
+ """``{"status": "merged"}``, ``{"status": "held", "reasons": [...]}`` or ``{"status": "conflict"}``."""
87
+ path = f"/agents/v1/runs/{_q(self.id)}/propose"
88
+ status, v = self._client._raw("POST", path, None, self.token)
89
+ if status == 409:
90
+ return {"status": "conflict", **(v if isinstance(v, dict) else {})}
91
+ if status >= 400:
92
+ raise _fail("POST", path, status, v)
93
+ self.status = v.get("status")
94
+ return v
95
+
96
+ def discard(self):
97
+ return self._call("POST", "/discard")
98
+
99
+ def refresh(self):
100
+ data = self._client._do("GET", f"/agents/v1/runs/{_q(self.id)}", None, self.token)
101
+ self._set({**data, "token": self.token, "database_url": self.database_url})
102
+ return self
103
+
104
+
105
+ class _RunScope:
106
+ def __init__(self, agents, intent, kw):
107
+ self._agents, self._intent, self._kw = agents, intent, kw
108
+ self.run = None
109
+ self.outcome = None
110
+
111
+ def __enter__(self):
112
+ self.run = self._agents.run(self._intent, **self._kw)
113
+ return self.run
114
+
115
+ def __exit__(self, kind, err, tb):
116
+ if kind is not None:
117
+ try:
118
+ self.run.discard()
119
+ except Exception: # noqa: BLE001
120
+ pass
121
+ return False
122
+ self.outcome = self.run.propose()
123
+ return False
124
+
125
+
126
+ class Agents:
127
+ def __init__(self, c):
128
+ self._c = c
129
+
130
+ def create(self, name, policy=None):
131
+ """Makes an agent (service key): its ``fba_`` token is shown once."""
132
+ return self._c._do("POST", "/agents/v1/agents", {"name": name, "policy": policy})
133
+
134
+ def list(self):
135
+ return self._c._do("GET", "/agents/v1/agents")
136
+
137
+ def run(self, intent, agent=None, ttl_seconds=None, meta=None, act_as=None, policy=None):
138
+ """Starts a run. With the service key, ``agent`` names whose run it is."""
139
+ body = {"intent": intent}
140
+ if agent:
141
+ body["agent"] = agent
142
+ if ttl_seconds:
143
+ body["ttl_seconds"] = ttl_seconds
144
+ if meta:
145
+ body["meta"] = meta
146
+ if act_as:
147
+ body["act_as"] = {"user_token": act_as} if isinstance(act_as, str) else act_as
148
+ if policy:
149
+ body["policy"] = policy
150
+ return Run(self._c, self._c._do("POST", "/agents/v1/runs", body))
151
+
152
+ def with_run(self, intent, **kw):
153
+ """``with client.agents.with_run("...") as run:`` proposes on success, discards on an error.
154
+ The scope's ``outcome`` holds what ``propose()`` answered."""
155
+ return _RunScope(self, intent, kw)
156
+
157
+ def get(self, run_id):
158
+ return Run(self._c, self._c._do("GET", f"/agents/v1/runs/{_q(run_id)}"))
159
+
160
+ def list_runs(self, status=None, limit=None):
161
+ q = {k: v for k, v in {"status": status, "limit": limit}.items() if v}
162
+ return self._c._do("GET", "/agents/v1/runs" + (f"?{urllib.parse.urlencode(q)}" if q else ""))
163
+
164
+ def approve(self, run_id):
165
+ return self._c._do("POST", f"/agents/v1/runs/{_q(run_id)}/approve")
166
+
167
+ def reject(self, run_id, reason=None):
168
+ return self._c._do("POST", f"/agents/v1/runs/{_q(run_id)}/reject", {"reason": reason})
169
+
170
+ def undo(self, run_id, skip_changed=False):
171
+ return self._c._do("POST", f"/agents/v1/runs/{_q(run_id)}/undo", {"skip_changed": bool(skip_changed)})
172
+
173
+
174
+ class Jobs:
175
+ def __init__(self, c):
176
+ self._c = c
177
+
178
+ def deploy(self, **fn):
179
+ """``deploy(name=..., files={"main.py": ...} or source=..., entry=..., env=..., agent=..., ...)``."""
180
+ return self._c._do("POST", "/jobs/v1/functions", fn)
181
+
182
+ def functions(self):
183
+ return self._c._do("GET", "/jobs/v1/functions")
184
+
185
+ def invoke(self, name, payload=None, delay_s=None, run_at=None, idempotency_key=None, wait=None):
186
+ body = {"payload": payload}
187
+ if delay_s is not None:
188
+ body["delay_s"] = delay_s
189
+ if run_at is not None:
190
+ body["run_at"] = int(run_at.timestamp() * 1000) if hasattr(run_at, "timestamp") else run_at
191
+ if idempotency_key:
192
+ body["idempotency_key"] = idempotency_key
193
+ path = f"/jobs/v1/functions/{_q(name)}/invoke" + (f"?wait={int(wait)}" if wait else "")
194
+ return self._c._do("POST", path, body, timeout=max(120, (wait or 0) + 30))
195
+
196
+ def get(self, job_id):
197
+ return self._c._do("GET", f"/jobs/v1/jobs/{_q(job_id)}")
198
+
199
+ def list(self, function=None, status=None, before=None, limit=None):
200
+ q = {k: v for k, v in {"function": function, "status": status, "before": before, "limit": limit}.items() if v}
201
+ return self._c._do("GET", "/jobs/v1/jobs" + (f"?{urllib.parse.urlencode(q)}" if q else ""))
202
+
203
+ def cancel(self, job_id):
204
+ return self._c._do("POST", f"/jobs/v1/jobs/{_q(job_id)}/cancel")
205
+
206
+ def retry(self, job_id):
207
+ return self._c._do("POST", f"/jobs/v1/jobs/{_q(job_id)}/retry")
208
+
209
+ def schedule(self, function, cron, payload=None):
210
+ return self._c._do("POST", "/jobs/v1/schedules", {"function": function, "cron": cron, "payload": payload})
211
+
212
+
213
+ class Client:
214
+ def __init__(self, url, key, headers=None):
215
+ if not url:
216
+ raise ValueError("create_client: the server's URL")
217
+ if not key:
218
+ raise ValueError("create_client: a key (service_role, or an agent's fba_ token)")
219
+ self.url = str(url).rstrip("/")
220
+ self.key = key
221
+ self._headers = headers or {}
222
+ self.agents = Agents(self)
223
+ self.jobs = Jobs(self)
224
+
225
+ def _raw(self, method, path, body=None, token=None, timeout=120):
226
+ return _request(self.url, token or self.key, method, path, body, self._headers, timeout)
227
+
228
+ def _do(self, method, path, body=None, token=None, timeout=120):
229
+ status, v = self._raw(method, path, body, token, timeout)
230
+ if status >= 400:
231
+ raise _fail(method, path, status, v)
232
+ return v
233
+
234
+ def request(self, method, path, body=None):
235
+ """Any route: ``request("GET", "/platform/v1/project")``."""
236
+ return self._do(method, path, body)
237
+
238
+ def supabase(self, **options):
239
+ """A supabase-py client for tables, auth, storage and realtime (``pip install supabase``)."""
240
+ from supabase import create_client as _sb # noqa: PLC0415
241
+
242
+ return _sb(self.url, self.key, **options)
243
+
244
+
245
+ def create_client(url, key, **options):
246
+ """A client for a Forkbase server."""
247
+ return Client(url, key, **options)
248
+
249
+
250
+ # ---- inside a job ------------------------------------------------------------------------------------------------
251
+
252
+
253
+ class Suspend(Exception):
254
+ """Raised by ``sleep`` to end this attempt until the sleep is over; Forkbase starts the job again then."""
255
+
256
+ def __init__(self, until):
257
+ super().__init__(f"sleeping until {until}")
258
+ self.until = until
259
+
260
+
261
+ def _in_job(what):
262
+ if not _env.get("FORKBASE_JOB_TOKEN"):
263
+ raise RuntimeError(f"{what}() works inside a Forkbase job")
264
+
265
+
266
+ def _self(method, path, body=None):
267
+ status, v = _request(_env["FORKBASE_URL"], _env["FORKBASE_JOB_TOKEN"], method, path, body)
268
+ if status >= 400 and status != 404:
269
+ raise _fail(method, path, status, v)
270
+ return status, v
271
+
272
+
273
+ def step(name, fn):
274
+ """Runs ``fn`` once per job: on a retry, a step that finished returns what it returned then. Results must be JSON."""
275
+ _in_job("step")
276
+ path = f"/jobs/v1/self/steps/{_q(name)}"
277
+ status, got = _self("GET", path)
278
+ if status == 200:
279
+ return got["result"]
280
+ result = fn()
281
+ _self("PUT", path, {"result": result})
282
+ return result
283
+
284
+
285
+ def sleep(name, seconds):
286
+ """Ends this attempt and starts the job again after ``seconds`` (no process waits meanwhile)."""
287
+ _in_job("sleep")
288
+ path = f"/jobs/v1/self/steps/{_q('sleep:' + name)}"
289
+ status, got = _self("GET", path)
290
+ if status == 200:
291
+ until = got["result"]["until"]
292
+ else:
293
+ until = int(time.time() * 1000) + int(max(0, seconds) * 1000)
294
+ _self("PUT", path, {"result": {"until": until}})
295
+ if time.time() * 1000 < until:
296
+ raise Suspend(until)
297
+
298
+
299
+ def sql(query, params=None):
300
+ """SQL in the job's world (functions deployed with an agent): ``{"columns", "rows", ...}``."""
301
+ run = _env.get("FORKBASE_RUN_ID")
302
+ if not run:
303
+ raise RuntimeError("sql() needs a function deployed with an agent: its jobs work in a world")
304
+ path = f"/agents/v1/runs/{_q(run)}/sql"
305
+ status, v = _request(_env["FORKBASE_URL"], _env.get("FORKBASE_RUN_TOKEN"), "POST", path, {"sql": query, "params": params or []})
306
+ if status >= 400:
307
+ raise _fail("POST", path, status, v)
308
+ return v
309
+
310
+
311
+ class Context:
312
+ """The job: its payload, ids, attempt, its world (or None), and the helpers above."""
313
+
314
+ def __init__(self, payload=None):
315
+ _in_job("context")
316
+ if payload is None and _env.get("FORKBASE_PAYLOAD_FILE"):
317
+ with open(_env["FORKBASE_PAYLOAD_FILE"], encoding="utf-8") as f:
318
+ payload = json.loads(f.read() or "null")
319
+ self.payload = payload
320
+ self.job = {"id": _env.get("FORKBASE_JOB_ID"), "attempt": int(_env.get("FORKBASE_ATTEMPT", "1")), "function": _env.get("FORKBASE_FUNCTION")}
321
+ self.run = (
322
+ {"id": _env["FORKBASE_RUN_ID"], "database_url": _env.get("DATABASE_URL"), "token": _env.get("FORKBASE_RUN_TOKEN")}
323
+ if _env.get("FORKBASE_RUN_ID")
324
+ else None
325
+ )
326
+ self.url = _env.get("FORKBASE_URL")
327
+ self.step = step
328
+ self.sleep = sleep
329
+ self.sql = sql
330
+
331
+
332
+ def context(payload=None):
333
+ return Context(payload)
334
+
335
+
336
+ def _limit_memory():
337
+ mb = int(_env.get("FORKBASE_MEMORY_MB", "0") or 0)
338
+ if mb <= 0:
339
+ return
340
+ try:
341
+ import resource, sys # noqa: E401, PLC0415
342
+
343
+ if sys.platform.startswith("linux"):
344
+ resource.setrlimit(resource.RLIMIT_AS, (mb * 1024 * 1024, mb * 1024 * 1024))
345
+ except Exception: # noqa: BLE001
346
+ pass
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: forkbase
3
+ Version: 0.1.0
4
+ Summary: Forkbase for Python: agents' runs (worlds, propose, review), jobs, and the job runtime's helpers.
5
+ License: FSL-1.1-ALv2
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Provides-Extra: supabase
10
+ Requires-Dist: supabase>=2; extra == "supabase"
11
+ Dynamic: license-file
12
+
13
+ # forkbase
14
+
15
+ Forkbase for Python (3.9+, standard library only): agents' runs (a world per run, propose, review) and jobs.
16
+ Tables, auth, storage and realtime speak Supabase's APIs: `client.supabase()` returns a supabase-py client for them
17
+ (`pip install "forkbase[supabase]"`).
18
+
19
+ ```python
20
+ from forkbase import create_client
21
+
22
+ fb = create_client("https://api.example.com", agent_token)
23
+ scope = fb.agents.with_run("close stale carts")
24
+ with scope as run:
25
+ run.sql("update carts set closed = true where updated_at < now() - interval '30 days'")
26
+ print(scope.outcome["status"]) # merged | held | conflict
27
+ ```
28
+
29
+ - `fb.agents`: `run(intent)`, `with_run(intent)` (proposes on success, discards on an exception), `get`, `list_runs`;
30
+ with the service key also `create`, `approve`, `reject`, `undo`.
31
+ - `run`: `sql(query, params)`, `changes()`, `propose()`, `discard()`, `refresh()`.
32
+ - `fb.jobs` (service key): `deploy`, `functions`, `invoke(name, payload, wait=..., delay_s=..., run_at=...,
33
+ idempotency_key=...)`, `get`, `list`, `cancel`, `retry`, `schedule`.
34
+ - Inside a job: `step(name, fn)`, `sleep(name, seconds)`, `sql(query, params)`, `context()`. The job runtime ships
35
+ this module, so functions import it without installing it.
36
+
37
+ Errors are `ForkbaseError` with `status`, `code` and `body`.
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ forkbase/__init__.py
5
+ forkbase.egg-info/PKG-INFO
6
+ forkbase.egg-info/SOURCES.txt
7
+ forkbase.egg-info/dependency_links.txt
8
+ forkbase.egg-info/requires.txt
9
+ forkbase.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+
2
+ [supabase]
3
+ supabase>=2
@@ -0,0 +1 @@
1
+ forkbase
@@ -0,0 +1,18 @@
1
+ [project]
2
+ name = "forkbase"
3
+ version = "0.1.0"
4
+ description = "Forkbase for Python: agents' runs (worlds, propose, review), jobs, and the job runtime's helpers."
5
+ readme = "README.md"
6
+ requires-python = ">=3.9"
7
+ license = { text = "FSL-1.1-ALv2" }
8
+ dependencies = []
9
+
10
+ [project.optional-dependencies]
11
+ supabase = ["supabase>=2"]
12
+
13
+ [build-system]
14
+ requires = ["setuptools>=61"]
15
+ build-backend = "setuptools.build_meta"
16
+
17
+ [tool.setuptools]
18
+ packages = ["forkbase"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+