@pi-unipi/web-api 0.1.1 → 0.1.3
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/package.json +1 -1
- package/src/index.ts +15 -6
- package/src/tools.ts +4 -3
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -36,7 +36,7 @@ function getInfoRegistry() {
|
|
|
36
36
|
|
|
37
37
|
export default function (pi: ExtensionAPI) {
|
|
38
38
|
// Register skills directory
|
|
39
|
-
const skillsDir = new URL("
|
|
39
|
+
const skillsDir = new URL("../skills", import.meta.url).pathname;
|
|
40
40
|
pi.on("resources_discover", async (_event, _ctx) => {
|
|
41
41
|
return {
|
|
42
42
|
skillPaths: [skillsDir],
|
|
@@ -75,7 +75,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
75
75
|
name: "Web API",
|
|
76
76
|
icon: "🌐",
|
|
77
77
|
priority: 50,
|
|
78
|
-
|
|
78
|
+
config: {
|
|
79
|
+
showByDefault: true,
|
|
80
|
+
stats: [
|
|
81
|
+
{ id: "providers", label: "Enabled Providers", show: true },
|
|
82
|
+
{ id: "cacheEntries", label: "Cache Entries", show: true },
|
|
83
|
+
{ id: "cacheSize", label: "Cache Size", show: true },
|
|
84
|
+
{ id: "expired", label: "Expired Entries", show: true },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
dataProvider: async () => {
|
|
79
88
|
const config = loadConfig();
|
|
80
89
|
const stats = webCache.getStats();
|
|
81
90
|
const enabledCount = Object.values(config.providers).filter(
|
|
@@ -83,10 +92,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
83
92
|
).length;
|
|
84
93
|
|
|
85
94
|
return {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
providers: { value: String(enabledCount) },
|
|
96
|
+
cacheEntries: { value: String(stats.totalEntries) },
|
|
97
|
+
cacheSize: { value: `${(stats.totalSizeBytes / 1024).toFixed(1)} KB` },
|
|
98
|
+
expired: { value: String(stats.expiredEntries) },
|
|
90
99
|
};
|
|
91
100
|
},
|
|
92
101
|
});
|
package/src/tools.ts
CHANGED
|
@@ -69,9 +69,10 @@ function selectProvider(
|
|
|
69
69
|
const allProviders = registry.getProvidersForCapability(capability);
|
|
70
70
|
const providerNames = allProviders.map((p) => p.name).join(", ");
|
|
71
71
|
throw new Error(
|
|
72
|
-
`No ${capability} provider
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
`No ${capability} provider configured.\n` +
|
|
73
|
+
`→ Run /unipi:web-settings to enable providers and add API keys.\n` +
|
|
74
|
+
`→ Free options: DuckDuckGo (search), Jina Reader (read).\n` +
|
|
75
|
+
`→ Available providers: ${providerNames}`
|
|
75
76
|
);
|
|
76
77
|
}
|
|
77
78
|
|