@7ots/cli 0.1.17 → 0.1.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/.env.example +14 -0
  2. package/README.md +11 -0
  3. package/brand/logos/base.svg +1 -0
  4. package/brand/logos/clawpump.png +0 -0
  5. package/brand/logos/conductors.svg +1 -0
  6. package/brand/logos/notlogin.svg +12 -0
  7. package/brand/logos/pumpfun.png +0 -0
  8. package/brand/logos/solana.png +0 -0
  9. package/brand/logos/spawnerbot.svg +1 -0
  10. package/brand/logos/virtuals.png +0 -0
  11. package/cli/7ots.mjs +61 -1
  12. package/cli/lib/account.mjs +23 -3
  13. package/cli/lib/assistant.mjs +92 -14
  14. package/cli/lib/brain.mjs +84 -11
  15. package/cli/lib/card-shot.mjs +1 -1
  16. package/cli/lib/config.mjs +14 -3
  17. package/cli/lib/desktop-sync.mjs +177 -0
  18. package/cli/lib/i18n.mjs +9 -0
  19. package/cli/lib/inferences.mjs +19 -2
  20. package/cli/lib/integrations.mjs +98 -13
  21. package/cli/lib/mcp.mjs +1 -1
  22. package/cli/lib/open.mjs +3 -1
  23. package/cli/lib/pet-server.mjs +352 -41
  24. package/cli/lib/prompts.mjs +1 -1
  25. package/cli/lib/screen.mjs +1 -1
  26. package/cli/lib/senses/gestures.mjs +121 -0
  27. package/cli/lib/senses/index.mjs +490 -0
  28. package/cli/lib/senses/rules.mjs +159 -0
  29. package/cli/lib/senses/sources/activity.mjs +95 -0
  30. package/cli/lib/senses/sources/calendar.mjs +75 -0
  31. package/cli/lib/senses/sources/index.mjs +17 -0
  32. package/cli/lib/senses/sources/mail.mjs +48 -0
  33. package/cli/lib/senses/sources/system.mjs +39 -0
  34. package/cli/lib/senses/util.mjs +41 -0
  35. package/cli/lib/senses/vendor.mjs +78 -0
  36. package/cli/lib/stt-local.py +16 -8
  37. package/cli/lib/stt.mjs +53 -6
  38. package/cli/lib/tooluse.mjs +56 -0
  39. package/cli/lib/tts-local.mjs +2 -2
  40. package/cli/lib/vm.mjs +2 -2
  41. package/cli/lib/wake-local.py +109 -0
  42. package/cli/lib/wake.mjs +102 -0
  43. package/cli/pet/electron/main.cjs +190 -8
  44. package/cli/pet/pet.html +153 -34
  45. package/cli/pet/senses.html +342 -0
  46. package/cli/pet/settings.html +815 -74
  47. package/dist/7ots.esm.js +373 -146
  48. package/dist/7ots.esm.js.map +4 -4
  49. package/dist/7ots.iife.js +373 -146
  50. package/dist/7ots.iife.js.map +4 -4
  51. package/llms.txt +27 -0
  52. package/package.json +5 -2
  53. package/server/channels/apuchat.mjs +18 -4
  54. package/server/errors.mjs +90 -0
  55. package/server/notify.mjs +78 -0
  56. package/server/server.mjs +84 -14
  57. package/server/settings.mjs +3 -0
  58. package/server/site.mjs +401 -0
  59. package/server/tts.mjs +29 -5
  60. package/src/avatar/AvatarStage.js +2 -2
  61. package/src/avatar/three.js +3 -2
  62. package/src/character/AvatarEditor.js +2 -1
  63. package/src/character/Character.js +38 -5
  64. package/src/character/TradingCard.js +2 -0
  65. package/src/character/beat.js +64 -2
  66. package/src/character/mods/orc.js +8 -1
  67. package/src/character/mods.js +104 -10
  68. package/src/character/motion.js +252 -1
  69. package/src/character/parts.js +40 -38
  70. package/src/character/styles.js +40 -38
  71. package/src/character3d/Character3D.js +26 -5
  72. package/src/character3d/body.js +14 -12
  73. package/src/character3d/export.js +693 -0
  74. package/src/character3d/fx.js +13 -0
  75. package/src/character3d/index.js +2 -0
  76. package/src/character3d/materials.js +106 -10
  77. package/src/character3d/room-themes.js +1184 -0
  78. package/src/character3d/room.js +487 -0
  79. package/src/character3d/stage.js +14 -2
  80. package/src/creator/StepCreator.js +316 -0
  81. package/src/i18n/index.js +3 -3
  82. package/src/i18n/messages/character.js +352 -4
  83. package/src/i18n/messages/creator.js +138 -0
  84. package/src/i18n/messages/identity.js +89 -1
  85. package/src/i18n/messages/platform.js +270 -4
  86. package/src/i18n/messages/server.js +443 -1
  87. package/src/i18n/messages/widget.js +233 -0
  88. package/src/identity/random.js +14 -2
  89. package/src/identity/schema.js +2 -1
  90. package/src/index.js +9 -2
  91. package/src/voice/tags.js +22 -0
  92. package/server/platform/apuchat.mjs +0 -266
  93. package/server/platform/auth.mjs +0 -319
  94. package/server/platform/connect.mjs +0 -387
  95. package/server/platform/crypto.mjs +0 -80
  96. package/server/platform/db.mjs +0 -275
  97. package/server/platform/device.mjs +0 -222
  98. package/server/platform/integrations.mjs +0 -169
  99. package/server/platform/look.mjs +0 -20
  100. package/server/platform/mods.mjs +0 -222
  101. package/server/platform/orquesta.mjs +0 -577
  102. package/server/platform/profile.mjs +0 -161
  103. package/server/platform/routes.mjs +0 -542
  104. package/server/platform/runtime.mjs +0 -242
  105. package/server/platform/sites.mjs +0 -146
  106. package/server/platform/store.mjs +0 -456
  107. package/server/platform/vm.mjs +0 -1057
