EnergyVenom commited on
Commit
ccfcfd5
·
verified ·
1 Parent(s): 0ca03eb

Agent Studio: delivery mode pull (c0e2413)

Browse files
coworker/api/routes/agent_studio.py CHANGED
@@ -6,6 +6,8 @@ For the Fusion side (OAuth 2.0 client credentials, scope patchwise.invoke):
6
  POST /api/agent-studio/v1/cycles approved synthetic test data starts a test cycle
7
  GET /api/agent-studio/v1/cycles/{cycle_id} where the cycle is
8
  POST /api/agent-studio/v1/cycles/{cycle_id}/approval the person's start-testing decision, made in Fusion
 
 
9
 
10
  For Patchwise administrators (signed-in session): clients, cycles, callbacks sent, the release watch, the stand-in."""
11
  from __future__ import annotations
@@ -141,6 +143,27 @@ def approval(cycle_id: str, body: ApprovalIn, request: Request, client: dict = D
141
  _fail(e)
142
 
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  # ====================================================================== administration (signed-in admins)
145
  class ClientIn(BaseModel):
146
  name: str = Field(min_length=1, max_length=80)
@@ -187,13 +210,14 @@ class FusionDeliveryIn(BaseModel):
187
 
188
 
189
  class DeliveryIn(BaseModel):
190
- mode: Literal["url", "fusion"]
191
  fusion: FusionDeliveryIn | None = None
192
 
193
 
194
  @router.put("/agent-studio/clients/{client_id}/delivery")
195
  def set_delivery(client_id: str, body: DeliveryIn, request: Request, user: Principal = Depends(require("admin"))):
196
- """Where this client's events go: signed POSTs to its callback address, or straight to Oracle Fusion (invokeAsync)."""
 
197
  f = body.fusion.model_dump(exclude_none=True) if body.fusion else {}
198
  secret = f.pop("client_secret", None)
199
  try:
 
6
  POST /api/agent-studio/v1/cycles approved synthetic test data starts a test cycle
7
  GET /api/agent-studio/v1/cycles/{cycle_id} where the cycle is
8
  POST /api/agent-studio/v1/cycles/{cycle_id}/approval the person's start-testing decision, made in Fusion
9
+ POST /api/agent-studio/v1/events/claim delivery mode pull: pick up waiting events
10
+ POST /api/agent-studio/v1/events/ack confirm them
11
 
12
  For Patchwise administrators (signed-in session): clients, cycles, callbacks sent, the release watch, the stand-in."""
13
  from __future__ import annotations
 
143
  _fail(e)
144
 
145
 
146
+ class ClaimIn(BaseModel):
147
+ max: int = Field(5, ge=1, le=20, description="at most this many events")
148
+ cycle_id: str | None = Field(None, max_length=40, description="only this cycle's events")
149
+
150
+
151
+ class AckIn(BaseModel):
152
+ delivery_ids: list[str] = Field(min_length=1, max_length=50)
153
+
154
+
155
+ @router.post("/agent-studio/v1/events/claim", summary="Pick up waiting events (delivery mode pull)")
156
+ def claim_events(body: ClaimIn, request: Request, client: dict = Depends(agent_client)):
157
+ """The events Patchwise would have sent (scripts_ready, failures_need_review, results, stopped, patch_update), oldest
158
+ first. Confirm each with /events/ack; one not confirmed within confirm_within_s is handed out again."""
159
+ return _studio(request).claim(client["client_id"], body.max, body.cycle_id)
160
+
161
+
162
+ @router.post("/agent-studio/v1/events/ack", summary="Confirm picked-up events")
163
+ def ack_events(body: AckIn, request: Request, client: dict = Depends(agent_client)):
164
+ return _studio(request).ack(client["client_id"], body.delivery_ids)
165
+
166
+
167
  # ====================================================================== administration (signed-in admins)
168
  class ClientIn(BaseModel):
169
  name: str = Field(min_length=1, max_length=80)
 
210
 
211
 
212
  class DeliveryIn(BaseModel):
213
+ mode: Literal["url", "fusion", "pull"]
214
  fusion: FusionDeliveryIn | None = None
215
 
216
 
217
  @router.put("/agent-studio/clients/{client_id}/delivery")
218
  def set_delivery(client_id: str, body: DeliveryIn, request: Request, user: Principal = Depends(require("admin"))):
219
+ """Where this client's events go: signed POSTs to its callback address, straight to Oracle Fusion (invokeAsync), or
220
+ nowhere until the Fusion workflow picks them up (pull)."""
221
  f = body.fusion.model_dump(exclude_none=True) if body.fusion else {}
222
  secret = f.pop("client_secret", None)
223
  try:
coworker/platform/agent_studio.py CHANGED
@@ -70,6 +70,11 @@ FUSION_DEFAULTS = {"workflow_code": "PATCH_TEST_CALLBACK_V3_7", "invocation_mode
70
  "conversational": True, "scope": ""}
71
  _WF_CODE = re.compile(r"^[A-Z][A-Z0-9_]{1,79}$")
72
  MAX_PAYLOAD_PARAM = 60_000
 
 
 
 
 
73
 
74
 
75
  def fusion_envelope(f: dict, source: str, delivery_id: str, payload: dict) -> dict:
@@ -205,7 +210,7 @@ class AgentStudio:
205
 
206
  def ensure_from_env(self) -> list[str]:
207
  """Clients defined by the server's secrets (agent_studio.bootstrap_clients, i.e. FPT_SECRET_AGENT_STUDIO_BOOTSTRAP_CLIENTS):
208
- a JSON list of {client_id, client_secret, name, callback_url?, release_watch_url?, signing_key?}. Each exists after
209
  every start with that id and secret, so the Fusion tool keeps working on a server without saved state. A client an
