npm package: @instructure/platform-learning-agent-launcher
Description: Initial React package scaffold for launching the Learning Agent user experience.
Latest version: 4.0.0

# @instructure/platform-learning-agent-launcher

Initial React package scaffold for launching the Learning Agent user experience.

## Features

- Host-agnostic React component package
- InstUI-based launcher button component
- Storybook story for local development
- Vitest + Testing Library test setup
- TypeScript declaration output via Vite build

## Installation

```bash
pnpm add @instructure/platform-learning-agent-launcher
```

### Peer Dependencies

```json
{
  "@instructure/platform-provider": "^0.1.1",
  "react": "^18.0.0",
  "react-dom": "^18.0.0",
  "@instructure/ui-buttons": "^10.0.0",
  "@instructure/ui-svg-images": "^10.0.0"
}
```

## Usage

```tsx
import { PlatformUiProvider } from '@instructure/platform-provider'
import { LearningAgentLauncher } from '@instructure/platform-learning-agent-launcher'
import '@instructure/platform-learning-agent-launcher/styles'

export function Example() {
  return (
    <PlatformUiProvider executeQuery={async () => ({})} currentUserId="12345">
      <LearningAgentLauncher
        learningAgentPath="/lms-launcher"
        lmsPathname="/courses/42/modules/items/9"
        lmsDomain="canvas.example.edu"
        lmsHasAthenaUser={false}
      />
    </PlatformUiProvider>
  )
}
```

### Minimal Usage (All Launcher Defaults)

```tsx
import { PlatformUiProvider } from '@instructure/platform-provider'
import { QueryClient } from '@tanstack/react-query'
import { LearningAgentLauncher } from '@instructure/platform-learning-agent-launcher'
import '@instructure/platform-learning-agent-launcher/styles'

const queryClient = new QueryClient()

export function ExampleWithDefaults() {
  return (
    <PlatformUiProvider
      executeQuery={async () => ({})}
      currentUserId="12345"
      locale="en"
      timezone="America/Denver"
      appContext="canvas-academic"
      queryClient={queryClient}
    >
      <LearningAgentLauncher />
    </PlatformUiProvider>
  )
}
```

## API

All `LearningAgentLauncher` props are optional.

Temporary behavior note: when `lmsHasAthenaUser` is `false`, the launcher renders nothing (`null`). This is a temporary rollout behavior until Canvas supports multiple feature flags.

- `label?: string`
  - Optional launcher button label.
  - Defaults to `Launch Athena`.
- `enabled?: boolean`
  - Controls button enabled/disabled state.
  - Defaults to `true`.
- `learningAgentDomain?: string`
  - Base Learning Agent domain.
  - Defaults to `https://studywithathena.com`.
- `learningAgentPath?: string`
  - Destination path used when building the launcher URL.
  - Defaults to `/lms-launcher`.
- `lmsPathname?: string`
  - Optional LMS pathname context passed in query params as `lmsPathname`.
  - will be used to derive the course context for the Learning Agent experience.
  - Defaults to `window.location.pathname` when omitted.
- `lmsDomain?: string`
  - Optional LMS domain context passed in query params as `lmsDomain`.
  - i.e. `myuniversity.instructure.com`.
  - Defaults to `window.location.host` when omitted.
- `lmsUserId?: string`
  - Optional LMS user identifier passed in query params as `lmsUserId`.
  - Defaults to `currentUserId` from `PlatformUiProvider` when omitted.
- `lmsHasAthenaUser?: boolean`
  - Whether the LMS user has an Athena user account
  - When `false`, the component returns `null` and does not render a launcher button (temporary until Canvas has multiple feature flags).
  - Passed in query params as `lmsHasAthenaUser`.
  - Defaults to `false`.
- `lmsSource?: string`
  - Source value passed in query params as `lmsSource`.
  - Defaults to `appContext` from `PlatformUiProvider` when omitted.
- `locale?: string`
  - Locale value passed in query params as `locale`.
  - Defaults to `locale` from `PlatformUiProvider` when omitted.
- `timezone?: string`
  - Timezone value passed in query params as `timezone`.
  - Defaults to `timezone` from `PlatformUiProvider` when omitted.

## Development

```bash
# Run tests
pnpm test

# Run tests with coverage
pnpm test --coverage

# Build
pnpm build

# Type check
pnpm type-check
```