@czj-git/dsh-plugin-hub 0.1.0 → 0.2.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 (44) hide show
  1. package/README.en.md +93 -6
  2. package/README.md +93 -6
  3. package/dist/api.d.ts +4 -199
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +5 -90
  6. package/dist/api.js.map +1 -0
  7. package/dist/client/PluginHubSettings.d.ts +19 -0
  8. package/dist/client/PluginHubSettings.d.ts.map +1 -0
  9. package/dist/client/PluginHubSettings.js +172 -0
  10. package/dist/client/PluginHubSettings.js.map +1 -0
  11. package/dist/client/api.d.ts +18 -0
  12. package/dist/client/api.d.ts.map +1 -0
  13. package/dist/client/api.js +59 -0
  14. package/dist/client/api.js.map +1 -0
  15. package/dist/client/index.d.ts +15 -0
  16. package/dist/client/index.d.ts.map +1 -0
  17. package/dist/client/index.js +43 -0
  18. package/dist/client/index.js.map +1 -0
  19. package/dist/client/locales.d.ts +54 -0
  20. package/dist/client/locales.d.ts.map +1 -0
  21. package/dist/client/locales.js +100 -0
  22. package/dist/client/locales.js.map +1 -0
  23. package/dist/client.js +833 -0
  24. package/dist/client.js.map +7 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +9 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/render.d.ts.map +1 -0
  29. package/dist/render.js.map +1 -0
  30. package/dist/schemas.d.ts +285 -0
  31. package/dist/schemas.d.ts.map +1 -0
  32. package/dist/schemas.js +85 -0
  33. package/dist/schemas.js.map +1 -0
  34. package/dist/shared.d.ts +32 -0
  35. package/dist/shared.d.ts.map +1 -0
  36. package/dist/shared.js +26 -0
  37. package/dist/shared.js.map +1 -0
  38. package/dist/tool-schema.d.ts.map +1 -0
  39. package/dist/tool-schema.js.map +1 -0
  40. package/dist/web-route.d.ts +19 -0
  41. package/dist/web-route.d.ts.map +1 -0
  42. package/dist/web-route.js +115 -0
  43. package/dist/web-route.js.map +1 -0
  44. package/package.json +50 -5
