@vibe-forge/core 0.10.0 → 0.11.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-forge/core",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "imports": {
5
5
  "#~/*.js": {
6
6
  "__vibe-forge__": {
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "zod": "^3.24.1",
47
- "@vibe-forge/types": "^0.10.0",
48
- "@vibe-forge/utils": "^0.10.0"
47
+ "@vibe-forge/types": "^0.11.0",
48
+ "@vibe-forge/utils": "^0.11.0"
49
49
  }
50
50
  }
package/src/channel.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { z } from 'zod'
2
2
 
3
+ import type { Config } from '@vibe-forge/types'
4
+
3
5
  export interface ChannelMap {}
4
6
 
5
7
  export type ChannelType = keyof ChannelMap
@@ -47,6 +49,19 @@ export const channelBaseSchema = z.object({
47
49
  language: z
48
50
  .enum(['zh', 'en']).optional()
49
51
  .describe('频道提示语言,默认 zh'),
52
+ enableSessionMcp: z
53
+ .boolean().optional()
54
+ .describe('是否在通过该频道启动的会话中自动挂载该频道提供的 companion MCP,默认 true'),
55
+ serverBaseUrl: z
56
+ .string().optional()
57
+ .describe(
58
+ '用户可访问的 server 基础地址,例如 http://192.168.1.10:8787 或 https://example.com/vf;用于生成频道内跳转和 server 动作链接'
59
+ ),
60
+ sessionDetailBaseUrl: z
61
+ .string().optional()
62
+ .describe(
63
+ '用户可访问的会话详情页面基础地址,例如 https://example.com/ui;用于生成频道内跳转到 server 会话详情的链接'
64
+ ),
50
65
  // 访问权限控制
51
66
  access: channelAccessSchema
52
67
  .optional()
@@ -73,8 +88,17 @@ export interface ChannelFollowUp {
73
88
  }>
74
89
  }
75
90
 
91
+ export interface ChannelFileMessage {
92
+ receiveId: string
93
+ receiveIdType: string
94
+ fileName: string
95
+ content: string | Uint8Array
96
+ }
97
+
76
98
  export interface ChannelConnection<TMessage> {
77
99
  sendMessage: (message: TMessage) => Promise<ChannelSendResult | undefined>
100
+ sendFileMessage?: (message: ChannelFileMessage) => Promise<ChannelSendResult | undefined>
101
+ updateMessage?: (messageId: string, message: TMessage) => Promise<ChannelSendResult | undefined>
78
102
  pushFollowUps?: (input: {
79
103
  messageId: string
80
104
  followUps: readonly ChannelFollowUp[]
@@ -126,6 +150,26 @@ export interface ChannelEventHandlers {
126
150
  [event: string]: ChannelEventHandler | ChannelEventHandler<ChannelInboundEvent> | undefined
127
151
  }
128
152
 
153
+ export interface ChannelSessionMcpContext {
154
+ sessionId: string
155
+ channelKey: string
156
+ channelType: string
157
+ channelId: string
158
+ sessionType: string
159
+ replyReceiveId?: string
160
+ replyReceiveIdType?: string
161
+ }
162
+
163
+ export interface ChannelSessionMcpServer {
164
+ name: string
165
+ config: NonNullable<Config['mcpServers']>[string]
166
+ }
167
+
168
+ export type ResolveChannelSessionMcpServersFn<TConfig = unknown> = (
169
+ config: TConfig,
170
+ context: ChannelSessionMcpContext
171
+ ) => Promise<readonly ChannelSessionMcpServer[] | undefined> | readonly ChannelSessionMcpServer[] | undefined
172
+
129
173
  export interface ChannelDescriptor<
130
174
  TConfigSchema extends z.ZodTypeAny = z.ZodTypeAny,
131
175
  TMessageSchema extends z.ZodTypeAny = z.ZodTypeAny,
@@ -153,3 +197,7 @@ export type ChannelCreateFn<TConfig = unknown, TMessage = unknown> = (
153
197
  export const defineCreateChannelConnection = <TConfigSchema extends z.ZodTypeAny, TMessageSchema extends z.ZodTypeAny>(
154
198
  connect: ChannelCreateFn<z.infer<TConfigSchema>, z.infer<TMessageSchema>>
155
199
  ): ChannelCreateFn<z.infer<TConfigSchema>, z.infer<TMessageSchema>> => connect
200
+
201
+ export const defineResolveChannelSessionMcpServers = <TConfig = unknown>(
202
+ resolve: ResolveChannelSessionMcpServersFn<TConfig>
203
+ ): ResolveChannelSessionMcpServersFn<TConfig> => resolve
package/src/env.ts CHANGED
@@ -10,6 +10,8 @@ export interface ServerEnv {
10
10
  __VF_PROJECT_AI_SERVER_HOST__: string
11
11
  __VF_PROJECT_AI_SERVER_PORT__: number
12
12
  __VF_PROJECT_AI_SERVER_WS_PATH__: string
13
+ __VF_PROJECT_AI_PUBLIC_BASE_URL__?: string
14
+ __VF_PROJECT_AI_SERVER_ACTION_SECRET__?: string
13
15
  __VF_PROJECT_AI_SERVER_DATA_DIR__: string
14
16
  __VF_PROJECT_AI_SERVER_LOG_DIR__: string
15
17
  __VF_PROJECT_AI_SERVER_LOG_LEVEL__: LogLevel
@@ -25,6 +27,8 @@ export function loadEnv(): ServerEnv {
25
27
  __VF_PROJECT_AI_SERVER_HOST__ = 'localhost',
26
28
  __VF_PROJECT_AI_SERVER_PORT__ = '8787',
27
29
  __VF_PROJECT_AI_SERVER_WS_PATH__ = '/ws',
30
+ __VF_PROJECT_AI_PUBLIC_BASE_URL__,
31
+ __VF_PROJECT_AI_SERVER_ACTION_SECRET__,
28
32
  __VF_PROJECT_AI_SERVER_DATA_DIR__ = '.data',
29
33
  __VF_PROJECT_AI_SERVER_LOG_DIR__ = '.logs',
30
34
  __VF_PROJECT_AI_SERVER_LOG_LEVEL__ = 'info',
@@ -38,6 +42,8 @@ export function loadEnv(): ServerEnv {
38
42
  __VF_PROJECT_AI_SERVER_HOST__,
39
43
  __VF_PROJECT_AI_SERVER_PORT__: Number(__VF_PROJECT_AI_SERVER_PORT__),
40
44
  __VF_PROJECT_AI_SERVER_WS_PATH__,
45
+ __VF_PROJECT_AI_PUBLIC_BASE_URL__,
46
+ __VF_PROJECT_AI_SERVER_ACTION_SECRET__,
41
47
  __VF_PROJECT_AI_SERVER_DATA_DIR__,
42
48
  __VF_PROJECT_AI_SERVER_LOG_DIR__,
43
49
  __VF_PROJECT_AI_SERVER_LOG_LEVEL__: normalizeLogLevel(__VF_PROJECT_AI_SERVER_LOG_LEVEL__) ?? 'info',