Skip to content

feat: auto-wire telemetry in initSquadTelemetry() (#281)#501

Merged
bradygaster merged 1 commit intodevfrom
squad/281-telemetry-auto-wiring
Mar 22, 2026
Merged

feat: auto-wire telemetry in initSquadTelemetry() (#281)#501
bradygaster merged 1 commit intodevfrom
squad/281-telemetry-auto-wiring

Conversation

@bradygaster
Copy link
Copy Markdown
Owner

What

initSquadTelemetry() now auto-creates EventBus and CostTracker so users just call:

const telemetry = initSquadTelemetry();
// That's it. Everything lights up.
console.log(telemetry.costTracker.formatSummary());

Changes

  • Auto-create EventBus internally if none is provided
  • Auto-wire CostTracker to the internal EventBus
  • SquadClient.sendMessage() now calls recordTokenUsage() (not just span attributes)
  • New SquadClient.sendAndWait() with OTel tracing + metric recording
  • Auto-forward session usage events to the EventBus when sessions are created via SquadClient
  • Model pricing table included in SDK — users don't maintain their own pricing
  • estimateCost() helper for token-based cost estimation
  • Expose costTracker and eventBus on SquadTelemetryHandle
  • SquadClient accepts optional eventBus parameter for auto-wiring
  • New subpath exports: ./runtime/otel-init, ./config/models

Tests

16 new tests covering auto-wiring, pricing, cost accumulation, and unwiring. All 107 related tests pass.

Files Changed

File Change
packages/squad-sdk/src/runtime/otel-init.ts Auto-create EventBus + CostTracker, expose on handle
packages/squad-sdk/src/config/models.ts Add ModelPricing, pricing data, estimateCost()
packages/squad-sdk/src/adapter/client.ts eventBus option, recordTokenUsage(), sendAndWait(), usage forwarding
packages/squad-sdk/package.json New subpath exports
test/telemetry-auto-wiring.test.ts 16 new tests

Closes #281

Credit: Brady Gaster (issue author), Squad IRL samples (discovery source)
Working as EECOM (Core Dev)

initSquadTelemetry() now auto-creates EventBus + CostTracker internally,
so users just call it once and everything lights up:

  const telemetry = initSquadTelemetry();
  // EventBus, CostTracker, OTel bridge — all wired.
  console.log(telemetry.costTracker.formatSummary());

Changes:
- Auto-create EventBus when none provided (otel-init.ts)
- Auto-wire CostTracker to EventBus on init (otel-init.ts)
- Expose eventBus + costTracker on SquadTelemetryHandle
- Add model pricing table to MODEL_CATALOG (models.ts)
- Add estimateCost() helper for token-based cost estimation
- SquadClient.sendMessage() now calls recordTokenUsage() (not just span attrs)
- Add SquadClient.sendAndWait() with OTel tracing + metric recording
- SquadClient accepts optional eventBus for auto-forwarding usage events
- createSession() auto-wires usage event forwarding to EventBus
- Add subpath exports: ./runtime/otel-init, ./config/models
- 16 new tests covering auto-wiring, pricing, and unwiring

Closes #281

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bradygaster bradygaster merged commit d507dc3 into dev Mar 22, 2026
0 of 2 checks passed
chrislomonico pushed a commit to clomonico/squad that referenced this pull request Mar 26, 2026
…radygaster#540)

Wires 5 ghost commands: hire→init, heartbeat→doctor, shell→REPL, loop→triage, run→stub with redirect.

Closes bradygaster#501, Closes bradygaster#503, Closes bradygaster#504, Closes bradygaster#507, Closes bradygaster#509

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bradygaster bradygaster deleted the squad/281-telemetry-auto-wiring branch March 26, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

initSquadTelemetry() should auto-wire EventBus, CostTracker, and token metrics

1 participant