@vibe-forge/core 0.10.0 → 0.10.1

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.10.1",
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/utils": "^0.10.1",
48
+ "@vibe-forge/types": "^0.10.1"
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,15 @@ 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('用户可访问的 server 基础地址,例如 http://192.168.1.10:8787 或 https://example.com/vf;用于生成频道内跳转和 server 动作链接'),
58
+ sessionDetailBaseUrl: z
59
+ .string().optional()
60
+ .describe('用户可访问的会话详情页面基础地址,例如 https://example.com/ui;用于生成频道内跳转到 server 会话详情的链接'),
50
61
  // 访问权限控制
51
62
  access: channelAccessSchema
52
63
  .optional()
@@ -73,8 +84,17 @@ export interface ChannelFollowUp {
73
84
  }>
74
85
  }
75
86
 
87
+ export interface ChannelFileMessage {
88
+ receiveId: string
89
+ receiveIdType: string
90
+ fileName: string
91
+ content: string | Uint8Array
92
+ }
93
+
76
94
  export interface ChannelConnection<TMessage> {
77
95
  sendMessage: (message: TMessage) => Promise<ChannelSendResult | undefined>
96
+ sendFileMessage?: (message: ChannelFileMessage) => Promise<ChannelSendResult | undefined>
97
+ updateMessage?: (messageId: string, message: TMessage) => Promise<ChannelSendResult | undefined>
78
98
  pushFollowUps?: (input: {
79
99
  messageId: string
80
100
  followUps: readonly ChannelFollowUp[]
@@ -126,6 +146,26 @@ export interface ChannelEventHandlers {
126
146
  [event: string]: ChannelEventHandler | ChannelEventHandler<ChannelInboundEvent> | undefined
127
147
  }
128
148
 
149
+ export interface ChannelSessionMcpContext {
150
+ sessionId: string
151
+ channelKey: string
152
+ channelType: string
153
+ channelId: string
154
+ sessionType: string
155
+ replyReceiveId?: string
156
+ replyReceiveIdType?: string
157
+ }
158
+
159
+ export interface ChannelSessionMcpServer {
160
+ name: string
161
+ config: NonNullable<Config['mcpServers']>[string]
162
+ }
163
+
164
+ export type ResolveChannelSessionMcpServersFn<TConfig = unknown> = (
165
+ config: TConfig,
166
+ context: ChannelSessionMcpContext
167
+ ) => Promise<readonly ChannelSessionMcpServer[] | undefined> | readonly ChannelSessionMcpServer[] | undefined
168
+
129
169
  export interface ChannelDescriptor<
130
170
  TConfigSchema extends z.ZodTypeAny = z.ZodTypeAny,
131
171
  TMessageSchema extends z.ZodTypeAny = z.ZodTypeAny,
@@ -153,3 +193,7 @@ export type ChannelCreateFn<TConfig = unknown, TMessage = unknown> = (
153
193
  export const defineCreateChannelConnection = <TConfigSchema extends z.ZodTypeAny, TMessageSchema extends z.ZodTypeAny>(
154
194
  connect: ChannelCreateFn<z.infer<TConfigSchema>, z.infer<TMessageSchema>>
155
195
  ): ChannelCreateFn<z.infer<TConfigSchema>, z.infer<TMessageSchema>> => connect
196
+
197
+ export const defineResolveChannelSessionMcpServers = <TConfig = unknown>(
198
+ resolve: ResolveChannelSessionMcpServersFn<TConfig>
199
+ ): 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',