@vertesia/tools-sdk 0.79.0 → 0.80.0-dev-20251118
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/lib/cjs/InteractionCollection.js +46 -0
- package/lib/cjs/InteractionCollection.js.map +1 -0
- package/lib/cjs/ToolCollection.js +2 -4
- package/lib/cjs/ToolCollection.js.map +1 -1
- package/lib/cjs/auth.js +10 -5
- package/lib/cjs/auth.js.map +1 -1
- package/lib/cjs/index.js +5 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils.js +7 -0
- package/lib/cjs/utils.js.map +1 -0
- package/lib/esm/InteractionCollection.js +42 -0
- package/lib/esm/InteractionCollection.js.map +1 -0
- package/lib/esm/ToolCollection.js +1 -3
- package/lib/esm/ToolCollection.js.map +1 -1
- package/lib/esm/auth.js +10 -5
- package/lib/esm/auth.js.map +1 -1
- package/lib/esm/index.js +2 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/utils.js +4 -0
- package/lib/esm/utils.js.map +1 -0
- package/lib/types/InteractionCollection.d.ts +19 -0
- package/lib/types/InteractionCollection.d.ts.map +1 -0
- package/lib/types/ToolCollection.d.ts +5 -36
- package/lib/types/ToolCollection.d.ts.map +1 -1
- package/lib/types/auth.d.ts.map +1 -1
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/types.d.ts +22 -0
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/utils.d.ts +2 -0
- package/lib/types/utils.d.ts.map +1 -0
- package/package.json +42 -37
- package/src/InteractionCollection.ts +53 -0
- package/src/ToolCollection.ts +6 -28
- package/src/auth.ts +12 -7
- package/src/index.ts +2 -1
- package/src/types.ts +24 -0
- package/src/utils.ts +3 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InteractionCollection = void 0;
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
|
+
class InteractionCollection {
|
|
6
|
+
interactions;
|
|
7
|
+
name;
|
|
8
|
+
title;
|
|
9
|
+
icon;
|
|
10
|
+
description;
|
|
11
|
+
constructor({ name, title, icon, description, interactions }) {
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.title = title || (0, utils_js_1.kebabCaseToTitle)(name);
|
|
14
|
+
this.icon = icon;
|
|
15
|
+
this.description = description;
|
|
16
|
+
this.interactions = interactions;
|
|
17
|
+
}
|
|
18
|
+
addInteraction(interaction) {
|
|
19
|
+
this.interactions.push(interaction);
|
|
20
|
+
}
|
|
21
|
+
getInteractions() {
|
|
22
|
+
return this.interactions;
|
|
23
|
+
}
|
|
24
|
+
[Symbol.iterator]() {
|
|
25
|
+
let index = 0;
|
|
26
|
+
const interactions = this.interactions;
|
|
27
|
+
return {
|
|
28
|
+
next() {
|
|
29
|
+
if (index < interactions.length) {
|
|
30
|
+
return { value: interactions[index++], done: false };
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return { done: true, value: undefined };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
map(callback) {
|
|
39
|
+
return this.interactions.map(callback);
|
|
40
|
+
}
|
|
41
|
+
getInteractionByName(name) {
|
|
42
|
+
return this.interactions.find(interaction => interaction.name === name);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.InteractionCollection = InteractionCollection;
|
|
46
|
+
//# sourceMappingURL=InteractionCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractionCollection.js","sourceRoot":"","sources":["../../src/InteractionCollection.ts"],"names":[],"mappings":";;;AAEA,yCAA8C;AAK9C,MAAa,qBAAqB;IAC9B,YAAY,CAAoB;IAChC,IAAI,CAAS;IACb,KAAK,CAAU;IACf,IAAI,CAAU;IACd,WAAW,CAAU;IACrB,YAAY,EACR,IAAI,EAAE,KAAK,EAAE,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4
4
|
const http_exception_1 = require("hono/http-exception");
|
|
5
5
|
const auth_js_1 = require("./auth.js");
|
|
6
6
|
const ToolRegistry_js_1 = require("./ToolRegistry.js");
|
|
7
|
+
const utils_js_1 = require("./utils.js");
|
|
7
8
|
/**
|
|
8
9
|
* Implements a tools collection endpoint
|
|
9
10
|
*/
|
|
@@ -33,7 +34,7 @@ class ToolCollection {
|
|
|
33
34
|
tools;
|
|
34
35
|
constructor({ name, title, icon, description, tools }) {
|
|
35
36
|
this.name = name;
|
|
36
|
-
this.title = title || kebabCaseToTitle(name);
|
|
37
|
+
this.title = title || (0, utils_js_1.kebabCaseToTitle)(name);
|
|
37
38
|
this.icon = icon;
|
|
38
39
|
this.description = description;
|
|
39
40
|
this.tools = new ToolRegistry_js_1.ToolRegistry(tools);
|
|
@@ -90,7 +91,4 @@ async function readPayload(ctx) {
|
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
function kebabCaseToTitle(name) {
|
|
94
|
-
return name.split('-').map(p => p[0].toUpperCase() + p.substring(1)).join(' ');
|
|
95
|
-
}
|
|
96
94
|
//# sourceMappingURL=ToolCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolCollection.js","sourceRoot":"","sources":["../../src/ToolCollection.ts"],"names":[],"mappings":";;;AACA,wDAAoD;AACpD,uCAAsC;AACtC,uDAAiD;
|
|
1
|
+
{"version":3,"file":"ToolCollection.js","sourceRoot":"","sources":["../../src/ToolCollection.ts"],"names":[],"mappings":";;;AACA,wDAAoD;AACpD,uCAAsC;AACtC,uDAAiD;AAEjD,yCAA8C;AAS9C;;GAEG;AACH,MAAa,cAAc;IAEvB;;;;OAIG;IACH,IAAI,CAAS;IACb;;;OAGG;IACH,KAAK,CAAU;IACf;;OAEG;IACH,IAAI,CAAU;IACd;;OAEG;IACH,WAAW,CAAU;IACrB;;OAEG;IACH,KAAK,CAAe;IAEpB,YAAY,EACR,IAAI,EAAE,KAAK,EAA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AI,CAAC;gBACZ,GAAG,CAAC;gBACJ,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;aACH,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC,CAAC,kBAAkB;YACnC,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC;YACjC,OAAO,GAAG,CAAC,IAAI,CAAC;gBACZ,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,WAAW;gBAChD,KAAK,EAAE,GAAG,CAAC,OAAO,IAAI,sBAAsB;gBAC5C,MAAM;aAC4B,EAAE,MAAM,CAAC,CAAA;QACnD,CAAC;IACL,CAAC;IAED,kBAAkB;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;IACvC,CAAC;CAEJ;AA/ED,wCA+EC;AAGD,KAAK,UAAU,WAAW,CAAC,GAAY;IACnC,IAAI,CAAC;QACD,OAAO,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,EAA+B,CAAC;IAC7D,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAChB,MAAM,IAAI,8BAAa,CAAC,GAAG,EAAE;YACzB,OAAO,EAAE,4CAA4C,GAAG,GAAG,CAAC,OAAO;SACtE,CAAC,CAAC;IACP,CAAC;AACL,CAAC"}
|
package/lib/cjs/auth.js
CHANGED
|
@@ -25,18 +25,20 @@ async function getJwks(url) {
|
|
|
25
25
|
}
|
|
26
26
|
async function verifyToken(token) {
|
|
27
27
|
const decodedJwt = (0, jose_1.decodeJwt)(token);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
throw new Error("No studio endpoint found in JWT");
|
|
28
|
+
if (!decodedJwt.iss) {
|
|
29
|
+
throw new Error("No issuer URL found in JWT");
|
|
31
30
|
}
|
|
32
|
-
|
|
31
|
+
if (!isAllowedIssuer(decodedJwt.iss)) {
|
|
32
|
+
throw new Error("Issuer is not allowed: " + decodedJwt.iss);
|
|
33
|
+
}
|
|
34
|
+
const jwks = await getJwks(`${decodedJwt.iss}/.well-known/jwks`);
|
|
33
35
|
return await (0, jose_1.jwtVerify)(token, jwks);
|
|
34
36
|
}
|
|
35
37
|
async function authorize(ctx) {
|
|
36
38
|
const auth = ctx.req.header('Authorization');
|
|
37
39
|
if (!auth) {
|
|
38
40
|
throw new http_exception_1.HTTPException(401, {
|
|
39
|
-
message: `Missing Authorization header
|
|
41
|
+
message: `Missing Authorization header`
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
const [scheme, value] = auth.trim().split(' ');
|
|
@@ -81,4 +83,7 @@ class AuthSession {
|
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
exports.AuthSession = AuthSession;
|
|
86
|
+
function isAllowedIssuer(iss) {
|
|
87
|
+
return iss.endsWith(".vertesia.io") || iss.endsWith(".becomposable.com");
|
|
88
|
+
}
|
|
84
89
|
//# sourceMappingURL=auth.js.map
|
package/lib/cjs/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":";;;AAQA,0BAcC;AAED,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":";;;AAQA,0BAcC;AAED,kCAUC;AAGD,8BA6BC;AAlED,6CAAmE;AAGnE,wDAAoD;AACpD,+BAA+F;AAE/F,MAAM,KAAK,GAAoC,EAAE,CAAC;AAE3C,KAAK,UAAU,OAAO,CAAC,GAAW;IACrC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACnC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;gBACP,OAAO,CAAC,CAAC,IAAI,E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AO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAnBD,kCAmBC;AAED,SAAS,eAAe,CAAC,GAAW;IAChC,OAAO,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AAC7E,CAAC"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -14,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.AuthSession = exports.authorize = void 0;
|
|
18
|
+
var auth_js_1 = require("./auth.js");
|
|
19
|
+
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return auth_js_1.authorize; } });
|
|
20
|
+
Object.defineProperty(exports, "AuthSession", { enumerable: true, get: function () { return auth_js_1.AuthSession; } });
|
|
21
|
+
__exportStar(require("./InteractionCollection.js"), exports);
|
|
18
22
|
__exportStar(require("./ToolCollection.js"), exports);
|
|
19
23
|
__exportStar(require("./ToolRegistry.js"), exports);
|
|
20
24
|
__exportStar(require("./types.js"), exports);
|
|
21
|
-
var auth_js_1 = require("./auth.js");
|
|
22
|
-
Object.defineProperty(exports, "AuthSession", { enumerable: true, get: function () { return auth_js_1.AuthSession; } });
|
|
23
|
-
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return auth_js_1.authorize; } });
|
|
24
25
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAmD;AAA1C,oGAAA,SAAS,OAAA;AAAE,sGAAA,WAAW,OAAA;AAC/B,6DAA2C;AAC3C,sDAAoC;AACpC,oDAAkC;AAClC,6CAA2B"}
|
package/lib/cjs/utils.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.kebabCaseToTitle = kebabCaseToTitle;
|
|
4
|
+
function kebabCaseToTitle(name) {
|
|
5
|
+
return name.split('-').map(p => p[0].toUpperCase() + p.substring(1)).join(' ');
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;AAAA,4CAEC;AAFD,SAAgB,gBAAgB,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { kebabCaseToTitle } from "./utils.js";
|
|
2
|
+
export class InteractionCollection {
|
|
3
|
+
interactions;
|
|
4
|
+
name;
|
|
5
|
+
title;
|
|
6
|
+
icon;
|
|
7
|
+
description;
|
|
8
|
+
constructor({ name, title, icon, description, interactions }) {
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.title = title || kebabCaseToTitle(name);
|
|
11
|
+
this.icon = icon;
|
|
12
|
+
this.description = description;
|
|
13
|
+
this.interactions = interactions;
|
|
14
|
+
}
|
|
15
|
+
addInteraction(interaction) {
|
|
16
|
+
this.interactions.push(interaction);
|
|
17
|
+
}
|
|
18
|
+
getInteractions() {
|
|
19
|
+
return this.interactions;
|
|
20
|
+
}
|
|
21
|
+
[Symbol.iterator]() {
|
|
22
|
+
let index = 0;
|
|
23
|
+
const interactions = this.interactions;
|
|
24
|
+
return {
|
|
25
|
+
next() {
|
|
26
|
+
if (index < interactions.length) {
|
|
27
|
+
return { value: interactions[index++], done: false };
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return { done: true, value: undefined };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
map(callback) {
|
|
36
|
+
return this.interactions.map(callback);
|
|
37
|
+
}
|
|
38
|
+
getInteractionByName(name) {
|
|
39
|
+
return this.interactions.find(interaction => interaction.name === name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=InteractionCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractionCollection.js","sourceRoot":"","sources":["../../src/InteractionCollection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK9C,MAAM,OAAO,qBAAqB;IAC9B,YAAY,CAAoB;IAChC,IAAI,CAAS;IACb,KAAK,CAAU;IACf,IAAI,CAAU;IACd,WAAW,CAAU;IACrB,YAAY,EACR,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EACnB;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IACD,cAAc,CAAC,WAAgB;QAC3B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACb,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QAEvC,OAAO;YACH,IAAI;gBACA,IAAI,KAAK,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC;oBAC9B,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gBACzD,CAAC;qBAAM,CAAC;oBACJ,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;gBAC5C,CAAC;YACL,CAAC;SACJ,CAAC;IACN,CAAC;IAED,GAAG,CAAI,QAA4D;QAC/D,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED,oBAAoB,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC5E,CAAC;CACJ"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HTTPException } from "hono/http-exception";
|
|
2
2
|
import { authorize } from "./auth.js";
|
|
3
3
|
import { ToolRegistry } from "./ToolRegistry.js";
|
|
4
|
+
import { kebabCaseToTitle } from "./utils.js";
|
|
4
5
|
/**
|
|
5
6
|
* Implements a tools collection endpoint
|
|
6
7
|
*/
|
|
@@ -86,7 +87,4 @@ async function readPayload(ctx) {
|
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
|
-
function kebabCaseToTitle(name) {
|
|
90
|
-
return name.split('-').map(p => p[0].toUpperCase() + p.substring(1)).join(' ');
|
|
91
|
-
}
|
|
92
90
|
//# sourceMappingURL=ToolCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolCollection.js","sourceRoot":"","sources":["../../src/ToolCollection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ToolCollection.js","sourceRoot":"","sources":["../../src/ToolCollection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAS9C;;GAEG;AACH,MAAM,OAAO,cAAc;IAEvB;;;;OAIG;IACH,IAAI,CAAS;IACb;;;OAGG;IACH,KAAK,CAAU;IACf;;OAEG;IACH,IAAI,CAAU;IACd;;OAEG;IACH,WAAW,CAAU;IACrB;;OAEG;IACH,KAAK,CAAe;IAEpB,YAAY,EACR,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EACd;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACb,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAEpC,OAAO;YACH,IAAI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CAAC;IACvC,CAAC;CAEJ;AAGD,KAAK,UAAU,WAAW,CAAC,GAAY;IACnC,IAAI,CAAC;QACD,OAAO,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,EAA+B,CAAC;IAC7D,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAChB,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE;YACzB,OAAO,EAAE,4CAA4C,GAAG,GAAG,CAAC,OAAO;SACtE,CAAC,CAAC;IACP,CAAC;AACL,CAAC"}
|
package/lib/esm/auth.js
CHANGED
|
@@ -19,18 +19,20 @@ export async function getJwks(url) {
|
|
|
19
19
|
}
|
|
20
20
|
export async function verifyToken(token) {
|
|
21
21
|
const decodedJwt = decodeJwt(token);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
throw new Error("No studio endpoint found in JWT");
|
|
22
|
+
if (!decodedJwt.iss) {
|
|
23
|
+
throw new Error("No issuer URL found in JWT");
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
if (!isAllowedIssuer(decodedJwt.iss)) {
|
|
26
|
+
throw new Error("Issuer is not allowed: " + decodedJwt.iss);
|
|
27
|
+
}
|
|
28
|
+
const jwks = await getJwks(`${decodedJwt.iss}/.well-known/jwks`);
|
|
27
29
|
return await jwtVerify(token, jwks);
|
|
28
30
|
}
|
|
29
31
|
export async function authorize(ctx) {
|
|
30
32
|
const auth = ctx.req.header('Authorization');
|
|
31
33
|
if (!auth) {
|
|
32
34
|
throw new HTTPException(401, {
|
|
33
|
-
message: `Missing Authorization header
|
|
35
|
+
message: `Missing Authorization header`
|
|
34
36
|
});
|
|
35
37
|
}
|
|
36
38
|
const [scheme, value] = auth.trim().split(' ');
|
|
@@ -74,4 +76,7 @@ export class AuthSession {
|
|
|
74
76
|
return this._client;
|
|
75
77
|
}
|
|
76
78
|
}
|
|
79
|
+
function isAllowedIssuer(iss) {
|
|
80
|
+
return iss.endsWith(".vertesia.io") || iss.endsWith(".becomposable.com");
|
|
81
|
+
}
|
|
77
82
|
//# sourceMappingURL=auth.js.map
|
package/lib/esm/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAiB,SAAS,EAAmB,MAAM,MAAM,CAAC;AAE/F,MAAM,KAAK,GAAoC,EAAE,CAAC;AAElD,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW;IACrC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACnC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;gBACP,OAAO,CAAC,CAAC,IAAI,EAA4B,CAAC;YAC9C,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAA;QACF,KAAK,CAAC,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAa;IAC3C,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACpC,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../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AC,GAAG,EAAE;YACzB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,KAAK,EAAE,GAAG;SACb,CAAC,CAAC;IACP,CAAC;AACL,CAAC;AAED,MAAM,OAAO,WAAW;IAOD;IAAsB;IANzC,OAAO,CAA6B;IACpC,SAAS,CAGP;IAEF,YAAmB,KAAa,EAAS,OAAyB;QAA/C,UAAK,GAAL,KAAK,CAAQ;QAAS,YAAO,GAAP,OAAO,CAAkB;QAC9D,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,SAAS,CAEjD,CAAC;IACN,CAAC;IAED,KAAK,CAAC,SAAS;QACX,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,GAAG,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAChF,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAED,SAAS,eAAe,CAAC,GAAW;IAChC,OAAO,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AAC7E,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export { authorize, AuthSession } from "./auth.js";
|
|
2
|
+
export * from "./InteractionCollection.js";
|
|
1
3
|
export * from "./ToolCollection.js";
|
|
2
4
|
export * from "./ToolRegistry.js";
|
|
3
5
|
export * from "./types.js";
|
|
4
|
-
export { AuthSession, authorize } from "./auth.js";
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
package/lib/esm/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InteractionSpec } from "@vertesia/common";
|
|
2
|
+
import { ICollection, CollectionProperties } from "./types.js";
|
|
3
|
+
export interface InteractionCollectionProps extends CollectionProperties {
|
|
4
|
+
interactions: InteractionSpec[];
|
|
5
|
+
}
|
|
6
|
+
export declare class InteractionCollection implements ICollection<InteractionSpec> {
|
|
7
|
+
interactions: InteractionSpec[];
|
|
8
|
+
name: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
icon?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
constructor({ name, title, icon, description, interactions }: InteractionCollectionProps);
|
|
13
|
+
addInteraction(interaction: any): void;
|
|
14
|
+
getInteractions(): InteractionSpec[];
|
|
15
|
+
[Symbol.iterator](): Iterator<InteractionSpec>;
|
|
16
|
+
map<U>(callback: (interaction: InteractionSpec, index: number) => U): U[];
|
|
17
|
+
getInteractionByName(name: string): InteractionSpec | undefined;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=InteractionCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractionCollection.d.ts","sourceRoot":"","sources":["../../src/InteractionCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAG/D,MAAM,WAAW,0BAA2B,SAAQ,oBAAoB;IACpE,YAAY,EAAE,eAAe,EAAE,CAAC;CACnC;AACD,qBAAa,qBAAsB,YAAW,WAAW,CAAC,eAAe,CAAC;IACtE,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;gBACT,EACR,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAC/C,EAAE,0BAA0B;IAO7B,cAAc,CAAC,WAAW,EAAE,GAAG;IAI/B,eAAe;IAIf,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,eAAe,CAAC;IAe9C,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE;IAIzE,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;CAGlE"}
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
import { Context } from "hono";
|
|
2
2
|
import { ToolRegistry } from "./ToolRegistry.js";
|
|
3
|
-
import type { Tool, ToolDefinition } from "./types.js";
|
|
4
|
-
export interface ToolCollectionProperties {
|
|
5
|
-
/**
|
|
6
|
-
* A kebab case collection name. Must only contains alphanumeric and dash characters,
|
|
7
|
-
* The name can be used to generate the path where the collection is exposed.
|
|
8
|
-
* Example: my-collection
|
|
9
|
-
*/
|
|
10
|
-
name: string;
|
|
11
|
-
/**
|
|
12
|
-
* Optional title for UI display.
|
|
13
|
-
* If not provided the pascal case version of the name will be used
|
|
14
|
-
*/
|
|
15
|
-
title?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Optional icon for UI display
|
|
18
|
-
*/
|
|
19
|
-
icon?: string;
|
|
20
|
-
/**
|
|
21
|
-
* A short description
|
|
22
|
-
*/
|
|
23
|
-
description: string;
|
|
3
|
+
import type { CollectionProperties, ICollection, Tool, ToolDefinition } from "./types.js";
|
|
4
|
+
export interface ToolCollectionProperties extends CollectionProperties {
|
|
24
5
|
/**
|
|
25
6
|
* The tools
|
|
26
7
|
*/
|
|
@@ -29,7 +10,7 @@ export interface ToolCollectionProperties {
|
|
|
29
10
|
/**
|
|
30
11
|
* Implements a tools collection endpoint
|
|
31
12
|
*/
|
|
32
|
-
export declare class ToolCollection implements
|
|
13
|
+
export declare class ToolCollection implements ICollection<Tool<any>> {
|
|
33
14
|
/**
|
|
34
15
|
* A kebab case collection name. Must only contains alphanumeric and dash characters,
|
|
35
16
|
* The name can be used to generate the path where the collection is exposed.
|
|
@@ -48,7 +29,7 @@ export declare class ToolCollection implements Iterable<Tool<any>> {
|
|
|
48
29
|
/**
|
|
49
30
|
* A short description
|
|
50
31
|
*/
|
|
51
|
-
description
|
|
32
|
+
description?: string;
|
|
52
33
|
/**
|
|
53
34
|
* The tool registry
|
|
54
35
|
*/
|
|
@@ -56,19 +37,7 @@ export declare class ToolCollection implements Iterable<Tool<any>> {
|
|
|
56
37
|
constructor({ name, title, icon, description, tools }: ToolCollectionProperties);
|
|
57
38
|
[Symbol.iterator](): Iterator<Tool<any>>;
|
|
58
39
|
map<U>(callback: (tool: Tool<any>, index: number) => U): U[];
|
|
59
|
-
execute(ctx: Context): Promise<
|
|
60
|
-
tool_use_id: string;
|
|
61
|
-
meta?: {
|
|
62
|
-
[x: string]: any;
|
|
63
|
-
} | undefined;
|
|
64
|
-
content: string;
|
|
65
|
-
is_error: boolean;
|
|
66
|
-
files?: string[] | undefined;
|
|
67
|
-
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
68
|
-
tool_use_id: string;
|
|
69
|
-
error: any;
|
|
70
|
-
status: any;
|
|
71
|
-
}, any, "json">)>;
|
|
40
|
+
execute(ctx: Context): Promise<Response>;
|
|
72
41
|
getToolDefinitions(): ToolDefinition[];
|
|
73
42
|
}
|
|
74
43
|
//# sourceMappingURL=ToolCollection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolCollection.d.ts","sourceRoot":"","sources":["../../src/ToolCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ToolCollection.d.ts","sourceRoot":"","sources":["../../src/ToolCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAA2E,MAAM,YAAY,CAAC;AAGnK,MAAM,WAAW,wBAAyB,SAAQ,oBAAoB;IAClE;;OAEG;IACH,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEzD;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;gBAER,EACR,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EACxC,EAAE,wBAAwB;IAQ3B,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAexC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE;IAItD,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAoB9C,kBAAkB,IAAI,cAAc,EAAE;CAIzC"}
|
package/lib/types/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAA0D,eAAe,EAAE,MAAM,MAAM,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGlD,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,4BAcxC;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAA0D,eAAe,EAAE,MAAM,MAAM,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGlD,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,4BAcxC;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,0FAU9C;AAGD,wBAAsB,SAAS,CAAC,GAAG,EAAE,OAAO,wBA6B3C;AAED,qBAAa,WAAY,YAAW,oBAAoB;IAOjC,KAAK,EAAE,MAAM;IAAS,OAAO,EAAE,gBAAgB;IANlE,OAAO,EAAE,cAAc,GAAG,SAAS,CAAC;IACpC,SAAS,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC;gBAEiB,KAAK,EAAE,MAAM,EAAS,OAAO,EAAE,gBAAgB;IAM5D,SAAS;CAMlB"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export { authorize, AuthSession } from "./auth.js";
|
|
2
|
+
export * from "./InteractionCollection.js";
|
|
1
3
|
export * from "./ToolCollection.js";
|
|
2
4
|
export * from "./ToolRegistry.js";
|
|
3
5
|
export * from "./types.js";
|
|
4
|
-
export { AuthSession, authorize } from "./auth.js";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import type { ToolDefinition, ToolUse } from "@llumiverse/common";
|
|
2
2
|
import { VertesiaClient } from "@vertesia/client";
|
|
3
3
|
import { AuthTokenPayload, ToolResult, ToolResultContent } from "@vertesia/common";
|
|
4
|
+
export type ICollection<T = any> = CollectionProperties & Iterable<T>;
|
|
5
|
+
export interface CollectionProperties {
|
|
6
|
+
/**
|
|
7
|
+
* A kebab case collection name. Must only contains alphanumeric and dash characters,
|
|
8
|
+
* The name can be used to generate the path where the collection is exposed.
|
|
9
|
+
* Example: my-collection
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional title for UI display.
|
|
14
|
+
* If not provided the pascal case version of the name will be used
|
|
15
|
+
*/
|
|
16
|
+
title?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional icon for UI display
|
|
19
|
+
*/
|
|
20
|
+
icon?: string;
|
|
21
|
+
/**
|
|
22
|
+
* A short description
|
|
23
|
+
*/
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
4
26
|
export interface ToolExecutionContext {
|
|
5
27
|
/**
|
|
6
28
|
* The raw JWT token to the tool execution request
|
package/lib/types/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEnF,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,gBAAgB,CAAC;IAC1B;;;OAGG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC1D;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAA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
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"types": "./lib/types/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"lib",
|
|
9
|
-
"src"
|
|
10
|
-
],
|
|
11
|
-
"license": "Apache-2.0",
|
|
12
|
-
"exports": {
|
|
2
|
+
"name": "@vertesia/tools-sdk",
|
|
3
|
+
"version": "0.80.0-dev-20251118",
|
|
4
|
+
"description": "Tools SDK - utilities for building remote tools",
|
|
5
|
+
"type": "module",
|
|
13
6
|
"types": "./lib/types/index.d.ts",
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
}
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"build": "pnpm exec tsmod build",
|
|
15
|
+
"clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"import": "./lib/esm/index.js",
|
|
20
|
+
"require": "./lib/cjs/index.js"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"ts-dual-module": "^0.6.3",
|
|
24
|
+
"typescript": "^5.0.2",
|
|
25
|
+
"vitest": "^3.0.9"
|
|
26
|
+
},
|
|
27
|
+
"ts_dual_module": {
|
|
28
|
+
"outDir": "lib"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"hono": "^4.9.6"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@llumiverse/common": "workspace:*",
|
|
35
|
+
"@vertesia/client": "workspace:*",
|
|
36
|
+
"@vertesia/common": "workspace:*",
|
|
37
|
+
"jose": "^6.0.11"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/vertesia/composableai.git",
|
|
42
|
+
"directory": "packages/tools-sdk"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { InteractionSpec } from "@vertesia/common";
|
|
2
|
+
import { ICollection, CollectionProperties } from "./types.js";
|
|
3
|
+
import { kebabCaseToTitle } from "./utils.js";
|
|
4
|
+
|
|
5
|
+
export interface InteractionCollectionProps extends CollectionProperties {
|
|
6
|
+
interactions: InteractionSpec[];
|
|
7
|
+
}
|
|
8
|
+
export class InteractionCollection implements ICollection<InteractionSpec> {
|
|
9
|
+
interactions: InteractionSpec[];
|
|
10
|
+
name: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
icon?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
constructor({
|
|
15
|
+
name, title, icon, description, interactions
|
|
16
|
+
}: InteractionCollectionProps) {
|
|
17
|
+
this.name = name;
|
|
18
|
+
this.title = title || kebabCaseToTitle(name);
|
|
19
|
+
this.icon = icon;
|
|
20
|
+
this.description = description;
|
|
21
|
+
this.interactions = interactions;
|
|
22
|
+
}
|
|
23
|
+
addInteraction(interaction: any) {
|
|
24
|
+
this.interactions.push(interaction);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getInteractions() {
|
|
28
|
+
return this.interactions;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[Symbol.iterator](): Iterator<InteractionSpec> {
|
|
32
|
+
let index = 0;
|
|
33
|
+
const interactions = this.interactions;
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
next(): IteratorResult<InteractionSpec> {
|
|
37
|
+
if (index < interactions.length) {
|
|
38
|
+
return { value: interactions[index++], done: false };
|
|
39
|
+
} else {
|
|
40
|
+
return { done: true, value: undefined };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
map<U>(callback: (interaction: InteractionSpec, index: number) => U): U[] {
|
|
47
|
+
return this.interactions.map(callback);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getInteractionByName(name: string): InteractionSpec | undefined {
|
|
51
|
+
return this.interactions.find(interaction => interaction.name === name);
|
|
52
|
+
}
|
|
53
|
+
}
|
package/src/ToolCollection.ts
CHANGED
|
@@ -2,29 +2,10 @@ import { Context } from "hono";
|
|
|
2
2
|
import { HTTPException } from "hono/http-exception";
|
|
3
3
|
import { authorize } from "./auth.js";
|
|
4
4
|
import { ToolRegistry } from "./ToolRegistry.js";
|
|
5
|
-
import type { Tool, ToolDefinition, ToolExecutionPayload, ToolExecutionResponse, ToolExecutionResponseError } from "./types.js";
|
|
6
|
-
|
|
7
|
-
export interface ToolCollectionProperties {
|
|
8
|
-
/**
|
|
9
|
-
* A kebab case collection name. Must only contains alphanumeric and dash characters,
|
|
10
|
-
* The name can be used to generate the path where the collection is exposed.
|
|
11
|
-
* Example: my-collection
|
|
12
|
-
*/
|
|
13
|
-
name: string;
|
|
14
|
-
/**
|
|
15
|
-
* Optional title for UI display.
|
|
16
|
-
* If not provided the pascal case version of the name will be used
|
|
17
|
-
*/
|
|
18
|
-
title?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Optional icon for UI display
|
|
21
|
-
*/
|
|
22
|
-
icon?: string;
|
|
23
|
-
/**
|
|
24
|
-
* A short description
|
|
25
|
-
*/
|
|
26
|
-
description: string;
|
|
5
|
+
import type { CollectionProperties, ICollection, Tool, ToolDefinition, ToolExecutionPayload, ToolExecutionResponse, ToolExecutionResponseError } from "./types.js";
|
|
6
|
+
import { kebabCaseToTitle } from "./utils.js";
|
|
27
7
|
|
|
8
|
+
export interface ToolCollectionProperties extends CollectionProperties {
|
|
28
9
|
/**
|
|
29
10
|
* The tools
|
|
30
11
|
*/
|
|
@@ -34,7 +15,7 @@ export interface ToolCollectionProperties {
|
|
|
34
15
|
/**
|
|
35
16
|
* Implements a tools collection endpoint
|
|
36
17
|
*/
|
|
37
|
-
export class ToolCollection implements
|
|
18
|
+
export class ToolCollection implements ICollection<Tool<any>> {
|
|
38
19
|
|
|
39
20
|
/**
|
|
40
21
|
* A kebab case collection name. Must only contains alphanumeric and dash characters,
|
|
@@ -54,7 +35,7 @@ export class ToolCollection implements Iterable<Tool<any>> {
|
|
|
54
35
|
/**
|
|
55
36
|
* A short description
|
|
56
37
|
*/
|
|
57
|
-
description
|
|
38
|
+
description?: string;
|
|
58
39
|
/**
|
|
59
40
|
* The tool registry
|
|
60
41
|
*/
|
|
@@ -89,7 +70,7 @@ export class ToolCollection implements Iterable<Tool<any>> {
|
|
|
89
70
|
return this.tools.getTools().map(callback);
|
|
90
71
|
}
|
|
91
72
|
|
|
92
|
-
async execute(ctx: Context) {
|
|
73
|
+
async execute(ctx: Context): Promise<Response> {
|
|
93
74
|
let payload: ToolExecutionPayload<any> | undefined;
|
|
94
75
|
try {
|
|
95
76
|
payload = await readPayload(ctx);
|
|
@@ -126,6 +107,3 @@ async function readPayload(ctx: Context) {
|
|
|
126
107
|
}
|
|
127
108
|
}
|
|
128
109
|
|
|
129
|
-
function kebabCaseToTitle(name: string) {
|
|
130
|
-
return name.split('-').map(p => p[0].toUpperCase() + p.substring(1)).join(' ');
|
|
131
|
-
}
|
package/src/auth.ts
CHANGED
|
@@ -24,21 +24,22 @@ export async function getJwks(url: string) {
|
|
|
24
24
|
|
|
25
25
|
export async function verifyToken(token: string) {
|
|
26
26
|
const decodedJwt = decodeJwt(token);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
throw new Error("No studio endpoint found in JWT");
|
|
27
|
+
if (!decodedJwt.iss) {
|
|
28
|
+
throw new Error("No issuer URL found in JWT");
|
|
30
29
|
}
|
|
31
|
-
|
|
30
|
+
if (!isAllowedIssuer(decodedJwt.iss)) {
|
|
31
|
+
throw new Error("Issuer is not allowed: " + decodedJwt.iss);
|
|
32
|
+
}
|
|
33
|
+
const jwks = await getJwks(`${decodedJwt.iss}/.well-known/jwks`);
|
|
32
34
|
return await jwtVerify<AuthTokenPayload>(token, jwks);
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
|
|
36
|
-
|
|
37
38
|
export async function authorize(ctx: Context) {
|
|
38
39
|
const auth = ctx.req.header('Authorization');
|
|
39
40
|
if (!auth) {
|
|
40
41
|
throw new HTTPException(401, {
|
|
41
|
-
message: `Missing Authorization header
|
|
42
|
+
message: `Missing Authorization header`
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
const [scheme, value] = auth.trim().split(' ');
|
|
@@ -84,4 +85,8 @@ export class AuthSession implements ToolExecutionContext {
|
|
|
84
85
|
}
|
|
85
86
|
return this._client;
|
|
86
87
|
}
|
|
87
|
-
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function isAllowedIssuer(iss: string) {
|
|
91
|
+
return iss.endsWith(".vertesia.io") || iss.endsWith(".becomposable.com");
|
|
92
|
+
}
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -2,6 +2,30 @@ import type { ToolDefinition, ToolUse } from "@llumiverse/common";
|
|
|
2
2
|
import { VertesiaClient } from "@vertesia/client";
|
|
3
3
|
import { AuthTokenPayload, ToolResult, ToolResultContent } from "@vertesia/common";
|
|
4
4
|
|
|
5
|
+
export type ICollection<T = any> = CollectionProperties & Iterable<T>
|
|
6
|
+
|
|
7
|
+
export interface CollectionProperties {
|
|
8
|
+
/**
|
|
9
|
+
* A kebab case collection name. Must only contains alphanumeric and dash characters,
|
|
10
|
+
* The name can be used to generate the path where the collection is exposed.
|
|
11
|
+
* Example: my-collection
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional title for UI display.
|
|
16
|
+
* If not provided the pascal case version of the name will be used
|
|
17
|
+
*/
|
|
18
|
+
title?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Optional icon for UI display
|
|
21
|
+
*/
|
|
22
|
+
icon?: string;
|
|
23
|
+
/**
|
|
24
|
+
* A short description
|
|
25
|
+
*/
|
|
26
|
+
description?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
5
29
|
export interface ToolExecutionContext {
|
|
6
30
|
/**
|
|
7
31
|
* The raw JWT token to the tool execution request
|
package/src/utils.ts
ADDED