@@ -57,111 +57,7 @@ public sealed class ExtensionInfo
5757 public string Name { get ; set ; } = string . Empty ;
5858}
5959
60- /// <summary>Response returned from <see cref="ICanvasHandler.OnOpenAsync"/>.</summary>
61- [ Experimental ( Diagnostics . Experimental ) ]
62- public sealed class CanvasOpenResponse
63- {
64- /// <summary>URL the host should render. Optional for canvases with no visual surface.</summary>
65- [ JsonPropertyName ( "url" ) ]
66- public string ? Url { get ; set ; }
67-
68- /// <summary>Provider-supplied title shown in host chrome.</summary>
69- [ JsonPropertyName ( "title" ) ]
70- public string ? Title { get ; set ; }
71-
72- /// <summary>Provider-supplied status text shown in host chrome.</summary>
73- [ JsonPropertyName ( "status" ) ]
74- public string ? Status { get ; set ; }
75- }
76-
77- /// <summary>Host capabilities passed to canvas provider callbacks.</summary>
78- [ Experimental ( Diagnostics . Experimental ) ]
79- public sealed class CanvasHostContext
80- {
81- /// <summary>Host capability details.</summary>
82- [ JsonPropertyName ( "capabilities" ) ]
83- public CanvasHostCapabilities Capabilities { get ; set ; } = new ( ) ;
84- }
85-
86- /// <summary>Host capability details passed to canvas provider callbacks.</summary>
87- [ Experimental ( Diagnostics . Experimental ) ]
88- public sealed class CanvasHostCapabilities
89- {
90- /// <summary>Whether the host supports canvas rendering.</summary>
91- [ JsonPropertyName ( "canvases" ) ]
92- public bool Canvases { get ; set ; }
93- }
94-
95- /// <summary>Context handed to <see cref="ICanvasHandler.OnOpenAsync"/>.</summary>
96- [ Experimental ( Diagnostics . Experimental ) ]
97- public sealed class CanvasOpenContext
98- {
99- /// <summary>Session that requested the canvas.</summary>
100- public string SessionId { get ; set ; } = string . Empty ;
101-
102- /// <summary>Owning provider identifier.</summary>
103- public string ExtensionId { get ; set ; } = string . Empty ;
104-
105- /// <summary>Canvas id from the declaring <see cref="CanvasDeclaration"/>.</summary>
106- public string CanvasId { get ; set ; } = string . Empty ;
107-
108- /// <summary>Stable instance id supplied by the runtime.</summary>
109- public string InstanceId { get ; set ; } = string . Empty ;
110-
111- /// <summary>Validated input payload.</summary>
112- public JsonElement Input { get ; set ; }
113-
114- /// <summary>Host capabilities supplied by the runtime.</summary>
115- public CanvasHostContext ? Host { get ; set ; }
116- }
117-
118- /// <summary>Context handed to <see cref="ICanvasHandler.OnActionAsync"/>.</summary>
119- [ Experimental ( Diagnostics . Experimental ) ]
120- public sealed class CanvasActionContext
121- {
122- /// <summary>Session that invoked the action.</summary>
123- public string SessionId { get ; set ; } = string . Empty ;
124-
125- /// <summary>Owning provider identifier.</summary>
126- public string ExtensionId { get ; set ; } = string . Empty ;
127-
128- /// <summary>Canvas id targeted by the action.</summary>
129- public string CanvasId { get ; set ; } = string . Empty ;
130-
131- /// <summary>Instance id targeted by the action.</summary>
132- public string InstanceId { get ; set ; } = string . Empty ;
133-
134- /// <summary>Action name from <see cref="CanvasAction.Name"/>.</summary>
135- public string ActionName { get ; set ; } = string . Empty ;
136-
137- /// <summary>Validated input payload.</summary>
138- public JsonElement Input { get ; set ; }
139-
140- /// <summary>Host capabilities supplied by the runtime.</summary>
141- public CanvasHostContext ? Host { get ; set ; }
142- }
143-
144- /// <summary>Context handed to a canvas's close lifecycle hook.</summary>
145- [ Experimental ( Diagnostics . Experimental ) ]
146- public sealed class CanvasLifecycleContext
147- {
148- /// <summary>Session owning the canvas instance.</summary>
149- public string SessionId { get ; set ; } = string . Empty ;
150-
151- /// <summary>Owning provider identifier.</summary>
152- public string ExtensionId { get ; set ; } = string . Empty ;
153-
154- /// <summary>Canvas id from the declaring <see cref="CanvasDeclaration"/>.</summary>
155- public string CanvasId { get ; set ; } = string . Empty ;
156-
157- /// <summary>Instance id this lifecycle event applies to.</summary>
158- public string InstanceId { get ; set ; } = string . Empty ;
159-
160- /// <summary>Host capabilities supplied by the runtime.</summary>
161- public CanvasHostContext ? Host { get ; set ; }
162- }
163-
164- /// <summary>Structured error returned from canvas handlers.</summary>
60+ /// <summary>Structured exception returned from canvas handlers.</summary>
16561/// <remarks>
16662/// Throw this from <see cref="ICanvasHandler"/> implementations to surface a
16763/// machine-readable error code to the runtime. Any other exception is wrapped
@@ -182,7 +78,7 @@ public CanvasException(string code, string message) : base(message)
18278 public string Code { get ; }
18379
18480 /// <summary>
185- /// Default error returned when a custom action has no handler.
81+ /// Default exception returned when a custom action has no handler.
18682 /// </summary>
18783 public static CanvasException NoHandler ( ) => new (
18884 "canvas_action_no_handler" ,
@@ -222,9 +118,9 @@ private static LocalRpcInvocationException Build(string code, string message)
222118/// <remarks>
223119/// A session installs a single <see cref="ICanvasHandler"/> via
224120/// <c>SessionConfigBase.CanvasHandler</c>. The handler receives every
225- /// inbound <c>canvas.open</c> / <c>canvas.close</c> / <c>canvas.action.invoke </c>
121+ /// inbound <c>canvas.open</c> / <c>canvas.close</c> / <c>canvas.invokeAction </c>
226122/// JSON-RPC request the runtime issues for this session and decides — typically
227- /// by inspecting <see cref="CanvasOpenContext .CanvasId"/> — which
123+ /// by inspecting <see cref="CanvasProviderOpenRequest .CanvasId"/> — which
228124/// application-side canvas should handle the call.
229125/// <para>
230126/// The SDK does not maintain a per-canvas registry; multiplexing across
@@ -240,16 +136,16 @@ private static LocalRpcInvocationException Build(string code, string message)
240136public interface ICanvasHandler
241137{
242138 /// <summary>Open a new canvas instance.</summary>
243- Task < CanvasOpenResponse > OnOpenAsync ( CanvasOpenContext context , CancellationToken cancellationToken ) ;
139+ Task < CanvasProviderOpenResult > OnOpenAsync ( CanvasProviderOpenRequest context , CancellationToken cancellationToken ) ;
244140
245141 /// <summary>Canvas was closed by the user or agent. Default: no-op.</summary>
246- Task OnCloseAsync ( CanvasLifecycleContext context , CancellationToken cancellationToken ) ;
142+ Task OnCloseAsync ( CanvasProviderCloseRequest context , CancellationToken cancellationToken ) ;
247143
248144 /// <summary>
249145 /// Handle a non-lifecycle action declared by the canvas.
250146 /// Default: throws <see cref="CanvasException.NoHandler"/>.
251147 /// </summary>
252- Task < object ? > OnActionAsync ( CanvasActionContext context , CancellationToken cancellationToken ) ;
148+ Task < object ? > OnActionAsync ( CanvasProviderInvokeActionRequest context , CancellationToken cancellationToken ) ;
253149}
254150
255151/// <summary>
@@ -260,17 +156,17 @@ public interface ICanvasHandler
260156public abstract class CanvasHandlerBase : ICanvasHandler
261157{
262158 /// <inheritdoc />
263- public abstract Task < CanvasOpenResponse > OnOpenAsync ( CanvasOpenContext context , CancellationToken cancellationToken ) ;
159+ public abstract Task < CanvasProviderOpenResult > OnOpenAsync ( CanvasProviderOpenRequest context , CancellationToken cancellationToken ) ;
264160
265161 /// <inheritdoc />
266- public virtual Task OnCloseAsync ( CanvasLifecycleContext context , CancellationToken cancellationToken )
162+ public virtual Task OnCloseAsync ( CanvasProviderCloseRequest context , CancellationToken cancellationToken )
267163#if NET8_0_OR_GREATER
268164 => Task . CompletedTask ;
269165#else
270166 => Task . FromResult < object ? > ( null ) ;
271167#endif
272168
273169 /// <inheritdoc />
274- public virtual Task < object ? > OnActionAsync ( CanvasActionContext context , CancellationToken cancellationToken )
170+ public virtual Task < object ? > OnActionAsync ( CanvasProviderInvokeActionRequest context , CancellationToken cancellationToken )
275171 => Task . FromException < object ? > ( CanvasException . NoHandler ( ) ) ;
276172}
0 commit comments