Skip to content

Add polyglot interaction service APIs#17874

Closed
sebastienros wants to merge 4 commits into
mainfrom
sebastienros/polyglot-integration-service
Closed

Add polyglot interaction service APIs#17874
sebastienros wants to merge 4 commits into
mainfrom
sebastienros/polyglot-integration-service

Conversation

@sebastienros

Copy link
Copy Markdown
Contributor

Description

Expose Aspire's interaction service to polyglot AppHosts through callback IServiceProvider instances, matching the existing pattern for other services available from callback service providers. Polyglot integration authors can now resolve the interaction service and prompt users from TypeScript, Python, Go, and Java AppHosts.

This adds ATS-friendly interaction wrappers for availability checks, confirmation prompts, message boxes, single input prompts, multiple input prompts, and notifications. The wrappers return non-generic result DTOs so the generated SDKs do not need to model InteractionResult<T> directly. The generated SDK baselines and compile-time validation AppHosts were updated across TypeScript, Python, Go, Java, and Rust, and Java option DTO names were kept idiomatic without a Dto suffix.

User-facing usage

TypeScript AppHosts can resolve and use the interaction service from callback service providers:

const interactionService = executionContext.serviceProvider.getInteractionService();
const isAvailable = interactionService.isAvailable();

interactionService.promptMessageBoxAsync("Message", "Message body", {
  options: {
    intent: MessageIntent.INFORMATION
  }
});

Java AppHosts get natural generated option names:

var interactionService = executionContextServiceProvider.getInteractionService();
var options = new MessageBoxInteractionOptions();
options.setIntent(MessageIntent.INFORMATION);

interactionService.promptMessageBoxAsync(
    "Message",
    "Message body",
    new PromptMessageBoxAsyncOptions().options(options));

Validation:

  • RunAnalyzers=false dotnet run --project src/Aspire.Cli/Aspire.Cli.csproj -- sdk dump --format ci --output src/Aspire.Hosting/api/Aspire.Hosting.ats.txt
  • dotnet test for the ATS scanner tests and TypeScript, Go, Python, Java, and Rust code generation test projects
  • Compile-time validation for the edited tests/PolyglotAppHosts/Aspire.Hosting TypeScript, Python, Go, and Java AppHosts after aspire restore

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Expose IInteractionService through polyglot AppHost service providers and add ATS-friendly prompt wrappers for interaction prompts. Update generated SDK snapshots and compile-time validation apps across TypeScript, Python, Go, and Java.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 3, 2026 17:23
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17874

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17874"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes Aspire’s IInteractionService through ATS/polyglot callback IServiceProvider instances, enabling TypeScript/Python/Go/Java/Rust AppHosts to prompt users (confirmation, message box, input dialogs, notifications) via generated SDK wrappers.

Changes:

  • Added new ATS exports and DTO wrappers for interaction capabilities (availability + prompt APIs) and exported IInteractionService in ATS type mappings.
  • Updated polyglot compile-time validation AppHosts (TS/Python/Go/Java) to resolve and call the interaction service from callback service providers.
  • Regenerated/updated ATS baselines and multi-language generated SDK snapshots; adjusted Java generator option-parameter naming (optionsoptionsBag) to keep generated overloads idiomatic.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/PolyglotAppHosts/Aspire.Hosting/TypeScript/apphost.mts Adds interaction service resolution and prompt API calls for TS compile-time validation.
tests/PolyglotAppHosts/Aspire.Hosting/Python/apphost.py Adds interaction service resolution and prompt API calls for Python compile-time validation.
tests/PolyglotAppHosts/Aspire.Hosting/Java/AppHost.java Adds interaction service resolution and prompt API calls for Java compile-time validation.
tests/PolyglotAppHosts/Aspire.Hosting/Go/apphost.go Adds interaction service resolution and prompt API validation helper for Go compile-time validation.
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts Updates TS generated SDK snapshot with interaction service handles, DTOs, enums, and service-provider accessors.
tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs Updates Rust generated SDK snapshot with interaction service wrappers, DTOs, and enums.
tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py Updates Python generated SDK snapshot with interaction service wrappers/DTOs and service-provider accessor.
tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/AtsGeneratedAspire.verified.java Updates Java generated SDK snapshot (including option overload parameter naming changes).
tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go Updates Go generated SDK snapshot with interaction service wrappers/DTOs and service-provider accessor.
src/Aspire.Hosting/Ats/InteractionExports.cs Introduces ATS exports for IInteractionService + ATS-friendly DTO wrappers for polyglot SDKs.
src/Aspire.Hosting/Ats/AtsTypeMappings.cs Exports IInteractionService as an ATS handle type.
src/Aspire.Hosting/api/Aspire.Hosting.ats.txt Updates ATS baseline with interaction capabilities, DTOs, and MessageIntent.
src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs Renames generated options overload parameter from options to optionsBag for Java output.

