@doubao-dev/cli 0.0.14 → 0.0.15

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 (91) hide show
  1. package/bin/run.js +1 -1
  2. package/dist/1664.js +60 -0
  3. package/dist/180.js +1 -0
  4. package/dist/{bin/win32-x64/security_tasm_codec.exe → 1966.js} +0 -0
  5. package/dist/1966.js.LICENSE.txt +119 -0
  6. package/dist/2585.js +2 -0
  7. package/dist/318.js +1 -0
  8. package/dist/3551.js +1 -0
  9. package/dist/3997.js +2 -0
  10. package/dist/4880.js +1 -0
  11. package/dist/5418.js +3 -0
  12. package/dist/5732.js +1 -0
  13. package/dist/7410.js +2 -0
  14. package/dist/7410.js.LICENSE.txt +1 -0
  15. package/dist/7526.js +1 -0
  16. package/dist/@byted-doubao-apps/create.js +4 -5
  17. package/dist/@byted-doubao-apps/login.js +2 -3
  18. package/dist/@byted-doubao-apps/login~1.js +2 -0
  19. package/dist/@byted-doubao-apps/template-empty/package.json +3 -3
  20. package/dist/@byted-doubao-apps/template-starter/package.json +3 -3
  21. package/dist/@byted-hdt/cli.js +11 -12
  22. package/dist/@inquirer/select.js +1 -0
  23. package/dist/app.js +1 -2
  24. package/dist/assets/web-sdk-debugger/index.html +1 -1
  25. package/dist/assets/web-sdk-debugger/static/css/{index.4b84c01189.css → index.123e72a5bc.css} +1 -1
  26. package/dist/assets/web-sdk-debugger/static/js/index.019ceb233a.js +26 -0
  27. package/dist/assets/web-sdk-debugger/wsd/doubao-apps-api.template.js +0 -0
  28. package/dist/assets/web-sdk-debugger/wsd/doubao-apps-framework.template.js +0 -0
  29. package/dist/auth.js +1 -2
  30. package/dist/browser.js +1 -2
  31. package/dist/components-loader.js +2 -3
  32. package/dist/dbx-demo.js +2 -3
  33. package/dist/demo-server.js +3 -4
  34. package/dist/dev-service-client.js +16 -10
  35. package/dist/dev-service-client.js.LICENSE.txt +89 -0
  36. package/dist/dev-shell.js +5 -2
  37. package/dist/dev-shell.js.LICENSE.txt +59 -0
  38. package/dist/dev.js +18 -19
  39. package/dist/devtools.js +2 -0
  40. package/dist/devtools.js.LICENSE.txt +1 -0
  41. package/dist/environment.js +1 -0
  42. package/dist/eval.js +1 -2
  43. package/dist/get.js +1 -2
  44. package/dist/init.js +6 -7
  45. package/dist/login.js +1 -2
  46. package/dist/main.js +1 -0
  47. package/dist/manifest-mcp-config.js +1 -2
  48. package/dist/project-layout.js +1 -2
  49. package/dist/prompt.js +5 -6
  50. package/dist/push-page.js +1 -2
  51. package/dist/push-widget.js +1 -2
  52. package/dist/rslib-runtime.js +1 -2
  53. package/dist/sandbox.js +1 -2
  54. package/dist/sdk.js +76 -169
  55. package/dist/sdk.js.LICENSE.txt +1 -13
  56. package/dist/sdk~1.js +218 -0
  57. package/dist/sdk~1.js.LICENSE.txt +15 -0
  58. package/dist/skills.js +2 -3
  59. package/dist/static/404/404.html +455 -0
  60. package/dist/static/assets/package.json +137 -0
  61. package/dist/static/home_choose/chooseRegion.html +345 -0
  62. package/dist/static/openChrome.applescript +88 -0
  63. package/dist/status.js +2 -3
  64. package/dist/status~1.js +1 -2
  65. package/dist/stop.js +1 -2
  66. package/dist/update.js +1 -2
  67. package/dist/upgrade.js +1 -2
  68. package/dist/upload.js +7 -8
  69. package/dist/validate.js +1 -2
  70. package/dist/yaml.js +25 -0
  71. package/package.json +34 -35
  72. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/01-/345/237/272/347/241/200.md +114 -7
  73. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/02-/347/263/273/347/273/237.md +126 -0
  74. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/06-/344/272/244/344/272/222.md +71 -0
  75. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/08-/347/275/221/347/273/234.md +222 -0
  76. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/10-/344/270/232/345/212/241/350/203/275/345/212/233.md +122 -0
  77. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/groups.md +5 -5
  78. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/quick-reference.md +7 -2
  79. package/dist/183.js +0 -2
  80. package/dist/564.js +0 -13
  81. package/dist/714.js +0 -1
  82. package/dist/assets/web-sdk-debugger/static/js/index.62b5cae841.js +0 -26
  83. package/dist/bin/darwin-arm64/security_tasm_codec +0 -0
  84. package/dist/bin/darwin-arm64/security_tasm_codec.sha256 +0 -1
  85. package/dist/bin/darwin-x64/security_tasm_codec +0 -0
  86. package/dist/bin/darwin-x64/security_tasm_codec.sha256 +0 -1
  87. package/dist/bin/linux-x64/security_tasm_codec +0 -0
  88. package/dist/bin/linux-x64/security_tasm_codec.sha256 +0 -1
  89. package/dist/bin/win32-x64/security_tasm_codec.exe.sha256 +0 -1
  90. package/dist/index.js +0 -1
  91. package/dist/package.json +0 -56
