@reopt-ai/brandapp-sdk 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/README.md +10 -1
- package/dist/abort--nOBFN4M.js +50 -0
- package/dist/ai/index.d.ts +2 -314
- package/dist/ai/index.js +3 -8
- package/dist/ai-provider/index.d.ts +79 -163
- package/dist/ai-provider/index.js +752 -685
- package/dist/auth/index.d.ts +27 -27
- package/dist/auth/index.js +41 -34
- package/dist/better-auth/client.d.ts +6 -5
- package/dist/better-auth/client.js +28 -5
- package/dist/better-auth/index.d.ts +19 -17
- package/dist/better-auth/index.js +180 -144
- package/dist/client-B1q5P8rv.js +83 -0
- package/dist/client-B9QHVhdM.js +77 -0
- package/dist/client-BGGd_cpV.d.ts +103 -0
- package/dist/client-BJcy1V1a.js +140 -0
- package/dist/client-Beivhucf.js +55 -0
- package/dist/client-BruP5_nU.d.ts +147 -0
- package/dist/client-D-yNxNfk.js +28 -0
- package/dist/client-D0eBxh8j.d.ts +284 -0
- package/dist/client-D3RHHUUW.d.ts +207 -0
- package/dist/client-D6gs61w8.d.ts +53 -0
- package/dist/client-DBnK7ooQ.js +86 -0
- package/dist/client-DDw5yz_h.d.ts +53 -0
- package/dist/client-DPmoKuR9.js +305 -0
- package/dist/client-DsdakibF.js +503 -0
- package/dist/client-Dxg8_DIH.d.ts +71 -0
- package/dist/client-EbhUIhHq.js +53 -0
- package/dist/client-lk6wBu_0.d.ts +48 -0
- package/dist/client-p49ol9pg.d.ts +124 -0
- package/dist/cms/index.d.ts +52 -108
- package/dist/cms/index.js +103 -86
- package/dist/config-CRytOPPl.d.ts +394 -0
- package/dist/config-Cw0a3-C8.js +487 -0
- package/dist/dev/index.d.ts +2 -528
- package/dist/dev/index.js +2731 -2967
- package/dist/eav/coerce.d.ts +3 -1
- package/dist/eav/coerce.js +72 -46
- package/dist/eav/index.d.ts +72 -100
- package/dist/eav/index.js +158 -126
- package/dist/eav/migrate.d.ts +112 -109
- package/dist/eav/migrate.js +230 -196
- package/dist/eav/schema.d.ts +111 -150
- package/dist/eav/schema.js +624 -603
- package/dist/encoding-Bwfm3iaE.js +21 -0
- package/dist/{errors-BjDFIyA6.d.ts → errors-CRCcErNC.d.ts} +55 -53
- package/dist/feedback/index.d.ts +2 -132
- package/dist/feedback/index.js +3 -6
- package/dist/files/index.d.ts +14 -14
- package/dist/files/index.js +41 -25
- package/dist/http-client-QKUvvirs.js +386 -0
- package/dist/index-DrVaKfhs.d.ts +456 -0
- package/dist/index-Z6OGcurJ.d.ts +169 -0
- package/dist/index.d.ts +6 -230
- package/dist/index.js +119 -71
- package/dist/logout/index.d.ts +56 -53
- package/dist/logout/index.js +232 -289
- package/dist/plans/index.d.ts +2 -236
- package/dist/plans/index.js +3 -6
- package/dist/push/index.d.ts +2 -79
- package/dist/push/index.js +3 -6
- package/dist/query-BvbCiGWb.js +35 -0
- package/dist/react/hooks.d.ts +97 -99
- package/dist/react/hooks.js +742 -404
- package/dist/sse-parser-FMjxM7sY.js +86 -0
- package/dist/terms/index.d.ts +3 -79
- package/dist/terms/index.js +3 -6
- package/dist/testing/index.d.ts +52 -104
- package/dist/testing/index.js +94 -72
- package/dist/types-B-SMkH6s.d.ts +26 -0
- package/dist/types-BXDcoJHG.d.ts +131 -0
- package/dist/types-BrghN2rJ.d.ts +105 -0
- package/dist/types-DjDRszNj.js +11 -0
- package/dist/webhooks/index.d.ts +77 -50
- package/dist/webhooks/index.js +150 -127
- package/docs/api-reference.md +87 -6
- package/package.json +6 -5
- package/dist/chunk-2LSCQHAU.js +0 -21
- package/dist/chunk-4U4ZPPL4.js +0 -599
- package/dist/chunk-55KHY5GH.js +0 -96
- package/dist/chunk-C5VTRZWX.js +0 -458
- package/dist/chunk-F7BXBTZI.js +0 -54
- package/dist/chunk-FJUCWXX3.js +0 -350
- package/dist/chunk-H33OTQEN.js +0 -112
- package/dist/chunk-L4DHB36G.js +0 -75
- package/dist/chunk-OG7R3UAR.js +0 -105
- package/dist/chunk-PF24XU54.js +0 -32
- package/dist/chunk-QN3QD67K.js +0 -49
- package/dist/chunk-REIKXSMY.js +0 -7
- package/dist/chunk-UGBBXCZE.js +0 -157
- package/dist/chunk-UVT2E6KD.js +0 -81
- package/dist/chunk-YPLT3RFL.js +0 -63
- package/dist/chunk-YTKSAWV2.js +0 -463
- package/dist/client-BkcO-0C2.d.ts +0 -216
- package/dist/client-CN5_tNOC.d.ts +0 -147
- package/dist/client-DttyeM_h.d.ts +0 -102
- package/dist/config-CtxyJsDR.d.ts +0 -397
- package/dist/typed-client-BxOVIiMU.d.ts +0 -40
- package/dist/types-6E3ZLL9X.d.ts +0 -24
- package/dist/types-DskYLVb8.d.ts +0 -104
- package/dist/types-ckmDDW3N.d.ts +0 -129
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,73 @@ All notable changes to `@reopt-ai/brandapp-sdk` are documented here.
|
|
|
5
5
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
6
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [3.4.0] — 2026-07-27
|
|
11
|
+
|
|
12
|
+
구독 생애주기를 **서버에서** 따라갈 수 있게 됐다 — 웹훅 4종과 실 결제 해지 결과가
|
|
13
|
+
추가되고, 피드백이 양방향 스레드가 됐다. 전부 backward-compatible(minor).
|
|
14
|
+
|
|
15
|
+
### Added — 구독 생애주기 웹훅 (`@reopt-ai/brandapp-sdk/webhooks`)
|
|
16
|
+
|
|
17
|
+
지금까지 웹훅 이벤트는 contact/workflow 5종뿐이라 브랜드앱 소비자는 구독 상태 변화를
|
|
18
|
+
**서버에서 알 방법이 없었다**. 체크아웃 복귀 URL이나 `getMyPlan` 폴링에만 의존했고,
|
|
19
|
+
사용자 행동 없이 일어나는 변화(정기결제 실패, 카드 만료, PG측 해지)는 폴링해야만
|
|
20
|
+
발견됐다.
|
|
21
|
+
|
|
22
|
+
- **`WebhookEventType`에 4종 추가** — `subscriptionActivated`(체크아웃 완료 → 엔타이틀먼트
|
|
23
|
+
부여) / `subscriptionRenewed`(정기결제 성공 → `accessUntil` 연장) /
|
|
24
|
+
`subscriptionCanceled`(해지 — `accessUntil`까지는 접근 유지) /
|
|
25
|
+
`subscriptionPaymentFailed`(past due → 독촉·유예 안내).
|
|
26
|
+
- **`SubscriptionWebhookData`** — 4종의 공통 페이로드
|
|
27
|
+
(`brandappId`, `brandappCustomerId`, `customerId`, `planId`, `planName`, `provider`,
|
|
28
|
+
`accessUntil`).
|
|
29
|
+
|
|
30
|
+
웹훅은 **워크스페이스 단위**로 등록되므로 한 워크스페이스에 브랜드앱이 여럿이면 같은
|
|
31
|
+
엔드포인트로 전부 도착한다 — `data.brandappId`로 반드시 필터링할 것. 플랫폼 쪽 발행은
|
|
32
|
+
결제 상태 커밋과 같은 트랜잭션(transactional outbox)이라 상태와 알림이 어긋나지 않는다.
|
|
33
|
+
|
|
34
|
+
### Added — 실 결제 해지 결과 (`sdk.plans.cancel`)
|
|
35
|
+
|
|
36
|
+
`CancelSubscriptionResult`에 세 필드 추가(모두 optional — 구버전 서버는 내려주지 않는다):
|
|
37
|
+
|
|
38
|
+
- **`provider`** — `sandbox` | `paddle` | `toss` | `apple` | `google`. 안내 문구를 결제
|
|
39
|
+
수단별로 가를 때.
|
|
40
|
+
- **`accessUntil`** — 이 시각(ISO-8601)까지는 계속 이용 가능. `null`이면 무기한 플랜.
|
|
41
|
+
- **`providerCanceled`** — 결제사 쪽 해지까지 성공했는지. `false`면 로컬 구독은 확실히
|
|
42
|
+
종료됐지만(다음 청구 없음) 결제사 대시보드에 잔재가 남아 운영자 확인이 필요할 수 있다.
|
|
43
|
+
|
|
44
|
+
`cancel`은 이제 **sandbox 전용이 아니다** — 실 결제(Paddle/Toss)와 IAP 구독도 같은
|
|
45
|
+
호출로 해지된다(플랫폼 측 변경, SDK 호출 형태는 동일). 로컬 확정 먼저, 결제사 해지는
|
|
46
|
+
best-effort. IAP는 스토어에서 해지되므로 원격 호출 없음.
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- **문서 — 실 Paddle 체크아웃 지원 반영.** `createCheckout`의 `LIVE_MODE_UNSUPPORTED`(409)는
|
|
51
|
+
이제 **Toss** 실 결제 + 유료 플랜에만 해당한다. Paddle 브랜드앱은 같은 호출로 Paddle
|
|
52
|
+
호스티드 결제 페이지 URL을 받는다(0원 플랜은 live 모드에서도 sandbox 세션 흐름). 코드
|
|
53
|
+
동작은 이전 릴리스에서 이미 그랬고, 이번엔 JSDoc·`docs/api-reference.md`를 정합화했다.
|
|
54
|
+
|
|
55
|
+
### Added — Feedback 양방향 스레드 (`sdk.feedback`)
|
|
56
|
+
|
|
57
|
+
고객이 운영팀 답변을 **평가하고 되받아칠 수 있게** 됐다. 지금까지 피드백은 한 번의
|
|
58
|
+
왕복으로 끝났고 — 답변이 빗나가면 고객은 새 피드백을 다시 내야 했으며 운영 큐에는
|
|
59
|
+
맥락이 끊긴 별개 항목이 쌓였다. 전부 backward-compatible(minor).
|
|
60
|
+
|
|
61
|
+
- **`sdk.feedback.me.reply(feedbackId, content, accessToken)`** — 자기 피드백 스레드에
|
|
62
|
+
답글. 이미 응답된 피드백은 새 상태 `reopened`로 전이하고 워크스페이스에 알림이 간다.
|
|
63
|
+
반환값 `feedbackStatus`로 재오픈 여부를 바로 알 수 있다.
|
|
64
|
+
- **`sdk.feedback.me.rateReply(feedbackId, replyId, helpful, accessToken)`** — 운영팀
|
|
65
|
+
답변의 유용성 평가(`true`/`false`/`null`로 취소). 평가만으로는 재오픈되지 않는다.
|
|
66
|
+
- **`FeedbackReply.author`** (`"staff" | "customer"`) — 스레드가 양방향이 되면서 각
|
|
67
|
+
메시지의 방향이 노출된다. 운영자 신원은 계속 비노출.
|
|
68
|
+
- **`FeedbackReply.helpful`** — 고객이 그 답변에 매긴 평가(staff 답변에만, null = 미평가).
|
|
69
|
+
- **`FeedbackStatus`에 `"reopened"` 추가** — 응답 후 고객이 되물어 워크스페이스 차례가
|
|
70
|
+
된 상태. `status` 필터로도 조회 가능.
|
|
71
|
+
|
|
72
|
+
`replyCount`는 **staff 답변 수 그대로**다 — 고객이 자기 답글을 달았다고
|
|
73
|
+
`replyCount > 0`("답변 왔음") 신호가 켜지지 않는다.
|
|
74
|
+
|
|
8
75
|
## [3.3.0] — 2026-07-24
|
|
9
76
|
|
|
10
77
|
리뷰(멀티에이전트 교차검증) 후속 하드닝 — 로그아웃 보안·코어 정확성·AI/React/CMS
|
package/README.md
CHANGED
|
@@ -454,9 +454,18 @@ export const POST = createWebhookHandler({
|
|
|
454
454
|
```
|
|
455
455
|
|
|
456
456
|
Event types: `contactCreated` / `contactUpdated` / `contactDeleted` /
|
|
457
|
-
`workflowRunCompleted` / `workflowRunFailed
|
|
457
|
+
`workflowRunCompleted` / `workflowRunFailed`, plus the subscription lifecycle
|
|
458
|
+
(3.4+) `subscriptionActivated` / `subscriptionRenewed` /
|
|
459
|
+
`subscriptionCanceled` / `subscriptionPaymentFailed`. Each `payload` is
|
|
458
460
|
`{ id, type, entityType, entityId, createdAt, data }`.
|
|
459
461
|
|
|
462
|
+
Subscription events carry `SubscriptionWebhookData`
|
|
463
|
+
(`{ brandappId, brandappCustomerId, customerId, planId, planName, provider, accessUntil }`)
|
|
464
|
+
— this is the server-side way to sync entitlements for changes that happen with
|
|
465
|
+
no user action (renewal, failed charge, provider-side cancellation). Webhooks
|
|
466
|
+
are registered per workspace, so filter on `data.brandappId`, and treat
|
|
467
|
+
`subscriptionCanceled` as "access until `accessUntil`", not "revoke now".
|
|
468
|
+
|
|
460
469
|
The handler verifies the `x-reopt-signature` header
|
|
461
470
|
(`sha256=HMAC-SHA256(secret, "{timestamp}.{body}")`) in constant time against
|
|
462
471
|
the `x-reopt-timestamp` header, rejects a missing/invalid signature or timestamp
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/core/abort.ts
|
|
2
|
+
function createManagedAbort(opts) {
|
|
3
|
+
const { timeoutMs, external, idle = false } = opts;
|
|
4
|
+
const controller = new AbortController();
|
|
5
|
+
let timer;
|
|
6
|
+
let finished = false;
|
|
7
|
+
let timedOut = false;
|
|
8
|
+
const arm = () => {
|
|
9
|
+
timer = setTimeout(() => {
|
|
10
|
+
timedOut = true;
|
|
11
|
+
controller.abort();
|
|
12
|
+
}, timeoutMs);
|
|
13
|
+
};
|
|
14
|
+
const disarm = () => {
|
|
15
|
+
if (timer !== void 0) {
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
timer = void 0;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const onExternalAbort = () => {
|
|
21
|
+
disarm();
|
|
22
|
+
controller.abort();
|
|
23
|
+
};
|
|
24
|
+
if (external) if (external.aborted) {
|
|
25
|
+
controller.abort();
|
|
26
|
+
finished = true;
|
|
27
|
+
} else external.addEventListener("abort", onExternalAbort, { once: true });
|
|
28
|
+
if (!finished) arm();
|
|
29
|
+
return {
|
|
30
|
+
signal: controller.signal,
|
|
31
|
+
kick() {
|
|
32
|
+
if (!idle || finished) return;
|
|
33
|
+
disarm();
|
|
34
|
+
arm();
|
|
35
|
+
},
|
|
36
|
+
cleanup() {
|
|
37
|
+
if (finished) return;
|
|
38
|
+
finished = true;
|
|
39
|
+
disarm();
|
|
40
|
+
external?.removeEventListener("abort", onExternalAbort);
|
|
41
|
+
},
|
|
42
|
+
get timedOut() {
|
|
43
|
+
return timedOut;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { createManagedAbort as t };
|
|
50
|
+
//# sourceMappingURL=abort--nOBFN4M.js.map
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,314 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/** 메시지 역할 */
|
|
4
|
-
type MessageRole = "system" | "user" | "assistant";
|
|
5
|
-
/** 채팅 메시지 */
|
|
6
|
-
type ChatMessage = {
|
|
7
|
-
role: MessageRole;
|
|
8
|
-
content: string;
|
|
9
|
-
};
|
|
10
|
-
/** AI completion 요청 옵션 */
|
|
11
|
-
type CompletionOptions = {
|
|
12
|
-
/** 모델 ID (e.g. "anthropic/claude-haiku-4.5"). 미지정 시 BrandApp 기본 모델. */
|
|
13
|
-
model?: string;
|
|
14
|
-
/** 커스텀 에이전트 ID (e.g. "custom:uuid") */
|
|
15
|
-
agentId?: string;
|
|
16
|
-
/** 메시지 배열 */
|
|
17
|
-
messages: ChatMessage[];
|
|
18
|
-
/** 최대 출력 토큰 (기본 4096) */
|
|
19
|
-
maxTokens?: number;
|
|
20
|
-
/** 생성 온도 (0-2) */
|
|
21
|
-
temperature?: number;
|
|
22
|
-
/** BrandappCustomer ID (사용량 추적용) */
|
|
23
|
-
customerId?: string;
|
|
24
|
-
/** AbortSignal for request cancellation */
|
|
25
|
-
signal?: AbortSignal;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* 생성 종료 사유. `unified`는 AI SDK v3 finishReason과 같은 어휘다. 서버가 보고하면
|
|
29
|
-
* 채워지고, 미보고 시 생략된다(소비처는 없으면 정상 종료로 간주).
|
|
30
|
-
*/
|
|
31
|
-
type FinishReason = {
|
|
32
|
-
unified: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other";
|
|
33
|
-
raw?: string;
|
|
34
|
-
};
|
|
35
|
-
/** AI completion 응답 (non-streaming) */
|
|
36
|
-
type CompletionResult = {
|
|
37
|
-
id: string;
|
|
38
|
-
model: string;
|
|
39
|
-
message: {
|
|
40
|
-
role: "assistant";
|
|
41
|
-
content: string;
|
|
42
|
-
};
|
|
43
|
-
usage: {
|
|
44
|
-
promptTokens: number;
|
|
45
|
-
completionTokens: number;
|
|
46
|
-
creditCost: number;
|
|
47
|
-
};
|
|
48
|
-
creditsRemaining: number;
|
|
49
|
-
/** 생성 종료 사유 (서버가 보고 시) */
|
|
50
|
-
finishReason?: FinishReason;
|
|
51
|
-
/**
|
|
52
|
-
* true면 이 호출은 잔액을 초과해 차감됐다(출력은 이미 생성되어 반환되지만 잔액은
|
|
53
|
-
* 0으로 소진). 다음 호출은 사전 크레딧 체크에서 차단된다 — "1회 후 차단" 의도.
|
|
54
|
-
*/
|
|
55
|
-
creditLimited?: boolean;
|
|
56
|
-
};
|
|
57
|
-
/** 크레딧 잔액 정보 */
|
|
58
|
-
type CreditInfo = {
|
|
59
|
-
balance: number;
|
|
60
|
-
limit: number;
|
|
61
|
-
percentage: number;
|
|
62
|
-
resetAt: string | null;
|
|
63
|
-
status: "normal" | "warning" | "critical" | "exhausted";
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* 사용 가능 모델 정보 — `sdk.ai.models()` / `sdk.ai.imageModels()` 응답 항목.
|
|
67
|
-
*
|
|
68
|
-
* 서버 `AvailableModel`(packages/ai)과 구조가 일치한다 — contract type-test가
|
|
69
|
-
* CI에서 동일성을 강제한다. `isDefault`로 "model 미지정 시 쓰이는 기본 모델"을,
|
|
70
|
-
* `modality`로 chat/image 구분을 사전에 알 수 있다.
|
|
71
|
-
*/
|
|
72
|
-
type ModelInfo = {
|
|
73
|
-
id: string;
|
|
74
|
-
displayName: string;
|
|
75
|
-
description: string;
|
|
76
|
-
provider: string;
|
|
77
|
-
/** chat | image */
|
|
78
|
-
modality: "chat" | "image";
|
|
79
|
-
tier: string;
|
|
80
|
-
tierLabel: string;
|
|
81
|
-
/** credits per 1K input tokens (image-only 모델은 0) */
|
|
82
|
-
inputRate: number;
|
|
83
|
-
/** credits per 1K output tokens (image-only 모델은 0) */
|
|
84
|
-
outputRate: number;
|
|
85
|
-
/** 이미지 생성당 고정 크레딧 (image 모델 전용) */
|
|
86
|
-
creditsPerImage?: number;
|
|
87
|
-
/** 최대 입력 컨텍스트 토큰 */
|
|
88
|
-
contextWindow?: number;
|
|
89
|
-
/** 최대 출력 토큰 */
|
|
90
|
-
maxOutputTokens?: number;
|
|
91
|
-
/** 이미지/파일 입력(비전) 지원 */
|
|
92
|
-
supportsVision?: boolean;
|
|
93
|
-
/** function/tool calling 지원 (외부 brandapp API에서는 미노출이나 메타로 제공) */
|
|
94
|
-
supportsTools?: boolean;
|
|
95
|
-
/** 이 brandapp의 기본 모델인지 (modality별 기본값과 일치) */
|
|
96
|
-
isDefault: boolean;
|
|
97
|
-
};
|
|
98
|
-
/** 이미지 생성 요청 옵션 */
|
|
99
|
-
type ImageGenerateOptions = {
|
|
100
|
-
/** 이미지 설명 프롬프트 */
|
|
101
|
-
prompt: string;
|
|
102
|
-
/** 네거티브 프롬프트 (생성에서 제외할 요소) */
|
|
103
|
-
negativePrompt?: string;
|
|
104
|
-
/** 스타일 (e.g. "watercolor", "photorealistic") */
|
|
105
|
-
style?: string;
|
|
106
|
-
/** 종횡비 (기본 1:1) */
|
|
107
|
-
aspectRatio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4";
|
|
108
|
-
/** 이미지 모델 (기본: google/gemini-2.5-flash-image) */
|
|
109
|
-
model?: string;
|
|
110
|
-
/** BrandappCustomer ID (사용량 추적용) */
|
|
111
|
-
customerId?: string;
|
|
112
|
-
};
|
|
113
|
-
/** 이미지 생성 결과 */
|
|
114
|
-
type ImageGenerateResult = {
|
|
115
|
-
/** 파일 ID */
|
|
116
|
-
id: string;
|
|
117
|
-
/** 이미지 URL (Vercel Blob) */
|
|
118
|
-
url: string;
|
|
119
|
-
/** 파일 크기 (bytes) */
|
|
120
|
-
size: number;
|
|
121
|
-
/** MIME 타입 */
|
|
122
|
-
contentType: string;
|
|
123
|
-
/** 사용량 */
|
|
124
|
-
usage: {
|
|
125
|
-
creditCost: number;
|
|
126
|
-
};
|
|
127
|
-
/** 남은 크레딧 */
|
|
128
|
-
creditsRemaining: number;
|
|
129
|
-
/** true면 잔액 초과 차감(이미지는 반환되나 잔액 소진, 다음 호출 차단) */
|
|
130
|
-
creditLimited?: boolean;
|
|
131
|
-
};
|
|
132
|
-
/** SSE 스트림 이벤트 */
|
|
133
|
-
type StreamEvent = {
|
|
134
|
-
event: "text-delta";
|
|
135
|
-
data: string;
|
|
136
|
-
} | {
|
|
137
|
-
event: "done";
|
|
138
|
-
data: StreamDoneData;
|
|
139
|
-
} | {
|
|
140
|
-
event: "error";
|
|
141
|
-
data: {
|
|
142
|
-
code: string;
|
|
143
|
-
message: string;
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
/** 스트림 완료 메타데이터 */
|
|
147
|
-
type StreamDoneData = {
|
|
148
|
-
usage: {
|
|
149
|
-
promptTokens: number;
|
|
150
|
-
completionTokens: number;
|
|
151
|
-
creditCost: number;
|
|
152
|
-
};
|
|
153
|
-
creditsRemaining: number;
|
|
154
|
-
/** 생성 종료 사유 (서버가 보고 시) */
|
|
155
|
-
finishReason?: FinishReason;
|
|
156
|
-
};
|
|
157
|
-
/** 커스텀 에이전트 정보 */
|
|
158
|
-
type AgentInfo = {
|
|
159
|
-
id: string;
|
|
160
|
-
name: string;
|
|
161
|
-
description: string;
|
|
162
|
-
defaultModel: string;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* BrandApp AI 클라이언트
|
|
167
|
-
*
|
|
168
|
-
* 기존 BaseHttpClient를 확장하여 AI API를 호출합니다.
|
|
169
|
-
* SSE 스트리밍은 fetch API를 직접 사용합니다.
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* ```ts
|
|
173
|
-
* const sdk = createReoptSDK({ ... });
|
|
174
|
-
*
|
|
175
|
-
* // Non-streaming
|
|
176
|
-
* const result = await sdk.ai.complete({
|
|
177
|
-
* messages: [{ role: "user", content: "안녕하세요" }],
|
|
178
|
-
* });
|
|
179
|
-
* console.log(result.message.content);
|
|
180
|
-
*
|
|
181
|
-
* // Streaming
|
|
182
|
-
* for await (const chunk of sdk.ai.stream({
|
|
183
|
-
* messages: [{ role: "user", content: "안녕하세요" }],
|
|
184
|
-
* })) {
|
|
185
|
-
* process.stdout.write(chunk);
|
|
186
|
-
* }
|
|
187
|
-
*
|
|
188
|
-
* // Credits
|
|
189
|
-
* const credits = await sdk.ai.credits();
|
|
190
|
-
* console.log(`${credits.balance} / ${credits.limit}`);
|
|
191
|
-
*
|
|
192
|
-
* // Models
|
|
193
|
-
* const models = await sdk.ai.models();
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
|
|
197
|
-
declare class ReoptAiClient {
|
|
198
|
-
private readonly http;
|
|
199
|
-
/**
|
|
200
|
-
* Idle (inactivity) timeout for streaming, in ms — the maximum gap allowed
|
|
201
|
-
* *between* SSE chunks, not a deadline on the whole generation. A long but
|
|
202
|
-
* healthy generation keeps resetting this; only a genuine stall aborts.
|
|
203
|
-
*/
|
|
204
|
-
private readonly streamIdleTimeout;
|
|
205
|
-
constructor(config: ReoptSDKConfig);
|
|
206
|
-
/**
|
|
207
|
-
* AI 텍스트 생성 (non-streaming)
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* ```ts
|
|
211
|
-
* const result = await sdk.ai.complete({
|
|
212
|
-
* messages: [{ role: "user", content: "Hello" }],
|
|
213
|
-
* model: "anthropic/claude-haiku-4.5",
|
|
214
|
-
* maxTokens: 1024,
|
|
215
|
-
* });
|
|
216
|
-
* console.log(result.message.content);
|
|
217
|
-
* ```
|
|
218
|
-
*/
|
|
219
|
-
complete(options: CompletionOptions): Promise<CompletionResult>;
|
|
220
|
-
/**
|
|
221
|
-
* AI 텍스트 생성 (SSE 스트리밍)
|
|
222
|
-
*
|
|
223
|
-
* async generator로 텍스트 청크를 반환합니다.
|
|
224
|
-
* 사용량 메타데이터가 필요하면 `streamWithMetadata()`를 사용하세요.
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
* ```ts
|
|
228
|
-
* for await (const chunk of sdk.ai.stream({
|
|
229
|
-
* messages: [{ role: "user", content: "Hello" }],
|
|
230
|
-
* })) {
|
|
231
|
-
* process.stdout.write(chunk);
|
|
232
|
-
* }
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
stream(options: CompletionOptions): AsyncGenerator<string>;
|
|
236
|
-
/**
|
|
237
|
-
* AI 텍스트 생성 (SSE 스트리밍 + 메타데이터)
|
|
238
|
-
*
|
|
239
|
-
* 텍스트 청크와 함께 최종 사용량/크레딧 메타데이터를 반환합니다.
|
|
240
|
-
*
|
|
241
|
-
* @example
|
|
242
|
-
* ```ts
|
|
243
|
-
* const { textStream, metadata } = sdk.ai.streamWithMetadata({
|
|
244
|
-
* messages: [{ role: "user", content: "Hello" }],
|
|
245
|
-
* });
|
|
246
|
-
*
|
|
247
|
-
* let text = "";
|
|
248
|
-
* for await (const chunk of textStream) {
|
|
249
|
-
* text += chunk;
|
|
250
|
-
* }
|
|
251
|
-
*
|
|
252
|
-
* const meta = await metadata;
|
|
253
|
-
* console.log(`사용 크레딧: ${meta?.usage.creditCost}`);
|
|
254
|
-
* ```
|
|
255
|
-
*/
|
|
256
|
-
streamWithMetadata(options: CompletionOptions): {
|
|
257
|
-
textStream: AsyncGenerator<string>;
|
|
258
|
-
metadata: Promise<StreamDoneData | null>;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* 이미지 생성
|
|
262
|
-
*
|
|
263
|
-
* BrandApp의 AI 크레딧으로 이미지를 생성합니다.
|
|
264
|
-
* 생성된 이미지는 자동으로 Vercel Blob에 저장되고 URL이 반환됩니다.
|
|
265
|
-
*
|
|
266
|
-
* @example
|
|
267
|
-
* ```ts
|
|
268
|
-
* const image = await sdk.ai.generateImage({
|
|
269
|
-
* prompt: "브랜드 배너 이미지",
|
|
270
|
-
* style: "minimalist",
|
|
271
|
-
* aspectRatio: "16:9",
|
|
272
|
-
* });
|
|
273
|
-
* console.log(image.url); // https://...blob.vercel-storage.com/...
|
|
274
|
-
* console.log(image.size); // 12345 (bytes)
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
|
-
generateImage(options: ImageGenerateOptions): Promise<ImageGenerateResult>;
|
|
278
|
-
/**
|
|
279
|
-
* 크레딧 잔액 조회
|
|
280
|
-
*
|
|
281
|
-
* @example
|
|
282
|
-
* ```ts
|
|
283
|
-
* const credits = await sdk.ai.credits();
|
|
284
|
-
* console.log(`${credits.balance} / ${credits.limit} (${credits.status})`);
|
|
285
|
-
* ```
|
|
286
|
-
*/
|
|
287
|
-
credits(): Promise<CreditInfo>;
|
|
288
|
-
/**
|
|
289
|
-
* 사용 가능 모델 목록 조회
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
* ```ts
|
|
293
|
-
* const models = await sdk.ai.models();
|
|
294
|
-
* models.forEach(m => console.log(`${m.id} (${m.tierLabel})`));
|
|
295
|
-
* ```
|
|
296
|
-
*/
|
|
297
|
-
models(): Promise<ModelInfo[]>;
|
|
298
|
-
/**
|
|
299
|
-
* 사용 가능한 커스텀 에이전트 목록 조회
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* ```ts
|
|
303
|
-
* const agents = await sdk.ai.agents();
|
|
304
|
-
* for (const agent of agents) {
|
|
305
|
-
* console.log(`${agent.name}: ${agent.description}`);
|
|
306
|
-
* }
|
|
307
|
-
* ```
|
|
308
|
-
*/
|
|
309
|
-
agents(): Promise<AgentInfo[]>;
|
|
310
|
-
private fetchSSE;
|
|
311
|
-
}
|
|
312
|
-
declare function createReoptAiClient(config: ReoptSDKConfig): ReoptAiClient;
|
|
313
|
-
|
|
314
|
-
export { type AgentInfo, type ChatMessage, type CompletionOptions, type CompletionResult, type CreditInfo, type FinishReason, type ImageGenerateOptions, type ImageGenerateResult, type MessageRole, type ModelInfo, ReoptAiClient, type StreamDoneData, type StreamEvent, createReoptAiClient };
|
|
1
|
+
import { a as CompletionOptions, c as FinishReason, d as MessageRole, f as ModelInfo, i as ChatMessage, l as ImageGenerateOptions, m as StreamEvent, n as createReoptAiClient, o as CompletionResult, p as StreamDoneData, r as AgentInfo, s as CreditInfo, t as ReoptAiClient, u as ImageGenerateResult } from "../client-D0eBxh8j.js";
|
|
2
|
+
export { type AgentInfo, type ChatMessage, type CompletionOptions, type CompletionResult, type CreditInfo, type FinishReason, type ImageGenerateOptions, type ImageGenerateResult, type MessageRole, type ModelInfo, ReoptAiClient, type StreamDoneData, type StreamEvent, createReoptAiClient };
|
package/dist/ai/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '../chunk-YTKSAWV2.js';
|
|
5
|
-
import '../chunk-2LSCQHAU.js';
|
|
6
|
-
import '../chunk-C5VTRZWX.js';
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { n as createReoptAiClient, t as ReoptAiClient } from "../client-DPmoKuR9.js";
|
|
2
|
+
|
|
3
|
+
export { ReoptAiClient, createReoptAiClient };
|