210
  admin revoked stays revoked. Returns the ids made or refreshed."""
211
  raw = self.svc.vault.get("agent_studio.bootstrap_clients") or ""
@@ -226,6 +231,8 @@ class AgentStudio:
226
  if row and row.get("revoked_at"):
227
  continue
228
  cb, rw = it.get("callback_url"), it.get("release_watch_url")
 
 
229
  if row:
230
  self.db.update("agent_clients", "client_id", cid, secret_hash=_hash(secret), name=str(it.get("name") or row["name"])[:80])
231
  else:
@@ -233,6 +240,8 @@ class AgentStudio:
233
  "secret_hash": _hash(secret), "callback_url": _check_url(cb, "callback address"),
234
  "release_watch_url": _check_url(rw, "release watch address"),
235
  "created_by": "server settings", "created_at": now_iso()})
 
 
236
  if it.get("signing_key"):
237
  self.svc.vault.set(f"agent_studio.{cid}.signing", str(it["signing_key"]))
238
  elif not self.svc.vault.get(f"agent_studio.{cid}.signing"):
@@ -268,12 +277,13 @@ class AgentStudio:
268
  # ------------------------------------------------------------ delivery: a signed POST, or straight to Oracle Fusion
269
  def set_delivery(self, client_id: str, actor: str, mode: str, fusion: dict | None = None, secret: str | None = None) -> dict:
270
  """mode "url": signed POSTs to the callback address (a relay, or any receiver). mode "fusion": Patchwise starts
271
- the callback workflow itself (invokeAsync), signed in with the client's OCI IAM confidential app."""
 
272
  self.client(client_id)
273
- if mode not in ("url", "fusion"):
274
- raise AgentStudioError("BAD_DELIVERY", "delivery is url or fusion")
275
- if mode == "url":
276
- self.db.update("agent_clients", "client_id", client_id, delivery="url")
277
  else:
278
  f = {**FUSION_DEFAULTS, **{k: v for k, v in (fusion or {}).items() if v not in (None, "")}}
279
  f["base_url"] = _check_url(str(f.get("base_url") or "").rstrip("/"), "Fusion address") or ""
@@ -355,6 +365,9 @@ class AgentStudio:
355
  return {"ok": ok, "detail": detail}
356
 
357
  def _target(self, client_id: str, url: str | None) -> str | None:
 
 
 
358
  got = self._fusion(client_id)
359
  return invoke_url(got[0]) if got else url
360
 
@@ -526,8 +539,8 @@ class AgentStudio:
526
  def deliver_due(self) -> int:
527
  """Send callbacks that are due; a failure is tried again later (1, 2, 4, 8, 16 minutes), six tries in all."""
528
  sent = 0
529
- for d in self.db.q("SELECT * FROM agent_callbacks WHERE delivered_at IS NULL AND attempts < ? AND next_at <= ? ORDER BY id LIMIT 20",
530
- (MAX_ATTEMPTS, now_iso())):
531
  key = self.svc.vault.get(f"agent_studio.{d['client_id']}.signing") or ""
532
  payload = _j(d["payload"])
533
  body = json.dumps(payload).encode()
@@ -560,6 +573,33 @@ class AgentStudio:
560
  self.db.update("agent_callbacks", "id", d["id"], attempts=n, status_code=code, error=err, next_at=_later(60 * 2 ** (n - 1)))
561
  return sent
562
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
563
  def deliveries(self, limit: int = 50) -> list[dict]:
564
  return [{k: (_j(v) if k == "payload" else v) for k, v in r.items()}
565
  for r in self.db.q("SELECT * FROM agent_callbacks ORDER BY id DESC LIMIT ?", (limit,))]
@@ -657,7 +697,7 @@ class AgentStudio:
657
  found.setdefault(p["release"].upper(), []).extend(self.release_item(c, code, p["release"]) for c in new)
658
  sent = 0
659
  for rel, items in found.items():
660
- for cl in self.db.q("SELECT * FROM agent_clients WHERE revoked_at IS NULL AND (release_watch_url IS NOT NULL OR delivery='fusion')"):
661
  if self.queue(cl["client_id"], cl["release_watch_url"], "patch_update", {"release": rel, "changes": items,
662
  "count": len(items)}):
663
  sent += 1
@@ -716,7 +756,7 @@ class Courier:
716
  self.studio.deliver_due()
717
  if self.watch_s and time.monotonic() - self._last_watch > self.watch_s:
718
  self._last_watch = time.monotonic()
719
- if self.studio.db.one("SELECT 1 AS x FROM agent_clients WHERE revoked_at IS NULL AND (release_watch_url IS NOT NULL OR delivery='fusion')"):
720
  self.studio.check_releases()
721
 
722
  def _loop(self) -> None:
 
70
  "conversational": True, "scope": ""}
71
  _WF_CODE = re.compile(r"^[A-Z][A-Z0-9_]{1,79}$")
72
  MAX_PAYLOAD_PARAM = 60_000
73
+ # Delivery "pull": nothing is sent; the Fusion workflow picks its events up with its own OAuth client (no OCI IAM app
74
+ # needed) and confirms each. An event not confirmed within LEASE_S is handed out again, at most MAX_PICKUPS times.
75
+ PULL = "pull:"
76
+ LEASE_S = 300
77
+ MAX_PICKUPS = 20
78
 
79
 
80
  def fusion_envelope(f: dict, source: str, delivery_id: str, payload: dict) -> dict:
 
210
 
211
  def ensure_from_env(self) -> list[str]:
212
  """Clients defined by the server's secrets (agent_studio.bootstrap_clients, i.e. FPT_SECRET_AGENT_STUDIO_BOOTSTRAP_CLIENTS):
213
+ a JSON list of {client_id, client_secret, name, callback_url?, release_watch_url?, signing_key?, delivery?: "pull"}. Each exists after
214
  every start with that id and secret, so the Fusion tool keeps working on a server without saved state. A client an
215
  admin revoked stays revoked. Returns the ids made or refreshed."""
216
  raw = self.svc.vault.get("agent_studio.bootstrap_clients") or ""
 
231
  if row and row.get("revoked_at"):
232
  continue
233
  cb, rw = it.get("callback_url"), it.get("release_watch_url")
234
+ if it.get("delivery") not in (None, "pull"):
235
+ log.warning("a bootstrap client's delivery can only be pull (the others need an admin): ignored")
236
  if row:
237
  self.db.update("agent_clients", "client_id", cid, secret_hash=_hash(secret), name=str(it.get("name") or row["name"])[:80])
238
  else:
 
240
  "secret_hash": _hash(secret), "callback_url": _check_url(cb, "callback address"),
