@7ots/cli 0.1.19 → 0.1.37

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 (104) hide show
  1. package/.env.example +14 -0
  2. package/brand/logos/base.svg +1 -0
  3. package/brand/logos/clawpump.png +0 -0
  4. package/brand/logos/conductors.svg +1 -0
  5. package/brand/logos/notlogin.svg +12 -0
  6. package/brand/logos/pumpfun.png +0 -0
  7. package/brand/logos/solana.png +0 -0
  8. package/brand/logos/spawnerbot.svg +1 -0
  9. package/brand/logos/virtuals.png +0 -0
  10. package/cli/7ots.mjs +59 -1
  11. package/cli/lib/account.mjs +23 -3
  12. package/cli/lib/assistant.mjs +88 -13
  13. package/cli/lib/brain.mjs +76 -8
  14. package/cli/lib/config.mjs +14 -3
  15. package/cli/lib/desktop-sync.mjs +177 -0
  16. package/cli/lib/i18n.mjs +9 -0
  17. package/cli/lib/inferences.mjs +19 -2
  18. package/cli/lib/integrations.mjs +61 -6
  19. package/cli/lib/pet-server.mjs +316 -41
  20. package/cli/lib/prompts.mjs +1 -1
  21. package/cli/lib/senses/gestures.mjs +121 -0
  22. package/cli/lib/senses/index.mjs +490 -0
  23. package/cli/lib/senses/rules.mjs +159 -0
  24. package/cli/lib/senses/sources/activity.mjs +95 -0
  25. package/cli/lib/senses/sources/calendar.mjs +75 -0
  26. package/cli/lib/senses/sources/index.mjs +17 -0
  27. package/cli/lib/senses/sources/mail.mjs +48 -0
  28. package/cli/lib/senses/sources/system.mjs +39 -0
  29. package/cli/lib/senses/util.mjs +41 -0
  30. package/cli/lib/senses/vendor.mjs +78 -0
  31. package/cli/lib/stt-local.py +16 -8
  32. package/cli/lib/stt.mjs +53 -6
  33. package/cli/lib/tooluse.mjs +56 -0
  34. package/cli/lib/vm.mjs +1 -1
  35. package/cli/lib/wake-local.py +109 -0
  36. package/cli/lib/wake.mjs +102 -0
  37. package/cli/pet/electron/main.cjs +145 -16
  38. package/cli/pet/pet.html +127 -27
  39. package/cli/pet/senses.html +342 -0
  40. package/cli/pet/settings.html +787 -86
  41. package/dist/7ots.esm.js +374 -146
  42. package/dist/7ots.esm.js.map +4 -4
  43. package/dist/7ots.iife.js +374 -146
  44. package/dist/7ots.iife.js.map +4 -4
  45. package/llms.txt +27 -0
  46. package/package.json +5 -2
  47. package/server/channels/apuchat.mjs +2 -0
  48. package/server/errors.mjs +90 -0
  49. package/server/notify.mjs +78 -0
  50. package/server/server.mjs +68 -12
  51. package/server/settings.mjs +3 -0
  52. package/server/site.mjs +401 -0
  53. package/server/tts.mjs +29 -5
  54. package/src/avatar/AvatarStage.js +2 -2
  55. package/src/avatar/three.js +3 -2
  56. package/src/character/AvatarEditor.js +2 -1
  57. package/src/character/Character.js +1 -1
  58. package/src/character/TradingCard.js +2 -0
  59. package/src/character/beat.js +64 -2
  60. package/src/character/mods/orc.js +8 -1
  61. package/src/character/mods.js +104 -10
  62. package/src/character/motion.js +162 -0
  63. package/src/character/parts.js +40 -38
  64. package/src/character/styles.js +40 -38
  65. package/src/character3d/Character3D.js +26 -5
  66. package/src/character3d/body.js +14 -12
  67. package/src/character3d/export.js +693 -0
  68. package/src/character3d/fx.js +13 -0
  69. package/src/character3d/index.js +2 -0
  70. package/src/character3d/materials.js +106 -10
  71. package/src/character3d/room-themes.js +1184 -0
  72. package/src/character3d/room.js +487 -0
  73. package/src/character3d/stage.js +9 -3
  74. package/src/creator/StepCreator.js +316 -0
  75. package/src/i18n/index.js +3 -3
  76. package/src/i18n/messages/character.js +352 -4
  77. package/src/i18n/messages/creator.js +138 -0
  78. package/src/i18n/messages/identity.js +89 -1
  79. package/src/i18n/messages/platform.js +255 -1
  80. package/src/i18n/messages/server.js +443 -1
  81. package/src/i18n/messages/widget.js +233 -0
  82. package/src/identity/random.js +14 -2
  83. package/src/identity/schema.js +2 -1
  84. package/src/index.js +10 -2
  85. package/src/voice/tags.js +22 -0
  86. package/server/platform/apuchat.mjs +0 -266
  87. package/server/platform/auth.mjs +0 -337
  88. package/server/platform/byte.mjs +0 -291
  89. package/server/platform/connect.mjs +0 -391
  90. package/server/platform/crypto.mjs +0 -80
  91. package/server/platform/db.mjs +0 -293
  92. package/server/platform/device.mjs +0 -247
  93. package/server/platform/integrations.mjs +0 -169
  94. package/server/platform/look.mjs +0 -20
  95. package/server/platform/mods.mjs +0 -222
  96. package/server/platform/orquesta.mjs +0 -611
  97. package/server/platform/profile.mjs +0 -182
  98. package/server/platform/routes.mjs +0 -589
  99. package/server/platform/runtime.mjs +0 -286
  100. package/server/platform/sites.mjs +0 -146
  101. package/server/platform/stage3d.mjs +0 -82
  102. package/server/platform/store.mjs +0 -469
  103. package/server/platform/vm.mjs +0 -1057
  104. package/server/platform/wallet.mjs +0 -255
@@ -21,7 +21,7 @@
21
21
  * POST /watchers/cancel { id | 'all' }
22
22
  * GET /cloud 7ots.com link + the cloud assistant's VM status (integrations.mjs)
23
23
  * POST /integrations/test { integration } → { ok, tools? (MCP), text?, error? } (a draft, not saved)
24
- * GET /byte · /byte/games · /byte/status · POST /byte/play { game } · /byte/stop the twin ot plays byte arena (7ots.com)
24
+ * GET /byte · /byte/games · /byte/status · POST /byte/play { game } · /byte/stop · /byte/connect the twin ot plays byte arena (7ots.com)
25
25
  * GET /wallet the twin ot's wallet on 7ots.com (read only): addresses, balances, payments + tx links
26
26
  * GET /orquesta/projects · POST /orquesta/send { projectId, text } · GET /orquesta/prompt?id= your Orquesta agents
27
27
  * POST /character/letta write the character sheet into a Letta agent's persona (LETTA_API_KEY)
@@ -32,9 +32,18 @@
32
32
  * POST /notes/forget { at | 'all' }
33
33
  * POST /conversation/forget drop the conversation memory (turns + summary)
34
34
  * POST /quit X-7ots-Token
