@nimblebrain/mpak-sdk 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/LICENSE CHANGED
@@ -1,190 +1,13 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
1
+ Copyright 2026 NimbleBrain Inc.
4
2
 
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
6
 
7
- 1. Definitions.
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
8
 
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to the Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- Copyright 2026 NimbleBrain Inc.
179
-
180
- Licensed under the Apache License, Version 2.0 (the "License");
181
- you may not use this file except in compliance with the License.
182
- You may obtain a copy of the License at
183
-
184
- http://www.apache.org/licenses/LICENSE-2.0
185
-
186
- Unless required by applicable law or agreed to in writing, software
187
- distributed under the License is distributed on an "AS IS" BASIS,
188
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
- See the License for the specific language governing permissions and
190
- limitations under the License.
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md CHANGED
@@ -1,23 +1,20 @@
1
1
  # @nimblebrain/mpak-sdk
2
2
 
3
- TypeScript SDK for mpak registry - MCPB bundles and Agent Skills.
3
+ [![CI](https://github.com/NimbleBrainInc/mpak/actions/workflows/sdk-typescript-ci.yml/badge.svg)](https://github.com/NimbleBrainInc/mpak/actions/workflows/sdk-typescript-ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/@nimblebrain/mpak-sdk)](https://www.npmjs.com/package/@nimblebrain/mpak-sdk)
5
+ [![Node](https://img.shields.io/node/v/@nimblebrain/mpak-sdk)](https://www.npmjs.com/package/@nimblebrain/mpak-sdk)
6
+ [![License](https://img.shields.io/npm/l/@nimblebrain/mpak-sdk)](https://github.com/NimbleBrainInc/mpak/blob/main/packages/sdk-typescript/LICENSE)
7
+ [![mpak.dev](https://mpak.dev/badge.svg)](https://mpak.dev)
4
8
 
5
- ## Features
6
-
7
- - Zero runtime dependencies (native `fetch` and `crypto` only)
8
- - Requires Node.js 18+
9
- - Type-safe API (types generated from OpenAPI spec)
10
- - Fail-closed integrity verification
9
+ TypeScript SDK for the mpak registry - search, download, and resolve MCPB bundles and Agent Skills.
11
10
 
12
11
  ## Installation
13
12
 
14
13
  ```bash
15
- npm install @nimblebrain/mpak-sdk
14
+ pnpm add @nimblebrain/mpak-sdk
16
15
  ```
17
16
 
18
- ## Usage
19
-
20
- ### Search Bundles
17
+ ## Quick Start
21
18
 
22
19
  ```typescript
23
20
  import { MpakClient } from '@nimblebrain/mpak-sdk';
@@ -26,12 +23,18 @@ const client = new MpakClient();
26
23
 
27
24
  // Search for bundles
28
25
  const results = await client.searchBundles({ q: 'mcp', limit: 10 });
29
-
30
26
  for (const bundle of results.bundles) {
31
27
  console.log(`${bundle.name}@${bundle.latest_version}`);
32
28
  }
29
+
30
+ // Get download info
31
+ const download = await client.getBundleDownload('@nimblebraininc/echo', 'latest');
32
+ console.log(`Download URL: ${download.url}`);
33
+ console.log(`SHA256: ${download.bundle.sha256}`);
33
34
  ```
34
35
 
36
+ ## Usage
37
+
35
38
  ### Get Bundle Details
36
39
 
37
40
  ```typescript
@@ -41,20 +44,6 @@ console.log(bundle.description);
41
44
  console.log(`Versions: ${bundle.versions.map(v => v.version).join(', ')}`);
42
45
  ```
43
46
 
44
- ### Download a Bundle
45
-
46
- ```typescript
47
- // Get download info for the latest version
48
- const versions = await client.getBundleVersions('@nimblebraininc/echo');
49
- const download = await client.getBundleDownload(
50
- '@nimblebraininc/echo',
51
- versions.latest
52
- );
53
-
54
- console.log(`Download URL: ${download.url}`);
55
- console.log(`SHA256: ${download.bundle.sha256}`);
56
- ```
57
-
58
47
  ### Platform-Specific Downloads
59
48
 
60
49
  ```typescript
@@ -99,6 +88,39 @@ console.log(`Verified: ${verified}`);
99
88
  console.log(content);
100
89
  ```
101
90
 
91
+ ### Resolve Skill References
92
+
93
+ ```typescript
94
+ import { MpakClient, SkillReference } from '@nimblebrain/mpak-sdk';
95
+
96
+ const client = new MpakClient();
97
+
98
+ // Resolve from mpak registry
99
+ const skill = await client.resolveSkillRef({
100
+ source: 'mpak',
101
+ name: '@nimblebraininc/folk-crm',
102
+ version: '1.3.0',
103
+ });
104
+ console.log(skill.content);
105
+
106
+ // Resolve from GitHub
107
+ const ghSkill = await client.resolveSkillRef({
108
+ source: 'github',
109
+ name: '@example/my-skill',
110
+ version: 'v1.0.0',
111
+ repo: 'owner/repo',
112
+ path: 'skills/my-skill/SKILL.md',
113
+ });
114
+
115
+ // Resolve from URL
116
+ const urlSkill = await client.resolveSkillRef({
117
+ source: 'url',
118
+ name: '@example/custom',
119
+ version: '1.0.0',
120
+ url: 'https://example.com/skill.md',
121
+ });
122
+ ```
123
+
102
124
  ## Error Handling
103
125
 
104
126
  ```typescript
@@ -131,7 +153,7 @@ try {
131
153
 
132
154
  ```typescript
133
155
  const client = new MpakClient({
134
- registryUrl: 'https://api.mpak.dev', // Custom registry URL
156
+ registryUrl: 'https://registry.mpak.dev', // Custom registry URL
135
157
  timeout: 30000, // Request timeout in ms
136
158
  });
137
159
  ```
@@ -155,6 +177,7 @@ const client = new MpakClient({
155
177
  - `getSkillDownload(name)` - Get latest version download
156
178
  - `getSkillVersionDownload(name, version)` - Get specific version download
157
179
  - `downloadSkillContent(url, expectedSha256?)` - Download with optional integrity check
180
+ - `resolveSkillRef(ref)` - Resolve a skill reference to content
158
181
 
159
182
  #### Static Methods
160
183
 
@@ -171,39 +194,64 @@ const client = new MpakClient({
171
194
 
172
195
  ```bash
173
196
  # Install dependencies
174
- npm install
197
+ pnpm install
175
198
 
176
199
  # Run unit tests
177
- npm run test
200
+ pnpm test
178
201
 
179
202
  # Run integration tests (hits real API)
180
- npm run test:integration
203
+ pnpm test:integration
181
204
 
182
205
  # Type check
183
- npm run typecheck
184
-
185
- # Lint
186
- npm run lint
187
-
188
- # Full verification
189
- npm run verify
190
-
191
- # Generate types from OpenAPI spec
192
- npm run generate:types
206
+ pnpm typecheck
193
207
 
194
208
  # Build
195
- npm run build
209
+ pnpm build
196
210
  ```
197
211
 
198
- ## Type Generation
212
+ ### Verification
199
213
 
200
- Types are generated from the mpak.dev OpenAPI spec using `openapi-typescript`:
214
+ Run all checks before submitting changes:
201
215
 
202
216
  ```bash
203
- npm run generate:types
217
+ pnpm --filter @nimblebrain/mpak-sdk lint # lint
218
+ pnpm --filter @nimblebrain/mpak-sdk exec prettier --check "src/**/*.ts" "tests/**/*.ts" # format
219
+ pnpm --filter @nimblebrain/mpak-sdk typecheck # type check
220
+ pnpm --filter @nimblebrain/mpak-sdk test # unit tests
221
+ pnpm --filter @nimblebrain/mpak-sdk test:integration # integration tests (hits live registry)
204
222
  ```
205
223
 
206
- This fetches the spec from `https://api.mpak.dev/documentation/json` and generates `src/schema.d.ts`.
224
+ CI runs lint, format check, typecheck, and unit tests on every PR via [`sdk-typescript-ci.yml`](../../.github/workflows/sdk-typescript-ci.yml).
225
+
226
+ ## Releasing
227
+
228
+ Releases are automated via GitHub Actions. The publish workflow is triggered by git tags.
229
+
230
+ **Version is defined in one place:** `package.json`.
231
+
232
+ ### Steps
233
+
234
+ 1. **Bump version** in `package.json`:
235
+ ```bash
236
+ cd packages/sdk-typescript
237
+ npm version patch # 0.1.0 -> 0.1.1
238
+ npm version minor # 0.1.0 -> 0.2.0
239
+ npm version major # 0.1.0 -> 1.0.0
240
+ ```
241
+
242
+ 2. **Commit and push:**
243
+ ```bash
244
+ git commit -am "sdk-typescript: bump to X.Y.Z"
245
+ git push
246
+ ```
247
+
248
+ 3. **Tag and push** (this triggers the publish):
249
+ ```bash
250
+ git tag sdk-typescript-vX.Y.Z
251
+ git push origin sdk-typescript-vX.Y.Z
252
+ ```
253
+
254
+ CI will run the full verification suite, verify the tag matches `package.json`, build, and publish to npm. See [`sdk-typescript-publish.yml`](../../.github/workflows/sdk-typescript-publish.yml).
207
255
 
208
256
  ## License
209
257
 
package/dist/index.cjs CHANGED
@@ -62,10 +62,7 @@ var MpakIntegrityError = class extends MpakError {
62
62
  expected;
63
63
  actual;
64
64
  constructor(expected, actual) {
65
- super(
66
- `Integrity mismatch: expected ${expected}, got ${actual}`,
67
- "INTEGRITY_MISMATCH"
68
- );
65
+ super(`Integrity mismatch: expected ${expected}, got ${actual}`, "INTEGRITY_MISMATCH");
69
66
  this.name = "MpakIntegrityError";
70
67
  this.expected = expected;
71
68
  this.actual = actual;
@@ -79,14 +76,16 @@ var MpakNetworkError = class extends MpakError {
79
76
  };
80
77
 
81
78
  // src/client.ts
82
- var DEFAULT_REGISTRY_URL = "https://api.mpak.dev";
79
+ var DEFAULT_REGISTRY_URL = "https://registry.mpak.dev";
83
80
  var DEFAULT_TIMEOUT = 3e4;
84
81
  var MpakClient = class {
85
82
  registryUrl;
86
83
  timeout;
84
+ userAgent;
87
85
  constructor(config = {}) {
88
86
  this.registryUrl = config.registryUrl ?? DEFAULT_REGISTRY_URL;
89
87
  this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
88
+ this.userAgent = config.userAgent;
90
89
  }
91
90
  // ===========================================================================
92
91
  // Bundle API
@@ -104,6 +103,9 @@ var MpakClient = class {
104
103
  const queryString = searchParams.toString();
105
104
  const url = `${this.registryUrl}/v1/bundles/search${queryString ? `?${queryString}` : ""}`;
106
105
  const response = await this.fetchWithTimeout(url);
106
+ if (response.status === 404) {
107
+ throw new MpakNotFoundError("bundles/search endpoint");
108
+ }
107
109
  if (!response.ok) {
108
110
  throw new MpakNetworkError(`Failed to search bundles: HTTP ${response.status}`);
109
111
  }
@@ -195,6 +197,9 @@ var MpakClient = class {
195
197
  const queryString = searchParams.toString();
196
198
  const url = `${this.registryUrl}/v1/skills/search${queryString ? `?${queryString}` : ""}`;
197
199
  const response = await this.fetchWithTimeout(url);
200
+ if (response.status === 404) {
201
+ throw new MpakNotFoundError("skills/search endpoint");
202
+ }
198
203
  if (!response.ok) {
199
204
  throw new MpakNetworkError(`Failed to search skills: HTTP ${response.status}`);
200
205
  }
@@ -354,9 +359,19 @@ var MpakClient = class {
354
359
  const content = await response.text();
355
360
  if (ref.integrity) {
356
361
  this.verifyIntegrityOrThrow(content, ref.integrity);
357
- return { content, version: ref.version, source: "github", verified: true };
358
- }
359
- return { content, version: ref.version, source: "github", verified: false };
362
+ return {
363
+ content,
364
+ version: ref.version,
365
+ source: "github",
366
+ verified: true
367
+ };
368
+ }
369
+ return {
370
+ content,
371
+ version: ref.version,
372
+ source: "github",
373
+ verified: false
374
+ };
360
375
  }
361
376
  /**
362
377
  * Resolve a skill from a direct URL
@@ -471,15 +486,23 @@ var MpakClient = class {
471
486
  const timeoutId = setTimeout(() => {
472
487
  controller.abort();
473
488
  }, this.timeout);
489
+ const headers = {
490
+ ...init?.headers
491
+ };
492
+ if (this.userAgent) {
493
+ headers["User-Agent"] = this.userAgent;
494
+ }
474
495
  try {
475
- return await fetch(url, { ...init, signal: controller.signal });
496
+ return await fetch(url, {
497
+ ...init,
498
+ headers,
499
+ signal: controller.signal
500
+ });
476
501
  } catch (error) {
477
502
  if (error instanceof Error && error.name === "AbortError") {
478
503
  throw new MpakNetworkError(`Request timeout after ${this.timeout}ms`);
479
504
  }
480
- throw new MpakNetworkError(
481
- error instanceof Error ? error.message : "Network error"
482
- );
505
+ throw new MpakNetworkError(error instanceof Error ? error.message : "Network error");
483
506
  } finally {
484
507
  clearTimeout(timeoutId);
485
508
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/errors.ts"],"sourcesContent":["/**\n * @nimblebrain/mpak-sdk\n *\n * TypeScript SDK for mpak registry - MCPB bundles and Agent Skills\n *\n * Requires Node.js 18+ for native fetch support.\n *\n * @example\n * ```typescript\n * import { MpakClient, SkillReference } from '@nimblebrain/mpak-sdk';\n *\n * const client = new MpakClient();\n *\n * // Search for bundles\n * const bundles = await client.searchBundles({ q: 'mcp' });\n *\n * // Get bundle details\n * const bundle = await client.getBundle('@nimbletools/echo');\n *\n * // Search for skills\n * const skills = await client.searchSkills({ q: 'crm' });\n *\n * // Resolve a skill reference to content (recommended)\n * const ref: SkillReference = {\n * source: 'mpak',\n * name: '@nimblebraininc/folk-crm',\n * version: '1.3.0',\n * };\n * const resolved = await client.resolveSkillRef(ref);\n * console.log(resolved.content); // Skill markdown content\n * ```\n */\n\nexport { MpakClient } from './client.js';\n\n// Configuration\nexport type { MpakClientConfig } from './types.js';\n\n// Bundle types\nexport type {\n BundleSearchResponse,\n BundleDetailResponse,\n BundleVersionsResponse,\n BundleVersionResponse,\n BundleDownloadResponse,\n BundleIndexResponse,\n BundleSearchParams,\n Bundle,\n BundleDetail,\n BundleVersion,\n BundleArtifact,\n BundleDownloadInfo,\n} from './types.js';\n\n// Skill types\nexport type {\n SkillSearchResponse,\n SkillDetailResponse,\n SkillDownloadResponse,\n SkillSearchParams,\n Skill,\n SkillDetail,\n SkillDownloadInfo,\n SkillVersion,\n // Skill reference types (for resolveSkillRef)\n SkillReference,\n MpakSkillReference,\n GithubSkillReference,\n UrlSkillReference,\n ResolvedSkill,\n} from './types.js';\n\n// Common types\nexport type {\n Platform,\n Pagination,\n Provenance,\n Author,\n} from './types.js';\n\n// Errors\nexport {\n MpakError,\n MpakNotFoundError,\n MpakIntegrityError,\n MpakNetworkError,\n} from './errors.js';\n","import { createHash } from 'crypto';\nimport type {\n MpakClientConfig,\n BundleSearchResponse,\n BundleDetailResponse,\n BundleVersionsResponse,\n BundleVersionResponse,\n BundleDownloadResponse,\n BundleSearchParams,\n SkillSearchResponse,\n SkillDetailResponse,\n SkillDownloadResponse,\n SkillSearchParams,\n Platform,\n SkillReference,\n GithubSkillReference,\n UrlSkillReference,\n ResolvedSkill,\n} from './types.js';\nimport {\n MpakNotFoundError,\n MpakIntegrityError,\n MpakNetworkError,\n} from './errors.js';\n\nconst DEFAULT_REGISTRY_URL = 'https://api.mpak.dev';\nconst DEFAULT_TIMEOUT = 30000;\n\n/**\n * Client for interacting with the mpak registry\n *\n * Zero runtime dependencies - uses native fetch and crypto only.\n * Requires Node.js 18+ for native fetch support.\n */\nexport class MpakClient {\n private readonly registryUrl: string;\n private readonly timeout: number;\n\n constructor(config: MpakClientConfig = {}) {\n this.registryUrl = config.registryUrl ?? DEFAULT_REGISTRY_URL;\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT;\n }\n\n // ===========================================================================\n // Bundle API\n // ===========================================================================\n\n /**\n * Search for bundles\n */\n async searchBundles(params: BundleSearchParams = {}): Promise<BundleSearchResponse> {\n const searchParams = new URLSearchParams();\n if (params.q) searchParams.set('q', params.q);\n if (params.type) searchParams.set('type', params.type);\n if (params.sort) searchParams.set('sort', params.sort);\n if (params.limit) searchParams.set('limit', String(params.limit));\n if (params.offset) searchParams.set('offset', String(params.offset));\n\n const queryString = searchParams.toString();\n const url = `${this.registryUrl}/v1/bundles/search${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.fetchWithTimeout(url);\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to search bundles: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<BundleSearchResponse>;\n }\n\n /**\n * Get bundle details\n */\n async getBundle(name: string): Promise<BundleDetailResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/bundles/${name}`;\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError(name);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get bundle: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<BundleDetailResponse>;\n }\n\n /**\n * Get all versions of a bundle\n */\n async getBundleVersions(name: string): Promise<BundleVersionsResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/bundles/${name}/versions`;\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError(name);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get bundle versions: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<BundleVersionsResponse>;\n }\n\n /**\n * Get a specific version of a bundle\n */\n async getBundleVersion(name: string, version: string): Promise<BundleVersionResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/bundles/${name}/versions/${version}`;\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError(`${name}@${version}`);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get bundle version: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<BundleVersionResponse>;\n }\n\n /**\n * Get download info for a bundle\n */\n async getBundleDownload(\n name: string,\n version: string,\n platform?: Platform\n ): Promise<BundleDownloadResponse> {\n this.validateScopedName(name);\n\n const params = new URLSearchParams();\n if (platform) {\n params.set('os', platform.os);\n params.set('arch', platform.arch);\n }\n\n const queryString = params.toString();\n const url = `${this.registryUrl}/v1/bundles/${name}/versions/${version}/download${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.fetchWithTimeout(url, {\n headers: { Accept: 'application/json' },\n });\n\n if (response.status === 404) {\n throw new MpakNotFoundError(`${name}@${version}`);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get bundle download: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<BundleDownloadResponse>;\n }\n\n // ===========================================================================\n // Skill API\n // ===========================================================================\n\n /**\n * Search for skills\n */\n async searchSkills(params: SkillSearchParams = {}): Promise<SkillSearchResponse> {\n const searchParams = new URLSearchParams();\n if (params.q) searchParams.set('q', params.q);\n if (params.tags) searchParams.set('tags', params.tags);\n if (params.category) searchParams.set('category', params.category);\n if (params.surface) searchParams.set('surface', params.surface);\n if (params.sort) searchParams.set('sort', params.sort);\n if (params.limit) searchParams.set('limit', String(params.limit));\n if (params.offset) searchParams.set('offset', String(params.offset));\n\n const queryString = searchParams.toString();\n const url = `${this.registryUrl}/v1/skills/search${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.fetchWithTimeout(url);\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to search skills: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<SkillSearchResponse>;\n }\n\n /**\n * Get skill details\n */\n async getSkill(name: string): Promise<SkillDetailResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/skills/${name}`;\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError(name);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get skill: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<SkillDetailResponse>;\n }\n\n /**\n * Get download info for a skill (latest version)\n */\n async getSkillDownload(name: string): Promise<SkillDownloadResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/skills/${name}/download`;\n\n const response = await this.fetchWithTimeout(url, {\n headers: { Accept: 'application/json' },\n });\n\n if (response.status === 404) {\n throw new MpakNotFoundError(name);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get skill download: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<SkillDownloadResponse>;\n }\n\n /**\n * Get download info for a specific skill version\n */\n async getSkillVersionDownload(name: string, version: string): Promise<SkillDownloadResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/skills/${name}/versions/${version}/download`;\n\n const response = await this.fetchWithTimeout(url, {\n headers: { Accept: 'application/json' },\n });\n\n if (response.status === 404) {\n throw new MpakNotFoundError(`${name}@${version}`);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get skill download: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<SkillDownloadResponse>;\n }\n\n /**\n * Download skill content and verify integrity\n *\n * @throws {MpakIntegrityError} If expectedSha256 is provided and doesn't match (fail-closed)\n */\n async downloadSkillContent(\n downloadUrl: string,\n expectedSha256?: string\n ): Promise<{ content: string; verified: boolean }> {\n const response = await this.fetchWithTimeout(downloadUrl);\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to download skill: HTTP ${response.status}`);\n }\n\n const content = await response.text();\n\n if (expectedSha256) {\n const actualHash = this.computeSha256(content);\n if (actualHash !== expectedSha256) {\n throw new MpakIntegrityError(expectedSha256, actualHash);\n }\n return { content, verified: true };\n }\n\n return { content, verified: false };\n }\n\n /**\n * Resolve a skill reference to actual content\n *\n * Supports mpak, github, and url sources. This is the main method for\n * fetching skill content from any supported source.\n *\n * @throws {MpakNotFoundError} If skill not found\n * @throws {MpakIntegrityError} If integrity check fails (fail-closed)\n * @throws {MpakNetworkError} For network failures\n *\n * @example\n * ```typescript\n * // Resolve from mpak registry\n * const skill = await client.resolveSkillRef({\n * source: 'mpak',\n * name: '@nimblebraininc/folk-crm',\n * version: '1.3.0',\n * });\n *\n * // Resolve from GitHub\n * const skill = await client.resolveSkillRef({\n * source: 'github',\n * name: '@example/my-skill',\n * version: 'v1.0.0',\n * repo: 'owner/repo',\n * path: 'skills/my-skill/SKILL.md',\n * });\n *\n * // Resolve from URL\n * const skill = await client.resolveSkillRef({\n * source: 'url',\n * name: '@example/custom',\n * version: '1.0.0',\n * url: 'https://example.com/skill.md',\n * });\n * ```\n */\n async resolveSkillRef(ref: SkillReference): Promise<ResolvedSkill> {\n switch (ref.source) {\n case 'mpak':\n return this.resolveMpakSkill(ref);\n case 'github':\n return this.resolveGithubSkill(ref);\n case 'url':\n return this.resolveUrlSkill(ref);\n default: {\n const _exhaustive: never = ref;\n throw new Error(`Unknown skill source: ${(_exhaustive as SkillReference).source}`);\n }\n }\n }\n\n /**\n * Resolve a skill from mpak registry\n *\n * The API returns a ZIP bundle containing SKILL.md and metadata.\n */\n private async resolveMpakSkill(ref: SkillReference & { source: 'mpak' }): Promise<ResolvedSkill> {\n const url = `${this.registryUrl}/v1/skills/${ref.name}/versions/${ref.version}/download`;\n\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError(`${ref.name}@${ref.version}`);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to fetch skill: HTTP ${response.status}`);\n }\n\n // Response is a ZIP file - extract SKILL.md\n const zipBuffer = await response.arrayBuffer();\n const content = await this.extractSkillFromZip(zipBuffer, ref.name);\n\n if (ref.integrity) {\n this.verifyIntegrityOrThrow(content, ref.integrity);\n return { content, version: ref.version, source: 'mpak', verified: true };\n }\n\n return { content, version: ref.version, source: 'mpak', verified: false };\n }\n\n /**\n * Resolve a skill from GitHub releases\n */\n private async resolveGithubSkill(ref: GithubSkillReference): Promise<ResolvedSkill> {\n const url = `https://github.com/${ref.repo}/releases/download/${ref.version}/${ref.path}`;\n const response = await this.fetchWithTimeout(url);\n\n if (!response.ok) {\n throw new MpakNotFoundError(`github:${ref.repo}/${ref.path}@${ref.version}`);\n }\n\n const content = await response.text();\n\n if (ref.integrity) {\n this.verifyIntegrityOrThrow(content, ref.integrity);\n return { content, version: ref.version, source: 'github', verified: true };\n }\n\n return { content, version: ref.version, source: 'github', verified: false };\n }\n\n /**\n * Resolve a skill from a direct URL\n */\n private async resolveUrlSkill(ref: UrlSkillReference): Promise<ResolvedSkill> {\n const response = await this.fetchWithTimeout(ref.url);\n\n if (!response.ok) {\n throw new MpakNotFoundError(`url:${ref.url}`);\n }\n\n const content = await response.text();\n\n if (ref.integrity) {\n this.verifyIntegrityOrThrow(content, ref.integrity);\n return { content, version: ref.version, source: 'url', verified: true };\n }\n\n return { content, version: ref.version, source: 'url', verified: false };\n }\n\n /**\n * Extract SKILL.md content from a skill bundle ZIP\n */\n private async extractSkillFromZip(zipBuffer: ArrayBuffer, skillName: string): Promise<string> {\n const JSZip = (await import('jszip')).default;\n const zip = await JSZip.loadAsync(zipBuffer);\n\n // Skill name format: @scope/name -> folder is just 'name'\n const folderName = skillName.split('/').pop() ?? skillName;\n const skillPath = `${folderName}/SKILL.md`;\n\n const skillFile = zip.file(skillPath);\n if (!skillFile) {\n // Try without folder prefix\n const altFile = zip.file('SKILL.md');\n if (!altFile) {\n throw new MpakNotFoundError(`SKILL.md not found in bundle for ${skillName}`);\n }\n return altFile.async('string');\n }\n\n return skillFile.async('string');\n }\n\n /**\n * Verify content integrity and throw if mismatch (fail-closed)\n */\n private verifyIntegrityOrThrow(content: string, integrity: string): void {\n const expectedHash = this.extractHash(integrity);\n const actualHash = this.computeSha256(content);\n\n if (actualHash !== expectedHash) {\n throw new MpakIntegrityError(expectedHash, actualHash);\n }\n }\n\n /**\n * Extract hash from integrity string (removes prefix)\n */\n private extractHash(integrity: string): string {\n if (integrity.startsWith('sha256:')) {\n return integrity.slice(7);\n }\n if (integrity.startsWith('sha256-')) {\n return integrity.slice(7);\n }\n return integrity;\n }\n\n // ===========================================================================\n // Utility Methods\n // ===========================================================================\n\n /**\n * Detect the current platform\n */\n static detectPlatform(): Platform {\n const nodePlatform = process.platform;\n const nodeArch = process.arch;\n\n let os: string;\n switch (nodePlatform) {\n case 'darwin':\n os = 'darwin';\n break;\n case 'win32':\n os = 'win32';\n break;\n case 'linux':\n os = 'linux';\n break;\n default:\n os = 'any';\n }\n\n let arch: string;\n switch (nodeArch) {\n case 'x64':\n arch = 'x64';\n break;\n case 'arm64':\n arch = 'arm64';\n break;\n default:\n arch = 'any';\n }\n\n return { os, arch };\n }\n\n /**\n * Compute SHA256 hash of content\n */\n private computeSha256(content: string): string {\n return createHash('sha256').update(content, 'utf8').digest('hex');\n }\n\n /**\n * Validate that a name is scoped (@scope/name)\n */\n private validateScopedName(name: string): void {\n if (!name.startsWith('@')) {\n throw new Error('Package name must be scoped (e.g., @scope/package-name)');\n }\n }\n\n /**\n * Fetch with timeout support\n */\n private async fetchWithTimeout(\n url: string,\n init?: RequestInit\n ): Promise<Response> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => {\n controller.abort();\n }, this.timeout);\n\n try {\n return await fetch(url, { ...init, signal: controller.signal });\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n throw new MpakNetworkError(`Request timeout after ${this.timeout}ms`);\n }\n throw new MpakNetworkError(\n error instanceof Error ? error.message : 'Network error'\n );\n } finally {\n clearTimeout(timeoutId);\n }\n }\n}\n","/**\n * Base error class for mpak SDK errors\n */\nexport class MpakError extends Error {\n code: string;\n statusCode?: number;\n\n constructor(message: string, code: string, statusCode?: number) {\n super(message);\n this.name = 'MpakError';\n this.code = code;\n this.statusCode = statusCode;\n }\n}\n\n/**\n * Thrown when a requested resource is not found (404)\n */\nexport class MpakNotFoundError extends MpakError {\n constructor(resource: string) {\n super(`Resource not found: ${resource}`, 'NOT_FOUND', 404);\n this.name = 'MpakNotFoundError';\n }\n}\n\n/**\n * Thrown when integrity verification fails (hash mismatch)\n * This is a fail-closed error - content is NOT returned when this is thrown\n */\nexport class MpakIntegrityError extends MpakError {\n expected: string;\n actual: string;\n\n constructor(expected: string, actual: string) {\n super(\n `Integrity mismatch: expected ${expected}, got ${actual}`,\n 'INTEGRITY_MISMATCH'\n );\n this.name = 'MpakIntegrityError';\n this.expected = expected;\n this.actual = actual;\n }\n}\n\n/**\n * Thrown for network-related failures (timeouts, connection errors)\n */\nexport class MpakNetworkError extends MpakError {\n constructor(message: string) {\n super(message, 'NETWORK_ERROR');\n this.name = 'MpakNetworkError';\n }\n}\n"],"m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,eAAO,0BAAW,QAAQ,EAAE,OAAO,SAAS,MAAM,EAAE,OAAO,KAAK;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB,MAAoB;AAC7C,QAAI,CAAC,KAAK,WAAW,GAAG,GAAG;AACzB,YAAM,IAAI,MAAM,yDAAyD;AAAA,IAC3E;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAc,iBACZ,KACA,MACmB;AACnB,UAAM,aAAa,IAAI,gBAAgB;AACvC,UAAM,YAAY,WAAW,MAAM;AACjC,iBAAW,MAAM;AAAA,IACnB,GAAG,KAAK,OAAO;AAEf,QAAI;AACF,aAAO,MAAM,MAAM,KAAK,EAAE,GAAG,MAAM,QAAQ,WAAW,OAAO,CAAC;AAAA,IAChE,SAAS,OAAO;AACd,UAAI,iBAAiB,SAAS,MAAM,SAAS,cAAc;AACzD,cAAM,IAAI,iBAAiB,yBAAyB,KAAK,OAAO,IAAI;AAAA,MACtE;AACA,YAAM,IAAI;AAAA,QACR,iBAAiB,QAAQ,MAAM,UAAU;AAAA,MAC3C;AAAA,IACF,UAAE;AACA,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/errors.ts"],"sourcesContent":["/**\n * @nimblebrain/mpak-sdk\n *\n * TypeScript SDK for mpak registry - MCPB bundles and Agent Skills\n *\n * Requires Node.js 18+ for native fetch support.\n *\n * @example\n * ```typescript\n * import { MpakClient, SkillReference } from '@nimblebrain/mpak-sdk';\n *\n * const client = new MpakClient();\n *\n * // Search for bundles\n * const bundles = await client.searchBundles({ q: 'mcp' });\n *\n * // Get bundle details\n * const bundle = await client.getBundle('@nimbletools/echo');\n *\n * // Search for skills\n * const skills = await client.searchSkills({ q: 'crm' });\n *\n * // Resolve a skill reference to content (recommended)\n * const ref: SkillReference = {\n * source: 'mpak',\n * name: '@nimblebraininc/folk-crm',\n * version: '1.3.0',\n * };\n * const resolved = await client.resolveSkillRef(ref);\n * console.log(resolved.content); // Skill markdown content\n * ```\n */\n\nexport { MpakClient } from './client.js';\n\n// Configuration\nexport type { MpakClientConfig } from './types.js';\n\n// Bundle types\nexport type {\n BundleSearchParams,\n BundleDetailResponse,\n BundleVersionsResponse,\n BundleVersionResponse,\n BundleDownloadResponse,\n Bundle,\n BundleDetail,\n BundleVersion,\n BundleArtifact,\n BundleDownloadInfo,\n} from './types.js';\n\n// Re-export BundleSearchResponse from schemas\nexport type { BundleSearchResponse } from '@nimblebrain/mpak-schemas';\n\n// Skill types\nexport type {\n SkillSearchParams,\n SkillDetailResponse,\n SkillDownloadResponse,\n Skill,\n SkillDetail,\n SkillDownloadInfo,\n SkillVersion,\n // Skill reference types (for resolveSkillRef)\n SkillReference,\n MpakSkillReference,\n GithubSkillReference,\n UrlSkillReference,\n ResolvedSkill,\n} from './types.js';\n\n// Re-export SkillSearchResponse from schemas\nexport type { SkillSearchResponse } from '@nimblebrain/mpak-schemas';\n\n// Common types\nexport type { Platform, Pagination, Provenance, Author } from './types.js';\n\n// Errors\nexport { MpakError, MpakNotFoundError, MpakIntegrityError, MpakNetworkError } from './errors.js';\n","import { createHash } from 'crypto';\nimport type {\n MpakClientConfig,\n BundleSearchParams,\n BundleDetailResponse,\n BundleVersionsResponse,\n BundleVersionResponse,\n BundleDownloadResponse,\n SkillDetailResponse,\n SkillDownloadResponse,\n SkillSearchParams,\n Platform,\n SkillReference,\n GithubSkillReference,\n UrlSkillReference,\n ResolvedSkill,\n} from './types.js';\nimport type { BundleSearchResponse, SkillSearchResponse } from '@nimblebrain/mpak-schemas';\nimport { MpakNotFoundError, MpakIntegrityError, MpakNetworkError } from './errors.js';\n\nconst DEFAULT_REGISTRY_URL = 'https://registry.mpak.dev';\nconst DEFAULT_TIMEOUT = 30000;\n\n/**\n * Client for interacting with the mpak registry\n *\n * Requires Node.js 18+ for native fetch support.\n * Uses jszip for skill bundle extraction.\n */\nexport class MpakClient {\n private readonly registryUrl: string;\n private readonly timeout: number;\n private readonly userAgent: string | undefined;\n\n constructor(config: MpakClientConfig = {}) {\n this.registryUrl = config.registryUrl ?? DEFAULT_REGISTRY_URL;\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT;\n this.userAgent = config.userAgent;\n }\n\n // ===========================================================================\n // Bundle API\n // ===========================================================================\n\n /**\n * Search for bundles\n */\n async searchBundles(params: BundleSearchParams = {}): Promise<BundleSearchResponse> {\n const searchParams = new URLSearchParams();\n if (params.q) searchParams.set('q', params.q);\n if (params.type) searchParams.set('type', params.type);\n if (params.sort) searchParams.set('sort', params.sort);\n if (params.limit) searchParams.set('limit', String(params.limit));\n if (params.offset) searchParams.set('offset', String(params.offset));\n\n const queryString = searchParams.toString();\n const url = `${this.registryUrl}/v1/bundles/search${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError('bundles/search endpoint');\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to search bundles: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<BundleSearchResponse>;\n }\n\n /**\n * Get bundle details\n */\n async getBundle(name: string): Promise<BundleDetailResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/bundles/${name}`;\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError(name);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get bundle: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<BundleDetailResponse>;\n }\n\n /**\n * Get all versions of a bundle\n */\n async getBundleVersions(name: string): Promise<BundleVersionsResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/bundles/${name}/versions`;\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError(name);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get bundle versions: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<BundleVersionsResponse>;\n }\n\n /**\n * Get a specific version of a bundle\n */\n async getBundleVersion(name: string, version: string): Promise<BundleVersionResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/bundles/${name}/versions/${version}`;\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError(`${name}@${version}`);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get bundle version: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<BundleVersionResponse>;\n }\n\n /**\n * Get download info for a bundle\n */\n async getBundleDownload(\n name: string,\n version: string,\n platform?: Platform,\n ): Promise<BundleDownloadResponse> {\n this.validateScopedName(name);\n\n const params = new URLSearchParams();\n if (platform) {\n params.set('os', platform.os);\n params.set('arch', platform.arch);\n }\n\n const queryString = params.toString();\n const url = `${this.registryUrl}/v1/bundles/${name}/versions/${version}/download${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.fetchWithTimeout(url, {\n headers: { Accept: 'application/json' },\n });\n\n if (response.status === 404) {\n throw new MpakNotFoundError(`${name}@${version}`);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get bundle download: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<BundleDownloadResponse>;\n }\n\n // ===========================================================================\n // Skill API\n // ===========================================================================\n\n /**\n * Search for skills\n */\n async searchSkills(params: SkillSearchParams = {}): Promise<SkillSearchResponse> {\n const searchParams = new URLSearchParams();\n if (params.q) searchParams.set('q', params.q);\n if (params.tags) searchParams.set('tags', params.tags);\n if (params.category) searchParams.set('category', params.category);\n if (params.surface) searchParams.set('surface', params.surface);\n if (params.sort) searchParams.set('sort', params.sort);\n if (params.limit) searchParams.set('limit', String(params.limit));\n if (params.offset) searchParams.set('offset', String(params.offset));\n\n const queryString = searchParams.toString();\n const url = `${this.registryUrl}/v1/skills/search${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError('skills/search endpoint');\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to search skills: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<SkillSearchResponse>;\n }\n\n /**\n * Get skill details\n */\n async getSkill(name: string): Promise<SkillDetailResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/skills/${name}`;\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError(name);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get skill: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<SkillDetailResponse>;\n }\n\n /**\n * Get download info for a skill (latest version)\n */\n async getSkillDownload(name: string): Promise<SkillDownloadResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/skills/${name}/download`;\n\n const response = await this.fetchWithTimeout(url, {\n headers: { Accept: 'application/json' },\n });\n\n if (response.status === 404) {\n throw new MpakNotFoundError(name);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get skill download: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<SkillDownloadResponse>;\n }\n\n /**\n * Get download info for a specific skill version\n */\n async getSkillVersionDownload(name: string, version: string): Promise<SkillDownloadResponse> {\n this.validateScopedName(name);\n\n const url = `${this.registryUrl}/v1/skills/${name}/versions/${version}/download`;\n\n const response = await this.fetchWithTimeout(url, {\n headers: { Accept: 'application/json' },\n });\n\n if (response.status === 404) {\n throw new MpakNotFoundError(`${name}@${version}`);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to get skill download: HTTP ${response.status}`);\n }\n\n return response.json() as Promise<SkillDownloadResponse>;\n }\n\n /**\n * Download skill content and verify integrity\n *\n * @throws {MpakIntegrityError} If expectedSha256 is provided and doesn't match (fail-closed)\n */\n async downloadSkillContent(\n downloadUrl: string,\n expectedSha256?: string,\n ): Promise<{ content: string; verified: boolean }> {\n const response = await this.fetchWithTimeout(downloadUrl);\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to download skill: HTTP ${response.status}`);\n }\n\n const content = await response.text();\n\n if (expectedSha256) {\n const actualHash = this.computeSha256(content);\n if (actualHash !== expectedSha256) {\n throw new MpakIntegrityError(expectedSha256, actualHash);\n }\n return { content, verified: true };\n }\n\n return { content, verified: false };\n }\n\n /**\n * Resolve a skill reference to actual content\n *\n * Supports mpak, github, and url sources. This is the main method for\n * fetching skill content from any supported source.\n *\n * @throws {MpakNotFoundError} If skill not found\n * @throws {MpakIntegrityError} If integrity check fails (fail-closed)\n * @throws {MpakNetworkError} For network failures\n *\n * @example\n * ```typescript\n * // Resolve from mpak registry\n * const skill = await client.resolveSkillRef({\n * source: 'mpak',\n * name: '@nimblebraininc/folk-crm',\n * version: '1.3.0',\n * });\n *\n * // Resolve from GitHub\n * const skill = await client.resolveSkillRef({\n * source: 'github',\n * name: '@example/my-skill',\n * version: 'v1.0.0',\n * repo: 'owner/repo',\n * path: 'skills/my-skill/SKILL.md',\n * });\n *\n * // Resolve from URL\n * const skill = await client.resolveSkillRef({\n * source: 'url',\n * name: '@example/custom',\n * version: '1.0.0',\n * url: 'https://example.com/skill.md',\n * });\n * ```\n */\n async resolveSkillRef(ref: SkillReference): Promise<ResolvedSkill> {\n switch (ref.source) {\n case 'mpak':\n return this.resolveMpakSkill(ref);\n case 'github':\n return this.resolveGithubSkill(ref);\n case 'url':\n return this.resolveUrlSkill(ref);\n default: {\n const _exhaustive: never = ref;\n throw new Error(`Unknown skill source: ${(_exhaustive as SkillReference).source}`);\n }\n }\n }\n\n /**\n * Resolve a skill from mpak registry\n *\n * The API returns a ZIP bundle containing SKILL.md and metadata.\n */\n private async resolveMpakSkill(ref: SkillReference & { source: 'mpak' }): Promise<ResolvedSkill> {\n const url = `${this.registryUrl}/v1/skills/${ref.name}/versions/${ref.version}/download`;\n\n const response = await this.fetchWithTimeout(url);\n\n if (response.status === 404) {\n throw new MpakNotFoundError(`${ref.name}@${ref.version}`);\n }\n\n if (!response.ok) {\n throw new MpakNetworkError(`Failed to fetch skill: HTTP ${response.status}`);\n }\n\n // Response is a ZIP file - extract SKILL.md\n const zipBuffer = await response.arrayBuffer();\n const content = await this.extractSkillFromZip(zipBuffer, ref.name);\n\n if (ref.integrity) {\n this.verifyIntegrityOrThrow(content, ref.integrity);\n return { content, version: ref.version, source: 'mpak', verified: true };\n }\n\n return { content, version: ref.version, source: 'mpak', verified: false };\n }\n\n /**\n * Resolve a skill from GitHub releases\n */\n private async resolveGithubSkill(ref: GithubSkillReference): Promise<ResolvedSkill> {\n const url = `https://github.com/${ref.repo}/releases/download/${ref.version}/${ref.path}`;\n const response = await this.fetchWithTimeout(url);\n\n if (!response.ok) {\n throw new MpakNotFoundError(`github:${ref.repo}/${ref.path}@${ref.version}`);\n }\n\n const content = await response.text();\n\n if (ref.integrity) {\n this.verifyIntegrityOrThrow(content, ref.integrity);\n return {\n content,\n version: ref.version,\n source: 'github',\n verified: true,\n };\n }\n\n return {\n content,\n version: ref.version,\n source: 'github',\n verified: false,\n };\n }\n\n /**\n * Resolve a skill from a direct URL\n */\n private async resolveUrlSkill(ref: UrlSkillReference): Promise<ResolvedSkill> {\n const response = await this.fetchWithTimeout(ref.url);\n\n if (!response.ok) {\n throw new MpakNotFoundError(`url:${ref.url}`);\n }\n\n const content = await response.text();\n\n if (ref.integrity) {\n this.verifyIntegrityOrThrow(content, ref.integrity);\n return { content, version: ref.version, source: 'url', verified: true };\n }\n\n return { content, version: ref.version, source: 'url', verified: false };\n }\n\n /**\n * Extract SKILL.md content from a skill bundle ZIP\n */\n private async extractSkillFromZip(zipBuffer: ArrayBuffer, skillName: string): Promise<string> {\n const JSZip = (await import('jszip')).default;\n const zip = await JSZip.loadAsync(zipBuffer);\n\n // Skill name format: @scope/name -> folder is just 'name'\n const folderName = skillName.split('/').pop() ?? skillName;\n const skillPath = `${folderName}/SKILL.md`;\n\n const skillFile = zip.file(skillPath);\n if (!skillFile) {\n // Try without folder prefix\n const altFile = zip.file('SKILL.md');\n if (!altFile) {\n throw new MpakNotFoundError(`SKILL.md not found in bundle for ${skillName}`);\n }\n return altFile.async('string');\n }\n\n return skillFile.async('string');\n }\n\n /**\n * Verify content integrity and throw if mismatch (fail-closed)\n */\n private verifyIntegrityOrThrow(content: string, integrity: string): void {\n const expectedHash = this.extractHash(integrity);\n const actualHash = this.computeSha256(content);\n\n if (actualHash !== expectedHash) {\n throw new MpakIntegrityError(expectedHash, actualHash);\n }\n }\n\n /**\n * Extract hash from integrity string (removes prefix)\n */\n private extractHash(integrity: string): string {\n if (integrity.startsWith('sha256:')) {\n return integrity.slice(7);\n }\n if (integrity.startsWith('sha256-')) {\n return integrity.slice(7);\n }\n return integrity;\n }\n\n // ===========================================================================\n // Utility Methods\n // ===========================================================================\n\n /**\n * Detect the current platform\n */\n static detectPlatform(): Platform {\n const nodePlatform = process.platform;\n const nodeArch = process.arch;\n\n let os: string;\n switch (nodePlatform) {\n case 'darwin':\n os = 'darwin';\n break;\n case 'win32':\n os = 'win32';\n break;\n case 'linux':\n os = 'linux';\n break;\n default:\n os = 'any';\n }\n\n let arch: string;\n switch (nodeArch) {\n case 'x64':\n arch = 'x64';\n break;\n case 'arm64':\n arch = 'arm64';\n break;\n default:\n arch = 'any';\n }\n\n return { os, arch };\n }\n\n /**\n * Compute SHA256 hash of content\n */\n private computeSha256(content: string): string {\n return createHash('sha256').update(content, 'utf8').digest('hex');\n }\n\n /**\n * Validate that a name is scoped (@scope/name)\n */\n private validateScopedName(name: string): void {\n if (!name.startsWith('@')) {\n throw new Error('Package name must be scoped (e.g., @scope/package-name)');\n }\n }\n\n /**\n * Fetch with timeout support\n */\n private async fetchWithTimeout(url: string, init?: RequestInit): Promise<Response> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => {\n controller.abort();\n }, this.timeout);\n\n const headers: Record<string, string> = {\n ...(init?.headers as Record<string, string>),\n };\n if (this.userAgent) {\n headers['User-Agent'] = this.userAgent;\n }\n\n try {\n return await fetch(url, {\n ...init,\n headers,\n signal: controller.signal,\n });\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n throw new MpakNetworkError(`Request timeout after ${this.timeout}ms`);\n }\n throw new MpakNetworkError(error instanceof Error ? error.message : 'Network error');\n } finally {\n clearTimeout(timeoutId);\n }\n }\n}\n","/**\n * Base error class for mpak SDK errors\n */\nexport class MpakError extends Error {\n code: string;\n statusCode: number | undefined;\n\n constructor(message: string, code: string, statusCode?: number) {\n super(message);\n this.name = 'MpakError';\n this.code = code;\n this.statusCode = statusCode;\n }\n}\n\n/**\n * Thrown when a requested resource is not found (404)\n */\nexport class MpakNotFoundError extends MpakError {\n constructor(resource: string) {\n super(`Resource not found: ${resource}`, 'NOT_FOUND', 404);\n this.name = 'MpakNotFoundError';\n }\n}\n\n/**\n * Thrown when integrity verification fails (hash mismatch)\n * This is a fail-closed error - content is NOT returned when this is thrown\n */\nexport class MpakIntegrityError extends MpakError {\n expected: string;\n actual: string;\n\n constructor(expected: string, actual: string) {\n super(`Integrity mismatch: expected ${expected}, got ${actual}`, 'INTEGRITY_MISMATCH');\n this.name = 'MpakIntegrityError';\n this.expected = expected;\n this.actual = actual;\n }\n}\n\n/**\n * Thrown for network-related failures (timeouts, connection errors)\n */\nexport class MpakNetworkError extends MpakError {\n constructor(message: string) {\n super(message, 'NETWORK_ERROR');\n this.name = 'MpakNetworkError';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA2B;;;ACGpB,IAAM,YAAN,cAAwB,MAAM;AAAA,EACnC;AAAA,EACA;AAAA,EAEA,YAAY,SAAiB,MAAc,YAAqB;AAC9D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,aAAa;AAAA,EACpB;AACF;AAKO,IAAM,oBAAN,cAAgC,UAAU;AAAA,EAC/C,YAAY,UAAkB;AAC5B,UAAM,uBAAuB,QAAQ,IAAI,aAAa,GAAG;AACzD,SAAK,OAAO;AAAA,E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