@decibelsystems/tools 2.0.2 → 2.1.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/README.md +115 -233
- package/dist/daemon.d.ts +29 -0
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +64 -0
- package/dist/daemon.js.map +1 -1
- package/dist/daemonConfig.d.ts +7 -0
- package/dist/daemonConfig.d.ts.map +1 -1
- package/dist/daemonConfig.js +9 -0
- package/dist/daemonConfig.js.map +1 -1
- package/dist/facades/definitions.d.ts.map +1 -1
- package/dist/facades/definitions.js +107 -31
- package/dist/facades/definitions.js.map +1 -1
- package/dist/httpServer.d.ts +4 -0
- package/dist/httpServer.d.ts.map +1 -1
- package/dist/httpServer.js +177 -13
- package/dist/httpServer.js.map +1 -1
- package/dist/kernel.d.ts +2 -0
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +1 -0
- package/dist/kernel.js.map +1 -1
- package/dist/server.js +30 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/coordinator/coordinator.d.ts +14 -0
- package/dist/tools/coordinator/coordinator.d.ts.map +1 -1
- package/dist/tools/coordinator/coordinator.js +101 -0
- package/dist/tools/coordinator/coordinator.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts +2 -0
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +2 -0
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/deck.d.ts +4 -4
- package/dist/tools/deck.d.ts.map +1 -1
- package/dist/tools/deck.js +1546 -78
- package/dist/tools/deck.js.map +1 -1
- package/dist/tools/guardian/index.d.ts +1 -0
- package/dist/tools/guardian/index.d.ts.map +1 -1
- package/dist/tools/guardian/index.js +40 -1
- package/dist/tools/guardian/index.js.map +1 -1
- package/dist/tools/guardian.d.ts +30 -0
- package/dist/tools/guardian.d.ts.map +1 -1
- package/dist/tools/guardian.js +96 -0
- package/dist/tools/guardian.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +5 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/mother.d.ts +11 -0
- package/dist/tools/mother.d.ts.map +1 -0
- package/dist/tools/mother.js +503 -0
- package/dist/tools/mother.js.map +1 -0
- package/dist/tools/swarm.d.ts +11 -0
- package/dist/tools/swarm.d.ts.map +1 -0
- package/dist/tools/swarm.js +701 -0
- package/dist/tools/swarm.js.map +1 -0
- package/dist/tools/terminal.d.ts +17 -0
- package/dist/tools/terminal.d.ts.map +1 -0
- package/dist/tools/terminal.js +968 -0
- package/dist/tools/terminal.js.map +1 -0
- package/dist/transports/http.d.ts.map +1 -1
- package/dist/transports/http.js +2 -0
- package/dist/transports/http.js.map +1 -1
- package/dist/transports/types.d.ts +4 -0
- package/dist/transports/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mother Tools — daemon advice, policy patches, and incident management.
|
|
3
|
+
*
|
|
4
|
+
* Tools for writing advice snapshots, proposing policy patches,
|
|
5
|
+
* publishing incidents, and querying the Mother daemon's Postgres tables.
|
|
6
|
+
*
|
|
7
|
+
* Env var: MOTHER_DATABASE_URL
|
|
8
|
+
*/
|
|
9
|
+
import pg from 'pg';
|
|
10
|
+
const { Pool } = pg;
|
|
11
|
+
// Lazy-init pool
|
|
12
|
+
let pool = null;
|
|
13
|
+
function getPool() {
|
|
14
|
+
if (!pool) {
|
|
15
|
+
const connectionString = process.env.MOTHER_DATABASE_URL;
|
|
16
|
+
if (!connectionString) {
|
|
17
|
+
throw new Error('MOTHER_DATABASE_URL environment variable not set');
|
|
18
|
+
}
|
|
19
|
+
pool = new Pool({
|
|
20
|
+
connectionString,
|
|
21
|
+
ssl: { rejectUnauthorized: false },
|
|
22
|
+
max: 5,
|
|
23
|
+
idleTimeoutMillis: 30000,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return pool;
|
|
27
|
+
}
|
|
28
|
+
// =============================================================================
|
|
29
|
+
// Helpers
|
|
30
|
+
// =============================================================================
|
|
31
|
+
function jsonResult(data, isError = false) {
|
|
32
|
+
return {
|
|
33
|
+
content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
|
|
34
|
+
isError,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const VALID_VERDICTS = ['ALLOW', 'REDUCE', 'SKIP'];
|
|
38
|
+
const VALID_REASON_CODES = [
|
|
39
|
+
'stop_streak',
|
|
40
|
+
'thesis_invalidation',
|
|
41
|
+
'win_rate_collapse',
|
|
42
|
+
'regime_mismatch',
|
|
43
|
+
'vol_spike',
|
|
44
|
+
'drawdown_limit',
|
|
45
|
+
'correlation_risk',
|
|
46
|
+
'liquidity_concern',
|
|
47
|
+
'time_of_day',
|
|
48
|
+
'overexposure',
|
|
49
|
+
'mean_reversion_expected',
|
|
50
|
+
'momentum_exhaustion',
|
|
51
|
+
'institutional_flow_shift',
|
|
52
|
+
'giveback_pattern',
|
|
53
|
+
'consecutive_losses',
|
|
54
|
+
];
|
|
55
|
+
function validateSnapshot(args) {
|
|
56
|
+
const errors = [];
|
|
57
|
+
if (!VALID_VERDICTS.includes(args.verdict)) {
|
|
58
|
+
errors.push(`Invalid verdict "${args.verdict}". Must be one of: ${VALID_VERDICTS.join(', ')}`);
|
|
59
|
+
}
|
|
60
|
+
if (args.confidence_mult < 0.0 || args.confidence_mult > 1.2) {
|
|
61
|
+
errors.push(`confidence_mult ${args.confidence_mult} out of range [0.0, 1.2]`);
|
|
62
|
+
}
|
|
63
|
+
if (args.size_mult < 0.0 || args.size_mult > 1.0) {
|
|
64
|
+
errors.push(`size_mult ${args.size_mult} out of range [0.0, 1.0]`);
|
|
65
|
+
}
|
|
66
|
+
if (args.exit_aggressiveness_mult < 0.7 || args.exit_aggressiveness_mult > 1.3) {
|
|
67
|
+
errors.push(`exit_aggressiveness_mult ${args.exit_aggressiveness_mult} out of range [0.7, 1.3]`);
|
|
68
|
+
}
|
|
69
|
+
if (args.verdict === 'SKIP') {
|
|
70
|
+
const codes = args.reason_codes ?? [];
|
|
71
|
+
if (codes.length < 2) {
|
|
72
|
+
errors.push(`SKIP verdict requires >= 2 reason_codes (got ${codes.length})`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (args.reason_codes) {
|
|
76
|
+
for (const code of args.reason_codes) {
|
|
77
|
+
if (!VALID_REASON_CODES.includes(code)) {
|
|
78
|
+
errors.push(`Invalid reason_code "${code}". Valid: ${VALID_REASON_CODES.join(', ')}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { valid: errors.length === 0, errors };
|
|
83
|
+
}
|
|
84
|
+
// =============================================================================
|
|
85
|
+
// Tool 1: mother_write_advice_snapshot (WRITE)
|
|
86
|
+
// =============================================================================
|
|
87
|
+
const motherWriteAdviceSnapshot = {
|
|
88
|
+
definition: {
|
|
89
|
+
name: 'mother_write_advice_snapshot',
|
|
90
|
+
description: 'Write an advice snapshot for a symbol×strategy pair. Validates verdict, multiplier bounds, and reason codes before inserting. SKIP verdict requires >= 2 reason_codes.',
|
|
91
|
+
annotations: {
|
|
92
|
+
title: 'Write Advice Snapshot',
|
|
93
|
+
readOnlyHint: false,
|
|
94
|
+
destructiveHint: false,
|
|
95
|
+
openWorldHint: false,
|
|
96
|
+
},
|
|
97
|
+
inputSchema: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
properties: {
|
|
100
|
+
symbol: { type: 'string', description: 'Trading symbol (e.g. BTCUSDT)' },
|
|
101
|
+
strategy: { type: 'string', description: 'Strategy name' },
|
|
102
|
+
verdict: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: 'ALLOW | REDUCE | SKIP',
|
|
105
|
+
},
|
|
106
|
+
confidence_mult: {
|
|
107
|
+
type: 'number',
|
|
108
|
+
description: 'Confidence multiplier [0.0–1.2] (default: 1.0)',
|
|
109
|
+
},
|
|
110
|
+
size_mult: {
|
|
111
|
+
type: 'number',
|
|
112
|
+
description: 'Position size multiplier [0.0–1.0] (default: 1.0)',
|
|
113
|
+
},
|
|
114
|
+
exit_aggressiveness_mult: {
|
|
115
|
+
type: 'number',
|
|
116
|
+
description: 'Exit aggressiveness multiplier [0.7–1.3] (default: 1.0)',
|
|
117
|
+
},
|
|
118
|
+
risk_notes: {
|
|
119
|
+
type: 'array',
|
|
120
|
+
items: { type: 'string' },
|
|
121
|
+
description: 'Free-form risk notes',
|
|
122
|
+
},
|
|
123
|
+
evidence_refs: {
|
|
124
|
+
type: 'array',
|
|
125
|
+
items: { type: 'string' },
|
|
126
|
+
description: 'References to evidence (metric IDs, URLs, etc.)',
|
|
127
|
+
},
|
|
128
|
+
reason_codes: {
|
|
129
|
+
type: 'array',
|
|
130
|
+
items: { type: 'string' },
|
|
131
|
+
description: 'Reason codes from the Mother enum (e.g. stop_streak, vol_spike)',
|
|
132
|
+
},
|
|
133
|
+
ttl_seconds: {
|
|
134
|
+
type: 'number',
|
|
135
|
+
description: 'Time-to-live in seconds (default: 3600)',
|
|
136
|
+
},
|
|
137
|
+
account: { type: 'string', description: 'Account name (default: "default")' },
|
|
138
|
+
exchange: { type: 'string', description: 'Exchange name (default: "binance")' },
|
|
139
|
+
run_id: { type: 'string', description: 'Agent run ID for traceability' },
|
|
140
|
+
},
|
|
141
|
+
required: ['symbol', 'strategy', 'verdict'],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
handler: async (args) => {
|
|
145
|
+
try {
|
|
146
|
+
const confidence_mult = args.confidence_mult ?? 1.0;
|
|
147
|
+
const size_mult = args.size_mult ?? 1.0;
|
|
148
|
+
const exit_aggressiveness_mult = args.exit_aggressiveness_mult ?? 1.0;
|
|
149
|
+
const validation = validateSnapshot({
|
|
150
|
+
verdict: args.verdict,
|
|
151
|
+
confidence_mult,
|
|
152
|
+
size_mult,
|
|
153
|
+
exit_aggressiveness_mult,
|
|
154
|
+
reason_codes: args.reason_codes,
|
|
155
|
+
});
|
|
156
|
+
if (!validation.valid) {
|
|
157
|
+
return jsonResult({ success: false, errors: validation.errors }, true);
|
|
158
|
+
}
|
|
159
|
+
const db = getPool();
|
|
160
|
+
const query = `
|
|
161
|
+
INSERT INTO mother_advice_snapshots
|
|
162
|
+
(symbol, strategy, verdict, confidence_mult, size_mult,
|
|
163
|
+
exit_aggressiveness_mult, risk_notes, evidence_refs,
|
|
164
|
+
reason_codes, ttl_seconds, account, exchange, run_id)
|
|
165
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
|
|
166
|
+
RETURNING id, symbol, strategy, verdict, confidence_mult, size_mult,
|
|
167
|
+
exit_aggressiveness_mult, reason_codes, ttl_seconds,
|
|
168
|
+
expires_at, created_at
|
|
169
|
+
`;
|
|
170
|
+
const result = await db.query(query, [
|
|
171
|
+
args.symbol,
|
|
172
|
+
args.strategy,
|
|
173
|
+
args.verdict,
|
|
174
|
+
confidence_mult,
|
|
175
|
+
size_mult,
|
|
176
|
+
exit_aggressiveness_mult,
|
|
177
|
+
args.risk_notes ?? [],
|
|
178
|
+
args.evidence_refs ?? [],
|
|
179
|
+
args.reason_codes ?? [],
|
|
180
|
+
args.ttl_seconds ?? 3600,
|
|
181
|
+
args.account ?? 'default',
|
|
182
|
+
args.exchange ?? 'binance',
|
|
183
|
+
args.run_id ?? null,
|
|
184
|
+
]);
|
|
185
|
+
return jsonResult({
|
|
186
|
+
success: true,
|
|
187
|
+
snapshot: result.rows[0],
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
192
|
+
return jsonResult({ success: false, error: msg }, true);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
// =============================================================================
|
|
197
|
+
// Tool 2: mother_propose_policy_patch (WRITE)
|
|
198
|
+
// =============================================================================
|
|
199
|
+
const motherProposePolicyPatch = {
|
|
200
|
+
definition: {
|
|
201
|
+
name: 'mother_propose_policy_patch',
|
|
202
|
+
description: 'Propose a bounded policy change with TTL and blast radius scoring. Auto-computes revert_at from ttl_seconds. Status starts as "proposed".',
|
|
203
|
+
annotations: {
|
|
204
|
+
title: 'Propose Policy Patch',
|
|
205
|
+
readOnlyHint: false,
|
|
206
|
+
destructiveHint: false,
|
|
207
|
+
openWorldHint: false,
|
|
208
|
+
},
|
|
209
|
+
inputSchema: {
|
|
210
|
+
type: 'object',
|
|
211
|
+
properties: {
|
|
212
|
+
scope_symbol: { type: 'string', description: 'Symbol scope (optional — omit for global)' },
|
|
213
|
+
scope_strategy: { type: 'string', description: 'Strategy scope (optional)' },
|
|
214
|
+
scope_account: { type: 'string', description: 'Account scope (optional)' },
|
|
215
|
+
changes: {
|
|
216
|
+
type: 'object',
|
|
217
|
+
description: 'Key-value map of policy changes',
|
|
218
|
+
},
|
|
219
|
+
ttl_seconds: {
|
|
220
|
+
type: 'number',
|
|
221
|
+
description: 'Time-to-live before auto-revert (default: 3600)',
|
|
222
|
+
},
|
|
223
|
+
reason_codes: {
|
|
224
|
+
type: 'array',
|
|
225
|
+
items: { type: 'string' },
|
|
226
|
+
description: 'Reason codes justifying the patch',
|
|
227
|
+
},
|
|
228
|
+
blast_radius_score: {
|
|
229
|
+
type: 'number',
|
|
230
|
+
description: 'Estimated blast radius [0.0–1.0] (default: 0.0)',
|
|
231
|
+
},
|
|
232
|
+
proposed_by: {
|
|
233
|
+
type: 'string',
|
|
234
|
+
description: 'Who proposed (default: "agent")',
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
required: ['changes', 'ttl_seconds', 'reason_codes'],
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
handler: async (args) => {
|
|
241
|
+
try {
|
|
242
|
+
// Validate reason codes
|
|
243
|
+
for (const code of args.reason_codes) {
|
|
244
|
+
if (!VALID_REASON_CODES.includes(code)) {
|
|
245
|
+
return jsonResult({
|
|
246
|
+
success: false,
|
|
247
|
+
error: `Invalid reason_code "${code}". Valid: ${VALID_REASON_CODES.join(', ')}`,
|
|
248
|
+
}, true);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const db = getPool();
|
|
252
|
+
const query = `
|
|
253
|
+
INSERT INTO mother_policy_patches
|
|
254
|
+
(scope_symbol, scope_strategy, scope_account, changes,
|
|
255
|
+
ttl_seconds, revert_at, reason_codes, blast_radius_score,
|
|
256
|
+
status, proposed_by)
|
|
257
|
+
VALUES ($1, $2, $3, $4, $5, NOW() + ($5 * interval '1 second'),
|
|
258
|
+
$6, $7, 'proposed', $8)
|
|
259
|
+
RETURNING id, scope_symbol, scope_strategy, scope_account,
|
|
260
|
+
changes, ttl_seconds, revert_at, reason_codes,
|
|
261
|
+
blast_radius_score, status, proposed_by, created_at
|
|
262
|
+
`;
|
|
263
|
+
const result = await db.query(query, [
|
|
264
|
+
args.scope_symbol ?? null,
|
|
265
|
+
args.scope_strategy ?? null,
|
|
266
|
+
args.scope_account ?? null,
|
|
267
|
+
JSON.stringify(args.changes),
|
|
268
|
+
args.ttl_seconds,
|
|
269
|
+
args.reason_codes,
|
|
270
|
+
args.blast_radius_score ?? 0.0,
|
|
271
|
+
args.proposed_by ?? 'agent',
|
|
272
|
+
]);
|
|
273
|
+
return jsonResult({
|
|
274
|
+
success: true,
|
|
275
|
+
patch: result.rows[0],
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
280
|
+
return jsonResult({ success: false, error: msg }, true);
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
// =============================================================================
|
|
285
|
+
// Tool 3: mother_publish_incident (WRITE)
|
|
286
|
+
// =============================================================================
|
|
287
|
+
const motherPublishIncident = {
|
|
288
|
+
definition: {
|
|
289
|
+
name: 'mother_publish_incident',
|
|
290
|
+
description: 'Publish a structured incident with tags, reason codes, and features. Used for postmortems and cross-project learning.',
|
|
291
|
+
annotations: {
|
|
292
|
+
title: 'Publish Incident',
|
|
293
|
+
readOnlyHint: false,
|
|
294
|
+
destructiveHint: false,
|
|
295
|
+
openWorldHint: false,
|
|
296
|
+
},
|
|
297
|
+
inputSchema: {
|
|
298
|
+
type: 'object',
|
|
299
|
+
properties: {
|
|
300
|
+
incident_type: {
|
|
301
|
+
type: 'string',
|
|
302
|
+
description: 'Type of incident (e.g. "drawdown_breach", "regime_shift", "stop_cascade")',
|
|
303
|
+
},
|
|
304
|
+
symbol: { type: 'string', description: 'Affected symbol (optional)' },
|
|
305
|
+
strategy: { type: 'string', description: 'Affected strategy (optional)' },
|
|
306
|
+
features: {
|
|
307
|
+
type: 'object',
|
|
308
|
+
description: 'Structured evidence — metrics, thresholds, observations',
|
|
309
|
+
},
|
|
310
|
+
action_taken: {
|
|
311
|
+
type: 'string',
|
|
312
|
+
description: 'What action was taken in response',
|
|
313
|
+
},
|
|
314
|
+
tags: {
|
|
315
|
+
type: 'array',
|
|
316
|
+
items: { type: 'string' },
|
|
317
|
+
description: 'Free-form tags for categorization',
|
|
318
|
+
},
|
|
319
|
+
reason_codes: {
|
|
320
|
+
type: 'array',
|
|
321
|
+
items: { type: 'string' },
|
|
322
|
+
description: 'Reason codes from the Mother enum',
|
|
323
|
+
},
|
|
324
|
+
run_id: { type: 'string', description: 'Agent run ID for traceability' },
|
|
325
|
+
},
|
|
326
|
+
required: ['incident_type', 'action_taken', 'reason_codes'],
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
handler: async (args) => {
|
|
330
|
+
try {
|
|
331
|
+
// Validate reason codes
|
|
332
|
+
for (const code of args.reason_codes) {
|
|
333
|
+
if (!VALID_REASON_CODES.includes(code)) {
|
|
334
|
+
return jsonResult({
|
|
335
|
+
success: false,
|
|
336
|
+
error: `Invalid reason_code "${code}". Valid: ${VALID_REASON_CODES.join(', ')}`,
|
|
337
|
+
}, true);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const db = getPool();
|
|
341
|
+
const query = `
|
|
342
|
+
INSERT INTO mother_incidents
|
|
343
|
+
(incident_type, symbol, strategy, features, action_taken,
|
|
344
|
+
tags, reason_codes, run_id)
|
|
345
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
346
|
+
RETURNING id, incident_type, symbol, strategy, action_taken,
|
|
347
|
+
tags, reason_codes, run_id, created_at
|
|
348
|
+
`;
|
|
349
|
+
const result = await db.query(query, [
|
|
350
|
+
args.incident_type,
|
|
351
|
+
args.symbol ?? null,
|
|
352
|
+
args.strategy ?? null,
|
|
353
|
+
JSON.stringify(args.features ?? {}),
|
|
354
|
+
args.action_taken,
|
|
355
|
+
args.tags ?? [],
|
|
356
|
+
args.reason_codes,
|
|
357
|
+
args.run_id ?? null,
|
|
358
|
+
]);
|
|
359
|
+
return jsonResult({
|
|
360
|
+
success: true,
|
|
361
|
+
incident: result.rows[0],
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
366
|
+
return jsonResult({ success: false, error: msg }, true);
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
// =============================================================================
|
|
371
|
+
// Tool 4: mother_get_advice_snapshot (READ)
|
|
372
|
+
// =============================================================================
|
|
373
|
+
const motherGetAdviceSnapshot = {
|
|
374
|
+
definition: {
|
|
375
|
+
name: 'mother_get_advice_snapshot',
|
|
376
|
+
description: 'Get the latest non-expired advice snapshot for a symbol×strategy pair. Returns null if no active snapshot exists.',
|
|
377
|
+
annotations: {
|
|
378
|
+
title: 'Get Advice Snapshot',
|
|
379
|
+
readOnlyHint: true,
|
|
380
|
+
destructiveHint: false,
|
|
381
|
+
openWorldHint: false,
|
|
382
|
+
},
|
|
383
|
+
inputSchema: {
|
|
384
|
+
type: 'object',
|
|
385
|
+
properties: {
|
|
386
|
+
symbol: { type: 'string', description: 'Trading symbol (e.g. BTCUSDT)' },
|
|
387
|
+
strategy: { type: 'string', description: 'Strategy name' },
|
|
388
|
+
},
|
|
389
|
+
required: ['symbol', 'strategy'],
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
handler: async (args) => {
|
|
393
|
+
try {
|
|
394
|
+
const db = getPool();
|
|
395
|
+
const query = `
|
|
396
|
+
SELECT
|
|
397
|
+
id, account, exchange, symbol, strategy, as_of,
|
|
398
|
+
verdict, confidence_mult, size_mult, exit_aggressiveness_mult,
|
|
399
|
+
risk_notes, evidence_refs, reason_codes, run_id,
|
|
400
|
+
ttl_seconds, expires_at, created_at
|
|
401
|
+
FROM mother_advice_snapshots
|
|
402
|
+
WHERE symbol = $1
|
|
403
|
+
AND strategy = $2
|
|
404
|
+
AND (expires_at IS NULL OR expires_at > NOW())
|
|
405
|
+
ORDER BY as_of DESC
|
|
406
|
+
LIMIT 1
|
|
407
|
+
`;
|
|
408
|
+
const result = await db.query(query, [args.symbol, args.strategy]);
|
|
409
|
+
return jsonResult({
|
|
410
|
+
success: true,
|
|
411
|
+
snapshot: result.rows[0] ?? null,
|
|
412
|
+
active: result.rows.length > 0,
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
catch (error) {
|
|
416
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
417
|
+
return jsonResult({ success: false, error: msg }, true);
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
};
|
|
421
|
+
// =============================================================================
|
|
422
|
+
// Tool 5: mother_list_incidents (READ)
|
|
423
|
+
// =============================================================================
|
|
424
|
+
const motherListIncidents = {
|
|
425
|
+
definition: {
|
|
426
|
+
name: 'mother_list_incidents',
|
|
427
|
+
description: 'List incidents filtered by symbol, strategy, type, and/or date range. Returns most recent first.',
|
|
428
|
+
annotations: {
|
|
429
|
+
title: 'List Incidents',
|
|
430
|
+
readOnlyHint: true,
|
|
431
|
+
destructiveHint: false,
|
|
432
|
+
openWorldHint: false,
|
|
433
|
+
},
|
|
434
|
+
inputSchema: {
|
|
435
|
+
type: 'object',
|
|
436
|
+
properties: {
|
|
437
|
+
symbol: { type: 'string', description: 'Filter by symbol' },
|
|
438
|
+
strategy: { type: 'string', description: 'Filter by strategy' },
|
|
439
|
+
incident_type: { type: 'string', description: 'Filter by incident type' },
|
|
440
|
+
since: {
|
|
441
|
+
type: 'string',
|
|
442
|
+
description: 'ISO date — only incidents after this time',
|
|
443
|
+
},
|
|
444
|
+
until: {
|
|
445
|
+
type: 'string',
|
|
446
|
+
description: 'ISO date — only incidents before this time',
|
|
447
|
+
},
|
|
448
|
+
limit: {
|
|
449
|
+
type: 'number',
|
|
450
|
+
description: 'Max results (default: 50)',
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
required: [],
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
handler: async (args) => {
|
|
457
|
+
try {
|
|
458
|
+
const db = getPool();
|
|
459
|
+
const limit = args.limit ?? 50;
|
|
460
|
+
const query = `
|
|
461
|
+
SELECT
|
|
462
|
+
id, incident_type, symbol, strategy, features,
|
|
463
|
+
action_taken, outcome, tags, reason_codes, run_id, created_at
|
|
464
|
+
FROM mother_incidents
|
|
465
|
+
WHERE ($1::text IS NULL OR symbol = $1)
|
|
466
|
+
AND ($2::text IS NULL OR strategy = $2)
|
|
467
|
+
AND ($3::text IS NULL OR incident_type = $3)
|
|
468
|
+
AND ($4::timestamptz IS NULL OR created_at >= $4)
|
|
469
|
+
AND ($5::timestamptz IS NULL OR created_at <= $5)
|
|
470
|
+
ORDER BY created_at DESC
|
|
471
|
+
LIMIT $6
|
|
472
|
+
`;
|
|
473
|
+
const result = await db.query(query, [
|
|
474
|
+
args.symbol ?? null,
|
|
475
|
+
args.strategy ?? null,
|
|
476
|
+
args.incident_type ?? null,
|
|
477
|
+
args.since ?? null,
|
|
478
|
+
args.until ?? null,
|
|
479
|
+
limit,
|
|
480
|
+
]);
|
|
481
|
+
return jsonResult({
|
|
482
|
+
success: true,
|
|
483
|
+
incidents: result.rows,
|
|
484
|
+
count: result.rows.length,
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
catch (error) {
|
|
488
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
489
|
+
return jsonResult({ success: false, error: msg }, true);
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
};
|
|
493
|
+
// =============================================================================
|
|
494
|
+
// Export
|
|
495
|
+
// =============================================================================
|
|
496
|
+
export const motherTools = [
|
|
497
|
+
motherWriteAdviceSnapshot,
|
|
498
|
+
motherProposePolicyPatch,
|
|
499
|
+
motherPublishIncident,
|
|
500
|
+
motherGetAdviceSnapshot,
|
|
501
|
+
motherListIncidents,
|
|
502
|
+
];
|
|
503
|
+
//# sourceMappingURL=mother.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mother.js","sourceRoot":"","sources":["../../src/tools/mother.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAEpB,iBAAiB;AACjB,IAAI,IAAI,GAAmB,IAAI,CAAC;AAEhC,SAAS,OAAO;IACd,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;QACzD,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,CAAC;QACD,IAAI,GAAG,IAAI,IAAI,CAAC;YACd,gBAAgB;YAChB,GAAG,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE;YAClC,GAAG,EAAE,CAAC;YACN,iBAAiB,EAAE,KAAK;SACzB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,SAAS,UAAU,CAAC,IAAa,EAAE,OAAO,GAAG,KAAK;IAChD,OAAO;QACL,OAAO,EAAE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C,IAAI,CAAC,MAAM,IAAI,IAAI;gBACnB,IAAI,CAAC,QAAQ,IAAI,IAAI;gBACrB,IAAI,CAAC,aAAa,IAAI,IAAI;gBAC1B,IAAI,CAAC,KAAK,IAAI,IAAI;gBAClB,IAAI,CAAC,KAAK,IAAI,IAAI;gBAClB,KAAK;aACN,CAAC,CAAC;YAEH,OAAO,UAAU,CAAC;gBAChB,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,MAAM,CAAC,IAAI;gBACtB,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM;aAC1B,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnE,OAAO,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF,CAAC;AAEF,gFAAgF;AAChF,SAAS;AACT,gFAAgF;AAEhF,MAAM,CAAC,MAAM,WAAW,GAAe;IACrC,yBAAyB;IACzB,wBAAwB;IACxB,qBAAqB;IACrB,uBAAuB;IACvB,mBAAmB;CACpB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Tools — Shared Agent Context Layer
|
|
3
|
+
*
|
|
4
|
+
* Multi-agent coordination via sessions, signals, artifacts, and snapshots.
|
|
5
|
+
* Phase 1: Sessions + Signals. Backed by Supabase (Core project).
|
|
6
|
+
*
|
|
7
|
+
* Env var: DECK_SUPABASE_KEY (reuses deck's anon key — same Supabase project)
|
|
8
|
+
*/
|
|
9
|
+
import { ToolSpec } from './types.js';
|
|
10
|
+
export declare const swarmTools: ToolSpec[];
|
|
11
|
+
//# sourceMappingURL=swarm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../../src/tools/swarm.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,QAAQ,EAAc,MAAM,YAAY,CAAC;AAmvBlD,eAAO,MAAM,UAAU,EAAE,QAAQ,EAYhC,CAAC"}
|