@@ -359,4 +359,237 @@ addCatalog({
359
359
  },
360
360
  },
361
361
  },
362
+ zh: {
363
+ widget: {
364
+ defaultName: '助手',
365
+ launcher: { open: '打开助手 {name}' },
366
+ panel: { label: '助手 {name}' },
367
+ teaser: { dismiss: '关闭' },
368
+ status: { online: '在线', thinking: '思考中…', withTeam: '与团队对话中' },
369
+ typing: '助手正在思考',
370
+ voice: { on: '语音已开启', off: '语音已静音', mute: '静音', micDenied: '麦克风权限被拒绝' },
371
+ menu: {
372
+ contact: '联系团队',
373
+ more: '更多选项',
374
+ minimize: '最小化',
375
+ initiativeLabel: '助手主动性',
376
+ initiative: '主动性',
377
+ level: { quiet: '低调', normal: '普通', bold: '大胆' },
378
+ muteSuggestions: '关闭建议',
379
+ unmuteSuggestions: '开启建议',
380
+ reset: '新对话',
381
+ },
382
+ composer: {
383
+ placeholder: '输入文字或点击麦克风…',
384
+ placeholderTeam: '给团队留言…',
385
+ label: '消息',
386
+ mic: '说话',
387
+ send: '发送',
388
+ },
389
+ footer: { ai: 'AI 助手 · 可能会出错' },
390
+ pageTools: { done: '已完成:{title}' },
391
+ handoff: {
392
+ team: '支持团队',
393
+ author: '团队',
394
+ video: '视频通话',
395
+ back: '返回助手',
396
+ userLeft: '用户已返回助手',
397
+ ended: '与团队的对话已结束。',
398
+ closed: '支持频道已关闭。',
399
+ sendFailed: '无法将消息发送给团队。',
400
+ },
401
+ brain: {
402
+ stuck: '我做到一半卡住了。要我换个方式再试试吗?',
403
+ error: '哎呀,我回答时出了点问题。要再试一次吗?',
404
+ },
405
+ pointer: {
406
+ stopped: '已停止。在你吩咐之前我不会再做任何操作。',
407
+ hint: '按 Esc 停止',
408
+ halted: '已停止',
409
+ typing: '输入中…',
410
+ },
411
+ companion: {
412
+ talkTo: '和 {name} 聊天',
413
+ pointAt: '指给你看',
414
+ tour: '导览',
415
+ goHome: '回到角落',
416
+ },
417
+ dialog: {
418
+ close: '关闭',
419
+ confirm: '确认',
420
+ ok: '确定',
421
+ cancel: '取消',
422
+ info: '信息',
423
+ gotIt: '知道了',
424
+ },
425
+ confirm: {
426
+ title: '确认操作',
427
+ yes: '是,继续',
428
+ runAction: '允许助手执行“{action}”吗?',
429
+ mcp: '助手想在你的账户上执行“{action}”。继续吗?',
430
+ click: '助手想点击“{label}”。继续吗?',
431
+ typeSubmit: '要我输入文字并提交表单吗?',
432
+ enterSubmit: '助手想在“{label}”上按 Enter,这会提交表单。继续吗?',
433
+ fillSubmit: '要用我填写的信息提交表单吗?',
434
+ pageTool: '助手想使用“{title}”。继续吗?',
435
+ pageToolWith: '助手想用 {detail} 来使用“{title}”。继续吗?',
436
+ },
437
+ contact: {
438
+ human: '与真人交谈',
439
+ mail: '通过邮件留言',
440
+ askHuman: '我想和团队里的真人聊聊。',
441
+ askMail: '我想通过邮件给团队留言。',
442
+ mailPreview: '以下消息将发送给支持团队:\n\n主题:{subject}\n回复至:{to}\n\n{message}',
443
+ noEmail: '(无邮箱)',
444
+ ticket: '工单 {id}',
445
+ replyTo: '我们会回复到 {email}。',
446
+ humanConfirm: '要我现在为你联系团队里的真人吗?他们会看到这次对话的摘要。',
447
+ connected: '已连接团队。他们会在这里回复你。',
448
+ handoffIntro: '你好,我是 {name}。原因:{reason}。\n\n助手摘要:{summary}\n\n页面:{url}',
449
+ visitor: '一位访客',
450
+ },
451
+ actions: {
452
+ get_page_context: '正在查看页面',
453
+ find_on_page: '正在页面中搜索',
454
+ read_element: '正在阅读',
455
+ navigate: '正在跳转',
456
+ scroll_to: '正在滚动',
457
+ click: '正在点击',
458
+ hover: '正在移动鼠标',
459
+ type_text: '正在输入',
460
+ press_key: '正在按键',
461
+ drag_and_drop: '正在拖动',
462
+ scroll: '正在滚动',
463
+ fill_form: '正在填写表单',
464
+ highlight: '正在指示',
465
+ show_toast: '正在显示提示',
466
+ show_modal: '正在打开窗口',
467
+ show_card: '正在显示信息',
468
+ open_sidebar: '正在打开面板',
469
+ close_panels: '正在关闭面板',
470
+ send_email_ticket: '正在给团队发邮件',
471
+ escalate_to_human: '正在为你联系真人',
472
+ point_at: '正在指示',
473
+ tour: '导览',
474
+ go_home: '正在回到角落',
475
+ },
476
+ },
477
+ },
478
+
479
+ hi: {
480
+ widget: {
481
+ defaultName: 'सहायक',
482
+ launcher: { open: 'सहायक {name} खोलें' },
483
+ panel: { label: 'सहायक {name}' },
484
+ teaser: { dismiss: 'हटाएँ' },
485
+ status: { online: 'ऑनलाइन', thinking: 'सोच रहा है…', withTeam: 'टीम के साथ' },
486
+ typing: 'सहायक सोच रहा है',
487
+ voice: { on: 'आवाज़ चालू', off: 'आवाज़ बंद', mute: 'आवाज़ बंद करें', micDenied: 'माइक्रोफ़ोन की अनुमति नहीं मिली' },
488
+ menu: {
489
+ contact: 'टीम से संपर्क करें',
490
+ more: 'और विकल्प',
491
+ minimize: 'छोटा करें',
492
+ initiativeLabel: 'सहायक की पहल',
493
+ initiative: 'पहल',
494
+ level: { quiet: 'शांत', normal: 'सामान्य', bold: 'बेबाक' },
495
+ muteSuggestions: 'सुझाव बंद करें',
496
+ unmuteSuggestions: 'सुझाव चालू करें',
497
+ reset: 'नई बातचीत',
498
+ },
499
+ composer: {
500
+ placeholder: 'लिखें या माइक्रोफ़ोन दबाएँ…',
501
+ placeholderTeam: 'टीम को लिखें…',
502
+ label: 'संदेश',
503
+ mic: 'बोलें',
504
+ send: 'भेजें',
505
+ },
506
+ footer: { ai: 'AI सहायक · गलती कर सकता है' },
507
+ pageTools: { done: 'हो गया: {title}' },
508
+ handoff: {
509
+ team: 'सपोर्ट टीम',
510
+ author: 'टीम',
511
+ video: 'वीडियो कॉल',
512
+ back: 'सहायक पर वापस जाएँ',
513
+ userLeft: 'उपयोगकर्ता सहायक पर वापस चला गया',
514
+ ended: 'टीम के साथ बातचीत खत्म हो गई।',
515
+ closed: 'सपोर्ट चैनल बंद कर दिया गया।',
516
+ sendFailed: 'टीम को संदेश नहीं भेजा जा सका।',
517
+ },
518
+ brain: {
519
+ stuck: 'मैं बीच में अटक गया। क्या मैं किसी और तरीके से कोशिश करूँ?',
520
+ error: 'उफ़, जवाब देने में दिक्कत आई। फिर से कोशिश करें?',
521
+ },
522
+ pointer: {
523
+ stopped: 'रुक गया। जब तक आप न कहें, मैं और कुछ नहीं करूँगा।',
524
+ hint: 'रोकने के लिए Esc',
525
+ halted: 'रुका हुआ',
526
+ typing: 'लिख रहा है…',
527
+ },
528
+ companion: {
529
+ talkTo: '{name} से बात करें',
530
+ pointAt: 'दिखाएँ',
531
+ tour: 'टूर',
532
+ goHome: 'कोने में वापस',
533
+ },
534
+ dialog: {
535
+ close: 'बंद करें',
536
+ confirm: 'पुष्टि करें',
537
+ ok: 'ठीक है',
538
+ cancel: 'रद्द करें',
539
+ info: 'जानकारी',
540
+ gotIt: 'समझ गया',
541
+ },
542
+ confirm: {
543
+ title: 'कार्रवाई की पुष्टि करें',
544
+ yes: 'हाँ, जारी रखें',
545
+ runAction: 'क्या सहायक को "{action}" चलाने की अनुमति दें?',
546
+ mcp: 'सहायक आपके खाते में "{action}" चलाना चाहता है। जारी रखें?',
547
+ click: 'सहायक "{label}" पर क्लिक करना चाहता है। जारी रखें?',
548
+ typeSubmit: 'क्या मैं टेक्स्ट लिखकर फ़ॉर्म जमा कर दूँ?',
549
+ enterSubmit: 'सहायक "{label}" पर Enter दबाना चाहता है, जिससे फ़ॉर्म जमा हो जाएगा। जारी रखें?',
550
+ fillSubmit: 'क्या मैं भरी गई जानकारी के साथ फ़ॉर्म जमा कर दूँ?',
551
+ pageTool: 'सहायक "{title}" इस्तेमाल करना चाहता है। जारी रखें?',
552
+ pageToolWith: 'सहायक {detail} के साथ "{title}" इस्तेमाल करना चाहता है। जारी रखें?',
553
+ },
554
+ contact: {
555
+ human: 'किसी इंसान से बात करें',
556
+ mail: 'ईमेल से संदेश छोड़ें',
557
+ askHuman: 'मैं टीम के किसी व्यक्ति से बात करना चाहता हूँ।',
558
+ askMail: 'मैं टीम के लिए ईमेल से संदेश छोड़ना चाहता हूँ।',
559
+ mailPreview: 'यह संदेश सपोर्ट टीम को भेजा जाएगा:\n\nविषय: {subject}\nजवाब यहाँ: {to}\n\n{message}',
560
+ noEmail: '(ईमेल नहीं)',
561
+ ticket: 'टिकट {id}',
562
+ replyTo: 'हम {email} पर जवाब देंगे।',
563
+ humanConfirm: 'क्या मैं अभी आपको टीम के किसी व्यक्ति से जोड़ दूँ? उन्हें इस बातचीत का सारांश दिखेगा।',
564
+ connected: 'टीम से जुड़ गए। वे यहीं जवाब देंगे।',
565
+ handoffIntro: 'नमस्ते, मैं {name} हूँ। कारण: {reason}।\n\nसहायक का सारांश: {summary}\n\nपेज: {url}',
566
+ visitor: 'एक विज़िटर',
567
+ },
568
+ actions: {
569
+ get_page_context: 'पेज देख रहा है',
570
+ find_on_page: 'पेज पर खोज रहा है',
571
+ read_element: 'पढ़ रहा है',
572
+ navigate: 'नेविगेट कर रहा है',
573
+ scroll_to: 'स्क्रॉल कर रहा है',
574
+ click: 'क्लिक कर रहा है',
575
+ hover: 'माउस घुमा रहा है',
576
+ type_text: 'लिख रहा है',
577
+ press_key: 'कुंजियाँ दबा रहा है',
578
+ drag_and_drop: 'खींच रहा है',
579
+ scroll: 'स्क्रॉल कर रहा है',
580
+ fill_form: 'फ़ॉर्म भर रहा है',
581
+ highlight: 'दिखा रहा है',
582
+ show_toast: 'सूचना दिखा रहा है',
583
+ show_modal: 'विंडो खोल रहा है',
584
+ show_card: 'जानकारी दिखा रहा है',
585
+ open_sidebar: 'पैनल खोल रहा है',
586
+ close_panels: 'पैनल बंद कर रहा है',
587
+ send_email_ticket: 'टीम को ईमेल भेज रहा है',
588
+ escalate_to_human: 'आपको किसी इंसान से जोड़ रहा है',
589
+ point_at: 'दिखा रहा है',
590
+ tour: 'गाइडेड टूर',
591
+ go_home: 'कोने में वापस जा रहा है',
592
+ },
593
+ },
594
+ },
362
595
  });
