Skip to content

Commit e9bf640

Browse files
khaliqgantProactive Runtime Botgithub-actions[bot]agent-relay-code[bot]
authored
fix(cli): retry inbound webhook auth from local broker (#1198)
* fix(cli): retry inbound webhook auth from local broker * style: auto-format with Prettier * chore: apply pr-reviewer fixes for #1198 * fix(cli): generalize integration auth fallback * docs(changelog): simplify integration auth fix entry * style: auto-format with Prettier --------- Co-authored-by: Proactive Runtime Bot <agent@agent-relay.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: agent-relay-code[bot] <agent-relay-code[bot]@users.noreply.github.com>
1 parent e08b39e commit e9bf640

13 files changed

Lines changed: 517 additions & 64 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Trajectory: Debug invalid API key for integration webhook create-inbound
2+
3+
> **Status:** ✅ Completed
4+
> **Confidence:** 86%
5+
> **Started:** June 24, 2026 at 03:34 PM
6+
> **Completed:** June 24, 2026 at 03:38 PM
7+
8+
---
9+
10+
## Summary
11+
12+
Fixed inbound webhook CLI local workflow auth fallback. The new create-inbound/list-inbound/delete-inbound commands now retry once with the running project broker's workspace key after SDK Invalid API key or missing-key failures, preserving explicit --workspace-key behavior. Added focused tests and changelog entry; CLI package build passes.
13+
14+
**Approach:** Standard approach
15+
16+
---
17+
18+
## Key Decisions
19+
20+
### Retry inbound webhook CLI operations with local broker workspace key after SDK auth failure
21+
22+
- **Chose:** Retry inbound webhook CLI operations with local broker workspace key after SDK auth failure
23+
- **Reasoning:** PR 1193 added command wrappers, but local workflows can still use stale global SDK auth; retrying only inbound webhook commands preserves explicit --workspace-key behavior while making local broker sessions work.
24+
25+
---
26+
27+
## Chapters
28+
29+
### 1. Work
30+
31+
_Agent: default_
32+
33+
- Retry inbound webhook CLI operations with local broker workspace key after SDK auth failure: Retry inbound webhook CLI operations with local broker workspace key after SDK auth failure
34+
- Focused CLI tests and package build pass; change is scoped to inbound webhook auth fallback
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"id": "traj_ikt549lejpvk",
3+
"version": 1,
4+
"task": {
5+
"title": "Debug invalid API key for integration webhook create-inbound"
6+
},
7+
"status": "completed",
8+
"startedAt": "2026-06-24T13:34:15.300Z",
9+
"completedAt": "2026-06-24T13:38:26.732Z",
10+
"agents": [
11+
{
12+
"name": "default",
13+
"role": "lead",
14+
"joinedAt": "2026-06-24T13:37:36.196Z"
15+
}
16+
],
17+
"chapters": [
18+
{
19+
"id": "chap_3u2wlfcx1nz4",
20+
"title": "Work",
21+
"agentName": "default",
22+
"startedAt": "2026-06-24T13:37:36.196Z",
23+
"endedAt": "2026-06-24T13:38:26.732Z",
24+
"events": [
25+
{
26+
"ts": 1782308256198,
27+
"type": "decision",
28+
"content": "Retry inbound webhook CLI operations with local broker workspace key after SDK auth failure: Retry inbound webhook CLI operations with local broker workspace key after SDK auth failure",
29+
"raw": {
30+
"question": "Retry inbound webhook CLI operations with local broker workspace key after SDK auth failure",
31+
"chosen": "Retry inbound webhook CLI operations with local broker workspace key after SDK auth failure",
32+
"alternatives": [],
33+
"reasoning": "PR 1193 added command wrappers, but local workflows can still use stale global SDK auth; retrying only inbound webhook commands preserves explicit --workspace-key behavior while making local broker sessions work."
34+
},
35+
"significance": "high"
36+
},
37+
{
38+
"ts": 1782308294395,
39+
"type": "reflection",
40+
"content": "Focused CLI tests and package build pass; change is scoped to inbound webhook auth fallback",
41+
"raw": {
42+
"confidence": 0.86
43+
},
44+
"significance": "high",
45+
"tags": ["confidence:0.86"]
46+
}
47+
]
48+
}
49+
],
50+
"retrospective": {
51+
"summary": "Fixed inbound webhook CLI local workflow auth fallback. The new create-inbound/list-inbound/delete-inbound commands now retry once with the running project broker's workspace key after SDK Invalid API key or missing-key failures, preserving explicit --workspace-key behavior. Added focused tests and changelog entry; CLI package build passes.",
52+
"approach": "Standard approach",
53+
"confidence": 0.86
54+
},
55+
"commits": [],
56+
"filesChanged": [],
57+
"projectId": "AgentWorkforce/relay",
58+
"tags": [],
59+
"_trace": {
60+
"startRef": "e08b39ede25d51277182dbe64185898c4ad420bf",
61+
"endRef": "e08b39ede25d51277182dbe64185898c4ad420bf"
62+
}
63+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Trajectory: Address PR 1198 changelog feedback
2+
3+
> **Status:** ✅ Completed
4+
> **Confidence:** 95%
5+
> **Started:** June 24, 2026 at 03:55 PM
6+
> **Completed:** June 24, 2026 at 03:56 PM
7+
8+
---
9+
10+
## Summary
11+
12+
Shortened PR 1198 changelog entry per CodeRabbit feedback so it describes the local broker workflow fix without implementation details.
13+
14+
**Approach:** Standard approach
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"id": "traj_ipdlvxuqj2b0",
3+
"version": 1,
4+
"task": {
5+
"title": "Address PR 1198 changelog feedback"
6+
},
7+
"status": "completed",
8+
"startedAt": "2026-06-24T13:55:49.343Z",
9+
"completedAt": "2026-06-24T13:56:04.609Z",
10+
"agents": [],
11+
"chapters": [],
12+
"retrospective": {
13+
"summary": "Shortened PR 1198 changelog entry per CodeRabbit feedback so it describes the local broker workflow fix without implementation details.",
14+
"approach": "Standard approach",
15+
"confidence": 0.95
16+
},
17+
"commits": [],
18+
"filesChanged": [],
19+
"projectId": "AgentWorkforce/relay",
20+
"tags": [],
21+
"_trace": {
22+
"startRef": "f15b38cdf85a1d8dd4fc116d344c077d469a9c4f",
23+
"endRef": "f15b38cdf85a1d8dd4fc116d344c077d469a9c4f"
24+
}
25+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Trajectory: Address PR 1198 feedback
2+
3+
> **Status:** ✅ Completed
4+
> **Confidence:** 90%
5+
> **Started:** June 24, 2026 at 03:48 PM
6+
> **Completed:** June 24, 2026 at 03:54 PM
7+
8+
---
9+
10+
## Summary
11+
12+
Addressed PR 1198 feedback by broadening integration auth fallback matching, generalizing retry handling across webhook and subscription commands, and carrying the broker Relaycast base URL through /api/session so local broker retries target the correct backend. Added CLI and broker session tests; focused validation and builds passed.
13+
14+
**Approach:** Standard approach
15+
16+
---
17+
18+
## Key Decisions
19+
20+
### Generalized integration auth fallback and included broker Relaycast base URL
21+
22+
- **Chose:** Generalized integration auth fallback and included broker Relaycast base URL
23+
- **Reasoning:** PR feedback pointed out brittle auth matching and inbound-only fallback; exposing relay_base_url in /api/session also prevents retrying a broker workspace key against the wrong Relaycast backend.
24+
25+
---
26+
27+
## Chapters
28+
29+
### 1. Work
30+
31+
_Agent: default_
32+
33+
- Generalized integration auth fallback and included broker Relaycast base URL: Generalized integration auth fallback and included broker Relaycast base URL
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"id": "traj_v96vk8uaesyw",
3+
"version": 1,
4+
"task": {
5+
"title": "Address PR 1198 feedback"
6+
},
7+
"status": "completed",
8+
"startedAt": "2026-06-24T13:48:38.977Z",
9+
"completedAt": "2026-06-24T13:54:21.164Z",
10+
"agents": [
11+
{
12+
"name": "default",
13+
"role": "lead",
14+
"joinedAt": "2026-06-24T13:51:20.030Z"
15+
}
16+
],
17+
"chapters": [
18+
{
19+
"id": "chap_0xmtpnvtrfzb",
20+
"title": "Work",
21+
"agentName": "default",
22+
"startedAt": "2026-06-24T13:51:20.030Z",
23+
"endedAt": "2026-06-24T13:54:21.164Z",
24+
"events": [
25+
{
26+
"ts": 1782309080032,
27+
"type": "decision",
28+
"content": "Generalized integration auth fallback and included broker Relaycast base URL: Generalized integration auth fallback and included broker Relaycast base URL",
29+
"raw": {
30+
"question": "Generalized integration auth fallback and included broker Relaycast base URL",
31+
"chosen": "Generalized integration auth fallback and included broker Relaycast base URL",
32+
"alternatives": [],
33+
"reasoning": "PR feedback pointed out brittle auth matching and inbound-only fallback; exposing relay_base_url in /api/session also prevents retrying a broker workspace key against the wrong Relaycast backend."
34+
},
35+
"significance": "high"
36+
}
37+
]
38+
}
39+
],
40+
"retrospective": {
41+
"summary": "Addressed PR 1198 feedback by broadening integration auth fallback matching, generalizing retry handling across webhook and subscription commands, and carrying the broker Relaycast base URL through /api/session so local broker retries target the correct backend. Added CLI and broker session tests; focused validation and builds passed.",
42+
"approach": "Standard approach",
43+
"confidence": 0.9
44+
},
45+
"commits": [],
46+
"filesChanged": [],
47+
"projectId": "AgentWorkforce/relay",
48+
"tags": [],
49+
"_trace": {
50+
"startRef": "89ecfa7e2169a6a5ce3fa8b11504497282c44541",
51+
"endRef": "89ecfa7e2169a6a5ce3fa8b11504497282c44541"
52+
}
53+
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12+
- `agent-relay integration webhook|subscription` commands work reliably in local broker workflows even when shell auth is stale or missing.
1213
- The Bun-compiled `agent-relay` standalone binary now bundles workspace packages from their compiled JS instead of their `.d.ts`, so `local up` starts the implicit Fleet local node instead of failing with `Fleet local node skipped: … is not a function`. The `tsconfig` `paths` that mapped `@agent-relay/*` to declaration files (no runtime exports) were redundant with the npm workspace symlinks and have been removed.
1314
- `agent-relay` and `@agent-relay/sdk` require `@relaycast/sdk` `^4.1.2`, whose matching `@relaycast/types` package is now published, so publish installs resolve cleanly without pinning.
1415
- `agent-relay fleet serve <node-def>` loads plain JavaScript node definitions without `jiti`, so the published Bun-compiled CLI can serve compiled JS node files.

crates/broker/src/listen_api.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ struct ListenApiState {
312312
/// endpoint so the dashboard can bootstrap Relaycast calls without a
313313
/// relaycast.json or env var.
314314
workspace_key: Option<String>,
315+
/// Relaycast HTTP base URL that owns the workspace key.
316+
relay_base_url: Option<String>,
315317
memberships: Vec<WorkspaceMembershipSummary>,
316318
default_workspace_id: Option<WorkspaceId>,
317319
/// Broker version string (from Cargo.toml)
@@ -346,6 +348,7 @@ pub struct ListenApiConfig {
346348
pub events_tx: broadcast::Sender<String>,
347349
pub replay_buffer: ReplayBuffer,
348350
pub workspace_key: Option<String>,
351+
pub relay_base_url: Option<String>,
349352
pub memberships: Vec<WorkspaceMembershipSummary>,
350353
pub default_workspace_id: Option<WorkspaceId>,
351354
pub persist: bool,
@@ -379,6 +382,10 @@ fn listen_api_router_with_auth(
379382
.workspace_key
380383
.map(|value| value.trim().to_string())
381384
.filter(|value| !value.is_empty()),
385+
relay_base_url: config
386+
.relay_base_url
387+
.map(|value| value.trim().to_string())
388+
.filter(|value| !value.is_empty()),
382389
memberships: config.memberships,
383390
default_workspace_id: config.default_workspace_id,
384391
broker_version: crate::util::version::broker_version().to_string(),
@@ -514,6 +521,7 @@ async fn listen_api_session(
514521
"broker_version": state.broker_version,
515522
"protocol_version": 2,
516523
"workspace_key": state.workspace_key,
524+
"relay_base_url": state.relay_base_url,
517525
"default_workspace_id": state.default_workspace_id,
518526
"mode": if state.persist { "persist" } else { "ephemeral" },
519527
"uptime_secs": state.started_at.elapsed().as_secs(),
@@ -2540,6 +2548,7 @@ mod auth_tests {
25402548
events_tx,
25412549
replay_buffer,
25422550
workspace_key: None,
2551+
relay_base_url: Some("https://relay.test".to_string()),
25432552
memberships: vec![],
25442553
default_workspace_id: None,
25452554
persist: false,
@@ -3144,6 +3153,7 @@ mod auth_tests {
31443153
let body = response_json(response).await;
31453154
assert!(body["broker_version"].is_string());
31463155
assert_eq!(body["protocol_version"], 2);
3156+
assert_eq!(body["relay_base_url"], "https://relay.test");
31473157
assert_eq!(body["mode"], "ephemeral");
31483158
}
31493159

crates/broker/src/runtime/init.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ pub(crate) async fn run_init(cmd: InitCommand, telemetry: TelemetryClient) -> Re
283283
events_tx: events_tx.clone(),
284284
replay_buffer: replay_buffer.clone(),
285285
workspace_key: Some(relay_workspace_key.clone()),
286+
relay_base_url: Some(http_base.clone()),
286287
memberships: workspace_memberships.clone(),
287288
default_workspace_id: default_workspace_id.clone(),
288289
persist: cmd.persist,

0 commit comments

Comments
 (0)