@@ -0,0 +1,115 @@
1
+ /** Same-origin Host proxy used by the browser Settings page. */
2
+ import { PluginHubApiError, } from './api.js';
3
+ import { pluginHubCategories, pluginHubLocales, pluginHubSorts, pluginHubSources, pluginHubTypes, PLUGIN_HUB_SEARCH_ROUTE, } from './shared.js';
4
+ function enumValue(name, value, allowed) {
5
+ if (value === null || value === '')
6
+ return undefined;
7
+ if (!allowed.includes(value))
8
+ throw new Error(`${name} is unsupported`);
9
+ return value;
10
+ }
11
+ function integerValue(name, value, fallback, maximum) {
12
+ if (value === null || value === '')
13
+ return fallback;
14
+ const parsed = Number(value);
15
+ if (!Number.isInteger(parsed) || parsed < 1 || parsed > maximum) {
16
+ throw new Error(`${name} must be an integer from 1 to ${maximum}`);
17
+ }
18
+ return parsed;
19
+ }
20
+ /**
21
+ * Validate browser query parameters before forwarding them to the public API.
22
+ * @param url - Local request URL.
23
+ * @param defaultLocale - Locale used when the browser omits one.
24
+ * @returns Validated public API search input.
25
+ */
26
+ export function parseLocalSearchInput(url, defaultLocale) {
27
+ const query = url.searchParams.get('q')?.trim().replace(/\s+/g, ' ') ?? '';
28
+ if (query.length > 100)
29
+ throw new Error('q must contain at most 100 characters');
30
+ const locale = enumValue('locale', url.searchParams.get('locale'), pluginHubLocales) ?? defaultLocale;
31
+ const category = enumValue('category', url.searchParams.get('category'), pluginHubCategories);
32
+ const type = enumValue('type', url.searchParams.get('type'), pluginHubTypes);
33
+ const source = enumValue('source', url.searchParams.get('source'), pluginHubSources);
34
+ const sort = enumValue('sort', url.searchParams.get('sort'), pluginHubSorts) ?? (query ? 'relevance' : 'stars');
35
+ return {
36
+ ...(query ? { query } : {}),
37
+ locale,
38
+ ...(category ? { category: category } : {}),
39
+ ...(type ? { type: type } : {}),
40
+ ...(source ? { source: source } : {}),
41
+ sort: sort,
42
+ page: integerValue('page', url.searchParams.get('page'), 1, 1000),
43
+ perPage: integerValue('per_page', url.searchParams.get('per_page'), 12, 50),
44
+ };
45
+ }
46
+ function writeJson(res, status, body) {
47
+ res.writeHead(status, {
48
+ 'Cache-Control': 'no-store',
49
+ 'Content-Type': 'application/json; charset=utf-8',
50
+ });
51
+ res.end(JSON.stringify(body));
52
+ }
53
+ /**
54
+ * Create the read-only local HTTP handler for the Settings client.
55
+ * @param client - Validating public API client.
56
+ * @param defaultLocale - Host-configured fallback locale.
57
+ * @returns Node HTTP handler suitable for the Harness WebServer registry.
58
+ */
59
+ export function createPluginHubSearchHandler(client, defaultLocale) {
60
+ return async (req, res) => {
61
+ if (req.method === 'OPTIONS') {
62
+ res.writeHead(204, { Allow: 'GET, OPTIONS', 'Cache-Control': 'no-store' });
63
+ res.end();
64
+ return;
65
+ }
66
+ if (req.method !== 'GET') {
67
+ writeJson(res, 405, { error: { code: 'METHOD_NOT_ALLOWED', message: 'Only GET is supported.' } });
68
+ return;
69
+ }
70
+ let input;
71
+ try {
72
+ input = parseLocalSearchInput(new URL(req.url ?? PLUGIN_HUB_SEARCH_ROUTE, 'http://localhost'), defaultLocale);
73
+ }
74
+ catch (error) {
75
+ writeJson(res, 400, {
76
+ error: {
77
+ code: 'INVALID_QUERY',
78
+ message: error instanceof Error ? error.message : 'Invalid request parameters.',
79
+ },
80
+ });
81
+ return;
82
+ }
83
+ const request = new AbortController();
84
+ const abort = () => { request.abort(); };
85
+ req.once('aborted', abort);
86
+ try {
87
+ const result = await client.search(input, request.signal);
88
+ if (!res.destroyed)
89
+ writeJson(res, 200, result);
90
+ }
91
+ catch (error) {
92
+ if (res.destroyed)
93
+ return;
94
+ if (error instanceof PluginHubApiError) {
95
+ const remoteStatus = error.status;
96
+ const status = remoteStatus !== null && remoteStatus >= 400 && remoteStatus <= 599 ? remoteStatus : 502;
97
+ writeJson(res, status, {
98
+ error: {
99
+ code: error.code,
100
+ message: error.message,
101
+ ...(Object.keys(error.fields).length > 0 ? { fields: error.fields } : {}),
102
+ },
103
+ });
104
+ return;
105
+ }
106
+ writeJson(res, 502, {
107
+ error: { code: 'PLUGIN_HUB_UNAVAILABLE', message: 'DSH Plugin Hub is temporarily unavailable.' },
108
+ });
109
+ }
110
+ finally {
111
+ req.off('aborted', abort);
112
+ }
113
+ };
114
+ }
115
+ //# sourceMappingURL=web-route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-route.js","sourceRoot":"","sources":["../src/web-route.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAGhE,OAAO,EACL,iBAAiB,GAElB,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,uBAAuB,GAOxB,MAAM,aAAa,CAAA;AAEpB,SAAS,SAAS,CAAmB,IAAY,EAAE,KAAoB,EAAE,OAAqB;IAC5F,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,SAAS,CAAA;IACpD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAU,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,iBAAiB,CAAC,CAAA;IAC5E,OAAO,KAAU,CAAA;AACnB,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,KAAoB,EAAE,QAAgB,EAAE,OAAe;IACzF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,QAAQ,CAAA;IACnD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAC5B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,OAAO,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,iCAAiC,OAAO,EAAE,CAAC,CAAA;IACpE,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAQ,EAAE,aAA8B;IAC5E,MAAM,KA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K,EAAE;wBACL,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;wBACtB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBAC1E;iBACF,CAAC,CAAA;gBACF,OAAM;YACR,CAAC;YACD,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE;gBAClB,KAAK,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,4CAA4C,EAAE;aACjG,CAAC,CAAA;QACJ,CAAC;gBAAS,CAAC;YACT,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAC3B,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@czj-git/dsh-plugin-hub",
3
- "version": "0.1.0",
4
- "description": "DeepSeek Harness tools for searching and ranking verified plugins from DSH Plugin Hub",
3
+ "version": "0.2.0",
4
+ "description": "DeepSeek Harness Plugin Hub tools and native Settings marketplace",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -14,18 +14,32 @@
14
14
  "types": "./dist/api.d.ts",
