@sentry/junior 0.203.0 → 0.205.0
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/agent-D4nu8MQV.js +17521 -0
- package/dist/agent-hooks-DXHpTJ4m.js +4042 -0
- package/dist/agent-runner-C04colea.js +678 -0
- package/dist/api/schema.d.ts +2736 -2639
- package/dist/api/schema.js +4 -169
- package/dist/api.d.ts +23 -17
- package/dist/api.js +3881 -5326
- package/dist/app-Cb776lL8.d.ts +247 -0
- package/dist/app.d.ts +4 -520
- package/dist/app.js +9524 -11875
- package/dist/auth-pause-state-C2P3guS1.js +168 -0
- package/dist/catalog-runtime-CXw3asJD.js +7 -0
- package/dist/checkpoint-CrViJ8Ps.js +2450 -0
- package/dist/cli/chat.d.ts +20 -0
- package/dist/cli/chat.js +229 -336
- package/dist/cli/check.d.ts +8 -0
- package/dist/cli/check.js +513 -806
- package/dist/cli/env.d.ts +13 -0
- package/dist/cli/env.js +63 -12
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.js +90 -159
- package/dist/cli/main.d.ts +6 -0
- package/dist/cli/main.js +43 -64
- package/dist/cli/plugins.d.ts +13 -0
- package/dist/cli/plugins.js +148 -227
- package/dist/cli/run.d.ts +16 -0
- package/dist/cli/run.js +52 -8
- package/dist/cli/snapshot-create.d.ts +4 -0
- package/dist/cli/snapshot-create.js +71 -125
- package/dist/cli/upgrade.d.ts +15 -0
- package/dist/cli/upgrade.js +232 -335
- package/dist/config-BOtJQ7Pc.js +941 -0
- package/dist/context-B45_WqVX.js +298 -0
- package/dist/conversation-privacy-BZRA6Pes.js +182 -0
- package/dist/conversation-work-C6y3T5Hx.js +51 -0
- package/dist/credential-sync-Bep34IB_.js +2661 -0
- package/dist/db-BeyXKJOI.d.ts +5 -0
- package/dist/destinations-BeBiJeEM.js +29 -0
- package/dist/execution-stats-B6lgWxCK.js +373 -0
- package/dist/executor-BlUhFL7_.js +721 -0
- package/dist/experimental-CIXf7Uye.js +46 -0
- package/dist/history-ClE4toxe.d.ts +32 -0
- package/dist/history-CqTuSAdI.js +441 -0
- package/dist/instrumentation.d.ts +3 -3
- package/dist/instrumentation.js +130 -176
- package/dist/job-queue-DLMqIK74.js +63 -0
- package/dist/logging-BMJzdDlP.js +1210 -0
- package/dist/model-profile-CZmVoGdX.js +49 -0
- package/dist/nitro.d.ts +31 -36
- package/dist/nitro.js +275 -456
- package/dist/oauth-callback-server-WwG5_Zgm.js +130 -0
- package/dist/oauth-relay-CdCnu80W.js +62 -0
- package/dist/package-discovery-7a9YqLhE.js +455 -0
- package/dist/pending-auth-CUbXq06G.js +185 -0
- package/dist/plugin-module-BKGOXca2.js +81 -0
- package/dist/plugins-BI9A1vKA.d.ts +95 -0
- package/dist/plugins-egKWjgue.js +99 -0
- package/dist/private-trace-result-BLvBjy_e.js +16 -0
- package/dist/profile-T0tXE4zu.js +861 -0
- package/dist/registry-BA0__8ai.js +1419 -0
- package/dist/reporting-schema-DosTN__Q.js +105 -0
- package/dist/resolve-bvD1ORdv.js +546 -0
- package/dist/rolldown-runtime-B4FMCO8f.js +28 -0
- package/dist/runner-BXYxfIUL.js +392 -0
- package/dist/sandbox-egress-signals-ngEPjSEW.js +46 -0
- package/dist/schema-Rn8-XEaN.js +1140 -0
- package/dist/sentry-CD3SdJl-.js +26 -0
- package/dist/skills-DJOlYdBs.js +316 -0
- package/dist/spawn-h0R1bTEo.js +29 -0
- package/dist/stats-3YZn-Swi.js +2648 -0
- package/dist/store-C5qxF2ac.d.ts +208 -0
- package/dist/task-queue-CoXwd2eq.js +136 -0
- package/dist/task-runner-B2_mJZj0.js +639 -0
- package/dist/thread-state-CqZ1m-es.js +431 -0
- package/dist/turn-execution-fI6PZ0iI.js +47 -0
- package/dist/turn-lifecycle-CcnwrOcp.js +54 -0
- package/dist/usage-B5SfMb3H.js +296 -0
- package/dist/usage-schema-CKaDkH_j.js +20 -0
- package/dist/validation-DfWcvhuS.js +40 -0
- package/dist/vercel-queue-DIkVcfK4.js +167 -0
- package/dist/vercel.d.ts +6 -6
- package/dist/vercel.js +14 -6
- package/dist/version-CnXZ614E.d.ts +5 -0
- package/dist/version-oD-oPrbO.js +8 -0
- package/dist/version.d.ts +2 -4
- package/dist/version.js +2 -6
- package/dist/web-authorization-Crbzlmzo.js +76 -0
- package/dist/web-input-BOuq3oKK.js +494 -0
- package/dist/work-B91LQKHr.js +509 -0
- package/dist/worker-BcRRTe6k.js +625 -0
- package/package.json +9 -9
- package/dist/agent-hooks-GB2VPTNA.js +0 -51
- package/dist/catalog-runtime-UBLIWD3O.js +0 -14
- package/dist/chunk-2LYHWMR4.js +0 -46
- package/dist/chunk-352OWAZH.js +0 -320
- package/dist/chunk-3Y47VMHV.js +0 -6
- package/dist/chunk-3YJSKOWF.js +0 -164
- package/dist/chunk-4KSSKTQ5.js +0 -229
- package/dist/chunk-4UO6FK4G.js +0 -64
- package/dist/chunk-5AHX53NQ.js +0 -717
- package/dist/chunk-5J3E5FWA.js +0 -700
- package/dist/chunk-5PDAG6O3.js +0 -206
- package/dist/chunk-6Y5B5PEX.js +0 -80
- package/dist/chunk-7GWQ5S5R.js +0 -2086
- package/dist/chunk-7H2VZTWN.js +0 -103
- package/dist/chunk-7NL7T6VU.js +0 -406
- package/dist/chunk-A5L27LE4.js +0 -387
- package/dist/chunk-ADIAWL34.js +0 -81
- package/dist/chunk-ASTEMBKJ.js +0 -519
- package/dist/chunk-CEMMLV5L.js +0 -98
- package/dist/chunk-CM5HNV2W.js +0 -131
- package/dist/chunk-CRTRBBRI.js +0 -105
- package/dist/chunk-DA2KGZZI.js +0 -13
- package/dist/chunk-DIB4GX3G.js +0 -8
- package/dist/chunk-DKIJ2RP5.js +0 -68
- package/dist/chunk-DWPN6SCH.js +0 -172
- package/dist/chunk-EDKUFGPL.js +0 -64
- package/dist/chunk-ENY6SKIU.js +0 -1228
- package/dist/chunk-F4MGCZOX.js +0 -2943
- package/dist/chunk-FA6POGLH.js +0 -70
- package/dist/chunk-FSUR7GTG.js +0 -20475
- package/dist/chunk-GKEOHJL5.js +0 -1856
- package/dist/chunk-GMCB6W5Y.js +0 -333
- package/dist/chunk-IE2VPG7O.js +0 -1135
- package/dist/chunk-IZ5B5IHQ.js +0 -3656
- package/dist/chunk-JAL3CH4G.js +0 -27
- package/dist/chunk-KIIEUXD3.js +0 -1764
- package/dist/chunk-KXU4NIL7.js +0 -692
- package/dist/chunk-MTM5IFCY.js +0 -1190
- package/dist/chunk-N7TMSOZH.js +0 -235
- package/dist/chunk-NCEBK6PH.js +0 -36
- package/dist/chunk-NHJU2ZAL.js +0 -56
- package/dist/chunk-P6KTRNVC.js +0 -321
- package/dist/chunk-PDO5BLNM.js +0 -22
- package/dist/chunk-PDRNLLFT.js +0 -3295
- package/dist/chunk-PEQXYSSE.js +0 -45
- package/dist/chunk-PKEX2AQX.js +0 -198
- package/dist/chunk-PSJCGIGO.js +0 -1163
- package/dist/chunk-PZUSUL55.js +0 -506
- package/dist/chunk-R45M4TUS.js +0 -37
- package/dist/chunk-RC745GGZ.js +0 -122
- package/dist/chunk-SP3QKZXJ.js +0 -820
- package/dist/chunk-TXKUKMVO.js +0 -417
- package/dist/chunk-UE4GPWSD.js +0 -931
- package/dist/chunk-UIE3R5XU.js +0 -17
- package/dist/chunk-UXPG6ZIN.js +0 -84
- package/dist/chunk-VFUK3X5B.js +0 -50
- package/dist/chunk-VNMJWREK.js +0 -787
- package/dist/chunk-VZ7CSOX2.js +0 -706
- package/dist/chunk-WCNQJKFT.js +0 -10
- package/dist/chunk-WDZR3QQM.js +0 -135
- package/dist/chunk-WLYVJCHV.js +0 -1433
- package/dist/chunk-WS7NAFTM.js +0 -1520
- package/dist/chunk-X6GDDWQH.js +0 -60
- package/dist/chunk-XPDEYNQI.js +0 -102
- package/dist/chunk-XRW44VGM.js +0 -58
- package/dist/chunk-Y2CM7HXH.js +0 -111
- package/dist/chunk-Y7X25LFY.js +0 -15
- package/dist/conversation-work-VIOQ5ZF3.js +0 -54
- package/dist/db-NGDJV7YH.js +0 -26
- package/dist/discovery-DWVDM7UK.js +0 -44
- package/dist/experimental-P5FZM4CU.js +0 -12
- package/dist/oauth-callback-server-YFY7YEGK.js +0 -243
- package/dist/oauth-relay-5XPVRPYB.js +0 -8
- package/dist/plugins-YTYJMMJF.js +0 -14
- package/dist/runner-ORTNSB2Q.js +0 -522
- package/dist/sandbox-egress-signals-FIL7EGPR.js +0 -73
- package/dist/sentry-MB3NL3IR.js +0 -42
- package/dist/skills-H376WQOH.js +0 -27
- package/dist/spawn-T43WHLOS.js +0 -42
- package/dist/task-runner-LBZWF32V.js +0 -36
- package/dist/validation-REJLRKI6.js +0 -17
- package/dist/work-3KJ3RE76.js +0 -51
- package/dist/worker-QFEBU72E.js +0 -24
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
+
import { captureException, captureMessage, continueTrace, flush, getActiveSpan, getClient, getGlobalScope, getTraceData, init, logger, setTag, setUser, spanToJSON, startInactiveSpan, startSpan, vercelAIIntegration, withActiveSpan, withScope, withStreamedSpan } from "@sentry/node";
|
|
3
|
+
//#region src/chat/sentry.ts
|
|
4
|
+
var sentry_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
captureException: () => captureException,
|
|
6
|
+
captureMessage: () => captureMessage,
|
|
7
|
+
continueTrace: () => continueTrace,
|
|
8
|
+
flush: () => flush,
|
|
9
|
+
getActiveSpan: () => getActiveSpan,
|
|
10
|
+
getClient: () => getClient,
|
|
11
|
+
getGlobalScope: () => getGlobalScope,
|
|
12
|
+
getTraceData: () => getTraceData,
|
|
13
|
+
init: () => init,
|
|
14
|
+
logger: () => logger,
|
|
15
|
+
setTag: () => setTag,
|
|
16
|
+
setUser: () => setUser,
|
|
17
|
+
spanToJSON: () => spanToJSON,
|
|
18
|
+
startInactiveSpan: () => startInactiveSpan,
|
|
19
|
+
startSpan: () => startSpan,
|
|
20
|
+
vercelAIIntegration: () => vercelAIIntegration,
|
|
21
|
+
withActiveSpan: () => withActiveSpan,
|
|
22
|
+
withScope: () => withScope,
|
|
23
|
+
withStreamedSpan: () => withStreamedSpan
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
26
|
+
export { withActiveSpan as _, getClient as a, init as c, setTag as d, setUser as f, vercelAIIntegration as g, startSpan as h, getActiveSpan as i, logger as l, startInactiveSpan as m, captureMessage as n, getGlobalScope as o, spanToJSON as p, continueTrace as r, getTraceData as s, captureException as t, sentry_exports as u, withScope as v, withStreamedSpan as y };
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
+
import { f as logWarn } from "./logging-BMJzdDlP.js";
|
|
3
|
+
import { s as skillRoots } from "./package-discovery-7a9YqLhE.js";
|
|
4
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-CXw3asJD.js";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import fs from "node:fs/promises";
|
|
8
|
+
import { parse } from "yaml";
|
|
9
|
+
//#region src/chat/skills.ts
|
|
10
|
+
var skills_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
discoverSkills: () => discoverSkills,
|
|
12
|
+
findSkillByName: () => findSkillByName,
|
|
13
|
+
loadSkillsByName: () => loadSkillsByName,
|
|
14
|
+
parseSkillFile: () => parseSkillFile,
|
|
15
|
+
parseSkillInvocation: () => parseSkillInvocation,
|
|
16
|
+
stripFrontmatter: () => stripFrontmatter
|
|
17
|
+
});
|
|
18
|
+
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
|
|
19
|
+
const SKILL_NAME_RE = /^[a-z0-9-]+$/;
|
|
20
|
+
const MAX_NAME_LENGTH = 64;
|
|
21
|
+
const MAX_DESCRIPTION_LENGTH = 1024;
|
|
22
|
+
const MAX_COMPATIBILITY_LENGTH = 500;
|
|
23
|
+
function hasAngleBrackets(value) {
|
|
24
|
+
return value.includes("<") || value.includes(">");
|
|
25
|
+
}
|
|
26
|
+
function validateSkillName(name) {
|
|
27
|
+
if (!name) return "name must not be empty";
|
|
28
|
+
if (name.length > MAX_NAME_LENGTH) return `name must be <= ${MAX_NAME_LENGTH} characters`;
|
|
29
|
+
if (!SKILL_NAME_RE.test(name)) return "name must contain only lowercase letters, digits, and hyphens";
|
|
30
|
+
if (name.startsWith("-") || name.endsWith("-")) return "name must not start or end with a hyphen";
|
|
31
|
+
if (name.includes("--")) return "name must not contain consecutive hyphens";
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
function parseTokenList(value) {
|
|
35
|
+
if (typeof value !== "string") return;
|
|
36
|
+
const tokens = value.split(/\s+/).map((token) => token.trim()).filter((token) => token.length > 0);
|
|
37
|
+
return tokens.length > 0 ? tokens : void 0;
|
|
38
|
+
}
|
|
39
|
+
const skillFrontmatterSchema = z.object({
|
|
40
|
+
name: z.string({ error: "Frontmatter field \"name\" must be a string" }).superRefine((value, ctx) => {
|
|
41
|
+
const nameError = validateSkillName(value);
|
|
42
|
+
if (nameError) ctx.addIssue({
|
|
43
|
+
code: z.ZodIssueCode.custom,
|
|
44
|
+
message: nameError
|
|
45
|
+
});
|
|
46
|
+
}),
|
|
47
|
+
description: z.string({ error: "Frontmatter field \"description\" must be a string" }).superRefine((value, ctx) => {
|
|
48
|
+
if (!value.trim()) {
|
|
49
|
+
ctx.addIssue({
|
|
50
|
+
code: z.ZodIssueCode.custom,
|
|
51
|
+
message: "description must not be empty"
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (value.length > MAX_DESCRIPTION_LENGTH) {
|
|
56
|
+
ctx.addIssue({
|
|
57
|
+
code: z.ZodIssueCode.custom,
|
|
58
|
+
message: `description must be <= ${MAX_DESCRIPTION_LENGTH} characters`
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (hasAngleBrackets(value)) ctx.addIssue({
|
|
63
|
+
code: z.ZodIssueCode.custom,
|
|
64
|
+
message: "description must not contain \"<\" or \">\""
|
|
65
|
+
});
|
|
66
|
+
}),
|
|
67
|
+
metadata: z.record(z.string(), z.unknown(), { error: "Frontmatter field \"metadata\" must be an object when present" }).optional(),
|
|
68
|
+
compatibility: z.string({ error: "Frontmatter field \"compatibility\" must be a string when present" }).superRefine((value, ctx) => {
|
|
69
|
+
if (value.length > MAX_COMPATIBILITY_LENGTH) ctx.addIssue({
|
|
70
|
+
code: z.ZodIssueCode.custom,
|
|
71
|
+
message: `compatibility must be <= ${MAX_COMPATIBILITY_LENGTH} characters`
|
|
72
|
+
});
|
|
73
|
+
}).optional(),
|
|
74
|
+
license: z.string({ error: "Frontmatter field \"license\" must be a string when present" }).optional(),
|
|
75
|
+
"allowed-tools": z.string({ error: "Frontmatter field \"allowed-tools\" must be a string when present" }).optional(),
|
|
76
|
+
"disable-model-invocation": z.boolean({ error: "Frontmatter field \"disable-model-invocation\" must be a boolean when present" }).optional()
|
|
77
|
+
}).passthrough();
|
|
78
|
+
/** Strip YAML frontmatter from a skill file, returning only the body. */
|
|
79
|
+
function stripFrontmatter(raw) {
|
|
80
|
+
return raw.replace(FRONTMATTER_RE, "").trim();
|
|
81
|
+
}
|
|
82
|
+
/** Parse a SKILL.md file's frontmatter and body. */
|
|
83
|
+
function parseSkillFile(raw, expectedName) {
|
|
84
|
+
const match = FRONTMATTER_RE.exec(raw);
|
|
85
|
+
if (!match) return {
|
|
86
|
+
ok: false,
|
|
87
|
+
error: "Missing YAML frontmatter at start of file"
|
|
88
|
+
};
|
|
89
|
+
let parsed;
|
|
90
|
+
try {
|
|
91
|
+
parsed = parse(match[1]);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return {
|
|
94
|
+
ok: false,
|
|
95
|
+
error: `Invalid YAML frontmatter: ${error instanceof Error ? error.message : String(error)}`
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {
|
|
99
|
+
ok: false,
|
|
100
|
+
error: "Frontmatter must be a YAML object"
|
|
101
|
+
};
|
|
102
|
+
if ("requires-capabilities" in parsed) return {
|
|
103
|
+
ok: false,
|
|
104
|
+
error: "Frontmatter field \"requires-capabilities\" is no longer supported; provider credentials are declared by plugin.yaml."
|
|
105
|
+
};
|
|
106
|
+
if ("uses-config" in parsed) return {
|
|
107
|
+
ok: false,
|
|
108
|
+
error: "Frontmatter field \"uses-config\" is no longer supported; plugin config keys come from plugin.yaml."
|
|
109
|
+
};
|
|
110
|
+
const result = skillFrontmatterSchema.safeParse(parsed);
|
|
111
|
+
if (!result.success) return {
|
|
112
|
+
ok: false,
|
|
113
|
+
error: result.error.issues[0]?.message ?? "Invalid YAML frontmatter"
|
|
114
|
+
};
|
|
115
|
+
if (expectedName && result.data.name !== expectedName) return {
|
|
116
|
+
ok: false,
|
|
117
|
+
error: `name "${result.data.name}" must match directory "${expectedName}"`
|
|
118
|
+
};
|
|
119
|
+
const allowedTools = parseTokenList(result.data["allowed-tools"]);
|
|
120
|
+
const disableModelInvocation = result.data["disable-model-invocation"] === true;
|
|
121
|
+
return {
|
|
122
|
+
ok: true,
|
|
123
|
+
skill: {
|
|
124
|
+
name: result.data.name,
|
|
125
|
+
description: result.data.description,
|
|
126
|
+
body: stripFrontmatter(raw),
|
|
127
|
+
...result.data.metadata ? { metadata: result.data.metadata } : void 0,
|
|
128
|
+
...result.data.compatibility !== void 0 ? { compatibility: result.data.compatibility } : void 0,
|
|
129
|
+
...result.data.license !== void 0 ? { license: result.data.license } : void 0,
|
|
130
|
+
...allowedTools ? { allowedTools } : void 0,
|
|
131
|
+
...disableModelInvocation ? { disableModelInvocation } : void 0
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const SKILL_CACHE_TTL_MS = 5e3;
|
|
136
|
+
let skillCache = null;
|
|
137
|
+
function resolveSkillRoots(options) {
|
|
138
|
+
const additionalRoots = options?.additionalRoots ?? [];
|
|
139
|
+
const envRoots = process.env.SKILL_DIRS?.split(path.delimiter).filter(Boolean) ?? [];
|
|
140
|
+
const defaults = skillRoots();
|
|
141
|
+
const pluginRoots = pluginCatalogRuntime.getSkillRoots();
|
|
142
|
+
const seen = /* @__PURE__ */ new Set();
|
|
143
|
+
const resolved = [];
|
|
144
|
+
for (const root of [
|
|
145
|
+
...additionalRoots,
|
|
146
|
+
...envRoots,
|
|
147
|
+
...defaults,
|
|
148
|
+
...pluginRoots
|
|
149
|
+
]) {
|
|
150
|
+
const normalized = path.resolve(root);
|
|
151
|
+
if (seen.has(normalized)) continue;
|
|
152
|
+
seen.add(normalized);
|
|
153
|
+
resolved.push(normalized);
|
|
154
|
+
}
|
|
155
|
+
return resolved;
|
|
156
|
+
}
|
|
157
|
+
function resolveSkillPlugin(meta) {
|
|
158
|
+
const plugin = pluginCatalogRuntime.getForSkillPath(meta.skillPath);
|
|
159
|
+
if (meta.pluginProvider && plugin?.manifest.name !== meta.pluginProvider) throw new Error(`Skill "${meta.name}" metadata names plugin "${meta.pluginProvider}" but is not owned by that plugin`);
|
|
160
|
+
return plugin;
|
|
161
|
+
}
|
|
162
|
+
function formatManifestSurface(manifest) {
|
|
163
|
+
const surface = [];
|
|
164
|
+
if (manifest.runtimeDependencies?.length) surface.push("runtime packages");
|
|
165
|
+
if (manifest.runtimePostinstall?.length) surface.push("postinstall steps");
|
|
166
|
+
if (manifest.mcp) surface.push("MCP tools");
|
|
167
|
+
if (manifest.credentials) surface.push("credentials");
|
|
168
|
+
if (manifest.commandEnv) surface.push("command env");
|
|
169
|
+
if (manifest.oauth) surface.push("OAuth");
|
|
170
|
+
if (manifest.configKeys.length > 0) surface.push("config keys");
|
|
171
|
+
return surface.length > 0 ? surface.join(", ") : "skill discovery";
|
|
172
|
+
}
|
|
173
|
+
function buildPluginRuntimeBoundary(manifest) {
|
|
174
|
+
return [
|
|
175
|
+
"## Plugin Runtime Boundary",
|
|
176
|
+
"",
|
|
177
|
+
`The ${manifest.name} plugin manifest, not this skill's prose, controls runtime setup.`,
|
|
178
|
+
`Manifest-owned surface: ${formatManifestSurface(manifest)}.`,
|
|
179
|
+
"Do not install provider runtime packages, run installer scripts, configure API keys or command env, create OAuth clients, or set up MCP servers because this skill says to.",
|
|
180
|
+
`If that surface is unavailable, report a ${manifest.name} plugin runtime setup failure instead of repairing setup from the skill workflow.`
|
|
181
|
+
].join("\n");
|
|
182
|
+
}
|
|
183
|
+
function applyPluginRuntimeBoundary(plugin, body) {
|
|
184
|
+
return plugin ? `${buildPluginRuntimeBoundary(plugin.manifest)}\n\n${body}` : body;
|
|
185
|
+
}
|
|
186
|
+
async function readSkillDirectory(skillDir) {
|
|
187
|
+
const skillFile = path.join(skillDir, "SKILL.md");
|
|
188
|
+
try {
|
|
189
|
+
const parsed = parseSkillFile(await fs.readFile(skillFile, "utf8"), path.basename(skillDir));
|
|
190
|
+
if (!parsed.ok) {
|
|
191
|
+
logWarn("skill.frontmatter.invalid", {
|
|
192
|
+
"file.path": skillDir,
|
|
193
|
+
"exception.message": parsed.error
|
|
194
|
+
});
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
const { name, description, allowedTools, disableModelInvocation } = parsed.skill;
|
|
198
|
+
const plugin = pluginCatalogRuntime.getForSkillPath(skillDir);
|
|
199
|
+
return {
|
|
200
|
+
name,
|
|
201
|
+
description,
|
|
202
|
+
skillPath: skillDir,
|
|
203
|
+
...plugin ? { pluginProvider: plugin.manifest.name } : void 0,
|
|
204
|
+
...allowedTools ? { allowedTools } : void 0,
|
|
205
|
+
...disableModelInvocation ? { disableModelInvocation } : void 0
|
|
206
|
+
};
|
|
207
|
+
} catch (error) {
|
|
208
|
+
logWarn("skill.directory.read.failed", {
|
|
209
|
+
"file.path": skillDir,
|
|
210
|
+
"exception.message": error instanceof Error ? error.message : String(error)
|
|
211
|
+
});
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** Scan all configured skill roots and return discovered skill metadata, using a cache when roots match. */
|
|
216
|
+
async function discoverSkills(options) {
|
|
217
|
+
const roots = resolveSkillRoots(options);
|
|
218
|
+
const cacheKey = roots.join(path.delimiter);
|
|
219
|
+
if (skillCache && skillCache.expiresAt > Date.now() && skillCache.key === cacheKey) return skillCache.skills;
|
|
220
|
+
const discovered = [];
|
|
221
|
+
const seen = /* @__PURE__ */ new Set();
|
|
222
|
+
for (const root of roots) try {
|
|
223
|
+
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
224
|
+
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
225
|
+
if (!entry.isDirectory()) continue;
|
|
226
|
+
const skill = await readSkillDirectory(path.join(root, entry.name));
|
|
227
|
+
if (skill && !seen.has(skill.name)) {
|
|
228
|
+
seen.add(skill.name);
|
|
229
|
+
discovered.push(skill);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
} catch (error) {
|
|
233
|
+
logWarn("skill.root.read.failed", {
|
|
234
|
+
"file.directory": root,
|
|
235
|
+
"exception.message": error instanceof Error ? error.message : String(error)
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
const sorted = discovered.sort((a, b) => a.name.localeCompare(b.name));
|
|
239
|
+
skillCache = {
|
|
240
|
+
expiresAt: Date.now() + SKILL_CACHE_TTL_MS,
|
|
241
|
+
key: cacheKey,
|
|
242
|
+
skills: sorted
|
|
243
|
+
};
|
|
244
|
+
return sorted;
|
|
245
|
+
}
|
|
246
|
+
function isCommonEnvironmentVariable(name) {
|
|
247
|
+
return [
|
|
248
|
+
"HOME",
|
|
249
|
+
"LANG",
|
|
250
|
+
"PATH",
|
|
251
|
+
"PWD",
|
|
252
|
+
"SHELL",
|
|
253
|
+
"TEMP",
|
|
254
|
+
"TERM",
|
|
255
|
+
"TMP",
|
|
256
|
+
"TMPDIR",
|
|
257
|
+
"USER",
|
|
258
|
+
"XDG_CONFIG_HOME"
|
|
259
|
+
].includes(name.toUpperCase());
|
|
260
|
+
}
|
|
261
|
+
/** Extract an explicit skill invocation from a user message. */
|
|
262
|
+
function parseSkillInvocation(messageText, availableSkills) {
|
|
263
|
+
const trimmed = messageText.trim();
|
|
264
|
+
const escapePattern = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
265
|
+
const slashMatch = /(?:^|\s)\/([a-z0-9]+(?:-[a-z0-9]+)*)/i.exec(trimmed);
|
|
266
|
+
if (slashMatch) {
|
|
267
|
+
const skillName = slashMatch[1].toLowerCase();
|
|
268
|
+
if (!availableSkills.some((skill) => skill.name === skillName)) return null;
|
|
269
|
+
return { skillName };
|
|
270
|
+
}
|
|
271
|
+
for (const match of trimmed.matchAll(/(?:^|\s)\$([a-z0-9]+(?:-[a-z0-9]+)*)/gi)) {
|
|
272
|
+
const skillName = match[1].toLowerCase();
|
|
273
|
+
if (isCommonEnvironmentVariable(skillName)) continue;
|
|
274
|
+
if (availableSkills.some((skill) => skill.name === skillName)) return { skillName };
|
|
275
|
+
}
|
|
276
|
+
const namedSkill = availableSkills.find((skill) => {
|
|
277
|
+
if (skill.disableModelInvocation !== true) return false;
|
|
278
|
+
const skillPattern = escapePattern(skill.name);
|
|
279
|
+
const explicitUse = new RegExp(`\\b(?:use|run|load|call|invoke)\\s+(?:the\\s+)?${skillPattern}(?:\\s+skill)?\\b`, "i");
|
|
280
|
+
const negatedUse = new RegExp(`\\b(?:do\\s+not|don't|dont|never)\\s+(?:use|run|load|call|invoke)\\s+(?:the\\s+)?${skillPattern}(?:\\s+skill)?\\b`, "i");
|
|
281
|
+
return explicitUse.test(trimmed) && !negatedUse.test(trimmed);
|
|
282
|
+
});
|
|
283
|
+
if (!namedSkill) return null;
|
|
284
|
+
return { skillName: namedSkill.name };
|
|
285
|
+
}
|
|
286
|
+
/** Look up a skill by name from the available set. */
|
|
287
|
+
function findSkillByName(skillName, available) {
|
|
288
|
+
return available.find((skill) => skill.name === skillName) ?? null;
|
|
289
|
+
}
|
|
290
|
+
/** Load full skill bodies for a list of skill names, reading SKILL.md files from disk. */
|
|
291
|
+
async function loadSkillsByName(skillNames, available) {
|
|
292
|
+
const selected = new Set(skillNames);
|
|
293
|
+
const skills = [];
|
|
294
|
+
for (const meta of available) {
|
|
295
|
+
if (!selected.has(meta.name)) continue;
|
|
296
|
+
const skillFile = path.join(meta.skillPath, "SKILL.md");
|
|
297
|
+
const parsed = parseSkillFile(await fs.readFile(skillFile, "utf8"), meta.name);
|
|
298
|
+
if (!parsed.ok) throw new Error(`Invalid skill file in ${skillFile}: ${parsed.error}`);
|
|
299
|
+
const plugin = resolveSkillPlugin(meta);
|
|
300
|
+
const loadedMeta = {
|
|
301
|
+
name: parsed.skill.name,
|
|
302
|
+
description: parsed.skill.description,
|
|
303
|
+
skillPath: meta.skillPath,
|
|
304
|
+
...plugin ? { pluginProvider: plugin.manifest.name } : void 0,
|
|
305
|
+
...parsed.skill.allowedTools ? { allowedTools: parsed.skill.allowedTools } : void 0,
|
|
306
|
+
...parsed.skill.disableModelInvocation ? { disableModelInvocation: parsed.skill.disableModelInvocation } : void 0
|
|
307
|
+
};
|
|
308
|
+
skills.push({
|
|
309
|
+
...loadedMeta,
|
|
310
|
+
body: applyPluginRuntimeBoundary(plugin, parsed.skill.body)
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
return skills;
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
export { parseSkillInvocation as a, parseSkillFile as i, findSkillByName as n, skills_exports as o, loadSkillsByName as r, discoverSkills as t };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
+
import { C as toolInvocationDestination, y as actorFromRun } from "./agent-runner-C04colea.js";
|
|
3
|
+
import { n as createAndEnqueueAgentInvocation } from "./work-B91LQKHr.js";
|
|
4
|
+
//#region src/chat/agent-invocations/spawn.ts
|
|
5
|
+
var spawn_exports = /* @__PURE__ */ __exportAll({ bindSpawnAgent: () => bindSpawnAgent });
|
|
6
|
+
/** Bind a Run's Actor and credentials to new Agent invocations. */
|
|
7
|
+
function bindSpawnAgent(run, options) {
|
|
8
|
+
const actor = actorFromRun(run);
|
|
9
|
+
if (!actor) return;
|
|
10
|
+
return async (input, call) => {
|
|
11
|
+
call.signal?.throwIfAborted();
|
|
12
|
+
const queue = typeof options.queue === "function" ? options.queue() : options.queue;
|
|
13
|
+
return { invocationId: (await createAndEnqueueAgentInvocation({
|
|
14
|
+
actor,
|
|
15
|
+
...input.name ? { agentName: input.name } : void 0,
|
|
16
|
+
...run.credentialContext ? { credentialContext: run.credentialContext } : void 0,
|
|
17
|
+
destination: toolInvocationDestination(run),
|
|
18
|
+
idempotencyKey: `${run.turnId}:${call.toolCallId}`,
|
|
19
|
+
input: input.task,
|
|
20
|
+
parentConversationId: run.conversationId,
|
|
21
|
+
...input.reasoningLevel ? { reasoningLevel: input.reasoningLevel } : void 0
|
|
22
|
+
}, {
|
|
23
|
+
...options,
|
|
24
|
+
queue
|
|
25
|
+
})).invocationId };
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { spawn_exports as n, bindSpawnAgent as t };
|