@optimizely-opal/opal-tools-sdk 0.1.6-dev → 0.1.9-dev

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/src/decorators.ts CHANGED
@@ -20,6 +20,7 @@ interface ToolOptions {
20
20
  description: string;
21
21
  name: string;
22
22
  parameters?: ParameterDefinition[];
23
+ uiResource?: string;
23
24
  }
24
25
 
25
26
  /**
@@ -30,6 +31,7 @@ interface ToolOptions {
30
31
  * - authRequirements: (Optional) Authentication requirements
31
32
  * Format: { provider: "oauth_provider", scopeBundle: "permissions_scope", required: true }
32
33
  * Example: { provider: "google", scopeBundle: "calendar", required: true }
34
+ * - uiResource: (Optional) URI of associated UI resource for dynamic rendering (e.g., "ui://my-app/create-form")
33
35
  *
34
36
  * Note: If your tool requires authentication, define your handler function with two parameters:
35
37
  * ```
@@ -87,6 +89,8 @@ export function tool(options: ToolOptions) {
87
89
  parameters,
88
90
  endpoint,
89
91
  authRequirements,
92
+ false,
93
+ options.uiResource,
90
94
  );
91
95
  }
92
96
 
package/src/index.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import "reflect-metadata";
2
2
 
3
3
  export { requiresAuth } from "./auth";
4
- export { Block, isBlockResponse } from "./block";
5
- export type * from "./block";
6
4
  export { tool } from "./decorators";
7
5
  export * from "./models";
6
+ export { UI } from "./proteus";
7
+ export type * from "./proteus";
8
+ export { registerResource } from "./registerResource";
8
9
  export { registerTool } from "./registerTool";
9
10
  export type { RequestHandlerExtra } from "./registerTool";
10
11
  export { ToolsService } from "./service";
package/src/models.ts CHANGED
@@ -80,6 +80,7 @@ export class Function {
80
80
  * @param parameters Function parameters
81
81
  * @param endpoint API endpoint
82
82
  * @param authRequirements Authentication requirements (optional)
83
+ * @param uiResource URI of associated UI resource for dynamic rendering (optional)
83
84
  */
84
85
  constructor(
85
86
  public name: string,
@@ -87,6 +88,7 @@ export class Function {
87
88
  public parameters: Parameter[],
88
89
  public endpoint: string,
89
90
  public authRequirements?: AuthRequirement[],
91
+ public uiResource?: string,
90
92
  ) {}
91
93
 
92
94
  /**
@@ -108,6 +110,10 @@ export class Function {
108
110
  );
109
111
  }
110
112
 
113
+ if (this.uiResource !== undefined) {
114
+ result.ui_resource = this.uiResource;
115
+ }
116
+
111
117
  return result;
112
118
  }
113
119
  }
@@ -303,3 +309,24 @@ export class Parameter {
303
309
  };
304
310
  }
305
311
  }
312
+
313
+ /**
314
+ * Resource definition for MCP resources
315
+ */
316
+ export class Resource {
317
+ /**
318
+ * Create a new resource definition
319
+ * @param uri The unique URI for this resource (e.g., "ui://my-app/create-form")
320
+ * @param name Name of the resource
321
+ * @param description Description of the resource (optional)
322
+ * @param mimeType MIME type of the resource content (optional)
323
+ * @param title Human-readable title for the resource (optional)
324
+ */
325
+ constructor(
326
+ public uri: string,
327
+ public name: string,
328
+ public description?: string,
329
+ public mimeType?: string,
330
+ public title?: string,
331
+ ) {}
332
+ }