@vvedantb/server 0.19.0 → 0.21.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/ai/errors.d.ts +0 -2
  3. package/dist/ai/errors.js +0 -16
  4. package/dist/ai/serviceTier.d.ts +0 -4
  5. package/dist/ai/serviceTier.js +0 -4
  6. package/dist/artifacts/document.d.ts +0 -2
  7. package/dist/artifacts/document.js +0 -1
  8. package/dist/artifacts/protocol.d.ts +0 -5
  9. package/dist/artifacts/schemas.d.ts +0 -6
  10. package/dist/artifacts/storageShim.js +0 -2
  11. package/dist/convex/authFunctions.d.ts +0 -57
  12. package/dist/convex/clerkBilling.d.ts +2 -18
  13. package/dist/convex/clerkBilling.js +0 -9
  14. package/dist/convex/clerkBillingFunctions.d.ts +0 -35
  15. package/dist/convex/clerkBillingFunctions.js +0 -8
  16. package/dist/convex/clerkBillingNodeFunctions.d.ts +0 -29
  17. package/dist/convex/clerkBillingNodeFunctions.js +0 -1
  18. package/dist/convex/clerkUserAuth.d.ts +0 -18
  19. package/dist/convex/clerkUserAuth.js +0 -14
  20. package/dist/convex/clerkWebhook.d.ts +0 -2
  21. package/dist/convex/convexAdminClient.d.ts +0 -30
  22. package/dist/convex/convexAdminClient.js +0 -34
  23. package/dist/convex/convexQueryLimits.d.ts +0 -8
  24. package/dist/convex/convexQueryLimits.js +0 -8
  25. package/dist/convex/createMcpAuthActions.d.ts +0 -31
  26. package/dist/convex/expoPush.d.ts +0 -24
  27. package/dist/convex/expoPush.js +0 -4
  28. package/dist/convex/homepageRoutes.d.ts +0 -12
  29. package/dist/convex/mcpServerInfo.d.ts +0 -2
  30. package/dist/convex/mcpTokenCache.d.ts +0 -17
  31. package/dist/convex/mcpTokenCache.js +0 -2
  32. package/dist/convex/memoryStore.js +0 -6
  33. package/dist/convex/originAllowlistCors.d.ts +0 -8
  34. package/dist/convex/productEmails.d.ts +0 -4
  35. package/dist/convex/tempId.js +0 -2
  36. package/dist/convex/vPlan.d.ts +0 -4
  37. package/dist/convex/vProModule.d.ts +0 -27
  38. package/dist/convex/vProModule.js +0 -11
  39. package/dist/convex/verifyClerkAccessToken.d.ts +3 -13
  40. package/dist/convex/verifyClerkOAuthJwt.d.ts +0 -18
  41. package/dist/convex/verifyClerkOAuthJwt.js +0 -6
  42. package/dist/crypto/aesGcm.d.ts +0 -2
  43. package/dist/crypto/aesGcm.js +0 -2
  44. package/dist/crypto/encoding.d.ts +0 -8
  45. package/dist/crypto/encoding.js +0 -3
  46. package/dist/generative-ui/catalog.d.ts +0 -17
  47. package/dist/generative-ui/catalog.js +0 -18
  48. package/dist/generative-ui/spec.d.ts +0 -8
  49. package/dist/generative-ui/spec.js +0 -12
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +1 -0
  52. package/dist/mcp/dispatcher.d.ts +0 -7
  53. package/dist/mcp/dispatcher.js +0 -1
  54. package/dist/mcp/explorer.d.ts +0 -21
  55. package/dist/mcp/http.d.ts +7 -31
  56. package/dist/mcp/http.js +43 -11
  57. package/dist/mcp/index.d.ts +2 -1
  58. package/dist/mcp/index.js +2 -1
  59. package/dist/mcp/json.d.ts +0 -1
  60. package/dist/mcp/jsonRpc.d.ts +0 -2
  61. package/dist/mcp/metadata.d.ts +0 -15
  62. package/dist/mcp/routes.d.ts +2 -12
  63. package/dist/mcp/routes.js +6 -2
  64. package/dist/mcp/sdk.d.ts +0 -12
  65. package/dist/mcp/tools.d.ts +0 -18
  66. package/dist/mcp/tools.js +0 -1
  67. package/dist/mcp/upstreamUser.d.ts +17 -0
  68. package/dist/mcp/upstreamUser.js +43 -0
  69. package/dist/mcp/zodJsonSchema.d.ts +0 -4
  70. package/dist/mcp/zodJsonSchema.js +0 -5
  71. package/dist/mcp-oauth-client/loopback.d.ts +0 -5
  72. package/dist/mcp-oauth-client/loopback.js +0 -6
  73. package/dist/mcp-oauth-client/oauth.d.ts +0 -14
  74. package/dist/mcp-oauth-client/oauth.js +0 -16
  75. package/dist/mcp-oauth-client/state.d.ts +0 -3
  76. package/dist/sandbox/runtime.d.ts +0 -15
  77. package/dist/sandbox/runtime.js +0 -25
  78. package/dist/skills/githubSkills.d.ts +51 -0
  79. package/dist/skills/githubSkills.js +172 -0
  80. package/dist/skills/index.d.ts +2 -0
  81. package/dist/skills/index.js +2 -0
  82. package/dist/skills/skillRef.d.ts +18 -0
  83. package/dist/skills/skillRef.js +168 -0
  84. package/package.json +1 -1
