@audiofool/moondog 0.3.0-beta.9 → 0.3.1
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/README.md +100 -136
- package/package.json +9 -7
- package/scripts/moondog.mjs +47 -9
- package/src/core/apple-projection-domain-services.mjs +4 -0
- package/src/core/capability-catalog.mjs +46 -14
- package/src/core/host.mjs +30 -0
- package/src/core/library-store.mjs +82 -6
- package/src/core/listening-now.mjs +7 -2
- package/src/core/listening-profile-domain-services.mjs +4 -0
- package/src/core/moondog-application.mjs +412 -144
- package/src/i18n/messages/de.mjs +4 -3
- package/src/i18n/messages/en.mjs +4 -3
- package/src/i18n/messages/es.mjs +4 -3
- package/src/i18n/messages/fr.mjs +4 -3
- package/src/i18n/messages/it.mjs +4 -3
- package/src/i18n/messages/ja.mjs +4 -3
- package/src/i18n/messages/ko.mjs +4 -3
- package/src/i18n/messages/pt.mjs +4 -3
- package/src/i18n/messages/zh-Hant.mjs +4 -3
- package/src/i18n/messages/zh.mjs +4 -3
- package/src/i18n/screen/es.mjs +54 -7
- package/src/i18n/screen/ja.mjs +54 -7
- package/src/i18n/screen/pt.mjs +54 -7
- package/src/i18n/screen/zh.mjs +54 -7
- package/src/importers/zip-reader.mjs +61 -0
- package/src/integrations/apple-music/music-app.mjs +3 -2
- package/src/integrations/lastfm/history.mjs +2 -1
- package/src/integrations/lyrics/lrclib.mjs +1 -1
- package/src/integrations/netease/ncm-cli-player.mjs +62 -20
- package/src/integrations/open-music-similarity/artist-radio.mjs +3 -3
- package/src/integrations/playlist-links.mjs +114 -0
- package/src/integrations/public-playlists.mjs +41 -8
- package/src/integrations/spotify/account-data-history.mjs +63 -57
- package/src/integrations/spotify/authentication.mjs +2 -22
- package/src/integrations/spotify/extended-streaming-history.mjs +48 -40
- package/src/integrations/spotify/history-archive.mjs +2 -13
- package/src/integrations/spotify/service.mjs +88 -58
- package/src/integrations/spotify/web-api-client.mjs +12 -4
- package/src/integrations/user-agent.mjs +6 -0
- package/src/integrations/web/codex-web.mjs +3 -1
- package/src/integrations/web/deepseek-web.mjs +1 -1
- package/src/integrations/web/moondog-web.mjs +57 -0
- package/src/integrations/web/web-research.mjs +106 -22
- package/src/integrations/web/web-result.mjs +61 -12
- package/src/integrations/youtube-music/takeout.mjs +11 -16
- package/src/profile/history-import.mjs +3 -1
- package/src/profile/listening-history-store.mjs +55 -1
- package/src/profile/listening-profile-projection.mjs +1 -1
- package/src/profile/music-import-bundle.mjs +3 -1
- package/src/profile/music-providers.mjs +3 -0
- package/src/runtime/pi/agent-runtime.mjs +247 -148
- package/src/runtime/pi/configured-runtime.mjs +4 -1
- package/src/runtime/pi/image-input.mjs +148 -0
- package/src/runtime/pi/memory-agent-runtime.mjs +1 -1
- package/src/runtime/pi/model-roles.mjs +138 -0
- package/src/runtime/pi/model-settings.mjs +141 -6
- package/src/runtime/pi/model-transport.mjs +9 -0
- package/src/runtime/pi/moondog-model.mjs +159 -0
- package/src/runtime/pi/next-songs.mjs +71 -0
- package/src/runtime/pi/persistent-credential-store.mjs +2 -0
- package/src/runtime/pi/profile-build-runtime.mjs +1 -1
- package/src/runtime/pi/public-model-catalog.mjs +11 -4
- package/src/runtime/pi/runtime-settings.mjs +7 -3
- package/src/surfaces/cli/brand-components.mjs +3 -3
- package/src/surfaces/cli/command-completions.mjs +43 -3
- package/src/surfaces/cli/format-output.mjs +19 -7
- package/src/surfaces/cli/invite-command.mjs +65 -0
- package/src/surfaces/cli/model-roles-command.mjs +60 -0
- package/src/surfaces/cli/tui.mjs +91 -5
package/src/surfaces/cli/tui.mjs
CHANGED
|
@@ -24,6 +24,9 @@ import { getPublicPiModelCatalog } from "../../runtime/pi/public-model-catalog.m
|
|
|
24
24
|
import { serviceKeyProviders, supportedAuthProviderIds } from "../../runtime/pi/authentication.mjs";
|
|
25
25
|
import { EFFORT_LEVELS, EFFORT_SCALE } from "../../runtime/pi/runtime-settings.mjs";
|
|
26
26
|
import { runtimeBehindSelection } from "../../runtime/pi/runtime-selection.mjs";
|
|
27
|
+
import { MODEL_ROLE_WORDS } from "./model-roles-command.mjs";
|
|
28
|
+
import { followChatModel } from "../../runtime/pi/model-roles.mjs";
|
|
29
|
+
import { imagesFromText } from "../../runtime/pi/image-input.mjs";
|
|
27
30
|
import {
|
|
28
31
|
formatLocalResult,
|
|
29
32
|
helpText,
|
|
@@ -123,14 +126,15 @@ const slashCommands = [
|
|
|
123
126
|
{ name: "effort", description: N_("Choose how hard the model thinks") },
|
|
124
127
|
{ name: "auth", description: N_("Sign in to a model or web search service") },
|
|
125
128
|
{ name: "endpoint", description: N_("Add a model service by its address") },
|
|
129
|
+
{ name: "invite", description: N_("Use an invite code for Moondog's own model") },
|
|
126
130
|
{ name: "web", description: N_("Look things up on public music sites") },
|
|
127
131
|
{ name: "service", description: N_("Choose where Moondog plays music") },
|
|
128
132
|
{ name: "library", description: N_("Your saved songs and playlists") },
|
|
129
133
|
{ name: "generation", description: N_("Let Moondog make music on this Mac") },
|
|
130
134
|
{ name: "onair", description: N_("Go on air: Moondog keeps making music from your taste") },
|
|
131
135
|
{ name: "spotify", description: N_("Connect and control Spotify") },
|
|
132
|
-
{ name: "skip", description: N_("Skip to the next song preview") },
|
|
133
|
-
{ name: "stop", description: N_("Stop the song previews") },
|
|
136
|
+
{ name: "skip", description: N_("Skip to the next song preview or stream track") },
|
|
137
|
+
{ name: "stop", description: N_("Stop the song previews or the stream") },
|
|
134
138
|
{ name: "reload", description: N_("Reload model settings and sign-ins") },
|
|
135
139
|
{ name: "remember", description: N_("Ask Moondog to remember something") },
|
|
136
140
|
{ name: "forget", description: N_("Forget one memory by ID") },
|
|
@@ -205,10 +209,12 @@ export async function runMoondogTui({
|
|
|
205
209
|
rebuildRuntime,
|
|
206
210
|
runAuth,
|
|
207
211
|
runEndpoint,
|
|
212
|
+
runInvite,
|
|
208
213
|
runSpotify,
|
|
209
214
|
runProfile,
|
|
210
215
|
runProfileAction,
|
|
211
216
|
runWeb,
|
|
217
|
+
runModelRoles,
|
|
212
218
|
checkUpdates,
|
|
213
219
|
runUpdate,
|
|
214
220
|
lyrics,
|
|
@@ -1089,7 +1095,49 @@ export async function runMoondogTui({
|
|
|
1089
1095
|
setFooter(text, success);
|
|
1090
1096
|
return;
|
|
1091
1097
|
}
|
|
1092
|
-
|
|
1098
|
+
// A playlist link: a copy in the library, and its songs in the listener's taste when they made it or say taste.
|
|
1099
|
+
if (action === "import") {
|
|
1100
|
+
const choice = rest.find((word) => ["taste", "no-taste"].includes(word));
|
|
1101
|
+
const link = rest.filter((word) => word !== choice).join(" ").trim();
|
|
1102
|
+
if (!link) throw new Error(tr("Paste a playlist link after /library import."));
|
|
1103
|
+
setFooter(tr("Reading the playlist…"));
|
|
1104
|
+
const imported = await application.importPlaylistFromLink({ link, ...(choice ? { taste: choice === "taste" } : {}) });
|
|
1105
|
+
const counted = imported.total && imported.total > imported.added
|
|
1106
|
+
? tr("{added} of {total} songs came in.", { added: imported.added, total: imported.total })
|
|
1107
|
+
: tr.n(imported.added, "{count} song came in.", "{count} songs came in.");
|
|
1108
|
+
const taste = imported.taste === "added" ? tr("It now shapes your taste.")
|
|
1109
|
+
: imported.taste === "failed" ? tr("It couldn't shape your taste this time.")
|
|
1110
|
+
: tr("It doesn't shape your taste; add taste after the link if it should.");
|
|
1111
|
+
addMoondogMessage(`${tr("Imported {name}.", { name: imported.playlist.name })} ${counted} ${taste}`);
|
|
1112
|
+
setFooter(tr("Imported {name}.", { name: imported.playlist.name }), success);
|
|
1113
|
+
// A playlist that shapes the taste shows the profile it now reads, as any import into the profile does.
|
|
1114
|
+
if (imported.taste === "added") await openProfile({ imported: true }).catch(() => {});
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
// A copy on Spotify: made by the first export, brought up to date by a later one. replace overwrites a copy changed there.
|
|
1118
|
+
if (action === "export") {
|
|
1119
|
+
const replace = rest.at(-1) === "replace";
|
|
1120
|
+
const wanted = (replace ? rest.slice(0, -1) : rest).join(" ").trim();
|
|
1121
|
+
const [playlist] = application.findLibraryPlaylists(wanted);
|
|
1122
|
+
if (!playlist || !wanted) throw new Error(tr("No playlist is called “{name}”.", { name: wanted }));
|
|
1123
|
+
setFooter(tr("Sending {name} to Spotify…", { name: nameOf(playlist) }));
|
|
1124
|
+
const sent = await application.exportLibraryPlaylist({ playlistId: playlist.id, service: "spotify", replace });
|
|
1125
|
+
if (sent.state === "changed_on_service") {
|
|
1126
|
+
addMoondogMessage(tr("{name} was changed on Spotify since the last export, so nothing was sent. Add replace after the name to overwrite it there.", { name: nameOf(playlist) }));
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
if (!["created", "updated"].includes(sent.state)) {
|
|
1130
|
+
addMoondogMessage(sent.state === "empty" ? tr("{name} has no songs to send.", { name: nameOf(playlist) }) : tr("None of its songs could be found."));
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
const text = sent.state === "updated" ? tr("Updated {name} on Spotify.", { name: nameOf(playlist) }) : tr("{name} is now on Spotify.", { name: nameOf(playlist) });
|
|
1134
|
+
addMoondogMessage([text, tr.n(sent.exported, "{count} song went over.", "{count} songs went over."),
|
|
1135
|
+
sent.not_found ? tr("Some songs couldn't be found.") : "",
|
|
1136
|
+
sent.left_out_made ? tr("Moondog's tracks stay here; Spotify can't hold them.") : "", sent.url].filter(Boolean).join(" "));
|
|
1137
|
+
setFooter(text, success);
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
throw new Error(tr("Use /library, /library play <name>, /library save [playlist], /library import <link>, or /library export <name>."));
|
|
1093
1141
|
};
|
|
1094
1142
|
|
|
1095
1143
|
const removeLifecycleListeners = () => {
|
|
@@ -1421,9 +1469,9 @@ export async function runMoondogTui({
|
|
|
1421
1469
|
// The window's endpoints reach /model here; an agent on an endpoint that changed is rebuilt, since its
|
|
1422
1470
|
// address or key may have. The window's menu list and its per-conversation choices don't move this one.
|
|
1423
1471
|
const stopWatchingModel = watchModelSettings?.((selection, changed) => {
|
|
1424
|
-
if (changed === "models") return;
|
|
1472
|
+
if (changed === "models" || changed === "roles") return;
|
|
1425
1473
|
if (changed === "endpoints") void refreshEndpoints?.();
|
|
1426
|
-
const onEndpoint = changed === "endpoints" && String(runtimeStatus.provider ?? "")
|
|
1474
|
+
const onEndpoint = changed === "endpoints" && /^(?:endpoint-|moondog$)/u.test(String(runtimeStatus.provider ?? ""));
|
|
1427
1475
|
if (!onEndpoint && !runtimeBehindSelection(runtimeStatus, selection)) return;
|
|
1428
1476
|
modelChangedElsewhere = true;
|
|
1429
1477
|
void followModel();
|
|
@@ -1535,6 +1583,8 @@ export async function runMoondogTui({
|
|
|
1535
1583
|
setBusy(true);
|
|
1536
1584
|
setFooter(tr("Loading {model}...", { model: `${providerId}/${modelId}` }));
|
|
1537
1585
|
const status = await replaceRuntime(runtimeSelection(providerId, modelId, runtimeStatus.effort));
|
|
1586
|
+
// Moondog's own model brings its vision and web search, as choosing it in the window does.
|
|
1587
|
+
const followed = await followChatModel({ provider: providerId, model: modelId }, environment).catch(() => []);
|
|
1538
1588
|
say(
|
|
1539
1589
|
status.state === "configured"
|
|
1540
1590
|
? tr("Now talking through `{model}`. This conversation and what I remember carry over.", { model: `${providerId}/${modelId}` })
|
|
@@ -1542,6 +1592,7 @@ export async function runMoondogTui({
|
|
|
1542
1592
|
? tr("Saved `{model}`, but you're not signed in yet. Run `/auth {provider}` to connect it.", { model: `${providerId}/${modelId}`, provider: providerId })
|
|
1543
1593
|
: tr("Saved `{model}`, but I can't reach it yet (`{reason}`).", { model: `${providerId}/${modelId}`, reason: status.reason }),
|
|
1544
1594
|
);
|
|
1595
|
+
if (followed.length) say(tr("Vision and web search are back on auto, where Moondog sees images and searches the web itself. `/model roles` shows them."));
|
|
1545
1596
|
setFooter(
|
|
1546
1597
|
status.state === "configured" ? tr("Model ready.") : tr("Model saved, not connected yet."),
|
|
1547
1598
|
status.state === "configured" ? success : warning,
|
|
@@ -1668,6 +1719,26 @@ export async function runMoondogTui({
|
|
|
1668
1719
|
setFooter(tr("Signed in."), success);
|
|
1669
1720
|
};
|
|
1670
1721
|
|
|
1722
|
+
// The invite code for Moondog's own model: saved once the gateway takes it, shown, or removed.
|
|
1723
|
+
const manageInvite = async (args) => {
|
|
1724
|
+
if (typeof runInvite !== "function") throw new Error(tr("Invite codes aren't available when Moondog is started this way."));
|
|
1725
|
+
if (args.length > 1) throw new Error(tr("Use /invite, /invite <code>, or /invite remove."));
|
|
1726
|
+
const result = await runInvite(args);
|
|
1727
|
+
await refreshEndpoints?.();
|
|
1728
|
+
if (result.action === "remove") {
|
|
1729
|
+
addMoondogMessage(tr("Removed the invite code."));
|
|
1730
|
+
setFooter(tr("Invite code removed."), success);
|
|
1731
|
+
} else if (!result.saved) {
|
|
1732
|
+
addMoondogMessage(tr("No invite code is saved. Type `/invite <code>` to use yours."));
|
|
1733
|
+
} else if (result.action === "save") {
|
|
1734
|
+
addMoondogMessage(result.becameDefault ? tr("Saved. Moondog's own model now answers.")
|
|
1735
|
+
: tr("Saved. Type `/model moondog/moondog` to talk through Moondog's own model."));
|
|
1736
|
+
setFooter(tr("Invite code saved."), success);
|
|
1737
|
+
} else {
|
|
1738
|
+
addMoondogMessage(tr("An invite code is saved. Moondog's own model can answer."));
|
|
1739
|
+
}
|
|
1740
|
+
};
|
|
1741
|
+
|
|
1671
1742
|
// Endpoints: the list, one added on the paused terminal with its key out of sight, or one removed.
|
|
1672
1743
|
// /model then offers their models.
|
|
1673
1744
|
const manageEndpoints = async (args) => {
|
|
@@ -2531,6 +2602,13 @@ export async function runMoondogTui({
|
|
|
2531
2602
|
return;
|
|
2532
2603
|
}
|
|
2533
2604
|
if (command === "model") {
|
|
2605
|
+
// /model roles, vision, web and audio set what other models are for; the rest pick the chat model.
|
|
2606
|
+
if (args[0] && Object.hasOwn(MODEL_ROLE_WORDS, args[0].toLowerCase())) {
|
|
2607
|
+
if (typeof runModelRoles !== "function") throw new Error(tr("Model roles aren't available when Moondog is started this way."));
|
|
2608
|
+
addMoondogMessage(await runModelRoles(args));
|
|
2609
|
+
setFooter(tr("Done."), success);
|
|
2610
|
+
return;
|
|
2611
|
+
}
|
|
2534
2612
|
await selectModel(args);
|
|
2535
2613
|
return;
|
|
2536
2614
|
}
|
|
@@ -2546,6 +2624,10 @@ export async function runMoondogTui({
|
|
|
2546
2624
|
await manageEndpoints(args);
|
|
2547
2625
|
return;
|
|
2548
2626
|
}
|
|
2627
|
+
if (command === "invite") {
|
|
2628
|
+
await manageInvite(args);
|
|
2629
|
+
return;
|
|
2630
|
+
}
|
|
2549
2631
|
if (command === "service") {
|
|
2550
2632
|
await pickService(args);
|
|
2551
2633
|
return;
|
|
@@ -2808,8 +2890,12 @@ export async function runMoondogTui({
|
|
|
2808
2890
|
};
|
|
2809
2891
|
|
|
2810
2892
|
try {
|
|
2893
|
+
// An image path in the message goes with it, as Hermes Agent's terminal does; the words stay.
|
|
2894
|
+
const images = await imagesFromText(value);
|
|
2895
|
+
if (images.length) setFooter(tr("Looking at the attached images... Ctrl+C cancels."));
|
|
2811
2896
|
const result = await activeRuntime.prompt(value, {
|
|
2812
2897
|
...(profileSeed ? { profileSeed } : {}),
|
|
2898
|
+
...(images.length ? { images } : {}),
|
|
2813
2899
|
onTextDelta: (delta) => {
|
|
2814
2900
|
if (cleanedUp) return;
|
|
2815
2901
|
work.quiet();
|