@@ -0,0 +1,345 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6
+ <title>Choose Region</title>
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <style>
9
+ .choose-container,
10
+ .loading-container {
11
+ display: flex;
12
+ flex-direction: column;
13
+ justify-content: center;
14
+ align-items: center;
15
+ height: 100vh;
16
+ }
17
+
18
+ .box-container {
19
+ margin-top: 50px;
20
+ display: flex;
21
+ justify-content: center;
22
+ align-items: center;
23
+ }
24
+
25
+ .box {
26
+ width: 220px;
27
+ height: 220px;
28
+ margin: 0 50px;
29
+ padding: 10px;
30
+ display: flex;
31
+ flex-direction: column;
32
+ justify-content: center;
33
+ align-items: center;
34
+ background-color: #FFF;
35
+ border: 3px solid #CCC;
36
+ color: #BBB;
37
+ transition: all 0.5s;
38
+ text-decoration: none;
39
+ }
40
+
41
+ .box:hover,
42
+ .box-downloading {
43
+ border: 3px solid #000;
44
+ color: #000;
45
+ cursor: pointer;
46
+ }
47
+
48
+ .hidden {
49
+ display: none;
50
+ }
51
+
52
+ .loading-bar {
53
+ width: 50vh;
54
+ height: 20px;
55
+ margin: 50px 0;
56
+ border: 3px solid #000;
57
+ }
58
+
59
+ .btn {
60
+ z-index: 1;
61
+ overflow: hidden;
62
+ background: transparent;
63
+ position: relative;
64
+ padding: 8px 50px;
65
+ border-radius: 30px;
66
+ cursor: pointer;
67
+ font-size: 1em;
68
+ letter-spacing: 2px;
69
+ -webkit-transition: 0.2s ease;
70
+ transition: 0.2s ease;
71
+ font-weight: bold;
72
+ margin: 5px 30px;
73
+ }
74
+
75
+ .btn:hover {
76
+ background: lightgrey;
77
+ }
78
+
79
+ .btn-container {
80
+ display: flex;
81
+ flex-direction: row;
82
+ }
83
+
84
+ .failed-tips {
85
+ display: flex;
86
+ flex-direction: column;
87
+ align-items: center;
88
+ visibility: hidden;
89
+ }
90
+
91
+ .toast {
92
+ padding: 10px;
93
+ position: fixed;
94
+ left: 50%;
95
+ top: 10%;
96
+ transform: translate(-50%, 0);
97
+ visibility: hidden;
98
+ border-radius: 10px;
99
+ background-color: #ffffff;
100
+ box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
101
+ color: #666;
102
+ }
103
+ </style>
104
+
105
+ <script>
106
+ var timer;
107
+ function toast() {
108
+ const toast = document.getElementById("toast");
109
+ toast.style.visibility = 'visible';
110
+ clearTimeout(timer);
111
+ timer = setTimeout(() => {
112
+ toast.style.visibility = 'hidden';
113
+ }, 3000);
114
+ }
115
+
116
+ function addEnvLogs(msg) {
117
+ console.log('addEnvLog', msg);
118
+ const xhr = new XMLHttpRequest();
119
+ xhr.open('POST', '/addEnvLogs');
120
+ xhr.setRequestHeader('Content-Type', 'application/json');
121
+ const data = {
122
+ logs: [{
123
+ level: 'debug',
124
+ module: 'updater',
125
+ tag: 'chooseRegion',
126
+ msg,
127
+ timestamp: Date.now()
128
+ }],
129
+ batchId: 0
130
+ };
131
+ xhr.send(JSON.stringify(data));
132
+ }
133
+
134
+ function deleteCLI() {
135
+ try {
136
+ const xhr = new XMLHttpRequest();
137
+ xhr.onreadystatechange = function () {
138
+ if (xhr.readyState === 4 && xhr.status === 200) {
139
+ const responseText = xhr.responseText;
140
+ console.log(responseText);
141
+ let result = {};
142
+ try {
143
+ result = JSON.parse(responseText);
144
+ if (result.code === 0) {
145
+ toast();
146
+ }
147
+ } catch (e) {
148
+ addEnvLogs(`deleteCLI parse error:, ${e.toString()}`);
149
+ }
150
+ }
151
+ };
152
+ xhr.open('POST', '/deleteCLI');
153
+ xhr.send();
154
+ } catch (e) {
155
+ addEnvLogs(`deleteCLI error: ${e.toString()}`);
156
+ }
157
+ }
158
+
159
+ function clickReset() {
160
+ addEnvLogs('reset click');
161
+ deleteCLI();
162
+ }
163
+
164
+ function clickRefresh() {
165
+ addEnvLogs('refresh click');
166
+ window.location.reload();
167
+ }
168
+
169
+ function showFailedTips() {
170
+ addEnvLogs(`show failed tips`);
171
+ const failedTips = document.querySelectorAll('.failed-tips');
172
+ failedTips.forEach(f => {
173
+ f.style.visibility = 'visible';
174
+ });
175
+ }
176
+
177
+ function updateResourceWithProgress(region, progressListener, onFailedListener) {
178
+ let called = false;
179
+ let lastProgressTimestamp = Date.now();
180
+ function onFailedCallbackOnce() {
181
+ if (!called && onFailedListener) {
182
+ called = true;
183
+ onFailedListener();
184
+ }
185
+ }
186
+ const timeInterval = setInterval(() => {
187
+ const currentTimestamp = Date.now();
188
+ // 10秒没有进度更新,视为卡住
189
+ if (currentTimestamp - lastProgressTimestamp > 10 * 1000) {
190
+ onFailedCallbackOnce();
191
+ clearInterval(timeInterval);
192
+ }
193
+ }, 10 * 1000);
194
+ try {
195
+ const xhr = new XMLHttpRequest();
196
+ xhr.onprogress = function (event) {
197
+ if (event.lengthComputable) {
198
+ const percentage = Math.round(100 * event.loaded / event.total);
199
+ progressListener(percentage);
200
+ lastProgressTimestamp = Date.now();
201
+ }
202
+ };
203
+ xhr.onreadystatechange = function () {
204
+ if (xhr.readyState === 4 && xhr.status === 200) {
205
+ const responseText = xhr.responseText;
206
+ console.log(responseText);
207
+ let result = {};
208
+ try {
209
+ result = JSON.parse(responseText)
210
+ } catch (e) {
211
+ addEnvLogs(`update resource parse error: ${e.toString()}`);
212
+ }
213
+ if (result.code === 0) {
214
+ window.location.reload();
215
+ } else {
216
+ onFailedCallbackOnce();
217
+ }
218
+ addEnvLogs(`update resource sucess`);
219
+ }
220
+ };
221
+ xhr.open('GET', '/chooseRegion?region=' + region);
222
+ xhr.send();
223
+ } catch (e) {
224
+ onFailedCallbackOnce();
225
+ addEnvLogs(`update resource error: ${e.toString()}`);
226
+ }
227
+ }
228
+
229
+ let clickable = true;
230
+ function handleClick(region) {
231
+ return function (clickEvent) {
232
+ if (clickable) {
233
+ clickable = false;
234
+ const target = clickEvent.currentTarget;
235
+ target.classList.add('box-downloading');
236
+ updateResourceWithProgress(region, (percentage) => {
237
+ target.style.background = `linear-gradient(to bottom, white ${Math.max(0, 100 - percentage)}%, rgb(199,214,239) 0%)`;
238
+ }, () => {
239
+ showFailedTips();
240
+ });
241
+ }
242
+ }
243
+ }
244
+
245
+ let inited = false;
246
+ let init = function () {
247
+ if (inited) {
248
+ return;
249
+ }
250
+ inited = true;
251
+ const boxes = document.querySelectorAll('.box');
252
+ boxes.forEach(box => {
253
+ box.addEventListener('click', handleClick(box.dataset.region));
254
+ });
255
+
256
+ const contact = document.querySelectorAll('.contact');
257
+ contact.forEach(c => {
258
+ c.setAttribute('href', "https://applink.feishu.cn/client/chat/chatter/add_by_link?link_token=726ia6da-fa2b-4b63-bf79-8e165cd5c83e");
259
+ c.setAttribute('target', "_blank");
260
+ });
261
+
262
+ fetch('/getConfigItemByKey?key=region').then(res => res.json()).then(data => {
263
+ const region = data.value;
264
+ if (region) {
265
+ updateResourceWithProgress(region, (percentage) => {
266
+ const loadingBar = document.querySelector('.loading-bar');
267
+ loadingBar.style.background = `linear-gradient(to left, white ${Math.max(0, 100 - percentage)}%, rgb(199,214,239) 0%)`;
268
+ }, () => {
269
+ showFailedTips();
270
+ });
271
+ } else {
272
+ addEnvLogs(`region not exists`);
273
+ throw "region not exists";
274
+ }
275
+ }).catch((e) => {
276
+ addEnvLogs(`show choose region buttons`);
277
+ const chooseContainer = document.querySelector('.choose-container');
278
+ const loadingContainer = document.querySelector('.loading-container');
279
+ chooseContainer.classList.remove('hidden');
280
+ loadingContainer.classList.add('hidden');
281
+ });
282
+ }
283
+ window.onload = init;
284
+ document.addEventListener('DOMContentLoaded', init);
285
+ </script>
286
+ </head>
287
+
288
+ <body>
289
+ <div>
290
+ <div class="choose-container hidden">
291
+ <div>由于国内外跨端能力实现有差异,当前HDT由国内外跨端团队分别维护,请选择对应的HDT版本。如在本页面遇到问题,可<a class="contact">联系我们</a></div>
292
+ <div>Due to differences in the implementation of cross-platform abilities at China and non-China, current
293
+ HDT is
294
+ maintained separately by cross-platform teams of China and non-China, please
295
+ select the corresponding HDT version. Any issues in this page, please <a class="contact">contact us</a>
296
+ </div>
297
+ <div class="box-container">
298
+ <div class="box" data-region="cn">
299
+ <h1>cn</h1>
300
+ <div>适用于在中国运营或使用Annie容器的App,如抖音。</div>
301
+ <br />
302
+ <div>For Apps operating in China or using Annie container, such as Douyin.</div>
303
+ </div>
304
+ <div class="box" data-region="non-cn">
305
+ <h1>i18n</h1>
306
+ <div>适用于在海外运营或使用Spark容器的App,如TikTok。</div>
307
+ <br />
308
+ <div>For Apps operating in non-China regions or using Spark container, such as TikTok.</div>
309
+ </div>
310
+ </div>
311
+ <br />
312
+ <div class="failed-tips">
313
+ <div>如果页面卡住,可尝试刷新或重置HDT</div>
314
+ <div>If blocking in this page, please try to refresh or reset HDT.</div>
315
+ <br />
316
+ <div class="btn-container">
317
+ <button class="btn" onclick="clickRefresh()">Refresh</button> <button class="btn"
318
+ onclick="clickReset()">Reset</button>
319
+ </div>
320
+ </div>
321
+ </div>
322
+ </div>
323
+ <div class="loading-container">
324
+ <div>资源更新中,请稍候...</div>
325
+ <div>Resource update, please wait...</div>
326
+ <div class="loading-bar"></div>
327
+ <div class="failed-tips">
328
+ <div>如果页面卡住,可尝试重新下载或重置HDT,如仍有问题,请<a class="contact">联系我们</a></div>
329
+ <div>If blocking in this page, please try to refresh or reset HDT. If the problem persists, please
330
+ <a class="contact">contact us</a>
331
+ </div>
332
+ <br />
333
+ <div class="btn-container">
334
+ <button class="btn" onclick="clickRefresh()">Refresh</button> <button class="btn"
335
+ onclick="clickReset()">Reset</button>
336
+ </div>
337
+ </div>
338
+ </div>
339
+ <div class="toast" id="toast">
340
+ <div>HDT重置完成,需重新启动。</div>
341
+ <div>HDT reset completed, please restart.</div>
342
+ </div>
343
+ </body>
344
+
345
+ </html>
@@ -0,0 +1,88 @@
1
+ property targetTab: null
2
+ property targetTabIndex: -1
3
+ property targetWindow: null
4
+
5
+ on run argv
6
+ set theURL to item 1 of argv
7
+ set realURL to item 2 of argv
8
+ set deeplinkURL to item 3 of argv
9
+
10
+ -- use HDT Electron if possible
11
+ if (count of argv) >= 3 then
12
+ try
13
+ set appID to id of application "HybridDevtool"
14
+ tell application "Finder" to get application file id appID
15
+ open location deeplinkURL
16
+ return
17
+ end try
18
+ end if
19
+
20
+ tell application "Chrome"
21
+
22
+ if (count every window) = 0 then
23
+ make new window
24
+ end if
25
+
26
+ -- 1: Looking for tab running debugger
27
+ -- then, Reload debugging tab if found
28
+ -- then return
29
+ set found to my lookupTabWithUrl(theURL)
30
+ if found then
31
+ set targetWindow's active tab index to targetTabIndex
32
+ set URL of targetTab to realURL
33
+ tell targetWindow to activate
34
+ set index of targetWindow to 1
35
+ return
36
+ end if
37
+
38
+ -- 2: Looking for Empty tab
39
+ -- In case debugging tab was not found
40
+ -- We try to find an empty tab instead
41
+ set found to my lookupTabWithUrl("chrome://newtab/")
42
+ if found then
43
+ set targetWindow's active tab index to targetTabIndex
44
+ set URL of targetTab to realURL
45
+ tell targetWindow to activate
46
+ return
47
+ end if
48
+
49
+ -- 3: Create new tab
50
+ -- both debugging and empty tab were not found
51
+ -- make a new tab with url
52
+ tell window 1
53
+ activate
54
+ make new tab with properties {URL:realURL}
55
+ end tell
56
+ end tell
57
+ end run
58
+
59
+ -- Function:
60
+ -- Lookup tab with given url
61
+ -- if found, store tab, index, and window in properties
62
+ -- (properties were declared on top of file)
63
+ on lookupTabWithUrl(lookupUrl)
64
+ tell application "Chrome"
65
+ -- Find a tab with the given url
66
+ set found to false
67
+ set theTabIndex to -1
68
+ repeat with theWindow in every window
69
+ set theTabIndex to 0
70
+ repeat with theTab in every tab of theWindow
71
+ set theTabIndex to theTabIndex + 1
72
+ if (theTab's URL as string) contains lookupUrl then
73
+ -- assign tab, tab index, and window to properties
74
+ set targetTab to theTab
75
+ set targetTabIndex to theTabIndex
76
+ set targetWindow to theWindow
77
+ set found to true
78
+ exit repeat
79
+ end if
80
+ end repeat
81
+
82
+ if found then
83
+ exit repeat
84
+ end if
85
+ end repeat
86
+ end tell
87
+ return found
88
+ end lookupTabWithUrl
package/dist/status.js CHANGED
@@ -1,3 +1,2 @@
1
- import"node:module";import{mkdirSync as t,writeFileSync as r}from"node:fs";import{tmpdir as e}from"node:os";import{join as o}from"node:path";import{setTimeout as i}from"node:timers/promises";import{Command as a,InvalidArgumentError as n,Option as s}from"commander";import{getMiniAppVersionArtifact as _}from"./app.js";import{runCommand as u,parseInteger as f,getLastHttpResponseLogId as d}from"./564.js";import{miniAppDetailUrl as l,miniAppVersionDetailUrl as c,resolveAppKey as p}from"./183.js";let m=new Set([7]),g=new Set([8]),b={1:{name:"PENDING_BUILD",description:"Waiting for cloud build to start"},2:{name:"BUILD_STARTED",description:"Cloud build has started"},3:{name:"CODE_READY",description:"Source package is ready"},4:{name:"COMPILING",description:"Compiling frontend code"},5:{name:"COMPILE_SUCCEEDED",description:"Compilation succeeded; waiting for upload or final packaging"},6:{name:"UPLOADING",description:"Uploading build output"},7:{name:"BUILD_SUCCEEDED",description:"Cloud build succeeded"},8:{name:"BUILD_FAILED",description:"Cloud build failed"}};async function $(t,r){var e;let o=p(r.project,r.appId),a=Date.now(),n=0,s=await v(o,r.versionTag,n);for(;r.poll&&"success"!==(e=s.status)&&"failed"!==e;){if(Date.now()-a>=1e3*r.timeoutSeconds)throw D("artifact build status polling timed out",s);await i(1e3*r.intervalSeconds),n+=1,s=await v(o,r.versionTag,n)}let _=function(t){let r=t.artifact_build_error_info;if(r){var e,o;let i;return e=r,o=t.error_info_file,i=e.error_code||"artifact build failed",o?`${i}; error_info written to ${o}`:e.error_info?e.error_info:e.error_code?e.error_code:"number"==typeof e.last_status_before_failed?`artifact build failed after status ${e.last_status_before_failed}`:"artifact build failed"}let i=t.artifact_status;if("number"==typeof i&&g.has(i)){let t=h(i);return`artifact_status=${i} (${t.name})`}}(s);if(t.log(`artifact status: ${s.status}`),"number"==typeof s.artifact_status?t.log(`artifact_status: ${s.artifact_status} (${s.artifact_status_name})`):t.log("artifact_status: unknown"),t.log(`status_description: ${s.artifact_status_description}`),t.log(`app_id: ${s.app_id}`),t.log(`version_tag: ${s.version_tag}`),"success"===s.status&&(t.log("后续调试指引:"),t.log(`1. 打开版本详情页查看真机调试二维码: ${s.version_detail_url}`),t.log(`2. 扫码前,先将豆包 UID 加入当前应用的调试白名单: ${s.app_detail_url} 的「体验白名单」部分。`),t.log("3. 在豆包 App 中打开调试对话。"),t.log(`4. 如果是首次调试,在手机浏览器中打开 ${s.doubao_debug_conversation_url},会自动调起豆包 App 并打开调试会话。`)),_)for(let r of(t.log(`failure_reason: ${_}`),function(t,r){if(!t)return[];let e=[];if(t.error_code&&e.push(`error_code: ${t.error_code}`),r?(e.push(`error_info_file: ${r}`),e.push("error_info: written to temporary file for agent diagnosis")):t.error_info&&e.push(`error_info: ${t.error_info}`),"number"==typeof t.last_status_before_failed){let r=h(t.last_status_before_failed);e.push(`last_status_before_failed: ${t.last_status_before_failed} (${r.name})`),e.push(`last_status_description: ${r.description}`)}return e}(s.artifact_build_error_info,s.error_info_file)))t.log(r);if(_)throw D(`artifact build failed: ${_}`,s);return s}function w(t){let r=f(t);if(r<1)throw new n("expected an integer greater than or equal to 1");return r}async function v(i,a,n){var s,u,f,p;let b,$,w,v=await _(i,a),D=v.data,E=h(D?.artifact_status),U=(s=D,"number"!=typeof(b=s?.artifact_status)?"unknown":m.has(b)?"success":g.has(b)||s?.artifact_build_error_info?"failed":"building"),N="failed"===U&&D?.artifact_build_error_info?.error_info?(u=i,f=D?.version_tag||a,p=D.artifact_build_error_info.error_info,t($=o(e(),"dbx-artifact-build-errors"),{recursive:!0}),r(w=o($,`${C(u)}-${C(f)}-${Date.now()}-${process.pid}.log`),p.endsWith("\n")?p:`${p}
2
- `,"utf8"),w):void 0,S=D?.artifact_build_error_info?function(t,r){if(!r)return t;let{error_info:e,...o}=t;return o}(D.artifact_build_error_info,!!N):void 0;return{app_id:i,version_tag:D?.version_tag||a,artifact_status:D?.artifact_status,artifact_status_name:E.name,artifact_status_description:E.description,status:U,...S?{artifact_build_error_info:S}:{},...N?{error_info_file:N}:{},attempt:n,..."success"===U?{version_detail_url:c(i,D?.version_tag||a),app_detail_url:l(i),doubao_debug_conversation_url:"https://inhouse.doubao.com/bot/2xgttdEs"}:{},log_id:v.log_id??d()??""}}function h(t){return"number"!=typeof t?{name:"UNKNOWN",description:"No artifact status was returned by the server"}:b[t]??{name:"UNKNOWN",description:`Unrecognized artifact status ${t}`}}function C(t){return t.trim().replace(/[^a-zA-Z0-9._-]+/g,"_")||"unknown"}function D(t,r){let e=Error(t);return e.exitCode=1,e.logId=d(),e.details=r,e}export default function(){return new a("status").description("查询或轮询版本产物构建状态").option("--app-id <app-id>","兼容参数;manifest 存在时必须与 app_key 一致").option("--project <path>","项目路径,用于按项目布局读取 Manifest",".").requiredOption("--version-tag <tag>","版本 tag").option("--poll","持续轮询直到构建成功、失败或超时",!1).addOption(new s("--interval-seconds <seconds>","轮询间隔秒数").default(5).argParser(w)).addOption(new s("--timeout-seconds <seconds>","轮询超时时间秒数").default(300).argParser(w)).action(async(t,r)=>u(r,r=>$(r,t)))};
3
- //# sourceMappingURL=status.js.map
1
+ import"node:module";import{__webpack_require__ as t}from"./rslib-runtime.js";import{InvalidArgumentError as r,parseInteger as e,runCommand as i,promises_namespaceObject as a,command_Command as o,option_Option as n,getLastHttpResponseLogId as s}from"./1664.js";import{getMiniAppVersionArtifact as _}from"./app.js";import{miniAppDetailUrl as u,miniAppVersionDetailUrl as d,resolveAppKey as f}from"./5732.js";let l=t("node:fs"),c=t("node:os"),p=t("node:path"),g=new Set([7]),m=new Set([8]),b={1:{name:"PENDING_BUILD",description:"Waiting for cloud build to start"},2:{name:"BUILD_STARTED",description:"Cloud build has started"},3:{name:"CODE_READY",description:"Source package is ready"},4:{name:"COMPILING",description:"Compiling frontend code"},5:{name:"COMPILE_SUCCEEDED",description:"Compilation succeeded; waiting for upload or final packaging"},6:{name:"UPLOADING",description:"Uploading build output"},7:{name:"BUILD_SUCCEEDED",description:"Cloud build succeeded"},8:{name:"BUILD_FAILED",description:"Cloud build failed"}};async function $(t,r){var e;let i=f(r.project,r.appId),o=Date.now(),n=0,s=await v(i,r.versionTag,n);for(;r.poll&&"success"!==(e=s.status)&&"failed"!==e;){if(Date.now()-o>=1e3*r.timeoutSeconds)throw D("artifact build status polling timed out",s);await (0,a.setTimeout)(1e3*r.intervalSeconds),n+=1,s=await v(i,r.versionTag,n)}let _=function(t){let r=t.artifact_build_error_info;if(r){var e,i;let a;return e=r,i=t.error_info_file,a=e.error_code||"artifact build failed",i?`${a}; error_info written to ${i}`:e.error_info?e.error_info:e.error_code?e.error_code:"number"==typeof e.last_status_before_failed?`artifact build failed after status ${e.last_status_before_failed}`:"artifact build failed"}let a=t.artifact_status;if("number"==typeof a&&m.has(a)){let t=C(a);return`artifact_status=${a} (${t.name})`}}(s);if(t.log(`artifact status: ${s.status}`),"number"==typeof s.artifact_status?t.log(`artifact_status: ${s.artifact_status} (${s.artifact_status_name})`):t.log("artifact_status: unknown"),t.log(`status_description: ${s.artifact_status_description}`),t.log(`app_id: ${s.app_id}`),t.log(`version_tag: ${s.version_tag}`),"success"===s.status&&(t.log("后续调试指引:"),t.log(`1. 打开版本详情页查看真机调试二维码: ${s.version_detail_url}`),t.log(`2. 扫码前,先将豆包 UID 加入当前应用的调试白名单: ${s.app_detail_url} 的「体验白名单」部分。`),t.log("3. 在豆包 App 中打开调试对话。"),t.log(`4. 如果是首次调试,在手机浏览器中打开 ${s.doubao_debug_conversation_url},会自动调起豆包 App 并打开调试会话。`)),_)for(let r of(t.log(`failure_reason: ${_}`),function(t,r){if(!t)return[];let e=[];if(t.error_code&&e.push(`error_code: ${t.error_code}`),r?(e.push(`error_info_file: ${r}`),e.push("error_info: written to temporary file for agent diagnosis")):t.error_info&&e.push(`error_info: ${t.error_info}`),"number"==typeof t.last_status_before_failed){let r=C(t.last_status_before_failed);e.push(`last_status_before_failed: ${t.last_status_before_failed} (${r.name})`),e.push(`last_status_description: ${r.description}`)}return e}(s.artifact_build_error_info,s.error_info_file)))t.log(r);if(_)throw D(`artifact build failed: ${_}`,s);return s}function w(t){let i=e(t);if(i<1)throw new r("expected an integer greater than or equal to 1");return i}async function v(t,r,e){var i,a,o,n;let f,b,$,w=await _(t,r),v=w.data,D=C(v?.artifact_status),E=(i=v,"number"!=typeof(f=i?.artifact_status)?"unknown":g.has(f)?"success":m.has(f)||i?.artifact_build_error_info?"failed":"building"),S="failed"===E&&v?.artifact_build_error_info?.error_info?(a=t,o=v?.version_tag||r,n=v.artifact_build_error_info.error_info,b=(0,p.join)((0,c.tmpdir)(),"dbx-artifact-build-errors"),(0,l.mkdirSync)(b,{recursive:!0}),$=(0,p.join)(b,`${h(a)}-${h(o)}-${Date.now()}-${process.pid}.log`),(0,l.writeFileSync)($,n.endsWith("\n")?n:`${n}
2
+ `,"utf8"),$):void 0,U=v?.artifact_build_error_info?function(t,r){if(!r)return t;let{error_info:e,...i}=t;return i}(v.artifact_build_error_info,!!S):void 0;return{app_id:t,version_tag:v?.version_tag||r,artifact_status:v?.artifact_status,artifact_status_name:D.name,artifact_status_description:D.description,status:E,...U?{artifact_build_error_info:U}:{},...S?{error_info_file:S}:{},attempt:e,..."success"===E?{version_detail_url:d(t,v?.version_tag||r),app_detail_url:u(t),doubao_debug_conversation_url:"https://inhouse.doubao.com/bot/2xgttdEs"}:{},log_id:w.log_id??s()??""}}function C(t){return"number"!=typeof t?{name:"UNKNOWN",description:"No artifact status was returned by the server"}:b[t]??{name:"UNKNOWN",description:`Unrecognized artifact status ${t}`}}function h(t){return t.trim().replace(/[^a-zA-Z0-9._-]+/g,"_")||"unknown"}function D(t,r){let e=Error(t);return e.exitCode=1,e.logId=s(),e.details=r,e}export default function(){return new o("status").description("查询或轮询版本产物构建状态").option("--app-id <app-id>","兼容参数;manifest 存在时必须与 app_key 一致").option("--project <path>","项目路径,用于按项目布局读取 Manifest",".").requiredOption("--version-tag <tag>","版本 tag").option("--poll","持续轮询直到构建成功、失败或超时",!1).addOption(new n("--interval-seconds <seconds>","轮询间隔秒数").default(5).argParser(w)).addOption(new n("--timeout-seconds <seconds>","轮询超时时间秒数").default(300).argParser(w)).action(async(t,r)=>i(r,r=>$(r,t)))};
package/dist/status~1.js CHANGED
@@ -1,2 +1 @@
1
- import"node:module";import{Command as e}from"commander";import{runCommand as o}from"./564.js";import{getAuthStatus as r}from"./auth.js";async function t(e){let o=await r();return o.loggedIn?(e.log("Logged in"),e.log(`User ID: ${o.uid??"unknown"}`),o.expiresAt&&e.log(`Expires at: ${new Date(1e3*o.expiresAt).toISOString()}`),o.baseUrl&&e.log(`Base URL: ${o.baseUrl}`),o):(o.credentialError?(e.log("Credential store unavailable"),e.log(o.credentialError.message)):e.log("Not logged in"),o)}export default function(){return new e("status").description("查看登录状态").action(async(e,r)=>o(r,t))};
2
- //# sourceMappingURL=status~1.js.map
1
+ import"node:module";import{command_Command as e,runCommand as o}from"./1664.js";import{getAuthStatus as r}from"./auth.js";async function t(e){let o=await r();return o.loggedIn?(e.log("Logged in"),e.log(`User ID: ${o.uid??"unknown"}`),o.expiresAt&&e.log(`Expires at: ${new Date(1e3*o.expiresAt).toISOString()}`),o.baseUrl&&e.log(`Base URL: ${o.baseUrl}`),o):(o.credentialError?(e.log("Credential store unavailable"),e.log(o.credentialError.message)):e.log("Not logged in"),o)}export default function(){return new e("status").description("查看登录状态").action(async(e,r)=>o(r,t))};
package/dist/stop.js CHANGED
@@ -1,2 +1 @@
1
- import"node:module";import{resolve as t}from"node:path";import{Command as o}from"commander";import{stopDevService as e,connectDevService as r,DEV_ACTIONS as s}from"./dev-service-client.js";import{runCommand as i}from"./564.js";import{resolveProjectLayout as a}from"./project-layout.js";async function n(o){let r=t(process.cwd()),s=a(r).frontendDirectory,i=await p(r,s);if(i)return o.log("dev service stopped"),o.log("status: stopping"),{status:"stopping",result:i};let n=await e({projectPath:r,appDir:s});return o.log("dev service stopped"),o.log(`status: ${n?.status??"stopped"}`),n??{status:"stopped"}}async function p(t,o){let e;try{return e=await r({projectPath:t,appDir:o,nodeIdPrefix:"dev-stop",requestTimeoutMs:5e3}),await e.call(s.stop)}catch{return}finally{await e?.stop().catch(()=>void 0)}}export default function(){return new o("stop").description("停止常驻 dev 调试服务").action(async(t,o)=>i(o,t=>n(t)))};
2
- //# sourceMappingURL=stop.js.map
1
+ import"node:module";import{__webpack_require__ as t}from"./rslib-runtime.js";import{command_Command as e,runCommand as o}from"./1664.js";import{stopDevService as r,connectDevService as s,DEV_ACTIONS as i}from"./dev-service-client.js";import{resolveProjectLayout as a}from"./project-layout.js";let n=t("node:path");async function p(t){let e=(0,n.resolve)(process.cwd()),o=a(e).frontendDirectory,s=await _(e,o);if(s)return t.log("dev service stopped"),t.log("status: stopping"),{status:"stopping",result:s};let i=await r({projectPath:e,appDir:o});return t.log("dev service stopped"),t.log(`status: ${i?.status??"stopped"}`),i??{status:"stopped"}}async function _(t,e){let o;try{return o=await s({projectPath:t,appDir:e,nodeIdPrefix:"dev-stop",requestTimeoutMs:5e3}),await o.call(i.stop)}catch{return}finally{await o?.stop().catch(()=>void 0)}}export default function(){return new e("stop").description("停止常驻 dev 调试服务").action(async(t,e)=>o(e,t=>p(t)))};
package/dist/update.js CHANGED
@@ -1,2 +1 @@
1
- import"node:module";import{execa as r}from"execa";import{runtime_packageName as e,compareSemver as t,normalizeVersion as n,isValidSemver as a,writeUpdateCheckState as i}from"./564.js";import{refreshCurrentSkills as o}from"./skills.js";let l={npmView:async e=>(await r("npm",["view",e,"version"],{env:process.env,stdio:["ignore","pipe","pipe"]})).stdout.trim(),async npmInstallGlobal(e){await r("npm",["install","-g",e],{env:process.env,stdio:"inherit"})},async npmAvailable(){try{return await r("npm",["--version"],{env:process.env,stdio:["ignore","ignore","ignore"]}),!0}catch{return!1}}};async function s(r,o=l){let p=n(await o.npmView(e)),u=n(r);if(!a(p))throw Error(`Invalid latest version from npm registry: ${p}`);if(!a(u))throw Error(`Invalid current version: ${r}`);return await i(p),{currentVersion:u,latestVersion:p,updateAvailable:t(p,u)>0}}async function p(r){let t=r.runner??l,n=await s(r.currentVersion,t);if(r.check)return{...n,action:n.updateAvailable?"check_update_available":"already_up_to_date"};if(!r.force&&!n.updateAvailable){let r=u(n.currentVersion);return{...n,action:"already_up_to_date",...r}}if(!await t.npmAvailable())throw Error(`npm not found in PATH. Install npm or update manually with npm install -g ${e}`);await t.npmInstallGlobal(`${e}@${n.latestVersion}`),await i(n.latestVersion);let a=u(n.latestVersion);return{...n,action:"updated",...a}}function u(r){try{return{skills:o(r)}}catch(r){return{skillsWarning:c(r)}}}function c(r){return r instanceof Error&&r.message?r.message:String(r)}export{c as formatError,p as updateCli};
2
- //# sourceMappingURL=update.js.map
1
+ import"node:module";import{execa as r,runtime_packageName as e,compareSemver as n,normalizeVersion as t,isValidSemver as a,writeUpdateCheckState as i}from"./1664.js";import{refreshCurrentSkills as o}from"./skills.js";let l={npmView:async e=>(await r("npm",["view",e,"version"],{env:process.env,stdio:["ignore","pipe","pipe"]})).stdout.trim(),async npmInstallGlobal(e){await r("npm",["install","-g",e],{env:process.env,stdio:"inherit"})},async npmAvailable(){try{return await r("npm",["--version"],{env:process.env,stdio:["ignore","ignore","ignore"]}),!0}catch{return!1}}};async function s(r,o=l){let p=t(await o.npmView(e)),u=t(r);if(!a(p))throw Error(`Invalid latest version from npm registry: ${p}`);if(!a(u))throw Error(`Invalid current version: ${r}`);return await i(p),{currentVersion:u,latestVersion:p,updateAvailable:n(p,u)>0}}async function p(r){let n=r.runner??l,t=await s(r.currentVersion,n);if(r.check)return{...t,action:t.updateAvailable?"check_update_available":"already_up_to_date"};if(!r.force&&!t.updateAvailable){let r=u(t.currentVersion);return{...t,action:"already_up_to_date",...r}}if(!await n.npmAvailable())throw Error(`npm not found in PATH. Install npm or update manually with npm install -g ${e}`);await n.npmInstallGlobal(`${e}@${t.latestVersion}`),await i(t.latestVersion);let a=u(t.latestVersion);return{...t,action:"updated",...a}}function u(r){try{return{skills:o(r)}}catch(r){return{skillsWarning:c(r)}}}function c(r){return r instanceof Error&&r.message?r.message:String(r)}export{c as formatError,p as updateCli};
package/dist/upgrade.js CHANGED
@@ -1,2 +1 @@
1
- import"node:module";import{Command as e}from"commander";import{version_version as r,runCommand as o}from"./564.js";import{updateCli as n}from"./update.js";async function t(e,o){let t=await n({currentVersion:r,check:o.check,force:o.force});return"already_up_to_date"===t.action?e.log(`dbx is up to date: ${t.currentVersion}`):"check_update_available"===t.action?e.log(`dbx ${t.latestVersion} available, current ${t.currentVersion}`):e.log(`dbx upgraded: ${t.currentVersion} -> ${t.latestVersion}`),t.skills&&(e.log(`skills refreshed: ${t.skills.skillNames.length}`),e.log(`skills current: ${t.skills.currentRoot}`)),t.skillsWarning&&e.warn(`skills refresh failed: ${t.skillsWarning}`),t}export default function(){return new e("upgrade").description("升级 dbx 相关资源").option("--check","只检查是否有新版本,不安装",!1).option("--force","即使当前已是最新版本也重新安装",!1).action(async(e,r)=>o(r,r=>t(r,e)))};
2
- //# sourceMappingURL=upgrade.js.map
1
+ import"node:module";import{version_version as e,command_Command as r,runCommand as o}from"./1664.js";import{updateCli as l}from"./update.js";async function n(r,o){let n=await l({currentVersion:e,check:o.check,force:o.force});return"already_up_to_date"===n.action?r.log(`dbx is up to date: ${n.currentVersion}`):"check_update_available"===n.action?r.log(`dbx ${n.latestVersion} available, current ${n.currentVersion}`):r.log(`dbx upgraded: ${n.currentVersion} -> ${n.latestVersion}`),n.skills&&(r.log(`skills refreshed: ${n.skills.skillNames.length}`),r.log(`skills current: ${n.skills.currentRoot}`)),n.skillsWarning&&r.warn(`skills refresh failed: ${n.skillsWarning}`),n}export default function(){return new r("upgrade").description("升级 dbx 相关资源").option("--check","只检查是否有新版本,不安装",!1).option("--force","即使当前已是最新版本也重新安装",!1).action(async(e,r)=>o(r,r=>n(r,e)))};
package/dist/upload.js CHANGED
@@ -1,8 +1,8 @@
1
- import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";import{copyFileSync as t,existsSync as r,mkdirSync as i,mkdtempSync as n,readFileSync as o,readdirSync as a,realpathSync as s,rmSync as l,statSync as p,writeFileSync as d}from"node:fs";import{basename as u,join as c,relative as f,resolve as _}from"node:path";import{Command as h}from"commander";import m from"yaml";import{stripVTControlCharacters as g}from"node:util";import{getLastHttpResponseLogId as w,runCommand as v,isRecord as E}from"./564.js";import{uploadMiniAppVersionDraftPackage as y,verifyYAML as I,submitMiniAppVersionDraft as L,uploadMiniAppVersionDraftSourceCode as b}from"./app.js";import{sourceTypeForWorkspaceFileType as k,miniAppVersionDetailUrl as U,describeWorkspaceUpload as C,resolveAppKey as x}from"./183.js";import{resolveProjectLayout as $}from"./project-layout.js";var S={};function P(e){if(!E(e))return;let t=E(e.mcp_server)?e.mcp_server:void 0,r=t?.end_point;return"string"==typeof r&&r.trim()?r:void 0}function M(e,t,r){return{checked:!0,endpoint:e,cloud_reachable:!1,reason:t,message:r}}function O(e){let t=e.split(".");if(4!==t.length)return;let r=t.map(e=>Number(e));if(!r.some(e=>!Number.isInteger(e)||e<0||e>255))return r}async function z(e,t={}){let r=j(e),i={cwd:r};try{await B({action:"build",appDir:r,appId:t.appId})}catch(e){throw new F(r,e,i)}return i}async function R(e,t){let r=j(e),i={cwd:r,output_dir:t},n="";try{i.archive_path=n=(await B({action:"cloudPackage",appDir:r,outputDir:t})).archivePath||""}catch(e){throw new A(r,e,i)}if(!n)throw new A(r,Error("DoubaoAppsSDK.cloudPackage did not return an archive path"),i);return n}function j(e){if(!r(e))throw Error(`frontend_code path not found: ${e}`);if(p(e).isFile())throw Error(`frontend_code must be a directory: ${e}`);return s(e)}async function B(e){let t,r,i,n,o=process.cwd(),a={CI:process.env.CI,FORCE_COLOR:process.env.FORCE_COLOR,NO_COLOR:process.env.NO_COLOR},s=(t=[],r=[],i=process.stdout.write,n=process.stderr.write,process.stdout.write=K(t),process.stderr.write=K(r),{result(){let e=N({stdout:t.join(""),stderr:r.join("")});return{...e,...e.stdout||e.stderr?{output:T([e.stdout,e.stderr].filter(Boolean).join("\n"))}:{}}},restore(){process.stdout.write=i,process.stderr.write=n}});try{process.chdir(e.appDir),process.env.CI="true",process.env.FORCE_COLOR="0",process.env.NO_COLOR="1";let{DoubaoAppsSDK:t}=await import("./sdk.js"),r=new t(e.appDir);if("build"===e.action)return await r.build(e.appId?{appId:e.appId}:void 0),s.result();let i=await r.cloudPackage({outputDir:e.outputDir});return{...s.result(),archivePath:i}}catch(t){let e=s.result();throw E(t)&&Object.assign(t,e),t}finally{s.restore(),process.chdir(o),function(e){for(let[t,r]of Object.entries(e))void 0===r?delete process.env[t]:process.env[t]=r}(a)}}function K(e){return(t,r,i)=>{e.push("string"==typeof t?t:Buffer.from(t).toString("string"==typeof r?r:"utf8"));let n="function"==typeof r?r:i;return n?.(),!0}}function N(e){let t=T(e.stdout),r=T(e.stderr),i=T(e.output);return{...t?{stdout:t}:{},...r?{stderr:r}:{},...i?{output:i}:{}}}e.r(S),e.d(S,{default:()=>W});class F extends Error{constructor(e,t,r){var i;let n,o=D(t),a=r?.stdout||o.stdout,s=r?.stderr||o.stderr,l=H(r?.output||o.output||s||a),p={code:"frontend_build_check_failed",cwd:r?.cwd||e,...void 0===o.exitCode?{}:{exit_code:o.exitCode},...o.signal?{signal:o.signal}:{},...o.shortMessage?{short_message:o.shortMessage}:{},...o.originalMessage?{original_message:o.originalMessage}:{},...l?{output:l}:{}};super((n=(i=p).output||i.stderr||i.stdout||i.short_message||i.original_message||"unknown build failure",["frontend build check failed",`cwd: ${i.cwd}`,"build output:",n].join("\n"))),this.exitCode=1,this.name="FrontendBuildCheckError",this.details=p}}class A extends Error{constructor(e,t,r){var i;let n,o=D(t),a=r?.stdout||o.stdout,s=r?.stderr||o.stderr,l=H(r?.output||o.output||s||a),p={code:"frontend_package_failed",cwd:r?.cwd||e,output_dir:r?.output_dir??"",...r?.archive_path?{archive_path:r.archive_path}:{},...void 0===o.exitCode?{}:{exit_code:o.exitCode},...o.signal?{signal:o.signal}:{},...o.shortMessage?{short_message:o.shortMessage}:{},...o.originalMessage?{original_message:o.originalMessage}:{},...l?{output:l}:{}};super((n=(i=p).output||i.stderr||i.stdout||i.short_message||i.original_message||"unknown package failure",["frontend package failed",`cwd: ${i.cwd}`,"package output:",n].join("\n"))),this.exitCode=1,this.name="FrontendPackageError",this.details=p}}function D(e){if(!E(e))return{output:String(e)};let t=N({stdout:e.stdout,stderr:e.stderr,output:e.all??e.output}),r=!!(t.stdout||t.stderr||t.output);return{exitCode:"number"==typeof e.exitCode?e.exitCode:void 0,signal:"string"==typeof e.signal?e.signal:void 0,shortMessage:r||"string"!=typeof e.shortMessage?void 0:e.shortMessage,originalMessage:"string"==typeof e.originalMessage?e.originalMessage:r||"string"!=typeof e.message?void 0:e.message,...t}}function T(e){return g(Buffer.isBuffer(e)?e.toString("utf8"):"string"==typeof e?e:"").replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n").map(e=>e.trimEnd()).join("\n").trim()||void 0}function H(e){let t,r=T(e);if(!r)return;let i=(t=[r.search(/(^|\n)error\s+Build error:/i),r.search(/(^|\n)Build error:/i),r.search(/(^|\n)File:\s/i),r.search(/(^|\n)\s*[×x]\s+.*TS\d+:/i)].filter(e=>e>=0)).length>0?Math.min(...t):-1,n=i>=0?r.slice(i).trim():r;return n.length<=4e3?n:`${n.slice(0,4e3).trimEnd()}
2
- ... output truncated ...`}function W(){return new h("upload").description("上传产物并触发云构建").option("--app-id <app-id>","兼容参数;必须与 manifest.app_key 一致").option("--project <path>","项目路径;默认使用当前目录",".").option("--manifest <path>","manifest.yaml 路径;默认按项目布局自动解析").option("--skill <path>","Skill 目录路径;默认按项目布局自动解析,目录根部必须包含 SKILL.md").option("--frontend-code <path>","前端源码目录路径;默认按项目布局自动解析").option("--keep-packages","上传后保留本次打包生成的临时包,用于调试",!1).action(async(e,t)=>v(t,t=>q(t,e)))}async function q(e,r){let a,s=$(r.project),p=G(r.project,r.manifest,s.manifestPath),d=G(r.project,r.skill,s.skillDirectory),f=G(r.project,r.frontendCode,_(r.project,s.frontendDirectory)),h=x(r.project,r.appId,p),g=r.keepPackages,v=(i(a=c("/tmp","dbx","artifacts-upload"),{recursive:!0}),n(c(a,"upload-"))),y="",I="",b="",k=[];try{var C,S,R,j,B;let r,i,n,a=[],s=await z(f,{appId:h});R=p,j=v,ei(R,"manifest"),r=c(j,"manifest.yaml"),t(R,r),y=r,k.push(Z({type:"manifest",file:y}));let l=await ee(y),_=(C=o(y,"utf8"),S=l.manifest,(i=P(function(e){try{return m.parse(e)}catch{return}}(C))??P(S))?function(e){let t,r=e.trim();try{t=new URL(r)}catch{return M(r,"invalid_url","manifest.mcp_server.end_point must be a valid http(s) URL.")}if("http:"!==t.protocol&&"https:"!==t.protocol)return M(r,"invalid_protocol","manifest.mcp_server.end_point must use http:// or https://.");let i=function(e){if(!e)return"empty_hostname";if("localhost"===e||e.endsWith(".localhost"))return"localhost";if(e.endsWith(".local")||e.endsWith(".lan")||e.endsWith(".internal"))return"private_hostname";if(!e.includes(".")&&!e.includes(":"))return"unqualified_hostname";let t=O(e)??function(e){let t="::ffff:";if(!e.startsWith(t))return;let r=e.slice(t.length),i=O(r);if(i)return i;let n=r.split(":");if(2!==n.length)return;let o=n.map(e=>Number.parseInt(e,16));if(o.some((e,t)=>!/^[0-9a-f]{1,4}$/i.test(n[t])||!Number.isInteger(e)||e<0||e>65535))return;let[a,s]=o;return[a>>8,255&a,s>>8,255&s]}(e);return t?function(e){let[t,r]=e;return 10===t?"private_ipv4":127===t?"loopback_ipv4":172===t&&r>=16&&r<=31||192===t&&168===r?"private_ipv4":169===t&&254===r?"link_local_ipv4":100===t&&r>=64&&r<=127?"carrier_grade_nat_ipv4":0===t?"reserved_ipv4":192===t&&0===e[1]&&2===e[2]||198===t&&51===e[1]&&100===e[2]||203===t&&0===e[1]&&113===e[2]?"documentation_ipv4":198===t&&(18===r||19===r)?"benchmark_ipv4":t>=224?"reserved_ipv4":void 0}(t):e.includes(":")?function(e){if("::1"===e||"0:0:0:0:0:0:0:1"===e)return"loopback_ipv6";let t=Number.parseInt(e.split(":")[0]||"0",16);if(Number.isFinite(t)){if((65024&t)==64512)return"unique_local_ipv6";if((65472&t)==65152)return"link_local_ipv6"}}(e):void 0}(t.hostname.replace(/^\[/,"").replace(/\]$/,"").toLowerCase());return i?M(r,i,"manifest.mcp_server.end_point points to a local or private network address that cloud build and real devices cannot reach."):{checked:!0,endpoint:r,cloud_reachable:!0}}(i):{checked:!1,cloud_reachable:!1,reason:"mcp_endpoint_missing",message:"manifest.mcp_server.end_point is missing"});_.checked&&!_.cloud_reachable&&process.stderr.write(`[WARNING]
3
- ${(n=_.endpoint??"(missing)",`manifest.mcp_server.end_point may not be reachable from cloud build or real devices.
4
- endpoint: ${n}
5
- reason: ${_.reason??"unknown"}
1
+ import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";import"./yaml.js";import{isRecord as t,runCommand as r,command_Command as i,getLastHttpResponseLogId as n}from"./1664.js";import{uploadMiniAppVersionDraftPackage as o,verifyYAML as a,submitMiniAppVersionDraft as s,uploadMiniAppVersionDraftSourceCode as l}from"./app.js";import{sourceTypeForWorkspaceFileType as d,miniAppVersionDetailUrl as p,describeWorkspaceUpload as u,resolveAppKey as c}from"./5732.js";import{resolveProjectLayout as f}from"./project-layout.js";var _={};e.r(_),e.d(_,{__testOnly:()=>V,default:()=>O});let h=e("../../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/index.js");function m(e){if(!t(e))return;let r=t(e.mcp_server)?e.mcp_server:void 0,i=r?.end_point;return"string"==typeof i&&i.trim()?i:void 0}function g(e,t,r){return{checked:!0,endpoint:e,cloud_reachable:!1,reason:t,message:r}}function v(e){let t=e.split(".");if(4!==t.length)return;let r=t.map(e=>Number(e));if(!r.some(e=>!Number.isInteger(e)||e<0||e>255))return r}let w=e("node:fs"),y=e("node:util");async function E(e,t={}){let r=L(e),i={cwd:r};try{await b({action:"build",appDir:r,appId:t.appId})}catch(e){throw new S(r,e,i)}return i}async function I(e,t){let r=L(e),i={cwd:r,output_dir:t},n="";try{i.archive_path=n=(await b({action:"cloudPackage",appDir:r,outputDir:t})).archivePath||""}catch(e){throw new C(r,e,i)}if(!n)throw new C(r,Error("DoubaoAppsSDK.cloudPackage did not return an archive path"),i);return n}function L(e){if(!(0,w.existsSync)(e))throw Error(`frontend_code path not found: ${e}`);if((0,w.statSync)(e).isFile())throw Error(`frontend_code must be a directory: ${e}`);return(0,w.realpathSync)(e)}async function b(e){let r,i,n,o,a=process.cwd(),s={CI:process.env.CI,FORCE_COLOR:process.env.FORCE_COLOR,NO_COLOR:process.env.NO_COLOR},l=(r=[],i=[],n=process.stdout.write,o=process.stderr.write,process.stdout.write=k(r),process.stderr.write=k(i),{result(){let e=U({stdout:r.join(""),stderr:i.join("")});return{...e,...e.stdout||e.stderr?{output:$([e.stdout,e.stderr].filter(Boolean).join("\n"))}:{}}},restore(){process.stdout.write=n,process.stderr.write=o}});try{process.chdir(e.appDir),process.env.CI="true",process.env.FORCE_COLOR="0",process.env.NO_COLOR="1";let{DoubaoAppsSDK:t}=await import("./sdk.js"),r=new t(e.appDir);if("build"===e.action)return await r.build(e.appId?{appId:e.appId}:void 0),l.result();let i=await r.cloudPackage({outputDir:e.outputDir});return{...l.result(),archivePath:i}}catch(r){let e=l.result();throw t(r)&&Object.assign(r,e),r}finally{l.restore(),process.chdir(a),function(e){for(let[t,r]of Object.entries(e))void 0===r?delete process.env[t]:process.env[t]=r}(s)}}function k(e){return(t,r,i)=>{e.push("string"==typeof t?t:Buffer.from(t).toString("string"==typeof r?r:"utf8"));let n="function"==typeof r?r:i;return n?.(),!0}}function U(e){let t=$(e.stdout),r=$(e.stderr),i=$(e.output);return{...t?{stdout:t}:{},...r?{stderr:r}:{},...i?{output:i}:{}}}class S extends Error{exitCode=1;details;constructor(e,t,r){var i;let n,o=x(t),a=r?.stdout||o.stdout,s=r?.stderr||o.stderr,l=P(r?.output||o.output||s||a),d={code:"frontend_build_check_failed",cwd:r?.cwd||e,...void 0===o.exitCode?{}:{exit_code:o.exitCode},...o.signal?{signal:o.signal}:{},...o.shortMessage?{short_message:o.shortMessage}:{},...o.originalMessage?{original_message:o.originalMessage}:{},...l?{output:l}:{}};super((n=(i=d).output||i.stderr||i.stdout||i.short_message||i.original_message||"unknown build failure",["frontend build check failed",`cwd: ${i.cwd}`,"build output:",n].join("\n"))),this.name="FrontendBuildCheckError",this.details=d}}class C extends Error{exitCode=1;details;constructor(e,t,r){var i;let n,o=x(t),a=r?.stdout||o.stdout,s=r?.stderr||o.stderr,l=P(r?.output||o.output||s||a),d={code:"frontend_package_failed",cwd:r?.cwd||e,output_dir:r?.output_dir??"",...r?.archive_path?{archive_path:r.archive_path}:{},...void 0===o.exitCode?{}:{exit_code:o.exitCode},...o.signal?{signal:o.signal}:{},...o.shortMessage?{short_message:o.shortMessage}:{},...o.originalMessage?{original_message:o.originalMessage}:{},...l?{output:l}:{}};super((n=(i=d).output||i.stderr||i.stdout||i.short_message||i.original_message||"unknown package failure",["frontend package failed",`cwd: ${i.cwd}`,"package output:",n].join("\n"))),this.name="FrontendPackageError",this.details=d}}function x(e){if(!t(e))return{output:String(e)};let r=U({stdout:e.stdout,stderr:e.stderr,output:e.all??e.output}),i=!!(r.stdout||r.stderr||r.output);return{exitCode:"number"==typeof e.exitCode?e.exitCode:void 0,signal:"string"==typeof e.signal?e.signal:void 0,shortMessage:i||"string"!=typeof e.shortMessage?void 0:e.shortMessage,originalMessage:"string"==typeof e.originalMessage?e.originalMessage:i||"string"!=typeof e.message?void 0:e.message,...r}}function $(e){let t=Buffer.isBuffer(e)?e.toString("utf8"):"string"==typeof e?e:"";return(0,y.stripVTControlCharacters)(t).replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n").map(e=>e.trimEnd()).join("\n").trim()||void 0}function P(e){let t,r=$(e);if(!r)return;let i=(t=[r.search(/(^|\n)error\s+Build error:/i),r.search(/(^|\n)Build error:/i),r.search(/(^|\n)File:\s/i),r.search(/(^|\n)\s*[×x]\s+.*TS\d+:/i)].filter(e=>e>=0)).length>0?Math.min(...t):-1,n=i>=0?r.slice(i).trim():r;return n.length<=4e3?n:`${n.slice(0,4e3).trimEnd()}
2
+ ... output truncated ...`}let M=e("node:path");function O(){return new i("upload").description("上传产物并触发云构建").option("--app-id <app-id>","兼容参数;必须与 manifest.app_key 一致").option("--project <path>","项目路径;默认使用当前目录",".").option("--manifest <path>","manifest.yaml 路径;默认按项目布局自动解析").option("--skill <path>","Skill 目录路径;默认按项目布局自动解析,目录根部必须包含 SKILL.md").option("--frontend-code <path>","前端源码目录路径;默认按项目布局自动解析").option("--keep-packages","上传后保留本次打包生成的临时包,用于调试",!1).action(async(e,t)=>r(t,t=>j(t,e)))}async function j(e,r){let i,o=f(r.project),a=z(r.project,r.manifest,o.manifestPath),l=z(r.project,r.skill,o.skillDirectory),d=z(r.project,r.frontendCode,(0,M.resolve)(r.project,o.frontendDirectory)),u=c(r.project,r.appId,a),_=r.keepPackages,y=(i=(0,M.join)("/tmp","dbx","artifacts-upload"),(0,w.mkdirSync)(i,{recursive:!0}),(0,w.mkdtempSync)((0,M.join)(i,"upload-"))),I="",L="",b="",k=[];try{var U,S,C,x,$;let t,r,i,o=[],c=await E(d,{appId:u});C=a,x=y,q(C,"manifest"),t=(0,M.join)(x,"manifest.yaml"),(0,w.copyFileSync)(C,t),I=t,k.push(A({type:"manifest",file:I}));let f=await T(I),P=(U=(0,w.readFileSync)(I,"utf8"),S=f.manifest,(r=m(function(e){try{return h.qg(e)}catch{return}}(U))??m(S))?function(e){let t,r=e.trim();try{t=new URL(r)}catch{return g(r,"invalid_url","manifest.mcp_server.end_point must be a valid http(s) URL.")}if("http:"!==t.protocol&&"https:"!==t.protocol)return g(r,"invalid_protocol","manifest.mcp_server.end_point must use http:// or https://.");let i=function(e){if(!e)return"empty_hostname";if("localhost"===e||e.endsWith(".localhost"))return"localhost";if(e.endsWith(".local")||e.endsWith(".lan")||e.endsWith(".internal"))return"private_hostname";if(!e.includes(".")&&!e.includes(":"))return"unqualified_hostname";let t=v(e)??function(e){let t="::ffff:";if(!e.startsWith(t))return;let r=e.slice(t.length),i=v(r);if(i)return i;let n=r.split(":");if(2!==n.length)return;let o=n.map(e=>Number.parseInt(e,16));if(o.some((e,t)=>!/^[0-9a-f]{1,4}$/i.test(n[t])||!Number.isInteger(e)||e<0||e>65535))return;let[a,s]=o;return[a>>8,255&a,s>>8,255&s]}(e);return t?function(e){let[t,r]=e;return 10===t?"private_ipv4":127===t?"loopback_ipv4":172===t&&r>=16&&r<=31||192===t&&168===r?"private_ipv4":169===t&&254===r?"link_local_ipv4":100===t&&r>=64&&r<=127?"carrier_grade_nat_ipv4":0===t?"reserved_ipv4":192===t&&0===e[1]&&2===e[2]||198===t&&51===e[1]&&100===e[2]||203===t&&0===e[1]&&113===e[2]?"documentation_ipv4":198===t&&(18===r||19===r)?"benchmark_ipv4":t>=224?"reserved_ipv4":void 0}(t):e.includes(":")?function(e){if("::1"===e||"0:0:0:0:0:0:0:1"===e)return"loopback_ipv6";let t=Number.parseInt(e.split(":")[0]||"0",16);if(Number.isFinite(t)){if((65024&t)==64512)return"unique_local_ipv6";if((65472&t)==65152)return"link_local_ipv6"}}(e):void 0}(t.hostname.replace(/^\[/,"").replace(/\]$/,"").toLowerCase());return i?g(r,i,"manifest.mcp_server.end_point points to a local or private network address that cloud build and real devices cannot reach."):{checked:!0,endpoint:r,cloud_reachable:!0}}(r):{checked:!1,cloud_reachable:!1,reason:"mcp_endpoint_missing",message:"manifest.mcp_server.end_point is missing"});P.checked&&!P.cloud_reachable&&process.stderr.write(`[WARNING]
3
+ ${(i=P.endpoint??"(missing)",`manifest.mcp_server.end_point may not be reachable from cloud build or real devices.
4
+ endpoint: ${i}
5
+ reason: ${P.reason??"unknown"}
6
6
 
7
7
  Impact:
8
8
  - Upload will continue.
@@ -10,6 +10,5 @@ Impact:
10
10
 
11
11
  Action:
12
12
  Set manifest.mcp_server.end_point to an http(s) MCP URL reachable from the cloud/device environment before release.`)}
13
- `),a.push(await Y(h,{type:"manifest",file:y})),I=await X(d,v),k.push(Z({type:"skill",file:I}));let E=function(e){let t,r=o(e);if(r.byteLength<22||(t=r.readUInt32LE(0),0x4034b50!==t&&0x6054b50!==t&&0x8074b50!==t))throw Error(`invalid skill zip: ${e} is not a zip file`);if(!(function(e){let t=function(e){let t=Math.max(0,e.length-65535-22);for(let r=e.length-22;r>=t;r-=1)if(0x6054b50===e.readUInt32LE(r))return r;return -1}(e);if(t<0)return[];let r=e.readUInt32LE(t+12),i=e.readUInt32LE(t+16),n=Math.min(e.length,i+r),o=[],a=i;for(;a+46<=n&&0x2014b50===e.readUInt32LE(a);){let t=e.readUInt16LE(a+28),r=e.readUInt16LE(a+30),i=e.readUInt16LE(a+32),n=a+46,s=n+t;o.push(e.toString("utf8",n,s)),a=s+r+i}return o})(r).includes("SKILL.md"))throw Error("invalid skill zip: zip root must contain SKILL.md");return{valid:!0,file_name:u(e),contains_skill_md:!0}}(I);a.push(await Y(h,{type:"skill",file:I})),b=await J(f,v),k.push(Z({type:"frontend_code",file:b})),a.push(await Y(h,{type:"frontend_code",file:b}));let x=await L(h),$=x.data?.version_tag||(B=a,B.find(e=>e.version_tag)?.version_tag??""),K={app_id:h,version_tag:$,status:"submitted",submitted:!0,build_triggered:!0,uploaded_artifacts:a.map(e=>e.type),packages:k,next:{status_command:`dbx app artifacts status --app-id ${h} --version-tag ${$} --poll`,version_detail_url:U(h,$)},...g?{kept_packages:{temp_dir:v,manifest:y,skill_zip:I,frontend_code_zip:b}}:{},...e.debug?{debug:{frontend_build_check:s,manifest:l,skill:E,uploads:a,endpoints:{manifest_validate:{method:"POST",path:"/app_developer/api/yaml/verify"},upload:{method:"POST",path:"/app_developer/api/apps/:app_key/draft/upload"},source_code_upload_start:{method:"POST",path:"/app_developer/api/apps/:app_key/draft/source_code/upload/start"},source_code_tos_upload:{method:"PUT",path:"<upload_url>"},source_code_upload_finish:{method:"POST",path:"/app_developer/api/apps/:app_key/draft/source_code/upload/finish"},submit:{method:"POST",path:"/app_developer/api/apps/:app_key/draft/submit"}}}}:{},log_id:x.log_id??w()??""};for(let t of(e.log("artifacts uploaded and build triggered"),e.log(`app_id: ${h}`),e.log(`version_tag: ${$}`),e.log(`status: ${K.status}`),e.log(`next: ${K.next.status_command}`),e.log(`version detail: ${K.next.version_detail_url}`),e.log("package sizes:"),k))e.log(` ${t.type}: ${t.file_name} (${t.file_size_human})`);return g&&e.log(`kept packages: ${v}`),K}catch(e){throw function(e,t){let r=e instanceof Error?e:Error(String(e));if(0===t.length)return r;let i=t.map(e=>({...e})),n=r.details;return r.details=E(n)?{...n,package_sizes:i}:{...void 0===n?{}:{cause:n},package_sizes:i},r.message.includes("package sizes:")||(r.message=`${r.message}
14
- ${["package sizes:",...t.map(e=>` ${e.type}: ${e.file_name} (${e.file_size_human})`)].join("\n")}`),r}(e,k)}finally{g||l(v,{recursive:!0,force:!0})}}function G(e,t,r){return t?.trim()?_(e,t.trim()):r}async function X(e,t){var r,i,n;let s,l;if(Q(e,"skill"),p(e).isFile())throw Error(`skill must be a directory: ${e}`);ei(c(e,"SKILL.md"),"skill");let u=c(t,"skill.zip");return r=e,i=u,!function(e,t){let r=[],i=[],n=0;for(let t of e){let e=t.data,o=Buffer.from(t.zipPath),a=function(e){let t=0xffffffff;for(let r of e)t=t>>>8^V[(t^r)&255];return(0xffffffff^t)>>>0}(e),s=Buffer.alloc(30);s.writeUInt32LE(0x4034b50,0),s.writeUInt16LE(20,4),s.writeUInt16LE(2048,6),s.writeUInt16LE(0,8),s.writeUInt16LE(0,10),s.writeUInt16LE(0,12),s.writeUInt32LE(a,14),s.writeUInt32LE(e.length,18),s.writeUInt32LE(e.length,22),s.writeUInt16LE(o.length,26),s.writeUInt16LE(0,28),r.push(s,o,e);let l=Buffer.alloc(46);l.writeUInt32LE(0x2014b50,0),l.writeUInt16LE(20,4),l.writeUInt16LE(20,6),l.writeUInt16LE(2048,8),l.writeUInt16LE(0,10),l.writeUInt16LE(0,12),l.writeUInt16LE(0,14),l.writeUInt32LE(a,16),l.writeUInt32LE(e.length,20),l.writeUInt32LE(e.length,24),l.writeUInt16LE(o.length,28),l.writeUInt16LE(0,30),l.writeUInt16LE(0,32),l.writeUInt16LE(0,34),l.writeUInt16LE(0,36),l.writeUInt32LE(0,38),l.writeUInt32LE(n,42),i.push(l,o),n+=s.length+o.length+e.length}let o=n,a=Buffer.concat(i),s=Buffer.alloc(22);s.writeUInt32LE(0x6054b50,0),s.writeUInt16LE(0,4),s.writeUInt16LE(0,6),s.writeUInt16LE(e.length,8),s.writeUInt16LE(e.length,10),s.writeUInt32LE(a.length,12),s.writeUInt32LE(o,16),s.writeUInt16LE(0,20),d(t,Buffer.concat([...r,a,s]))}((n=r,s=[],(l=e=>{for(let t of a(e,{withFileTypes:!0})){if(".DS_Store"===t.name||"__MACOSX"===t.name)continue;let r=c(e,t.name);if(t.isDirectory()){l(r);continue}t.isFile()&&s.push({absolutePath:r,zipPath:f(n,r).split(/[\\/]/g).join("/")})}})(n),s.sort((e,t)=>e.zipPath.localeCompare(t.zipPath))).map(e=>({zipPath:e.zipPath,data:o(e.absolutePath)})),i),u}async function J(e,t){if(Q(e,"frontend_code"),p(e).isFile())throw Error(`frontend_code must be a directory: ${e}`);let r=await R(e,t);return ei(r,"frontend_code"),r}function Q(e,t){if(!r(e))throw Error(`${t} path not found: ${e}`)}let V=function(){let e=[];for(let t=0;t<256;t+=1){let r=t;for(let e=0;e<8;e+=1)r=1&r?0xedb88320^r>>>1:r>>>1;e[t]=r>>>0}return e}();async function Y(e,t){if("frontend_code"===t.type){let r=await b({appKey:e,filePath:t.file});return{...C(t),source_type:k(t.type),version_tag:r.data?.version_tag??""}}let r=await y({appKey:e,sourceType:k(t.type),filePath:t.file,contentType:"manifest"===t.type?"application/x-yaml":"application/zip"});return{...C(t),source_type:k(t.type),version_tag:r.data?.version_tag??""}}function Z(e){let t=C(e);return{type:t.type,file_name:t.file_name,file_size:t.file_size,file_size_human:function(e){let t=["B","KiB","MiB","GiB"],r=e,i=0;for(;r>=1024&&i<t.length-1;)r/=1024,i+=1;return 0===i?`${e} B`:`${r>=10?r.toFixed(1):r.toFixed(2)} ${t[i]}`}(t.file_size)}}async function ee(e){let t=await I(o(e,"utf8"),"strict"),r=t.data,i={valid:!!r?.success,manifest:r?.manifest,errors:et(r?.errors??[]),warnings:et(r?.warnings??[]),log_id:t.log_id??w()??""};if(!i.valid)throw new er(i);return{...i,valid:!0}}function et(e){return e.map(e=>({code:e.code,path:e.path,message:e.message}))}class er extends Error{constructor(e){super("manifest validation failed"),this.result=e,this.exitCode=1,this.logId=e.log_id,this.details=e}}function ei(e,t){if(!r(e)||!p(e).isFile())throw Error(`${t} file not found: ${e}`)}export{S as upload_namespaceObject};
15
- //# sourceMappingURL=upload.js.map
13
+ `),o.push(await N(u,{type:"manifest",file:I})),L=await F(l,y),k.push(A({type:"skill",file:L}));let O=function(e){let t,r=(0,w.readFileSync)(e);if(r.byteLength<22||(t=r.readUInt32LE(0),0x4034b50!==t&&0x6054b50!==t&&0x8074b50!==t))throw Error(`invalid skill zip: ${e} is not a zip file`);if(!(function(e){let t=function(e){let t=Math.max(0,e.length-65535-22);for(let r=e.length-22;r>=t;r-=1)if(0x6054b50===e.readUInt32LE(r))return r;return -1}(e);if(t<0)return[];let r=e.readUInt32LE(t+12),i=e.readUInt32LE(t+16),n=Math.min(e.length,i+r),o=[],a=i;for(;a+46<=n&&0x2014b50===e.readUInt32LE(a);){let t=e.readUInt16LE(a+28),r=e.readUInt16LE(a+30),i=e.readUInt16LE(a+32),n=a+46,s=n+t;o.push(e.toString("utf8",n,s)),a=s+r+i}return o})(r).includes("SKILL.md"))throw Error("invalid skill zip: zip root must contain SKILL.md");return{valid:!0,file_name:(0,M.basename)(e),contains_skill_md:!0}}(L);o.push(await N(u,{type:"skill",file:L})),b=await K(d,y),k.push(A({type:"frontend_code",file:b})),o.push(await N(u,{type:"frontend_code",file:b}));let j=await s(u),z=j.data?.version_tag||($=o,$.find(e=>e.version_tag)?.version_tag??""),R={app_id:u,version_tag:z,status:"submitted",submitted:!0,build_triggered:!0,uploaded_artifacts:o.map(e=>e.type),packages:k,next:{status_command:`dbx app artifacts status --app-id ${u} --version-tag ${z} --poll`,version_detail_url:p(u,z)},..._?{kept_packages:{temp_dir:y,manifest:I,skill_zip:L,frontend_code_zip:b}}:{},...e.debug?{debug:{frontend_build_check:c,manifest:f,skill:O,uploads:o,endpoints:{manifest_validate:{method:"POST",path:"/app_developer/api/yaml/verify"},upload:{method:"POST",path:"/app_developer/api/apps/:app_key/draft/upload"},source_code_upload_start:{method:"POST",path:"/app_developer/api/apps/:app_key/draft/source_code/upload/start"},source_code_tos_upload:{method:"PUT",path:"<upload_url>"},source_code_upload_finish:{method:"POST",path:"/app_developer/api/apps/:app_key/draft/source_code/upload/finish"},submit:{method:"POST",path:"/app_developer/api/apps/:app_key/draft/submit"}}}}:{},log_id:j.log_id??n()??""};for(let t of(e.log("artifacts uploaded and build triggered"),e.log(`app_id: ${u}`),e.log(`version_tag: ${z}`),e.log(`status: ${R.status}`),e.log(`next: ${R.next.status_command}`),e.log(`version detail: ${R.next.version_detail_url}`),e.log("package sizes:"),k))e.log(` ${t.type}: ${t.file_name} (${t.file_size_human})`);return _&&e.log(`kept packages: ${y}`),R}catch(e){throw function(e,r){let i=e instanceof Error?e:Error(String(e));if(0===r.length)return i;let n=r.map(e=>({...e})),o=i.details;return i.details=t(o)?{...o,package_sizes:n}:{...void 0===o?{}:{cause:o},package_sizes:n},i.message.includes("package sizes:")||(i.message=`${i.message}
14
+ ${["package sizes:",...r.map(e=>` ${e.type}: ${e.file_name} (${e.file_size_human})`)].join("\n")}`),i}(e,k)}finally{_||(0,w.rmSync)(y,{recursive:!0,force:!0})}}function z(e,t,r){return t?.trim()?(0,M.resolve)(e,t.trim()):r}async function F(e,t){var r,i,n;let o,a;if(R(e,"skill"),(0,w.statSync)(e).isFile())throw Error(`skill must be a directory: ${e}`);q((0,M.join)(e,"SKILL.md"),"skill");let s=(0,M.join)(t,"skill.zip");return r=e,i=s,!function(e,t){let r=[],i=[],n=0;for(let t of e){let e=t.data,o=Buffer.from(t.zipPath),a=function(e){let t=0xffffffff;for(let r of e)t=t>>>8^B[(t^r)&255];return(0xffffffff^t)>>>0}(e),s=Buffer.alloc(30);s.writeUInt32LE(0x4034b50,0),s.writeUInt16LE(20,4),s.writeUInt16LE(2048,6),s.writeUInt16LE(0,8),s.writeUInt16LE(0,10),s.writeUInt16LE(0,12),s.writeUInt32LE(a,14),s.writeUInt32LE(e.length,18),s.writeUInt32LE(e.length,22),s.writeUInt16LE(o.length,26),s.writeUInt16LE(0,28),r.push(s,o,e);let l=Buffer.alloc(46);l.writeUInt32LE(0x2014b50,0),l.writeUInt16LE(20,4),l.writeUInt16LE(20,6),l.writeUInt16LE(2048,8),l.writeUInt16LE(0,10),l.writeUInt16LE(0,12),l.writeUInt16LE(0,14),l.writeUInt32LE(a,16),l.writeUInt32LE(e.length,20),l.writeUInt32LE(e.length,24),l.writeUInt16LE(o.length,28),l.writeUInt16LE(0,30),l.writeUInt16LE(0,32),l.writeUInt16LE(0,34),l.writeUInt16LE(0,36),l.writeUInt32LE(0,38),l.writeUInt32LE(n,42),i.push(l,o),n+=s.length+o.length+e.length}let o=n,a=Buffer.concat(i),s=Buffer.alloc(22);s.writeUInt32LE(0x6054b50,0),s.writeUInt16LE(0,4),s.writeUInt16LE(0,6),s.writeUInt16LE(e.length,8),s.writeUInt16LE(e.length,10),s.writeUInt32LE(a.length,12),s.writeUInt32LE(o,16),s.writeUInt16LE(0,20),(0,w.writeFileSync)(t,Buffer.concat([...r,a,s]))}((n=r,o=[],(a=e=>{for(let t of(0,w.readdirSync)(e,{withFileTypes:!0})){if(".DS_Store"===t.name||"__MACOSX"===t.name)continue;let r=(0,M.join)(e,t.name);if(t.isDirectory()){a(r);continue}t.isFile()&&o.push({absolutePath:r,zipPath:(0,M.relative)(n,r).split(/[\\/]/g).join("/")})}})(n),o.sort((e,t)=>e.zipPath.localeCompare(t.zipPath))).map(e=>({zipPath:e.zipPath,data:(0,w.readFileSync)(e.absolutePath)})),i),s}async function K(e,t){if(R(e,"frontend_code"),(0,w.statSync)(e).isFile())throw Error(`frontend_code must be a directory: ${e}`);let r=await I(e,t);return q(r,"frontend_code"),r}function R(e,t){if(!(0,w.existsSync)(e))throw Error(`${t} path not found: ${e}`)}let B=function(){let e=[];for(let t=0;t<256;t+=1){let r=t;for(let e=0;e<8;e+=1)r=1&r?0xedb88320^r>>>1:r>>>1;e[t]=r>>>0}return e}();async function N(e,t){if("frontend_code"===t.type){let r=await l({appKey:e,filePath:t.file});return{...u(t),source_type:d(t.type),version_tag:r.data?.version_tag??""}}let r=await o({appKey:e,sourceType:d(t.type),filePath:t.file,contentType:"manifest"===t.type?"application/x-yaml":"application/zip"});return{...u(t),source_type:d(t.type),version_tag:r.data?.version_tag??""}}function A(e){let t=u(e);return{type:t.type,file_name:t.file_name,file_size:t.file_size,file_size_human:function(e){let t=["B","KiB","MiB","GiB"],r=e,i=0;for(;r>=1024&&i<t.length-1;)r/=1024,i+=1;return 0===i?`${e} B`:`${r>=10?r.toFixed(1):r.toFixed(2)} ${t[i]}`}(t.file_size)}}async function T(e){let t=await a((0,w.readFileSync)(e,"utf8"),"strict"),r=t.data,i={valid:!!r?.success,manifest:r?.manifest,errors:D(r?.errors??[]),warnings:D(r?.warnings??[]),log_id:t.log_id??n()??""};if(!i.valid)throw new H(i);return{...i,valid:!0}}function D(e){return e.map(e=>({code:e.code,path:e.path,message:e.message}))}class H extends Error{result;exitCode=1;logId;details;constructor(e){super(W(e.errors)),this.result=e,this.logId=e.log_id,this.details=e}}function W(e){return 0===e.length?"manifest validation failed":["manifest validation failed","manifest validation errors:",...e.map(e=>` - [${e.code}] ${e.path}: ${e.message}`)].join("\n")}function q(e,t){if(!(0,w.existsSync)(e)||!(0,w.statSync)(e).isFile())throw Error(`${t} file not found: ${e}`)}let V={ManifestValidationError:H,formatManifestValidationFailure:W};export{_ as upload_namespaceObject};
package/dist/validate.js CHANGED
@@ -1,2 +1 @@
1
- import"node:module";import{existsSync as i,readFileSync as e,statSync as a}from"node:fs";import{Command as n}from"commander";import{verifyYAML as o}from"./app.js";import{CliError as t,runCommand as r}from"./564.js";async function f(n,r){r||n.error("manifest file is required: pass <manifest.yaml> or --file <manifest.yaml>"),i(r)&&a(r).isFile()||n.error(`manifest file not found: ${r}`);let f=e(r,"utf8"),l=await o(f,"compatible"),m=l.data,d={valid:!!m?.success,manifest:m?.manifest,errors:s(m?.errors??[]),warnings:s(m?.warnings??[]),log_id:l.log_id??""};if(n.log(`manifest validation: ${d.valid?"passed":"failed"}`),n.log(JSON.stringify(d,null,2)),!d.valid)throw new t("manifest validation failed",{json:d,logId:d.log_id});return d}function s(i){return i.map(i=>({code:i.code,path:i.path,message:i.message}))}export default function(){return new n("validate").description("校验 manifest 配置").argument("[file]","manifest.yaml 路径").option("-f, --file <file>","manifest.yaml 路径").action(async(i,e,a)=>r(a,a=>f(a,e.file??i)))};
2
- //# sourceMappingURL=validate.js.map
1
+ import"node:module";import{__webpack_require__ as i}from"./rslib-runtime.js";import{command_Command as e,CliError as a,runCommand as n}from"./1664.js";import{verifyYAML as t}from"./app.js";let o=i("node:fs");async function s(i,e){e||i.error("manifest file is required: pass <manifest.yaml> or --file <manifest.yaml>"),(0,o.existsSync)(e)&&(0,o.statSync)(e).isFile()||i.error(`manifest file not found: ${e}`);let n=(0,o.readFileSync)(e,"utf8"),s=await t(n,"compatible"),l=s.data,f={valid:!!l?.success,manifest:l?.manifest,errors:r(l?.errors??[]),warnings:r(l?.warnings??[]),log_id:s.log_id??""};if(i.log(`manifest validation: ${f.valid?"passed":"failed"}`),i.log(JSON.stringify(f,null,2)),!f.valid)throw new a("manifest validation failed",{json:f,logId:f.log_id});return f}function r(i){return i.map(i=>({code:i.code,path:i.path,message:i.message}))}export default function(){return new e("validate").description("校验 manifest 配置").argument("[file]","manifest.yaml 路径").option("-f, --file <file>","manifest.yaml 路径").action(async(i,e,a)=>n(a,a=>s(a,e.file??i)))};