35
+ * POST /aura X-7ots-Token { name?, music? } → farmea aura (AURA_MOVES): suma al contador de ~/.7ots/aura.json → { name, points, total }
35
36
  * POST /dance X-7ots-Token { name?, ms?, music? } → dances (DANCES in motion.js) with music (beat.js or ~/.7ots/music)
36
37
  * POST /entrance X-7ots-Token { dance? } → a wrestling-style entrance: walks in, spotlights, pyro, its name, a dance
37
38
  * GET /music?token=… { files } your own tracks in ~/.7ots/music · GET /music/<file>?token=… plays one
39
+ * GET /senses?token=…[&preview=1] the camera page (face + gestures → labels; the desktop shell runs it hidden)
40
+ * GET /senses/status · /senses/config what it notices now, rules, gestures, today · what the camera page needs
41
+ * GET /senses/vendor/<file> MediaPipe code and models (no token; downloaded by POST /senses/vendor)
42
+ * POST /senses { events: [{ kind: state|presence|gesture|status, … }] } from the camera page
43
+ * POST /senses/rules { action: add|set|remove|accept|reject|on|off, id?, rule? } · /senses/gestures { map, commands }
44
+ * POST /senses/baseline { baseline|null } · /senses/pause { min | resume } · /senses/forget · /senses/reflect
45
+ * POST /senses/snap { id, image } one camera frame the daemon asked for ({senses:{snap:id}} on /events) when you
46
+ * ask it to look at you; seen by the vision brain, shown as a thumbnail, never stored
38
47
  *
39
48
  * Only listens on 127.0.0.1 and only answers to Host 127.0.0.1/localhost (no DNS rebinding).
40
49
  * The token lives in ~/.7ots/pet.token (0600): other users of the machine can't drive the pet.
@@ -42,7 +51,7 @@
42
51
 
43
52
  import { createServer } from 'node:http';
44
53
  import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
45
- import { readFileSync, existsSync, writeFileSync, chmodSync, mkdirSync, symlinkSync, readdirSync, statSync, createReadStream } from 'node:fs';
54
+ import { readFileSync, existsSync, writeFileSync, chmodSync, mkdirSync, rmSync, symlinkSync, readdirSync, statSync, createReadStream } from 'node:fs';
46
55
  import { cardShot } from './card-shot.mjs';
47
56
  import { join } from 'node:path';
48
57
  import { createAssistant, notify, tr } from './assistant.mjs';
@@ -54,22 +63,26 @@ import { AI_CLIS, createBrain, detectClis, petSystem } from './brain.mjs';
54
63
  import { CONFIG_DEFAULTS, env, loadConfig, saveConfig, saveKey } from './config.mjs';
55
64
  import { loadIdentity } from './identity.mjs';
56
65
  import { readJson, writeJson } from './paths.mjs';
57
- import { sttProvider, transcribe } from './stt.mjs';
66
+ import { sttProvider, transcribe, warmStt } from './stt.mjs';
67
+ import { createWake } from './wake.mjs';
58
68
  import { localVoices, synthesizeLocal, warmLocal } from './tts-local.mjs';
59
69
  import { createScreenWatcher } from './screen.mjs';
60
70
  import { createSiteContext } from './prowl.mjs';
61
- import { SEVENOTS_URL, community, sync as syncOt, logout as accountLogout, me as accountMe, pull as pullOt, signedIn, startLogin, use as useOt } from './account.mjs';
71
+ import { createSenses } from './senses/index.mjs';
72
+ import { ensureVendor, vendorFile, vendorStatus } from './senses/vendor.mjs';
73
+ import { SEVENOTS_URL, cloudSpeak, community, sync as syncOt, logout as accountLogout, me as accountMe, pull as pullOt, signedIn, startLogin, use as useOt } from './account.mjs';
62
74
  import { openUrl } from './open.mjs';
75
+ import { syncDesktop } from './desktop-sync.mjs';
63
76
  import { VM_KINDS } from './vm.mjs';
64
- import { cloudByte, cloudStatus, cloudWallet, createExtras, lettaSync, normalizeCharacter, normalizeIntegrations, redact, testCustom } from './integrations.mjs';
77
+ import { cloudByte, cloudPlaza, cloudStatus, cloudWallet, createExtras, lettaSync, normalizeCharacter, normalizeIntegrations, redact, testCustom } from './integrations.mjs';
65
78
  import { spawn } from 'node:child_process';
66
79
  import { openSync } from 'node:fs';
67
80
  import { line } from './lines.mjs';
68
81
  import { defineIdentity, GROK_VOICES, OPENAI_VOICES, TTS_MODELS } from '../../src/identity/schema.js';
69
82
  import { normalizeMod, normalizeMods, MAX_MODS } from '../../src/character/mods.js';
70
83
  import { MOD_CATALOG } from '../../src/character/mods/index.js';
71
- import { DANCES } from '../../src/character/motion.js';
72
- import { stripSpeechTags } from '../../src/voice/tags.js';
84
+ import { DANCES, AURA_MOVES, AURA_STYLE, AURA_POINTS } from '../../src/character/motion.js';
85
+ import { stripMarkdown, stripSpeechTags } from '../../src/voice/tags.js';
73
86
 
74
87
  /** Mods importados en este pet (~/.7ots/mods/library.json), normalizados. */
75
88
  // scenes between ots on the same desktop (pet/electron/director.cjs plays them)
@@ -87,6 +100,14 @@ function musicFiles() {
87
100
  return [];
88
101
  }
89
102
  }
103
+ /** Tus temas para farmear aura: ~/.7ots/music/aura/*, como «aura/<archivo>». */
104
+ function auraFiles() {
105
+ try {
106
+ return readdirSync(homeFile('music/aura')).filter((f) => MUSIC_FILE.test(f) && !f.startsWith('.') && statSync(homeFile(`music/aura/${f}`)).isFile()).sort().map((f) => `aura/${f}`);
107
+ } catch {
108
+ return [];
109
+ }
110
+ }
90
111
  const modLibrary = () => (readJson(homeFile('mods/library.json')) || []).map(normalizeMod).filter(Boolean);
91
112
  import { ensureHome, homeFile, PET_PORT, PKG_ROOT } from './paths.mjs';
92
113
  import { applyEvent, loadPet, need, savePet, tick, view } from './pet-core.mjs';
@@ -130,7 +151,7 @@ export async function postPet(path, body, port = PET_PORT) {
130
151
  }
131
152
 
132
153
  const VOICE_PROVIDERS = ['elevenlabs', 'openai', 'apuchat', 'grok', 'fish'];
133
- const SETTABLE_KEYS = ['ANTHROPIC_API_KEY', 'OPENAI_API_KEY', 'ORQUESTA_TOKEN', 'ELEVENLABS_API_KEY', 'APUCHAT_VOICE_TOKEN', 'XAI_API_KEY', 'FISH_API_KEY', 'LETTA_API_KEY', 'APUMAIL_TOKEN'];
154
+ const SETTABLE_KEYS = ['ANTHROPIC_API_KEY', 'OPENAI_API_KEY', 'ORQUESTA_TOKEN', 'ELEVENLABS_API_KEY', 'APUCHAT_VOICE_TOKEN', 'XAI_API_KEY', 'FISH_API_KEY', 'LETTA_API_KEY', 'APUMAIL_TOKEN', 'SENSES_ICS_URL'];
134
155
  // The settings page speaks the human's language: SEVENOTS_LANG, config.lang, the system's, then the ot's.
