orca-multiagent-kit 1.5.0 → 1.6.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/CHANGELOG.md +30 -1
- package/README.md +2 -1
- package/VERSION +1 -1
- package/bin/omk.js +7 -0
- package/bin/team.js +353 -0
- package/core/AGENTS.md +1 -1
- package/docs/PLUGIN-ORCA.md +107 -18
- package/orca-plugin/README.md +5 -1
- package/orca-plugin/assets/logos/README.md +10 -0
- package/orca-plugin/assets/logos/agent.png +0 -0
- package/orca-plugin/assets/logos/aider.png +0 -0
- package/orca-plugin/assets/logos/amp.png +0 -0
- package/orca-plugin/assets/logos/antigravity.png +0 -0
- package/orca-plugin/assets/logos/claude.png +0 -0
- package/orca-plugin/assets/logos/cline.png +0 -0
- package/orca-plugin/assets/logos/codex.png +0 -0
- package/orca-plugin/assets/logos/copilot.png +0 -0
- package/orca-plugin/assets/logos/cursor.png +0 -0
- package/orca-plugin/assets/logos/devin.png +0 -0
- package/orca-plugin/assets/logos/droid.png +0 -0
- package/orca-plugin/assets/logos/gemini.png +0 -0
- package/orca-plugin/assets/logos/goose.png +0 -0
- package/orca-plugin/assets/logos/grok.png +0 -0
- package/orca-plugin/assets/logos/kimi.png +0 -0
- package/orca-plugin/assets/logos/kiro.png +0 -0
- package/orca-plugin/assets/logos/opencode.png +0 -0
- package/orca-plugin/assets/logos/qwen-code.png +0 -0
- package/orca-plugin/orca-plugin.json +25 -7
- package/orca-plugin/src/icons.test.ts +14 -0
- package/orca-plugin/src/icons.ts +30 -0
- package/orca-plugin/src/kit.test.ts +456 -9
- package/orca-plugin/src/kit.ts +626 -21
- package/orca-plugin/src/models.test.ts +28 -0
- package/orca-plugin/src/models.ts +29 -0
- package/orca-plugin/src/node.d.ts +40 -0
- package/orca-plugin/src/panel-state.ts +28 -0
- package/orca-plugin/src/panel.test.tsx +228 -30
- package/orca-plugin/src/panel.tsx +482 -78
- package/orca-plugin/src/plan-card.test.ts +99 -0
- package/orca-plugin/src/plan-card.ts +107 -0
- package/orca-plugin/src/protocol.ts +166 -5
- package/orca-plugin/src/tabs/autonomy.tsx +70 -0
- package/orca-plugin/src/tabs/history.test.tsx +78 -0
- package/orca-plugin/src/tabs/history.tsx +118 -0
- package/orca-plugin/src/tabs/notices.test.tsx +183 -0
- package/orca-plugin/src/tabs/notices.tsx +274 -0
- package/orca-plugin/src/tabs/worktrees.test.tsx +130 -0
- package/orca-plugin/src/tabs/worktrees.tsx +138 -0
- package/orca-plugin/src/ui/agent-icon.tsx +13 -0
- package/orca-plugin/src/worker/context.test.ts +32 -0
- package/orca-plugin/src/worker/context.ts +92 -0
- package/orca-plugin/src/worker/history.test.ts +149 -0
- package/orca-plugin/src/worker/history.ts +181 -0
- package/orca-plugin/src/worker/notices.test.ts +356 -0
- package/orca-plugin/src/worker/notices.ts +291 -0
- package/orca-plugin/src/worker/system.test.ts +58 -0
- package/orca-plugin/src/worker/system.ts +122 -0
- package/orca-plugin/src/worker/worktrees.test.ts +177 -0
- package/orca-plugin/src/worker/worktrees.ts +188 -0
- package/orca-plugin/src/worker.test.ts +265 -22
- package/orca-plugin/src/worker.ts +318 -34
- package/package.json +2 -2
- package/skills/orca/SKILL.md +1 -0
- package/skills/orca/references/engine-orca.md +1 -0
- package/skills/orca/references/olimpo.md +1 -0
- package/skills/orca/references/plan-card.md +45 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
// La pestaña Avisos del worker, cargada con el núcleo contra un host simulado.
|
|
2
|
+
import { afterEach, assert, hostError, mockHost, mountWorker, test, type TestWorker } from 'orca/testing'
|
|
3
|
+
import type { NoticeItem } from '../protocol.ts'
|
|
4
|
+
import * as main from '../worker.ts'
|
|
5
|
+
|
|
6
|
+
const PLAN = {
|
|
7
|
+
version: 1,
|
|
8
|
+
run: '20261107-recargas',
|
|
9
|
+
source: 'spec-kit 003-recargas',
|
|
10
|
+
autonomy: 'semi',
|
|
11
|
+
base: null,
|
|
12
|
+
integration: 'feat/003-recargas',
|
|
13
|
+
merge: 'feat/003-recargas → main',
|
|
14
|
+
units: [
|
|
15
|
+
{ round: 0, id: 'U0', title: 'setup', role: 'Hefesto', level: 'alto', agent: 'coordinador', model: null, resource: 'inline', files: '7', depends: null },
|
|
16
|
+
{ round: 1, id: 'U2', title: 'recarga', role: 'Ariadna', level: 'alto', agent: 'claude', model: '<alto>', resource: 'worker', files: '11', depends: 'U0' }
|
|
17
|
+
],
|
|
18
|
+
notes: ['modelos: nuevo']
|
|
19
|
+
}
|
|
20
|
+
const PLAN_PATH = 'C:\\repo\\.work\\runs\\r1\\plan.json'
|
|
21
|
+
|
|
22
|
+
let worker: TestWorker | undefined
|
|
23
|
+
afterEach(async () => {
|
|
24
|
+
await worker?.deactivate()
|
|
25
|
+
worker = undefined
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const start = async (results: Record<string, unknown> = {}) => {
|
|
29
|
+
worker = await mountWorker(main, {
|
|
30
|
+
host: mockHost({
|
|
31
|
+
results: {
|
|
32
|
+
'workspace.readContext': { branch: 'main', displayName: 'app', terminals: [] },
|
|
33
|
+
'workspace.list': {
|
|
34
|
+
workspaces: [{ id: 'w1', kind: 'worktree', name: 'app', path: '/repo/app', branch: 'refs/heads/main', hostId: null }],
|
|
35
|
+
truncated: false
|
|
36
|
+
},
|
|
37
|
+
'agents.list': { agents: [] },
|
|
38
|
+
'terminal.read': { lines: [], truncated: false },
|
|
39
|
+
'terminal.sendText': { accepted: true },
|
|
40
|
+
'notifications.show': { delivered: true },
|
|
41
|
+
'statusBar.update': { ok: true },
|
|
42
|
+
...results
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
return worker
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const settle = () => new Promise<void>((resolve) => setTimeout(resolve, 5))
|
|
50
|
+
const list = async (w: TestWorker) => ((await w.request('notices.list')) as { items: NoticeItem[] }).items
|
|
51
|
+
const status = (terminalId: string, state: 'working' | 'blocked' | 'waiting' | 'done', receivedAt: number) => ({
|
|
52
|
+
workspaceId: 'w1',
|
|
53
|
+
paneKey: `p-${terminalId}`,
|
|
54
|
+
terminalId,
|
|
55
|
+
state,
|
|
56
|
+
receivedAt,
|
|
57
|
+
title: `agente ${terminalId}`
|
|
58
|
+
})
|
|
59
|
+
// `terminalId: null` es un coordinador sin terminal: Orca no manda el campo.
|
|
60
|
+
const write = (path: string, content: string, terminalId: string | null = 't1', tool = 'Write') =>
|
|
61
|
+
({ agent: 'claude', workspaceId: 'w1', ...(terminalId === null ? {} : { terminalId }), tool, input: { file_path: path, content } }) as never
|
|
62
|
+
|
|
63
|
+
test('un Write de plan.json enseña la tarjeta, avisa y la deja en el historial', async () => {
|
|
64
|
+
const w = await start()
|
|
65
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify(PLAN)))
|
|
66
|
+
const [notice, ...rest] = await list(w)
|
|
67
|
+
assert.equal(rest.length, 0)
|
|
68
|
+
assert.equal(notice?.id, 'plan:20261107-recargas')
|
|
69
|
+
assert.equal(notice?.kind, 'plan')
|
|
70
|
+
assert.equal(notice?.canReply, true)
|
|
71
|
+
assert.equal(notice?.plan?.units.length, 2)
|
|
72
|
+
assert.deepEqual(w.host.callsOf('notifications.show'), [
|
|
73
|
+
{ title: 'Plan listo: 20261107-recargas', body: '2 unidades en 2 rondas. Confírmalo en Avisos.' }
|
|
74
|
+
])
|
|
75
|
+
assert.equal(w.posts.filter((post) => post.event === 'notices.changed').length, 1)
|
|
76
|
+
assert.deepEqual(w.refusals, [])
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
test('otro tool, otra ruta o un JSON roto no hacen nada; lo roto queda en el log', async () => {
|
|
80
|
+
const w = await start()
|
|
81
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify(PLAN), 't1', 'Edit'))
|
|
82
|
+
await w.hooks.fire('agent.tool.after', write('C:\\repo\\notas.json', JSON.stringify(PLAN)))
|
|
83
|
+
await w.hooks.fire('agent.tool.after', { agent: 'claude', workspaceId: 'w1', terminalId: 't1', tool: 'Write', input: 'x' } as never)
|
|
84
|
+
assert.deepEqual(await list(w), [])
|
|
85
|
+
assert.equal(w.logs.length, 0)
|
|
86
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, '{ roto'))
|
|
87
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify({ ...PLAN, version: 9 })))
|
|
88
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, 'x'.repeat(70 * 1024)))
|
|
89
|
+
assert.deepEqual(await list(w), [])
|
|
90
|
+
assert.equal(w.logs.filter((line) => line.startsWith('plan.json ignorado')).length, 3)
|
|
91
|
+
assert.equal(w.host.callsOf('notifications.show').length, 0)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('un plan nuevo del mismo run sustituye al anterior; sin terminal no se puede responder', async () => {
|
|
95
|
+
const w = await start()
|
|
96
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify(PLAN)))
|
|
97
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify({ ...PLAN, units: [PLAN.units[0]] }), null))
|
|
98
|
+
const items = await list(w)
|
|
99
|
+
assert.equal(items.length, 1)
|
|
100
|
+
assert.equal(items[0]?.plan?.units.length, 1)
|
|
101
|
+
assert.equal(items[0]?.canReply, false)
|
|
102
|
+
await assert.rejects(w.request('notices.reply', { id: 'plan:20261107-recargas', text: 'sí' }), /no se le puede escribir/)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('«sí» y «cambia: …» se escriben en el terminal del coordinador y quitan el aviso', async () => {
|
|
106
|
+
const w = await start()
|
|
107
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify(PLAN), 't7'))
|
|
108
|
+
const result = await w.request('notices.reply', { id: 'plan:20261107-recargas', text: 'sí' })
|
|
109
|
+
assert.deepEqual(w.host.callsOf('terminal.sendText'), [{ terminalId: 't7', text: 'sí', enter: true }])
|
|
110
|
+
assert.match(result.message, /Enviado a su terminal: Plan de rondas/)
|
|
111
|
+
assert.deepEqual(await list(w), [])
|
|
112
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify(PLAN), 't7'))
|
|
113
|
+
await w.request('notices.reply', { id: 'plan:20261107-recargas', text: 'cambia: sin la ronda 2' })
|
|
114
|
+
assert.equal((w.host.callsOf('terminal.sendText')[1] as { text: string }).text, 'cambia: sin la ronda 2')
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
test('un agente bloqueado sale con su contexto limpio y desaparece al volver a trabajar', async () => {
|
|
118
|
+
const lines = ['\u001b[31mrojo\u001b[0m', '', 'x\u0007y', ...Array.from({ length: 20 }, (_, i) => `línea ${i}`), 'z'.repeat(300)]
|
|
119
|
+
const w = await start({ 'terminal.read': { lines, truncated: false } })
|
|
120
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1000))
|
|
121
|
+
await settle()
|
|
122
|
+
const [notice] = await list(w)
|
|
123
|
+
assert.equal(notice?.id, 't:t1')
|
|
124
|
+
assert.equal(notice?.kind, 'blocked')
|
|
125
|
+
assert.equal(notice?.workspace, 'app')
|
|
126
|
+
assert.equal(notice?.canReply, true)
|
|
127
|
+
assert.equal(notice?.context.length, 12)
|
|
128
|
+
assert.equal(notice?.context.at(-1)?.length, 200)
|
|
129
|
+
assert.equal(notice?.context.at(-2), 'línea 19')
|
|
130
|
+
assert.deepEqual(w.host.callsOf('terminal.read'), [{ terminalId: 't1', maxLines: 40 }])
|
|
131
|
+
await w.emit('agent.status.changed', status('t1', 'working', 2000))
|
|
132
|
+
assert.deepEqual(await list(w), [])
|
|
133
|
+
await w.emit('agent.status.changed', status('t1', 'waiting', 3000))
|
|
134
|
+
assert.equal((await list(w))[0]?.kind, 'waiting')
|
|
135
|
+
await w.emit('agent.status.changed', status('t1', 'done', 4000))
|
|
136
|
+
assert.deepEqual(await list(w), [])
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
test('un fallo al leer el terminal se registra y el aviso sale sin contexto', async () => {
|
|
140
|
+
const w = await start({
|
|
141
|
+
'terminal.read': () => {
|
|
142
|
+
throw hostError('unavailable', 'sin terminal')
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
await w.emit('agent.status.changed', status('t1', 'waiting', 1000))
|
|
146
|
+
await settle()
|
|
147
|
+
const [notice] = await list(w)
|
|
148
|
+
assert.deepEqual(notice?.context, [])
|
|
149
|
+
assert.match(w.logs.join('\n'), /contexto de t:t1 no leído/)
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
test('un chat de Orca sin terminal sale pero no admite respuesta', async () => {
|
|
153
|
+
const w = await start()
|
|
154
|
+
await w.emit('agent.status.changed', {
|
|
155
|
+
workspaceId: 'w1',
|
|
156
|
+
paneKey: 'structured-agent-session-claude_abc:1',
|
|
157
|
+
state: 'blocked',
|
|
158
|
+
receivedAt: 1000
|
|
159
|
+
})
|
|
160
|
+
const [notice] = await list(w)
|
|
161
|
+
assert.equal(notice?.id, 'p:structured-agent-session-claude_abc:1')
|
|
162
|
+
assert.equal(notice?.agent, 'claude')
|
|
163
|
+
assert.equal(notice?.canReply, false)
|
|
164
|
+
assert.deepEqual(notice?.context, [])
|
|
165
|
+
assert.equal(w.host.callsOf('terminal.read').length, 0)
|
|
166
|
+
await assert.rejects(w.request('notices.reply', { id: notice?.id ?? '', text: 'hola' }), /no se le puede escribir/)
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
test('el orden es planes, bloqueados y esperando, y dentro el más antiguo primero', async () => {
|
|
170
|
+
const w = await start()
|
|
171
|
+
await w.emit('agent.status.changed', status('t1', 'waiting', 1000))
|
|
172
|
+
await w.emit('agent.status.changed', status('t2', 'blocked', 3000))
|
|
173
|
+
await w.emit('agent.status.changed', status('t3', 'blocked', 2000))
|
|
174
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify(PLAN)))
|
|
175
|
+
assert.deepEqual((await list(w)).map((item) => item.id), ['plan:20261107-recargas', 't:t3', 't:t2', 't:t1'])
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
test('una unidad del kit lleva su nombre de unidad', async () => {
|
|
179
|
+
const w = await start()
|
|
180
|
+
await w.hooks.fire('agent.prompt.before', {
|
|
181
|
+
agent: 'claude',
|
|
182
|
+
terminalId: 't1',
|
|
183
|
+
prompt: 'UNIT: U2 — Pagos RUN: r1 BASE: abc\nROL: Ariadna · código — nivel alto',
|
|
184
|
+
inputKind: 'orchestration'
|
|
185
|
+
})
|
|
186
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1000))
|
|
187
|
+
const [notice] = await list(w)
|
|
188
|
+
assert.equal(notice?.unit, 'U2 · Ariadna — Pagos')
|
|
189
|
+
assert.equal(notice?.title, 'U2 · Ariadna — Pagos')
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
test('responder limpia el texto, quita el aviso y no lo deja volver con el mismo estado', async () => {
|
|
193
|
+
const w = await start()
|
|
194
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1000))
|
|
195
|
+
const result = await w.request('notices.reply', { id: 't:t1', text: ' dale\u001b[31m\nahora\ty ya\r\n ' })
|
|
196
|
+
assert.deepEqual(w.host.callsOf('terminal.sendText'), [{ terminalId: 't1', text: 'dale[31m ahora y ya', enter: true }])
|
|
197
|
+
assert.equal(result.message, 'Enviado a su terminal: agente t1.')
|
|
198
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1500))
|
|
199
|
+
assert.deepEqual(await list(w), [])
|
|
200
|
+
await w.emit('agent.status.changed', status('t1', 'waiting', 2000))
|
|
201
|
+
assert.equal((await list(w)).length, 1)
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
test('responder rechaza ids desconocidos, textos vacíos o largos y no textos', async () => {
|
|
205
|
+
const w = await start()
|
|
206
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1000))
|
|
207
|
+
await assert.rejects(w.request('notices.reply', { id: 't:otro', text: 'hola' }), /ya no existe/)
|
|
208
|
+
await assert.rejects(w.request('notices.reply', { id: 't1', text: 'hola' }), /ya no existe/)
|
|
209
|
+
for (const text of ['', ' \n\t ', '\u001b\u0007', 'x'.repeat(2001), 5 as never]) {
|
|
210
|
+
await assert.rejects(w.request('notices.reply', { id: 't:t1', text }), (error: unknown) => (error as { code?: string }).code === 'invalid_params')
|
|
211
|
+
}
|
|
212
|
+
assert.equal(w.host.callsOf('terminal.sendText').length, 0)
|
|
213
|
+
assert.equal((await list(w)).length, 1)
|
|
214
|
+
await w.request('notices.reply', { id: 't:t1', text: 'x'.repeat(2000) })
|
|
215
|
+
assert.equal(w.host.callsOf('terminal.sendText').length, 1)
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
test('si el terminal no acepta el texto, el aviso se queda y el error es claro', async () => {
|
|
219
|
+
const w = await start({ 'terminal.sendText': { accepted: false } })
|
|
220
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1000))
|
|
221
|
+
await assert.rejects(w.request('notices.reply', { id: 't:t1', text: 'hola' }), /no aceptó el texto/)
|
|
222
|
+
assert.equal((await list(w)).length, 1)
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
test('descartar quita el aviso; el de un agente no vuelve hasta que cambie su estado', async () => {
|
|
226
|
+
const w = await start()
|
|
227
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1000))
|
|
228
|
+
await w.request('notices.dismiss', { id: 't:t1' })
|
|
229
|
+
assert.deepEqual(await list(w), [])
|
|
230
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1200))
|
|
231
|
+
assert.deepEqual(await list(w), [])
|
|
232
|
+
await w.emit('agent.status.changed', status('t1', 'working', 1500))
|
|
233
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 2000))
|
|
234
|
+
assert.equal((await list(w)).length, 1)
|
|
235
|
+
await assert.rejects(w.request('notices.dismiss', { id: 'nada' }), /ya no existe/)
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
test('un plan descartado no vuelve hasta que llegue otro plan.json', async () => {
|
|
239
|
+
const w = await start()
|
|
240
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify(PLAN)))
|
|
241
|
+
await w.request('notices.dismiss', { id: 'plan:20261107-recargas' })
|
|
242
|
+
assert.deepEqual(await list(w), [])
|
|
243
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1000))
|
|
244
|
+
assert.equal((await list(w)).length, 1)
|
|
245
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify(PLAN)))
|
|
246
|
+
assert.equal((await list(w)).length, 2)
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
test('al quitar un workspace salen sus avisos de agente, no los planes', async () => {
|
|
250
|
+
const w = await start()
|
|
251
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1000))
|
|
252
|
+
await w.hooks.fire('agent.tool.after', write(PLAN_PATH, JSON.stringify(PLAN)))
|
|
253
|
+
await w.emit('workspace.removed', { workspaceId: 'w1', kind: 'worktree', path: '/repo/app' })
|
|
254
|
+
assert.deepEqual((await list(w)).map((item) => item.id), ['plan:20261107-recargas'])
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
test('notices.changed solo se publica cuando cambia lo que se ve', async () => {
|
|
258
|
+
const w = await start()
|
|
259
|
+
const changes = () => w.posts.filter((post) => post.event === 'notices.changed').length
|
|
260
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1000))
|
|
261
|
+
await settle()
|
|
262
|
+
const before = changes()
|
|
263
|
+
await w.emit('agent.status.changed', status('t1', 'blocked', 1000))
|
|
264
|
+
assert.equal(changes(), before)
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
// Un coordinador que corre como chat de Orca: sin terminal ni hook de herramientas. El plan sale
|
|
268
|
+
// del disco cuando se para, y la respuesta va al buzón de su run de Orca.
|
|
269
|
+
const CHAT_PANE = 'structured-agent-session-claude_abc:1'
|
|
270
|
+
const chatStatus = (state: 'working' | 'waiting', receivedAt: number) => ({ workspaceId: 'w1', paneKey: CHAT_PANE, state, receivedAt })
|
|
271
|
+
|
|
272
|
+
const withSystem = (plans: { mtimeMs: number; content: string }[]) => {
|
|
273
|
+
const sent: { orcaRun: string; subject: string; body: string }[] = []
|
|
274
|
+
const reads: { path: string; since: number }[] = []
|
|
275
|
+
const previous = main.hostSystem.current
|
|
276
|
+
main.hostSystem.current = {
|
|
277
|
+
readPlans: async (path, since) => {
|
|
278
|
+
reads.push({ path, since })
|
|
279
|
+
return plans.filter((plan) => plan.mtimeMs > since).map((plan) => ({ path: `${path}/.work/runs/r1/plan.json`, ...plan }))
|
|
280
|
+
},
|
|
281
|
+
sendToRun: async (orcaRun, subject, body) => {
|
|
282
|
+
sent.push({ orcaRun, subject, body })
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return { sent, reads, restore: () => (main.hostSystem.current = previous) }
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
test('con el coordinador en un chat, el plan sale del disco al pararse y «sí» va al buzón de su run', async () => {
|
|
289
|
+
const later = Date.now() + 60_000
|
|
290
|
+
const system = withSystem([{ mtimeMs: later, content: JSON.stringify({ ...PLAN, orcaRun: 'run_4fbb2d2e147c' }) }])
|
|
291
|
+
try {
|
|
292
|
+
const w = await start()
|
|
293
|
+
await w.emit('agent.status.changed', chatStatus('waiting', 1))
|
|
294
|
+
await settle()
|
|
295
|
+
const [plan, chat] = await list(w)
|
|
296
|
+
assert.equal(plan?.kind, 'plan')
|
|
297
|
+
assert.equal(plan?.via, 'run')
|
|
298
|
+
assert.equal(plan?.canReply, true)
|
|
299
|
+
assert.deepEqual(system.reads.map(({ path }) => path), ['/repo/app'])
|
|
300
|
+
// El chat del coordinador también se puede contestar: va al mismo buzón.
|
|
301
|
+
await w.emit('agent.status.changed', chatStatus('working', 2))
|
|
302
|
+
await w.emit('agent.status.changed', chatStatus('waiting', 3))
|
|
303
|
+
await settle()
|
|
304
|
+
assert.equal((await list(w)).find(({ kind }) => kind === 'waiting')?.via, 'run')
|
|
305
|
+
assert.ok(chat === undefined || chat.kind === 'waiting')
|
|
306
|
+
const result = await w.request('notices.reply', { id: plan?.id ?? '', text: 'sí' })
|
|
307
|
+
assert.match(result.message, /al chat del coordinador/)
|
|
308
|
+
assert.deepEqual(system.sent, [{ orcaRun: 'run_4fbb2d2e147c', subject: 'Respuesta desde el panel: Plan de rondas · 20261107-recargas', body: 'sí' }])
|
|
309
|
+
assert.equal(w.host.callsOf('terminal.sendText').length, 0)
|
|
310
|
+
// Pararse otra vez no lo saca de nuevo: ese plan.json ya se vio.
|
|
311
|
+
await w.emit('agent.status.changed', chatStatus('working', 4))
|
|
312
|
+
await w.emit('agent.status.changed', chatStatus('waiting', 5))
|
|
313
|
+
await settle()
|
|
314
|
+
assert.equal((await list(w)).filter(({ kind }) => kind === 'plan').length, 0)
|
|
315
|
+
} finally {
|
|
316
|
+
system.restore()
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
test('un plan.json de antes de arrancar el plugin no sale, y sin run de Orca el chat no se puede contestar', async () => {
|
|
321
|
+
const system = withSystem([{ mtimeMs: 1, content: JSON.stringify(PLAN) }])
|
|
322
|
+
try {
|
|
323
|
+
const w = await start()
|
|
324
|
+
await w.emit('agent.status.changed', chatStatus('waiting', 1))
|
|
325
|
+
await settle()
|
|
326
|
+
const items = await list(w)
|
|
327
|
+
assert.deepEqual(items.map(({ kind }) => kind), ['waiting'])
|
|
328
|
+
assert.equal(items[0]?.canReply, false)
|
|
329
|
+
assert.equal(items[0]?.via, null)
|
|
330
|
+
await assert.rejects(w.request('notices.reply', { id: items[0]?.id ?? '', text: 'hola' }), /no se le puede escribir/)
|
|
331
|
+
assert.deepEqual(system.sent, [])
|
|
332
|
+
} finally {
|
|
333
|
+
system.restore()
|
|
334
|
+
}
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
test('si Orca no entrega la respuesta, se dice y el aviso se queda', async () => {
|
|
338
|
+
const later = Date.now() + 60_000
|
|
339
|
+
const system = withSystem([{ mtimeMs: later, content: JSON.stringify({ ...PLAN, orcaRun: 'run_4fbb2d2e147c' }) }])
|
|
340
|
+
main.hostSystem.current = {
|
|
341
|
+
...main.hostSystem.current,
|
|
342
|
+
sendToRun: async () => {
|
|
343
|
+
throw Object.assign(new Error('Orca no entregó el mensaje (runtime_unavailable: x)'), { code: 'unavailable' })
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
try {
|
|
347
|
+
const w = await start()
|
|
348
|
+
await w.emit('agent.status.changed', chatStatus('waiting', 1))
|
|
349
|
+
await settle()
|
|
350
|
+
const [plan] = await list(w)
|
|
351
|
+
await assert.rejects(w.request('notices.reply', { id: plan?.id ?? '', text: 'sí' }), /no entregó/)
|
|
352
|
+
assert.equal((await list(w))[0]?.kind, 'plan')
|
|
353
|
+
} finally {
|
|
354
|
+
system.restore()
|
|
355
|
+
}
|
|
356
|
+
})
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
// Pestaña Avisos: lo que espera a la persona (planes de rondas por confirmar, agentes bloqueados o
|
|
2
|
+
// esperando) y sus respuestas. Con terminal, la respuesta se escribe en él; con el coordinador en un
|
|
3
|
+
// chat de Orca, va al buzón de su run de Orca, que se la entrega en el chat (src/worker/system.ts).
|
|
4
|
+
// Estado en memoria: un aviso por agente que espera (clave del núcleo) y uno por plan (`plan:<run>`).
|
|
5
|
+
import { agentName, canonicalWorkspaceId, cleanLabel, type TrackedAgent } from '../kit.ts'
|
|
6
|
+
import { parsePlan, planPathRun } from '../plan-card.ts'
|
|
7
|
+
import type { NoticeItem, PlanCard } from '../protocol.ts'
|
|
8
|
+
import type { KitContext, KitEvents } from './context.ts'
|
|
9
|
+
|
|
10
|
+
const CONTEXT_READ_LINES = 40
|
|
11
|
+
const CONTEXT_LINES = 12
|
|
12
|
+
const CONTEXT_LINE_MAX = 200
|
|
13
|
+
const PLAN_BYTES_MAX = 64 * 1024
|
|
14
|
+
const REPLY_MAX = 2000
|
|
15
|
+
const DETAIL_MAX = 120
|
|
16
|
+
const KIND_ORDER: Record<NoticeItem['kind'], number> = { plan: 0, blocked: 1, waiting: 2 }
|
|
17
|
+
|
|
18
|
+
// Códigos de escape de terminal (CSI y OSC) antes de quitar los demás caracteres de control.
|
|
19
|
+
const ANSI = /\u001b\[[0-?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g
|
|
20
|
+
|
|
21
|
+
// Un aviso y lo que el panel no ve: el terminal o el run de Orca al que se responde, su workspace
|
|
22
|
+
// y su run del kit.
|
|
23
|
+
type Entry = {
|
|
24
|
+
item: NoticeItem
|
|
25
|
+
terminalId: string | null
|
|
26
|
+
workspaceId: string | null
|
|
27
|
+
run: string | null
|
|
28
|
+
orcaRun: string | null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Quién ha escrito o tiene el plan: el agente que se para o el que llama a su herramienta.
|
|
32
|
+
type PlanSource = { agent: string | null; terminalId: string | null; workspaceId: string | null; at: number }
|
|
33
|
+
|
|
34
|
+
const invalidParams = (message: string) => Object.assign(new Error(message), { code: 'invalid_params' })
|
|
35
|
+
const describeError = (error: unknown) => (error instanceof Error ? error.message : String(error))
|
|
36
|
+
|
|
37
|
+
// Una línea sin saltos, tabuladores ni caracteres de control o de formato, recortada.
|
|
38
|
+
function replyText(value: unknown): string {
|
|
39
|
+
if (typeof value !== 'string') throw invalidParams('el texto de la respuesta no es un texto')
|
|
40
|
+
const text = value
|
|
41
|
+
.replace(/\r\n|\n|\t/g, ' ')
|
|
42
|
+
.replace(/[\p{Cc}\p{Cf}]/gu, '')
|
|
43
|
+
.trim()
|
|
44
|
+
if (text === '') throw invalidParams('la respuesta está vacía')
|
|
45
|
+
if (text.length > REPLY_MAX) throw invalidParams(`la respuesta pasa de ${REPLY_MAX} caracteres`)
|
|
46
|
+
return text
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function contextLines(lines: readonly string[]): string[] {
|
|
50
|
+
const clean: string[] = []
|
|
51
|
+
for (const line of lines) {
|
|
52
|
+
const text = cleanLabel(line.replace(ANSI, ''), CONTEXT_LINE_MAX)
|
|
53
|
+
if (text !== null) clean.push(text)
|
|
54
|
+
}
|
|
55
|
+
return clean.slice(-CONTEXT_LINES)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Por dónde va la respuesta: el terminal manda; sin él, el buzón del run de Orca del coordinador. */
|
|
59
|
+
function route(terminalId: string | null, orcaRun: string | null): Pick<NoticeItem, 'canReply' | 'via'> {
|
|
60
|
+
if (terminalId !== null) return { canReply: true, via: 'terminal' }
|
|
61
|
+
if (orcaRun !== null) return { canReply: true, via: 'run' }
|
|
62
|
+
return { canReply: false, via: null }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function registerNotices(ctx: KitContext): void {
|
|
66
|
+
const entries = new Map<string, Entry>()
|
|
67
|
+
// Avisos de agente descartados, con el estado en que se descartaron: no vuelven hasta que cambie.
|
|
68
|
+
const dismissed = new Map<string, TrackedAgent['state']>()
|
|
69
|
+
// Por workspace del coordinador, el run de Orca de su último plan: su buzón llega a su chat.
|
|
70
|
+
const coordinatorRuns = new Map<string, string>()
|
|
71
|
+
// Por carpeta de workspace, hasta cuándo se han mirado sus plan.json. Los de antes de arrancar
|
|
72
|
+
// el plugin no salen: son de runs ya confirmados o abandonados.
|
|
73
|
+
const plansSeen = new Map<string, number>()
|
|
74
|
+
const startedAt = Date.now()
|
|
75
|
+
let posted = ''
|
|
76
|
+
|
|
77
|
+
const items = () =>
|
|
78
|
+
[...entries.values()]
|
|
79
|
+
.map(({ item }) => item)
|
|
80
|
+
.sort((a, b) => KIND_ORDER[a.kind] - KIND_ORDER[b.kind] || a.since - b.since)
|
|
81
|
+
|
|
82
|
+
// Los paneles abiertos reciben la lista solo cuando cambia lo serializado.
|
|
83
|
+
const publish = () => {
|
|
84
|
+
const view = { items: items() }
|
|
85
|
+
const serialized = JSON.stringify(view)
|
|
86
|
+
if (serialized === posted) return
|
|
87
|
+
posted = serialized
|
|
88
|
+
ctx.panels.post('notices.changed', view)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const remove = (id: string) => {
|
|
92
|
+
if (entries.delete(id)) publish()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Lo último que pinta el terminal. Un fallo se registra y el aviso se queda sin contexto.
|
|
96
|
+
const loadContext = async (id: string, terminalId: string, since: number) => {
|
|
97
|
+
let lines: string[]
|
|
98
|
+
try {
|
|
99
|
+
lines = contextLines((await ctx.host.call('terminal.read', { terminalId, maxLines: CONTEXT_READ_LINES })).lines)
|
|
100
|
+
} catch (error) {
|
|
101
|
+
ctx.log(`contexto de ${id} no leído: ${describeError(error)}`)
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
const entry = entries.get(id)
|
|
105
|
+
// El agente pudo cambiar de estado o desaparecer mientras se leía.
|
|
106
|
+
if (!entry || entry.item.since !== since) return
|
|
107
|
+
entries.set(id, { ...entry, item: { ...entry.item, context: lines } })
|
|
108
|
+
publish()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const showPlan = (plan: PlanCard, source: PlanSource) => {
|
|
112
|
+
const id = `plan:${plan.run}`
|
|
113
|
+
const rounds = new Set(plan.units.map(({ round }) => round)).size
|
|
114
|
+
const summary = `${plan.units.length} unidades en ${rounds} rondas`
|
|
115
|
+
if (plan.orcaRun !== null && source.workspaceId !== null) coordinatorRuns.set(source.workspaceId, plan.orcaRun)
|
|
116
|
+
entries.set(id, {
|
|
117
|
+
item: {
|
|
118
|
+
id,
|
|
119
|
+
kind: 'plan',
|
|
120
|
+
title: `Plan de rondas · ${plan.run}`,
|
|
121
|
+
agent: source.agent === null ? null : cleanLabel(source.agent, 40),
|
|
122
|
+
workspace: ctx.workspaceName(source.workspaceId),
|
|
123
|
+
unit: null,
|
|
124
|
+
since: source.at,
|
|
125
|
+
context: [],
|
|
126
|
+
...route(source.terminalId, plan.orcaRun),
|
|
127
|
+
plan
|
|
128
|
+
},
|
|
129
|
+
terminalId: source.terminalId,
|
|
130
|
+
workspaceId: source.workspaceId,
|
|
131
|
+
run: plan.run,
|
|
132
|
+
orcaRun: plan.orcaRun
|
|
133
|
+
})
|
|
134
|
+
publish()
|
|
135
|
+
ctx.notify(`Plan listo: ${plan.run}`, `${summary}. Confírmalo en Avisos.`)
|
|
136
|
+
ctx.emit('action', { kind: 'plan', title: `Plan listo: ${plan.run}`, detail: summary, agentKey: null, run: plan.run, at: source.at })
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Un plan.json escrito: se valida entero; lo que no encaja queda en el log y no sale.
|
|
140
|
+
const learnPlan = (label: string, content: unknown, source: PlanSource) => {
|
|
141
|
+
if (typeof content !== 'string' || content.length > PLAN_BYTES_MAX) {
|
|
142
|
+
ctx.log(`plan.json ignorado (${label}): el contenido no es un texto de hasta 64 KB`)
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
let plan
|
|
146
|
+
try {
|
|
147
|
+
plan = parsePlan(JSON.parse(content))
|
|
148
|
+
} catch (error) {
|
|
149
|
+
ctx.log(`plan.json ignorado (${label}): JSON roto, ${describeError(error)}`)
|
|
150
|
+
return
|
|
151
|
+
}
|
|
152
|
+
if (plan === null) {
|
|
153
|
+
ctx.log(`plan.json ignorado (${label}): no encaja con la versión 1 de plan-card.md`)
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
showPlan(plan, source)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const workspacePath = (workspaceId: string | null) => {
|
|
160
|
+
if (workspaceId === null) return null
|
|
161
|
+
const index = ctx.workspaces()
|
|
162
|
+
return index.byId.get(canonicalWorkspaceId(workspaceId, index))?.path ?? null
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Cuando un agente se para (también un chat de Orca, que no avisa de sus herramientas), los
|
|
166
|
+
// plan.json nuevos de su workspace.
|
|
167
|
+
const scanPlans = async (source: PlanSource) => {
|
|
168
|
+
const path = workspacePath(source.workspaceId)
|
|
169
|
+
if (path === null) return
|
|
170
|
+
const since = plansSeen.get(path) ?? startedAt
|
|
171
|
+
let files
|
|
172
|
+
try {
|
|
173
|
+
files = await ctx.system.readPlans(path, since)
|
|
174
|
+
} catch (error) {
|
|
175
|
+
ctx.log(`plan.json de ${cleanLabel(path, 120)} no leídos: ${describeError(error)}`)
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
if (files.length === 0) return
|
|
179
|
+
plansSeen.set(path, Math.max(since, ...files.map(({ mtimeMs }) => mtimeMs)))
|
|
180
|
+
for (const file of files) learnPlan(cleanLabel(file.path, 120) ?? 'plan.json', file.content, source)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const onAgent = ({ key, agent, state, at }: KitEvents['agent']) => {
|
|
184
|
+
if (agent === null || (state !== 'blocked' && state !== 'waiting')) {
|
|
185
|
+
dismissed.delete(key)
|
|
186
|
+
remove(key)
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
const terminalId = agent.terminalId ?? null
|
|
190
|
+
if (state === 'waiting') {
|
|
191
|
+
void scanPlans({ agent: agent.agent ?? null, terminalId, workspaceId: agent.workspaceId, at })
|
|
192
|
+
}
|
|
193
|
+
if (dismissed.get(key) === state) return
|
|
194
|
+
dismissed.delete(key)
|
|
195
|
+
const previous = entries.get(key)
|
|
196
|
+
const since = agent.since ?? at
|
|
197
|
+
const changed = previous?.item.kind !== state || previous.item.since !== since
|
|
198
|
+
const { unit } = agent
|
|
199
|
+
// Un chat que coordina un run con plan: se le responde por el buzón de ese run.
|
|
200
|
+
const orcaRun = terminalId === null && agent.workspaceId !== null ? (coordinatorRuns.get(agent.workspaceId) ?? null) : null
|
|
201
|
+
const item: NoticeItem = {
|
|
202
|
+
id: key,
|
|
203
|
+
kind: state,
|
|
204
|
+
title: agentName(agent),
|
|
205
|
+
agent: agent.agent ?? null,
|
|
206
|
+
workspace: ctx.workspaceName(agent.workspaceId),
|
|
207
|
+
unit: unit ? agentName({ ...agent, title: null }) : null,
|
|
208
|
+
since,
|
|
209
|
+
context: changed ? [] : (previous?.item.context ?? []),
|
|
210
|
+
...route(terminalId, orcaRun),
|
|
211
|
+
plan: null
|
|
212
|
+
}
|
|
213
|
+
entries.set(key, { item, terminalId, workspaceId: agent.workspaceId, run: unit?.run ?? null, orcaRun })
|
|
214
|
+
publish()
|
|
215
|
+
if (changed && terminalId !== null) void loadContext(key, terminalId, since)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const onTool = (event: KitEvents['tool']) => {
|
|
219
|
+
if (event.tool !== 'Write') return
|
|
220
|
+
const input = event.input
|
|
221
|
+
if (typeof input !== 'object' || input === null || Array.isArray(input)) return
|
|
222
|
+
const { file_path: file, content } = input
|
|
223
|
+
if (typeof file !== 'string' || planPathRun(file) === null) return
|
|
224
|
+
// Visto por el hook: cuando el agente se pare no se vuelve a sacar del disco.
|
|
225
|
+
const path = workspacePath(event.workspaceId)
|
|
226
|
+
if (path !== null) plansSeen.set(path, Date.now())
|
|
227
|
+
learnPlan(cleanLabel(file, 120) ?? 'plan.json', content, {
|
|
228
|
+
agent: event.agent,
|
|
229
|
+
terminalId: event.terminalId,
|
|
230
|
+
workspaceId: event.workspaceId,
|
|
231
|
+
at: event.at
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
ctx.on('agent', onAgent)
|
|
236
|
+
ctx.on('tool', onTool)
|
|
237
|
+
ctx.on('workspaceRemoved', ({ workspaceId }) => {
|
|
238
|
+
for (const [id, entry] of entries) {
|
|
239
|
+
if (entry.item.kind !== 'plan' && entry.workspaceId === workspaceId) entries.delete(id)
|
|
240
|
+
}
|
|
241
|
+
coordinatorRuns.delete(workspaceId)
|
|
242
|
+
for (const key of dismissed.keys()) if (!ctx.agents.has(key)) dismissed.delete(key)
|
|
243
|
+
publish()
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
ctx.panels.handle('notices.list', () => ({ items: items() }))
|
|
247
|
+
|
|
248
|
+
ctx.panels.handle('notices.reply', async (input) => {
|
|
249
|
+
const id: unknown = input?.id
|
|
250
|
+
const entry = typeof id === 'string' ? entries.get(id) : undefined
|
|
251
|
+
if (!entry) throw invalidParams('ese aviso ya no existe')
|
|
252
|
+
const { terminalId, orcaRun } = entry
|
|
253
|
+
if (!entry.item.canReply || (terminalId === null && orcaRun === null)) {
|
|
254
|
+
throw invalidParams('a ese aviso no se le puede escribir desde aquí')
|
|
255
|
+
}
|
|
256
|
+
const text = replyText(input?.text)
|
|
257
|
+
const { title } = entry.item
|
|
258
|
+
if (terminalId !== null) {
|
|
259
|
+
const { accepted } = await ctx.host.call('terminal.sendText', { terminalId, text, enter: true })
|
|
260
|
+
if (!accepted) {
|
|
261
|
+
throw Object.assign(new Error('el terminal no aceptó el texto: puede que ya se haya cerrado'), { code: 'unavailable' })
|
|
262
|
+
}
|
|
263
|
+
} else if (orcaRun !== null) {
|
|
264
|
+
await ctx.system.sendToRun(orcaRun, `Respuesta desde el panel: ${title}`, text)
|
|
265
|
+
}
|
|
266
|
+
// Respondido: no vuelve hasta que el agente cambie de estado (un evento repetido no lo resucita).
|
|
267
|
+
if (entry.item.kind !== 'plan') dismissed.set(entry.item.id, entry.item.kind)
|
|
268
|
+
entries.delete(entry.item.id)
|
|
269
|
+
publish()
|
|
270
|
+
const agentKey = entry.item.kind !== 'plan' ? entry.item.id : terminalId === null ? null : `t:${terminalId}`
|
|
271
|
+
ctx.emit('action', {
|
|
272
|
+
kind: 'reply',
|
|
273
|
+
title: `Respuesta a ${title}`,
|
|
274
|
+
detail: cleanLabel(text, DETAIL_MAX),
|
|
275
|
+
agentKey,
|
|
276
|
+
run: entry.run,
|
|
277
|
+
at: Date.now()
|
|
278
|
+
})
|
|
279
|
+
const where = terminalId !== null ? 'a su terminal' : 'al chat del coordinador'
|
|
280
|
+
return { message: `Enviado ${where}: ${title}.` }
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
ctx.panels.handle('notices.dismiss', (input) => {
|
|
284
|
+
const id: unknown = input?.id
|
|
285
|
+
const entry = typeof id === 'string' ? entries.get(id) : undefined
|
|
286
|
+
if (!entry) throw invalidParams('ese aviso ya no existe')
|
|
287
|
+
if (entry.item.kind !== 'plan') dismissed.set(entry.item.id, entry.item.kind)
|
|
288
|
+
remove(entry.item.id)
|
|
289
|
+
return { message: `Descartado: ${entry.item.title}.` }
|
|
290
|
+
})
|
|
291
|
+
}
|