Update TypeScript code generation so nullable ATS DTO members, including interaction result data, are emitted with null in their TypeScript types.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@davidfowl

Copy link
Copy Markdown
Contributor

Is the code sample right?

Comment thread tests/PolyglotAppHosts/Aspire.Hosting/TypeScript/apphost.mts Outdated
/// <param name="cancellationToken">A token to cancel the operation.</param>
/// <returns>The input interaction result.</returns>
[AspireExport("promptInputWithInput", MethodName = "promptInputWithInputAsync")]
public static async Task<InputInteractionResult> PromptInputWithInputAsync(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PromptInputWithInputAsync?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. No overloads.

IMO remove existing PromptInputAsync, it's just a helper method, and rename this to PromptInputAsync.

Comment on lines +150 to +151
InteractionInput input,
InputsDialogInteractionOptions? options = null,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you decide whether to expose a custom export type or not? I'm curious why the options needs one and InteractionInput does.

@JamesNK

JamesNK commented Jun 4, 2026

Copy link
Copy Markdown
Member

Have you tested this works IRL?

It's tough to unit test this as it shows up as UI in the dashboard. I'd like to see a TypeScript playground app have a resource with a command, and in that command it prompts for input. The input should be a choice, and use DynamicLoading to populate options. The callback should wait for a second and then set some option values. And have validation of the input values.

After the input returns then get the value from the input and write to logging (or return it with command result).

That would excerise all the most complex parts of the interaction service.

[AspireDto]
internal sealed class InputsDialogInteractionOptions : InteractionOptions
{
internal PublicInputsDialogInteractionOptions ToInputsDialogInteractionOptions()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing the validationcallback property

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem here with that one. It's not working with DTOs ... for the reason I explained on the other issue with DTOs, can't serialize behavior either.

Will think about a solution, might have to refactor what is exposed use handles instead. I understand it's required for dynamic inputs. validationCallback is the remaining issue. Everything else seems to work (including loadCallback which is surprising).

sebastienros and others added 2 commits June 4, 2026 17:53
Move validation AppHost service-provider access until after builder.build() and document that the execution context service provider is populated during build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

CLI E2E Tests unknown — 113 passed, 0 failed, 2 unknown (commit fccc2b5)

View all recordings
- Test Detail
AddPackageInteractiveWhileAppHostRunningDetached Recording · Job · CLI logs
AddPackageWhileAppHostRunningDetached Recording · Job · CLI logs
AgentCommands_AllHelpOutputs_AreCorrect Recording · Job · CLI logs
AgentInitCommand_DefaultSelection_InstallsDefaultSkills Recording · Job · CLI logs
AgentInitCommand_MigratesDeprecatedConfig Recording · Job · CLI logs
AgentInit_NonInteractive_BundleOnlySkillsNotInCatalog Recording · Job · CLI logs
AgentMcpListStructuredLogsReturnsLogsFromStarterApp Recording · Job · CLI logs
AgentMcpListStructuredLogsReturnsLogsFromStarterApp_DevLocalhost Recording · Job · CLI logs
AgentMcpListStructuredLogsReturnsLogsFromStarterApp_Isolated Recording · Job · CLI logs
AllPublishMethodsBuildDockerImages Recording · Job · CLI logs
AspireAddAndStartWorkAgainstLegacyAppHostTs Recording · Job · CLI logs
AspireAddPackageVersionToDirectoryPackagesProps Recording · Job · CLI logs
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost Recording · Job · CLI logs
AspireInit_ExistingAppHostDir_RecreatesNuGetConfigKeepsFiles Recording · Job · CLI logs
AspireInit_SolutionFile_BuildsAgainstChannelHive Recording · Job · CLI logs
AspireStartUpdatesStaleTypeScriptAppHostPath Recording · Job · CLI logs
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps Recording · Job · CLI logs
AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrent Recording · Job · CLI logs
Banner_DisplayedOnFirstRun Recording · Job · CLI logs
Banner_DisplayedWithExplicitFlag Recording · Job · CLI logs
Banner_NotDisplayedWithNoLogoFlag Recording · Job · CLI logs
CertificatesClean_RemovesCertificates Recording · Job · CLI logs
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate Recording · Job · CLI logs
CertificatesTrust_WithUntrustedCert_TrustsCertificate Recording · Job · CLI logs
ConfigSetGet_CreatesNestedJsonFormat Recording · Job · CLI logs
CreateAndRunAspireStarterProject Recording · Job · CLI logs
CreateAndRunAspireStarterProjectWithBundle Recording · Job · CLI logs
CreateAndRunEmptyAppHostProject Recording · Job · CLI logs
CreateAndRunJavaEmptyAppHostProject Recording · Job · CLI logs
CreateAndRunJsReactProject Recording · Job · CLI logs
CreateAndRunPolyglotAppHostWithDevLocalhostUrls Recording · Job · CLI logs
CreateAndRunPythonReactProject Recording · Job · CLI logs
CreateAndRunTypeScriptEmptyAppHostProject Recording · Job · CLI logs
CreateAndRunTypeScriptStarterProject Recording · Job · CLI logs
CreateJavaAppHostWithViteApp Recording · Job · CLI logs
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain Recording · Job · CLI logs
DashboardRunWithAgentMcpListTracesReturnsNoTraces Recording · Job · CLI logs
DashboardRunWithAgentMcpListTracesReturnsNoTraces_DevLocalhost Recording · Job · CLI logs
DashboardRunWithOtelTracesReturnsNoTraces Recording · Job · CLI logs
DashboardRunWithOtelTracesReturnsNoTraces_DevLocalhost Recording · Job · CLI logs
DeployK8sBasicApiService Recording · Job · CLI logs
DeployK8sWithExternalHelmChart Recording · Job · CLI logs
DeployK8sWithGarnet Recording · Job · CLI logs
DeployK8sWithMongoDB Recording · Job · CLI logs
DeployK8sWithMySql Recording · Job · CLI logs
DeployK8sWithPostgres Recording · Job · CLI logs
DeployK8sWithRabbitMQ Recording · Job · CLI logs
DeployK8sWithRedis Recording · Job · CLI logs
DeployK8sWithSqlServer Recording · Job · CLI logs
DeployK8sWithValkey Recording · Job · CLI logs
DeployTypeScriptAppToKubernetes Recording · Job · CLI logs
DescribeCommandResolvesReplicaNames Recording · Job · CLI logs
DescribeCommandShowsRunningResources Recording · Job · CLI logs
DetachFormatJsonProducesValidJson Recording · Job · CLI logs
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance Recording · Job · CLI logs
DoPublishAndDeployListStepsWork Recording · Job · CLI logs
DocsCommand_RendersInteractiveMarkdownFromLocalSource Recording · Job · CLI logs
DoctorCommand_DetectsDeprecatedAgentConfig Recording · Job · CLI logs
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain Recording · Job · CLI logs
DoctorCommand_WithSslCertDir_ShowsTrusted Recording · Job · CLI logs
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted Recording · Job · CLI logs
DotNetRunFileBasedAppHostUsesAspireCliBundle Recording · Job · CLI logs
DotNetRunProjectAppHostUsesAspireCliBundle Recording · Job · CLI logs
GatewayWithoutExternalEndpoint_FailsPublishWithGuidance Recording · Job · CLI logs
GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchain Recording · Job · CLI logs
GlobalMigration_HandlesCommentsAndTrailingCommas Recording · Job · CLI logs
GlobalMigration_HandlesMalformedLegacyJson Recording · Job · CLI logs
GlobalMigration_PreservesAllValueTypes Recording · Job · CLI logs
GlobalMigration_SkipsWhenNewConfigExists Recording · Job · CLI logs
GlobalSettings_MigratedFromLegacyFormat Recording · Job · CLI logs
IngressWithoutExternalEndpoint_FailsPublishWithGuidance Recording · Job · CLI logs
InitTypeScriptAppHost_AugmentsExistingViteRepoInWorkspaceSubdirectory Recording · Job · CLI logs
InteractiveCSharpInitCreatesExpectedFiles Recording · Job · CLI logs
InvalidAppHostPathWithComments_IsHealedOnRun Recording · Job · CLI logs
JavaScriptHostingApisRunFromTypeScriptAppHost Recording · Job · CLI logs
LatestCliCanStartStableChannelAppHost Recording · Job · CLI logs
LatestCliCanStartStableChannelTypeScriptAppHost Recording · Job · CLI logs
LegacySettingsMigration_AdjustsRelativeAppHostPath Recording · Job · CLI logs
LogsCommandShowsResourceLogs Recording · Job · CLI logs
OtelLogsReturnsStructuredLogsFromStarterApp Recording · Job · CLI logs
OtelLogsReturnsStructuredLogsFromStarterAppIsolated Recording · Job · CLI logs
PersistentContainersPreserveDataAcrossAppHostRuns Recording · Job · CLI logs
PsCommandListsRunningAppHost Recording · Job · CLI logs
PsFormatJsonOutputsOnlyJsonToStdout Recording · Job · CLI logs
PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifacts Recording · Job · CLI logs
PublishWithConfigureEnvFileUpdatesEnvOutput Recording · Job · CLI logs
PublishWithDockerComposeServiceCallbackSucceeds Recording · Job · CLI logs
PublishWithoutOutputPathUsesAppHostDirectoryDefault Recording · Job · CLI logs
ResourceCommand_FailedExec_ShowsLogPathAndLogHasEntries Recording · Job · CLI logs
ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutput Recording · Job · CLI logs
RestoreGeneratesSdkFiles Recording · Job · CLI logs
RestoreGeneratesSdkFiles_WithConfiguredToolchain Recording · Job · CLI logs
RestoreRefreshesGeneratedSdkAfterAddingIntegration Recording · Job · CLI logs
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes Recording · Job · CLI logs
RunFromParentDirectory_UsesExistingConfigNearAppHost Recording · Job · CLI logs
RunReportsSyntaxErrorsForDotNetAppHost Recording · Job · CLI logs
RunReportsSyntaxErrorsForTypeScriptAppHost Recording · Job · CLI logs
SecretCrudOnDotNetAppHost Recording · Job · CLI logs
SecretCrudOnTypeScriptAppHost Recording · Job · CLI logs
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels Recording · Job · CLI logs
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets Recording · Job · CLI logs
StartReportsSyntaxErrorsForDotNetAppHost Recording · Job · CLI logs
StartReportsSyntaxErrorsForTypeScriptAppHost Recording · Job · CLI logs
StopAllAppHostsFromAppHostDirectory Recording · Job · CLI logs
StopJavaPolyglotAppHostUsingApphostDirectory Recording · Job · CLI logs
StopNonInteractiveSingleAppHost Recording · Job · CLI logs
StopTypeScriptPolyglotAppHostUsingApphostDirectory Recording · Job · CLI logs
StopWithNoRunningAppHostExitsSuccessfully Recording · Job · CLI logs
TypeScriptAppHostRunDoesNotDeadlockWhenLazyOptionsInvokeAsyncCallback Recording · Job · CLI logs
TypeScriptAppHostWithVite_AllowsDifferentGuestPkgManager Recording · Job · CLI logs
UnAwaitedChainsCompileWithAutoResolvePromises Recording · Job · CLI logs
UpdateToStable_CSharpEmptyAppHost_KeepsConfigChannel Recording · Job · CLI logs
UpdateToStable_CSharpSingleFileInit_KeepsConfigChannel Recording · Job · CLI logs
UpdateToStable_TypeScriptSingleFileInit_KeepsConfigChannel Recording · Job · CLI logs
UpdateToStable_TypeScript_PreviewsStablePkgsAndKeepsChannel Recording · Job · CLI logs

📹 Recordings uploaded automatically from CI run #26990450410

@sebastienros

Copy link
Copy Markdown
Contributor Author

Replaced by #17959 which is not using DTOs where we need to use callbacks (dynamic loading, validation)

@sebastienros sebastienros deleted the sebastienros/polyglot-integration-service branch June 5, 2026 17:47
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.5 milestone Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants