@moonan_ai/sdk 0.0.5-alpha1 → 0.0.5-alpha2

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
@@ -59,20 +59,30 @@ export default defineFacet((api) => {
59
59
  ## 约定
60
60
 
61
61
  - 契约在两端**各写一份**:Chord 认指纹(名字、版本、成员、类型住在哪个宿主),不认模块实例。
62
- - 注册表贡献(`Routes`、`Panels`、`DataCodecs`、`ModelProviders`)必须来自 `{ lifetime: "host" }` 的对象。
63
- - 需要统一导出/导入的数据放 `DataStore`,并注册 `DataCodecs`;需要给其他插件用模型时注册 `ModelProviders`。
62
+ - 注册表贡献(`Routes`、`Panels`、`DataCodecs`)必须来自 `{ lifetime: "host" }` 的对象。
63
+ - 功能专属注册表由对应的插件包定义,例如 ai-gateway 的 `ModelProviders`;SDK 只提供通用的 `defineRegistry`。
64
+ - 需要统一导出/导入的数据放 `DataStore`,并注册 `DataCodecs`;功能能力(如模型)由对应插件包自己定义注册表。
64
65
  - 服务端宿主名固定为 `"moonan"`;写别的名字,`api.serve` 会当场拒绝。
65
66
  - 浏览器切面是**单个 ESM 文件**:浏览器没有模块 hook,重载只换入口。
66
67
 
67
- ## 统一数据与模型
68
+ ## 统一数据
68
69
 
69
70
  ```js
70
- import { DataCodecs, DataStore, ModelProviders } from "@moonan_ai/sdk";
71
+ import { DataCodecs, DataStore } from "@moonan_ai/sdk";
71
72
  ```
72
73
 
73
74
  - `DataStore` 是平台唯一的统一数据文件(local、host-lifetime);`read` 返回 `{ value, version }`,`update` 是串行读改写,`exportAll`/`importAll` 由平台 HTTP 表面调用。
74
75
  - `DataCodecs` 是插件贡献的导出/导入 codec 注册表;没有 codec 的 namespace 不会进入统一导出。
75
- - `ModelProviders` 是服务端模型提供商注册表;`list()` 是 key-free 目录,`runtime()` 是 server-only 运行时,不能给浏览器。
76
+
77
+ ## 功能注册表
78
+
79
+ 功能专属的注册表不属于 SDK。例如模型能力由 ai-gateway 自己定义并导出:
80
+
81
+ ```js
82
+ import { ModelProviders } from "@moonan_ai/ai-gateway/model-provider";
83
+ ```
84
+
85
+ 消费方按 id 查找,平台和 SDK 不需要认识 `ModelInfo`。后续的图像、语音等能力也应各自定义自己的注册表。
76
86
 
77
87
  完整写法:<https://github.com/Pheobe-Southwood/Moonan/blob/main/docs/plugins.md> ·
78
88
  词汇表:<https://github.com/Pheobe-Southwood/Moonan/blob/main/CONTEXT.md>
package/dist/index.js CHANGED
@@ -2,14 +2,12 @@
2
2
  * `@moonan_ai/sdk` — everything a plugin needs on either side of the wire.
3
3
  *
4
4
  * The root entry is shared by the server facet and the browser facet: contracts,
5
- * registries (including `DataCodecs` and `ModelProviders`) and the Chord primitives they
6
- * are built from. Browser-only surface (the `Panels` registry and the React hooks) lives
5
+ * registries (including `DataCodecs`) and the Chord primitives they are built from. Browser-only surface (the `Panels` registry and the React hooks) lives
7
6
  * in `@moonan_ai/sdk/web`, because it needs React and the root entry must stay importable
8
7
  * from a Node facet.
9
8
  */
10
9
  export { WebFacetCatalog, FacetSetSchema, WebFacetSchema, } from "./web-facet-catalog.js";
11
10
  export { DataStore, DataCodecs, DataBundleSchema, DataImportReportSchema, DataStoreStorageInfoSchema, StoredDatasetSchema, defineDataset, } from "./data.js";
12
- export { ModelProviders, } from "./model-provider.js";
13
11
  export { Routes } from "./routes.js";
14
12
  /** Chord primitives, re-exported so a plugin needs two dependencies instead of three. */
15
13
  export { ChordError, defineFacet, defineRegistry, forbidden, hostFamily, hostNamed, invalid, isChordError, local, method, opaque, remote, } from "@earendil-works/chord";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACN,eAAe,EACf,cAAc,EACd,cAAc,GAGd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,sBAAsB,EACtB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,GAOb,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,GAGd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AAExD,yFAAyF;AACzF,OAAO,EACN,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EACT,OAAO,EACP,YAAY,EACZ,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,GAiBN,MAAM,uBAAuB,CAAC;AAE/B,uFAAuF;AACvF,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,eAAe,EACf,UAAU,EACV,kBAAkB,GAElB,MAAM,+BAA+B,CAAC;AAEvC,yDAAyD;AACzD,OAAO,EAAE,IAAI,EAA6B,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACN,eAAe,EACf,cAAc,EACd,cAAc,GAGd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,sBAAsB,EACtB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,GAOb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AAExD,yFAAyF;AACzF,OAAO,EACN,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EACT,OAAO,EACP,YAAY,EACZ,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,GAiBN,MAAM,uBAAuB,CAAC;AAE/B,uFAAuF;AACvF,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,eAAe,EACf,UAAU,EACV,kBAAkB,GAElB,MAAM,+BAA+B,CAAC;AAEvC,yDAAyD;AACzD,OAAO,EAAE,IAAI,EAA6B,MAAM,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moonan_ai/sdk",
3
- "version": "0.0.5-alpha1",
3
+ "version": "0.0.5-alpha2",
4
4
  "description": "Moonan plugin SDK: contracts, registries and browser hooks for plugin authors.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -2,8 +2,7 @@
2
2
  * `@moonan_ai/sdk` — everything a plugin needs on either side of the wire.
3
3
  *
4
4
  * The root entry is shared by the server facet and the browser facet: contracts,
5
- * registries (including `DataCodecs` and `ModelProviders`) and the Chord primitives they
6
- * are built from. Browser-only surface (the `Panels` registry and the React hooks) lives
5
+ * registries (including `DataCodecs`) and the Chord primitives they are built from. Browser-only surface (the `Panels` registry and the React hooks) lives
7
6
  * in `@moonan_ai/sdk/web`, because it needs React and the root entry must stay importable
8
7
  * from a Node facet.
9
8
  */
@@ -29,11 +28,6 @@ export {
29
28
  type DatasetExportOptions,
30
29
  type StoredDataset,
31
30
  } from "./data.js";
32
- export {
33
- ModelProviders,
34
- type ModelInfo,
35
- type ModelProvider,
36
- } from "./model-provider.js";
37
31
  export { Routes, type RouteHandler } from "./routes.js";
38
32
 
39
33
  /** Chord primitives, re-exported so a plugin needs two dependencies instead of three. */
@@ -1,5 +0,0 @@
1
- import { defineRegistry } from "@earendil-works/chord";
2
- export const ModelProviders = defineRegistry("moonan.model-providers", {
3
- conflict: "error",
4
- });
5
- //# sourceMappingURL=model-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model-provider.js","sourceRoot":"","sources":["../src/model-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA0CvD,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAgB,wBAAwB,EAAE;IACrF,QAAQ,EAAE,OAAO;CACjB,CAAC,CAAC"}
@@ -1,45 +0,0 @@
1
- import { defineRegistry } from "@earendil-works/chord";
2
-
3
- /**
4
- * Provider-neutral metadata for one configured chat model.
5
- *
6
- * This is plain JSON: the registry value never crosses a link, but keeping the catalog
7
- * serializable lets a plugin expose it over HTTP or in a panel without a second shape.
8
- */
9
- export interface ModelInfo {
10
- readonly providerId: string;
11
- readonly modelId: string;
12
- readonly name: string;
13
- readonly contextWindow?: number;
14
- readonly maxTokens?: number;
15
- readonly input: readonly ("text" | "image")[];
16
- readonly reasoning: boolean;
17
- }
18
-
19
- /**
20
- * A model provider contribution.
21
- *
22
- * `list()` is the key-free catalog. `runtime()` is a server-only handle whose concrete
23
- * shape belongs to the provider package; ai-gateway returns its pi-ai `MutableModels`
24
- * there. The SDK stays free of pi-ai so a generic plugin does not inherit an AI dependency.
25
- *
26
- * A consumer looks the provider up with the code version of its root:
27
- *
28
- * ```ts
29
- * const providers = api.registry(ModelProviders);
30
- * const provider = providers.get("ai-gateway", ctx);
31
- * ```
32
- *
33
- * The registry value is not a Chord contract: there is no `uses` entry and no wire
34
- * compatibility rule. Its table is replaced with each code version like every registry.
35
- */
36
- export interface ModelProvider {
37
- readonly id: string;
38
- readonly title: string;
39
- list(): readonly ModelInfo[];
40
- runtime(): unknown;
41
- }
42
-
43
- export const ModelProviders = defineRegistry<ModelProvider>("moonan.model-providers", {
44
- conflict: "error",
45
- });