Astra: CES logo and name; Scout reads the run's own areas (8827e9d)
Browse files- coworker/api/a2a.py +28 -28
- coworker/api/app.py +1 -1
- coworker/api/mcp.py +12 -12
- coworker/channels/core.py +13 -13
- coworker/config.py +1 -1
- coworker/graph/nodes/research.py +1 -1
- coworker/platform/assets/astra-logo.png +0 -0
- coworker/platform/brand.py +9 -8
- coworker/platform/integrations.py +7 -7
- coworker/platform/notify.py +9 -9
- coworker/platform/report_pdf.py +2 -1
- coworker/tests/test_a2a.py +3 -3
- coworker/tests/test_brand.py +12 -15
- coworker/tests/test_mcp.py +1 -1
- coworker/tests/test_notify_telegram.py +3 -3
- coworker/tests/test_pods.py +23 -0
- web/index.html +2 -3
- web/public/apple-touch-icon-180.png +0 -0
- web/public/astra-logo.png +0 -0
- web/public/astra-mark.png +0 -0
- web/public/favicon-16.png +0 -0
- web/public/favicon-32.png +0 -0
- web/public/favicon-48.png +0 -0
- web/public/icon-512.png +0 -0
- web/src/account/AccessTokensCard.tsx +2 -2
- web/src/api/openapi.json +1 -1
- web/src/apple.css +2 -0
- web/src/chat/speaker.test.ts +1 -1
- web/src/chat/speaker.ts +3 -3
- web/src/components/components.test.tsx +2 -2
- web/src/components/shell/AppSidebar.tsx +3 -4
- web/src/components/shell/IconRail.tsx +2 -2
- web/src/components/shell/TopNav.tsx +2 -3
- web/src/desktop.ts +2 -2
- web/src/notify/NotificationBell.tsx +1 -1
- web/src/notify/NotificationsSettings.tsx +3 -3
- web/src/notify/TelegramLinkCard.tsx +2 -2
- web/src/notify/telegramlink.test.tsx +1 -1
- web/src/pages/AgentStudioPage.tsx +10 -10
- web/src/pages/AiMonitoringPage.tsx +1 -1
- web/src/pages/AuthShell.tsx +3 -3
- web/src/pages/ImportCasesPage.tsx +3 -3
- web/src/pages/IntegrationsPage.tsx +24 -24
- web/src/pages/LoginPage.tsx +1 -1
- web/src/pages/RegisterPage.test.tsx +1 -1
- web/src/pages/SettingsPage.tsx +1 -1
- web/src/pages/login/BrandMark.tsx +2 -14
- web/src/pages/login/ReleaseScene.tsx +1 -1
- web/src/theme.ts +1 -1
coworker/api/a2a.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
"""/a2a:
|
| 2 |
|
| 3 |
-
Another agent (for example one that crawls a pod's modules and versions and Oracle's patch updates) finds
|
| 4 |
/.well-known/agent-card.json and calls POST /a2a with a personal access token (`Authorization: Bearer pwt_...`, the same
|
| 5 |
tokens, scopes, rate limit and code paths as /mcp, see api/mcp.py). Skills:
|
| 6 |
|
|
@@ -9,7 +9,7 @@ tokens, scopes, rate limit and code paths as /mcp, see api/mcp.py). Skills:
|
|
| 9 |
{"confirm": true} on the same task starts it through the same confirm path as Ask and MCP (role, gate and the
|
| 10 |
emergency stop re-checked; a proposal is single use).
|
| 11 |
- test-these-cases (scope "read,act" and run.start): parse + script + dry run (custom_cases.py). The task waits until a
|
| 12 |
-
PERSON approves the cases in
|
| 13 |
|
| 14 |
A task that leads to a test run follows it (working, input-required while a person reviews, completed with the report,
|
| 15 |
failed). Never through A2A: approving custom cases, sign-off, failure verdicts, waivers, the emergency stop, admin.
|
|
@@ -57,7 +57,7 @@ STREAM_MAX_SECONDS = 600
|
|
| 57 |
TERMINAL = {"completed", "canceled", "failed", "rejected"}
|
| 58 |
STOP = TERMINAL | {"input-required", "auth-required"} # a stream ends here (final: true)
|
| 59 |
ACT_SKILLS = {"design-tests", "run-tests", "test-these-cases"}
|
| 60 |
-
PATCH_RE = re.compile(r"^\d{2}[A-D]$", re.I) # the release names
|
| 61 |
|
| 62 |
# JSON-RPC / A2A error codes
|
| 63 |
TASK_NOT_FOUND, NOT_CANCELABLE, PUSH_UNSUPPORTED, UNSUPPORTED, CONTENT_TYPE, EXT_CARD = -32001, -32002, -32003, -32004, -32005, -32007
|
|
@@ -71,14 +71,14 @@ SKILLS = [
|
|
| 71 |
"inputModes": IO, "outputModes": IO},
|
| 72 |
{"id": "design-tests", "name": "Design tests for a patch",
|
| 73 |
"description": "Send what your agent found: DataPart {pod: {...}, patch: {id, changes: [{area, description, source_url?}]}, "
|
| 74 |
-
"mode?: quick|browser, environment?}.
|
| 75 |
"generator chooses the scenarios; your facts are recorded as data). Reply {confirm: true} on the same "
|
| 76 |
"task to start it. Scope: read,act.",
|
| 77 |
"tags": ["oracle-fusion", "patch", "test-design"], "inputModes": ["application/json"], "outputModes": IO},
|
| 78 |
{"id": "test-these-cases", "name": "Test these cases",
|
| 79 |
"description": "Your own test cases: DataPart {cases: [{title, area, priority?, steps: [{action, expected?}], data?, "
|
| 80 |
-
"preconditions?}], environment?} (at most 50).
|
| 81 |
-
"approves them in
|
| 82 |
"Scope: read,act.",
|
| 83 |
"tags": ["oracle-fusion", "custom-test-cases"], "inputModes": ["application/json"], "outputModes": IO},
|
| 84 |
{"id": "run-tests", "name": "Run tests",
|
|
@@ -92,9 +92,9 @@ SKILLS = [
|
|
| 92 |
"tags": ["oracle-fusion", "report"], "inputModes": IO, "outputModes": IO + ["application/pdf"]},
|
| 93 |
]
|
| 94 |
SKILL_IDS = {s["id"] for s in SKILLS}
|
| 95 |
-
HELP = ("I am
|
| 96 |
+ ". Choose one with message.metadata.skill or a DataPart {\"skill\": ...}. Starting anything needs a confirm, and "
|
| 97 |
-
"custom test cases need a person's approval in
|
| 98 |
|
| 99 |
|
| 100 |
class RpcError(Exception):
|
|
@@ -284,10 +284,10 @@ class Tasks:
|
|
| 284 |
# -- permission
|
| 285 |
def act_refusal(self, skill: str) -> str | None:
|
| 286 |
if "act" not in self.scopes:
|
| 287 |
-
return ("This token is read-only. Create a token with the 'read and act' scope in
|
| 288 |
"(Account → Access tokens for AI assistants) to design or run tests.")
|
| 289 |
if not self.user.can("run.start"):
|
| 290 |
-
return f"Your role ({self.user.role}) can't start test runs in
|
| 291 |
return None
|
| 292 |
|
| 293 |
# -- message/send
|
|
@@ -342,7 +342,7 @@ class Tasks:
|
|
| 342 |
parts += [{"kind": "file", "file": {"uri": a["pdf"], "mimeType": "application/pdf", "name": f"patchwise-{row['run_id']}-{a['area'].lower()}.pdf"}}
|
| 343 |
for a in info.get("areas") or [] if a.get("pdf")]
|
| 344 |
row = self.artifact(row, "report", "Test report", parts, "Verdict and QA rule result per area, counts, exit criteria and links. "
|
| 345 |
-
"Sign-off happens in
|
| 346 |
if not final:
|
| 347 |
return row
|
| 348 |
return self.state(row, "completed", res["content"][0]["text"])
|
|
@@ -368,12 +368,12 @@ class Tasks:
|
|
| 368 |
mods.append(m)
|
| 369 |
patch_id = d.patch.id.upper() if d.patch.id and PATCH_RE.match(d.patch.id) else None
|
| 370 |
note = (f" Your agent's facts are recorded on this task as data ({len(d.patch.changes)} change(s)"
|
| 371 |
-
+ (f", patch {d.patch.id[:40]}" if d.patch.id else "") + ");
|
| 372 |
+ (f" for patch {patch_id}" if patch_id else "") + "."
|
| 373 |
+ (f" Areas not recognised: {', '.join(sorted(set(unknown)))}." if unknown else ""))
|
| 374 |
if not mods:
|
| 375 |
from ..chat.intent import MODULE_NAMES
|
| 376 |
-
return self.state(row, "rejected", "None of the areas is a business area
|
| 377 |
+ ", ".join(f"{k} ({v})" for k, v in MODULE_NAMES.items()) + "." + note)
|
| 378 |
return self.propose(row, mods, d.mode, d.environment, patch_id, note)
|
| 379 |
|
|
@@ -457,7 +457,7 @@ class Tasks:
|
|
| 457 |
d = data or {}
|
| 458 |
if any(k in d for k in ("approve", "approved", "approve_cases", "sign_off", "signoff", "verdict")):
|
| 459 |
self.audit("a2a.refused", row, "approval or sign-off asked through A2A")
|
| 460 |
-
return self.state(row, "input-required", "Only a person can approve, decide or sign off, in
|
| 461 |
+ (row["status_text"] or ""))
|
| 462 |
if not (d.get("confirm") is True or (text or "").strip().lower().rstrip(".!") == "confirm"):
|
| 463 |
return self.state(row, "input-required", (row["status_text"] or "").split("\n\nReply")[0]
|
|
@@ -488,7 +488,7 @@ class Tasks:
|
|
| 488 |
keys = [c["key"] for c in v["cases"] if c["state"] == "approved"]
|
| 489 |
if not keys:
|
| 490 |
return self.state(row, "input-required", "No case has been approved by a person yet. "
|
| 491 |
-
+ f"Waiting for a person to approve the scenarios in
|
| 492 |
if not self.claim(row):
|
| 493 |
return self.get(row["id"])
|
| 494 |
row = self.get(row["id"])
|
|
@@ -520,9 +520,9 @@ class Tasks:
|
|
| 520 |
return self.state(row, "failed", "The test run no longer exists.")
|
| 521 |
st, gate = run.get("status"), run.get("pending_gate")
|
| 522 |
if gate == "approve_cases" or st == "waiting_approval":
|
| 523 |
-
return self.state(row, "input-required", f"Waiting for a person to approve the scenarios in
|
| 524 |
if gate == "human_review" or st == "waiting_review":
|
| 525 |
-
return self.state(row, "input-required", f"Waiting for a person to decide the failures in
|
| 526 |
if st == "completed":
|
| 527 |
row = self.report(row, final=False)
|
| 528 |
return self.state(row, "completed", f"The test run finished. Report: {self.link(f'/runs/{rid}/report')}")
|
|
@@ -531,7 +531,7 @@ class Tasks:
|
|
| 531 |
if st == "cancelled":
|
| 532 |
return self.state(row, "canceled", "The test run was cancelled.")
|
| 533 |
step = f" ({run['current_node']})" if run.get("current_node") else ""
|
| 534 |
-
return self.state(row, "working", f"Testing: {STATUS_WORDS.get(st, st)}{step}. Follow it in
|
| 535 |
|
| 536 |
def follow_batch(self, row: dict) -> dict:
|
| 537 |
try:
|
|
@@ -546,12 +546,12 @@ class Tasks:
|
|
| 546 |
if v["status"] in ("parsed", "building"):
|
| 547 |
return self.state(row, "working", "Writing scripts and dry-running your cases on the pod.")
|
| 548 |
if v["status"] == "failed":
|
| 549 |
-
return self.state(row, "failed", f"The scripts could not be built: {v.get('message') or 'see
|
| 550 |
by = lambda s: [c for c in cases if c["state"] == s] # noqa: E731
|
| 551 |
approved, waiting = by("approved"), by("dry_run_passed")
|
| 552 |
if waiting:
|
| 553 |
return self.state(row, "input-required", f"{len(waiting)} case(s) passed their dry run. Waiting for a person to approve the "
|
| 554 |
-
f"scenarios in
|
| 555 |
if approved:
|
| 556 |
return self.state(row, "input-required", f"A person approved {len(approved)} case(s). Reply {{\"confirm\": true}} on this task "
|
| 557 |
"to run them (optionally with \"mode\": \"quick\" or \"browser\").")
|
|
@@ -589,16 +589,16 @@ def agent_card(request: Request) -> dict:
|
|
| 589 |
svc = request.app.state.svc
|
| 590 |
base = (svc.cfg.public_url or str(request.base_url)).rstrip("/")
|
| 591 |
return {
|
| 592 |
-
"protocolVersion": PROTOCOL_VERSION, "name": "
|
| 593 |
-
"description": "
|
| 594 |
"and runs on a test pod, your own test cases (a person approves them), and the report. Starting "
|
| 595 |
-
"anything needs a confirm; approvals and sign-off stay with people in
|
| 596 |
"url": f"{base}/a2a", "preferredTransport": "JSONRPC", "version": VERSION,
|
| 597 |
-
"provider": {"organization": "
|
| 598 |
"capabilities": {"streaming": True, "pushNotifications": False, "stateTransitionHistory": True},
|
| 599 |
"defaultInputModes": IO, "defaultOutputModes": IO,
|
| 600 |
"securitySchemes": {"bearer": {"type": "http", "scheme": "bearer",
|
| 601 |
-
"description": "
|
| 602 |
"security": [{"bearer": []}],
|
| 603 |
"skills": SKILLS,
|
| 604 |
"supportsAuthenticatedExtendedCard": False,
|
|
@@ -654,7 +654,7 @@ def _handle(body, request: Request, user, token: dict) -> dict:
|
|
| 654 |
return _err(mid, e.code, str(e))
|
| 655 |
except Exception: # noqa: BLE001 (never a stack trace to the caller; the log has it)
|
| 656 |
log.exception("a2a %s failed", body["method"][:40])
|
| 657 |
-
return _err(mid, -32603, "
|
| 658 |
|
| 659 |
|
| 660 |
def _sse(obj: dict) -> bytes:
|
|
@@ -675,7 +675,7 @@ async def _stream(request: Request, tasks: Tasks, mid, method: str, params: dict
|
|
| 675 |
return
|
| 676 |
except Exception: # noqa: BLE001
|
| 677 |
log.exception("a2a %s failed", method)
|
| 678 |
-
yield _sse(_err(mid, -32603, "
|
| 679 |
return
|
| 680 |
prev = task_out(row, _history_length(params))
|
| 681 |
yield _sse(_ok(mid, prev))
|
|
|
|
| 1 |
+
"""/a2a: Astra as an A2A (Agent2Agent protocol v0.3) agent, JSON-RPC 2.0 over HTTP, with SSE streaming.
|
| 2 |
|
| 3 |
+
Another agent (for example one that crawls a pod's modules and versions and Oracle's patch updates) finds Astra at
|
| 4 |
/.well-known/agent-card.json and calls POST /a2a with a personal access token (`Authorization: Bearer pwt_...`, the same
|
| 5 |
tokens, scopes, rate limit and code paths as /mcp, see api/mcp.py). Skills:
|
| 6 |
|
|
|
|
| 9 |
{"confirm": true} on the same task starts it through the same confirm path as Ask and MCP (role, gate and the
|
| 10 |
emergency stop re-checked; a proposal is single use).
|
| 11 |
- test-these-cases (scope "read,act" and run.start): parse + script + dry run (custom_cases.py). The task waits until a
|
| 12 |
+
PERSON approves the cases in Astra; the caller can never approve. Then {"confirm": true} runs the approved ones.
|
| 13 |
|
| 14 |
A task that leads to a test run follows it (working, input-required while a person reviews, completed with the report,
|
| 15 |
failed). Never through A2A: approving custom cases, sign-off, failure verdicts, waivers, the emergency stop, admin.
|
|
|
|
| 57 |
TERMINAL = {"completed", "canceled", "failed", "rejected"}
|
| 58 |
STOP = TERMINAL | {"input-required", "auth-required"} # a stream ends here (final: true)
|
| 59 |
ACT_SKILLS = {"design-tests", "run-tests", "test-these-cases"}
|
| 60 |
+
PATCH_RE = re.compile(r"^\d{2}[A-D]$", re.I) # the release names Astra's research knows (e.g. 26C)
|
| 61 |
|
| 62 |
# JSON-RPC / A2A error codes
|
| 63 |
TASK_NOT_FOUND, NOT_CANCELABLE, PUSH_UNSUPPORTED, UNSUPPORTED, CONTENT_TYPE, EXT_CARD = -32001, -32002, -32003, -32004, -32005, -32007
|
|
|
|
| 71 |
"inputModes": IO, "outputModes": IO},
|
| 72 |
{"id": "design-tests", "name": "Design tests for a patch",
|
| 73 |
"description": "Send what your agent found: DataPart {pod: {...}, patch: {id, changes: [{area, description, source_url?}]}, "
|
| 74 |
+
"mode?: quick|browser, environment?}. Astra proposes a test run of the affected areas (its own "
|
| 75 |
"generator chooses the scenarios; your facts are recorded as data). Reply {confirm: true} on the same "
|
| 76 |
"task to start it. Scope: read,act.",
|
| 77 |
"tags": ["oracle-fusion", "patch", "test-design"], "inputModes": ["application/json"], "outputModes": IO},
|
| 78 |
{"id": "test-these-cases", "name": "Test these cases",
|
| 79 |
"description": "Your own test cases: DataPart {cases: [{title, area, priority?, steps: [{action, expected?}], data?, "
|
| 80 |
+
"preconditions?}], environment?} (at most 50). Astra writes the scripts and dry-runs them; a PERSON "
|
| 81 |
+
"approves them in Astra (never the caller). Then reply {confirm: true} to run the approved ones. "
|
| 82 |
"Scope: read,act.",
|
| 83 |
"tags": ["oracle-fusion", "custom-test-cases"], "inputModes": ["application/json"], "outputModes": IO},
|
| 84 |
{"id": "run-tests", "name": "Run tests",
|
|
|
|
| 92 |
"tags": ["oracle-fusion", "report"], "inputModes": IO, "outputModes": IO + ["application/pdf"]},
|
| 93 |
]
|
| 94 |
SKILL_IDS = {s["id"] for s in SKILLS}
|
| 95 |
+
HELP = ("I am Astra: I test Oracle Fusion patches. Skills: " + "; ".join(f"{s['id']} ({s['name']})" for s in SKILLS)
|
| 96 |
+ ". Choose one with message.metadata.skill or a DataPart {\"skill\": ...}. Starting anything needs a confirm, and "
|
| 97 |
+
"custom test cases need a person's approval in Astra.")
|
| 98 |
|
| 99 |
|
| 100 |
class RpcError(Exception):
|
|
|
|
| 284 |
# -- permission
|
| 285 |
def act_refusal(self, skill: str) -> str | None:
|
| 286 |
if "act" not in self.scopes:
|
| 287 |
+
return ("This token is read-only. Create a token with the 'read and act' scope in Astra "
|
| 288 |
"(Account → Access tokens for AI assistants) to design or run tests.")
|
| 289 |
if not self.user.can("run.start"):
|
| 290 |
+
return f"Your role ({self.user.role}) can't start test runs in Astra."
|
| 291 |
return None
|
| 292 |
|
| 293 |
# -- message/send
|
|
|
|
| 342 |
parts += [{"kind": "file", "file": {"uri": a["pdf"], "mimeType": "application/pdf", "name": f"patchwise-{row['run_id']}-{a['area'].lower()}.pdf"}}
|
| 343 |
for a in info.get("areas") or [] if a.get("pdf")]
|
| 344 |
row = self.artifact(row, "report", "Test report", parts, "Verdict and QA rule result per area, counts, exit criteria and links. "
|
| 345 |
+
"Sign-off happens in Astra.")
|
| 346 |
if not final:
|
| 347 |
return row
|
| 348 |
return self.state(row, "completed", res["content"][0]["text"])
|
|
|
|
| 368 |
mods.append(m)
|
| 369 |
patch_id = d.patch.id.upper() if d.patch.id and PATCH_RE.match(d.patch.id) else None
|
| 370 |
note = (f" Your agent's facts are recorded on this task as data ({len(d.patch.changes)} change(s)"
|
| 371 |
+
+ (f", patch {d.patch.id[:40]}" if d.patch.id else "") + "); Astra's own generator chooses the scenarios"
|
| 372 |
+ (f" for patch {patch_id}" if patch_id else "") + "."
|
| 373 |
+ (f" Areas not recognised: {', '.join(sorted(set(unknown)))}." if unknown else ""))
|
| 374 |
if not mods:
|
| 375 |
from ..chat.intent import MODULE_NAMES
|
| 376 |
+
return self.state(row, "rejected", "None of the areas is a business area Astra tests. Known: "
|
| 377 |
+ ", ".join(f"{k} ({v})" for k, v in MODULE_NAMES.items()) + "." + note)
|
| 378 |
return self.propose(row, mods, d.mode, d.environment, patch_id, note)
|
| 379 |
|
|
|
|
| 457 |
d = data or {}
|
| 458 |
if any(k in d for k in ("approve", "approved", "approve_cases", "sign_off", "signoff", "verdict")):
|
| 459 |
self.audit("a2a.refused", row, "approval or sign-off asked through A2A")
|
| 460 |
+
return self.state(row, "input-required", "Only a person can approve, decide or sign off, in Astra. "
|
| 461 |
+ (row["status_text"] or ""))
|
| 462 |
if not (d.get("confirm") is True or (text or "").strip().lower().rstrip(".!") == "confirm"):
|
| 463 |
return self.state(row, "input-required", (row["status_text"] or "").split("\n\nReply")[0]
|
|
|
|
| 488 |
keys = [c["key"] for c in v["cases"] if c["state"] == "approved"]
|
| 489 |
if not keys:
|
| 490 |
return self.state(row, "input-required", "No case has been approved by a person yet. "
|
| 491 |
+
+ f"Waiting for a person to approve the scenarios in Astra: {self.link('/scenarios/import?batch=' + row['batch_id'])}")
|
| 492 |
if not self.claim(row):
|
| 493 |
return self.get(row["id"])
|
| 494 |
row = self.get(row["id"])
|
|
|
|
| 520 |
return self.state(row, "failed", "The test run no longer exists.")
|
| 521 |
st, gate = run.get("status"), run.get("pending_gate")
|
| 522 |
if gate == "approve_cases" or st == "waiting_approval":
|
| 523 |
+
return self.state(row, "input-required", f"Waiting for a person to approve the scenarios in Astra: {self.link(f'/runs/{rid}/scenarios')}")
|
| 524 |
if gate == "human_review" or st == "waiting_review":
|
| 525 |
+
return self.state(row, "input-required", f"Waiting for a person to decide the failures in Astra: {self.link(f'/runs/{rid}/failures')}")
|
| 526 |
if st == "completed":
|
| 527 |
row = self.report(row, final=False)
|
| 528 |
return self.state(row, "completed", f"The test run finished. Report: {self.link(f'/runs/{rid}/report')}")
|
|
|
|
| 531 |
if st == "cancelled":
|
| 532 |
return self.state(row, "canceled", "The test run was cancelled.")
|
| 533 |
step = f" ({run['current_node']})" if run.get("current_node") else ""
|
| 534 |
+
return self.state(row, "working", f"Testing: {STATUS_WORDS.get(st, st)}{step}. Follow it in Astra: {self.link(f'/runs/{rid}')}")
|
| 535 |
|
| 536 |
def follow_batch(self, row: dict) -> dict:
|
| 537 |
try:
|
|
|
|
| 546 |
if v["status"] in ("parsed", "building"):
|
| 547 |
return self.state(row, "working", "Writing scripts and dry-running your cases on the pod.")
|
| 548 |
if v["status"] == "failed":
|
| 549 |
+
return self.state(row, "failed", f"The scripts could not be built: {v.get('message') or 'see Astra'}.")
|
| 550 |
by = lambda s: [c for c in cases if c["state"] == s] # noqa: E731
|
| 551 |
approved, waiting = by("approved"), by("dry_run_passed")
|
| 552 |
if waiting:
|
| 553 |
return self.state(row, "input-required", f"{len(waiting)} case(s) passed their dry run. Waiting for a person to approve the "
|
| 554 |
+
f"scenarios in Astra: {link}" + (f" ({len(approved)} already approved: reply {{\"confirm\": true}} to run those.)" if approved else ""))
|
| 555 |
if approved:
|
| 556 |
return self.state(row, "input-required", f"A person approved {len(approved)} case(s). Reply {{\"confirm\": true}} on this task "
|
| 557 |
"to run them (optionally with \"mode\": \"quick\" or \"browser\").")
|
|
|
|
| 589 |
svc = request.app.state.svc
|
| 590 |
base = (svc.cfg.public_url or str(request.base_url)).rstrip("/")
|
| 591 |
return {
|
| 592 |
+
"protocolVersion": PROTOCOL_VERSION, "name": "Astra",
|
| 593 |
+
"description": "Astra tests Oracle Fusion patches before they go live: readiness per business area, test design "
|
| 594 |
"and runs on a test pod, your own test cases (a person approves them), and the report. Starting "
|
| 595 |
+
"anything needs a confirm; approvals and sign-off stay with people in Astra.",
|
| 596 |
"url": f"{base}/a2a", "preferredTransport": "JSONRPC", "version": VERSION,
|
| 597 |
+
"provider": {"organization": "Astra", "url": base},
|
| 598 |
"capabilities": {"streaming": True, "pushNotifications": False, "stateTransitionHistory": True},
|
| 599 |
"defaultInputModes": IO, "defaultOutputModes": IO,
|
| 600 |
"securitySchemes": {"bearer": {"type": "http", "scheme": "bearer",
|
| 601 |
+
"description": "Astra access token (pwt_…) from Account → Access tokens for AI assistants"}},
|
| 602 |
"security": [{"bearer": []}],
|
| 603 |
"skills": SKILLS,
|
| 604 |
"supportsAuthenticatedExtendedCard": False,
|
|
|
|
| 654 |
return _err(mid, e.code, str(e))
|
| 655 |
except Exception: # noqa: BLE001 (never a stack trace to the caller; the log has it)
|
| 656 |
log.exception("a2a %s failed", body["method"][:40])
|
| 657 |
+
return _err(mid, -32603, "Astra could not complete that. Try again, or open the app.")
|
| 658 |
|
| 659 |
|
| 660 |
def _sse(obj: dict) -> bytes:
|
|
|
|
| 675 |
return
|
| 676 |
except Exception: # noqa: BLE001
|
| 677 |
log.exception("a2a %s failed", method)
|
| 678 |
+
yield _sse(_err(mid, -32603, "Astra could not complete that."))
|
| 679 |
return
|
| 680 |
prev = task_out(row, _history_length(params))
|
| 681 |
yield _sse(_ok(mid, prev))
|
coworker/api/app.py
CHANGED
|
@@ -90,7 +90,7 @@ def create_app(svc: Services | None = None, cfg: Settings | None = None, *, back
|
|
| 90 |
if syncer:
|
| 91 |
syncer.stop()
|
| 92 |
|
| 93 |
-
app = FastAPI(title="
|
| 94 |
description="Pilot backend. Runs against the local mock app or a registered Oracle Fusion TEST pod (never production); "
|
| 95 |
"every run and report names its target.",
|
| 96 |
docs_url="/api/docs" if svc.cfg.api_docs else None, redoc_url=None,
|
|
|
|
| 90 |
if syncer:
|
| 91 |
syncer.stop()
|
| 92 |
|
| 93 |
+
app = FastAPI(title="Astra API", version=VERSION, lifespan=lifespan,
|
| 94 |
description="Pilot backend. Runs against the local mock app or a registered Oracle Fusion TEST pod (never production); "
|
| 95 |
"every run and report names its target.",
|
| 96 |
docs_url="/api/docs" if svc.cfg.api_docs else None, redoc_url=None,
|
coworker/api/mcp.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""/mcp: the
|
| 2 |
|
| 3 |
Microsoft Copilot (Copilot Studio), ChatGPT, Claude, VS Code / GitHub Copilot and Cursor connect here with a personal
|
| 4 |
access token (`Authorization: Bearer pwt_...`, see platform/api_tokens.py). Every call acts as the token's owner with the
|
|
@@ -42,11 +42,11 @@ RATE_PER_MINUTE = 60
|
|
| 42 |
_calls: dict[int, deque] = defaultdict(deque)
|
| 43 |
|
| 44 |
INSTRUCTIONS = (
|
| 45 |
-
"
|
| 46 |
-
"for the user, test runs and reports, and to ask questions answered from
|
| 47 |
"approving scenarios is two steps: a propose_* tool returns a proposal_id and a summary; show the summary to the user "
|
| 48 |
"and call confirm only after they agree. Sign-off, failure verdicts and administration are not available here: they "
|
| 49 |
-
"stay in the
|
| 50 |
|
| 51 |
|
| 52 |
# ------------------------------------------------------------------------------------------------ tools (schemas)
|
|
@@ -85,9 +85,9 @@ TOOLS: list[dict] = [
|
|
| 85 |
"description": "A finished test run's report: readiness verdict and the exact QA rule result per area, counts, exit criteria "
|
| 86 |
"met / not met, executive summary, and links to the report and PDF.",
|
| 87 |
"inputSchema": _schema({"run_id": {"type": "string"}}, ["run_id"]), "annotations": READ, "scope": "read"},
|
| 88 |
-
{"name": "ask", "title": "Ask
|
| 89 |
"description": "Ask a question in plain words (e.g. 'What does this patch change in invoice matching?'). Answered from "
|
| 90 |
-
"
|
| 91 |
"inputSchema": _schema({"question": {"type": "string", "maxLength": 2000}}, ["question"]), "annotations": READ, "scope": "read"},
|
| 92 |
{"name": "propose_test_run", "title": "Propose a test run",
|
| 93 |
"description": "Prepare a test run (nothing starts). Returns a proposal_id and a summary to show the user; call confirm to start it.",
|
|
@@ -280,7 +280,7 @@ class Toolbox:
|
|
| 280 |
areas.append(area)
|
| 281 |
not_met = [k for k, ok in crit.items() if not ok]
|
| 282 |
lines.append(f"{m}: {area['verdict']} (rule result {decision})" + (f"; not met: {', '.join(not_met)}" if not_met else "; all exit criteria met"))
|
| 283 |
-
lines.append("Sign-off happens in
|
| 284 |
return _result("\n".join(lines), {"run_id": run_id, "target": self.svc.target(run_id), "areas": areas})
|
| 285 |
|
| 286 |
def ask(self, question: str) -> dict:
|
|
@@ -405,7 +405,7 @@ def _now() -> str:
|
|
| 405 |
# ------------------------------------------------------------------------------------------------ transport
|
| 406 |
def _unauthorized(detail: str) -> JSONResponse:
|
| 407 |
return JSONResponse({"error": "unauthorized", "detail": detail}, status_code=401,
|
| 408 |
-
headers={"WWW-Authenticate": 'Bearer realm="
|
| 409 |
|
| 410 |
|
| 411 |
def _origin_ok(request: Request) -> bool:
|
|
@@ -448,7 +448,7 @@ def _handle(msg, request: Request, user, token: dict) -> dict | None:
|
|
| 448 |
return {"jsonrpc": "2.0", "id": mid, "result": {
|
| 449 |
"protocolVersion": asked if asked in PROTOCOL_VERSIONS else PROTOCOL_VERSIONS[0],
|
| 450 |
"capabilities": {"tools": {"listChanged": False}},
|
| 451 |
-
"serverInfo": {"name": "
|
| 452 |
"instructions": INSTRUCTIONS}}
|
| 453 |
if method == "ping":
|
| 454 |
return {"jsonrpc": "2.0", "id": mid, "result": {}}
|
|
@@ -463,10 +463,10 @@ def _handle(msg, request: Request, user, token: dict) -> dict | None:
|
|
| 463 |
return _rpc_error(mid, -32602, f"Unknown tool: {str(name)[:60]}")
|
| 464 |
if t["scope"] not in scopes:
|
| 465 |
return {"jsonrpc": "2.0", "id": mid, "result": _tool_error(
|
| 466 |
-
"This token is read-only. Create a token with the 'read and act' scope in
|
| 467 |
perm = ACT_PERM.get(t["name"])
|
| 468 |
if perm and not user.can(perm):
|
| 469 |
-
return {"jsonrpc": "2.0", "id": mid, "result": _tool_error(f"Your role ({user.role}) can't do that in
|
| 470 |
allowed = set(t["inputSchema"]["properties"])
|
| 471 |
if set(args) - allowed or any(r not in args for r in t["inputSchema"]["required"]):
|
| 472 |
return _rpc_error(mid, -32602, f"Invalid arguments for {t['name']}: expected {sorted(allowed)}, required {t['inputSchema']['required']}")
|
|
@@ -476,7 +476,7 @@ def _handle(msg, request: Request, user, token: dict) -> dict | None:
|
|
| 476 |
result = _tool_error(str(e))
|
| 477 |
except Exception: # noqa: BLE001 (never a stack trace to the client; the log has it)
|
| 478 |
log.exception("mcp tool %s failed", t["name"])
|
| 479 |
-
result = _tool_error("
|
| 480 |
return {"jsonrpc": "2.0", "id": mid, "result": result}
|
| 481 |
return _rpc_error(mid, -32601, f"Method not found: {method[:60]}")
|
| 482 |
|
|
|
|
| 1 |
+
"""/mcp: the Astra MCP connector (Model Context Protocol, Streamable HTTP transport, stateless JSON responses).
|
| 2 |
|
| 3 |
Microsoft Copilot (Copilot Studio), ChatGPT, Claude, VS Code / GitHub Copilot and Cursor connect here with a personal
|
| 4 |
access token (`Authorization: Bearer pwt_...`, see platform/api_tokens.py). Every call acts as the token's owner with the
|
|
|
|
| 42 |
_calls: dict[int, deque] = defaultdict(deque)
|
| 43 |
|
| 44 |
INSTRUCTIONS = (
|
| 45 |
+
"Astra tests Oracle Fusion patches before they go live. Use these tools to read patch readiness, what is waiting "
|
| 46 |
+
"for the user, test runs and reports, and to ask questions answered from Astra's own data. Starting a test run or "
|
| 47 |
"approving scenarios is two steps: a propose_* tool returns a proposal_id and a summary; show the summary to the user "
|
| 48 |
"and call confirm only after they agree. Sign-off, failure verdicts and administration are not available here: they "
|
| 49 |
+
"stay in the Astra app (links are included).")
|
| 50 |
|
| 51 |
|
| 52 |
# ------------------------------------------------------------------------------------------------ tools (schemas)
|
|
|
|
| 85 |
"description": "A finished test run's report: readiness verdict and the exact QA rule result per area, counts, exit criteria "
|
| 86 |
"met / not met, executive summary, and links to the report and PDF.",
|
| 87 |
"inputSchema": _schema({"run_id": {"type": "string"}}, ["run_id"]), "annotations": READ, "scope": "read"},
|
| 88 |
+
{"name": "ask", "title": "Ask Astra",
|
| 89 |
"description": "Ask a question in plain words (e.g. 'What does this patch change in invoice matching?'). Answered from "
|
| 90 |
+
"Astra's own data, with sources. Never performs actions.",
|
| 91 |
"inputSchema": _schema({"question": {"type": "string", "maxLength": 2000}}, ["question"]), "annotations": READ, "scope": "read"},
|
| 92 |
{"name": "propose_test_run", "title": "Propose a test run",
|
| 93 |
"description": "Prepare a test run (nothing starts). Returns a proposal_id and a summary to show the user; call confirm to start it.",
|
|
|
|
| 280 |
areas.append(area)
|
| 281 |
not_met = [k for k, ok in crit.items() if not ok]
|
| 282 |
lines.append(f"{m}: {area['verdict']} (rule result {decision})" + (f"; not met: {', '.join(not_met)}" if not_met else "; all exit criteria met"))
|
| 283 |
+
lines.append("Sign-off happens in Astra: " + (_abs(self.svc, f"/runs/{run_id}/report") or f"/runs/{run_id}/report"))
|
| 284 |
return _result("\n".join(lines), {"run_id": run_id, "target": self.svc.target(run_id), "areas": areas})
|
| 285 |
|
| 286 |
def ask(self, question: str) -> dict:
|
|
|
|
| 405 |
# ------------------------------------------------------------------------------------------------ transport
|
| 406 |
def _unauthorized(detail: str) -> JSONResponse:
|
| 407 |
return JSONResponse({"error": "unauthorized", "detail": detail}, status_code=401,
|
| 408 |
+
headers={"WWW-Authenticate": 'Bearer realm="Astra", error="invalid_token"'})
|
| 409 |
|
| 410 |
|
| 411 |
def _origin_ok(request: Request) -> bool:
|
|
|
|
| 448 |
return {"jsonrpc": "2.0", "id": mid, "result": {
|
| 449 |
"protocolVersion": asked if asked in PROTOCOL_VERSIONS else PROTOCOL_VERSIONS[0],
|
| 450 |
"capabilities": {"tools": {"listChanged": False}},
|
| 451 |
+
"serverInfo": {"name": "Astra", "title": "Astra", "version": VERSION},
|
| 452 |
"instructions": INSTRUCTIONS}}
|
| 453 |
if method == "ping":
|
| 454 |
return {"jsonrpc": "2.0", "id": mid, "result": {}}
|
|
|
|
| 463 |
return _rpc_error(mid, -32602, f"Unknown tool: {str(name)[:60]}")
|
| 464 |
if t["scope"] not in scopes:
|
| 465 |
return {"jsonrpc": "2.0", "id": mid, "result": _tool_error(
|
| 466 |
+
"This token is read-only. Create a token with the 'read and act' scope in Astra (Account) to start runs or approve.")}
|
| 467 |
perm = ACT_PERM.get(t["name"])
|
| 468 |
if perm and not user.can(perm):
|
| 469 |
+
return {"jsonrpc": "2.0", "id": mid, "result": _tool_error(f"Your role ({user.role}) can't do that in Astra.")}
|
| 470 |
allowed = set(t["inputSchema"]["properties"])
|
| 471 |
if set(args) - allowed or any(r not in args for r in t["inputSchema"]["required"]):
|
| 472 |
return _rpc_error(mid, -32602, f"Invalid arguments for {t['name']}: expected {sorted(allowed)}, required {t['inputSchema']['required']}")
|
|
|
|
| 476 |
result = _tool_error(str(e))
|
| 477 |
except Exception: # noqa: BLE001 (never a stack trace to the client; the log has it)
|
| 478 |
log.exception("mcp tool %s failed", t["name"])
|
| 479 |
+
result = _tool_error("Astra could not complete that. Try again, or open the app.")
|
| 480 |
return {"jsonrpc": "2.0", "id": mid, "result": result}
|
| 481 |
return _rpc_error(mid, -32601, f"Method not found: {method[:60]}")
|
| 482 |
|
coworker/channels/core.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
A channel adapter turns its platform's messages into `Inbound` and sends `OutMessage` back; everything else lives here:
|
| 4 |
|
| 5 |
-
- Linking: a person links a chat to their
|
| 6 |
Only the code's hash is stored; it works once, for 10 minutes. From then on the bot acts as that user, with that user's
|
| 7 |
role: the same RBAC as the screens. An unlinked chat only gets help and "/link CODE".
|
| 8 |
- Talking: any free text goes to the Ask service (coworker/chat/service.py) exactly as the Ask page does, as that user:
|
|
@@ -141,10 +141,10 @@ class Conversation:
|
|
| 141 |
link = self._link(inb)
|
| 142 |
if inb.callback_data is not None:
|
| 143 |
if not link:
|
| 144 |
-
return [OutMessage("This chat is not linked to a
|
| 145 |
user = self._principal(link)
|
| 146 |
if not user:
|
| 147 |
-
return [OutMessage("This
|
| 148 |
return self._callback(inb, user, link)
|
| 149 |
text = (inb.text or "").strip()
|
| 150 |
cmd, _, rest = text.partition(" ")
|
|
@@ -155,13 +155,13 @@ class Conversation:
|
|
| 155 |
return [OutMessage(WELCOME + "\n\n" + LINK_HELP)]
|
| 156 |
user = self._principal(link)
|
| 157 |
if not user:
|
| 158 |
-
return [OutMessage("This
|
| 159 |
if cmd in ("/start", "/help"):
|
| 160 |
return [OutMessage(HELP.format(name=user.username))]
|
| 161 |
if cmd == "/unlink":
|
| 162 |
self.db.x("DELETE FROM channel_links WHERE id=?", (link["id"],))
|
| 163 |
self._audit("unlinked", inb, user, summary=f"{inb.channel} chat unlinked")
|
| 164 |
-
return [OutMessage("This chat is no longer linked. You will not get
|
| 165 |
if cmd == "/status":
|
| 166 |
return [self._status(user, inb)]
|
| 167 |
if cmd == "/run":
|
|
@@ -180,19 +180,19 @@ class Conversation:
|
|
| 180 |
recent = [t for t in _tries.get(key, []) if now - t < 600]
|
| 181 |
if len(recent) >= LINK_TRIES:
|
| 182 |
_tries[key] = recent
|
| 183 |
-
return OutMessage("Too many tries. Wait 10 minutes, then make a new code in
|
| 184 |
_tries[key] = recent + [now]
|
| 185 |
if not code:
|
| 186 |
return OutMessage(LINK_HELP)
|
| 187 |
row = self.db.one("SELECT * FROM channel_link_codes WHERE code_hash=? AND channel=?", (_hash(code), inb.channel))
|
| 188 |
if not row or row["used_at"] or _utc(row["expires_at"]) <= datetime.now(timezone.utc):
|
| 189 |
self._audit("link.refused", inb, summary="unknown, used or expired link code")
|
| 190 |
-
return OutMessage("That code is not valid (codes work once, for 10 minutes). Make a new one in
|
| 191 |
if not self.db.x("UPDATE channel_link_codes SET used_at=? WHERE code_hash=? AND used_at IS NULL", (now_iso(), row["code_hash"])):
|
| 192 |
-
return OutMessage("That code was just used. Make a new one in
|
| 193 |
u = self.svc.users.get(int(row["user_id"]))
|
| 194 |
if not u or u.get("disabled"):
|
| 195 |
-
return OutMessage("That
|
| 196 |
with self.db.tx() as c:
|
| 197 |
c.execute("DELETE FROM channel_links WHERE channel=? AND (external_user_id=? OR user_id=?)",
|
| 198 |
(inb.channel, inb.external_user_id, u["id"]))
|
|
@@ -323,7 +323,7 @@ class Conversation:
|
|
| 323 |
"approve_scenarios": f"Done: {res.get('approved', 'the')} scenarios approved; testing starts now.",
|
| 324 |
"cancel_run": "Done: the test run was cancelled.", "add_note": "Done: the note is saved."}.get(str(payload.get("tool")), "Done.")
|
| 325 |
url = absolute(self.svc, res.get("to"))
|
| 326 |
-
return OutMessage(words, [[Button("Open in
|
| 327 |
|
| 328 |
def _cancel(self, inb: Inbound, user, payload: dict) -> OutMessage:
|
| 329 |
from ..chat.service import ChatError, ChatService
|
|
@@ -366,7 +366,7 @@ def notification_buttons(conv: Conversation, chat: Inbound, user, event: dict) -
|
|
| 366 |
url = absolute(conv.svc, event.get("link"))
|
| 367 |
if url:
|
| 368 |
label = {"run.waiting_approval": "Open review", "run.waiting_decision": "Open failures", "run.finished": "Open report"}.get(
|
| 369 |
-
str(event.get("kind")), "Open in
|
| 370 |
row.append(Button(label, url=url))
|
| 371 |
return [row] if row else []
|
| 372 |
|
|
@@ -388,8 +388,8 @@ def _run_words(rest: str) -> str:
|
|
| 388 |
return f"start a {mode} of {what}"
|
| 389 |
|
| 390 |
|
| 391 |
-
WELCOME = "Hello, I'm the
|
| 392 |
-
LINK_HELP = ("To link this chat to your
|
| 393 |
"then send me /link CODE here.")
|
| 394 |
HELP_COMMANDS = ("/status: what is waiting for you\n/run Procure-to-Pay quick: start a test run (you confirm first)\n"
|
| 395 |
"/unlink: stop using this chat\nOr just ask, for example: Is Procure-to-Pay ready for 26C?")
|
|
|
|
| 2 |
|
| 3 |
A channel adapter turns its platform's messages into `Inbound` and sends `OutMessage` back; everything else lives here:
|
| 4 |
|
| 5 |
+
- Linking: a person links a chat to their Astra account with a one-time code made in the app (Account > Telegram).
|
| 6 |
Only the code's hash is stored; it works once, for 10 minutes. From then on the bot acts as that user, with that user's
|
| 7 |
role: the same RBAC as the screens. An unlinked chat only gets help and "/link CODE".
|
| 8 |
- Talking: any free text goes to the Ask service (coworker/chat/service.py) exactly as the Ask page does, as that user:
|
|
|
|
| 141 |
link = self._link(inb)
|
| 142 |
if inb.callback_data is not None:
|
| 143 |
if not link:
|
| 144 |
+
return [OutMessage("This chat is not linked to a Astra account yet. " + LINK_HELP)]
|
| 145 |
user = self._principal(link)
|
| 146 |
if not user:
|
| 147 |
+
return [OutMessage("This Astra account is switched off. Ask an administrator.")]
|
| 148 |
return self._callback(inb, user, link)
|
| 149 |
text = (inb.text or "").strip()
|
| 150 |
cmd, _, rest = text.partition(" ")
|
|
|
|
| 155 |
return [OutMessage(WELCOME + "\n\n" + LINK_HELP)]
|
| 156 |
user = self._principal(link)
|
| 157 |
if not user:
|
| 158 |
+
return [OutMessage("This Astra account is switched off. Ask an administrator.")]
|
| 159 |
if cmd in ("/start", "/help"):
|
| 160 |
return [OutMessage(HELP.format(name=user.username))]
|
| 161 |
if cmd == "/unlink":
|
| 162 |
self.db.x("DELETE FROM channel_links WHERE id=?", (link["id"],))
|
| 163 |
self._audit("unlinked", inb, user, summary=f"{inb.channel} chat unlinked")
|
| 164 |
+
return [OutMessage("This chat is no longer linked. You will not get Astra messages here. Link again with /link CODE.")]
|
| 165 |
if cmd == "/status":
|
| 166 |
return [self._status(user, inb)]
|
| 167 |
if cmd == "/run":
|
|
|
|
| 180 |
recent = [t for t in _tries.get(key, []) if now - t < 600]
|
| 181 |
if len(recent) >= LINK_TRIES:
|
| 182 |
_tries[key] = recent
|
| 183 |
+
return OutMessage("Too many tries. Wait 10 minutes, then make a new code in Astra.")
|
| 184 |
_tries[key] = recent + [now]
|
| 185 |
if not code:
|
| 186 |
return OutMessage(LINK_HELP)
|
| 187 |
row = self.db.one("SELECT * FROM channel_link_codes WHERE code_hash=? AND channel=?", (_hash(code), inb.channel))
|
| 188 |
if not row or row["used_at"] or _utc(row["expires_at"]) <= datetime.now(timezone.utc):
|
| 189 |
self._audit("link.refused", inb, summary="unknown, used or expired link code")
|
| 190 |
+
return OutMessage("That code is not valid (codes work once, for 10 minutes). Make a new one in Astra: Account > Telegram.")
|
| 191 |
if not self.db.x("UPDATE channel_link_codes SET used_at=? WHERE code_hash=? AND used_at IS NULL", (now_iso(), row["code_hash"])):
|
| 192 |
+
return OutMessage("That code was just used. Make a new one in Astra.")
|
| 193 |
u = self.svc.users.get(int(row["user_id"]))
|
| 194 |
if not u or u.get("disabled"):
|
| 195 |
+
return OutMessage("That Astra account is switched off. Ask an administrator.")
|
| 196 |
with self.db.tx() as c:
|
| 197 |
c.execute("DELETE FROM channel_links WHERE channel=? AND (external_user_id=? OR user_id=?)",
|
| 198 |
(inb.channel, inb.external_user_id, u["id"]))
|
|
|
|
| 323 |
"approve_scenarios": f"Done: {res.get('approved', 'the')} scenarios approved; testing starts now.",
|
| 324 |
"cancel_run": "Done: the test run was cancelled.", "add_note": "Done: the note is saved."}.get(str(payload.get("tool")), "Done.")
|
| 325 |
url = absolute(self.svc, res.get("to"))
|
| 326 |
+
return OutMessage(words, [[Button("Open in Astra", url=url)]] if url else [])
|
| 327 |
|
| 328 |
def _cancel(self, inb: Inbound, user, payload: dict) -> OutMessage:
|
| 329 |
from ..chat.service import ChatError, ChatService
|
|
|
|
| 366 |
url = absolute(conv.svc, event.get("link"))
|
| 367 |
if url:
|
| 368 |
label = {"run.waiting_approval": "Open review", "run.waiting_decision": "Open failures", "run.finished": "Open report"}.get(
|
| 369 |
+
str(event.get("kind")), "Open in Astra")
|
| 370 |
row.append(Button(label, url=url))
|
| 371 |
return [row] if row else []
|
| 372 |
|
|
|
|
| 388 |
return f"start a {mode} of {what}"
|
| 389 |
|
| 390 |
|
| 391 |
+
WELCOME = "Hello, I'm the Astra bot. I tell you when a test run needs you, and you can ask me about your patches."
|
| 392 |
+
LINK_HELP = ("To link this chat to your Astra account: in Astra open Account > Telegram, press \"Get a link code\", "
|
| 393 |
"then send me /link CODE here.")
|
| 394 |
HELP_COMMANDS = ("/status: what is waiting for you\n/run Procure-to-Pay quick: start a test run (you confirm first)\n"
|
| 395 |
"/unlink: stop using this chat\nOr just ask, for example: Is Procure-to-Pay ready for 26C?")
|
coworker/config.py
CHANGED
|
@@ -37,7 +37,7 @@ class Settings(BaseSettings):
|
|
| 37 |
web_dist: Path = Field(default=ROOT / "web" / "dist", validation_alias=_alias("fpt_web_dist", "web_dist"))
|
| 38 |
oidc_issuer: str = ""
|
| 39 |
# shown in the menu and on the sign-in page (a reseller or customer can set its own)
|
| 40 |
-
product_name: str = Field("
|
| 41 |
org_name: str = Field("", validation_alias=_alias("fpt_org_name", "org_name"))
|
| 42 |
|
| 43 |
# ---- Supabase (optional): identity provider for sign-in / registration, and storage for the encrypted state archive.
|
|
|
|
| 37 |
web_dist: Path = Field(default=ROOT / "web" / "dist", validation_alias=_alias("fpt_web_dist", "web_dist"))
|
| 38 |
oidc_issuer: str = ""
|
| 39 |
# shown in the menu and on the sign-in page (a reseller or customer can set its own)
|
| 40 |
+
product_name: str = Field("Astra", validation_alias=_alias("fpt_product_name", "product_name"))
|
| 41 |
org_name: str = Field("", validation_alias=_alias("fpt_org_name", "org_name"))
|
| 42 |
|
| 43 |
# ---- Supabase (optional): identity provider for sign-in / registration, and storage for the encrypted state archive.
|
coworker/graph/nodes/research.py
CHANGED
|
@@ -79,7 +79,7 @@ def scout(state, config, svc) -> dict:
|
|
| 79 |
roles: set[str] = set()
|
| 80 |
found = None
|
| 81 |
if getattr(pod, "kind", "") == "fusion":
|
| 82 |
-
found = _discover(svc, run_id, pod, state.get("
|
| 83 |
status = {a["code"]: a for a in found["areas"]}
|
| 84 |
for m in pod.modules():
|
| 85 |
if found is not None: # a Fusion pod: keep the areas discovery found on it, with their real record counts
|
|
|
|
| 79 |
roles: set[str] = set()
|
| 80 |
found = None
|
| 81 |
if getattr(pod, "kind", "") == "fusion":
|
| 82 |
+
found = _discover(svc, run_id, pod, state.get("modules_requested") or None) # the areas this run was started for
|
| 83 |
status = {a["code"]: a for a in found["areas"]}
|
| 84 |
for m in pod.modules():
|
| 85 |
if found is not None: # a Fusion pod: keep the areas discovery found on it, with their real record counts
|
coworker/platform/assets/astra-logo.png
ADDED
|
coworker/platform/brand.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""The product name and logo for documents (report HTML/PDF, Excel). The web app reads the name from /api/ready (product_name).
|
| 2 |
|
| 3 |
-
The logo is the
|
| 4 |
-
|
| 5 |
from __future__ import annotations
|
| 6 |
|
| 7 |
import base64
|
|
@@ -11,23 +11,24 @@ from pathlib import Path
|
|
| 11 |
|
| 12 |
from ..config import VERSION
|
| 13 |
|
| 14 |
-
NAME = "
|
| 15 |
-
LEGAL = "
|
| 16 |
-
|
| 17 |
|
| 18 |
|
| 19 |
@lru_cache(maxsize=1)
|
| 20 |
def wordmark_data_uri() -> str:
|
| 21 |
-
"""The
|
| 22 |
try:
|
| 23 |
-
return "data:image/
|
| 24 |
except OSError:
|
| 25 |
return ""
|
| 26 |
|
| 27 |
|
| 28 |
def header_html() -> str:
|
| 29 |
uri = wordmark_data_uri()
|
| 30 |
-
logo = f"<img src='{uri}' alt='
|
|
|
|
| 31 |
return f"<div style='display:flex;align-items:center;gap:12px;padding:0 0 10px;border-bottom:1px solid #d2d2d7;margin-bottom:12px'>{logo}</div>"
|
| 32 |
|
| 33 |
|
|
|
|
| 1 |
"""The product name and logo for documents (report HTML/PDF, Excel). The web app reads the name from /api/ready (product_name).
|
| 2 |
|
| 3 |
+
The logo is the CES logo (assets/astra-logo.png, the same file as web/public/astra-logo.png), shown next to the name, so a
|
| 4 |
+
report stays one self-contained file (the image is embedded as a data URI)."""
|
| 5 |
from __future__ import annotations
|
| 6 |
|
| 7 |
import base64
|
|
|
|
| 11 |
|
| 12 |
from ..config import VERSION
|
| 13 |
|
| 14 |
+
NAME = "Astra"
|
| 15 |
+
LEGAL = "Astra is independent software. Oracle and Fusion are trademarks of Oracle Corporation."
|
| 16 |
+
_LOGO = Path(__file__).with_name("assets") / "astra-logo.png"
|
| 17 |
|
| 18 |
|
| 19 |
@lru_cache(maxsize=1)
|
| 20 |
def wordmark_data_uri() -> str:
|
| 21 |
+
"""The logo as a data URI, so a report stays one self-contained file. Empty when the asset is missing."""
|
| 22 |
try:
|
| 23 |
+
return "data:image/png;base64," + base64.b64encode(_LOGO.read_bytes()).decode("ascii")
|
| 24 |
except OSError:
|
| 25 |
return ""
|
| 26 |
|
| 27 |
|
| 28 |
def header_html() -> str:
|
| 29 |
uri = wordmark_data_uri()
|
| 30 |
+
logo = (f"<img src='{uri}' alt='' style='height:30px;width:auto;display:block'><b style='font-size:18px'>{NAME}</b>"
|
| 31 |
+
if uri else f"<b>{NAME}</b>")
|
| 32 |
return f"<div style='display:flex;align-items:center;gap:12px;padding:0 0 10px;border-bottom:1px solid #d2d2d7;margin-bottom:12px'>{logo}</div>"
|
| 33 |
|
| 34 |
|
coworker/platform/integrations.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""Incoming-webhook integrations: Slack, Microsoft Teams, Google Chat and Discord receive the notification outbox.
|
| 2 |
|
| 3 |
- What they get: the same events as the other channels (a run waits for approval or a decision, finished, failed or
|
| 4 |
-
stopped, a defect was raised), in each service's own message format, with an "Open in
|
| 5 |
is an absolute https address. Text from the app is neutralised so it can never mention everyone or inject markup.
|
| 6 |
- The webhook address is the credential (whoever holds it can post): it is stored in the vault under
|
| 7 |
INTEGRATION_<KEY>_WEBHOOK, never returned by the API, and the audit and the server log only ever show its host.
|
|
@@ -95,14 +95,14 @@ def _discord_text(s: Any) -> str:
|
|
| 95 |
|
| 96 |
def message(key: str, row: dict) -> dict:
|
| 97 |
"""The JSON body each service expects for one outbox row."""
|
| 98 |
-
coworker = str(row.get("coworker") or "
|
| 99 |
title, body = str(row.get("title") or ""), str(row.get("body") or "")
|
| 100 |
link = _https(row.get("link"))
|
| 101 |
if key == "slack":
|
| 102 |
text = f"*{_slack_text(coworker)}*\n{_slack_text(title)}" + (f"\n{_slack_text(body)}" if body else "")
|
| 103 |
blocks: list[dict] = [{"type": "section", "text": {"type": "mrkdwn", "text": text}}]
|
| 104 |
if link:
|
| 105 |
-
blocks.append({"type": "actions", "elements": [{"type": "button", "text": {"type": "plain_text", "text": "Open in
|
| 106 |
"url": link}]})
|
| 107 |
return {"text": f"{_slack_text(coworker)}: {_slack_text(title)}", "blocks": blocks}
|
| 108 |
if key == "teams":
|
|
@@ -113,14 +113,14 @@ def message(key: str, row: dict) -> dict:
|
|
| 113 |
+ ([{"type": "TextBlock", "text": body, "wrap": True, "isSubtle": True}] if body else []),
|
| 114 |
}
|
| 115 |
if link:
|
| 116 |
-
content["actions"] = [{"type": "Action.OpenUrl", "title": "Open in
|
| 117 |
return {"type": "message", "attachments": [{"contentType": "application/vnd.microsoft.card.adaptive", "content": content}]}
|
| 118 |
if key == "google_chat":
|
| 119 |
text = f"*{_plain_angle(coworker)}*\n{_plain_angle(title)}" + (f"\n{_plain_angle(body)}" if body else "")
|
| 120 |
msg: dict[str, Any] = {"text": text}
|
| 121 |
if link:
|
| 122 |
msg["cardsV2"] = [{"cardId": f"patchwise-{row.get('id')}", "card": {"sections": [{"widgets": [
|
| 123 |
-
{"buttonList": {"buttons": [{"text": "Open in
|
| 124 |
return msg
|
| 125 |
if key == "discord":
|
| 126 |
content = f"**{_discord_text(coworker)}**: {_discord_text(title)}" + (f"\n{_discord_text(body)}" if body else "")
|
|
@@ -173,8 +173,8 @@ def queue_test(svc, key: str) -> int:
|
|
| 173 |
administrator chat (and linked chats skip this kind), so the other channels don't receive it."""
|
| 174 |
now = now_iso()
|
| 175 |
row = {"kind": TEST_KIND, "run_id": None, "title": "This is a test message",
|
| 176 |
-
"body": f"{NAMES[key]} is connected:
|
| 177 |
-
"coworker": "
|
| 178 |
"created_at": now, "target": key}
|
| 179 |
with svc.db.tx() as c:
|
| 180 |
cur = c.execute("INSERT INTO notify_events (kind, run_id, title, body, coworker, link, payload_json, created_at, next_attempt_at, "
|
|
|
|
| 1 |
"""Incoming-webhook integrations: Slack, Microsoft Teams, Google Chat and Discord receive the notification outbox.
|
| 2 |
|
| 3 |
- What they get: the same events as the other channels (a run waits for approval or a decision, finished, failed or
|
| 4 |
+
stopped, a defect was raised), in each service's own message format, with an "Open in Astra" button when the link
|
| 5 |
is an absolute https address. Text from the app is neutralised so it can never mention everyone or inject markup.
|
| 6 |
- The webhook address is the credential (whoever holds it can post): it is stored in the vault under
|
| 7 |
INTEGRATION_<KEY>_WEBHOOK, never returned by the API, and the audit and the server log only ever show its host.
|
|
|
|
| 95 |
|
| 96 |
def message(key: str, row: dict) -> dict:
|
| 97 |
"""The JSON body each service expects for one outbox row."""
|
| 98 |
+
coworker = str(row.get("coworker") or "Astra")
|
| 99 |
title, body = str(row.get("title") or ""), str(row.get("body") or "")
|
| 100 |
link = _https(row.get("link"))
|
| 101 |
if key == "slack":
|
| 102 |
text = f"*{_slack_text(coworker)}*\n{_slack_text(title)}" + (f"\n{_slack_text(body)}" if body else "")
|
| 103 |
blocks: list[dict] = [{"type": "section", "text": {"type": "mrkdwn", "text": text}}]
|
| 104 |
if link:
|
| 105 |
+
blocks.append({"type": "actions", "elements": [{"type": "button", "text": {"type": "plain_text", "text": "Open in Astra"},
|
| 106 |
"url": link}]})
|
| 107 |
return {"text": f"{_slack_text(coworker)}: {_slack_text(title)}", "blocks": blocks}
|
| 108 |
if key == "teams":
|
|
|
|
| 113 |
+ ([{"type": "TextBlock", "text": body, "wrap": True, "isSubtle": True}] if body else []),
|
| 114 |
}
|
| 115 |
if link:
|
| 116 |
+
content["actions"] = [{"type": "Action.OpenUrl", "title": "Open in Astra", "url": link}]
|
| 117 |
return {"type": "message", "attachments": [{"contentType": "application/vnd.microsoft.card.adaptive", "content": content}]}
|
| 118 |
if key == "google_chat":
|
| 119 |
text = f"*{_plain_angle(coworker)}*\n{_plain_angle(title)}" + (f"\n{_plain_angle(body)}" if body else "")
|
| 120 |
msg: dict[str, Any] = {"text": text}
|
| 121 |
if link:
|
| 122 |
msg["cardsV2"] = [{"cardId": f"patchwise-{row.get('id')}", "card": {"sections": [{"widgets": [
|
| 123 |
+
{"buttonList": {"buttons": [{"text": "Open in Astra", "onClick": {"openLink": {"url": link}}}]}}]}]}}]
|
| 124 |
return msg
|
| 125 |
if key == "discord":
|
| 126 |
content = f"**{_discord_text(coworker)}**: {_discord_text(title)}" + (f"\n{_discord_text(body)}" if body else "")
|
|
|
|
| 173 |
administrator chat (and linked chats skip this kind), so the other channels don't receive it."""
|
| 174 |
now = now_iso()
|
| 175 |
row = {"kind": TEST_KIND, "run_id": None, "title": "This is a test message",
|
| 176 |
+
"body": f"{NAMES[key]} is connected: Astra will post here when a test run needs you.",
|
| 177 |
+
"coworker": "Astra", "link": f"{(svc.cfg.public_url or '').rstrip('/')}/" if svc.cfg.public_url else "/",
|
| 178 |
"created_at": now, "target": key}
|
| 179 |
with svc.db.tx() as c:
|
| 180 |
cur = c.execute("INSERT INTO notify_events (kind, run_id, title, body, coworker, link, payload_json, created_at, next_attempt_at, "
|
coworker/platform/notify.py
CHANGED
|
@@ -51,20 +51,20 @@ COWORKER = {
|
|
| 51 |
"run.waiting_approval": "Test generator",
|
| 52 |
"run.waiting_decision": "Triage",
|
| 53 |
"run.finished": "Triage",
|
| 54 |
-
"run.failed": "
|
| 55 |
-
"run.stopped": "
|
| 56 |
"defect.created": "Triage",
|
| 57 |
-
"test": "
|
| 58 |
}
|
| 59 |
DECISION_WORDS = {"GO": "Ready", "NO-GO": "Not ready", "HELD": "Held"}
|
| 60 |
-
COWORKER["channel.telegram"] = "
|
| 61 |
|
| 62 |
TG_API = "https://api.telegram.org"
|
| 63 |
TG_KV = "notify_telegram" # {"chat_id", "title", "since"}: the chosen chat, and when it was connected
|
| 64 |
TG_ENV_SINCE_KV = "notify_telegram_env_since"
|
| 65 |
TG_REFUSED_GIVE_UP = 2 # a chat that answers 400 / 403 (not found, bot blocked) is retried once, then dropped
|
| 66 |
TG_BACKFILL = timedelta(hours=1) # a new chat gets at most the last hour of events, never an old backlog
|
| 67 |
-
TG_WELCOME = "Telegram is connected:
|
| 68 |
|
| 69 |
|
| 70 |
|
|
@@ -149,17 +149,17 @@ def telegram_text(row: dict) -> str:
|
|
| 149 |
nxt = d.get("next", row.get("body"))
|
| 150 |
if nxt:
|
| 151 |
out += ["", f"\U0001F449 {escape(str(nxt))}"]
|
| 152 |
-
out += ["", f"<i>\u2014 {escape(str(row.get('coworker') or '
|
| 153 |
text = "\n".join(out)
|
| 154 |
return text if len(text) <= TG_MAX else text[:TG_MAX].rsplit("\n", 1)[0] + "\n\u2026"
|
| 155 |
|
| 156 |
|
| 157 |
def telegram_message(chat_id: str, row: dict) -> dict:
|
| 158 |
-
"""The sendMessage body. The "Open in
|
| 159 |
msg: dict[str, Any] = {"chat_id": chat_id, "text": telegram_text(row), "parse_mode": "HTML", "disable_web_page_preview": True}
|
| 160 |
link = str(row.get("link") or "")
|
| 161 |
if link.startswith("https://"):
|
| 162 |
-
msg["reply_markup"] = {"inline_keyboard": [[{"text": "Open in
|
| 163 |
return msg
|
| 164 |
|
| 165 |
|
|
@@ -241,7 +241,7 @@ class Notifier:
|
|
| 241 |
base = (self.cfg.public_url or "").rstrip("/")
|
| 242 |
link = f"{base}{path}" if base else path
|
| 243 |
row = {"kind": kind, "run_id": (run or {}).get("run_id"), "title": title, "body": body,
|
| 244 |
-
"coworker": COWORKER.get(kind, "
|
| 245 |
"details": self._run_details(kind, run or {}, extra)}
|
| 246 |
with self.db.tx() as c:
|
| 247 |
cur = c.execute("INSERT INTO notify_events (kind, run_id, title, body, coworker, link, payload_json, created_at, next_attempt_at) "
|
|
|
|
| 51 |
"run.waiting_approval": "Test generator",
|
| 52 |
"run.waiting_decision": "Triage",
|
| 53 |
"run.finished": "Triage",
|
| 54 |
+
"run.failed": "Astra",
|
| 55 |
+
"run.stopped": "Astra",
|
| 56 |
"defect.created": "Triage",
|
| 57 |
+
"test": "Astra",
|
| 58 |
}
|
| 59 |
DECISION_WORDS = {"GO": "Ready", "NO-GO": "Not ready", "HELD": "Held"}
|
| 60 |
+
COWORKER["channel.telegram"] = "Astra"
|
| 61 |
|
| 62 |
TG_API = "https://api.telegram.org"
|
| 63 |
TG_KV = "notify_telegram" # {"chat_id", "title", "since"}: the chosen chat, and when it was connected
|
| 64 |
TG_ENV_SINCE_KV = "notify_telegram_env_since"
|
| 65 |
TG_REFUSED_GIVE_UP = 2 # a chat that answers 400 / 403 (not found, bot blocked) is retried once, then dropped
|
| 66 |
TG_BACKFILL = timedelta(hours=1) # a new chat gets at most the last hour of events, never an old backlog
|
| 67 |
+
TG_WELCOME = "Telegram is connected: Astra will tell you here when a test run needs you."
|
| 68 |
|
| 69 |
|
| 70 |
|
|
|
|
| 149 |
nxt = d.get("next", row.get("body"))
|
| 150 |
if nxt:
|
| 151 |
out += ["", f"\U0001F449 {escape(str(nxt))}"]
|
| 152 |
+
out += ["", f"<i>\u2014 {escape(str(row.get('coworker') or 'Astra'))}</i>"]
|
| 153 |
text = "\n".join(out)
|
| 154 |
return text if len(text) <= TG_MAX else text[:TG_MAX].rsplit("\n", 1)[0] + "\n\u2026"
|
| 155 |
|
| 156 |
|
| 157 |
def telegram_message(chat_id: str, row: dict) -> dict:
|
| 158 |
+
"""The sendMessage body. The "Open in Astra" button only for an absolute https link (Telegram refuses others)."""
|
| 159 |
msg: dict[str, Any] = {"chat_id": chat_id, "text": telegram_text(row), "parse_mode": "HTML", "disable_web_page_preview": True}
|
| 160 |
link = str(row.get("link") or "")
|
| 161 |
if link.startswith("https://"):
|
| 162 |
+
msg["reply_markup"] = {"inline_keyboard": [[{"text": "Open in Astra", "url": link}]]}
|
| 163 |
return msg
|
| 164 |
|
| 165 |
|
|
|
|
| 241 |
base = (self.cfg.public_url or "").rstrip("/")
|
| 242 |
link = f"{base}{path}" if base else path
|
| 243 |
row = {"kind": kind, "run_id": (run or {}).get("run_id"), "title": title, "body": body,
|
| 244 |
+
"coworker": COWORKER.get(kind, "Astra"), "link": link, "created_at": now_iso(),
|
| 245 |
"details": self._run_details(kind, run or {}, extra)}
|
| 246 |
with self.db.tx() as c:
|
| 247 |
cur = c.execute("INSERT INTO notify_events (kind, run_id, title, body, coworker, link, payload_json, created_at, next_attempt_at) "
|
coworker/platform/report_pdf.py
CHANGED
|
@@ -136,7 +136,8 @@ def bundle_html(*, run_id: str, module: str, area_name: str, decision: str, deci
|
|
| 136 |
generated = generated or datetime.now().astimezone()
|
| 137 |
word, tone = VERDICT.get(decision, (decision, "held"))
|
| 138 |
logo = brand.wordmark_data_uri()
|
| 139 |
-
logo_html = f"<img src='{logo}' alt='
|
|
|
|
| 140 |
failed = int(counts.get("failed", 0) or 0) + int(counts.get("real_defect", 0) or 0)
|
| 141 |
|
| 142 |
stats = "".join(
|
|
|
|
| 136 |
generated = generated or datetime.now().astimezone()
|
| 137 |
word, tone = VERDICT.get(decision, (decision, "held"))
|
| 138 |
logo = brand.wordmark_data_uri()
|
| 139 |
+
logo_html = (f"<img src='{logo}' alt='' style='width:auto'> <b>{_e(brand.NAME)}</b>" if logo # the logo, then the name
|
| 140 |
+
else f"<b>{_e(brand.NAME)}</b>")
|
| 141 |
failed = int(counts.get("failed", 0) or 0) + int(counts.get("real_defect", 0) or 0)
|
| 142 |
|
| 143 |
stats = "".join(
|
coworker/tests/test_a2a.py
CHANGED
|
@@ -68,7 +68,7 @@ class TestCardAndAuth(A2ACase):
|
|
| 68 |
r = self.c.get("/.well-known/agent-card.json")
|
| 69 |
self.assertEqual(r.status_code, 200)
|
| 70 |
card = r.json()
|
| 71 |
-
self.assertEqual((card["name"], card["protocolVersion"], card["preferredTransport"]), ("
|
| 72 |
self.assertEqual(card["url"], "https://patchwise.example/a2a")
|
| 73 |
self.assertEqual(card["capabilities"], {"streaming": True, "pushNotifications": False, "stateTransitionHistory": True})
|
| 74 |
self.assertEqual(card["securitySchemes"]["bearer"]["scheme"], "bearer")
|
|
@@ -174,7 +174,7 @@ class TestRunTests(A2ACase):
|
|
| 174 |
self.runs.drain()
|
| 175 |
g = self.get(tok, t["id"])
|
| 176 |
self.assertEqual(g["status"]["state"], "input-required")
|
| 177 |
-
self.assertIn("Waiting for a person to approve the scenarios in
|
| 178 |
refused = self.send(tok, data_msg({"approve": True}, taskId=t["id"])) # the caller can't approve
|
| 179 |
self.assertIn("Only a person", self.status_text(refused))
|
| 180 |
self.assertEqual(self.svc.db.get_run(rid)["pending_gate"], "approve_cases")
|
|
@@ -332,7 +332,7 @@ class TestTheseCases(Rpc, tcc.Base):
|
|
| 332 |
self.assertIn("No case has been approved by a person yet", self.status_text(again))
|
| 333 |
self.assertEqual(self.svc.db.one("SELECT state FROM custom_cases WHERE batch_id=?", (bid,))["state"], "dry_run_passed")
|
| 334 |
self.assertIsNone(again["metadata"]["run_id"])
|
| 335 |
-
# a person approves in
|
| 336 |
r = self.c.post(f"/api/custom-cases/{bid}/approve", json={"keys": ["c1"]}, headers=self.h["consultant"])
|
| 337 |
self.assertEqual(r.status_code, 200, r.text)
|
| 338 |
g = self.get(tok, t["id"])
|
|
|
|
| 68 |
r = self.c.get("/.well-known/agent-card.json")
|
| 69 |
self.assertEqual(r.status_code, 200)
|
| 70 |
card = r.json()
|
| 71 |
+
self.assertEqual((card["name"], card["protocolVersion"], card["preferredTransport"]), ("Astra", "0.3.0", "JSONRPC"))
|
| 72 |
self.assertEqual(card["url"], "https://patchwise.example/a2a")
|
| 73 |
self.assertEqual(card["capabilities"], {"streaming": True, "pushNotifications": False, "stateTransitionHistory": True})
|
| 74 |
self.assertEqual(card["securitySchemes"]["bearer"]["scheme"], "bearer")
|
|
|
|
| 174 |
self.runs.drain()
|
| 175 |
g = self.get(tok, t["id"])
|
| 176 |
self.assertEqual(g["status"]["state"], "input-required")
|
| 177 |
+
self.assertIn("Waiting for a person to approve the scenarios in Astra: https://patchwise.example/runs/", self.status_text(g))
|
| 178 |
refused = self.send(tok, data_msg({"approve": True}, taskId=t["id"])) # the caller can't approve
|
| 179 |
self.assertIn("Only a person", self.status_text(refused))
|
| 180 |
self.assertEqual(self.svc.db.get_run(rid)["pending_gate"], "approve_cases")
|
|
|
|
| 332 |
self.assertIn("No case has been approved by a person yet", self.status_text(again))
|
| 333 |
self.assertEqual(self.svc.db.one("SELECT state FROM custom_cases WHERE batch_id=?", (bid,))["state"], "dry_run_passed")
|
| 334 |
self.assertIsNone(again["metadata"]["run_id"])
|
| 335 |
+
# a person approves in Astra
|
| 336 |
r = self.c.post(f"/api/custom-cases/{bid}/approve", json={"keys": ["c1"]}, headers=self.h["consultant"])
|
| 337 |
self.assertEqual(r.status_code, 200, r.text)
|
| 338 |
g = self.get(tok, t["id"])
|
coworker/tests/test_brand.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""The product is "
|
| 2 |
from __future__ import annotations
|
| 3 |
|
| 4 |
import unittest
|
|
@@ -9,23 +9,20 @@ from coworker.platform import brand
|
|
| 9 |
|
| 10 |
class TestBrand(unittest.TestCase):
|
| 11 |
def test_default_product_name(self):
|
| 12 |
-
self.assertEqual(Settings().product_name, "
|
| 13 |
|
| 14 |
-
def
|
| 15 |
h = brand.header_html()
|
| 16 |
-
self.assertIn("data:image/
|
| 17 |
-
self.assertIn("
|
| 18 |
|
| 19 |
-
def
|
| 20 |
import base64
|
|
|
|
| 21 |
h = brand.header_html()
|
| 22 |
-
|
| 23 |
-
self.
|
| 24 |
-
self.
|
| 25 |
-
self.assertIn("#34c759", svg) # the one green status dot
|
| 26 |
-
self.assertIn("aria-label=\"Patchwise\"", svg)
|
| 27 |
-
for blue in ("0071e3", "0a84ff", "2997ff", "4aa3ff", "0062d6"):
|
| 28 |
-
self.assertNotIn(blue, svg.lower()) # no blue anywhere in the brand
|
| 29 |
|
| 30 |
def test_every_brand_asset_is_free_of_blue_and_live_text(self):
|
| 31 |
from coworker.config import ROOT
|
|
@@ -38,7 +35,7 @@ class TestBrand(unittest.TestCase):
|
|
| 38 |
|
| 39 |
def test_report_footer_names_the_product_version_and_the_legal_line(self):
|
| 40 |
f = brand.footer_html("Mock app, not Oracle Fusion.")
|
| 41 |
-
self.assertIn(f"Generated by
|
| 42 |
self.assertIn("Mock app, not Oracle Fusion.", f)
|
| 43 |
self.assertIn("Oracle and Fusion are trademarks of Oracle Corporation", f)
|
| 44 |
|
|
@@ -46,7 +43,7 @@ class TestBrand(unittest.TestCase):
|
|
| 46 |
import json
|
| 47 |
from coworker.config import ROOT
|
| 48 |
spec = json.loads((ROOT / "web" / "src" / "api" / "openapi.json").read_text(encoding="utf-8"))
|
| 49 |
-
self.assertEqual(spec["info"]["title"], "
|
| 50 |
|
| 51 |
|
| 52 |
if __name__ == "__main__":
|
|
|
|
| 1 |
+
"""The product is "Astra" (logo: the CES logo): default name, API docs title, and the report header and footer."""
|
| 2 |
from __future__ import annotations
|
| 3 |
|
| 4 |
import unittest
|
|
|
|
| 9 |
|
| 10 |
class TestBrand(unittest.TestCase):
|
| 11 |
def test_default_product_name(self):
|
| 12 |
+
self.assertEqual(Settings().product_name, "Astra")
|
| 13 |
|
| 14 |
+
def test_report_header_has_the_logo_as_a_data_uri_and_the_name(self):
|
| 15 |
h = brand.header_html()
|
| 16 |
+
self.assertIn("data:image/png;base64,", h) # one self-contained file: no external logo request
|
| 17 |
+
self.assertIn("<b style='font-size:18px'>Astra</b>", h)
|
| 18 |
|
| 19 |
+
def test_the_logo_is_the_ces_png_shared_with_the_web_app(self):
|
| 20 |
import base64
|
| 21 |
+
from coworker.config import ROOT
|
| 22 |
h = brand.header_html()
|
| 23 |
+
png = base64.b64decode(h.split("base64,")[1].split("'")[0])
|
| 24 |
+
self.assertEqual(png[1:4], b"PNG")
|
| 25 |
+
self.assertEqual(png, (ROOT / "web" / "public" / "astra-logo.png").read_bytes()) # one logo, the same everywhere
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
def test_every_brand_asset_is_free_of_blue_and_live_text(self):
|
| 28 |
from coworker.config import ROOT
|
|
|
|
| 35 |
|
| 36 |
def test_report_footer_names_the_product_version_and_the_legal_line(self):
|
| 37 |
f = brand.footer_html("Mock app, not Oracle Fusion.")
|
| 38 |
+
self.assertIn(f"Generated by Astra v{VERSION}", f)
|
| 39 |
self.assertIn("Mock app, not Oracle Fusion.", f)
|
| 40 |
self.assertIn("Oracle and Fusion are trademarks of Oracle Corporation", f)
|
| 41 |
|
|
|
|
| 43 |
import json
|
| 44 |
from coworker.config import ROOT
|
| 45 |
spec = json.loads((ROOT / "web" / "src" / "api" / "openapi.json").read_text(encoding="utf-8"))
|
| 46 |
+
self.assertEqual(spec["info"]["title"], "Astra API")
|
| 47 |
|
| 48 |
|
| 49 |
if __name__ == "__main__":
|
coworker/tests/test_mcp.py
CHANGED
|
@@ -112,7 +112,7 @@ class TestTransport(McpCase):
|
|
| 112 |
r = self.rpc(t["token"], "initialize", {"protocolVersion": "2025-03-26", "capabilities": {}, "clientInfo": {"name": "test"}})
|
| 113 |
res = r.json()["result"]
|
| 114 |
self.assertEqual(res["protocolVersion"], "2025-03-26")
|
| 115 |
-
self.assertEqual(res["serverInfo"]["name"], "
|
| 116 |
self.assertIn("Sign-off", res["instructions"])
|
| 117 |
self.assertEqual(self.rpc(t["token"], "initialize", {"protocolVersion": "1999-01-01"}).json()["result"]["protocolVersion"], "2025-06-18")
|
| 118 |
n = self.c.post("/mcp", json={"jsonrpc": "2.0", "method": "notifications/initialized"}, headers={"Authorization": f"Bearer {t['token']}"})
|
|
|
|
| 112 |
r = self.rpc(t["token"], "initialize", {"protocolVersion": "2025-03-26", "capabilities": {}, "clientInfo": {"name": "test"}})
|
| 113 |
res = r.json()["result"]
|
| 114 |
self.assertEqual(res["protocolVersion"], "2025-03-26")
|
| 115 |
+
self.assertEqual(res["serverInfo"]["name"], "Astra")
|
| 116 |
self.assertIn("Sign-off", res["instructions"])
|
| 117 |
self.assertEqual(self.rpc(t["token"], "initialize", {"protocolVersion": "1999-01-01"}).json()["result"]["protocolVersion"], "2025-06-18")
|
| 118 |
n = self.c.post("/mcp", json={"jsonrpc": "2.0", "method": "notifications/initialized"}, headers={"Authorization": f"Bearer {t['token']}"})
|
coworker/tests/test_notify_telegram.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""Telegram notifications: the app sends to the chosen chat itself. The bot token never reaches the audit log or the API;
|
| 2 |
-
the message is HTML-escaped with the "Open in
|
| 3 |
own (a failing chat never holds back the webhook); a chat that refuses is given up quickly; a new chat gets no old
|
| 4 |
backlog; the chats that wrote to the bot are found through getUpdates; only administrators manage any of it."""
|
| 5 |
from __future__ import annotations
|
|
@@ -75,9 +75,9 @@ class TestTelegram(unittest.TestCase):
|
|
| 75 |
msg = next(m for t, m in msgs.items() if "Ready" in t)
|
| 76 |
self.assertEqual(msg["chat_id"], "4242")
|
| 77 |
self.assertEqual(msg["parse_mode"], "HTML")
|
| 78 |
-
self.assertIn("<i>—
|
| 79 |
self.assertIn("Ready <now> & done", msg["text"])
|
| 80 |
-
self.assertEqual(msg["reply_markup"]["inline_keyboard"][0][0], {"text": "Open in
|
| 81 |
self.assertIsNotNone(tg_row(svc, nid)["tg_delivered_at"])
|
| 82 |
audit = json.dumps(svc.audit.query(limit=500))
|
| 83 |
self.assertNotIn(TOKEN, audit)
|
|
|
|
| 1 |
"""Telegram notifications: the app sends to the chosen chat itself. The bot token never reaches the audit log or the API;
|
| 2 |
+
the message is HTML-escaped with the "Open in Astra" button only for an https link; each channel is delivered on its
|
| 3 |
own (a failing chat never holds back the webhook); a chat that refuses is given up quickly; a new chat gets no old
|
| 4 |
backlog; the chats that wrote to the bot are found through getUpdates; only administrators manage any of it."""
|
| 5 |
from __future__ import annotations
|
|
|
|
| 75 |
msg = next(m for t, m in msgs.items() if "Ready" in t)
|
| 76 |
self.assertEqual(msg["chat_id"], "4242")
|
| 77 |
self.assertEqual(msg["parse_mode"], "HTML")
|
| 78 |
+
self.assertIn("<i>— Astra</i>", msg["text"])
|
| 79 |
self.assertIn("Ready <now> & done", msg["text"])
|
| 80 |
+
self.assertEqual(msg["reply_markup"]["inline_keyboard"][0][0], {"text": "Open in Astra", "url": "https://patchwise.example/"})
|
| 81 |
self.assertIsNotNone(tg_row(svc, nid)["tg_delivered_at"])
|
| 82 |
audit = json.dumps(svc.audit.query(limit=500))
|
| 83 |
self.assertNotIn(TOKEN, audit)
|
coworker/tests/test_pods.py
CHANGED
|
@@ -177,6 +177,29 @@ class TestPodFromServerSettings(unittest.TestCase):
|
|
| 177 |
self.assertEqual((s["state"], sorted(s["areas"])), ("done", ["CM", "PO"])) # INV failing keeps the others
|
| 178 |
self.assertIn("the INV tile did not open", s["error"])
|
| 179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
def test_without_the_secrets_the_pod_exists_but_asks_for_a_test_user(self):
|
| 181 |
import os
|
| 182 |
os.environ.pop("FPT_SECRET_FUSION_PASSWORD")
|
|
|
|
| 177 |
self.assertEqual((s["state"], sorted(s["areas"])), ("done", ["CM", "PO"])) # INV failing keeps the others
|
| 178 |
self.assertIn("the INV tile did not open", s["error"])
|
| 179 |
|
| 180 |
+
def test_a_runs_scout_reads_in_the_background_only_the_areas_the_run_tests(self):
|
| 181 |
+
from unittest import mock
|
| 182 |
+
from coworker.graph.nodes import research
|
| 183 |
+
from coworker.platform.pods import PodRegistry
|
| 184 |
+
_, _, svc, _ = make_app(fusion_base_url=self.URL)
|
| 185 |
+
asked = []
|
| 186 |
+
pod = mock.MagicMock(kind="fusion")
|
| 187 |
+
pod.about.return_value = {"environment": "test", "is_mock": False, "release": "26D"}
|
| 188 |
+
pod.modules.return_value = []
|
| 189 |
+
found = {"areas": [{"code": c, "status": "in_use", "counts": {}} for c in ("AP", "GL", "PO", "INV")], "discovered_at": "2026-11-16T00:00:00Z"}
|
| 190 |
+
state = {"run_id": "r-scout", "modules_requested": ["PO", "INV"]} # the shape create_run_record gives a run
|
| 191 |
+
with mock.patch.object(svc, "pod", return_value=pod), mock.patch.object(svc, "fusion_pod_id", return_value=1), \
|
| 192 |
+
mock.patch("coworker.platform.discovery.discover", return_value=found), \
|
| 193 |
+
mock.patch.object(PodRegistry, "read_in_background", lambda self, pid, actor, areas=None: asked.append(areas)):
|
| 194 |
+
svc.db.create_run({"run_id": "r-scout", "created_by": "t", "trigger": "manual", "patch_id": "", "modules": ["PO", "INV"],
|
| 195 |
+
"include_p2": 0, "playwright_mode": "live", "inputs": {}, "status": "running", "orchestrator": "langgraph", "pod_id": 1})
|
| 196 |
+
from coworker.graph.runtime import FatalNodeError
|
| 197 |
+
try:
|
| 198 |
+
research.scout(state, {}, svc)
|
| 199 |
+
except FatalNodeError: # this thin fake pod has no area packs; the background read was asked for before that
|
| 200 |
+
pass
|
| 201 |
+
self.assertEqual(asked, [["PO", "INV"]])
|
| 202 |
+
|
| 203 |
def test_without_the_secrets_the_pod_exists_but_asks_for_a_test_user(self):
|
| 204 |
import os
|
| 205 |
os.environ.pop("FPT_SECRET_FUSION_PASSWORD")
|
web/index.html
CHANGED
|
@@ -2,15 +2,14 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
-
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
| 6 |
<link rel="icon" type="image/png" sizes="48x48" href="/favicon-48.png" />
|
| 7 |
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png" />
|
| 8 |
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16.png" />
|
| 9 |
<link rel="apple-touch-icon" href="/apple-touch-icon-180.png" />
|
| 10 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 11 |
<meta name="color-scheme" content="light dark" />
|
| 12 |
-
<meta name="description" content="
|
| 13 |
-
<title>
|
| 14 |
</head>
|
| 15 |
<body>
|
| 16 |
<div id="root"></div>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
|
|
|
| 5 |
<link rel="icon" type="image/png" sizes="48x48" href="/favicon-48.png" />
|
| 6 |
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png" />
|
| 7 |
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16.png" />
|
| 8 |
<link rel="apple-touch-icon" href="/apple-touch-icon-180.png" />
|
| 9 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 10 |
<meta name="color-scheme" content="light dark" />
|
| 11 |
+
<meta name="description" content="Astra. Patch testing for Oracle Fusion. Mock app, not Oracle Fusion." />
|
| 12 |
+
<title>Astra</title>
|
| 13 |
</head>
|
| 14 |
<body>
|
| 15 |
<div id="root"></div>
|
web/public/apple-touch-icon-180.png
CHANGED
|
|
|
|
web/public/astra-logo.png
ADDED
|
web/public/astra-mark.png
ADDED
|
web/public/favicon-16.png
CHANGED
|
|
|
|
web/public/favicon-32.png
CHANGED
|
|
|
|
web/public/favicon-48.png
CHANGED
|
|
|
|
web/public/icon-512.png
CHANGED
|
|
|
|
web/src/account/AccessTokensCard.tsx
CHANGED
|
@@ -88,8 +88,8 @@ export function AccessTokensCard() {
|
|
| 88 |
<section ref={ref} id="tokens" className="fpt-card tok-card" style={{ padding: 20 }} aria-labelledby="acc-tokens">
|
| 89 |
<h2 id="acc-tokens" className="trio-card-h"><IconKey size={18} aria-hidden /> Access tokens for AI assistants</h2>
|
| 90 |
<Text size="sm" mt={4}>
|
| 91 |
-
A token lets Microsoft Copilot, Claude, ChatGPT or another assistant use
|
| 92 |
-
Anything that changes something, such as starting a run, still asks you to confirm. Sign-off stays in
|
| 93 |
</Text>
|
| 94 |
|
| 95 |
{created && <ShownOnce created={created} onDone={() => setCreated(null)} />}
|
|
|
|
| 88 |
<section ref={ref} id="tokens" className="fpt-card tok-card" style={{ padding: 20 }} aria-labelledby="acc-tokens">
|
| 89 |
<h2 id="acc-tokens" className="trio-card-h"><IconKey size={18} aria-hidden /> Access tokens for AI assistants</h2>
|
| 90 |
<Text size="sm" mt={4}>
|
| 91 |
+
A token lets Microsoft Copilot, Claude, ChatGPT or another assistant use Astra as you, with your permissions.
|
| 92 |
+
Anything that changes something, such as starting a run, still asks you to confirm. Sign-off stays in Astra.
|
| 93 |
</Text>
|
| 94 |
|
| 95 |
{created && <ShownOnce created={created} onDone={() => setCreated(null)} />}
|
web/src/api/openapi.json
CHANGED
|
@@ -4753,7 +4753,7 @@
|
|
| 4753 |
},
|
| 4754 |
"info": {
|
| 4755 |
"description": "Pilot backend. Runs against the local mock app or a registered Oracle Fusion TEST pod (never production); every run and report names its target.",
|
| 4756 |
-
"title": "
|
| 4757 |
"version": "1.0.0-pilot"
|
| 4758 |
},
|
| 4759 |
"openapi": "3.1.0",
|
|
|
|
| 4753 |
},
|
| 4754 |
"info": {
|
| 4755 |
"description": "Pilot backend. Runs against the local mock app or a registered Oracle Fusion TEST pod (never production); every run and report names its target.",
|
| 4756 |
+
"title": "Astra API",
|
| 4757 |
"version": "1.0.0-pilot"
|
| 4758 |
},
|
| 4759 |
"openapi": "3.1.0",
|
web/src/apple.css
CHANGED
|
@@ -186,6 +186,8 @@ html:root[data-mantine-color-scheme='dark'] .mantine-Tooltip-tooltip { backgroun
|
|
| 186 |
.trio-logo[data-for='dark'] { display: none; }
|
| 187 |
html:root[data-mantine-color-scheme='dark'] .trio-logo[data-for='dark'] { display: block; }
|
| 188 |
html:root[data-mantine-color-scheme='dark'] .trio-logo[data-for='light'] { display: none; }
|
|
|
|
|
|
|
| 189 |
.fpt-sb-brand-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
|
| 190 |
.fpt-sb-brand-name small { font-weight: var(--fw-regular); font-size: var(--fs-xs); color: var(--label-2); letter-spacing: 0; margin-top: -1px; }
|
| 191 |
.fpt-sb-top { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
|
|
|
|
| 186 |
.trio-logo[data-for='dark'] { display: none; }
|
| 187 |
html:root[data-mantine-color-scheme='dark'] .trio-logo[data-for='dark'] { display: block; }
|
| 188 |
html:root[data-mantine-color-scheme='dark'] .trio-logo[data-for='light'] { display: none; }
|
| 189 |
+
/* the product logo (CES, a wide shape): keeps its proportions at the height it is given; reads on light and dark */
|
| 190 |
+
.astra-logo { display: block; width: auto; max-width: 64px; object-fit: contain; flex: none; }
|
| 191 |
.fpt-sb-brand-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
|
| 192 |
.fpt-sb-brand-name small { font-weight: var(--fw-regular); font-size: var(--fs-xs); color: var(--label-2); letter-spacing: 0; margin-top: -1px; }
|
| 193 |
.fpt-sb-top { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
|
web/src/chat/speaker.test.ts
CHANGED
|
@@ -14,7 +14,7 @@ describe('who answers in Ask', () => {
|
|
| 14 |
});
|
| 15 |
|
| 16 |
it('actions, help and unknown answers come from the coordinator; Hermes answers as Hermes', () => {
|
| 17 |
-
expect(speakerFor({ tool: 'start_run' })).toMatchObject({ kind: 'patchwise', name: '
|
| 18 |
expect(speakerFor({ tool: 'help' }).kind).toBe('patchwise');
|
| 19 |
expect(speakerFor({})).toMatchObject({ kind: 'patchwise' });
|
| 20 |
expect(speakerFor({ by: 'hermes', tool: 'readiness' })).toMatchObject({ kind: 'hermes', name: 'Hermes' });
|
|
|
|
| 14 |
});
|
| 15 |
|
| 16 |
it('actions, help and unknown answers come from the coordinator; Hermes answers as Hermes', () => {
|
| 17 |
+
expect(speakerFor({ tool: 'start_run' })).toMatchObject({ kind: 'patchwise', name: 'Astra' });
|
| 18 |
expect(speakerFor({ tool: 'help' }).kind).toBe('patchwise');
|
| 19 |
expect(speakerFor({})).toMatchObject({ kind: 'patchwise' });
|
| 20 |
expect(speakerFor({ by: 'hermes', tool: 'readiness' })).toMatchObject({ kind: 'hermes', name: 'Hermes' });
|
web/src/chat/speaker.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
import { COWORKERS, type Coworker } from '../coworkers';
|
| 2 |
import type { ChatResult } from './api';
|
| 3 |
|
| 4 |
-
/** Who an answer comes from: a coworker of the AI team, the built-in coordinator ("
|
| 5 |
export type Speaker =
|
| 6 |
| { kind: 'coworker'; name: string; role: string }
|
| 7 |
-
| { kind: 'patchwise'; name: '
|
| 8 |
| { kind: 'hermes'; name: 'Hermes'; role: string };
|
| 9 |
|
| 10 |
const byLead = (lead: string): Coworker | undefined => COWORKERS.find((c) => c.lead === lead);
|
|
@@ -19,7 +19,7 @@ const TOOL_LEAD: Record<string, string> = {
|
|
| 19 |
/** Answer cards point at the same coworkers when the tool is not known (an answer restored from history has none). */
|
| 20 |
const CARD_LEAD: Record<string, string> = { readiness: 'scout', changes: 'scout', pods: 'scout', scenario: 'test_generator', run: 'executor', runs: 'executor', failures: 'triage' };
|
| 21 |
|
| 22 |
-
const PATCHWISE: Speaker = { kind: 'patchwise', name: '
|
| 23 |
|
| 24 |
/** Pick the speaker for an answer: Hermes when Hermes answered; actions that start or change runs, help and anything
|
| 25 |
* unknown are the coordinator; otherwise the coworker behind the tool or the first card. */
|
|
|
|
| 1 |
import { COWORKERS, type Coworker } from '../coworkers';
|
| 2 |
import type { ChatResult } from './api';
|
| 3 |
|
| 4 |
+
/** Who an answer comes from: a coworker of the AI team, the built-in coordinator ("Astra"), or Hermes. */
|
| 5 |
export type Speaker =
|
| 6 |
| { kind: 'coworker'; name: string; role: string }
|
| 7 |
+
| { kind: 'patchwise'; name: 'Astra'; role: string }
|
| 8 |
| { kind: 'hermes'; name: 'Hermes'; role: string };
|
| 9 |
|
| 10 |
const byLead = (lead: string): Coworker | undefined => COWORKERS.find((c) => c.lead === lead);
|
|
|
|
| 19 |
/** Answer cards point at the same coworkers when the tool is not known (an answer restored from history has none). */
|
| 20 |
const CARD_LEAD: Record<string, string> = { readiness: 'scout', changes: 'scout', pods: 'scout', scenario: 'test_generator', run: 'executor', runs: 'executor', failures: 'triage' };
|
| 21 |
|
| 22 |
+
const PATCHWISE: Speaker = { kind: 'patchwise', name: 'Astra', role: 'Coordinator' };
|
| 23 |
|
| 24 |
/** Pick the speaker for an answer: Hermes when Hermes answered; actions that start or change runs, help and anything
|
| 25 |
* unknown are the coordinator; otherwise the coworker behind the tool or the first card. */
|
web/src/components/components.test.tsx
CHANGED
|
@@ -106,9 +106,9 @@ describe('components', () => {
|
|
| 106 |
|
| 107 |
it('desktop notifications fire only on attention transitions', () => {
|
| 108 |
expect(statusTransitions({ a: 'running', b: 'queued' }, { a: 'waiting_approval', b: 'running', c: 'completed' }))
|
| 109 |
-
.toEqual([{ title: '
|
| 110 |
expect(statusTransitions({ a: 'waiting_approval' }, { a: 'waiting_approval|reminder: run a is still waiting at approve_cases' }))
|
| 111 |
-
.toEqual([{ title: '
|
| 112 |
});
|
| 113 |
|
| 114 |
it('login form has labelled inputs and shows API errors', async () => {
|
|
|
|
| 106 |
|
| 107 |
it('desktop notifications fire only on attention transitions', () => {
|
| 108 |
expect(statusTransitions({ a: 'running', b: 'queued' }, { a: 'waiting_approval', b: 'running', c: 'completed' }))
|
| 109 |
+
.toEqual([{ title: 'Astra (mock app)', body: 'Run a is waiting for case approval' }]);
|
| 110 |
expect(statusTransitions({ a: 'waiting_approval' }, { a: 'waiting_approval|reminder: run a is still waiting at approve_cases' }))
|
| 111 |
+
.toEqual([{ title: 'Astra (mock app)', body: 'reminder: run a is still waiting at approve_cases' }]);
|
| 112 |
});
|
| 113 |
|
| 114 |
it('login form has labelled inputs and shows API errors', async () => {
|
web/src/components/shell/AppSidebar.tsx
CHANGED
|
@@ -44,7 +44,7 @@ export const SETTINGS: NavItem = { to: '/admin', label: 'Settings', icon: <IconS
|
|
| 44 |
/** Where "New test run" links go: they open the Start sheet (`/runs/new` redirects there). */
|
| 45 |
export const NEW_RUN_PATH = '/runs/new';
|
| 46 |
|
| 47 |
-
export const initials = (name?: string) => (name ?? '
|
| 48 |
|
| 49 |
function NavLink({ item, badge, onNavigate }: { item: NavItem; badge?: number; onNavigate?: () => void }) {
|
| 50 |
const loc = useLocation();
|
|
@@ -112,14 +112,13 @@ export function AppSidebar({ onNavigate }: { onNavigate?: () => void }) {
|
|
| 112 |
const brand = useBrand();
|
| 113 |
const mine = useWaitsOnMe();
|
| 114 |
const waiting = (runs.data?.items ?? []).filter(mine).length;
|
| 115 |
-
const name = brand.data?.product_name ?? '
|
| 116 |
|
| 117 |
return (
|
| 118 |
<div className="fpt-sb">
|
| 119 |
<div className="fpt-sb-top">
|
| 120 |
<div className="fpt-sb-brand" data-testid="brand">
|
| 121 |
-
<img className="
|
| 122 |
-
<img className="trio-logo" data-for="dark" src="/favicon-paper.svg" alt="" width={30} height={30} />
|
| 123 |
<span className="fpt-sb-brand-name" title={name}><b className="fpt-sb-name">{name}</b>{brand.data?.org_name ? <small>{brand.data.org_name}</small> : null}</span>
|
| 124 |
</div>
|
| 125 |
<EnvSwitcher />
|
|
|
|
| 44 |
/** Where "New test run" links go: they open the Start sheet (`/runs/new` redirects there). */
|
| 45 |
export const NEW_RUN_PATH = '/runs/new';
|
| 46 |
|
| 47 |
+
export const initials = (name?: string) => (name ?? 'Astra').split(/\s+/).slice(0, 2).map((w) => w[0]?.toUpperCase() ?? '').join('') || 'TC';
|
| 48 |
|
| 49 |
function NavLink({ item, badge, onNavigate }: { item: NavItem; badge?: number; onNavigate?: () => void }) {
|
| 50 |
const loc = useLocation();
|
|
|
|
| 112 |
const brand = useBrand();
|
| 113 |
const mine = useWaitsOnMe();
|
| 114 |
const waiting = (runs.data?.items ?? []).filter(mine).length;
|
| 115 |
+
const name = brand.data?.product_name ?? 'Astra';
|
| 116 |
|
| 117 |
return (
|
| 118 |
<div className="fpt-sb">
|
| 119 |
<div className="fpt-sb-top">
|
| 120 |
<div className="fpt-sb-brand" data-testid="brand">
|
| 121 |
+
<img className="astra-logo" src="/astra-logo.png" alt="" height={30} />
|
|
|
|
| 122 |
<span className="fpt-sb-brand-name" title={name}><b className="fpt-sb-name">{name}</b>{brand.data?.org_name ? <small>{brand.data.org_name}</small> : null}</span>
|
| 123 |
</div>
|
| 124 |
<EnvSwitcher />
|
web/src/components/shell/IconRail.tsx
CHANGED
|
@@ -40,12 +40,12 @@ export function IconRail() {
|
|
| 40 |
const health = useHealth();
|
| 41 |
const env = useChosenEnv().pod;
|
| 42 |
const waiting = (runs.data?.items ?? []).filter(mine).length;
|
| 43 |
-
const name = brand.data?.product_name ?? '
|
| 44 |
const items: NavItem[] = [...MAIN, ...LIBRARY, ...SETUP, ...(can('admin') ? [AGENT_STUDIO, AI_MONITORING, INTEGRATIONS, SETTINGS] : [])];
|
| 45 |
return (
|
| 46 |
<div className="pw-rail">
|
| 47 |
<RouterLink to="/" className="pw-rail-brand" aria-label={`${name} home`} data-testid="brand">
|
| 48 |
-
<img src="/
|
| 49 |
</RouterLink>
|
| 50 |
<nav className="pw-rail-nav" aria-label="Pages">
|
| 51 |
{items.map((it, i) => (
|
|
|
|
| 40 |
const health = useHealth();
|
| 41 |
const env = useChosenEnv().pod;
|
| 42 |
const waiting = (runs.data?.items ?? []).filter(mine).length;
|
| 43 |
+
const name = brand.data?.product_name ?? 'Astra';
|
| 44 |
const items: NavItem[] = [...MAIN, ...LIBRARY, ...SETUP, ...(can('admin') ? [AGENT_STUDIO, AI_MONITORING, INTEGRATIONS, SETTINGS] : [])];
|
| 45 |
return (
|
| 46 |
<div className="pw-rail">
|
| 47 |
<RouterLink to="/" className="pw-rail-brand" aria-label={`${name} home`} data-testid="brand">
|
| 48 |
+
<img className="astra-logo" src="/astra-logo.png" alt="" height={26} />
|
| 49 |
</RouterLink>
|
| 50 |
<nav className="pw-rail-nav" aria-label="Pages">
|
| 51 |
{items.map((it, i) => (
|
web/src/components/shell/TopNav.tsx
CHANGED
|
@@ -29,15 +29,14 @@ export function TopNav() {
|
|
| 29 |
const scheme = useComputedColorScheme('dark');
|
| 30 |
const dark = scheme === 'dark';
|
| 31 |
const waiting = (runs.data?.items ?? []).filter(mine).length;
|
| 32 |
-
const name = brand.data?.product_name ?? '
|
| 33 |
const main = [...MAIN.filter((i) => i.to !== '/assistant'), ...LIBRARY, ...MAIN.filter((i) => i.to === '/assistant')];
|
| 34 |
const more = [...SETUP, ...(can('admin') ? [AGENT_STUDIO, AI_MONITORING, INTEGRATIONS, SETTINGS] : [])];
|
| 35 |
const moreActive = more.find((i) => isActive(i, loc.pathname));
|
| 36 |
return (
|
| 37 |
<header className="pw-nav" aria-label="Main navigation">
|
| 38 |
<Link to="/" className="pw-nav-brand" aria-label={`${name} home`} data-testid="brand">
|
| 39 |
-
<img className="
|
| 40 |
-
<img className="trio-logo" data-for="dark" src="/favicon-paper.svg" alt="" width={28} height={28} />
|
| 41 |
<span className="pw-nav-name">{name}<small>Oracle patch testing</small></span>
|
| 42 |
</Link>
|
| 43 |
|
|
|
|
| 29 |
const scheme = useComputedColorScheme('dark');
|
| 30 |
const dark = scheme === 'dark';
|
| 31 |
const waiting = (runs.data?.items ?? []).filter(mine).length;
|
| 32 |
+
const name = brand.data?.product_name ?? 'Astra';
|
| 33 |
const main = [...MAIN.filter((i) => i.to !== '/assistant'), ...LIBRARY, ...MAIN.filter((i) => i.to === '/assistant')];
|
| 34 |
const more = [...SETUP, ...(can('admin') ? [AGENT_STUDIO, AI_MONITORING, INTEGRATIONS, SETTINGS] : [])];
|
| 35 |
const moreActive = more.find((i) => isActive(i, loc.pathname));
|
| 36 |
return (
|
| 37 |
<header className="pw-nav" aria-label="Main navigation">
|
| 38 |
<Link to="/" className="pw-nav-brand" aria-label={`${name} home`} data-testid="brand">
|
| 39 |
+
<img className="astra-logo" src="/astra-logo.png" alt="" height={28} />
|
|
|
|
| 40 |
<span className="pw-nav-name">{name}<small>Oracle patch testing</small></span>
|
| 41 |
</Link>
|
| 42 |
|
web/src/desktop.ts
CHANGED
|
@@ -26,8 +26,8 @@ export function statusTransitions(prev: Record<string, string>, next: Record<str
|
|
| 26 |
const [st, attention] = raw.split('|');
|
| 27 |
const [pst, pattention] = (prev[id] ?? '').split('|');
|
| 28 |
if (prev[id] === undefined) continue;
|
| 29 |
-
if (pst !== st && NOTIFY_ON[st]) out.push({ title: '
|
| 30 |
-
else if (attention && attention !== pattention) out.push({ title: '
|
| 31 |
}
|
| 32 |
return out;
|
| 33 |
}
|
|
|
|
| 26 |
const [st, attention] = raw.split('|');
|
| 27 |
const [pst, pattention] = (prev[id] ?? '').split('|');
|
| 28 |
if (prev[id] === undefined) continue;
|
| 29 |
+
if (pst !== st && NOTIFY_ON[st]) out.push({ title: 'Astra (mock app)', body: `Run ${id} ${NOTIFY_ON[st]}` });
|
| 30 |
+
else if (attention && attention !== pattention) out.push({ title: 'Astra (mock app)', body: attention });
|
| 31 |
}
|
| 32 |
return out;
|
| 33 |
}
|
web/src/notify/NotificationBell.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { COWORKERS } from '../coworkers';
|
|
| 7 |
import { toPath, useBrowserPref, useNotifications, whenWords, type Notice } from './useNotifications';
|
| 8 |
import './notify.css';
|
| 9 |
|
| 10 |
-
/** The coworker's face, or the
|
| 11 |
function Face({ name }: { name: string }) {
|
| 12 |
const known = COWORKERS.some((c) => c.name === name);
|
| 13 |
if (!known) return <img className="pw-notify-mark" src="/favicon-graphite.svg" alt="" width={28} height={28} />;
|
|
|
|
| 7 |
import { toPath, useBrowserPref, useNotifications, whenWords, type Notice } from './useNotifications';
|
| 8 |
import './notify.css';
|
| 9 |
|
| 10 |
+
/** The coworker's face, or the Astra mark for the app itself (and anyone not on the team). */
|
| 11 |
function Face({ name }: { name: string }) {
|
| 12 |
const known = COWORKERS.some((c) => c.name === name);
|
| 13 |
if (!known) return <img className="pw-notify-mark" src="/favicon-graphite.svg" alt="" width={28} height={28} />;
|
web/src/notify/NotificationsSettings.tsx
CHANGED
|
@@ -32,7 +32,7 @@ export function NotificationsSettings() {
|
|
| 32 |
return (
|
| 33 |
<div className="pw-notify-settings" data-testid="notify-settings">
|
| 34 |
<Text size="sm" c="dimmed">
|
| 35 |
-
When a coworker needs you (scenarios to approve, a failure to decide, a finished run, a new defect),
|
| 36 |
message. Each message opens the right screen; nothing is approved or changed until you confirm it there.
|
| 37 |
</Text>
|
| 38 |
|
|
@@ -47,7 +47,7 @@ export function NotificationsSettings() {
|
|
| 47 |
<dt>Webhook</dt>
|
| 48 |
<dd data-testid="notify-webhook">{d.webhook_configured ? <>Set up{d.webhook_host ? <>, sends to <b>{d.webhook_host}</b></> : null}</> : 'Not set up yet'}</dd>
|
| 49 |
<dt>Signed messages</dt>
|
| 50 |
-
<dd>{d.signing ? 'On: n8n can check that each message came from
|
| 51 |
<dt>Waiting to send</dt>
|
| 52 |
<dd>{d.pending}</dd>
|
| 53 |
<dt>Last delivery</dt>
|
|
@@ -79,7 +79,7 @@ export function NotificationsSettings() {
|
|
| 79 |
<ol className="pw-notify-steps">
|
| 80 |
<li>In n8n, import the workflow <code>integrations/n8n/patchwise-telegram.json</code> and turn it on. Copy its production webhook URL.</li>
|
| 81 |
<li>In n8n, add your Telegram bot token as a Telegram credential, and set the chat id (the workflow's README shows where).</li>
|
| 82 |
-
<li>On the
|
| 83 |
<li>Come back here and press <b>Send a test message</b>.</li>
|
| 84 |
</ol>
|
| 85 |
</section>
|
|
|
|
| 32 |
return (
|
| 33 |
<div className="pw-notify-settings" data-testid="notify-settings">
|
| 34 |
<Text size="sm" c="dimmed">
|
| 35 |
+
When a coworker needs you (scenarios to approve, a failure to decide, a finished run, a new defect), Astra sends a
|
| 36 |
message. Each message opens the right screen; nothing is approved or changed until you confirm it there.
|
| 37 |
</Text>
|
| 38 |
|
|
|
|
| 47 |
<dt>Webhook</dt>
|
| 48 |
<dd data-testid="notify-webhook">{d.webhook_configured ? <>Set up{d.webhook_host ? <>, sends to <b>{d.webhook_host}</b></> : null}</> : 'Not set up yet'}</dd>
|
| 49 |
<dt>Signed messages</dt>
|
| 50 |
+
<dd>{d.signing ? 'On: n8n can check that each message came from Astra' : 'Off: set FPT_NOTIFY_SECRET to sign them'}</dd>
|
| 51 |
<dt>Waiting to send</dt>
|
| 52 |
<dd>{d.pending}</dd>
|
| 53 |
<dt>Last delivery</dt>
|
|
|
|
| 79 |
<ol className="pw-notify-steps">
|
| 80 |
<li>In n8n, import the workflow <code>integrations/n8n/patchwise-telegram.json</code> and turn it on. Copy its production webhook URL.</li>
|
| 81 |
<li>In n8n, add your Telegram bot token as a Telegram credential, and set the chat id (the workflow's README shows where).</li>
|
| 82 |
+
<li>On the Astra server, set <code>FPT_NOTIFY_WEBHOOK_URL</code> to that webhook URL and <code>FPT_NOTIFY_SECRET</code> to a long random value; put the same value in the n8n workflow. Restart Astra.</li>
|
| 83 |
<li>Come back here and press <b>Send a test message</b>.</li>
|
| 84 |
</ol>
|
| 85 |
</section>
|
web/src/notify/TelegramLinkCard.tsx
CHANGED
|
@@ -30,7 +30,7 @@ function useSecondsLeft(iso: string | null): number {
|
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
-
* "
|
| 34 |
* The chat then acts as them, with their permissions (status, starting runs after a confirm, questions).
|
| 35 |
*/
|
| 36 |
export function TelegramLinkCard() {
|
|
@@ -58,7 +58,7 @@ export function TelegramLinkCard() {
|
|
| 58 |
|
| 59 |
return (
|
| 60 |
<section className="pw-card pw-bot" aria-labelledby="acc-tg-h" data-testid="tg-link-card">
|
| 61 |
-
<h2 id="acc-tg-h" className="trio-card-h"><IconBrandTelegram size={18} aria-hidden />
|
| 62 |
<div aria-live="polite" className="pw-bot-state">
|
| 63 |
{linked && tg ? (
|
| 64 |
<div className="pw-bot-linked" data-testid="tg-linked">
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
+
* "Astra in Telegram" on the Account page: each person links their own chat with a one-time code sent to the bot.
|
| 34 |
* The chat then acts as them, with their permissions (status, starting runs after a confirm, questions).
|
| 35 |
*/
|
| 36 |
export function TelegramLinkCard() {
|
|
|
|
| 58 |
|
| 59 |
return (
|
| 60 |
<section className="pw-card pw-bot" aria-labelledby="acc-tg-h" data-testid="tg-link-card">
|
| 61 |
+
<h2 id="acc-tg-h" className="trio-card-h"><IconBrandTelegram size={18} aria-hidden /> Astra in Telegram</h2>
|
| 62 |
<div aria-live="polite" className="pw-bot-state">
|
| 63 |
{linked && tg ? (
|
| 64 |
<div className="pw-bot-linked" data-testid="tg-linked">
|
web/src/notify/telegramlink.test.tsx
CHANGED
|
@@ -32,7 +32,7 @@ function backend({ linkedFromStart = false, linkAfter = Infinity, botUsername =
|
|
| 32 |
return calls;
|
| 33 |
}
|
| 34 |
|
| 35 |
-
describe('
|
| 36 |
afterEach(() => { vi.restoreAllMocks(); vi.useRealTimers(); });
|
| 37 |
|
| 38 |
it('not linked: shows the code with the bot link, then the linked state after the poll', async () => {
|
|
|
|
| 32 |
return calls;
|
| 33 |
}
|
| 34 |
|
| 35 |
+
describe('Astra in Telegram (Account page)', () => {
|
| 36 |
afterEach(() => { vi.restoreAllMocks(); vi.useRealTimers(); });
|
| 37 |
|
| 38 |
it('not linked: shows the code with the bot link, then the linked state after the poll', async () => {
|
web/src/pages/AgentStudioPage.tsx
CHANGED
|
@@ -15,15 +15,15 @@ interface Delivery { id: number; delivery_id: string; event: string; cycle_id: s
|
|
| 15 |
interface Watch { checked_at?: string; checked?: { release: string; area: string; changes?: number; new?: number; error?: string }[]; updates?: number }
|
| 16 |
interface InboxItem { id: number; event: string; signature_ok: boolean; received_at: string; payload: Record<string, unknown> & { cycle_id?: string; scenarios?: { id: string; title: string; area: string; written_by: string }[]; verdict?: string; areas?: { area: string; verdict: string }[] } }
|
| 17 |
|
| 18 |
-
/** The workflow in Oracle Fusion, and which steps are
|
| 19 |
const FLOW: { n: number; text: string; who: 'fusion' | 'patchwise' | 'person' }[] = [
|
| 20 |
{ n: 1, text: 'Read the module space', who: 'fusion' },
|
| 21 |
{ n: 2, text: 'Generate synthetic test data', who: 'fusion' },
|
| 22 |
{ n: 3, text: 'Mask and validate it', who: 'fusion' },
|
| 23 |
{ n: 4, text: 'A person approves the test data', who: 'person' },
|
| 24 |
-
{ n: 5, text: '
|
| 25 |
{ n: 6, text: 'A person approves start testing', who: 'person' },
|
| 26 |
-
{ n: 7, text: '
|
| 27 |
];
|
| 28 |
|
| 29 |
const deliveryState = (d: Delivery) => (d.delivered_at ? { tone: 'green', words: `Delivered${d.attempts > 1 ? ` after ${d.attempts} tries` : ''}${d.job_id ? ` (Fusion job ${d.job_id})` : ''}` }
|
|
@@ -85,7 +85,7 @@ function Clients() {
|
|
| 85 |
<Modal opened={open} onClose={() => setOpen(false)} title="New OAuth client" centered>
|
| 86 |
<Stack>
|
| 87 |
<TextInput label="Name" placeholder="Fusion test pod, Agent Studio" required value={form.name} onChange={(e) => setForm({ ...form, name: e.currentTarget.value })} />
|
| 88 |
-
<TextInput label="Callback address" description="Where
|
| 89 |
<TextInput label="Release watch address" description="Where patch updates go: the Release Watch Agent (https). Optional." placeholder="https://…/release-watch" value={form.release_watch_url} onChange={(e) => setForm({ ...form, release_watch_url: e.currentTarget.value })} />
|
| 90 |
<ErrorAlert error={create.error} />
|
| 91 |
<Group justify="flex-end"><Button variant="default" onClick={() => setOpen(false)}>Cancel</Button><Button onClick={() => create.mutate()} loading={create.isPending} disabled={!form.name.trim()}>Create client</Button></Group>
|
|
@@ -95,7 +95,7 @@ function Clients() {
|
|
| 95 |
<Modal opened={!!made} onClose={() => setMade(null)} title="Client created: copy these now" centered size="lg">
|
| 96 |
{made && (
|
| 97 |
<Stack>
|
| 98 |
-
<Text size="sm">The secret and the signing key are shown <b>once</b>.
|
| 99 |
<Secret label="Client ID" value={made.client_id} />
|
| 100 |
<Secret label="Client secret" value={made.client_secret} />
|
| 101 |
<Secret label="Signing key (checks the X-Patchwise-Signature of each callback)" value={made.signing_key} />
|
|
@@ -108,7 +108,7 @@ function Clients() {
|
|
| 108 |
}
|
| 109 |
|
| 110 |
/** Where a client's events go: signed POSTs to its callback address (a relay), straight to Oracle Fusion, where
|
| 111 |
-
*
|
| 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();
|
|
@@ -137,7 +137,7 @@ function DeliverySheet({ c, onClose }: { c: Client; onClose: () => void }) {
|
|
| 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 |
<>
|
| 140 |
-
<Text size="sm" c="dimmed">
|
| 141 |
<TextInput label="Fusion address" placeholder="https://<pod host>" required value={form.base_url} onChange={set('base_url')} />
|
| 142 |
<TextInput label="Token address (OCI IAM)" placeholder="https://idcs-….identity.oraclecloud.com/oauth2/v1/token" required value={form.token_url} onChange={set('token_url')} />
|
| 143 |
<Group grow>
|
|
@@ -273,7 +273,7 @@ function StandIn() {
|
|
| 273 |
return (
|
| 274 |
<section className="pw-card as-card as-standin" aria-labelledby="as-si-h">
|
| 275 |
<div className="as-card-head">
|
| 276 |
-
<div><h2 id="as-si-h">Stand-in for Oracle Fusion</h2><p>Plays the Agent Studio workflow against this
|
| 277 |
{!creds && <Button onClick={() => setup.mutate()} loading={setup.isPending}>Set up the stand-in</Button>}
|
| 278 |
</div>
|
| 279 |
<ErrorAlert error={setup.error} />
|
|
@@ -287,7 +287,7 @@ function StandIn() {
|
|
| 287 |
<div className="as-si-step">
|
| 288 |
<h3>Step 4 · A person approves the test data</h3>
|
| 289 |
<TextInput label="Approved by" placeholder="Name in Fusion" value={who} onChange={(e) => setWho(e.currentTarget.value)} />
|
| 290 |
-
<Button disabled={!who.trim()} onClick={() => go(async () => { const r = await call('POST', '/api/agent-studio/v1/cycles', { test_data: JSON.parse(data), data_approved_by: who, areas: Object.keys(JSON.parse(data)) }); void qc.invalidateQueries({ queryKey: ['as-cycles'] }); return `Cycle ${r.cycle_id} started. Scripts come back in a few minutes.`; })}>Approve and send to
|
| 291 |
</div>
|
| 292 |
<div className="as-si-step">
|
| 293 |
<h3>Steps 5–6 · Scripts ready, approve start testing</h3>
|
|
@@ -322,7 +322,7 @@ export function AgentStudioPage() {
|
|
| 322 |
<PageHeader crumbs={[]} title="Oracle AI Agent Studio"
|
| 323 |
extra={<span>Fusion’s AI Agent Studio drives each test cycle: it sends synthetic test data a person approved, approves start testing, and receives the scripts and the results. <a href="https://github.com/SaiPhaniAnirudh/patchwise-agent-studio/blob/main/docs/AGENT_STUDIO.md" target="_blank" rel="noreferrer">Integration guide</a></span>} />
|
| 324 |
<ol className="as-flow" aria-label="The workflow">
|
| 325 |
-
{FLOW.map((s) => <li key={s.n} data-who={s.who}><span className="as-flow-n">{s.n}</span><span>{s.text}</span><small>{s.who === 'fusion' ? 'In Fusion' : s.who === 'person' ? 'A person, in Fusion' : '
|
| 326 |
</ol>
|
| 327 |
<Clients />
|
| 328 |
<Cycles />
|
|
|
|
| 15 |
interface Watch { checked_at?: string; checked?: { release: string; area: string; changes?: number; new?: number; error?: string }[]; updates?: number }
|
| 16 |
interface InboxItem { id: number; event: string; signature_ok: boolean; received_at: string; payload: Record<string, unknown> & { cycle_id?: string; scenarios?: { id: string; title: string; area: string; written_by: string }[]; verdict?: string; areas?: { area: string; verdict: string }[] } }
|
| 17 |
|
| 18 |
+
/** The workflow in Oracle Fusion, and which steps are Astra's. */
|
| 19 |
const FLOW: { n: number; text: string; who: 'fusion' | 'patchwise' | 'person' }[] = [
|
| 20 |
{ n: 1, text: 'Read the module space', who: 'fusion' },
|
| 21 |
{ n: 2, text: 'Generate synthetic test data', who: 'fusion' },
|
| 22 |
{ n: 3, text: 'Mask and validate it', who: 'fusion' },
|
| 23 |
{ n: 4, text: 'A person approves the test data', who: 'person' },
|
| 24 |
+
{ n: 5, text: 'Astra writes the scripts; Fusion emails them', who: 'patchwise' },
|
| 25 |
{ n: 6, text: 'A person approves start testing', who: 'person' },
|
| 26 |
+
{ n: 7, text: 'Astra tests and reports; Fusion emails the results', who: 'patchwise' },
|
| 27 |
];
|
| 28 |
|
| 29 |
const deliveryState = (d: Delivery) => (d.delivered_at ? { tone: 'green', words: `Delivered${d.attempts > 1 ? ` after ${d.attempts} tries` : ''}${d.job_id ? ` (Fusion job ${d.job_id})` : ''}` }
|
|
|
|
| 85 |
<Modal opened={open} onClose={() => setOpen(false)} title="New OAuth client" centered>
|
| 86 |
<Stack>
|
| 87 |
<TextInput label="Name" placeholder="Fusion test pod, Agent Studio" required value={form.name} onChange={(e) => setForm({ ...form, name: e.currentTarget.value })} />
|
| 88 |
+
<TextInput label="Callback address" description="Where Astra sends scripts ready, results and stopped (https)." placeholder="https://…/patchwise/callback" value={form.callback_url} onChange={(e) => setForm({ ...form, callback_url: e.currentTarget.value })} />
|
| 89 |
<TextInput label="Release watch address" description="Where patch updates go: the Release Watch Agent (https). Optional." placeholder="https://…/release-watch" value={form.release_watch_url} onChange={(e) => setForm({ ...form, release_watch_url: e.currentTarget.value })} />
|
| 90 |
<ErrorAlert error={create.error} />
|
| 91 |
<Group justify="flex-end"><Button variant="default" onClick={() => setOpen(false)}>Cancel</Button><Button onClick={() => create.mutate()} loading={create.isPending} disabled={!form.name.trim()}>Create client</Button></Group>
|
|
|
|
| 95 |
<Modal opened={!!made} onClose={() => setMade(null)} title="Client created: copy these now" centered size="lg">
|
| 96 |
{made && (
|
| 97 |
<Stack>
|
| 98 |
+
<Text size="sm">The secret and the signing key are shown <b>once</b>. Astra keeps only the secret’s hash.</Text>
|
| 99 |
<Secret label="Client ID" value={made.client_id} />
|
| 100 |
<Secret label="Client secret" value={made.client_secret} />
|
| 101 |
<Secret label="Signing key (checks the X-Patchwise-Signature of each callback)" value={made.signing_key} />
|
|
|
|
| 108 |
}
|
| 109 |
|
| 110 |
/** Where a client's events go: signed POSTs to its callback address (a relay), straight to Oracle Fusion, where
|
| 111 |
+
* Astra 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();
|
|
|
|
| 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 |
<>
|
| 140 |
+
<Text size="sm" c="dimmed">Astra signs in to your Oracle identity domain with a confidential app (client credentials) and starts the callback workflow with <code>invokeAsync</code>. No relay is needed.</Text>
|
| 141 |
<TextInput label="Fusion address" placeholder="https://<pod host>" required value={form.base_url} onChange={set('base_url')} />
|
| 142 |
<TextInput label="Token address (OCI IAM)" placeholder="https://idcs-….identity.oraclecloud.com/oauth2/v1/token" required value={form.token_url} onChange={set('token_url')} />
|
| 143 |
<Group grow>
|
|
|
|
| 273 |
return (
|
| 274 |
<section className="pw-card as-card as-standin" aria-labelledby="as-si-h">
|
| 275 |
<div className="as-card-head">
|
| 276 |
+
<div><h2 id="as-si-h">Stand-in for Oracle Fusion</h2><p>Plays the Agent Studio workflow against this Astra, over the same API, so the whole cycle can be tried and shown before the Fusion side is built.</p></div>
|
| 277 |
{!creds && <Button onClick={() => setup.mutate()} loading={setup.isPending}>Set up the stand-in</Button>}
|
| 278 |
</div>
|
| 279 |
<ErrorAlert error={setup.error} />
|
|
|
|
| 287 |
<div className="as-si-step">
|
| 288 |
<h3>Step 4 · A person approves the test data</h3>
|
| 289 |
<TextInput label="Approved by" placeholder="Name in Fusion" value={who} onChange={(e) => setWho(e.currentTarget.value)} />
|
| 290 |
+
<Button disabled={!who.trim()} onClick={() => go(async () => { const r = await call('POST', '/api/agent-studio/v1/cycles', { test_data: JSON.parse(data), data_approved_by: who, areas: Object.keys(JSON.parse(data)) }); void qc.invalidateQueries({ queryKey: ['as-cycles'] }); return `Cycle ${r.cycle_id} started. Scripts come back in a few minutes.`; })}>Approve and send to Astra</Button>
|
| 291 |
</div>
|
| 292 |
<div className="as-si-step">
|
| 293 |
<h3>Steps 5–6 · Scripts ready, approve start testing</h3>
|
|
|
|
| 322 |
<PageHeader crumbs={[]} title="Oracle AI Agent Studio"
|
| 323 |
extra={<span>Fusion’s AI Agent Studio drives each test cycle: it sends synthetic test data a person approved, approves start testing, and receives the scripts and the results. <a href="https://github.com/SaiPhaniAnirudh/patchwise-agent-studio/blob/main/docs/AGENT_STUDIO.md" target="_blank" rel="noreferrer">Integration guide</a></span>} />
|
| 324 |
<ol className="as-flow" aria-label="The workflow">
|
| 325 |
+
{FLOW.map((s) => <li key={s.n} data-who={s.who}><span className="as-flow-n">{s.n}</span><span>{s.text}</span><small>{s.who === 'fusion' ? 'In Fusion' : s.who === 'person' ? 'A person, in Fusion' : 'Astra'}</small></li>)}
|
| 326 |
</ol>
|
| 327 |
<Clients />
|
| 328 |
<Cycles />
|
web/src/pages/AiMonitoringPage.tsx
CHANGED
|
@@ -164,7 +164,7 @@ function Evals() {
|
|
| 164 |
return (
|
| 165 |
<section className="pw-card aim-card" aria-labelledby="aim-ev-h">
|
| 166 |
<div className="aim-head">
|
| 167 |
-
<div><h2 id="aim-ev-h">Evaluations</h2><p>Score a model on fixed, synthetic cases from real
|
| 168 |
</div>
|
| 169 |
<div className="aim-ds">
|
| 170 |
{(ds.data?.items ?? []).map((d) => (
|
|
|
|
| 164 |
return (
|
| 165 |
<section className="pw-card aim-card" aria-labelledby="aim-ev-h">
|
| 166 |
<div className="aim-head">
|
| 167 |
+
<div><h2 id="aim-ev-h">Evaluations</h2><p>Score a model on fixed, synthetic cases from real Astra work: classify a failure, pick a renamed screen element, choose the assistant’s tool, summarise without inventing numbers. The external model only gets the tasks that may go to it.</p></div>
|
| 168 |
</div>
|
| 169 |
<div className="aim-ds">
|
| 170 |
{(ds.data?.items ?? []).map((d) => (
|
web/src/pages/AuthShell.tsx
CHANGED
|
@@ -13,15 +13,15 @@ export const FIELD = { root: 'beui-field', input: 'border-0' };
|
|
| 13 |
|
| 14 |
/**
|
| 15 |
* The frame of every account page (sign in, create an account, forgot, reset). On large screens a black brand
|
| 16 |
-
* panel with the ember glow on the left (the
|
| 17 |
* own type and accent; on small screens only the form. `title` is the visible heading; `srTitle` adds words for screen
|
| 18 |
-
* readers only (e.g. "Sign in" + " to
|
| 19 |
*/
|
| 20 |
export function AuthShell({ children, label, title, srTitle, sub }: {
|
| 21 |
children: ReactNode; label: string; title: string; srTitle?: string; sub?: ReactNode;
|
| 22 |
}) {
|
| 23 |
const brand = useBrand();
|
| 24 |
-
const name = brand.data?.product_name ?? '
|
| 25 |
return (
|
| 26 |
<div className="grid min-h-dvh grid-cols-1 bg-[var(--bg)] text-[var(--label)] lg:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)]">
|
| 27 |
<section className="trio-force-dark relative hidden overflow-hidden bg-[#000] lg:flex" aria-label={`About ${name}`}>
|
|
|
|
| 13 |
|
| 14 |
/**
|
| 15 |
* The frame of every account page (sign in, create an account, forgot, reset). On large screens a black brand
|
| 16 |
+
* panel with the ember glow on the left (the Astra story and a live 3D scene) and the form on the right, in the app's
|
| 17 |
* own type and accent; on small screens only the form. `title` is the visible heading; `srTitle` adds words for screen
|
| 18 |
+
* readers only (e.g. "Sign in" + " to Astra").
|
| 19 |
*/
|
| 20 |
export function AuthShell({ children, label, title, srTitle, sub }: {
|
| 21 |
children: ReactNode; label: string; title: string; srTitle?: string; sub?: ReactNode;
|
| 22 |
}) {
|
| 23 |
const brand = useBrand();
|
| 24 |
+
const name = brand.data?.product_name ?? 'Astra';
|
| 25 |
return (
|
| 26 |
<div className="grid min-h-dvh grid-cols-1 bg-[var(--bg)] text-[var(--label)] lg:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)]">
|
| 27 |
<section className="trio-force-dark relative hidden overflow-hidden bg-[#000] lg:flex" aria-label={`About ${name}`}>
|
web/src/pages/ImportCasesPage.tsx
CHANGED
|
@@ -287,7 +287,7 @@ function BuildAndRun({ batchId, fromAgent = false }: { batchId: string; fromAgen
|
|
| 287 |
}
|
| 288 |
|
| 289 |
/* ------------------------------------------------------------------ the page */
|
| 290 |
-
/** /scenarios/import: people (or agents, through the same API) bring their own test cases;
|
| 291 |
* builds and dry-runs a script for each on a pod, and runs the ones a person approved. */
|
| 292 |
export function ImportCasesPage() {
|
| 293 |
const { can } = useAuth();
|
|
@@ -300,14 +300,14 @@ export function ImportCasesPage() {
|
|
| 300 |
<div className="ic-page">
|
| 301 |
<PageHeader crumbs={[{ label: 'Home', to: '/' }, { label: 'Scenarios', to: '/scenarios' }, { label: 'Bring your own test cases' }]}
|
| 302 |
title="Bring your own test cases"
|
| 303 |
-
extra={<span className="fpt-pagedesc">Give
|
| 304 |
{!allowed ? (
|
| 305 |
<Alert color="gray" className="ic-locked">{VIEWER_START_WORDS}</Alert>
|
| 306 |
) : (
|
| 307 |
agentBatch ? (
|
| 308 |
<ol className="ic-guide">
|
| 309 |
<Step n={1} title="Cases sent by an agent" done current={false}>
|
| 310 |
-
<p className="ic-lede">Another agent sent these cases and
|
| 311 |
<UnstyledButton className="ic-link" onClick={() => setParams((n) => { n.delete('batch'); return n; })}>bring your own instead</UnstyledButton>.</p>
|
| 312 |
</Step>
|
| 313 |
<BuildAndRun key={agentBatch} batchId={agentBatch} fromAgent />
|
|
|
|
| 287 |
}
|
| 288 |
|
| 289 |
/* ------------------------------------------------------------------ the page */
|
| 290 |
+
/** /scenarios/import: people (or agents, through the same API) bring their own test cases; Astra turns them into steps,
|
| 291 |
* builds and dry-runs a script for each on a pod, and runs the ones a person approved. */
|
| 292 |
export function ImportCasesPage() {
|
| 293 |
const { can } = useAuth();
|
|
|
|
| 300 |
<div className="ic-page">
|
| 301 |
<PageHeader crumbs={[{ label: 'Home', to: '/' }, { label: 'Scenarios', to: '/scenarios' }, { label: 'Bring your own test cases' }]}
|
| 302 |
title="Bring your own test cases"
|
| 303 |
+
extra={<span className="fpt-pagedesc">Give Astra your test cases: it writes the steps and scripts, tries them on a pod, and runs the ones you approve.</span>} />
|
| 304 |
{!allowed ? (
|
| 305 |
<Alert color="gray" className="ic-locked">{VIEWER_START_WORDS}</Alert>
|
| 306 |
) : (
|
| 307 |
agentBatch ? (
|
| 308 |
<ol className="ic-guide">
|
| 309 |
<Step n={1} title="Cases sent by an agent" done current={false}>
|
| 310 |
+
<p className="ic-lede">Another agent sent these cases and Astra has tried them on a pod. Review the results, approve the ones to run, or{' '}
|
| 311 |
<UnstyledButton className="ic-link" onClick={() => setParams((n) => { n.delete('batch'); return n; })}>bring your own instead</UnstyledButton>.</p>
|
| 312 |
</Step>
|
| 313 |
<BuildAndRun key={agentBatch} batchId={agentBatch} fromAgent />
|
web/src/pages/IntegrationsPage.tsx
CHANGED
|
@@ -19,7 +19,7 @@ export interface HookIntegration { configured: boolean; host: string | null; las
|
|
| 19 |
/** Messaging tools that receive notifications through an incoming webhook (one-way). */
|
| 20 |
export type HookKey = 'slack' | 'teams' | 'google_chat' | 'discord';
|
| 21 |
export type IntegrationsState = Record<HookKey, HookIntegration>;
|
| 22 |
-
/** AI assistants that use
|
| 23 |
type AssistantKey = 'copilot' | 'chatgpt' | 'claude' | 'github' | 'cursor';
|
| 24 |
type Key = 'telegram' | HookKey | AssistantKey | 'a2a' | 'webhook' | 'jira' | 'servicenow';
|
| 25 |
type Status = { tone: 'green' | 'neutral' | 'red'; words: string; planned?: boolean; outline?: boolean };
|
|
@@ -191,10 +191,10 @@ const ASSISTANT_CAN = [
|
|
| 191 |
function clientSetup(kind: AssistantKey, url: string): ReactNode {
|
| 192 |
const claudeDesktop = JSON.stringify({ mcpServers: { patchwise: {
|
| 193 |
command: 'npx', args: ['-y', 'mcp-remote', url, '--header', 'Authorization:${PATCHWISE_AUTH}'],
|
| 194 |
-
env: { PATCHWISE_AUTH: 'Bearer <paste your
|
| 195 |
const claudeCode = `claude mcp add --transport http patchwise ${url} --header "Authorization: Bearer $PATCHWISE_TOKEN"`;
|
| 196 |
const vscode = JSON.stringify({ servers: { patchwise: { type: 'http', url, headers: { Authorization: 'Bearer ${input:patchwise-token}' } } },
|
| 197 |
-
inputs: [{ type: 'promptString', id: 'patchwise-token', description: '
|
| 198 |
const cursor = JSON.stringify({ mcpServers: { patchwise: { url, headers: { Authorization: 'Bearer ${env:PATCHWISE_TOKEN}' } } } }, null, 2);
|
| 199 |
if (kind === 'claude') return (
|
| 200 |
<>
|
|
@@ -206,7 +206,7 @@ function clientSetup(kind: AssistantKey, url: string): ReactNode {
|
|
| 206 |
if (kind === 'github') return (
|
| 207 |
<>
|
| 208 |
<Snippet title="VS Code: .vscode/mcp.json" label="the VS Code settings" code={vscode} />
|
| 209 |
-
<Text size="sm" c="dimmed">VS Code asks for the token the first time GitHub Copilot uses
|
| 210 |
</>
|
| 211 |
);
|
| 212 |
if (kind === 'cursor') return (
|
|
@@ -222,7 +222,7 @@ function clientSetup(kind: AssistantKey, url: string): ReactNode {
|
|
| 222 |
<li>In Copilot Studio, open your agent, then <b>Tools</b>, <b>Add a tool</b>, <b>Model Context Protocol</b>.</li>
|
| 223 |
<li>Server URL: the address above.</li>
|
| 224 |
<li>Authentication: <b>API key</b>, sent in the header <code>Authorization</code>, with the value <code>Bearer <your token></code>.</li>
|
| 225 |
-
<li>Save, then try: "What is waiting for me in
|
| 226 |
</ol>
|
| 227 |
</div>
|
| 228 |
);
|
|
@@ -247,12 +247,12 @@ function AddressRow({ title, label, value, testId }: { title: string; label: str
|
|
| 247 |
);
|
| 248 |
}
|
| 249 |
|
| 250 |
-
/** What another agent can ask
|
| 251 |
const A2A_SKILLS: { id: string; words: string }[] = [
|
| 252 |
{ id: 'assess-readiness', words: 'How ready each business area is for a patch, with the numbers behind it.' },
|
| 253 |
{ id: 'design-tests', words: 'Design scenarios from the pod and patch facts your agent sends.' },
|
| 254 |
{ id: 'test-these-cases', words: 'Turn your own test cases into scripts and try them on a pod.' },
|
| 255 |
-
{ id: 'run-tests', words: 'Start a test run; it waits until a person approves in
|
| 256 |
{ id: 'get-report', words: 'Fetch the verdict, counts and the report of a finished run.' },
|
| 257 |
];
|
| 258 |
|
|
@@ -277,7 +277,7 @@ send = {
|
|
| 277 |
}
|
| 278 |
task = httpx.post(BASE + "/a2a", json=send, headers=HEADERS).json()["result"]
|
| 279 |
|
| 280 |
-
# follow the task: it stops at input-required until a person approves in
|
| 281 |
while task["status"]["state"] not in ("completed", "failed", "canceled", "input-required"):
|
| 282 |
time.sleep(10)
|
| 283 |
get = {"jsonrpc": "2.0", "id": 2, "method": "tasks/get", "params": {"id": task["id"]}}
|
|
@@ -286,13 +286,13 @@ print(task["status"]["state"])
|
|
| 286 |
`;
|
| 287 |
}
|
| 288 |
|
| 289 |
-
/** Your own agent talking to
|
| 290 |
function A2ASetup() {
|
| 291 |
const origin = typeof window !== 'undefined' ? window.location.origin : '';
|
| 292 |
return (
|
| 293 |
<Stack gap="md" data-testid="a2a-setup">
|
| 294 |
<Text size="sm">
|
| 295 |
-
Your own agent, for example one that reads your pod and its patch updates, can ask
|
| 296 |
test your own cases, start test runs and fetch the report. It acts as the person whose token it uses, with their permissions.
|
| 297 |
</Text>
|
| 298 |
<div>
|
|
@@ -302,7 +302,7 @@ function A2ASetup() {
|
|
| 302 |
</ul>
|
| 303 |
</div>
|
| 304 |
<Text size="sm" className="int-rule" data-testid="a2a-rule">
|
| 305 |
-
A person always approves in
|
| 306 |
</Text>
|
| 307 |
<Group gap="xs">
|
| 308 |
<Button component={Link} to="/account#tokens" variant="filled" leftSection={<IconKey size={15} aria-hidden />}>Create a token</Button>
|
|
@@ -315,13 +315,13 @@ function A2ASetup() {
|
|
| 315 |
);
|
| 316 |
}
|
| 317 |
|
| 318 |
-
/** An AI assistant: what it can do through
|
| 319 |
function AssistantSetup({ kind }: { kind: AssistantKey }) {
|
| 320 |
const url = `${typeof window !== 'undefined' ? window.location.origin : ''}/mcp`;
|
| 321 |
const web = kind === 'chatgpt';
|
| 322 |
return (
|
| 323 |
<Stack gap="md" data-testid={`assistant-setup-${kind}`}>
|
| 324 |
-
<Text size="sm">It uses
|
| 325 |
{ASSISTANT_CAN.map((l) => (
|
| 326 |
<div key={l.title}><h3 className="int-subh">{l.title}</h3><ul className="int-steps int-bullets">{l.items.map((t) => <li key={t}>{t}</li>)}</ul></div>
|
| 327 |
))}
|
|
@@ -345,8 +345,8 @@ const ASSISTANTS: AssistantKey[] = ['copilot', 'chatgpt', 'claude', 'github', 'c
|
|
| 345 |
|
| 346 |
const PLANNED_DRAWER: Partial<Record<Key, ReactNode>> = {
|
| 347 |
jira: (
|
| 348 |
-
<PlannedSetup intro="Defects a person confirms in
|
| 349 |
-
lists={[{ title: 'It will', items: ['Create a Jira issue for each confirmed defect, with the failed step, expected and actual result, and screenshots', 'Link the issue back to the test run and the scenario', 'Show the Jira status next to the defect in
|
| 350 |
note="It will use a Jira account with the least rights it needs: create and comment on issues in that one project." />
|
| 351 |
),
|
| 352 |
servicenow: (
|
|
@@ -360,7 +360,7 @@ const PLANNED_DRAWER: Partial<Record<Key, ReactNode>> = {
|
|
| 360 |
),
|
| 361 |
};
|
| 362 |
|
| 363 |
-
/** Integrations: where
|
| 364 |
export function IntegrationsPage() {
|
| 365 |
const ns = useNotifySettings();
|
| 366 |
const ints = useIntegrations();
|
|
@@ -384,22 +384,22 @@ export function IntegrationsPage() {
|
|
| 384 |
{ id: 'discord', icon: <IconBrandDiscord size={22} stroke={1.7} />, name: 'Discord', description: 'Notifications in a Discord channel, through a channel webhook.',
|
| 385 |
caps: ['Notifications'], st: hook('discord') },
|
| 386 |
] },
|
| 387 |
-
{ id: 'assistants', title: 'AI assistants', lede: 'Ask
|
| 388 |
{ id: 'copilot', icon: <IconSparkles size={22} stroke={1.7} />, name: 'Microsoft Copilot', description: 'Ask about readiness and start runs from a Copilot Studio agent.', caps: mcpCaps, st: assistant },
|
| 389 |
{ id: 'chatgpt', icon: <IconBrandOpenai size={22} stroke={1.7} />, name: 'ChatGPT', description: 'Ask about readiness and start runs from ChatGPT.', caps: mcpCaps, st: COMING_NEXT },
|
| 390 |
{ id: 'claude', icon: <IconMessageChatbot size={22} stroke={1.7} />, name: 'Claude', description: 'Ask about readiness and start runs from Claude Desktop or Claude Code.', caps: mcpCaps, st: assistant },
|
| 391 |
-
{ id: 'github', icon: <IconBrandGithubCopilot size={22} stroke={1.7} />, name: 'GitHub Copilot (VS Code)', description: 'Ask
|
| 392 |
-
{ id: 'cursor', icon: <IconCode size={22} stroke={1.7} />, name: 'Cursor', description: "Ask
|
| 393 |
] },
|
| 394 |
-
{ id: 'agents', title: 'Your own agents', lede: 'Agents you build can work with
|
| 395 |
{ id: 'a2a', icon: <IconAffiliate size={22} stroke={1.7} />, name: 'Agent2Agent (A2A)',
|
| 396 |
-
description: 'Your agent sends pod and patch facts or your own test cases;
|
| 397 |
caps: ['Send pod and patch facts', 'Your test cases', 'Follow runs', 'Get reports'], st: AVAILABLE },
|
| 398 |
] },
|
| 399 |
-
{ id: 'tools', title: 'Tools', lede: 'Systems that receive
|
| 400 |
{ id: 'webhook', icon: <IconWebhook size={22} stroke={1.7} />, name: 'Webhook (n8n and other tools)', description: 'Signed events for automation tools such as n8n.',
|
| 401 |
caps: ['Notifications', 'Signed (HMAC)'], st: status(!!ns.data?.webhook_configured, ns.data?.last_delivery) },
|
| 402 |
-
{ id: 'jira', icon: <IconBrandJira size={22} stroke={1.7} />, name: 'Jira', description: 'Planned: defects confirmed in
|
| 403 |
{ id: 'servicenow', icon: <IconTicket size={22} stroke={1.7} />, name: 'ServiceNow',
|
| 404 |
description: "Attach the readiness verdict and sign-off evidence to the patch's change request, and raise confirmed defects as incidents.",
|
| 405 |
caps: ['Change requests', 'Incidents'], st: PLANNED },
|
|
@@ -409,7 +409,7 @@ export function IntegrationsPage() {
|
|
| 409 |
return (
|
| 410 |
<Stack className="adm-wide">
|
| 411 |
<PageHeader crumbs={[{ label: 'Home', to: '/' }, { label: 'Setup' }, { label: 'Integrations' }]} title="Integrations"
|
| 412 |
-
extra={<span className="fpt-pagedesc">Where
|
| 413 |
<ErrorAlert error={ns.error || ints.error || tokens.error} title="Some integrations could not be loaded" />
|
| 414 |
{sections.map((s) => (
|
| 415 |
<section key={s.id} className="int-section" aria-labelledby={`int-sec-${s.id}`}>
|
|
|
|
| 19 |
/** Messaging tools that receive notifications through an incoming webhook (one-way). */
|
| 20 |
export type HookKey = 'slack' | 'teams' | 'google_chat' | 'discord';
|
| 21 |
export type IntegrationsState = Record<HookKey, HookIntegration>;
|
| 22 |
+
/** AI assistants that use Astra through the MCP connector (/mcp, with a personal access token). */
|
| 23 |
type AssistantKey = 'copilot' | 'chatgpt' | 'claude' | 'github' | 'cursor';
|
| 24 |
type Key = 'telegram' | HookKey | AssistantKey | 'a2a' | 'webhook' | 'jira' | 'servicenow';
|
| 25 |
type Status = { tone: 'green' | 'neutral' | 'red'; words: string; planned?: boolean; outline?: boolean };
|
|
|
|
| 191 |
function clientSetup(kind: AssistantKey, url: string): ReactNode {
|
| 192 |
const claudeDesktop = JSON.stringify({ mcpServers: { patchwise: {
|
| 193 |
command: 'npx', args: ['-y', 'mcp-remote', url, '--header', 'Authorization:${PATCHWISE_AUTH}'],
|
| 194 |
+
env: { PATCHWISE_AUTH: 'Bearer <paste your Astra token>' } } } }, null, 2);
|
| 195 |
const claudeCode = `claude mcp add --transport http patchwise ${url} --header "Authorization: Bearer $PATCHWISE_TOKEN"`;
|
| 196 |
const vscode = JSON.stringify({ servers: { patchwise: { type: 'http', url, headers: { Authorization: 'Bearer ${input:patchwise-token}' } } },
|
| 197 |
+
inputs: [{ type: 'promptString', id: 'patchwise-token', description: 'Astra token', password: true }] }, null, 2);
|
| 198 |
const cursor = JSON.stringify({ mcpServers: { patchwise: { url, headers: { Authorization: 'Bearer ${env:PATCHWISE_TOKEN}' } } } }, null, 2);
|
| 199 |
if (kind === 'claude') return (
|
| 200 |
<>
|
|
|
|
| 206 |
if (kind === 'github') return (
|
| 207 |
<>
|
| 208 |
<Snippet title="VS Code: .vscode/mcp.json" label="the VS Code settings" code={vscode} />
|
| 209 |
+
<Text size="sm" c="dimmed">VS Code asks for the token the first time GitHub Copilot uses Astra, and keeps it in its secret storage.</Text>
|
| 210 |
</>
|
| 211 |
);
|
| 212 |
if (kind === 'cursor') return (
|
|
|
|
| 222 |
<li>In Copilot Studio, open your agent, then <b>Tools</b>, <b>Add a tool</b>, <b>Model Context Protocol</b>.</li>
|
| 223 |
<li>Server URL: the address above.</li>
|
| 224 |
<li>Authentication: <b>API key</b>, sent in the header <code>Authorization</code>, with the value <code>Bearer <your token></code>.</li>
|
| 225 |
+
<li>Save, then try: "What is waiting for me in Astra?"</li>
|
| 226 |
</ol>
|
| 227 |
</div>
|
| 228 |
);
|
|
|
|
| 247 |
);
|
| 248 |
}
|
| 249 |
|
| 250 |
+
/** What another agent can ask Astra for over A2A, one line each (the skills on the Agent Card). */
|
| 251 |
const A2A_SKILLS: { id: string; words: string }[] = [
|
| 252 |
{ id: 'assess-readiness', words: 'How ready each business area is for a patch, with the numbers behind it.' },
|
| 253 |
{ id: 'design-tests', words: 'Design scenarios from the pod and patch facts your agent sends.' },
|
| 254 |
{ id: 'test-these-cases', words: 'Turn your own test cases into scripts and try them on a pod.' },
|
| 255 |
+
{ id: 'run-tests', words: 'Start a test run; it waits until a person approves in Astra.' },
|
| 256 |
{ id: 'get-report', words: 'Fetch the verdict, counts and the report of a finished run.' },
|
| 257 |
];
|
| 258 |
|
|
|
|
| 277 |
}
|
| 278 |
task = httpx.post(BASE + "/a2a", json=send, headers=HEADERS).json()["result"]
|
| 279 |
|
| 280 |
+
# follow the task: it stops at input-required until a person approves in Astra
|
| 281 |
while task["status"]["state"] not in ("completed", "failed", "canceled", "input-required"):
|
| 282 |
time.sleep(10)
|
| 283 |
get = {"jsonrpc": "2.0", "id": 2, "method": "tasks/get", "params": {"id": task["id"]}}
|
|
|
|
| 286 |
`;
|
| 287 |
}
|
| 288 |
|
| 289 |
+
/** Your own agent talking to Astra over A2A: what it can ask for, the addresses, the token, and an example. */
|
| 290 |
function A2ASetup() {
|
| 291 |
const origin = typeof window !== 'undefined' ? window.location.origin : '';
|
| 292 |
return (
|
| 293 |
<Stack gap="md" data-testid="a2a-setup">
|
| 294 |
<Text size="sm">
|
| 295 |
+
Your own agent, for example one that reads your pod and its patch updates, can ask Astra to design tests,
|
| 296 |
test your own cases, start test runs and fetch the report. It acts as the person whose token it uses, with their permissions.
|
| 297 |
</Text>
|
| 298 |
<div>
|
|
|
|
| 302 |
</ul>
|
| 303 |
</div>
|
| 304 |
<Text size="sm" className="int-rule" data-testid="a2a-rule">
|
| 305 |
+
A person always approves in Astra before anything runs as a real test. Sign-off is never available through A2A.
|
| 306 |
</Text>
|
| 307 |
<Group gap="xs">
|
| 308 |
<Button component={Link} to="/account#tokens" variant="filled" leftSection={<IconKey size={15} aria-hidden />}>Create a token</Button>
|
|
|
|
| 315 |
);
|
| 316 |
}
|
| 317 |
|
| 318 |
+
/** An AI assistant: what it can do through Astra, the token it needs, the /mcp address and its own settings. */
|
| 319 |
function AssistantSetup({ kind }: { kind: AssistantKey }) {
|
| 320 |
const url = `${typeof window !== 'undefined' ? window.location.origin : ''}/mcp`;
|
| 321 |
const web = kind === 'chatgpt';
|
| 322 |
return (
|
| 323 |
<Stack gap="md" data-testid={`assistant-setup-${kind}`}>
|
| 324 |
+
<Text size="sm">It uses Astra as you, with your permissions, through one MCP connector (Model Context Protocol). Sign-off and failure verdicts stay in Astra.</Text>
|
| 325 |
{ASSISTANT_CAN.map((l) => (
|
| 326 |
<div key={l.title}><h3 className="int-subh">{l.title}</h3><ul className="int-steps int-bullets">{l.items.map((t) => <li key={t}>{t}</li>)}</ul></div>
|
| 327 |
))}
|
|
|
|
| 345 |
|
| 346 |
const PLANNED_DRAWER: Partial<Record<Key, ReactNode>> = {
|
| 347 |
jira: (
|
| 348 |
+
<PlannedSetup intro="Defects a person confirms in Astra will be raised as Jira issues in the project you choose, with the evidence attached."
|
| 349 |
+
lists={[{ title: 'It will', items: ['Create a Jira issue for each confirmed defect, with the failed step, expected and actual result, and screenshots', 'Link the issue back to the test run and the scenario', 'Show the Jira status next to the defect in Astra'] }]}
|
| 350 |
note="It will use a Jira account with the least rights it needs: create and comment on issues in that one project." />
|
| 351 |
),
|
| 352 |
servicenow: (
|
|
|
|
| 360 |
),
|
| 361 |
};
|
| 362 |
|
| 363 |
+
/** Integrations: where Astra reaches people (messaging), the AI assistants that will ask it, and the tools it feeds. */
|
| 364 |
export function IntegrationsPage() {
|
| 365 |
const ns = useNotifySettings();
|
| 366 |
const ints = useIntegrations();
|
|
|
|
| 384 |
{ id: 'discord', icon: <IconBrandDiscord size={22} stroke={1.7} />, name: 'Discord', description: 'Notifications in a Discord channel, through a channel webhook.',
|
| 385 |
caps: ['Notifications'], st: hook('discord') },
|
| 386 |
] },
|
| 387 |
+
{ id: 'assistants', title: 'AI assistants', lede: 'Ask Astra from the assistant you already use.', cards: [
|
| 388 |
{ id: 'copilot', icon: <IconSparkles size={22} stroke={1.7} />, name: 'Microsoft Copilot', description: 'Ask about readiness and start runs from a Copilot Studio agent.', caps: mcpCaps, st: assistant },
|
| 389 |
{ id: 'chatgpt', icon: <IconBrandOpenai size={22} stroke={1.7} />, name: 'ChatGPT', description: 'Ask about readiness and start runs from ChatGPT.', caps: mcpCaps, st: COMING_NEXT },
|
| 390 |
{ id: 'claude', icon: <IconMessageChatbot size={22} stroke={1.7} />, name: 'Claude', description: 'Ask about readiness and start runs from Claude Desktop or Claude Code.', caps: mcpCaps, st: assistant },
|
| 391 |
+
{ id: 'github', icon: <IconBrandGithubCopilot size={22} stroke={1.7} />, name: 'GitHub Copilot (VS Code)', description: 'Ask Astra from GitHub Copilot chat in VS Code.', caps: ide, st: assistant },
|
| 392 |
+
{ id: 'cursor', icon: <IconCode size={22} stroke={1.7} />, name: 'Cursor', description: "Ask Astra from Cursor's assistant.", caps: ide, st: assistant },
|
| 393 |
] },
|
| 394 |
+
{ id: 'agents', title: 'Your own agents', lede: 'Agents you build can work with Astra through Agent2Agent (A2A).', cards: [
|
| 395 |
{ id: 'a2a', icon: <IconAffiliate size={22} stroke={1.7} />, name: 'Agent2Agent (A2A)',
|
| 396 |
+
description: 'Your agent sends pod and patch facts or your own test cases; Astra designs and runs the tests and returns the report.',
|
| 397 |
caps: ['Send pod and patch facts', 'Your test cases', 'Follow runs', 'Get reports'], st: AVAILABLE },
|
| 398 |
] },
|
| 399 |
+
{ id: 'tools', title: 'Tools', lede: 'Systems that receive Astra events and results.', cards: [
|
| 400 |
{ id: 'webhook', icon: <IconWebhook size={22} stroke={1.7} />, name: 'Webhook (n8n and other tools)', description: 'Signed events for automation tools such as n8n.',
|
| 401 |
caps: ['Notifications', 'Signed (HMAC)'], st: status(!!ns.data?.webhook_configured, ns.data?.last_delivery) },
|
| 402 |
+
{ id: 'jira', icon: <IconBrandJira size={22} stroke={1.7} />, name: 'Jira', description: 'Planned: defects confirmed in Astra raised as Jira issues.', caps: ['Defects'], st: PLANNED },
|
| 403 |
{ id: 'servicenow', icon: <IconTicket size={22} stroke={1.7} />, name: 'ServiceNow',
|
| 404 |
description: "Attach the readiness verdict and sign-off evidence to the patch's change request, and raise confirmed defects as incidents.",
|
| 405 |
caps: ['Change requests', 'Incidents'], st: PLANNED },
|
|
|
|
| 409 |
return (
|
| 410 |
<Stack className="adm-wide">
|
| 411 |
<PageHeader crumbs={[{ label: 'Home', to: '/' }, { label: 'Setup' }, { label: 'Integrations' }]} title="Integrations"
|
| 412 |
+
extra={<span className="fpt-pagedesc">Where Astra reaches you, and the AI assistants that can work with it. Notifications go to every connected place; Telegram also lets people start runs and approve from the chat.</span>} />
|
| 413 |
<ErrorAlert error={ns.error || ints.error || tokens.error} title="Some integrations could not be loaded" />
|
| 414 |
{sections.map((s) => (
|
| 415 |
<section key={s.id} className="int-section" aria-labelledby={`int-sec-${s.id}`}>
|
web/src/pages/LoginPage.tsx
CHANGED
|
@@ -28,7 +28,7 @@ export function LoginPage() {
|
|
| 28 |
const reduce = useReducedMotion();
|
| 29 |
const authCfg = useAuthConfig();
|
| 30 |
const supabase = authCfg.data?.provider === 'supabase';
|
| 31 |
-
const name = brand.data?.product_name ?? '
|
| 32 |
// only a path inside this app: never '//host' or '/\host', which a browser reads as another site
|
| 33 |
const asked = (loc.state as { from?: string } | null)?.from ?? '/';
|
| 34 |
const from = /^\/(?![/\\])/.test(asked) ? asked : '/';
|
|
|
|
| 28 |
const reduce = useReducedMotion();
|
| 29 |
const authCfg = useAuthConfig();
|
| 30 |
const supabase = authCfg.data?.provider === 'supabase';
|
| 31 |
+
const name = brand.data?.product_name ?? 'Astra';
|
| 32 |
// only a path inside this app: never '//host' or '/\host', which a browser reads as another site
|
| 33 |
const asked = (loc.state as { from?: string } | null)?.from ?? '/';
|
| 34 |
const from = /^\/(?![/\\])/.test(asked) ? asked : '/';
|
web/src/pages/RegisterPage.test.tsx
CHANGED
|
@@ -12,7 +12,7 @@ function mockApi(registration: boolean, posts: unknown[]) {
|
|
| 12 |
if (req.url.endsWith('/api/auth/me')) return jsonResponse({ detail: 'not signed in', code: 'UNAUTHENTICATED' }, 401);
|
| 13 |
if (req.url.endsWith('/api/auth/config')) return jsonResponse({ provider: 'supabase', registration, new_account_role: 'viewer' });
|
| 14 |
if (req.url.endsWith('/api/auth/register')) { posts.push(await req.json()); return jsonResponse({ status: 'confirm_email', message: 'check' }); }
|
| 15 |
-
return jsonResponse({ ready: true, product_name: '
|
| 16 |
});
|
| 17 |
}
|
| 18 |
|
|
|
|
| 12 |
if (req.url.endsWith('/api/auth/me')) return jsonResponse({ detail: 'not signed in', code: 'UNAUTHENTICATED' }, 401);
|
| 13 |
if (req.url.endsWith('/api/auth/config')) return jsonResponse({ provider: 'supabase', registration, new_account_role: 'viewer' });
|
| 14 |
if (req.url.endsWith('/api/auth/register')) { posts.push(await req.json()); return jsonResponse({ status: 'confirm_email', message: 'check' }); }
|
| 15 |
+
return jsonResponse({ ready: true, product_name: 'Astra' });
|
| 16 |
});
|
| 17 |
}
|
| 18 |
|
web/src/pages/SettingsPage.tsx
CHANGED
|
@@ -224,7 +224,7 @@ export function SettingsPage() {
|
|
| 224 |
<Tabs.Panel value="advanced" pt="md">
|
| 225 |
<Text size="sm" c="dimmed" mb="sm">Engineering views of the co-worker. Functional consultants do not need these.</Text>
|
| 226 |
<div className="adm-grid">
|
| 227 |
-
<AdvCard to="/integrations" icon={<IconPlug size={17} />} title="Integrations" body="Telegram, Teams, Slack and other places
|
| 228 |
<AdvCard to="/agents" icon={<IconRobot size={17} />} title="Agent team" body="The agents, their engines and the workflow." />
|
| 229 |
<AdvCard to="/heal" icon={<IconWand size={17} />} title="Self-heal review" body="Proposed fixes from failed scripts." />
|
| 230 |
<AdvCard to="/scripts" icon={<IconBooks size={17} />} title="Scripts & drafts" body="Automation scripts and library history." />
|
|
|
|
| 224 |
<Tabs.Panel value="advanced" pt="md">
|
| 225 |
<Text size="sm" c="dimmed" mb="sm">Engineering views of the co-worker. Functional consultants do not need these.</Text>
|
| 226 |
<div className="adm-grid">
|
| 227 |
+
<AdvCard to="/integrations" icon={<IconPlug size={17} />} title="Integrations" body="Telegram, Teams, Slack and other places Astra reaches people." />
|
| 228 |
<AdvCard to="/agents" icon={<IconRobot size={17} />} title="Agent team" body="The agents, their engines and the workflow." />
|
| 229 |
<AdvCard to="/heal" icon={<IconWand size={17} />} title="Self-heal review" body="Proposed fixes from failed scripts." />
|
| 230 |
<AdvCard to="/scripts" icon={<IconBooks size={17} />} title="Scripts & drafts" body="Automation scripts and library history." />
|
web/src/pages/login/BrandMark.tsx
CHANGED
|
@@ -1,16 +1,4 @@
|
|
| 1 |
-
/** The
|
| 2 |
-
* sign-in page; the rest of the app keeps its current logo until this one is approved. */
|
| 3 |
export function BrandMark({ size = 40, title }: { size?: number; title?: string }) {
|
| 4 |
-
return
|
| 5 |
-
<svg width={size} height={size} viewBox="0 0 64 64" role={title ? 'img' : undefined} aria-label={title} aria-hidden={title ? undefined : true}>
|
| 6 |
-
<rect width="64" height="64" rx="16" fill="#f5f5f7" />
|
| 7 |
-
<g fill="none" stroke="#1d1d1f" strokeWidth="2.6" opacity="0.92">
|
| 8 |
-
<ellipse cx="32" cy="32" rx="20" ry="8.5" />
|
| 9 |
-
<ellipse cx="32" cy="32" rx="20" ry="8.5" transform="rotate(60 32 32)" />
|
| 10 |
-
<ellipse cx="32" cy="32" rx="20" ry="8.5" transform="rotate(120 32 32)" />
|
| 11 |
-
</g>
|
| 12 |
-
<circle cx="32" cy="32" r="5" fill="#1d1d1f" />
|
| 13 |
-
<circle cx="52" cy="32" r="4.2" fill="#1d7a35" stroke="#f5f5f7" strokeWidth="1.6" />
|
| 14 |
-
</svg>
|
| 15 |
-
);
|
| 16 |
}
|
|
|
|
| 1 |
+
/** The product mark (the CES logo, web/public/astra-logo.png), on the sign-in pages. */
|
|
|
|
| 2 |
export function BrandMark({ size = 40, title }: { size?: number; title?: string }) {
|
| 3 |
+
return <img className="astra-logo" src="/astra-logo.png" height={size} alt={title ?? ''} aria-hidden={title ? undefined : true} />;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
web/src/pages/login/ReleaseScene.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { useEffect, useRef } from 'react';
|
|
| 2 |
import * as THREE from 'three';
|
| 3 |
|
| 4 |
/**
|
| 5 |
-
* The sign-in hero:
|
| 6 |
* nodes orbit it on tilted rings; a test wave sweeps the shell and turns the points it passes green ("tested").
|
| 7 |
*
|
| 8 |
* Production rules: one still frame when reduced motion is requested; paused while the tab is hidden; pixel ratio
|
|
|
|
| 2 |
import * as THREE from 'three';
|
| 3 |
|
| 4 |
/**
|
| 5 |
+
* The sign-in hero: Astra's idea in 3D. A release core (the Oracle update) sits in a shell of test points; three agent
|
| 6 |
* nodes orbit it on tilted rings; a test wave sweeps the shell and turns the points it passes green ("tested").
|
| 7 |
*
|
| 8 |
* Production rules: one still frame when reduced motion is requested; paused while the tab is hidden; pixel ratio
|
web/src/theme.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import { createTheme, type MantineColorsTuple } from '@mantine/core';
|
| 2 |
|
| 3 |
-
//
|
| 4 |
// filled buttons take the deeper burnt orange from tokens.css (--mantine-primary-color-filled) so white text passes AA.
|
| 5 |
const trio: MantineColorsTuple = ['#fff1eb', '#ffdccd', '#ffbb9c', '#ff9668', '#f5763f', '#e8602e', '#c4471a', '#a93b14', '#86300f', '#5e210a'];
|
| 6 |
// Neutral ramp for Mantine's "dark" lookups; the real surfaces come from the CSS variables in apple.css.
|
|
|
|
| 1 |
import { createTheme, type MantineColorsTuple } from '@mantine/core';
|
| 2 |
|
| 3 |
+
// Astra, Ember (after Sheryians): Mantine's primary is the ember orange (checkboxes, switches, progress, steppers);
|
| 4 |
// filled buttons take the deeper burnt orange from tokens.css (--mantine-primary-color-filled) so white text passes AA.
|
| 5 |
const trio: MantineColorsTuple = ['#fff1eb', '#ffdccd', '#ffbb9c', '#ff9668', '#f5763f', '#e8602e', '#c4471a', '#a93b14', '#86300f', '#5e210a'];
|
| 6 |
// Neutral ramp for Mantine's "dark" lookups; the real surfaces come from the CSS variables in apple.css.
|