@almyty/skills 1.0.11 → 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/client.js +42 -6
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -114,16 +114,52 @@ export class AlmytyClient {
|
|
|
114
114
|
}
|
|
115
115
|
async executeSkill(gatewayId, toolId, parameters) {
|
|
116
116
|
// The execute endpoint expects a UUID. If toolId is a name slug,
|
|
117
|
-
// resolve
|
|
117
|
+
// resolve by listing the gateway's tools and matching either
|
|
118
|
+
// the raw tool name, its kebab slug, OR the new
|
|
119
|
+
// `${gateway-slug}-${tool-slug}` composed form (with shared
|
|
120
|
+
// head segments deduped — the same rule the backend uses to
|
|
121
|
+
// generate SKILL.md names).
|
|
118
122
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
119
123
|
let resolvedId = toolId;
|
|
120
124
|
if (!uuidRegex.test(toolId)) {
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
|
|
125
|
+
const gateway = await this.request(`/gateways/${gatewayId}`).catch(() => null);
|
|
126
|
+
const gatewaySlug = gateway?.data?.endpoint?.replace(/^\/+/, '') || '';
|
|
127
|
+
// Walk every page — server caps limit at 100.
|
|
128
|
+
const allTools = [];
|
|
129
|
+
let page = 1;
|
|
130
|
+
while (true) {
|
|
131
|
+
const resp = await this.request(`/gateways/${gatewayId}/tools?limit=100&page=${page}`);
|
|
132
|
+
const data = resp?.data || resp;
|
|
133
|
+
const items = data?.gatewayTools || data?.data || (Array.isArray(data) ? data : []);
|
|
134
|
+
allTools.push(...(Array.isArray(items) ? items : []));
|
|
135
|
+
const totalPages = data?.totalPages ?? 1;
|
|
136
|
+
if (page >= totalPages || items.length === 0)
|
|
137
|
+
break;
|
|
138
|
+
page++;
|
|
139
|
+
if (page > 50)
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
const slugify = (s) => (s || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
143
|
+
const dedupeShared = (head, tail) => {
|
|
144
|
+
const h = head.split('-').filter(Boolean);
|
|
145
|
+
const t = tail.split('-').filter(Boolean);
|
|
146
|
+
let i = 0;
|
|
147
|
+
while (i < t.length && i < h.length && t[i] === h[i])
|
|
148
|
+
i++;
|
|
149
|
+
return t.slice(i).join('-');
|
|
150
|
+
};
|
|
151
|
+
const match = allTools.find((gt) => {
|
|
124
152
|
const t = gt.tool || gt;
|
|
125
|
-
|
|
126
|
-
|
|
153
|
+
if (!t)
|
|
154
|
+
return false;
|
|
155
|
+
const rawName = t.name || '';
|
|
156
|
+
const slug = slugify(rawName);
|
|
157
|
+
const composed = gatewaySlug
|
|
158
|
+
? `${gatewaySlug}-${dedupeShared(gatewaySlug, slug)}`
|
|
159
|
+
: slug;
|
|
160
|
+
return (rawName === toolId ||
|
|
161
|
+
slug === toolId ||
|
|
162
|
+
composed === toolId);
|
|
127
163
|
});
|
|
128
164
|
if (!match) {
|
|
129
165
|
throw new Error(`Tool "${toolId}" not found in gateway ${gatewayId}`);
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { installSkills, removeSkills, listInstalledSkills } from './installer.js
|
|
|
6
6
|
import { loadConfig, resolveTargets } from './config.js';
|
|
7
7
|
import { generateMetaSkill } from './meta-skill.js';
|
|
8
8
|
import { selectInstallTargetsAuto, selectInstallTargetsInteractive, } from './target-selector.js';
|
|
9
|
-
const VERSION = '1.0.
|
|
9
|
+
const VERSION = '1.0.12';
|
|
10
10
|
function printHelp() {
|
|
11
11
|
console.log(`
|
|
12
12
|
almyty Skills CLI v${VERSION}
|