241
  "release_watch_url": _check_url(rw, "release watch address"),
242
  "created_by": "server settings", "created_at": now_iso()})
243
+ if it.get("delivery") == "pull":
244
+ self.db.update("agent_clients", "client_id", cid, delivery="pull")
245
  if it.get("signing_key"):
246
  self.svc.vault.set(f"agent_studio.{cid}.signing", str(it["signing_key"]))
247
  elif not self.svc.vault.get(f"agent_studio.{cid}.signing"):
 
277
  # ------------------------------------------------------------ delivery: a signed POST, or straight to Oracle Fusion
278
  def set_delivery(self, client_id: str, actor: str, mode: str, fusion: dict | None = None, secret: str | None = None) -> dict:
279
  """mode "url": signed POSTs to the callback address (a relay, or any receiver). mode "fusion": Patchwise starts
280
+ the callback workflow itself (invokeAsync), signed in with the client's OCI IAM confidential app. mode "pull":
281
+ nothing is sent; the Fusion workflow picks its events up (claim, then ack)."""
282
  self.client(client_id)
283
+ if mode not in ("url", "fusion", "pull"):
284
+ raise AgentStudioError("BAD_DELIVERY", "delivery is url, fusion or pull")
285
+ if mode in ("url", "pull"):
286
+ self.db.update("agent_clients", "client_id", client_id, delivery=mode)
287
  else:
288
  f = {**FUSION_DEFAULTS, **{k: v for k, v in (fusion or {}).items() if v not in (None, "")}}
289
  f["base_url"] = _check_url(str(f.get("base_url") or "").rstrip("/"), "Fusion address") or ""
 
365
  return {"ok": ok, "detail": detail}
366
 
367
  def _target(self, client_id: str, url: str | None) -> str | None:
368
+ r = self.db.one("SELECT delivery FROM agent_clients WHERE client_id=?", (client_id,))
369
+ if r and r.get("delivery") == "pull":
370
+ return PULL
371
  got = self._fusion(client_id)
372
  return invoke_url(got[0]) if got else url
373
 
 
539
  def deliver_due(self) -> int:
540
  """Send callbacks that are due; a failure is tried again later (1, 2, 4, 8, 16 minutes), six tries in all."""
541
  sent = 0
542
+ for d in self.db.q("SELECT * FROM agent_callbacks WHERE delivered_at IS NULL AND attempts < ? AND next_at <= ? AND url <> ? "
543
+ "ORDER BY id LIMIT 20", (MAX_ATTEMPTS, now_iso(), PULL)):
544
  key = self.svc.vault.get(f"agent_studio.{d['client_id']}.signing") or ""
545
  payload = _j(d["payload"])
546
  body = json.dumps(payload).encode()
 
573
  self.db.update("agent_callbacks", "id", d["id"], attempts=n, status_code=code, error=err, next_at=_later(60 * 2 ** (n - 1)))
574
  return sent
575
 
576
+ def claim(self, client_id: str, limit: int = 5, cycle_id: str | None = None) -> dict:
577
+ """The pull client's waiting events, oldest first (one cycle's, when cycle_id is given). Each is held for
578
+ LEASE_S; one not confirmed with ack() by then is handed out again."""
579
+ limit = max(1, min(int(limit or 5), 20))
580
+ where, args = "client_id=? AND url=? AND delivered_at IS NULL AND attempts < ? AND next_at <= ?", [client_id, PULL, MAX_PICKUPS, now_iso()]
581
+ if cycle_id:
582
+ where, args = where + " AND cycle_id=?", args + [cycle_id]
583
+ rows = self.db.q(f"SELECT * FROM agent_callbacks WHERE {where} ORDER BY id LIMIT ?", (*args, limit + 1))
584
+ out = []
585
+ for d in rows[:limit]:
586
+ self.db.update("agent_callbacks", "id", d["id"], attempts=d["attempts"] + 1, next_at=_later(LEASE_S))
587
+ out.append({**_j(d["payload"]), "delivery_id": d["delivery_id"], "pickup": d["attempts"] + 1})
588
+ if out:
589
+ self.db.update("agent_clients", "client_id", client_id, last_used_at=now_iso())
590
+ return {"events": out, "count": len(out), "more": len(rows) > limit, "confirm_within_s": LEASE_S}
591
+
592
+ def ack(self, client_id: str, delivery_ids: list[str]) -> dict:
593
+ """Confirms picked-up events: they are not handed out again. Ids of other clients or unknown ids are ignored."""
594
+ done = []
595
+ for did in dict.fromkeys(str(x) for x in delivery_ids or []):
596
+ d = self.db.one("SELECT id FROM agent_callbacks WHERE delivery_id=? AND client_id=? AND url=? AND delivered_at IS NULL",
597
+ (did, client_id, PULL))
598
+ if d:
599
+ self.db.update("agent_callbacks", "id", d["id"], delivered_at=now_iso(), status_code=200, error=None)
600
+ done.append(did)
601
+ return {"confirmed": done, "count": len(done)}
602
+
603
  def deliveries(self, limit: int = 50) -> list[dict]:
604
  return [{k: (_j(v) if k == "payload" else v) for k, v in r.items()}
605
  for r in self.db.q("SELECT * FROM agent_callbacks ORDER BY id DESC LIMIT ?", (limit,))]
 
697
  found.setdefault(p["release"].upper(), []).extend(self.release_item(c, code, p["release"]) for c in new)
698
  sent = 0
699
  for rel, items in found.items():
700
+ for cl in self.db.q("SELECT * FROM agent_clients WHERE revoked_at IS NULL AND (release_watch_url IS NOT NULL OR delivery IN ('fusion','pull'))"):
701
  if self.queue(cl["client_id"], cl["release_watch_url"], "patch_update", {"release": rel, "changes": items,
702
  "count": len(items)}):
703
  sent += 1
 
756
  self.studio.deliver_due()
757
  if self.watch_s and time.monotonic() - self._last_watch > self.watch_s:
758
  self._last_watch = time.monotonic()
759
+ if self.studio.db.one("SELECT 1 AS x FROM agent_clients WHERE revoked_at IS NULL AND (release_watch_url IS NOT NULL OR delivery IN ('fusion','pull'))"):
760
  self.studio.check_releases()