@@ -31,6 +31,18 @@ const TEXT = {
31
31
  traits: ['curioso', 'paciente', 'brincalhão', 'organizado', 'dramático', 'otimista', 'distraído', 'leal', 'mandão', 'dorminhoco', 'guloso', 'corajoso'],
32
32
  tagline: (n) => `Oi, eu sou ${n}.`,
33
33
  },
34
+ zh: {
35
+ roles: ['家庭助手', '好奇的向导', '编程伙伴', '数字主持人', '不知疲倦的帮手', '网页探险家', '有主见的宠物', '终端瞭望员'],
36
+ tones: ['亲切又俏皮', '沉稳而清晰', '热情又直接', '爱调侃但友善', '可爱又好奇', '认真中带点火花'],
37
+ traits: ['好奇', '耐心', '爱开玩笑', '爱整洁', '戏精', '乐观', '迷糊', '忠诚', '爱指挥', '贪睡', '贪吃', '勇敢'],
38
+ tagline: (n) => `你好,我是${n}。`,
39
+ },
40
+ hi: {
41
+ roles: ['घर का सहायक', 'जिज्ञासु गाइड', 'कोडिंग साथी', 'डिजिटल मेज़बान', 'अथक मददगार', 'पेज खोजी', 'राय रखने वाला पालतू', 'टर्मिनल का पहरेदार'],
42
+ tones: ['अपनापन भरा और चंचल', 'शांत और साफ़', 'उत्साही और सीधा', 'चुटीला पर दयालु', 'प्यारा और जिज्ञासु', 'गंभीर पर चमकदार'],
43
+ traits: ['जिज्ञासु', 'धैर्यवान', 'नटखट', 'सलीकेदार', 'नाटकीय', 'आशावादी', 'भुलक्कड़', 'वफ़ादार', 'हुक्म चलाने वाला', 'नींद का मारा', 'पेटू', 'बहादुर'],
44
+ tagline: (n) => `नमस्ते, मैं ${n} हूँ।`,
45
+ },
34
46
  };