@@ -0,0 +1,168 @@
1
+ import { sha256Hex } from "../crypto/sha256.js";
2
+ export const SKILL_FILE_NAME = "SKILL.md";
3
+ const SKILL_ROOTS = ["skills", ".agents/skills", ".claude/skills"];
4
+ const SEGMENT = /^[A-Za-z0-9._-]+$/;
5
+ const SHORT_REF = /^([A-Za-z0-9._-]+)\/([A-Za-z0-9._-]+)(?:@(\S+))?$/;
6
+ function stripGitSuffix(repo) {
7
+ return repo.endsWith(".git") ? repo.slice(0, -4) : repo;
8
+ }
9
+ function cleanPath(segments) {
10
+ const joined = segments.filter((part) => part.length > 0).join("/");
11
+ return joined.length > 0 ? joined : undefined;
12
+ }
13
+ function withoutSkillFile(path) {
14
+ if (path === undefined)
15
+ return undefined;
16
+ const parts = path.split("/");
17
+ if (parts[parts.length - 1] === SKILL_FILE_NAME)
18
+ parts.pop();
19
+ return cleanPath(parts);
20
+ }
21
+ function parseGithubPath(owner, repo, rest) {
22
+ if (!SEGMENT.test(owner) || !SEGMENT.test(repo))
23
+ return null;
24
+ const base = { owner, repo: stripGitSuffix(repo) };
25
+ const [kind, ref, ...pathParts] = rest;
26
+ if (kind === undefined)
27
+ return base;
28
+ if ((kind !== "tree" && kind !== "blob") || ref === undefined)
29
+ return null;
30
+ const path = withoutSkillFile(cleanPath(pathParts));
31
+ return { ...base, ref: decodeURIComponent(ref), path };
32
+ }
33
+ export function parseSkillRef(input) {
34
+ const trimmed = input.trim();
35
+ if (trimmed.length === 0)
36
+ return null;
37
+ const short = SHORT_REF.exec(trimmed);
38
+ if (short !== null && !trimmed.includes("://")) {
39
+ const [, owner, repo, ref] = short;
40
+ if (owner === undefined || repo === undefined)
41
+ return null;
42
+ return { owner, repo: stripGitSuffix(repo), ref };
43
+ }
44
+ let url;
45
+ try {
46
+ url = new URL(trimmed);
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ if (url.protocol !== "https:")
52
+ return null;
53
+ const host = url.hostname.toLowerCase();
54
+ const segments = url.pathname.split("/").filter((part) => part.length > 0);
55
+ const [owner, repo, ...rest] = segments;
56
+ if (owner === undefined || repo === undefined)
57
+ return null;
58
+ if (host === "github.com" || host === "www.github.com") {
59
+ return parseGithubPath(owner, repo, rest);
60
+ }
61
+ if (host === "skills.sh" || host === "www.skills.sh") {
62
+ if (!SEGMENT.test(owner) || !SEGMENT.test(repo))
63
+ return null;
64
+ const [skill, ...extra] = rest;
65
+ if (extra.length > 0)
66
+ return null;
67
+ return { owner, repo: stripGitSuffix(repo), skill };
68
+ }
69
+ return null;
70
+ }
71
+ export function normalizeSkillText(text) {
72
+ const withoutBom = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
73
+ return withoutBom.replace(/\r\n?/g, "\n");
74
+ }
75
+ export async function hashSkillText(text) {
76
+ return sha256Hex(normalizeSkillText(text));
77
+ }
78
+ function unquote(value) {
79
+ const trimmed = value.trim();
80
+ const first = trimmed.charAt(0);
81
+ if (trimmed.length >= 2 && (first === '"' || first === "'") && trimmed.endsWith(first)) {
82
+ return trimmed.slice(1, -1);
83
+ }
84
+ return trimmed;
85
+ }
86
+ function readFrontmatterBlock(lines) {
87
+ if (lines[0]?.trim() !== "---")
88
+ return null;
89
+ const end = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
90
+ if (end === -1)
91
+ return null;
92
+ return lines.slice(1, end);
93
+ }
94
+ function readScalar(block, key) {
95
+ const index = block.findIndex((line) => line.startsWith(`${key}:`));
96
+ if (index === -1)
97
+ return undefined;
98
+ const first = block[index]?.slice(key.length + 1).trim() ?? "";
99
+ if (first === ">" || first === "|" || first === ">-" || first === "|-") {
100
+ const parts = [];
101
+ for (const line of block.slice(index + 1)) {
102
+ if (line.length > 0 && !line.startsWith(" ") && !line.startsWith("\t")) {
103
+ break;
104
+ }
105
+ parts.push(line.trim());
106
+ }
107
+ const joiner = first.startsWith("|") ? "\n" : " ";
108
+ return parts.filter((part) => part.length > 0).join(joiner);
109
+ }
110
+ return unquote(first);
111
+ }
112
+ function firstContentLine(lines) {
113
+ for (const line of lines) {
114
+ const text = line.replace(/^#+\s*/, "").trim();
115
+ if (text.length > 0)
116
+ return text;
117
+ }
118
+ return "";
119
+ }
120
+ export function parseSkillFrontmatter(text, folderName) {
121
+ const lines = normalizeSkillText(text).split("\n");
122
+ const block = readFrontmatterBlock(lines);
123
+ const body = block === null ? lines : lines.slice(block.length + 2);
124
+ const name = block === null ? undefined : readScalar(block, "name");
125
+ const description = block === null ? undefined : readScalar(block, "description");
126
+ return {
127
+ name: name !== undefined && name.length > 0 ? name : folderName,
128
+ description: description !== undefined && description.length > 0 ? description : firstContentLine(body),
129
+ };
130
+ }
131
+ function dirOf(filePath) {
132
+ const index = filePath.lastIndexOf("/");
133
+ return index === -1 ? "" : filePath.slice(0, index);
134
+ }
135
+ function isInside(dir, base) {
136
+ return base === "" || dir === base || dir.startsWith(`${base}/`);
137
+ }
138
+ function isCommonRoot(dir) {
139
+ const parent = dirOf(dir);
140
+ return SKILL_ROOTS.some((root) => parent === root || parent.endsWith(`/${root}`));
141
+ }
142
+ export function discoverSkillFolders(filePaths, basePath) {
143
+ const base = (basePath ?? "").replace(/^\/+|\/+$/g, "");
144
+ const dirs = filePaths
145
+ .filter((file) => file === SKILL_FILE_NAME || file.endsWith(`/${SKILL_FILE_NAME}`))
146
+ .map(dirOf)
147
+ .filter((dir) => isInside(dir, base));
148
+ const unique = [...new Set(dirs)].sort();
149
+ if (unique.includes(base))
150
+ return [base];
151
+ const common = unique.filter(isCommonRoot);
152
+ return common.length > 0 ? common : unique;
153
+ }
154
+ export function skillFolderFiles(filePaths, folder) {
155
+ const nested = filePaths
156
+ .filter((file) => file === SKILL_FILE_NAME || file.endsWith(`/${SKILL_FILE_NAME}`))
157
+ .map(dirOf)
158
+ .filter((dir) => dir !== folder && isInside(dir, folder));
159
+ const prefix = folder === "" ? "" : `${folder}/`;
160
+ return filePaths
161
+ .filter((file) => file.startsWith(prefix))
162
+ .filter((file) => {
163
+ const dir = dirOf(file);
164
+ return !nested.some((skillDir) => isInside(dir, skillDir));
165
+ })
166
+ .map((file) => file.slice(prefix.length))
167
+ .sort();
168
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/server",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "license": "MIT",
5
5
  "description": "Shared Convex backend helpers, MCP server scaffolding and Node-side MCP OAuth client helpers from one root import: query-limit errors, Clerk auth and token verification, an MCP bearer-token cache, Expo push token storage, batched send and receipts, Clerk-user lookups and ensure-user for Convex functions, V Pro plan checks and Clerk Billing webhook helpers, bearer tokens, env, CORS, JSON responses, MCP route registration, a bearer-auth MCP HTTP handler, OAuth metadata, a JSON-RPC dispatcher, explorer tools, WebCrypto primitives, Convex optimistic-update helpers, MCP OAuth client helpers (provider, sign-in, refresh, revocation, loopback redirect server) for desktop apps, a QuickJS code sandbox that bridges script tool calls to host handlers, and a pure artifacts core (Zod contract, state limits and ops, quiz and flashcards pages, a sandboxed document wrapper with CSP and a guest state bridge); and, from the `@vvedantb/server/ai` subpath, Vercel AI Gateway helpers (service tier provider options, cost from provider metadata, error classification).",
6
6
  "type": "module",