@agentgo-tw/app-sdk 0.0.0-stage → 1.0.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 +261 -2
- package/dist/browser.cjs +233 -0
- package/dist/browser.d.cts +20 -0
- package/dist/browser.d.ts +20 -0
- package/dist/browser.js +64 -0
- package/dist/chunk-6QX4VARC.js +159 -0
- package/dist/index.cjs +484 -0
- package/dist/index.d.cts +122 -0
- package/dist/index.d.ts +122 -0
- package/dist/index.js +314 -0
- package/dist/version-CAQs9BfE.d.cts +225 -0
- package/dist/version-CAQs9BfE.d.ts +225 -0
- package/package.json +51 -4
|
@@ -0,0 +1,225 @@
|
|
|
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' | '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
|
+
/** 掛在 `req.academy` 的內容;沒有身分(公開路徑、尚未啟用的正式環境)時整個是 null */
|
|
49
|
+
interface AcademyContext {
|
|
50
|
+
user: AcademyUser;
|
|
51
|
+
entitlement: AcademyEntitlement;
|
|
52
|
+
env: AppIdentityEnv;
|
|
53
|
+
/** 原始身分 JWT(呼叫平台閘道時轉送;5 分鐘效期) */
|
|
54
|
+
identityToken: string | null;
|
|
55
|
+
/** 開發模式的假身分 */
|
|
56
|
+
dev: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface AcademyQuota {
|
|
59
|
+
tier: MembershipTier | null;
|
|
60
|
+
points_remaining: number;
|
|
61
|
+
points_held: number;
|
|
62
|
+
reset_at: string;
|
|
63
|
+
/** 只在測試環境與開發模式回傳 */
|
|
64
|
+
dev_quota_remaining?: number;
|
|
65
|
+
}
|
|
66
|
+
interface AcademyMe {
|
|
67
|
+
user: AcademyUser;
|
|
68
|
+
ent: AcademyEntitlement;
|
|
69
|
+
env: AppIdentityEnv;
|
|
70
|
+
quota: AcademyQuota;
|
|
71
|
+
}
|
|
72
|
+
type AppJobStatus = 'OPEN' | 'CLOSED' | 'EXPIRED' | (string & {});
|
|
73
|
+
interface AcademyJobInfo {
|
|
74
|
+
job_uuid: string;
|
|
75
|
+
status: AppJobStatus;
|
|
76
|
+
purpose: string;
|
|
77
|
+
max_points: number;
|
|
78
|
+
used_points: number;
|
|
79
|
+
expires_at: string;
|
|
80
|
+
closed_at: string | null;
|
|
81
|
+
}
|
|
82
|
+
type ChatRole = 'system' | 'user' | 'assistant' | 'tool' | (string & {});
|
|
83
|
+
interface ChatMessage {
|
|
84
|
+
role: ChatRole;
|
|
85
|
+
content: string | Array<{
|
|
86
|
+
type: string;
|
|
87
|
+
[k: string]: unknown;
|
|
88
|
+
}> | null;
|
|
89
|
+
[k: string]: unknown;
|
|
90
|
+
}
|
|
91
|
+
interface ChatCompletionRequest {
|
|
92
|
+
/** 平台別名:`fast`、`smart`…(不是模型名) */
|
|
93
|
+
model: string;
|
|
94
|
+
messages: ChatMessage[];
|
|
95
|
+
max_tokens?: number;
|
|
96
|
+
max_completion_tokens?: number;
|
|
97
|
+
temperature?: number;
|
|
98
|
+
stream?: boolean;
|
|
99
|
+
tools?: unknown[];
|
|
100
|
+
[k: string]: unknown;
|
|
101
|
+
}
|
|
102
|
+
interface ChatCompletion {
|
|
103
|
+
id?: string;
|
|
104
|
+
model?: string;
|
|
105
|
+
choices: Array<{
|
|
106
|
+
index: number;
|
|
107
|
+
message: {
|
|
108
|
+
role: string;
|
|
109
|
+
content: string | null;
|
|
110
|
+
[k: string]: unknown;
|
|
111
|
+
};
|
|
112
|
+
finish_reason?: string | null;
|
|
113
|
+
}>;
|
|
114
|
+
usage?: {
|
|
115
|
+
prompt_tokens?: number;
|
|
116
|
+
completion_tokens?: number;
|
|
117
|
+
total_tokens?: number;
|
|
118
|
+
[k: string]: unknown;
|
|
119
|
+
};
|
|
120
|
+
[k: string]: unknown;
|
|
121
|
+
}
|
|
122
|
+
interface ChatCompletionChunk {
|
|
123
|
+
id?: string;
|
|
124
|
+
choices: Array<{
|
|
125
|
+
index: number;
|
|
126
|
+
delta: {
|
|
127
|
+
role?: string;
|
|
128
|
+
content?: string | null;
|
|
129
|
+
[k: string]: unknown;
|
|
130
|
+
};
|
|
131
|
+
finish_reason?: string | null;
|
|
132
|
+
}>;
|
|
133
|
+
usage?: Record<string, unknown>;
|
|
134
|
+
[k: string]: unknown;
|
|
135
|
+
}
|
|
136
|
+
interface ImageGenerateRequest {
|
|
137
|
+
model: string;
|
|
138
|
+
prompt: string;
|
|
139
|
+
/** 一次最多 4 張 */
|
|
140
|
+
n?: number;
|
|
141
|
+
size?: string;
|
|
142
|
+
[k: string]: unknown;
|
|
143
|
+
}
|
|
144
|
+
interface ImageGenerateResponse {
|
|
145
|
+
data: Array<{
|
|
146
|
+
b64_json?: string;
|
|
147
|
+
url?: string;
|
|
148
|
+
}>;
|
|
149
|
+
[k: string]: unknown;
|
|
150
|
+
}
|
|
151
|
+
interface SpeechRequest {
|
|
152
|
+
model: string;
|
|
153
|
+
/** 最多 5,000 字 */
|
|
154
|
+
input: string;
|
|
155
|
+
/** 系統聲音名,例如 `Chinese (Mandarin)_Warm_Girl`、`female-shaonv`;未帶用平台預設 */
|
|
156
|
+
voice?: string;
|
|
157
|
+
[k: string]: unknown;
|
|
158
|
+
}
|
|
159
|
+
interface SpeechResponse {
|
|
160
|
+
model: string;
|
|
161
|
+
provider: string;
|
|
162
|
+
/** 上游 CDN 的限時網址:要長期保存請自行下載 */
|
|
163
|
+
audio_url: string;
|
|
164
|
+
[k: string]: unknown;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface AcademyAI {
|
|
168
|
+
chat: {
|
|
169
|
+
completions: {
|
|
170
|
+
create(body: ChatCompletionRequest & {
|
|
171
|
+
stream?: false;
|
|
172
|
+
}): Promise<ChatCompletion>;
|
|
173
|
+
create(body: ChatCompletionRequest & {
|
|
174
|
+
stream: true;
|
|
175
|
+
}): Promise<AsyncIterable<ChatCompletionChunk>>;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
images: {
|
|
179
|
+
generate(body: ImageGenerateRequest): Promise<ImageGenerateResponse>;
|
|
180
|
+
};
|
|
181
|
+
audio: {
|
|
182
|
+
speech: {
|
|
183
|
+
create(body: SpeechRequest): Promise<SpeechResponse>;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** 查詢參數:與研究所 MCP 的開放資料工具相同(中文縣市名、萬元/坪、坪),陣列以逗號送出 */
|
|
189
|
+
type OdQuery = Record<string, string | number | boolean | Array<string | number> | undefined | null>;
|
|
190
|
+
type OdResult = Record<string, unknown>;
|
|
191
|
+
interface AcademyOD {
|
|
192
|
+
lvr: {
|
|
193
|
+
/** 實價登錄逐筆成交(對應 MCP `search_lvr_deals`):city 必填,district、keyword、價格面積屋齡篩選、page、limit… */
|
|
194
|
+
deals(q: OdQuery): Promise<OdResult>;
|
|
195
|
+
/** 區域行情統計(`get_lvr_market_context`):樣本數、單價與總價中位數、p25/p75、逐月趨勢 */
|
|
196
|
+
marketContext(q: OdQuery): Promise<OdResult>;
|
|
197
|
+
};
|
|
198
|
+
nearby: {
|
|
199
|
+
/** 座標或地址周邊近期成交(`get_nearby` 的成交) */
|
|
200
|
+
deals(q: OdQuery): Promise<OdResult>;
|
|
201
|
+
/** 周邊生活機能與嫌惡設施(`get_nearby`;include 可選 amenities、nimby) */
|
|
202
|
+
amenities(q: OdQuery): Promise<OdResult>;
|
|
203
|
+
};
|
|
204
|
+
address: {
|
|
205
|
+
/** 地址正規化、地址與座標互轉(`convert_location`) */
|
|
206
|
+
convert(q: OdQuery): Promise<OdResult>;
|
|
207
|
+
};
|
|
208
|
+
area: {
|
|
209
|
+
/** 人口、年齡結構、所得、房貸利率(`get_area_profile`) */
|
|
210
|
+
profile(q: OdQuery): Promise<OdResult>;
|
|
211
|
+
};
|
|
212
|
+
/** 五類災害潛勢(`get_property_risk`);查無不等於無風險 */
|
|
213
|
+
hazards(q: OdQuery): Promise<OdResult>;
|
|
214
|
+
/** 市場快訊日報/週報/月報(`get_market_brief`) */
|
|
215
|
+
marketBriefs(q?: OdQuery): Promise<OdResult>;
|
|
216
|
+
/** 直接以資源路徑查詢(新資源上線、SDK 還沒加方法時用) */
|
|
217
|
+
get(resource: string, q?: OdQuery): Promise<OdResult>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** SDK 版本(送審自檢與瀏覽器握手會回報);與 package.json 同步 */
|
|
221
|
+
declare const SDK_VERSION = "1.0.0";
|
|
222
|
+
/** 身分 JWT 與閘道協定的版本:SDK 主版號跟著它走(spec/16 § 7.1) */
|
|
223
|
+
declare const CONTRACT_VERSION = 1;
|
|
224
|
+
|
|
225
|
+
export { type AcademyMe as A, CONTRACT_VERSION as C, type ImageGenerateRequest as I, type MembershipTier as M, type OdQuery as O, SDK_VERSION as S, type AcademyAI as a, type AcademyOD as b, type AcademyContext as c, type AcademyEntitlement as d, AcademyError as e, type AcademyErrorCode as f, type AcademyJobInfo as g, type AcademyQuota as h, type AcademyUser as i, type AppEntitlementKind as j, type AppIdentityEnv as k, type AppJobStatus as l, type ChatCompletion as m, type ChatCompletionChunk as n, type ChatCompletionRequest as o, type ChatMessage as p, type ChatRole as q, type ImageGenerateResponse as r, type OdResult as s, type SpeechRequest as t, type SpeechResponse as u };
|
|
@@ -0,0 +1,225 @@
|
|
|
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' | '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
|
+
/** 掛在 `req.academy` 的內容;沒有身分(公開路徑、尚未啟用的正式環境)時整個是 null */
|
|
49
|
+
interface AcademyContext {
|
|
50
|
+
user: AcademyUser;
|
|
51
|
+
entitlement: AcademyEntitlement;
|
|
52
|
+
env: AppIdentityEnv;
|
|
53
|
+
/** 原始身分 JWT(呼叫平台閘道時轉送;5 分鐘效期) */
|
|
54
|
+
identityToken: string | null;
|
|
55
|
+
/** 開發模式的假身分 */
|
|
56
|
+
dev: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface AcademyQuota {
|
|
59
|
+
tier: MembershipTier | null;
|
|
60
|
+
points_remaining: number;
|
|
61
|
+
points_held: number;
|
|
62
|
+
reset_at: string;
|
|
63
|
+
/** 只在測試環境與開發模式回傳 */
|
|
64
|
+
dev_quota_remaining?: number;
|
|
65
|
+
}
|
|
66
|
+
interface AcademyMe {
|
|
67
|
+
user: AcademyUser;
|
|
68
|
+
ent: AcademyEntitlement;
|
|
69
|
+
env: AppIdentityEnv;
|
|
70
|
+
quota: AcademyQuota;
|
|
71
|
+
}
|
|
72
|
+
type AppJobStatus = 'OPEN' | 'CLOSED' | 'EXPIRED' | (string & {});
|
|
73
|
+
interface AcademyJobInfo {
|
|
74
|
+
job_uuid: string;
|
|
75
|
+
status: AppJobStatus;
|
|
76
|
+
purpose: string;
|
|
77
|
+
max_points: number;
|
|
78
|
+
used_points: number;
|
|
79
|
+
expires_at: string;
|
|
80
|
+
closed_at: string | null;
|
|
81
|
+
}
|
|
82
|
+
type ChatRole = 'system' | 'user' | 'assistant' | 'tool' | (string & {});
|
|
83
|
+
interface ChatMessage {
|
|
84
|
+
role: ChatRole;
|
|
85
|
+
content: string | Array<{
|
|
86
|
+
type: string;
|
|
87
|
+
[k: string]: unknown;
|
|
88
|
+
}> | null;
|
|
89
|
+
[k: string]: unknown;
|
|
90
|
+
}
|
|
91
|
+
interface ChatCompletionRequest {
|
|
92
|
+
/** 平台別名:`fast`、`smart`…(不是模型名) */
|
|
93
|
+
model: string;
|
|
94
|
+
messages: ChatMessage[];
|
|
95
|
+
max_tokens?: number;
|
|
96
|
+
max_completion_tokens?: number;
|
|
97
|
+
temperature?: number;
|
|
98
|
+
stream?: boolean;
|
|
99
|
+
tools?: unknown[];
|
|
100
|
+
[k: string]: unknown;
|
|
101
|
+
}
|
|
102
|
+
interface ChatCompletion {
|
|
103
|
+
id?: string;
|
|
104
|
+
model?: string;
|
|
105
|
+
choices: Array<{
|
|
106
|
+
index: number;
|
|
107
|
+
message: {
|
|
108
|
+
role: string;
|
|
109
|
+
content: string | null;
|
|
110
|
+
[k: string]: unknown;
|
|
111
|
+
};
|
|
112
|
+
finish_reason?: string | null;
|
|
113
|
+
}>;
|
|
114
|
+
usage?: {
|
|
115
|
+
prompt_tokens?: number;
|
|
116
|
+
completion_tokens?: number;
|
|
117
|
+
total_tokens?: number;
|
|
118
|
+
[k: string]: unknown;
|
|
119
|
+
};
|
|
120
|
+
[k: string]: unknown;
|
|
121
|
+
}
|
|
122
|
+
interface ChatCompletionChunk {
|
|
123
|
+
id?: string;
|
|
124
|
+
choices: Array<{
|
|
125
|
+
index: number;
|
|
126
|
+
delta: {
|
|
127
|
+
role?: string;
|
|
128
|
+
content?: string | null;
|
|
129
|
+
[k: string]: unknown;
|
|
130
|
+
};
|
|
131
|
+
finish_reason?: string | null;
|
|
132
|
+
}>;
|
|
133
|
+
usage?: Record<string, unknown>;
|
|
134
|
+
[k: string]: unknown;
|
|
135
|
+
}
|
|
136
|
+
interface ImageGenerateRequest {
|
|
137
|
+
model: string;
|
|
138
|
+
prompt: string;
|
|
139
|
+
/** 一次最多 4 張 */
|
|
140
|
+
n?: number;
|
|
141
|
+
size?: string;
|
|
142
|
+
[k: string]: unknown;
|
|
143
|
+
}
|
|
144
|
+
interface ImageGenerateResponse {
|
|
145
|
+
data: Array<{
|
|
146
|
+
b64_json?: string;
|
|
147
|
+
url?: string;
|
|
148
|
+
}>;
|
|
149
|
+
[k: string]: unknown;
|
|
150
|
+
}
|
|
151
|
+
interface SpeechRequest {
|
|
152
|
+
model: string;
|
|
153
|
+
/** 最多 5,000 字 */
|
|
154
|
+
input: string;
|
|
155
|
+
/** 系統聲音名,例如 `Chinese (Mandarin)_Warm_Girl`、`female-shaonv`;未帶用平台預設 */
|
|
156
|
+
voice?: string;
|
|
157
|
+
[k: string]: unknown;
|
|
158
|
+
}
|
|
159
|
+
interface SpeechResponse {
|
|
160
|
+
model: string;
|
|
161
|
+
provider: string;
|
|
162
|
+
/** 上游 CDN 的限時網址:要長期保存請自行下載 */
|
|
163
|
+
audio_url: string;
|
|
164
|
+
[k: string]: unknown;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface AcademyAI {
|
|
168
|
+
chat: {
|
|
169
|
+
completions: {
|
|
170
|
+
create(body: ChatCompletionRequest & {
|
|
171
|
+
stream?: false;
|
|
172
|
+
}): Promise<ChatCompletion>;
|
|
173
|
+
create(body: ChatCompletionRequest & {
|
|
174
|
+
stream: true;
|
|
175
|
+
}): Promise<AsyncIterable<ChatCompletionChunk>>;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
images: {
|
|
179
|
+
generate(body: ImageGenerateRequest): Promise<ImageGenerateResponse>;
|
|
180
|
+
};
|
|
181
|
+
audio: {
|
|
182
|
+
speech: {
|
|
183
|
+
create(body: SpeechRequest): Promise<SpeechResponse>;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** 查詢參數:與研究所 MCP 的開放資料工具相同(中文縣市名、萬元/坪、坪),陣列以逗號送出 */
|
|
189
|
+
type OdQuery = Record<string, string | number | boolean | Array<string | number> | undefined | null>;
|
|
190
|
+
type OdResult = Record<string, unknown>;
|
|
191
|
+
interface AcademyOD {
|
|
192
|
+
lvr: {
|
|
193
|
+
/** 實價登錄逐筆成交(對應 MCP `search_lvr_deals`):city 必填,district、keyword、價格面積屋齡篩選、page、limit… */
|
|
194
|
+
deals(q: OdQuery): Promise<OdResult>;
|
|
195
|
+
/** 區域行情統計(`get_lvr_market_context`):樣本數、單價與總價中位數、p25/p75、逐月趨勢 */
|
|
196
|
+
marketContext(q: OdQuery): Promise<OdResult>;
|
|
197
|
+
};
|
|
198
|
+
nearby: {
|
|
199
|
+
/** 座標或地址周邊近期成交(`get_nearby` 的成交) */
|
|
200
|
+
deals(q: OdQuery): Promise<OdResult>;
|
|
201
|
+
/** 周邊生活機能與嫌惡設施(`get_nearby`;include 可選 amenities、nimby) */
|
|
202
|
+
amenities(q: OdQuery): Promise<OdResult>;
|
|
203
|
+
};
|
|
204
|
+
address: {
|
|
205
|
+
/** 地址正規化、地址與座標互轉(`convert_location`) */
|
|
206
|
+
convert(q: OdQuery): Promise<OdResult>;
|
|
207
|
+
};
|
|
208
|
+
area: {
|
|
209
|
+
/** 人口、年齡結構、所得、房貸利率(`get_area_profile`) */
|
|
210
|
+
profile(q: OdQuery): Promise<OdResult>;
|
|
211
|
+
};
|
|
212
|
+
/** 五類災害潛勢(`get_property_risk`);查無不等於無風險 */
|
|
213
|
+
hazards(q: OdQuery): Promise<OdResult>;
|
|
214
|
+
/** 市場快訊日報/週報/月報(`get_market_brief`) */
|
|
215
|
+
marketBriefs(q?: OdQuery): Promise<OdResult>;
|
|
216
|
+
/** 直接以資源路徑查詢(新資源上線、SDK 還沒加方法時用) */
|
|
217
|
+
get(resource: string, q?: OdQuery): Promise<OdResult>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** SDK 版本(送審自檢與瀏覽器握手會回報);與 package.json 同步 */
|
|
221
|
+
declare const SDK_VERSION = "1.0.0";
|
|
222
|
+
/** 身分 JWT 與閘道協定的版本:SDK 主版號跟著它走(spec/16 § 7.1) */
|
|
223
|
+
declare const CONTRACT_VERSION = 1;
|
|
224
|
+
|
|
225
|
+
export { type AcademyMe as A, CONTRACT_VERSION as C, type ImageGenerateRequest as I, type MembershipTier as M, type OdQuery as O, SDK_VERSION as S, type AcademyAI as a, type AcademyOD as b, type AcademyContext as c, type AcademyEntitlement as d, AcademyError as e, type AcademyErrorCode as f, type AcademyJobInfo as g, type AcademyQuota as h, type AcademyUser as i, type AppEntitlementKind as j, type AppIdentityEnv as k, type AppJobStatus as l, type ChatCompletion as m, type ChatCompletionChunk as n, type ChatCompletionRequest as o, type ChatMessage as p, type ChatRole as q, type ImageGenerateResponse as r, type OdResult as s, type SpeechRequest as t, type SpeechResponse as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentgo-tw/app-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "AI 研究所(agentgo.tw)上架 App 的平台 SDK:會員身分、平台 AI、房市資料、工作憑證與點數查詢",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.cjs",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/index.d.cts",
|
|
21
|
+
"default": "./dist/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"./browser": {
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./dist/browser.d.ts",
|
|
27
|
+
"default": "./dist/browser.js"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./dist/browser.d.cts",
|
|
31
|
+
"default": "./dist/browser.cjs"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"sideEffects": false,
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"test": "npm run build && node --test test/*.test.mjs"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^20.19.43",
|
|
50
|
+
"tsup": "^8.5.1",
|
|
51
|
+
"typescript": "^5.9.3"
|
|
52
|
+
}
|
|
53
|
+
}
|