@reopt-ai/brandapp-sdk 4.7.0-rc.8 → 4.7.0-rc.9

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/ai/index.d.ts +52 -2
  3. package/dist/ai/index.js +32 -2
  4. package/dist/ai-provider/index.d.ts +26 -2
  5. package/dist/ai-provider/index.js +139 -12
  6. package/dist/analytics/index.js +1 -1
  7. package/dist/auth/index.js +1 -1
  8. package/dist/better-auth/index.js +2 -2
  9. package/dist/{client-DMKaOPgU.js → client-BSkEu3Bv.js} +2 -2
  10. package/dist/{client-Cm7LK9If.d.ts → client-CP1Jgq4R.d.ts} +88 -2
  11. package/dist/{client-B1Yh78Q2.js → client-CezHrq4c.js} +2 -2
  12. package/dist/{client-B3mfgfKm.js → client-D5rvzXf3.js} +4 -4
  13. package/dist/{client-IT-ulPXq.js → client-D6BIpDuI.js} +2 -2
  14. package/dist/{client-UlK_7r41.js → client-DNs5PvB4.js} +3 -3
  15. package/dist/{client-8-voCIn6.js → client-DmfPn8Fe.js} +2 -2
  16. package/dist/{client-CeRmh20T.js → client-DvBL8-qz.js} +3 -3
  17. package/dist/{client-DM4rX1ng.js → client-DywMETbG.js} +3 -3
  18. package/dist/{client-CZZ_ENbq.js → client-Dz-IP_n_.js} +2 -2
  19. package/dist/{client-GRG2iZTx.js → client-Ghq4BgoW.js} +2 -2
  20. package/dist/{client-C8Fs2kuo.js → client-Nv1DvsTh.js} +35 -4
  21. package/dist/{client-DrTi1wIz.js → client-aQa7wcA1.js} +2 -2
  22. package/dist/cms/index.js +1 -1
  23. package/dist/{config-C4uJ8ixE.js → config-CkG8Anez.js} +39 -4
  24. package/dist/dev/index.js +59 -0
  25. package/dist/eav/index.js +2 -2
  26. package/dist/feedback/index.js +1 -1
  27. package/dist/files/index.js +1 -1
  28. package/dist/{http-client-DdW_W7IB.js → http-client-C1Ahb6A0.js} +2 -2
  29. package/dist/{index-Dd_2Eq1a.d.ts → index-CaXrNTtU.d.ts} +2 -2
  30. package/dist/index.d.ts +3 -3
  31. package/dist/index.js +12 -12
  32. package/dist/installation/index.js +3 -3
  33. package/dist/logout/index.js +1 -1
  34. package/dist/machine/index.js +1 -1
  35. package/dist/plans/index.js +1 -1
  36. package/dist/push/index.js +1 -1
  37. package/dist/{query-okRw8nVs.js → query-5kxgEXLX.js} +2 -2
  38. package/dist/react/hooks.d.ts +2 -2
  39. package/dist/social/index.js +1 -1
  40. package/dist/terms/index.js +1 -1
  41. package/dist/testing/index.d.ts +1 -1
  42. package/dist/workspace/index.js +1 -1
  43. package/docs/api-reference.md +98 -1
  44. package/docs/errors.md +15 -0
  45. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ This project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [4.7.0-rc.9] — 2026-10-30
11
+
12
+ Pre-release (`npm i @reopt-ai/brandapp-sdk@next`) — 평가(Jev)·json-render 조립(RFC-0041). 서버 평가 중계는
13
+ 플랫폼이 열기 전까지 503 `EVALUATIONS_UNAVAILABLE`이다 — 그동안은 dev 서버로 개발한다.
14
+
15
+ ### Added
16
+
17
+ - `sdk.ai.evaluate()` — 평가 모델(Jev)에 상태와 질문(choice·score·boolean, 최대 128개)을 보내 답과 확률을 받는다
18
+ (`POST /ai/evaluations`, RFC-0041). 브랜드앱 AI 설정 "평가 허용"이 켜져 있어야 하고, 답을 못 준 호출은
19
+ 과금되지 않으며, 과금 호출이라 재시도하지 않는다.
20
+ - `createBrandappEvaluator(sdk)` — json-render `experimental_composeSpec`의 `evaluate`에 그대로 꽂는 평가자.
21
+ json-render를 의존성으로 들이지 않는다(구조 호환, 테스트가 실제 `composeSpec`으로 확인).
22
+ `onEvaluation` 콜백으로 평가마다의 실제 크레딧(`creditCostMilli`)을 받는다.
23
+ - `brandapp.decisionModel()`(`/ai-provider`) — AI SDK `experimental_evaluate`용 결정 모델(`Experimental_DecisionModelV4`).
24
+ `evaluationModel()`은 옛 이름. 크레딧은 `providerMetadata.brandapp`. 중계하지 않는 모델 id는 `NoSuchModelError`.
25
+ - dev 서버 `/ai/evaluations` — 결정적인 흉내(실서버와 같은 상한)로 json-render 조립이 오프라인에서 끝까지 돈다.
26
+ - 평가 오류 코드 7종의 `diagnostic`(원인·해결·과금 여부)과 `docs/errors.md` 표. 평가 타입을 루트에서도 export한다.
27
+
28
+ ### Fixed
29
+
30
+ - AI provider가 503 `EVALUATIONS_UNAVAILABLE`을 재시도 가능으로 표시하던 것 — 다시 보내도 같은 답이라 AI SDK의 자동
31
+ 재시도가 헛돈다.
32
+
33
+ ### Docs
34
+
35
+ - `/ai-provider` 진입점 주석이 도구 호출·구조화 출력을 "미지원"으로 적고 있었다(실제로는 4.7부터 지원) —
36
+ 지원 범위를 구현과 맞추고, 예시를 기계 자격(`authorization: machine.headers`) 기준으로 바꿨다.
37
+ - `docs/api-reference.md`에 json-render(Standalone·Inline) 연결 예시를 더했다.
38
+
10
39
  ## [4.7.0-rc.8] — 2026-10-29
