@7ots/cli 0.1.19 → 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.
- package/.env.example +14 -0
- package/brand/logos/base.svg +1 -0
- package/brand/logos/clawpump.png +0 -0
- package/brand/logos/conductors.svg +1 -0
- package/brand/logos/notlogin.svg +12 -0
- package/brand/logos/pumpfun.png +0 -0
- package/brand/logos/solana.png +0 -0
- package/brand/logos/spawnerbot.svg +1 -0
- package/brand/logos/virtuals.png +0 -0
- package/cli/7ots.mjs +59 -1
- package/cli/lib/account.mjs +23 -3
- package/cli/lib/assistant.mjs +88 -13
- package/cli/lib/brain.mjs +76 -8
- package/cli/lib/config.mjs +14 -3
- package/cli/lib/desktop-sync.mjs +177 -0
- package/cli/lib/i18n.mjs +9 -0
- package/cli/lib/inferences.mjs +19 -2
- package/cli/lib/integrations.mjs +61 -6
- package/cli/lib/pet-server.mjs +316 -41
- package/cli/lib/prompts.mjs +1 -1
- package/cli/lib/senses/gestures.mjs +121 -0
- package/cli/lib/senses/index.mjs +490 -0
- package/cli/lib/senses/rules.mjs +159 -0
- package/cli/lib/senses/sources/activity.mjs +95 -0
- package/cli/lib/senses/sources/calendar.mjs +75 -0
- package/cli/lib/senses/sources/index.mjs +17 -0
- package/cli/lib/senses/sources/mail.mjs +48 -0
- package/cli/lib/senses/sources/system.mjs +39 -0
- package/cli/lib/senses/util.mjs +41 -0
- package/cli/lib/senses/vendor.mjs +78 -0
- package/cli/lib/stt-local.py +16 -8
- package/cli/lib/stt.mjs +53 -6
- package/cli/lib/tooluse.mjs +56 -0
- package/cli/lib/vm.mjs +1 -1
- package/cli/lib/wake-local.py +109 -0
- package/cli/lib/wake.mjs +102 -0
- package/cli/pet/electron/main.cjs +137 -13
- package/cli/pet/pet.html +125 -26
- package/cli/pet/senses.html +342 -0
- package/cli/pet/settings.html +787 -86
- package/dist/7ots.esm.js +373 -146
- package/dist/7ots.esm.js.map +4 -4
- package/dist/7ots.iife.js +373 -146
- package/dist/7ots.iife.js.map +4 -4
- package/llms.txt +27 -0
- package/package.json +5 -2
- package/server/channels/apuchat.mjs +2 -0
- package/server/errors.mjs +90 -0
- package/server/notify.mjs +78 -0
- package/server/server.mjs +68 -12
- package/server/settings.mjs +3 -0
- package/server/site.mjs +401 -0
- package/server/tts.mjs +29 -5
- package/src/avatar/AvatarStage.js +2 -2
- package/src/avatar/three.js +3 -2
- package/src/character/AvatarEditor.js +2 -1
- package/src/character/Character.js +1 -1
- package/src/character/TradingCard.js +2 -0
- package/src/character/beat.js +64 -2
- package/src/character/mods/orc.js +8 -1
- package/src/character/mods.js +104 -10
- package/src/character/motion.js +162 -0
- package/src/character/parts.js +40 -38
- package/src/character/styles.js +40 -38
- package/src/character3d/Character3D.js +26 -5
- package/src/character3d/body.js +14 -12
- package/src/character3d/export.js +693 -0
- package/src/character3d/fx.js +13 -0
- package/src/character3d/index.js +2 -0
- package/src/character3d/materials.js +106 -10
- package/src/character3d/room-themes.js +1184 -0
- package/src/character3d/room.js +487 -0
- package/src/character3d/stage.js +2 -1
- package/src/creator/StepCreator.js +316 -0
- package/src/i18n/index.js +3 -3
- package/src/i18n/messages/character.js +352 -4
- package/src/i18n/messages/creator.js +138 -0
- package/src/i18n/messages/identity.js +89 -1
- package/src/i18n/messages/platform.js +255 -1
- package/src/i18n/messages/server.js +443 -1
- package/src/i18n/messages/widget.js +233 -0
- package/src/identity/random.js +14 -2
- package/src/identity/schema.js +2 -1
- package/src/index.js +9 -2
- package/src/voice/tags.js +22 -0
- package/server/platform/apuchat.mjs +0 -266
- package/server/platform/auth.mjs +0 -337
- package/server/platform/byte.mjs +0 -291
- package/server/platform/connect.mjs +0 -391
- package/server/platform/crypto.mjs +0 -80
- package/server/platform/db.mjs +0 -293
- package/server/platform/device.mjs +0 -247
- package/server/platform/integrations.mjs +0 -169
- package/server/platform/look.mjs +0 -20
- package/server/platform/mods.mjs +0 -222
- package/server/platform/orquesta.mjs +0 -611
- package/server/platform/profile.mjs +0 -182
- package/server/platform/routes.mjs +0 -589
- package/server/platform/runtime.mjs +0 -286
- package/server/platform/sites.mjs +0 -146
- package/server/platform/stage3d.mjs +0 -82
- package/server/platform/store.mjs +0 -469
- package/server/platform/vm.mjs +0 -1057
- package/server/platform/wallet.mjs +0 -255
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the desktop pet keeps of its ot, the same on every computer signed in to 7ots.com
|
|
3
|
+
* (GET/PUT /api/device/ots/:id/desktop, server/platform/device.mjs). account.mjs sync() covers the
|
|
4
|
+
* identity (look, mods, personality); this covers the rest:
|
|
5
|
+
*
|
|
6
|
+
* settings config.json: brain, voice, pet, access, screen, memory, integrations
|
|
7
|
+
* (not home/account/lang/character: those are this computer's or the identity's)
|
|
8
|
+
* progress the tamagotchi's born, xp and stats (food/energy/fun stay per computer: they decay anyway)
|
|
9
|
+
* notes memory.json · reminders.json · watchers.json
|
|
10
|
+
*
|
|
11
|
+
* Three-way merge against the last state both sides agreed on (~/.7ots/sync-desktop.json), so what one
|
|
12
|
+
* computer deleted (a fired reminder, a forgotten note) does not come back from the other:
|
|
13
|
+
* settings, per key: the side that changed wins; both → the newer one. A computer that never synced
|
|
14
|
+
* takes what 7ots.com has (a new install should not wipe your settings with its defaults),
|
|
15
|
+
* unless 7ots.com only has the default and this computer changed it.
|
|
16
|
+
* lists: union by id, minus what either side removed since the base.
|
|
17
|
+
* progress: each side's gains since the base add up; born is the oldest.
|
|
18
|
+
* Keys (keys.json) never leave the computer.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { existsSync, statSync } from 'node:fs';
|
|
22
|
+
import { api, signedIn } from './account.mjs';
|
|
23
|
+
import { CONFIG_DEFAULTS, loadConfig, saveConfig } from './config.mjs';
|
|
24
|
+
import { homeFile, readJson, writeJson } from './paths.mjs';
|
|
25
|
+
import { xpForLevel } from './pet-core.mjs';
|
|
26
|
+
|
|
27
|
+
const SETTINGS = ['brain', 'voice', 'pet', 'access', 'screen', 'memory', 'integrations'];
|
|
28
|
+
// what the senses may read is decided per computer (a camera allowed at home is not allowed at the office)
|
|
29
|
+
const LOCAL_ACCESS = ['camera', 'activity', 'mail', 'calendar', 'whatsapp'];
|
|
30
|
+
const shared = (k, v) => (k === 'access' && v && typeof v === 'object' ? Object.fromEntries(Object.entries(v).filter(([a]) => !LOCAL_ACCESS.includes(a))) : v);
|
|
31
|
+
const STATS = ['ok', 'fail', 'turns'];
|
|
32
|
+
const MAX_NOTES = 200;
|
|
33
|
+
const LISTS = {
|
|
34
|
+
notes: { file: 'memory.json', key: (n) => `${n.at}|${n.text}`, order: (n) => n.at || 0, keep: (n) => n && typeof n.text === 'string' },
|
|
35
|
+
reminders: { file: 'reminders.json', key: (r) => r.id, order: (r) => r.at || 0, keep: (r) => r?.id && !r.done },
|
|
36
|
+
watchers: { file: 'watchers.json', key: (w) => w.id, order: (w) => w.created || 0, keep: (w) => w?.id && !w.done },
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// equal regardless of key order (each computer's config.json writes its keys in its own order)
|
|
40
|
+
const canon = (v) => (Array.isArray(v) ? v.map(canon) : v && typeof v === 'object' ? Object.fromEntries(Object.keys(v).sort().map((k) => [k, canon(v[k])])) : v);
|
|
41
|
+
const same = (a, b) => JSON.stringify(canon(a ?? null)) === JSON.stringify(canon(b ?? null));
|
|
42
|
+
const mtime = (f) => (existsSync(homeFile(f)) ? statSync(homeFile(f)).mtimeMs : 0);
|
|
43
|
+
|
|
44
|
+
/** xp as one number (level 3 with 10 xp = everything it took to get there + 10). */
|
|
45
|
+
export function totalXp({ level = 1, xp = 0 } = {}) {
|
|
46
|
+
let t = Math.max(0, Number(xp) || 0);
|
|
47
|
+
for (let l = 1; l < level; l++) t += xpForLevel(l);
|
|
48
|
+
return t;
|
|
49
|
+
}
|
|
50
|
+
export function levelOf(total) {
|
|
51
|
+
let level = 1;
|
|
52
|
+
let xp = Math.max(0, Math.round(total));
|
|
53
|
+
while (xp >= xpForLevel(level)) xp -= xpForLevel(level++);
|
|
54
|
+
return { level, xp };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** This computer's side. `pet` is the live tamagotchi object when the pet is running. */
|
|
58
|
+
export function localState(pet = readJson(homeFile('pet.json')) || {}) {
|
|
59
|
+
const config = loadConfig();
|
|
60
|
+
const lists = Object.fromEntries(Object.entries(LISTS).map(([k, l]) => [k, (readJson(homeFile(l.file), []) || []).filter(l.keep)]));
|
|
61
|
+
return {
|
|
62
|
+
settings: Object.fromEntries(SETTINGS.map((k) => [k, shared(k, config[k])])),
|
|
63
|
+
progress: { born: pet.born || Date.now(), xp: totalXp(pet), stats: Object.fromEntries(STATS.map((k) => [k, Number(pet.stats?.[k]) || 0])) },
|
|
64
|
+
...lists,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function mergeList(name, base, local, remote) {
|
|
69
|
+
const { key, order } = LISTS[name];
|
|
70
|
+
if (!remote) return local;
|
|
71
|
+
const inB = new Set((base || []).map(key));
|
|
72
|
+
const inL = new Set(local.map(key));
|
|
73
|
+
const inR = new Set(remote.map(key));
|
|
74
|
+
const out = new Map();
|
|
75
|
+
for (const x of [...local, ...remote]) {
|
|
76
|
+
const k = key(x);
|
|
77
|
+
if (out.has(k)) continue; // the local copy came first
|
|
78
|
+
if (base && inB.has(k) && (!inL.has(k) || !inR.has(k))) continue; // removed on one side
|
|
79
|
+
out.set(k, x);
|
|
80
|
+
}
|
|
81
|
+
const list = [...out.values()].sort((a, b) => order(a) - order(b));
|
|
82
|
+
return name === 'notes' ? list.slice(-MAX_NOTES) : list;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function mergeProgress(base, local, remote) {
|
|
86
|
+
if (!remote) return local;
|
|
87
|
+
const born = Math.min(...[base?.born, local.born, remote.born].filter(Boolean));
|
|
88
|
+
// no base: this computer never synced; its counts may overlap the cloud's, so the larger wins
|
|
89
|
+
const add = (b, l, r) => (b == null ? Math.max(l, r) : Math.max(0, b + (l - b) + (r - b)));
|
|
90
|
+
return { born, xp: add(base?.xp, local.xp, remote.xp), stats: Object.fromEntries(STATS.map((k) => [k, add(base?.stats?.[k], local.stats[k], remote.stats?.[k] || 0)])) };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** @returns the merged state, with when each setting last changed (settingsAt) */
|
|
94
|
+
export function merge(base, local, remote, localAt = Date.now()) {
|
|
95
|
+
const settings = {};
|
|
96
|
+
const settingsAt = {};
|
|
97
|
+
for (const k of SETTINGS) {
|
|
98
|
+
const l = local.settings[k];
|
|
99
|
+
const r = remote?.settings?.[k];
|
|
100
|
+
const b = base?.settings?.[k];
|
|
101
|
+
const rAt = remote?.settingsAt?.[k] || 0;
|
|
102
|
+
let useLocal;
|
|
103
|
+
if (r === undefined) useLocal = true;
|
|
104
|
+
// first sync here: what 7ots.com has wins (your settings from another computer), unless only this side was customized
|
|
105
|
+
else if (!base) useLocal = same(shared(k, r), shared(k, CONFIG_DEFAULTS[k])) && !same(l, shared(k, CONFIG_DEFAULTS[k]));
|
|
106
|
+
else {
|
|
107
|
+
const lc = !same(l, b);
|
|
108
|
+
const rc = !same(r, b);
|
|
109
|
+
useLocal = lc && rc ? localAt > rAt : lc;
|
|
110
|
+
}
|
|
111
|
+
settings[k] = useLocal ? l : r;
|
|
112
|
+
settingsAt[k] = useLocal ? (base && same(l, b) ? base.settingsAt?.[k] || rAt : localAt) : rAt;
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
v: 1,
|
|
116
|
+
settings,
|
|
117
|
+
settingsAt,
|
|
118
|
+
progress: mergeProgress(base?.progress, local.progress, remote?.progress),
|
|
119
|
+
...Object.fromEntries(Object.keys(LISTS).map((k) => [k, mergeList(k, base?.[k], local[k], remote?.[k])])),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Writes what changed here. @returns the sections it wrote */
|
|
124
|
+
function apply(next, local, pet) {
|
|
125
|
+
const wrote = [];
|
|
126
|
+
if (!same(next.settings, local.settings)) {
|
|
127
|
+
const now = loadConfig();
|
|
128
|
+
const mine = Object.fromEntries(LOCAL_ACCESS.map((a) => [a, now.access[a]]));
|
|
129
|
+
saveConfig({ ...now, ...next.settings, access: { ...shared('access', next.settings.access), ...mine } });
|
|
130
|
+
wrote.push('settings');
|
|
131
|
+
}
|
|
132
|
+
if (!same(next.progress, local.progress)) {
|
|
133
|
+
const p = pet || readJson(homeFile('pet.json')) || {};
|
|
134
|
+
Object.assign(p, levelOf(next.progress.xp), { born: next.progress.born, stats: { ...p.stats, ...next.progress.stats } });
|
|
135
|
+
if (!pet) writeJson(homeFile('pet.json'), p);
|
|
136
|
+
wrote.push('progress');
|
|
137
|
+
}
|
|
138
|
+
for (const [k, l] of Object.entries(LISTS)) {
|
|
139
|
+
if (same(next[k], local[k])) continue;
|
|
140
|
+
writeJson(homeFile(l.file), next[k]);
|
|
141
|
+
wrote.push(k);
|
|
142
|
+
}
|
|
143
|
+
return wrote;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* One round. `pet`: the running pet's tamagotchi (it saves it itself, so progress goes there, not to the file).
|
|
148
|
+
* @returns {Promise<{action: 'off'|'same'|'push'|'pull', wrote?: string[]}>} pull = something changed here
|
|
149
|
+
*/
|
|
150
|
+
export async function syncDesktop({ pet } = {}) {
|
|
151
|
+
const otsId = loadConfig().account?.otsId;
|
|
152
|
+
if (!signedIn() || !otsId) return { action: 'off' };
|
|
153
|
+
const file = homeFile('sync-desktop.json');
|
|
154
|
+
const saved = readJson(file) || {};
|
|
155
|
+
const base = saved.otsId === otsId ? saved.state : null;
|
|
156
|
+
const local = localState(pet);
|
|
157
|
+
const localAt = Math.max(mtime('config.json'), 1);
|
|
158
|
+
const path = `/ots/${encodeURIComponent(otsId)}/desktop`;
|
|
159
|
+
let { state: remote, rev } = await api(path);
|
|
160
|
+
let next;
|
|
161
|
+
let pushed = false;
|
|
162
|
+
for (let tries = 0; ; tries++) {
|
|
163
|
+
next = merge(base, local, remote, localAt);
|
|
164
|
+
if (same(next, remote)) break;
|
|
165
|
+
try {
|
|
166
|
+
({ rev } = await api(path, { method: 'PUT', body: { state: next, rev } }));
|
|
167
|
+
pushed = true;
|
|
168
|
+
break;
|
|
169
|
+
} catch (e) {
|
|
170
|
+
if (e.status !== 409 || tries >= 2) throw e;
|
|
171
|
+
({ state: remote, rev } = e.data); // another computer wrote meanwhile: merge with that
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const wrote = apply(next, local, pet);
|
|
175
|
+
writeJson(file, { otsId, rev, at: Date.now(), state: next });
|
|
176
|
+
return { action: wrote.length ? 'pull' : pushed ? 'push' : 'same', wrote };
|
|
177
|
+
}
|
package/cli/lib/i18n.mjs
CHANGED
|
@@ -16,9 +16,11 @@ const M = {
|
|
|
16
16
|
7ots pet --tmux the terminal pet in a tmux side pane
|
|
17
17
|
7ots feed | play | sleep | wake | say <text> | stop
|
|
18
18
|
7ots dance [name] [--ms N] [--no-music] [--list] | entrance [--dance name]
|
|
19
|
+
7ots aura [sixseven|mewing|tikio|garza|deal|siu] [--no-music] [--list] aura farming (+aura, its own counter; phonk, or your tracks in ~/.7ots/music/aura)
|
|
19
20
|
7ots status [--line|--json] pet state (--line: one line for tmux)
|
|
20
21
|
7ots ask <text> talk to it: "remind me to check email in 10 min", "open my calendar", "remember that…"
|
|
21
22
|
7ots reminders [--cancel <id>] pending reminders and what it remembers
|
|
23
|
+
7ots senses [status|rules|pause [min]|resume|reflect|forget] what it notices (camera, apps, mail) and its rules
|
|
22
24
|
7ots config [--print] settings page: brain, what it can see, notes
|
|
23
25
|
7ots hooks install|remove [--claude] [--shell] [--global]
|
|
24
26
|
7ots meet --new | "<invite or call URL>" join apuchat meet with this identity
|
|
@@ -104,6 +106,7 @@ Docs: https://7ots.com/llms.txt`,
|
|
|
104
106
|
'err.unknown': 'Unknown command "{cmd}". Try: 7ots help',
|
|
105
107
|
'err.noPet': 'The pet is not awake. Start it with: 7ots pet',
|
|
106
108
|
'pet.settings': 'Opening the settings in your browser.',
|
|
109
|
+
'usage.senses': '7ots senses [status|rules|pause [min]|resume|reflect|forget] [--json]\n\n Turn them on in settings → Senses (7ots config).',
|
|
107
110
|
'usage.ask': '7ots ask <text>\n\n e.g. 7ots ask "remind me to check email in 10 minutes and open it"\n 7ots ask "remember that Fridays we demo" · 7ots ask "my reminders"\n Seeing your screen or processes: coming soon.',
|
|
108
111
|
'err.noIdentity': 'No identity yet. Create one with "7ots new" or run "7ots setup".',
|
|
109
112
|
'w.title': '7ots setup — {name}',
|
|
@@ -207,9 +210,11 @@ Docs: https://7ots.com/llms.txt`,
|
|
|
207
210
|
7ots pet --tmux la mascota de terminal en un panel de tmux
|
|
208
211
|
7ots feed | play | sleep | wake | say <texto> | stop
|
|
209
212
|
7ots dance [nombre] [--ms N] [--no-music] [--list] | entrance [--dance nombre]
|
|
213
|
+
7ots aura [sixseven|mewing|tikio|garza|deal|siu] [--no-music] [--list] farmeo de aura (+aura, su propio contador; phonk, o tus temas en ~/.7ots/music/aura)
|
|
210
214
|
7ots status [--line|--json] estado (--line: una línea para tmux)
|
|
211
215
|
7ots ask <texto> háblale: "recuérdame ver el correo en 10 min", "abre mi calendario", "anota que…"
|
|
212
216
|
7ots reminders [--cancel <id>] recordatorios pendientes y lo que recuerda
|
|
217
|
+
7ots senses [status|rules|pause [min]|resume|reflect|forget] lo que nota (cámara, apps, correo) y sus reglas
|
|
213
218
|
7ots config [--print] ajustes: cerebro, qué puede ver, notas
|
|
214
219
|
7ots hooks install|remove [--claude] [--shell] [--global]
|
|
215
220
|
7ots meet --new | "<invitación o enlace>" entra a apuchat meet con esta identidad
|
|
@@ -295,6 +300,7 @@ Docs: https://7ots.com/llms.txt`,
|
|
|
295
300
|
'err.unknown': 'Comando desconocido «{cmd}». Prueba: 7ots help',
|
|
296
301
|
'err.noPet': 'La mascota no está despierta. Iníciala con: 7ots pet',
|
|
297
302
|
'pet.settings': 'Abriendo los ajustes en tu navegador.',
|
|
303
|
+
'usage.senses': '7ots senses [status|rules|pause [min]|resume|reflect|forget] [--json]\n\n Se activan en ajustes → Sentidos (7ots config).',
|
|
298
304
|
'usage.ask': '7ots ask <texto>\n\n ej. 7ots ask "recuérdame ver el correo en 10 minutos y ábrelo"\n 7ots ask "anota que los viernes hay demo" · 7ots ask "mis recordatorios"\n Ver tu pantalla o tus procesos: muy pronto.',
|
|
299
305
|
'err.noIdentity': 'Aún no hay identidad. Crea una con «7ots new» o corre «7ots setup».',
|
|
300
306
|
'w.title': 'Configuración de 7ots — {name}',
|
|
@@ -398,9 +404,11 @@ Docs: https://7ots.com/llms.txt`,
|
|
|
398
404
|
7ots pet --tmux o bichinho de terminal num painel do tmux
|
|
399
405
|
7ots feed | play | sleep | wake | say <texto> | stop
|
|
400
406
|
7ots dance [nombre] [--ms N] [--no-music] [--list] | entrance [--dance nombre]
|
|
407
|
+
7ots aura [sixseven|mewing|tikio|garza|deal|siu] [--no-music] [--list] farmar aura (+aura, seu próprio contador; phonk, ou suas músicas em ~/.7ots/music/aura)
|
|
401
408
|
7ots status [--line|--json] estado (--line: uma linha para tmux)
|
|
402
409
|
7ots ask <texto> fale com ele: "me lembre de ver o e-mail em 10 min", "abra minha agenda", "anote que…"
|
|
403
410
|
7ots reminders [--cancel <id>] lembretes pendentes e o que ele lembra
|
|
411
|
+
7ots senses [status|rules|pause [min]|resume|reflect|forget] o que ele nota (câmera, apps, e-mail) e suas regras
|
|
404
412
|
7ots config [--print] ajustes: cérebro, o que pode ver, notas
|
|
405
413
|
7ots hooks install|remove [--claude] [--shell] [--global]
|
|
406
414
|
7ots meet --new | "<convite ou link>" entra no apuchat meet com esta identidade
|
|
@@ -486,6 +494,7 @@ Docs: https://7ots.com/llms.txt`,
|
|
|
486
494
|
'err.unknown': 'Comando desconhecido «{cmd}». Tente: 7ots help',
|
|
487
495
|
'err.noPet': 'O bichinho não está acordado. Inicie com: 7ots pet',
|
|
488
496
|
'pet.settings': 'Abrindo os ajustes no seu navegador.',
|
|
497
|
+
'usage.senses': '7ots senses [status|rules|pause [min]|resume|reflect|forget] [--json]\n\n Ative em ajustes → Sentidos (7ots config).',
|
|
489
498
|
'usage.ask': '7ots ask <texto>\n\n ex. 7ots ask "me lembre de ver o e-mail em 10 minutos e abra"\n 7ots ask "anote que às sextas tem demo" · 7ots ask "meus lembretes"\n Ver sua tela ou processos: em breve.',
|
|
490
499
|
'err.noIdentity': 'Ainda não há identidade. Crie uma com «7ots new» ou rode «7ots setup».',
|
|
491
500
|
'w.title': 'Configuração do 7ots — {name}',
|
package/cli/lib/inferences.mjs
CHANGED
|
@@ -34,8 +34,9 @@ export function otherInferences() {
|
|
|
34
34
|
} catch {}
|
|
35
35
|
const host = companion ? [{ home: root, id: readJson(join(root, 'config.json'))?.account?.otsId || 'local' }] : [];
|
|
36
36
|
return [...host, ...ids.map((id) => ({ home: join(dir, id), id }))].flatMap(({ home, id }) => {
|
|
37
|
-
const
|
|
38
|
-
|
|
37
|
+
const idy = readJson(join(home, 'identity.json'));
|
|
38
|
+
const ot = { id, name: idy?.name || id, character: idy?.look?.character || null }; // its look: settings draws it on the filter
|
|
39
|
+
return readRows(join(home, 'inferences.jsonl')).map((r) => ({ ...r, ot }));
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -84,6 +85,22 @@ export function createInferenceLog() {
|
|
|
84
85
|
throw e;
|
|
85
86
|
}
|
|
86
87
|
},
|
|
88
|
+
// long local work (only CLI brains have it); undefined otherwise so callers fall back to the cloud
|
|
89
|
+
get work() {
|
|
90
|
+
if (typeof getBrain().work !== 'function') return undefined;
|
|
91
|
+
return async (prompt, o) => {
|
|
92
|
+
const t0 = Date.now();
|
|
93
|
+
const row = { at: t0, purpose: 'work', brain: label(), input: [{ role: 'user', content: cut(prompt, 8000) }] };
|
|
94
|
+
try {
|
|
95
|
+
const text = await getBrain().work(prompt, o);
|
|
96
|
+
add({ ...row, ok: true, output: cut(text, 4000), ms: Date.now() - t0 });
|
|
97
|
+
return text;
|
|
98
|
+
} catch (e) {
|
|
99
|
+
add({ ...row, ok: false, error: cut(e.message, 300), ms: Date.now() - t0 });
|
|
100
|
+
throw e;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
},
|
|
87
104
|
};
|
|
88
105
|
}
|
|
89
106
|
|
package/cli/lib/integrations.mjs
CHANGED
|
@@ -30,6 +30,7 @@ import { homedir } from 'node:os';
|
|
|
30
30
|
import { env, loadConfig, loadKeys } from './config.mjs';
|
|
31
31
|
import { SEVENOTS_URL, me as accountMe, signedIn } from './account.mjs';
|
|
32
32
|
import { mcpCall, mcpTools, mcpToolsCached } from './mcp.mjs';
|
|
33
|
+
import { recordUse } from './tooluse.mjs';
|
|
33
34
|
|
|
34
35
|
const LETTA_URL = (process.env.LETTA_BASE_URL || 'https://api.letta.com').replace(/\/+$/, '');
|
|
35
36
|
const APUMAIL_API = (process.env.APUMAIL_API || 'https://api.apumail.com').replace(/\/+$/, '');
|
|
@@ -222,7 +223,7 @@ export async function readLogs({ source, target }) {
|
|
|
222
223
|
const isAcctToken = (t) => typeof t === 'string' && t.startsWith('acct_');
|
|
223
224
|
|
|
224
225
|
/** An inbox token reads that inbox; an account token (`acct_…`) reads that inbox, or all of the account's when none is set. */
|
|
225
|
-
export async function
|
|
226
|
+
export async function mailMessages(inbox, { n = 8 } = {}) {
|
|
226
227
|
const token = env().APUMAIL_TOKEN;
|
|
227
228
|
const all = !inbox && isAcctToken(token);
|
|
228
229
|
if (!token || (!inbox && !all)) throw new Error('email is not connected');
|
|
@@ -231,9 +232,18 @@ export async function readMail(inbox, { n = 8 } = {}) {
|
|
|
231
232
|
if (!res.ok) throw new Error(`apumail ${res.status}`);
|
|
232
233
|
const { messages = [] } = await res.json();
|
|
233
234
|
// all-mail comes newest first; an inbox's wait, oldest first.
|
|
234
|
-
return (all ? messages.slice(0, n) : messages.slice(-n).reverse())
|
|
235
|
-
|
|
236
|
-
.
|
|
235
|
+
return (all ? messages.slice(0, n) : messages.slice(-n).reverse()).map((m) => ({
|
|
236
|
+
id: String(m.id ?? m.message_id ?? `${m.received_at}|${m.from}|${m.subject}`),
|
|
237
|
+
at: Number(m.received_at) || Date.parse(m.received_at) || 0,
|
|
238
|
+
to: all ? str(m._addr, 120) : '',
|
|
239
|
+
from: str(m.from, 120),
|
|
240
|
+
subject: str(m.subject, 160),
|
|
241
|
+
text: str(m.text, 300).replace(/\s+/g, ' '),
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export async function readMail(inbox, { n = 8 } = {}) {
|
|
246
|
+
return (await mailMessages(inbox, { n })).map((m) => `- ${new Date(m.at).toLocaleString()} · ${m.to ? `${m.to} ← ` : ''}${m.from} · ${m.subject || '(no subject)'}\n ${m.text}`).join('\n');
|
|
237
247
|
}
|
|
238
248
|
|
|
239
249
|
/** The ot's apuchat / email conversations on 7ots.com (device token), as text for the brain. */
|
|
@@ -294,6 +304,16 @@ export async function cloudStatus(config = loadConfig()) {
|
|
|
294
304
|
}
|
|
295
305
|
const id = config.account?.otsId;
|
|
296
306
|
if (!id || !out.signedIn) return out;
|
|
307
|
+
// what 7ots pays for this ot (its AI when it has no key of its own) and how much is left
|
|
308
|
+
try {
|
|
309
|
+
const res = await fetch(`${SEVENOTS_URL}/api/device/ots/${encodeURIComponent(id)}/quota`, { headers: { Authorization: `Bearer ${env().SEVENOTS_TOKEN}` }, signal: AbortSignal.timeout(10000) });
|
|
310
|
+
if (res.ok) {
|
|
311
|
+
const q = await res.json().catch(() => null);
|
|
312
|
+
const n = (v) => Math.max(0, Math.round(Number(v) || 0));
|
|
313
|
+
const pair = (x) => ({ used: n(x?.used), free: n(x?.free) });
|
|
314
|
+
if (q) out.quota = { platformLlm: !!q.platformLlm, unlimited: !!q.unlimited, messages: pair(q.messages), tts: pair(q.tts), games: pair(q.games) };
|
|
315
|
+
}
|
|
316
|
+
} catch {}
|
|
297
317
|
try {
|
|
298
318
|
const res = await fetch(`${SEVENOTS_URL}/api/device/ots/${encodeURIComponent(id)}/vm`, { headers: { Authorization: `Bearer ${env().SEVENOTS_TOKEN}` }, signal: AbortSignal.timeout(10000) });
|
|
299
319
|
if (res.ok) {
|
|
@@ -333,6 +353,26 @@ export async function cloudByte(config = loadConfig(), sub = '', { method = 'GET
|
|
|
333
353
|
return { available: true, ...data };
|
|
334
354
|
}
|
|
335
355
|
|
|
356
|
+
/**
|
|
357
|
+
* The plaza (the ots' social network on 7ots.com): how the twin ot takes part — on, autopilot, what it may post,
|
|
358
|
+
* comments, language, tool sharing. GET /api/device/plaza/settings?ot= · POST { ot, …changes } (server/platform/plaza.mjs).
|
|
359
|
+
*/
|
|
360
|
+
export async function cloudPlaza(config = loadConfig(), { method = 'GET', body } = {}) {
|
|
361
|
+
const id = config.account?.otsId;
|
|
362
|
+
if (!signedIn() || !id) return { available: false };
|
|
363
|
+
const q = method === 'GET' ? `?ot=${encodeURIComponent(id)}` : '';
|
|
364
|
+
const res = await fetch(`${SEVENOTS_URL}/api/device/plaza/settings${q}`, {
|
|
365
|
+
method,
|
|
366
|
+
headers: { Authorization: `Bearer ${env().SEVENOTS_TOKEN}`, ...(body ? { 'Content-Type': 'application/json' } : {}) },
|
|
367
|
+
body: body ? JSON.stringify({ ...body, ot: id }) : undefined,
|
|
368
|
+
signal: AbortSignal.timeout(20000),
|
|
369
|
+
});
|
|
370
|
+
if (res.status === 404 || res.status === 401) return { available: false };
|
|
371
|
+
const data = await res.json().catch(() => ({}));
|
|
372
|
+
if (!res.ok) throw Object.assign(new Error(data.error || `7ots.com ${res.status}`), { status: res.status });
|
|
373
|
+
return { available: true, url: SEVENOTS_URL, ...data };
|
|
374
|
+
}
|
|
375
|
+
|
|
336
376
|
// ── Letta (persona memory) ──
|
|
337
377
|
// Contract (docs.letta.com): Bearer LETTA_API_KEY
|
|
338
378
|
// POST /v1/agents { name, memory_blocks: [{ label, value }], model, embedding } → { id }
|
|
@@ -535,9 +575,11 @@ export function createExtras({ config, brain, system, onLater, confirm = null, c
|
|
|
535
575
|
}
|
|
536
576
|
// anything that may change something gets the human's OK first
|
|
537
577
|
if (!/^(get|list|search|read|fetch|find|query|describe|show|lookup|count)[\w-]*$/i.test(a.tool) && !(await ask(lang, 'mcp', x.name, a.tool, cut(JSON.stringify(a.args || {}), 140)))) return { data: `(they rejected calling ${a.tool}: do not call it)` };
|
|
538
|
-
|
|
578
|
+
const out = await timed(x.url, () => mcpCall(x, customToken(x), a.tool, a.args), (r) => !r.startsWith('ERROR: '));
|
|
579
|
+
return { data: `${x.name} · ${a.tool}:\n${redact(out).slice(0, MAX_OUT) || '(empty)'}` };
|
|
539
580
|
}
|
|
540
|
-
|
|
581
|
+
const out = await timed(x.url, () => runCustom(x, a.path), (r) => !/^HTTP [45]\d\d/.test(r));
|
|
582
|
+
return { data: `${x.name}:\n${out || '(empty)'}` };
|
|
541
583
|
}
|
|
542
584
|
} catch (e) {
|
|
543
585
|
return { data: `(${a.type} failed: ${redact(e.message).slice(0, 200)})` };
|
|
@@ -557,4 +599,17 @@ function say(lang, k, ...v) {
|
|
|
557
599
|
return typeof L[k] === 'function' ? L[k](...v) : L[k];
|
|
558
600
|
}
|
|
559
601
|
|
|
602
|
+
// with access.prowl: host, ok and latency of remote integrations (tooluse.mjs); stdio commands have no url
|
|
603
|
+
async function timed(url, fn, ok) {
|
|
604
|
+
const t0 = Date.now();
|
|
605
|
+
try {
|
|
606
|
+
const r = await fn();
|
|
607
|
+
recordUse(url, ok(r), Date.now() - t0);
|
|
608
|
+
return r;
|
|
609
|
+
} catch (e) {
|
|
610
|
+
recordUse(url, false, Date.now() - t0);
|
|
611
|
+
throw e;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
560
615
|
const cut = (s, n) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
|