@hoox-sh/hoox-shared 1.2.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 +44 -0
- package/dist/agent-config-fields.d.ts +32 -0
- package/dist/agent-config-fields.d.ts.map +1 -0
- package/dist/agent-config-fields.js +220 -0
- package/dist/analytics.d.ts +47 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +45 -0
- package/dist/api-client.d.ts +48 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +191 -0
- package/dist/colors.d.ts +76 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +82 -0
- package/dist/config.d.ts +61 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +146 -0
- package/dist/cron-handler.d.ts +38 -0
- package/dist/cron-handler.d.ts.map +1 -0
- package/dist/cron-handler.js +48 -0
- package/dist/d1/index.d.ts +9 -0
- package/dist/d1/index.d.ts.map +1 -0
- package/dist/d1/index.js +360 -0
- package/dist/d1/repository.d.ts +86 -0
- package/dist/d1/repository.d.ts.map +1 -0
- package/dist/d1/repository.js +297 -0
- package/dist/d1/schemas.d.ts +89 -0
- package/dist/d1/schemas.d.ts.map +1 -0
- package/dist/d1/schemas.js +81 -0
- package/dist/dashboard-manifest.d.ts +135 -0
- package/dist/dashboard-manifest.d.ts.map +1 -0
- package/dist/dashboard-manifest.js +401 -0
- package/dist/errors.d.ts +44 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +149 -0
- package/dist/exchange-client.d.ts +98 -0
- package/dist/exchange-client.d.ts.map +1 -0
- package/dist/exchange-client.js +107 -0
- package/dist/exchanges/base-exchange-client.d.ts +81 -0
- package/dist/exchanges/base-exchange-client.d.ts.map +1 -0
- package/dist/exchanges/base-exchange-client.js +123 -0
- package/dist/exchanges/index.d.ts +7 -0
- package/dist/exchanges/index.d.ts.map +1 -0
- package/dist/exchanges/index.js +123 -0
- package/dist/exchanges/types.d.ts +23 -0
- package/dist/exchanges/types.d.ts.map +1 -0
- package/dist/exchanges/types.js +1 -0
- package/dist/format-time.d.ts +28 -0
- package/dist/format-time.d.ts.map +1 -0
- package/dist/format-time.js +57 -0
- package/dist/formatters.d.ts +36 -0
- package/dist/formatters.d.ts.map +1 -0
- package/dist/formatters.js +155 -0
- package/dist/health.d.ts +19 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/health.js +160 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4198 -0
- package/dist/kvKeys.d.ts +76 -0
- package/dist/kvKeys.d.ts.map +1 -0
- package/dist/kvKeys.js +107 -0
- package/dist/kvUtils.d.ts +30 -0
- package/dist/kvUtils.d.ts.map +1 -0
- package/dist/kvUtils.js +170 -0
- package/dist/legal.d.ts +15 -0
- package/dist/legal.d.ts.map +1 -0
- package/dist/legal.js +40 -0
- package/dist/middleware/auth.d.ts +102 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +151 -0
- package/dist/middleware/cors.d.ts +58 -0
- package/dist/middleware/cors.d.ts.map +1 -0
- package/dist/middleware/cors.js +77 -0
- package/dist/middleware/index.d.ts +14 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +635 -0
- package/dist/middleware/logger.d.ts +17 -0
- package/dist/middleware/logger.d.ts.map +1 -0
- package/dist/middleware/logger.js +202 -0
- package/dist/middleware/rate-limit.d.ts +30 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/rate-limit.js +181 -0
- package/dist/middleware/security-headers.d.ts +43 -0
- package/dist/middleware/security-headers.d.ts.map +1 -0
- package/dist/middleware/security-headers.js +58 -0
- package/dist/middleware/validate.d.ts +25 -0
- package/dist/middleware/validate.d.ts.map +1 -0
- package/dist/middleware/validate.js +56 -0
- package/dist/operator-transport.d.ts +65 -0
- package/dist/operator-transport.d.ts.map +1 -0
- package/dist/operator-transport.js +87 -0
- package/dist/path-utils.d.ts +190 -0
- package/dist/path-utils.d.ts.map +1 -0
- package/dist/path-utils.js +188 -0
- package/dist/queue-handler.d.ts +47 -0
- package/dist/queue-handler.d.ts.map +1 -0
- package/dist/queue-handler.js +46 -0
- package/dist/router.d.ts +15 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +130 -0
- package/dist/schemas/index.d.ts +8 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +705 -0
- package/dist/schemas/registry.d.ts +12 -0
- package/dist/schemas/registry.d.ts.map +1 -0
- package/dist/schemas/registry.js +433 -0
- package/dist/schemas/types.d.ts +83 -0
- package/dist/schemas/types.d.ts.map +1 -0
- package/dist/schemas/types.js +1 -0
- package/dist/schemas/validators.d.ts +39 -0
- package/dist/schemas/validators.d.ts.map +1 -0
- package/dist/schemas/validators.js +290 -0
- package/dist/service-bindings.d.ts +78 -0
- package/dist/service-bindings.d.ts.map +1 -0
- package/dist/service-bindings.js +248 -0
- package/dist/session.d.ts +39 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +261 -0
- package/dist/sse.d.ts +39 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +154 -0
- package/dist/stores/config-store.d.ts +91 -0
- package/dist/stores/config-store.d.ts.map +1 -0
- package/dist/stores/config-store.js +255 -0
- package/dist/stores/service-store.d.ts +266 -0
- package/dist/stores/service-store.d.ts.map +1 -0
- package/dist/stores/service-store.js +516 -0
- package/dist/stores/ui-store.d.ts +67 -0
- package/dist/stores/ui-store.d.ts.map +1 -0
- package/dist/stores/ui-store.js +62 -0
- package/dist/test-utils.d.ts +136 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.js +128 -0
- package/dist/types/errors.d.ts +20 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +1 -0
- package/dist/types/router.d.ts +36 -0
- package/dist/types/router.d.ts.map +1 -0
- package/dist/types/router.js +1 -0
- package/dist/types.d.ts +442 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +83 -0
- package/dist/wizard/engine.d.ts +46 -0
- package/dist/wizard/engine.d.ts.map +1 -0
- package/dist/wizard/engine.js +525 -0
- package/dist/wizard/index.d.ts +11 -0
- package/dist/wizard/index.d.ts.map +1 -0
- package/dist/wizard/index.js +544 -0
- package/dist/wizard/persistence.d.ts +18 -0
- package/dist/wizard/persistence.d.ts.map +1 -0
- package/dist/wizard/persistence.js +31 -0
- package/dist/wizard/presets.d.ts +38 -0
- package/dist/wizard/presets.d.ts.map +1 -0
- package/dist/wizard/presets.js +223 -0
- package/dist/wizard/provisioner.d.ts +15 -0
- package/dist/wizard/provisioner.d.ts.map +1 -0
- package/dist/wizard/provisioner.js +1 -0
- package/dist/wizard/types.d.ts +76 -0
- package/dist/wizard/types.d.ts.map +1 -0
- package/dist/wizard/types.js +1 -0
- package/package.json +117 -0
|
@@ -0,0 +1,705 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
+
|
|
18
|
+
// src/schemas/registry.ts
|
|
19
|
+
function deriveCalledBy(manifests) {
|
|
20
|
+
const calledBy = {};
|
|
21
|
+
for (const [workerName, manifest] of Object.entries(manifests)) {
|
|
22
|
+
if (!calledBy[workerName])
|
|
23
|
+
calledBy[workerName] = new Set;
|
|
24
|
+
for (const svc of manifest.services) {
|
|
25
|
+
if (!calledBy[svc.service])
|
|
26
|
+
calledBy[svc.service] = new Set;
|
|
27
|
+
calledBy[svc.service].add(workerName);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const result = {};
|
|
31
|
+
for (const [worker, callers] of Object.entries(calledBy)) {
|
|
32
|
+
result[worker] = [...callers].sort();
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
var manifests = {
|
|
37
|
+
hoox: {
|
|
38
|
+
name: "hoox",
|
|
39
|
+
path: "workers/hoox-worker",
|
|
40
|
+
vars: {
|
|
41
|
+
WEBHOOK_API_KEY_BINDING: {
|
|
42
|
+
type: "secret",
|
|
43
|
+
description: "External webhook auth key"
|
|
44
|
+
},
|
|
45
|
+
INTERNAL_KEY_BINDING: {
|
|
46
|
+
type: "secret",
|
|
47
|
+
description: "Inter-worker auth key"
|
|
48
|
+
},
|
|
49
|
+
HA_TOKEN_BINDING: { type: "secret", description: "Home Assistant token" }
|
|
50
|
+
},
|
|
51
|
+
services: [
|
|
52
|
+
{
|
|
53
|
+
binding: "TRADE_SERVICE",
|
|
54
|
+
service: "trade-worker",
|
|
55
|
+
description: "Trading functionality"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
binding: "TELEGRAM_SERVICE",
|
|
59
|
+
service: "telegram-worker",
|
|
60
|
+
description: "Notifications"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
infrastructure: {
|
|
64
|
+
kv: [
|
|
65
|
+
{ binding: "SESSIONS_KV", description: "Webhook session storage" },
|
|
66
|
+
{
|
|
67
|
+
binding: "CONFIG_KV",
|
|
68
|
+
description: "Configuration + rate limiter state"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
vectorize: [{ binding: "VECTORIZE_INDEX", index: "my-rag-index" }],
|
|
72
|
+
ai: true,
|
|
73
|
+
queues: { producer: ["trade-execution"] },
|
|
74
|
+
durableObjects: [
|
|
75
|
+
{ name: "IDEMPOTENCY_STORE", className: "IdempotencyStore" }
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
middleware: [
|
|
79
|
+
"requireAuth",
|
|
80
|
+
"requireInternalAuth",
|
|
81
|
+
"cors",
|
|
82
|
+
"rateLimit",
|
|
83
|
+
"logger",
|
|
84
|
+
"validate"
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"trade-worker": {
|
|
88
|
+
name: "trade-worker",
|
|
89
|
+
path: "workers/trade-worker",
|
|
90
|
+
vars: {
|
|
91
|
+
INTERNAL_KEY_BINDING: {
|
|
92
|
+
type: "secret",
|
|
93
|
+
description: "Inter-worker auth key"
|
|
94
|
+
},
|
|
95
|
+
TELEGRAM_INTERNAL_KEY_BINDING: {
|
|
96
|
+
type: "secret",
|
|
97
|
+
description: "Telegram outbound auth"
|
|
98
|
+
},
|
|
99
|
+
BINANCE_KEY_BINDING: { type: "secret", description: "Binance API key" },
|
|
100
|
+
BINANCE_SECRET_BINDING: {
|
|
101
|
+
type: "secret",
|
|
102
|
+
description: "Binance API secret"
|
|
103
|
+
},
|
|
104
|
+
MEXC_KEY_BINDING: { type: "secret", description: "MEXC API key" },
|
|
105
|
+
MEXC_SECRET_BINDING: { type: "secret", description: "MEXC API secret" },
|
|
106
|
+
BYBIT_KEY_BINDING: { type: "secret", description: "Bybit API key" },
|
|
107
|
+
BYBIT_SECRET_BINDING: { type: "secret", description: "Bybit API secret" }
|
|
108
|
+
},
|
|
109
|
+
services: [
|
|
110
|
+
{
|
|
111
|
+
binding: "D1_SERVICE",
|
|
112
|
+
service: "d1-worker",
|
|
113
|
+
description: "Database operations"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
binding: "TELEGRAM_SERVICE",
|
|
117
|
+
service: "telegram-worker",
|
|
118
|
+
description: "Notifications"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
infrastructure: {
|
|
122
|
+
kv: [{ binding: "CONFIG_KV", description: "Configuration" }],
|
|
123
|
+
d1: [
|
|
124
|
+
{
|
|
125
|
+
binding: "DB",
|
|
126
|
+
database: "trade-data-db",
|
|
127
|
+
description: "Trade operations"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
r2: [
|
|
131
|
+
{
|
|
132
|
+
binding: "REPORTS_BUCKET",
|
|
133
|
+
bucket: "trade-reports",
|
|
134
|
+
description: "Trade reports"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
binding: "SYSTEM_LOGS_BUCKET",
|
|
138
|
+
bucket: "hoox-system-logs",
|
|
139
|
+
description: "Verbose exchange logs"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
queues: { consumer: ["trade-execution"] }
|
|
143
|
+
},
|
|
144
|
+
middleware: ["requireInternalAuth"]
|
|
145
|
+
},
|
|
146
|
+
"telegram-worker": {
|
|
147
|
+
name: "telegram-worker",
|
|
148
|
+
path: "workers/telegram-worker",
|
|
149
|
+
vars: {
|
|
150
|
+
INTERNAL_KEY_BINDING: {
|
|
151
|
+
type: "secret",
|
|
152
|
+
description: "Inter-worker auth key"
|
|
153
|
+
},
|
|
154
|
+
TG_BOT_TOKEN_BINDING: {
|
|
155
|
+
type: "secret",
|
|
156
|
+
description: "Telegram bot token"
|
|
157
|
+
},
|
|
158
|
+
TG_CHAT_ID_BINDING: { type: "secret", description: "Default chat ID" },
|
|
159
|
+
TELEGRAM_SECRET_TOKEN: {
|
|
160
|
+
type: "secret",
|
|
161
|
+
description: "Webhook verification token"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
services: [],
|
|
165
|
+
infrastructure: {
|
|
166
|
+
kv: [{ binding: "CONFIG_KV", description: "Configuration" }],
|
|
167
|
+
r2: [
|
|
168
|
+
{
|
|
169
|
+
binding: "UPLOADS_BUCKET",
|
|
170
|
+
bucket: "user-uploads",
|
|
171
|
+
description: "User uploaded files"
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
vectorize: [{ binding: "VECTORIZE_INDEX", index: "my-rag-index" }],
|
|
175
|
+
ai: true
|
|
176
|
+
},
|
|
177
|
+
middleware: ["requireInternalAuth"]
|
|
178
|
+
},
|
|
179
|
+
"d1-worker": {
|
|
180
|
+
name: "d1-worker",
|
|
181
|
+
path: "workers/d1-worker",
|
|
182
|
+
vars: {
|
|
183
|
+
INTERNAL_KEY_BINDING: {
|
|
184
|
+
type: "secret",
|
|
185
|
+
description: "Inter-worker auth key"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
services: [],
|
|
189
|
+
infrastructure: {
|
|
190
|
+
kv: [{ binding: "CONFIG_KV", description: "Configuration" }],
|
|
191
|
+
d1: [
|
|
192
|
+
{
|
|
193
|
+
binding: "DB",
|
|
194
|
+
database: "trade-data-db",
|
|
195
|
+
description: "Main database"
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
middleware: ["requireInternalAuth"]
|
|
200
|
+
},
|
|
201
|
+
"web3-wallet-worker": {
|
|
202
|
+
name: "web3-wallet-worker",
|
|
203
|
+
path: "workers/web3-wallet-worker",
|
|
204
|
+
vars: {
|
|
205
|
+
WALLET_PK_SECRET: { type: "secret", description: "Wallet private key" },
|
|
206
|
+
WALLET_MNEMONIC_SECRET: {
|
|
207
|
+
type: "secret",
|
|
208
|
+
description: "Wallet mnemonic phrase"
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
services: [
|
|
212
|
+
{
|
|
213
|
+
binding: "TELEGRAM_SERVICE",
|
|
214
|
+
service: "telegram-worker",
|
|
215
|
+
description: "Notifications"
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
infrastructure: {},
|
|
219
|
+
middleware: ["requireInternalAuth"]
|
|
220
|
+
},
|
|
221
|
+
"agent-worker": {
|
|
222
|
+
name: "agent-worker",
|
|
223
|
+
path: "workers/agent-worker",
|
|
224
|
+
vars: {
|
|
225
|
+
AGENT_INTERNAL_KEY: { type: "secret", description: "Agent worker auth" },
|
|
226
|
+
INTERNAL_KEY_BINDING: {
|
|
227
|
+
type: "secret",
|
|
228
|
+
description: "Inter-worker auth key"
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
services: [
|
|
232
|
+
{
|
|
233
|
+
binding: "TRADE_SERVICE",
|
|
234
|
+
service: "trade-worker",
|
|
235
|
+
description: "Trading functionality"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
binding: "TELEGRAM_SERVICE",
|
|
239
|
+
service: "telegram-worker",
|
|
240
|
+
description: "Notifications"
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
infrastructure: {
|
|
244
|
+
kv: [{ binding: "CONFIG_KV", description: "Configuration" }],
|
|
245
|
+
d1: [
|
|
246
|
+
{
|
|
247
|
+
binding: "DB",
|
|
248
|
+
database: "trade-data-db",
|
|
249
|
+
description: "Portfolio queries"
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
ai: true
|
|
253
|
+
},
|
|
254
|
+
middleware: ["requireInternalAuth"],
|
|
255
|
+
cron: ["*/15 * * * *"]
|
|
256
|
+
},
|
|
257
|
+
"email-worker": {
|
|
258
|
+
name: "email-worker",
|
|
259
|
+
path: "workers/email-worker",
|
|
260
|
+
vars: {
|
|
261
|
+
INTERNAL_KEY_BINDING: {
|
|
262
|
+
type: "secret",
|
|
263
|
+
description: "Inter-worker auth key"
|
|
264
|
+
},
|
|
265
|
+
EMAIL_HOST_BINDING: { type: "secret", description: "Email IMAP host" },
|
|
266
|
+
EMAIL_USER_BINDING: { type: "secret", description: "Email username" },
|
|
267
|
+
EMAIL_PASS_BINDING: { type: "secret", description: "Email password" },
|
|
268
|
+
TRADE_WORKER_NAME: {
|
|
269
|
+
type: "plaintext",
|
|
270
|
+
description: "Trade worker service name",
|
|
271
|
+
default: "trade-worker"
|
|
272
|
+
},
|
|
273
|
+
USE_IMAP: {
|
|
274
|
+
type: "plaintext",
|
|
275
|
+
description: "Use IMAP for email",
|
|
276
|
+
default: "false"
|
|
277
|
+
},
|
|
278
|
+
MAILGUN_API_KEY: { type: "secret", description: "Mailgun API key" },
|
|
279
|
+
EMAIL_SCAN_SUBJECT: { type: "secret", description: "Email scan subject" }
|
|
280
|
+
},
|
|
281
|
+
services: [
|
|
282
|
+
{
|
|
283
|
+
binding: "TRADE_SERVICE",
|
|
284
|
+
service: "trade-worker",
|
|
285
|
+
description: "Trading functionality"
|
|
286
|
+
}
|
|
287
|
+
],
|
|
288
|
+
infrastructure: {
|
|
289
|
+
kv: [{ binding: "CONFIG_KV", description: "Configuration" }]
|
|
290
|
+
},
|
|
291
|
+
middleware: ["requireInternalAuth"],
|
|
292
|
+
cron: ["*/5 * * * *"]
|
|
293
|
+
},
|
|
294
|
+
"analytics-worker": {
|
|
295
|
+
name: "analytics-worker",
|
|
296
|
+
path: "workers/analytics-worker",
|
|
297
|
+
vars: {
|
|
298
|
+
CLOUDFLARE_API_TOKEN: {
|
|
299
|
+
type: "secret",
|
|
300
|
+
description: "CF API token for Analytics SQL"
|
|
301
|
+
},
|
|
302
|
+
CLOUDFLARE_ACCOUNT_ID: {
|
|
303
|
+
type: "plaintext",
|
|
304
|
+
description: "CF Account ID"
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
services: [],
|
|
308
|
+
infrastructure: {
|
|
309
|
+
analyticsEngine: true
|
|
310
|
+
},
|
|
311
|
+
middleware: []
|
|
312
|
+
},
|
|
313
|
+
"report-worker": {
|
|
314
|
+
name: "report-worker",
|
|
315
|
+
path: "workers/report-worker",
|
|
316
|
+
vars: {
|
|
317
|
+
CF_API_TOKEN_BINDING: {
|
|
318
|
+
type: "secret",
|
|
319
|
+
description: "CF API token for Browser Rendering"
|
|
320
|
+
},
|
|
321
|
+
ACCOUNT_ID: { type: "plaintext", description: "CF Account ID" }
|
|
322
|
+
},
|
|
323
|
+
services: [
|
|
324
|
+
{
|
|
325
|
+
binding: "D1_SERVICE",
|
|
326
|
+
service: "d1-worker",
|
|
327
|
+
description: "Database queries"
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
binding: "TELEGRAM_SERVICE",
|
|
331
|
+
service: "telegram-worker",
|
|
332
|
+
description: "Notifications"
|
|
333
|
+
}
|
|
334
|
+
],
|
|
335
|
+
infrastructure: {
|
|
336
|
+
r2: [
|
|
337
|
+
{
|
|
338
|
+
binding: "REPORTS_BUCKET",
|
|
339
|
+
bucket: "trade-reports",
|
|
340
|
+
description: "PDF reports"
|
|
341
|
+
}
|
|
342
|
+
]
|
|
343
|
+
},
|
|
344
|
+
middleware: ["requireInternalAuth"],
|
|
345
|
+
cron: ["0 8 * * *", "0 18 * * *"]
|
|
346
|
+
},
|
|
347
|
+
"pyne-worker": {
|
|
348
|
+
name: "pyne-worker",
|
|
349
|
+
path: "workers/pyne-worker",
|
|
350
|
+
vars: {
|
|
351
|
+
API_KEY: {
|
|
352
|
+
type: "secret",
|
|
353
|
+
description: "X-API-Key for /run and management endpoints"
|
|
354
|
+
},
|
|
355
|
+
ALERT_WEBHOOK_URL: {
|
|
356
|
+
type: "secret",
|
|
357
|
+
description: "Default HTTPS webhook for alert()/alertcondition()"
|
|
358
|
+
},
|
|
359
|
+
TRADE_WORKER_NAME: {
|
|
360
|
+
type: "plaintext",
|
|
361
|
+
description: "Trade worker service name",
|
|
362
|
+
default: "trade-worker"
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
services: [
|
|
366
|
+
{
|
|
367
|
+
binding: "TRADE_SERVICE",
|
|
368
|
+
service: "trade-worker",
|
|
369
|
+
description: "Forward strategy trade events"
|
|
370
|
+
}
|
|
371
|
+
],
|
|
372
|
+
infrastructure: {
|
|
373
|
+
r2: [
|
|
374
|
+
{
|
|
375
|
+
binding: "OHLCV_DATA",
|
|
376
|
+
bucket: "pyne-worker-ohlcv",
|
|
377
|
+
description: "OHLCV klines + script registry"
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
},
|
|
381
|
+
middleware: [],
|
|
382
|
+
cron: ["* * * * *"]
|
|
383
|
+
},
|
|
384
|
+
dashboard: {
|
|
385
|
+
name: "dashboard",
|
|
386
|
+
path: "workers/dashboard",
|
|
387
|
+
vars: {
|
|
388
|
+
DASHBOARD_USER: {
|
|
389
|
+
type: "secret",
|
|
390
|
+
description: "Dashboard admin username"
|
|
391
|
+
},
|
|
392
|
+
DASHBOARD_PASS: {
|
|
393
|
+
type: "secret",
|
|
394
|
+
description: "Dashboard admin password"
|
|
395
|
+
},
|
|
396
|
+
SESSION_SECRET: { type: "secret", description: "Session encryption key" },
|
|
397
|
+
PYNE_API_KEY: {
|
|
398
|
+
type: "secret",
|
|
399
|
+
description: "Dashboard \u2192 pyne-worker X-API-Key (match API_KEY)"
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
services: [
|
|
403
|
+
{
|
|
404
|
+
binding: "D1_SERVICE",
|
|
405
|
+
service: "d1-worker",
|
|
406
|
+
description: "Database queries"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
binding: "AGENT_SERVICE",
|
|
410
|
+
service: "agent-worker",
|
|
411
|
+
description: "AI risk data"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
binding: "PYNE_SERVICE",
|
|
415
|
+
service: "pyne-worker",
|
|
416
|
+
description: "PYNE edge evaluate"
|
|
417
|
+
}
|
|
418
|
+
],
|
|
419
|
+
infrastructure: {
|
|
420
|
+
kv: [{ binding: "CONFIG_KV", description: "Configuration" }],
|
|
421
|
+
ai: true
|
|
422
|
+
},
|
|
423
|
+
middleware: []
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
var CALLED_BY = deriveCalledBy(manifests);
|
|
427
|
+
var WORKER_MANIFESTS = manifests;
|
|
428
|
+
var WORKER_NAMES = Object.keys(manifests).sort();
|
|
429
|
+
|
|
430
|
+
// src/schemas/validators.ts
|
|
431
|
+
import { parse } from "jsonc-parser";
|
|
432
|
+
function validateWranglerJsonc(workerName, manifest, jsoncContent) {
|
|
433
|
+
const errors = [];
|
|
434
|
+
let parsed;
|
|
435
|
+
try {
|
|
436
|
+
parsed = parse(jsoncContent);
|
|
437
|
+
} catch {
|
|
438
|
+
errors.push({
|
|
439
|
+
worker: workerName,
|
|
440
|
+
severity: "error",
|
|
441
|
+
message: "Failed to parse wrangler.jsonc",
|
|
442
|
+
file: "wrangler.jsonc"
|
|
443
|
+
});
|
|
444
|
+
return errors;
|
|
445
|
+
}
|
|
446
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
447
|
+
errors.push({
|
|
448
|
+
worker: workerName,
|
|
449
|
+
severity: "error",
|
|
450
|
+
message: "Failed to parse wrangler.jsonc \u2014 result is not a valid object",
|
|
451
|
+
file: "wrangler.jsonc"
|
|
452
|
+
});
|
|
453
|
+
return errors;
|
|
454
|
+
}
|
|
455
|
+
const wrangler = parsed;
|
|
456
|
+
const declaredVars = wrangler.vars ?? {};
|
|
457
|
+
for (const [name, def] of Object.entries(manifest.vars)) {
|
|
458
|
+
if (!(name in declaredVars)) {
|
|
459
|
+
errors.push({
|
|
460
|
+
worker: workerName,
|
|
461
|
+
severity: "error",
|
|
462
|
+
message: `Missing var: ${name} (${def.description})`,
|
|
463
|
+
file: "wrangler.jsonc"
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
for (const [name, def] of Object.entries(manifest.vars)) {
|
|
468
|
+
if (def.type === "secret" && !name.endsWith("_BINDING") && !name.endsWith("_SECRET") && !name.startsWith("CLOUDFLARE_") && name !== "TELEGRAM_SECRET_TOKEN" && name !== "MAILGUN_API_KEY" && name !== "EMAIL_SCAN_SUBJECT" && name !== "DASHBOARD_USER" && name !== "DASHBOARD_PASS" && name !== "SESSION_SECRET" && name !== "AGENT_INTERNAL_KEY") {
|
|
469
|
+
errors.push({
|
|
470
|
+
worker: workerName,
|
|
471
|
+
severity: "warning",
|
|
472
|
+
message: `Secret var "${name}" does not end with _BINDING or _SECRET suffix`,
|
|
473
|
+
file: "wrangler.jsonc"
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const declaredServices = wrangler.services ?? [];
|
|
478
|
+
for (const expected of manifest.services) {
|
|
479
|
+
const match = declaredServices.find((s) => s.binding === expected.binding && s.service === expected.service);
|
|
480
|
+
if (!match) {
|
|
481
|
+
const declared = declaredServices.find((s) => s.binding === expected.binding);
|
|
482
|
+
if (declared) {
|
|
483
|
+
errors.push({
|
|
484
|
+
worker: workerName,
|
|
485
|
+
severity: "error",
|
|
486
|
+
message: `Service "${expected.binding}" points to "${declared.service}" but manifest expects "${expected.service}"`,
|
|
487
|
+
file: "wrangler.jsonc"
|
|
488
|
+
});
|
|
489
|
+
} else {
|
|
490
|
+
errors.push({
|
|
491
|
+
worker: workerName,
|
|
492
|
+
severity: "error",
|
|
493
|
+
message: `Missing service binding: ${expected.binding} -> ${expected.service}`,
|
|
494
|
+
file: "wrangler.jsonc"
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
for (const declared of declaredServices) {
|
|
500
|
+
const expected = manifest.services.find((s) => s.binding === declared.binding);
|
|
501
|
+
if (!expected) {
|
|
502
|
+
errors.push({
|
|
503
|
+
worker: workerName,
|
|
504
|
+
severity: "warning",
|
|
505
|
+
message: `Unexpected service binding: ${declared.binding}`,
|
|
506
|
+
file: "wrangler.jsonc"
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return errors;
|
|
511
|
+
}
|
|
512
|
+
function validateRootSecrets(workerName, manifest, rootJsoncContent) {
|
|
513
|
+
const errors = [];
|
|
514
|
+
let parsed;
|
|
515
|
+
try {
|
|
516
|
+
parsed = parse(rootJsoncContent);
|
|
517
|
+
} catch {
|
|
518
|
+
errors.push({
|
|
519
|
+
worker: workerName,
|
|
520
|
+
severity: "error",
|
|
521
|
+
message: "Failed to parse root wrangler.jsonc"
|
|
522
|
+
});
|
|
523
|
+
return errors;
|
|
524
|
+
}
|
|
525
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
526
|
+
errors.push({
|
|
527
|
+
worker: workerName,
|
|
528
|
+
severity: "error",
|
|
529
|
+
message: "Failed to parse root wrangler.jsonc \u2014 result is not a valid object"
|
|
530
|
+
});
|
|
531
|
+
return errors;
|
|
532
|
+
}
|
|
533
|
+
const rootWrangler = parsed;
|
|
534
|
+
const rootSecrets = rootWrangler.workers?.[workerName]?.secrets ?? [];
|
|
535
|
+
const expectedSecrets = Object.entries(manifest.vars).filter(([_, def]) => def.type === "secret").map(([name]) => name);
|
|
536
|
+
for (const expected of expectedSecrets) {
|
|
537
|
+
if (!rootSecrets.includes(expected)) {
|
|
538
|
+
errors.push({
|
|
539
|
+
worker: workerName,
|
|
540
|
+
severity: "error",
|
|
541
|
+
message: `Secret "${expected}" missing from root wrangler.jsonc workers.${workerName}.secrets`,
|
|
542
|
+
file: "wrangler.jsonc (root)"
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return errors;
|
|
547
|
+
}
|
|
548
|
+
function validateDevVars(workerName, manifest, devVarsContent) {
|
|
549
|
+
const errors = [];
|
|
550
|
+
const vars = new Map;
|
|
551
|
+
for (const line of devVarsContent.split(`
|
|
552
|
+
`)) {
|
|
553
|
+
const trimmed = line.trim();
|
|
554
|
+
if (trimmed === "" || trimmed.startsWith("#"))
|
|
555
|
+
continue;
|
|
556
|
+
const eqIdx = trimmed.indexOf("=");
|
|
557
|
+
if (eqIdx < 1)
|
|
558
|
+
continue;
|
|
559
|
+
vars.set(trimmed.substring(0, eqIdx).trim(), trimmed.substring(eqIdx + 1).trim());
|
|
560
|
+
}
|
|
561
|
+
for (const [name, def] of Object.entries(manifest.vars)) {
|
|
562
|
+
if (def.type !== "secret")
|
|
563
|
+
continue;
|
|
564
|
+
if (!vars.has(name)) {
|
|
565
|
+
errors.push({
|
|
566
|
+
worker: workerName,
|
|
567
|
+
severity: "error",
|
|
568
|
+
message: `Missing "${name}" in .dev.vars`,
|
|
569
|
+
file: ".dev.vars"
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return errors;
|
|
574
|
+
}
|
|
575
|
+
function generateWranglerJsonc(manifest) {
|
|
576
|
+
const parts = [];
|
|
577
|
+
parts.push(`{`);
|
|
578
|
+
parts.push(` "name": "${manifest.name}",`);
|
|
579
|
+
parts.push(` "main": "src/index.ts",`);
|
|
580
|
+
const varKeys = Object.keys(manifest.vars);
|
|
581
|
+
if (varKeys.length > 0) {
|
|
582
|
+
parts.push(` "vars": {`);
|
|
583
|
+
for (const [i, name] of varKeys.entries()) {
|
|
584
|
+
const def = manifest.vars[name];
|
|
585
|
+
const comma = i < varKeys.length - 1 ? "," : "";
|
|
586
|
+
const val = def.type === "secret" ? "__SECRET__" : JSON.stringify(def.default ?? "");
|
|
587
|
+
parts.push(` "${name}": ${val}${comma}`);
|
|
588
|
+
}
|
|
589
|
+
parts.push(` },`);
|
|
590
|
+
}
|
|
591
|
+
if (manifest.services.length > 0) {
|
|
592
|
+
parts.push(` "services": [`);
|
|
593
|
+
for (const [i, svc] of manifest.services.entries()) {
|
|
594
|
+
const comma = i < manifest.services.length - 1 ? "," : "";
|
|
595
|
+
parts.push(` { "binding": "${svc.binding}", "service": "${svc.service}" }${comma}`);
|
|
596
|
+
}
|
|
597
|
+
parts.push(` ],`);
|
|
598
|
+
}
|
|
599
|
+
const infra = manifest.infrastructure;
|
|
600
|
+
if (infra.kv && infra.kv.length > 0) {
|
|
601
|
+
parts.push(` "kv_namespaces": [`);
|
|
602
|
+
for (const [i, binding] of infra.kv.entries()) {
|
|
603
|
+
const comma = i < infra.kv.length - 1 ? "," : "";
|
|
604
|
+
parts.push(` { "binding": "${binding.binding}", "id": "" }${comma}`);
|
|
605
|
+
}
|
|
606
|
+
parts.push(` ],`);
|
|
607
|
+
}
|
|
608
|
+
if (infra.d1 && infra.d1.length > 0) {
|
|
609
|
+
parts.push(` "d1_databases": [`);
|
|
610
|
+
for (const [i, binding] of infra.d1.entries()) {
|
|
611
|
+
const comma = i < infra.d1.length - 1 ? "," : "";
|
|
612
|
+
parts.push(` { "binding": "${binding.binding}", "database_name": "${binding.database}", "database_id": "" }${comma}`);
|
|
613
|
+
}
|
|
614
|
+
parts.push(` ],`);
|
|
615
|
+
}
|
|
616
|
+
if (infra.r2 && infra.r2.length > 0) {
|
|
617
|
+
parts.push(` "r2_buckets": [`);
|
|
618
|
+
for (const [i, binding] of infra.r2.entries()) {
|
|
619
|
+
const comma = i < infra.r2.length - 1 ? "," : "";
|
|
620
|
+
parts.push(` { "binding": "${binding.binding}", "bucket_name": "${binding.bucket}" }${comma}`);
|
|
621
|
+
}
|
|
622
|
+
parts.push(` ],`);
|
|
623
|
+
}
|
|
624
|
+
if (infra.ai) {
|
|
625
|
+
parts.push(` "ai": { "binding": "AI" },`);
|
|
626
|
+
}
|
|
627
|
+
if (infra.analyticsEngine) {
|
|
628
|
+
parts.push(` "analytics_engine_datasets": [{ "binding": "ANALYTICS_ENGINE", "dataset": "hoox-analytics" }],`);
|
|
629
|
+
}
|
|
630
|
+
if (infra.vectorize && infra.vectorize.length > 0) {
|
|
631
|
+
parts.push(` "vectorize": [`);
|
|
632
|
+
for (const [i, binding] of infra.vectorize.entries()) {
|
|
633
|
+
const comma = i < infra.vectorize.length - 1 ? "," : "";
|
|
634
|
+
parts.push(` { "binding": "${binding.binding}", "index_name": "${binding.index}" }${comma}`);
|
|
635
|
+
}
|
|
636
|
+
parts.push(` ],`);
|
|
637
|
+
}
|
|
638
|
+
if (infra.queues) {
|
|
639
|
+
if (infra.queues.producer && infra.queues.producer.length > 0) {
|
|
640
|
+
parts.push(` "queues": { "producers": [`);
|
|
641
|
+
for (const [i, q] of infra.queues.producer.entries()) {
|
|
642
|
+
const comma = i < infra.queues.producer.length - 1 ? "," : "";
|
|
643
|
+
parts.push(` { "queue": "${q}", "binding": "" }${comma}`);
|
|
644
|
+
}
|
|
645
|
+
parts.push(` ] },`);
|
|
646
|
+
}
|
|
647
|
+
if (infra.queues.consumer && infra.queues.consumer.length > 0) {
|
|
648
|
+
parts.push(` "queues": { "consumers": [`);
|
|
649
|
+
for (const [i, q] of infra.queues.consumer.entries()) {
|
|
650
|
+
const comma = i < infra.queues.consumer.length - 1 ? "," : "";
|
|
651
|
+
parts.push(` { "queue": "${q}" }${comma}`);
|
|
652
|
+
}
|
|
653
|
+
parts.push(` ] },`);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (infra.durableObjects && infra.durableObjects.length > 0) {
|
|
657
|
+
parts.push(` "durable_objects": { "bindings": [`);
|
|
658
|
+
for (const [i, doBinding] of infra.durableObjects.entries()) {
|
|
659
|
+
const comma = i < infra.durableObjects.length - 1 ? "," : "";
|
|
660
|
+
parts.push(` { "name": "${doBinding.name}", "class_name": "${doBinding.className}" }${comma}`);
|
|
661
|
+
}
|
|
662
|
+
parts.push(` ] },`);
|
|
663
|
+
}
|
|
664
|
+
parts.push(`}`);
|
|
665
|
+
return parts.join(`
|
|
666
|
+
`) + `
|
|
667
|
+
`;
|
|
668
|
+
}
|
|
669
|
+
function generateDevVars(manifest) {
|
|
670
|
+
const lines = [];
|
|
671
|
+
lines.push(`# ${manifest.name} \u2014 Environment Variables`);
|
|
672
|
+
lines.push(`# Auto-generated from worker manifest schema`);
|
|
673
|
+
lines.push(``);
|
|
674
|
+
for (const [name, def] of Object.entries(manifest.vars)) {
|
|
675
|
+
if (def.type === "secret") {
|
|
676
|
+
lines.push(`${name}=placeholder_${name.toLowerCase()}`);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
lines.push(``);
|
|
680
|
+
return lines.join(`
|
|
681
|
+
`);
|
|
682
|
+
}
|
|
683
|
+
function validateAll(workerName, manifest, files) {
|
|
684
|
+
const errors = [
|
|
685
|
+
...validateWranglerJsonc(workerName, manifest, files.wranglerJsonc),
|
|
686
|
+
...validateRootSecrets(workerName, manifest, files.rootWranglerJsonc),
|
|
687
|
+
...validateDevVars(workerName, manifest, files.devVars)
|
|
688
|
+
];
|
|
689
|
+
return {
|
|
690
|
+
worker: workerName,
|
|
691
|
+
passed: errors.filter((e) => e.severity === "error").length === 0,
|
|
692
|
+
errors
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
export {
|
|
696
|
+
validateWranglerJsonc,
|
|
697
|
+
validateRootSecrets,
|
|
698
|
+
validateDevVars,
|
|
699
|
+
validateAll,
|
|
700
|
+
generateWranglerJsonc,
|
|
701
|
+
generateDevVars,
|
|
702
|
+
WORKER_NAMES,
|
|
703
|
+
WORKER_MANIFESTS,
|
|
704
|
+
CALLED_BY
|
|
705
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 HOOX · HOOX · jango-blockchained (hoox-sh)
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { WorkerManifest } from "./types.js";
|
|
6
|
+
/** Map of worker-name -> list-of-workers-that-call-it (computed). */
|
|
7
|
+
export declare const CALLED_BY: Record<string, string[]>;
|
|
8
|
+
/** The canonical registry of all worker manifests. */
|
|
9
|
+
export declare const WORKER_MANIFESTS: Record<string, WorkerManifest>;
|
|
10
|
+
/** List of all worker names in the registry. */
|
|
11
|
+
export declare const WORKER_NAMES: string[];
|
|
12
|
+
//# sourceMappingURL=registry.d.ts.map
|