11
40
 
12
41
  Pre-release (`npm i @reopt-ai/brandapp-sdk@next`) — 도구 루프 정산·경고·끊김 처리.
@@ -1,2 +1,52 @@
1
- import { _ as StreamDoneData, a as CompletionContentPart, c as CompletionUsage, d as FinishReason, f as ImageGenerateOptions, g as PartProviderMetadata, h as ModelInfo, i as ChatMessage, l as CompletionWarning, m as MessageRole, n as createReoptAiClient, o as CompletionOptions, p as ImageGenerateResult, r as AgentInfo, s as CompletionResult, t as ReoptAiClient, u as CreditInfo, v as StreamEvent } from "../client-Cm7LK9If.js";
2
- export { type AgentInfo, type ChatMessage, type CompletionContentPart, type CompletionOptions, type CompletionResult, type CompletionUsage, type CompletionWarning, type CreditInfo, type FinishReason, type ImageGenerateOptions, type ImageGenerateResult, type MessageRole, type ModelInfo, type PartProviderMetadata, ReoptAiClient, type StreamDoneData, type StreamEvent, createReoptAiClient };
1
+ import { C as StreamEvent, S as StreamDoneData, _ as ImageGenerateOptions, a as CompletionContentPart, b as ModelInfo, c as CompletionUsage, d as EvaluateOptions, f as EvaluationAnswer, g as FinishReason, h as EvaluationResult, i as ChatMessage, l as CompletionWarning, m as EvaluationQuestion, n as createReoptAiClient, o as CompletionOptions, p as EvaluationInput, r as AgentInfo, s as CompletionResult, t as ReoptAiClient, u as CreditInfo, v as ImageGenerateResult, x as PartProviderMetadata, y as MessageRole } from "../client-CP1Jgq4R.js";
2
+ //#region src/ai/evaluator.d.ts
3
+ /**
4
+ * json-render `experimental_composeSpec`의 `evaluate`와 같은 모양(0.21 `Experimental_CompositionEvaluator`).
5
+ * json-render를 의존성으로 들이지 않으려고 구조만 같게 적는다 — 호환은 테스트가 실제 `composeSpec`에
6
+ * 꽂아 확인한다.
7
+ */
8
+ type BrandappCompositionEvaluator = (request: {
9
+ state: Record<string, unknown>;
10
+ questions: Record<string, {
11
+ type: "choice";
12
+ instructions: string;
13
+ criteria: Record<string, string>;
14
+ }>;
15
+ signal: AbortSignal;
16
+ }) => Promise<{
17
+ answers: Record<string, {
18
+ choice: string;
19
+ confidence?: number;
20
+ }>;
21
+ usage?: {
22
+ inputTokens?: number;
23
+ };
24
+ }>;
25
+ type EvaluatorSource = Pick<ReoptAiClient, "evaluate"> | {
26
+ ai: Pick<ReoptAiClient, "evaluate">;
27
+ };
28
+ /**
29
+ * 브랜드앱 크레딧으로 도는 json-render 평가자(4.7+, RFC-0041).
30
+ *
31
+ * ```ts
32
+ * for await (const event of experimental_composeSpec({
33
+ * catalog, candidates, prompt,
34
+ * evaluate: createBrandappEvaluator(sdk, { customerId }),
35
+ * })) { … }
36
+ * ```
37
+ *
38
+ * 질문은 그대로 보내고 답을 json-render 모양(`{ choice, confidence? }`)으로 옮긴다. 모델이 답을
39
+ * 거부했거나 choice가 아닌 답이 오면 던진다 — json-render는 평가자 오류를 던져 조립을 끝내고
40
+ * 마지막 스냅샷을 남기는 설계다. **서버 전용**(브라우저에서 앱 자격을 쓰지 않는다).
41
+ */
42
+ type BrandappEvaluatorOptions = Pick<EvaluateOptions, "customerId" | "timeoutMs"> & {
43
+ /**
44
+ * 평가 한 번이 끝날 때마다(성공만) 부른다 — 조립 한 번의 실제 비용을 앱이 셀 자리다. json-render는
45
+ * 입력 토큰만 넘기므로 크레딧은 여기서만 보인다. 합산은 `usage.creditCostMilli`를 더한 뒤 한 번 올림.
46
+ */
47
+ onEvaluation?: (result: EvaluationResult) => void;
48
+ };
49
+ declare function createBrandappEvaluator(source: EvaluatorSource, options?: BrandappEvaluatorOptions): BrandappCompositionEvaluator;
50
+ //#endregion
51
+ export { type AgentInfo, type BrandappCompositionEvaluator, type BrandappEvaluatorOptions, type ChatMessage, type CompletionContentPart, type CompletionOptions, type CompletionResult, type CompletionUsage, type CompletionWarning, type CreditInfo, type EvaluateOptions, type EvaluationAnswer, type EvaluationInput, type EvaluationQuestion, type EvaluationResult, type FinishReason, type ImageGenerateOptions, type ImageGenerateResult, type MessageRole, type ModelInfo, type PartProviderMetadata, ReoptAiClient, type StreamDoneData, type StreamEvent, createBrandappEvaluator, createReoptAiClient };
52
+ //# sourceMappingURL=index.d.ts.map
package/dist/ai/index.js CHANGED
@@ -1,3 +1,33 @@
1
- import { n as createReoptAiClient, t as ReoptAiClient } from "../client-C8Fs2kuo.js";
1
+ import { S as ReoptSDKError } from "../config-CkG8Anez.js";
2
+ import { n as createReoptAiClient, t as ReoptAiClient } from "../client-Nv1DvsTh.js";
2
3
 