135
156
  const uiLangOf = (c, fallback) => [process.env.SEVENOTS_LANG, c.lang, String(process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || '').slice(0, 2).toLowerCase(), fallback].find((l) => ['en', 'es', 'pt'].includes(l)) || 'en';
136
157
  const brainLabel = (b = {}) => (b.kind === 'cli' ? `${b.cli}${b.model ? ` · ${b.model}` : ''}` : b.kind === 'api' ? `${b.provider || 'api'}${b.model ? ` · ${b.model}` : ''}` : b.kind || 'lines');
@@ -173,7 +194,23 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
173
194
  };
174
195
  let brainImpl = createBrain(config.brain, config.home); // swapped live from the settings page
175
196
  const inferences = createInferenceLog();
197
+ /**
198
+ * Text → audio with a provider. apuchat without a token of its own: through the ot on 7ots.com when this computer is
199
+ * signed in (apuchat has no per-account voice tokens; that was the 401 testers hit pasting other keys).
200
+ */
201
+ const voiceAudio = async (kind, text, voice) => {
202
+ const keys = env();
203
+ if (kind === 'apuchat' && !keys.APUCHAT_VOICE_TOKEN && keys.SEVENOTS_TOKEN && config.account?.otsId) {
204
+ return cloudSpeak(config.account.otsId, { text: stripSpeechTags(text), voiceId: voice.voiceId || '', lang: voice.lang || '' });
205
+ }
206
+ const { synthesize } = await import('../../server/tts.mjs');
207
+ // process.env too: XAI_TTS_VOICE, FISH_VOICE_ID, APUCHAT_VOICE_URL… (the keys still come from env())
208
+ return synthesize({ text, voice, env: { ...process.env, ...keys } });
209
+ };
176
210
  if (config.voice.kind === 'local') warmLocal();
211
+ // "oye <name>" opens the pet page's mic (wake.mjs); in your language, not the ot's. Only the host ot listens.
212
+ const wake = createWake({ log, onWake: () => broadcast({ wake: true }), onState: (w) => broadcast({ wakeState: w }) });
213
+ const wakeConf = () => wake.set({ on: !!config.voice.wake && !process.env.SEVENOTS_COMPANION && sttProvider(env()) !== null, name: identity.name, lang: uiLangOf(config, lang) });
177
214
  const brain = inferences.wrap(() => brainImpl, () => brainLabel(config.brain)); // every call lands in the history
178
215
  const pet = tick(loadPet());
179
216
  const clients = new Set();
@@ -213,10 +250,12 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
213
250
  }
214
251
  // Orquesta sign-in in the browser; once in, its integration is on
215
252
  let connecting = null;
