ceulen 0.7.0 → 0.9.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/extensions/lib/registry.test.ts +67 -0
  3. package/extensions/lib/registry.ts +24 -7
  4. package/extensions/modules/a2a/configPanel.ts +435 -0
  5. package/extensions/modules/a2a/index.ts +1117 -0
  6. package/extensions/modules/a2a/lib/activity.ts +173 -0
  7. package/extensions/modules/a2a/lib/client.ts +1061 -0
  8. package/extensions/modules/a2a/lib/config.ts +920 -0
  9. package/extensions/modules/a2a/lib/discovery.ts +158 -0
  10. package/extensions/modules/a2a/lib/gateway.ts +889 -0
  11. package/extensions/modules/a2a/lib/mdns.ts +233 -0
  12. package/extensions/modules/a2a/lib/outcome.ts +48 -0
  13. package/extensions/modules/a2a/lib/persistence.ts +123 -0
  14. package/extensions/modules/a2a/lib/protocol.ts +506 -0
  15. package/extensions/modules/a2a/lib/registry.ts +146 -0
  16. package/extensions/modules/a2a/lib/retry.ts +86 -0
  17. package/extensions/modules/a2a/lib/security.ts +394 -0
  18. package/extensions/modules/a2a/lib/server.ts +1436 -0
  19. package/extensions/modules/a2a/test/activity.test.ts +138 -0
  20. package/extensions/modules/a2a/test/bridge.test.ts +101 -0
  21. package/extensions/modules/a2a/test/broadcast-parse.test.ts +31 -0
  22. package/extensions/modules/a2a/test/chai.ts +101 -0
  23. package/extensions/modules/a2a/test/client.test.ts +856 -0
  24. package/extensions/modules/a2a/test/completion-guard.test.ts +73 -0
  25. package/extensions/modules/a2a/test/config.test.ts +1396 -0
  26. package/extensions/modules/a2a/test/configPanel.test.ts +393 -0
  27. package/extensions/modules/a2a/test/discovery.test.ts +144 -0
  28. package/extensions/modules/a2a/test/extension.test.ts +135 -0
  29. package/extensions/modules/a2a/test/gateway.test.ts +1449 -0
  30. package/extensions/modules/a2a/test/helpers.ts +39 -0
  31. package/extensions/modules/a2a/test/mdns.test.ts +131 -0
  32. package/extensions/modules/a2a/test/outcome.test.ts +61 -0
  33. package/extensions/modules/a2a/test/persistence.test.ts +92 -0
  34. package/extensions/modules/a2a/test/protocol.test.ts +217 -0
  35. package/extensions/modules/a2a/test/registry.test.ts +114 -0
  36. package/extensions/modules/a2a/test/retry.test.ts +136 -0
  37. package/extensions/modules/a2a/test/security.test.ts +281 -0
  38. package/extensions/modules/a2a/test/server.test.ts +1966 -0
  39. package/extensions/modules/a2a/test/tmp.ts +59 -0
  40. package/extensions/modules/a2a/test/vendor.test.ts +57 -0
  41. package/extensions/modules/a2a/types/bonjour-service.d.ts +22 -0
  42. package/extensions/modules/a2a/vendor/VENDORED.md +18 -0
  43. package/extensions/modules/a2a/vendor/package.json +1 -0
  44. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/LICENSE +23 -0
  45. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/index.d.ts +14 -0
  46. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/index.js +57 -0
  47. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/KeyValue.d.ts +4 -0
  48. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/KeyValue.js +3 -0
  49. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/bonjour.d.ts +13 -0
  50. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/bonjour.js +50 -0
  51. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/browser.d.ts +41 -0
  52. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/browser.js +209 -0
  53. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/dns-txt.d.ts +9 -0
  54. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/dns-txt.js +42 -0
  55. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/mdns-server.d.ts +14 -0
  56. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/mdns-server.js +119 -0
  57. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/registry.d.ts +14 -0
  58. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/registry.js +142 -0
  59. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service-types.d.ts +7 -0
  60. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service-types.js +53 -0
  61. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service.d.ts +58 -0
  62. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service.js +130 -0
  63. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/dns-equal.d.ts +1 -0
  64. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/dns-equal.js +13 -0
  65. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/equal-txt.d.ts +1 -0
  66. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/equal-txt.js +17 -0
  67. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-service.d.ts +4 -0
  68. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-service.js +22 -0
  69. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-txt.d.ts +3 -0
  70. package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-txt.js +6 -0
  71. package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/LICENSE +21 -0
  72. package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/classes.js +23 -0
  73. package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/index.js +1761 -0
  74. package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/opcodes.js +50 -0
  75. package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/optioncodes.js +59 -0
  76. package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/rcodes.js +50 -0
  77. package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/types.js +103 -0
  78. package/extensions/modules/a2a/vendor/vendored_deps/fast-deep-equal/LICENSE +21 -0
  79. package/extensions/modules/a2a/vendor/vendored_deps/fast-deep-equal/es6.js +73 -0
  80. package/extensions/modules/a2a/vendor/vendored_deps/fast-deep-equal/index.js +46 -0
  81. package/extensions/modules/a2a/vendor/vendored_deps/ip-codec/LICENSE +21 -0
  82. package/extensions/modules/a2a/vendor/vendored_deps/ip-codec/index.cjs +250 -0
  83. package/extensions/modules/a2a/vendor/vendored_deps/multicast-dns/LICENSE +21 -0
  84. package/extensions/modules/a2a/vendor/vendored_deps/multicast-dns/index.js +205 -0
  85. package/extensions/modules/a2a/vendor/vendored_deps/thunky/LICENSE +21 -0
  86. package/extensions/modules/a2a/vendor/vendored_deps/thunky/index.js +55 -0
  87. package/extensions/modules/advisor/index.ts +20 -2
  88. package/extensions/modules/advisor/lib/watcher.ts +3 -1
  89. package/extensions/modules/advisor/test/module.test.ts +64 -1
  90. package/extensions/modules/composer/test/module.test.ts +2 -2
  91. package/extensions/modules/config/index.ts +2 -0
  92. package/extensions/modules/config/test/renderTools.test.ts +1 -1
  93. package/extensions/modules/munin/configPanel.ts +5 -2
  94. package/extensions/modules/munin/test/configPanel.test.ts +27 -2
  95. package/extensions/modules/router/configPanel.ts +24 -10
  96. package/extensions/modules/router/lib/client.ts +6 -4
  97. package/extensions/modules/router/test/unit.test.ts +83 -2
  98. package/extensions/modules/rules/index.ts +120 -0
  99. package/extensions/modules/rules/lib/rules.ts +348 -0
  100. package/extensions/modules/rules/test/lib.test.ts +263 -0
  101. package/extensions/modules/rules/test/module.test.ts +222 -0
  102. package/extensions/modules/subagent/index.ts +19 -6
  103. package/extensions/modules/subagent/lib/routing.ts +11 -6
  104. package/extensions/modules/subagent/lib/security.ts +12 -1
  105. package/extensions/modules/subagent/test/routing.test.ts +174 -0
  106. package/extensions/modules/todo/configPanel.ts +55 -0
  107. package/extensions/modules/todo/index.ts +511 -0
  108. package/extensions/modules/todo/lib/render.ts +271 -0
  109. package/extensions/modules/todo/lib/settings.ts +73 -0
  110. package/extensions/modules/todo/test/todo.test.ts +528 -0
  111. package/extensions/modules/usage/index.ts +11 -0
  112. package/extensions/modules/usage/test/session-accumulators.test.ts +85 -0
  113. package/extensions/modules/web/configPanel.ts +38 -13
  114. package/extensions/modules/web/lib/settings.ts +11 -2
  115. package/extensions/modules/web/test/configPanel.test.ts +67 -1
  116. package/extensions/modules/zai/configPanel.ts +5 -2
  117. package/extensions/modules/zai/lib/signing.ts +4 -1
  118. package/extensions/modules/zai/test/configPanel.test.ts +23 -0
  119. package/extensions/modules/zai/test/signing.test.ts +19 -0
  120. package/package.json +2 -2
  121. package/skills/a2a/SKILL.md +63 -0
