@futurewindai/wotchi 0.1.0-beta.1
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/LICENSE +201 -0
- package/README.md +128 -0
- package/SECURITY.md +17 -0
- package/dist/cjs/core/client.js +154 -0
- package/dist/cjs/core/config.js +114 -0
- package/dist/cjs/core/diagnostics.js +14 -0
- package/dist/cjs/core/errors.js +11 -0
- package/dist/cjs/core/fingerprint.js +37 -0
- package/dist/cjs/core/group-store.js +95 -0
- package/dist/cjs/core/incident-builder.js +46 -0
- package/dist/cjs/core/incident-policy.js +31 -0
- package/dist/cjs/core/normalize.js +138 -0
- package/dist/cjs/core/notification-queue.js +103 -0
- package/dist/cjs/core/process-monitor.js +30 -0
- package/dist/cjs/core/redact.js +141 -0
- package/dist/cjs/core/rolling-window.js +60 -0
- package/dist/cjs/core/stack-frame.js +33 -0
- package/dist/cjs/core/types.js +2 -0
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/integrations/express/error-handler.js +15 -0
- package/dist/cjs/integrations/express/index.js +12 -0
- package/dist/cjs/integrations/express/request-context.js +19 -0
- package/dist/cjs/integrations/nest/exception-filter.js +36 -0
- package/dist/cjs/integrations/nest/index.js +9 -0
- package/dist/cjs/integrations/nest/register.js +13 -0
- package/dist/cjs/integrations/nest/request-context.js +41 -0
- package/dist/cjs/integrations/request-context.js +76 -0
- package/dist/cjs/notifiers/console.js +33 -0
- package/dist/cjs/notifiers/telegram-format.js +52 -0
- package/dist/cjs/notifiers/telegram-http.js +150 -0
- package/dist/cjs/notifiers/telegram.js +38 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/core/client.js +151 -0
- package/dist/esm/core/config.js +110 -0
- package/dist/esm/core/diagnostics.js +10 -0
- package/dist/esm/core/errors.js +7 -0
- package/dist/esm/core/fingerprint.js +33 -0
- package/dist/esm/core/group-store.js +92 -0
- package/dist/esm/core/incident-builder.js +43 -0
- package/dist/esm/core/incident-policy.js +28 -0
- package/dist/esm/core/normalize.js +134 -0
- package/dist/esm/core/notification-queue.js +100 -0
- package/dist/esm/core/process-monitor.js +27 -0
- package/dist/esm/core/redact.js +136 -0
- package/dist/esm/core/rolling-window.js +57 -0
- package/dist/esm/core/stack-frame.js +29 -0
- package/dist/esm/core/types.js +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/integrations/express/error-handler.js +12 -0
- package/dist/esm/integrations/express/index.js +5 -0
- package/dist/esm/integrations/express/request-context.js +16 -0
- package/dist/esm/integrations/nest/exception-filter.js +33 -0
- package/dist/esm/integrations/nest/index.js +2 -0
- package/dist/esm/integrations/nest/register.js +10 -0
- package/dist/esm/integrations/nest/request-context.js +38 -0
- package/dist/esm/integrations/request-context.js +72 -0
- package/dist/esm/notifiers/console.js +29 -0
- package/dist/esm/notifiers/telegram-format.js +49 -0
- package/dist/esm/notifiers/telegram-http.js +144 -0
- package/dist/esm/notifiers/telegram.js +34 -0
- package/dist/types/core/client.d.ts +2 -0
- package/dist/types/core/config.d.ts +29 -0
- package/dist/types/core/diagnostics.d.ts +7 -0
- package/dist/types/core/errors.d.ts +3 -0
- package/dist/types/core/fingerprint.d.ts +3 -0
- package/dist/types/core/group-store.d.ts +15 -0
- package/dist/types/core/incident-builder.d.ts +3 -0
- package/dist/types/core/incident-policy.d.ts +15 -0
- package/dist/types/core/normalize.d.ts +17 -0
- package/dist/types/core/notification-queue.d.ts +16 -0
- package/dist/types/core/process-monitor.d.ts +5 -0
- package/dist/types/core/redact.d.ts +11 -0
- package/dist/types/core/rolling-window.d.ts +12 -0
- package/dist/types/core/stack-frame.d.ts +2 -0
- package/dist/types/core/types.d.ts +109 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/integrations/express/error-handler.d.ts +4 -0
- package/dist/types/integrations/express/index.d.ts +7 -0
- package/dist/types/integrations/express/request-context.d.ts +5 -0
- package/dist/types/integrations/nest/exception-filter.d.ts +10 -0
- package/dist/types/integrations/nest/index.d.ts +4 -0
- package/dist/types/integrations/nest/register.d.ts +10 -0
- package/dist/types/integrations/nest/request-context.d.ts +5 -0
- package/dist/types/integrations/request-context.d.ts +13 -0
- package/dist/types/notifiers/console.d.ts +3 -0
- package/dist/types/notifiers/telegram-format.d.ts +2 -0
- package/dist/types/notifiers/telegram-http.d.ts +21 -0
- package/dist/types/notifiers/telegram.d.ts +4 -0
- package/package.json +111 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Wotchi
|
|
2
|
+
|
|
3
|
+
> Your production's night shift.
|
|
4
|
+
|
|
5
|
+
Wotchi is a lightweight incident assistant for Node.js applications. It is intended to help small teams turn repeated Express and NestJS application errors into a small number of useful console or Telegram alerts without operating a separate monitoring stack.
|
|
6
|
+
|
|
7
|
+
> **Project status:** Private beta candidate (`0.1.0-beta.1`). Phases 1–8 are implemented and locally validated, including bounded incident processing, console and Telegram alerts, Express 4/5 middleware, NestJS 10/11 exception-filter integration, opt-in crash observation, security gates, performance budgets, packed-tarball examples, and Node.js 18–26 CI. The source repository is public; the npm package is not published yet.
|
|
8
|
+
|
|
9
|
+
The working package name is `@futurewindai/wotchi`. The founder accepted the documented Wotchi trademark risk for the beta release on 2026-08-08; this is not legal clearance. The package remains unpublished until the exact release snapshot and gates are verified.
|
|
10
|
+
|
|
11
|
+
## Planned v0.1 Scope
|
|
12
|
+
|
|
13
|
+
- one framework-independent TypeScript core;
|
|
14
|
+
- focused integrations for Express 4/5 and NestJS 10/11;
|
|
15
|
+
- manual exception and structured error-event capture;
|
|
16
|
+
- sensitive-data redaction before storage, fingerprinting, logging, or transmission;
|
|
17
|
+
- stable fingerprints and deterministic incident summaries;
|
|
18
|
+
- bounded in-memory grouping, thresholds, cooldowns, and notification queueing;
|
|
19
|
+
- console and Telegram notifiers;
|
|
20
|
+
- CommonJS and ECMAScript module package exports;
|
|
21
|
+
- measured latency, CPU, heap, queue, and package-size release gates.
|
|
22
|
+
|
|
23
|
+
The package exposes a root entry point plus focused `/express` and `/nest` entry points. Framework adapters are loaded only through their subpaths, and they observe errors while leaving response ownership with Express or NestJS.
|
|
24
|
+
|
|
25
|
+
Express applications install the middleware after routes and before the existing final error handler:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import express from "express";
|
|
29
|
+
import { consoleNotifier, createWotchi } from "@futurewindai/wotchi";
|
|
30
|
+
import { wotchiErrorHandler } from "@futurewindai/wotchi/express";
|
|
31
|
+
|
|
32
|
+
const app = express();
|
|
33
|
+
const wotchi = createWotchi({
|
|
34
|
+
service: "orders-api",
|
|
35
|
+
environment: "production",
|
|
36
|
+
notifiers: [consoleNotifier()],
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
app.use(wotchiErrorHandler(wotchi));
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
NestJS applications register the delegating global filter once after creating the application:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { registerWotchiNest } from "@futurewindai/wotchi/nest";
|
|
46
|
+
|
|
47
|
+
registerWotchiNest(app, wotchi);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Telegram is an optional self-hosted notifier. The application owner creates a bot with BotFather, starts or adds it to the destination chat, and keeps the credentials outside source control:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { consoleNotifier, createWotchi, telegramNotifier } from "@futurewindai/wotchi";
|
|
54
|
+
|
|
55
|
+
const wotchi = createWotchi({
|
|
56
|
+
service: "orders-api",
|
|
57
|
+
environment: "production",
|
|
58
|
+
notifiers: [
|
|
59
|
+
consoleNotifier(),
|
|
60
|
+
telegramNotifier({
|
|
61
|
+
botToken: process.env.WOTCHI_TELEGRAM_BOT_TOKEN ?? "",
|
|
62
|
+
chatId: process.env.WOTCHI_TELEGRAM_CHAT_ID ?? "",
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Wotchi does not ship a shared bot token. Telegram delivery is queued outside the request path, uses bounded HTTPS timeouts/retries, and sends only the sanitized incident alert.
|
|
69
|
+
|
|
70
|
+
Crash observation is also opt-in:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { registerWotchiProcessMonitor } from "@futurewindai/wotchi";
|
|
74
|
+
|
|
75
|
+
const monitor = registerWotchiProcessMonitor(wotchi);
|
|
76
|
+
// monitor.unregister() when the host intentionally stops observing crashes
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The implemented core can be exercised directly:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { consoleNotifier, createWotchi } from "@futurewindai/wotchi";
|
|
83
|
+
|
|
84
|
+
const wotchi = createWotchi({
|
|
85
|
+
service: "orders-api",
|
|
86
|
+
environment: "production",
|
|
87
|
+
notifiers: [consoleNotifier()],
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
wotchi.captureException(new Error("database query failed"));
|
|
91
|
+
await wotchi.flush();
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The default policy emits after three matching errors in one minute and suppresses duplicate alerts during the cooldown. The capture path remains synchronous; `flush()` is only needed when the host explicitly wants to wait for notifier work.
|
|
95
|
+
|
|
96
|
+
## Product Principles
|
|
97
|
+
|
|
98
|
+
- **Host safety:** Wotchi must not break, suppress, or materially delay the application's normal error flow.
|
|
99
|
+
- **Bounded overhead:** memory, payloads, groups, and queued notifications must all have explicit limits.
|
|
100
|
+
- **Privacy first:** request bodies, response bodies, raw headers, and arbitrary environment variables are outside the first release.
|
|
101
|
+
- **Deterministic first:** the MVP must work without an AI provider, database, hosted account, or collector.
|
|
102
|
+
- **Honest compatibility:** the MVP targets Node.js 18.18 and later. Supported framework/module combinations are claimed only after packed-tarball CI verification. Maintained Node.js LTS versions are recommended for production.
|
|
103
|
+
|
|
104
|
+
## Not Planned for v0.1
|
|
105
|
+
|
|
106
|
+
- a full observability, APM, or log-management platform;
|
|
107
|
+
- a hosted dashboard, collector, or persistent incident history;
|
|
108
|
+
- AI-generated summaries;
|
|
109
|
+
- Slack, Discord, email, or generic webhook notifiers;
|
|
110
|
+
- logger transports, Docker collectors, Kubernetes agents, or Helm charts in the npm SDK itself; a separate future collector/relay deployment may receive its own Docker and Helm milestone;
|
|
111
|
+
- automatic remediation.
|
|
112
|
+
|
|
113
|
+
A token-based hosted demo viewer is a separate possible future milestone, not part of the package MVP.
|
|
114
|
+
|
|
115
|
+
## Project Documents
|
|
116
|
+
|
|
117
|
+
- [Architecture and package boundaries](docs/ARCHITECTURE.md)
|
|
118
|
+
- [Setup](docs/SETUP.md)
|
|
119
|
+
- [Configuration](docs/CONFIGURATION.md)
|
|
120
|
+
- [Testing and smoke validation](docs/TESTING.md)
|
|
121
|
+
- [Security and privacy notes](docs/SECURITY.md)
|
|
122
|
+
- [Development workflow](docs/DEVELOPMENT.md)
|
|
123
|
+
- [Security policy](SECURITY.md)
|
|
124
|
+
- [Contributing guide](CONTRIBUTING.md)
|
|
125
|
+
- [Changelog](CHANGELOG.md)
|
|
126
|
+
- [Apache License 2.0](LICENSE)
|
|
127
|
+
|
|
128
|
+
Wotchi is an early open-source project from FutureWind AI. Contributions and product feedback should stay within the documented scope and avoid real secrets or customer error data.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Wotchi is currently pre-release. The package targets consumers running Node.js `>=18.18.0` and is built and tested across the maintained Node.js 18–26 matrix. Node.js versions below 18.18 are not supported.
|
|
6
|
+
|
|
7
|
+
The current pre-release package contains the framework-independent capture core, console and Telegram notifiers, Express 4/5 middleware, NestJS 10/11 exception-filter integration, and opt-in process monitoring. The package has not been published to npm. Supported runtime and framework combinations are documented only after the packed-tarball compatibility and release-security gates pass.
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
Do not disclose a suspected vulnerability, exploit detail, credential, token, or real customer error in a public issue, discussion, pull request, or example.
|
|
12
|
+
|
|
13
|
+
Use [GitHub private vulnerability reporting](https://github.com/FutureWindAI/wotchi/security/advisories/new) when it is available for this repository. If that private form is unavailable, open a public issue containing no sensitive detail and ask the maintainers to establish a private reporting channel.
|
|
14
|
+
|
|
15
|
+
Include only the minimum sanitized information needed to reproduce the problem. Remove application secrets, personal data, proprietary source, production URLs, and raw customer payloads.
|
|
16
|
+
|
|
17
|
+
We will acknowledge a valid private report, investigate its scope, and coordinate disclosure after a fix or mitigation is ready. Response-time commitments will be added only when the project has an active release and a maintained security process.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWotchi = createWotchi;
|
|
4
|
+
const config_js_1 = require("./config.js");
|
|
5
|
+
const diagnostics_js_1 = require("./diagnostics.js");
|
|
6
|
+
const fingerprint_js_1 = require("./fingerprint.js");
|
|
7
|
+
const group_store_js_1 = require("./group-store.js");
|
|
8
|
+
const incident_builder_js_1 = require("./incident-builder.js");
|
|
9
|
+
const incident_policy_js_1 = require("./incident-policy.js");
|
|
10
|
+
const normalize_js_1 = require("./normalize.js");
|
|
11
|
+
const notification_queue_js_1 = require("./notification-queue.js");
|
|
12
|
+
const redact_js_1 = require("./redact.js");
|
|
13
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14
|
+
const asString = (value) => typeof value === "string" ? value : undefined;
|
|
15
|
+
const asStatusCode = (value) => typeof value === "number" && Number.isSafeInteger(value) ? value : undefined;
|
|
16
|
+
const safeRecord = (value, privacy) => {
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const redacted = (0, redact_js_1.redactValue)(value, privacy);
|
|
21
|
+
return isRecord(redacted) ? redacted : undefined;
|
|
22
|
+
};
|
|
23
|
+
const mergeContext = (metadata, context, privacy) => {
|
|
24
|
+
if (metadata === undefined && context === undefined) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const metadataValue = safeRecord(metadata, privacy);
|
|
28
|
+
const contextValue = safeRecord(context, privacy);
|
|
29
|
+
if (metadataValue === undefined && contextValue === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return { ...(metadataValue ?? {}), ...(contextValue ?? {}) };
|
|
33
|
+
};
|
|
34
|
+
const safeRequest = (request, privacy) => {
|
|
35
|
+
if (request === undefined) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const redacted = (0, redact_js_1.redactValue)(request, privacy);
|
|
39
|
+
if (!isRecord(redacted)) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const method = asString(redacted.method);
|
|
43
|
+
const route = asString(redacted.route);
|
|
44
|
+
const requestId = asString(redacted.requestId);
|
|
45
|
+
const statusCode = asStatusCode(redacted.statusCode);
|
|
46
|
+
if (method === undefined &&
|
|
47
|
+
route === undefined &&
|
|
48
|
+
requestId === undefined &&
|
|
49
|
+
statusCode === undefined) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
...(method === undefined ? {} : { method }),
|
|
54
|
+
...(route === undefined ? {} : { route }),
|
|
55
|
+
...(requestId === undefined ? {} : { requestId }),
|
|
56
|
+
...(statusCode === undefined ? {} : { statusCode }),
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const safeMessage = (value, privacy) => {
|
|
60
|
+
const normalized = (0, normalize_js_1.normalizeUnknown)(value, privacy);
|
|
61
|
+
return typeof normalized === "string" ? normalized : "[unreadable value]";
|
|
62
|
+
};
|
|
63
|
+
function createWotchi(config) {
|
|
64
|
+
const normalized = (0, config_js_1.validateConfig)(config);
|
|
65
|
+
const now = Date.now;
|
|
66
|
+
const groupStore = (0, group_store_js_1.createGroupStore)({
|
|
67
|
+
maxGroups: normalized.grouping.maxGroups,
|
|
68
|
+
maxEventsPerWindow: normalized.grouping.maxEventsPerWindow,
|
|
69
|
+
windowMs: normalized.grouping.windowMs,
|
|
70
|
+
now,
|
|
71
|
+
});
|
|
72
|
+
const diagnostics = (0, diagnostics_js_1.createDiagnosticsState)();
|
|
73
|
+
const queue = (0, notification_queue_js_1.createNotificationQueue)({
|
|
74
|
+
maxPendingAlerts: normalized.queue.maxPendingAlerts,
|
|
75
|
+
concurrency: normalized.queue.concurrency,
|
|
76
|
+
});
|
|
77
|
+
const privacy = normalized.privacy;
|
|
78
|
+
let eventSequence = 0;
|
|
79
|
+
const captureSafeEvent = (error, metadata, context, request, eventKind = "error") => {
|
|
80
|
+
const timestamp = now();
|
|
81
|
+
const safeError = (0, redact_js_1.redactError)((0, normalize_js_1.normalizeError)(error, privacy), privacy);
|
|
82
|
+
const requestContext = safeRequest(request, privacy);
|
|
83
|
+
const eventContext = mergeContext(metadata, context, privacy);
|
|
84
|
+
const safeEvent = {
|
|
85
|
+
id: `event-${eventSequence + 1}`,
|
|
86
|
+
timestamp: new Date(timestamp).toISOString(),
|
|
87
|
+
service: normalized.service,
|
|
88
|
+
environment: normalized.environment,
|
|
89
|
+
...(normalized.release === undefined ? {} : { release: normalized.release }),
|
|
90
|
+
error: safeError,
|
|
91
|
+
...(requestContext === undefined ? {} : { request: requestContext }),
|
|
92
|
+
...(eventContext === undefined ? {} : { context: eventContext }),
|
|
93
|
+
};
|
|
94
|
+
eventSequence += 1;
|
|
95
|
+
const fingerprint = (0, fingerprint_js_1.fingerprintSafeErrorEvent)(safeEvent);
|
|
96
|
+
const group = groupStore.record(fingerprint, safeEvent);
|
|
97
|
+
const decision = (0, incident_policy_js_1.evaluateIncidentPolicy)({
|
|
98
|
+
group,
|
|
99
|
+
now: timestamp,
|
|
100
|
+
alertThreshold: normalized.grouping.alertThreshold,
|
|
101
|
+
cooldownMs: normalized.grouping.cooldownMs,
|
|
102
|
+
eventKind,
|
|
103
|
+
});
|
|
104
|
+
if (decision.shouldAlert) {
|
|
105
|
+
const alert = (0, incident_builder_js_1.buildIncidentAlert)(group, decision);
|
|
106
|
+
if (queue.enqueue(alert, normalized.notifiers)) {
|
|
107
|
+
groupStore.markAlerted(fingerprint, timestamp);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
diagnostics.capturedEvents += 1;
|
|
111
|
+
};
|
|
112
|
+
const captureException = (error, context) => {
|
|
113
|
+
if (!normalized.enabled) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
captureSafeEvent(error, undefined, context, undefined);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
diagnostics.captureFailures += 1;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const captureEvent = (event) => {
|
|
124
|
+
if (!normalized.enabled) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
if (event === null || typeof event !== "object" || event.level !== "error") {
|
|
129
|
+
throw new TypeError("event.level must be error");
|
|
130
|
+
}
|
|
131
|
+
if (typeof event.message !== "string") {
|
|
132
|
+
throw new TypeError("event.message must be a string");
|
|
133
|
+
}
|
|
134
|
+
captureSafeEvent(event.error ?? safeMessage(event.message, privacy), event.metadata, event.context, event.request, event.kind ?? "error");
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
diagnostics.captureFailures += 1;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
captureException,
|
|
142
|
+
captureEvent,
|
|
143
|
+
flush: (timeoutMs) => queue.flush(timeoutMs),
|
|
144
|
+
getDiagnostics: () => (0, diagnostics_js_1.snapshotDiagnostics)(diagnostics, {
|
|
145
|
+
groupsEvicted: groupStore.groupsEvicted(),
|
|
146
|
+
alertsQueued: queue.alertsQueued(),
|
|
147
|
+
alertsDropped: queue.alertsDropped(),
|
|
148
|
+
alertsSent: queue.alertsSent(),
|
|
149
|
+
notifierFailures: queue.notifierFailures(),
|
|
150
|
+
activeGroups: groupStore.size(),
|
|
151
|
+
pendingAlerts: queue.pending(),
|
|
152
|
+
}),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WotchiConfigurationError = void 0;
|
|
4
|
+
exports.validateConfig = validateConfig;
|
|
5
|
+
const errors_js_1 = require("./errors.js");
|
|
6
|
+
Object.defineProperty(exports, "WotchiConfigurationError", { enumerable: true, get: function () { return errors_js_1.WotchiConfigurationError; } });
|
|
7
|
+
const MAX_REDACT_KEYS = 100;
|
|
8
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
9
|
+
const fail = (field) => {
|
|
10
|
+
throw new errors_js_1.WotchiConfigurationError(`${field} is invalid`);
|
|
11
|
+
};
|
|
12
|
+
const readPositiveInteger = (parent, field, defaultValue) => {
|
|
13
|
+
const value = parent?.[field];
|
|
14
|
+
if (value === undefined) {
|
|
15
|
+
return defaultValue;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
18
|
+
return fail(field);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
22
|
+
const readOptionalRecord = (value, field) => {
|
|
23
|
+
if (value === undefined) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
if (!isRecord(value)) {
|
|
27
|
+
return fail(field);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
const normalizeRedactKeys = (privacy) => {
|
|
32
|
+
const value = privacy?.redactKeys;
|
|
33
|
+
if (value === undefined) {
|
|
34
|
+
return Object.freeze([]);
|
|
35
|
+
}
|
|
36
|
+
if (!Array.isArray(value) || value.length > MAX_REDACT_KEYS) {
|
|
37
|
+
return fail("privacy.redactKeys");
|
|
38
|
+
}
|
|
39
|
+
const keys = value.map((key, index) => {
|
|
40
|
+
if (typeof key !== "string" || key.trim().length === 0) {
|
|
41
|
+
return fail(`privacy.redactKeys[${index}]`);
|
|
42
|
+
}
|
|
43
|
+
return key.trim();
|
|
44
|
+
});
|
|
45
|
+
return Object.freeze([...new Set(keys)]);
|
|
46
|
+
};
|
|
47
|
+
const normalizeNotifiers = (value) => {
|
|
48
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
49
|
+
return fail("notifiers");
|
|
50
|
+
}
|
|
51
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
52
|
+
const notifier = value[index];
|
|
53
|
+
if (!isRecord(notifier) ||
|
|
54
|
+
typeof notifier.name !== "string" ||
|
|
55
|
+
notifier.name.trim().length === 0 ||
|
|
56
|
+
typeof notifier.send !== "function") {
|
|
57
|
+
return fail(`notifiers[${index}]`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return Object.freeze([...value]);
|
|
61
|
+
};
|
|
62
|
+
function validateConfig(config) {
|
|
63
|
+
if (!isRecord(config)) {
|
|
64
|
+
return fail("config");
|
|
65
|
+
}
|
|
66
|
+
const service = config.service;
|
|
67
|
+
if (typeof service !== "string" || service.trim().length === 0) {
|
|
68
|
+
return fail("service");
|
|
69
|
+
}
|
|
70
|
+
const environment = config.environment;
|
|
71
|
+
if (typeof environment !== "string" || environment.trim().length === 0) {
|
|
72
|
+
return fail("environment");
|
|
73
|
+
}
|
|
74
|
+
if (config.release !== undefined &&
|
|
75
|
+
(typeof config.release !== "string" || config.release.trim().length === 0)) {
|
|
76
|
+
return fail("release");
|
|
77
|
+
}
|
|
78
|
+
if (config.enabled !== undefined && typeof config.enabled !== "boolean") {
|
|
79
|
+
return fail("enabled");
|
|
80
|
+
}
|
|
81
|
+
const grouping = readOptionalRecord(config.grouping, "grouping");
|
|
82
|
+
const queue = readOptionalRecord(config.queue, "queue");
|
|
83
|
+
const privacy = readOptionalRecord(config.privacy, "privacy");
|
|
84
|
+
const concurrency = queue?.concurrency;
|
|
85
|
+
if (concurrency !== undefined && concurrency !== 1) {
|
|
86
|
+
return fail("queue.concurrency");
|
|
87
|
+
}
|
|
88
|
+
const normalized = {
|
|
89
|
+
service: service.trim(),
|
|
90
|
+
environment: environment.trim(),
|
|
91
|
+
...(config.release === undefined ? {} : { release: config.release.trim() }),
|
|
92
|
+
enabled: config.enabled ?? true,
|
|
93
|
+
grouping: Object.freeze({
|
|
94
|
+
windowMs: readPositiveInteger(grouping, "windowMs", 60_000),
|
|
95
|
+
alertThreshold: readPositiveInteger(grouping, "alertThreshold", 3),
|
|
96
|
+
cooldownMs: readPositiveInteger(grouping, "cooldownMs", 900_000),
|
|
97
|
+
maxGroups: readPositiveInteger(grouping, "maxGroups", 200),
|
|
98
|
+
maxEventsPerWindow: readPositiveInteger(grouping, "maxEventsPerWindow", 100),
|
|
99
|
+
}),
|
|
100
|
+
queue: Object.freeze({
|
|
101
|
+
maxPendingAlerts: readPositiveInteger(queue, "maxPendingAlerts", 100),
|
|
102
|
+
concurrency: 1,
|
|
103
|
+
}),
|
|
104
|
+
privacy: Object.freeze({
|
|
105
|
+
redactKeys: normalizeRedactKeys(privacy),
|
|
106
|
+
maxDepth: readPositiveInteger(privacy, "maxDepth", 5),
|
|
107
|
+
maxKeys: readPositiveInteger(privacy, "maxKeys", 100),
|
|
108
|
+
maxStringLength: readPositiveInteger(privacy, "maxStringLength", 500),
|
|
109
|
+
maxStackLength: readPositiveInteger(privacy, "maxStackLength", 4_000),
|
|
110
|
+
}),
|
|
111
|
+
notifiers: normalizeNotifiers(config.notifiers),
|
|
112
|
+
};
|
|
113
|
+
return Object.freeze(normalized);
|
|
114
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDiagnosticsState = createDiagnosticsState;
|
|
4
|
+
exports.snapshotDiagnostics = snapshotDiagnostics;
|
|
5
|
+
function createDiagnosticsState() {
|
|
6
|
+
return { capturedEvents: 0, captureFailures: 0 };
|
|
7
|
+
}
|
|
8
|
+
function snapshotDiagnostics(state, values) {
|
|
9
|
+
return Object.freeze({
|
|
10
|
+
capturedEvents: state.capturedEvents,
|
|
11
|
+
captureFailures: state.captureFailures,
|
|
12
|
+
...values,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WotchiConfigurationError = void 0;
|
|
4
|
+
class WotchiConfigurationError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(`Invalid Wotchi configuration: ${message}`);
|
|
7
|
+
this.name = "WotchiConfigurationError";
|
|
8
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.WotchiConfigurationError = WotchiConfigurationError;
|