@dudko.dev/agent-web 0.0.41 → 0.0.42
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 +7 -3
- package/dist/agent-web.js +133 -133
- package/dist/agent-web.js.map +1 -1
- package/dist/{chunk-4FBTBE74.js → chunk-2MLHZ6LQ.js} +2 -2
- package/dist/{chunk-L7Y3QRAM.js → chunk-DAREMCXF.js} +2 -2
- package/dist/{chunk-YUA2BHRM.js → chunk-ZSZSSJS4.js} +402 -13
- package/dist/chunk-ZSZSSJS4.js.map +1 -0
- package/dist/{elicitation-BA1knkdA.d.cts → elicitation-DS-84_bF.d.cts} +123 -9
- package/dist/{elicitation-BA1knkdA.d.ts → elicitation-DS-84_bF.d.ts} +123 -9
- package/dist/index.cjs +145 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +69 -23
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +352 -9
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +12 -6
- package/dist/mcp.d.ts +12 -6
- package/dist/mcp.js +8 -3
- package/dist/mcp.js.map +1 -1
- package/dist/{sandbox-ZDQIIZS7.js → sandbox-3VRX47UY.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-YUA2BHRM.js.map +0 -1
- /package/dist/{chunk-4FBTBE74.js.map → chunk-2MLHZ6LQ.js.map} +0 -0
- /package/dist/{chunk-L7Y3QRAM.js.map → chunk-DAREMCXF.js.map} +0 -0
- /package/dist/{sandbox-ZDQIIZS7.js.map → sandbox-3VRX47UY.js.map} +0 -0
|
@@ -40,9 +40,15 @@ declare class IndexedDBVault {
|
|
|
40
40
|
* (`selectMcpSkills`), the files of a loaded skill the model may read (`resolveMcpSkillFile`),
|
|
41
41
|
* the preamble a skill's text is loaded under, the mark that carries a server's skills on its
|
|
42
42
|
* tools (`markMcpSkills` / `collectMcpSkillSources`), a skill the model names by URI
|
|
43
|
-
* (`mcpSkillUriRefusal`, `resolveMcpSkillServer`: `skills/get` to that one server only)
|
|
43
|
+
* (`mcpSkillUriRefusal`, `resolveMcpSkillServer`: `skills/get` to that one server only), the
|
|
44
44
|
* person's consent before a skill's text enters the model's context (`decideMcpSkillConsent`,
|
|
45
|
-
* `mcpSkillConsentView`)
|
|
45
|
+
* `mcpSkillConsentView`) and a directory of a skill (`skillDirectoryOf`, `resolveMcpSkillPath`,
|
|
46
|
+
* `skillDirectoryListing` - for every kind of skill - and, for a server that serves
|
|
47
|
+
* `resources/directory/read`, `compareMcpSkillDirectory`) and, for a server the host trusts with
|
|
48
|
+
* its generated skills (`skills: { dynamic: true }`), the snapshot such a skill is read into
|
|
49
|
+
* before anyone is asked (`startMcpSkillWalk`, `takeMcpSkillWalkListing`,
|
|
50
|
+
* `mcpSkillSnapshotBytesRefusal`, `mcpSkillSnapshotEntry`). Pure, no imports (a digest is
|
|
51
|
+
* computed with the platform's WebCrypto, `globalThis.crypto.subtle`, or a function passed in).
|
|
46
52
|
*
|
|
47
53
|
* A server's skills are third-party text. They reach the model only as knowledge, under
|
|
48
54
|
* `mcpSkillPreamble`, and - unless the host vetted the server (`consent: 'never'`) - only after a
|
|
@@ -95,13 +101,19 @@ interface McpSkillEntryLike {
|
|
|
95
101
|
* naming rules;
|
|
96
102
|
* - a description to show in the catalog;
|
|
97
103
|
* - `resources` is the complete list of its files (Resources): `"dynamic"` content is declined
|
|
98
|
-
* (a host MAY: there is nothing to verify it against
|
|
104
|
+
* (a host MAY: there is nothing to verify it against, and a consent could not bind to its
|
|
105
|
+
* content) - unless `options.dynamic` (the server's `skills: { dynamic: true }`: the host
|
|
106
|
+
* trusts that server with its generated skills, which are then read into a snapshot before
|
|
107
|
+
* anyone is asked, see {@link mcpSkillSnapshotEntry}); anything else is invalid;
|
|
99
108
|
* - every file is `SKILL.md` or a file inside the skill's directory, listed once, with a
|
|
100
109
|
* `sha256:` digest and a byte size, and `SKILL.md` is listed;
|
|
101
110
|
* - at most {@link MCP_SKILL_MAX_RESOURCES} files and {@link MCP_SKILL_MAX_TOTAL_BYTES} bytes
|
|
102
|
-
* (Limits: "both limits are checkable from the entry alone"
|
|
111
|
+
* (Limits: "both limits are checkable from the entry alone"; a generated skill's are counted
|
|
112
|
+
* on what its snapshot reads).
|
|
103
113
|
*/
|
|
104
|
-
declare const mcpSkillEntryRefusal: (entry: unknown
|
|
114
|
+
declare const mcpSkillEntryRefusal: (entry: unknown, options?: {
|
|
115
|
+
dynamic?: boolean;
|
|
116
|
+
}) => string | undefined;
|
|
105
117
|
/** One skill of a server, as the agent's catalog holds it (the entry stays with the connection). */
|
|
106
118
|
interface McpSkillRecord {
|
|
107
119
|
/** The `SKILL.md` URI: with the server, the skill's identity. */
|
|
@@ -114,6 +126,11 @@ interface McpSkillRecord {
|
|
|
114
126
|
path: string[];
|
|
115
127
|
/** Its files other than `SKILL.md`, by their path inside the skill, sorted. */
|
|
116
128
|
files: string[];
|
|
129
|
+
/**
|
|
130
|
+
* Generated by the server (`"resources": "dynamic"`, taken with `skills: { dynamic: true }`):
|
|
131
|
+
* no files are known until its snapshot is read, and there are no checksums.
|
|
132
|
+
*/
|
|
133
|
+
dynamic?: true;
|
|
117
134
|
}
|
|
118
135
|
/**
|
|
119
136
|
* How a skill of a server is introduced wherever its text is shown to the model (its
|
|
@@ -121,6 +138,44 @@ interface McpSkillRecord {
|
|
|
121
138
|
* wording is the guard.
|
|
122
139
|
*/
|
|
123
140
|
declare const mcpSkillPreamble: (server: string, uri: string) => string;
|
|
141
|
+
/**
|
|
142
|
+
* The most entries of one `resources/directory/read` answer looked at: the specification's 512
|
|
143
|
+
* files per skill, and room for the directories among them. The rest are not looked at.
|
|
144
|
+
*/
|
|
145
|
+
declare const MCP_SKILL_DIRECTORY_ENTRIES_MAX: number;
|
|
146
|
+
/**
|
|
147
|
+
* What a server's live view of a directory says against the entry a skill was loaded with
|
|
148
|
+
* ({@link compareMcpSkillDirectory}): a count and paths of that entry - nothing of the server's
|
|
149
|
+
* own listing.
|
|
150
|
+
*/
|
|
151
|
+
interface McpSkillDirectoryDrift {
|
|
152
|
+
/** Children the server lists that the entry does not hold: counted, never named. */
|
|
153
|
+
extra: number;
|
|
154
|
+
/** Children the entry holds (paths inside the skill) that the server does not list, sorted. */
|
|
155
|
+
notServed: string[];
|
|
156
|
+
/**
|
|
157
|
+
* The server listed more than {@link MCP_SKILL_DIRECTORY_ENTRIES_MAX} entries: only those were
|
|
158
|
+
* looked at - `extra` is at least what it says, and `notServed` is left empty (unknown).
|
|
159
|
+
*/
|
|
160
|
+
truncated: boolean;
|
|
161
|
+
}
|
|
162
|
+
/** What `read_skill_file` answers for a directory of a skill (every path inside the skill). */
|
|
163
|
+
interface SkillDirectoryListing {
|
|
164
|
+
/** The skill's name in the catalog. */
|
|
165
|
+
name: string;
|
|
166
|
+
/** The directory: `.` for the skill's root, else its path inside the skill. */
|
|
167
|
+
directory: string;
|
|
168
|
+
/** Its files (each read with `read_skill_file`), sorted. */
|
|
169
|
+
files: string[];
|
|
170
|
+
/** Its subdirectories (each listed the same way), sorted. */
|
|
171
|
+
directories: string[];
|
|
172
|
+
/** How many more it holds than the two lists show ({@link MCP_SKILL_FILES_SHOWN_MAX} in all). */
|
|
173
|
+
more?: number;
|
|
174
|
+
/** Shown above, but no longer listed by the skill's MCP server: a read of them will fail. */
|
|
175
|
+
notServed?: string[];
|
|
176
|
+
/** The skill changed on its MCP server since it was loaded ({@link mcpSkillDirectoryNote}). */
|
|
177
|
+
note?: string;
|
|
178
|
+
}
|
|
124
179
|
/** The longest URI `load_skill` sends to a server, in characters. */
|
|
125
180
|
declare const MCP_SKILL_URI_MAX_CHARS = 512;
|
|
126
181
|
/**
|
|
@@ -150,6 +205,16 @@ interface McpSkillsOptions {
|
|
|
150
205
|
* vetted (its skills load as soon as the model asks). Whatever the approval mode says.
|
|
151
206
|
*/
|
|
152
207
|
consent?: McpSkillConsent;
|
|
208
|
+
/**
|
|
209
|
+
* `true`: also take this server's GENERATED skills (`"resources": "dynamic"` - no checksums;
|
|
210
|
+
* declined by default). When one would enter the model's context, the agent first reads all
|
|
211
|
+
* of it - `SKILL.md` and, if the server serves `resources/directory/read`, every file its
|
|
212
|
+
* directories list, within the specification's limits - computes each file's digest itself,
|
|
213
|
+
* and holds that copy in memory: the person approves that copy (the consent binds to its
|
|
214
|
+
* digests), and the model is given only that copy, never a later read. Per server, for a
|
|
215
|
+
* server you trust with this; there is no agent-wide switch.
|
|
216
|
+
*/
|
|
217
|
+
dynamic?: boolean;
|
|
153
218
|
}
|
|
154
219
|
/** `skills` on a server's config: `true`, or options (on, with them); `false` / absent: off. */
|
|
155
220
|
type McpSkillsSetting = boolean | McpSkillsOptions;
|
|
@@ -196,9 +261,33 @@ interface McpSkillConsentView {
|
|
|
196
261
|
byUri?: true;
|
|
197
262
|
/** It sits inside this skill of the same server, whose approval does not cover it. */
|
|
198
263
|
nestedIn?: string;
|
|
264
|
+
/**
|
|
265
|
+
* Generated by the server (`"resources": "dynamic"`, taken with `skills: { dynamic: true }`):
|
|
266
|
+
* there are no checksums. The size, the files and the text are those of the copy the agent just
|
|
267
|
+
* read (its snapshot), and only that copy is used - say so.
|
|
268
|
+
*/
|
|
269
|
+
dynamic?: true;
|
|
270
|
+
/**
|
|
271
|
+
* (with `dynamic`) The server cannot list the skill's files (no `resources/directory/read`): the
|
|
272
|
+
* copy is its `SKILL.md` alone, and no other file of it can be read.
|
|
273
|
+
*/
|
|
274
|
+
noFileListing?: true;
|
|
199
275
|
/** Asked for this run only (`'ask'`) or, on a yes, for the agent's life (`'once-per-skill'`). */
|
|
200
276
|
consent: Exclude<McpSkillConsent, 'never'>;
|
|
201
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* The most directories one snapshot reads (`resources/directory/read`, the skill's root
|
|
280
|
+
* included). One read is one directory, its pages walked by the SDK (bounded by its own page cap).
|
|
281
|
+
*/
|
|
282
|
+
declare const MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES = 64;
|
|
283
|
+
/** The deepest directory of a skill a snapshot reads: its root is 0, `templates` 1, ... */
|
|
284
|
+
declare const MCP_SKILL_SNAPSHOT_MAX_DEPTH = 8;
|
|
285
|
+
/** The most bytes the snapshots of one agent hold in memory together. */
|
|
286
|
+
declare const MCP_SKILL_SNAPSHOTS_MAX_BYTES: number;
|
|
287
|
+
/** What the snapshots of one agent hold in memory, in bytes ({@link MCP_SKILL_SNAPSHOTS_MAX_BYTES}). */
|
|
288
|
+
interface McpSkillSnapshotMemory {
|
|
289
|
+
used: number;
|
|
290
|
+
}
|
|
202
291
|
/** A loaded skill: its instructions, and the entry its files are read against (opaque). */
|
|
203
292
|
interface McpSkillLoaded {
|
|
204
293
|
readonly uri: string;
|
|
@@ -208,6 +297,16 @@ interface McpSkillLoaded {
|
|
|
208
297
|
readonly files: readonly string[];
|
|
209
298
|
/** The entry it was loaded with (the "held entry"): what a consent is bound to and shows. */
|
|
210
299
|
readonly entry: McpSkillEntryLike;
|
|
300
|
+
/**
|
|
301
|
+
* A generated skill's snapshot: `entry` is the manifest of the copy the agent read, which is
|
|
302
|
+
* held in memory and the only one used. `bytes`: what it holds (counted against the agent's
|
|
303
|
+
* {@link McpSkillSnapshotMemory}); `listed`: the server listed its files (`directoryRead`) -
|
|
304
|
+
* without, the copy is `SKILL.md` alone.
|
|
305
|
+
*/
|
|
306
|
+
readonly snapshot?: {
|
|
307
|
+
readonly bytes: number;
|
|
308
|
+
readonly listed: boolean;
|
|
309
|
+
};
|
|
211
310
|
}
|
|
212
311
|
/**
|
|
213
312
|
* The skills of one connected server, for the agent (a connection with `skills` on, to a server
|
|
@@ -234,18 +333,33 @@ interface McpSkillSource {
|
|
|
234
333
|
}) => Promise<McpSkillRecord>;
|
|
235
334
|
/**
|
|
236
335
|
* Read the skill's `SKILL.md` and verify it against its entry (size, digest, frontmatter);
|
|
237
|
-
* throws - and gives nothing - when it does not match.
|
|
336
|
+
* throws - and gives nothing - when it does not match. A generated skill (`dynamic`) is read
|
|
337
|
+
* into a snapshot instead (see {@link mcpSkillSnapshotEntry}), its bytes counted against
|
|
338
|
+
* `options.memory` (the agent's; a fresh one without); throws - logged - when it passes a bound.
|
|
238
339
|
*/
|
|
239
340
|
load: (uri: string, options?: {
|
|
240
341
|
signal?: AbortSignal;
|
|
342
|
+
memory?: McpSkillSnapshotMemory;
|
|
241
343
|
}) => Promise<McpSkillLoaded>;
|
|
242
344
|
/**
|
|
243
345
|
* Read one file of a loaded skill - a path its entry lists - and verify it against the entry
|
|
244
|
-
* the skill was loaded with
|
|
346
|
+
* the skill was loaded with; a snapshot's file is served from the snapshot, never read again.
|
|
347
|
+
* Text only; throws for anything else.
|
|
245
348
|
*/
|
|
246
349
|
readFile: (loaded: McpSkillLoaded, path: string, options?: {
|
|
247
350
|
signal?: AbortSignal;
|
|
248
351
|
}) => Promise<string>;
|
|
352
|
+
/**
|
|
353
|
+
* Only for a server that declared `directoryRead`: its live view of a directory of a loaded
|
|
354
|
+
* skill (`resources/directory/read` to THIS server, of the skill's root or `<root>/<dir>`),
|
|
355
|
+
* compared with the entry the skill was loaded with ({@link compareMcpSkillDirectory}) - a
|
|
356
|
+
* count and paths of that entry, nothing of the server's listing. `undefined` when the read
|
|
357
|
+
* failed (logged): the directory is then listed from the entry alone. Throws when `dir` is no
|
|
358
|
+
* directory of that entry (before any request), or when `options.signal` aborted the read.
|
|
359
|
+
*/
|
|
360
|
+
readDirectory?: (loaded: McpSkillLoaded, dir: string, options?: {
|
|
361
|
+
signal?: AbortSignal;
|
|
362
|
+
}) => Promise<McpSkillDirectoryDrift | undefined>;
|
|
249
363
|
}
|
|
250
364
|
|
|
251
365
|
/**
|
|
@@ -562,5 +676,5 @@ declare const normalizeMcpElicitationSchema: (raw: unknown) => Checked<McpElicit
|
|
|
562
676
|
*/
|
|
563
677
|
declare const validateMcpElicitationContent: (schema: McpElicitationSchema, content: unknown) => Checked<McpElicitationContent>;
|
|
564
678
|
|
|
565
|
-
export {
|
|
566
|
-
export type {
|
|
679
|
+
export { MCP_SKILL_URI_MAX_CHARS as A, IndexedDBVault as I, mcpAppOrigin as J, mcpSkillEntryRefusal as K, mcpSkillPreamble as L, mcpSkillUriRefusal as N, MCP_APP_DEFAULT_VISIBILITY as R, MCP_APP_MAX_DOMAINS as T, MCP_APP_MAX_DOWNLOAD_BYTES as U, MCP_ELICITATION_MAX_PER_RUN as W, MCP_ELICITATION_MAX_PER_TOOL_CALL as X, MCP_ELICITATION_TIMEOUT_MS as Y, McpAppResourceError as Z, isMcpAppMimeType as a4, isMcpAppUri as a5, mcpAppCspOf as a6, mcpAppDownloadOf as a7, mcpAppPermissionsOf as a8, mcpAppResourceOf as a9, mcpAppToolMeta as aa, mcpAppToolResultOf as ab, mcpAppsModeOf as ac, normalizeMcpElicitationSchema as ad, validateMcpElicitationContent as ae, MCP_APPS_EXTENSION as i, MCP_APP_MAX_HTML_CHARS as j, MCP_APP_MAX_RESULT_CHARS as k, MCP_APP_MIME_TYPE as l, MCP_SKILLS_EXTENSION as m, MCP_SKILLS_MAX_PER_SERVER as n, MCP_SKILLS_MAX_TOTAL as o, MCP_SKILL_BODY_MAX_CHARS as p, MCP_SKILL_CONSENTS as q, MCP_SKILL_CONSENT_DEFAULT as r, MCP_SKILL_DESCRIPTION_MAX_CHARS as s, MCP_SKILL_DIRECTORY_ENTRIES_MAX as t, MCP_SKILL_FILE_MAX_CHARS as u, MCP_SKILL_MAX_RESOURCES as v, MCP_SKILL_MAX_TOTAL_BYTES as w, MCP_SKILL_SNAPSHOTS_MAX_BYTES as x, MCP_SKILL_SNAPSHOT_MAX_DEPTH as y, MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES as z };
|
|
680
|
+
export type { McpAppsMode as $, McpAppCsp as B, McpAppPermissions as C, McpAppResource as D, McpAppVisibility as E, McpElicitationFieldSchema as F, McpSkillsOptions as G, McpSkillsSetting as H, McpSkillSource as M, McpElicitationHandler as O, McpElicitationOptions as P, McpAppDownloadResource as Q, SkillDirectoryListing as S, VaultOptions as V, McpAppToolMeta as _, McpSkillConsent as a, McpElicitationContent as a0, McpElicitationContext as a1, McpElicitationRequest as a2, McpElicitationResult as a3, McpSkillGrants as b, McpSkillRunConsent as c, McpSkillConsentView as d, McpSkillSnapshotMemory as e, McpElicitationSchema as f, McpElicitationReason as g, McpAppToolResult as h };
|
package/dist/index.cjs
CHANGED
|
@@ -586,7 +586,7 @@ var init_webllm = __esm({
|
|
|
586
586
|
});
|
|
587
587
|
|
|
588
588
|
// src/mcp/skills.ts
|
|
589
|
-
var MCP_SKILLS_EXTENSION, MCP_SKILL_MAX_RESOURCES, MCP_SKILL_MAX_TOTAL_BYTES, MCP_SKILLS_MAX_PER_SERVER, MCP_SKILLS_MAX_TOTAL, MCP_SKILL_DESCRIPTION_MAX_CHARS, MCP_SKILL_BODY_MAX_CHARS, MCP_SKILL_FILE_MAX_CHARS, MCP_SKILL_FILES_SHOWN_MAX, MCP_SKILL_SERVER_LABEL_MAX_CHARS, INVISIBLE, cleanMcpSkillText, oneLine, MCP_SKILL_NAME_PATTERN, DIGEST, SKILL_URI, isRecord, mcpSkillPath, mcpSkillFilePath, mcpSkillEntryRefusal, mcpSkillRecordOf, labelOf, segmentOf, assignMcpSkillNames, isMcpSkillName, selectMcpSkills, clipped, shownUri, mcpSkillTag, mcpSkillDescription, mcpSkillPreamble, mcpSkillBodyPreview, mcpSkillBodyText, mcpSkillFileText, resolveMcpSkillFile, MCP_SKILL_URI_MAX_CHARS, mcpSkillUriRefusal, resolveMcpSkillServer, mcpSkillRoomRefusal, assignAddedMcpSkillName, mcpSkillEnclosingUri, mcpSkillLoadByUriNote, MCP_SKILL_CONSENTS, MCP_SKILL_CONSENT_DEFAULT, consentList, mcpSkillConsentOf, resolveMcpSkillConsent, createMcpSkillGrants, createMcpSkillRunConsent, mcpSkillGrantKey, decideMcpSkillConsent, recordMcpSkillConsent, mcpSkillConsentView, mcpSkillDeniedMessage, MCP_SKILLS_MARK, collectMcpSkillSources;
|
|
589
|
+
var MCP_SKILLS_EXTENSION, MCP_SKILL_MAX_RESOURCES, MCP_SKILL_MAX_TOTAL_BYTES, MCP_SKILLS_MAX_PER_SERVER, MCP_SKILLS_MAX_TOTAL, MCP_SKILL_DESCRIPTION_MAX_CHARS, MCP_SKILL_BODY_MAX_CHARS, MCP_SKILL_FILE_MAX_CHARS, MCP_SKILL_FILES_SHOWN_MAX, MCP_SKILL_SERVER_LABEL_MAX_CHARS, INVISIBLE, cleanMcpSkillText, oneLine, MCP_SKILL_NAME_PATTERN, DIGEST, SKILL_URI, isRecord, mcpSkillPath, mcpSkillFilePath, mcpSkillEntryRefusal, mcpSkillRecordOf, labelOf, segmentOf, assignMcpSkillNames, isMcpSkillName, selectMcpSkills, clipped, shownUri, mcpSkillTag, mcpSkillDescription, mcpSkillPreamble, mcpSkillBodyPreview, mcpSkillBodyText, mcpSkillFileText, resolveMcpSkillFile, MCP_SKILL_DIRECTORY_ENTRIES_MAX, skillDirectoryRef, isPlainPath, skillDirectoryChildren, skillDirectoryOf, resolveMcpSkillPath, mcpSkillDirectoryNote, skillDirectoryListing, MCP_SKILL_URI_MAX_CHARS, mcpSkillUriRefusal, resolveMcpSkillServer, mcpSkillRoomRefusal, assignAddedMcpSkillName, mcpSkillEnclosingUri, mcpSkillLoadByUriNote, MCP_SKILL_CONSENTS, MCP_SKILL_CONSENT_DEFAULT, consentList, mcpSkillConsentOf, resolveMcpSkillConsent, createMcpSkillGrants, createMcpSkillRunConsent, mcpSkillGrantKey, decideMcpSkillConsent, recordMcpSkillConsent, mcpSkillConsentView, mcpSkillDeniedMessage, MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES, MCP_SKILL_SNAPSHOT_MAX_DEPTH, MCP_SKILL_SNAPSHOTS_MAX_BYTES, createMcpSkillSnapshotMemory, MCP_SKILLS_MARK, collectMcpSkillSources;
|
|
590
590
|
var init_skills = __esm({
|
|
591
591
|
"src/mcp/skills.ts"() {
|
|
592
592
|
"use strict";
|
|
@@ -629,7 +629,7 @@ var init_skills = __esm({
|
|
|
629
629
|
}
|
|
630
630
|
return path;
|
|
631
631
|
};
|
|
632
|
-
mcpSkillEntryRefusal = (entry) => {
|
|
632
|
+
mcpSkillEntryRefusal = (entry, options = {}) => {
|
|
633
633
|
if (!isRecord(entry) || typeof entry.uri !== "string") return "not a skill entry (no uri)";
|
|
634
634
|
const path = mcpSkillPath(entry.uri);
|
|
635
635
|
if (!path) return `${entry.uri} is not the SKILL.md of a named skill directory`;
|
|
@@ -646,6 +646,7 @@ var init_skills = __esm({
|
|
|
646
646
|
if (!oneLine(frontmatter.description)) return "the frontmatter has no description";
|
|
647
647
|
const resources = entry.resources;
|
|
648
648
|
if (resources === "dynamic") {
|
|
649
|
+
if (options.dynamic === true) return void 0;
|
|
649
650
|
return 'its content is generated ("resources": "dynamic"): there are no digests to verify it against';
|
|
650
651
|
}
|
|
651
652
|
if (!Array.isArray(resources)) return 'the entry does not list its files ("resources")';
|
|
@@ -691,7 +692,8 @@ var init_skills = __esm({
|
|
|
691
692
|
name: entry.frontmatter.name,
|
|
692
693
|
description: oneLine(entry.frontmatter.description),
|
|
693
694
|
path: mcpSkillPath(entry.uri) ?? [entry.frontmatter.name],
|
|
694
|
-
files
|
|
695
|
+
files,
|
|
696
|
+
...entry.resources === "dynamic" ? { dynamic: true } : {}
|
|
695
697
|
};
|
|
696
698
|
};
|
|
697
699
|
labelOf = (server) => (server.replace(/[^a-zA-Z0-9_-]/g, "_") || "_").slice(0, MCP_SKILL_SERVER_LABEL_MAX_CHARS);
|
|
@@ -729,9 +731,9 @@ var init_skills = __esm({
|
|
|
729
731
|
clipped = (text, max, what) => text.length > max ? `${text.slice(0, max)}
|
|
730
732
|
\u2026 [${what} cut at ${max} characters; the rest is not shown]` : text;
|
|
731
733
|
shownUri = (uri) => oneLine(uri).replace(/[[\]]/g, "").slice(0, 200);
|
|
732
|
-
mcpSkillTag = (server) => `[from the MCP server "${labelOf(server)}" - third-party]`;
|
|
733
|
-
mcpSkillDescription = (description, server) => {
|
|
734
|
-
const tag = ` ${mcpSkillTag(server)}`;
|
|
734
|
+
mcpSkillTag = (server, dynamic = false) => `[from the MCP server "${labelOf(server)}" - third-party${dynamic ? ", no checksums" : ""}]`;
|
|
735
|
+
mcpSkillDescription = (description, server, dynamic = false) => {
|
|
736
|
+
const tag = ` ${mcpSkillTag(server, dynamic)}`;
|
|
735
737
|
const room = Math.max(0, MCP_SKILL_DESCRIPTION_MAX_CHARS - tag.length);
|
|
736
738
|
const text = oneLine(description);
|
|
737
739
|
return `${text.length > room ? `${text.slice(0, Math.max(0, room - 1))}\u2026` : text}${tag}`;
|
|
@@ -765,6 +767,78 @@ var init_skills = __esm({
|
|
|
765
767
|
}
|
|
766
768
|
return { path };
|
|
767
769
|
};
|
|
770
|
+
MCP_SKILL_DIRECTORY_ENTRIES_MAX = MCP_SKILL_MAX_RESOURCES + 128;
|
|
771
|
+
skillDirectoryRef = (requested) => {
|
|
772
|
+
if (typeof requested !== "string") return { refused: "no directory path given" };
|
|
773
|
+
const raw = requested.trim();
|
|
774
|
+
if (raw === "" || raw === "." || raw === "./" || raw === "/") return { dir: "" };
|
|
775
|
+
const refused = { refused: `"${oneLine(requested)}" is not a directory inside the skill` };
|
|
776
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(raw) || raw.startsWith("/") || /[?#\\]/.test(raw)) {
|
|
777
|
+
return refused;
|
|
778
|
+
}
|
|
779
|
+
const dir = raw.replace(/^\.\/+/, "").replace(/\/+$/, "");
|
|
780
|
+
if (!dir) return { dir: "" };
|
|
781
|
+
if (dir.split("/").some((s) => !s || s === "." || s === "..")) return refused;
|
|
782
|
+
return { dir };
|
|
783
|
+
};
|
|
784
|
+
isPlainPath = (path) => path.split("/").every((s) => s !== "" && s !== "." && s !== "..");
|
|
785
|
+
skillDirectoryChildren = (paths, dir) => {
|
|
786
|
+
const prefix = dir ? `${dir}/` : "";
|
|
787
|
+
const files = /* @__PURE__ */ new Set();
|
|
788
|
+
const directories = /* @__PURE__ */ new Set();
|
|
789
|
+
for (const path of paths) {
|
|
790
|
+
if (typeof path !== "string" || !isPlainPath(path) || !path.startsWith(prefix)) continue;
|
|
791
|
+
const rest = path.slice(prefix.length);
|
|
792
|
+
const cut = rest.indexOf("/");
|
|
793
|
+
if (cut < 0) files.add(path);
|
|
794
|
+
else directories.add(`${prefix}${rest.slice(0, cut)}`);
|
|
795
|
+
}
|
|
796
|
+
if (dir && !files.size && !directories.size) return void 0;
|
|
797
|
+
return { files: [...files].sort(), directories: [...directories].sort() };
|
|
798
|
+
};
|
|
799
|
+
skillDirectoryOf = (paths, requested) => {
|
|
800
|
+
const ref = skillDirectoryRef(requested);
|
|
801
|
+
if ("refused" in ref) return void 0;
|
|
802
|
+
const children = skillDirectoryChildren(paths, ref.dir);
|
|
803
|
+
return children ? { dir: ref.dir, ...children } : void 0;
|
|
804
|
+
};
|
|
805
|
+
resolveMcpSkillPath = (files, requested) => {
|
|
806
|
+
const file = resolveMcpSkillFile(files, requested);
|
|
807
|
+
if ("path" in file) return file;
|
|
808
|
+
return skillDirectoryOf(files, requested) ?? file;
|
|
809
|
+
};
|
|
810
|
+
mcpSkillDirectoryNote = (extra, notServed, truncated2 = false) => {
|
|
811
|
+
const parts = [];
|
|
812
|
+
if (extra > 0) {
|
|
813
|
+
parts.push(
|
|
814
|
+
`The server now lists ${truncated2 ? "at least " : ""}${extra} more item(s) here than the approved entry of this skill: the skill changed on the server. They are not shown and cannot be read under the current approval.`
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
if (notServed > 0) {
|
|
818
|
+
parts.push(
|
|
819
|
+
`${notServed} item(s) listed here (notServed) are no longer listed by the server: a read of them will fail - the skill changed on the server.`
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
if (!parts.length) return void 0;
|
|
823
|
+
return `${parts.join(" ")} The skill is read again, and asked about again, when the server's skills are refreshed.`;
|
|
824
|
+
};
|
|
825
|
+
skillDirectoryListing = (name, dir, children, drift) => {
|
|
826
|
+
const directories = children.directories.slice(0, MCP_SKILL_FILES_SHOWN_MAX);
|
|
827
|
+
const files = children.files.slice(0, MCP_SKILL_FILES_SHOWN_MAX - directories.length);
|
|
828
|
+
const more = children.files.length + children.directories.length - files.length - directories.length;
|
|
829
|
+
const shown = /* @__PURE__ */ new Set([...directories, ...files]);
|
|
830
|
+
const notServed = drift ? drift.notServed.filter((p) => shown.has(p)) : [];
|
|
831
|
+
const note = drift ? mcpSkillDirectoryNote(drift.extra, notServed.length, drift.truncated) : void 0;
|
|
832
|
+
return {
|
|
833
|
+
name,
|
|
834
|
+
directory: dir || ".",
|
|
835
|
+
files,
|
|
836
|
+
directories,
|
|
837
|
+
...more > 0 ? { more } : {},
|
|
838
|
+
...notServed.length ? { notServed } : {},
|
|
839
|
+
...note ? { note } : {}
|
|
840
|
+
};
|
|
841
|
+
};
|
|
768
842
|
MCP_SKILL_URI_MAX_CHARS = 512;
|
|
769
843
|
mcpSkillUriRefusal = (uri) => {
|
|
770
844
|
if (typeof uri !== "string" || !uri) return "no skill URI given";
|
|
@@ -890,6 +964,7 @@ var init_skills = __esm({
|
|
|
890
964
|
body: mcpSkillBodyPreview(o.body),
|
|
891
965
|
...o.byUri ? { byUri: true } : {},
|
|
892
966
|
...o.nestedIn ? { nestedIn: oneLine(o.nestedIn).slice(0, 200) } : {},
|
|
967
|
+
...o.snapshot ? { dynamic: true, ...o.snapshot.listed ? {} : { noFileListing: true } } : {},
|
|
893
968
|
consent: o.consent
|
|
894
969
|
};
|
|
895
970
|
};
|
|
@@ -899,6 +974,10 @@ var init_skills = __esm({
|
|
|
899
974
|
const head = why === "denied" ? `The user did not allow ${what} to be loaded${said}` : why === "denied-earlier" ? `The user already refused ${what} in this task` : why === "no-one-to-ask" ? `${what[0].toUpperCase()}${what.slice(1)} is loaded only with a person's consent, and no one can be asked (no approval handler is configured)` : `No one answered whether ${what} may be loaded${said}`;
|
|
900
975
|
return `${head}: nothing of it is in your context. Do not load it again in this task; continue without it, or say what it would have been needed for.`;
|
|
901
976
|
};
|
|
977
|
+
MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES = 64;
|
|
978
|
+
MCP_SKILL_SNAPSHOT_MAX_DEPTH = 8;
|
|
979
|
+
MCP_SKILL_SNAPSHOTS_MAX_BYTES = 64 * 1024 * 1024;
|
|
980
|
+
createMcpSkillSnapshotMemory = () => ({ used: 0 });
|
|
902
981
|
MCP_SKILLS_MARK = /* @__PURE__ */ Symbol.for("@dudko.dev/agent:mcp-skills");
|
|
903
982
|
collectMcpSkillSources = (tools) => {
|
|
904
983
|
const out = [];
|
|
@@ -3033,9 +3112,13 @@ __export(src_exports, {
|
|
|
3033
3112
|
MCP_SKILL_CONSENTS: () => MCP_SKILL_CONSENTS,
|
|
3034
3113
|
MCP_SKILL_CONSENT_DEFAULT: () => MCP_SKILL_CONSENT_DEFAULT,
|
|
3035
3114
|
MCP_SKILL_DESCRIPTION_MAX_CHARS: () => MCP_SKILL_DESCRIPTION_MAX_CHARS,
|
|
3115
|
+
MCP_SKILL_DIRECTORY_ENTRIES_MAX: () => MCP_SKILL_DIRECTORY_ENTRIES_MAX,
|
|
3036
3116
|
MCP_SKILL_FILE_MAX_CHARS: () => MCP_SKILL_FILE_MAX_CHARS,
|
|
3037
3117
|
MCP_SKILL_MAX_RESOURCES: () => MCP_SKILL_MAX_RESOURCES,
|
|
3038
3118
|
MCP_SKILL_MAX_TOTAL_BYTES: () => MCP_SKILL_MAX_TOTAL_BYTES,
|
|
3119
|
+
MCP_SKILL_SNAPSHOTS_MAX_BYTES: () => MCP_SKILL_SNAPSHOTS_MAX_BYTES,
|
|
3120
|
+
MCP_SKILL_SNAPSHOT_MAX_DEPTH: () => MCP_SKILL_SNAPSHOT_MAX_DEPTH,
|
|
3121
|
+
MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES: () => MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES,
|
|
3039
3122
|
MCP_SKILL_URI_MAX_CHARS: () => MCP_SKILL_URI_MAX_CHARS,
|
|
3040
3123
|
MEDIA_AUDIO_TYPES: () => MEDIA_AUDIO_TYPES,
|
|
3041
3124
|
MEDIA_DEFAULT_MAX_CALLS: () => MEDIA_DEFAULT_MAX_CALLS,
|
|
@@ -3748,17 +3831,24 @@ var McpSkillDeniedError = class extends Error {
|
|
|
3748
3831
|
return this.message;
|
|
3749
3832
|
}
|
|
3750
3833
|
};
|
|
3751
|
-
var mcpSkillOf = (source, record2, name, byUri) => {
|
|
3834
|
+
var mcpSkillOf = (source, record2, name, byUri, memory) => {
|
|
3752
3835
|
const skill = {
|
|
3753
3836
|
name,
|
|
3754
|
-
description: mcpSkillDescription(record2.description, source.server),
|
|
3837
|
+
description: mcpSkillDescription(record2.description, source.server, record2.dynamic === true),
|
|
3755
3838
|
content: "",
|
|
3756
3839
|
mcp: { server: source.server, uri: record2.uri }
|
|
3757
3840
|
};
|
|
3758
|
-
mcpSkillStates.set(skill, { source, record: record2, ...byUri ? { byUri: true } : {} });
|
|
3841
|
+
mcpSkillStates.set(skill, { source, record: record2, memory, ...byUri ? { byUri: true } : {} });
|
|
3759
3842
|
return skill;
|
|
3760
3843
|
};
|
|
3761
|
-
var
|
|
3844
|
+
var memoryOf = (skills) => {
|
|
3845
|
+
for (const skill of skills) {
|
|
3846
|
+
const memory = mcpSkillStates.get(skill)?.memory;
|
|
3847
|
+
if (memory) return memory;
|
|
3848
|
+
}
|
|
3849
|
+
return void 0;
|
|
3850
|
+
};
|
|
3851
|
+
var createMcpSkills = (sources, names, warn, memory = createMcpSkillSnapshotMemory()) => {
|
|
3762
3852
|
const own = new Set(names);
|
|
3763
3853
|
const taken = new Set(own);
|
|
3764
3854
|
const { kept, notices } = selectMcpSkills(
|
|
@@ -3789,12 +3879,12 @@ var createMcpSkills = (sources, names, warn) => {
|
|
|
3789
3879
|
`[mcp] ${source.server}: its skill "${record2.name}" has the name of one of this agent's own skills; the agent's keeps the name, the server's is "${name}"`
|
|
3790
3880
|
);
|
|
3791
3881
|
}
|
|
3792
|
-
out.push(mcpSkillOf(source, record2, name, added.has(record2)));
|
|
3882
|
+
out.push(mcpSkillOf(source, record2, name, added.has(record2), memory));
|
|
3793
3883
|
}
|
|
3794
3884
|
}
|
|
3795
3885
|
return out;
|
|
3796
3886
|
};
|
|
3797
|
-
var addMcpSkillByUri = async (skills, sources, requested, signal) => {
|
|
3887
|
+
var addMcpSkillByUri = async (skills, sources, requested, signal, memory) => {
|
|
3798
3888
|
const refused = mcpSkillUriRefusal(requested.uri);
|
|
3799
3889
|
if (refused) throw new Error(`load_skill: ${refused}`);
|
|
3800
3890
|
const able = sources.filter((s) => typeof s.get === "function");
|
|
@@ -3819,13 +3909,22 @@ var addMcpSkillByUri = async (skills, sources, requested, signal) => {
|
|
|
3819
3909
|
const meanwhile = held();
|
|
3820
3910
|
if (meanwhile) return meanwhile;
|
|
3821
3911
|
const name = assignAddedMcpSkillName(source.server, record2, new Set(skills.map((s) => s.name)));
|
|
3822
|
-
const skill = mcpSkillOf(
|
|
3912
|
+
const skill = mcpSkillOf(
|
|
3913
|
+
source,
|
|
3914
|
+
record2,
|
|
3915
|
+
name,
|
|
3916
|
+
true,
|
|
3917
|
+
memoryOf(skills) ?? memory ?? createMcpSkillSnapshotMemory()
|
|
3918
|
+
);
|
|
3823
3919
|
skills.push(skill);
|
|
3824
3920
|
return skill;
|
|
3825
3921
|
};
|
|
3826
3922
|
var fetchMcpSkill = async (state, signal) => {
|
|
3827
3923
|
if (state.fetched) return state.fetched;
|
|
3828
|
-
state.fetching ??= state.source.load(state.record.uri,
|
|
3924
|
+
state.fetching ??= state.source.load(state.record.uri, {
|
|
3925
|
+
...signal ? { signal } : {},
|
|
3926
|
+
memory: state.memory
|
|
3927
|
+
});
|
|
3829
3928
|
try {
|
|
3830
3929
|
state.fetched = await state.fetching;
|
|
3831
3930
|
return state.fetched;
|
|
@@ -3886,7 +3985,8 @@ var acquireMcpSkill = async (skill, skills, scope, opts = {}) => {
|
|
|
3886
3985
|
body: fetched.body,
|
|
3887
3986
|
consent,
|
|
3888
3987
|
...state.byUri ? { byUri: true } : {},
|
|
3889
|
-
...enclosing ? { nestedIn: enclosing } : {}
|
|
3988
|
+
...enclosing ? { nestedIn: enclosing } : {},
|
|
3989
|
+
...fetched.snapshot ? { snapshot: fetched.snapshot } : {}
|
|
3890
3990
|
});
|
|
3891
3991
|
const answer = await scope.ask(opts.input ?? { name: skill.name }, view, opts.signal);
|
|
3892
3992
|
if (answer.by === "person") {
|
|
@@ -3931,8 +4031,16 @@ var readMcpSkillFile = async (skill, skills, requested, scope, signal) => {
|
|
|
3931
4031
|
}
|
|
3932
4032
|
const state = mcpSkillStates.get(skill);
|
|
3933
4033
|
const loaded = state.loaded;
|
|
3934
|
-
const target =
|
|
4034
|
+
const target = resolveMcpSkillPath(loaded.files, requested);
|
|
3935
4035
|
if ("refused" in target) throw new Error(`skill "${skill.name}": ${target.refused}`);
|
|
4036
|
+
if ("dir" in target) {
|
|
4037
|
+
const drift = await state.source.readDirectory?.(
|
|
4038
|
+
loaded,
|
|
4039
|
+
target.dir,
|
|
4040
|
+
signal ? { signal } : void 0
|
|
4041
|
+
);
|
|
4042
|
+
return skillDirectoryListing(skill.name, target.dir, target, drift);
|
|
4043
|
+
}
|
|
3936
4044
|
const text = await state.source.readFile(loaded, target.path, signal ? { signal } : void 0);
|
|
3937
4045
|
return mcpSkillFileText(state.source.server, state.record.uri, target.path, text);
|
|
3938
4046
|
};
|
|
@@ -3999,7 +4107,8 @@ var createSkillTools = (skills, onLoad, mcp) => {
|
|
|
3999
4107
|
skills,
|
|
4000
4108
|
servers,
|
|
4001
4109
|
{ server, uri },
|
|
4002
|
-
signalOf(options)
|
|
4110
|
+
signalOf(options),
|
|
4111
|
+
mcp?.memory
|
|
4003
4112
|
);
|
|
4004
4113
|
return load(skill2, { server, uri }, signalOf(options));
|
|
4005
4114
|
}
|
|
@@ -4025,12 +4134,15 @@ var createSkillTools = (skills, onLoad, mcp) => {
|
|
|
4025
4134
|
}
|
|
4026
4135
|
});
|
|
4027
4136
|
const readFile = (0, import_ai4.tool)({
|
|
4028
|
-
description:
|
|
4137
|
+
description: `Read one of a skill's bundled files (paths are listed by load_skill); a directory path ("templates/", "." for the root) returns its listing.`,
|
|
4029
4138
|
inputSchema: (0, import_ai4.jsonSchema)({
|
|
4030
4139
|
type: "object",
|
|
4031
4140
|
properties: {
|
|
4032
4141
|
name: { type: "string", description: "The skill name" },
|
|
4033
|
-
path: {
|
|
4142
|
+
path: {
|
|
4143
|
+
type: "string",
|
|
4144
|
+
description: "The file path, relative to the skill, or a directory to list"
|
|
4145
|
+
}
|
|
4034
4146
|
},
|
|
4035
4147
|
required: ["name", "path"],
|
|
4036
4148
|
additionalProperties: false
|
|
@@ -4043,8 +4155,12 @@ var createSkillTools = (skills, onLoad, mcp) => {
|
|
|
4043
4155
|
}
|
|
4044
4156
|
const file = skill.files?.find((f) => f.path === path);
|
|
4045
4157
|
if (!file) {
|
|
4046
|
-
const
|
|
4047
|
-
|
|
4158
|
+
const paths = (skill.files ?? []).map((f) => f.path);
|
|
4159
|
+
const directory = skillDirectoryOf(paths, path);
|
|
4160
|
+
if (directory) return skillDirectoryListing(skill.name, directory.dir, directory);
|
|
4161
|
+
throw new Error(
|
|
4162
|
+
`skill "${name}" has no file "${path}"; files: ${paths.join(", ") || "none"}`
|
|
4163
|
+
);
|
|
4048
4164
|
}
|
|
4049
4165
|
return file.content;
|
|
4050
4166
|
}
|
|
@@ -8783,12 +8899,14 @@ var createAgent = async (config) => {
|
|
|
8783
8899
|
const spawnBuiltIn = Boolean(dynamicSubagents) && config.tools?.[SPAWN_SUBAGENT_TOOL] === void 0 && baseTools[SPAWN_SUBAGENT_TOOL] !== void 0;
|
|
8784
8900
|
const mcpInstructions = config.mcpInstructions === false ? "" : renderMcpInstructions(collectMcpInstructions(baseTools));
|
|
8785
8901
|
const mcpSkillSources = collectMcpSkillSources(baseTools);
|
|
8902
|
+
const mcpSkillMemory = createMcpSkillSnapshotMemory();
|
|
8786
8903
|
if (!seed) {
|
|
8787
8904
|
skills.push(
|
|
8788
8905
|
...createMcpSkills(
|
|
8789
8906
|
mcpSkillSources,
|
|
8790
8907
|
skills.map((s) => s.name),
|
|
8791
|
-
(m) => log.warn(m)
|
|
8908
|
+
(m) => log.warn(m),
|
|
8909
|
+
mcpSkillMemory
|
|
8792
8910
|
)
|
|
8793
8911
|
);
|
|
8794
8912
|
}
|
|
@@ -8992,7 +9110,7 @@ ${renderActiveSkills(active)}`
|
|
|
8992
9110
|
createSkillTools(
|
|
8993
9111
|
skills,
|
|
8994
9112
|
(s) => activateSkill(s.name, "tool"),
|
|
8995
|
-
mcpSkillSources.length ? { sources: mcpSkillSources, scope: skillScope } : void 0
|
|
9113
|
+
mcpSkillSources.length ? { sources: mcpSkillSources, scope: skillScope, memory: mcpSkillMemory } : void 0
|
|
8996
9114
|
)
|
|
8997
9115
|
);
|
|
8998
9116
|
}
|
|
@@ -11762,9 +11880,13 @@ var MCP_APP_MAX_DOWNLOAD_BYTES = 20 * 1024 * 1024;
|
|
|
11762
11880
|
MCP_SKILL_CONSENTS,
|
|
11763
11881
|
MCP_SKILL_CONSENT_DEFAULT,
|
|
11764
11882
|
MCP_SKILL_DESCRIPTION_MAX_CHARS,
|
|
11883
|
+
MCP_SKILL_DIRECTORY_ENTRIES_MAX,
|
|
11765
11884
|
MCP_SKILL_FILE_MAX_CHARS,
|
|
11766
11885
|
MCP_SKILL_MAX_RESOURCES,
|
|
11767
11886
|
MCP_SKILL_MAX_TOTAL_BYTES,
|
|
11887
|
+
MCP_SKILL_SNAPSHOTS_MAX_BYTES,
|
|
11888
|
+
MCP_SKILL_SNAPSHOT_MAX_DEPTH,
|
|
11889
|
+
MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES,
|
|
11768
11890
|
MCP_SKILL_URI_MAX_CHARS,
|
|
11769
11891
|
MEDIA_AUDIO_TYPES,
|
|
11770
11892
|
MEDIA_DEFAULT_MAX_CALLS,
|