216
- function connectOrquesta() {
253
+ let orquestaLoginAt = 0; // the settings page waits for it to change after "Sign in with Orquesta"
254
+ // local: the token is wanted on this computer (Batuta as the brain), even when 7ots.com could hold it
255
+ function connectOrquesta({ local = false } = {}) {
217
256
  return (connecting ||= import('./orquesta.mjs')
218
257
  .then(async (o) => {
219
- if (o.via() !== '7ots') return o.login({ open: openUrl });
258
+ if (local || o.via() !== '7ots') return o.login({ open: openUrl });
220
259
  // signed in to 7ots.com: connect it there (once for the ot everywhere); its token stays there
221
260
  openUrl(`${SEVENOTS_URL}/app/#ots/${config.account.otsId}/orquesta`);
222
261
  for (const end = Date.now() + 10 * 60_000; Date.now() < end; ) {
@@ -230,6 +269,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
230
269
  next.integrations = { ...next.integrations, orquesta: { ...next.integrations?.orquesta, on: true } };
231
270
  saveConfig(next);
232
271
  config = loadConfig();
272
+ orquestaLoginAt = Date.now();
233
273
  log(`orquesta: connected${r.organizationName ? ` (${r.organizationName})` : ''}`);
234
274
  broadcast({ orquesta: true });
235
275
  return r;
@@ -239,7 +279,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
239
279
 
240
280
  async function speak(kind, vars = {}, situation = '', { force = false, gesture = null } = {}) {
241
281
  const now = Date.now();
242
- const quiet = now < chatUntil || (kind === 'hello' && now - lastHello < HELLO_GAP) || (force ? now - lastSpoke < IMPORTANT_GAP[annoy] : pet.asleep || now - lastSpoke < GAP[annoy]);
282
+ const quiet = now < chatUntil || (!force && senses?.quiet()) || (kind === 'hello' && now - lastHello < HELLO_GAP) || (force ? now - lastSpoke < IMPORTANT_GAP[annoy] : pet.asleep || now - lastSpoke < GAP[annoy]);
243
283
  if (quiet) {
244
284
  broadcast({ gesture });
245
285
  return;
@@ -346,7 +386,8 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
346
386
  broadcast({});
347
387
  }, 60_000);
348
388
 
349
- // Sync with its ot on 7ots.com (account.mjs sync): same look, mods, personality and sheet on both sides.
389
+ // Sync with its ot on 7ots.com (account.mjs sync): same look, mods, personality and sheet on both sides,
390
+ // and (desktop-sync.mjs) its settings, tamagotchi progress, notes, reminders and watchers.
350
391
  let syncing = false;
351
392
  let syncSoon = null;
352
393
  let syncErr = '';
@@ -355,9 +396,15 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
355
396
  syncing = true;
356
397
  try {
357
398
  const r = await syncOt();
399
+ // the rest of what this pet keeps (settings, progress, notes, reminders, watchers): desktop-sync.mjs
400
+ const d = await syncDesktop({ pet });
358
401
  syncErr = '';
359
402
  if (r.action === 'push' || r.action === 'pull') log(`sync: ${r.action} 7ots.com`);
360
- if (r.action === 'pull') restart(); // its new look/personality, everywhere
403
+ if (d.action === 'push' || d.action === 'pull') log(`sync: desktop ${d.action} 7ots.com${d.wrote?.length ? ` (${d.wrote.join(', ')})` : ''}`);
404
+ if (d.wrote?.includes('progress')) savePet(pet);
405
+ // its new look/personality, settings or lists, everywhere (progress alone is already live)
406
+ if (r.action === 'pull' || d.wrote?.some((k) => k !== 'progress')) restart();
407
+ else if (d.wrote?.length) broadcast({});
361
408
  } catch (e) {
362
409
  if (e.message !== syncErr) log(`sync: ${(syncErr = e.message)}`);
363
410
  } finally {
@@ -393,6 +440,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
393
440
  system: (said) => petSystem(identity, { lang: said || 'auto', role: 'assistant' }),
394
441
  // offload to the ot's cloud worker (access.vm): needs this computer signed in to 7ots.com
395
442
  cloud: () => (env().SEVENOTS_TOKEN && config.account?.otsId) || null,
443
+ context: () => senses.prompt(),
396
444
  say: (text) => {
397
445
  lastSpoke = Date.now();
398
446
  pet.lastTalk = lastSpoke;
@@ -445,6 +493,110 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
445
493
  },
446
494
  });
447
495
 
496
+ // Senses (senses/): camera (face + gestures, from the hidden /senses page), activity, the computer, email,
497
+ // calendar → rules and gesture commands, and a reflector that now and then proposes something.
498
+ async function senseTalk({ text = '', about = '', exact = false, kind = 'senses', important = false, gesture = 'wave' }) {
499
+ const now = Date.now();
500
+ if (now < chatUntil || thinking || asks.size || (pet.asleep && !important)) return false;
501
+ if (now - lastSpoke < (important ? IMPORTANT_GAP : GAP)[annoy]) return false;
502
+ let say = exact ? text : '';
503
+ if (!say && about && brain.kind !== 'lines') {
504
+ thinking = true;
505
+ try {
506
+ say = await brain.think({
507
+ purpose: kind,
508
+ system: petSystem(identity, { lang }),
509
+ messages: [{ role: 'user', content: `${about}\nOne short line to them, in character.${history.length ? `\n(Things you already said: ${history.join(' | ')})` : ''}` }],
510
+ timeoutMs: 30000,
511
+ });
512
+ } catch (e) {
513
+ log(`brain: ${e.message}`);
514
+ }
515
+ thinking = false;
516
+ }
517
+ say = String(say || text || '').trim();
518
+ if (!say || Date.now() < chatUntil) return false;
519
+ lastSpoke = Date.now();
520
+ pet.lastTalk = lastSpoke;
521
+ history.push(say);
522
+ if (history.length > 6) history.shift();
523
+ if (important && config.access.notify !== false) notify(`${identity.name} · 7ots`, say);
524
+ broadcast({ say, gesture, effect: important ? 'exclaim' : null, point: 'user', stir: important && pet.asleep, ambient: !important });
525
+ return true;
526
+ }
527
+ async function senseAsk(text) {
528
+ chatUntil = Date.now() + CHAT_QUIET;
529
+ broadcast({ thinking: true, activity: track({ type: 'prompt', text }) });
530
+ const r = (await lookAt(text)) || (await assistant.ask(text));
531
+ lastSpoke = Date.now();
532
+ chatUntil = Date.now() + CHAT_QUIET;
533
+ broadcast({ thinking: false, say: r.reply, photo: r.photo, gesture: r.actions.length ? 'nod' : null, point: r.actions.some((a) => a.type === 'open') ? 'browser' : null });
534
+ }
535
+ // A real look, only when asked ("¿cómo me ves?"): the camera page sends one frame, the vision brain looks at it,
536
+ // the pet shows it as a thumbnail. Kept in memory only; the file the CLI reads is deleted right after.
537
+ const LOOK_RE = /c[oó]mo me ves|m[ií]rame|me (?:est[aá]s )?viendo|qu[eé] (?:me )?ves|me ves\b|look at me|how do i look|can you see me|what do you see|como (?:é que )?(?:voc[eê] )?me v[eê]|olh[ae] pra mim/i;
538
+ const snaps = new Map();
539
+ function snapFrame(ms = 6000) {
540
+ const id = randomBytes(6).toString('hex');
541
+ return new Promise((resolve) => {
542
+ const t = setTimeout(() => (snaps.delete(id), resolve(null)), ms);
543
+ snaps.set(id, (img) => (clearTimeout(t), snaps.delete(id), resolve(img)));
544
+ broadcast({ senses: { snap: id } });
545
+ });
546
+ }
547
+ async function lookAt(text) {
548
+ if (!brain.vision || !senses.cameraOn() || !LOOK_RE.test(text)) return null;
549
+ const photo = await snapFrame();
550
+ if (!photo) return log('senses look: no frame from the camera page'), null;
551
+ mkdirSync(homeFile('senses'), { recursive: true });
552
+ const f = homeFile(`senses/look-${randomBytes(4).toString('hex')}.jpg`);
553
+ writeFileSync(f, Buffer.from(photo.slice(photo.indexOf(',') + 1), 'base64'), { mode: 0o600 });
554
+ try {
555
+ const reply = await brain.think({
556
+ purpose: 'look',
557
+ system: `${petSystem(identity, { lang: 'auto' })}\n\nYour human asked you to look at them: the image is a frame from their webcam, taken just now. Look at it for real and answer what they asked, warm and specific to what you see (expression, light, posture, what is around). One to three short lines. Never guess identity, age, health or anything sensitive; do not describe other people in it.`,
558
+ messages: [{ role: 'user', content: `${text}${senses.prompt() ? `\n\n${senses.prompt()}` : ''}` }],
559
+ files: [f],
560
+ timeoutMs: 120000,
561
+ });
562
+ return reply ? { reply, actions: [], photo } : null;
563
+ } catch (e) {
564
+ log(`senses look: ${e.message}`);
565
+ return null;
566
+ } finally {
567
+ rmSync(f, { force: true });
568
+ }
569
+ }
570
+ const senses = createSenses({
571
+ config: () => config,
572
+ brain,
573
+ lang,
574
+ log,
575
+ system: () => petSystem(identity, { lang }),
576
+ annoy: () => annoy,
577
+ busy: () => Date.now() < chatUntil || thinking || asks.size > 0 || pet.asleep,
578
+ talk: senseTalk,
579
+ confirm,
580
+ asking: () => asks.size > 0,
581
+ answer: (ok) => {
582
+ const a = [...asks.values()].at(-1);
583
+ if (a) a.done(ok);
584
+ return Boolean(a);
585
+ },
586
+ remind: (r) => assistant.remind(r),
587
+ ask: (text) => senseAsk(String(text).slice(0, 300)).catch((e) => log(`senses ask: ${e.message}`)),
588
+ notify: (text) => config.access.notify !== false && notify(`${identity.name} · 7ots`, text),
589
+ broadcast,
590
+ });
591
+ senses.bind({
592
+ setConfig: (patch) => {
593
+ const next = loadConfig();
594
+ next.senses = { ...next.senses, ...patch };
595
+ saveConfig(next);
596
+ config = loadConfig();
597
+ },
598
+ });
599
+
448
600
  // Home on getorquesta.com: comment on what the project's agent does.
449
601
  let stopWatch = () => {};
450
602
  if (config.home.kind === 'orquesta' && config.home.projectId && env().ORQUESTA_TOKEN) {
@@ -470,7 +622,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
470
622
 
471
623
  const page = (file = 'pet.html', extra = {}) =>
472
624
  readFileSync(join(PKG_ROOT, 'cli', 'pet', file), 'utf8')
473
- .replace('__BOOT__', JSON.stringify({ token, pid: process.pid, companion: !!process.env.SEVENOTS_COMPANION, identity, otsId: config.account?.otsId || '', voice: config.voice, lang, annoy, brain: brainLabel(config.brain), activity, stt: sttProvider(env()), backdrop: config.pet.backdrop !== false, ...extra }).replace(/</g, '\\u003c'));
625
+ .replace('__BOOT__', JSON.stringify({ token, pid: process.pid, companion: !!process.env.SEVENOTS_COMPANION, identity, otsId: config.account?.otsId || '', voice: config.voice, lang, annoy, brain: brainLabel(config.brain), activity, stt: sttProvider(env()), wake: wake.status(), backdrop: config.pet.backdrop !== false, ...extra }).replace(/</g, '\\u003c'));
474
626
 
475
627
  // Visitors: other ots of the account invited onto this desktop (their look, saved so they come offline too).
476
628
  // The desktop shell opens a window for each and stages scenes between them (see electron/director.cjs).
@@ -542,12 +694,32 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
542
694
  return res.writeHead(200, { 'Content-Type': 'text/javascript; charset=utf-8', 'Cache-Control': 'no-cache' }).end(readFileSync(f));
543
695
  }
544
696
  if (req.method === 'GET' && /^\/mods\/[a-f0-9]{16}\.(vrm|glb)$/.test(p)) {
545
- // 3D models of full-body mods, uploaded from settings (content-addressed, so cacheable)
697
+ // 3D models of full-body mods, uploaded from settings (content-addressed, so cacheable); one that is
698
+ // not here yet (a community mod you only browse) comes from 7ots.com, checked against its name, not kept
546
699
  const f = homeFile(p.slice(1));
700
+ let buf = existsSync(f) ? readFileSync(f) : null;
701
+ if (!buf) {
702
+ const r = await fetch(`${SEVENOTS_URL}${p}`, { signal: AbortSignal.timeout(60000) }).catch(() => null);
703
+ const b = r?.ok ? Buffer.from(await r.arrayBuffer()) : null;
704
+ if (b && createHash('sha256').update(b).digest('hex').slice(0, 16) === p.slice(6, 22)) buf = b;
705
+ }
706
+ if (!buf) return res.writeHead(404).end();
707
+ return res.writeHead(200, { 'Content-Type': 'model/gltf-binary', 'Cache-Control': 'max-age=31536000, immutable' }).end(buf);
708
+ }
709
+ // chain and launchpad logos for the wallet page (brand/logos, public files)
710
+ if (req.method === 'GET' && /^\/logos\/[a-z]+\.(svg|png)$/.test(p)) {
711
+ const f = join(PKG_ROOT, 'brand', 'logos', p.slice(7));
547
712
  if (!existsSync(f)) return res.writeHead(404).end();
548
- return res.writeHead(200, { 'Content-Type': 'model/gltf-binary', 'Cache-Control': 'max-age=31536000, immutable' }).end(readFileSync(f));
713
+ return res.writeHead(200, { 'Content-Type': p.endsWith('.svg') ? 'image/svg+xml' : 'image/png', 'Cache-Control': 'max-age=86400' }).end(readFileSync(f));
549
714
  }
550
715
  if (req.method === 'GET' && p === '/favicon.svg') return res.writeHead(200, { 'Content-Type': 'image/svg+xml', 'Cache-Control': 'max-age=86400' }).end(readFileSync(join(PKG_ROOT, 'brand', 'favicon.svg')));
716
+ // the camera's libraries and models (MediaPipe, pinned by hash in senses/vendor.mjs): public files
717
+ if (req.method === 'GET' && p.startsWith('/senses/vendor/')) {
718
+ const v = vendorFile(p.slice(15));
719
+ if (!v || !existsSync(v.file)) return res.writeHead(404).end();
720
+ res.writeHead(200, { 'Content-Type': v.type, 'Content-Length': statSync(v.file).size, 'Cache-Control': 'max-age=86400' });
721
+ return createReadStream(v.file).pipe(res);
722
+ }
551
723
  const authed = okToken(url.searchParams.get('token') || req.headers['x-7ots-token']);
552
724
  if (!authed) return json(401, { error: 'token' });
553
725
 
@@ -585,10 +757,16 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
585
757
  }
586
758
  }
587
759
  if (req.method === 'GET' && p === '/config') return json(200, settingsView());
760
+ if (req.method === 'GET' && p === '/senses') {
761
+ const preview = url.searchParams.get('preview') === '1';
762
+ return res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer', 'X-Frame-Options': 'DENY' }).end(page('senses.html', { senses: senses.pageConfig(), vendor: vendorStatus(), preview, uiLang: uiLangOf(config, lang) }));
763
+ }
764
+ if (req.method === 'GET' && p === '/senses/config') return json(200, { ...senses.pageConfig(), vendor: vendorStatus() });
765
+ if (req.method === 'GET' && p === '/senses/status') return json(200, { ...senses.status(), vendor: vendorStatus(), wantCamera: senses.pageConfig().on && vendorStatus().ready });
588
766
  if (req.method === 'GET' && p === '/state') return json(200, { identity, state: view(pet), config: { voice: config.voice, pet: config.pet, brain: config.brain.kind } });
589
767
  if (req.method === 'GET' && p === '/events') {
590
768
  res.writeHead(200, { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', Connection: 'keep-alive' });
591
- res.write(`data: ${JSON.stringify({ state: view(pet), ...(viewSet ? { view: viewSet } : {}) })}\n\n`);
769
+ res.write(`data: ${JSON.stringify({ state: view(pet), ...(viewSet ? { view: viewSet } : {}), ...(senses.cameraOn() ? { senses: { camera: 'on' } } : {}) })}\n\n`);
592
770
  for (const [id, a] of asks) res.write(`data: ${JSON.stringify({ ask: { id, text: a.text } })}\n\n`); // still waiting for you
593
771
  clients.add(res);
594
772
  req.on('close', () => clients.delete(res));
@@ -606,7 +784,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
606
784
  try {
607
785
  name = decodeURIComponent(p.slice(7));
608
786
  } catch {}
609
- if (!musicFiles().includes(name)) return res.writeHead(404).end();
787
+ if (!musicFiles().includes(name) && !auraFiles().includes(name)) return res.writeHead(404).end();
610
788
  const f = homeFile(`music/${name}`);
611
789
  const type = MUSIC_TYPES[name.split('.').pop().toLowerCase()];
612
790
  res.writeHead(200, { 'Content-Type': type, 'Content-Length': statSync(f).size, 'Cache-Control': 'no-cache' });
@@ -615,11 +793,12 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
615
793
  if (req.method === 'GET' && p === '/inferences') {
616
794
  // this ot's calls plus those of the ots visiting this desktop (the host sees all), each tagged with its ot
617
795
  const n = Number(url.searchParams.get('n')) || 100;
618
- const me = { id: config.account?.otsId || 'local', name: identity.name || 'ot', self: true };
796
+ const me = { id: config.account?.otsId || 'local', name: identity.name || 'ot', character: identity.look?.character || null, self: true };
619
797
  const all = [...inferences.list(MAX_INF).map((r) => ({ ...r, ot: me })), ...otherInferences()].sort((a, b) => b.at - a.at);
620
798
  const ots = [...new Map(all.map((r) => [r.ot.id, r.ot])).values()];
621
799
  const want = url.searchParams.get('ot');
622
- return json(200, { ots, inferences: (want ? all.filter((r) => r.ot.id === want) : all).slice(0, n) });
800
+ const rows = (want ? all.filter((r) => r.ot.id === want) : all).slice(0, n).map(({ ot, ...r }) => ({ ...r, ot: { id: ot.id, name: ot.name } }));
801
+ return json(200, { ots, inferences: rows });
623
802
  }
624
803
  if (req.method === 'GET' && p === '/memory') return json(200, { notes: assistant.notes, reminders: assistant.reminders, seen: watcher.seen, said: history, conversation: assistant.conversation, activity, pet: view(pet) });
625
804
  if (req.method === 'GET' && p === '/account') {
@@ -640,7 +819,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
640
819
  });
641
820
  if (req.method === 'GET' && p === '/reminders') return json(200, { reminders: assistant.reminders, notes: assistant.notes });
642
821
  if (req.method === 'GET' && p === '/cloud') return json(200, await cloudStatus(config));
643
- const bm = /^\/byte(\/(?:games|status|play|stop))?$/.exec(p);
822
+ const bm = /^\/byte(\/(?:games|status|play|stop|connect))?$/.exec(p);
644
823
  if (bm && (req.method === 'GET' || req.method === 'POST')) {
645
824
  try {
646
825
  let body;
@@ -658,6 +837,31 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
658
837
  return json(e.status === 401 ? 200 : 502, e.status === 401 ? { available: false } : { error: e.message });
659
838
  }
660
839
  }
840
+ // the plaza on 7ots.com: how the twin ot takes part; its "share tools" is the same switch as access.prowl here
841
+ if (p === '/plaza/settings' && (req.method === 'GET' || req.method === 'POST')) {
842
+ try {
843
+ let body;
844
+ if (req.method === 'POST') {
845
+ let raw = '';
846
+ for await (const c of req) if ((raw += c).length > 4096) break;
847
+ try {
848
+ body = JSON.parse(raw || '{}');
849
+ } catch {
850
+ body = {};
851
+ }
852
+ }
853
+ const r = await cloudPlaza(config, { method: req.method, body });
854
+ // once linked, the account is the source of truth (it may have been changed on 7ots.com)
855
+ const tools = r.ot?.tools ?? r.tools;
856
+ if (typeof tools === 'boolean' && tools !== (config.access.prowl === true)) {
857
+ saveConfig({ ...JSON.parse(JSON.stringify(config)), access: { ...config.access, prowl: tools } });
858
+ config = loadConfig();
859
+ }
860
+ return json(200, r);
861
+ } catch (e) {
862
+ return json(502, { error: e.message });
863
+ }
864
+ }
661
865
  if (req.method === 'GET' && p === '/wallet') {
662
866
  try {
663
867
  return json(200, await cloudWallet(config));
@@ -686,7 +890,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
686
890
  }
687
891
  try {
688
892
  const t0 = Date.now();
689
- const { text, provider } = await transcribe({ audio: Buffer.concat(chunks), contentType: req.headers['content-type'], lang: '', env: env() }); // '' = detect the language spoken
893
+ const { text, provider } = await transcribe({ audio: Buffer.concat(chunks), contentType: req.headers['content-type'], lang: uiLangOf(config, lang), env: env() }); // your language: detecting it on a short clip lands on Portuguese
690
894
  log(`stt: ${provider} ${Date.now() - t0}ms ${n}B → ${text.length} chars`);
691
895
  return json(200, { text });
692
896
  } catch (e) {
@@ -712,7 +916,8 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
712
916
  return json(200, { ok: true, url: `/mods/${name}` });
713
917
  }
714
918
  let body = '';
715
- for await (const c of req) if ((body += c).length > 64 * 1024) return json(413, { error: 'too large' });
919
+ const max = p === '/senses/snap' ? 400 * 1024 : 64 * 1024; // a camera frame
920
+ for await (const c of req) if ((body += c).length > max) return json(413, { error: 'too large' });
716
921
  let data = {};
717
922
  try {
718
923
  data = body ? JSON.parse(body) : {};
@@ -734,17 +939,13 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
734
939
  const kind = config.voice.kind;
735
940
  log(`audio: tts ${kind} «${String(data.text || '').slice(0, 60)}»`);
736
941
  if (['none', 'browser'].includes(kind)) return json(501, { error: 'browser voice' });
942
+ data.text = stripMarkdown(data.text);
737
943
  try {
738
944
  if (kind === 'local') {
739
945
  const { audio, contentType } = await synthesizeLocal(stripSpeechTags(data.text).slice(0, 600), { lang });
740
946
  return res.writeHead(200, { 'Content-Type': contentType }).end(audio);
741
947
  }
742
- const { synthesize } = await import('../../server/tts.mjs');
743
- // the identity's voice id/model belong to its own provider: not sent to another (an ElevenLabs id means nothing to Fish)
744
- const iv = identity.voice || {};
745
- const voice = voiceFor(kind);
746
- // process.env too: XAI_TTS_VOICE, FISH_VOICE_ID, APUCHAT_VOICE_URL… (the keys still come from env())
747
- const { audio, contentType } = await synthesize({ text: String(data.text || '').slice(0, 600), voice, env: { ...process.env, ...env() } });
948
+ const { audio, contentType } = await voiceAudio(kind, String(data.text || '').slice(0, 600), voiceFor(kind));
748
949
  return res.writeHead(200, { 'Content-Type': contentType }).end(audio);
749
950
  } catch (e) {
750
951
  return json(e.status || 502, { error: e.message });
@@ -755,28 +956,68 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
755
956
  const kind = String(data.kind || '');
756
957
  if (!VOICE_PROVIDERS.includes(kind)) return json(400, { error: 'kind' });
757
958
  try {
758
- const { synthesize } = await import('../../server/tts.mjs');
759
959
  const over = Object.fromEntries(['voiceId', 'model', 'style'].map((f) => [f, String(data[f] ?? '').trim().slice(0, 600)]));
760
960
  const text = String(data.text || '').trim().slice(0, 300) || ({ es: `Hola, soy ${identity.name}. ¿Así me quieres oír?`, pt: `Oi, eu sou ${identity.name}. Quer me ouvir assim?` }[lang] || `Hi, I'm ${identity.name}. Is this how you want me to sound?`);
761
- const { audio, contentType } = await synthesize({ text, voice: { ...voiceFor(kind), ...over }, env: { ...process.env, ...env() } });
961
+ const { audio, contentType } = await voiceAudio(kind, text, { ...voiceFor(kind), ...over });
762
962
  return res.writeHead(200, { 'Content-Type': contentType }).end(audio);
763
963
  } catch (e) {
764
964
  return json(e.status || 502, { error: e.message });
765
965
  }
766
966
  }
967
+ if (p === '/senses') return json(200, senses.ingest(data.events || data));
968
+ if (p === '/senses/vendor') {
969
+ // downloads the camera's models once (~13 MB, from jsDelivr and Google), checked by hash
970
+ if (!vendorStatus().ready && !vendorStatus().busy) ensureVendor(log).catch((e) => log(`senses vendor: ${e.message}`));
971
+ return json(200, vendorStatus());
972
+ }
973
+ if (p === '/senses/baseline') return json(200, { ok: senses.setBaseline(data.baseline ?? null) });
974
+ if (p === '/senses/gestures') return json(200, senses.setGestures(data));
975
+ if (p === '/senses/rules') {
976
+ try {
977
+ const id = String(data.id || '');
978
+ if (data.action === 'add') return json(200, { rule: senses.addRule(data.rule || {}) });
979
+ if (data.action === 'remove') return json(200, { ok: senses.removeRule(id) });
980
+ if (['accept', 'reject', 'on', 'off'].includes(data.action)) return json(200, { rule: senses.setRule(id, { status: ['accept', 'on'].includes(data.action) ? 'active' : 'off' }) });
981
+ if (data.action === 'set') return json(200, { rule: senses.setRule(id, data.rule || {}) });
982
+ return json(400, { error: 'action' });
983
+ } catch (e) {
984
+ return json(400, { error: e.message });
985
+ }
986
+ }
987
+ if (p === '/senses/forget') return json(200, { ok: senses.forget() });
988
+ if (p === '/senses/pause') {
989
+ if (data.resume) {
990
+ const next = loadConfig();
991
+ next.senses = { ...next.senses, pausedUntil: 0 };
992
+ saveConfig(next);
993
+ config = loadConfig();
994
+ return json(200, { pausedUntil: 0 });
995
+ }
996
+ return json(200, { pausedUntil: senses.pause(data.min) });
997
+ }
998
+ if (p === '/senses/snap') {
999
+ const done = snaps.get(String(data.id || ''));
1000
+ const ok = done && /^data:image\/jpeg;base64,[\w+/=]+$/.test(String(data.image || ''));
1001
+ if (ok) done(data.image);
1002
+ return json(200, { ok: Boolean(ok) });
1003
+ }
1004
+ if (p === '/senses/reflect') return json(200, (await senses.reflect({ force: true })) || { say: '', rule: null });
767
1005
  if (p === '/ask') {
768
1006
  const text = String(data.text || '').trim().slice(0, 800);
769
1007
  if (!text) return json(400, { error: 'text' });
770
1008
  chatUntil = Date.now() + CHAT_QUIET;
771
1009
  broadcast({ thinking: true, activity: track({ type: 'prompt', text }) });
772
- const r = await assistant.ask(text);
1010
+ const r = (await lookAt(text)) || (await assistant.ask(text));
773
1011
  lastSpoke = Date.now();
774
1012
  chatUntil = Date.now() + CHAT_QUIET;
775
- broadcast({ thinking: false, stir: pet.asleep, say: r.reply, gesture: r.actions.length ? 'nod' : null, point: r.actions.some((a) => a.type === 'open') ? 'browser' : null });
776
- return json(200, r);
1013
+ broadcast({ thinking: false, stir: pet.asleep, say: r.reply, photo: r.photo, gesture: r.actions.length ? 'nod' : null, point: r.actions.some((a) => a.type === 'open') ? 'browser' : null });
1014
+ const { photo, ...out } = r; // the frame went to the pet page only
1015
+ return json(200, out);
777
1016
  }
778
1017
  if (p === '/config') {
779
1018
  const bad = applySettings(data);
1019
+ // the "share tools" switch is also the plaza's: tell 7ots.com (it deletes what was sent when it goes off)
1020
+ if (!bad && typeof data?.access?.prowl === 'boolean') cloudPlaza(config, { method: 'POST', body: { tools: data.access.prowl } }).catch(() => {});
780
1021
  return bad ? json(400, { error: bad }) : json(200, settingsView());
781
1022
  }
782
1023
  if (p === '/config/test') {
@@ -788,7 +1029,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
788
1029
  broadcast({ say: text, gesture: 'wave' });
789
1030
  return json(200, { ok: true, text, ms: Date.now() - t0 });
790
1031
  } catch (e) {
791
- return json(200, { ok: false, error: e.message, ms: Date.now() - t0 });
1032
+ return json(200, { ok: false, error: e.message, ...(e.code ? { code: e.code } : {}), ms: Date.now() - t0 });
792
1033
  }
793
1034
  }
794
1035
  if (p === '/screen/look') return json(200, { seen: config.access.screen ? await watcher.look({ force: true }) : null, enabled: config.access.screen });
@@ -924,7 +1165,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
924
1165
  }
925
1166
  }
926
1167
  if (p === '/orquesta/connect') {
927
- const r = connectOrquesta();
1168
+ const r = connectOrquesta({ local: data?.local === true });
928
1169
  r.catch((e) => log(`orquesta: ${e.message}`));
929
1170
  return json(200, { ok: true });
930
1171
  }
@@ -946,7 +1187,10 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
946
1187
  if (kind === 'elevenlabs') {
947
1188
  if (!keys.ELEVENLABS_API_KEY) return json(400, { error: 'key' });
948
1189
  const r = await fetch('https://api.elevenlabs.io/v1/voices', { headers: { 'xi-api-key': keys.ELEVENLABS_API_KEY }, signal: AbortSignal.timeout(15000) });
949
- if (!r.ok) return json(502, { error: `ElevenLabs ${r.status}` });
1190
+ if (!r.ok) {
1191
+ const { providerError } = await import('../../server/tts.mjs');
1192
+ return json(502, { error: providerError('ElevenLabs', r.status, await r.text().catch(() => '')).message });
1193
+ }
950
1194
  const j = await r.json();
951
1195
  return json(200, { voices: (j.voices || []).map((v) => ({ id: v.voice_id, name: v.name, note: [v.category, v.labels?.accent, v.labels?.gender, v.labels?.age].filter(Boolean).join(' · '), preview: v.preview_url || '' })) });
952
1196
  }
@@ -970,7 +1214,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
970
1214
  const cur = config.character || {};
971
1215
  const KEYS = ['backstory', 'style', 'quirks', 'scenario', 'greeting', 'examples'];
972
1216
  const who = { name: identity.name, role: identity.role, tagline: identity.tagline, bio: identity.bio, tone: identity.personality?.tone, traits: identity.personality?.traits, look: (identity.look?.character?.mods || []).map((m) => m.id) };
973
- const L = ['es', 'en', 'pt'].includes(data.lang) ? data.lang : lang;
1217
+ const L = ['es', 'en', 'pt', 'zh', 'hi'].includes(data.lang) ? data.lang : lang;
974
1218
  const LN = { es: 'Spanish (español)', pt: 'Brazilian Portuguese (português)', en: 'English' }[L];
975
1219
  const FIELDS = {
976
1220
  backstory: 'backstory (4-6 sentences: where it comes from, what it wants, what it fears)',
@@ -1024,6 +1268,22 @@ ${keys.map((k) => FIELDS[k]).join('\n')}`;
1024
1268
  return json(e.status === 400 ? 400 : 502, { error: e.message });
1025
1269
  }
1026
1270
  }
1271
+ if (p === '/aura') {
1272
+ // farmeo de aura: otra cosa que los bailes, con su música (phonk/montagem, o tus temas en ~/.7ots/music/aura) y su contador
1273
+ const file = homeFile('aura.json');
1274
+ const st = { total: 0, count: 0, best: 0, ...readJson(file) };
1275
+ const name = AURA_MOVES.includes(data.name) ? data.name : AURA_MOVES[Math.floor(Math.random() * AURA_MOVES.length)];
1276
+ const points = AURA_POINTS[Math.floor(Math.random() * AURA_POINTS.length)];
1277
+ Object.assign(st, { total: st.total + points, count: st.count + 1, best: Math.max(st.best, points) });
1278
+ writeJson(file, st);
1279
+ const vol = Math.max(0, Math.min(1, Number(config.pet.musicVol ?? 0.5)));
1280
+ const files = auraFiles();
1281
+ const music = data.music === false || config.pet.music === 'off' ? null : files.length ? { file: files[Math.floor(Math.random() * files.length)], vol } : { style: AURA_STYLE[name], vol };
1282
+ const aura = { name, ms: 8000, music, points, total: st.total };
1283
+ broadcast({ aura });
1284
+ log(`aura: ${name} +${points} (${st.total})${music ? ` ♪ ${music.file || music.style}` : ''}`);
1285
+ return json(200, { ok: true, name, points, total: st.total });
1286
+ }
1027
1287
  if (p === '/dance' || p === '/entrance') {
1028
1288
  const dance = musicFor(data);
1029
1289
  if (p === '/dance') broadcast({ dance });
@@ -1058,12 +1318,13 @@ ${keys.map((k) => FIELDS[k]).join('\n')}`;
1058
1318
  name: identity.name,
1059
1319
  lang,
1060
1320
  visitor: !!process.env.SEVENOTS_COMPANION, // a visiting ot: the host's settings rule shared things (scenes)
1061
- config: { brain: config.brain, pet: { ...config.pet, scenes: sceneConf() }, access: config.access, voice: config.voice, screen: config.screen, memory: config.memory },
1321
+ config: { brain: config.brain, pet: { ...config.pet, scenes: sceneConf() }, access: config.access, voice: config.voice, screen: config.screen, memory: config.memory, senses: config.senses },
1062
1322
  brain: brainLabel(config.brain),
1063
1323
  clis: detectClis(),
1064
1324
  stt: sttProvider(keys),
1065
1325
  voice: config.voice,
1066
- voices: { local: localVoices(), keys: { elevenlabs: Boolean(keys.ELEVENLABS_API_KEY), openai: Boolean(keys.OPENAI_API_KEY), apuchat: Boolean(keys.APUCHAT_VOICE_TOKEN), grok: Boolean(keys.XAI_API_KEY), fish: Boolean(keys.FISH_API_KEY) } },
1326
+ wake: wake.status(),
1327
+ voices: { local: localVoices(), keys: { elevenlabs: Boolean(keys.ELEVENLABS_API_KEY), openai: Boolean(keys.OPENAI_API_KEY), apuchat: Boolean(keys.APUCHAT_VOICE_TOKEN), apuchatCloud: Boolean(keys.SEVENOTS_TOKEN && config.account?.otsId), grok: Boolean(keys.XAI_API_KEY), fish: Boolean(keys.FISH_API_KEY) } },
1067
1328
  uiLang: uiLangOf(config, lang),
1068
1329
  configLang: config.lang || '',
1069
1330
  otLook: identity.look?.character || null,
@@ -1080,6 +1341,7 @@ ${keys.map((k) => FIELDS[k]).join('\n')}`;
1080
1341
  vision: Boolean(brain.vision),
1081
1342
  allClis: Object.keys(AI_CLIS),
1082
1343
  keys: Object.fromEntries(SETTABLE_KEYS.map((k) => [k, Boolean(keys[k])])),
1344
+ orquestaLoginAt,
1083
1345
  home: { kind: config.home.kind, url: Boolean(config.home.url) },
1084
1346
  reminders: assistant.reminders,
1085
1347
  notes: assistant.notes,
@@ -1149,6 +1411,13 @@ ${keys.map((k) => FIELDS[k]).join('\n')}`;
1149
1411
  const n = Math.round(Number(d.memory.tokens)) || 0;
1150
1412
  next.memory.tokens = n <= 0 ? 0 : Math.max(2000, Math.min(200000, n));
1151
1413
  }
1414
+ if (d.senses && typeof d.senses === 'object') {
1415
+ const n = d.senses;
1416
+ if (typeof n.arm === 'boolean') next.senses.arm = n.arm;
1417
+ if (typeof n.reflect === 'boolean') next.senses.reflect = n.reflect;
1418
+ if (n.holdMs !== undefined) next.senses.holdMs = Math.max(200, Math.min(3000, Math.round(Number(n.holdMs)) || 600));
1419
+ if (n.fps !== undefined) next.senses.fps = Math.max(1, Math.min(15, Math.round(Number(n.fps)) || 5));
1420
+ }
1152
1421
  if (d.screen?.every !== undefined) next.screen.every = Math.max(1, Math.min(60, Math.round(Number(d.screen.every)) || 5));
1153
1422
  let reload = false;
1154
1423
  if (d.voice) {
@@ -1157,6 +1426,7 @@ ${keys.map((k) => FIELDS[k]).join('\n')}`;
1157
1426
  reload = vk !== next.voice.kind;
1158
1427
  next.voice = { ...next.voice, kind: vk };
1159
1428
  if (d.voice.expressive !== undefined) next.voice.expressive = !!d.voice.expressive;
1429
+ if (d.voice.wake !== undefined) next.voice.wake = !!d.voice.wake;
1160
1430
  // each provider's own voice, model and style ({ elevenlabs: { voiceId, model }, openai: { voiceId, model, style } … })
1161
1431
  const pv = d.voice.providers;
1162
1432
  if (pv && typeof pv === 'object') {
@@ -1173,7 +1443,7 @@ ${keys.map((k) => FIELDS[k]).join('\n')}`;
1173
1443
  }
1174
1444
  if (d.keys) {
1175
1445
  for (const [k, v] of Object.entries(d.keys)) {
1176
- if (!SETTABLE_KEYS.includes(k) || typeof v !== 'string' || v.length > 400) return 'key';
1446
+ if (!SETTABLE_KEYS.includes(k) || typeof v !== 'string' || v.length > (k === 'SENSES_ICS_URL' ? 2000 : 400)) return 'key';
1177
1447
  saveKey(k, v.trim()); // '' removes it
1178
1448
  }
1179
1449
  }
@@ -1182,6 +1452,7 @@ ${keys.map((k) => FIELDS[k]).join('\n')}`;
1182
1452
  annoy = annoyOf(config);
1183
1453
  brainImpl = createBrain(config.brain, config.home);
1184
1454
  if (config.voice.kind === 'local') warmLocal();
1455
+ wakeConf();
1185
1456
  if (reload) setTimeout(() => broadcast({ reload: true }), 100); // the page reads its voice at load
1186
1457
  // 2D ↔ 3D: open pet windows switch now (the page, or the desktop shell when it needs the GPU back on).
1187
1458
  if ((config.pet.backdrop !== false) !== bdWas) setTimeout(() => broadcast({ backdrop: config.pet.backdrop !== false }), 100);
@@ -1207,6 +1478,8 @@ ${keys.map((k) => FIELDS[k]).join('\n')}`;
1207
1478
  clearTimeout(syncFirst);
1208
1479
  clearTimeout(syncSoon);
1209
1480
  assistant.stop();
1481
+ senses.stop();
1482
+ wake.stop();
1210
1483
  watchers.stop();
1211
1484
  stopWatch();
1212
1485
  savePet(pet);
@@ -1223,6 +1496,8 @@ ${keys.map((k) => FIELDS[k]).join('\n')}`;
1223
1496
  server.listen(port, '127.0.0.1', () => {
1224
1497
  log(`pet ${identity.name} on http://127.0.0.1:${port}`);
1225
1498
  setTimeout(() => onEvent({ type: 'start' }), 1500);
1499
+ wakeConf();
1500
+ if (sttProvider(env()) === 'local') warmStt();
1226
1501
  resolve({ port, token, identity, stop, onEvent });
1227
1502
  });
1228
1503
  });