761
 
762
  def _loop(self) -> None:
coworker/tests/test_agent_studio_pull.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Delivery mode pull: nothing is sent; the Fusion workflow (a While Loop with a Wait) picks its events up with its own
2
+ OAuth client and confirms each. No OCI IAM app is needed. An event not confirmed is handed out again; one client never
3
+ sees another's events."""
4
+ from __future__ import annotations
5
+
6
+ import unittest
7
+
8
+ from coworker.platform import agent_studio as A
9
+ from coworker.platform.agent_studio import AgentStudio
10
+ from coworker.tests.test_ai_scenarios import fusion_app
11
+
12
+
13
+ class TestPullDelivery(unittest.TestCase):
14
+ @classmethod
15
+ def setUpClass(cls):
16
+ cls.app, cls.c, cls.svc, cls.h, _ = fusion_app()
17
+ cls.studio = AgentStudio(cls.svc)
18
+ cls.clients = {}
19
+ for name in ("pull", "other"):
20
+ r = cls.c.post("/api/agent-studio/clients", json={"name": name}, headers=cls.h["admin"])
21
+ assert r.status_code == 201, r.text
22
+ cls.clients[name] = r.json()
23
+ for name in ("pull", "other"):
24
+ r = cls.c.put(f"/api/agent-studio/clients/{cls.clients[name]['client_id']}/delivery", json={"mode": "pull"}, headers=cls.h["admin"])
25
+ assert r.status_code == 200 and r.json()["delivery"] == "pull", r.text
26
+
27
+ def auth(self, name="pull"):
28
+ c = self.clients[name]
29
+ t = self.c.post("/oauth/token", data={"grant_type": "client_credentials", "client_id": c["client_id"],
30
+ "client_secret": c["client_secret"], "scope": "patchwise.invoke"})
31
+ assert t.status_code == 200, t.text
32
+ return {"Authorization": "Bearer " + t.json()["access_token"]}
33
+
34
+ def claim(self, name="pull", **body):
35
+ r = self.c.post("/api/agent-studio/v1/events/claim", json=body, headers=self.auth(name))
36
+ self.assertEqual(r.status_code, 200, r.text)
37
+ return r.json()
38
+
39
+ def ack(self, ids, name="pull"):
40
+ return self.c.post("/api/agent-studio/v1/events/ack", json={"delivery_ids": ids}, headers=self.auth(name)).json()
41
+
42
+ def test_a_events_wait_are_picked_up_once_and_confirmed(self):
43
+ cid = self.clients["pull"]["client_id"]
44
+ d1 = self.studio.queue(cid, None, "scripts_ready", {"count": 3}, "cyc_pull_a")
45
+ d2 = self.studio.queue(cid, None, "results", {"passed": 3}, "cyc_pull_b")
46
+ self.assertEqual(self.studio.deliver_due(), 0) # nothing is pushed
47
+ got = self.claim(cycle_id="cyc_pull_a")
48
+ self.assertEqual([(e["delivery_id"], e["event"], e["count"]) for e in got["events"]], [(d1, "scripts_ready", 3)])
49
+ self.assertEqual(self.claim(cycle_id="cyc_pull_a")["count"], 0) # held while Fusion handles it
50
+ self.assertEqual(self.ack([d1, "dlv_unknown"])["confirmed"], [d1])
51
+ self.assertEqual(self.ack([d1])["count"], 0) # confirming twice is harmless
52
+ self.assertEqual([e["delivery_id"] for e in self.claim()["events"]], [d2])
53
+ self.ack([d2])
54
+
55
+ def test_b_an_unconfirmed_event_comes_back(self):
56
+ cid = self.clients["pull"]["client_id"]
57
+ did = self.studio.queue(cid, None, "stopped", {"status": "failed"}, "cyc_pull_c")
58
+ self.assertEqual(self.claim(cycle_id="cyc_pull_c")["events"][0]["pickup"], 1)
59
+ self.svc.db.q("UPDATE agent_callbacks SET next_at=? WHERE delivery_id=?", ("2000-01-01T00:00:00+00:00", did))
60
+ again = self.claim(cycle_id="cyc_pull_c")["events"]
61
+ self.assertEqual((again[0]["delivery_id"], again[0]["pickup"]), (did, 2))
62
+ self.ack([did])
63
+
64
+ def test_c_a_client_sees_and_confirms_only_its_own_events(self):
65
+ did = self.studio.queue(self.clients["pull"]["client_id"], None, "results", {}, "cyc_pull_d")
66
+ self.assertEqual(self.claim("other")["count"], 0)
67
+ self.assertEqual(self.ack([did], "other")["count"], 0)
68
+ self.assertEqual(self.claim(cycle_id="cyc_pull_d")["count"], 1)
69
+ self.ack([did])
70
+
71
+ def test_d_claim_needs_the_client_token_and_limits_are_kept(self):
72
+ self.assertEqual(self.c.post("/api/agent-studio/v1/events/claim", json={}).status_code, 401)
73
+ self.assertEqual(self.c.post("/api/agent-studio/v1/events/claim", json={"max": 50}, headers=self.auth()).status_code, 422)
74
+ cid = self.clients["pull"]["client_id"]
75
+ ids = [self.studio.queue(cid, None, "results", {"n": i}, "cyc_pull_e") for i in range(3)]
76
+ got = self.claim(cycle_id="cyc_pull_e", max=2)
77
+ self.assertEqual((got["count"], got["more"], got["confirm_within_s"]), (2, True, A.LEASE_S))
78
+ self.ack(ids)
79
+
80
+ def test_e_bootstrap_can_set_pull(self):
81
+ import json
82
+ import os
83
+ from unittest import mock
84
+ cid, secret = "pwc_00112233445566cc", "pws_" + "p" * 40
85
+ with mock.patch.dict(os.environ, {"FPT_SECRET_AGENT_STUDIO_BOOTSTRAP_CLIENTS": json.dumps([{"client_id": cid, "client_secret": secret, "delivery": "pull"}])}):
86
+ self.assertEqual(self.studio.ensure_from_env(), [cid])
87
+ self.assertEqual(self.studio.client(cid)["delivery"], "pull")
88
+
89
+
90
+ if __name__ == "__main__":
91
+ unittest.main()
docs/AGENT_STUDIO.md CHANGED
@@ -152,6 +152,22 @@ A 401 refreshes the token once. **Test sign-in** checks the app without starting
152
  shown under **Callbacks**. The API is `PUT /api/agent-studio/clients/{id}/delivery` and