3
- export { ReoptAiClient, createReoptAiClient };
4
+ //#region src/ai/evaluator.ts
5
+ function createBrandappEvaluator(source, options = {}) {
6
+ const client = "ai" in source ? source.ai : source;
7
+ return async ({ state, questions, signal }) => {
8
+ const result = await client.evaluate({
9
+ state,
10
+ questions,
11
+ ...options.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {},
12
+ ...options.customerId ? { customerId: options.customerId } : {}
13
+ }, { signal });
14
+ options.onEvaluation?.(result);
15
+ const answers = {};
16
+ for (const id of Object.keys(questions)) {
17
+ const answer = result.answers[id];
18
+ if (!answer || answer.type !== "choice") throw new ReoptSDKError(answer?.type === "refusal" ? `Evaluation model declined to answer "${id}"` : `Evaluation returned no choice for "${id}"`, 502, answer?.type === "refusal" ? "EVALUATION_REFUSED" : "EVALUATION_INVALID_ANSWER");
19
+ answers[id] = {
20
+ choice: answer.choice,
21
+ ...answer.confidence != null ? { confidence: answer.confidence } : {}
22
+ };
23
+ }
24
+ return {
25
+ answers,
26
+ ...result.usage.inputTokens != null ? { usage: { inputTokens: result.usage.inputTokens } } : {}
27
+ };
28
+ };
29
+ }
30
+
31
+ //#endregion
32
+ export { ReoptAiClient, createBrandappEvaluator, createReoptAiClient };
33
+ //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { n as ReoptSDKConfig } from "../config-BGT9h1OW.js";
2
- import { ImageModelV3, ImageModelV3CallOptions, LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, ProviderV3 } from "@ai-sdk/provider";
2
+ import { Experimental_DecisionModelV4, Experimental_DecisionModelV4CallOptions, Experimental_DecisionModelV4Result, ImageModelV3, ImageModelV3CallOptions, LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, ProviderV3 } from "@ai-sdk/provider";
3
3
  //#region src/ai-provider/brandapp-language-model.d.ts
