feat(cli): support optional extra headers for hub requests#445
feat(cli): support optional extra headers for hub requests#445Shujakuinkuraudo wants to merge 2 commits intotiann:mainfrom
Conversation
2ec4461 to
f656817
Compare
There was a problem hiding this comment.
Findings
- [Major] Relaxing
model,modelReasoningEffort, andeffortto optional changes the sharedSessioncontract fromstring | nulltostring | null | undefined. Downstream code still treats these fields asstring | nullonly, for exampletoSessionSummary()forwards them intoSessionSummaryfields that do not allowundefined. That turns a tolerant parser change into a repo-wide type/API-shape change. Evidenceshared/src/schemas.ts:178,cli/src/api/types.ts:103; related contextshared/src/sessionSummary.ts:18,shared/src/sessionSummary.ts:19,shared/src/sessionSummary.ts:51,shared/src/sessionSummary.ts:52.
Suggested fix:Mirror the same normalization inmodel: z.string().nullable().optional().default(null), modelReasoningEffort: z.string().nullable().optional().default(null), effort: z.string().nullable().optional().default(null),
cli/src/api/types.tsso missing fields stay backward-compatible asnull.
Summary
Review mode: initial
1 major issue found: the schema relaxation currently leaks undefined into shared session fields that the rest of the repo still models as string | null. No other high-confidence regressions found in the touched header-propagation paths from static review.
Testing
- Not run (automation):
bunis unavailable in this runner, and repo-wide package typecheck could not be executed here because the installed type dependencies are missing.
HAPI Bot
shared/src/schemas.ts
Outdated
| model: z.string().nullable(), | ||
| modelReasoningEffort: z.string().nullable(), | ||
| effort: z.string().nullable(), | ||
| model: z.string().nullable().optional(), |
There was a problem hiding this comment.
[MAJOR] This widens Session.model / modelReasoningEffort / effort to include undefined, but downstream code still declares string | null only. For example, shared/src/sessionSummary.ts returns model: session.model and effort: session.effort into fields that do not accept undefined, so this parser tweak becomes a repo-wide type/API contract change.
Suggested fix:
model: z.string().nullable().optional().default(null),
modelReasoningEffort: z.string().nullable().optional().default(null),
effort: z.string().nullable().optional().default(null),Mirror the same normalization in cli/src/api/types.ts.
There was a problem hiding this comment.
Findings
- No new high-confidence issues found in the added/modified lines.
Summary
- Review mode: follow-up after new commits
- Previous schema-contract finding appears fixed by normalizing missing
model/modelReasoningEffort/efforttonullin both shared and CLI response schemas. - Residual risk: static review only. The added tests cover parsing plus POST/session-socket wiring, but not the
/cli/sessions/:id/messagesbackfill GET path or the machine-scoped socket client.
Testing
- Not run (automation):
bunis unavailable in this runner.
HAPI Bot
Summary
This PR adds an optional env-based configuration for attaching extra outbound headers when the CLI/runner connects to a self-hosted hub behind an auth proxy.
Scope is intentionally minimal:
HAPI_EXTRA_HEADERS_JSONUse case
This helps self-hosted deployments that sit behind an auth proxy or access gateway, such as Cloudflare Access, OAuth2 Proxy, IAP, or other reverse proxies that require extra request headers/cookies.
Example:
or:
What changed
HAPI_EXTRA_HEADERS_JSONin CLI configurationNotes
Authorization)Validation
Ran focused CLI tests: