Files
zeekay 043ac58d3c chore: sweep upstream brand from ALL files; restore LICENSE/NOTICE attribution
Extends the sweep beyond packages/ to the whole repo (178 files): workflows,
.eslintrc, playground, examples, tooling, root docs. Zero upstream-brand refs and
zero such filenames outside the exemptions.

REVERTS A LICENSING ERROR (from earlier rebrand e43ab1af, not this sweep):
- LICENSE had its copyright holder rewritten to 'Insights'. Restored to the real
  holder: 'Copyright 2020 Posthog / Hiberly, Inc.' (+ Mixpanel, Inc.).
- NOTICE credited a non-existent upstream (github.com/getinsights/insights-js).
  Restored to the real one: github.com/PostHog/posthog-js.
Apache-2.0 4(c) requires retaining upstream attribution; rewriting a third
party's copyright line falsifies ownership. Both files are now excluded from the
guard and documented as exempt in LLM.md.

Also:
- Deleted junk: AGENTS.md~upstream_main (merge leftover), the now-obsolete
  rebrand script; renamed upload-*-s3.ts tooling (still used by cli.ts).
- Removed 42 stale playground/example pnpm-lock.yaml files: they pinned upstream
  packages the package.json no longer references. Regenerated on install —
  sed-ing a lockfile would corrupt its integrity hashes.
- Guard renamed no-posthog.yml -> brand-guard.yml and now assembles the pattern
  at runtime, so no filename or file content carries the string (the previous
  guard was swept by its own rule, inverting it to forbid 'insights').
2026-07-16 09:54:05 -07:00

69 lines
2.3 KiB
TypeScript

/** Mastra agent with Insights tracking via the official @mastra/insights exporter. */
import { Mastra } from '@mastra/core'
import { Agent } from '@mastra/core/agent'
import { createTool } from '@mastra/core/tools'
import { Observability } from '@mastra/observability'
import { InsightsExporter } from '@mastra/insights'
import { z } from 'zod'
const weatherTool = createTool({
id: 'get_weather',
description: 'Get current weather for a location',
inputSchema: z.object({
latitude: z.number(),
longitude: z.number(),
location_name: z.string(),
}),
execute: async ({ latitude, longitude, location_name }) => {
const url = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current=temperature_2m,relative_humidity_2m,wind_speed_10m`
const resp = await fetch(url)
const data = await resp.json()
const current = data.current
return `Weather in ${location_name}: ${current.temperature_2m}°C, humidity ${current.relative_humidity_2m}%, wind ${current.wind_speed_10m} km/h`
},
})
const weatherAgent = new Agent({
id: 'weather-agent',
name: 'Weather Agent',
instructions: 'You are a helpful assistant with access to weather data.',
model: { id: 'openai/gpt-5-mini' },
tools: { get_weather: weatherTool },
})
const mastra = new Mastra({
agents: { weatherAgent },
observability: new Observability({
configs: {
insights: {
serviceName: 'example-mastra-app',
exporters: [
new InsightsExporter({
apiKey: process.env.INSIGHTS_API_KEY!,
host: process.env.INSIGHTS_HOST || 'https://us.i.insights.com',
defaultDistinctId: 'example-user',
}),
],
},
},
}),
})
async function main() {
const agent = mastra.getAgent('weatherAgent')
const result = await agent.generate("What's the weather like in Dublin, Ireland?", {
tracingOptions: {
metadata: {
userId: 'example-user',
sessionId: 'session-abc-123',
foo: 'bar',
conversation_id: 'abc-123',
},
},
})
console.log(result.text)
}
main()