@workopilot/pluginapi-sdk 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -46,6 +46,13 @@ Register exported handlers in the plugin manifest:
46
46
 
47
47
  ## Provided Types
48
48
 
49
+ ### Platform Service URL
50
+
51
+ Hosts configure `PLATFORM_SERVICE_URL` as an HTTP(S) origin without `/net-api`
52
+ (for example `https://agent.workopilot.com`). HTTP and MCP handlers receive the
53
+ normalized origin through `ctx.platformServiceUrl`. It contains no database
54
+ credentials. `readPlatformServiceUrl(value)` validates and normalizes this setting.
55
+
49
56
  ### Plugin Handler
50
57
 
51
58
  ```ts
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export type PluginRouteMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
2
+ /** Normalize a configured platform origin before forwarding authentication headers. */
3
+ export declare function readPlatformServiceUrl(value: string | undefined): string;
2
4
  export interface PluginManifest {
3
5
  name: string;
4
6
  version: string;
@@ -50,6 +52,8 @@ export interface PluginRequest {
50
52
  headers: Record<string, string | string[] | undefined>;
51
53
  }
52
54
  export interface PluginContext {
55
+ /** 智能体平台服务域名,由宿主配置并注入,不包含 /net-api。 */
56
+ platformServiceUrl: string;
53
57
  database: DatabaseCapability;
54
58
  logger: PluginLogger;
55
59
  currentUser: CurrentUser;
package/dist/index.js CHANGED
@@ -1 +1,11 @@
1
- export {};
1
+ /** Normalize a configured platform origin before forwarding authentication headers. */
2
+ export function readPlatformServiceUrl(value) {
3
+ if (!value?.trim())
4
+ throw new Error('Missing required environment variable: PLATFORM_SERVICE_URL');
5
+ const url = new URL(value.trim());
6
+ if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password ||
7
+ url.pathname !== '/' || url.search || url.hash) {
8
+ throw new Error('PLATFORM_SERVICE_URL must be an HTTP(S) origin without credentials, path, query or fragment.');
9
+ }
10
+ return url.origin;
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workopilot/pluginapi-sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Workopilot plugin API SDK for database-capability plugins",
5
5
  "keywords": [
6
6
  "wiseai",