4
4
  type BrandappLanguageModelConfig = {
5
5
  /** BrandApp API base URL */
@@ -53,6 +53,26 @@ declare class BrandappLanguageModel implements LanguageModelV3 {
53
53
  private createStreamPartTransform;
54
54
  }
55
55
  //#endregion
56
+ //#region src/ai-provider/brandapp-decision-model.d.ts
57
+ /** 서버가 중계하는 평가 모델 — 지금은 Jev 하나다(서버가 고정 버전으로 부른다). */
58
+ declare const BRANDAPP_DECISION_MODEL_IDS: readonly ["typesafe-ai/jev", "typesafe-ai/jev-1.14.0"];
59
+ type BrandappDecisionModelId = (typeof BRANDAPP_DECISION_MODEL_IDS)[number];
60
+ type BrandappDecisionProviderOptions = {
61
+ /** BrandappCustomer ID (사용량 귀속) */
62
+ customerId?: string;
63
+ /** 서버 상한 1000~10000ms (기본 10000). 넘으면 504 — 과금 없음. */
64
+ timeoutMs?: number;
65
+ };
66
+ declare class BrandappDecisionModel implements Experimental_DecisionModelV4 {
67
+ readonly specificationVersion: "v4";
68
+ readonly provider = "brandapp";
69
+ readonly modelId: string;
70
+ readonly supportedQuestionTypes: readonly ["choice", "score", "boolean"];
71
+ private readonly config;
72
+ constructor(modelId: string, config: BrandappLanguageModelConfig);
73
+ doDecide(options: Experimental_DecisionModelV4CallOptions): Promise<Experimental_DecisionModelV4Result>;
74
+ }
75
+ //#endregion
56
76
  //#region src/ai-provider/brandapp-image-model.d.ts
57
77
  type BrandappImageProviderOptions = {
58
78
  /** BrandappCustomer ID (사용량 추적) */
@@ -134,7 +154,11 @@ type BrandappProviderConfig = {
134
154
  declare function createBrandappProvider(config: BrandappProviderConfig): BrandappProvider;
135
155
  type BrandappProvider = ProviderV3 & {
136
156
  (modelId: string): LanguageModelV3;
157
+ /** 평가 모델(Jev) — AI SDK `experimental_evaluate`의 `model`. 생략하면 `typesafe-ai/jev`. */
158
+ decisionModel(modelId?: string): BrandappDecisionModel;
159
+ /** @deprecated `decisionModel`과 같다(AI SDK의 옛 이름). */
160
+ evaluationModel(modelId?: string): BrandappDecisionModel;
137
161
  };
138
162
  //#endregion
139
- export { BrandappImageModel, type BrandappImageProviderOptions, BrandappLanguageModel, type BrandappLanguageModelConfig, BrandappProvider, BrandappProviderConfig, type BrandappProviderOptions, createBrandappProvider };
163
+ export { BRANDAPP_DECISION_MODEL_IDS, BrandappDecisionModel, type BrandappDecisionModelId, type BrandappDecisionProviderOptions, BrandappImageModel, type BrandappImageProviderOptions, BrandappLanguageModel, type BrandappLanguageModelConfig, BrandappProvider, BrandappProviderConfig, type BrandappProviderOptions, createBrandappProvider };
140
164
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import { i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, r as assertBrowserSafe } from "../config-C4uJ8ixE.js";
1
+ import { i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, r as assertBrowserSafe } from "../config-CkG8Anez.js";
2
2
  import { t as createManagedAbort } from "../abort--nOBFN4M.js";
3
3
  import { t as createAuthHeader } from "../encoding-Bwfm3iaE.js";
4
4
  import { t as createSSELineProcessor } from "../sse-parser-FMjxM7sY.js";
@@ -90,6 +90,8 @@ async function fetchWithTimeout(config, fetchFn, url, init) {
90
90
  * `sdk.ai.*` 경로와 **동일한 코드/진단**을 노출한다(공유 mapper 사용).
91
91
  * 소비처: `err.data?.code`, `err.data?.diagnostic`, `err.cause`(ReoptSDKError).
92
92
  */
93
+ /** 플랫폼 설정이 바뀌기 전에는 같은 답이 오는 코드(예: 평가가 아직 열리지 않음 — RFC-0041). */
94
+ const NON_RETRYABLE_CODES = /* @__PURE__ */ new Set(["EVALUATIONS_UNAVAILABLE"]);
93
95
  async function throwProviderApiError(response, url, requestBodyValues, requestId) {
94
96
  const body = await response.json().catch(() => ({}));
95
97
  const code = body.error?.code;
@@ -106,7 +108,7 @@ async function throwProviderApiError(response, url, requestBodyValues, requestId
106
108
  statusCode: response.status,
107
109
  responseHeaders: extractResponseHeaders(response),
108
110
  responseBody: JSON.stringify(body),
109
- isRetryable: response.status === 429 || response.status >= 500,
111
+ isRetryable: (response.status === 429 || response.status >= 500) && !NON_RETRYABLE_CODES.has(code ?? ""),
110
112
  data: {
111
113
  code: reoptError.code,
112
114
  diagnostic: reoptError.diagnostic,
@@ -123,6 +125,106 @@ function extractResponseHeaders(response) {
123
125
  return headers;
124
126
  }
125
127
 
128
+ //#endregion
129
+ //#region src/ai-provider/brandapp-decision-model.ts
130
+ /**
131
+ * BrandApp AI SDK 결정(평가) 모델 — `Experimental_DecisionModelV4` 구현 (4.7+, RFC-0041)
132
+ *
133
+ * AI SDK의 `experimental_evaluate`(옛 이름 `experimental_decide`)를 브랜드앱 크레딧으로 돌린다.
134
+ * `/ai/evaluations`를 부르고, 서버가 덧붙인 `confidence`를 걷어 사업자 답 그대로 돌려준다 —
135
+ * 확률 분포(`probabilities`)가 같은 정보를 담고, AI SDK가 답을 스스로 검증한다.
136
+ *
137
+ * ```ts
138
+ * import { experimental_evaluate as evaluate } from "ai";
139
+ *
140
+ * const { answers, providerMetadata } = await evaluate({
141
+ * model: brandapp.decisionModel(),
142
+ * state: { ticket: "환불해 주세요" },
143
+ * questions: { intent: { type: "choice", instructions: "의도", criteria: { refund: null, other: null } } },
144
+ * });
145
+ * providerMetadata?.brandapp?.creditCostMilli;
146
+ * ```
147
+ */
148
+ /** 서버가 중계하는 평가 모델 — 지금은 Jev 하나다(서버가 고정 버전으로 부른다). */
149
+ const BRANDAPP_DECISION_MODEL_IDS = ["typesafe-ai/jev", "typesafe-ai/jev-1.14.0"];
150
+ var BrandappDecisionModel = class {
151
+ specificationVersion = "v4";
152
+ provider = "brandapp";
153
+ modelId;
154
+ supportedQuestionTypes = [
155
+ "choice",
156
+ "score",
157
+ "boolean"
158
+ ];
159
+ config;
160
+ constructor(modelId, config) {
161
+ if (!BRANDAPP_DECISION_MODEL_IDS.includes(modelId)) throw new NoSuchModelError({
162
+ modelId,
163
+ modelType: "languageModel",
164
+ message: `BrandApp evaluations relay ${BRANDAPP_DECISION_MODEL_IDS.join(", ")} only`
165
+ });
166
+ this.modelId = modelId;
167
+ this.config = config;
168
+ }
169
+ async doDecide(options) {
170
+ const brandappOptions = options.providerOptions?.brandapp;
171
+ const customerId = brandappOptions?.customerId ?? this.config.customerId;
172
+ const body = {
173
+ state: options.state,
174
+ questions: options.questions,
175
+ ...brandappOptions?.timeoutMs != null ? { timeoutMs: brandappOptions.timeoutMs } : {},
176
+ ...customerId ? { customerId } : {}
177
+ };
178
+ const url = `${this.config.baseUrl}/evaluations`;
179
+ const requestId = newRequestId(this.config.sdkVersion);
180
+ const response = await fetchWithTimeout(this.config, this.config.fetch ?? globalThis.fetch, url, {
181
+ method: "POST",
182
+ headers: mergeProviderHeaders({
183
+ ...await providerAuthHeaders(this.config, {
184
+ method: "POST",
185
+ url
186
+ }),
187
+ ...buildProviderHeaders(this.config, options.headers)
188
+ }, { "X-Request-Id": requestId }),
189
+ body: JSON.stringify(body),
190
+ signal: options.abortSignal
191
+ });
192
+ if (!response.ok) await throwProviderApiError(response, url, body, requestId);
193
+ const { data } = await response.json();
194
+ const answers = {};
195
+ for (const [id, answer] of Object.entries(data.answers)) if (answer.type === "choice") answers[id] = {
196
+ type: "choice",
197
+ choice: answer.choice,
198
+ ...answer.probabilities ? { probabilities: answer.probabilities } : {}
199
+ };
200
+ else if (answer.type === "score") answers[id] = {
201
+ type: "score",
202
+ score: answer.score,
203
+ ...answer.probabilities ? { probabilities: answer.probabilities } : {}
204
+ };
205
+ else answers[id] = answer;
206
+ return {
207
+ answers,
208
+ usage: {
209
+ ...data.usage.inputTokens != null ? { inputTokens: data.usage.inputTokens } : {},
210
+ ...data.usage.outputTokens != null ? { outputTokens: data.usage.outputTokens } : {}
211
+ },
212
+ warnings: [],
213
+ providerMetadata: { brandapp: {
214
+ creditCost: data.usage.creditCost,
215
+ creditCostMilli: data.usage.creditCostMilli,
216
+ creditsRemaining: data.creditsRemaining,
217
+ ...data.creditLimited ? { creditLimited: true } : {}
218
+ } },
219
+ response: {
220
+ id: data.id,
221
+ modelId: data.model,
222
+ headers: extractResponseHeaders(response)
223
+ }
224
+ };
225
+ }
226
+ };
227
+
126
228
  //#endregion
127
229
  //#region src/ai-provider/brandapp-image-model.ts
128
230
  var BrandappImageModel = class {
@@ -854,24 +956,37 @@ var BrandappLanguageModel = class {
854
956
  *
855
957
  * Vercel AI SDK와 호환되는 커스텀 프로바이더를 생성합니다.
856
958
  *
857
- * **지원**: `generateText()`, `streamText()` (텍스트 생성), `generateImage()`
858
- * (이미지 생성), `providerMetadata.brandapp`(사용량/사용량), `providerOptions.brandapp`.
959
+ * **지원**: `generateText()`, `streamText()`, `ToolLoopAgent`, `experimental_evaluate`(평가 모델
960
+ * `brandapp.decisionModel()` — Jev, RFC-0041) — 텍스트·도구 호출(도구는 호출
961
+ * 앱이 실행)·구조화 출력(`responseFormat: json`)·추론 파트 왕복, `generateImage()`(이미지 생성),
962
+ * `providerMetadata.brandapp`(사용량), `providerOptions.brandapp`. 도구·구조화 출력은 브랜드앱 AI
963
+ * 설정의 "도구 호출·구조화 출력 허용"이 켜져 있어야 한다(꺼져 있으면 403 `CLIENT_TOOLS_DISABLED`).
964
+ * 범위의 정본은 `brandapp-language-model.ts` 머리 주석과 `docs/api-reference.md`다.
859
965
  *
860
- * **미지원** (호출 시 `warnings`로 알리고 해당 부분은 무시됨): tool/function calling,
861
- * 구조화 출력(`generateObject`/`responseFormat: json`), 비전·파일 입력, `topP`/`topK`/
862
- * `frequencyPenalty`/`presencePenalty`/`stopSequences`/`seed`. BrandApp AI API는 멀티
863
- * 테넌트 안전을 위해 텍스트·이미지 표면만 노출한다. 임베딩/음성/전사 모델은 없다
864
- * (`NoSuchModelError`).
966
+ * **미지원**: 비전·파일 입력과 provider 실행 도구(요청 전에 거절), `topP`/`topK`/
967
+ * `frequencyPenalty`/`presencePenalty`/`stopSequences`/`seed`(warnings로 알리고 무시).
968
+ * 임베딩/음성/전사 모델은 없다(`NoSuchModelError`).
969
+ *
970
+ * **서버 전용**이다 — 브라우저에서 `clientSecret`을 주면 거절한다. 서버 간 호출은 기계 자격
971
+ * (`@reopt-ai/brandapp-sdk/machine`)을 `authorization`으로 꽂는 것이 기본이고, `clientSecret`
972
+ * (Basic)은 그 클라이언트에 기계 scope가 남아 있을 때만 통한다(RFC-0034).
865
973
  *
866
974
  * @example
867
975
  * ```ts
868
976
  * import { createBrandappProvider } from "@reopt-ai/brandapp-sdk/ai-provider";
977
+ * import { createMachineClient, readClientKeyRing } from "@reopt-ai/brandapp-sdk/machine";
869
978
  * import { generateText, streamText } from "ai";
870
979
  *
980
+ * const machine = createMachineClient({
981
+ * clientId: process.env.BRANDAPP_MACHINE_CLIENT_ID!,
982
+ * keyRing: readClientKeyRing()!,
983
+ * resource: "https://brandapp.reopt.ai",
984
+ * scopes: ["brandapp:read", "brandapp:write"],
985
+ * });
871
986
  * const brandapp = createBrandappProvider({
872
- * clientId: process.env.BRANDAPP_CLIENT_ID!,
873
- * clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
987
+ * clientId: machine.clientId,
874
988
  * brandappId: process.env.BRANDAPP_ID!,
989
+ * authorization: machine.headers,
875
990
  * });
876
991
  *
877
992
  * // Non-streaming
@@ -955,6 +1070,7 @@ function createBrandappProvider(config) {
955
1070
  };
956
1071
  const languageModelCache = /* @__PURE__ */ new Map();
957
1072
  const imageModelCache = /* @__PURE__ */ new Map();
1073
+ const decisionModelCache = /* @__PURE__ */ new Map();
958
1074
  function provider(modelId) {
959
1075
  let model = languageModelCache.get(modelId);
960
1076
  if (!model) {
@@ -973,6 +1089,17 @@ function createBrandappProvider(config) {
973
1089
  }
974
1090
  return model;
975
1091
  };
1092
+ const decisionModel = (modelId = BRANDAPP_DECISION_MODEL_IDS[0]) => {
1093
+ let model = decisionModelCache.get(modelId);
1094
+ if (!model) {
1095
+ model = new BrandappDecisionModel(modelId, modelConfig);
1096
+ decisionModelCache.set(modelId, model);
1097
+ }
1098
+ return model;
1099
+ };
1100
+ provider.decisionModel = decisionModel;
1101
+ /** @deprecated AI SDK가 `decisionModel`로 이름을 바꿨다 — 같은 모델이다. */
1102
+ provider.evaluationModel = decisionModel;
976
1103
  provider.embeddingModel = (modelId) => {
977
1104
  throw new NoSuchModelError({
978
1105
  modelId,
@@ -1001,5 +1128,5 @@ function createBrandappProvider(config) {
1001
1128
  }
1002
1129
 
1003
1130
  //#endregion
1004
- export { BrandappImageModel, BrandappLanguageModel, createBrandappProvider };
1131
+ export { BRANDAPP_DECISION_MODEL_IDS, BrandappDecisionModel, BrandappImageModel, BrandappLanguageModel, createBrandappProvider };
1005
1132
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { n as createReoptAnalyticsClient, t as ReoptAnalyticsClient } from "../client-GRG2iZTx.js";
1
+ import { n as createReoptAnalyticsClient, t as ReoptAnalyticsClient } from "../client-Ghq4BgoW.js";
2
2
  import { getInstance, identify, init, pageView, setConsent, track } from "@reopt-ai/data-sdk";
3
3
 
4
4
  //#region src/analytics/browser.ts
@@ -1,4 +1,4 @@
1
- import { n as createReoptAuthClient, t as ReoptAuthClient } from "../client-DMKaOPgU.js";
1
+ import { n as createReoptAuthClient, t as ReoptAuthClient } from "../client-BSkEu3Bv.js";
2
2
 
3
3
  //#region src/auth/session.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { O as isReoptSDKError, S as ReoptSDKError, a as resolveIdBaseUrl, s as AuthError, t as REOPT_BASE_URLS, w as ServerError, x as RateLimitError } from "../config-C4uJ8ixE.js";
2
- import { t as BaseHttpClient } from "../http-client-DdW_W7IB.js";
1
+ import { O as isReoptSDKError, S as ReoptSDKError, a as resolveIdBaseUrl, s as AuthError, t as REOPT_BASE_URLS, w as ServerError, x as RateLimitError } from "../config-CkG8Anez.js";
2
+ import { t as BaseHttpClient } from "../http-client-C1Ahb6A0.js";
3
3
  import { o as readClientKeyRing } from "../keys-B_R_lsyF.js";
4
4
  import { a as STEP_UP_MAX_AUTH_AGE_SECONDS, i as REOPT_STEP_UP_PROVIDER_ID, n as REOPT_PROVIDER_ID, r as REOPT_PROVIDER_IDS, t as REOPT_DEFAULT_SCOPES } from "../types-DGAVaUCc.js";
5
5
  import { createAdapterFactory } from "better-auth/adapters";
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-DdW_W7IB.js";
1
+ import { t as BaseHttpClient } from "./http-client-C1Ahb6A0.js";
2
2
 
3
3
  //#region src/auth/client.ts
4
4
  function unwrap(body) {
@@ -50,4 +50,4 @@ function createReoptAuthClient(config) {
50
50
 
51
51
  //#endregion
52
52
  export { createReoptAuthClient as n, ReoptAuthClient as t };
53
- //# sourceMappingURL=client-DMKaOPgU.js.map
53
+ //# sourceMappingURL=client-BSkEu3Bv.js.map
@@ -201,6 +201,70 @@ type AgentInfo = {
201
201
  description: string;
202
202
  defaultModel: string;
203
203
  };
204
+ /** 공유 상태·지시문 — 문자열, JSON 객체, JSON 배열. */
205
+ type EvaluationInput = string | Readonly<Record<string, unknown>> | readonly unknown[];
206
+ /** AI SDK 결정 모델 계약과 같은 모양의 질문. */
207
+ type EvaluationQuestion = {
208
+ type: "choice";
209
+ instructions: EvaluationInput;
210
+ /** 선택지 이름 → 설명(1~100개). */
211
+ criteria: Readonly<Record<string, EvaluationInput | null>>;
212
+ } | {
213
+ type: "score";
214
+ instructions: EvaluationInput;
215
+ /** 0부터 순서가 있는 레벨(2~10개). */
216
+ criteria: readonly (EvaluationInput | null)[];
217
+ } | {
218
+ type: "boolean";
219
+ instructions: EvaluationInput;
220
+ criteria?: {
221
+ true?: EvaluationInput | null;
222
+ false?: EvaluationInput | null;
223
+ };
224
+ };
225
+ type EvaluateOptions = {
226
+ state: EvaluationInput;
227
+ /** 질문 id → 질문(1~128개). 한 호출이 전부를 함께 묻는다. */
228
+ questions: Readonly<Record<string, EvaluationQuestion>>;
229
+ /** 1000~10000ms, 기본 10000. 넘으면 504 `EVALUATION_TIMEOUT`(과금 없음). */
230
+ timeoutMs?: number;
231
+ /** BrandappCustomer ID (사용량 귀속) */
232
+ customerId?: string;
233
+ };
234
+ /**
235
+ * 답. choice·score의 `confidence`는 분포의 최빈 확률이고 분포가 없으면 null(0이 아니다).
236
+ * boolean의 `probability`는 P(참)이지 확신이 아니다. `refusal`은 모델이 답하지 않은 것이다.
237
+ */
238
+ type EvaluationAnswer = {
239
+ type: "choice";
240
+ choice: string;
241
+ probabilities?: Record<string, number>;
242
+ confidence: number | null;
243
+ } | {
244
+ type: "score";
245
+ score: number;
246
+ probabilities?: Record<string, number>;
247
+ confidence: number | null;
248
+ } | {
249
+ type: "boolean";
250
+ probability: number;
251
+ } | {
252
+ type: "refusal";
253
+ };
254
+ type EvaluationResult = {
255
+ id: string;
256
+ model: string;
257
+ answers: Record<string, EvaluationAnswer>;
258
+ usage: {
259
+ inputTokens: number | null;
260
+ outputTokens: number | null;
261
+ creditCost: number;
262
+ /** 실제 사용량(1/1000 크레딧). 여러 호출을 더할 때는 이것을 더한 뒤 한 번만 올림한다. */
263
+ creditCostMilli: number;
264
+ };
265
+ creditsRemaining: number;
266
+ creditLimited?: boolean;
267
+ };
204
268
  //#endregion
205
269
  //#region src/ai/client.d.ts
206
270
  declare class ReoptAiClient {
@@ -284,6 +348,28 @@ declare class ReoptAiClient {
284
348
  * ```
285
349
  */
286
350
  generateImage(options: ImageGenerateOptions): Promise<ImageGenerateResult>;
351
+ /**
352
+ * 평가 — 상태와 질문을 보내면 평가 모델(Jev)이 선택지·점수·확률로 답한다(4.7+, RFC-0041).
353
+ *
354
+ * 브랜드앱 AI 설정의 "평가 허용"이 켜져 있어야 한다(꺼져 있으면 403 `EVALUATIONS_DISABLED`).
355
+ * 답을 못 준 호출(시간 초과·취소·사업자 거절·범위 밖 답)은 과금하지 않는다. 재시도하지 않는다 —
356
+ * 과금되는 호출이라 SDK가 같은 요청을 두 번 보내지 않는다.
357
+ * json-render의 화면 조립에 꽂으려면 `createBrandappEvaluator`를 쓴다.
358
+ *
359
+ * @example
360
+ * ```ts
361
+ * const result = await sdk.ai.evaluate({
362
+ * state: { request: "동네 김밥집 소개 페이지" },
363
+ * questions: {
364
+ * root: { type: "choice", instructions: "첫 구획", criteria: { hero: "큰 제목", menu: "메뉴" } },
365
+ * },
366
+ * });
367
+ * result.answers.root; // { type: "choice", choice: "hero", confidence: 0.98, … }
368
+ * ```
369
+ */
370
+ evaluate(options: EvaluateOptions, fetchOptions?: {
371
+ signal?: AbortSignal;
372
+ }): Promise<EvaluationResult>;
287
373
  /**
288
374
  * 사용량 잔액 조회
289
375
  *
@@ -320,5 +406,5 @@ declare class ReoptAiClient {
320
406
  }
321
407
  declare function createReoptAiClient(config: ReoptSDKConfig): ReoptAiClient;
322
408
  //#endregion
323
- export { StreamDoneData as _, CompletionContentPart as a, CompletionUsage as c, FinishReason as d, ImageGenerateOptions as f, PartProviderMetadata as g, ModelInfo as h, ChatMessage as i, CompletionWarning as l, MessageRole as m, createReoptAiClient as n, CompletionOptions as o, ImageGenerateResult as p, AgentInfo as r, CompletionResult as s, ReoptAiClient as t, CreditInfo as u, StreamEvent as v };
324
- //# sourceMappingURL=client-Cm7LK9If.d.ts.map
409
+ export { StreamEvent as C, StreamDoneData as S, ImageGenerateOptions as _, CompletionContentPart as a, ModelInfo as b, CompletionUsage as c, EvaluateOptions as d, EvaluationAnswer as f, FinishReason as g, EvaluationResult as h, ChatMessage as i, CompletionWarning as l, EvaluationQuestion as m, createReoptAiClient as n, CompletionOptions as o, EvaluationInput as p, AgentInfo as r, CompletionResult as s, ReoptAiClient as t, CreditInfo as u, ImageGenerateResult as v, PartProviderMetadata as x, MessageRole as y };
410
+ //# sourceMappingURL=client-CP1Jgq4R.d.ts.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-DdW_W7IB.js";
1
+ import { t as BaseHttpClient } from "./http-client-C1Ahb6A0.js";
2
2
 
3
3
  //#region src/plans/client.ts
4
4
  function unwrap(body) {
@@ -143,4 +143,4 @@ function createReoptPlansClient(config) {
143
143
 
144
144
  //#endregion
145
145
  export { createReoptPlansClient as n, ReoptPlansClient as t };
146
- //# sourceMappingURL=client-B1Yh78Q2.js.map
146
+ //# sourceMappingURL=client-CezHrq4c.js.map
@@ -1,6 +1,6 @@
1
- import { S as ReoptSDKError, u as BadRequestError } from "./config-C4uJ8ixE.js";
2
- import { t as BaseHttpClient } from "./http-client-DdW_W7IB.js";
3
- import { t as buildQuery } from "./query-okRw8nVs.js";
1
+ import { S as ReoptSDKError, u as BadRequestError } from "./config-CkG8Anez.js";
2
+ import { t as BaseHttpClient } from "./http-client-C1Ahb6A0.js";
3
+ import { t as buildQuery } from "./query-5kxgEXLX.js";
4
4
 
5
5
  //#region src/eav/cache.ts
6
6
  var SchemaCache = class {
@@ -603,4 +603,4 @@ function createReoptEavClient(config) {
603
603
 
604
604
  //#endregion
605
605
  export { RECORDS_PAGE_LIMIT_MAX as i, ATTRIBUTE_FILTER_LIST_MAX as n, ATTRIBUTE_FILTER_OPERATORS as r, createReoptEavClient as t };
606
- //# sourceMappingURL=client-B3mfgfKm.js.map
606
+ //# sourceMappingURL=client-D5rvzXf3.js.map
@@ -1,4 +1,4 @@
1
- import { a as resolveIdBaseUrl } from "./config-C4uJ8ixE.js";
1
+ import { a as resolveIdBaseUrl } from "./config-CkG8Anez.js";
2
2
  import { o as readClientKeyRing, s as toPublicJwk } from "./keys-B_R_lsyF.js";
3
3
  import { createPrivateKeyJwtClientAssertionGetter } from "@better-auth/core/oauth2";
4
4
  import * as jose from "jose";
@@ -191,4 +191,4 @@ function createMachineClient(config) {
191
191
 
192
192
  //#endregion
193
193
  export { createDpopProof as n, createMachineClient as r, MachineTokenError as t };
194
- //# sourceMappingURL=client-IT-ulPXq.js.map
194
+ //# sourceMappingURL=client-D6BIpDuI.js.map
@@ -1,5 +1,5 @@
1
- import { t as BaseHttpClient } from "./http-client-DdW_W7IB.js";
2
- import { t as buildQuery } from "./query-okRw8nVs.js";
1
+ import { t as BaseHttpClient } from "./http-client-C1Ahb6A0.js";
2
+ import { t as buildQuery } from "./query-5kxgEXLX.js";
3
3
 
4
4
  //#region src/cms/client.ts
5
5
  function createReoptCmsClient(config) {
@@ -52,4 +52,4 @@ async list(query) {
52
52
 
53
53
  //#endregion
54
54
  export { createReoptCmsClient as t };
55
- //# sourceMappingURL=client-UlK_7r41.js.map
55
+ //# sourceMappingURL=client-DNs5PvB4.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-DdW_W7IB.js";
1
+ import { t as BaseHttpClient } from "./http-client-C1Ahb6A0.js";
2
2
 
3
3
  //#region src/push/client.ts
4
4
  var ReoptPushClient = class {
@@ -25,4 +25,4 @@ function createReoptPushClient(config) {
25
25
 
26
26
  //#endregion
27
27
  export { createReoptPushClient as n, ReoptPushClient as t };
28
- //# sourceMappingURL=client-8-voCIn6.js.map
28
+ //# sourceMappingURL=client-DmfPn8Fe.js.map
@@ -1,6 +1,6 @@
1
- import { n as SDK_VERSION } from "./config-C4uJ8ixE.js";
1
+ import { n as SDK_VERSION } from "./config-CkG8Anez.js";
2
2
  import { o as readClientKeyRing } from "./keys-B_R_lsyF.js";
3
- import { r as createMachineClient } from "./client-IT-ulPXq.js";
3
+ import { r as createMachineClient } from "./client-D6BIpDuI.js";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region src/workspace/schemas.ts
@@ -742,4 +742,4 @@ function createPlatformClient(config) {
742
742
 
743
743
  //#endregion
744
744
  export { platformWebhookUpsertInputSchema as $, platformEavSchemaOperationSchema as A, platformPipelineResourceSchema as B, platformBrandappResourceSchema as C, platformEavEntityResourceSchema as D, platformEavBrandappResourcesSchema as E, platformMeSchema as F, platformResourcesSchema as G, platformPipelineStageInputSchema as H, platformOAuthClientImportInputSchema as I, platformTaskStageInputSchema as J, platformResourcesV2Schema as K, platformOAuthClientResourceSchema as L, platformExternalIdSchema as M, platformLockAcquiredSchema as N, platformEavSchemaApplyInputSchema as O, platformLockReleasedSchema as P, platformWebhookSchema as Q, platformOAuthClientUpsertInputSchema as R, platformBrandUpsertInputSchema as S, platformCustomerUpsertInputSchema as T, platformPipelineUpsertInputSchema as U, platformPipelineSchema as V, platformResourceKeySchema as W, platformTaskUpsertInputSchema as X, platformTaskStageSchema as Y, platformWebhookResourceSchema as Z, PLATFORM_TASK_PRIORITIES as _, createPlatformClient as a, platformBrandImportInputSchema as b, PLATFORM_ADMIN_SCOPE as c, PLATFORM_MANAGED_BY_VALUES as d, platformWorkTaskStageChangedEventSchema as et, PLATFORM_OAUTH_APPLICATION_TYPES as f, PLATFORM_TASK_OUTCOMES as g, PLATFORM_STAGE_COLORS as h, REOPT_PLATFORM_URLS as i, platformErrorSchema as j, platformEavSchemaApplyResultSchema as k, PLATFORM_BRANDAPP_STATUSES as l, PLATFORM_OAUTH_GRANT_TYPES as m, PlatformApiError as n, createPlatformRequester as o, PLATFORM_OAUTH_CLIENT_PURPOSES as p, platformTaskSchema as q, REOPT_PLATFORM_ID_URLS as r, resolvePlatformUrls as s, DEFAULT_PLATFORM_SCOPES as t, platformWriteMetaSchema as tt, PLATFORM_DOMAIN_STATUSES as u, PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS as v, platformBrandappUpsertInputSchema as w, platformBrandResourceSchema as x, PLATFORM_WEBHOOK_TRIGGERS as y, platformPipelineImportInputSchema as z };
745
- //# sourceMappingURL=client-CeRmh20T.js.map
745
+ //# sourceMappingURL=client-DvBL8-qz.js.map
@@ -1,6 +1,6 @@
1
- import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-C4uJ8ixE.js";
1
+ import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-CkG8Anez.js";
2
2
  import { t as createManagedAbort } from "./abort--nOBFN4M.js";
3
- import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-DdW_W7IB.js";
3
+ import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-C1Ahb6A0.js";
4
4
 
5
5
  //#region src/files/client.ts
6
6
  var ReoptFileClient = class {
@@ -276,4 +276,4 @@ function createReoptFileClient(config) {
276
276
 
277
277
  //#endregion
278
278
  export { createReoptFileClient as n, ReoptFileClient as t };
279
- //# sourceMappingURL=client-DM4rX1ng.js.map
279
+ //# sourceMappingURL=client-DywMETbG.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-DdW_W7IB.js";
1
+ import { t as BaseHttpClient } from "./http-client-C1Ahb6A0.js";
2
2
 
3
3
  //#region src/feedback/client.ts
4
4
  function buildListQuery(query) {
@@ -83,4 +83,4 @@ function createReoptFeedbackClient(config) {
83
83
 
84
84
  //#endregion
85
85
  export { createReoptFeedbackClient as n, ReoptFeedbackClient as t };
86
- //# sourceMappingURL=client-CZZ_ENbq.js.map
86
+ //# sourceMappingURL=client-Dz-IP_n_.js.map