@audiofool/moondog 0.2.2 → 0.3.0-beta.2
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/NOTICE +12 -0
- package/README.md +3 -2
- package/licenses/stability-ai-community-license.md +58 -0
- package/package.json +3 -1
- package/scripts/moondog.mjs +118 -3
- package/src/core/apple-projection-domain-services.mjs +14 -0
- package/src/core/capability-catalog.mjs +55 -0
- package/src/core/listening-profile-domain-services.mjs +12 -0
- package/src/core/moondog-application.mjs +244 -11
- package/src/i18n/messages/de.mjs +3 -0
- package/src/i18n/messages/en.mjs +4 -0
- package/src/i18n/messages/es.mjs +3 -0
- package/src/i18n/messages/fr.mjs +3 -0
- package/src/i18n/messages/it.mjs +3 -0
- package/src/i18n/messages/ja.mjs +3 -0
- package/src/i18n/messages/ko.mjs +3 -0
- package/src/i18n/messages/pt.mjs +3 -0
- package/src/i18n/messages/zh-Hant.mjs +3 -0
- package/src/i18n/messages/zh.mjs +3 -0
- package/src/i18n/screen/es.mjs +33 -0
- package/src/i18n/screen/ja.mjs +33 -0
- package/src/i18n/screen/pt.mjs +33 -0
- package/src/i18n/screen/zh.mjs +33 -0
- package/src/integrations/apple-music/terminal-preview-player.mjs +40 -11
- package/src/integrations/netease/ncm-cli-player.mjs +12 -6
- package/src/integrations/stable-audio/local-generator.mjs +758 -0
- package/src/profile/moondog-suggestions.mjs +9 -0
- package/src/profile/taste-compiler.mjs +197 -0
- package/src/runtime/pi/agent-runtime.mjs +278 -9
- package/src/surfaces/cli/command-completions.mjs +1 -0
- package/src/surfaces/cli/format-output.mjs +1 -0
- package/src/surfaces/cli/tui.mjs +138 -17
package/NOTICE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Moondog
|
|
2
|
+
Copyright 2026 Audiofool.
|
|
3
|
+
|
|
4
|
+
Moondog can make music with Stable Audio 3 by Stability AI.
|
|
5
|
+
Listeners install Stable Audio 3 and its weights on their own Mac; Moondog does not include them.
|
|
6
|
+
|
|
7
|
+
This Stability AI Model is licensed under the Stability AI Community License, Copyright © Stability AI Ltd. All Rights Reserved
|
|
8
|
+
|
|
9
|
+
A copy of the Stability AI Community License is in licenses/stability-ai-community-license.md.
|
|
10
|
+
|
|
11
|
+
Stable Audio 3 uses the T5Gemma text encoder.
|
|
12
|
+
Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">Moondog</h1>
|
|
6
6
|
|
|
7
|
-
<p align="center">
|
|
7
|
+
<p align="center">Source candidate 0.3.0-beta.2</p>
|
|
8
8
|
|
|
9
9
|
<p align="center"><strong>A listening room that shows its work.</strong></p>
|
|
10
10
|
|
|
@@ -33,7 +33,7 @@ npm ci
|
|
|
33
33
|
npm start
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
[@audiofool/moondog](https://www.npmjs.com/package/@audiofool/moondog) 0.2.
|
|
36
|
+
[@audiofool/moondog](https://www.npmjs.com/package/@audiofool/moondog) 0.2.2 is the published package; `npm install --global @audiofool/moondog` installs it.
|
|
37
37
|
To see the agent work through fictional data, with no sign-in at all, run `npm run demo` from the checkout.
|
|
38
38
|
|
|
39
39
|
The source version supports `moondog update` and `/update`, with stable (`latest`) and preview (`beta`) channels.
|
|
@@ -212,3 +212,4 @@ Your profile, and anything Moondog remembers, carry over.
|
|
|
212
212
|
|
|
213
213
|
Moondog is open source under the [Apache License 2.0](LICENSE).
|
|
214
214
|
Copyright 2026 Audiofool.
|
|
215
|
+
Music making runs Stable Audio 3, which you install yourself; [NOTICE](NOTICE) holds its attribution, and [licenses/](licenses/stability-ai-community-license.md) holds the Stability AI Community License.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
STABILITY AI COMMUNITY LICENSE AGREEMENT
|
|
2
|
+
|
|
3
|
+
Last Updated: July 5, 2024
|
|
4
|
+
|
|
5
|
+
1. INTRODUCTION
|
|
6
|
+
|
|
7
|
+
This Agreement applies to any individual person or entity (“You”, “Your” or “Licensee”) that uses or distributes any portion or element of the Stability AI Materials or Derivative Works thereof for any Research & Non-Commercial or Commercial purpose. Capitalized terms not otherwise defined herein are defined in Section V below.
|
|
8
|
+
|
|
9
|
+
This Agreement is intended to allow research, non-commercial, and limited commercial uses of the Models free of charge. In order to ensure that certain limited commercial uses of the Models continue to be allowed, this Agreement preserves free access to the Models for people or organizations generating annual revenue of less than US $1,000,000 (or local currency equivalent).
|
|
10
|
+
|
|
11
|
+
By clicking “I Accept” or by using or distributing or using any portion or element of the Stability Materials or Derivative Works, You agree that You have read, understood and are bound by the terms of this Agreement. If You are acting on behalf of a company, organization or other entity, then “You” includes you and that entity, and You agree that You: (i) are an authorized representative of such entity with the authority to bind such entity to this Agreement, and (ii) You agree to the terms of this Agreement on that entity’s behalf.
|
|
12
|
+
|
|
13
|
+
2. RESEARCH & NON-COMMERCIAL USE LICENSE
|
|
14
|
+
|
|
15
|
+
Subject to the terms of this Agreement, Stability AI grants You a non-exclusive, worldwide, non-transferable, non-sublicensable, revocable and royalty-free limited license under Stability AI’s intellectual property or other rights owned by Stability AI embodied in the Stability AI Materials to use, reproduce, distribute, and create Derivative Works of, and make modifications to, the Stability AI Materials for any Research or Non-Commercial Purpose. “Research Purpose” means academic or scientific advancement, and in each case, is not primarily intended for commercial advantage or monetary compensation to You or others. “Non-Commercial Purpose” means any purpose other than a Research Purpose that is not primarily intended for commercial advantage or monetary compensation to You or others, such as personal use (i.e., hobbyist) or evaluation and testing.
|
|
16
|
+
|
|
17
|
+
3. COMMERCIAL USE LICENSE
|
|
18
|
+
|
|
19
|
+
Subject to the terms of this Agreement (including the remainder of this Section III), Stability AI grants You a non-exclusive, worldwide, non-transferable, non-sublicensable, revocable and royalty-free limited license under Stability AI’s intellectual property or other rights owned by Stability AI embodied in the Stability AI Materials to use, reproduce, distribute, and create Derivative Works of, and make modifications to, the Stability AI Materials for any Commercial Purpose. “Commercial Purpose” means any purpose other than a Research Purpose or Non-Commercial Purpose that is primarily intended for commercial advantage or monetary compensation to You or others, including but not limited to, (i) creating, modifying, or distributing Your product or service, including via a hosted service or application programming interface, and (ii) for Your business’s or organization’s internal operations.
|
|
20
|
+
If You are using or distributing the Stability AI Materials for a Commercial Purpose, You must register with Stability AI at (https://stability.ai/community-license). If at any time You or Your Affiliate(s), either individually or in aggregate, generate more than USD $1,000,000 in annual revenue (or the equivalent thereof in Your local currency), regardless of whether that revenue is generated directly or indirectly from the Stability AI Materials or Derivative Works, any licenses granted to You under this Agreement shall terminate as of such date. You must request a license from Stability AI at (https://stability.ai/enterprise) , which Stability AI may grant to You in its sole discretion. If you receive Stability AI Materials, or any Derivative Works thereof, from a Licensee as part of an integrated end user product, then Section III of this Agreement will not apply to you.
|
|
21
|
+
|
|
22
|
+
4. GENERAL TERMS
|
|
23
|
+
|
|
24
|
+
Your Research, Non-Commercial, and Commercial License(s) under this Agreement are subject to the following terms.
|
|
25
|
+
a. Distribution & Attribution. If You distribute or make available the Stability AI Materials or a Derivative Work to a third party, or a product or service that uses any portion of them, You shall: (i) provide a copy of this Agreement to that third party, (ii) retain the following attribution notice within a "Notice" text file distributed as a part of such copies: "This Stability AI Model is licensed under the Stability AI Community License, Copyright © Stability AI Ltd. All Rights Reserved”, and (iii) prominently display “Powered by Stability AI” on a related website, user interface, blogpost, about page, or product documentation. If You create a Derivative Work, You may add your own attribution notice(s) to the “Notice” text file included with that Derivative Work, provided that You clearly indicate which attributions apply to the Stability AI Materials and state in the “Notice” text file that You changed the Stability AI Materials and how it was modified.
|
|
26
|
+
b. Use Restrictions. Your use of the Stability AI Materials and Derivative Works, including any output or results of the Stability AI Materials or Derivative Works, must comply with applicable laws and regulations (including Trade Control Laws and equivalent regulations) and adhere to the Documentation and Stability AI’s AUP, which is hereby incorporated by reference. Furthermore, You will not use the Stability AI Materials or Derivative Works, or any output or results of the Stability AI Materials or Derivative Works, to create or improve any foundational generative AI model (excluding the Models or Derivative Works).
|
|
27
|
+
c. Intellectual Property.
|
|
28
|
+
(i) Trademark License. No trademark licenses are granted under this Agreement, and in connection with the Stability AI Materials or Derivative Works, You may not use any name or mark owned by or associated with Stability AI or any of its Affiliates, except as required under Section IV(a) herein.
|
|
29
|
+
(ii) Ownership of Derivative Works. As between You and Stability AI, You are the owner of Derivative Works You create, subject to Stability AI’s ownership of the Stability AI Materials and any Derivative Works made by or for Stability AI.
|
|
30
|
+
(iii) Ownership of Outputs. As between You and Stability AI, You own any outputs generated from the Models or Derivative Works to the extent permitted by applicable law.
|
|
31
|
+
(iv) Disputes. If You or Your Affiliate(s) institute litigation or other proceedings against Stability AI (including a cross-claim or counterclaim in a lawsuit) alleging that the Stability AI Materials, Derivative Works or associated outputs or results, or any portion of any of the foregoing, constitutes infringement of intellectual property or other rights owned or licensable by You, then any licenses granted to You under this Agreement shall terminate as of the date such litigation or claim is filed or instituted. You will indemnify and hold harmless Stability AI from and against any claim by any third party arising out of or related to Your use or distribution of the Stability AI Materials or Derivative Works in violation of this Agreement.
|
|
32
|
+
(v) Feedback. From time to time, You may provide Stability AI with verbal and/or written suggestions, comments or other feedback related to Stability AI’s existing or prospective technology, products or services (collectively, “Feedback”). You are not obligated to provide Stability AI with Feedback, but to the extent that You do, You hereby grant Stability AI a perpetual, irrevocable, royalty-free, fully-paid, sub-licensable, transferable, non-exclusive, worldwide right and license to exploit the Feedback in any manner without restriction. Your Feedback is provided “AS IS” and You make no warranties whatsoever about any Feedback.
|
|
33
|
+
d. Disclaimer Of Warranty. UNLESS REQUIRED BY APPLICABLE LAW, THE STABILITY AI MATERIALS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OR LAWFULNESS OF USING OR REDISTRIBUTING THE STABILITY AI MATERIALS, DERIVATIVE WORKS OR ANY OUTPUT OR RESULTS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR USE OF THE STABILITY AI MATERIALS, DERIVATIVE WORKS AND ANY OUTPUT AND RESULTS.
|
|
34
|
+
e. Limitation Of Liability. IN NO EVENT WILL STABILITY AI OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS AGREEMENT, FOR ANY LOST PROFITS OR ANY DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN IF STABILITY AI OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
|
|
35
|
+
f. Term And Termination. The term of this Agreement will commence upon Your acceptance of this Agreement or access to the Stability AI Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein. Stability AI may terminate this Agreement if You are in breach of any term or condition of this Agreement. Upon termination of this Agreement, You shall delete and cease use of any Stability AI Materials or Derivative Works. Section IV(d), (e), and (g) shall survive the termination of this Agreement.
|
|
36
|
+
g. Governing Law. This Agreement will be governed by and constructed in accordance with the laws of the United States and the State of California without regard to choice of law principles, and the UN Convention on Contracts for International Sale of Goods does not apply to this Agreement.
|
|
37
|
+
|
|
38
|
+
5. DEFINITIONS
|
|
39
|
+
|
|
40
|
+
“Affiliate(s)” means any entity that directly or indirectly controls, is controlled by, or is under common control with the subject entity; for purposes of this definition, “control” means direct or indirect ownership or control of more than 50% of the voting interests of the subject entity.
|
|
41
|
+
|
|
42
|
+
"Agreement" means this Stability AI Community License Agreement.
|
|
43
|
+
|
|
44
|
+
“AUP” means the Stability AI Acceptable Use Policy available at (https://stability.ai/use-policy), as may be updated from time to time.
|
|
45
|
+
|
|
46
|
+
"Derivative Work(s)” means (a) any derivative work of the Stability AI Materials as recognized by U.S. copyright laws and (b) any modifications to a Model, and any other model created which is based on or derived from the Model or the Model’s output, including “fine tune” and “low-rank adaptation” models derived from a Model or a Model’s output, but do not include the output of any Model.
|
|
47
|
+
|
|
48
|
+
“Documentation” means any specifications, manuals, documentation, and other written information provided by Stability AI related to the Software or Models.
|
|
49
|
+
|
|
50
|
+
“Model(s)" means, collectively, Stability AI’s proprietary models and algorithms, including machine-learning models, trained model weights and other elements of the foregoing listed on Stability’s Core Models Webpage available at (https://stability.ai/core-models), as may be updated from time to time.
|
|
51
|
+
|
|
52
|
+
"Stability AI" or "we" means Stability AI Ltd. and its Affiliates.
|
|
53
|
+
|
|
54
|
+
"Software" means Stability AI’s proprietary software made available under this Agreement now or in the future.
|
|
55
|
+
|
|
56
|
+
“Stability AI Materials” means, collectively, Stability’s proprietary Models, Software and Documentation (and any portion or combination thereof) made available under this Agreement.
|
|
57
|
+
|
|
58
|
+
“Trade Control Laws” means any applicable U.S. and non-U.S. export control and trade sanctions laws and regulations.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audiofool/moondog",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Local-first personal AI music agent.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
"moondog": "scripts/moondog"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
|
+
"NOTICE",
|
|
22
|
+
"licenses/stability-ai-community-license.md",
|
|
21
23
|
"assets/brand/moondog-logo.svg",
|
|
22
24
|
"contracts/v1",
|
|
23
25
|
"contracts/v2",
|
package/scripts/moondog.mjs
CHANGED
|
@@ -34,6 +34,7 @@ import { runListenerProfileCommand, savedProfileActions } from "../src/surfaces/
|
|
|
34
34
|
import { createWebResearch } from "../src/integrations/web/web-research.mjs";
|
|
35
35
|
import { runWebCommand } from "../src/surfaces/cli/web-command.mjs";
|
|
36
36
|
import { openSpotifyConnection } from "../src/integrations/spotify/connection.mjs";
|
|
37
|
+
import { preferredIdleDevice, thisComputerName } from "../src/integrations/spotify/service.mjs";
|
|
37
38
|
import {
|
|
38
39
|
openSpotifyResolutionCache,
|
|
39
40
|
} from "../src/integrations/spotify/resolution-cache.mjs";
|
|
@@ -53,6 +54,7 @@ import { startListeningUpkeep } from "../src/core/listening-upkeep.mjs";
|
|
|
53
54
|
import { createAppleMusicCatalog } from "../src/integrations/apple-music/catalog.mjs";
|
|
54
55
|
import { createTerminalPreviewPlayer } from "../src/integrations/apple-music/terminal-preview-player.mjs";
|
|
55
56
|
import { createNeteasePlayer } from "../src/integrations/netease/ncm-cli-player.mjs";
|
|
57
|
+
import { createAtmosphereStream, createLocalGenerator } from "../src/integrations/stable-audio/local-generator.mjs";
|
|
56
58
|
import { createMusicAppPlayer } from "../src/integrations/apple-music/music-app.mjs";
|
|
57
59
|
import {
|
|
58
60
|
createOpenMusicSimilarity,
|
|
@@ -451,6 +453,76 @@ async function emitTasteprintArtifact(
|
|
|
451
453
|
return result;
|
|
452
454
|
}
|
|
453
455
|
|
|
456
|
+
// While the terminal's stream runs, the Music app is read this often. Only a change from not playing
|
|
457
|
+
// to playing ends the stream, and only in a read that began after the stream last changed and past its
|
|
458
|
+
// start: the song the first track pauses keeps playing while that track is made.
|
|
459
|
+
const STREAM_MUSIC_APP_MS = 5_000;
|
|
460
|
+
function watchMusicAppForStream(stream, { musicApp, interval = STREAM_MUSIC_APP_MS }) {
|
|
461
|
+
if (musicApp?.available !== true) return () => {};
|
|
462
|
+
let timer = null;
|
|
463
|
+
let reading = false;
|
|
464
|
+
let playing = null;
|
|
465
|
+
let phase = null;
|
|
466
|
+
let changedAt = 0;
|
|
467
|
+
const read = async () => {
|
|
468
|
+
if (reading) return;
|
|
469
|
+
reading = true;
|
|
470
|
+
const began = Date.now();
|
|
471
|
+
try {
|
|
472
|
+
const now = await musicApp.nowPlaying().catch(() => null);
|
|
473
|
+
const view = stream.view();
|
|
474
|
+
if (!view || began <= changedAt) return;
|
|
475
|
+
const playingNow = now?.state === "playing";
|
|
476
|
+
if (playingNow && playing === false && view.phase !== "starting") stream.stop("other_music");
|
|
477
|
+
playing = playingNow;
|
|
478
|
+
} finally {
|
|
479
|
+
reading = false;
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
const unsubscribe = stream.subscribe(({ view }) => {
|
|
483
|
+
changedAt = Date.now();
|
|
484
|
+
// The first track just paused the Music app, so playing at a later read is news.
|
|
485
|
+
if (phase === "starting" && view && view.phase !== "starting") playing = false;
|
|
486
|
+
phase = view?.phase ?? null;
|
|
487
|
+
if (view && !timer) {
|
|
488
|
+
playing = null;
|
|
489
|
+
timer = setInterval(() => void read(), interval);
|
|
490
|
+
timer.unref?.();
|
|
491
|
+
} else if (!view && timer) {
|
|
492
|
+
clearInterval(timer);
|
|
493
|
+
timer = null;
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
return () => {
|
|
497
|
+
unsubscribe();
|
|
498
|
+
clearInterval(timer);
|
|
499
|
+
timer = null;
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Whether a /spotify command starts Spotify on this Mac: play on the device it resumes on (the active one,
|
|
504
|
+
// or with none active the one it would pick), or a move onto this Mac with --play or while Spotify plays (a
|
|
505
|
+
// move keeps playing what plays). A command its own checks refuse, or reads that fail, start nothing here.
|
|
506
|
+
async function spotifyStartsHere(application, args, { signal } = {}) {
|
|
507
|
+
if (!application.spotifyReady?.()) return false;
|
|
508
|
+
// A trailing --json changes only how the result is written.
|
|
509
|
+
if (args.at(-1) === "--json") args = args.slice(0, -1);
|
|
510
|
+
const play = args[0] === "play" && args.length <= 2;
|
|
511
|
+
const transfer = args[0] === "transfer" && args.length >= 2 && args.length <= 3 && (args.length === 2 || args[2] === "--play");
|
|
512
|
+
if (!play && !transfer) return false;
|
|
513
|
+
const service = application.requireSpotifyService();
|
|
514
|
+
const [listed, player] = await Promise.all([service.devices({ signal }).catch(() => null), service.currentPlayer({ signal }).catch(() => null)]);
|
|
515
|
+
const devices = listed?.devices ?? [];
|
|
516
|
+
if (transfer) {
|
|
517
|
+
const device = devices.find((entry) => entry.id === args[1]);
|
|
518
|
+
const playing = player?.state === "available" && player.is_playing === true;
|
|
519
|
+
return Boolean(device) && application.spotifyOnThisMac(device) && (args[2] === "--play" || playing);
|
|
520
|
+
}
|
|
521
|
+
const active = player?.device?.is_active === true ? player.device : devices.find((device) => device.is_active === true);
|
|
522
|
+
const device = active ?? preferredIdleDevice(devices, { thisComputer: await thisComputerName() });
|
|
523
|
+
return Boolean(device) && application.spotifyOnThisMac(device);
|
|
524
|
+
}
|
|
525
|
+
|
|
454
526
|
async function main() {
|
|
455
527
|
const updater = createApplicationUpdater();
|
|
456
528
|
const argv = process.argv.slice(2);
|
|
@@ -850,11 +922,33 @@ async function main() {
|
|
|
850
922
|
const neteasePlayer = createNeteasePlayer();
|
|
851
923
|
const playbackService = await resolvePlaybackService();
|
|
852
924
|
if (playbackService === "netease") await neteasePlayer.check();
|
|
925
|
+
// Moondog makes music on this Mac with the listener's own Stable Audio 3 once they turn it on, in a
|
|
926
|
+
// room that can play what it makes. The terminal and the window each keep one generator, so each
|
|
927
|
+
// makes one track at a time; a choice saved on one side is checked again on the other.
|
|
928
|
+
const localGenerator = previewPlayer ? createLocalGenerator() : null;
|
|
929
|
+
await localGenerator?.check();
|
|
930
|
+
void localGenerator?.sweep().catch(() => {});
|
|
931
|
+
const unwatchGeneration = localGenerator?.watch() ?? (() => {});
|
|
932
|
+
// How each made track landed (played through, skipped, stopped) comes from this room's player.
|
|
933
|
+
await localGenerator?.load();
|
|
934
|
+
const unobservePlayer = localGenerator ? previewPlayer.subscribe?.((event) => localGenerator.observe(event)) : null;
|
|
935
|
+
// Moondog's atmosphere stream: one per room, on its generator and its player, moved along by what the player reports.
|
|
936
|
+
const atmosphereStream = localGenerator && typeof previewPlayer?.enqueueGenerated === "function"
|
|
937
|
+
? createAtmosphereStream({ generator: localGenerator, player: previewPlayer }) : null;
|
|
938
|
+
// After the generator's own observer: the stream may stop the player while an event is still being
|
|
939
|
+
// delivered, and the generator must record that event's outcome first.
|
|
940
|
+
const unobserveStream = atmosphereStream ? previewPlayer.subscribe?.((event) => atmosphereStream.observe(event)) : null;
|
|
941
|
+
// Music making turned off, here or on the other surface, ends the stream.
|
|
942
|
+
const unwatchStreamGeneration = atmosphereStream ? localGenerator.subscribe((status) => { if (status.state !== "ready") atmosphereStream.stop("generation_off"); }) : null;
|
|
943
|
+
// The window watches the Music app for its own stream; the terminal has no window, so while its
|
|
944
|
+
// stream runs it reads the Music app itself, and music the listener starts there ends the stream.
|
|
945
|
+
const unwatchStreamMusicApp = atmosphereStream && !host ? watchMusicAppForStream(atmosphereStream, { musicApp }) : null;
|
|
853
946
|
const playbackSelection = createPlaybackSelection({ service: playbackService, save: writePlaybackPreference });
|
|
854
947
|
// The terminal and the window each run this core on one playback.json. A service chosen on the
|
|
855
|
-
// other side reaches this side's picker and agents, and stops the
|
|
948
|
+
// other side reaches this side's picker and agents, and stops the Apple Music songs this side plays.
|
|
949
|
+
// Moondog's stream is not a service: its made tracks play on.
|
|
856
950
|
const unwatchPlayback = watchPlaybackPreference(playbackSelection, {
|
|
857
|
-
onChange: (service) => { if (service !== "apple_music") previewPlayer?.stop?.(); },
|
|
951
|
+
onChange: (service) => { if (service !== "apple_music" && previewPlayer?.holdsCatalogSongs?.() !== false) previewPlayer?.stop?.(); },
|
|
858
952
|
});
|
|
859
953
|
// The main application and every conversation the window opens beside it are built from
|
|
860
954
|
// this one list, so they cannot drift apart. Each passes in what may change after launch:
|
|
@@ -863,7 +957,7 @@ async function main() {
|
|
|
863
957
|
const spotifyTopArtists = { read_at: null, artists: [] };
|
|
864
958
|
const applicationOptions = ({ domainServices, domainServicesError, spotifyConnection, locale, playbackService }) => ({
|
|
865
959
|
domainServices, domainServicesError, spotifyConnection, locale, playbackService, playbackSelection,
|
|
866
|
-
webResearch, memoryStore, musicCatalog, musicPreviewPlayer: previewPlayer, neteasePlayer, musicSimilarity, artistIdentityResolver,
|
|
960
|
+
webResearch, memoryStore, musicCatalog, musicPreviewPlayer: previewPlayer, neteasePlayer, localGenerator, atmosphereStream, musicSimilarity, artistIdentityResolver,
|
|
867
961
|
spotifyTopArtists, musicApp,
|
|
868
962
|
});
|
|
869
963
|
const application = new MoondogApplication(applicationOptions({
|
|
@@ -1059,6 +1153,13 @@ async function main() {
|
|
|
1059
1153
|
return prepareTuiHistoryImport(undefined, { recentPage, librarySnapshot, libraryUnavailable });
|
|
1060
1154
|
},
|
|
1061
1155
|
openImportHelp,
|
|
1156
|
+
// Local generation: what the room shows and the switch the listener turns, in Settings or with /generation.
|
|
1157
|
+
generation: localGenerator && {
|
|
1158
|
+
status: () => localGenerator.status(),
|
|
1159
|
+
check: () => localGenerator.check(),
|
|
1160
|
+
save: (settings) => localGenerator.save(settings),
|
|
1161
|
+
subscribe: (listener) => localGenerator.subscribe(listener),
|
|
1162
|
+
},
|
|
1062
1163
|
// The room asks whether a Last.fm key is set, and saves one the listener pastes.
|
|
1063
1164
|
lastfm: {
|
|
1064
1165
|
status: async () => {
|
|
@@ -1141,6 +1242,9 @@ async function main() {
|
|
|
1141
1242
|
return json ? `\`\`\`json\n${output.trim()}\n\`\`\`` : output.trim();
|
|
1142
1243
|
},
|
|
1143
1244
|
runSpotify: async (args, { signal, stderr } = {}) => {
|
|
1245
|
+
// /spotify play, and a move onto this Mac that plays there, start Spotify here: the other players go
|
|
1246
|
+
// quiet first. A command its own checks will refuse, or a move to another device, quiets nothing.
|
|
1247
|
+
if (await spotifyStartsHere(application, args, { signal })) await application.quietOtherPlayers("spotify", { signal });
|
|
1144
1248
|
let output = "";
|
|
1145
1249
|
const capture = {
|
|
1146
1250
|
write(value) {
|
|
@@ -1165,6 +1269,17 @@ async function main() {
|
|
|
1165
1269
|
});
|
|
1166
1270
|
} finally {
|
|
1167
1271
|
unwatchPlayback();
|
|
1272
|
+
unwatchGeneration();
|
|
1273
|
+
// A made track still playing is stopped while the generator listens, so its outcome is kept.
|
|
1274
|
+
if (localGenerator) {
|
|
1275
|
+
previewPlayer?.stop?.();
|
|
1276
|
+
await localGenerator.flush?.();
|
|
1277
|
+
}
|
|
1278
|
+
unobservePlayer?.();
|
|
1279
|
+
unobserveStream?.();
|
|
1280
|
+
unwatchStreamGeneration?.();
|
|
1281
|
+
unwatchStreamMusicApp?.();
|
|
1282
|
+
atmosphereStream?.stop("closed");
|
|
1168
1283
|
listeningUpkeep?.stop();
|
|
1169
1284
|
lyrics?.close();
|
|
1170
1285
|
// Conversations close first: their domain services are forks of the main application's.
|
|
@@ -4,6 +4,7 @@ import { createListenerProfileInput, savedListenerChoices } from "../profile/lis
|
|
|
4
4
|
import { lyricSeedsFromProfile } from "./lyric-profile.mjs";
|
|
5
5
|
import { cachedAvoidGate, createAvoidGate, listeningVersion } from "./listener-avoids.mjs";
|
|
6
6
|
import { recordListenerChoice } from "../profile/listener-corrections.mjs";
|
|
7
|
+
import { listenedNames } from "../profile/taste-compiler.mjs";
|
|
7
8
|
import { normalizedTrackTitle } from "./track-title.mjs";
|
|
8
9
|
import { collectionCoverage } from "../profile/music-providers.mjs";
|
|
9
10
|
import { lstat } from "node:fs/promises";
|
|
@@ -1848,6 +1849,19 @@ export class AppleProjectionDomainServices {
|
|
|
1848
1849
|
return (this.#listeningHistoryStore?.listenedTracks?.({ subjectId: this.#subjectId }) ?? []).some(heard => exactTitleArtistMatch(track, heard));
|
|
1849
1850
|
}
|
|
1850
1851
|
|
|
1852
|
+
// Every Avoid in force, imported bans included, as the play paths read them.
|
|
1853
|
+
activeAvoids() {
|
|
1854
|
+
const store = this.#listeningHistoryStore;
|
|
1855
|
+
const avoids = store?.activeAvoidances?.({ subjectId: this.#subjectId }) ?? [];
|
|
1856
|
+
return normalizeAppleCorrectionLabels({ listener_assertions: { avoids } }, this.#projection).listener_assertions.avoids
|
|
1857
|
+
.map((avoid) => ({ stance: "avoid", subject: avoid.entity_type ?? "artist", name: avoid.label, ...(avoid.artist_credit ? { artist: avoid.artist_credit } : {}) }));
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
// Every artist, song and album the listener has played, so a track Moondog makes names none of them.
|
|
1861
|
+
listenedNames() {
|
|
1862
|
+
return listenedNames(this.#listeningHistoryStore?.listenedTracks?.({ subjectId: this.#subjectId }) ?? []);
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1851
1865
|
registerExternalCandidateSet({ tracks, source, excludeKnown = true } = {}) {
|
|
1852
1866
|
if (
|
|
1853
1867
|
!Array.isArray(tracks) ||
|
|
@@ -601,6 +601,55 @@ const catalog = [
|
|
|
601
601
|
label: N_("Save the playlist to Spotify"),
|
|
602
602
|
},
|
|
603
603
|
},
|
|
604
|
+
{
|
|
605
|
+
id: "music.generate.local",
|
|
606
|
+
version: "1",
|
|
607
|
+
state: "enabled",
|
|
608
|
+
effect: "generate_local",
|
|
609
|
+
description:
|
|
610
|
+
"Make an instrumental track on this Mac with the listener's own Stable Audio 3 install, shaped by their taste, and play it in Moondog's player. Stable Audio 3 runs offline; the track stays on this Mac.",
|
|
611
|
+
requires_local_generation: true,
|
|
612
|
+
agent_tool: {
|
|
613
|
+
name: "moondog_make_track",
|
|
614
|
+
label: N_("Make a track"),
|
|
615
|
+
},
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
id: "music.generate.replay",
|
|
619
|
+
version: "1",
|
|
620
|
+
state: "enabled",
|
|
621
|
+
effect: "generate_local",
|
|
622
|
+
description: "Play again a track Moondog made on this Mac, from its own folder.",
|
|
623
|
+
requires_local_generation: true,
|
|
624
|
+
agent_tool: {
|
|
625
|
+
name: "moondog_play_made_track",
|
|
626
|
+
label: N_("Play a track Moondog made"),
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
id: "music.generate.stream",
|
|
631
|
+
version: "1",
|
|
632
|
+
state: "enabled",
|
|
633
|
+
effect: "generate_local",
|
|
634
|
+
description: "Keep making instrumental tracks on this Mac from the listener's taste, one after another, until they stop it or the time runs out.",
|
|
635
|
+
requires_local_generation: true,
|
|
636
|
+
agent_tool: {
|
|
637
|
+
name: "moondog_start_stream",
|
|
638
|
+
label: N_("Start a stream"),
|
|
639
|
+
},
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
id: "music.generate.stream.stop",
|
|
643
|
+
version: "1",
|
|
644
|
+
state: "enabled",
|
|
645
|
+
effect: "generate_local",
|
|
646
|
+
description: "Stop Moondog's stream of tracks made on this Mac.",
|
|
647
|
+
requires_local_generation: true,
|
|
648
|
+
agent_tool: {
|
|
649
|
+
name: "moondog_stop_stream",
|
|
650
|
+
label: N_("Stop the stream"),
|
|
651
|
+
},
|
|
652
|
+
},
|
|
604
653
|
{
|
|
605
654
|
id: "music.generate",
|
|
606
655
|
version: "1",
|
|
@@ -636,7 +685,11 @@ function withRuntimeAvailability(
|
|
|
636
685
|
profileBuildReady,
|
|
637
686
|
musicPreviewReady,
|
|
638
687
|
tasteChoicesReady,
|
|
688
|
+
localGenerationReady,
|
|
639
689
|
) {
|
|
690
|
+
if (capability.requires_local_generation && !localGenerationReady) {
|
|
691
|
+
return { ...capability, state: "blocked", blocked_by: "local_generation_not_ready" };
|
|
692
|
+
}
|
|
640
693
|
if (capability.requires_taste_choices && !tasteChoicesReady) {
|
|
641
694
|
return { ...capability, state: "blocked", blocked_by: "taste_choices_not_ready" };
|
|
642
695
|
}
|
|
@@ -769,6 +822,7 @@ export function listCapabilities({
|
|
|
769
822
|
profileBuildReady = false,
|
|
770
823
|
musicPreviewReady = false,
|
|
771
824
|
tasteChoicesReady = false,
|
|
825
|
+
localGenerationReady = false,
|
|
772
826
|
} = {}) {
|
|
773
827
|
return structuredClone(
|
|
774
828
|
catalog.map((capability) =>
|
|
@@ -791,6 +845,7 @@ export function listCapabilities({
|
|
|
791
845
|
profileBuildReady,
|
|
792
846
|
musicPreviewReady,
|
|
793
847
|
tasteChoicesReady,
|
|
848
|
+
localGenerationReady,
|
|
794
849
|
),
|
|
795
850
|
),
|
|
796
851
|
);
|
|
@@ -4,6 +4,7 @@ import { createListenerProfileInput, savedListenerChoices } from "../profile/lis
|
|
|
4
4
|
import { lyricSeedsFromProfile } from "./lyric-profile.mjs";
|
|
5
5
|
import { cachedAvoidGate, listeningVersion } from "./listener-avoids.mjs";
|
|
6
6
|
import { recordListenerChoice } from "../profile/listener-corrections.mjs";
|
|
7
|
+
import { listenedNames } from "../profile/taste-compiler.mjs";
|
|
7
8
|
|
|
8
9
|
import { isUuid } from "./uuid-v5.mjs";
|
|
9
10
|
import { createListeningHistoryProfileProjection } from "../profile/spotify-archive-taste.mjs";
|
|
@@ -601,6 +602,17 @@ export class ListeningProfileDomainServices {
|
|
|
601
602
|
return (this.#store.listenedTracks?.({ subjectId: this.#subjectId }) ?? []).some(heard => exactTitleArtistMatch(track, heard));
|
|
602
603
|
}
|
|
603
604
|
|
|
605
|
+
// Every Avoid in force, imported bans included, as the play paths read them.
|
|
606
|
+
activeAvoids() {
|
|
607
|
+
return (this.#store.activeAvoidances?.({ subjectId: this.#subjectId }) ?? [])
|
|
608
|
+
.map((avoid) => ({ stance: "avoid", subject: avoid.entity_type ?? "artist", name: avoid.label, ...(avoid.artist_credit ? { artist: avoid.artist_credit } : {}) }));
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// Every artist, song and album the listener has played, so a track Moondog makes names none of them.
|
|
612
|
+
listenedNames() {
|
|
613
|
+
return listenedNames(this.#store.listenedTracks?.({ subjectId: this.#subjectId }) ?? []);
|
|
614
|
+
}
|
|
615
|
+
|
|
604
616
|
registerExternalCandidateSet({ tracks, source, excludeKnown = true } = {}) {
|
|
605
617
|
if (!Array.isArray(tracks) || tracks.length < 1 || tracks.length > HISTORY_MAX_ITEMS) {
|
|
606
618
|
throw new TypeError("External catalog candidates are invalid");
|