@discord-player/plugin-host 8.0.0-dev.0 → 8.0.0-dev.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 CHANGED
@@ -17,6 +17,39 @@ The `@remedia/client` dependency supplies source descriptor types only.
17
17
  The official `@discord-player/extractor` collection is an optional, separate package.
18
18
  It is neither bundled nor automatically registered.
19
19
 
20
+ ## Using a host from a bot
21
+
22
+ Normal applications do not need to create an HTTP host. Register sources locally
23
+ as before, or configure standalone deployments once in Player options:
24
+
25
+ ```ts
26
+ const player = new Player({
27
+ // Existing Remedia nodes and gateway send callback:
28
+ ...audioOptions,
29
+ sourceHosts: [
30
+ {
31
+ hostId: 'sources-1',
32
+ url: 'https://plugins.example.com',
33
+ token: process.env.SOURCE_TOKEN,
34
+ timeoutMs: 15000,
35
+ },
36
+ ],
37
+ });
38
+
39
+ const result = await player.search('some song', { hostId: 'sources-1' });
40
+ await player.play(channel, result);
41
+ ```
42
+
43
+ This requires `@remedia/client@0.1.0-dev.5` and a matching remote server configured
44
+ with the same `pluginHosts` ID and the `discord-player.source` / `source.stream`
45
+ operation. The bot searches over HTTP and sends an operation descriptor for play
46
+ and automatic crossfade staging. Encoded bytes flow directly from host to audio
47
+ node. Local sources run locally. Embedded nodes cannot play hosted Tracks.
48
+
49
+ See the [complete deployment example](https://discord-player.js.org/docs/plugins/remote-hosts).
50
+ The direct HTTP examples below describe protocol consumers; a bot should use
51
+ `player.search()` and queue playback, without fetching media grants itself.
52
+
20
53
  ## Registration and direct execution
21
54
 
22
55
  ```ts
@@ -24,6 +57,7 @@ import { createSourcePluginHost, SOURCE_PLUGIN_ID } from '@discord-player/plugin
24
57
  import { MyExtractor } from './my-extractor.js';
25
58
  import { mySourcePlugin } from './my-source-plugin.js';
26
59
 
60
+ // Local-only handle() usage may omit hostId.
27
61
  const host = createSourcePluginHost({ name: 'My Source Host' });
28
62
  await host.extractors.register(MyExtractor);
29
63
  await host.plugins.register(mySourcePlugin());
@@ -64,7 +98,7 @@ import { serve } from '@hono/node-server';
64
98
  import { createSourcePluginHost } from '@discord-player/plugin-host';
65
99
  import { MyExtractor } from './my-extractor.js';
66
100
 
67
- const host = createSourcePluginHost({ name: 'Sources', publicUrl: 'http://localhost:3000' });
101
+ const host = createSourcePluginHost({ name: 'Sources', hostId: 'sources-eu-1', publicUrl: 'http://localhost:3000' });
68
102
  await host.extractors.register(MyExtractor);
69
103
  const app = new Hono();
70
104
  app.all('*', (c) => host.fetch(c.req.raw));
@@ -85,7 +119,7 @@ import { createNodeMiddleware } from '@remedia/plugin-host/node';
85
119
  import { createSourcePluginHost } from '@discord-player/plugin-host';
86
120
  import { MyExtractor } from './my-extractor.js';
87
121
 
88
- const host = createSourcePluginHost({ name: 'Sources', publicUrl: 'http://localhost:3000' });
122
+ const host = createSourcePluginHost({ name: 'Sources', hostId: 'sources-eu-1', publicUrl: 'http://localhost:3000' });
89
123
  await host.extractors.register(MyExtractor);
90
124
  const app = express();
91
125
  app.use(createNodeMiddleware(host));
@@ -160,17 +194,36 @@ Direct calls retain native descriptors; HTTP never returns nested Readables.
160
194
 
161
195
  ## Portable metadata and process-local state
162
196
 
163
- HTTP results contain version 1 Track and Playlist data. A `PortableSourceTrack`
164
- adds an optional opaque `sourceState` field. `deserializeSourceResult()` removes
165
- that transport extension before strict versioned deserialization and links the
166
- shared Track instances to their Playlist. For raw `deserialize()`, remove the
167
- `sourceState` extension first. Provider identity remains in `sourceReference`.
168
-
169
- The host retains original Track objects (including `raw.engine`, extractor
170
- identity and metadata callbacks) in a bounded cache: 10000 tracks and one hour by
171
- default, configurable with `maxTrackStates` and `trackStateTtlMs`. Expiration is
172
- checked on use; eviction releases references. Cache entries are invalidated by
173
- provider removal and host shutdown. No media streams are retained by this cache.
197
+ HTTP results contain version 1 Track and Playlist data. `deserializeSourceResult()`
198
+ retains the opaque `sourceState` token on the normal Track and links Playlist
199
+ instances. Pass `serializeSourceTrack(track)` to source operations; no second HTTP
200
+ payload needs to be retained. `serialize()` and `toJSON()` deliberately omit the
201
+ temporary token. Persistence and clones made through persistence reconstruct from
202
+ provider metadata. Ordinary queue/history insertion retains the same Track and its
203
+ token. Host identity persists in `sourceReference.hostId`, separate from
204
+ `sourceReference.pluginId` and the provider's source name/data.
205
+
206
+ HTTP hosts must configure a stable non-secret `hostId`, including deployments
207
+ that do not configure `publicUrl`. Construction with `publicUrl` requires it, and
208
+ `fetch()` rejects HTTP use without it. Local-only `handle()` hosts may omit it and
209
+ receive a generated process identifier that intentionally does not survive restarts. Two hosts
210
+ can use the same provider IDs, but cannot redeem one another's Tracks. The embedded
211
+ registry rejects hosted Tracks when used as local sources. DiscordPlayer routes them
212
+ through configured remote hosts and compatible Remedia nodes instead.
213
+ Do not put endpoints, bearer tokens or credentials in sourceReference.
214
+
215
+ The per-host FIFO cache defaults to 1000 Track states for ten minutes. Previous
216
+ 10000/one-hour defaults could retain substantial provider payloads and playlists.
217
+ Periodic cleanup runs even while idle (at most every 30 seconds), with additional
218
+ checks on use, provider lifetime changes and shutdown. Cached snapshots omit
219
+ Playlist links and metadata callbacks so one entry cannot retain the whole result
220
+ through those links. This is a count limit, not a byte memory guarantee: trusted
221
+ providers can still attach large engines. Tune limits for the deployment.
222
+
223
+ Concurrent remote playback receives copied engine/public metadata, never the
224
+ cached Track itself. Non-cloneable engines are reconstructed instead. Copies use
225
+ snapshot metadata rather than callbacks closing over the original Track. Direct
226
+ execution retains original object identity and the caller's ownership contract.
174
227
 
175
228
  After eviction, expiration, or restart, modern plugins receive reconstructed
176
229
  Track metadata and their portable sourceReference. Legacy extractors re-run
@@ -205,19 +258,91 @@ compatibility surface does not emulate the whole Player API.
205
258
 
206
259
  ## Remedia server integration boundary
207
260
 
208
- The inspected Remedia Rust sources do not implement plugin-host discovery or
209
- source operation routing. Creating a remote Remedia client does not register this
210
- host with an audio server. A bot can call this HTTP protocol explicitly and redeem
211
- the media descriptor, or pass a reachable descriptor URL to supported playback
212
- APIs before the grant expires. Automatic Rust-side routing still requires host
213
- configuration/discovery, authenticated operation execution, sourceReference
214
- round-tripping, cancellation, and timely media-grant redemption. No new Rust API,
215
- custom IPC transport or automatic remote registry is claimed by this package.
261
+ Remedia dev.5 supports generic host discovery, authenticated operation execution,
262
+ native decoding of single-use grants, and cancellation. Configure the deployment
263
+ in the server's `pluginHosts` list and in the bot's `sourceHosts` list. Installing
264
+ `@remedia/plugin-host@0.1.0-dev.5` alone does not register a host with an audio node.
265
+
266
+ DiscordPlayer sends operation descriptors for playback and staged-next preparation;
267
+ the audio node invokes `source.stream` and consumes encoded bytes directly. The
268
+ bot uses HTTP only for metadata and never redeems a playback grant. Host affinity
269
+ is checked during session selection and before playback/staging. Embedded playback
270
+ continues to execute local registrations and rejects remote-host Tracks.
216
271
 
217
272
  ## Validation
218
273
 
219
274
  `pnpm build`, `pnpm typecheck`, `pnpm test`, `pnpm lint`, and `pnpm format:check`
220
- cover the workspace. Source tests use synthetic encoded bytes and local fixtures,
221
- without public media-provider access. CI builds the host before discord-player,
275
+ cover the workspace. Tests include the published optional extractor collection (SDK calls stubbed),
276
+ real HTTP disconnect/shutdown, and real FFmpeg decoding of generated MP3, Ogg/Opus
277
+ and faststart M4A. FFmpeg must be installed; CI installs it explicitly. No personal
278
+ media files or third-party service access are needed. CI builds the host before discord-player,
222
279
  includes its dist artifacts, and publishes it before dependent packages using the
223
280
  shared release inventory.
281
+
282
+ ## Remote media policy
283
+
284
+ `mediaPolicy` denies private, loopback, link-local, reserved and transition IP
285
+ ranges by default. DNS results are checked and the selected address is pinned to
286
+ the connection, preserving TLS hostname verification. Every redirect is checked;
287
+ TLS downgrades and URL user/password credentials are rejected. Optional
288
+ `allowedHosts` restricts exact hostnames. No inbound authorization or provider
289
+ request headers are copied to upstreams. Providers needing custom authorization
290
+ must return an encoded Readable opened by their trusted SDK. Plugins execute
291
+ trusted code and can open their own network/file resources; this policy does not
292
+ sandbox extractor `handle()` or provider-created streams.
293
+
294
+ File descriptors require explicit `allowedFileRoots`. Canonical paths are checked,
295
+ then regular files are opened through owned handles. Authorized roots and parent
296
+ directories must be administrator-owned; concurrent hostile filesystem mutation is
297
+ outside this policy's trust boundary. Default limits are 32 active streams, 512 MiB
298
+ per stream, 30 minutes total, five redirects and 30 seconds upstream socket idle.
299
+ Tune `maxConcurrent`, `maxBytes`, `timeoutMs`, and `allowPrivateNetworks` for trusted
300
+ private deployments. Buffers are already allocated by providers; the host bounds
301
+ output bytes but cannot undo that allocation. Streaming uses backpressure; abort,
302
+ consumer disconnect, byte/deadline errors and host shutdown release resources.
303
+ After headers, errors terminate the body/socket, never masquerade as successful
304
+ JSON responses. Use Remedia's Node middleware to connect network disconnects to
305
+ Fetch cancellation. Configure `token` and HTTPS for remote authorization.
306
+
307
+ Default proxy delivery resolves media on grant redemption. Expired provider
308
+ sources are rejected rather than fetching expired credentials; request a fresh
309
+ `source.stream` grant. Provider expiration survives materialization and stream
310
+ transforms. Grant expiration is a separate deadline managed by Remedia.
311
+ `mediaDelivery: 'direct-url'` enables direct delivery for explicitly declared
312
+ `directUrlProviders` only. Invoking an arbitrary `track.stream` handler may already
313
+ open a Readable, so unknown or mixed-source providers must stay deferred. Declare
314
+ only trusted providers whose handlers return URL metadata without opening media:
315
+
316
+ ```ts
317
+ const host = createSourcePluginHost({
318
+ name: 'Sources',
319
+ hostId: 'sources-eu-1',
320
+ publicUrl: 'https://sources.example.com',
321
+ mediaDelivery: 'direct-url',
322
+ directUrlProviders: ['example.url-provider'],
323
+ });
324
+ ```
325
+
326
+ These providers resolve URL metadata at `source.stream` invocation, never search.
327
+ The dispatcher checks active, unblocked transformations for the actual stream
328
+ owner. Applicable byte transforms force the existing secure proxy path, and run
329
+ once on redemption. Unrelated providers' transforms do not prevent direct delivery.
330
+ The check repeats after asynchronous URL preparation so newly registered transforms
331
+ cannot be skipped. A declining URL-only handler defers bridge resolution; a handler
332
+ that returns bytes despite its declaration fails explicitly and its stream is
333
+ destroyed, without a retry. Do not list legacy or mixed-result providers.
334
+
335
+ All other providers, including Readables, files and buffers, resolve and materialize
336
+ only when their grant is redeemed. There is no eager byte-source fallback or retained
337
+ live stream in an unredeemed grant. Cancellation, expiration, provider removal and
338
+ shutdown release transport resources; an old grant cannot bind a replacement
339
+ registration. Provider URL expiration remains intact. The consuming node must still
340
+ independently enforce its DNS/redirect policy for direct URLs. Authentication or
341
+ byte transformations requiring the host must use proxy delivery.
342
+
343
+ Single-use media grants reject Range requests. Remedia dev.5 opens these operation
344
+ results as sequential, non-seekable FFmpeg inputs, avoiding default Range probing.
345
+ This does not add random access or turn grant URLs into durable source references.
346
+ See [the Remedia integration contract](docs/remedia-contract.md) for the current
347
+ protocol and validation limits. Native Remedia playback and Discord voice delivery
348
+ remain outside this repository's HTTP/client integration tests.
@@ -59,7 +59,7 @@ export function createExtractorPlugin(instance, context, getBridgeAttempts, onAc
59
59
  : undefined;
60
60
  return checkLegacyStream(await instance.stream(track));
61
61
  }, metadata);
62
- ctx.on('track.related', async ({ track, history }) => stamp(await instance.getRelatedTracks(track, history)), metadata);
62
+ ctx.on('track.related', async ({ track, history }) => stamp(await instance.getRelatedTracks(track, history ?? { tracks: [] })), metadata);
63
63
  ctx.on('track.bridge', async ({ track, sourcePluginId }) => {
64
64
  const attempts = getBridgeAttempts();
65
65
  if (sourcePluginId === instance.identifier || attempts?.has(instance.identifier)) {
@@ -83,10 +83,19 @@ export function createExtractorPlugin(instance, context, getBridgeAttempts, onAc
83
83
  ctx.on('stream.transform', async ({ track, stream }, { signal }) => ({
84
84
  track,
85
85
  stream: await new Promise((resolve, reject) => {
86
- const abort = () => reject(signal.reason);
86
+ signal.throwIfAborted();
87
+ const abort = () => {
88
+ stream.destroy();
89
+ reject(signal.reason);
90
+ };
87
91
  signal.addEventListener('abort', abort, { once: true });
88
92
  const next = (error, result) => {
89
93
  signal.removeEventListener('abort', abort);
94
+ if (signal.aborted) {
95
+ result?.destroy();
96
+ reject(signal.reason);
97
+ return;
98
+ }
90
99
  if (error) {
91
100
  reject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CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
package/dist/host.d.ts CHANGED
@@ -1,12 +1,27 @@
1
+ import { type MediaAccessPolicy } from './media.js';
1
2
  import { type PluginHostOptions, type PluginRequest, type ExecuteResult } from '@remedia/plugin-host';
2
3
  import { SourcePluginRuntime, type SourcePluginRuntimeOptions } from './runtime.js';
3
4
  /** Stable aggregate protocol registration identifier. */
4
5
  export declare const SOURCE_PLUGIN_ID = "discord-player.source";
5
6
  /** Standalone source host configuration. */
6
7
  export interface SourcePluginHostOptions extends PluginHostOptions, Omit<SourcePluginRuntimeOptions, 'player'> {
7
- /** Maximum retained process-local Track references; default 10000. */
8
+ /** Stable non-secret deployment ID. Required for HTTP; generated only for local handle() usage. */
9
+ hostId?: string;
10
+ /** Return provider URLs directly when no byte transforms are needed. Default proxy.
11
+ * Opt in only when the consuming node can enforce its own DNS/redirect policy and access these URLs.
12
+ * Declared URL-only providers resolve at source.stream invocation; all byte sources remain deferred.
13
+ */
14
+ mediaDelivery?: 'proxy' | 'direct-url';
15
+ /** Providers guaranteed to return only URLs without opening byte resources during track.stream.
16
+ * Required for direct URL optimization; other providers stay lazy. Applicable transforms always force proxying.
17
+ * A provider that violates this promise fails explicitly; legacy and mixed-source providers should be omitted.
18
+ */
19
+ directUrlProviders?: readonly string[];
20
+ /** Remote materialization policy; files and private networks are denied by default. */
21
+ mediaPolicy?: MediaAccessPolicy;
22
+ /** Maximum retained process-local Track references; default 1000. */
8
23
  maxTrackStates?: number;
9
- /** State lifetime in milliseconds; default one hour. Expired tracks are reconstructed by URL. */
24
+ /** State lifetime in milliseconds; default ten minutes. Expired tracks are reconstructed by URL. */
10
25
  trackStateTtlMs?: number;
11
26
  }
12
27
  /** Source runtime and the published Remedia transport sharing one set of handlers. */
@@ -19,6 +34,11 @@ export declare class SourcePluginHost {
19
34
  readonly extractors: import("./index.js").ExtractorExecutionContext;
20
35
  /** Underlying generic host; exposes discovery, middleware matching and transport. */
21
36
  readonly remedia: import("@remedia/plugin-host").PluginHost<import("@remedia/plugin-host").PluginOperations>;
37
+ /** Stable deployment identity, independent of provider identifiers and network addresses. */
38
+ readonly hostId: string;
39
+ private readonly mediaPolicy;
40
+ private readonly sweep;
41
+ private readonly explicitHostId;
22
42
  private boundary;
23
43
  private states;
24
44
  private ttl;
@@ -33,12 +53,13 @@ export declare class SourcePluginHost {
33
53
  private prune;
34
54
  private portable;
35
55
  private restore;
56
+ private assertHost;
36
57
  /** Execute directly without serialization; caller owns returned media.
37
58
  * @param request Generic Remedia request targeting discord-player.source.
38
59
  */
39
60
  handle(request: PluginRequest): Promise<ExecuteResult>;
40
61
  /** Execute HTTP through Remedia's transport and the same operation handlers.
41
- * @param request Fetch request.
62
+ * @param request Fetch request. An explicitly configured hostId is required even without publicUrl.
42
63
  */
43
64
  fetch(request: Request): Promise<Response>;
44
65
  /** Identify Remedia routes for Node middleware.
package/dist/host.js CHANGED
@@ -1,11 +1,12 @@
1
+ import { authorizeMediaURL, openMedia } from './media.js';
1
2
  import { AsyncLocalStorage } from 'node:async_hooks';
2
3
  import { randomUUID } from 'node:crypto';
3
- import { createReadStream } from 'node:fs';
4
- import { Readable } from 'node:stream';
5
4
  import { createMediaSource, createPluginHost, } from '@remedia/plugin-host';
6
5
  import { SourcePluginRuntime } from './runtime.js';
7
6
  import { Track } from './structures/track.js';
8
7
  import { deserialize } from './utils/serde.js';
8
+ import { DeferredSourceRequired } from './plugins/stream-resolver.js';
9
+ import { serializeSourceTrack } from './protocol.js';
9
10
  import { cloneJSONValue } from './utils/serialization.js';
10
11
  /** Stable aggregate protocol registration identifier. */
11
12
  export const SOURCE_PLUGIN_ID = 'discord-player.source';
@@ -19,6 +20,11 @@ export class SourcePluginHost {
19
20
  extractors;
20
21
  /** Underlying generic host; exposes discovery, middleware matching and transport. */
21
22
  remedia;
23
+ /** Stable deployment identity, independent of provider identifiers and network addresses. */
24
+ hostId;
25
+ mediaPolicy;
26
+ sweep;
27
+ explicitHostId;
22
28
  boundary = new AsyncLocalStorage();
23
29
  states = new Map();
24
30
  ttl;
@@ -27,15 +33,24 @@ export class SourcePluginHost {
27
33
  * @param options Transport and source settings.
28
34
  */
29
35
  constructor(options) {
30
- this.ttl = options.trackStateTtlMs ?? 3600000;
31
- this.capacity = options.maxTrackStates ?? 10000;
36
+ this.ttl = options.trackStateTtlMs ?? 600000;
37
+ this.capacity = options.maxTrackStates ?? 1000;
32
38
  if (!Number.isSafeInteger(this.ttl) || this.ttl < 1 || !Number.isSafeInteger(this.capacity) || this.capacity < 1) {
33
39
  throw new RangeError('Track state limits must be positive safe integers.');
34
40
  }
35
- this.runtime = new SourcePluginRuntime(options);
41
+ this.explicitHostId = options.hostId !== undefined;
42
+ if (options.publicUrl !== undefined && !this.explicitHostId)
43
+ throw new TypeError('HTTP source hosts require an explicit hostId');
44
+ this.hostId = options.hostId ?? randomUUID();
45
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(this.hostId))
46
+ throw new TypeError('Invalid hostId');
47
+ this.mediaPolicy = { ...options.mediaPolicy };
48
+ this.remedia = createPluginHost(options);
49
+ this.runtime = new SourcePluginRuntime({ ...options, hostId: this.hostId });
50
+ this.sweep = setInterval(() => this.prune(), Math.max(1000, Math.min(this.ttl, 30000)));
51
+ this.sweep.unref();
36
52
  this.plugins = this.runtime.plugins;
37
53
  this.extractors = this.runtime.extractors;
38
- this.remedia = createPluginHost(options);
39
54
  this.remedia.register({
40
55
  id: SOURCE_PLUGIN_ID,
41
56
  operations: {
@@ -67,14 +82,50 @@ export class SourcePluginHost {
67
82
  if (!this.boundary.getStore()) {
68
83
  return this.plugins.resolveStream(await this.restore(this.record(input).track, signal), { signal });
69
84
  }
70
- // Resolve only when the media grant is redeemed: queued tracks do not hold live streams.
71
- const payload = cloneJSONValue(this.record(input).track);
85
+ const value = this.record(input).track;
86
+ const payload = cloneJSONValue(value instanceof Track ? serializeSourceTrack(value) : value);
87
+ const { sourceState: _state, ...entity } = this.record(payload);
88
+ const metadata = deserialize(entity);
89
+ if (!(metadata instanceof Track))
90
+ throw new TypeError('Expected a serialized Track');
91
+ this.assertHost(metadata);
92
+ const providerId = metadata.sourceReference?.pluginId;
93
+ await this.plugins.ready();
94
+ const registration = this.plugins.registrationSignal(providerId ?? '');
95
+ if (options.mediaDelivery === 'direct-url' &&
96
+ providerId &&
97
+ options.directUrlProviders?.includes(providerId) &&
98
+ !this.plugins.hasStreamTransforms(providerId)) {
99
+ try {
100
+ const track = await this.restore(payload, signal);
101
+ return await this.plugins.resolveStream(track, {
102
+ signal,
103
+ directUrlOnly: true,
104
+ prepareSource: async (media, lifetime) => {
105
+ if (!('url' in media))
106
+ throw new Error('Expected a direct media URL');
107
+ await authorizeMediaURL(new URL(media.url), this.mediaPolicy, lifetime ?? signal);
108
+ if ('expiresAtMs' in media &&
109
+ (!Number.isFinite(Number(media.expiresAtMs)) || Number(media.expiresAtMs) <= Date.now()))
110
+ throw new Error('Media source credentials have expired');
111
+ return media;
112
+ },
113
+ });
114
+ }
115
+ catch (error) {
116
+ if (!(error instanceof DeferredSourceRequired))
117
+ throw error;
118
+ }
119
+ }
120
+ // Unknown source types and transformed URLs resolve only on grant redemption.
72
121
  return createMediaSource({
73
122
  open: async ({ signal: mediaSignal }) => {
74
- const track = await this.restore(payload, mediaSignal);
123
+ const lifetime = registration ? AbortSignal.any([mediaSignal, registration]) : mediaSignal;
124
+ lifetime.throwIfAborted();
125
+ const track = await this.restore(payload, lifetime);
75
126
  const source = await this.plugins.resolveStream(track, {
76
- signal: mediaSignal,
77
- prepareSource: (media, lifetime) => this.prepareMedia(media, lifetime),
127
+ signal: lifetime,
128
+ prepareSource: (media, sourceSignal) => this.prepareMedia(media, sourceSignal),
78
129
  });
79
130
  if ('stream' in source)
80
131
  return source.stream;
@@ -84,29 +135,14 @@ export class SourcePluginHost {
84
135
  },
85
136
  },
86
137
  dispose: async () => {
138
+ clearInterval(this.sweep);
87
139
  this.states.clear();
88
140
  await this.runtime.destroy();
89
141
  },
90
142
  });
91
143
  }
92
144
  async prepareMedia(source, signal) {
93
- if ('stream' in source)
94
- return source;
95
- if ('buffer' in source)
96
- return { stream: Readable.from([source.buffer]) };
97
- if ('file' in source)
98
- return {
99
- stream: createReadStream(source.file.startsWith('file:') ? new URL(source.file) : source.file, { signal }),
100
- };
101
- const url = new URL(source.url);
102
- if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password)
103
- throw new Error('Expected a public HTTP(S) media URL');
104
- const response = await fetch(url, { signal });
105
- if (!response.ok || !response.body) {
106
- await response.body?.cancel();
107
- throw new Error(`Media upstream returned ${response.status}`);
108
- }
109
- return { stream: Readable.fromWeb(response.body) };
145
+ return openMedia(source, this.mediaPolicy, signal);
110
146
  }
111
147
  record(input) {
112
148
  if (!input || typeof input !== 'object' || Array.isArray(input))
@@ -156,10 +192,16 @@ export class SourcePluginHost {
156
192
  this.prune();
157
193
  const tracks = result.tracks.map((track) => {
158
194
  // serialize first; never retain an invalid or unsafe response.
195
+ if (track.sourceReference)
196
+ track.sourceReference.hostId = this.hostId;
159
197
  const serialized = track.serialize();
160
198
  const stateId = randomUUID();
161
199
  this.states.set(stateId, {
162
- track,
200
+ track: Object.assign(Object.create(Object.getPrototypeOf(track)), track, {
201
+ playlist: null,
202
+ raw: { ...track.raw, playlist: undefined, requestMetadata: undefined },
203
+ metadataProvider: undefined,
204
+ }),
163
205
  expires: Date.now() + this.ttl,
164
206
  signal: this.plugins.registrationSignal(track.sourceReference?.pluginId ?? ''),
165
207
  });
@@ -170,43 +212,88 @@ export class SourcePluginHost {
170
212
  return { tracks, playlist: result.playlist?.serialize() ?? null };
171
213
  }
172
214
  async restore(input, signal) {
173
- if (input instanceof Track && !this.boundary.getStore())
215
+ signal.throwIfAborted();
216
+ if (input instanceof Track && !this.boundary.getStore()) {
217
+ this.assertHost(input);
218
+ // A consumer-side model has no host-local engine. Ordinary local models retain identity.
219
+ if (input.sourceState || (this.extractors.get(input.sourceReference?.pluginId ?? '') && !input.extractor)) {
220
+ return this.restore(serializeSourceTrack(input), signal);
221
+ }
174
222
  return input;
223
+ }
175
224
  const payload = this.record(input);
176
225
  const { sourceState: _state, ...entity } = payload;
177
226
  const track = deserialize(entity);
178
227
  if (!(track instanceof Track))
179
228
  throw new TypeError('Expected a serialized Track');
229
+ this.assertHost(track);
180
230
  this.prune();
181
231
  const cached = typeof payload.sourceState === 'string' ? this.states.get(payload.sourceState)?.track : undefined;
182
232
  if (cached &&
183
233
  cached.id === track.id &&
184
234
  cached.url === track.url &&
185
- cached.sourceReference?.pluginId === track.sourceReference?.pluginId)
186
- return cached;
235
+ cached.sourceReference?.pluginId === track.sourceReference?.pluginId) {
236
+ // Copy mutable extractor data per invocation. Opaque/non-cloneable engines are reconstructed below.
237
+ try {
238
+ const { requestMetadata: _callback, playlist: _playlist, ...rawData } = cached.raw;
239
+ const engine = rawData.engine;
240
+ if (engine &&
241
+ typeof engine === 'object' &&
242
+ !Array.isArray(engine) &&
243
+ Object.getPrototypeOf(engine) !== Object.prototype)
244
+ throw new Error('Opaque engine requires reconstruction');
245
+ const raw = structuredClone(rawData);
246
+ const copy = Object.assign(Object.create(Object.getPrototypeOf(cached)), cached, { raw });
247
+ copy.sourceReference = structuredClone(cached.sourceReference);
248
+ copy.trackMetadata = structuredClone(cached.metadata);
249
+ copy.metadataProvider = undefined;
250
+ copy.requestedBy = track.requestedBy;
251
+ copy.playlist = null;
252
+ copy.bridgedTrack = null;
253
+ copy.bridgedExtractor = null;
254
+ return copy;
255
+ }
256
+ catch {
257
+ // Legacy callbacks/classes cannot be safely copied; resolve their public location again.
258
+ }
259
+ }
187
260
  const pluginId = track.sourceReference?.pluginId;
188
261
  if (!pluginId || !this.plugins.has(pluginId))
189
262
  throw new Error('Track source is unavailable; register its provider and search again');
190
263
  if (!this.extractors.get(pluginId))
191
264
  return track;
192
265
  // Re-run legacy metadata resolution rather than guessing the meaning of raw.engine.
193
- const result = await this.runtime.search(track.url, { pluginId, signal });
266
+ const data = track.sourceReference?.data;
267
+ const queryType = data && typeof data === 'object' && 'queryType' in data ? data.queryType : undefined;
268
+ const result = await this.runtime.search(track.url, {
269
+ pluginId,
270
+ signal,
271
+ searchEngine: typeof queryType === 'string' ? queryType : undefined,
272
+ });
194
273
  const restored = result.tracks.find((item) => item.url === track.url);
195
274
  if (!restored)
196
275
  throw new Error(`Source ${pluginId} could not reconstruct expired Track state; search again`);
197
276
  restored.requestedBy = track.requestedBy;
277
+ restored.sourceReference = track.sourceReference;
198
278
  return restored;
199
279
  }
280
+ assertHost(track) {
281
+ if (track.sourceReference?.hostId !== this.hostId) {
282
+ throw new Error('Track belongs to another source host or has no host affinity; resolve it on this host first');
283
+ }
284
+ }
200
285
  /** Execute directly without serialization; caller owns returned media.
201
286
  * @param request Generic Remedia request targeting discord-player.source.
202
287
  */
203
288
  handle(request) {
204
- return this.remedia.handle(request);
289
+ return this.boundary.run(false, () => this.remedia.handle(request));
205
290
  }
206
291
  /** Execute HTTP through Remedia's transport and the same operation handlers.
207
- * @param request Fetch request.
292
+ * @param request Fetch request. An explicitly configured hostId is required even without publicUrl.
208
293
  */
209
294
  fetch(request) {
295
+ if (!this.explicitHostId)
296
+ return Promise.reject(new TypeError('HTTP source hosts require an explicit hostId'));
210
297
  return this.boundary.run(true, () => this.remedia.fetch(request));
211
298
  }
212
299
  /** Identify Remedia routes for Node middleware.
package/dist/host.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GAIjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAmC,MAA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