@allbluecn/web-app 0.28.11 → 0.28.13
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 +5 -5
- package/public/dev-gallery.html +19 -0
- package/src/__tests__/bench/baselines/format-timestamp.json +44 -0
- package/src/__typeprobe__.d.ts +4 -0
- package/src/components/harness/extension-panel/panels/terminal/__tests__/terminal-instance.test.tsx +93 -4
- package/src/components/harness/extension-panel/panels/terminal/sse-transport.ts +28 -5
- package/src/components/harness/extension-panel/panels/terminal/terminal-instance.tsx +53 -10
- package/src/components/harness/extension-panel/panels/terminal/transport.ts +10 -3
- package/src/components/harness/extension-panel/panels/terminal/ws-transport.ts +13 -2
- package/src/components/settings/harness/connectors-card.tsx +5 -0
- package/src/components/story/detail/story-detail-toolbar/associated-attachments-panel.tsx +2 -1
- package/src/dev/gallery-entry.tsx +38 -0
- package/src/dev/gallery.tsx +610 -0
- package/src/lib/changelog/sdk-versions.ts +4 -4
- package/src/lib/session.ts +10 -0
- package/src/paraglide/README.md +1 -1
- package/src/paraglide/messages/_index.d.ts +9 -0
- package/src/paraglide/messages/_index.js +9 -0
- package/src/paraglide/messages/capabilities_webhook.d.ts +16 -0
- package/src/paraglide/messages/capabilities_webhook.js +29 -0
- package/src/paraglide/messages/capabilities_workflow.d.ts +16 -0
- package/src/paraglide/messages/capabilities_workflow.js +29 -0
- package/src/paraglide/messages/harness_panel_terminal_exitedrecycled1.d.ts +17 -0
- package/src/paraglide/messages/harness_panel_terminal_exitedrecycled1.js +30 -0
- package/src/paraglide/messages/harness_panel_terminal_restarted.d.ts +16 -0
- package/src/paraglide/messages/harness_panel_terminal_restarted.js +29 -0
- package/src/paraglide/messages/settings_harness_connectors_needsauth1.d.ts +17 -0
- package/src/paraglide/messages/settings_harness_connectors_needsauth1.js +30 -0
- package/src/paraglide/messages/settings_harness_ralphenabled1.d.ts +17 -0
- package/src/paraglide/messages/settings_harness_ralphenabled1.js +30 -0
- package/src/paraglide/messages/settings_harness_ralphenabled_description1.d.ts +17 -0
- package/src/paraglide/messages/settings_harness_ralphenabled_description1.js +30 -0
- package/src/paraglide/messages/settings_harness_ralphmaxrounds2.d.ts +17 -0
- package/src/paraglide/messages/settings_harness_ralphmaxrounds2.js +30 -0
- package/src/paraglide/messages/settings_harness_ralphmaxrounds_description2.d.ts +17 -0
- package/src/paraglide/messages/settings_harness_ralphmaxrounds_description2.js +30 -0
- package/src/routeTree.gen.ts +21 -0
- package/src/routes/api/auth/desktop-callback.ts +9 -0
- package/src/routes/api/chat.ts +8 -1
- package/src/routes/api/harness/browser/proxy.ts +41 -12
- package/src/routes/api/harness/terminal/$.ts +32 -13
- package/src/routes/api/harness/terminal/__tests__/route.test.ts +41 -0
- package/src/routes/api/harness/webhook/$token.ts +23 -0
- package/src/routes/api/sync/__tests__/bootstrap.test.ts +32 -1
- package/src/routes/api/sync/bootstrap.ts +11 -0
- package/src/server/ai-gateway/adapter.ts +7 -3
- package/src/server/ai-gateway/connectivity-check.ts +3 -2
- package/src/server/ai-gateway/durability/__tests__/sse-resume-frames.test.ts +123 -0
- package/src/server/ai-gateway/embedding.ts +3 -2
- package/src/server/ai-gateway/model-fetch.ts +3 -2
- package/src/server/ai-gateway/sandbox/__tests__/provider.test.ts +12 -1
- package/src/server/ai-gateway/sandbox/policy.ts +27 -1
- package/src/server/ai-gateway/sandbox/provider.ts +10 -0
- package/src/server/ai-gateway/tools/definitions.ts +1 -1
- package/src/server/ai-gateway/tools/server.ts +4 -2
- package/src/server/harness/__tests__/agent-terminal-sandbox.test.ts +23 -4
- package/src/server/harness/__tests__/agent-terminal.server.test.ts +118 -2
- package/src/server/harness/__tests__/credentials.server.test.ts +25 -2
- package/src/server/harness/__tests__/host-schedule-worker.test.ts +43 -0
- package/src/server/harness/__tests__/runtime-without-providers.test.ts +11 -0
- package/src/server/harness/__tests__/sticky-route.test.ts +86 -0
- package/src/server/harness/__tests__/terminal-foreground.server.test.ts +80 -0
- package/src/server/harness/__tests__/terminal-manager.server.test.ts +75 -1
- package/src/server/harness/__tests__/tool-entitlements.test.ts +6 -2
- package/src/server/harness/agent-terminal.server.ts +25 -4
- package/src/server/harness/agents/__tests__/agent-control.test.ts +1 -0
- package/src/server/harness/agents/run-view.server.ts +55 -2
- package/src/server/harness/capabilities/__tests__/__snapshots__/matrix.test.ts.snap +92 -0
- package/src/server/harness/capabilities/__tests__/execution-plane-denials.test.ts +3 -1
- package/src/server/harness/capabilities/__tests__/p3-matrix.test.ts +3 -3
- package/src/server/harness/capabilities/__tests__/p5-matrix.test.ts +293 -0
- package/src/server/harness/capabilities/__tests__/validate.test.ts +8 -2
- package/src/server/harness/capabilities/execution-plane-denials.ts +9 -3
- package/src/server/harness/capabilities/manifests/agent-terminal.ts +3 -2
- package/src/server/harness/capabilities/manifests/webhook.ts +45 -0
- package/src/server/harness/capabilities/manifests/workflow.ts +40 -0
- package/src/server/harness/capabilities/registry.ts +4 -0
- package/src/server/harness/connectors/__tests__/connector-accounts.test.ts +22 -1
- package/src/server/harness/connectors/connector-accounts.server.ts +7 -0
- package/src/server/harness/credentials.server.ts +3 -1
- package/src/server/harness/define.server.ts +11 -0
- package/src/server/harness/mcp/mcp-config.server.ts +3 -1
- package/src/server/harness/outbox/outbox-dispatcher.server.ts +9 -0
- package/src/server/harness/outbox/outbox-store.server.ts +7 -0
- package/src/server/harness/persistence/__tests__/log-store.server.test.ts +4 -1
- package/src/server/harness/plugins/__tests__/tool-risk-audit.test.ts +5 -1
- package/src/server/harness/plugins/builtin/agent-terminal.plugin.ts +12 -2
- package/src/server/harness/providers/contracts.ts +16 -0
- package/src/server/harness/schedule/schedule-dispatcher.server.ts +3 -0
- package/src/server/harness/search/__tests__/indexer.test.ts +4 -1
- package/src/server/harness/search/__tests__/lifecycle.test.ts +4 -1
- package/src/server/harness/search/__tests__/search.test.ts +4 -1
- package/src/server/harness/sticky-route.server.ts +72 -0
- package/src/server/harness/terminal-foreground.server.ts +90 -0
- package/src/server/harness/terminal-manager.server.ts +78 -3
- package/src/server/harness/tool-entitlements.server.ts +5 -0
- package/src/server/harness/webhook/__tests__/body.test.ts +73 -0
- package/src/server/harness/webhook/__tests__/payload.test.ts +215 -0
- package/src/server/harness/webhook/__tests__/signature.test.ts +170 -0
- package/src/server/harness/webhook/__tests__/webhook-dispatcher.test.ts +212 -0
- package/src/server/harness/webhook/__tests__/webhook.plugin.test.ts +195 -0
- package/src/server/harness/webhook/__tests__/webhook.service.test.ts +354 -0
- package/src/server/harness/webhook/body.server.ts +56 -0
- package/src/server/harness/webhook/payload.server.ts +169 -0
- package/src/server/harness/webhook/signature.server.ts +118 -0
- package/src/server/harness/webhook/types.ts +57 -0
- package/src/server/harness/webhook/webhook-dispatcher.server.ts +495 -0
- package/src/server/harness/webhook/webhook-store.server.ts +115 -0
- package/src/server/harness/webhook/webhook.plugin.ts +273 -0
- package/src/server/harness/webhook/webhook.service.server.ts +577 -0
- package/src/server/harness/worker/__tests__/worker-http.test.ts +8 -1
- package/src/server/harness/worker/worker-health.server.ts +4 -1
- package/src/server/harness/worker/worker-runtime.server.ts +43 -1
- package/src/server/harness/workflow/__tests__/engine.test.ts +195 -0
- package/src/server/harness/workflow/__tests__/settings.test.ts +125 -0
- package/src/server/harness/workflow/__tests__/validate.test.ts +151 -0
- package/src/server/harness/workflow/engine.server.ts +155 -0
- package/src/server/harness/workflow/settings.ts +84 -0
- package/src/server/harness/workflow/store.server.ts +147 -0
- package/src/server/harness/workflow/types.ts +80 -0
- package/src/server/harness/workflow/validate.ts +130 -0
- package/src/server/harness/workflow/workflow.plugin.ts +261 -0
- package/src/server/knowledge/search-scope.ts +8 -1
- package/src/server/middlewares/security-headers.ts +1 -0
- package/src/server/serverFns/__tests__/link-preview.test.ts +2 -2
- package/src/server/serverFns/collab.ts +4 -0
- package/src/server/serverFns/design/versions.ts +6 -0
- package/src/server/serverFns/harness/__tests__/fork-thread.test.ts +14 -1
- package/src/server/serverFns/harness/fork-thread.ts +17 -0
- package/src/server/serverFns/story/link-preview.ts +3 -2
- package/src/server-entry.ts +13 -1
- package/src/start.ts +15 -1
- package/vite.shared.ts +0 -13
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
type SpawnHelperProbe,
|
|
32
32
|
type TerminalFrame,
|
|
33
33
|
} from '../terminal-manager.server'
|
|
34
|
+
import type { ForegroundProber } from '../terminal-foreground.server'
|
|
34
35
|
|
|
35
36
|
/** fake IPty:记录 write/resize/kill 调用,暴露 onData/onExit 监听器供测试触发。 */
|
|
36
37
|
function makeFakePty() {
|
|
@@ -86,7 +87,13 @@ function makeFakePty() {
|
|
|
86
87
|
type FakeRegistry = ReturnType<typeof makeFakePty>
|
|
87
88
|
|
|
88
89
|
/** 注入 fake spawn 的 manager 工厂:每次 create 产出一个新 fake pty 并登记。 */
|
|
89
|
-
function makeManager(opts: {
|
|
90
|
+
function makeManager(opts: {
|
|
91
|
+
now?: () => number
|
|
92
|
+
pollIntervalMs?: number
|
|
93
|
+
idleKillMs?: number
|
|
94
|
+
ringMaxBytes?: number
|
|
95
|
+
probeForeground?: ForegroundProber
|
|
96
|
+
} = {}) {
|
|
90
97
|
const spawned: FakeRegistry[] = []
|
|
91
98
|
// spawnPty 签名:(file, args, options) => Promise<IPty>(真实现动态 import node-pty 后
|
|
92
99
|
// 调其 spawn)。fake 保持同语义——调用即登记新 fake 并 resolve 其 pty。
|
|
@@ -100,6 +107,8 @@ function makeManager(opts: { now?: () => number; pollIntervalMs?: number; idleKi
|
|
|
100
107
|
const manager = createTerminalManager({
|
|
101
108
|
...opts,
|
|
102
109
|
spawnPty: fakeSpawn,
|
|
110
|
+
// 默认探测替身(P5 任务 4):不碰真实进程表;需要前台组的用例显式注入。
|
|
111
|
+
probeForeground: opts.probeForeground ?? (async () => ({ kind: 'unknown' as const })),
|
|
103
112
|
})
|
|
104
113
|
return { manager, spawned }
|
|
105
114
|
}
|
|
@@ -522,6 +531,71 @@ describe('terminal-manager(真 PTY 后端,设计 §4.2)', () => {
|
|
|
522
531
|
expect(() => manager.agentSignal(r.terminalId, 'SIGINT')).toThrow(TerminalControlError)
|
|
523
532
|
})
|
|
524
533
|
|
|
534
|
+
it('agentSignalForeground:只对前台进程组发 kill(-pgid);前台是 shell / 探测不可用则拒(P5 任务 4 / O3)', async () => {
|
|
535
|
+
// ① 前台有命令 → kill(-pgid)
|
|
536
|
+
const command = makeManager({
|
|
537
|
+
probeForeground: async () => ({ kind: 'command', pgid: 4321, state: 'S+' }),
|
|
538
|
+
})
|
|
539
|
+
const r = await command.manager.createForAgent({ threadId: 't1', userId: 'u1' }, ROOT)
|
|
540
|
+
const killSpy = vi.spyOn(process, 'kill').mockImplementation(() => true)
|
|
541
|
+
try {
|
|
542
|
+
expect(await command.manager.agentSignalForeground(r.terminalId, 'SIGTERM')).toEqual({
|
|
543
|
+
delivered: true,
|
|
544
|
+
method: 'foreground-group',
|
|
545
|
+
pgid: 4321,
|
|
546
|
+
})
|
|
547
|
+
// 负 pgid = 整个前台进程组;绝不发给 shell 自身(正 pid)
|
|
548
|
+
expect(killSpy).toHaveBeenCalledWith(-4321, 'SIGTERM')
|
|
549
|
+
} finally {
|
|
550
|
+
killSpy.mockRestore()
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// ② 前台是 shell 自身 → 拒(等价关终端)
|
|
554
|
+
const shellFg = makeManager({ probeForeground: async () => ({ kind: 'shell', pgid: 4242 }) })
|
|
555
|
+
const s = await shellFg.manager.createForAgent({ threadId: 't1', userId: 'u1' }, ROOT)
|
|
556
|
+
await expect(shellFg.manager.agentSignalForeground(s.terminalId, 'SIGTERM')).rejects.toMatchObject({
|
|
557
|
+
code: 'invalid_signal',
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
// ③ 探测不可用 → fail-closed 拒(不回退成控制字符,也不猜 pgid)
|
|
561
|
+
const unknown = makeManager()
|
|
562
|
+
const u = await unknown.manager.createForAgent({ threadId: 't1', userId: 'u1' }, ROOT)
|
|
563
|
+
const killSpy2 = vi.spyOn(process, 'kill').mockImplementation(() => true)
|
|
564
|
+
try {
|
|
565
|
+
await expect(unknown.manager.agentSignalForeground(u.terminalId, 'SIGKILL')).rejects.toMatchObject({
|
|
566
|
+
code: 'invalid_signal',
|
|
567
|
+
})
|
|
568
|
+
expect(killSpy2).not.toHaveBeenCalled()
|
|
569
|
+
} finally {
|
|
570
|
+
killSpy2.mockRestore()
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// ④ 守卫同 agentWrite:接管后 → user-control(control 不符不得发信号)
|
|
574
|
+
command.manager.write(r.terminalId, 1, 'x', true)
|
|
575
|
+
await expect(command.manager.agentSignalForeground(r.terminalId, 'SIGTERM')).rejects.toMatchObject({
|
|
576
|
+
code: 'terminal/control-unavailable',
|
|
577
|
+
})
|
|
578
|
+
})
|
|
579
|
+
|
|
580
|
+
it('foregroundOf:只读探测,终端不存在/已退出/无 pid → undefined(不抛)', async () => {
|
|
581
|
+
const { manager, spawned } = makeManager({
|
|
582
|
+
probeForeground: async () => ({ kind: 'command', pgid: 777, state: 'R' }),
|
|
583
|
+
})
|
|
584
|
+
const r = await manager.createForAgent({ threadId: 't1', userId: 'u1' }, ROOT)
|
|
585
|
+
expect(await manager.foregroundOf(r.terminalId)).toEqual({ kind: 'command', pgid: 777, state: 'R' })
|
|
586
|
+
expect(await manager.foregroundOf('nope')).toBeUndefined()
|
|
587
|
+
spawned[0].listeners.exit.forEach((fn) => fn({ exitCode: 0 }))
|
|
588
|
+
expect(await manager.foregroundOf(r.terminalId)).toBeUndefined()
|
|
589
|
+
// 探测器抛错也不外溢(旁路信息不参与控制流)
|
|
590
|
+
const throwing = makeManager({
|
|
591
|
+
probeForeground: async () => {
|
|
592
|
+
throw new Error('ps 炸了')
|
|
593
|
+
},
|
|
594
|
+
})
|
|
595
|
+
const t = await throwing.manager.createForAgent({ threadId: 't1', userId: 'u1' }, ROOT)
|
|
596
|
+
expect(await throwing.manager.foregroundOf(t.terminalId)).toBeUndefined()
|
|
597
|
+
})
|
|
598
|
+
|
|
525
599
|
it('agentClose:control=agent → 真杀返回 closed(exit 帧经 onExit 广播);关闭中再调 already-closing;exit 后幂等 closed', async () => {
|
|
526
600
|
const { manager, spawned } = makeManager()
|
|
527
601
|
const r = await manager.createForAgent({ threadId: 't1', userId: 'u1' }, ROOT)
|
|
@@ -228,7 +228,7 @@ describe('requireFeatureForTool 三态门控(hostedAi 通路证明,Ruling P6
|
|
|
228
228
|
})
|
|
229
229
|
|
|
230
230
|
describe('enforceToolFeature(工具名级入口)', () => {
|
|
231
|
-
it('仅 team
|
|
231
|
+
it('仅 team 四工具、agents 七工具与 workflow 四工具映射 customAgents,七域不发明 key', () => {
|
|
232
232
|
const expected = {
|
|
233
233
|
team_task_create: 'customAgents',
|
|
234
234
|
team_task_list: 'customAgents',
|
|
@@ -241,13 +241,17 @@ describe('enforceToolFeature(工具名级入口)', () => {
|
|
|
241
241
|
send_message: 'customAgents',
|
|
242
242
|
wait_agent: 'customAgents',
|
|
243
243
|
interrupt_agent: 'customAgents',
|
|
244
|
+
workflow_start: 'customAgents',
|
|
245
|
+
workflow_list: 'customAgents',
|
|
246
|
+
workflow_view: 'customAgents',
|
|
247
|
+
workflow_cancel: 'customAgents',
|
|
244
248
|
}
|
|
245
249
|
expect(HARNESS_TOOL_FEATURE_MAP).toEqual(expected)
|
|
246
250
|
const manifestTools = CAPABILITY_REGISTRY
|
|
247
251
|
.filter((manifest) => manifest.entitlement === 'customAgents')
|
|
248
252
|
.flatMap((manifest) => manifest.tools.map((tool) => tool.name))
|
|
249
253
|
expect(Object.keys(HARNESS_TOOL_FEATURE_MAP).sort()).toEqual(manifestTools.sort())
|
|
250
|
-
expect(Object.keys(HARNESS_TOOL_FEATURE_MAP)).toHaveLength(
|
|
254
|
+
expect(Object.keys(HARNESS_TOOL_FEATURE_MAP)).toHaveLength(15)
|
|
251
255
|
expect(new Set(Object.keys(HARNESS_TOOL_FEATURE_MAP))).toEqual(new Set(Object.keys(expected)))
|
|
252
256
|
})
|
|
253
257
|
|
|
@@ -50,6 +50,7 @@ import type {
|
|
|
50
50
|
import type { CreateForAgentOptions } from './terminal-manager.server'
|
|
51
51
|
import type { WorkspaceRootResolution } from './workspace-binder.server'
|
|
52
52
|
import { ProviderError } from './providers/contracts'
|
|
53
|
+
import { isAwaitingInput } from './terminal-foreground.server'
|
|
53
54
|
import { buildAgentTerminalLaunch, resolveLocalSandbox } from './sandbox/local-sandbox.server'
|
|
54
55
|
import {
|
|
55
56
|
readThreadExecutionPolicy,
|
|
@@ -154,6 +155,8 @@ export interface AgentTerminalCallOpts {
|
|
|
154
155
|
| 'createForAgent'
|
|
155
156
|
| 'agentWrite'
|
|
156
157
|
| 'agentSignal'
|
|
158
|
+
| 'agentSignalForeground'
|
|
159
|
+
| 'foregroundOf'
|
|
157
160
|
| 'agentClose'
|
|
158
161
|
| 'readScreen'
|
|
159
162
|
| 'listForAgent'
|
|
@@ -185,6 +188,12 @@ export interface AgentTerminalSendResult {
|
|
|
185
188
|
waitReason: AgentTerminalWaitReason
|
|
186
189
|
sessionStatus: AgentTerminalSessionStatus
|
|
187
190
|
truncated: boolean
|
|
191
|
+
/**
|
|
192
|
+
* stdin readiness 启发式(P5 任务 4 / §6.5 O2):前台命令处于可中断睡眠(大概率阻塞在
|
|
193
|
+
* 读 stdin——交互提示/REPL/分页器)。仅在为 true 时出现,避免给模型塞恒 false 的噪声。
|
|
194
|
+
* 不是保证(`sleep 10` 同样睡眠),工具描述按「可能」表述。
|
|
195
|
+
*/
|
|
196
|
+
awaitingInput?: boolean
|
|
188
197
|
}
|
|
189
198
|
|
|
190
199
|
/** terminal_list 列表项(§6.2:exitCode 不下发的 agent 通道恒 running,省略可选键)。 */
|
|
@@ -605,7 +614,12 @@ export async function sendToAgentTerminal(
|
|
|
605
614
|
} catch {
|
|
606
615
|
// 回收竞态 / 读取悬挂超时(兜底):viewport 保持空(进程已不在,输出无从读取)
|
|
607
616
|
}
|
|
608
|
-
|
|
617
|
+
// stdin readiness(P5 任务 4):仍 running 时探一次前台组——命令多半在等输入(交互提示
|
|
618
|
+
// 回显后静默、REPL、less/man 分页)时给模型一个明确信号,免得它以为命令跑完了。
|
|
619
|
+
const awaitingInput = state === 'running'
|
|
620
|
+
? isAwaitingInput(await manager.foregroundOf(sessionId))
|
|
621
|
+
: false
|
|
622
|
+
return { viewport, waitReason, sessionStatus: state, truncated, ...(awaitingInput ? { awaitingInput } : {}) }
|
|
609
623
|
}
|
|
610
624
|
|
|
611
625
|
// ── terminal_read / terminal_signal / terminal_close / terminal_list(§6.2)──────
|
|
@@ -630,21 +644,28 @@ export async function readAgentTerminal(
|
|
|
630
644
|
}
|
|
631
645
|
}
|
|
632
646
|
|
|
647
|
+
/** 终止型信号(P5 任务 4 / §6.5 O3):仅定向到前台进程组,绝不发给 shell/后台作业。 */
|
|
648
|
+
const FOREGROUND_ONLY_SIGNALS: ReadonlySet<TerminalAgentSignal> = new Set(['SIGTERM', 'SIGKILL', 'SIGHUP'])
|
|
649
|
+
|
|
633
650
|
/**
|
|
634
|
-
* 发送信号(§6.2 terminal_signal
|
|
635
|
-
*
|
|
651
|
+
* 发送信号(§6.2 terminal_signal):
|
|
652
|
+
* - SIGINT/SIGTSTP → 控制字符(`\x03`/`\x1a`,等价于用户在终端按键);
|
|
653
|
+
* - SIGTERM/SIGKILL/SIGHUP → **前台进程组定向**(`kill(-pgid)`):只命当前前台命令,
|
|
654
|
+
* 不波及 shell 与后台作业;前台就是 shell 或无法探测时 fail-closed 拒绝并引导
|
|
655
|
+
* terminal_close(P5 任务 4 收口 O3 偏离:v1 曾对这三个信号一律拒)。
|
|
636
656
|
*/
|
|
637
657
|
export async function signalAgentTerminal(
|
|
638
658
|
ctx: AgentTerminalCtx,
|
|
639
659
|
sessionId: string,
|
|
640
660
|
signal: TerminalAgentSignal,
|
|
641
661
|
opts: AgentTerminalCallOpts = {},
|
|
642
|
-
): Promise<{ delivered: true; method: 'control-char' }> {
|
|
662
|
+
): Promise<{ delivered: true; method: 'control-char' | 'foreground-group'; pgid?: number }> {
|
|
643
663
|
const manager = await resolveManager(opts)
|
|
644
664
|
// 发送前档位门控(安全边界):信号同样能改变沙箱内进程状态。
|
|
645
665
|
ensureSendAllowedWithinPolicy(manager, ctx.threadId, sessionId, await readThreadExecutionPolicy(ctx.threadId))
|
|
646
666
|
ensureThreadTerminal(manager, ctx.threadId, sessionId)
|
|
647
667
|
try {
|
|
668
|
+
if (FOREGROUND_ONLY_SIGNALS.has(signal)) return await manager.agentSignalForeground(sessionId, signal)
|
|
648
669
|
return manager.agentSignal(sessionId, signal)
|
|
649
670
|
} catch (err) {
|
|
650
671
|
if (isManagerError(err) && err.code === 'invalid_signal') {
|
|
@@ -703,6 +703,7 @@ describe('agentControlLogReduce', () => {
|
|
|
703
703
|
agents: {
|
|
704
704
|
'agent-1': { ...started, type: 'allblue.agent.finished', status: 'completed', finishedAt: 200, tokens: 12 },
|
|
705
705
|
},
|
|
706
|
+
workflows: {},
|
|
706
707
|
config: { modelSearchEnabled: { value: true } },
|
|
707
708
|
settings: { reasoning: 'high' },
|
|
708
709
|
})
|
|
@@ -43,14 +43,21 @@ export interface AgentControlLogEntry {
|
|
|
43
43
|
|
|
44
44
|
export interface AgentControlLogState {
|
|
45
45
|
agents: Record<string, AgentControlLogEntry>
|
|
46
|
+
/**
|
|
47
|
+
* workflow run 折叠态(P5 任务 1):allblue.workflow.* 记录折叠产物。与 agents
|
|
48
|
+
* 共用同一 reducer(官方 durability.logState 只有一个槽位),按 runId 索引。
|
|
49
|
+
*/
|
|
50
|
+
workflows: Record<string, import('../workflow/types').WorkflowRunSnapshot>
|
|
46
51
|
settings?: ThreadSettings
|
|
47
52
|
config: Record<string, { value: unknown }>
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
export const agentControlLogReduce: ReduceOptions<AgentControlLogState> = {
|
|
51
56
|
includeHarnessRecords: ['harness.settings', 'harness.config'],
|
|
52
|
-
version
|
|
53
|
-
|
|
57
|
+
// v3(P5 任务 1):state 增加 workflows 折叠桶,形状变更须 bump version——旧快照
|
|
58
|
+
// 被忽略并全量重放一次(每线程一次性成本),保证 workflows 从空桶正确起算。
|
|
59
|
+
version: '3',
|
|
60
|
+
initial: { agents: {}, workflows: {}, config: {} },
|
|
54
61
|
record: ({ state, record }) => {
|
|
55
62
|
if (record.type === 'harness.settings') {
|
|
56
63
|
if (!record.settings || typeof record.settings !== 'object' || Array.isArray(record.settings)) return state
|
|
@@ -73,6 +80,52 @@ export const agentControlLogReduce: ReduceOptions<AgentControlLogState> = {
|
|
|
73
80
|
if (!previous) return state
|
|
74
81
|
return { ...state, agents: { ...state.agents, [patch.runId]: { ...previous, ...patch } } }
|
|
75
82
|
}
|
|
83
|
+
const workflows = state.workflows ?? {}
|
|
84
|
+
if (record.type === 'allblue.workflow.started') {
|
|
85
|
+
const entry = record as unknown as import('../workflow/types').WorkflowRunSnapshot
|
|
86
|
+
if (workflows[entry.runId]) return state
|
|
87
|
+
return { ...state, workflows: { ...workflows, [entry.runId]: entry } }
|
|
88
|
+
}
|
|
89
|
+
if (record.type === 'allblue.workflow.stage') {
|
|
90
|
+
const patch = record as unknown as {
|
|
91
|
+
runId: string
|
|
92
|
+
stage: import('../workflow/types').WorkflowStageState
|
|
93
|
+
}
|
|
94
|
+
const previous = workflows[patch.runId]
|
|
95
|
+
if (!previous) return state
|
|
96
|
+
const stages = previous.stages.map((stage) =>
|
|
97
|
+
stage.id === patch.stage.id ? { ...stage, ...patch.stage } : stage,
|
|
98
|
+
)
|
|
99
|
+
return {
|
|
100
|
+
...state,
|
|
101
|
+
workflows: {
|
|
102
|
+
...workflows,
|
|
103
|
+
[patch.runId]: { ...previous, stages, updatedAt: patch.stage.finishedAt ?? Date.now() },
|
|
104
|
+
},
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (record.type === 'allblue.workflow.finished') {
|
|
108
|
+
const patch = record as unknown as {
|
|
109
|
+
runId: string
|
|
110
|
+
status: import('../workflow/types').WorkflowRunStatus
|
|
111
|
+
round?: number
|
|
112
|
+
finishedAt: number
|
|
113
|
+
}
|
|
114
|
+
const previous = workflows[patch.runId]
|
|
115
|
+
if (!previous) return state
|
|
116
|
+
return {
|
|
117
|
+
...state,
|
|
118
|
+
workflows: {
|
|
119
|
+
...workflows,
|
|
120
|
+
[patch.runId]: {
|
|
121
|
+
...previous,
|
|
122
|
+
status: patch.status,
|
|
123
|
+
...(patch.round === undefined ? {} : { round: patch.round }),
|
|
124
|
+
updatedAt: patch.finishedAt,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
}
|
|
76
129
|
return state
|
|
77
130
|
},
|
|
78
131
|
}
|
|
@@ -252,6 +252,29 @@ exports[`capability matrix snapshot > desktop 能力矩阵快照稳定 1`] = `
|
|
|
252
252
|
"team_task_update",
|
|
253
253
|
],
|
|
254
254
|
},
|
|
255
|
+
{
|
|
256
|
+
"available": true,
|
|
257
|
+
"id": "workflow",
|
|
258
|
+
"missingProviders": [],
|
|
259
|
+
"tools": [
|
|
260
|
+
"workflow_start",
|
|
261
|
+
"workflow_list",
|
|
262
|
+
"workflow_view",
|
|
263
|
+
"workflow_cancel",
|
|
264
|
+
],
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"available": true,
|
|
268
|
+
"id": "webhook",
|
|
269
|
+
"missingProviders": [],
|
|
270
|
+
"tools": [
|
|
271
|
+
"webhook_create",
|
|
272
|
+
"webhook_list",
|
|
273
|
+
"webhook_view",
|
|
274
|
+
"webhook_edit",
|
|
275
|
+
"webhook_delete",
|
|
276
|
+
],
|
|
277
|
+
},
|
|
255
278
|
{
|
|
256
279
|
"available": true,
|
|
257
280
|
"id": "agents",
|
|
@@ -524,6 +547,29 @@ exports[`capability matrix snapshot > oss-web 能力矩阵快照稳定 1`] = `
|
|
|
524
547
|
"team_task_update",
|
|
525
548
|
],
|
|
526
549
|
},
|
|
550
|
+
{
|
|
551
|
+
"available": true,
|
|
552
|
+
"id": "workflow",
|
|
553
|
+
"missingProviders": [],
|
|
554
|
+
"tools": [
|
|
555
|
+
"workflow_start",
|
|
556
|
+
"workflow_list",
|
|
557
|
+
"workflow_view",
|
|
558
|
+
"workflow_cancel",
|
|
559
|
+
],
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
"available": true,
|
|
563
|
+
"id": "webhook",
|
|
564
|
+
"missingProviders": [],
|
|
565
|
+
"tools": [
|
|
566
|
+
"webhook_create",
|
|
567
|
+
"webhook_list",
|
|
568
|
+
"webhook_view",
|
|
569
|
+
"webhook_edit",
|
|
570
|
+
"webhook_delete",
|
|
571
|
+
],
|
|
572
|
+
},
|
|
527
573
|
{
|
|
528
574
|
"available": true,
|
|
529
575
|
"id": "agents",
|
|
@@ -805,6 +851,29 @@ exports[`capability matrix snapshot > saas 能力矩阵快照稳定 1`] = `
|
|
|
805
851
|
"team_task_update",
|
|
806
852
|
],
|
|
807
853
|
},
|
|
854
|
+
{
|
|
855
|
+
"available": true,
|
|
856
|
+
"id": "workflow",
|
|
857
|
+
"missingProviders": [],
|
|
858
|
+
"tools": [
|
|
859
|
+
"workflow_start",
|
|
860
|
+
"workflow_list",
|
|
861
|
+
"workflow_view",
|
|
862
|
+
"workflow_cancel",
|
|
863
|
+
],
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
"available": true,
|
|
867
|
+
"id": "webhook",
|
|
868
|
+
"missingProviders": [],
|
|
869
|
+
"tools": [
|
|
870
|
+
"webhook_create",
|
|
871
|
+
"webhook_list",
|
|
872
|
+
"webhook_view",
|
|
873
|
+
"webhook_edit",
|
|
874
|
+
"webhook_delete",
|
|
875
|
+
],
|
|
876
|
+
},
|
|
808
877
|
{
|
|
809
878
|
"available": true,
|
|
810
879
|
"id": "agents",
|
|
@@ -1087,6 +1156,29 @@ exports[`capability matrix snapshot > self-hosted 能力矩阵快照稳定 1`] =
|
|
|
1087
1156
|
"team_task_update",
|
|
1088
1157
|
],
|
|
1089
1158
|
},
|
|
1159
|
+
{
|
|
1160
|
+
"available": true,
|
|
1161
|
+
"id": "workflow",
|
|
1162
|
+
"missingProviders": [],
|
|
1163
|
+
"tools": [
|
|
1164
|
+
"workflow_start",
|
|
1165
|
+
"workflow_list",
|
|
1166
|
+
"workflow_view",
|
|
1167
|
+
"workflow_cancel",
|
|
1168
|
+
],
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
"available": true,
|
|
1172
|
+
"id": "webhook",
|
|
1173
|
+
"missingProviders": [],
|
|
1174
|
+
"tools": [
|
|
1175
|
+
"webhook_create",
|
|
1176
|
+
"webhook_list",
|
|
1177
|
+
"webhook_view",
|
|
1178
|
+
"webhook_edit",
|
|
1179
|
+
"webhook_delete",
|
|
1180
|
+
],
|
|
1181
|
+
},
|
|
1090
1182
|
{
|
|
1091
1183
|
"available": true,
|
|
1092
1184
|
"id": "agents",
|
|
@@ -93,9 +93,11 @@ describe('EXECUTION_PLANE_DENIALS 账本(P3.5 任务 1)', () => {
|
|
|
93
93
|
reason: 'deferred-coding-agents-need-cli-and-oauth',
|
|
94
94
|
revisit: 'P4+',
|
|
95
95
|
})
|
|
96
|
+
// agent-terminal 的 P5 窗口已用掉(P5 任务 9 结案):reason 不变,revisit 改 '—'
|
|
97
|
+
// (缺席是终态,不再排期)——PTY 不可远程化,终端增强只落本地三端。
|
|
96
98
|
expect(denialOf('agent-terminal')).toMatchObject({
|
|
97
99
|
reason: 'pty-belongs-to-p5-terminal',
|
|
98
|
-
revisit: '
|
|
100
|
+
revisit: '—',
|
|
99
101
|
})
|
|
100
102
|
})
|
|
101
103
|
|
|
@@ -546,15 +546,15 @@ describe('七个新错误码汇总(fail-closed 路径与稳定错误码)', (
|
|
|
546
546
|
// ── manifest 登记计数(执行日实测并集落值,复审 C-F12) ─────────────────────────
|
|
547
547
|
|
|
548
548
|
describe('manifest 登记计数(执行日实测并集落值)', () => {
|
|
549
|
-
it('全 manifest 工具名并集 =
|
|
549
|
+
it('全 manifest 工具名并集 = 90 键(P4 任务 26 执行日 computer-use 三工具 + P5 任务 1 workflow 四工具 + P5 任务 3 webhook 五工具),与风险索引同源', () => {
|
|
550
550
|
// 执行日实测:`grep -rn "name:" apps/web/src/server/harness/capabilities/manifests/`
|
|
551
|
-
// 工具名并集
|
|
551
|
+
// 工具名并集 90(P3.5 任务 11 落值 78 + P4 任务 26 三窗口工具 + P5 任务 1 workflow 四工具 + P5 任务 3 webhook 五工具),与
|
|
552
552
|
// HARNESS_TOOL_RISK 键数一致。
|
|
553
553
|
// 工具增删必须先改 manifest 再回填本值。
|
|
554
554
|
const names = CAPABILITY_REGISTRY.flatMap((manifest) =>
|
|
555
555
|
manifest.tools.map((tool) => tool.name),
|
|
556
556
|
)
|
|
557
|
-
expect(new Set(names).size, 'manifest 工具名并集').toBe(
|
|
557
|
+
expect(new Set(names).size, 'manifest 工具名并集').toBe(90)
|
|
558
558
|
// 登记与风险派生单一来源:兼容桥(legacy 消费面)键集合与 manifest 并集零漂移。
|
|
559
559
|
expect(Object.keys(getDeclaredHarnessToolRisk()).sort()).toEqual([...new Set(names)].sort())
|
|
560
560
|
})
|