@allbluecn/web-app 0.27.33 → 0.27.35

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": "@allbluecn/web-app",
3
- "version": "0.27.33",
3
+ "version": "0.27.35",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "files": [
@@ -112,7 +112,7 @@ export const SDK_GROUPS: SdkGroup[] = [
112
112
  "items": [
113
113
  {
114
114
  "name": "@allbluecn/web-app",
115
- "version": "v0.27.33",
115
+ "version": "v0.27.35",
116
116
  "lastUpdate": "Nov 10, 2026",
117
117
  "source": "apps/web/package.json",
118
118
  "docsUrl": "https://github.com/allbluecn/allblue"
@@ -239,7 +239,7 @@ describe('sandboxExecution/mediaGeneration 下放(2026-11-07,tier oss 直放
239
239
  expect(mockRequireAuth).not.toHaveBeenCalled()
240
240
  })
241
241
 
242
- it('desktop 豁免只针对 sandboxExecution:其它 paid 功能仍走正常门控', async () => {
242
+ it('desktop 豁免不扩及非豁免 paid 功能:largePageSize 仍走正常门控', async () => {
243
243
  vi.stubEnv('DEPLOY_TARGET', 'desktop')
244
244
 
245
245
  await expect(
@@ -248,6 +248,42 @@ describe('sandboxExecution/mediaGeneration 下放(2026-11-07,tier oss 直放
248
248
  })
249
249
  })
250
250
 
251
+ describe('customAgents 桌面豁免(2026-11-10,本地优先:桌面 guest 可建 harnessKind agent)', () => {
252
+ beforeEach(() => {
253
+ vi.clearAllMocks()
254
+ vi.unstubAllEnvs()
255
+ vi.stubEnv('DEPLOY_TARGET', 'web')
256
+ proSvc.billing = null
257
+ proSvc.hostedAi = null
258
+ mockRequireAuth.mockReset()
259
+ mockRequireAuth.mockResolvedValue({ user: { id: 'user-1' } })
260
+ })
261
+
262
+ it('desktop 部署 → customAgents 点式直放(本地 PGlite 存储 + 本地 ACP 执行,guest 可建)', async () => {
263
+ vi.stubEnv('DEPLOY_TARGET', 'desktop')
264
+
265
+ await expect(requireFeature(undefined, 'customAgents')).resolves.toBeUndefined()
266
+ // 与 sandboxExecution 同款:直放在权益解析之前,不查订阅、不需要会话
267
+ expect(mockRequireAuth).not.toHaveBeenCalled()
268
+ })
269
+
270
+ it('web 部署 customAgents 仍走 paid 门控(无权益 → Forbidden)', async () => {
271
+ vi.stubEnv('DEPLOY_TARGET', 'web')
272
+ // web/SaaS 非 desktop:customAgents 是 paid 特性,无权益(plan features 无
273
+ // customAgents)→ FeatureForbiddenError(largePageSize locked 同款口径)
274
+ proSvc.billing = {
275
+ getEffectivePlan: vi.fn().mockResolvedValue({
276
+ planName: 'free',
277
+ features: { customAgents: false },
278
+ }),
279
+ }
280
+
281
+ await expect(
282
+ requireFeature(undefined, 'customAgents'),
283
+ ).rejects.toThrow(FeatureForbiddenError)
284
+ })
285
+ })
286
+
251
287
  describe('mediaGeneration 门控(P4e 任务 2)', () => {
252
288
  beforeEach(() => {
253
289
  vi.clearAllMocks()
@@ -545,6 +545,12 @@ export async function* handleChatRequest(
545
545
  localCwd: cwd,
546
546
  localAgentId: effectiveLocalAgentId,
547
547
  localAgentModel,
548
+ // harnessKind agent 的 persona 随 prompt 文本注入桌面 ACP(ACP 无 system
549
+ // 槽,persona 只能进 prompt turn)。仅 harnessKind 激活时携带——内置 CLI
550
+ // 无 persona,行为不变。
551
+ ...(harnessKindActive && options?.overrides?.agent?.persona
552
+ ? { localSystemPrompt: options.overrides.agent.persona }
553
+ : {}),
548
554
  aiSourceMode: session.user.aiSourceMode ?? null,
549
555
  },
550
556
  request,
@@ -110,6 +110,11 @@ interface BuildChatStreamParams {
110
110
  localAgentId?: string
111
111
  /** 本地模型选择(ACP configOptions 值 / modes id) */
112
112
  localAgentModel?: string
113
+ /**
114
+ * 本地 agent 的 persona(system prompt)。harnessKind agent 经桌面 ACP 执行时
115
+ * 随 prompt 文本注入(ACP 无 system 槽)。仅 harnessKind 激活时由 chat-handler 传入。
116
+ */
117
+ localSystemPrompt?: string
113
118
  }
114
119
 
115
120
  /**
@@ -173,6 +178,10 @@ export async function buildChatStreamWithTools(
173
178
  sessionId: localThreadId,
174
179
  ...(params.localAgentId !== undefined ? { agentId: params.localAgentId } : {}),
175
180
  ...(params.localAgentModel !== undefined ? { agentModel: params.localAgentModel } : {}),
181
+ // harnessKind agent 的 persona:随 prompt 文本注入桌面 ACP(ACP 无 system 槽)。
182
+ ...(params.localSystemPrompt !== undefined
183
+ ? { systemPrompt: params.localSystemPrompt }
184
+ : {}),
176
185
  },
177
186
  // 本地 agent 自带 agent loop:单次 adapter 调用即完整运行,禁止引擎再发起模型轮次
178
187
  agentLoopStrategy: maxIterations(1),
@@ -56,6 +56,11 @@ export interface LocalAgentRunInput {
56
56
  agentId?: string
57
57
  /** ACP 模型选择(configOptions 值 / modes id) */
58
58
  modelId?: string
59
+ /**
60
+ * persona(system prompt)。harnessKind agent 经桌面 ACP 执行时随 prompt 文本
61
+ * 注入(ACP 无 system 槽)。仅 harnessKind agent 携带;内置 CLI 不传(行为不变)。
62
+ */
63
+ systemPrompt?: string
59
64
  signal?: AbortSignal
60
65
  }
61
66
 
@@ -134,7 +139,7 @@ export class LocalAgentAdapter {
134
139
  return
135
140
  }
136
141
 
137
- const modelOptions = options.modelOptions as { cwd?: unknown; agentId?: unknown; agentModel?: unknown } | undefined
142
+ const modelOptions = options.modelOptions as { cwd?: unknown; agentId?: unknown; agentModel?: unknown; systemPrompt?: unknown } | undefined
138
143
  const cwd = typeof modelOptions?.cwd === 'string' ? modelOptions.cwd : ''
139
144
  if (cwd === '') {
140
145
  yield this.errorEvent('本地 Agent 缺少工作目录(cwd)')
@@ -142,6 +147,8 @@ export class LocalAgentAdapter {
142
147
  }
143
148
  const agentId = typeof modelOptions?.agentId === 'string' && modelOptions.agentId !== '' ? modelOptions.agentId : undefined
144
149
  const modelId = typeof modelOptions?.agentModel === 'string' && modelOptions.agentModel !== '' ? modelOptions.agentModel : undefined
150
+ // harnessKind agent 的 persona(system prompt):随 prompt 文本注入桌面 ACP。
151
+ const systemPrompt = typeof modelOptions?.systemPrompt === 'string' && modelOptions.systemPrompt !== '' ? modelOptions.systemPrompt : undefined
145
152
 
146
153
  const prompt = extractLastUserText(options.messages)
147
154
  if (prompt === '') {
@@ -165,6 +172,7 @@ export class LocalAgentAdapter {
165
172
  runId,
166
173
  ...(agentId !== undefined ? { agentId } : {}),
167
174
  ...(modelId !== undefined ? { modelId } : {}),
175
+ ...(systemPrompt !== undefined ? { systemPrompt } : {}),
168
176
  signal: abort.signal,
169
177
  })) {
170
178
  const event = normalizeEvent(raw, this.model, options.threadId, runId)
@@ -86,6 +86,12 @@ export interface UnifiedAiRequest {
86
86
  localAgentId?: string
87
87
  /** 本地模型选择(ACP configOptions 值 / modes id) */
88
88
  localAgentModel?: string
89
+ /**
90
+ * 本地 agent 的 persona(system prompt)。harnessKind agent(带自定义 persona 的
91
+ * UserAgent)经桌面 ACP 通道执行时,persona 随 prompt 文本注入(ACP 无 system 槽)。
92
+ * 仅 harnessKind 激活时由 chat-handler 注入;内置 CLI 不传(行为不变)。
93
+ */
94
+ localSystemPrompt?: string
89
95
  }
90
96
 
91
97
  export type UnifiedAiStream = AsyncIterable<StreamChunk>
@@ -86,11 +86,14 @@ export async function requireFeature(
86
86
  if (meta.tier === 'oss') return
87
87
 
88
88
  // 点式豁免(P3/P4e):沙箱/媒体生成/AI 生成用例为 desktop 用户 BYOK 自担能力(P4c §8.5 承诺,
89
- // testcase 生成编排同款口径),桌面端无订阅体系。仅豁免这三个 key——不引入「desktop 全放行」的机制级旁路。
89
+ // testcase 生成编排同款口径),桌面端无订阅体系。仅豁免这几个 key——不引入「desktop 全放行」的机制级旁路。
90
+ // customAgents(2026-11-10 用户裁决):自定义 agent 存本地 PGlite、经本地 ACP 执行,是桌面本地优先能力,
91
+ // 桌面未登录(guest)也应可建——否则 harnessKind agent(persona 走 ACP)在桌面 guest 下根本建不出来。
90
92
  if (
91
93
  (feature === 'sandboxExecution' ||
92
94
  feature === 'mediaGeneration' ||
93
- feature === 'testGeneration') &&
95
+ feature === 'testGeneration' ||
96
+ feature === 'customAgents') &&
94
97
  isDesktopDeployment()
95
98
  )
96
99
  return