@ttmg/cli 0.4.6-vibe-beta.13 → 0.4.6-vibe-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6780,11 +6780,11 @@ function printApiResponseLog(title, result) {
6780
6780
  ['Return Value', result.data],
6781
6781
  ]);
6782
6782
  }
6783
- async function request({ url, method, data, headers, params, logRequestBody = true, signal, }) {
6783
+ async function request({ url, method, data, headers, params, logRequestBody = true, logApiCalls = true, signal, }) {
6784
6784
  const config = getTTMGRC();
6785
6785
  const cookie = sanitizeCookieHeader(config?.cookie);
6786
6786
  const proxyConfig = getAxiosProxyConfig();
6787
- if (isVerboseEnabled()) {
6787
+ if (isVerboseEnabled() && logApiCalls) {
6788
6788
  printApiRequestLog({
6789
6789
  url,
6790
6790
  method,
@@ -6811,7 +6811,7 @@ async function request({ url, method, data, headers, params, logRequestBody = tr
6811
6811
  },
6812
6812
  ...proxyConfig,
6813
6813
  });
6814
- if (isVerboseEnabled()) {
6814
+ if (isVerboseEnabled() && logApiCalls) {
6815
6815
  printApiResponseLog('API Response', {
6816
6816
  status: res?.status,
6817
6817
  logid: res?.headers['x-tt-logid'],
@@ -6839,7 +6839,7 @@ async function request({ url, method, data, headers, params, logRequestBody = tr
6839
6839
  NetworkCode: axiosError.code,
6840
6840
  NetworkMessage: axiosError.message,
6841
6841
  };
6842
- if (isVerboseEnabled()) {
6842
+ if (isVerboseEnabled() && logApiCalls) {
6843
6843
  printApiResponseLog('API Error', {
6844
6844
  status: axiosError.response?.status,
6845
6845
  logid: axiosError.response?.headers['x-tt-logid'],
@@ -7210,6 +7210,16 @@ const messages = {
7210
7210
  'en-US': {
7211
7211
  'cli.command.wasm.desc': 'Prepare or split Wasm into a separate output directory',
7212
7212
  'cli.command.wasm.prepare': 'Instrument original Wasm for function collection',
7213
+ 'cli.command.wasm.collect': 'Manage platform function collection using the local CLI login',
7214
+ 'cli.command.wasm.collect.start': 'Open or resume a collection window; preserve existing IDs unless --reset is set',
7215
+ 'cli.command.wasm.collect.export': 'Export collected IDs to an identity-matched collection.json file',
7216
+ 'cli.command.wasm.collect.clientKey': 'Client Key for the game being collected',
7217
+ 'cli.command.wasm.collect.md5': 'Original Wasm collection MD5 used by the instrumented game',
7218
+ 'cli.command.wasm.collect.timeout': 'Platform request deadline: 1–300 seconds',
7219
+ 'cli.command.wasm.collect.reset': 'Clear historical function IDs for this game and Wasm before collecting',
7220
+ 'cli.command.wasm.collect.output': 'New collection JSON file (never overwrite)',
7221
+ 'wasm.collect.succeeded': 'Wasm collection command completed.',
7222
+ 'wasm.collect.failed': 'Wasm collection command failed.',
7213
7223
  'cli.command.wasm.split': 'Split original Wasm using an identity-matched collection',
7214
7224
  'cli.command.wasm.input': 'Original .wasm or Brotli .wasm.br file',
7215
7225
  'cli.command.wasm.output': 'New output directory (never overwrite)',
@@ -7233,11 +7243,23 @@ const messages = {
7233
7243
  'cli.command.auth.desc': 'Inspect local authentication state',
7234
7244
  'cli.command.auth.open.desc': 'Open an existing Vibe task authorization page in the system browser',
7235
7245
  'cli.command.upload.vibeWeb': 'Authorize in the browser, then upload to PPE (--vibe; no Mock or --no-open)',
7246
+ 'cli.command.game.desc': 'Inspect game metadata supported by the platform',
7247
+ 'cli.command.game.categories.desc': 'List game categories and subcategories with gameplay descriptions (offline, read-only)',
7248
+ 'cli.command.game.categories.category': 'Filter by an exact category value, e.g. Puzzle',
7249
+ 'cli.command.game.categories.unknown': 'Unknown category. Run ttmg game categories --format json for valid values.',
7250
+ 'cli.command.game.categories.invalidFormat': 'Use text, json, or ndjson output.',
7251
+ 'cli.command.upload.vibeCategory': 'Optional game category; provide with --subcategory (--vibe). Query ttmg game categories --format json',
7252
+ 'cli.command.upload.vibeDescription': 'Optional game description (--vibe); default: Discover the fun of TikTok Mini Games.',
7253
+ 'cli.command.upload.vibeSubcategory': 'Optional subcategory belonging to --category; omit both to keep Other/Other (--vibe)',
7236
7254
  'cli.command.upload.vibeWebGuide': `
7237
7255
  Vibe web upload (real PPE trial):
7238
7256
  ttmg upload --vibe --web --dir ./game --title "My game" --icon ./avatar.png --format ndjson
7239
7257
  Use --package ./game.zip instead of --dir for an existing ZIP.
7240
7258
  Collect only title and icon; the CLI fills other app_info fields with PPE trial defaults.
7259
+ Skill may pass --description "Game description"; otherwise use "Discover the fun of TikTok Mini Games." (legacy metadata-file descriptions are preserved).
7260
+ Skill may query ttmg game categories --format json and pass --category Puzzle --subcategory Physics together.
7261
+ Omit both to keep Other/Other (or the legacy metadata-file classification). Invalid pairs fail before task creation.
7262
+ prepared and terminal events expose the submitted classification and its source.
7241
7263
  Keep this process running. At waiting_authorization, complete authorization in the system browser on the CLI computer.
7242
7264
  pageUrl is the local binding/progress page. To reopen authorization, execute the returned authorizationOpenCommand.
7243
7265
  The CLI polls and uploads avatar, app_info and package automatically after authorization. Do not start a second upload.
@@ -7635,6 +7657,16 @@ Vibe web upload (real PPE trial):
7635
7657
  'zh-CN': {
7636
7658
  'cli.command.wasm.desc': '准备或分包 Wasm,产物写入独立目录',
7637
7659
  'cli.command.wasm.prepare': '对原始 Wasm 插桩,用于函数采集',
7660
+ 'cli.command.wasm.collect': '复用 CLI 本机登录态管理平台函数采集',
7661
+ 'cli.command.wasm.collect.start': '开启或恢复采集窗口;未指定 --reset 时保留已有函数 ID',
7662
+ 'cli.command.wasm.collect.export': '导出函数 ID,生成与原始 Wasm 匹配的 collection.json',
7663
+ 'cli.command.wasm.collect.clientKey': '采集游戏的 Client Key',
7664
+ 'cli.command.wasm.collect.md5': '插桩游戏上报使用的原始 Wasm 采集 MD5',
7665
+ 'cli.command.wasm.collect.timeout': '平台请求超时:1–300 秒',
7666
+ 'cli.command.wasm.collect.reset': '清空此游戏、此 Wasm 的历史函数 ID,再开始采集',
7667
+ 'cli.command.wasm.collect.output': '新的采集 JSON 文件(不覆盖已有文件)',
7668
+ 'wasm.collect.succeeded': 'Wasm 采集命令已完成。',
7669
+ 'wasm.collect.failed': 'Wasm 采集命令失败。',
7638
7670
  'cli.command.wasm.split': '使用与原始 Wasm 匹配的采集数据分包',
7639
7671
  'cli.command.wasm.input': '原始 .wasm 或 Brotli .wasm.br 文件',
7640
7672
  'cli.command.wasm.output': '新的输出目录(不覆盖已有内容)',
@@ -7658,11 +7690,23 @@ Vibe web upload (real PPE trial):
7658
7690
  'cli.command.auth.desc': '查看本地登录状态',
7659
7691
  'cli.command.auth.open.desc': '在系统浏览器打开已有 Vibe 任务的授权页',
7660
7692
  'cli.command.upload.vibeWeb': '网页授权就绪后自动上传到 PPE(--vibe;不能与 Mock 或 --no-open 同用)',
7693
+ 'cli.command.game.desc': '查询平台支持的游戏资料',
7694
+ 'cli.command.game.categories.desc': '查询游戏类型、子类型及玩法说明(离线、只读)',
7695
+ 'cli.command.game.categories.category': '按类型的精确值筛选,例如 Puzzle',
7696
+ 'cli.command.game.categories.unknown': '类型不存在。使用 ttmg game categories --format json 查询有效值。',
7697
+ 'cli.command.game.categories.invalidFormat': '输出格式请使用 text、json 或 ndjson。',
7698
+ 'cli.command.upload.vibeCategory': '可选游戏类型,须与 --subcategory 同传(--vibe);用 ttmg game categories --format json 查询',
7699
+ 'cli.command.upload.vibeDescription': '可选游戏描述(--vibe);默认值:Discover the fun of TikTok Mini Games.',
7700
+ 'cli.command.upload.vibeSubcategory': '所属类型的可选子类型;两者均不传保留 Other/Other(--vibe)',
7661
7701
  'cli.command.upload.vibeWebGuide': `
7662
7702
  Vibe 网页上传(真实 PPE 试用):
7663
7703
  ttmg upload --vibe --web --dir ./game --title "游戏名称" --icon ./avatar.png --format ndjson
7664
7704
  已有 ZIP 时,用 --package ./game.zip 替换 --dir。
7665
7705
  只收集标题和头像;其他 app_info 字段由 CLI 使用 PPE 试用默认值补齐。
7706
+ Skill 可传 --description "游戏描述";省略时使用 Discover the fun of TikTok Mini Games.(旧资料文件中的描述保留)。
7707
+ Skill 可先查 ttmg game categories --format json,再成对传入 --category Puzzle --subcategory Physics。
7708
+ 两者均不传保留 Other/Other(旧资料文件调用保留文件分类);无效组合在创建任务前报错。
7709
+ prepared 和终态事件返回最终 classification 及其来源。
7666
7710
  保持原进程运行。在 waiting_authorization 阶段,在 CLI 所在电脑的系统浏览器完成授权。
7667
7711
  pageUrl 是本机绑定/进度页;重新打开授权页时,执行返回的 authorizationOpenCommand。
7668
7712
  CLI 负责轮询,授权后自动上传 avatar、app_info、package,不再启动第二次上传。
@@ -16332,7 +16376,7 @@ async function authStatus(options = {}) {
16332
16376
  return result;
16333
16377
  }
16334
16378
 
16335
- var version = "0.4.6-vibe-beta.13";
16379
+ var version = "0.4.6-vibe-beta.15";
16336
16380
  var engines = {
16337
16381
  node: ">=20.19.1 <21 || >=22"
16338
16382
  };
@@ -16342,12 +16386,18 @@ var pkg = {
16342
16386
  };
16343
16387
 
16344
16388
  // Skill-facing v2 contract. Backend credentials never cross this boundary.
16389
+ const VIBE_DEFAULT_DESCRIPTION = 'Discover the fun of TikTok Mini Games.';
16345
16390
  const VIBE_INPUT_REQUIREMENTS = {
16346
16391
  requiredUserInputs: ['title', 'icon'],
16347
16392
  codeSource: ['dir', 'package'],
16348
16393
  additionalMetadataSource: 'cli-defaults',
16349
16394
  defaultMetadataProfile: 'ppe-trial',
16350
16395
  requestAdditionalMetadata: false,
16396
+ optionalSkillInputs: ['category', 'subcategory', 'description'],
16397
+ defaultDescription: VIBE_DEFAULT_DESCRIPTION,
16398
+ categoryQuery: 'ttmg game categories --format json',
16399
+ categoryPairRequiredWhenProvided: true,
16400
+ defaultCategory: { category: 'Other', subcategory: 'Other' },
16351
16401
  };
16352
16402
  class VibeError extends Error {
16353
16403
  constructor(code) {
@@ -16356,11 +16406,593 @@ class VibeError extends Error {
16356
16406
  }
16357
16407
  }
16358
16408
 
16409
+ var catalogVersion = "sha256:f1d67b08cfbfb9396cba1ec246a84a4c1b6b2c9f077e236498c42e9c154b6900";
16410
+ var source = "bundled";
16411
+ var categories$1 = [
16412
+ {
16413
+ value: "Action",
16414
+ subcategories: [
16415
+ {
16416
+ value: "Artillery Shooter",
16417
+ description: "Turn based tactics game in which players aim and shoot other players"
16418
+ },
16419
+ {
16420
+ value: "Asymmetric Battle",
16421
+ description: "Game in which different players have different roles and capabilities as well as win condition (e.g. Identity 5)"
16422
+ },
16423
+ {
16424
+ value: "Brawl",
16425
+ description: "Multiplayer battle where player controls a character in team deathmatch battle without aiming a gun"
16426
+ },
16427
+ {
16428
+ value: "Fighting",
16429
+ description: "A game where the player controls a character to fight against other characters"
16430
+ },
16431
+ {
16432
+ value: "MOBA",
16433
+ description: "Multiplayer battle arena where the player controls a character on a team to destroy an enemy base"
16434
+ },
16435
+ {
16436
+ value: "Music & Rhythm",
16437
+ description: "Games that feature music as the primary gameplay driver"
16438
+ },
16439
+ {
16440
+ value: "Open World",
16441
+ description: "Action game in which players can explore the world and attempt objectives freely"
16442
+ },
16443
+ {
16444
+ value: "Platformer",
16445
+ description: "A game where players complete stages by avoiding obstacles and jumping between platforms"
16446
+ },
16447
+ {
16448
+ value: "Royale Battle",
16449
+ description: "Battle royale game (many players compete but with a single winner) that is action based and not a shooter"
16450
+ },
16451
+ {
16452
+ value: "Run & Gun Platformer",
16453
+ description: "Action games similar to side-scrolling platformers, but players are typically battling an onslaught of enemies appearing in front or behind them"
16454
+ },
16455
+ {
16456
+ value: "Runner",
16457
+ description: "A game where the player automatically progresses and must avoid obstacles to continue"
16458
+ },
16459
+ {
16460
+ value: "Shark",
16461
+ description: "Game in which the player eats other objects in the game to grow or stay alive"
16462
+ },
16463
+ {
16464
+ value: "Shoot'em Up",
16465
+ description: "A game where a lone unit (usually a spaceship) shoots projectiles against a large number of other enemies. Generally in a 2D movement space"
16466
+ },
16467
+ {
16468
+ value: "Slicing (Slasher)",
16469
+ description: "Game in which the main objective is to cut objects into pieces using a swiping motion"
16470
+ },
16471
+ {
16472
+ value: "Stealth",
16473
+ description: "Game where the player attempts to sneak around a game world and achieve objectives or escape"
16474
+ },
16475
+ {
16476
+ value: "Adventure",
16477
+ description: "Focuses on the actions themselves (shooting, twitch combat, etc.) or exploration of the world instead (finding non-gameplay collectables, solving puzzles, etc.) - Super Mario"
16478
+ },
16479
+ {
16480
+ value: "Beat 'em up",
16481
+ description: "Featuring hand-to-hand combat between the protagonist and an improbably large number of opponents."
16482
+ },
16483
+ {
16484
+ value: "Other Action",
16485
+ description: "Other general action gameplay or games that feature arcade-style gameplay"
16486
+ }
16487
+ ]
16488
+ },
16489
+ {
16490
+ value: "Match",
16491
+ subcategories: [
16492
+ {
16493
+ value: "Blast-Meta",
16494
+ description: "Blast-style game with a heavy emphasis on an investable meta game system"
16495
+ },
16496
+ {
16497
+ value: "Blast-Saga",
16498
+ description: "Game where primary mechanic involves blasting/removing adjacent like items with saga based progression"
16499
+ },
16500
+ {
16501
+ value: "Bubble Shooter",
16502
+ description: "Game where bubbles are shot at different angles clearing groups of bubbles arranged on top of screen"
16503
+ },
16504
+ {
16505
+ value: "Connect Tiles",
16506
+ description: "Game in which two like tiles are linked via a pathway on a board and removed from the board"
16507
+ },
16508
+ {
16509
+ value: "Line-Saga",
16510
+ description: "Game where a line is created between like items to remove them from the board with saga based progression"
16511
+ },
16512
+ {
16513
+ value: "M3-Meta",
16514
+ description: "Match 3 swapping game with a focus on some form of building in its meta game"
16515
+ },
16516
+ {
16517
+ value: "M3-Saga",
16518
+ description: "Primary gameplay mechanism is matching 3 items on screen and swapping matched items"
16519
+ },
16520
+ {
16521
+ value: "Merge-Saga",
16522
+ description: "Game with focus on merging like items to create more powerful units or items and utilizing saga based progression"
16523
+ },
16524
+ {
16525
+ value: "Other-Meta",
16526
+ description: "Other match style game with a heavy emphasis on an investable meta game system"
16527
+ },
16528
+ {
16529
+ value: "Other Match",
16530
+ description: "Other kind of matching game"
16531
+ }
16532
+ ]
16533
+ },
16534
+ {
16535
+ value: "Puzzle",
16536
+ subcategories: [
16537
+ {
16538
+ value: "Block Puzzle",
16539
+ description: "Game in which players need to fit different shaped block pieces to fit onto a game board efficiently"
16540
+ },
16541
+ {
16542
+ value: "Brain Puzzle",
16543
+ description: "Knowledge or intelligence-based puzzle games"
16544
+ },
16545
+ {
16546
+ value: "Brick-crusher",
16547
+ description: "A bubble shooter game featuring many balls shot, high action, and real time (not turn based) gameplay"
16548
+ },
16549
+ {
16550
+ value: "Detective",
16551
+ description: "Game in which players must solve puzzles based on various clues and involves solving a narrative arc"
16552
+ },
16553
+ {
16554
+ value: "Hidden Object",
16555
+ description: "Games where the primary objective is identifying visual elements"
16556
+ },
16557
+ {
16558
+ value: "Hybrid Puzzle",
16559
+ description: "Puzzle game involving multiple types of puzzles instead of focusing on just one"
16560
+ },
16561
+ {
16562
+ value: "Jigsaw",
16563
+ description: "Jigsaw puzzle game"
16564
+ },
16565
+ {
16566
+ value: "Klotski",
16567
+ description: "A sliding block puzzle game"
16568
+ },
16569
+ {
16570
+ value: "Maze",
16571
+ description: "Game in which players must determine paths out of a maze"
16572
+ },
16573
+ {
16574
+ value: "Minesweeper",
16575
+ description: "Games similar to the classic Minesweeper game"
16576
+ },
16577
+ {
16578
+ value: "Nonogram",
16579
+ description: "Game in which cells in a grid are colored or left blank according to numbers on the side of a grid to reveal a hidden picture"
16580
+ },
16581
+ {
16582
+ value: "Physics",
16583
+ description: "Games that utilize a physics engine-based primary gameplay mechanism"
16584
+ },
16585
+ {
16586
+ value: "Room Escape",
16587
+ description: "Puzzles focused on progressing a player to escape from a room or building"
16588
+ },
16589
+ {
16590
+ value: "Spot the Difference",
16591
+ description: "Matching images and determining the difference between the images"
16592
+ },
16593
+ {
16594
+ value: "Sudoku",
16595
+ description: "Sudoku based game"
16596
+ },
16597
+ {
16598
+ value: "Tile-Matching",
16599
+ description: "Game in which tiles are matched to remove them from the game board (like Tetris)"
16600
+ },
16601
+ {
16602
+ value: "Word",
16603
+ description: "Word Games"
16604
+ },
16605
+ {
16606
+ value: "Other Puzzle",
16607
+ description: "Puzzle-based games that do not fall into the above categories"
16608
+ }
16609
+ ]
16610
+ },
16611
+ {
16612
+ value: "Racing",
16613
+ subcategories: [
16614
+ {
16615
+ value: "Arcade Racing",
16616
+ description: "Casual and fun racing arcade type of game"
16617
+ },
16618
+ {
16619
+ value: "Competitive Racing",
16620
+ description: "PVP Racing that can use a variety of control schemes"
16621
+ },
16622
+ {
16623
+ value: "Simulation Racing",
16624
+ description: "Simulated game of realistic racing"
16625
+ }
16626
+ ]
16627
+ },
16628
+ {
16629
+ value: "RPG",
16630
+ subcategories: [
16631
+ {
16632
+ value: "Empire Simulation RPG",
16633
+ description: "RPG game in which the player rules an empire or kingdom of some kind"
16634
+ },
16635
+ {
16636
+ value: "Idle RPG",
16637
+ description: "Squad based RPG that includes idle progression mechanics"
16638
+ },
16639
+ {
16640
+ value: "Location RPG",
16641
+ description: "Game where location plays a critical component in the core gameplay"
16642
+ },
16643
+ {
16644
+ value: "MMORPG",
16645
+ description: "Massively multiplayer online role-playing game typically featuring worlds or servers with hundreds or thousands of players online simultaneously"
16646
+ },
16647
+ {
16648
+ value: "Open World RPG",
16649
+ description: "RPG game where players traverse an open world relatively freely"
16650
+ },
16651
+ {
16652
+ value: "Puzzle RPG",
16653
+ description: "RPG games that utilize a puzzle system as the primary combat mechanism"
16654
+ },
16655
+ {
16656
+ value: "Roguelike ARPG",
16657
+ description: "ARPG with roguelike (sub-genre of role-playing games characterized by the exploration of randomly-generated dungeons and permanent death) gameplay elements (e.g. Hades)"
16658
+ },
16659
+ {
16660
+ value: "Survival",
16661
+ description: "RPG based game with a strong focus on crafting mechanics"
16662
+ },
16663
+ {
16664
+ value: "Tactics",
16665
+ description: "RPG game involving turn based movement of different characters on a tile-based map"
16666
+ },
16667
+ {
16668
+ value: "Team Battle",
16669
+ description: "RPG where you control multiple characters to advance the gameplay and story"
16670
+ },
16671
+ {
16672
+ value: "Tower Defense RPG",
16673
+ description: "Tower defense game with a strong emphasis on character collection and stateful upgrading"
16674
+ },
16675
+ {
16676
+ value: "Other RPG",
16677
+ description: "Other RPG Game"
16678
+ }
16679
+ ]
16680
+ },
16681
+ {
16682
+ value: "Shooting",
16683
+ subcategories: [
16684
+ {
16685
+ value: "Battle Royale",
16686
+ description: "Shooter game in which battle royale is the primary game mode"
16687
+ },
16688
+ {
16689
+ value: "Cover-fire",
16690
+ description: "Shooting game where the player takes cover and shoots out of cover"
16691
+ },
16692
+ {
16693
+ value: "PvE Shooting",
16694
+ description: "Shooter game in which players primarily battle against computer generated, player-vs-environment enemies"
16695
+ },
16696
+ {
16697
+ value: "Sniper",
16698
+ description: "Shooting game focused on small number of accurate shots through a scope"
16699
+ },
16700
+ {
16701
+ value: "Team Deathmatch",
16702
+ description: "Shooter game in which team deathmatch is the primary gameplay mode"
16703
+ }
16704
+ ]
16705
+ },
16706
+ {
16707
+ value: "Simulation",
16708
+ subcategories: [
16709
+ {
16710
+ value: "Animal Avatar",
16711
+ description: "Game in which players take the form and play as an animal in a virtual world"
16712
+ },
16713
+ {
16714
+ value: "Avatar Life",
16715
+ description: "Simulated life based on avatars in an alternate reality world"
16716
+ },
16717
+ {
16718
+ value: "Build Breed",
16719
+ description: "Games in which the player grows a city used to breed creatures for combat"
16720
+ },
16721
+ {
16722
+ value: "Building",
16723
+ description: "Games focused on building up a city with limited/no focus on combat"
16724
+ },
16725
+ {
16726
+ value: "Creative Sandbox",
16727
+ description: "Players have tools to create user generated levels or games shared with the overall game community"
16728
+ },
16729
+ {
16730
+ value: "Dress Up & Lifestyle",
16731
+ description: "Games built around dressing up avatars and simulated life-like experiences with emphasis on lifestyle"
16732
+ },
16733
+ {
16734
+ value: "Driving",
16735
+ description: "Games where the primary gameplay loop is centered around simulating driving or parking (non-competitive)."
16736
+ },
16737
+ {
16738
+ value: "Farming",
16739
+ description: "Farming-based simulation titles"
16740
+ },
16741
+ {
16742
+ value: "Home Design",
16743
+ description: "Games involving decorating homes"
16744
+ },
16745
+ {
16746
+ value: "Idle",
16747
+ description: "Games where game progression continues even when a player leaves the game session"
16748
+ },
16749
+ {
16750
+ value: "Idol Training Sim",
16751
+ description: "Game in which players train and level up Japanese style idols against different types of activities or professions"
16752
+ },
16753
+ {
16754
+ value: "Life Simulator",
16755
+ description: "Simulation of a virtual character from birth to death in which the player makes different life choices"
16756
+ },
16757
+ {
16758
+ value: "Manager",
16759
+ description: "Games simulating the management of a team or business"
16760
+ },
16761
+ {
16762
+ value: "Pet",
16763
+ description: "Games where the primary gameplay loop is centered around raising a pet (non-combat)"
16764
+ },
16765
+ {
16766
+ value: "Time Management",
16767
+ description: "Simulation games where players are challenged to complete tasks or quests within a specific (usually short) time frame"
16768
+ },
16769
+ {
16770
+ value: "Weapon Simulator",
16771
+ description: "Video game that focuses on simulating the experience of using various weapons. These games aim to provide players with a realistic or immersive representation of different types of firearms, melee weapons, or other tools used in combat"
16772
+ },
16773
+ {
16774
+ value: "Other Sim",
16775
+ description: "Other Sim/Management games"
16776
+ }
16777
+ ]
16778
+ },
16779
+ {
16780
+ value: "Sports",
16781
+ subcategories: [
16782
+ {
16783
+ value: "Arcade Sports",
16784
+ description: "Sports games where gameplay focuses on non-realistic simulation of gameplay"
16785
+ },
16786
+ {
16787
+ value: "Simulation Sports",
16788
+ description: "Sports games where the gameplay focuses on realistic simulation of gameplay"
16789
+ },
16790
+ {
16791
+ value: "Team Manager",
16792
+ description: "Sports games where the player focuses on manage a team"
16793
+ },
16794
+ {
16795
+ value: "Other Sports",
16796
+ description: "Other Sports Games"
16797
+ }
16798
+ ]
16799
+ },
16800
+ {
16801
+ value: "Strategy",
16802
+ subcategories: [
16803
+ {
16804
+ value: "4X March-Battle",
16805
+ description: "Games where player grows a city, builds an army that attacks through timed marches on a map"
16806
+ },
16807
+ {
16808
+ value: "Auto Chess",
16809
+ description: "Tactical strategy game with drafting and in which play is conducted PVP in multiple rounds"
16810
+ },
16811
+ {
16812
+ value: "Build-Battle",
16813
+ description: "Games focused on building troops that attack enemies and can be lost. City building is usually used to upgrade troops."
16814
+ },
16815
+ {
16816
+ value: "CCG-Battle",
16817
+ description: "Strategy game based on card decks typically associated with mana costs to play"
16818
+ },
16819
+ {
16820
+ value: "Lane-Battle",
16821
+ description: "Strategy game involving multiple lanes where units are sent down a specific lane to battle"
16822
+ },
16823
+ {
16824
+ value: "Legion Battle",
16825
+ description: "Game with a focus on building different types of army units and battling other players' armies"
16826
+ },
16827
+ {
16828
+ value: "Summon-Battle",
16829
+ description: "Games where units are summoned via some means (e.g., cards or mana) and then auto-battle"
16830
+ },
16831
+ {
16832
+ value: "Tower Defense Strategy",
16833
+ description: "Games where players establish defenses against NPC enemies that attack the player at regular intervals"
16834
+ },
16835
+ {
16836
+ value: "RTS",
16837
+ description: "Real-time Strategy is a strategy game that allow all users to play simultaneously instead of processing incrementally in turns"
16838
+ },
16839
+ {
16840
+ value: "Other Strategy",
16841
+ description: "Other strategy games"
16842
+ }
16843
+ ]
16844
+ },
16845
+ {
16846
+ value: "Party",
16847
+ subcategories: [
16848
+ {
16849
+ value: "Guess Something",
16850
+ description: "Social game in which players must guess what another player has in mind from different kinds of hints or drawings"
16851
+ },
16852
+ {
16853
+ value: "Karaoke",
16854
+ description: "A Karaoke game is a type of video or computer game that simulates the experience of karaoke singing"
16855
+ },
16856
+ {
16857
+ value: "Dancing",
16858
+ description: "Video game that involves gameplay elements centered around dance and rhythm. These games often require players to mimic dance moves or follow on-screen prompts in synchronization with music."
16859
+ },
16860
+ {
16861
+ value: "Mafia/Betrayal",
16862
+ description: "Mafia based game"
16863
+ },
16864
+ {
16865
+ value: "Mini Games Collection",
16866
+ description: "Multiplayer social game in which players can choose to play from a collection of multiple minigames"
16867
+ },
16868
+ {
16869
+ value: "Party Royale",
16870
+ description: "Party based battle royale game"
16871
+ },
16872
+ {
16873
+ value: "Quiz",
16874
+ description: "Game involving trivia or quizzes"
16875
+ },
16876
+ {
16877
+ value: "Other Party",
16878
+ description: "Other party game"
16879
+ }
16880
+ ]
16881
+ },
16882
+ {
16883
+ value: "Tabletop",
16884
+ subcategories: [
16885
+ {
16886
+ value: "Board Game",
16887
+ description: "Board game is a game that involves the movement of counters or other objects round a board."
16888
+ },
16889
+ {
16890
+ value: "Card Games",
16891
+ description: "[Non gambling] A card game is any game using playing cards as the primary device with which the game is played, be they traditional or game-specific"
16892
+ },
16893
+ {
16894
+ value: "Chess",
16895
+ description: "Chess is a board game for two players, called White and Black. It is sometimes called international chess or Western chess"
16896
+ },
16897
+ {
16898
+ value: "Dice",
16899
+ description: "Dice games are games that use or incorporate one or more dice as their sole or central component, usually as a random device"
16900
+ },
16901
+ {
16902
+ value: "Ludo",
16903
+ description: "Ludo is a strategy board game for two to four players, in which the players race their four tokens from start to finish according to the rolls of a single die"
16904
+ },
16905
+ {
16906
+ value: "Othello",
16907
+ description: "Game based on the classic Othello game"
16908
+ },
16909
+ {
16910
+ value: "Solitaire",
16911
+ description: "Solitaire games are card based games that can be played by a single player."
16912
+ },
16913
+ {
16914
+ value: "Other Tabletop",
16915
+ description: "Other tabletop game"
16916
+ }
16917
+ ]
16918
+ },
16919
+ {
16920
+ value: "Other",
16921
+ subcategories: [
16922
+ {
16923
+ value: "Other",
16924
+ description: "Game that doesn't fit in any of the other categories"
16925
+ }
16926
+ ]
16927
+ }
16928
+ ];
16929
+ var catalog = {
16930
+ catalogVersion: catalogVersion,
16931
+ source: source,
16932
+ categories: categories$1
16933
+ };
16934
+
16935
+ const GAME_CATEGORY_CATALOG_VERSION = catalog.catalogVersion;
16936
+ const GAME_CATEGORIES = catalog.categories;
16937
+ function isGameCategoryPair(category, subcategory) {
16938
+ return GAME_CATEGORIES.some(item => item.value === category &&
16939
+ item.subcategories.some(child => child.value === subcategory));
16940
+ }
16941
+ function getGameCategories(options = {}) {
16942
+ const errorCode = !['text', 'json', 'ndjson'].includes(options.format || 'text')
16943
+ ? 'GAME_CATEGORIES_INVALID_FORMAT'
16944
+ : options.category !== undefined && !GAME_CATEGORIES.some(item => item.value === options.category)
16945
+ ? 'GAME_CATEGORY_UNKNOWN' : null;
16946
+ const categories = errorCode ? [] : GAME_CATEGORIES.filter(item => options.category === undefined || item.value === options.category);
16947
+ return {
16948
+ schemaVersion: '1',
16949
+ command: 'game categories',
16950
+ operationId: `game_categories_${crypto.randomUUID()}`,
16951
+ status: errorCode ? 'failed' : 'ready',
16952
+ terminal: true,
16953
+ platformWrite: false,
16954
+ catalogVersion: GAME_CATEGORY_CATALOG_VERSION,
16955
+ source: catalog.source,
16956
+ descriptionLanguage: 'en',
16957
+ categoryCount: categories.length,
16958
+ subcategoryCount: categories.reduce((count, item) => count + item.subcategories.length, 0),
16959
+ categories,
16960
+ errorCode,
16961
+ error: errorCode ? t(errorCode === 'GAME_CATEGORY_UNKNOWN'
16962
+ ? 'cli.command.game.categories.unknown' : 'cli.command.game.categories.invalidFormat') : null,
16963
+ };
16964
+ }
16965
+ function gameCategories(options) {
16966
+ const result = getGameCategories(options);
16967
+ if (options.format && options.format !== 'text')
16968
+ console.log(JSON.stringify(result));
16969
+ else if (result.error)
16970
+ console.error(result.error);
16971
+ else
16972
+ for (const category of result.categories) {
16973
+ console.log(category.value);
16974
+ for (const item of category.subcategories)
16975
+ console.log(` ${item.value}: ${item.description}`);
16976
+ }
16977
+ if (result.errorCode)
16978
+ process.exitCode = 1;
16979
+ }
16980
+
16981
+ var categories = /*#__PURE__*/Object.freeze({
16982
+ __proto__: null,
16983
+ GAME_CATEGORIES: GAME_CATEGORIES,
16984
+ GAME_CATEGORY_CATALOG_VERSION: GAME_CATEGORY_CATALOG_VERSION,
16985
+ gameCategories: gameCategories,
16986
+ getGameCategories: getGameCategories,
16987
+ isGameCategoryPair: isGameCategoryPair
16988
+ });
16989
+
16359
16990
  // Current PPE trial defaults: the owner-approved metadata used by the successful
16360
16991
  // real upload fixture on 2026-09-14, with owner-specified legal URLs updated on
16361
- // 2026-09-15. This is not a production metadata profile.
16992
+ // 2026-09-15 and the owner-approved brand description on 2026-09-16.
16993
+ // This is not a production metadata profile.
16362
16994
  const VIBE_PPE_DEFAULT_APP_INFO = Object.freeze({
16363
- description: 'DevTool PPE integration test fixture. Not a production game.',
16995
+ description: VIBE_DEFAULT_DESCRIPTION,
16364
16996
  category: 'Other',
16365
16997
  subcategory: 'Other',
16366
16998
  terms_of_service: 'https://www.tiktok.com',
@@ -16374,6 +17006,23 @@ const requiredStrings = [
16374
17006
  'description', 'category', 'subcategory', 'terms_of_service', 'privacy_policy',
16375
17007
  ];
16376
17008
  const optionalStrings = ['apple_team_id', 'contact_email', 'region', 'min_sdk_version'];
17009
+ function applyVibeDescription(description, appInfo) {
17010
+ if (description === undefined)
17011
+ return appInfo;
17012
+ if (typeof description !== 'string' || !description.trim() ||
17013
+ [...description].some(char => /^[\uD800-\uDFFF]$/.test(char)))
17014
+ throw new VibeError('VIBE_INVALID_DESCRIPTION');
17015
+ return { ...(appInfo || VIBE_PPE_DEFAULT_APP_INFO), description: description.trim() };
17016
+ }
17017
+ function applyVibeCategory(options, appInfo) {
17018
+ if (options.category === undefined && options.subcategory === undefined)
17019
+ return appInfo;
17020
+ if (options.category === undefined || options.subcategory === undefined)
17021
+ throw new VibeError('VIBE_CATEGORY_PAIR_REQUIRED');
17022
+ if (!isGameCategoryPair(options.category, options.subcategory))
17023
+ throw new VibeError('VIBE_INVALID_CATEGORY');
17024
+ return { ...(appInfo || VIBE_PPE_DEFAULT_APP_INFO), category: options.category, subcategory: options.subcategory };
17025
+ }
16377
17026
  function readVibeAppInfo(file) {
16378
17027
  if (file === undefined)
16379
17028
  return undefined;
@@ -16474,6 +17123,18 @@ function getCapabilities() {
16474
17123
  stdoutProtocolOnly: true,
16475
17124
  },
16476
17125
  commands: {
17126
+ gameCategories: {
17127
+ command: 'ttmg game categories --format json',
17128
+ available: true,
17129
+ schemaVersion: '1',
17130
+ platformWrite: false,
17131
+ source: 'bundled',
17132
+ catalogVersion: GAME_CATEGORY_CATALOG_VERSION,
17133
+ filterOption: '--category',
17134
+ includesGameplayDescriptions: true,
17135
+ requiresLogin: false,
17136
+ networkRequired: false,
17137
+ },
16477
17138
  vibeUpload: {
16478
17139
  command: 'ttmg upload --vibe --web --dir <gameDir> --title <title> --icon <iconPath> --format ndjson',
16479
17140
  mockCommand: 'ttmg upload --vibe --mock --dir <gameDir> --title <title> --icon <iconPath> --format ndjson',
@@ -16507,6 +17168,24 @@ function getCapabilities() {
16507
17168
  sourceProjectIdentity: '.ttmg/vibe-project.json',
16508
17169
  metadataInputs: ['title', 'icon', 'dir|package'],
16509
17170
  inputRequirements: VIBE_INPUT_REQUIREMENTS,
17171
+ description: {
17172
+ option: '--description',
17173
+ required: false,
17174
+ default: VIBE_PPE_DEFAULT_APP_INFO.description,
17175
+ precedence: ['argument', 'legacy-app-info', 'default'],
17176
+ invalidInput: 'reject-before-task-creation',
17177
+ resultField: 'description',
17178
+ sourceField: 'descriptionSource',
17179
+ },
17180
+ classification: {
17181
+ queryCommand: 'ttmg game categories --format json',
17182
+ options: ['--category', '--subcategory'],
17183
+ suppliedTogether: true,
17184
+ default: { category: 'Other', subcategory: 'Other' },
17185
+ invalidPair: 'reject-before-task-creation',
17186
+ legacyAppInfo: 'preserved-when-options-omitted; explicit-pair-overrides-category-fields',
17187
+ resultField: 'classification',
17188
+ },
16510
17189
  webAuthorization: { option: '--web', backend: 'ppe', defaultLane: 'ppe_op_vc', simulation: false, opensSystemBrowser: true, continuesPolling: true, formatIndependent: true, conflictsWith: ['--mock', '--mock-scenario', '--vibe-api', '--no-open'], mockBehaviorUnchanged: true, materialUploadEnabled: true },
16511
17190
  skillWorkflow: {
16512
17191
  preferredFormat: 'ndjson',
@@ -16635,6 +17314,20 @@ function getCapabilities() {
16635
17314
  projectIntegration: false,
16636
17315
  platformWrite: false,
16637
17316
  },
17317
+ wasmCollect: {
17318
+ available: true,
17319
+ experimental: true,
17320
+ authentication: 'local_cli_login',
17321
+ credentialOutput: false,
17322
+ nativeBindingRequired: false,
17323
+ platformVerified: false,
17324
+ outputFormats: ['text', 'json'],
17325
+ start: { command: 'ttmg wasm collect start', platformWrite: true,
17326
+ resetDefault: false, resetOption: '--reset', automaticRetry: false },
17327
+ export: { command: 'ttmg wasm collect export', platformWrite: false,
17328
+ collectionSchemaVersion: '1', originalInputRequired: true,
17329
+ outputPathField: 'collection.path', overwrite: false, strategy: 'union' },
17330
+ },
16638
17331
  dev: {
16639
17332
  command: 'ttmg dev --format json --no-open',
16640
17333
  eventsCommand: 'ttmg dev --events ndjson --no-open',
@@ -17226,6 +17919,8 @@ function getDesktopPath() {
17226
17919
  const program = new commander.Command();
17227
17920
  const isPreviewPageServerWorker = process.argv[2] === '__preview-page-server';
17228
17921
  const isVibePageServerWorker = process.argv[2] === '__vibe-page-server';
17922
+ const wasmArgumentIndex = process.argv.indexOf('wasm', 2);
17923
+ const isWasmCollectCommand = wasmArgumentIndex >= 2 && process.argv[wasmArgumentIndex + 1] === 'collect';
17229
17924
  const withVerboseOption = (command) => command.option('--verbose', t('cli.option.verbose'));
17230
17925
  const structuredFormatIndex = process.argv.indexOf('--format');
17231
17926
  const inlineStructuredFormat = process.argv.find(arg => arg.startsWith('--format='));
@@ -17236,6 +17931,7 @@ const structuredFormat = inlineStructuredFormat
17236
17931
  : '';
17237
17932
  if (!isPreviewPageServerWorker &&
17238
17933
  !isVibePageServerWorker &&
17934
+ !(isWasmCollectCommand && !structuredFormat) &&
17239
17935
  structuredFormat !== 'json' &&
17240
17936
  structuredFormat !== 'ndjson' &&
17241
17937
  !process.argv.includes('--implicit')) {
@@ -17264,6 +17960,14 @@ withVerboseOption(program.command('logout').description(t('cli.command.logout.de
17264
17960
  await logout();
17265
17961
  });
17266
17962
  const authCmd = program.command('auth').description(t('cli.command.auth.desc'));
17963
+ const gameCmd = program.command('game').description(t('cli.command.game.desc'));
17964
+ withVerboseOption(gameCmd.command('categories')
17965
+ .description(t('cli.command.game.categories.desc'))
17966
+ .option('--category <category>', t('cli.command.game.categories.category'))
17967
+ .option('--format <format>', t('cli.command.capabilities.format'), 'text')).action(async (cmd) => {
17968
+ const { gameCategories } = await Promise.resolve().then(function () { return categories; });
17969
+ gameCategories(cmd);
17970
+ });
17267
17971
  withVerboseOption(authCmd.command('open')
17268
17972
  .description(t('cli.command.auth.open.desc'))
17269
17973
  .option('--page-url <url>', t('cli.command.auth.open.pageUrl'))
@@ -17300,7 +18004,10 @@ withVerboseOption(program
17300
18004
  .option('--web', t('cli.command.upload.vibeWeb'))
17301
18005
  // Vibe v2 backend selection (including opt-in ppe-mock) stays outside the Skill workflow.
17302
18006
  .option('--title <title>', t('cli.command.upload.vibeTitle'))
18007
+ .option('--description <description>', t('cli.command.upload.vibeDescription'))
17303
18008
  .option('--icon <path>', t('cli.command.upload.vibeIcon'))
18009
+ .option('--category <category>', t('cli.command.upload.vibeCategory'))
18010
+ .option('--subcategory <subcategory>', t('cli.command.upload.vibeSubcategory'))
17304
18011
  .addOption(new commander.Option('--app-info <path>', t('cli.command.upload.vibeAppInfo')).hideHelp())
17305
18012
  .option('--package <path>', t('cli.command.upload.vibePackage'))
17306
18013
  .option('--dry-run', t('cli.command.upload.vibeDryRun'))
@@ -17319,8 +18026,11 @@ withVerboseOption(program
17319
18026
  }
17320
18027
  if ([
17321
18028
  cmd.title,
18029
+ cmd.description,
17322
18030
  cmd.icon,
17323
18031
  cmd.appInfo,
18032
+ cmd.category,
18033
+ cmd.subcategory,
17324
18034
  cmd.web,
17325
18035
  cmd.package,
17326
18036
  cmd.dryRun,
@@ -17663,6 +18373,25 @@ devSessionCmd
17663
18373
  });
17664
18374
  });
17665
18375
  const wasmCmd = program.command('wasm').description(t('cli.command.wasm.desc'));
18376
+ const collectCmd = wasmCmd.command('collect').description(t('cli.command.wasm.collect'));
18377
+ for (const operation of ['start', 'export']) {
18378
+ const command = collectCmd.command(operation)
18379
+ .description(t(operation === 'start' ? 'cli.command.wasm.collect.start' : 'cli.command.wasm.collect.export'))
18380
+ .allowExcessArguments(false)
18381
+ .option('--client-key <key>', t('cli.command.wasm.collect.clientKey'))
18382
+ .option('--wasm-md5 <md5>', t('cli.command.wasm.collect.md5'))
18383
+ .option('--timeout <seconds>', t('cli.command.wasm.collect.timeout'), '30')
18384
+ .option('--format <format>', t('cli.command.wasm.format'), 'json');
18385
+ if (operation === 'start')
18386
+ command.option('--reset', t('cli.command.wasm.collect.reset'));
18387
+ else
18388
+ command.option('--input <path>', t('cli.command.wasm.input'))
18389
+ .option('--output <path>', t('cli.command.wasm.collect.output'));
18390
+ command.action(async (options) => {
18391
+ const Native = await Promise.resolve().then(function () { return index; });
18392
+ await Native.wasmCollectCommand(operation, options);
18393
+ });
18394
+ }
17666
18395
  for (const operation of ['prepare', 'split']) {
17667
18396
  const command = wasmCmd.command(operation)
17668
18397
  .description(t(operation === 'prepare' ? 'cli.command.wasm.prepare' : 'cli.command.wasm.split'))
@@ -18479,7 +19208,7 @@ async function prepareVibeInput(options, onPackaging, signal, deps = { check: ex
18479
19208
  const title = options.title?.trim();
18480
19209
  if (!title)
18481
19210
  throw new VibeError('VIBE_TITLE_REQUIRED');
18482
- const appInfo = readVibeAppInfo(options.appInfo);
19211
+ const appInfo = applyVibeCategory(options, applyVibeDescription(options.description, readVibeAppInfo(options.appInfo)));
18483
19212
  if (options.package && options.dir)
18484
19213
  throw new VibeError('VIBE_INPUT_CONFLICT');
18485
19214
  const image = readFile(options.icon, VIBE_ICON_LIMIT, 'VIBE_INVALID_ICON');
@@ -18522,7 +19251,7 @@ async function prepareVibeInput(options, onPackaging, signal, deps = { check: ex
18522
19251
  },
18523
19252
  code: { bytes: code, name: 'game.zip', contentType: 'application/zip' },
18524
19253
  };
18525
- if (appInfo)
19254
+ if (options.appInfo !== undefined)
18526
19255
  validateVibeUploadInput(input);
18527
19256
  return input;
18528
19257
  }
@@ -19034,6 +19763,14 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
19034
19763
  terminal: !!options.dryRun,
19035
19764
  nextAction: options.dryRun ? 'none' : 'wait',
19036
19765
  title: input.title,
19766
+ description: (input.appInfo || VIBE_PPE_DEFAULT_APP_INFO).description,
19767
+ descriptionSource: options.description !== undefined ? 'arguments' : options.appInfo !== undefined ? 'app-info' : 'defaults',
19768
+ classification: {
19769
+ category: (input.appInfo || VIBE_PPE_DEFAULT_APP_INFO).category,
19770
+ subcategory: (input.appInfo || VIBE_PPE_DEFAULT_APP_INFO).subcategory,
19771
+ source: options.category !== undefined ? 'arguments' : options.appInfo !== undefined ? 'app-info' : 'defaults',
19772
+ catalogVersion: GAME_CATEGORY_CATALOG_VERSION,
19773
+ },
19037
19774
  iconSizeBytes: input.icon.bytes.length,
19038
19775
  packageSizeBytes: input.code.bytes.length,
19039
19776
  packageSha256: crypto.createHash('sha256')
@@ -19225,6 +19962,9 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
19225
19962
  ? 'cancelled'
19226
19963
  : 'failed';
19227
19964
  const messages = {
19965
+ VIBE_CATEGORY_PAIR_REQUIRED: ['--category 和 --subcategory 必须同时提供;均不传时保留默认分类。使用 ttmg game categories --format json 查询。', 'Provide --category and --subcategory together, or omit both to keep the default. Query ttmg game categories --format json.'],
19966
+ VIBE_INVALID_CATEGORY: ['类型或子类型无效,或两者不匹配。使用 ttmg game categories --format json 查询有效组合。', 'Invalid category/subcategory pair. Query valid values with ttmg game categories --format json.'],
19967
+ VIBE_INVALID_DESCRIPTION: ['描述必须是非空的有效 Unicode 文本;省略 --description 可使用默认描述。', 'Description must be non-empty valid Unicode text; omit --description to use the default.'],
19228
19968
  VIBE_WEB_OPTION_CONFLICT: ['--web 使用真实网页授权,不能与 --mock、--mock-scenario、--vibe-api 或 --no-open 同时使用。', '--web uses real browser authorization and cannot be combined with --mock, --mock-scenario, --vibe-api or --no-open.'],
19229
19969
  VIBE_AUTH_DENIED: [
19230
19970
  '已取消授权,本次未上传。',
@@ -30540,12 +31280,17 @@ async function snapshotWasm(input, output) {
30540
31280
  callback(bytes > 512 * 1024 * 1024 ? fail('WASM_INPUT_INVALID', 'Expanded Wasm exceeds 512 MiB.') : null, chunk);
30541
31281
  } });
30542
31282
  const source = fs$1.createReadStream(input);
31283
+ const fileMd5 = crypto$1.createHash('md5');
31284
+ const identity = new node_stream.Transform({ transform(chunk, _encoding, callback) {
31285
+ fileMd5.update(chunk);
31286
+ callback(null, chunk);
31287
+ } });
30543
31288
  const target = fs$1.createWriteStream(output, { flags: 'wx', mode: 0o600 });
30544
31289
  try {
30545
31290
  if (input.endsWith('.br'))
30546
- await promises$2.pipeline(source, zlib$1.createBrotliDecompress(), bound, target);
31291
+ await promises$2.pipeline(source, identity, zlib$1.createBrotliDecompress(), bound, target);
30547
31292
  else
30548
- await promises$2.pipeline(source, bound, target);
31293
+ await promises$2.pipeline(source, identity, bound, target);
30549
31294
  }
30550
31295
  catch (error) {
30551
31296
  throw fail(error.code === 'WASM_INPUT_INVALID' ? error.code : 'WASM_INPUT_INVALID', 'Could not read the original Wasm input.');
@@ -30562,7 +31307,11 @@ async function snapshotWasm(input, output) {
30562
31307
  throw fail('WASM_INPUT_INVALID', 'Expected a WebAssembly version 1 binary.');
30563
31308
  if (!WebAssembly.validate(await fsp.readFile(output)))
30564
31309
  throw fail('WASM_INPUT_INVALID', 'Original Wasm is invalid or unsupported by this Node.js WebAssembly engine.');
30565
- return { bytes, wasmSha256: await digest(output) };
31310
+ const rawMd5 = crypto$1.createHash('md5');
31311
+ for await (const chunk of fs$1.createReadStream(output))
31312
+ rawMd5.update(chunk);
31313
+ return { bytes, wasmSha256: await digest(output), wasmMd5: fileMd5.digest('hex'),
31314
+ uncompressedWasmMd5: rawMd5.digest('hex') };
30566
31315
  }
30567
31316
  async function executeWasm(operation, options, dependencies = {}) {
30568
31317
  const base = { schemaVersion: '1', command: `wasm.${operation}`, operationId: `wasm_${crypto$1.randomUUID()}`,
@@ -30670,6 +31419,149 @@ async function wasmCommand(operation, options) {
30670
31419
  process.exitCode = result.status === 'failed' ? 1 : 0;
30671
31420
  }
30672
31421
 
31422
+ class CollectError extends Error {
31423
+ constructor(code, message) {
31424
+ super(message);
31425
+ this.code = code;
31426
+ }
31427
+ }
31428
+ const invalid = (code, message) => { throw new CollectError(code, message); };
31429
+ async function executeWasmCollect(operation, options, overrides = {}) {
31430
+ const deps = { authenticated: () => Boolean(getCurrentUser()?.cookie), request, ...overrides };
31431
+ const base = { schemaVersion: '1', command: `wasm.collect.${operation}`,
31432
+ operationId: `wasm_collect_${crypto$1.randomUUID()}`, platformWrite: operation === 'start',
31433
+ platformWriteAttempted: false, sourceModified: false };
31434
+ let temporary;
31435
+ let staging;
31436
+ let timer;
31437
+ try {
31438
+ const timeout = Number(options.timeout ?? 30);
31439
+ if (!['start', 'export'].includes(operation) || !['json', 'text'].includes(options.format || 'json') ||
31440
+ !/^[A-Za-z0-9_-]{1,128}$/.test(options.clientKey || '') || !/^[a-fA-F0-9]{32}$/.test(options.wasmMd5 || '') ||
31441
+ !Number.isInteger(timeout) || timeout < 1 || timeout > 300 ||
31442
+ (options.reset !== undefined && typeof options.reset !== 'boolean') ||
31443
+ (operation === 'export' && (!options.input || !options.output || options.reset !== undefined)) ||
31444
+ (operation === 'start' && (options.input || options.output))) {
31445
+ invalid('WASM_COLLECT_INVALID_OPTIONS', 'Provide client-key and wasm-md5; export also requires original input and a new output file. Timeout: 1–300 seconds.');
31446
+ }
31447
+ const clientKey = options.clientKey;
31448
+ const wasmMd5 = options.wasmMd5.toLowerCase();
31449
+ const output = options.output ? path$1.resolve(options.output) : undefined;
31450
+ let source;
31451
+ if (operation === 'export') {
31452
+ // lstat detects dangling links as well as existing files. Never overwrite.
31453
+ if (await fsp.lstat(output).catch((e) => { if (e.code !== 'ENOENT')
31454
+ throw e; return null; }))
31455
+ invalid('WASM_OUTPUT_EXISTS', 'Collection output already exists; choose a new file.');
31456
+ temporary = await fsp.mkdtemp(path$1.join(os$1.tmpdir(), 'ttmg-collect-'));
31457
+ try {
31458
+ source = await snapshotWasm(path$1.resolve(options.input), path$1.join(temporary, 'original.wasm'));
31459
+ }
31460
+ catch {
31461
+ return invalid('WASM_INPUT_INVALID', 'Expected a valid original Wasm or Brotli Wasm file.');
31462
+ }
31463
+ if (wasmMd5 !== source.wasmMd5 && wasmMd5 !== source.uncompressedWasmMd5)
31464
+ invalid('WASM_COLLECTION_MISMATCH', 'Collection MD5 does not match this original Wasm (file bytes or uncompressed bytes).');
31465
+ }
31466
+ if (!deps.authenticated())
31467
+ invalid('WASM_AUTH_REQUIRED', 'Run ttmg login on this machine before collecting or exporting.');
31468
+ const controller = new AbortController();
31469
+ const deadline = new Promise((_, reject) => {
31470
+ timer = setTimeout(() => {
31471
+ controller.abort();
31472
+ reject(new CollectError('WASM_COLLECT_TIMEOUT', 'Platform request timed out. A start may have reached the server; retry without --reset to preserve collection.'));
31473
+ }, timeout * 1000);
31474
+ });
31475
+ base.platformWriteAttempted = operation === 'start';
31476
+ const response = await Promise.race([deps.request({
31477
+ url: `${WASM_COLLECT_BASE_URL}/${operation === 'start' ? 'start' : 'export'}`,
31478
+ method: operation === 'start' ? 'POST' : 'GET',
31479
+ ...(operation === 'start'
31480
+ ? { data: { app_id: clientKey, wasm_md5: wasmMd5, reset: options.reset ?? false } }
31481
+ : { params: { app_id: clientKey, wasm_md5: wasmMd5, strategy: 'union' } }),
31482
+ signal: controller.signal,
31483
+ logRequestBody: false, logApiCalls: false,
31484
+ }), deadline]);
31485
+ clearTimeout(timer);
31486
+ const code = response.error?.code ?? response.error?.StatusCode ?? response.data?.code;
31487
+ const httpStatus = response.ctx?.httpStatusCode;
31488
+ // Upstream bodies/errors are deliberately never included in output: they
31489
+ // can contain credentials or gateway HTML, even with verbose enabled.
31490
+ if ([401, -401].includes(Number(code)) || httpStatus === 401 ||
31491
+ (Number(code) === -1 && /login|log.?in|登录|未登|auth/i.test(String(response.error?.message ?? response.error?.StatusMessage ?? response.data?.message ?? ''))))
31492
+ invalid('WASM_AUTH_REQUIRED', 'Platform login expired. Run ttmg login and retry.');
31493
+ if ([403, -403].includes(Number(code)) || httpStatus === 403)
31494
+ invalid('WASM_COLLECT_FORBIDDEN', 'This account cannot access collection for this game.');
31495
+ if (response.error || response.data?.code !== 0 || (httpStatus && (httpStatus < 200 || httpStatus >= 300)))
31496
+ invalid('WASM_COLLECT_API_FAILED', 'Platform collection request failed; no collection file was written.');
31497
+ if (operation === 'start') {
31498
+ if (response.data.collect_state !== 'open')
31499
+ invalid('WASM_COLLECT_INVALID_RESPONSE', 'Platform did not confirm an open collection window.');
31500
+ return { ...base, status: 'succeeded', clientKey, wasmMd5, reset: options.reset ?? false,
31501
+ collectState: 'open', nextAction: 'run_instrumented_game_and_collect', errorCode: null, error: null };
31502
+ }
31503
+ if (Array.isArray(response.data.func_ids) && response.data.func_ids.length === 0)
31504
+ invalid('WASM_COLLECTION_EMPTY', 'No function IDs collected. Run the instrumented game and export again.');
31505
+ let ids;
31506
+ try {
31507
+ ids = parseCollection({ schemaVersion: '1', wasmSha256: source.wasmSha256,
31508
+ funcIds: response.data.func_ids, bootFuncIds: response.data.boot_func_ids }, source.wasmSha256);
31509
+ }
31510
+ catch {
31511
+ return invalid('WASM_COLLECTION_INVALID', 'Platform returned invalid function IDs; no collection file was written.');
31512
+ }
31513
+ const collection = { schemaVersion: '1', wasmSha256: source.wasmSha256, ...ids,
31514
+ clientKey, wasmMd5, strategy: 'union', exportedAt: new Date().toISOString() };
31515
+ const bytes = Buffer.from(JSON.stringify(collection, null, 2) + '\n');
31516
+ if (bytes.length > 32 * 1024 * 1024)
31517
+ invalid('WASM_COLLECTION_INVALID', 'Collection JSON exceeds 32 MiB.');
31518
+ await fsp.mkdir(path$1.dirname(output), { recursive: true });
31519
+ staging = path$1.join(path$1.dirname(output), `.ttmg-collection-${crypto$1.randomUUID()}.tmp`);
31520
+ await fsp.writeFile(staging, bytes, { flag: 'wx', mode: 0o600 });
31521
+ // Publish a complete file atomically, with exclusive no-clobber semantics.
31522
+ try {
31523
+ await fsp.link(staging, output);
31524
+ }
31525
+ catch (e) {
31526
+ if (e.code === 'EEXIST')
31527
+ invalid('WASM_OUTPUT_EXISTS', 'Collection output already exists; choose a new file.');
31528
+ throw e;
31529
+ }
31530
+ return { ...base, status: 'succeeded', clientKey, wasmMd5,
31531
+ collection: { path: output, schemaVersion: '1', wasmSha256: source.wasmSha256,
31532
+ funcCount: ids.funcIds.length, bootFuncCount: ids.bootFuncIds.length,
31533
+ bytes: bytes.length, sha256: crypto$1.createHash('sha256').update(bytes).digest('hex') },
31534
+ nextAction: 'split_with_collection', errorCode: null, error: null };
31535
+ }
31536
+ catch (error) {
31537
+ const known = error instanceof CollectError;
31538
+ return { ...base, status: 'failed', errorCode: known ? error.code : 'WASM_COLLECT_FAILED',
31539
+ error: known ? error.message : 'Collection operation failed; check the original Wasm, output directory and connection.',
31540
+ nextAction: known && error.code === 'WASM_AUTH_REQUIRED' ? 'login' : 'fix_and_retry' };
31541
+ }
31542
+ finally {
31543
+ if (timer)
31544
+ clearTimeout(timer);
31545
+ if (staging)
31546
+ await fsp.unlink(staging).catch(() => { });
31547
+ if (temporary)
31548
+ await fsp.rm(temporary, { recursive: true, force: true });
31549
+ }
31550
+ }
31551
+ async function wasmCollectCommand(operation, options) {
31552
+ const result = await executeWasmCollect(operation, options);
31553
+ if ((options.format || 'json') === 'json')
31554
+ console.log(JSON.stringify(result));
31555
+ else {
31556
+ console.log(t(result.status === 'failed' ? 'wasm.collect.failed' : 'wasm.collect.succeeded'));
31557
+ if (result.error)
31558
+ console.error(result.error);
31559
+ if ('collection' in result)
31560
+ console.log(result.collection.path);
31561
+ }
31562
+ process.exitCode = result.status === 'failed' ? 1 : 0;
31563
+ }
31564
+
30673
31565
  const problem = (code, message) => Object.assign(new Error(message), { code });
30674
31566
  const MAX_BYTES = 64 * 1024 * 1024;
30675
31567
  // Export one finite Runtime interval. Sequence numbers are global, so gaps in
@@ -30873,6 +31765,7 @@ var index = /*#__PURE__*/Object.freeze({
30873
31765
  devSessionStopCommand: devSessionStopCommand,
30874
31766
  devWorkflowCommand: devWorkflowCommand,
30875
31767
  doctor: doctor,
31768
+ wasmCollectCommand: wasmCollectCommand,
30876
31769
  wasmCommand: wasmCommand
30877
31770
  });
30878
31771
  //# sourceMappingURL=index.js.map