@picoxr/pico-release-cli-row 0.0.0-stage → 0.1.7

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/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ Copyright © 2026 PICO Immersive Pte. Ltd. and its affiliates. All rights reserved.
2
+
3
+ Your use of this software is subject to the PICO SDK License Terms, available at https://developer.picoxr.com/document/distribute/sdk-license-terms/. THIS SOFTWARE IS LICENSED AND DISTRIBUTED "AS-IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, GUARANTEES OR CONDITIONS OF ANY KIND, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
package/README.md CHANGED
@@ -1,3 +1,116 @@
1
- # Temporary Holding Version
1
+ # VibeLab Release CLI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ PICO Vibe Lab 命令行工具(类 Git 五步发布工作流):在终端 / CI / Agent 环境中通过 `init`、`add`、`commit`、`push`、`state` 五个核心命令完成应用首次发布与已上线应用迭代更新。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g @picoxr/pico-release-cli-row@latest --registry https://registry.npmjs.org
9
+ ```
10
+
11
+ 要求 Node.js >= 20。
12
+
13
+ 本文示例使用当前包的命令名。US、ROW 各自有独立的包及命令,分别消费对应区域的
14
+ Auth 登录态。业务 API、预览及 ImageX 域名目前保留国内迁移基线,后续由研发
15
+ 更新对应区域配置后重新构建发布。
16
+
17
+ ## 快速开始(类 Git 五步工作流)
18
+
19
+ 无论是**首次创建新应用**还是**已上线应用更新(仅改信息/素材或发新代码包)**,均统一使用以下 5 个命令:
20
+
21
+ ```bash
22
+ pico-release-cli-row init # 1. 生成 vibelab.yaml(或 --from-app <id> 反向拉取线上配置)
23
+ pico-release-cli-row add # 2. 校验配置与素材;若首次发版则自动在云端创建初始草稿并将 app.id 写回 vibelab.yaml
24
+ # -> 将代码与含 app.id 的 vibelab.yaml 提交并推送到 GitHub (git add / commit / push)
25
+ pico-release-cli-row commit # 3. 用最新 commit_sha 更新云端草稿(改初始草稿/改资料/发新包)并输出网页预览链接
26
+ # -> 打开 preview_url 浏览器预览/微调草稿,并勾选同意相关协议
27
+ pico-release-cli-row push --wait # 4. 将已通过 commit 保存并预览确认的云端草稿提交审核与构建 → 轮询结果
28
+ pico-release-cli-row state # 5. 查看发布状态、审核进度、驳回原因与下一步操作建议
29
+ ```
30
+
31
+ ## 核心命令参考
32
+
33
+ | 命令 | 类比 Git | 功能与底层自动编排逻辑 |
34
+ | --- | --- | --- |
35
+ | `pico-release-cli-row init [--from-app ID] [--force]` | `git init` / `git clone` | 初始化 `vibelab.yaml` 并配置 `.gitignore`;传入 `--from-app` 时从线上拉取配置(含 `app.id`)与 `.vibelab/state.json` |
36
+ | `pico-release-cli-row add` | `git add` | 校验 `vibelab.yaml`、素材(格式/尺寸/大小)和本地 Git `HEAD`;私有仓库(`repo_visibility: private`)自动获取 GitHub 只读 Deploy Key;若 `vibelab.yaml` 中尚无 `app.id`,自动在云端创建初始草稿并将 `app.id` 原位写回 `vibelab.yaml` |
37
+ | `pico-release-cli-row commit [--app ID]` | `git commit` | **智能路由更新已有 `app.id` 的云端草稿**并输出网页预览地址 `preview_url`:<br/>• 从未上线的首发应用 → 原位更新 `add` 阶段创建的初始草稿(`version_update`)<br/>• 已上线且 `version.name` 未变(且未显式指定新 `build.commit_sha`) → 发起信息更新(`info_update`, `update_type=1`)<br/>• 已上线且 `version.name` 变更(或显式指定新 `build.commit_sha`) → 发起新版本更新(`version_create`, `update_type=2`)<br/>• 已有同类型可编辑草稿 → 原位覆盖更新草稿(`version_update`;若切换更新类型则确认后清理旧草稿重建) |
38
+ | `pico-release-cli-row push [--wait] [--interval 10s] [--timeout 30m]` | `git push` | 将已通过 `commit` 保存并在网页端确认的云端草稿提交构建与审核(不会二次覆盖网页微调内容);`--wait` 持续轮询直至终态 |
39
+ | `pico-release-cli-row state [app_id] [--watch] [--interval 10s] [--timeout 30m] [--pending]` | `git status` | 聚合应用详情、线上版本、编辑中版本、待审信息更新与驳回原因(`rejection_issues`),并给出下一步操作建议 |
40
+
41
+ 全局参数:
42
+
43
+ - `--json`:stdout 输出 `{"ok":true,"data":...}`,错误输出到 stderr:`{"ok":false,"error":{"code","message","action","details?"}}`。
44
+ - `--ppe-env <lane>`:注入 PPE 泳道 Header;优先于 `VIBELAB_PPE_ENV`,泳道名必须以 `ppe_` 开头。
45
+ - `-y, --yes`:跳过确认。非交互环境(CI、`--json`)清理冲突草稿时必须显式传入。
46
+
47
+ 未传 `app_id` 时优先使用 `vibelab.yaml` 中的 `app.id`,其次回退到 `.vibelab/state.json`。
48
+
49
+ ## vibelab.yaml
50
+
51
+ ```yaml
52
+ app:
53
+ id: "1001" # 首次执行 add 时自动创建并原位回写(或由 init --from-app 生成)
54
+ name: 我的应用 # ≤ 50 字
55
+ slogan: 一句话简介 # ≤ 80 字
56
+ description: 应用描述 # ≤ 1000 字
57
+ tags: [休闲, 益智] # 1-5 个,每个 ≤ 10 字
58
+ category: game # game | application
59
+ icon: assets/icon.png # 1024x1024,jpg/png,≤ 4MB
60
+ landscape: assets/landscape.png # 2560x1440,jpg/png,≤ 5MB
61
+ detail_images: # 1-7 张,2560x1440,jpg/png,≤ 5MB
62
+ - assets/detail-1.png
63
+ videos: # 最多 3 个
64
+ - file: assets/demo.mp4 # mp4,> 0MB 且 ≤ 100MB
65
+ cover: assets/demo-cover.png
66
+ version:
67
+ name: 1.0.0 # ≤ 50 字
68
+ notes: 首个版本 # ≤ 1000 字
69
+ build:
70
+ repo_url: https://github.com/owner/repo
71
+ repo_visibility: public # public | private(private 会引导添加 Deploy Key)
72
+ # commit_sha: 省略时读取本地 git HEAD
73
+ tech_stack: unity # android_spatial | unity | ue | godot | 自定义(≤ 20 字)
74
+ ai_tool: Trae CLI # 预设或自定义(≤ 20 字)
75
+ ai_model: doubao-seed
76
+ features: [hand_tracking] # body_tracking | hand_tracking | eye_tracking | expression_simulation |
77
+ # avatar | mixed_reality | mixed_reality_capture | controller_support | none
78
+ teammates: [] # 最多 3 个,每个 ≤ 20 字
79
+ ```
80
+
81
+ 素材值以 `uri:` 开头表示已上传的远端 URI(`init --from-app` 生成),不会再读取本地文件或重新上传。
82
+
83
+ ## 本地文件
84
+
85
+ | 文件 | 作用 |
86
+ | --- | --- |
87
+ | `vibelab.yaml` | 应用、版本、素材配置,可提交 Git |
88
+ | `.vibelab/state.json` | app ID、version ID、draft ref、素材 URI |
89
+ | `.vibelab/cache.json` | 素材 SHA-256 → URI,避免重复上传 |
90
+
91
+ `.vibelab/` 会自动加入 `.gitignore`,其中不保存任何认证信息。
92
+
93
+ ## 退出码
94
+
95
+ | 退出码 | 含义 |
96
+ | --- | --- |
97
+ | 0 | 成功 |
98
+ | 1 | 未知错误 / 响应结构异常 |
99
+ | 2 | 参数或配置错误 |
100
+ | 3 | 未登录、登录过期或签名失败 |
101
+ | 4 | 网络临时错误 |
102
+ | 5 | 写请求结果未知(请先执行 `pico-release-cli-row state` 确认) |
103
+ | 6 | 业务拒绝或当前状态不允许 |
104
+ | 7 | 本地状态缺失或冲突 |
105
+ | 8 | 素材上传失败 |
106
+ | 9 | 审核驳回 / 构建失败 |
107
+ | 10 | 等待超时 |
108
+ | 130 | 用户取消 |
109
+
110
+ ## 开发与校验
111
+
112
+ ```bash
113
+ npm install
114
+ npm run quality
115
+ npm run pack:check
116
+ ```
@@ -0,0 +1,579 @@
1
+ PICO Release CLI Third-Party Notices
2
+
3
+ Generated from config/runtime-dependency-contract.json.
4
+
5
+ Runtime dependencies shipped by pico-release-cli-row:
6
+ [runtime-direct] @inquirer/prompts (MIT)
7
+
8
+ Source: https://github.com/SBoudrias/Inquirer.js
9
+
10
+ License text from installed version: 8.7.3
11
+
12
+ LICENSE:
13
+ Copyright (c) 2025 Simon Boudrias
14
+
15
+ Permission is hereby granted, free of charge, to any person
16
+ obtaining a copy of this software and associated documentation
17
+ files (the "Software"), to deal in the Software without
18
+ restriction, including without limitation the rights to use,
19
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the
21
+ Software is furnished to do so, subject to the following
22
+ conditions:
23
+
24
+ The above copyright notice and this permission notice shall be
25
+ included in all copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
29
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
31
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
32
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
33
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34
+ OTHER DEALINGS IN THE SOFTWARE.
35
+
36
+ [runtime-direct] @volcengine/openapi (Apache-2.0)
37
+
38
+ Source: https://github.com/volcengine/volc-sdk-nodejs
39
+
40
+ License text from installed version: 1.36.2
41
+
42
+ LICENSE:
43
+ Apache License
44
+ Version 2.0, January 2004
45
+ http://www.apache.org/licenses/
46
+
47
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
48
+
49
+ 1. Definitions.
50
+
51
+ "License" shall mean the terms and conditions for use, reproduction,
52
+ and distribution as defined by Sections 1 through 9 of this document.
53
+
54
+ "Licensor" shall mean the copyright owner or entity authorized by
55
+ the copyright owner that is granting the License.
56
+
57
+ "Legal Entity" shall mean the union of the acting entity and all
58
+ other entities that control, are controlled by, or are under common
59
+ control with that entity. For the purposes of this definition,
60
+ "control" means (i) the power, direct or indirect, to cause the
61
+ direction or management of such entity, whether by contract or
62
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
63
+ outstanding shares, or (iii) beneficial ownership of such entity.
64
+
65
+ "You" (or "Your") shall mean an individual or Legal Entity
66
+ exercising permissions granted by this License.
67
+
68
+ "Source" form shall mean the preferred form for making modifications,
69
+ including but not limited to software source code, documentation
70
+ source, and configuration files.
71
+
72
+ "Object" form shall mean any form resulting from mechanical
73
+ transformation or translation of a Source form, including but
74
+ not limited to compiled object code, generated documentation,
75
+ and conversions to other media types.
76
+
77
+ "Work" shall mean the work of authorship, whether in Source or
78
+ Object form, made available under the License, as indicated by a
79
+ copyright notice that is included in or attached to the work
80
+ (an example is provided in the Appendix below).
81
+
82
+ "Derivative Works" shall mean any work, whether in Source or Object
83
+ form, that is based on (or derived from) the Work and for which the
84
+ editorial revisions, annotations, elaborations, or other modifications
85
+ represent, as a whole, an original work of authorship. For the purposes
86
+ of this License, Derivative Works shall not include works that remain
87
+ separable from, or merely link (or bind by name) to the interfaces of,
88
+ the Work and Derivative Works thereof.
89
+
90
+ "Contribution" shall mean any work of authorship, including
91
+ the original version of the Work and any modifications or additions
92
+ to that Work or Derivative Works thereof, that is intentionally
93
+ submitted to Licensor for inclusion in the Work by the copyright owner
94
+ or by an individual or Legal Entity authorized to submit on behalf of
95
+ the copyright owner. For the purposes of this definition, "submitted"
96
+ means any form of electronic, verbal, or written communication sent
97
+ to the Licensor or its representatives, including but not limited to
98
+ communication on electronic mailing lists, source code control systems,
99
+ and issue tracking systems that are managed by, or on behalf of, the
100
+ Licensor for the purpose of discussing and improving the Work, but
101
+ excluding communication that is conspicuously marked or otherwise
102
+ designated in writing by the copyright owner as "Not a Contribution."
103
+
104
+ "Contributor" shall mean Licensor and any individual or Legal Entity
105
+ on behalf of whom a Contribution has been received by Licensor and
106
+ subsequently incorporated within the Work.
107
+
108
+ 2. Grant of Copyright License. Subject to the terms and conditions of
109
+ this License, each Contributor hereby grants to You a perpetual,
110
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
111
+ copyright license to reproduce, prepare Derivative Works of,
112
+ publicly display, publicly perform, sublicense, and distribute the
113
+ Work and such Derivative Works in Source or Object form.
114
+
115
+ 3. Grant of Patent License. Subject to the terms and conditions of
116
+ this License, each Contributor hereby grants to You a perpetual,
117
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
118
+ (except as stated in this section) patent license to make, have made,
119
+ use, offer to sell, sell, import, and otherwise transfer the Work,
120
+ where such license applies only to those patent claims licensable
121
+ by such Contributor that are necessarily infringed by their
122
+ Contribution(s) alone or by combination of their Contribution(s)
123
+ with the Work to which such Contribution(s) was submitted. If You
124
+ institute patent litigation against any entity (including a
125
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
126
+ or a Contribution incorporated within the Work constitutes direct
127
+ or contributory patent infringement, then any patent licenses
128
+ granted to You under this License for that Work shall terminate
129
+ as of the date such litigation is filed.
130
+
131
+ 4. Redistribution. You may reproduce and distribute copies of the
132
+ Work or Derivative Works thereof in any medium, with or without
133
+ modifications, and in Source or Object form, provided that You
134
+ meet the following conditions:
135
+
136
+ (a) You must give any other recipients of the Work or
137
+ Derivative Works a copy of this License; and
138
+
139
+ (b) You must cause any modified files to carry prominent notices
140
+ stating that You changed the files; and
141
+
142
+ (c) You must retain, in the Source form of any Derivative Works
143
+ that You distribute, all copyright, patent, trademark, and
144
+ attribution notices from the Source form of the Work,
145
+ excluding those notices that do not pertain to any part of
146
+ the Derivative Works; and
147
+
148
+ (d) If the Work includes a "NOTICE" text file as part of its
149
+ distribution, then any Derivative Works that You distribute must
150
+ include a readable copy of the attribution notices contained
151
+ within such NOTICE file, excluding those notices that do not
152
+ pertain to any part of the Derivative Works, in at least one
153
+ of the following places: within a NOTICE text file distributed
154
+ as part of the Derivative Works; within the Source form or
155
+ documentation, if provided along with the Derivative Works; or,
156
+ within a display generated by the Derivative Works, if and
157
+ wherever such third-party notices normally appear. The contents
158
+ of the NOTICE file are for informational purposes only and
159
+ do not modify the License. You may add Your own attribution
160
+ notices within Derivative Works that You distribute, alongside
161
+ or as an addendum to the NOTICE text from the Work, provided
162
+ that such additional attribution notices cannot be construed
163
+ as modifying the License.
164
+
165
+ You may add Your own copyright statement to Your modifications and
166
+ may provide additional or different license terms and conditions
167
+ for use, reproduction, or distribution of Your modifications, or
168
+ for any such Derivative Works as a whole, provided Your use,
169
+ reproduction, and distribution of the Work otherwise complies with
170
+ the conditions stated in this License.
171
+
172
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
173
+ any Contribution intentionally submitted for inclusion in the Work
174
+ by You to the Licensor shall be under the terms and conditions of
175
+ this License, without any additional terms or conditions.
176
+ Notwithstanding the above, nothing herein shall supersede or modify
177
+ the terms of any separate license agreement you may have executed
178
+ with Licensor regarding such Contributions.
179
+
180
+ 6. Trademarks. This License does not grant permission to use the trade
181
+ names, trademarks, service marks, or product names of the Licensor,
182
+ except as required for reasonable and customary use in describing the
183
+ origin of the Work and reproducing the content of the NOTICE file.
184
+
185
+ 7. Disclaimer of Warranty. Unless required by applicable law or
186
+ agreed to in writing, Licensor provides the Work (and each
187
+ Contributor provides its Contributions) on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
189
+ implied, including, without limitation, any warranties or conditions
190
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
191
+ PARTICULAR PURPOSE. You are solely responsible for determining the
192
+ appropriateness of using or redistributing the Work and assume any
193
+ risks associated with Your exercise of permissions under this License.
194
+
195
+ 8. Limitation of Liability. In no event and under no legal theory,
196
+ whether in tort (including negligence), contract, or otherwise,
197
+ unless required by applicable law (such as deliberate and grossly
198
+ negligent acts) or agreed to in writing, shall any Contributor be
199
+ liable to You for damages, including any direct, indirect, special,
200
+ incidental, or consequential damages of any character arising as a
201
+ result of this License or out of the use or inability to use the
202
+ Work (including but not limited to damages for loss of goodwill,
203
+ work stoppage, computer failure or malfunction, or any and all
204
+ other commercial damages or losses), even if such Contributor
205
+ has been advised of the possibility of such damages.
206
+
207
+ 9. Accepting Warranty or Additional Liability. While redistributing
208
+ the Work or Derivative Works thereof, You may choose to offer,
209
+ and charge a fee for, acceptance of support, warranty, indemnity,
210
+ or other liability obligations and/or rights consistent with this
211
+ License. However, in accepting such obligations, You may act only
212
+ on Your own behalf and on Your sole responsibility, not on behalf
213
+ of any other Contributor, and only if You agree to indemnify,
214
+ defend, and hold each Contributor harmless for any liability
215
+ incurred by, or claims asserted against, such Contributor by reason
216
+ of your accepting any such warranty or additional liability.
217
+
218
+ END OF TERMS AND CONDITIONS
219
+
220
+ APPENDIX: How to apply the Apache License to your work.
221
+
222
+ To apply the Apache License to your work, attach the following
223
+ boilerplate notice, with the fields enclosed by brackets "{}"
224
+ replaced with your own identifying information. (Don't include
225
+ the brackets!) The text should be enclosed in the appropriate
226
+ comment syntax for the file format. We also recommend that a
227
+ file or class name and description of purpose be included on the
228
+ same "printed page" as the copyright notice for easier
229
+ identification within third-party archives.
230
+
231
+ Copyright 2023 Beijing Volcano Engine Technology Ltd.
232
+
233
+ Licensed under the Apache License, Version 2.0 (the "License");
234
+ you may not use this file except in compliance with the License.
235
+ You may obtain a copy of the License at
236
+
237
+ http://www.apache.org/licenses/LICENSE-2.0
238
+
239
+ Unless required by applicable law or agreed to in writing, software
240
+ distributed under the License is distributed on an "AS IS" BASIS,
241
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
242
+ See the License for the specific language governing permissions and
243
+ limitations under the License.
244
+
245
+ [runtime-direct] aws4 (MIT)
246
+
247
+ Source: https://github.com/mhart/aws4
248
+
249
+ License text from installed version: 1.13.2
250
+
251
+ LICENSE:
252
+ Copyright 2013 Michael Hart (michael.hart.au@gmail.com)
253
+
254
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
255
+ this software and associated documentation files (the "Software"), to deal in
256
+ the Software without restriction, including without limitation the rights to
257
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
258
+ of the Software, and to permit persons to whom the Software is furnished to do
259
+ so, subject to the following conditions:
260
+
261
+ The above copyright notice and this permission notice shall be included in all
262
+ copies or substantial portions of the Software.
263
+
264
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
265
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
266
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
267
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
268
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
269
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
270
+ SOFTWARE.
271
+
272
+ [runtime-direct] commander (MIT)
273
+
274
+ Source: https://github.com/tj/commander.js
275
+
276
+ License text from installed version: 14.0.3
277
+
278
+ LICENSE:
279
+ (The MIT License)
280
+
281
+ Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
282
+
283
+ Permission is hereby granted, free of charge, to any person obtaining
284
+ a copy of this software and associated documentation files (the
285
+ 'Software'), to deal in the Software without restriction, including
286
+ without limitation the rights to use, copy, modify, merge, publish,
287
+ distribute, sublicense, and/or sell copies of the Software, and to
288
+ permit persons to whom the Software is furnished to do so, subject to
289
+ the following conditions:
290
+
291
+ The above copyright notice and this permission notice shall be
292
+ included in all copies or substantial portions of the Software.
293
+
294
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
295
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
296
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
297
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
298
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
299
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
300
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
301
+
302
+ [runtime-direct] keytar (MIT)
303
+
304
+ Source: https://github.com/atom/node-keytar
305
+
306
+ License text from installed version: 7.9.0
307
+
308
+ LICENSE.md:
309
+ Copyright (c) 2013 GitHub Inc.
310
+
311
+ Permission is hereby granted, free of charge, to any person obtaining
312
+ a copy of this software and associated documentation files (the
313
+ "Software"), to deal in the Software without restriction, including
314
+ without limitation the rights to use, copy, modify, merge, publish,
315
+ distribute, sublicense, and/or sell copies of the Software, and to
316
+ permit persons to whom the Software is furnished to do so, subject to
317
+ the following conditions:
318
+
319
+ The above copyright notice and this permission notice shall be
320
+ included in all copies or substantial portions of the Software.
321
+
322
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
323
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
324
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
325
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
326
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
327
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
328
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
329
+
330
+ [runtime-direct] sharp (Apache-2.0)
331
+
332
+ Source: https://github.com/lovell/sharp
333
+
334
+ License text from installed version: 0.35.5
335
+
336
+ LICENSE:
337
+ Apache License
338
+ Version 2.0, January 2004
339
+ http://www.apache.org/licenses/
340
+
341
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
342
+
343
+ 1. Definitions.
344
+
345
+ "License" shall mean the terms and conditions for use, reproduction, and
346
+ distribution as defined by Sections 1 through 9 of this document.
347
+
348
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
349
+ owner that is granting the License.
350
+
351
+ "Legal Entity" shall mean the union of the acting entity and all other entities
352
+ that control, are controlled by, or are under common control with that entity.
353
+ For the purposes of this definition, "control" means (i) the power, direct or
354
+ indirect, to cause the direction or management of such entity, whether by
355
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
356
+ outstanding shares, or (iii) beneficial ownership of such entity.
357
+
358
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
359
+ permissions granted by this License.
360
+
361
+ "Source" form shall mean the preferred form for making modifications, including
362
+ but not limited to software source code, documentation source, and configuration
363
+ files.
364
+
365
+ "Object" form shall mean any form resulting from mechanical transformation or
366
+ translation of a Source form, including but not limited to compiled object code,
367
+ generated documentation, and conversions to other media types.
368
+
369
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
370
+ available under the License, as indicated by a copyright notice that is included
371
+ in or attached to the work (an example is provided in the Appendix below).
372
+
373
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
374
+ is based on (or derived from) the Work and for which the editorial revisions,
375
+ annotations, elaborations, or other modifications represent, as a whole, an
376
+ original work of authorship. For the purposes of this License, Derivative Works
377
+ shall not include works that remain separable from, or merely link (or bind by
378
+ name) to the interfaces of, the Work and Derivative Works thereof.
379
+
380
+ "Contribution" shall mean any work of authorship, including the original version
381
+ of the Work and any modifications or additions to that Work or Derivative Works
382
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
383
+ by the copyright owner or by an individual or Legal Entity authorized to submit
384
+ on behalf of the copyright owner. For the purposes of this definition,
385
+ "submitted" means any form of electronic, verbal, or written communication sent
386
+ to the Licensor or its representatives, including but not limited to
387
+ communication on electronic mailing lists, source code control systems, and
388
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
389
+ the purpose of discussing and improving the Work, but excluding communication
390
+ that is conspicuously marked or otherwise designated in writing by the copyright
391
+ owner as "Not a Contribution."
392
+
393
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
394
+ of whom a Contribution has been received by Licensor and subsequently
395
+ incorporated within the Work.
396
+
397
+ 2. Grant of Copyright License.
398
+
399
+ Subject to the terms and conditions of this License, each Contributor hereby
400
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
401
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
402
+ publicly display, publicly perform, sublicense, and distribute the Work and such
403
+ Derivative Works in Source or Object form.
404
+
405
+ 3. Grant of Patent License.
406
+
407
+ Subject to the terms and conditions of this License, each Contributor hereby
408
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
409
+ irrevocable (except as stated in this section) patent license to make, have
410
+ made, use, offer to sell, sell, import, and otherwise transfer the Work, where
411
+ such license applies only to those patent claims licensable by such Contributor
412
+ that are necessarily infringed by their Contribution(s) alone or by combination
413
+ of their Contribution(s) with the Work to which such Contribution(s) was
414
+ submitted. If You institute patent litigation against any entity (including a
415
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
416
+ Contribution incorporated within the Work constitutes direct or contributory
417
+ patent infringement, then any patent licenses granted to You under this License
418
+ for that Work shall terminate as of the date such litigation is filed.
419
+
420
+ 4. Redistribution.
421
+
422
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
423
+ in any medium, with or without modifications, and in Source or Object form,
424
+ provided that You meet the following conditions:
425
+
426
+ You must give any other recipients of the Work or Derivative Works a copy of
427
+ this License; and
428
+ You must cause any modified files to carry prominent notices stating that You
429
+ changed the files; and
430
+ You must retain, in the Source form of any Derivative Works that You distribute,
431
+ all copyright, patent, trademark, and attribution notices from the Source form
432
+ of the Work, excluding those notices that do not pertain to any part of the
433
+ Derivative Works; and
434
+ If the Work includes a "NOTICE" text file as part of its distribution, then any
435
+ Derivative Works that You distribute must include a readable copy of the
436
+ attribution notices contained within such NOTICE file, excluding those notices
437
+ that do not pertain to any part of the Derivative Works, in at least one of the
438
+ following places: within a NOTICE text file distributed as part of the
439
+ Derivative Works; within the Source form or documentation, if provided along
440
+ with the Derivative Works; or, within a display generated by the Derivative
441
+ Works, if and wherever such third-party notices normally appear. The contents of
442
+ the NOTICE file are for informational purposes only and do not modify the
443
+ License. You may add Your own attribution notices within Derivative Works that
444
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
445
+ provided that such additional attribution notices cannot be construed as
446
+ modifying the License.
447
+ You may add Your own copyright statement to Your modifications and may provide
448
+ additional or different license terms and conditions for use, reproduction, or
449
+ distribution of Your modifications, or for any such Derivative Works as a whole,
450
+ provided Your use, reproduction, and distribution of the Work otherwise complies
451
+ with the conditions stated in this License.
452
+
453
+ 5. Submission of Contributions.
454
+
455
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
456
+ for inclusion in the Work by You to the Licensor shall be under the terms and
457
+ conditions of this License, without any additional terms or conditions.
458
+ Notwithstanding the above, nothing herein shall supersede or modify the terms of
459
+ any separate license agreement you may have executed with Licensor regarding
460
+ such Contributions.
461
+
462
+ 6. Trademarks.
463
+
464
+ This License does not grant permission to use the trade names, trademarks,
465
+ service marks, or product names of the Licensor, except as required for
466
+ reasonable and customary use in describing the origin of the Work and
467
+ reproducing the content of the NOTICE file.
468
+
469
+ 7. Disclaimer of Warranty.
470
+
471
+ Unless required by applicable law or agreed to in writing, Licensor provides the
472
+ Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
473
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
474
+ including, without limitation, any warranties or conditions of TITLE,
475
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
476
+ solely responsible for determining the appropriateness of using or
477
+ redistributing the Work and assume any risks associated with Your exercise of
478
+ permissions under this License.
479
+
480
+ 8. Limitation of Liability.
481
+
482
+ In no event and under no legal theory, whether in tort (including negligence),
483
+ contract, or otherwise, unless required by applicable law (such as deliberate
484
+ and grossly negligent acts) or agreed to in writing, shall any Contributor be
485
+ liable to You for damages, including any direct, indirect, special, incidental,
486
+ or consequential damages of any character arising as a result of this License or
487
+ out of the use or inability to use the Work (including but not limited to
488
+ damages for loss of goodwill, work stoppage, computer failure or malfunction, or
489
+ any and all other commercial damages or losses), even if such Contributor has
490
+ been advised of the possibility of such damages.
491
+
492
+ 9. Accepting Warranty or Additional Liability.
493
+
494
+ While redistributing the Work or Derivative Works thereof, You may choose to
495
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
496
+ other liability obligations and/or rights consistent with this License. However,
497
+ in accepting such obligations, You may act only on Your own behalf and on Your
498
+ sole responsibility, not on behalf of any other Contributor, and only if You
499
+ agree to indemnify, defend, and hold each Contributor harmless for any liability
500
+ incurred by, or claims asserted against, such Contributor by reason of your
501
+ accepting any such warranty or additional liability.
502
+
503
+ END OF TERMS AND CONDITIONS
504
+
505
+ APPENDIX: How to apply the Apache License to your work
506
+
507
+ To apply the Apache License to your work, attach the following boilerplate
508
+ notice, with the fields enclosed by brackets "[]" replaced with your own
509
+ identifying information. (Don't include the brackets!) The text should be
510
+ enclosed in the appropriate comment syntax for the file format. We also
511
+ recommend that a file or class name and description of purpose be included on
512
+ the same "printed page" as the copyright notice for easier identification within
513
+ third-party archives.
514
+
515
+ Copyright [yyyy] [name of copyright owner]
516
+
517
+ Licensed under the Apache License, Version 2.0 (the "License");
518
+ you may not use this file except in compliance with the License.
519
+ You may obtain a copy of the License at
520
+
521
+ http://www.apache.org/licenses/LICENSE-2.0
522
+
523
+ Unless required by applicable law or agreed to in writing, software
524
+ distributed under the License is distributed on an "AS IS" BASIS,
525
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
526
+ See the License for the specific language governing permissions and
527
+ limitations under the License.
528
+
529
+ [runtime-direct] yaml (ISC)
530
+
531
+ Source: https://github.com/eemeli/yaml
532
+
533
+ License text from installed version: 2.9.1
534
+
535
+ LICENSE:
536
+ Copyright Eemeli Aro <eemeli@gmail.com>
537
+
538
+ Permission to use, copy, modify, and/or distribute this software for any purpose
539
+ with or without fee is hereby granted, provided that the above copyright notice
540
+ and this permission notice appear in all copies.
541
+
542
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
543
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
544
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
545
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
546
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
547
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
548
+ THIS SOFTWARE.
549
+
550
+ [runtime-direct] zod (MIT)
551
+
552
+ Source: https://github.com/colinhacks/zod
553
+
554
+ License text from installed version: 4.6.6
555
+
556
+ LICENSE:
557
+ MIT License
558
+
559
+ Copyright (c) 2025 Colin McDonnell
560
+
561
+ Permission is hereby granted, free of charge, to any person obtaining a copy
562
+ of this software and associated documentation files (the "Software"), to deal
563
+ in the Software without restriction, including without limitation the rights
564
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
565
+ copies of the Software, and to permit persons to whom the Software is
566
+ furnished to do so, subject to the following conditions:
567
+
568
+ The above copyright notice and this permission notice shall be included in all
569
+ copies or substantial portions of the Software.
570
+
571
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
572
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
573
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
574
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
575
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
576
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
577
+ SOFTWARE.
578
+
579
+ Development-only dependencies are not included in the published package.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ declare const REGIONAL_CONFIG: Readonly<{
3
+ region: string;
4
+ binName: string;
5
+ endpoint: string;
6
+ auth: Readonly<{
7
+ baseUrl: string;
8
+ storeServiceName: string;
9
+ }>;
10
+ }>;
11
+
12
+ declare function main(argv?: string[]): Promise<number>;
13
+
14
+ export { REGIONAL_CONFIG, main };
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * Copyright 2026 PICO. All rights reserved.
4
+ *
5
+ * NOTICE: All information contained herein is, and remains the property of PICO.
6
+ * The intellectual and technical concepts contained herein are proprietary to PICO
7
+ * and may be covered by patents, patents in process, and are protected by trade
8
+ * secret or copyright law. Dissemination of this information or reproduction of
9
+ * this material is strictly forbidden unless prior written permission is obtained
10
+ * from PICO.
11
+ */
12
+
13
+ import {realpathSync,readFileSync,createReadStream}from'fs';import {fileURLToPath}from'url';import {createHash,randomUUID,randomBytes,generateKeyPairSync,createPrivateKey,sign}from'crypto';import {mkdir,writeFile,rm,stat,readFile,open,rename,access,link}from'fs/promises';import Ge,{join,resolve,dirname}from'path';import No,{tmpdir,userInfo}from'os';import {execFile,spawn,execFileSync}from'child_process';import {createRequire}from'module';import {promisify}from'util';import {CommanderError,Command}from'commander';import {stringify,parseDocument,isMap,isScalar,parse}from'yaml';import {z as z$1}from'zod';import na from'sharp';import Fa from'aws4';import {input,select,checkbox,confirm}from'@inquirer/prompts';
14
+ var h=class extends Error{kind;errorCode;description;descUrl;cause;constructor(e){super(e.description||e.kind.toLowerCase()),this.name="ProtocolError",this.kind=e.kind,this.errorCode=e.errorCode??0,this.description=e.description??"",this.descUrl=e.descUrl??"",this.cause=e.cause;}};function V(t,e){return t instanceof h&&(e===void 0||t.kind===e)}var Tn="/passport/cli/get_device_code/",Pn="/passport/cli/check_device_code/",Tr="/api/cli/v1/authorization/user_info",Ot="/passport/cli/refresh_token/",kt="/passport/cli/revoke/",Rr="X-Tt-Logid",Cn="same-origin",Dn="DPoP",Be=class{baseUrl;aid;pollRegion;headers;userAgent;fetchImpl;sleep;retryBaseDelayMs;maxServerErrorAttempts;constructor(e){this.baseUrl=Pr(e.baseUrl,"protocol base URL"),this.aid=e.aid,this.pollRegion=e.pollRegion,this.headers=$n(e.headers),this.userAgent=e.userAgent,this.fetchImpl=e.fetch??fetch,this.sleep=e.sleep??(r=>new Promise(i=>setTimeout(i,r))),this.retryBaseDelayMs=Math.max(0,e.retryBaseDelayMs??250),this.maxServerErrorAttempts=Math.max(1,Math.trunc(e.maxServerErrorAttempts??3));}async getDeviceCode(e,r){let i=new URLSearchParams({client_id:e.clientId,dpop_jkt:e.dpopJkt,os:e.deviceInfo.os,os_version:e.deviceInfo.osVersion,app_version:e.deviceInfo.cliVersion??"unknown",device_platform:"cli",device_model:e.deviceInfo.name,cli_device_id:e.cliDeviceId});Ke(i,"outside_agent",e.outsideAgent);let n=await this.postDecoded(this.resolve(Tn,this.baseUrl),i,void 0,r),o=M(n,"verification_uri_complete")??$(n,"verification_uri"),s=Ln(o,e.clientId,Un(this.pollRegion));return {deviceCode:$(n,"device_code"),userCode:$(n,"user_code"),verificationUri:s,intervalMs:Y(n,"interval")*1e3,expiresInMs:Y(n,"expires_in")*1e3,pollTicket:$(n,"poll_ticket"),pollDomains:Mn(n,"poll_domains")}}async checkDeviceCode(e,r){let i=this.pollRegion?[[this.pollRegion,this.baseUrl.host]]:Object.entries(e.pollDomains);if(i.length===0)throw new h({kind:"DECODE",description:"poll_domains is empty"});let n=new AbortController,o=()=>n.abort(r?.reason);r?.aborted?o():r?.addEventListener("abort",o,{once:true});let s=i.map(async([u,l])=>{let _=new URLSearchParams({client_id:e.clientId,device_code:e.deviceCode,poll_ticket:e.pollTicket,cli_device_id:e.cliDeviceId});Ke(_,"outside_agent",e.outsideAgent);try{let f=le(l,`poll_domains.${u}`),S=await this.postDecoded(this.resolve(Pn,f),_,void 0,n.signal);return {idc:u,data:S}}catch(f){return f instanceof h&&f.kind==="DECODE"&&f.description==="decode envelope"?{idc:u,data:{status:"pending"}}:{idc:u,error:f instanceof h?f:new h({kind:"TRANSPORT",description:`poll ${u}`,cause:f})}}}),a;try{a=await xn(s,n);}finally{r?.removeEventListener("abort",o);}let c=a.find(u=>ue(u.data)==="confirmed");if(c?.data)return Ir(c.data),{accessToken:$(c.data,"access_token"),refreshToken:$(c.data,"refresh_token"),expiresInMs:Y(c.data,"expires_in")*1e3,refreshTokenExpiresInMs:Y(c.data,"refresh_token_expires_in")*1e3,apiDomain:Vn(c.data,"api_domain"),region:M(c.data,"region")??c.idc,userInfo:me(c.data.user_info)?c.data.user_info:void 0};if(a.some(u=>ue(u.data)==="rejected"))throw new h({kind:"ACCESS_DENIED",description:"authorization rejected"});if(a.some(u=>ue(u.data)==="expired"))throw new h({kind:"EXPIRED_TOKEN",description:"device code expired"});let p=a.find(u=>u.error?.kind==="SERVER"&&u.error.errorCode!==0)?.error;throw p?new h({kind:"LOGIN_BLOCKED",errorCode:p.errorCode,description:p.description,cause:p}):a.some(u=>ue(u.data)==="pending")?new h({kind:"AUTHORIZATION_PENDING",description:"authorization pending"}):a.find(u=>u.error)?.error??new h({kind:"DECODE",description:"unexpected poll response"})}async refreshToken(e,r){let i=new URLSearchParams({client_id:e.clientId,refresh_token:e.refreshToken,cli_device_id:e.cliDeviceId});Ke(i,"outside_agent",e.outsideAgent);let n=le(e.apiDomain,"api_domain"),o=await this.postDecoded(this.resolve(Ot,n),i,{DPoP:e.dpopProof},r);return Ir(o),{accessToken:$(o,"access_token"),refreshToken:M(o,"refresh_token"),expiresInMs:Y(o,"expires_in")*1e3,refreshTokenExpiresInMs:Y(o,"refresh_token_expires_in")*1e3}}async fetchAuthorizationUserInfo(e,r){let i;try{i=await this.fetchImpl(e.url,{method:"POST",signal:r,body:e.body,redirect:"error",headers:{...this.headers,...e.headers,...this.userAgent?{"User-Agent":this.userAgent}:{}}});}catch(a){throw new h({kind:"TRANSPORT",description:"fetch authorization user info",cause:a})}let n=await i.text();if(i.status!==200)throw new h({kind:"SERVER",errorCode:i.status,description:i.statusText||`unexpected HTTP status ${i.status}`,descUrl:i.headers.get(Rr)??""});let o;try{o=JSON.parse(n);}catch(a){throw new h({kind:"DECODE",description:"decode authorization user info",cause:a})}if(!me(o))throw new h({kind:"DECODE",description:"authorization user info must be an object"});let s=We(o,"code");if(s!==0)throw new h({kind:"SERVER",errorCode:s??0,description:M(o,"em")??M(o,"et")??"authorization user info failed",descUrl:M(o,"trace_id")??""});if(!me(o.data))throw new h({kind:"DECODE",description:"authorization user info data must be an object"});return {uid:Gn(o.data,n)}}async revoke(e,r){let i=new URLSearchParams({client_id:e.clientId,refresh_token:e.refreshToken,token_type_hint:"refresh_token",cli_device_id:e.cliDeviceId});Ke(i,"outside_agent",e.outsideAgent);let n=le(e.apiDomain,"api_domain");await this.postDecoded(this.resolve(kt,n),i,{DPoP:e.dpopProof},r);}async postDecoded(e,r,i,n){for(let o=0;o<this.maxServerErrorAttempts;o+=1)try{return On(await this.postForm(e,r,i,n))}catch(s){if(!Nn(s)||o+1>=this.maxServerErrorAttempts)throw s;await this.sleep(this.retryBaseDelayMs*2**o);}throw new h({kind:"RETRYABLE",description:"retry attempts exhausted"})}async postForm(e,r,i,n){let o;try{o=await this.fetchImpl(e,{method:"POST",body:r,signal:n,headers:{...this.headers,...i??{},"Content-Type":"application/x-www-form-urlencoded","Sec-Fetch-Site":Cn,...this.userAgent?{"User-Agent":this.userAgent}:{}}});}catch(a){throw new h({kind:"TRANSPORT",description:"do request",cause:a})}let s=await o.text();if(o.status!==200)throw new h({kind:"SERVER",errorCode:o.status,description:o.statusText||`unexpected HTTP status ${o.status}`,descUrl:o.headers.get(Rr)??""});try{return JSON.parse(s)}catch(a){throw new h({kind:"DECODE",description:"decode envelope",cause:a})}}resolve(e,r){let i=new URL(e,r);return this.aid!==void 0&&this.aid!==0&&i.searchParams.set("aid",String(this.aid)),i.toString()}};function xn(t,e){return new Promise(r=>{let i=[],n=t.length;for(let o of t)o.then(s=>{if(i.push(s),n-=1,ue(s.data)==="confirmed"){e.abort(),r(i);return}n===0&&r(i);});})}function On(t){let e=me(t.data)?t.data:{};if(br(t.message,"success"))return e;if(!br(t.message,"error"))throw new h({kind:"DECODE",description:"unexpected response message"});let r=We(e,"error_code")??We(e,"code")??0,i=M(e,"description")??String(t.message??"error");throw kn(r,i)}function kn(t,e){switch(t){case 1:case 10:return new h({kind:"EXPIRED_TOKEN",errorCode:t,description:e});case 3:case 4:case 2136:return new h({kind:"INVALID_REQUEST",errorCode:t,description:e});case 6:return new h({kind:"RETRYABLE",errorCode:t,description:e});default:return new h({kind:"SERVER",errorCode:t,description:e})}}function Nn(t){return t instanceof h&&t.kind==="RETRYABLE"}function Ir(t){let e=$(t,"token_type");if(e.toLowerCase()!==Dn.toLowerCase())throw new h({kind:"DECODE",description:`unexpected token_type ${e}`})}function Pr(t,e){let r;try{r=new URL(t);}catch(i){throw new Error(`${e} must be an absolute URL`,{cause:i})}if(r.protocol!=="https:"||!r.host||r.username||r.password)throw new Error(`${e} must be an HTTPS URL without credentials`);return r.pathname="/",r.search="",r.hash="",r}function le(t,e){let r=t.trim();return Pr(r.includes("://")?r:`https://${r}`,e)}function Ln(t,e,r){try{let i=new URL(t);return i.searchParams.set("client_id",e),r&&i.searchParams.set("region",r),i.toString()}catch(i){throw new h({kind:"DECODE",description:"verification_uri is invalid",cause:i})}}function Un(t){return t==="sg"?"row":t}function Vn(t,e){let r=$(t,e);try{return le(r,e).host}catch(i){throw new h({kind:"DECODE",description:`${e} is invalid`,cause:i})}}function ue(t){return M(t??{},"status")?.trim().toLowerCase()??""}function Ke(t,e,r){r?.trim()&&t.set(e,r.trim());}function $n(t){let e=new Set(["authorization","content-type","dpop","sdk-version","sec-fetch-site","x-tt-cli-access-token"]),r={};for(let[i,n]of Object.entries(t??{}))e.has(i.toLowerCase())||(r[i]=n);return r}function $(t,e){let r=M(t,e);if(!r)throw new h({kind:"DECODE",description:`${e} is required`});return r}function Y(t,e){let r=We(t,e);if(r===void 0||!Number.isFinite(r)||r<=0)throw new h({kind:"DECODE",description:`${e} must be positive`});return r}function Mn(t,e){let r=t[e];if(!me(r))throw new h({kind:"DECODE",description:`${e} must be an object`});let i={};for(let[n,o]of Object.entries(r))if(n.trim()&&typeof o=="string"&&o.trim())try{i[n]=le(o,`${e}.${n}`).host;}catch(s){throw new h({kind:"DECODE",description:`${e}.${n} is invalid`,cause:s})}if(Object.keys(i).length===0)throw new h({kind:"DECODE",description:`${e} must not be empty`});return i}function M(t,e){let r=t[e];return typeof r=="string"&&r.trim()?r.trim():void 0}function We(t,e){let r=t[e];return typeof r=="number"?r:void 0}function Gn(t,e){let r=t.uid;if(typeof r=="number"&&Number.isSafeInteger(r)&&r>0||typeof r=="string"&&/^[1-9]\d*$/.test(r))return r;if(typeof r=="number"&&Number.isFinite(r)&&r>0){let i=/"uid"\s*:\s*([1-9]\d*)(?=\s*[,}])/.exec(e);if(i?.[1])return i[1]}throw new h({kind:"DECODE",description:"uid must be a positive integer"})}function br(t,e){return typeof t=="string"&&t.toLowerCase()===e.toLowerCase()}function me(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var qe=class{constructor(e=()=>new Date,r=randomUUID){this.now=e;this.uuid=r;}now;uuid;generateDeviceKey(){let{privateKey:e}=generateKeyPairSync("ec",{namedCurve:"P-256"}),r=e.export({format:"jwk"});if(r.kty!=="EC"||r.crv!=="P-256"||!r.x||!r.y||!r.d)throw new Error("signer: generated an invalid P-256 key");return {kty:"EC",crv:"P-256",x:r.x,y:r.y,d:r.d}}thumbprint(e){Dr(e);let r=JSON.stringify({crv:e.crv,kty:e.kty,x:e.x,y:e.y});return fe(createHash("sha256").update(r).digest())}sign(e,r){Dr(r);let i=e.method.trim().toUpperCase();if(!i)throw new Error("signer: HTTP method is required");let n=new URL(String(e.url));if(n.protocol!=="https:"||!n.host||n.username||n.password)throw new Error("signer: URL must be an absolute HTTPS URL without credentials");n.search="",n.hash="";let o={typ:"dpop+jwt",alg:"ES256",jwk:{kty:r.kty,crv:r.crv,x:r.x,y:r.y}},s={htm:i,htu:n.toString(),iat:Math.floor(this.now().getTime()/1e3),jti:this.uuid()};e.accessToken&&(s.ath=fe(createHash("sha256").update(e.accessToken).digest()));let a=`${fe(JSON.stringify(o))}.${fe(JSON.stringify(s))}`,c=createPrivateKey({key:r,format:"jwk"}),p=sign("sha256",Buffer.from(a),{key:c,dsaEncoding:"ieee-p1363"});if(p.byteLength!==64)throw new Error("signer: ES256 signature must use raw R||S encoding");return `${a}.${fe(p)}`}};function Dr(t){if(t.kty!=="EC"||t.crv!=="P-256"||!t.x||!t.y||!t.d)throw new Error("signer: invalid P-256 device key")}function fe(t){return Buffer.from(t).toString("base64url")}var ze=class extends Error{code;cause;constructor(e,r,i){super(i instanceof Error?`${r}: ${i.message}`:r),this.name="StoreError",this.code=e,this.cause=i;}};function R(t,e,r){return new ze(t,`${e}: ${Bn(t)}`,r)}function D(t,e){return t instanceof ze&&(e===void 0||t.code===e)}function Bn(t){switch(t){case "NOT_FOUND":return "store: not found";case "CORRUPT_RECORD":return "store: corrupt record";case "BACKEND_UNAVAILABLE":return "store: backend unavailable";case "PERMISSION_DENIED":return "store: permission denied";case "ENCODE_FAILED":return "store: encode failed";case "DECODE_FAILED":return "store: decode failed"}}var xr=1e6;function b(t){Or(t);let e={cli_device_id:t.cliDeviceId,device_key:t.deviceKey,device_code:K(t.deviceCode),user_code:K(t.userCode),verification_uri:K(t.verificationUri),interval:t.intervalMs===void 0?void 0:Math.trunc(t.intervalMs*xr),login_expires_at:t.loginExpiresAt?.toISOString(),login_context:t.loginContext,next_poll_at:t.nextPollAt?.toISOString(),poll_ticket:K(t.pollTicket),poll_domains:t.pollDomains,access_token:K(t.accessToken),refresh_token:K(t.refreshToken),refresh_token_expires_at:t.refreshTokenExpiresAt?.toISOString(),token_expires_at:t.tokenExpiresAt?.toISOString(),refresh_at:t.refreshAt?.toISOString(),api_domain:K(t.apiDomain),region:K(t.region),user_info:t.userInfo};return JSON.stringify(qn(e))}function Z(t){if(t.trim()==="")throw R("CORRUPT_RECORD","load",new Error("empty auth record"));let e;try{e=JSON.parse(t);}catch(i){throw R("DECODE_FAILED","load",i)}let r={cliDeviceId:e.cli_device_id??"",deviceKey:e.device_key,deviceCode:e.device_code,userCode:e.user_code,verificationUri:e.verification_uri,intervalMs:e.interval===void 0?void 0:e.interval/xr,loginExpiresAt:ge(e.login_expires_at),loginContext:e.login_context,nextPollAt:ge(e.next_poll_at),pollTicket:e.poll_ticket,pollDomains:Wn(e.poll_domains),accessToken:e.access_token,refreshToken:e.refresh_token,refreshTokenExpiresAt:ge(e.refresh_token_expires_at),tokenExpiresAt:ge(e.token_expires_at),refreshAt:ge(e.refresh_at),apiDomain:e.api_domain,region:e.region,userInfo:e.user_info};return Or(r),r}function Or(t){if(!t.cliDeviceId.trim())throw R("CORRUPT_RECORD","validate",new Error("cli_device_id is required"));if(!t.deviceKey||t.deviceKey.kty!=="EC"||t.deviceKey.crv!=="P-256"||!t.deviceKey.x||!t.deviceKey.y||!t.deviceKey.d)throw R("CORRUPT_RECORD","validate",new Error("P-256 device_key is required"))}function he(t){let e=t.trim();if(e==="")return "_";let r="";for(let i of e)/^[A-Za-z0-9._-]$/.test(i)?r+=i:r+="_";return r||"_"}function ge(t){if(t)return new Date(t)}function Wn(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e={};for(let[r,i]of Object.entries(t))r.trim()&&typeof i=="string"&&i.trim()&&(e[r]=i);return Object.keys(e).length?e:void 0}function K(t){return t===void 0||t===""?void 0:t}function qn(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(e[r]=i);return e}var Nr=promisify(execFile),no=createRequire(import.meta.url),oo=9e4,so=5*6e4,ao=100,Xe="pico-auth-cli-managed-v2",_e="pico-auth-cli-managed-v3",Q="pico-auth-cli-managed-v3-legacy-ambiguous",we=class{constructor(e,r,i=po){this.serviceName=e;this.account=r;this.runner=i;Ee(e,r);}serviceName;account;runner;withLock(e){return G(this.serviceName,`${this.account}.auth-session`,e)}async load(){let e;try{e=await this.runner.getPassword(this.serviceName,this.account);}catch(r){throw x("load",r)}if(e===null)throw R("NOT_FOUND","load",new Error("auth record not found"));try{return Z(e)}catch(r){throw D(r)?r:R("DECODE_FAILED","load",r)}}async save(e){let r;try{r=b(e);}catch(i){throw x("save",i)}try{await this.runner.setPassword(this.serviceName,this.account,r);}catch(i){throw x("save",fo(i,r))}}async updateUserInfo(e){let r=await this.load();r.userInfo=e,await this.save(r);}async delete(){try{await this.runner.deletePassword(this.serviceName,this.account);}catch(e){throw x("delete",e)}}},co={async getPassword(t,e){try{let{stdout:r}=await Nr("security",["find-generic-password","-s",t,"-a",e,"-w"]);return r.trimEnd()}catch(r){if(Ur(r))return null;throw r}},async deletePassword(t,e){try{return await Nr("security",["delete-generic-password","-s",t,"-a",e]),!0}catch(r){if(Ur(r))return false;throw r}}},Gr={getPassword:(t,e)=>Nt().getPassword(t,e),setPassword:(t,e,r)=>Nt().setPassword(t,e,r),deletePassword:(t,e)=>Nt().deletePassword(t,e)},Mt=class{constructor(e=Gr,r=co,i=G){this.managed=e;this.legacy=r;this.runExclusive=i;}managed;legacy;runExclusive;async getPassword(e,r){for(let o of [Ut(r),Vt(r)]){let s=await this.managed.getPassword(e,o);if(s!==null)return s}let i=await this.managed.getPassword(e,$t(r));if(i===_e||i===Q)return null;let n=await this.managed.getPassword(e,Lt(r));return n!==null?n:await this.managed.getPassword(e,Lr(r))===Xe?this.managed.getPassword(e,r):this.legacy.getPassword(e,r)}async setPassword(e,r,i){await this.runExclusive(e,r,async()=>{let n=Ut(r),o=Vt(r),s=$t(r);await this.managed.setPassword(e,n,i),await Je(this.managed,e,n,i,"recovery"),await this.managed.setPassword(e,o,i),await Je(this.managed,e,o,i,"primary"),await this.managed.setPassword(e,s,_e),await Je(this.managed,e,s,_e,"state"),await this.managed.deletePassword(e,n).catch(()=>{}),await this.managed.deletePassword(e,Lt(r)).catch(()=>{});});}async deletePassword(e,r){return this.runExclusive(e,r,async()=>{let i=[Ut(r),Vt(r),Lt(r)],n=await Promise.all(i.map(f=>this.managed.getPassword(e,f))),o=$t(r),s=await this.managed.getPassword(e,o),a=Lr(r),c=await this.managed.getPassword(e,a);if(!(n.some(f=>f!==null)||s===_e||s===Q||c===Xe))return this.legacy.deletePassword(e,r);let u=n[2]!==null&&c!==Xe||s===Q?Q:_e;await this.managed.setPassword(e,o,u),await Je(this.managed,e,o,u,"state");let l=false,_;for(let f of i)try{l=await this.managed.deletePassword(e,f)||l;}catch(S){_??=S;}if(_!==void 0)throw _;if(c===Xe)try{let f=await this.managed.deletePassword(e,r);l=f||l,(f||await this.managed.getPassword(e,r)===null)&&(l=await this.managed.deletePassword(e,a)||l);}catch(f){_??=f;}else if(u!==Q)try{l=await this.legacy.deletePassword(e,r)||l;}catch(f){_??=f;}if(_!==void 0)throw _;return u===Q||(l=await this.managed.deletePassword(e,o)||l),l})}},po=process.platform==="darwin"?new Mt:Gr;function Nt(){return no("keytar")}function Lt(t){return `${t}.pico-auth-cli-recovery-v1`}function Lr(t){return `${t}.pico-auth-cli-managed-v2`}function Ut(t){return `${t}.pico-auth-cli-recovery-v3`}function Vt(t){return `${t}.pico-auth-cli-payload-v3`}function $t(t){return `${t}.pico-auth-cli-state-v3`}async function G(t,e,r){let i=join(process.platform==="win32"?tmpdir():"/tmp",`pico-auth-cli-keychain-locks-${userInfo().uid}`);await mkdir(i,{recursive:true,mode:448});let n=createHash("sha256").update(t).update("\0").update(e).digest("hex"),o=join(i,`${n}.lock`),s=join(o,"owner.json"),a=randomUUID(),c=Date.now()+oo;for(;;)try{await mkdir(o,{mode:448});try{await writeFile(s,JSON.stringify({pid:process.pid,token:a,createdAt:Date.now()}),{flag:"wx",mode:384});}catch(p){throw await rm(o,{recursive:!0,force:!0}).catch(()=>{}),p}break}catch(p){if(ye(p)!=="EEXIST")throw p;if(await jr(o)&&await uo(o))continue;if(Date.now()>=c)throw new Error("timed out waiting for the credential store lock");await new Promise(m=>setTimeout(m,ao));}try{return await r()}finally{await mo(o,s,a).catch(()=>{});}}async function jr(t){try{let e=await stat(t);try{let r=await readFile(join(t,"owner.json"),"utf8"),i=JSON.parse(r);return typeof i.pid=="number"&&!lo(i.pid)}catch{return Date.now()-e.mtimeMs>=so}}catch{return false}}async function uo(t){let e=`${t}.reaper`,r;try{r=await open(e,"wx",384);}catch(i){if(ye(i)==="EEXIST")return false;throw i}try{if(!await jr(t))return !1;let i=`${t}.stale-${randomUUID()}`;try{await rename(t,i);}catch(n){if(ye(n)==="ENOENT")return !0;throw n}return await rm(i,{recursive:!0,force:!0}),!0}finally{await r.close().catch(()=>{}),await rm(e,{force:true}).catch(()=>{});}}function lo(t){try{return process.kill(t,0),!0}catch(e){return ye(e)==="EPERM"}}async function mo(t,e,r){try{JSON.parse(await readFile(e,"utf8")).token===r&&await rm(t,{recursive:!0,force:!0});}catch(i){if(ye(i)!=="ENOENT")throw i}}function ye(t){if(!(typeof t!="object"||t===null||!("code"in t)))return typeof t.code=="string"?t.code:void 0}async function Je(t,e,r,i,n){if(await t.getPassword(e,r)!==i)throw new Error(`macOS Keychain ${n} write verification failed`)}function Ee(t,e){if(!t.trim())throw new Error("service_name is required");if(!e.trim())throw new Error("account is required")}function Ur(t){let e=t instanceof Error?t.message:String(t);return e.includes("could not be found")||e.includes("The specified item could not be found")}function fo(t,e){let r=t instanceof Error?t.message:String(t),i=r.includes(e)?r.split(e).join("[REDACTED]"):r,n=new Error(i),o=Vr(t,"code"),s=Vr(t,"exitCode");return o!==void 0&&Object.assign(n,{code:o}),s!==void 0&&Object.assign(n,{exitCode:s}),n}function Vr(t,e){if(typeof t!="object"||t===null||!(e in t))return;let r=t[e];return typeof r=="number"?r:void 0}var Qe=class{constructor(e){this.path=e;if(!e.trim())throw new Error("path is required")}path;withLock(e){return G(resolve(this.path),"auth-session",e)}async load(){let e;try{e=await readFile(this.path,"utf8");}catch(r){throw r?.code==="ENOENT"?R("NOT_FOUND","load",r):x("load",r)}try{return Z(e)}catch(r){throw D(r)?r:R("DECODE_FAILED","load",r)}}async save(e){let r=b(e),i=dirname(this.path);await mkdir(i,{recursive:true,mode:448});let n=join(i,`${randomBytes(8).toString("hex")}.tmp`);try{await writeFile(n,r,{mode:384}),await rename(n,this.path);}catch(o){throw await rm(n,{force:true}).catch(()=>{}),x("save",o)}}async updateUserInfo(e){let r=await this.load();r.userInfo=e,await this.save(r);}async delete(){try{await rm(this.path,{force:!0});}catch(e){throw x("delete",e)}}};function Kr(t,e,r=process.env.HOME||tmpdir()){return join(r||".",".local","share",he(t),`${he(e)}.json`)}function x(t,e){let r=e instanceof Error?e.message.toLowerCase():String(e).toLowerCase();return r.includes("permission denied")||r.includes("access denied")?R("PERMISSION_DENIED",t,e):R("BACKEND_UNAVAILABLE",t,e)}var Gt=class extends Error{code;exitCode;stderr;constructor(e,r,i){let n=i.trim();super(`${e} exited with code ${r??"unknown"}${n?`: ${n}`:""}`),this.name="CommandExecutionError",this.code=r,this.exitCode=r,this.stderr=i;}};function Br(t,e,r,i=process.env){return new Promise((n,o)=>{let s=spawn(t,e,{env:i,stdio:["pipe","pipe","pipe"]}),a=[],c=[],p=false,m=u=>{p||(p=true,o(u));};s.stdout.on("data",u=>a.push(Buffer.from(u))),s.stderr.on("data",u=>c.push(Buffer.from(u))),s.once("error",m),s.stdin.once("error",m),s.once("close",u=>{if(p)return;p=true;let l={stdout:Buffer.concat(a).toString(),stderr:Buffer.concat(c).toString()};if(u===0){n(l);return}o(new Gt(t,u,l.stderr));}),s.stdin.end(r);})}var bo=promisify(execFile),To="Software\\BytedAuthClient\\keychain",et=class{constructor(e,r,i=Co){this.serviceName=e;this.account=r;this.runner=i;Ee(e,r);}serviceName;account;runner;withLock(e){return G(this.serviceName,`${this.account}.auth-session`,e)}async load(){let e;try{e=await this.runner.get(this.serviceName,this.account);}catch(r){throw x("load",r)}if(e===void 0)throw R("NOT_FOUND","load",new Error("auth record not found"));try{return Z(e)}catch(r){throw D(r)?r:R("DECODE_FAILED","load",r)}}async save(e){try{await this.runner.set(this.serviceName,this.account,b(e));}catch(r){throw x("save",r)}}async updateUserInfo(e){let r=await this.load();r.userInfo=e,await this.save(r);}async delete(){try{await this.runner.delete(this.serviceName,this.account);}catch(e){throw x("delete",e)}}};function Po(t=Oo){return {async get(e,r){let i=Buffer.from(Wr(e,r)).toString("base64"),n=`
15
+ $ErrorActionPreference = 'Stop'
16
+ Add-Type -AssemblyName System.Security
17
+ $path = '${ee(jt(e))}'
18
+ $name = '${ee(Ft(r))}'
19
+ $key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($path)
20
+ if ($null -eq $key) { exit 3 }
21
+ try { $value = $key.GetValue($name, $null) } finally { $key.Dispose() }
22
+ if ($null -eq $value) { exit 3 }
23
+ $cipher = [Convert]::FromBase64String($value)
24
+ $entropy = [Convert]::FromBase64String('${i}')
25
+ $plain = [Security.Cryptography.ProtectedData]::Unprotect($cipher, $entropy, [Security.Cryptography.DataProtectionScope]::CurrentUser)
26
+ [Console]::Out.Write([Convert]::ToBase64String($plain))
27
+ exit 0
28
+ `,o=await t(n);return o.missing?void 0:Buffer.from(o.stdout.trim(),"base64").toString("utf8")},async set(e,r,i){let n=Buffer.from(i,"utf8").toString("base64");await t(xo(e,r),n);},async delete(e,r){let i=`
29
+ $ErrorActionPreference = 'Stop'
30
+ $path = '${ee(jt(e))}'
31
+ $name = '${ee(Ft(r))}'
32
+ $key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($path, $true)
33
+ if ($null -ne $key) {
34
+ try { $key.DeleteValue($name, $false) } finally { $key.Dispose() }
35
+ }
36
+ exit 0
37
+ `;await t(i);}}}var Co=Po();function jt(t){return `${To}\\${he(t)}`}function Do(t){return `HKCU:\\${jt(t)}`}function Ft(t){return Buffer.from(t,"utf8").toString("base64url")}function Wr(t,e){return Buffer.concat([Buffer.from(t,"utf8"),Buffer.from([0]),Buffer.from(e,"utf8")])}function xo(t,e){let r=Buffer.from(Wr(t,e)).toString("base64");return `
38
+ $ErrorActionPreference = 'Stop'
39
+ Add-Type -AssemblyName System.Security
40
+ $path = '${ee(Do(t))}'
41
+ $name = '${ee(Ft(e))}'
42
+ New-Item -Path $path -Force | Out-Null
43
+ $encodedValue = [Console]::In.ReadToEnd()
44
+ $plain = [Convert]::FromBase64String($encodedValue)
45
+ $entropy = [Convert]::FromBase64String('${r}')
46
+ $cipher = [Security.Cryptography.ProtectedData]::Protect($plain, $entropy, [Security.Cryptography.DataProtectionScope]::CurrentUser)
47
+ $encoded = [Convert]::ToBase64String($cipher)
48
+ Set-ItemProperty -Path $path -Name $name -Value $encoded
49
+ exit 0
50
+ `}async function Oo(t,e){try{let r=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",t],{stdout:i}=e===void 0?await bo("powershell.exe",r):await Br("powershell.exe",r,e);return {stdout:i,missing:!1}}catch(r){if(r?.code===3||r?.exitCode===3)return {stdout:"",missing:true};throw r}}function ee(t){return t.replace(/'/g,"''")}var ko="byted_cli_user_token";function tt(t,e=ko,r=process.platform){switch(Ee(t,e),r){case "darwin":return new we(t,e);case "win32":return new et(t,e);default:return new Ht(new we(t,e),new Qe(Kr(t,e)),i=>G(t,e,i),i=>G(t,`${e}.auth-session`,i))}}var Ht=class{constructor(e,r,i=async o=>o(),n){this.primary=e;this.legacy=r;this.runExclusive=i;this.withLock=n;}primary;legacy;runExclusive;withLock;async load(){return this.runExclusive(()=>this.loadExclusive())}async save(e){await this.runExclusive(async()=>{await this.persistAndVerify(e),await this.legacy.delete();});}async updateUserInfo(e){await this.runExclusive(async()=>{let r=await this.loadExclusive();r.userInfo=e,await this.persistAndVerify(r),await this.legacy.delete();});}async delete(){await this.runExclusive(async()=>{let e;for(let r of [this.primary,this.legacy])try{await r.delete();}catch(i){e??=i;}if(e!==void 0)throw e});}async loadExclusive(){try{let r=await this.primary.load();return await this.legacy.delete(),r}catch(r){if(!D(r,"NOT_FOUND"))throw r}let e=await this.legacy.load();return await this.persistAndVerify(e),await this.legacy.delete(),e}async persistAndVerify(e){await this.primary.save(e);let r=await this.primary.load();if(b(r)!==b(e))throw await this.primary.delete().catch(()=>{}),R("BACKEND_UNAVAILABLE","save",new Error("credential migration verification failed"))}};var qr={NOT_LOGGED_IN:"authsdk: not logged in",LOGIN_PENDING:"authsdk: login pending",LOGIN_ALREADY_PENDING:"authsdk: a login request is already pending",LOGIN_NOT_PENDING:"authsdk: no pending login request",LOGIN_SUPERSEDED:"authsdk: login state changed in another client",LOGIN_CONTEXT_MISMATCH:"authsdk: pending login belongs to a different Auth environment",LOGIN_DENIED:"authsdk: login denied",LOGIN_ACTION_REQUIRED:"authsdk: login requires user action",AUTH_REQUEST_REJECTED:"authsdk: authentication request rejected",LOGIN_EXPIRED:"authsdk: login expired",TOKEN_EXPIRED:"authsdk: token expired",REFRESH_FAILED:"authsdk: refresh failed",REFRESH_REJECTED:"authsdk: refresh request rejected",SIGN_FAILED:"authsdk: sign failed",STORE_UNAVAILABLE:"authsdk: store unavailable",PROTOCOL_ERROR:"authsdk: protocol error",INVALID_ARGUMENT:"authsdk: invalid argument"},k=class extends Error{code;cause;pendingLogin;constructor(e,r=qr[e],i,n){super(i instanceof Error?`${r}: ${i.message}`:r),this.name="AuthError",this.code=e,this.cause=i,this.pendingLogin=n;}};function E(t,e){return new k(t,qr[t],e)}function Kt(t,e){return t instanceof k&&(e===void 0||t.code===e)}var Vo=createRequire(import.meta.url),$o="US";function Jr(){return {name:Mo(),os:Yr(process.platform),osVersion:Qr(No.release()||"",64),architecture:Zr(process.arch),cliVersion:Jo(),region:Go()}}function Mo(t={}){let e=t.platform??process.platform,r;e==="darwin"?r=te(t.readMacOSModel??Ko,void 0):e==="win32"?r=te(t.readWindowsModel??Bo,void 0):e==="linux"&&(r=te(t.readLinuxModel??Wo,void 0));let i=zr(r??"");return i||zr(`${Yr(e)} ${Zr(t.architecture??process.arch)}`)||"CLI device"}function Go(t={}){let e=t.platform??process.platform,r=t.environment??process.env,i=[];if(e==="darwin")i.push(te(t.readMacOSLocale??Ho,void 0));else if(e==="win32"){let n=jo(te(t.readWindowsRegion??qo,void 0));if(n)return n}else e==="linux"&&i.push(...Xo(te(t.readLinuxLocales??zo,[])));i.push(r.LC_ALL,r.LC_MESSAGES,r.LANG,r.LANGUAGE,t.intlLocale??Intl.DateTimeFormat().resolvedOptions().locale);for(let n of i){let o=Fo(n);if(o)return o}return $o}function jo(t){let e=t?.trim().toUpperCase();return e&&/^[A-Z]{2}$/.test(e)?e:void 0}function Fo(t){if(!t)return;let e=t.trim(),r=e.match(/^(?:export\s+)?[A-Za-z_][A-Za-z0-9_]*=(.*)$/);if(r&&(e=r[1].trim()),e=e.replace(/^["']|["']$/g,""),e=e.split(":",1)[0].split(/[.@]/,1)[0].replaceAll("_","-"),!(!e||/^(?:C|POSIX)$/i.test(e)))try{let i=new Intl.Locale(e).region?.toUpperCase();return i&&/^[A-Z]{2}$/.test(i)?i:void 0}catch{return}}function Ho(){return rt("/usr/bin/defaults",["read","-g","AppleLocale"])}function Ko(){return rt("/usr/sbin/sysctl",["-n","hw.model"])}function Bo(){return rt("powershell.exe",["-NoProfile","-NonInteractive","-Command","(Get-CimInstance -ClassName Win32_ComputerSystem).Model"])}function Wo(){for(let t of ["/sys/devices/virtual/dmi/id/product_name","/sys/firmware/devicetree/base/model"])try{let e=readFileSync(t,"utf8").replaceAll("\0","").trim();if(e)return e}catch{}}function qo(){return rt("powershell.exe",["-NoProfile","-NonInteractive","-Command","Get-ItemPropertyValue -LiteralPath 'HKCU:\\Control Panel\\International\\Geo' -Name Name"])}function zo(){let t=[];for(let e of ["/etc/locale.conf","/etc/default/locale"])try{for(let r of readFileSync(e,"utf8").split(/\r?\n/)){let i=r.trim();/^(?:LC_ALL|LC_MESSAGES|LANG|LANGUAGE)=/.test(i)&&t.push(i);}}catch{}return t}function Xo(t){let e=["LC_ALL","LC_MESSAGES","LANG","LANGUAGE"],r=[];for(let i of e)r.push(...t.filter(n=>n?.trim().startsWith(`${i}=`)));return r.push(...t.filter(i=>!i?.includes("="))),r}function rt(t,e){try{return execFileSync(t,e,{encoding:"utf8",timeout:1e3,stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{return}}function te(t,e){try{return t()}catch{return e}}function Yr(t){switch(t){case "darwin":return "macOS";case "win32":return "Windows";case "linux":return "Linux";default:return t}}function Zr(t){return t==="x64"?"x86_64":t}function Jo(){for(let t of ["../../package.json","../../../package.json"])try{let e=Vo(t);if(typeof e.version=="string")return e.version}catch{}return ""}function Qr(t,e){return t.length>e?t.slice(0,e):t}function zr(t){return Qr(t.replace(/[^A-Za-z0-9 _.,()+-]/g,"").replace(/\s+/g," ").trim(),128)}var Zo="X-Tt-Cli-Access-Token",Qo="DPoP",es="Sec-Fetch-Site",ts="same-origin",it=class{current=Promise.resolve();async run(e){let r=this.current,i;this.current=new Promise(n=>{i=n;}),await r;try{return await e()}finally{i();}}},nt=class{core;constructor(e,r={}){if(!e.clientId.trim())throw new Error("authsdk: client_id is required");let i=r.protocol??new Be({baseUrl:e.baseUrl,aid:e.aid,pollRegion:e.pollRegion,headers:e.customHttpHeaders});this.core={clientId:e.clientId.trim(),aid:e.aid,accountDomain:e.pollRegion?new URL(e.baseUrl).host:void 0,authorizationUserInfoUrl:new URL(Tr,e.baseUrl).toString(),outsideAgent:e.outsideAgent,protocol:i,signer:r.signer??new qe,store:r.store??tt(e.storeServiceName),now:r.now??(()=>new Date),mutex:new it,startupRefreshPending:true,loginContext:{baseUrl:new URL(e.baseUrl).toString(),clientId:e.clientId.trim(),aid:e.aid,pollRegion:e.pollRegion,ppeHeader:Object.entries(e.customHttpHeaders??{}).find(([n])=>n.toLowerCase()==="x-tt-env")?.[1]}};}authenticator(){return new Bt(this.core)}authorizer(){return new ot(this.core)}},Bt=class{constructor(e){this.core=e;}core;async newLoginFlow(e){return this.core.mutex.run(async()=>{let r=await Ae(this.core.store,async()=>{let s=await os(this.core);if(zt(s,this.core.now()))throw ve("LOGIN_ALREADY_PENDING",s);return s}),i=b(r),n=Jr(),o=await this.core.protocol.getDeviceCode({clientId:this.core.clientId,dpopJkt:this.core.signer.thumbprint(r.deviceKey),deviceInfo:n,cliDeviceId:r.cliDeviceId,outsideAgent:this.core.outsideAgent},e).catch(s=>{throw ii(s)});return B(r),ie(r),r.deviceCode=o.deviceCode,r.userCode=o.userCode,r.verificationUri=o.verificationUri,r.intervalMs=o.intervalMs,r.loginExpiresAt=new Date(this.core.now().getTime()+o.expiresInMs),r.pollTicket=o.pollTicket,r.pollDomains={...o.pollDomains},r.loginContext={...this.core.loginContext},await N(this.core.store,r,i,"LOGIN_SUPERSEDED"),this.core.pendingDeviceCode=r.deviceCode,{userCode:o.userCode,verificationUri:o.verificationUri,intervalMs:o.intervalMs,expiresAt:r.loginExpiresAt,context:{...this.core.loginContext}}})}async checkLogin(e){return this.core.mutex.run(async()=>{let r=await Ae(this.core.store,async()=>{let o=await si(this.core.store);if(this.core.pendingDeviceCode&&o?.deviceCode!==this.core.pendingDeviceCode)throw E("LOGIN_SUPERSEDED");if(!o?.deviceCode||!o.loginExpiresAt||!o.pollTicket||!o.pollDomains)throw E("LOGIN_NOT_PENDING");as(o,this.core.loginContext),this.core.pendingDeviceCode=o.deviceCode;let s=this.core.now();if(s.getTime()>=o.loginExpiresAt.getTime())throw B(o),await this.core.store.save(o),E("LOGIN_EXPIRED");if(o.nextPollAt&&s.getTime()<o.nextPollAt.getTime())throw ve("LOGIN_PENDING",o);return o.nextPollAt=new Date(s.getTime()+Math.max(0,o.intervalMs??0)),await this.core.store.save(o),o}),i=b(r),n;try{n=await this.core.protocol.checkDeviceCode({clientId:this.core.clientId,deviceCode:r.deviceCode,pollTicket:r.pollTicket,pollDomains:r.pollDomains,cliDeviceId:r.cliDeviceId,outsideAgent:this.core.outsideAgent},e);}catch(o){let s=ii(o);throw s.code==="LOGIN_EXPIRED"||s.code==="LOGIN_DENIED"?(B(r),await N(this.core.store,r,i,"LOGIN_SUPERSEDED")):await Ae(this.core.store,()=>ai(this.core.store,i,"LOGIN_SUPERSEDED")),s.code==="LOGIN_PENDING"||s.code==="LOGIN_ACTION_REQUIRED"?ve(s.code,r,s.cause):s}return B(r),oi(r,n,this.core.now()),r.apiDomain=n.apiDomain,r.region=n.region,r.userInfo=n.userInfo,await N(this.core.store,r,i,"LOGIN_SUPERSEDED"),this.core.startupRefreshPending=false,this.core.pendingDeviceCode=void 0,await rs(this.core,r,e),qt(this.core.now(),r)})}authorizer(){return new ot(this.core)}},ot=class{constructor(e){this.core=e;}core;async state(e){return e?.throwIfAborted(),this.core.mutex.run(async()=>{try{return qt(this.core.now(),await Wt(this.core.store))}catch(r){if(r instanceof k&&r.code==="NOT_LOGGED_IN")return {loggedIn:false};throw r}})}async refresh(e=0,r){return this.core.mutex.run(async()=>{let i=await this.ensureActiveRecord(Math.max(0,e),r);return qt(this.core.now(),i)})}async inject(e,r){return this.core.mutex.run(async()=>{let i=await this.ensureActiveRecord(0,r);ni(this.core,i,e);})}async updateUserInfo(e){return this.core.mutex.run(async()=>{try{await Ae(this.core.store,()=>this.core.store.updateUserInfo(e));}catch(r){throw Se(r)}})}async userInfo(){return this.core.mutex.run(async()=>{let e=await Wt(this.core.store);return pi(e.userInfo)})}async logout(e){return this.core.mutex.run(async()=>{let r;try{r=await ei(this.core);}catch(o){if(o instanceof k&&o.code==="NOT_LOGGED_IN")return;throw o}let i=b(r),n=this.core.accountDomain??r.apiDomain;if(r.refreshToken&&n){let o=ti(n,kt,this.core.aid),s;try{s=this.core.signer.sign({method:"POST",url:o},r.deviceKey);}catch(a){throw E("SIGN_FAILED",a)}try{await this.core.protocol.revoke({clientId:this.core.clientId,refreshToken:r.refreshToken,apiDomain:n,dpopProof:s,cliDeviceId:r.cliDeviceId,outsideAgent:this.core.outsideAgent},e);}catch(a){throw V(a,"INVALID_REQUEST")?E("AUTH_REQUEST_REJECTED",a):E("PROTOCOL_ERROR",a)}}B(r),ie(r),await N(this.core.store,r,i,"LOGIN_SUPERSEDED");})}async ensureActiveRecord(e,r){let i=await ei(this.core),n=b(i);if(!i.accessToken)throw zt(i,this.core.now())?ve("LOGIN_PENDING",i):E("NOT_LOGGED_IN");let o=this.core.now();if(i.tokenExpiresAt&&o>=i.tokenExpiresAt)throw B(i),ie(i),await N(this.core.store,i,n),E("TOKEN_EXPIRED");if(i.refreshTokenExpiresAt&&o>=i.refreshTokenExpiresAt)throw B(i),ie(i),await N(this.core.store,i,n),E("TOKEN_EXPIRED");if(!this.core.startupRefreshPending&&!ss(o,i,e))return i;let s=this.core.accountDomain??i.apiDomain;if(!i.refreshToken||!s)throw ie(i),await N(this.core.store,i,n),E("NOT_LOGGED_IN");let a=ti(s,Ot,this.core.aid),c;try{c=this.core.signer.sign({method:"POST",url:a},i.deviceKey);}catch(m){throw E("SIGN_FAILED",m)}let p;try{p=await this.core.protocol.refreshToken({clientId:this.core.clientId,refreshToken:i.refreshToken,apiDomain:s,dpopProof:c,cliDeviceId:i.cliDeviceId,outsideAgent:this.core.outsideAgent},r);}catch(m){throw V(m,"EXPIRED_TOKEN")?(B(i),ie(i),await N(this.core.store,i,n),E("NOT_LOGGED_IN",m)):V(m,"INVALID_REQUEST")?E("REFRESH_REJECTED",m):E("REFRESH_FAILED",m)}return oi(i,p,this.core.now()),await N(this.core.store,i,n),this.core.startupRefreshPending=false,i}};async function rs(t,e,r){let i=b(e),n={method:"POST",url:t.authorizationUserInfoUrl,headers:{cli:"1","Content-Type":"application/json"},body:JSON.stringify({})},o;try{ni(t,e,n),o=(await t.protocol.fetchAuthorizationUserInfo({url:String(n.url),headers:n.headers,body:String(n.body)},r)).uid;}catch{return}e.userInfo=is(e.userInfo,o),await N(t.store,e,i,"LOGIN_SUPERSEDED");}function is(t,e){return ns(t)?{...t,uid:e}:{uid:e}}function ns(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ni(t,e,r){if(!e.accessToken)throw E("NOT_LOGGED_IN");let i=r.method.trim().toUpperCase(),n=new URL(String(r.url)),o=n.pathname||"/",s=n.host;t.aid!==void 0&&t.aid!==0&&n.searchParams.set("aid",String(t.aid));let a;try{a=t.signer.sign({method:i,url:n,accessToken:e.accessToken},e.deviceKey);}catch(c){throw E("SIGN_FAILED",c)}r.url=n.toString();for(let c of ["Authorization","sdk-version","X-Pub-Key","X-Req-Sign","X-Req-Ts","X-Req-Nonce","X-Req-Method","X-Req-Path","X-Req-Host"])cs(r,c);re(r,Zo,e.accessToken),re(r,Qo,a),re(r,es,ts),re(r,"X-Req-Method",i),re(r,"X-Req-Path",o),re(r,"X-Req-Host",s);}async function os(t){try{return await t.store.load()}catch(r){if(!D(r,"NOT_FOUND"))throw Se(r)}let e={cliDeviceId:randomUUID(),deviceKey:t.signer.generateDeviceKey()};return await t.store.save(e),e}async function ei(t){return Wt(t.store)}function oi(t,e,r){t.accessToken=e.accessToken;let i=new Date(r.getTime()+e.refreshTokenExpiresInMs);e.refreshToken?(t.refreshToken=e.refreshToken,t.refreshTokenExpiresAt=i):(!t.refreshTokenExpiresAt||i<t.refreshTokenExpiresAt)&&(t.refreshTokenExpiresAt=i),t.tokenExpiresAt=new Date(r.getTime()+e.expiresInMs),t.refreshAt=new Date(r.getTime()+Math.floor(e.expiresInMs/2));}function ss(t,e,r){return e.tokenExpiresAt?t>=e.tokenExpiresAt||e.refreshAt&&t>=e.refreshAt?true:r>0&&t.getTime()+r>e.tokenExpiresAt.getTime():r>0||!!(e.refreshAt&&t>=e.refreshAt)}function ti(t,e,r){let i=t.includes("://")?t:`https://${t}`,n=new URL(e,i);return r!==void 0&&r!==0&&n.searchParams.set("aid",String(r)),n}function B(t){delete t.loginContext,delete t.deviceCode,delete t.userCode,delete t.verificationUri,delete t.intervalMs,delete t.loginExpiresAt,delete t.nextPollAt,delete t.pollTicket,delete t.pollDomains;}function ie(t){delete t.accessToken,delete t.refreshToken,delete t.refreshTokenExpiresAt,delete t.tokenExpiresAt,delete t.refreshAt,delete t.apiDomain,delete t.region,delete t.userInfo;}async function Wt(t){try{return await t.load()}catch(e){throw Se(e)}}async function N(t,e,r,i="NOT_LOGGED_IN"){await Ae(t,async()=>{r!==void 0&&await ai(t,r,i),await t.save(e);});}async function si(t){try{return await t.load()}catch(e){if(D(e,"NOT_FOUND"))return;throw Se(e)}}async function ai(t,e,r){let i=await si(t);if(!i||b(i)!==e)throw r==="NOT_LOGGED_IN"&&i?.accessToken?E("LOGIN_SUPERSEDED"):E(r)}var ri=new WeakMap;async function Ae(t,e){try{if(t.withLock)return await t.withLock(e);let r=ri.get(t);return r||(r=new it,ri.set(t,r)),await r.run(e)}catch(r){throw r instanceof k?r:Se(r)}}function zt(t,e){return !!(t.deviceCode&&t.pollTicket&&t.pollDomains&&t.loginExpiresAt&&e.getTime()<t.loginExpiresAt.getTime())}function ci(t){if(!(!t.verificationUri||!t.loginExpiresAt))return {verificationUri:t.verificationUri,expiresAt:new Date(t.loginExpiresAt),intervalMs:t.intervalMs??0,...t.loginContext?{context:{...t.loginContext}}:{}}}function ve(t,e,r){return new k(t,void 0,r,ci(e))}function as(t,e){if(t.loginContext&&(t.loginContext.baseUrl!==e.baseUrl||t.loginContext.clientId!==e.clientId||t.loginContext.aid!==e.aid||t.loginContext.pollRegion!==e.pollRegion||t.loginContext.ppeHeader!==e.ppeHeader))throw ve("LOGIN_CONTEXT_MISMATCH",t)}function Se(t){return D(t,"NOT_FOUND")?E("NOT_LOGGED_IN",t):E("STORE_UNAVAILABLE",t)}function ii(t){return V(t,"AUTHORIZATION_PENDING")?E("LOGIN_PENDING",t):V(t,"ACCESS_DENIED")?E("LOGIN_DENIED",t):V(t,"EXPIRED_TOKEN")?E("LOGIN_EXPIRED",t):V(t,"LOGIN_BLOCKED")?E("LOGIN_ACTION_REQUIRED",t):V(t,"INVALID_REQUEST")?E("AUTH_REQUEST_REJECTED",t):E("PROTOCOL_ERROR",t)}function qt(t,e){return {...zt(e,t)?{pending:true,loginExpiresAt:e.loginExpiresAt,pendingLogin:ci(e)}:{},loggedIn:!!e.accessToken&&(e.tokenExpiresAt===void 0||t.getTime()<e.tokenExpiresAt.getTime())&&(e.refreshTokenExpiresAt===void 0||t.getTime()<e.refreshTokenExpiresAt.getTime()),...e.tokenExpiresAt?{expiresAt:e.tokenExpiresAt}:{},...e.userInfo!==void 0?{identity:pi(e.userInfo)}:{}}}function re(t,e,r){if(t.headers instanceof Headers){t.headers.set(e,r);return}t.headers??={},di(t.headers,e),t.headers[e]=r;}function cs(t,e){if(t.headers instanceof Headers){t.headers.delete(e);return}t.headers&&di(t.headers,e);}function di(t,e){let r=e.toLowerCase();for(let i of Object.keys(t))i.toLowerCase()===r&&delete t[i];}function pi(t){return t==null?t:typeof structuredClone=="function"?structuredClone(t):JSON.parse(JSON.stringify(t))}var st={region:"row",baseUrl:"https://user-sg.picoxr.com/",pollRegion:"sg"};var us=/^ppe_[A-Za-z0-9_-]+$/,ui=st.region,li=`pico-auth-cli-${ui}`,Re={clientId:"84479f74-a2ca-4582-adf0-0d461b2c18a5",baseUrl:st.baseUrl,aid:935458,pollRegion:st.pollRegion,storeServiceName:li};function Xt(t={}){let e=t.ppeHeader?ls(t.ppeHeader):void 0;return {...Re,...t.outsideAgent?.trim()?{outsideAgent:t.outsideAgent.trim()}:{},...e?{customHttpHeaders:{...e}}:{}}}function ls(t){if(!us.test(t))throw new TypeError("ppeHeader must match ppe_[A-Za-z0-9_-]+");return Object.freeze({"X-TT-Env":t,"X-Use-PPE":"1"})}var ms=365*24*60*60*1e3;function mi(t={},e={}){let r=Xt(t),i=e.store??tt(r.storeServiceName),n=new nt(r,{...e,store:i});return {getStatus(o){return n.authorizer().state(o)},startLogin(o={}){return n.authenticator().newLoginFlow(o.signal)},resumeLogin(o){return n.authenticator().checkLogin(o)},ensureAuthenticated(o){return n.authorizer().refresh(0,o)},refresh(o){return n.authorizer().refresh(ms,o)},injectAuth(o,s){return n.authorizer().inject(o,s)},logout(){return n.authorizer().logout()}}}var z={region:"row",endpoint:"https://developer-sg.picoxr.com",previewBaseUrl:"https://developer-global.picoxr.com",imagexControlEndpoint:"https://imagex-ap-singapore-1.bytevcloudapi.com"};var at=z.region,g=`pico-release-cli-${at}`,W=`pico-auth-cli-${at}`,Jt=z.endpoint,fi=z.previewBaseUrl,gi=z.imagexControlEndpoint,gs=Object.freeze({region:z.region,binName:g,endpoint:z.endpoint,auth:Object.freeze({baseUrl:Re.baseUrl,storeServiceName:Re.storeServiceName})});var hs={UNKNOWN:1,PROTOCOL_ERROR:1,ARGUMENT_INVALID:2,CONFIG_INVALID:2,NOT_LOGGED_IN:3,AUTH_PENDING:3,EXPIRED:3,OAUTH_FAILED:3,AUTH_SIGN_FAILED:3,STORE_UNAVAILABLE:3,NETWORK_TEMPORARY:4,WRITE_OUTCOME_UNKNOWN:5,BUSINESS_REJECTED:6,INVALID_STATUS:6,STATE_MISSING:7,STATE_CONFLICT:7,UPLOAD_FAILED:8,REVIEW_REJECTED:9,WAIT_TIMEOUT:10,USER_CANCELLED:130},_s={UNKNOWN:"Contact the VibeLab CLI maintainer with the redacted error details.",PROTOCOL_ERROR:"Unexpected server response format. Verify that the CLI and BAM API versions match.",ARGUMENT_INVALID:`Run ${g} --help or <subcommand> --help to check usage.`,CONFIG_INVALID:`Fix vibelab.yaml and run ${g} add.`,STATE_MISSING:`Run ${g} add or ${g} init --from-app <ID> to initialize local state first.`,STATE_CONFLICT:`Run ${g} init --from-app <ID> --force to re-sync remote data before proceeding.`,NOT_LOGGED_IN:`Run ${W} login and retry.`,AUTH_PENDING:"Complete PICO authorization and retry.",EXPIRED:`Run ${W} login and retry.`,OAUTH_FAILED:`Run ${W} login, approve authorization, and retry.`,AUTH_SIGN_FAILED:`Run ${W} login to re-authenticate; if the issue persists, contact the maintainer.`,STORE_UNAVAILABLE:"Check local credential store permissions and retry.",NETWORK_TEMPORARY:"Check network connectivity and retry.",WRITE_OUTCOME_UNKNOWN:`Write outcome is unknown and the CLI does not retry automatically; run ${g} state to verify server state first.`,BUSINESS_REJECTED:"Fix the request based on the server error message and retry.",INVALID_STATUS:`Run ${g} state to check the current status before proceeding.`,UPLOAD_FAILED:"Check asset files and network connectivity, then retry. Already uploaded assets are cached and reused.",REVIEW_REJECTED:`Run ${g} state to inspect rejection reasons, fix the issues, and run add -> commit -> push.`,WAIT_TIMEOUT:`Run ${g} state --watch later to continue checking progress.`,USER_CANCELLED:"Operation cancelled."},d=class extends Error{code;exitCode;action;details;transient;constructor(e,r={}){super(r.message??e,{cause:r.cause}),this.name="VibelabError",this.code=e,this.exitCode=hs[e],this.action=r.action??_s[e],this.details=r.details,this.transient=r.transient??e==="NETWORK_TEMPORARY";}};function P(t,e){return new d("ARGUMENT_INVALID",{message:t,details:e})}function j(t,e){return new d("PROTOCOL_ERROR",{message:t,details:e})}function Yt(t){return t instanceof d?t:new d("UNKNOWN",{message:t instanceof Error?t.message:String(t),cause:t})}function hi(t){switch(t.code){case "NOT_LOGGED_IN":case "LOGIN_NOT_PENDING":return new d("NOT_LOGGED_IN",{message:"Not logged into a PICO account.",cause:t});case "LOGIN_PENDING":case "LOGIN_ALREADY_PENDING":case "LOGIN_ACTION_REQUIRED":return new d("AUTH_PENDING",{message:"PICO authorization is still pending.",cause:t});case "LOGIN_SUPERSEDED":case "LOGIN_CONTEXT_MISMATCH":return new d("AUTH_PENDING",{message:"PICO login state changed or belongs to another Auth environment.",action:`Check ${W} status and resume with the original region and PPE options; do not repeat writes automatically.`,cause:t});case "LOGIN_EXPIRED":case "TOKEN_EXPIRED":return new d("EXPIRED",{message:"PICO login credentials have expired.",cause:t});case "REFRESH_FAILED":case "PROTOCOL_ERROR":return new d("NETWORK_TEMPORARY",{message:"Failed to refresh PICO login credentials.",transient:true,cause:t});case "STORE_UNAVAILABLE":return new d("STORE_UNAVAILABLE",{message:"Unable to read local login credentials.",cause:t});case "LOGIN_DENIED":return new d("OAUTH_FAILED",{message:"PICO authorization was denied.",cause:t});case "AUTH_REQUEST_REJECTED":case "REFRESH_REJECTED":return new d("OAUTH_FAILED",{message:"PICO authentication request was rejected.",action:"Check the system clock and Auth configuration before retrying; do not repeat the rejected request unchanged.",transient:false,cause:t});case "SIGN_FAILED":return new d("AUTH_SIGN_FAILED",{message:"Request signing failed.",cause:t});case "INVALID_ARGUMENT":return new d("ARGUMENT_INVALID",{message:t.message,cause:t});default:return new d("UNKNOWN",{message:t.message,cause:t})}}function _i(t,e,r){return new d("BUSINESS_REJECTED",{message:e||`${r} failed (code=${t})`,details:{backend_code:t}})}var T={listApps:"/api/v1/apps",getApp:"/api/v1/apps/detail",saveApp:"/api/v1/apps/save",offlineApp:"/api/v1/apps/offline",deleteApp:"/api/v1/apps/delete",listVersions:"/api/v1/app-versions",getVersion:"/api/v1/app-versions/detail",saveVersion:"/api/v1/app-versions/save",deleteVersion:"/api/v1/app-versions/delete",submitReview:"/api/v1/app-versions/review-submissions",imagexSign:"/api/v1/vibe-app/imagex/sign",imagexDisplay:"/api/v1/vibe-app/imagex/display",deployKey:"/api/v1/vibe-app/github/deploy-key"},Ie="VIBELAB_ENDPOINT";var ws=3e4,ys=3,Es=500,Zt=401,As=408,vs=429,Ss=500,ct=class{endpoint;auth;fetchImpl;requestHeaders;sleep;timeoutMs;getMaxAttempts;constructor(e){this.endpoint=e.endpoint.replace(/\/+$/,""),this.auth=e.auth,this.fetchImpl=e.fetch??fetch,this.requestHeaders={...e.requestHeaders},this.sleep=e.sleep??Rs,this.timeoutMs=e.timeoutMs??ws,this.getMaxAttempts=e.getMaxAttempts??ys;}async listApps(e={}){return this.requestData({method:"GET",path:T.listApps,action:"List apps",query:{page:e.page,page_size:e.page_size,status:e.status}})}async getApp(e){return this.requestData({method:"GET",path:T.getApp,action:"Get app detail",query:{app_id:String(e)}})}async saveApp(e){return {drafts:((await this.requestData({method:"POST",path:T.saveApp,action:"Save app draft",body:e})).drafts??[]).map(wi)}}async offlineApp(e){await this.request({method:"POST",path:T.offlineApp,action:"Offline app",body:{app_id:String(e)}});}async deleteApp(e){await this.request({method:"POST",path:T.deleteApp,action:"Delete app",body:{app_id:String(e)}});}async listVersions(e){return this.requestData({method:"GET",path:T.listVersions,action:"List versions",query:{app_id:String(e.app_id),page:e.page,page_size:e.page_size}})}async getVersion(e,r,i=false){return this.requestData({method:"GET",path:T.getVersion,action:"Get version detail",query:{app_id:String(e),version_id:String(r),...i?{use_pending_info:true}:{}}})}async saveVersion(e){let r=await this.requestData({method:"POST",path:T.saveVersion,action:"Save version draft",body:e});return wi(r)}async deleteVersion(e,r){await this.request({method:"POST",path:T.deleteVersion,action:"Delete version draft",body:{app_id:String(e),version_id:String(r)}});}async submitReview(e){return this.requestData({method:"POST",path:T.submitReview,action:"Submit review",body:e})}async getImagexSign(){return this.requestData({method:"GET",path:T.imagexSign,action:"Get asset upload credentials"})}async getDisplayUrl(e){let r=await this.requestData({method:"GET",path:T.imagexDisplay,action:"Get asset display URL",query:{file:e}});if(typeof r!="string")throw j("Get asset display URL returned non-string data.");return r}async getDeployKey(e){return this.requestData({method:"POST",path:T.deployKey,action:"Get repository Deploy Key",body:{repo_url:e}})}async requestData(e){let r=await this.request(e);if(r.data===void 0)throw j(r.message||`${e.action} returned no data.`);return r.data}async request(e){let r=e.method==="GET"?this.getMaxAttempts:1,i;for(let n=0;n<r;n+=1){n>0&&await this.sleep(Es*2**(n-1));try{return await this.requestWithAuthRetry(e)}catch(o){if(!(o instanceof d)||!o.transient)throw o;i=o;}}throw i??j(`${e.action} failed.`)}async requestWithAuthRetry(e){await this.withTimeoutSignal(i=>this.auth.ensureAuthenticated(i));let r=await this.send(e);if(r.status===Zt&&(await this.withTimeoutSignal(i=>this.auth.refresh(i)),r=await this.send(e),r.status===Zt))throw new d("EXPIRED",{message:"Server still returned 401 after refreshing authentication credentials.",details:{http_status:Zt}});return this.parseResponse(r,e)}async withTimeoutSignal(e){let r=new AbortController,i=setTimeout(()=>r.abort(),this.timeoutMs);try{return await e(r.signal)}finally{clearTimeout(i);}}async send(e){let r=e.body===void 0?void 0:JSON.stringify(e.body),i={method:e.method,url:this.buildUrl(e.path,e.query),headers:{Accept:"application/json",...this.requestHeaders,...r===void 0?{}:{"Content-Type":"application/json"}},body:r},n=new AbortController,o=setTimeout(()=>n.abort(),this.timeoutMs);try{try{await this.auth.inject(i,n.signal);}catch(s){throw s instanceof d?s:new d("AUTH_SIGN_FAILED",{message:"Request signing failed before sending the HTTP request.",cause:s})}try{let s=await this.fetchImpl(i.url,{method:i.method,headers:i.headers,body:r,redirect:"error",signal:n.signal}),a=await s.text();return {status:s.status,ok:s.ok,text:a}}catch(s){throw s instanceof d?s:yi(e,s)}}finally{clearTimeout(o);}}parseResponse(e,r){let i,n=false;if(e.text.trim().length>0)try{i=JSON.parse(e.text),n=!0;}catch{n=false;}let o=n&&i&&typeof i=="object"&&!Array.isArray(i)?i:void 0;if(e.status===As||e.status===vs||e.status>=Ss)throw yi(r,void 0,e.status,o?.message);if(!o)throw e.ok?j(n?`${r.action} returned a non-object JSON payload.`:`${r.action} returned a non-JSON response.`,{http_status:e.status}):new d("BUSINESS_REJECTED",{message:`${r.action} failed (HTTP ${e.status}).`,details:{http_status:e.status}});if(o.code!==void 0&&o.code!==0)throw _i(o.code,o.message,r.action);if(!e.ok)throw new d("BUSINESS_REJECTED",{message:o.message||`${r.action} failed (HTTP ${e.status}).`,details:{http_status:e.status}});return o}buildUrl(e,r={}){let i=new URL(`${this.endpoint}${e}`);for(let[n,o]of Object.entries(r))o!==void 0&&i.searchParams.set(n,String(o));return i.toString()}};function wi(t){return {app_id:String(t.app_id),release_channel:t.release_channel,version_id:String(t.version_id)}}function yi(t,e,r,i){let n=r===void 0?void 0:{http_status:r};return t.method!=="GET"?new d("WRITE_OUTCOME_UNKNOWN",{message:`${t.action} request failed; the server may have already processed it.`,details:n,cause:e}):new d("NETWORK_TEMPORARY",{message:i||(r===void 0?`${t.action} network request failed.`:`${t.action} failed (HTTP ${r}).`),details:n,transient:true,cause:e})}function Rs(t){return new Promise(e=>setTimeout(e,t))}var dt=class{constructor(e,r={}){this.options=r;this.provider=e;}options;provider;async ensureAuthenticated(e){await this.call(()=>this.client().ensureAuthenticated(e));}async refresh(e){await this.call(()=>this.client().refresh(e));}async inject(e,r){await this.call(()=>this.client().injectAuth(e,r));}client(){return this.provider??=mi(this.options),this.provider}async call(e){try{return await e()}catch(r){throw Kt(r)?hi(r):r}}};var pt="VIBELAB_MOCK_AUTH",Is="X-Vibelab-Mock-Auth",bs="1",Ts="vibelab-local-mock",Ps="vibelab-local-mock-signature",Cs=new Set(["1","true"]),Ds=new Set(["","0","false"]),ut=class{async ensureAuthenticated(){return {loggedIn:true}}async refresh(){return {loggedIn:true}}async injectAuth(e){let r=e.method.trim().toUpperCase(),i=new URL(String(e.url)).pathname||"/";be(e,"Authorization",`Bearer ${Ts}`),be(e,"X-Req-Sign",Ps),be(e,"X-Req-Method",r),be(e,"X-Req-Path",i),be(e,Is,bs);}};function Ei(t){let e=t[pt]?.trim().toLowerCase()??"";if(Cs.has(e))return true;if(Ds.has(e))return false;throw P(`${pt} only supports 1/true/0/false.`)}function be(t,e,r){if(t.headers instanceof Headers){t.headers.set(e,r);return}t.headers??={},t.headers[e]=r;}var vi={1:"Draft",2:"Reviewing",3:"Rejected",4:"Online",5:"Offline"},C={0:"Unknown",1:"Draft",2:"Reviewing",3:"Rejected",4:"Approved",5:"Build Validating",6:"Build Failed"},ne={0:"-",1:"Info Update",2:"Version Update"},Si={0:"Unknown",1:"Pending",2:"Approved",3:"Rejected"};function v(t,e){return e===void 0?"-":t[e]??String(e)}function Te(t){if(!t)return "-";let e=t<1e11?t*1e3:t;return new Date(e).toISOString().replace("T"," ").replace(/\.\d{3}Z$/,"Z")}var se="vibelab.yaml",De=["Claude Code","Codex CLI","Cursor","GitHub Copilot","Trae CLI"],er=["android_spatial","unity","ue","godot"],oe=["body_tracking","hand_tracking","eye_tracking","expression_simulation","avatar","mixed_reality","mixed_reality_capture","controller_support","none"],lt=["game","application"],mt=["public","private"],w={nameMaxLength:50,sloganMaxLength:80,descriptionMaxLength:1e3,tagMaxCount:5,tagMaxLength:10,versionNameMaxLength:50,versionNotesMaxLength:1e3,customAiToolMaxLength:20,customTechStackMaxLength:20,teammateMaxCount:3,teammateMaxLength:20,detailImageMinCount:1,detailImageMaxCount:7,videoMaxCount:3},Os=/^https:\/\/github\.com\/[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9._-]+(?:\.git)?\/?$/,Ri=/^[0-9a-fA-F]{7,40}$/,Pe=(t,e)=>z$1.string({error:`${t} is required`}).trim().min(1,`${t} is required`).max(e,`${t} must not exceed ${e} characters`),Ce=t=>z$1.string({error:`${t} is required`}).trim().min(1,`${t} is required`),ks=z$1.object({file:Ce("Video file"),cover:Ce("Video cover")}),Ns=z$1.union([z$1.string(),z$1.number(),z$1.null()]).transform(t=>{if(t===null)return;let e=String(t).trim();return e.length>0?e:void 0}).refine(t=>t===void 0||t!=="0","app.id must be a valid non-zero App ID").optional(),Ls=z$1.object({id:Ns,name:Pe("App name",w.nameMaxLength),slogan:Pe("Slogan",w.sloganMaxLength),description:Pe("App description",w.descriptionMaxLength),tags:z$1.array(z$1.string()).transform(rr).refine(t=>t.length>0,"At least 1 tag is required"),category:z$1.enum(lt,{error:`Category must be ${lt.join(" | ")}`}),icon:Ce("App icon"),landscape:Ce("Landscape poster"),detail_images:z$1.array(Ce("Detail image")).min(w.detailImageMinCount,`At least ${w.detailImageMinCount} detail image is required`).max(w.detailImageMaxCount,`At most ${w.detailImageMaxCount} detail images are allowed`),videos:z$1.array(ks).max(w.videoMaxCount,`At most ${w.videoMaxCount} videos are allowed`).default([])}),Us=z$1.object({name:Pe("Version name",w.versionNameMaxLength),notes:Pe("Release notes",w.versionNotesMaxLength)}),Vs=z$1.object({repo_url:z$1.string().trim().regex(Os,"repo_url must be in https://github.com/<owner>/<repo> format"),repo_visibility:z$1.enum(mt,{error:`repo_visibility must be ${mt.join(" | ")}`}),commit_sha:z$1.string().trim().regex(Ri,"commit_sha must be 7-40 hexadecimal characters").optional(),tech_stack:z$1.string().trim().min(1,"tech_stack is required").refine(t=>tr(t)||t.length<=w.customTechStackMaxLength,`Custom tech_stack must not exceed ${w.customTechStackMaxLength} characters`),ai_tool:z$1.string().trim().min(1,"ai_tool is required").refine(t=>$s(t)||t.length<=w.customAiToolMaxLength,`Custom ai_tool must not exceed ${w.customAiToolMaxLength} characters`),ai_model:z$1.string().trim().min(1,"ai_model is required"),features:z$1.array(z$1.enum(oe,{error:`features values must be ${oe.join(" | ")}`})).min(1,"Select at least 1 feature (use none if no features apply)").refine(t=>!t.includes("none")||t.length===1,"none cannot be combined with other features").transform(t=>[...new Set(t)]),teammates:z$1.array(z$1.string().trim().min(1,"Teammate name cannot be empty").max(w.teammateMaxLength,`Teammate name must not exceed ${w.teammateMaxLength} characters`)).max(w.teammateMaxCount,`At most ${w.teammateMaxCount} teammates are allowed`).refine(t=>new Set(t).size===t.length,"Teammate names must be unique").default([])}),Ii=z$1.object({app:Ls,version:Us,build:Vs});function tr(t){return er.includes(t)}function $s(t){return De.includes(t)}function bi(t){return Ri.test(t)}function rr(t){let e=[];for(let r of t){let i=r.trim().slice(0,w.tagMaxLength);if(i&&!e.includes(i)&&e.push(i),e.length>=w.tagMaxCount)break}return e}function xe(t){return Ge.join(t,se)}async function ir(t){let e=xe(t),r;try{r=await readFile(e,"utf8");}catch(i){throw new d("CONFIG_INVALID",{message:`Configuration file ${se} not found.`,action:`Run ${g} init first to generate the configuration file.`,cause:i})}try{return parse(r)}catch(i){throw new d("CONFIG_INVALID",{message:`${se} is not valid YAML: ${i instanceof Error?i.message:String(i)}`,cause:i})}}function Ci(t){let e=Ii.safeParse(t);return e.success?{config:e.data,issues:[]}:{issues:qs(e.error)}}async function nr(t,e){let r=xe(t);return await Di(r,stringify(e,{lineWidth:0})),r}async function ft(t,e){let r=xe(t),i=await readFile(r,"utf8"),n=parseDocument(i),o=String(e).trim(),s=n.get("app",true);if(isMap(s)){let a=s.items.find(c=>isScalar(c.key)&&String(c.key.value)==="id");if(a)if(isScalar(a.value)){if(String(a.value.value)===o)return;a.value.value=o;}else a.value=n.createNode(o);else s.items.unshift(n.createPair("id",o));}else n.setIn(["app","id"],o);await Di(r,n.toString({lineWidth:0}));}async function Di(t,e){let r=`${t}.${process.pid}.${randomUUID()}.tmp`;await writeFile(r,e,"utf8"),await rename(r,t);}async function xi(t){try{let e=await ir(t);if(!e||typeof e!="object")return;let r=e.app;if(!r||typeof r!="object")return;let i=r.id;if(typeof i!="string"&&typeof i!="number")return;let n=String(i).trim();return n.length>0&&n!=="0"?n:void 0}catch{return}}function qs(t){return t.issues.map(e=>({path:e.path.length>0?e.path.map(String).join("."):"(root)",message:e.message}))}var Oi=new Set([2,5]);async function ki(t,e){if(!await t.confirm(e,{destructive:true}))throw new d("USER_CANCELLED",{message:"Operation cancelled."})}var or=[1],Js="zh-CN",sr="uri:",Ys="vibe-lab/",Ni="obj/",Li={android_spatial:2,unity:3,ue:4,godot:5},Ui={body_tracking:1,hand_tracking:2,eye_tracking:3,expression_simulation:4,avatar:5,mixed_reality:6,mixed_reality_capture:7,controller_support:8,none:9};function ar(t){return t.startsWith(sr)}function Zs(t){return `${sr}${t}`}function cr(t){return Vi(t.slice(sr.length))}function Vi(t){let e=t.trim();try{e.startsWith("//")?e=new URL(`https:${e}`).pathname:/^https?:\/\//i.test(e)&&(e=new URL(e).pathname);}catch{}e=(e.split(/[?#]/,1)[0]??"").replace(/^\/+/,"");let r=e.indexOf(Ys);return r!==-1?e.slice(r):e.startsWith(Ni)?e.slice(Ni.length):e}function $i(t,e,r){let{app:i,version:n,build:o}=t,s=tr(o.tech_stack)?o.tech_stack:void 0,a=Qs(o.features);return {assets:[{cover_art:{landscape:e.landscape},description:i.description,detail_images:e.detail_images,icon:e.icon,language_code:Js,name:i.name,slogan:i.slogan,tags:rr(i.tags),version_notes:n.notes,videos:e.videos.map(c=>({image_src:c.image_src,video_url:c.video_url}))}],features_and_release_config:{ai_tool:o.ai_tool,ai_model:o.ai_model,app_type:s?Li[s]:6,category:i.category==="game"?1:2,commit_sha:r,features:JSON.stringify(a),repo_url:o.repo_url,repo_visibility:o.repo_visibility==="private"?2:1,teammates:o.teammates,...s?{}:{tech_stack:o.tech_stack},version_name:n.name},release_channels:[...or]}}function Qs(t){let e=[...new Set(t.map(r=>Ui[r]))];return e.includes(9)?[9]:e}function Mi(t,e){let r=t.assets?.find(o=>o.language_code?.toLowerCase().startsWith("zh"))??t.assets?.[0],i=t.features_and_release_config??{},n=o=>o?Zs(Vi(o)):"";return {app:{...e?{id:String(e)}:{},name:r?.name??"",slogan:r?.slogan??"",description:r?.description??"",tags:r?.tags??[],category:i.category===1?"game":"application",icon:n(r?.icon),landscape:n(r?.cover_art?.landscape),detail_images:(r?.detail_images??[]).map(n),videos:(r?.videos??[]).map(o=>({file:n(o.video_url),cover:n(o.image_src)}))},version:{name:i.version_name||t.version_name||"1.0.0",notes:r?.version_notes??""},build:{repo_url:i.repo_url??"",repo_visibility:i.repo_visibility===2?"private":"public",tech_stack:ea(i.app_type,i.tech_stack),ai_tool:i.ai_tool||De[0],ai_model:i.ai_model??"",features:ta(i.features),teammates:i.teammates??[]}}}function ea(t,e){let r=Object.entries(Li).find(([,i])=>i===t);return r?r[0]:e??""}function ta(t){if(!t)return ["none"];let e;try{e=JSON.parse(t);}catch{return ["none"]}if(!Array.isArray(e))return ["none"];let r=oe.filter(i=>e.includes(Ui[i])||e.includes(i));return r.length===0?["none"]:r.includes("none")?["none"]:r}var ae=1024*1024,gt=[".jpg",".jpeg",".png"],oa=new Set(["jpeg","png"]),ht={icon:{label:"App icon",kind:"image",extensions:gt,maxBytes:4*ae,width:1024,height:1024},landscape:{label:"Landscape poster",kind:"image",extensions:gt,maxBytes:5*ae,width:2560,height:1440},detail_image:{label:"Detail image",kind:"image",extensions:gt,maxBytes:5*ae,width:2560,height:1440},video:{label:"Video",kind:"video",extensions:[".mp4"],maxBytes:100*ae},video_cover:{label:"Video cover",kind:"image",extensions:gt,maxBytes:5*ae,width:2560,height:1440}};async function Gi(t,e){let r=ht[e],i=s=>[{file:t,message:`${r.label} ${s}`}],n=Ge.extname(t).toLowerCase();if(!r.extensions.includes(n))return i(`format must be ${r.extensions.join("/")}`);let o;try{let s=await stat(t);if(!s.isFile())return i("is not a file");o=s.size;}catch{return i("file does not exist")}if(o<=0)return i("size must be greater than 0MB");if(o>r.maxBytes)return i(`must not exceed ${r.maxBytes/ae}MB`);if(r.kind==="video")return [];try{let s=await na(t).metadata();if(!s.format||!oa.has(s.format))return i("actual content is not a JPG/PNG image");if(s.width!==r.width||s.height!==r.height)return i(`dimensions must be ${r.width}x${r.height}, got ${s.width}x${s.height}`)}catch{return i("failed to parse image content")}return []}var da={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".mp4":"video/mp4"};function pa(t){let{app:e}=t;return [{source:e.icon,rule:"icon"},{source:e.landscape,rule:"landscape"},...e.detail_images.map(r=>({source:r,rule:"detail_image"})),...e.videos.flatMap(r=>[{source:r.file,rule:"video"},{source:r.cover,rule:"video_cover"}])]}async function ji(t,e){let r=[];for(let i of pa(t))ar(i.source)?cr(i.source)||r.push({file:i.source,message:"Remote asset URI after uri: cannot be empty"}):r.push(...await Gi(Ge.resolve(e,i.source),i.rule));return r}async function ua(t){let e=createHash("sha256");for await(let r of createReadStream(t))e.update(r);return e.digest("hex")}async function Fi(t){let{config:e,cwd:r,store:i,uploader:n,onProgress:o}=t,s=async(l,_)=>{if(ar(l))return o?.({file:l,status:"remote"}),cr(l);let f=Ge.resolve(r,l);if((await stat(f)).size<=0)throw new d("CONFIG_INVALID",{message:`${ht[_].label} size must be greater than 0MB: ${l}`});let J=await ua(f),xt=ht[_].kind,y=await i.getCachedAsset(J);if(y)return o?.({file:l,status:"cached"}),y.uri;let H=Ge.extname(f).toLowerCase(),[U]=await n.upload([{path:f,extension:H,contentType:da[H]??"application/octet-stream"}]);if(!U)throw new Error(`No URI returned for uploaded asset: ${l}`);return await i.cacheAsset(J,U,xt),o?.({file:l,status:"uploaded"}),U},{app:a}=e,c=await s(a.icon,"icon"),p=await s(a.landscape,"landscape"),m=[];for(let l of a.detail_images)m.push(await s(l,"detail_image"));let u=[];for(let l of a.videos)u.push({video_url:await s(l.file,"video"),image_src:await s(l.cover,"video_cover")});return {icon:c,landscape:p,detail_images:m,videos:u}}var _t="Open the preview URL in your browser to preview or modify the content uploaded by the CLI, and make sure to check and agree to the relevant agreements on the web page before final submission.";async function la(t,e){return t.progress("Processing assets..."),Fi({config:e,cwd:t.cwd,store:t.store,uploader:t.uploader,onProgress:({file:r,status:i})=>{let n={cached:"Cached",uploaded:"Uploaded",remote:"Using existing URI"};t.progress(` ${n[i]}: ${r}`);}})}async function ke(t,e,r,i,n={}){let o=await la(t,e),s=$i(e,o,r),a;if(i.update_type===void 0){t.progress("Saving app draft...");let c=i.drafts?.length?i.drafts:or.map(u=>({app_id:i.app_id,release_channel:u,version_id:i.version_id})),m=(await t.api.saveApp({assets:s.assets,drafts:c,features_and_release_config:s.features_and_release_config})).drafts[0];if(!m)throw new d("PROTOCOL_ERROR",{message:"Saving app draft did not return a draft ref."});a=m;}else t.progress("Saving version draft..."),a=await t.api.saveVersion({app_id:i.app_id,version_id:i.version_id,update_type:i.update_type,assets:s.assets,features_and_release_config:s.features_and_release_config,release_channels:s.release_channels});return await t.store.recordDraft(a,{updateType:i.update_type,assets:o,committed:n.committed??true}),{draft:a,update_type:i.update_type,assets:o}}function wt(t,e){return {app_id:t,version_id:"0",...e===void 0?{}:{update_type:e}}}function Hi(t){if(!t.app_id||!t.version_id||t.version_id==="0")throw new d("STATE_MISSING",{message:"No editable draft found in local state.",action:`Run ${g} commit to save a cloud draft first.`});return {app_id:t.app_id,version_id:t.version_id,...t.update_type===void 0?{}:{update_type:t.update_type},...t.drafts?{drafts:t.drafts}:{}}}function Ne(t,e){return `${fi}/vibelab/myapp/${encodeURIComponent(t)}/versions/${encodeURIComponent(e)}/edit?from=cli`}function yt(t){return {app_id:t.draft.app_id,version_id:t.draft.version_id,release_channel:t.draft.release_channel,update_type:t.update_type??null,preview_url:Ne(t.draft.app_id,t.draft.version_id),assets:t.assets}}var ma="PICO Vibe Lab";async function pr(t,e){let r=await t.api.getDeployKey(e);if(!r.public_key)throw new d("PROTOCOL_ERROR",{message:"Server did not return a Deploy Key public key."});return {repo_url:e,title:ma,public_key:r.public_key,settings_url:fa(e)}}function fa(t){return `${t.replace(/\/+$/,"").replace(/\.git$/,"")}/settings/keys`}async function ur(t,e){if(e.build.repo_visibility!=="private")return;let r=await pr(t,e.build.repo_url);if(t.progress(`Private repository requires a read-only Deploy Key (Title: ${r.title}):`),t.progress(r.public_key),t.progress(`Settings URL: ${r.settings_url}`),!await t.confirm("Have you added the Deploy Key to the GitHub repository?",{destructive:false}))throw new d("USER_CANCELLED",{message:"Deploy Key addition was not confirmed; stopped."});return r}function Et(t,e){let r=t===void 0?e:String(t);if(!r)throw new d("STATE_MISSING",{message:"No app ID specified and no app_id found in local state.",action:`Pass the app ID as an argument, or run ${g} add / ${g} init --from-app <ID> first.`});return r}async function lr(t,e={}){let{config:r,issues:i}=Ci(await ir(t.cwd));if(!r)return {valid:false,issues:i,warnings:[]};let n=[...i],o=[];for(let c of await ji(r,t.cwd))n.push({path:c.file,message:c.message});let s=await t.git.read(t.cwd),a=r.build.commit_sha??s.head;return (!a||!bi(a))&&(e.allowMissingCommitSha&&!r.build.commit_sha?o.push(`No local git HEAD commit found yet; make sure to run git commit and push to GitHub before running ${g} commit`):n.push({path:"build.commit_sha",message:"commit_sha is not configured and local git HEAD could not be read"})),r.build.commit_sha&&s.head&&!s.head.startsWith(r.build.commit_sha)&&o.push(`build.commit_sha (${r.build.commit_sha}) does not match local HEAD (${s.head})`),s.dirty&&o.push("Git working tree has uncommitted changes; review builds only use commits pushed to the remote"),{valid:n.length===0,issues:n,warnings:o,...a?{commit_sha:a}:{},config:r}}async function At(t){let e=await lr(t);if(!e.valid||!e.config||!e.commit_sha)throw new d("CONFIG_INVALID",{message:`Local validation failed: ${e.issues.map(r=>`${r.path} ${r.message}`).join("; ")}`,action:`Run ${g} add to inspect all issues and fix them.`,details:{issues:e.issues}});return {config:e.config,commitSha:e.commit_sha,warnings:e.warnings}}var Ki=1e4,Bi=30*6e4,mr=new Set([2,5]),ga=new Set([3,6]);async function Wi(t,e){let{config:r,warnings:i}=await At(t),n=await t.store.readState();if(r.app.id!==void 0&&n.app_id!==void 0&&r.app.id!==n.app_id)throw new d("STATE_CONFLICT",{message:`app.id (${r.app.id}) in vibelab.yaml does not match local draft state (${n.app_id}).`,action:`Run ${g} commit first to save a draft for the target app before running push.`});if(n.committed===false)throw new d("INVALID_STATUS",{message:"Current draft has not been committed yet (or has already been submitted for review).",action:`Run ${g} commit first, open the preview URL to check the agreement box, and then run ${g} push.`});let o=Hi(n);i.forEach(u=>t.progress(`Warning: ${u}`));let s=o.drafts?.[0]??{app_id:o.app_id,version_id:o.version_id,release_channel:1};t.progress("Submitting review...");let a=await t.api.submitReview({drafts:[s]});await t.store.updateState({committed:false});let p={draft:{app_id:s.app_id,version_id:s.version_id,release_channel:s.release_channel,update_type:o.update_type??null,preview_url:Ne(s.app_id,s.version_id),...n.assets?{assets:n.assets}:{}},submission:a,warnings:i};if(!e.wait)return p;let m=await ha(t,s.app_id,s.version_id,e.wait);if(p.final_version=m,m.status!==void 0&&ga.has(m.status))throw new d("REVIEW_REJECTED",{message:`Version ${s.version_id} ${v(C,m.status)}.`,details:{status:m.status,rejection_issues:m.rejection_issues??[]}});return p}async function ha(t,e,r,i){let n=t.now()+i.timeoutMs,o;for(;;){let s=await t.api.getVersion(e,r);if(s.status!==o&&(t.progress(`Version status: ${v(C,s.status)}`),o=s.status),s.status===void 0||!mr.has(s.status))return s;if(t.now()+i.intervalMs>n)throw new d("WAIT_TIMEOUT",{message:`Timed out waiting for version ${r}; current status: ${v(C,s.status)}.`,details:{status:s.status}});await t.sleep(i.intervalMs);}}async function fr(t,e){let r=await t.store.readState(),i=Et(e,r.app_id),[n,o]=await Promise.all([t.api.getApp(i),t.api.listVersions({app_id:i})]),s=n.editing_version?.version_id,a=s===void 0?void 0:await t.api.getVersion(i,s);return {app_id:i,detail:n,versions:o,...a?{editing_version:a}:{}}}function _a(t){let e=t.editing_version?.status??t.detail.editing_version?.status;if(e!==void 0&&mr.has(e))return true;let r=t.detail.online_version?.version_id;return (t.versions.versions??[]).some(i=>r!==void 0&&String(i.version_id)===String(r)&&i.info_update_status!==void 0&&mr.has(i.info_update_status))}async function qi(t,e,r){let i=t.now()+r.timeoutMs;for(;;){let n=await fr(t,e);if(r.onSnapshot(n),!_a(n))return n;if(t.now()+r.intervalMs>i)throw new d("WAIT_TIMEOUT",{message:"Timed out waiting for review/build result."});await t.sleep(r.intervalMs);}}var wa=new Set([1,3,6]);async function zi(t){return t.store.withLock("add",()=>ya(t))}async function ya(t){let{config:e,...r}=await lr(t,{allowMissingCommitSha:true});if(!r.valid||!e)throw new d("CONFIG_INVALID",{message:`Local validation failed: ${r.issues.map(s=>`${s.path} ${s.message}`).join("; ")}`,action:`Fix vibelab.yaml or local asset files and run ${g} add again.`,details:{issues:r.issues,warnings:r.warnings}});let i=e.build.repo_visibility==="private"?await pr(t,e.build.repo_url):void 0,n=await t.store.readState();if(!e.app.id&&!n.app_id){let s=await ke(t,e,r.commit_sha??"0000000",wt("0"),{committed:false}),a=String(s.draft.app_id),c=String(s.draft.version_id);return await ft(t.cwd,a),{...r,app_id:a,version_id:c,created_draft:true,preview_url:Ne(a,c),repo_visibility:e.build.repo_visibility,...i?{deploy_key:i}:{}}}if(!e.app.id&&n.app_id)return await ft(t.cwd,n.app_id),{...r,app_id:n.app_id,...n.version_id?{version_id:n.version_id}:{},created_draft:false,repo_visibility:e.build.repo_visibility,...i?{deploy_key:i}:{}};let o=String(e.app.id);return n.app_id!==o&&(await t.store.clearApp(),await t.store.updateState({app_id:o})),{...r,app_id:o,...n.app_id===o&&n.version_id?{version_id:n.version_id}:{},created_draft:false,repo_visibility:e.build.repo_visibility,...i?{deploy_key:i}:{}}}async function Xi(t,e={}){return t.store.withLock("commit",()=>Ea(t,e))}async function Ea(t,e={}){let{config:r,commitSha:i,warnings:n}=await At(t);n.forEach(I=>t.progress(`Warning: ${I}`));let o=await t.store.readState();if(e.appId!==void 0&&r.app.id!==void 0&&String(e.appId)!==r.app.id)throw new d("STATE_CONFLICT",{message:`--app (${String(e.appId)}) conflicts with app.id (${r.app.id}) in vibelab.yaml.`,action:"Update app.id in vibelab.yaml or omit --app so they match."});let s=e.appId!==void 0?String(e.appId):r.app.id??o.app_id;if(!s)throw new d("STATE_MISSING",{message:"No app_id found in vibelab.yaml or local state; commit only updates an existing app draft.",action:`Run ${g} add first to create the initial cloud draft and write app.id into vibelab.yaml, then commit and push to GitHub before running ${g} commit.`});let a=await t.api.getApp(s);r.app.id||await ft(t.cwd,s);let c=o.app_id===s?o:{schema_version:o.schema_version},p=a.online_version?.version_id,m=a.editing_version?.version_id,u=m!==void 0&&String(m)!==String(p);if(p===void 0&&a.app?.status!==5){let I=u?String(m):c.version_id;if(!I||I==="0")throw new d("STATE_MISSING",{message:"No editable initial draft version found for this app.",action:`Run ${g} init --from-app <app_id> --force to sync remote state.`});let pe=await t.api.getVersion(s,I);if(pe.status!==void 0&&!wa.has(pe.status))throw new d("INVALID_STATUS",{message:`Current version status is "${v(C,pe.status)}" and cannot be modified.`});let q=await ur(t,r),bn=await ke(t,r,i,{app_id:s,version_id:I,...c.version_id===I&&c.drafts?{drafts:c.drafts}:{}}),He=yt(bn);return {...He,app_id:String(He.app_id),version_id:String(He.version_id),mode:"version_update",preview_url:String(He.preview_url),notice:_t,...n.length?{warnings:n}:{},...q?{deploy_key:q}:{}}}let l=p===void 0?void 0:await t.api.getVersion(s,p),_=l?.features_and_release_config??{},f=_.version_name??a.online_version?.version_name,S=_.commit_sha,J=r.build.commit_sha!==void 0&&S!==void 0&&!Aa(r.build.commit_sha,S),y=l!==void 0&&f!==void 0&&r.version.name===f&&!J?1:2,H,U,de;if(u){let I=await t.api.getVersion(s,m);if(I.status!==void 0&&Oi.has(I.status))throw new d("INVALID_STATUS",{message:`Editing version ${String(m)} is currently under review or building and cannot be modified.`});I.update_type!==void 0&&I.update_type!==0&&I.update_type!==y?(await ki(t,`Existing draft ${String(m)} is "${v(ne,I.update_type)}", which conflicts with "${v(ne,y)}". Discard draft ${String(m)} and create a new one?`),await t.api.deleteVersion(s,m),await t.store.clearDraft(),de=String(m),H=wt(s,y),U=y===1?"info_update":"version_create"):(H={app_id:s,version_id:String(m),update_type:y},U="version_update");}else H=wt(s,y),U=y===1?"info_update":"version_create";if(y===1){let I={...r,build:{...r.build,..._.repo_url?{repo_url:_.repo_url}:{}},version:{...r.version,...f?{name:f}:{}}},pe=await ke(t,I,S??i,H),q=yt(pe);return {...q,app_id:String(q.app_id),version_id:String(q.version_id),mode:U,preview_url:String(q.preview_url),notice:_t,...n.length?{warnings:n}:{},...de?{replaced_version_id:de}:{}}}let Sr=await ur(t,r),In=await ke(t,r,i,H),Fe=yt(In);return {...Fe,app_id:String(Fe.app_id),version_id:String(Fe.version_id),mode:U,preview_url:String(Fe.preview_url),notice:_t,...n.length?{warnings:n}:{},...de?{replaced_version_id:de}:{},...Sr?{deploy_key:Sr}:{}}}async function Ji(t,e){return t.store.withLock("push",()=>Wi(t,e))}async function Yi(t,e={}){let r=await t.store.readState(),i=await xi(t.cwd),n=Et(e.appId,i??r.app_id),o=e.watch?await qi(t,n,e.watch):await fr(t,n),s=o.detail.online_version?.version_id,a=(o.versions.versions??[]).some(p=>s!==void 0&&String(p.version_id)===String(s)&&p.info_update_status!==void 0&&p.info_update_status!==0),c=s!==void 0&&(e.pending||a)?await t.api.getVersion(n,s,true):void 0;return {...o,...c?{pending_version:c}:{},next_action:va(o)}}function Aa(t,e){if(!e)return false;let r=t.trim().toLowerCase(),i=e.trim().toLowerCase();return r===i||r.startsWith(i)||i.startsWith(r)}function va(t){let e=t.editing_version?.status??t.detail.editing_version?.status,r=t.detail.online_version?.version_id,n=(t.versions.versions??[]).find(o=>r!==void 0&&String(o.version_id)===String(r))?.info_update_status;return e===3||e===6||n===3?`Fix the rejection/build issues in vibelab.yaml or your code repository, then run: ${g} add -> commit -> push`:e===1?`Open the preview URL to confirm the draft and check the agreement checkbox, then run: ${g} push --wait`:e===2||e===5||n===2||t.detail.app?.status===2?`Build validation or review is in progress. Run: ${g} state --watch to poll until completion`:t.detail.app?.status===4?`App is online. To update metadata/assets or publish a new version, edit vibelab.yaml and run: ${g} add -> commit -> push`:`Edit vibelab.yaml and run: ${g} add -> commit -> push`}var Zi={app:{name:"",slogan:"",description:"",tags:[],category:"game",icon:"assets/icon.png",landscape:"assets/landscape.png",detail_images:["assets/detail-1.png"],videos:[]},version:{name:"1.0.0",notes:""},build:{repo_url:"",repo_visibility:"public",tech_stack:"unity",ai_tool:"Trae CLI",ai_model:"",features:["none"],teammates:[]}};async function Qi(t,e){return t.store.withLock("init",async()=>{if(!e.force&&await ba(xe(t.cwd)))throw new d("ARGUMENT_INVALID",{message:`${se} already exists.`,action:"Use --force to overwrite, or edit the existing configuration directly."});if(e.fromApp)return await t.store.ensureGitignore(),Ra(t,e.fromApp);let r=e.prompter?await e.prompter(Zi):Zi;return await t.store.ensureGitignore(),await t.store.clearApp(),{config_path:await nr(t.cwd,r),source:e.prompter?"prompt":"template"}})}async function Ra(t,e){let r=await t.api.getApp(e),i=r.editing_version?.version_id,n=i??r.online_version?.version_id;if(n===void 0)throw new d("INVALID_STATUS",{message:`App ${e} has no readable version.`});let o=await t.api.getVersion(e,n),s=await nr(t.cwd,Mi(o,e)),a=r.online_version?.version_id!==void 0,c=i!==void 0&&String(i)!==String(r.online_version?.version_id);return await t.store.clearApp(),await t.store.updateState({app_id:e,...c?{version_id:String(i),update_type:Ia(o,a),committed:true}:{}}),{config_path:s,app_id:e,...c?{version_id:String(i)}:{},source:"remote"}}function Ia(t,e){return t.update_type!==void 0&&t.update_type!==0?t.update_type:e?2:void 0}async function ba(t){try{return await access(t),!0}catch{return false}}var en=/^(access[_-]?token|refresh[_-]?token|x[_-]?tt[_-]?cli[_-]?access[_-]?token|device[_-]?code|poll[_-]?ticket|authorization(?:-act)?|dpop|cookie|set[_-]?cookie|access[_-]?key(?:[_-]?id)?|secret(?:[_-]?access)?[_-]?key|session[_-]?token|device[_-]?key|private[_-]?key(?:base64)?|x[_-]?signature|signature|(?:x[_-]?)?req[_-]?sign)$/i,Ta=/(access[_-]?token|refresh[_-]?token|x[_-]?tt[_-]?cli[_-]?access[_-]?token|device[_-]?code|poll[_-]?ticket|authorization(?:-act)?|dpop|cookie|set[_-]?cookie|access[_-]?key(?:[_-]?id)?|secret(?:[_-]?access)?[_-]?key|session[_-]?token|device[_-]?key|private[_-]?key(?:base64)?|x[_-]?signature|signature|(?:x[_-]?)?req[_-]?sign)(["']?\s*[:=]\s*["']?)(?:Bearer\s+)?([^"'\s,}&]+)/gi,Pa=/(Bearer\s+)[A-Za-z0-9._~+/=-]+/g,Le="[REDACTED]",tn=new Set;function vt(t){t&&t.length>=4&&tn.add(t);}function Ue(t){let e=t.replace(Ta,(r,i,n)=>`${i}${n}${Le}`).replace(Pa,`$1${Le}`);for(let r of [...tn].sort((i,n)=>n.length-i.length))e=e.split(r).join(Le);return e}function ce(t,e=new WeakSet){if(Array.isArray(t))return e.has(t)?"[Circular]":(e.add(t),t.map(r=>ce(r,e)));if(t instanceof Date)return t.toISOString();if(t instanceof Error){if(e.has(t))return "[Circular]";e.add(t);let r={name:t.name,message:Ue(t.message)};for(let[i,n]of Object.entries(t))r[i]=en.test(i)?Le:ce(n,e);return r}if(t&&typeof t=="object"){if(e.has(t))return "[Circular]";e.add(t);let r={};for(let[i,n]of Object.entries(t))r[i]=en.test(i)?Le:ce(n,e);return r}return typeof t=="string"?Ue(t):t}function rn(t,e){if(t.json){t.stdout(`${JSON.stringify(ce({ok:true,data:e.data}))}
51
+ `);return}for(let r of e.lines)t.stdout(`${Ue(r)}
52
+ `);}function St(t,e){let r=ce({ok:false,error:{code:e.code,message:e.message,action:e.action,...e.details?{details:e.details}:{}}});if(t.json){t.stderr(`${JSON.stringify(r)}
53
+ `);return}t.stderr(`Error[${r.error.code}]: ${r.error.message}
54
+ `),t.stderr(`Suggestion: ${r.error.action}
55
+ `),r.error.details!==void 0&&t.stderr(`Details: ${JSON.stringify(r.error.details)}
56
+ `);}function nn(t,e){t.json||t.stderr(`${Ue(e)}
57
+ `);}function gr(t,e){let r=e.map(o=>t.map((s,a)=>on(o[a]))),i=t.map((o,s)=>Math.max(Ve(o),...r.map(a=>Ve(a[s]??"")))),n=o=>o.map((s,a)=>s+" ".repeat((i[a]??0)-Ve(s))).join(" ").trimEnd();return [n(t),n(i.map(o=>"-".repeat(o))),...r.map(n)]}function Rt(t){let e=Math.max(0,...t.map(([r])=>Ve(r)));return t.map(([r,i])=>`${r}${" ".repeat(e-Ve(r))} ${on(i)}`)}function on(t){return t==null||t===""?"-":String(t)}function Ve(t){let e=0;for(let r of t){let i=r.codePointAt(0)??0;e+=i>=4352&&/[\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\ufe30-\ufe4f\uff00-\uff60\uffe0-\uffe6]/u.test(r)?2:1;}return e}function Ca(t){let{app:e,online_version:r,editing_version:i,latest_activity:n}=t;return Rt([["App ID",e?.app_id===void 0?void 0:String(e.app_id)],["Name",e?.name],["Slogan",e?.slogan],["Status",v(vi,e?.status)],["Offline Reason",e?.offline_reason_text],["Online Version",r?`${r.version_name??"-"} (${String(r.version_id??"-")})`:void 0],["Editing Version",i?`${i.version_name??"-"} (${String(i.version_id??"-")}) ${v(C,i.status)}`:void 0],["Latest Activity",n?`${n.title??"-"} @ ${Te(n.create_time)}`:void 0]])}function Da(t){let e=t.versions??[];return e.length===0?["No versions found."]:gr(["VERSION_ID","VERSION","STATUS","UPDATE_TYPE","COMMIT","SUBMITTED_AT","PUBLISHED_AT"],e.map(r=>[r.version_id===void 0?void 0:String(r.version_id),r.version_name,v(C,r.status),v(ne,r.update_type),r.commit_sha?.slice(0,8),Te(r.submitted_at),Te(r.published_at)]))}function It(t){let e=t.features_and_release_config,r=t.assets?.[0];return [...Rt([["Version ID",t.version_id===void 0?void 0:String(t.version_id)],["Version Name",e?.version_name??t.version_name],["Status",v(C,t.status)],["Update Type",v(ne,t.update_type)],["App Name",r?.name],["Repository",e?.repo_url],["Commit",e?.commit_sha],["AI Tool",e?.ai_tool],["AI Model",e?.ai_model]]),...xa(t)]}function xa(t){let e=[],r=t.review_records??[];r.length>0&&(e.push("","Review Records:"),e.push(...gr(["ROUND","RESULT","SUBMITTED_AT","SUMMARY"],r.map(n=>[n.review_round,v(Si,n.result),Te(n.submit_time),n.summary]))));let i=t.rejection_issues??[];if(i.length>0){e.push("","Rejection Reasons:");for(let n of i){e.push(` ${n.sequence??"-"}. ${n.name??""}${n.content?`: ${n.content}`:""}`);for(let o of n.attachments??[])e.push(` Attachment: ${o.file_name??o.uri??"-"}`);}}return e}function an(t){let e=Ca(t.detail);return t.editing_version&&e.push("","Editing Version Details:",...It(t.editing_version)),(t.versions.versions??[]).length>0&&e.push("","Version History:",...Da(t.versions)),e}function hr(t){return Rt([["App ID",sn(t.app_id)],["Version ID",sn(t.version_id)],...typeof t.preview_url=="string"?[["Preview URL",t.preview_url]]:[]])}function sn(t){return typeof t=="string"||typeof t=="number"?String(t):void 0}var Oa=/^(\d+)(ms|s|m)?$/,ka={ms:1,s:1e3,m:6e4};function $e(t){let e=Oa.exec(t.trim());if(!e?.[1])throw P(`Invalid duration: ${t} (examples: 10s, 30m)`);let r=e[2]??"s",i=Number(e[1])*ka[r];if(i<=0)throw P(`Duration must be greater than 0: ${t}`);return i}var Na={version_update:"Draft updated.",info_update:"Info update draft saved.",version_create:"New version draft created."};function dn(t,e){t.command("init").description("Initialize release workspace (generate vibelab.yaml or pull remote app config and state)").option("--from-app <app_id>","Initialize configuration and local state from remote app data").option("--force","Overwrite existing vibelab.yaml").action(async(r,i)=>e.execute(i,async({ctx:n,interactive:o,prompter:s})=>{let a=await Qi(n,{fromApp:r.fromApp,force:r.force??false,prompter:o&&!r.fromApp?s:void 0});return {data:a,lines:[`Generated ${a.config_path}`,...a.app_id?[`Linked app ${a.app_id}${a.version_id?`, editing version ${a.version_id}`:""}`]:[],`Next step: fill in asset paths and run ${g} add`]}})),t.command("add").description("Validate local configuration/assets, create initial cloud draft & write app.id to vibelab.yaml if needed, and fetch private repo Deploy Key").action(async(r,i)=>e.execute(i,async({ctx:n})=>{let o=await zi(n);return {data:o,lines:[o.created_draft?`Initial app draft created (App ID: ${o.app_id}, Version ID: ${o.version_id??"-"}) and written to vibelab.yaml.`:`Validation passed (App ID: ${o.app_id}).`,...o.commit_sha?[`commit_sha: ${o.commit_sha}`]:[],...o.warnings.map(s=>`Warning: ${s}`),...o.deploy_key?[`Private repository Deploy Key (Title: ${o.deploy_key.title}):`,`Public Key: ${o.deploy_key.public_key}`,`Settings URL: ${o.deploy_key.settings_url}`]:[],o.created_draft?`Next step: commit and push your code and vibelab.yaml to GitHub, then run ${g} commit`:`Next step: ensure your latest changes are pushed to GitHub, then run ${g} commit`]}})),t.command("commit").description("Update the cloud draft for the linked app.id (version_update / info_update / version_create) and output web preview URL").option("--app <app_id>","App ID (defaults to app.id in vibelab.yaml or local state)").action(async(r,i)=>e.execute(i,async({ctx:n})=>{let o=await Xi(n,{appId:r.app});return {data:o,lines:[Na[o.mode],...hr(o),`Important: ${o.notice}`,`Next step: open the Preview URL in your browser, check the agreement box, then run ${g} push --wait`]}})),t.command("push").description("Submit the committed cloud draft for build validation and review").option("--wait","Poll version status after submission until a terminal result is reached").option("--interval <duration>","Polling interval (e.g. 10s)",$e).option("--timeout <duration>","Maximum wait time (e.g. 30m)",$e).action(async(r,i)=>e.execute(i,async({ctx:n})=>{let o=await Ji(n,{wait:r.wait?cn(r):void 0});return {data:o,lines:["Review submitted.",...hr(o.draft),...o.final_version?[`Review result: ${v(C,o.final_version.status)}`,...It(o.final_version)]:[`Run ${g} state to check review progress`]]}})),t.command("state").description("Inspect release status, review progress, rejection reasons, and next-step recommendations").argument("[app_id]","App ID (defaults to local state)").option("--watch","Continuously poll while review or build validation is in progress").option("--interval <duration>","Polling interval (e.g. 10s)",$e).option("--timeout <duration>","Maximum wait time (e.g. 30m)",$e).option("--pending","Also read pending info update content on the online version").action(async(r,i,n)=>e.execute(n,async({ctx:o})=>{let s=await Yi(o,{appId:r,pending:i.pending,watch:i.watch?{...cn(i),onSnapshot:a=>o.progress(`[${new Date(o.now()).toISOString()}] Editing version status: ${v(C,a.editing_version?.status)}`)}:void 0});return {data:s,lines:[...an(s),...s.pending_version?["","Pending Info Update:",...It(s.pending_version)]:[],"",`Next Step: ${s.next_action}`]}}));}function cn(t){return {intervalMs:t.interval??Ki,timeoutMs:t.timeout??Bi}}var pn=promisify(execFile),un={async read(t){let e;try{let{stdout:r}=await pn("git",["rev-parse","HEAD"],{cwd:t});e=r.trim()||void 0;}catch{e=void 0;}try{let{stdout:r}=await pn("git",["status","--porcelain"],{cwd:t});return {...e?{head:e}:{},dirty:r.trim().length>0}}catch{return {...e?{head:e}:{},dirty:false}}}};var L=".vibelab",yr="state.json",fn="cache.json",je="lock",Ma=".gitignore",gn=`${L}/`,Er=1,Tt=class{dir;cwd;now;pid;isProcessAlive;cacheScope;constructor(e,r=()=>new Date,i={}){this.cwd=e,this.dir=Ge.join(e,L),this.now=r,this.pid=i.pid??process.pid,this.isProcessAlive=i.isProcessAlive??Ga,this.cacheScope=i.cacheScope?.trim()||void 0;}async withLock(e,r){let i=await this.acquireLock(e);try{return await r()}finally{await i();}}async readState(){let e=await this.readJson(yr);if(!e)return {schema_version:Er};let{row_version:r,...i}=e,n=i.drafts?.map(o=>{let{row_version:s,...a}=o;return a});return {...i,...n?{drafts:n}:{}}}async requireApp(){let e=await this.readState();if(!e.app_id)throw new d("STATE_MISSING",{message:`No app_id found in local ${L}/${yr}.`});return {...e,app_id:e.app_id}}async updateState(e){let r={...await this.readState(),...e,schema_version:Er,updated_at:this.now().toISOString()};return await this.writeJson(yr,r),r}async recordDraft(e,r={}){return this.updateState({app_id:e.app_id,version_id:e.version_id,update_type:r.updateType,...r.committed===void 0?{}:{committed:r.committed},drafts:[e],...r.assets?{assets:r.assets}:{}})}async clearDraft(){return this.updateState({version_id:void 0,update_type:void 0,committed:void 0,drafts:void 0})}async clearApp(){return this.updateState({app_id:void 0,version_id:void 0,update_type:void 0,committed:void 0,drafts:void 0,assets:void 0})}async readCache(){return await this.readJson(fn)??{schema_version:Er,assets:{}}}async getCachedAsset(e){return (await this.readCache()).assets[this.toCacheKey(e)]}async cacheAsset(e,r,i){let n=await this.readCache();n.assets[this.toCacheKey(e)]={uri:r,kind:i,uploaded_at:this.now().toISOString()},await this.writeJson(fn,n);}toCacheKey(e){return this.cacheScope?`${this.cacheScope}:${e}`:e}async ensureGitignore(){let e=Ge.join(this.cwd,Ma),r="";try{r=await readFile(e,"utf8");}catch{r="";}let i=r.split(/\r?\n/).map(o=>o.trim());if(i.includes(gn)||i.includes(L))return false;let n=r.length>0&&!r.endsWith(`
58
+ `)?`
59
+ `:"";return await writeFile(e,`${r}${n}${gn}
60
+ `,"utf8"),true}async readJson(e){let r;try{r=await readFile(Ge.join(this.dir,e),"utf8");}catch{return}try{return JSON.parse(r)}catch(i){throw new d("STATE_CONFLICT",{message:`${L}/${e} is not valid JSON.`,action:`Delete ${L}/${e} and run ${g} init --from-app <ID> --force to re-initialize.`,cause:i})}}async writeJson(e,r){await mkdir(this.dir,{recursive:true}),await this.ensureGitignore();let i=Ge.join(this.dir,e),n=`${i}.${this.pid}.${randomUUID()}.tmp`;await writeFile(n,`${JSON.stringify(r,null,2)}
61
+ `,"utf8"),await rename(n,i);}async acquireLock(e){await mkdir(this.dir,{recursive:true}),await this.ensureGitignore();let r=Ge.join(this.dir,je),i=randomUUID(),n={pid:this.pid,operation:e,token:i,acquired_at:this.now().toISOString()},o=`${JSON.stringify(n,null,2)}
62
+ `;for(let s=0;s<2;s+=1)try{return await this.createExclusiveLockFile(r,o,i),async()=>{await this.releaseLock(r,i);}}catch(a){if(a?.code!=="EEXIST")throw a;await this.handleExistingLock(r,a);}throw new d("STATE_CONFLICT",{message:`Another VibeLab CLI operation is currently holding ${L}/${je}.`,action:`Wait for the running command to finish; if the previous process crashed, delete ${L}/${je} and retry.`})}async createExclusiveLockFile(e,r,i){let n=`${e}.${this.pid}.${i}.tmp`;await writeFile(n,r,"utf8");try{await link(n,e);}catch(o){if(o?.code==="EEXIST")throw o;let a=await open(e,"wx");try{await a.writeFile(r,"utf8");}catch(c){throw await a.close(),await rm(e,{force:true}),c}await a.close();}finally{await rm(n,{force:true});}}async handleExistingLock(e,r){let i;try{i=await readFile(e,"utf8");}catch(a){if(a?.code==="ENOENT")return;throw a}let n;try{n=JSON.parse(i);}catch{n=void 0;}let o=typeof n?.pid=="number"?n.pid:void 0,s=typeof n?.operation=="string"&&n.operation?n.operation:"command";if(o!==void 0&&this.isProcessAlive(o))throw new d("STATE_CONFLICT",{message:`Another VibeLab CLI "${s}" operation (PID ${o}) is already running in this workspace.`,action:`Wait for the running "${s}" command to finish before running another write command. If no CLI process is running, delete ${L}/${je}.`,details:{lock_file:`${L}/${je}`,pid:o,operation:s,...n?.acquired_at?{acquired_at:n.acquired_at}:{}},cause:r});try{if(await readFile(e,"utf8")!==i)return;let c=`${e}.stale.${this.pid}.${randomUUID()}.tmp`;await rename(e,c),await rm(c,{force:!0});}catch{}}async releaseLock(e,r){try{let i=await readFile(e,"utf8");if(JSON.parse(i).token!==r)return}catch{return}await rm(e,{force:true});}};function Ga(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e?.code==="EPERM"}}var Ha=6e4,Ka=5*6e4,Ba=3e4,Wa=1e11,qa="cn-north-1",za="imagex",Xa="2018-08-01",Pt=class{api;now;createClient;createObjectId;cached;constructor(e){this.api=e.api,this.now=e.now??Date.now,this.createClient=e.createClient??(r=>new Ar(r)),this.createObjectId=e.createObjectId??randomUUID;}async upload(e){if(e.length===0)return [];let r=await this.getUsableSign(),i=this.createClient(Za(r));try{let n=[];for(let o of e)n.push(await this.uploadOne(i,r,o));return n}finally{i.destroy();}}async uploadOne(e,r,i){let n={FilePath:i.path,FileExtension:i.extension,StoreKey:Qa(r.dir,i.extension,this.createObjectId())},o=await oc("UploadImage",()=>e.UploadImage(n)),s=o.ImageUri||o.SourceUri;if(typeof s!="string"||s.length===0)throw hn(`ImageX upload did not return a URI: ${i.path}`);return s}async getUsableSign(){if(this.cached){let{expiresAtMs:r}=this.cached;if(r===void 0||r-this.now()>Ha)return this.cached.sign}let e=await this.api.getImagexSign();for(let r of ["access_key_id","secret_access_key","session_token","service_id"])if(typeof e[r]!="string"||e[r].length===0)throw j(`ImageX credentials missing ${r}.`);return vt(e.access_key_id),vt(e.secret_access_key),vt(e.session_token),this.cached={sign:e,expiresAtMs:ec(e.expired_time)},e}},Ar=class{config;fetchImpl;createService;constructor(e,r={}){this.config=e,this.fetchImpl=r.fetchImpl??fetch,this.createService=r.createService??Ya;}async UploadImage(e){let r=await this.request("ApplyImageUpload","GET",{StoreKeys:e.StoreKey,FileExtension:e.FileExtension}),i=F(r.UploadAddress,"ApplyImageUpload UploadAddress"),n=i.StoreInfos,o=i.UploadHosts,s=i.SessionKey;if(!Array.isArray(n)||n.length!==1)throw new Error("ImageX returned an unexpected StoreInfos count.");if(!Array.isArray(o)||typeof o[0]!="string")throw new Error("ImageX ApplyImageUpload response is missing UploadHosts.");if(typeof s!="string"||!s)throw new Error("ImageX ApplyImageUpload response is missing SessionKey.");let a=await this.createService();a.setAccessKeyId(this.config.AccessKeyId),a.setSecretKey(this.config.SecretAccessKey),a.setSessionToken(this.config.SessionToken);let c=await sc(this.config.UploadTimeout,"ImageX DoUpload timed out.",()=>a.DoUpload([e.FilePath],rc(o[0]),n));if(c.length!==1)throw new Error("ImageX returned an unexpected upload result count.");let p=F(c[0],"DoUpload result");if(p.success!==true||typeof p.uri!="string"||!p.uri)throw new Error("ImageX DoUpload failed.");let u=(await this.request("CommitImageUpload","POST",{},JSON.stringify({SessionKey:s,SuccessOids:[p.uri]}))).Results;if(!Array.isArray(u)||u.length!==1)throw new Error("ImageX returned an unexpected commit result count.");let l=F(u[0],"CommitImageUpload result");if(l.UriStatus!==2e3)throw new Error("ImageX CommitImageUpload returned a failed URI status.");let _=nc(l.Uri,l.ImageUri,l.SourceUri);if(!_)throw new Error("ImageX CommitImageUpload response is missing a URI.");return {ImageUri:_,SourceUri:_}}destroy(){}async request(e,r,i,n){let o=new URL(this.config.ImageGatewayHost),s=new URLSearchParams({Action:e,Version:Xa,ServiceId:this.config.ServiceId,...i}),a=Fa.sign({hostname:o.hostname,method:r,path:`/?${s.toString()}`,service:za,region:this.config.Region,headers:{Accept:"application/json",...n?{"Content-Type":"application/json; charset=utf-8"}:{}},...n?{body:n}:{}},{accessKeyId:this.config.AccessKeyId,secretAccessKey:this.config.SecretAccessKey,sessionToken:this.config.SessionToken}),c=ic(a.headers);c.set("X-Vod-Upload-PSM",Ja(this.config.SessionToken));let p=await this.fetchImpl(new URL(a.path??"/",o),{method:r,headers:c,...n?{body:n}:{},signal:AbortSignal.timeout(this.config.GatewayTimeout)}),m=await p.text(),u;try{u=JSON.parse(m);}catch(f){throw new Error(`ImageX ${e} response is not valid JSON.`,{cause:f})}let l=F(u,`${e} response`),_=F(l.ResponseMetadata,`${e} ResponseMetadata`);if(!p.ok||_.Error!==void 0){let f=_.Error&&typeof _.Error=="object"?_.Error:void 0;throw new Error(`ImageX ${e} failed${typeof f?.Code=="string"?`: ${f.Code}`:""}.`)}return F(l.Result,`${e} Result`)}};function Ja(t){try{if(!t.startsWith("STS2"))throw new Error("missing STS2 prefix");let e=F(JSON.parse(Buffer.from(t.slice(4),"base64").toString("utf8")),"session token");if(typeof e.PolicyString!="string")throw new Error("missing PolicyString");let r=F(JSON.parse(e.PolicyString),"session token policy");if(!Array.isArray(r.Statement))throw new Error("missing Statement");for(let i of r.Statement){let n=F(i,"session token statement");if(!(Array.isArray(n.Action)?n.Action:[n.Action]).includes("PSM"))continue;let a=(Array.isArray(n.Resource)?n.Resource:[n.Resource]).find(c=>typeof c=="string"&&c.length>0&&!c.includes("\r")&&!c.includes(`
63
+ `));if(a)return a}}catch{throw j("ImageX session_token does not contain a valid PSM policy.")}throw j("ImageX session_token does not contain a valid PSM policy.")}async function Ya(){let{ImagexService:t}=await import('@volcengine/openapi/lib/services/imagex/index.js');return new t}function Za(t){return {AccessKeyId:t.access_key_id,SecretAccessKey:t.secret_access_key,SessionToken:t.session_token,ServiceId:t.service_id,Region:qa,ImageGatewayHost:gi,UploadTimeout:Ka,GatewayTimeout:Ba}}function Qa(t,e,r){let i=tc(t),n=e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`,o=`${r}${n}`;return i?`${i}/${o}`:o}function ec(t){if(!t)return;if(/^\d+$/.test(t)){let r=Number(t);return r<Wa?r*1e3:r}let e=Date.parse(t);return Number.isFinite(e)?e:void 0}function tc(t){return (t??"").split("/").filter(Boolean).join("/")||void 0}function rc(t){let e=t.includes("://")?t:`https://${t}`,r=new URL(e);if(r.protocol!=="https:"||r.username||r.password||!r.hostname||r.pathname!==""&&r.pathname!=="/"||r.search||r.hash)throw new Error("ImageX upload host must be an HTTPS origin.");return r.host}function ic(t){let e=new Headers;for(let[r,i]of Object.entries(t??{}))if(Array.isArray(i))for(let n of i)e.append(r,n);else i!==void 0&&e.set(r,String(i));return e}function F(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`ImageX ${e} is invalid.`);return t}function nc(...t){return t.find(e=>typeof e=="string"&&e.length>0)}async function oc(t,e){try{return await e()}catch(r){if(r instanceof d)throw r;let i=r instanceof Error&&r.message?` ${r.message}`:"";throw hn(`ImageX ${t} call failed.${i}`,r)}}function hn(t,e){return new d("UPLOAD_FAILED",{message:t,cause:e})}async function sc(t,e,r){let i;try{return await Promise.race([r(),new Promise((n,o)=>{i=setTimeout(()=>o(new Error(e)),t);})])}finally{i!==void 0&&clearTimeout(i);}}var Dt="__custom__",dc=/[,,]/,vr=t=>t.split(dc).map(e=>e.trim()).filter(Boolean),X=t=>e=>e.trim().length===0?"Required":e.trim().length<=t||`Cannot exceed ${t} characters`,_n=async t=>{let e=await input({message:"App name",default:t.app.name,validate:X(w.nameMaxLength)}),r=await input({message:"One-line slogan",default:t.app.slogan,validate:X(w.sloganMaxLength)}),i=await input({message:"App description",default:t.app.description,validate:X(w.descriptionMaxLength)}),n=vr(await input({message:`Content tags (comma-separated, up to ${w.tagMaxCount})`,validate:y=>vr(y).length>0||"At least 1 tag is required"})),o=await select({message:"Category",choices:lt.map(y=>({value:y,name:y==="game"?"Game":"Application"})),default:t.app.category}),s=await input({message:"Version name",default:t.version.name,validate:X(w.versionNameMaxLength)}),a=await input({message:"Release notes",validate:X(w.versionNotesMaxLength)}),c=await input({message:"GitHub repository URL",default:t.build.repo_url}),p=await select({message:"Repository visibility",choices:mt.map(y=>({value:y,name:y==="public"?"Public":"Private"})),default:t.build.repo_visibility}),m=await select({message:"Tech stack",choices:[...er.map(y=>({value:y})),{value:Dt,name:"Other"}],default:t.build.tech_stack}),u=m===Dt?await input({message:"Custom tech stack",validate:X(w.customTechStackMaxLength)}):m,l=await select({message:"AI tool",choices:[...De.map(y=>({value:y})),{value:Dt,name:"Other"}],default:t.build.ai_tool}),_=l===Dt?await input({message:"Custom AI tool",validate:X(w.customAiToolMaxLength)}):l,f=await input({message:"Primary AI model",validate:y=>y.trim().length>0||"Required"}),S=await checkbox({message:"App features (select none if none apply)",choices:oe.map(y=>({value:y})),validate:y=>y.length>0||"Select at least 1 item"}),J=vr(await input({message:`Teammates (comma-separated, up to ${w.teammateMaxCount}, optional)`}));return {app:{...t.app,name:e,slogan:r,description:i,tags:n,category:o},version:{name:s,notes:a},build:{...t.build,repo_url:c.trim(),repo_visibility:p,tech_stack:u.trim(),ai_tool:_.trim(),ai_model:f.trim(),features:S.includes("none")?["none"]:S,teammates:J}}};async function wn(t,e){return confirm({message:t,default:false})}var En=new Set(["localhost","127.0.0.1","[::1]"]),mc=/^ppe_[A-Za-z0-9][A-Za-z0-9_-]{0,123}$/u,yn="VIBELAB_PPE_ENV";async function An(t,e={}){let r=e.stdout??(p=>{process.stdout.write(p);}),i=e.stderr??(p=>{process.stderr.write(p);}),n={json:t.includes("--json"),stdout:r,stderr:i},o=0,s=false,c=fc({async execute(p,m){s=true;let u=p.optsWithGlobals(),l={json:u.json===true,stdout:r,stderr:i};try{let _=e.interactive??(!l.json&&!!(process.stdin.isTTY&&process.stdout.isTTY)),f=gc(e,l,u,_),S=await m({ctx:f,globals:u,interactive:_,prompter:e.prompter??_n});rn(l,S);}catch(_){let f=Yt(_);St(l,f),o=f.exitCode;}}},r,i,n.json);try{await c.parseAsync(t,{from:"user"}),s||vn({},c.opts().ppeEnv);}catch(p){if(p instanceof CommanderError)return p.exitCode===0?0:(n.json&&St(n,new d("ARGUMENT_INVALID",{message:p.message})),new d("ARGUMENT_INVALID").exitCode);let m=Yt(p);return St(n,m),m.exitCode}return o}function fc(t,e,r,i=false){let n=i?()=>{}:r,o=new Command(g).description(`PICO Vibe Lab command-line tool (use ${W} login to authenticate)`).version(wc(),"-v, --version").option("--json","Output stable JSON structure for CI and Agent parsing").option("--ppe-env <lane>","Inject PPE lane header (e.g. ppe_xxx)").option("-y, --yes","Skip confirmation prompts (required when replacing a conflicting draft in CI)").showHelpAfterError().exitOverride().configureOutput({writeOut:e,writeErr:n});dn(o,t);for(let s of Sn(o))s.exitOverride().configureOutput({writeOut:e,writeErr:n});return o}function gc(t,e,r,i){let n=t.cwd??process.cwd(),o=t.now??Date.now,s=t.sleep??(f=>new Promise(S=>setTimeout(S,f))),a=t.env??process.env,c=hc(a),p=vn(a,r.ppeEnv),m=p?.["x-tt-env"],u=`${at}#${c}#${m??"prod"}`,l=new ct({endpoint:c,auth:new dt(t.auth??_c(a,c),{ppeHeader:m}),fetch:t.fetch,requestHeaders:p,sleep:s}),_=t.confirm??wn;return {api:l,uploader:t.createUploader?.(l)??new Pt({api:l,now:o}),store:new Tt(n,()=>new Date(o()),{cacheScope:u}),git:t.git??un,cwd:n,sleep:s,now:o,progress:f=>nn(e,f),confirm:async(f,S)=>{if(r.yes)return true;if(!i){if(S.destructive)throw P("Passing --yes is required to replace a conflicting draft in non-interactive mode.");return true}return _(f,S)}}}function hc(t){let e=t[Ie]?.trim()||Jt,r;try{r=new URL(e);}catch{throw P(`${Ie} is not a valid URL: ${e}`)}if(r.protocol!=="https:"&&!(r.protocol==="http:"&&En.has(r.hostname)))throw P(`${Ie} must use HTTPS (except for local debugging).`);if(r.pathname!=="/"||r.search||r.hash||r.username||r.password)throw P(`${Ie} must contain only protocol and host (origin).`);return r.origin}function _c(t,e){if(Ei(t)){if(!En.has(new URL(e).hostname))throw P(`${pt} is only allowed with localhost/127.0.0.1 Mock Server.`);return new ut}}function vn(t,e){let i=(e??t[yn])?.trim();if(!i){if(e!==void 0)throw P("--ppe-env cannot be empty.");return}if(!mc.test(i))throw P(`Invalid --ppe-env/${yn} format: must start with ppe_ and contain only letters, digits, underscores, and hyphens.`);return {"x-use-ppe":"1","x-tt-env":i}}function Sn(t){return t.commands.flatMap(e=>[e,...Sn(e)])}function wc(){for(let t of ["../../package.json","../../../package.json"])try{let e=JSON.parse(readFileSync(new URL(t,import.meta.url),"utf8"));if(e.version)return e.version}catch{}return "0.0.0"}async function Ec(t=process.argv.slice(2)){return An(t)}function Ac(){let t=process.argv[1];return t?realpathSync(fileURLToPath(import.meta.url))===realpathSync(t):false}Ac()&&Ec().then(t=>{process.exitCode=t;}).catch(t=>{console.error(t instanceof Error?t.message:String(t)),process.exitCode=1;});
64
+ export{gs as REGIONAL_CONFIG,Ec as main};
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "@picoxr/pico-release-cli-row",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.7",
4
+ "description": "PICO Vibe Lab command-line client.",
5
+ "type": "module",
6
+ "bin": {
7
+ "pico-release-cli-row": "dist/src/cli/main.js"
8
+ },
9
+ "files": [
10
+ "dist/src",
11
+ "LICENSE",
12
+ "README.md",
13
+ "ThirdPartyNoticeText.txt"
14
+ ],
15
+ "engines": {
16
+ "node": ">=20"
17
+ },
18
+ "publishConfig": {
19
+ "registry": "https://registry.npmjs.org/",
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "@inquirer/prompts": "8.7.3",
24
+ "@volcengine/openapi": "1.36.2",
25
+ "aws4": "1.13.2",
26
+ "commander": "14.0.3",
27
+ "keytar": "7.9.0",
28
+ "sharp": "0.35.5",
29
+ "yaml": "2.9.1",
30
+ "zod": "4.6.6"
31
+ }
32
+ }