153
  `POST /api/agent-studio/clients/{id}/delivery/test` (admin).
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  ### Callback address (a relay or any receiver)
156
 
157
  Callbacks are sent with `POST` to the callback address, as `Content-Type: application/json`, with these headers:
 
152
  shown under **Callbacks**. The API is `PUT /api/agent-studio/clients/{id}/delivery` and
153
  `POST /api/agent-studio/clients/{id}/delivery/test` (admin).
154
 
155
+ ### Fusion picks them up (pull; no OCI IAM app)
156
+
157
+ Nothing is sent. Use this mode when nobody can create a confidential app in the pod's identity domain, for example on
158
+ a demo pod. The Fusion workflow asks for its events with the same OAuth client it uses for every other call, usually
159
+ in a **While Loop** with a **Wait** of 2 to 5 minutes after `createCycle`.
160
+
161
+ - **Pick up:** `POST /api/agent-studio/v1/events/claim` with `{"cycle_id": "cyc_…", "max": 5}`. Both fields are
162
+ optional. The answer is `{events, count, more, confirm_within_s}`. Each event is the callback body below, plus
163
+ `delivery_id` and `pickup` (how many times it was handed out).
164
+ - **Confirm:** `POST /api/agent-studio/v1/events/ack` with `{"delivery_ids": ["dlv_…"]}`. A confirmed event is not
165
+ handed out again.
166
+
167
+ An event that isn't confirmed within 5 minutes is handed out again, up to 20 times. A client only sees and confirms
168
+ its own events. To keep this mode on a server without saved state, add `"delivery": "pull"` to the client in
169
+ `FPT_SECRET_AGENT_STUDIO_BOOTSTRAP_CLIENTS`.
170
+
171
  ### Callback address (a relay or any receiver)
172
 
173
  Callbacks are sent with `POST` to the callback address, as `Content-Type: application/json`, with these headers:
