> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lynxops.co/llms.txt
> Use this file to discover all available pages before exploring further.

# 빠른 시작

> Lynx SDK를 설치하고 첫 번째 AI 에이전트 실행을 기록합니다.

## 준비물

* Node.js 18 이상
* Lynx 수집 endpoint
* Lynx API key

## 설치

```bash theme={null}
npm install @lynx/sdk
```

다른 패키지 매니저를 사용해도 됩니다.

```bash theme={null}
pnpm add @lynx/sdk
yarn add @lynx/sdk
```

## Tracer 만들기

```ts theme={null}
import { LynxTracer } from "@lynx/sdk";

const lynx = new LynxTracer({
  clientId: "support-api",
  endpoint: "https://lynx.example.com",
  apiKey: process.env.LYNX_API_KEY,
});
```

## 에이전트 실행 추적하기

에이전트 workflow를 `run()`으로 감싸세요. callback 안에서 기록한 이벤트는 모두 같은 실행 컨텍스트에 연결됩니다.

```ts theme={null}
await lynx.run("SupportAgent", async () => {
  lynx.userInput("환불하고 싶어요", { userId: "usr_123" });
  lynx.setAttributes({ orderId: "order_123" });

  lynx.context("refund-policy", {
    refundWindowDays: 30,
  });

  lynx.decision({
    name: "select_refund_workflow",
    selected: "refund",
    confidence: 0.82,
    reason: "주문이 환불 가능 기간 안에 있습니다",
  });

  lynx.outcome({
    status: "COMPLETED",
    businessStatus: "SUCCEEDED",
  });
});
```

## 안전하게 종료하기

서버에서는 프로세스 종료 hook에서 `shutdown()`을 호출하세요. 서버리스 함수에서는 handler가 끝나기 전에 마지막 전송을 최대한 마무리해야 할 때 호출하면 됩니다.

```ts theme={null}
process.on("SIGTERM", () => {
  void lynx.shutdown({ timeoutMs: 1000 });
});
```

<Note>
  기본 전송 방식은 background-only입니다. 수집 데이터 전송에 실패해도 에이전트 workflow의 예외로 전파되지 않습니다.
</Note>
