@majkapp/plugin-kit 1.0.10 → 1.0.12
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/dist/plugin-kit.d.ts.map +1 -1
- package/dist/plugin-kit.js +46 -8
- package/package.json +1 -1
package/dist/plugin-kit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-kit.d.ts","sourceRoot":"","sources":["../src/plugin-kit.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAGb,eAAe,EACf,QAAQ,EACR,WAAW,EACX,WAAW,EACX,QAAQ,EACR,WAAW,EACX,UAAU,EACV,eAAe,EACf,WAAW,EACX,KAAK,EACL,UAAU,EACV,SAAS,EACT,aAAa,EAIb,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin-kit.d.ts","sourceRoot":"","sources":["../src/plugin-kit.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAGb,eAAe,EACf,QAAQ,EACR,WAAW,EACX,WAAW,EACX,QAAQ,EACR,WAAW,EACX,UAAU,EACV,eAAe,EACf,WAAW,EACX,KAAK,EACL,UAAU,EACV,SAAS,EACT,aAAa,EAIb,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AA0tBjB;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,EAAE,SAAS,MAAM;IAC9C,mDAAmD;IACnD,MAAM,CAAC,KAAK,EAAE,mBAAmB,EAAE,IAAI,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAE7G,0CAA0C;IAC1C,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAE5B,yBAAyB;IACz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EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,aAAa,CAAC,EAAE,CAAC,CA4WnB"}
|
package/dist/plugin-kit.js
CHANGED
|
@@ -152,13 +152,19 @@ function validateEntity(entityType, entity) {
|
|
|
152
152
|
*/
|
|
153
153
|
function pathToRegex(p) {
|
|
154
154
|
const keys = [];
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
console.log(`[pathToRegex] Input path: ${p}`);
|
|
156
|
+
const afterParamReplace = p.replace(/\/:([A-Za-z0-9_]+)/g, (_m, k) => {
|
|
157
157
|
keys.push(k);
|
|
158
|
+
console.log(`[pathToRegex] Found param: ${k}`);
|
|
158
159
|
return '/([^/]+)';
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
});
|
|
161
|
+
console.log(`[pathToRegex] After param replace: ${afterParamReplace}`);
|
|
162
|
+
const pattern = afterParamReplace.replace(/([.+*?=^!${}()[\]|/\\])/g, '\\$1');
|
|
163
|
+
console.log(`[pathToRegex] Final pattern: ${pattern}`);
|
|
164
|
+
console.log(`[pathToRegex] Keys: [${keys.join(', ')}]`);
|
|
165
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
166
|
+
console.log(`[pathToRegex] Final regex: ${regex}`);
|
|
167
|
+
return { regex, keys };
|
|
162
168
|
}
|
|
163
169
|
/**
|
|
164
170
|
* CORS headers
|
|
@@ -527,6 +533,12 @@ class BuiltPlugin {
|
|
|
527
533
|
const url = new URL(req.url, `http://localhost:${port}`);
|
|
528
534
|
const pathname = url.pathname;
|
|
529
535
|
const method = req.method;
|
|
536
|
+
this.context.logger.info(`[ROUTE MATCHING] Incoming: ${method} ${pathname}`);
|
|
537
|
+
this.context.logger.info(`[ROUTE MATCHING] Available routes: ${this.router.length}`);
|
|
538
|
+
this.router.forEach((r, idx) => {
|
|
539
|
+
const matches = r.regex.test(pathname);
|
|
540
|
+
this.context.logger.info(`[ROUTE MATCHING] Route ${idx}: ${r.method} ${r.name} - regex: ${r.regex} - keys: [${r.keys.join(', ')}] - matches: ${matches}`);
|
|
541
|
+
});
|
|
530
542
|
const route = this.router.find(r => r.method === method && r.regex.test(pathname));
|
|
531
543
|
if (!route) {
|
|
532
544
|
res.writeHead(404, corsHeaders({ 'Content-Type': 'application/json' }));
|
|
@@ -808,11 +820,37 @@ function definePlugin(id, name, version) {
|
|
|
808
820
|
// Add tools (grouped by scope)
|
|
809
821
|
const toolGroups = groupByScope(_toolSpecs);
|
|
810
822
|
for (const group of toolGroups) {
|
|
811
|
-
|
|
823
|
+
const capability = {
|
|
812
824
|
type: 'tool',
|
|
813
825
|
scope: group.scope,
|
|
814
|
-
tools: group.tools
|
|
815
|
-
|
|
826
|
+
tools: group.tools.map(t => ({
|
|
827
|
+
name: t.name,
|
|
828
|
+
description: t.description,
|
|
829
|
+
inputSchema: t.inputSchema,
|
|
830
|
+
metadata: t.metadata
|
|
831
|
+
}))
|
|
832
|
+
};
|
|
833
|
+
// Extract scope entity info from first tool's metadata
|
|
834
|
+
// This allows plugins to specify teammateId, projectId, or conversationId in metadata
|
|
835
|
+
// and have them automatically promoted to capability-level scope fields
|
|
836
|
+
if (group.scope !== 'global' && group.tools.length > 0) {
|
|
837
|
+
const firstTool = group.tools[0];
|
|
838
|
+
if (firstTool.metadata) {
|
|
839
|
+
if (group.scope === 'teammate' && firstTool.metadata.teammateId) {
|
|
840
|
+
capability.scopeEntityType = 'teamMember';
|
|
841
|
+
capability.scopeEntityId = firstTool.metadata.teammateId;
|
|
842
|
+
}
|
|
843
|
+
else if (group.scope === 'project' && firstTool.metadata.projectId) {
|
|
844
|
+
capability.scopeEntityType = 'project';
|
|
845
|
+
capability.scopeEntityId = firstTool.metadata.projectId;
|
|
846
|
+
}
|
|
847
|
+
else if (group.scope === 'conversation' && firstTool.metadata.conversationId) {
|
|
848
|
+
capability.scopeEntityType = 'conversation';
|
|
849
|
+
capability.scopeEntityId = firstTool.metadata.conversationId;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
_capabilities.push(capability);
|
|
816
854
|
}
|
|
817
855
|
// Add entities
|
|
818
856
|
for (const entity of _entities) {
|