@nimblebrain/mpak-sdk 0.0.1

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 ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
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.
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # @nimblebrain/mpak-sdk
2
+
3
+ TypeScript SDK for mpak registry - MCPB bundles and Agent Skills.
4
+
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
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @nimblebrain/mpak-sdk
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ### Search Bundles
21
+
22
+ ```typescript
23
+ import { MpakClient } from '@nimblebrain/mpak-sdk';
24
+
25
+ const client = new MpakClient();
26
+
27
+ // Search for bundles
28
+ const results = await client.searchBundles({ q: 'mcp', limit: 10 });
29
+
30
+ for (const bundle of results.bundles) {
31
+ console.log(`${bundle.name}@${bundle.latest_version}`);
32
+ }
33
+ ```
34
+
35
+ ### Get Bundle Details
36
+
37
+ ```typescript
38
+ const bundle = await client.getBundle('@nimblebraininc/echo');
39
+
40
+ console.log(bundle.description);
41
+ console.log(`Versions: ${bundle.versions.map(v => v.version).join(', ')}`);
42
+ ```
43
+
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
+ ### Platform-Specific Downloads
59
+
60
+ ```typescript
61
+ // Detect current platform
62
+ const platform = MpakClient.detectPlatform();
63
+
64
+ // Get platform-specific download
65
+ const download = await client.getBundleDownload(
66
+ '@nimblebraininc/echo',
67
+ '0.1.3',
68
+ platform
69
+ );
70
+ ```
71
+
72
+ ### Search Skills
73
+
74
+ ```typescript
75
+ const skills = await client.searchSkills({
76
+ q: 'crm',
77
+ surface: 'claude-code',
78
+ limit: 10,
79
+ });
80
+
81
+ for (const skill of skills.skills) {
82
+ console.log(`${skill.name}: ${skill.description}`);
83
+ }
84
+ ```
85
+
86
+ ### Download Skill with Integrity Verification
87
+
88
+ ```typescript
89
+ // Get skill download info
90
+ const download = await client.getSkillDownload('@nimbletools/folk-crm');
91
+
92
+ // Download content with SHA256 verification (fail-closed)
93
+ const { content, verified } = await client.downloadSkillContent(
94
+ download.url,
95
+ download.skill.sha256 // If hash doesn't match, throws MpakIntegrityError
96
+ );
97
+
98
+ console.log(`Verified: ${verified}`);
99
+ console.log(content);
100
+ ```
101
+
102
+ ## Error Handling
103
+
104
+ ```typescript
105
+ import {
106
+ MpakClient,
107
+ MpakNotFoundError,
108
+ MpakIntegrityError,
109
+ MpakNetworkError,
110
+ } from '@nimblebrain/mpak-sdk';
111
+
112
+ const client = new MpakClient();
113
+
114
+ try {
115
+ const bundle = await client.getBundle('@nonexistent/bundle');
116
+ } catch (error) {
117
+ if (error instanceof MpakNotFoundError) {
118
+ console.error('Bundle not found:', error.message);
119
+ } else if (error instanceof MpakIntegrityError) {
120
+ // CRITICAL: Content was NOT returned (fail-closed)
121
+ console.error('Integrity mismatch!');
122
+ console.error('Expected:', error.expected);
123
+ console.error('Actual:', error.actual);
124
+ } else if (error instanceof MpakNetworkError) {
125
+ console.error('Network error:', error.message);
126
+ }
127
+ }
128
+ ```
129
+
130
+ ## Configuration
131
+
132
+ ```typescript
133
+ const client = new MpakClient({
134
+ registryUrl: 'https://api.mpak.dev', // Custom registry URL
135
+ timeout: 30000, // Request timeout in ms
136
+ });
137
+ ```
138
+
139
+ ## API Reference
140
+
141
+ ### MpakClient
142
+
143
+ #### Bundle Methods
144
+
145
+ - `searchBundles(params?)` - Search for bundles
146
+ - `getBundle(name)` - Get bundle details
147
+ - `getBundleVersions(name)` - List all versions
148
+ - `getBundleVersion(name, version)` - Get specific version info
149
+ - `getBundleDownload(name, version, platform?)` - Get download URL
150
+
151
+ #### Skill Methods
152
+
153
+ - `searchSkills(params?)` - Search for skills
154
+ - `getSkill(name)` - Get skill details
155
+ - `getSkillDownload(name)` - Get latest version download
156
+ - `getSkillVersionDownload(name, version)` - Get specific version download
157
+ - `downloadSkillContent(url, expectedSha256?)` - Download with optional integrity check
158
+
159
+ #### Static Methods
160
+
161
+ - `MpakClient.detectPlatform()` - Detect current OS/arch
162
+
163
+ ### Error Types
164
+
165
+ - `MpakError` - Base error class
166
+ - `MpakNotFoundError` - Resource not found (404)
167
+ - `MpakIntegrityError` - Hash mismatch (content NOT returned)
168
+ - `MpakNetworkError` - Network failures, timeouts
169
+
170
+ ## Development
171
+
172
+ ```bash
173
+ # Install dependencies
174
+ npm install
175
+
176
+ # Run unit tests
177
+ npm run test
178
+
179
+ # Run integration tests (hits real API)
180
+ npm run test:integration
181
+
182
+ # 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
193
+
194
+ # Build
195
+ npm run build
196
+ ```
197
+
198
+ ## Type Generation
199
+
200
+ Types are generated from the mpak.dev OpenAPI spec using `openapi-typescript`:
201
+
202
+ ```bash
203
+ npm run generate:types
204
+ ```
205
+
206
+ This fetches the spec from `https://api.mpak.dev/documentation/json` and generates `src/schema.d.ts`.
207
+
208
+ ## License
209
+
210
+ Apache-2.0
@@ -0,0 +1,74 @@
1
+ import type { MpakClientConfig, BundleSearchResponse, BundleDetailResponse, BundleVersionsResponse, BundleVersionResponse, BundleDownloadResponse, BundleSearchParams, SkillSearchResponse, SkillDetailResponse, SkillDownloadResponse, SkillSearchParams, Platform } from './types.js';
2
+ /**
3
+ * Client for interacting with the mpak registry
4
+ *
5
+ * Zero runtime dependencies - uses native fetch and crypto only.
6
+ * Requires Node.js 18+ for native fetch support.
7
+ */
8
+ export declare class MpakClient {
9
+ private readonly registryUrl;
10
+ private readonly timeout;
11
+ constructor(config?: MpakClientConfig);
12
+ /**
13
+ * Search for bundles
14
+ */
15
+ searchBundles(params?: BundleSearchParams): Promise<BundleSearchResponse>;
16
+ /**
17
+ * Get bundle details
18
+ */
19
+ getBundle(name: string): Promise<BundleDetailResponse>;
20
+ /**
21
+ * Get all versions of a bundle
22
+ */
23
+ getBundleVersions(name: string): Promise<BundleVersionsResponse>;
24
+ /**
25
+ * Get a specific version of a bundle
26
+ */
27
+ getBundleVersion(name: string, version: string): Promise<BundleVersionResponse>;
28
+ /**
29
+ * Get download info for a bundle
30
+ */
31
+ getBundleDownload(name: string, version: string, platform?: Platform): Promise<BundleDownloadResponse>;
32
+ /**
33
+ * Search for skills
34
+ */
35
+ searchSkills(params?: SkillSearchParams): Promise<SkillSearchResponse>;
36
+ /**
37
+ * Get skill details
38
+ */
39
+ getSkill(name: string): Promise<SkillDetailResponse>;
40
+ /**
41
+ * Get download info for a skill (latest version)
42
+ */
43
+ getSkillDownload(name: string): Promise<SkillDownloadResponse>;
44
+ /**
45
+ * Get download info for a specific skill version
46
+ */
47
+ getSkillVersionDownload(name: string, version: string): Promise<SkillDownloadResponse>;
48
+ /**
49
+ * Download skill content and verify integrity
50
+ *
51
+ * @throws {MpakIntegrityError} If expectedSha256 is provided and doesn't match (fail-closed)
52
+ */
53
+ downloadSkillContent(downloadUrl: string, expectedSha256?: string): Promise<{
54
+ content: string;
55
+ verified: boolean;
56
+ }>;
57
+ /**
58
+ * Detect the current platform
59
+ */
60
+ static detectPlatform(): Platform;
61
+ /**
62
+ * Compute SHA256 hash of content
63
+ */
64
+ private computeSha256;
65
+ /**
66
+ * Validate that a name is scoped (@scope/name)
67
+ */
68
+ private validateScopedName;
69
+ /**
70
+ * Fetch with timeout support
71
+ */
72
+ private fetchWithTimeout;
73
+ }
74
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB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AO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAwBlD;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,QAAQ;IAkCjC;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;OAEG;YACW,gBAAgB;CAsB/B"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Integration tests for MpakClient
3
+ *
4
+ * These tests hit the actual mpak.dev API. Run with:
5
+ * npm run test:integration
6
+ *
7
+ * Note: These tests depend on data in the production registry.
8
+ * If bundles are removed, tests may need updating.
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=client.integration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.integration.test.d.ts","sourceRoot":"","sources":["../src/client.integration.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Integration tests for MpakClient
3
+ *
4
+ * These tests hit the actual mpak.dev API. Run with:
5
+ * npm run test:integration
6
+ *
7
+ * Note: These tests depend on data in the production registry.
8
+ * If bundles are removed, tests may need updating.
9
+ */
10
+ import { describe, it, expect } from 'vitest';
11
+ import { MpakClient } from './client.js';
12
+ import { MpakNotFoundError } from './errors.js';
13
+ // Known bundle that exists in the registry
14
+ const KNOWN_BUNDLE = '@nimblebraininc/echo';
15
+ describe('MpakClient Integration Tests', () => {
16
+ const client = new MpakClient();
17
+ describe('Bundle API', () => {
18
+ it('searches bundles', async () => {
19
+ const result = await client.searchBundles({ limit: 5 });
20
+ expect(result.bundles).toBeInstanceOf(Array);
21
+ expect(result.bundles.length).toBeGreaterThan(0);
22
+ expect(result.total).toBeGreaterThan(0);
23
+ expect(result.pagination).toBeDefined();
24
+ expect(result.pagination.limit).toBe(5);
25
+ });
26
+ it('searches bundles with query', async () => {
27
+ const result = await client.searchBundles({ q: 'echo' });
28
+ expect(result.bundles).toBeInstanceOf(Array);
29
+ // Should find the echo bundle
30
+ const echoBundle = result.bundles.find(b => b.name.includes('echo'));
31
+ expect(echoBundle).toBeDefined();
32
+ });
33
+ it('gets bundle details', async () => {
34
+ const bundle = await client.getBundle(KNOWN_BUNDLE);
35
+ expect(bundle.name).toBe(KNOWN_BUNDLE);
36
+ expect(bundle.latest_version).toBeDefined();
37
+ expect(bundle.versions).toBeInstanceOf(Array);
38
+ expect(bundle.versions.length).toBeGreaterThan(0);
39
+ });
40
+ it('gets bundle versions', async () => {
41
+ const versions = await client.getBundleVersions(KNOWN_BUNDLE);
42
+ expect(versions.name).toBe(KNOWN_BUNDLE);
43
+ expect(versions.latest).toBeDefined();
44
+ expect(versions.versions).toBeInstanceOf(Array);
45
+ expect(versions.versions.length).toBeGreaterThan(0);
46
+ // Each version should have required fields
47
+ const firstVersion = versions.versions[0];
48
+ expect(firstVersion?.version).toBeDefined();
49
+ expect(firstVersion?.platforms).toBeInstanceOf(Array);
50
+ });
51
+ it('gets specific bundle version', async () => {
52
+ // First get the versions to find a valid version number
53
+ const versions = await client.getBundleVersions(KNOWN_BUNDLE);
54
+ const latestVersion = versions.latest;
55
+ const versionInfo = await client.getBundleVersion(KNOWN_BUNDLE, latestVersion);
56
+ expect(versionInfo.name).toBe(KNOWN_BUNDLE);
57
+ expect(versionInfo.version).toBe(latestVersion);
58
+ expect(versionInfo.artifacts).toBeInstanceOf(Array);
59
+ expect(versionInfo.manifest).toBeDefined();
60
+ });
61
+ it('gets bundle download info', async () => {
62
+ // First get the versions to find a valid version number
63
+ const versions = await client.getBundleVersions(KNOWN_BUNDLE);
64
+ const latestVersion = versions.latest;
65
+ const download = await client.getBundleDownload(KNOWN_BUNDLE, latestVersion);
66
+ expect(download.url).toBeDefined();
67
+ expect(download.url).toContain('http');
68
+ expect(download.bundle).toBeDefined();
69
+ expect(download.bundle.sha256).toBeDefined();
70
+ expect(download.bundle.size).toBeGreaterThan(0);
71
+ });
72
+ it('throws MpakNotFoundError for nonexistent bundle', async () => {
73
+ await expect(client.getBundle('@nonexistent/bundle-that-does-not-exist')).rejects.toThrow(MpakNotFoundError);
74
+ });
75
+ });
76
+ describe('Skill API', () => {
77
+ it('searches skills', async () => {
78
+ const result = await client.searchSkills({ limit: 5 });
79
+ expect(result.skills).toBeInstanceOf(Array);
80
+ expect(result.pagination).toBeDefined();
81
+ // Note: There may be no skills yet, so we just check the response structure
82
+ });
83
+ it('searches skills with filters', async () => {
84
+ const result = await client.searchSkills({
85
+ surface: 'claude-code',
86
+ limit: 10,
87
+ });
88
+ expect(result.skills).toBeInstanceOf(Array);
89
+ expect(result.pagination).toBeDefined();
90
+ });
91
+ it('throws MpakNotFoundError for nonexistent skill', async () => {
92
+ await expect(client.getSkill('@nonexistent/skill-that-does-not-exist')).rejects.toThrow(MpakNotFoundError);
93
+ });
94
+ });
95
+ describe('Platform detection', () => {
96
+ it('detects current platform', () => {
97
+ const platform = MpakClient.detectPlatform();
98
+ expect(platform.os).toBeDefined();
99
+ expect(platform.arch).toBeDefined();
100
+ expect(['darwin', 'linux', 'win32', 'any']).toContain(platform.os);
101
+ expect(['x64', 'arm64', 'any']).toContain(platform.arch);
102
+ });
103
+ it('can request bundle for current platform', async () => {
104
+ const versions = await client.getBundleVersions(KNOWN_BUNDLE);
105
+ const latestVersion = versions.latest;
106
+ const platform = MpakClient.detectPlatform();
107
+ // This should not throw even if the platform-specific artifact doesn't exist
108
+ // (it falls back to 'any')
109
+ const download = await client.getBundleDownload(KNOWN_BUNDLE, latestVersion, platform);
110
+ expect(download.url).toBeDefined();
111
+ });
112
+ });
113
+ describe('Error handling', () => {
114
+ it('handles timeout gracefully', async () => {
115
+ const shortTimeoutClient = new MpakClient({ timeout: 1 });
116
+ // With a 1ms timeout, this should fail
117
+ await expect(shortTimeoutClient.searchBundles()).rejects.toThrow();
118
+ });
119
+ });
120
+ });
121
+ //# sourceMappingURL=client.integration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.integration.test.js","sourceRoot":"","sources":["../src/client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