web/src/api/openapi.json CHANGED
@@ -1,6 +1,24 @@
1
  {
2
  "components": {
3
  "schemas": {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  "ApprovalIn": {
5
  "properties": {
6
  "approved_by": {
@@ -395,6 +413,33 @@
395
  "title": "ChatContext",
396
  "type": "object"
397
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  "ClientIn": {
399
  "properties": {
400
  "callback_url": {
@@ -798,7 +843,8 @@
798
  "mode": {
799
  "enum": [
800
  "url",
801
- "fusion"
 
802
  ],
803
  "title": "Mode",
804
  "type": "string"
@@ -4982,7 +5028,7 @@
4982
  },
4983
  "/api/agent-studio/clients/{client_id}/delivery": {
4984
  "put": {
4985
- "description": "Where this client's events go: signed POSTs to its callback address, or straight to Oracle Fusion (invokeAsync).",
4986
  "operationId": "set_delivery_api_agent_studio_clients__client_id__delivery_put",
4987
  "parameters": [
4988
  {
@@ -5337,6 +5383,85 @@
5337
  ]
5338
  }
5339
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5340
  "/api/agent-studio/v1/test-data/check": {
5341
  "post": {
5342
  "operationId": "check_test_data_api_agent_studio_v1_test_data_check_post",
 
1
  {
2
  "components": {
3
  "schemas": {
4
+ "AckIn": {
5
+ "properties": {
6
+ "delivery_ids": {
7
+ "items": {
8
+ "type": "string"
9
+ },
10
+ "maxItems": 50,
11
+ "minItems": 1,
12
+ "title": "Delivery Ids",
13
+ "type": "array"
14
+ }
15
+ },
16
+ "required": [
17
+ "delivery_ids"
18
+ ],
19
+ "title": "AckIn",
20
+ "type": "object"
21
+ },
22
  "ApprovalIn": {
23
  "properties": {
24
  "approved_by": {
 
413
  "title": "ChatContext",
414
  "type": "object"
415
  },
416
+ "ClaimIn": {
417
+ "properties": {
418
+ "cycle_id": {
419
+ "anyOf": [
420
+ {
421
+ "maxLength": 40,
422
+ "type": "string"
423
+ },
424
+ {
425
+ "type": "null"
426
+ }
427
+ ],
428
+ "description": "only this cycle's events",
429
+ "title": "Cycle Id"
430
+ },
431
+ "max": {
432
+ "default": 5,
433
+ "description": "at most this many events",
434
+ "maximum": 20.0,
435
+ "minimum": 1.0,
436
+ "title": "Max",
437
+ "type": "integer"
438
+ }
439
+ },
440
+ "title": "ClaimIn",
441
+ "type": "object"
442
+ },
443
  "ClientIn": {
444
  "properties": {
445
  "callback_url": {
 
843
  "mode": {
844
  "enum": [
845
  "url",
846
+ "fusion",
847
+ "pull"
848
  ],
849
  "title": "Mode",
850
  "type": "string"
 
5028
  },
5029
  "/api/agent-studio/clients/{client_id}/delivery": {
5030
  "put": {
5031
+ "description": "Where this client's events go: signed POSTs to its callback address, straight to Oracle Fusion (invokeAsync), or\nnowhere until the Fusion workflow picks them up (pull).",
5032
  "operationId": "set_delivery_api_agent_studio_clients__client_id__delivery_put",
5033
  "parameters": [
5034
  {
 
5383
  ]
5384
  }
5385
  },
5386
+ "/api/agent-studio/v1/events/ack": {
5387
+ "post": {
5388
+ "operationId": "ack_events_api_agent_studio_v1_events_ack_post",
5389
+ "requestBody": {
5390
+ "content": {
5391
+ "application/json": {
5392
+ "schema": {
5393
+ "$ref": "#/components/schemas/AckIn"
5394
+ }
5395
+ }
5396
+ },
5397
+ "required": true
5398
+ },
5399
+ "responses": {
5400
+ "200": {
5401
+ "content": {
5402
+ "application/json": {
5403
+ "schema": {}
5404
+ }
5405
+ },
5406
+ "description": "Successful Response"
5407
+ },
5408
+ "422": {
5409
+ "content": {
5410
+ "application/json": {
5411
+ "schema": {
5412
+ "$ref": "#/components/schemas/HTTPValidationError"
5413
+ }
5414
+ }
5415
+ },
5416
+ "description": "Validation Error"
5417
+ }
5418
+ },
5419
+ "summary": "Confirm picked-up events",
5420
+ "tags": [
5421
+ "agent-studio"
5422
+ ]
5423
+ }
5424
+ },
5425
+ "/api/agent-studio/v1/events/claim": {
5426
+ "post": {
5427
+ "description": "The events Patchwise would have sent (scripts_ready, failures_need_review, results, stopped, patch_update), oldest\nfirst. Confirm each with /events/ack; one not confirmed within confirm_within_s is handed out again.",
5428
+ "operationId": "claim_events_api_agent_studio_v1_events_claim_post",
5429
+ "requestBody": {
5430
+ "content": {
5431
+ "application/json": {
5432
+ "schema": {
5433
+ "$ref": "#/components/schemas/ClaimIn"
5434
+ }
5435
+ }
5436
+ },
5437
+ "required": true
5438
+ },
5439
+ "responses": {
5440
+ "200": {
5441
+ "content": {
5442
+ "application/json": {
5443
+ "schema": {}
5444
+ }
5445
+ },
5446
+ "description": "Successful Response"
5447
+ },
5448
+ "422": {
5449
+ "content": {
5450
+ "application/json": {
5451
+ "schema": {
5452
+ "$ref": "#/components/schemas/HTTPValidationError"
5453
+ }
5454
+ }
5455
+ },
5456
+ "description": "Validation Error"
5457
+ }
5458
+ },
5459
+ "summary": "Pick up waiting events (delivery mode pull)",
5460
+ "tags": [
5461
+ "agent-studio"
5462
+ ]
5463
+ }
5464
+ },
5465
  "/api/agent-studio/v1/test-data/check": {
5466
  "post": {
5467
  "operationId": "check_test_data_api_agent_studio_v1_test_data_check_post",
web/src/api/schema.d.ts CHANGED
@@ -118,7 +118,8 @@ export interface paths {
118
  get?: never;
119
  /**
120
  * Set Delivery
121
- * @description Where this client's events go: signed POSTs to its callback address, or straight to Oracle Fusion (invokeAsync).
 
122
  */
123
  put: operations["set_delivery_api_agent_studio_clients__client_id__delivery_put"];
124
  post?: never;
@@ -304,6 +305,44 @@ export interface paths {
304
  patch?: never;
305
  trace?: never;
306
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  "/api/agent-studio/v1/test-data/check": {
308
  parameters: {
309
  query?: never;
@@ -2636,6 +2675,11 @@ export interface paths {
2636
  export type webhooks = Record<string, never>;
2637
  export interface components {
2638
  schemas: {
 
 
 
 
 
2639
  /** ApprovalIn */
2640
  ApprovalIn: {
2641
  /**
@@ -2764,6 +2808,20 @@ export interface components {
2764
  /** Tz Offset */
2765
  tz_offset?: number | null;
2766
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2767
  /** ClientIn */
2768
  ClientIn: {
2769
  /** Callback Url */
@@ -2901,7 +2959,7 @@ export interface components {
2901
  * Mode
2902
  * @enum {string}
2903
  */
2904
- mode: "url" | "fusion";
2905
  };
2906
  /** EvalIn */
2907
  EvalIn: {
@@ -4664,6 +4722,72 @@ export interface operations {
4664
  };
4665
  };
4666
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4667
  check_test_data_api_agent_studio_v1_test_data_check_post: {
4668
  parameters: {
4669
  query?: never;
 
118
  get?: never;
119
  /**
120
  * Set Delivery
121
+ * @description Where this client's events go: signed POSTs to its callback address, straight to Oracle Fusion (invokeAsync), or
122
+ * nowhere until the Fusion workflow picks them up (pull).
123
  */
124
  put: operations["set_delivery_api_agent_studio_clients__client_id__delivery_put"];
125
  post?: never;
 
305
  patch?: never;
306
  trace?: never;
307
  };
308
+ "/api/agent-studio/v1/events/ack": {
309
+ parameters: {
310
+ query?: never;
311
+ header?: never;
312
+ path?: never;
313
+ cookie?: never;
314
+ };
315
+ get?: never;
316
+ put?: never;
317
+ /** Confirm picked-up events */
318
+ post: operations["ack_events_api_agent_studio_v1_events_ack_post"];
319
+ delete?: never;
320
+ options?: never;
321
+ head?: never;
322
+ patch?: never;
323
+ trace?: never;
324
+ };
325
+ "/api/agent-studio/v1/events/claim": {
326
+ parameters: {
327
+ query?: never;
328
+ header?: never;
329
+ path?: never;
330
+ cookie?: never;
331
+ };
332
+ get?: never;
333
+ put?: never;
334
+ /**
335
+ * Pick up waiting events (delivery mode pull)
336
+ * @description The events Patchwise would have sent (scripts_ready, failures_need_review, results, stopped, patch_update), oldest
337
+ * first. Confirm each with /events/ack; one not confirmed within confirm_within_s is handed out again.
338
+ */
339
+ post: operations["claim_events_api_agent_studio_v1_events_claim_post"];
340
+ delete?: never;
341
+ options?: never;
342
+ head?: never;
343
+ patch?: never;
344
+ trace?: never;
345
+ };
346
  "/api/agent-studio/v1/test-data/check": {
347
  parameters: {
348
  query?: never;
 
2675
  export type webhooks = Record<string, never>;
2676
  export interface components {
2677
  schemas: {
2678
+ /** AckIn */
2679
+ AckIn: {
2680
+ /** Delivery Ids */
2681
+ delivery_ids: string[];
2682
+ };
2683
  /** ApprovalIn */
2684
  ApprovalIn: {
2685
  /**
 
2808
  /** Tz Offset */
2809
  tz_offset?: number | null;
2810
  };
2811
+ /** ClaimIn */
2812
+ ClaimIn: {
2813
+ /**
2814
+ * Cycle Id
2815
+ * @description only this cycle's events
2816
+ */
2817
+ cycle_id?: string | null;
2818
+ /**
2819
+ * Max
2820
+ * @description at most this many events
2821
+ * @default 5
2822
+ */
2823
+ max: number;
2824
+ };
2825
  /** ClientIn */
2826
  ClientIn: {
2827
  /** Callback Url */
 
2959
  * Mode
2960
  * @enum {string}
2961
  */
2962
+ mode: "url" | "fusion" | "pull";
2963
  };
2964
  /** EvalIn */
2965
  EvalIn: {
 
4722
  };
4723
  };
4724
  };
4725
+ ack_events_api_agent_studio_v1_events_ack_post: {
4726
+ parameters: {
4727
+ query?: never;
4728
+ header?: never;
4729
+ path?: never;
4730
+ cookie?: never;
4731
+ };
4732
+ requestBody: {
4733
+ content: {
4734
+ "application/json": components["schemas"]["AckIn"];
4735
+ };
4736
+ };
4737
+ responses: {
4738
+ /** @description Successful Response */
4739
+ 200: {
4740
+ headers: {
4741
+ [name: string]: unknown;
4742
+ };
4743
+ content: {
4744
+ "application/json": unknown;
4745
+ };
4746
+ };
4747
+ /** @description Validation Error */
4748
+ 422: {
4749
+ headers: {
4750
+ [name: string]: unknown;
4751
+ };
4752
+ content: {
4753
+ "application/json": components["schemas"]["HTTPValidationError"];
4754
+ };
4755
+ };
4756
+ };
4757
+ };
4758
+ claim_events_api_agent_studio_v1_events_claim_post: {
4759
+ parameters: {
4760
+ query?: never;
4761
+ header?: never;
4762
+ path?: never;
4763
+ cookie?: never;
4764
+ };
4765
+ requestBody: {
4766
+ content: {
4767
+ "application/json": components["schemas"]["ClaimIn"];
4768
+ };
4769
+ };
4770
+ responses: {
4771
+ /** @description Successful Response */
4772
+ 200: {
4773
+ headers: {
4774
+ [name: string]: unknown;
4775
+ };
4776
+ content: {
4777
+ "application/json": unknown;
4778
+ };
4779
+ };
4780
+ /** @description Validation Error */
4781
+ 422: {
4782
+ headers: {
4783
+ [name: string]: unknown;
4784
+ };
4785
+ content: {
4786
+ "application/json": components["schemas"]["HTTPValidationError"];
4787
+ };
4788
+ };
4789
+ };
4790
+ };
4791
  check_test_data_api_agent_studio_v1_test_data_check_post: {
4792
  parameters: {
4793
  query?: never;
web/src/pages/AgentStudioPage.tsx CHANGED
@@ -8,7 +8,7 @@ import { ErrorAlert, fmtTs, PageHeader } from '../components/common';
8
  import './agent-studio.css';
9
 
10
  interface FusionDelivery { base_url: string; token_url: string; client_id: string; scope: string; workflow_code: string; invocation_mode: string; workflow_status: string; has_secret: boolean }
11
- interface Client { client_id: string; name: string; callback_url: string | null; release_watch_url: string | null; created_at: string; last_used_at: string | null; revoked_at: string | null; delivery?: 'url' | 'fusion'; fusion?: FusionDelivery | null }
12
  interface Created extends Client { client_secret: string; signing_key: string }
13
  interface Cycle { cycle_id: string; run_id: string; areas: string[]; status: string | null; waiting_for: string | null; data_approved_by: string; scripts_approved_by: string | null; created_at: string; correlation_id: string | null }
14
  interface Delivery { id: number; delivery_id: string; event: string; cycle_id: string | null; attempts: number; status_code: number | null; error: string | null; created_at: string; delivered_at: string | null; job_id?: string | null }
@@ -70,6 +70,8 @@ function Clients() {
70
  <Table.Td><b>{c.name}</b><div className="as-mono">{c.client_id}</div></Table.Td>
71
  <Table.Td>{c.delivery === 'fusion' && c.fusion
72
  ? <><Badge size="sm" variant="light" mb={4}>Oracle Fusion directly</Badge><div className="as-url">{c.fusion.workflow_code} on {c.fusion.base_url}</div></>
 
 
73
  : <><div className="as-url">{c.callback_url ?? 'Not set'}</div>{c.release_watch_url && <div className="as-url as-dim">Release watch: {c.release_watch_url}</div>}</>}</Table.Td>
74
  <Table.Td>{c.last_used_at ? fmtTs(c.last_used_at) : 'Never'}</Table.Td>
75
  <Table.Td ta="right"><Group gap={6} justify="flex-end" wrap="nowrap">
@@ -105,18 +107,19 @@ function Clients() {
105
  );
106
  }
107
 
108
- /** Where a client's events go: signed POSTs to its callback address (a relay), or straight to Oracle Fusion, where
109
- * Patchwise signs in to the identity domain and starts the callback workflow (invokeAsync). The secret is write-only. */
 
110
  function DeliverySheet({ c, onClose }: { c: Client; onClose: () => void }) {
111
  const qc = useQueryClient();
112
  const f = c.fusion;
113
- const [mode, setMode] = useState<'url' | 'fusion'>(c.delivery === 'fusion' ? 'fusion' : 'url');
114
  const [form, setForm] = useState({ base_url: f?.base_url ?? '', token_url: f?.token_url ?? '', client_id: f?.client_id ?? '', client_secret: '',
115
  scope: f?.scope ?? '', workflow_code: f?.workflow_code ?? 'PATCH_TEST_CALLBACK_V3_7' });
116
  const set = (k: keyof typeof form) => (e: React.ChangeEvent<HTMLInputElement>) => setForm({ ...form, [k]: e.currentTarget.value });
117
  const save = useMutation({
118
  mutationFn: () => sendJson<Client>('PUT', `/api/agent-studio/clients/${c.client_id}/delivery`,
119
- mode === 'url' ? { mode } : { mode, fusion: { ...form, client_secret: form.client_secret || null, scope: form.scope || null } }),
120
  onSuccess: () => void qc.invalidateQueries({ queryKey: ['as-clients'] }),
121
  });
122
  const test = useMutation({ mutationFn: () => sendJson<{ ok: boolean; detail: string }>('POST', `/api/agent-studio/clients/${c.client_id}/delivery/test`) });
@@ -126,8 +129,11 @@ function DeliverySheet({ c, onClose }: { c: Client; onClose: () => void }) {
126
  <div className="as-view" role="group" aria-label="Delivery">
127
  <Button variant={mode === 'url' ? 'filled' : 'default'} size="xs" onClick={() => setMode('url')} aria-pressed={mode === 'url'}>Callback address (relay)</Button>
128
  <Button variant={mode === 'fusion' ? 'filled' : 'default'} size="xs" onClick={() => setMode('fusion')} aria-pressed={mode === 'fusion'}>Oracle Fusion directly</Button>
 
129
  </div>
130
- {mode === 'url' ? (
 
 
131
  <Text size="sm" c="dimmed">Signed POSTs go to the client’s callback address{c.callback_url ? <> (<code>{c.callback_url}</code>)</> : ' (not set)'}, for example the PATCH_TEST_RELAY.</Text>
132
  ) : (
133
  <>
 
8
  import './agent-studio.css';
9
 
10
  interface FusionDelivery { base_url: string; token_url: string; client_id: string; scope: string; workflow_code: string; invocation_mode: string; workflow_status: string; has_secret: boolean }
11
+ interface Client { client_id: string; name: string; callback_url: string | null; release_watch_url: string | null; created_at: string; last_used_at: string | null; revoked_at: string | null; delivery?: 'url' | 'fusion' | 'pull'; fusion?: FusionDelivery | null }
12
  interface Created extends Client { client_secret: string; signing_key: string }
13
  interface Cycle { cycle_id: string; run_id: string; areas: string[]; status: string | null; waiting_for: string | null; data_approved_by: string; scripts_approved_by: string | null; created_at: string; correlation_id: string | null }
14
  interface Delivery { id: number; delivery_id: string; event: string; cycle_id: string | null; attempts: number; status_code: number | null; error: string | null; created_at: string; delivered_at: string | null; job_id?: string | null }
 
70
  <Table.Td><b>{c.name}</b><div className="as-mono">{c.client_id}</div></Table.Td>
71
  <Table.Td>{c.delivery === 'fusion' && c.fusion
72
  ? <><Badge size="sm" variant="light" mb={4}>Oracle Fusion directly</Badge><div className="as-url">{c.fusion.workflow_code} on {c.fusion.base_url}</div></>
73
+ : c.delivery === 'pull'
74
+ ? <><Badge size="sm" variant="light" mb={4}>Fusion picks them up</Badge><div className="as-url as-dim">events/claim, then events/ack</div></>
75
  : <><div className="as-url">{c.callback_url ?? 'Not set'}</div>{c.release_watch_url && <div className="as-url as-dim">Release watch: {c.release_watch_url}</div>}</>}</Table.Td>
76
  <Table.Td>{c.last_used_at ? fmtTs(c.last_used_at) : 'Never'}</Table.Td>
77
  <Table.Td ta="right"><Group gap={6} justify="flex-end" wrap="nowrap">
 
107
  );
108
  }
109
 
110
+ /** Where a client's events go: signed POSTs to its callback address (a relay), straight to Oracle Fusion, where
111
+ * Patchwise signs in to the identity domain and starts the callback workflow (invokeAsync), or nowhere until the Fusion
112
+ * workflow picks them up (pull: no OCI IAM app needed). The secret is write-only. */
113
  function DeliverySheet({ c, onClose }: { c: Client; onClose: () => void }) {
114
  const qc = useQueryClient();
115
  const f = c.fusion;
116
+ const [mode, setMode] = useState<'url' | 'fusion' | 'pull'>(c.delivery ?? 'url');
117
  const [form, setForm] = useState({ base_url: f?.base_url ?? '', token_url: f?.token_url ?? '', client_id: f?.client_id ?? '', client_secret: '',
118
  scope: f?.scope ?? '', workflow_code: f?.workflow_code ?? 'PATCH_TEST_CALLBACK_V3_7' });
119
  const set = (k: keyof typeof form) => (e: React.ChangeEvent<HTMLInputElement>) => setForm({ ...form, [k]: e.currentTarget.value });
120
  const save = useMutation({
121
  mutationFn: () => sendJson<Client>('PUT', `/api/agent-studio/clients/${c.client_id}/delivery`,
122
+ mode !== 'fusion' ? { mode } : { mode, fusion: { ...form, client_secret: form.client_secret || null, scope: form.scope || null } }),
123
  onSuccess: () => void qc.invalidateQueries({ queryKey: ['as-clients'] }),
124
  });
125
  const test = useMutation({ mutationFn: () => sendJson<{ ok: boolean; detail: string }>('POST', `/api/agent-studio/clients/${c.client_id}/delivery/test`) });
 
129
  <div className="as-view" role="group" aria-label="Delivery">
130
  <Button variant={mode === 'url' ? 'filled' : 'default'} size="xs" onClick={() => setMode('url')} aria-pressed={mode === 'url'}>Callback address (relay)</Button>
131
  <Button variant={mode === 'fusion' ? 'filled' : 'default'} size="xs" onClick={() => setMode('fusion')} aria-pressed={mode === 'fusion'}>Oracle Fusion directly</Button>
132
+ <Button variant={mode === 'pull' ? 'filled' : 'default'} size="xs" onClick={() => setMode('pull')} aria-pressed={mode === 'pull'}>Fusion picks them up</Button>
133
  </div>
134
+ {mode === 'pull' ? (
135
+ <Text size="sm" c="dimmed">Nothing is sent. The Fusion workflow asks for its events with this client’s own token (<code>POST /api/agent-studio/v1/events/claim</code>, then <code>/events/ack</code>), in a While Loop with a Wait. No Oracle identity domain app is needed.</Text>
136
+ ) : mode === 'url' ? (
137
  <Text size="sm" c="dimmed">Signed POSTs go to the client’s callback address{c.callback_url ? <> (<code>{c.callback_url}</code>)</> : ' (not set)'}, for example the PATCH_TEST_RELAY.</Text>
138
  ) : (
139
  <>