@zhin.js/mcp-feature 1.1.3 → 1.1.5

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
@@ -57,3 +57,14 @@ MCP 候选连接不会触碰旧 client。旧 turn 继续通过旧 projection 与
57
57
  pnpm --filter @zhin.js/mcp-feature test
58
58
  pnpm --filter @zhin.js/mcp-feature build
59
59
  ```
60
+
61
+
62
+ ### Transport 创建上下文
63
+
64
+ `create(context)` 只提供 `owner`、`config`、`generation`、`signal` 和 `use(token)`;
65
+ Adapter 还提供端点的 `id`、`endpointId` 和 `name`。这些值属于 owner 的创建生命周期,
66
+ 不是每次消息或工具调用的 operation snapshot。未改 owner 的连接可跨局部热重载保留。
67
+
68
+ 创建上下文不提供 `project()`,类型和实际对象都如此;JavaScript 强行调用会抛出
69
+ `TypeError`,不会悄悄读取旧代投影。需要跨 Feature 的业务执行放在 command、handler、
70
+ middleware 或 tool 中,通过它们当前 operation 的上下文解析。
@@ -1,4 +1,4 @@
1
- import type { CapabilityContext } from '@zhin.js/feature-kit';
1
+ import type { ConstructionContext } from '@zhin.js/feature-kit';
2
2
  declare const mcpBrand: "zhin.mcp/1";
3
3
  export interface McpToolDescriptor {
4
4
  readonly name: string;
@@ -14,7 +14,7 @@ export interface McpClientInstance {
14
14
  export interface McpDefinition<TConfig = unknown> {
15
15
  readonly $feature: typeof mcpBrand;
16
16
  readonly description?: string;
17
- create(context: CapabilityContext<TConfig>): McpClientInstance | Promise<McpClientInstance>;
17
+ create(context: ConstructionContext<TConfig>): McpClientInstance | Promise<McpClientInstance>;
18
18
  }
19
19
  declare module '@zhin.js/plugin-runtime' {
20
20
  interface PluginSetupContext<TConfig = unknown> {
package/lib/mcp-index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DisposeStack, } from '@zhin.js/plugin-runtime';
2
- import { OwnerCapabilityIndex, createCapabilityContext, } from '@zhin.js/feature-kit';
2
+ import { OwnerCapabilityIndex, createConstructionContext, } from '@zhin.js/feature-kit';
3
3
  import { assertMcpClient, } from './definition.js';
4
4
  export class McpIndex {
5
5
  $projection = 'zhin.mcp-index/1';
@@ -18,7 +18,7 @@ export class McpIndex {
18
18
  try {
19
19
  for (const entry of index.entries()) {
20
20
  signal.throwIfAborted();
21
- const client = await entry.slot.definition.create(createCapabilityContext(snapshot, entry.owner, undefined, signal));
21
+ const client = await entry.slot.definition.create(createConstructionContext(snapshot, entry.owner, undefined, signal));
22
22
  signal.throwIfAborted();
23
23
  assertMcpClient(client, entry.source);
24
24
  records.push({ entry, client, started: false, stopped: false });
package/lib/provider.js CHANGED
@@ -15,6 +15,7 @@ const mcpFeature = defineFeatureProvider({
15
15
  validate: parseMcpDefinition,
16
16
  },
17
17
  runtime: {
18
+ retain: 'when-owner-unchanged',
18
19
  async project(slots, context) {
19
20
  const index = await McpIndex.create(slots, context.snapshot, context.signal);
20
21
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/mcp-feature",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "Convention-based MCP client Feature for Zhin Plugin Runtime",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -17,8 +17,8 @@
17
17
  "src"
18
18
  ],
19
19
  "dependencies": {
20
- "@zhin.js/feature-kit": "1.1.2",
21
- "@zhin.js/plugin-runtime": "1.1.11"
20
+ "@zhin.js/feature-kit": "1.1.4",
21
+ "@zhin.js/plugin-runtime": "1.1.13"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^26.1.2",
package/src/definition.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CapabilityContext } from '@zhin.js/feature-kit';
1
+ import type { ConstructionContext } from '@zhin.js/feature-kit';
2
2
 
3
3
  const mcpBrand = 'zhin.mcp/1' as const;
4
4
 
@@ -18,7 +18,7 @@ export interface McpClientInstance {
18
18
  export interface McpDefinition<TConfig = unknown> {
19
19
  readonly $feature: typeof mcpBrand;
20
20
  readonly description?: string;
21
- create(context: CapabilityContext<TConfig>): McpClientInstance | Promise<McpClientInstance>;
21
+ create(context: ConstructionContext<TConfig>): McpClientInstance | Promise<McpClientInstance>;
22
22
  }
23
23
 
24
24
  declare module '@zhin.js/plugin-runtime' {
package/src/mcp-index.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  } from '@zhin.js/plugin-runtime';
7
7
  import {
8
8
  OwnerCapabilityIndex,
9
- createCapabilityContext,
9
+ createConstructionContext,
10
10
  type OwnerCapabilityEntry,
11
11
  } from '@zhin.js/feature-kit';
12
12
  import {
@@ -57,7 +57,7 @@ export class McpIndex {
57
57
  for (const entry of index.entries()) {
58
58
  signal.throwIfAborted();
59
59
  const client = await entry.slot.definition.create(
60
- createCapabilityContext(snapshot, entry.owner, undefined, signal),
60
+ createConstructionContext(snapshot, entry.owner, undefined, signal),
61
61
  );
62
62
  signal.throwIfAborted();
63
63
  assertMcpClient(client, entry.source);
package/src/provider.ts CHANGED
@@ -17,6 +17,7 @@ const mcpFeature = defineFeatureProvider({
17
17
  validate: parseMcpDefinition,
18
18
  },
19
19
  runtime: {
20
+ retain: 'when-owner-unchanged',
20
21
  async project(slots, context) {
21
22
  const index = await McpIndex.create(slots, context.snapshot, context.signal);
22
23
  return {