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

71 lines
2.0 KiB
TypeScript

/** OpenAI Agents SDK multi-agent with handoffs, tracked by Insights. */
import { Insights } from '@hanzo/insights-node'
import { instrument } from '@hanzo/insights-ai/openai-agents'
import { Agent, run, tool } from '@openai/agents'
import { z } from 'zod'
const phClient = new Insights(process.env.INSIGHTS_API_KEY!, {
host: process.env.INSIGHTS_HOST || 'https://us.i.insights.com',
})
const getWeather = tool({
name: 'get_weather',
description: 'Get current weather for a city',
parameters: z.object({
city: z.string().describe('The city to get weather for'),
}),
execute: async ({ city }) => {
return `Weather in ${city}: 18°C, partly cloudy, humidity 65%`
},
})
const calculate = tool({
name: 'calculate',
description: 'Evaluate a mathematical expression',
parameters: z.object({
expression: z.string().describe('A math expression to evaluate'),
}),
execute: async ({ expression }) => {
// Stub: replace with a real math library (e.g. mathjs) in production
return `Result of "${expression}": (math evaluation not implemented in this example)`
},
})
const weatherAgent = new Agent({
name: 'WeatherAgent',
instructions: 'You handle weather queries. Use the get_weather tool.',
model: 'gpt-4o-mini',
tools: [getWeather],
})
const mathAgent = new Agent({
name: 'MathAgent',
instructions: 'You handle math problems. Use the calculate tool.',
model: 'gpt-4o-mini',
tools: [calculate],
})
const generalAgent = new Agent({
name: 'GeneralAgent',
instructions: 'You handle general questions and conversation.',
model: 'gpt-4o-mini',
})
const triageAgent = new Agent({
name: 'TriageAgent',
instructions: 'Route to WeatherAgent for weather, MathAgent for math, GeneralAgent for everything else.',
model: 'gpt-4o-mini',
handoffs: [weatherAgent, mathAgent, generalAgent],
})
async function main() {
await instrument({ client: phClient, distinctId: 'example-user' })
const result = await run(triageAgent, "What's the weather in Tokyo?")
console.log(result.finalOutput)
await phClient.shutdown()
}
main()