@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/README.md +201 -216
- package/dist/decorators.d.ts +2 -0
- package/dist/decorators.js +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -4
- package/dist/models.d.ts +22 -1
- package/dist/models.js +28 -2
- package/dist/proteus.d.ts +1587 -0
- package/dist/proteus.js +98 -0
- package/dist/registerResource.d.ts +60 -0
- package/dist/registerResource.js +59 -0
- package/dist/registerTool.d.ts +18 -7
- package/dist/registerTool.js +52 -3
- package/dist/service.d.ts +15 -3
- package/dist/service.js +80 -21
- package/package.json +2 -2
- package/scripts/generate-proteus.ts +135 -0
- package/src/decorators.ts +4 -0
- package/src/index.ts +3 -2
- package/src/models.ts +27 -0
- package/src/proteus.ts +2314 -0
- package/src/registerResource.ts +82 -0
- package/src/registerTool.ts +19 -29
- package/src/service.ts +110 -23
- package/tests/integration.test.ts +252 -73
- package/tests/proteus.test.ts +122 -0
- package/dist/block.d.ts +0 -4760
- package/dist/block.js +0 -104
- package/scripts/generate-block.ts +0 -167
- package/src/block.ts +0 -11761
- package/tests/block.test.ts +0 -115
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
|
+
}
|