MCPcopy
hub / github.com/coder/mux / produceMessage

Method produceMessage

src/node/services/messageQueue.ts:362–411  ·  view source on GitHub ↗

* Get combined message and options for sending.

()

Source from the content-addressed store, hash-verified

360 * Get combined message and options for sending.
361 */
362 produceMessage(): {
363 message: string;
364 options?: SendMessageOptions & { fileParts?: FilePart[] };
365 internal?: QueuedMessageInternalOptions;
366 } {
367 const joinedMessages = this.messages.join("\n");
368 // First metadata takes precedence (preserves compaction + agent-skill invocations)
369 const muxMetadata =
370 this.firstMuxMetadata !== undefined
371 ? this.firstMuxMetadata
372 : (this.latestOptions?.muxMetadata as unknown);
373 const options = this.latestOptions
374 ? (() => {
375 const restOptions: SendMessageOptions = { ...this.latestOptions };
376 delete restOptions.queueDispatchMode;
377 if (this.goalInterventionPolicy != null) {
378 restOptions.goalInterventionPolicy = this.goalInterventionPolicy;
379 }
380 return {
381 ...restOptions,
382 muxMetadata,
383 fileParts: this.accumulatedFileParts.length > 0 ? this.accumulatedFileParts : undefined,
384 };
385 })()
386 : undefined;
387
388 const allQueuedEntriesAreSynthetic =
389 this.queuedEntryCount > 0 && this.queuedSyntheticCount === this.queuedEntryCount;
390 const allQueuedEntriesAreAgentInitiated =
391 this.queuedEntryCount > 0 && this.queuedAgentInitiatedCount === this.queuedEntryCount;
392 const hasInternalOptions =
393 allQueuedEntriesAreSynthetic ||
394 allQueuedEntriesAreAgentInitiated ||
395 this.onAccepted != null ||
396 this.onAcceptedPreStreamFailure != null ||
397 this.onCanceled != null;
398 const internal = hasInternalOptions
399 ? {
400 ...(allQueuedEntriesAreSynthetic ? { synthetic: true } : {}),
401 ...(allQueuedEntriesAreAgentInitiated ? { agentInitiated: true } : {}),
402 ...(this.onCanceled != null ? { onCanceled: this.onCanceled } : {}),
403 ...(this.onAccepted != null ? { onAccepted: this.onAccepted } : {}),
404 ...(this.onAcceptedPreStreamFailure != null
405 ? { onAcceptedPreStreamFailure: this.onAcceptedPreStreamFailure }
406 : {}),
407 }
408 : undefined;
409
410 return { message: joinedMessages, options, internal };
411 }
412
413 /**
414 * Clear all queued messages, options, and images.

Callers 2

sendQueuedMessagesMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected