@kevisual/cli 0.1.5 → 0.1.6
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/dist/assistant-opencode.js +273 -148
- package/dist/assistant-server.js +263 -159
- package/dist/assistant.js +115 -63
- package/dist/envision.js +1482 -1368
- package/package.json +4 -5
package/dist/assistant.js
CHANGED
|
@@ -35026,23 +35026,17 @@ var getEnvToken = () => {
|
|
|
35026
35026
|
return envTokne;
|
|
35027
35027
|
};
|
|
35028
35028
|
|
|
35029
|
-
// ../node_modules/.pnpm/@kevisual+query@0.0.
|
|
35029
|
+
// ../node_modules/.pnpm/@kevisual+query@0.0.49/node_modules/@kevisual/query/dist/query-browser.js
|
|
35030
35030
|
var isTextForContentType = (contentType) => {
|
|
35031
35031
|
if (!contentType)
|
|
35032
35032
|
return false;
|
|
35033
|
-
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
|
|
35033
|
+
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md", "json"];
|
|
35034
35034
|
return textTypes.some((type) => contentType.includes(type));
|
|
35035
35035
|
};
|
|
35036
35036
|
var adapter = async (opts = {}, overloadOpts) => {
|
|
35037
35037
|
const controller = new AbortController;
|
|
35038
35038
|
const signal = controller.signal;
|
|
35039
35039
|
const isPostFile = opts.isPostFile || false;
|
|
35040
|
-
let responseType = opts.responseType || "json";
|
|
35041
|
-
if (opts.isBlob) {
|
|
35042
|
-
responseType = "blob";
|
|
35043
|
-
} else if (opts.isText) {
|
|
35044
|
-
responseType = "text";
|
|
35045
|
-
}
|
|
35046
35040
|
const timeout = opts.timeout || 60000 * 3;
|
|
35047
35041
|
const timer = setTimeout(() => {
|
|
35048
35042
|
controller.abort();
|
|
@@ -35101,21 +35095,31 @@ var adapter = async (opts = {}, overloadOpts) => {
|
|
|
35101
35095
|
headers
|
|
35102
35096
|
}).then(async (response) => {
|
|
35103
35097
|
const contentType = response.headers.get("Content-Type");
|
|
35104
|
-
if (responseType === "blob") {
|
|
35105
|
-
return await response.blob();
|
|
35106
|
-
}
|
|
35107
|
-
const isText = responseType === "text";
|
|
35108
35098
|
const isJson = contentType && contentType.includes("application/json");
|
|
35109
|
-
|
|
35110
|
-
|
|
35099
|
+
const isSuccess = response.ok;
|
|
35100
|
+
if (isJson) {
|
|
35101
|
+
const json = await response.json();
|
|
35102
|
+
if (json?.code) {
|
|
35103
|
+
return json;
|
|
35104
|
+
}
|
|
35105
|
+
return {
|
|
35106
|
+
code: isSuccess ? 200 : response.status,
|
|
35107
|
+
status: response.status,
|
|
35108
|
+
data: json
|
|
35109
|
+
};
|
|
35111
35110
|
} else if (isTextForContentType(contentType)) {
|
|
35112
35111
|
return {
|
|
35113
|
-
code: response.status,
|
|
35112
|
+
code: isSuccess ? 200 : response.status,
|
|
35114
35113
|
status: response.status,
|
|
35115
35114
|
data: await response.text()
|
|
35116
35115
|
};
|
|
35117
35116
|
} else {
|
|
35118
|
-
return
|
|
35117
|
+
return {
|
|
35118
|
+
code: isSuccess ? 200 : response.status,
|
|
35119
|
+
status: response.status,
|
|
35120
|
+
data: "非文本非JSON响应, 请手动处理response。",
|
|
35121
|
+
response
|
|
35122
|
+
};
|
|
35119
35123
|
}
|
|
35120
35124
|
}).catch((err) => {
|
|
35121
35125
|
if (err.name === "AbortError") {
|
|
@@ -35135,16 +35139,14 @@ var adapter = async (opts = {}, overloadOpts) => {
|
|
|
35135
35139
|
var wrapperError = ({ code, message }) => {
|
|
35136
35140
|
const result = {
|
|
35137
35141
|
code: code || 500,
|
|
35138
|
-
|
|
35139
|
-
message: message || "api request error",
|
|
35140
|
-
showError: (fn) => {},
|
|
35141
|
-
noMsg: true
|
|
35142
|
+
message: message || "请求错误"
|
|
35142
35143
|
};
|
|
35143
35144
|
return result;
|
|
35144
35145
|
};
|
|
35145
35146
|
|
|
35146
35147
|
class Query {
|
|
35147
35148
|
adapter;
|
|
35149
|
+
baseURL;
|
|
35148
35150
|
url;
|
|
35149
35151
|
beforeRequest;
|
|
35150
35152
|
afterResponse;
|
|
@@ -35152,11 +35154,20 @@ class Query {
|
|
|
35152
35154
|
timeout;
|
|
35153
35155
|
stop;
|
|
35154
35156
|
qws;
|
|
35155
|
-
|
|
35157
|
+
tokenName;
|
|
35158
|
+
storage;
|
|
35159
|
+
token;
|
|
35156
35160
|
constructor(opts) {
|
|
35157
35161
|
this.adapter = opts?.adapter || adapter;
|
|
35162
|
+
this.tokenName = opts?.tokenName || "token";
|
|
35163
|
+
this.storage = opts?.storage || globalThis?.localStorage;
|
|
35158
35164
|
const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
|
|
35159
35165
|
this.url = opts?.url || defaultURL;
|
|
35166
|
+
if (this.url.startsWith("http")) {
|
|
35167
|
+
const urlObj = new URL(this.url);
|
|
35168
|
+
this.baseURL = urlObj.origin;
|
|
35169
|
+
}
|
|
35170
|
+
this.baseURL = opts?.baseURL || this.baseURL;
|
|
35160
35171
|
this.headers = opts?.headers || {
|
|
35161
35172
|
"Content-Type": "application/json"
|
|
35162
35173
|
};
|
|
@@ -35165,7 +35176,7 @@ class Query {
|
|
|
35165
35176
|
this.beforeRequest = opts.beforeRequest;
|
|
35166
35177
|
} else {
|
|
35167
35178
|
this.beforeRequest = async (opts2) => {
|
|
35168
|
-
const token =
|
|
35179
|
+
const token = this.token || this.storage?.getItem?.(this.tokenName);
|
|
35169
35180
|
if (token) {
|
|
35170
35181
|
opts2.headers = {
|
|
35171
35182
|
...opts2.headers,
|
|
@@ -35187,7 +35198,6 @@ class Query {
|
|
|
35187
35198
|
}
|
|
35188
35199
|
async post(body, options) {
|
|
35189
35200
|
const url = options?.url || this.url;
|
|
35190
|
-
console.log("query post", url, body, options);
|
|
35191
35201
|
const { headers, adapter: adapter2, beforeRequest, afterResponse, timeout, ...rest } = options || {};
|
|
35192
35202
|
const _headers = { ...this.headers, ...headers };
|
|
35193
35203
|
const _adapter = adapter2 || this.adapter;
|
|
@@ -35201,13 +35211,20 @@ class Query {
|
|
|
35201
35211
|
timeout: _timeout,
|
|
35202
35212
|
...rest
|
|
35203
35213
|
};
|
|
35214
|
+
const isStartsWithHttp = req.url.startsWith("http");
|
|
35215
|
+
if (!isStartsWithHttp) {
|
|
35216
|
+
if (this.baseURL) {
|
|
35217
|
+
const baseURL = new URL(this.baseURL || globalThis?.location?.origin).origin;
|
|
35218
|
+
req.url = baseURL + req.url;
|
|
35219
|
+
}
|
|
35220
|
+
}
|
|
35204
35221
|
try {
|
|
35205
35222
|
if (_beforeRequest) {
|
|
35206
35223
|
const res = await _beforeRequest(req);
|
|
35207
35224
|
if (res === false) {
|
|
35208
35225
|
return wrapperError({
|
|
35209
35226
|
code: 500,
|
|
35210
|
-
message: "
|
|
35227
|
+
message: "请求取消",
|
|
35211
35228
|
req
|
|
35212
35229
|
});
|
|
35213
35230
|
}
|
|
@@ -35216,13 +35233,13 @@ class Query {
|
|
|
35216
35233
|
console.error("request beforeFn error", e, req);
|
|
35217
35234
|
return wrapperError({
|
|
35218
35235
|
code: 500,
|
|
35219
|
-
message: "
|
|
35236
|
+
message: "请求在请求前处理时发生错误",
|
|
35220
35237
|
req
|
|
35221
35238
|
});
|
|
35222
35239
|
}
|
|
35223
35240
|
if (this.stop && !options?.noStop) {
|
|
35224
35241
|
const that = this;
|
|
35225
|
-
await new Promise((resolve) => {
|
|
35242
|
+
const res = await new Promise((resolve) => {
|
|
35226
35243
|
let timer = 0;
|
|
35227
35244
|
const detect = setInterval(() => {
|
|
35228
35245
|
if (!that.stop) {
|
|
@@ -35230,11 +35247,20 @@ class Query {
|
|
|
35230
35247
|
resolve(true);
|
|
35231
35248
|
}
|
|
35232
35249
|
timer++;
|
|
35233
|
-
if (timer >
|
|
35234
|
-
console.error("
|
|
35250
|
+
if (timer > 5) {
|
|
35251
|
+
console.error("等待请求失败:", req.url, timer);
|
|
35252
|
+
clearInterval(detect);
|
|
35253
|
+
resolve(false);
|
|
35235
35254
|
}
|
|
35236
35255
|
}, 1000);
|
|
35237
35256
|
});
|
|
35257
|
+
if (!res) {
|
|
35258
|
+
return wrapperError({
|
|
35259
|
+
code: 500,
|
|
35260
|
+
message: "请求取消,可能是因为用户未登录或者token过期",
|
|
35261
|
+
req
|
|
35262
|
+
});
|
|
35263
|
+
}
|
|
35238
35264
|
}
|
|
35239
35265
|
return _adapter(req).then(async (res) => {
|
|
35240
35266
|
try {
|
|
@@ -35247,10 +35273,10 @@ class Query {
|
|
|
35247
35273
|
}
|
|
35248
35274
|
return res;
|
|
35249
35275
|
} catch (e) {
|
|
35250
|
-
console.error("
|
|
35276
|
+
console.error("请求在响应后处理时发生错误", e, req);
|
|
35251
35277
|
return wrapperError({
|
|
35252
35278
|
code: 500,
|
|
35253
|
-
message: "
|
|
35279
|
+
message: "请求在响应后处理时发生错误",
|
|
35254
35280
|
req
|
|
35255
35281
|
});
|
|
35256
35282
|
}
|
|
@@ -35288,7 +35314,7 @@ class Query {
|
|
|
35288
35314
|
}
|
|
35289
35315
|
}
|
|
35290
35316
|
|
|
35291
|
-
// ../node_modules/.pnpm/@kevisual+router@0.0.
|
|
35317
|
+
// ../node_modules/.pnpm/@kevisual+router@0.0.80/node_modules/@kevisual/router/dist/router-browser.js
|
|
35292
35318
|
var __create3 = Object.create;
|
|
35293
35319
|
var __getProtoOf3 = Object.getPrototypeOf;
|
|
35294
35320
|
var __defProp3 = Object.defineProperty;
|
|
@@ -49295,7 +49321,7 @@ function filter(data, query) {
|
|
|
49295
49321
|
return executor.execute(ast, data);
|
|
49296
49322
|
}
|
|
49297
49323
|
|
|
49298
|
-
// ../node_modules/.pnpm/@kevisual+api@0.0.
|
|
49324
|
+
// ../node_modules/.pnpm/@kevisual+api@0.0.52_@types+react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-proxy/router-api-proxy.ts
|
|
49299
49325
|
var initApi = async (opts) => {
|
|
49300
49326
|
const router = opts?.router;
|
|
49301
49327
|
const item = opts?.item;
|
|
@@ -49332,7 +49358,7 @@ var initApi = async (opts) => {
|
|
|
49332
49358
|
metadata
|
|
49333
49359
|
}).define(async (ctx) => {
|
|
49334
49360
|
const msg = { ...ctx.query };
|
|
49335
|
-
if (msg.token === undefined && token !== undefined) {
|
|
49361
|
+
if (msg.token === undefined && token !== undefined && !_isBrowser) {
|
|
49336
49362
|
msg.token = token;
|
|
49337
49363
|
}
|
|
49338
49364
|
const res2 = await query.post({ path: r.path, key: r.key, ...msg });
|
|
@@ -63438,23 +63464,17 @@ class AssistantApp extends Manager2 {
|
|
|
63438
63464
|
}
|
|
63439
63465
|
}
|
|
63440
63466
|
}
|
|
63441
|
-
// ../node_modules/.pnpm/@kevisual+query@0.0.
|
|
63467
|
+
// ../node_modules/.pnpm/@kevisual+query@0.0.49/node_modules/@kevisual/query/dist/query.js
|
|
63442
63468
|
var isTextForContentType2 = (contentType) => {
|
|
63443
63469
|
if (!contentType)
|
|
63444
63470
|
return false;
|
|
63445
|
-
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
|
|
63471
|
+
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md", "json"];
|
|
63446
63472
|
return textTypes.some((type) => contentType.includes(type));
|
|
63447
63473
|
};
|
|
63448
63474
|
var adapter2 = async (opts = {}, overloadOpts) => {
|
|
63449
63475
|
const controller = new AbortController;
|
|
63450
63476
|
const signal = controller.signal;
|
|
63451
63477
|
const isPostFile = opts.isPostFile || false;
|
|
63452
|
-
let responseType = opts.responseType || "json";
|
|
63453
|
-
if (opts.isBlob) {
|
|
63454
|
-
responseType = "blob";
|
|
63455
|
-
} else if (opts.isText) {
|
|
63456
|
-
responseType = "text";
|
|
63457
|
-
}
|
|
63458
63478
|
const timeout = opts.timeout || 60000 * 3;
|
|
63459
63479
|
const timer = setTimeout(() => {
|
|
63460
63480
|
controller.abort();
|
|
@@ -63513,21 +63533,31 @@ var adapter2 = async (opts = {}, overloadOpts) => {
|
|
|
63513
63533
|
headers
|
|
63514
63534
|
}).then(async (response) => {
|
|
63515
63535
|
const contentType = response.headers.get("Content-Type");
|
|
63516
|
-
if (responseType === "blob") {
|
|
63517
|
-
return await response.blob();
|
|
63518
|
-
}
|
|
63519
|
-
const isText = responseType === "text";
|
|
63520
63536
|
const isJson = contentType && contentType.includes("application/json");
|
|
63521
|
-
|
|
63522
|
-
|
|
63537
|
+
const isSuccess = response.ok;
|
|
63538
|
+
if (isJson) {
|
|
63539
|
+
const json3 = await response.json();
|
|
63540
|
+
if (json3?.code) {
|
|
63541
|
+
return json3;
|
|
63542
|
+
}
|
|
63543
|
+
return {
|
|
63544
|
+
code: isSuccess ? 200 : response.status,
|
|
63545
|
+
status: response.status,
|
|
63546
|
+
data: json3
|
|
63547
|
+
};
|
|
63523
63548
|
} else if (isTextForContentType2(contentType)) {
|
|
63524
63549
|
return {
|
|
63525
|
-
code: response.status,
|
|
63550
|
+
code: isSuccess ? 200 : response.status,
|
|
63526
63551
|
status: response.status,
|
|
63527
63552
|
data: await response.text()
|
|
63528
63553
|
};
|
|
63529
63554
|
} else {
|
|
63530
|
-
return
|
|
63555
|
+
return {
|
|
63556
|
+
code: isSuccess ? 200 : response.status,
|
|
63557
|
+
status: response.status,
|
|
63558
|
+
data: "非文本非JSON响应, 请手动处理response。",
|
|
63559
|
+
response
|
|
63560
|
+
};
|
|
63531
63561
|
}
|
|
63532
63562
|
}).catch((err) => {
|
|
63533
63563
|
if (err.name === "AbortError") {
|
|
@@ -63547,16 +63577,14 @@ var adapter2 = async (opts = {}, overloadOpts) => {
|
|
|
63547
63577
|
var wrapperError2 = ({ code, message }) => {
|
|
63548
63578
|
const result = {
|
|
63549
63579
|
code: code || 500,
|
|
63550
|
-
|
|
63551
|
-
message: message || "api request error",
|
|
63552
|
-
showError: (fn) => {},
|
|
63553
|
-
noMsg: true
|
|
63580
|
+
message: message || "请求错误"
|
|
63554
63581
|
};
|
|
63555
63582
|
return result;
|
|
63556
63583
|
};
|
|
63557
63584
|
|
|
63558
63585
|
class Query2 {
|
|
63559
63586
|
adapter;
|
|
63587
|
+
baseURL;
|
|
63560
63588
|
url;
|
|
63561
63589
|
beforeRequest;
|
|
63562
63590
|
afterResponse;
|
|
@@ -63564,11 +63592,20 @@ class Query2 {
|
|
|
63564
63592
|
timeout;
|
|
63565
63593
|
stop;
|
|
63566
63594
|
qws;
|
|
63567
|
-
|
|
63595
|
+
tokenName;
|
|
63596
|
+
storage;
|
|
63597
|
+
token;
|
|
63568
63598
|
constructor(opts) {
|
|
63569
63599
|
this.adapter = opts?.adapter || adapter2;
|
|
63600
|
+
this.tokenName = opts?.tokenName || "token";
|
|
63601
|
+
this.storage = opts?.storage || globalThis?.localStorage;
|
|
63570
63602
|
const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
|
|
63571
63603
|
this.url = opts?.url || defaultURL;
|
|
63604
|
+
if (this.url.startsWith("http")) {
|
|
63605
|
+
const urlObj = new URL(this.url);
|
|
63606
|
+
this.baseURL = urlObj.origin;
|
|
63607
|
+
}
|
|
63608
|
+
this.baseURL = opts?.baseURL || this.baseURL;
|
|
63572
63609
|
this.headers = opts?.headers || {
|
|
63573
63610
|
"Content-Type": "application/json"
|
|
63574
63611
|
};
|
|
@@ -63577,7 +63614,7 @@ class Query2 {
|
|
|
63577
63614
|
this.beforeRequest = opts.beforeRequest;
|
|
63578
63615
|
} else {
|
|
63579
63616
|
this.beforeRequest = async (opts2) => {
|
|
63580
|
-
const token =
|
|
63617
|
+
const token = this.token || this.storage?.getItem?.(this.tokenName);
|
|
63581
63618
|
if (token) {
|
|
63582
63619
|
opts2.headers = {
|
|
63583
63620
|
...opts2.headers,
|
|
@@ -63599,7 +63636,6 @@ class Query2 {
|
|
|
63599
63636
|
}
|
|
63600
63637
|
async post(body, options) {
|
|
63601
63638
|
const url3 = options?.url || this.url;
|
|
63602
|
-
console.log("query post", url3, body, options);
|
|
63603
63639
|
const { headers, adapter: adapter22, beforeRequest, afterResponse, timeout, ...rest } = options || {};
|
|
63604
63640
|
const _headers = { ...this.headers, ...headers };
|
|
63605
63641
|
const _adapter = adapter22 || this.adapter;
|
|
@@ -63613,13 +63649,20 @@ class Query2 {
|
|
|
63613
63649
|
timeout: _timeout,
|
|
63614
63650
|
...rest
|
|
63615
63651
|
};
|
|
63652
|
+
const isStartsWithHttp = req.url.startsWith("http");
|
|
63653
|
+
if (!isStartsWithHttp) {
|
|
63654
|
+
if (this.baseURL) {
|
|
63655
|
+
const baseURL = new URL(this.baseURL || globalThis?.location?.origin).origin;
|
|
63656
|
+
req.url = baseURL + req.url;
|
|
63657
|
+
}
|
|
63658
|
+
}
|
|
63616
63659
|
try {
|
|
63617
63660
|
if (_beforeRequest) {
|
|
63618
63661
|
const res = await _beforeRequest(req);
|
|
63619
63662
|
if (res === false) {
|
|
63620
63663
|
return wrapperError2({
|
|
63621
63664
|
code: 500,
|
|
63622
|
-
message: "
|
|
63665
|
+
message: "请求取消",
|
|
63623
63666
|
req
|
|
63624
63667
|
});
|
|
63625
63668
|
}
|
|
@@ -63628,13 +63671,13 @@ class Query2 {
|
|
|
63628
63671
|
console.error("request beforeFn error", e, req);
|
|
63629
63672
|
return wrapperError2({
|
|
63630
63673
|
code: 500,
|
|
63631
|
-
message: "
|
|
63674
|
+
message: "请求在请求前处理时发生错误",
|
|
63632
63675
|
req
|
|
63633
63676
|
});
|
|
63634
63677
|
}
|
|
63635
63678
|
if (this.stop && !options?.noStop) {
|
|
63636
63679
|
const that = this;
|
|
63637
|
-
await new Promise((resolve) => {
|
|
63680
|
+
const res = await new Promise((resolve) => {
|
|
63638
63681
|
let timer = 0;
|
|
63639
63682
|
const detect = setInterval(() => {
|
|
63640
63683
|
if (!that.stop) {
|
|
@@ -63642,11 +63685,20 @@ class Query2 {
|
|
|
63642
63685
|
resolve(true);
|
|
63643
63686
|
}
|
|
63644
63687
|
timer++;
|
|
63645
|
-
if (timer >
|
|
63646
|
-
console.error("
|
|
63688
|
+
if (timer > 5) {
|
|
63689
|
+
console.error("等待请求失败:", req.url, timer);
|
|
63690
|
+
clearInterval(detect);
|
|
63691
|
+
resolve(false);
|
|
63647
63692
|
}
|
|
63648
63693
|
}, 1000);
|
|
63649
63694
|
});
|
|
63695
|
+
if (!res) {
|
|
63696
|
+
return wrapperError2({
|
|
63697
|
+
code: 500,
|
|
63698
|
+
message: "请求取消,可能是因为用户未登录或者token过期",
|
|
63699
|
+
req
|
|
63700
|
+
});
|
|
63701
|
+
}
|
|
63650
63702
|
}
|
|
63651
63703
|
return _adapter(req).then(async (res) => {
|
|
63652
63704
|
try {
|
|
@@ -63659,10 +63711,10 @@ class Query2 {
|
|
|
63659
63711
|
}
|
|
63660
63712
|
return res;
|
|
63661
63713
|
} catch (e) {
|
|
63662
|
-
console.error("
|
|
63714
|
+
console.error("请求在响应后处理时发生错误", e, req);
|
|
63663
63715
|
return wrapperError2({
|
|
63664
63716
|
code: 500,
|
|
63665
|
-
message: "
|
|
63717
|
+
message: "请求在响应后处理时发生错误",
|
|
63666
63718
|
req
|
|
63667
63719
|
});
|
|
63668
63720
|
}
|