35
47
 
36
48
  /**
@@ -85,7 +97,7 @@ export function randomName(seed) {
85
97
  /**
86
98
  * Identidad completa y válida (pasa por defineIdentity).
87
99
  * @param {string} seed
88
- * @param {{ lang?: 'en'|'es'|'pt', name?: string }} [opts] el nombre puede fijarse; el resto sale de la semilla
100
+ * @param {{ lang?: 'en'|'es'|'pt'|'zh'|'hi', name?: string }} [opts] el nombre puede fijarse; el resto sale de la semilla
89
101
  */
90
102
  export function randomIdentity(seed, { lang = 'en', name } = {}) {
91
103
  const sd = cleanSeed(seed) || newSeed();
@@ -117,7 +129,7 @@ export function randomIdentity(seed, { lang = 'en', name } = {}) {
117
129
  },
118
130
  voice: {
119
131
  provider: 'auto',
120
- lang: { es: 'es-ES', en: 'en-US', pt: 'pt-BR' }[L],
132
+ lang: { es: 'es-ES', en: 'en-US', pt: 'pt-BR', zh: 'zh-CN', hi: 'hi-IN' }[L],
121
133
  rate: Math.round((0.95 + rnd() * 0.2) * 100) / 100,
122
134
  pitch: Math.round((female ? 1.05 + rnd() * 0.3 : 0.8 + rnd() * 0.25) * 100) / 100,
123
135
  },
@@ -25,7 +25,8 @@ import '../i18n/messages/identity.js';
25
25
  export const LOOK_KINDS = ['character', 'plush', 'image', 'realistic'];
26
26
  /** Tipos que ofrecen los editores. */
27
27
  export const LOOK_KINDS_OFFERED = ['character', 'plush', 'image'];
28
- export const LOOK_MATERIALS = ['plush', 'vinyl'];
28
+ /** Material del ot en 3D: peluche, vinilo (acabado y textura del spec) o uno fijo (MATERIAL3D de character3d/Character3D.js). */
29
+ export const LOOK_MATERIALS = ['plush', 'vinyl', 'clay', 'metal', 'glass', 'pearl', 'holo', 'wood', 'stone', 'knit', 'quilt', 'glitter', 'honeycomb', 'bubbles'];
29
30
  export const MEET_AVATARS = ['shibu', 'shino', 'fumiriya', 'victoria', 'vita', 'vivi', 'kuro', 'maya', 'ingrid', 'kenji', 'viktor', 'marcus', 'leo', 'mei', 'claire', 'doctor', 'amira'];
30
31
  export const MEET_SCENES = ['studio', 'beach', 'castle', 'space', 'sunset', 'forest', 'night', 'office', 'neon'];
31
32
  export const VOICE_PROVIDERS = ['auto', 'apuchat', 'elevenlabs', 'grok', 'fish', 'openai', 'browser'];
package/src/index.js CHANGED
@@ -79,13 +79,20 @@ export { createFace, IdentityCard };
79
79
  export {
80
80
  createCharacter, renderCharacter, normalizeCharacter, randomCharacter, applyPreset, DEFAULT_CHARACTER,
81
81
  CHARACTER_MOODS, CHARACTER_GESTURES, CHARACTER_MORPHS, CHARACTER_EFFECTS, CHARACTER_GESTURE_ALIAS, VISEMES, textToVisemes, SHAPES, EYES, BROWS, MOUTHS, CHEEKS, PATTERNS, FINISHES, ACCESSORIES, ACCESSORY_GROUPS, PRESETS, partLabel,
82
- resolveCharacter, normalizeMods, normalizeMod, sanitizeSvg, modName, MOD_ANCHORS, MAX_MODS,
82
+ resolveCharacter, normalizeMods, normalizeMod, sanitizeSvg, modName, MOD_ANCHORS, MOD_SLOTS, MOD_FACE, MAX_MODS,
83
83
  } from './character/Character.js';
84
- export { DANCES, DANCE_STYLE, DANCE_BPM } from './character/motion.js';
84
+ export { DANCES, DANCE_STYLE, DANCE_BPM, AURA_MOVES, AURA_STYLE, AURA_POINTS } from './character/motion.js';
85
85
  export { playBeat, BEAT_STYLES } from './character/beat.js';
86
86
  import { createAvatarEditor, AvatarEditor } from './character/AvatarEditor.js';
87
87
  import { renderCharacter as _renderCharacter, createCharacter as _createCharacter } from './character/Character.js';
88
88
  export { createAvatarEditor, AvatarEditor };
89
+ export { createStepCreator } from './creator/StepCreator.js';
90
+ import { loadCharacter3D as _loadCharacter3D } from './avatar/three.js';
91
+ /** La habitación 3D del ot (src/character3d/room.js), cargando three bajo demanda. */
92
+ export async function createOtRoom(el, spec, opts) {
93
+ const m = await _loadCharacter3D();
94
+ return m.createRoom3D(el, spec, opts);
95
+ }
89
96
 
90
97
  export { t, translator, addMessages, addCatalog, resolveLocale, detectLocale, getLocale, setLocale, onLocaleChange, availableLocales, formatNumber, formatList, LOCALES, LOCALE_NAMES, DEFAULT_LOCALE } from './i18n/index.js';
91
98
  import { t as _t, translator as _translator, addMessages as _addMessages, setLocale as _setLocale, getLocale as _getLocale, LOCALES as _LOCALES } from './i18n/index.js';
package/src/voice/tags.js CHANGED
@@ -9,6 +9,28 @@ export function stripSpeechTags(text) {
9
9
  return String(text ?? '').replace(WRAP, '').replace(INLINE, ' ').replace(/\s{2,}/g, ' ').trim();
10
10
  }
11
11
 
12
+ /** Markdown read aloud is noise ("hashtag hashtag", "guión guión guión"): headings, rules, bullets, emphasis, code and
13
+ * links become plain words. Speech tags are left alone. */
14
+ export function stripMarkdown(text) {
15
+ return String(text ?? '')
16
+ .replace(/```[\s\S]*?```/g, ' ')
17
+ .replace(/^\s{0,3}(?:[-*_]\s*){3,}$/gm, ' ')
18
+ .replace(/^\s{0,3}#{1,6}\s+/gm, '')
19
+ .replace(/^\s{0,3}>\s?/gm, '')
20
+ .replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm, '')
21
+ .replace(/!?\[([^\]]*)\]\([^)]*\)/g, '$1')
22
+ .replace(/`([^`]*)`/g, '$1')
23
+ .replace(/(\*\*|__)(.+?)\1/g, '$2')
24
+ .replace(/(^|[\s(])[*_]([^*_\n]+)[*_](?=[\s).,;:!?]|$)/g, '$1$2')
25
+ .replace(/\|/g, ', ')
26
+ .replace(/[ \t]*\n\s*/g, '\n')
27
+ .replace(/^\n+|\n+$/g, '')
28
+ .replace(/([^.!?:;,…\n])\n+/g, '$1. ') // a line or list item ends: a short pause
29
+ .replace(/\n+/g, ' ')
30
+ .replace(/[ \t]{2,}/g, ' ')
31
+ .trim();
32
+ }
33
+
12
34
  const EL_INLINE = { laugh: '[laughs]', cry: '[crying]', sigh: '[sighs]', breath: '[exhales]', pause: '…', 'long-pause': '… …', 'mouth-click': '' };
13
35
  const EL_WRAP = { whisper: '[whispers]', soft: '[softly]', loud: '[shouting]', slow: '[slowly]', fast: '[quickly]', singing: '[sings]' };
14
36
 
@@ -1,266 +0,0 @@
1
- /**
2
- * apuchat for the platform: an apuchat identity (@callsign) for each ot, made from the dashboard.
3
- *
4
- * Every 7ots account can hold two apuchat accounts (sealed in `integrations`, kind 'apuchat'):
5
- * managed an anonymous apuchat account the platform creates on first use (no sign-up): it owns the
6
- * identities made for the user's ots. Its session lasts 90 days; when it is refused, the
7
- * recovery token gets a new one (and if even that fails, a new anonymous account is made).
8
- * linked the user's own apuchat account, connected with apuchat's /link flow (app "7ots"): new
9
- * identities go there and the ot's identity can be claimed into it.
10
- *
11
- * Hub contract (APUCHAT_HUB, read once at boot; server to server only):
12
- * POST /api/account → { account_id, recovery_token, session_token }
13
- * POST /api/account/recover {recovery_token} → { session_token }
14
- * POST /api/account/identities Bearer session|apt_ → { callsign, identity_key, free_identity, … }
15
- * DELETE /api/account/identities/:callsign
16
- * GET /api/identities/mint/quote?callsign= Bearer → { valid, taken, reason, tier, tier_label, price_usd, … }
17
- * POST /api/identities/mint/checkout { callsign, return_url } → { checkout_id, url, price_usd, tier }
18
- * GET /api/identities/mint/checkout/:id → { status, callsign, upgraded, identity_key? }
19
- * POST /api/v1/link/exchange { code, app } → { account_id, identities, app_token (apt_, shown once), scopes, notice }
20
- * POST /api/account/identities/claim { identity_key } Bearer apt_ → { ok, callsign, moved, paid }
21
- * (409 *_not_transferable when it is paid/verified elsewhere)
22
- * apt_ errors: 401 invalid_app_token (the link is forgotten) · 403 insufficient_scope. Paying needs
23
- * Stripe on apuchat: 503 not_configured until then (we point to minting with USDC on apuchat instead).
24
- * return_url must be on 7ots.com (or localhost:8787 in development); apuchat appends ?apuchat_checkout=<id>&status=….
25
- * GET /api/dm/wait?timeout=1 X-Identity-Key → { callsign, … } (checks a pasted key)
26
- *
27
- * Free identities expire after 24 h without DM activity; the ot's channel long-polls /api/dm/wait,
28
- * which counts as activity, so they live while the ot is on.
29
- */
30
-
31
- import { i18nError } from '../i18n.mjs';
32
- import { getIntegration, setIntegration } from './store.mjs';
33
-
34
- const penv = process.env;
35
- const HUB = (penv.APUCHAT_HUB || 'https://apuchat.com').replace(/\/+$/, '');
36
- const SESSION_REFRESH_MS = 80 * 24 * 3600_000; // sessions last 90 days: renew a bit before
37
- export const CALLSIGN_RE = /^[a-z0-9][a-z0-9_-]{0,31}$/;
38
- const IDENTITIES_PER_DAY = () => Number(penv.PLATFORM_APUCHAT_IDENTITIES_PER_DAY || 5);
39
-
40
- export const apuchatHub = () => HUB;
41
-
42
- async function hub(method, path, { bearer, identityKey, body, timeoutMs = 15000 } = {}) {
43
- let res;
44
- try {
45
- res = await fetch(HUB + path, {
46
- method,
47
- headers: {
48
- Accept: 'application/json',
49
- ...(body ? { 'Content-Type': 'application/json' } : {}),
50
- ...(bearer ? { Authorization: `Bearer ${bearer}` } : {}),
51
- ...(identityKey ? { 'X-Identity-Key': identityKey } : {}),
52
- },
53
- body: body ? JSON.stringify(body) : undefined,
54
- redirect: 'manual',
55
- signal: AbortSignal.timeout(timeoutMs),
56
- });
57
- } catch {
58
- throw i18nError(424, 'platform.apuchat.unreachable');
59
- }
60
- let data = null;
61
- try {
62
- data = await res.json();
63
- } catch {}
64
- return { ok: res.ok, status: res.status, data: data || {} };
65
- }
66
-
67
- /** Upstream error → our error (the hub's own text is never shown; its code helps a few cases). */
68
- function hubError(r) {
69
- const code = String(r.data.code || r.data.error || '');
70
- if (r.status === 503 && /not_configured/.test(code)) return i18nError(501, 'platform.apuchat.paymentsOff', { url: `${HUB}/account/mint` });
71
- if (r.status === 429) return i18nError(429, 'platform.apuchat.hubBusy');
72
- if (r.status === 403 && /insufficient_scope/.test(code)) return i18nError(403, 'platform.apuchat.insufficientScope');
73
- if (r.status === 409 && /not_transferable/.test(code)) return i18nError(409, 'platform.apuchat.notTransferable');
74
- if (r.status === 409) return i18nError(409, 'platform.apuchat.taken');
75
- return i18nError(424, 'platform.apuchat.failed', { status: r.status });
76
- }
77
-
78
- // ───────────────────────────── account state ─────────────────────────────
79
-
80
- const state = (accountId) => getIntegration(accountId, 'apuchat') || {};
81
- const saveState = (accountId, s) => setIntegration(accountId, 'apuchat', s.managed || s.linked || s.checkouts?.length ? s : null);
82
- const locks = new Map(); // accountId → Promise (one session refresh / account creation at a time)
83
-
84
- function locked(accountId, fn) {
85
- const prev = locks.get(accountId) || Promise.resolve();
86
- const run = prev.catch(() => {}).then(fn);
87
- const tail = run.catch(() => {});
88
- locks.set(accountId, tail);
89
- tail.then(() => locks.get(accountId) === tail && locks.delete(accountId));
90
- return run;
91
- }
92
-
93
- /** Public view for the dashboard (never tokens). */
94
- export function apuchatAccountView(accountId) {
95
- const s = state(accountId);
96
- return { managed: !!s.managed, linked: s.linked ? { accountId: s.linked.account_id || '', canClaim: can(s.linked, 'identities:write') } : null };
97
- }
98
-
99
- /** Whether the app token of the link was granted a scope (older links without a scope list: assume yes). */
100
- const can = (linked, scope) => !!linked?.app_token && (!Array.isArray(linked.scopes) || linked.scopes.includes(scope));
101
-
102
- async function createManaged(accountId) {
103
- const r = await hub('POST', '/api/account', { body: {} });
104
- if (!r.ok || !r.data.session_token || !r.data.recovery_token) throw hubError(r);
105
- const s = state(accountId);
106
- s.managed = { account_id: r.data.account_id, recovery_token: r.data.recovery_token, session_token: r.data.session_token, at: Date.now() };
107
- saveState(accountId, s);
108
- return s.managed.session_token;
109
- }
110
-
111
- /** Gets a fresh session with the recovery token; if apuchat no longer knows it, starts a new anonymous account. */
112
- async function recoverManaged(accountId) {
113
- const s = state(accountId);
114
- if (!s.managed?.recovery_token) return createManaged(accountId);
115
- const r = await hub('POST', '/api/account/recover', { body: { recovery_token: s.managed.recovery_token } });
116
- if (r.ok && r.data.session_token) {
117
- s.managed = { ...s.managed, session_token: r.data.session_token, at: Date.now() };
118
- saveState(accountId, s);
119
- return s.managed.session_token;
120
- }
121
- if (r.status === 401 || r.status === 403 || r.status === 404) {
122
- console.warn('[7ots] apuchat: recovery refused, new anonymous account for', accountId);
123
- return createManaged(accountId);
124
- }
125
- throw hubError(r);
126
- }
127
-
128
- /** Session of the managed account (made on first use, renewed when old). */
129
- function managedSession(accountId, { create = true } = {}) {
130
- return locked(accountId, async () => {
131
- const m = state(accountId).managed;
132
- if (!m) {
133
- if (!create) return null;
134
- return createManaged(accountId);
135
- }
136
- if (Date.now() - (m.at || 0) > SESSION_REFRESH_MS) return recoverManaged(accountId);
137
- return m.session_token;
138
- });
139
- }
140
-
141
- /**
142
- * A call as one of the account's apuchat accounts. 'managed' renews its session once on 401;
143
- * 'linked' uses the app token (a 401 means the user revoked it: the link is forgotten).
144
- */
145
- async function as(accountId, owner, method, path, o = {}) {
146
- if (owner === 'linked') {
147
- const l = state(accountId).linked;
148
- if (!l?.app_token) throw i18nError(409, 'platform.apuchat.notLinked');
149
- const r = await hub(method, path, { ...o, bearer: l.app_token });
150
- if (r.status === 401) {
151
- const s = state(accountId);
152
- delete s.linked;
153
- saveState(accountId, s);
154
- throw i18nError(409, 'platform.apuchat.linkExpired');
155
- }
156
- return r;
157
- }
158
- let token = await managedSession(accountId);
159
- let r = await hub(method, path, { ...o, bearer: token });
160
- if (r.status === 401) {
161
- token = await locked(accountId, () => recoverManaged(accountId));
162
- r = await hub(method, path, { ...o, bearer: token });
163
- }
164
- return r;
165
- }
166
-
167
- /** Which apuchat account new identities go to: the user's own when linked with a token, else the managed one. */
168
- export const defaultOwner = (accountId, scope = 'identities:write') => (can(state(accountId).linked, scope) ? 'linked' : 'managed');
169
-
170
- // ───────────────────────────── identities ─────────────────────────────
171
-
172
- const madeToday = new Map(); // accountId → timestamps (free identities made in the last day)
173
-
174
- /** A new free identity. Limited per account and day (each one is a handle taken on apuchat). */
175
- export async function createFreeIdentity(accountId) {
176
- const now = Date.now();
177
- const recent = (madeToday.get(accountId) || []).filter((t) => now - t < 86400_000);
178
- if (recent.length >= IDENTITIES_PER_DAY()) throw i18nError(429, 'platform.apuchat.tooManyIdentities', { max: IDENTITIES_PER_DAY() });
179
- const owner = defaultOwner(accountId);
180
- const r = await as(accountId, owner, 'POST', '/api/account/identities', { body: {} });
181
- if (!r.ok || !r.data.identity_key || !r.data.callsign) throw hubError(r);
182
- recent.push(now);
183
- madeToday.set(accountId, recent);
184
- if (madeToday.size > 5000) madeToday.clear();
185
- return { callsign: String(r.data.callsign).toLowerCase(), identityKey: r.data.identity_key, free: r.data.free_identity !== false, owner };
186
- }
187
-
188
- /** Deletes an identity on apuchat (only the free ones the platform made; best effort). */
189
- export async function deleteIdentity(accountId, owner, callsign) {
190
- if (!CALLSIGN_RE.test(callsign || '') || (owner !== 'managed' && owner !== 'linked')) return false;
191
- const r = await as(accountId, owner, 'DELETE', `/api/account/identities/${encodeURIComponent(callsign)}`).catch(() => null);
192
- return !!r?.ok;
193
- }
194
-
195
- /** The @callsign of an identity key, or null if apuchat does not accept it. */
196
- export async function callsignOf(identityKey) {
197
- const r = await hub('GET', '/api/dm/wait?timeout=1', { identityKey, timeoutMs: 20000 });
198
- if (r.status === 401 || r.status === 403 || r.status === 404) return null;
199
- if (!r.ok) throw hubError(r);
200
- return r.data.callsign ? String(r.data.callsign).toLowerCase() : null;
201
- }
202
-
203
- // ───────────────────────────── permanent handle (paid) ─────────────────────────────
204
-
205
- export async function quote(accountId, owner, callsign) {
206
- const r = await as(accountId, owner, 'GET', `/api/identities/mint/quote?callsign=${encodeURIComponent(callsign)}`);
207
- if (!r.ok) throw hubError(r);
208
- const q = r.data;
209
- return { callsign, valid: !!q.valid, taken: !!q.taken, reason: q.reason || null, tier: q.tier || null, tierLabel: q.tier_label || null, priceUsd: q.price_usd ?? null };
210
- }
211
-
212
- /** Starts a card checkout; the checkout is remembered so only this ot can read its result. */
213
- export async function checkout(accountId, owner, { otsId, callsign, returnUrl }) {
214
- const r = await as(accountId, owner, 'POST', '/api/identities/mint/checkout', { body: { callsign, return_url: returnUrl } });
215
- if (!r.ok || !r.data.checkout_id || !r.data.url) throw hubError(r);
216
- const s = state(accountId);
217
- s.checkouts = [{ id: String(r.data.checkout_id), otsId, callsign, owner, at: Date.now() }, ...(s.checkouts || []).filter((c) => Date.now() - c.at < 7 * 86400_000)].slice(0, 20);
218
- saveState(accountId, s);
219
- return { checkoutId: String(r.data.checkout_id), url: String(r.data.url), priceUsd: r.data.price_usd ?? null, tier: r.data.tier || null };
220
- }
221
-
222
- export const pendingCheckouts = (accountId, otsId) => (state(accountId).checkouts || []).filter((c) => c.otsId === otsId).map(({ id, callsign, at }) => ({ id, callsign, at }));
223
-
224
- /** Status of a checkout started for this ot (null if it isn't one of its own). Fulfilled/failed ones are forgotten. */
225
- export async function checkoutStatus(accountId, otsId, id) {
226
- const c = (state(accountId).checkouts || []).find((x) => x.id === String(id) && x.otsId === otsId);
227
- if (!c) return null;
228
- const r = await as(accountId, c.owner, 'GET', `/api/identities/mint/checkout/${encodeURIComponent(c.id)}`);
229
- if (!r.ok) throw hubError(r);
230
- const status = ['pending', 'fulfilled', 'failed'].includes(r.data.status) ? r.data.status : 'pending';
231
- if (status !== 'pending') {
232
- const s = state(accountId);
233
- s.checkouts = (s.checkouts || []).filter((x) => x.id !== c.id);
234
- saveState(accountId, s);
235
- }
236
- return { status, callsign: String(r.data.callsign || c.callsign).toLowerCase(), upgraded: !!r.data.upgraded, identityKey: r.data.identity_key || null, owner: c.owner };
237
- }
238
-
239
- // ───────────────────────────── linking the user's apuchat account ─────────────────────────────
240
-
241
- /** Where to send the browser to link (apuchat appends `code`; it doesn't echo `state`, so it rides in the return URL). */
242
- export const linkUrl = (returnUrl) => `${HUB}/link?${new URLSearchParams({ app: '7ots', return: returnUrl })}`;
243
-
244
- export async function exchangeLink(accountId, code) {
245
- const r = await hub('POST', '/api/v1/link/exchange', { body: { code, app: '7ots' } });
246
- if (!r.ok || !r.data.account_id) throw hubError(r);
247
- const s = state(accountId);
248
- const scopes = Array.isArray(r.data.scopes) ? r.data.scopes.map(String) : typeof r.data.scopes === 'string' ? r.data.scopes.split(/[\s,]+/).filter(Boolean) : null;
249
- // The app token is shown once: it lives only sealed in the database and is never logged.
250
- s.linked = { account_id: String(r.data.account_id), app_token: r.data.app_token || '', scopes, at: Date.now() };
251
- saveState(accountId, s);
252
- return { accountId: s.linked.account_id, canClaim: can(s.linked, 'identities:write') };
253
- }
254
-
255
- export function unlink(accountId) {
256
- const s = state(accountId);
257
- delete s.linked;
258
- saveState(accountId, s);
259
- }
260
-
261
- /** Moves an identity (by its key) into the linked account. */
262
- export async function claimIdentity(accountId, identityKey) {
263
- const r = await as(accountId, 'linked', 'POST', '/api/account/identities/claim', { body: { identity_key: identityKey } });
264
- if (!r.ok) throw hubError(r);
265
- return { callsign: r.data.callsign ? String(r.data.callsign).toLowerCase() : null, moved: r.data.moved !== false, paid: !!r.data.paid };
266
- }