15
15
  "default": "./dist/api.js"
16
16
  },
17
+ "./client": {
18
+ "types": "./dist/client/index.d.ts",
19
+ "default": "./dist/client.js"
20
+ },
21
+ "./schemas": {
22
+ "types": "./dist/schemas.d.ts",
23
+ "default": "./dist/schemas.js"
24
+ },
25
+ "./shared": {
26
+ "types": "./dist/shared.d.ts",
27
+ "default": "./dist/shared.js"
28
+ },
17
29
  "./package.json": "./package.json"
18
30
  },
19
31
  "files": [
20
32
  "dist/**/*.js",
33
+ "dist/**/*.js.map",
21
34
  "dist/**/*.d.ts",
35
+ "dist/**/*.d.ts.map",
22
36
  "cordis.patch.yml",
23
37
  "README.md",
24
38
  "README.en.md",
25
39
  "LICENSE"
26
40
  ],
27
41
  "scripts": {
28
- "build": "tsc -p tsconfig.json",
42
+ "build": "tsc -p tsconfig.json && node ./scripts/build-client.mjs",
29
43
  "typecheck": "tsc -p tsconfig.json --noEmit",
30
44
  "test": "tsx --test tests/*.test.ts",
31
45
  "check": "npm run typecheck && npm test && npm run build",
@@ -34,6 +48,14 @@
34
48
  "dsh": {
35
49
  "bundle": {
36
50
  "patch": "./cordis.patch.yml"
51
+ },
52
+ "client": {
53
+ "platform": "web",
54
+ "inject": [
55
+ "@deepseek-ai/dsh-client-runtime",
56
+ "@deepseek-ai/dsh-client-ui-settings",
57
+ "@deepseek-ai/dsh-client-locale"
58
+ ]
37
59
  }
38
60
  },
39
61
  "engines": {
@@ -43,7 +65,8 @@
43
65
  "deepseek-harness",
44
66
  "dsh-plugin",
45
67
  "plugin-search",
46
- "plugin-marketplace"
68
+ "plugin-marketplace",
69
+ "settings-page"
47
70
  ],
48
71
  "license": "MIT",
49
72
  "repository": {
@@ -63,12 +86,34 @@
63
86
  },
64
87
  "peerDependencies": {
65
88
  "@deepseek-ai/cordis": "^4.0.1",
66
- "@deepseek-ai/dsh-tools": ">=0.1.0-rc.7 <0.2.0"
89
+ "@deepseek-ai/dsh-client-locale": ">=0.1.0-rc.7 <0.2.0",
90
+ "@deepseek-ai/dsh-client-runtime": ">=0.1.0-rc.7 <0.2.0",
91
+ "@deepseek-ai/dsh-client-ui-settings": ">=0.1.0-rc.7 <0.2.0",
92
+ "@deepseek-ai/dsh-client-ui-slots": ">=0.1.0-rc.7 <0.2.0",
93
+ "@deepseek-ai/dsh-host-webserver": ">=0.1.0-rc.7 <0.2.0",
94
+ "@deepseek-ai/dsh-tools": ">=0.1.0-rc.7 <0.2.0",
95
+ "react": "^18.2.0"
96
+ },
97
+ "peerDependenciesMeta": {
98
+ "@deepseek-ai/dsh-client-locale": { "optional": true },
99
+ "@deepseek-ai/dsh-client-runtime": { "optional": true },
100
+ "@deepseek-ai/dsh-client-ui-settings": { "optional": true },
101
+ "@deepseek-ai/dsh-client-ui-slots": { "optional": true },
102
+ "@deepseek-ai/dsh-host-webserver": { "optional": true },
103
+ "react": { "optional": true }
67
104
  },
68
105
  "devDependencies": {
69
106
  "@deepseek-ai/cordis": "4.0.1",
107
+ "@deepseek-ai/dsh-client-locale": "0.1.0-rc.7",
108
+ "@deepseek-ai/dsh-client-runtime": "0.1.0-rc.7",
109
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.0-rc.7",
110
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.0-rc.7",
111
+ "@deepseek-ai/dsh-host-webserver": "0.1.0-rc.7",
70
112
  "@deepseek-ai/dsh-tools": "0.1.0-rc.7",
71
113
  "@types/node": "^22.18.0",
114
+ "@types/react": "^18.3.24",
115
+ "esbuild": "^0.25.9",
116
+ "react": "^18.3.1",
72
117
  "tsx": "^4.20.6",
73
118
  "typescript": "^5.9.2"
74
119
  }