@agentgo-tw/app-sdk 0.0.0-stage → 2.6.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/README.md +552 -2
- package/dist/browser.cjs +335 -0
- package/dist/browser.d.cts +22 -0
- package/dist/browser.d.ts +22 -0
- package/dist/browser.js +66 -0
- package/dist/chunk-4KBWZDXW.js +208 -0
- package/dist/chunk-VCZOS6GJ.js +61 -0
- package/dist/client.cjs +283 -0
- package/dist/client.d.cts +76 -0
- package/dist/client.d.ts +76 -0
- package/dist/client.js +205 -0
- package/dist/index.cjs +634 -0
- package/dist/index.d.cts +145 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.js +364 -0
- package/dist/od-BVdmZf1t.d.cts +2331 -0
- package/dist/od-sGQixHat.d.ts +2331 -0
- package/dist/version-ClrVQNzw.d.cts +214 -0
- package/dist/version-ClrVQNzw.d.ts +214 -0
- package/package.json +67 -4
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 錯誤碼(spec/16 § 7.6)。只增不減;平台日後新增的代碼 SDK 不認得也不會拋錯,
|
|
3
|
+
* 會原樣放在 `AcademyError.code`(spec/16 § 7.7)。
|
|
4
|
+
*/
|
|
5
|
+
type AcademyErrorCode = 'LOGIN_REQUIRED' | 'SUBSCRIPTION_REQUIRED' | 'APP_UNAVAILABLE' | 'ORIGIN_NOT_ALLOWED' | 'TOKEN_INVALID' | 'RATE_LIMITED' | 'ACCESS_DENIED' | 'IDENTITY_EXPIRED' | 'INSUFFICIENT_POINTS' | 'MODEL_NOT_ALLOWED' | 'AI_LIMIT_EXCEEDED' | 'AI_UNAVAILABLE' | 'CONTENT_FLAGGED' | 'INVALID_REQUEST' | 'DATA_UNAVAILABLE' | 'JOB_EXPIRED' | 'JOB_BUDGET_EXCEEDED' | 'JOB_LIMIT_EXCEEDED' | (string & {});
|
|
6
|
+
/**
|
|
7
|
+
* 平台回來的錯誤一律包成 `AcademyError`。App 要看 `code`,不要只看 HTTP 狀態
|
|
8
|
+
* (暫停、下架與沒有訂閱都是 403)。附帶欄位(`login_url`、`subscribe_url`、`upgrade_url`、
|
|
9
|
+
* `retry_after_seconds`、`reason`、`allowed`…)放在 `details`,常用的另有捷徑屬性。
|
|
10
|
+
*/
|
|
11
|
+
declare class AcademyError extends Error {
|
|
12
|
+
readonly code: AcademyErrorCode;
|
|
13
|
+
readonly status: number;
|
|
14
|
+
readonly details: Record<string, unknown>;
|
|
15
|
+
constructor(code: AcademyErrorCode, message: string, status?: number, details?: Record<string, unknown>);
|
|
16
|
+
/** `LOGIN_REQUIRED` 的重新登入網址 */
|
|
17
|
+
get loginUrl(): string | undefined;
|
|
18
|
+
/** `SUBSCRIPTION_REQUIRED` 的訂閱網址 */
|
|
19
|
+
get subscribeUrl(): string | undefined;
|
|
20
|
+
/** `INSUFFICIENT_POINTS` 的升級網址 */
|
|
21
|
+
get upgradeUrl(): string | undefined;
|
|
22
|
+
/** 429 類錯誤建議等待的秒數 */
|
|
23
|
+
get retryAfterSeconds(): number | undefined;
|
|
24
|
+
/** `AI_LIMIT_EXCEEDED`/`DATA_UNAVAILABLE` 的原因 */
|
|
25
|
+
get reason(): string | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 平台的型別(api/app-runtime/types.md)。列舉值只增不減,未知值一律容忍(spec/16 § 7.7)。 */
|
|
29
|
+
type AppEntitlementKind = 'SUBSCRIBED' | 'OPEN' | 'OWNER' | 'OWNER_TEST' | 'STAFF' | (string & {});
|
|
30
|
+
type MembershipTier = 'FREE' | 'STANDARD' | 'PREMIUM' | (string & {});
|
|
31
|
+
type AppIdentityEnv = 'test' | 'production';
|
|
32
|
+
interface AcademyUser {
|
|
33
|
+
/** 會員編號(平台的 user_uuid,同一會員在每個 App 都相同) */
|
|
34
|
+
uuid: string;
|
|
35
|
+
name: string;
|
|
36
|
+
email: string;
|
|
37
|
+
}
|
|
38
|
+
interface AcademyEntitlement {
|
|
39
|
+
/** 憑什麼進來。未知值視為「可以使用」 */
|
|
40
|
+
kind: AppEntitlementKind;
|
|
41
|
+
/** 會員等級,只供顯示;A/SA 為 null */
|
|
42
|
+
tier: MembershipTier | null;
|
|
43
|
+
billing_mode: 'FREE' | 'SUBSCRIPTION' | (string & {});
|
|
44
|
+
/** App 訂閱本期結束(ISO 8601);非訂閱為 null */
|
|
45
|
+
period_end: string | null;
|
|
46
|
+
subscription_uuid: string | null;
|
|
47
|
+
}
|
|
48
|
+
type AppClientKind = 'BROWSER_EXTENSION' | 'DESKTOP' | 'MOBILE' | (string & {});
|
|
49
|
+
/** 請求來自哪個會員用戶端(擴充功能、桌面或手機程式);會員在瀏覽器開 App 網頁時為 null */
|
|
50
|
+
interface AcademyClientInfo {
|
|
51
|
+
/** 上架資料宣告的用戶端代號 */
|
|
52
|
+
key: string;
|
|
53
|
+
kind: AppClientKind;
|
|
54
|
+
/** 委任編號(會員「已連結的裝置」的一筆) */
|
|
55
|
+
grant: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 掛在 `req.academy` 的內容;沒有會員身分時整個是 null:
|
|
59
|
+
* 公開路徑、尚未啟用的正式環境、以服務憑證進來的請求(看 `req.academyService`)。
|
|
60
|
+
*/
|
|
61
|
+
interface AcademyContext {
|
|
62
|
+
user: AcademyUser;
|
|
63
|
+
entitlement: AcademyEntitlement;
|
|
64
|
+
env: AppIdentityEnv;
|
|
65
|
+
/** 經會員委任憑證進來時有值;瀏覽器登入為 null */
|
|
66
|
+
client: AcademyClientInfo | null;
|
|
67
|
+
/** 原始身分 JWT(呼叫平台閘道時轉送;5 分鐘效期) */
|
|
68
|
+
identityToken: string | null;
|
|
69
|
+
/** 開發模式的假身分 */
|
|
70
|
+
dev: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 掛在 `req.academyService` 的內容:請求來自提供者自己的外部主機(帶服務憑證),沒有會員身分。
|
|
74
|
+
* 要處理某位會員的資料前,先以 `academy.members.entitlement(userUuid)` 確認。
|
|
75
|
+
*/
|
|
76
|
+
interface AcademyServiceContext {
|
|
77
|
+
/** 上架資料宣告的服務代號 */
|
|
78
|
+
key: string;
|
|
79
|
+
name: string;
|
|
80
|
+
/** 服務憑證編號(教官中心清單上的那一組) */
|
|
81
|
+
tokenId: string;
|
|
82
|
+
env: AppIdentityEnv;
|
|
83
|
+
/** 開發模式的假身分 */
|
|
84
|
+
dev: boolean;
|
|
85
|
+
}
|
|
86
|
+
type AppEntitlementReason = 'NOT_FOUND' | 'SUBSCRIPTION_REQUIRED' | 'APP_UNAVAILABLE' | (string & {});
|
|
87
|
+
/** `academy.members.entitlement()` 的回應(spec/16 § 19.4) */
|
|
88
|
+
interface MemberEntitlement {
|
|
89
|
+
/** 這位會員現在能不能使用這個工具 */
|
|
90
|
+
active: boolean;
|
|
91
|
+
/** `active` 為 false 時的原因;查無此人、帳號無效、沒有同意一律是 `NOT_FOUND` */
|
|
92
|
+
reason: AppEntitlementReason | null;
|
|
93
|
+
/** 只有 `active` 為 true 才有 */
|
|
94
|
+
user: AcademyUser | null;
|
|
95
|
+
entitlement: AcademyEntitlement | null;
|
|
96
|
+
env: AppIdentityEnv;
|
|
97
|
+
checked_at: string;
|
|
98
|
+
}
|
|
99
|
+
interface AcademyQuota {
|
|
100
|
+
tier: MembershipTier | null;
|
|
101
|
+
points_remaining: number;
|
|
102
|
+
points_held: number;
|
|
103
|
+
reset_at: string;
|
|
104
|
+
/** 只在測試環境與開發模式回傳 */
|
|
105
|
+
dev_quota_remaining?: number;
|
|
106
|
+
}
|
|
107
|
+
interface AcademyMe {
|
|
108
|
+
user: AcademyUser;
|
|
109
|
+
ent: AcademyEntitlement;
|
|
110
|
+
env: AppIdentityEnv;
|
|
111
|
+
quota: AcademyQuota;
|
|
112
|
+
}
|
|
113
|
+
type AppJobStatus = 'OPEN' | 'CLOSED' | 'EXPIRED' | (string & {});
|
|
114
|
+
interface AcademyJobInfo {
|
|
115
|
+
job_uuid: string;
|
|
116
|
+
status: AppJobStatus;
|
|
117
|
+
purpose: string;
|
|
118
|
+
max_points: number;
|
|
119
|
+
used_points: number;
|
|
120
|
+
expires_at: string;
|
|
121
|
+
closed_at: string | null;
|
|
122
|
+
}
|
|
123
|
+
type ChatRole = 'system' | 'user' | 'assistant' | 'tool' | (string & {});
|
|
124
|
+
interface ChatMessage {
|
|
125
|
+
role: ChatRole;
|
|
126
|
+
content: string | Array<{
|
|
127
|
+
type: string;
|
|
128
|
+
[k: string]: unknown;
|
|
129
|
+
}> | null;
|
|
130
|
+
[k: string]: unknown;
|
|
131
|
+
}
|
|
132
|
+
interface ChatCompletionRequest {
|
|
133
|
+
/** 平台別名:`fast`、`smart`…(不是模型名) */
|
|
134
|
+
model: string;
|
|
135
|
+
messages: ChatMessage[];
|
|
136
|
+
max_tokens?: number;
|
|
137
|
+
max_completion_tokens?: number;
|
|
138
|
+
temperature?: number;
|
|
139
|
+
stream?: boolean;
|
|
140
|
+
tools?: unknown[];
|
|
141
|
+
[k: string]: unknown;
|
|
142
|
+
}
|
|
143
|
+
interface ChatCompletion {
|
|
144
|
+
id?: string;
|
|
145
|
+
model?: string;
|
|
146
|
+
choices: Array<{
|
|
147
|
+
index: number;
|
|
148
|
+
message: {
|
|
149
|
+
role: string;
|
|
150
|
+
content: string | null;
|
|
151
|
+
[k: string]: unknown;
|
|
152
|
+
};
|
|
153
|
+
finish_reason?: string | null;
|
|
154
|
+
}>;
|
|
155
|
+
usage?: {
|
|
156
|
+
prompt_tokens?: number;
|
|
157
|
+
completion_tokens?: number;
|
|
158
|
+
total_tokens?: number;
|
|
159
|
+
[k: string]: unknown;
|
|
160
|
+
};
|
|
161
|
+
[k: string]: unknown;
|
|
162
|
+
}
|
|
163
|
+
interface ChatCompletionChunk {
|
|
164
|
+
id?: string;
|
|
165
|
+
choices: Array<{
|
|
166
|
+
index: number;
|
|
167
|
+
delta: {
|
|
168
|
+
role?: string;
|
|
169
|
+
content?: string | null;
|
|
170
|
+
[k: string]: unknown;
|
|
171
|
+
};
|
|
172
|
+
finish_reason?: string | null;
|
|
173
|
+
}>;
|
|
174
|
+
usage?: Record<string, unknown>;
|
|
175
|
+
[k: string]: unknown;
|
|
176
|
+
}
|
|
177
|
+
interface ImageGenerateRequest {
|
|
178
|
+
model: string;
|
|
179
|
+
prompt: string;
|
|
180
|
+
/** 一次最多 4 張 */
|
|
181
|
+
n?: number;
|
|
182
|
+
size?: string;
|
|
183
|
+
[k: string]: unknown;
|
|
184
|
+
}
|
|
185
|
+
interface ImageGenerateResponse {
|
|
186
|
+
data: Array<{
|
|
187
|
+
b64_json?: string;
|
|
188
|
+
url?: string;
|
|
189
|
+
}>;
|
|
190
|
+
[k: string]: unknown;
|
|
191
|
+
}
|
|
192
|
+
interface SpeechRequest {
|
|
193
|
+
model: string;
|
|
194
|
+
/** 最多 5,000 字 */
|
|
195
|
+
input: string;
|
|
196
|
+
/** 系統聲音名,例如 `Chinese (Mandarin)_Warm_Girl`、`female-shaonv`;未帶用平台預設 */
|
|
197
|
+
voice?: string;
|
|
198
|
+
[k: string]: unknown;
|
|
199
|
+
}
|
|
200
|
+
interface SpeechResponse {
|
|
201
|
+
model: string;
|
|
202
|
+
provider: string;
|
|
203
|
+
/** 上游 CDN 的限時網址:要長期保存請自行下載 */
|
|
204
|
+
audio_url: string;
|
|
205
|
+
[k: string]: unknown;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** SDK 版本(送審自檢與瀏覽器握手會回報);與 package.json 同步 */
|
|
209
|
+
declare const SDK_VERSION = "2.6.0";
|
|
210
|
+
/** 身分 JWT 與閘道協定的版本:SDK 主版號跟著它走(spec/16 § 7.1) */
|
|
211
|
+
/** 2:身分 JWT 加 `client`、新增服務 JWT(`X-Academy-Service`)、會員委任憑證與會員權益查詢(spec/16 § 19) */
|
|
212
|
+
declare const CONTRACT_VERSION = 2;
|
|
213
|
+
|
|
214
|
+
export { type AcademyMe as A, CONTRACT_VERSION as C, type ImageGenerateRequest as I, type MemberEntitlement as M, SDK_VERSION as S, type AcademyClientInfo as a, type AcademyContext as b, type AcademyEntitlement as c, AcademyError as d, type AcademyErrorCode as e, type AcademyJobInfo as f, type AcademyQuota as g, type AcademyServiceContext as h, type AcademyUser as i, type AppClientKind as j, type AppEntitlementKind as k, type AppEntitlementReason as l, type AppIdentityEnv as m, type AppJobStatus as n, type ChatCompletion as o, type ChatCompletionChunk as p, type ChatCompletionRequest as q, type ChatMessage as r, type ChatRole as s, type ImageGenerateResponse as t, type MembershipTier as u, type SpeechRequest as v, type SpeechResponse as w };
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 錯誤碼(spec/16 § 7.6)。只增不減;平台日後新增的代碼 SDK 不認得也不會拋錯,
|
|
3
|
+
* 會原樣放在 `AcademyError.code`(spec/16 § 7.7)。
|
|
4
|
+
*/
|
|
5
|
+
type AcademyErrorCode = 'LOGIN_REQUIRED' | 'SUBSCRIPTION_REQUIRED' | 'APP_UNAVAILABLE' | 'ORIGIN_NOT_ALLOWED' | 'TOKEN_INVALID' | 'RATE_LIMITED' | 'ACCESS_DENIED' | 'IDENTITY_EXPIRED' | 'INSUFFICIENT_POINTS' | 'MODEL_NOT_ALLOWED' | 'AI_LIMIT_EXCEEDED' | 'AI_UNAVAILABLE' | 'CONTENT_FLAGGED' | 'INVALID_REQUEST' | 'DATA_UNAVAILABLE' | 'JOB_EXPIRED' | 'JOB_BUDGET_EXCEEDED' | 'JOB_LIMIT_EXCEEDED' | (string & {});
|
|
6
|
+
/**
|
|
7
|
+
* 平台回來的錯誤一律包成 `AcademyError`。App 要看 `code`,不要只看 HTTP 狀態
|
|
8
|
+
* (暫停、下架與沒有訂閱都是 403)。附帶欄位(`login_url`、`subscribe_url`、`upgrade_url`、
|
|
9
|
+
* `retry_after_seconds`、`reason`、`allowed`…)放在 `details`,常用的另有捷徑屬性。
|
|
10
|
+
*/
|
|
11
|
+
declare class AcademyError extends Error {
|
|
12
|
+
readonly code: AcademyErrorCode;
|
|
13
|
+
readonly status: number;
|
|
14
|
+
readonly details: Record<string, unknown>;
|
|
15
|
+
constructor(code: AcademyErrorCode, message: string, status?: number, details?: Record<string, unknown>);
|
|
16
|
+
/** `LOGIN_REQUIRED` 的重新登入網址 */
|
|
17
|
+
get loginUrl(): string | undefined;
|
|
18
|
+
/** `SUBSCRIPTION_REQUIRED` 的訂閱網址 */
|
|
19
|
+
get subscribeUrl(): string | undefined;
|
|
20
|
+
/** `INSUFFICIENT_POINTS` 的升級網址 */
|
|
21
|
+
get upgradeUrl(): string | undefined;
|
|
22
|
+
/** 429 類錯誤建議等待的秒數 */
|
|
23
|
+
get retryAfterSeconds(): number | undefined;
|
|
24
|
+
/** `AI_LIMIT_EXCEEDED`/`DATA_UNAVAILABLE` 的原因 */
|
|
25
|
+
get reason(): string | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 平台的型別(api/app-runtime/types.md)。列舉值只增不減,未知值一律容忍(spec/16 § 7.7)。 */
|
|
29
|
+
type AppEntitlementKind = 'SUBSCRIBED' | 'OPEN' | 'OWNER' | 'OWNER_TEST' | 'STAFF' | (string & {});
|
|
30
|
+
type MembershipTier = 'FREE' | 'STANDARD' | 'PREMIUM' | (string & {});
|
|
31
|
+
type AppIdentityEnv = 'test' | 'production';
|
|
32
|
+
interface AcademyUser {
|
|
33
|
+
/** 會員編號(平台的 user_uuid,同一會員在每個 App 都相同) */
|
|
34
|
+
uuid: string;
|
|
35
|
+
name: string;
|
|
36
|
+
email: string;
|
|
37
|
+
}
|
|
38
|
+
interface AcademyEntitlement {
|
|
39
|
+
/** 憑什麼進來。未知值視為「可以使用」 */
|
|
40
|
+
kind: AppEntitlementKind;
|
|
41
|
+
/** 會員等級,只供顯示;A/SA 為 null */
|
|
42
|
+
tier: MembershipTier | null;
|
|
43
|
+
billing_mode: 'FREE' | 'SUBSCRIPTION' | (string & {});
|
|
44
|
+
/** App 訂閱本期結束(ISO 8601);非訂閱為 null */
|
|
45
|
+
period_end: string | null;
|
|
46
|
+
subscription_uuid: string | null;
|
|
47
|
+
}
|
|
48
|
+
type AppClientKind = 'BROWSER_EXTENSION' | 'DESKTOP' | 'MOBILE' | (string & {});
|
|
49
|
+
/** 請求來自哪個會員用戶端(擴充功能、桌面或手機程式);會員在瀏覽器開 App 網頁時為 null */
|
|
50
|
+
interface AcademyClientInfo {
|
|
51
|
+
/** 上架資料宣告的用戶端代號 */
|
|
52
|
+
key: string;
|
|
53
|
+
kind: AppClientKind;
|
|
54
|
+
/** 委任編號(會員「已連結的裝置」的一筆) */
|
|
55
|
+
grant: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 掛在 `req.academy` 的內容;沒有會員身分時整個是 null:
|
|
59
|
+
* 公開路徑、尚未啟用的正式環境、以服務憑證進來的請求(看 `req.academyService`)。
|
|
60
|
+
*/
|
|
61
|
+
interface AcademyContext {
|
|
62
|
+
user: AcademyUser;
|
|
63
|
+
entitlement: AcademyEntitlement;
|
|
64
|
+
env: AppIdentityEnv;
|
|
65
|
+
/** 經會員委任憑證進來時有值;瀏覽器登入為 null */
|
|
66
|
+
client: AcademyClientInfo | null;
|
|
67
|
+
/** 原始身分 JWT(呼叫平台閘道時轉送;5 分鐘效期) */
|
|
68
|
+
identityToken: string | null;
|
|
69
|
+
/** 開發模式的假身分 */
|
|
70
|
+
dev: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 掛在 `req.academyService` 的內容:請求來自提供者自己的外部主機(帶服務憑證),沒有會員身分。
|
|
74
|
+
* 要處理某位會員的資料前,先以 `academy.members.entitlement(userUuid)` 確認。
|
|
75
|
+
*/
|
|
76
|
+
interface AcademyServiceContext {
|
|
77
|
+
/** 上架資料宣告的服務代號 */
|
|
78
|
+
key: string;
|
|
79
|
+
name: string;
|
|
80
|
+
/** 服務憑證編號(教官中心清單上的那一組) */
|
|
81
|
+
tokenId: string;
|
|
82
|
+
env: AppIdentityEnv;
|
|
83
|
+
/** 開發模式的假身分 */
|
|
84
|
+
dev: boolean;
|
|
85
|
+
}
|
|
86
|
+
type AppEntitlementReason = 'NOT_FOUND' | 'SUBSCRIPTION_REQUIRED' | 'APP_UNAVAILABLE' | (string & {});
|
|
87
|
+
/** `academy.members.entitlement()` 的回應(spec/16 § 19.4) */
|
|
88
|
+
interface MemberEntitlement {
|
|
89
|
+
/** 這位會員現在能不能使用這個工具 */
|
|
90
|
+
active: boolean;
|
|
91
|
+
/** `active` 為 false 時的原因;查無此人、帳號無效、沒有同意一律是 `NOT_FOUND` */
|
|
92
|
+
reason: AppEntitlementReason | null;
|
|
93
|
+
/** 只有 `active` 為 true 才有 */
|
|
94
|
+
user: AcademyUser | null;
|
|
95
|
+
entitlement: AcademyEntitlement | null;
|
|
96
|
+
env: AppIdentityEnv;
|
|
97
|
+
checked_at: string;
|
|
98
|
+
}
|
|
99
|
+
interface AcademyQuota {
|
|
100
|
+
tier: MembershipTier | null;
|
|
101
|
+
points_remaining: number;
|
|
102
|
+
points_held: number;
|
|
103
|
+
reset_at: string;
|
|
104
|
+
/** 只在測試環境與開發模式回傳 */
|
|
105
|
+
dev_quota_remaining?: number;
|
|
106
|
+
}
|
|
107
|
+
interface AcademyMe {
|
|
108
|
+
user: AcademyUser;
|
|
109
|
+
ent: AcademyEntitlement;
|
|
110
|
+
env: AppIdentityEnv;
|
|
111
|
+
quota: AcademyQuota;
|
|
112
|
+
}
|
|
113
|
+
type AppJobStatus = 'OPEN' | 'CLOSED' | 'EXPIRED' | (string & {});
|
|
114
|
+
interface AcademyJobInfo {
|
|
115
|
+
job_uuid: string;
|
|
116
|
+
status: AppJobStatus;
|
|
117
|
+
purpose: string;
|
|
118
|
+
max_points: number;
|
|
119
|
+
used_points: number;
|
|
120
|
+
expires_at: string;
|
|
121
|
+
closed_at: string | null;
|
|
122
|
+
}
|
|
123
|
+
type ChatRole = 'system' | 'user' | 'assistant' | 'tool' | (string & {});
|
|
124
|
+
interface ChatMessage {
|
|
125
|
+
role: ChatRole;
|
|
126
|
+
content: string | Array<{
|
|
127
|
+
type: string;
|
|
128
|
+
[k: string]: unknown;
|
|
129
|
+
}> | null;
|
|
130
|
+
[k: string]: unknown;
|
|
131
|
+
}
|
|
132
|
+
interface ChatCompletionRequest {
|
|
133
|
+
/** 平台別名:`fast`、`smart`…(不是模型名) */
|
|
134
|
+
model: string;
|
|
135
|
+
messages: ChatMessage[];
|
|
136
|
+
max_tokens?: number;
|
|
137
|
+
max_completion_tokens?: number;
|
|
138
|
+
temperature?: number;
|
|
139
|
+
stream?: boolean;
|
|
140
|
+
tools?: unknown[];
|
|
141
|
+
[k: string]: unknown;
|
|
142
|
+
}
|
|
143
|
+
interface ChatCompletion {
|
|
144
|
+
id?: string;
|
|
145
|
+
model?: string;
|
|
146
|
+
choices: Array<{
|
|
147
|
+
index: number;
|
|
148
|
+
message: {
|
|
149
|
+
role: string;
|
|
150
|
+
content: string | null;
|
|
151
|
+
[k: string]: unknown;
|
|
152
|
+
};
|
|
153
|
+
finish_reason?: string | null;
|
|
154
|
+
}>;
|
|
155
|
+
usage?: {
|
|
156
|
+
prompt_tokens?: number;
|
|
157
|
+
completion_tokens?: number;
|
|
158
|
+
total_tokens?: number;
|
|
159
|
+
[k: string]: unknown;
|
|
160
|
+
};
|
|
161
|
+
[k: string]: unknown;
|
|
162
|
+
}
|
|
163
|
+
interface ChatCompletionChunk {
|
|
164
|
+
id?: string;
|
|
165
|
+
choices: Array<{
|
|
166
|
+
index: number;
|
|
167
|
+
delta: {
|
|
168
|
+
role?: string;
|
|
169
|
+
content?: string | null;
|
|
170
|
+
[k: string]: unknown;
|
|
171
|
+
};
|
|
172
|
+
finish_reason?: string | null;
|
|
173
|
+
}>;
|
|
174
|
+
usage?: Record<string, unknown>;
|
|
175
|
+
[k: string]: unknown;
|
|
176
|
+
}
|
|
177
|
+
interface ImageGenerateRequest {
|
|
178
|
+
model: string;
|
|
179
|
+
prompt: string;
|
|
180
|
+
/** 一次最多 4 張 */
|
|
181
|
+
n?: number;
|
|
182
|
+
size?: string;
|
|
183
|
+
[k: string]: unknown;
|
|
184
|
+
}
|
|
185
|
+
interface ImageGenerateResponse {
|
|
186
|
+
data: Array<{
|
|
187
|
+
b64_json?: string;
|
|
188
|
+
url?: string;
|
|
189
|
+
}>;
|
|
190
|
+
[k: string]: unknown;
|
|
191
|
+
}
|
|
192
|
+
interface SpeechRequest {
|
|
193
|
+
model: string;
|
|
194
|
+
/** 最多 5,000 字 */
|
|
195
|
+
input: string;
|
|
196
|
+
/** 系統聲音名,例如 `Chinese (Mandarin)_Warm_Girl`、`female-shaonv`;未帶用平台預設 */
|
|
197
|
+
voice?: string;
|
|
198
|
+
[k: string]: unknown;
|
|
199
|
+
}
|
|
200
|
+
interface SpeechResponse {
|
|
201
|
+
model: string;
|
|
202
|
+
provider: string;
|
|
203
|
+
/** 上游 CDN 的限時網址:要長期保存請自行下載 */
|
|
204
|
+
audio_url: string;
|
|
205
|
+
[k: string]: unknown;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** SDK 版本(送審自檢與瀏覽器握手會回報);與 package.json 同步 */
|
|
209
|
+
declare const SDK_VERSION = "2.6.0";
|
|
210
|
+
/** 身分 JWT 與閘道協定的版本:SDK 主版號跟著它走(spec/16 § 7.1) */
|
|
211
|
+
/** 2:身分 JWT 加 `client`、新增服務 JWT(`X-Academy-Service`)、會員委任憑證與會員權益查詢(spec/16 § 19) */
|
|
212
|
+
declare const CONTRACT_VERSION = 2;
|
|
213
|
+
|
|
214
|
+
export { type AcademyMe as A, CONTRACT_VERSION as C, type ImageGenerateRequest as I, type MemberEntitlement as M, SDK_VERSION as S, type AcademyClientInfo as a, type AcademyContext as b, type AcademyEntitlement as c, AcademyError as d, type AcademyErrorCode as e, type AcademyJobInfo as f, type AcademyQuota as g, type AcademyServiceContext as h, type AcademyUser as i, type AppClientKind as j, type AppEntitlementKind as k, type AppEntitlementReason as l, type AppIdentityEnv as m, type AppJobStatus as n, type ChatCompletion as o, type ChatCompletionChunk as p, type ChatCompletionRequest as q, type ChatMessage as r, type ChatRole as s, type ImageGenerateResponse as t, type MembershipTier as u, type SpeechRequest as v, type SpeechResponse as w };
|
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentgo-tw/app-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.6.0",
|
|
4
|
+
"description": "AI 研究所(agentgo.tw)上架 App 的平台 SDK:會員身分、平台 AI、房市資料、工作憑證、點數查詢,以及擴充功能與外部主機的平台憑證",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/pacific-realtor/academy.git",
|
|
9
|
+
"directory": "sdk/app-sdk"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://agentgo.tw",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.cjs",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/index.d.cts",
|
|
27
|
+
"default": "./dist/index.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"./browser": {
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/browser.d.ts",
|
|
33
|
+
"default": "./dist/browser.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/browser.d.cts",
|
|
37
|
+
"default": "./dist/browser.cjs"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"./client": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/client.d.ts",
|
|
43
|
+
"default": "./dist/client.js"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/client.d.cts",
|
|
47
|
+
"default": "./dist/client.cjs"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist",
|
|
53
|
+
"README.md"
|
|
54
|
+
],
|
|
55
|
+
"sideEffects": false,
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"test": "npm run build && node --test test/*.test.mjs"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@types/node": "^20.19.43",
|
|
66
|
+
"tsup": "^8.5.1",
|
|
67
|
+
"typescript": "^5.9.3"
|
|
68
|
+
}
|
|
69
|
+
}
|