@@ -0,0 +1,205 @@
1
+ var packet = require('../dns-packet/index.js') // ponytail: vendored from multicast-dns 7.2.5 — path localized
2
+ var dgram = require('dgram')
3
+ var thunky = require('../thunky/index.js') // ponytail: vendored from multicast-dns 7.2.5 — path localized
4
+ var events = require('events')
5
+ var os = require('os')
6
+
7
+ var noop = function () {}
8
+
9
+ module.exports = function (opts) {
10
+ if (!opts) opts = {}
11
+
12
+ var that = new events.EventEmitter()
13
+ var port = typeof opts.port === 'number' ? opts.port : 5353
14
+ var type = opts.type || 'udp4'
15
+ var ip = opts.ip || opts.host || (type === 'udp4' ? '224.0.0.251' : null)
16
+ var me = {address: ip, port: port}
17
+ var memberships = {}
18
+ var destroyed = false
19
+ var interval = null
20
+
21
+ if (type === 'udp6' && (!ip || !opts.interface)) {
22
+ throw new Error('For IPv6 multicast you must specify `ip` and `interface`')
23
+ }
24
+
25
+ var socket = opts.socket || dgram.createSocket({
26
+ type: type,
27
+ reuseAddr: opts.reuseAddr !== false,
28
+ toString: function () {
29
+ return type
30
+ }
31
+ })
32
+
33
+ socket.on('error', function (err) {
34
+ if (err.code === 'EACCES' || err.code === 'EADDRINUSE') that.emit('error', err)
35
+ else that.emit('warning', err)
36
+ })
37
+
38
+ socket.on('message', function (message, rinfo) {
39
+ try {
40
+ message = packet.decode(message)
41
+ } catch (err) {
42
+ that.emit('warning', err)
43
+ return
44
+ }
45
+
46
+ that.emit('packet', message, rinfo)
47
+
48
+ if (message.type === 'query') that.emit('query', message, rinfo)
49
+ if (message.type === 'response') that.emit('response', message, rinfo)
50
+ })
51
+
52
+ socket.on('listening', function () {
53
+ if (!port) port = me.port = socket.address().port
54
+ if (opts.multicast !== false) {
55
+ that.update()
56
+ interval = setInterval(that.update, 5000)
57
+ socket.setMulticastTTL(opts.ttl || 255)
58
+ socket.setMulticastLoopback(opts.loopback !== false)
59
+ }
60
+ })
61
+
62
+ var bind = thunky(function (cb) {
63
+ if (!port || opts.bind === false) return cb(null)
64
+ socket.once('error', cb)
65
+ socket.bind(port, opts.bind || opts.interface, function () {
66
+ socket.removeListener('error', cb)
67
+ cb(null)
68
+ })
69
+ })
70
+
71
+ bind(function (err) {
72
+ if (err) return that.emit('error', err)
73
+ that.emit('ready')
74
+ })
75
+
76
+ that.send = function (value, rinfo, cb) {
77
+ if (typeof rinfo === 'function') return that.send(value, null, rinfo)
78
+ if (!cb) cb = noop
79
+ if (!rinfo) rinfo = me
80
+ else if (!rinfo.host && !rinfo.address) rinfo.address = me.address
81
+
82
+ bind(onbind)
83
+
84
+ function onbind (err) {
85
+ if (destroyed) return cb()
86
+ if (err) return cb(err)
87
+ var message = packet.encode(value)
88
+ socket.send(message, 0, message.length, rinfo.port, rinfo.address || rinfo.host, cb)
89
+ }
90
+ }
91
+
92
+ that.response =
93
+ that.respond = function (res, rinfo, cb) {
94
+ if (Array.isArray(res)) res = {answers: res}
95
+
96
+ res.type = 'response'
97
+ res.flags = (res.flags || 0) | packet.AUTHORITATIVE_ANSWER
98
+ that.send(res, rinfo, cb)
99
+ }
100
+
101
+ that.query = function (q, type, rinfo, cb) {
102
+ if (typeof type === 'function') return that.query(q, null, null, type)
103
+ if (typeof type === 'object' && type && type.port) return that.query(q, null, type, rinfo)
104
+ if (typeof rinfo === 'function') return that.query(q, type, null, rinfo)
105
+ if (!cb) cb = noop
106
+
107
+ if (typeof q === 'string') q = [{name: q, type: type || 'ANY'}]
108
+ if (Array.isArray(q)) q = {type: 'query', questions: q}
109
+
110
+ q.type = 'query'
111
+ that.send(q, rinfo, cb)
112
+ }
113
+
114
+ that.destroy = function (cb) {
115
+ if (!cb) cb = noop
116
+ if (destroyed) return process.nextTick(cb)
117
+ destroyed = true
118
+ clearInterval(interval)
119
+
120
+ // Need to drop memberships by hand and ignore errors.
121
+ // socket.close() does not cope with errors.
122
+ for (var iface in memberships) {
123
+ try {
124
+ socket.dropMembership(ip, iface)
125
+ } catch (e) {
126
+ // eat it
127
+ }
128
+ }
129
+ memberships = {}
130
+ socket.close(cb)
131
+ }
132
+
133
+ that.update = function () {
134
+ var ifaces = opts.interface ? [].concat(opts.interface) : allInterfaces()
135
+ var updated = false
136
+
137
+ for (var i = 0; i < ifaces.length; i++) {
138
+ var addr = ifaces[i]
139
+ if (memberships[addr]) continue
140
+
141
+ try {
142
+ socket.addMembership(ip, addr)
143
+ memberships[addr] = true
144
+ updated = true
145
+ } catch (err) {
146
+ that.emit('warning', err)
147
+ }
148
+ }
149
+
150
+ if (updated) {
151
+ if (socket.setMulticastInterface) {
152
+ try {
153
+ socket.setMulticastInterface(opts.interface || defaultInterface())
154
+ } catch (err) {
155
+ that.emit('warning', err)
156
+ }
157
+ }
158
+ that.emit('networkInterface')
159
+ }
160
+ }
161
+
162
+ return that
163
+ }
164
+
165
+ function defaultInterface () {
166
+ var networks = os.networkInterfaces()
167
+ var names = Object.keys(networks)
168
+
169
+ for (var i = 0; i < names.length; i++) {
170
+ var net = networks[names[i]]
171
+ for (var j = 0; j < net.length; j++) {
172
+ var iface = net[j]
173
+ if (isIPv4(iface.family) && !iface.internal) {
174
+ if (os.platform() === 'darwin' && names[i] === 'en0') return iface.address
175
+ return '0.0.0.0'
176
+ }
177
+ }
178
+ }
179
+
180
+ return '127.0.0.1'
181
+ }
182
+
183
+ function allInterfaces () {
184
+ var networks = os.networkInterfaces()
185
+ var names = Object.keys(networks)
186
+ var res = []
187
+
188
+ for (var i = 0; i < names.length; i++) {
189
+ var net = networks[names[i]]
190
+ for (var j = 0; j < net.length; j++) {
191
+ var iface = net[j]
192
+ if (isIPv4(iface.family)) {
193
+ res.push(iface.address)
194
+ // could only addMembership once per interface (https://nodejs.org/api/dgram.html#dgram_socket_addmembership_multicastaddress_multicastinterface)
195
+ break
196
+ }
197
+ }
198
+ }
199
+
200
+ return res
201
+ }
202
+
203
+ function isIPv4 (family) { // for backwards compat
204
+ return family === 4 || family === 'IPv4'
205
+ }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Mathias Buus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ 'use strict'
2
+
3
+ var nextTick = nextTickArgs
4
+ process.nextTick(upgrade, 42) // pass 42 and see if upgrade is called with it
5
+
6
+ module.exports = thunky
7
+
8
+ function thunky (fn) {
9
+ var state = run
10
+ return thunk
11
+
12
+ function thunk (callback) {
13
+ state(callback || noop)
14
+ }
15
+
16
+ function run (callback) {
17
+ var stack = [callback]
18
+ state = wait
19
+ fn(done)
20
+
21
+ function wait (callback) {
22
+ stack.push(callback)
23
+ }
24
+
25
+ function done (err) {
26
+ var args = arguments
27
+ state = isError(err) ? run : finished
28
+ while (stack.length) finished(stack.shift())
29
+
30
+ function finished (callback) {
31
+ nextTick(apply, callback, args)
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ function isError (err) { // inlined from util so this works in the browser
38
+ return Object.prototype.toString.call(err) === '[object Error]'
39
+ }
40
+
41
+ function noop () {}
42
+
43
+ function apply (callback, args) {
44
+ callback.apply(null, args)
45
+ }
46
+
47
+ function upgrade (val) {
48
+ if (val === 42) nextTick = process.nextTick
49
+ }
50
+
51
+ function nextTickArgs (fn, a, b) {
52
+ process.nextTick(function () {
53
+ fn(a, b)
54
+ })
55
+ }
@@ -34,6 +34,12 @@ export function __setIsolatedForTest(fn: IsolatedCall | undefined): void {
34
34
  testIsolated = fn;
35
35
  }
36
36
 
37
+ // ponytail: test-only read of the newest module instance's runtime (cursor/wiring assertions).
38
+ let testRuntime: (() => WatcherRuntime | undefined) | undefined;
39
+ export function __getRuntimeForTest(): WatcherRuntime | undefined {
40
+ return testRuntime?.();
41
+ }
42
+
37
43
  interface NoteData {
38
44
  severity: Severity;
39
45
  note: string;
@@ -61,6 +67,7 @@ function renderNoteCard(raw: NoteData | undefined, expanded: boolean, theme: The
61
67
 
62
68
  export default function advisorModule(pi: ExtensionAPI): void {
63
69
  let runtime: WatcherRuntime | undefined;
70
+ testRuntime = () => runtime;
64
71
  let runtimeSessionId: string | undefined;
65
72
  /** Effective settings as last loaded/applied — the base for partial writes. */
66
73
  let settings: AdvisorConfig = DEFAULTS;
@@ -75,6 +82,12 @@ export default function advisorModule(pi: ExtensionAPI): void {
75
82
  function applySettings(next: AdvisorConfig, ctx: ExtensionContext): void {
76
83
  const masterChanged = next.enabled !== settings.enabled;
77
84
  settings = next;
85
+ // The session watch state this save TARGETS — computed before the reseed
86
+ // below: an explicit master change re-arms/disarms the session, an unchanged
87
+ // master leaves a /advisor watch-off override in place. Reading watchEnabled
88
+ // directly would miss a save that sets enabled + chain together, because
89
+ // watchEnabled is only updated at the end of this function.
90
+ const willWatch = masterChanged ? next.enabled : watchEnabled;
78
91
  const rt = runtime;
79
92
  const wasEmpty = !rt || rt.models.length === 0;
80
93
  if (rt) {
@@ -86,7 +99,7 @@ export default function advisorModule(pi: ExtensionAPI): void {
86
99
  rt.failures = 0;
87
100
  }
88
101
  // Enabling mid-session must not replay history.
89
- if (wasEmpty && next.models.length > 0 && watchEnabled) reseedCursor(rt, ctx);
102
+ if (wasEmpty && next.models.length > 0 && willWatch) reseedCursor(rt, ctx);
90
103
  }
91
104
  // An explicit master change re-arms/disarms the session; otherwise a
92
105
  // /advisor watch-off override stays in place.
@@ -178,11 +191,16 @@ export default function advisorModule(pi: ExtensionAPI): void {
178
191
  // watch-off flips the flag, repeated failures pause — a review in flight
179
192
  // across any of these must deliver nothing.
180
193
  const live = () => runtime === rt && watchEnabled && rt.models.length > 0 && !rt.stats.paused;
194
+ // Reviews/notes additionally require "not paused": the 3-strike pause exists
195
+ // precisely because the review just failed, so a notify behind live() could
196
+ // never tell the user the watch stopped. Passed as a separate predicate — the
197
+ // pause flag still suppresses outbound notes and further reviews.
198
+ const alive = () => runtime === rt && watchEnabled && rt.models.length > 0;
181
199
  void reviewTurn(rt, ctx, {
182
200
  sendMessage: (message, options) => { if (live()) pi.sendMessage(message, options as never); },
183
201
  sendUserMessage: (content, options) => { if (live()) pi.sendUserMessage(content, options); },
184
202
  appendEntry: (customType, data) => { if (live()) pi.appendEntry(customType, data); },
185
- notify: (message) => { if (live()) ctx.ui.notify(message, "error"); },
203
+ notify: (message) => { if (alive()) ctx.ui.notify(message, "error"); },
186
204
  }, testIsolated).catch((err) => { if (live()) ctx.ui.notify(`Advisor review failed: ${String(err)}`, "error"); });
187
205
  });
188
206
 
@@ -171,7 +171,9 @@ export interface WatcherHost {
171
171
  sendUserMessage(content: string, options?: { deliverAs?: "steer" | "followUp" }): void;
172
172
  /** Display-only immediate card (session entry; never enters LLM context). */
173
173
  appendEntry<T = unknown>(customType: string, data?: T): void;
174
- /** Error/status toast, liveness-gated by the caller (never leaks into a replaced session). */
174
+ /** Error/status toast, liveness-gated by the caller (never leaks into a replaced session).
175
+ * The pause notice is the ONE message that must survive the runtime's own
176
+ * `stats.paused` flag — the caller gates it on liveness WITHOUT the pause term. */
175
177
  notify(message: string): void;
176
178
  }
177
179
 
@@ -3,7 +3,7 @@ import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { after, beforeEach, describe, it } from "node:test";
6
- import advisorModule, { __setIsolatedForTest } from "../index.js";
6
+ import advisorModule, { __getRuntimeForTest, __setIsolatedForTest } from "../index.js";
7
7
  import { advisorConfig } from "../configPanel.js";
8
8
  import { writeAdvisorSettings } from "../lib/config.js";
9
9
 
@@ -229,6 +229,38 @@ describe("advisor module wiring", () => {
229
229
  await cmd.handler("on", ctx);
230
230
  assert.ok(state.activeTools.has("advisor"), "tool re-activated by /advisor on without waiting for session_start");
231
231
  });
232
+
233
+ it("session_start(review off, no chain) + /config save enabling both reseeds the cursor (no history replay)", async () => {
234
+ const { pi, state } = createFakePi();
235
+ advisorModule(pi);
236
+ writeSettings({ advisor: { enabled: false } });
237
+ // Session opens with the review OFF and NO chain → runtime cursor stays undefined.
238
+ let ctx = available(fakeCtx(toolCalls(4)));
239
+ await fire(pi, state, "session_start", ctx);
240
+ const rt = __getRuntimeForTest();
241
+ assert.ok(rt, "runtime created for the session");
242
+ assert.equal(rt!.cursor, undefined, "no chain + review off → nothing reviewed yet");
243
+ assert.equal(rt!.models.length, 0, "no advisor model configured at start");
244
+
245
+ // ONE /config save sets enabled:true AND the chain. The reseed must key on
246
+ // the target watch state (willWatch), not on the not-yet-updated watchEnabled.
247
+ const entries = toolCalls(4);
248
+ ctx = available(fakeCtx(entries));
249
+ const m = advisorConfig();
250
+ m.groups()[0]!.rows[0]!.set(true);
251
+ m.groups()[0]!.rows[1]!.set(MODEL);
252
+ await m.save(new Set(["advisor.enabled", "advisor.model"]), ctx);
253
+
254
+ assert.deepEqual(readSettings().advisor, { enabled: true, models: [MODEL], watch: { minToolCalls: 3, immuneTurns: 3 } }, "enabled + chain written in one save");
255
+ assert.equal(rt!.cursor, entries.at(-1).id, "cursor reseeded to the transcript tail — the pre-existing history is not replayed");
256
+
257
+ // And the watch actually reviews only NEW work: the settled turn adds
258
+ // nothing, so the reseeded cursor leaves the existing 4 tool calls unseen.
259
+ let calls = 0;
260
+ __setIsolatedForTest(async (_c, models) => { calls++; return { text: "", model: models[0], usage: NO_USAGE }; });
261
+ await fire(pi, state, "agent_settled", step(available(fakeCtx(entries)), "tui"));
262
+ assert.equal(calls, 0, "nothing new since the reseed → no review of the pre-existing turn");
263
+ });
232
264
  });
233
265
 
234
266
  describe("advisor review flow", () => {
@@ -389,6 +421,37 @@ describe("advisor review flow", () => {
389
421
  assert.equal(calls, 0, "no isolated call without a model");
390
422
  assert.equal(state.entries.length, 0);
391
423
  });
424
+
425
+ it("the 3-strike pause notice reaches the user exactly once through the real wiring", async () => {
426
+ const { pi, state } = await arm({ advisor: { models: [MODEL], watch: { minToolCalls: 0, immuneTurns: 1 } } });
427
+ __setIsolatedForTest(async () => { throw new Error("429 rate limited"); });
428
+ const base = toolCalls(1);
429
+ const ctx = step(available(fakeCtx(base)), "tui");
430
+ // Three consecutive failing reviews — each its own settled turn with new work.
431
+ for (const extra of [toolCalls(1), toolCalls(1), toolCalls(1)]) {
432
+ ctx.sessionManager = { ...ctx.sessionManager, getEntries: () => [...base, ...extra] };
433
+ await fire(pi, state, "agent_settled", ctx);
434
+ }
435
+ const pause = ctx.notes.filter((n: any) => n.message.includes("Advisor watch paused"));
436
+ assert.equal(pause.length, 1, "the pause toast lands (previously dead code behind the paused flag)");
437
+ assert.equal(pause[0].level, "error", "delivered as an error toast");
438
+ assert.equal(__getRuntimeForTest()!.stats.paused, true, "the watch is still paused");
439
+ assert.equal(state.userMessages.length, 0, "no note delivered by the failed reviews");
440
+
441
+ // Paused means NO further reviews until /advisor on — the next turn skips.
442
+ let calls = 0;
443
+ __setIsolatedForTest(async (_c, models) => { calls++; return { text: "", model: models[0], usage: NO_USAGE }; });
444
+ ctx.sessionManager = { ...ctx.sessionManager, getEntries: () => [...base, ...toolCalls(1), ...toolCalls(1)] };
445
+ await fire(pi, state, "agent_settled", ctx);
446
+ assert.equal(calls, 0, "paused watch issues no further review");
447
+
448
+ // …and /advisor on resumes, as the notice promises: no duplicate toast.
449
+ await state.commands.get("advisor").handler("on", ctx);
450
+ assert.equal(__getRuntimeForTest()!.stats.paused, false, "resumed");
451
+ await fire(pi, state, "agent_settled", ctx);
452
+ assert.equal(calls, 1, "reviews resume after /advisor on");
453
+ assert.equal(ctx.notes.filter((n: any) => n.message.includes("Advisor watch paused")).length, 1, "still exactly one pause notice");
454
+ });
392
455
  });
393
456
 
394
457
  describe("/advisor command surface", () => {
@@ -305,8 +305,8 @@ describe("core module contract", () => {
305
305
  it("nextDisabled excludes core modules; withEnableRow adds no row for them", async () => {
306
306
  const { nextDisabled, withEnableRow } = await import("../../config/index.js");
307
307
  // working = enabled set; nextDisabled lists the NOT-enabled non-core modules.
308
- assert.deepEqual(nextDisabled(new Set(["munin"])), ["zai", "ponytail", "subagent", "plan", "steering", "repair", "serena", "fff", "web", "rtk"]);
309
- assert.deepEqual(nextDisabled(new Set(["router", "classifier", "ux", "munin", "usage", "ponytail", "subagent", "plan", "steering", "zai", "serena", "fff", "web", "repair", "rtk", "config"])), [], "all-on → nothing disabled");
308
+ assert.deepEqual(nextDisabled(new Set(["munin"])), ["zai", "ponytail", "subagent", "plan", "a2a", "todo", "repair", "serena", "fff", "web", "rules", "steering", "rtk"]);
309
+ assert.deepEqual(nextDisabled(new Set(["router", "classifier", "ux", "munin", "usage", "ponytail", "subagent", "plan", "a2a", "todo", "repair", "serena", "fff", "web", "rules", "steering", "zai", "rtk", "config"])), [], "all-on → nothing disabled");
310
310
  for (const core of ["composer", "advisor", "router", "classifier", "usage", "ux", "config"]) {
311
311
  assert.ok(!nextDisabled(new Set()).includes(core), `core (${core}) is never disableable`);
312
312
  }
@@ -253,10 +253,12 @@ export default function configModule(pi: ExtensionAPI, deps?: ModuleLoadDeps): v
253
253
  ux: { section: "UX discipline", icon: "📐" },
254
254
  ponytail: { section: "Ponytail", icon: "🦥" },
255
255
  plan: { section: "Plan mode", icon: "🗺️" },
256
+ todo: { section: "Todo", icon: "☑" },
256
257
  serena: { section: "Serena" },
257
258
  repair: { section: "Repair", icon: "🔧" },
258
259
  fff: { section: "FFF search" },
259
260
  web: { section: "Web", icon: "🌍" },
261
+ a2a: { section: "A2A", icon: "📡" },
260
262
  rtk: { section: "RTK" },
261
263
  config: { section: "Ceulen config", icon: "🧩" },
262
264
  };
@@ -34,7 +34,7 @@ function toolGroups(): PanelGroup[] {
34
34
  describe("render smoke — ported modules' /config sections", () => {
35
35
  it("renders Enable + per-tool rows inside the boxed frame with zero overflow", () => {
36
36
  const groups = toolGroups();
37
- assert.equal(groups.length, 10, "serena + fff + ux + munin + classifier + advisor + subagent + repair + plan + web (rtk has no tools)");
37
+ assert.equal(groups.length, 13, "serena + fff + ux + munin + classifier + advisor + subagent + repair + plan + todo + web + rules + a2a (rtk has no tools)");
38
38
  const m = new ConfigPanelModel(groups, theme, "Settings");
39
39
  m.getHeight = () => 40;
40
40
  for (const w of [110, 100, 80, 60]) {
@@ -7,7 +7,7 @@
7
7
 
8
8
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
9
9
  import { row, type PanelGroup } from "../../lib/panel.js";
10
- import type { ModuleConfig } from "../../lib/registry.js";
10
+ import { isProjectTrusted, type ModuleConfig } from "../../lib/registry.js";
11
11
  import {
12
12
  DEFAULT_MUNIN_BASE_URL,
13
13
  getMuninConfig,
@@ -76,7 +76,10 @@ const OWNED_PREFIX = "munin.";
76
76
  * from the save ctx (factories receive none); reads use process.cwd(),
77
77
  * matching router's panel pattern. */
78
78
  export function muninConfig(): ModuleConfig {
79
- const before = readMuninSettings(process.cwd(), true);
79
+ // Baseline = what the tools resolve: the factory has no ctx, so the shared
80
+ // trust helper decides (the same rule the save ctx applies) — an untrusted
81
+ // checkout must not show phantom project values.
82
+ const before = readMuninSettings(process.cwd(), isProjectTrusted(process.cwd()));
80
83
  const working = structuredClone(before);
81
84
  return {
82
85
  groups: () => buildMuninGroups(working),
@@ -1,7 +1,7 @@
1
1
  // NEW for the ceulen port — panel groups shape, effective-value display, and
2
2
  // the project-level save path (write target, patch diffing, trust + env notes).
3
3
 
4
- import { mkdtempSync, mkdirSync, rmSync, writeFileSync, readFileSync } from "node:fs";
4
+ import { mkdtempSync, mkdirSync, realpathSync, rmSync, writeFileSync, readFileSync } from "node:fs";
5
5
  import { tmpdir } from "node:os";
6
6
  import { join } from "node:path";
7
7
  import { describe, it, beforeEach, afterEach } from "node:test";
@@ -9,7 +9,7 @@ import assert from "node:assert/strict";
9
9
  import { projectSettingsPath } from "../lib/helpers.js";
10
10
  import { buildMuninGroups, muninConfig, readMuninSettings, type MuninSettings } from "../configPanel.js";
11
11
 
12
- const ENV_KEYS = ["MUNIN_API_KEY", "MUNIN_PROJECT", "MUNIN_BASE_URL"] as const;
12
+ const ENV_KEYS = ["MUNIN_API_KEY", "MUNIN_PROJECT", "MUNIN_BASE_URL", "PI_CODING_AGENT_DIR"] as const;
13
13
 
14
14
  describe("buildMuninGroups", () => {
15
15
  it("renders the Memory tab with masked apiKey row", () => {
@@ -68,6 +68,31 @@ describe("readMuninSettings", () => {
68
68
  const none = readMuninSettings(join(cwd, "nowhere"), false);
69
69
  assert.deepEqual(none, { project: "", baseUrl: "https://munin.kalera.ai", apiKey: "" });
70
70
  });
71
+
72
+ it("muninConfig resolves the trust flag itself (no phantom project values untrusted)", () => {
73
+ // The factory gets no ctx, so the baseline must resolve trust through the
74
+ // shared helper — a hardcoded `true` shows a trusted-project value in an
75
+ // UNTRUSTED checkout (the phantom-value bug class).
76
+ const agentDir = mkdtempSync(join(tmpdir(), "munin-agent-"));
77
+ const cwd = mkdtempSync(join(tmpdir(), "munin-trust-"));
78
+ dirs.push(agentDir, cwd);
79
+ process.env.PI_CODING_AGENT_DIR = agentDir;
80
+ process.env.MUNIN_API_KEY = "env-key"; // keep getMuninConfig from throwing
81
+ process.env.MUNIN_PROJECT = "env-id";
82
+ mkdirSync(join(cwd, ".pi"), { recursive: true });
83
+ writeFileSync(projectSettingsPath(cwd), JSON.stringify({ munin: { baseUrl: "https://project.test" } }));
84
+ const prevCwd = process.cwd();
85
+ process.chdir(cwd);
86
+ const baseUrlRow = () => muninConfig().groups()[0]!.rows[1]!.value;
87
+ try {
88
+ writeFileSync(join(agentDir, "trust.json"), JSON.stringify({ [process.cwd()]: true }));
89
+ assert.equal(baseUrlRow(), "https://project.test", "trusted → project value shown");
90
+ writeFileSync(join(agentDir, "trust.json"), JSON.stringify({ [process.cwd()]: false }));
91
+ assert.equal(baseUrlRow(), "https://munin.kalera.ai", "untrusted → project value ignored");
92
+ } finally {
93
+ process.chdir(prevCwd);
94
+ }
95
+ });
71
96
  });
72
97
 
73
98
  describe("muninConfig save", () => {
@@ -5,12 +5,20 @@
5
5
  */
6
6
 
7
7
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
8
- import type { ModuleConfig } from "../../lib/registry.js";
8
+ import { isProjectTrusted, type ModuleConfig } from "../../lib/registry.js";
9
9
  import { row, type PanelGroup } from "../../lib/panel.js";
10
10
  import { getSettings, writeRouterSection, type RouterSettings } from "./lib/config.js";
11
11
  import { registerProvider, maybeRefreshCatalog } from "./lib/provider.js";
12
12
  import { refreshActiveModel } from "./lib/refresh.js";
13
13
 
14
+ /** Read the panel's working copy: the EFFECTIVE values (env/project overrides
15
+ * shown), so the panel never hides what the next request will actually use.
16
+ * `trusted` is required — the caller decides, mirroring the rule the save-time
17
+ * ctx applies (see zai's precedent). */
18
+ export function readRouterSettings(trusted: boolean): RouterSettings {
19
+ return getSettings({ trustProject: trusted });
20
+ }
21
+
14
22
  /** Build the router panel groups over a working copy (mutated by row setters).
15
23
  * ONE group — the OMP "Providers" tab carries a single "Router" section
16
24
  * (its Enable kill-switch row is prepended by the config module). Exported
@@ -40,12 +48,14 @@ export function buildRouterGroups(cfg: RouterSettings): PanelGroup[] {
40
48
  ];
41
49
  }
42
50
 
43
- /** Persist the working copy + apply it live: re-register the provider so its
44
- * closure picks up the new values, force a catalog refresh (new endpoint or
45
- * reasoning flag must take effect immediately — bypass TTL, supersede any
46
- * in-flight fetch), then keep the active model valid. Notifies effective vs
47
- * saved values (env/repo precedence can shadow the persisted ones) — one
48
- * save path, no drift. */
51
+ /** Persist the working copy + apply it live: re-register the provider from the
52
+ * EFFECTIVE settings (so a trusted repo's `router.baseUrl` is what the next
53
+ * request and the forced catalog refresh actually use — re-registering the raw
54
+ * saved copy would redirect the endpoint while `ROUTER_BASE_URL` set), force a
55
+ * catalog refresh (new endpoint or reasoning flag must take effect immediately
56
+ * — bypass TTL, supersede any in-flight fetch), then keep the active model
57
+ * valid. Notifies effective vs saved values (env/repo precedence can shadow
58
+ * the persisted ones) — one save path, no drift. */
49
59
  export async function saveRouterConfig(pi: ExtensionAPI, before: RouterSettings, working: RouterSettings, ctx: ExtensionContext): Promise<void> {
50
60
  if (working.baseUrl === before.baseUrl && working.enableReasoning === before.enableReasoning) {
51
61
  ctx.ui.notify("No changes.", "info");
@@ -55,12 +65,13 @@ export async function saveRouterConfig(pi: ExtensionAPI, before: RouterSettings,
55
65
  baseUrl: working.baseUrl !== before.baseUrl ? working.baseUrl : undefined,
56
66
  enableReasoning: working.enableReasoning !== before.enableReasoning ? working.enableReasoning : undefined,
57
67
  });
58
- registerProvider(pi, working);
68
+ const trusted = ctx.isProjectTrusted?.() === true;
69
+ const effective = readRouterSettings(trusted);
70
+ registerProvider(pi, effective);
59
71
  try {
60
72
  await maybeRefreshCatalog(ctx, { force: true });
61
73
  } catch { /* refresh errors are surfaced by Pi elsewhere */ }
62
74
  await refreshActiveModel(pi, ctx);
63
- const effective = getSettings();
64
75
  const overridden =
65
76
  (working.baseUrl !== effective.baseUrl && working.baseUrl !== "") ||
66
77
  working.enableReasoning !== effective.enableReasoning;
@@ -77,7 +88,10 @@ const OWNED_KEYS = ["router.baseUrl", "router.enableReasoning"];
77
88
 
78
89
  /** Router's ModuleConfig for the central /config panel. */
79
90
  export function routerConfig(pi: ExtensionAPI): ModuleConfig {
80
- const before = getSettings();
91
+ // Baseline = what the next request resolves: the factory gets no ctx, so the
92
+ // shared trust helper decides (same rule save-time ctx.isProjectTrusted
93
+ // applies) — an untrusted checkout must not show phantom project values.
94
+ const before = readRouterSettings(isProjectTrusted(process.cwd()));
81
95
  const working = structuredClone(before);
82
96
  return {
83
97
  groups: () => buildRouterGroups(working),
@@ -276,10 +276,12 @@ const FORMAT_TO_LEVEL_MAP: Record<string, Record<string, string | null>> = {
276
276
  // (GLM's single thinking-on tier), max→"max"; xhigh/minimal unsupported (hidden).
277
277
  "zai": { off:"none", minimal:null, low:"high", medium:"high", high:"high", xhigh:null, max:"max" },
278
278
  "minimax": { off:"none", minimal:null, low:"low", medium:"medium", high:"high", xhigh:"xhigh", max:"xhigh" },
279
- // Yardmaster CC-enum backends (combo/, live-probed): valid effort values are
280
- // exactly off|low|medium|high|xhigh|max — "none"/"minimal" 400. "off" is
281
- // honored (omitting it leaves the upstream defaulting to thinking ON).
282
- "cc-enum": { off:"off", minimal:null, low:"low", medium:"medium", high:"high", xhigh:"xhigh", max:"max" },
279
+ // Yardmaster CC-enum backends (combo/, live-probed): "none"/"minimal" 400,
280
+ // and the literal "off" 422s too (reasoning_effort: unknown variant 'off',
281
+ // observed live on combo/deepseek-v4.1-flash 2026-10-04 — an earlier probe
282
+ // claiming off was honored was wrong). off → null omits the parameter
283
+ // entirely (SDK no-level branch); the upstream then applies its own default.
284
+ "cc-enum": { off:null, minimal:null, low:"low", medium:"medium", high:"high", xhigh:"xhigh", max:"max" },
283
285
  };
284
286
 
285
287
  function getThinkingLevelMap(modelId: string): Record<string, string | null> {