@adonis-agora/telescope 0.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/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/configure.d.ts +16 -0
- package/dist/configure.d.ts.map +1 -0
- package/dist/configure.js +75 -0
- package/dist/configure.js.map +1 -0
- package/dist/providers/telescope_ai_provider.d.ts +20 -0
- package/dist/providers/telescope_ai_provider.d.ts.map +1 -0
- package/dist/providers/telescope_ai_provider.js +45 -0
- package/dist/providers/telescope_ai_provider.js.map +1 -0
- package/dist/providers/telescope_alerts_provider.d.ts +23 -0
- package/dist/providers/telescope_alerts_provider.d.ts.map +1 -0
- package/dist/providers/telescope_alerts_provider.js +72 -0
- package/dist/providers/telescope_alerts_provider.js.map +1 -0
- package/dist/providers/telescope_provider.d.ts +43 -0
- package/dist/providers/telescope_provider.d.ts.map +1 -0
- package/dist/providers/telescope_provider.js +103 -0
- package/dist/providers/telescope_provider.js.map +1 -0
- package/dist/providers/telescope_ui_provider.d.ts +21 -0
- package/dist/providers/telescope_ui_provider.d.ts.map +1 -0
- package/dist/providers/telescope_ui_provider.js +119 -0
- package/dist/providers/telescope_ui_provider.js.map +1 -0
- package/dist/providers/telescope_watchers_provider.d.ts +31 -0
- package/dist/providers/telescope_watchers_provider.d.ts.map +1 -0
- package/dist/providers/telescope_watchers_provider.js +116 -0
- package/dist/providers/telescope_watchers_provider.js.map +1 -0
- package/dist/src/ai/define_config.d.ts +56 -0
- package/dist/src/ai/define_config.d.ts.map +1 -0
- package/dist/src/ai/define_config.js +39 -0
- package/dist/src/ai/define_config.js.map +1 -0
- package/dist/src/ai/diagnoser.d.ts +34 -0
- package/dist/src/ai/diagnoser.d.ts.map +1 -0
- package/dist/src/ai/diagnoser.js +74 -0
- package/dist/src/ai/diagnoser.js.map +1 -0
- package/dist/src/ai/diagnosis_cache.d.ts +43 -0
- package/dist/src/ai/diagnosis_cache.d.ts.map +1 -0
- package/dist/src/ai/diagnosis_cache.js +56 -0
- package/dist/src/ai/diagnosis_cache.js.map +1 -0
- package/dist/src/ai/factory.d.ts +15 -0
- package/dist/src/ai/factory.d.ts.map +1 -0
- package/dist/src/ai/factory.js +24 -0
- package/dist/src/ai/factory.js.map +1 -0
- package/dist/src/ai/index.d.ts +14 -0
- package/dist/src/ai/index.d.ts.map +1 -0
- package/dist/src/ai/index.js +15 -0
- package/dist/src/ai/index.js.map +1 -0
- package/dist/src/ai/prompt.d.ts +31 -0
- package/dist/src/ai/prompt.d.ts.map +1 -0
- package/dist/src/ai/prompt.js +66 -0
- package/dist/src/ai/prompt.js.map +1 -0
- package/dist/src/ai/telescope_ai_diagnoser.d.ts +79 -0
- package/dist/src/ai/telescope_ai_diagnoser.d.ts.map +1 -0
- package/dist/src/ai/telescope_ai_diagnoser.js +111 -0
- package/dist/src/ai/telescope_ai_diagnoser.js.map +1 -0
- package/dist/src/alerts/alert_channel.d.ts +69 -0
- package/dist/src/alerts/alert_channel.d.ts.map +1 -0
- package/dist/src/alerts/alert_channel.js +114 -0
- package/dist/src/alerts/alert_channel.js.map +1 -0
- package/dist/src/alerts/alert_rule.d.ts +86 -0
- package/dist/src/alerts/alert_rule.d.ts.map +1 -0
- package/dist/src/alerts/alert_rule.js +2 -0
- package/dist/src/alerts/alert_rule.js.map +1 -0
- package/dist/src/alerts/alerter.d.ts +72 -0
- package/dist/src/alerts/alerter.d.ts.map +1 -0
- package/dist/src/alerts/alerter.js +248 -0
- package/dist/src/alerts/alerter.js.map +1 -0
- package/dist/src/alerts/define_config.d.ts +68 -0
- package/dist/src/alerts/define_config.d.ts.map +1 -0
- package/dist/src/alerts/define_config.js +57 -0
- package/dist/src/alerts/define_config.js.map +1 -0
- package/dist/src/alerts/exception_source.d.ts +44 -0
- package/dist/src/alerts/exception_source.d.ts.map +1 -0
- package/dist/src/alerts/exception_source.js +79 -0
- package/dist/src/alerts/exception_source.js.map +1 -0
- package/dist/src/alerts/index.d.ts +16 -0
- package/dist/src/alerts/index.d.ts.map +1 -0
- package/dist/src/alerts/index.js +17 -0
- package/dist/src/alerts/index.js.map +1 -0
- package/dist/src/alerts/new_exception_tracker.d.ts +50 -0
- package/dist/src/alerts/new_exception_tracker.d.ts.map +1 -0
- package/dist/src/alerts/new_exception_tracker.js +74 -0
- package/dist/src/alerts/new_exception_tracker.js.map +1 -0
- package/dist/src/alerts/parse_duration.d.ts +10 -0
- package/dist/src/alerts/parse_duration.d.ts.map +1 -0
- package/dist/src/alerts/parse_duration.js +27 -0
- package/dist/src/alerts/parse_duration.js.map +1 -0
- package/dist/src/alerts/slack_format.d.ts +60 -0
- package/dist/src/alerts/slack_format.d.ts.map +1 -0
- package/dist/src/alerts/slack_format.js +122 -0
- package/dist/src/alerts/slack_format.js.map +1 -0
- package/dist/src/context_accessor.d.ts +30 -0
- package/dist/src/context_accessor.d.ts.map +1 -0
- package/dist/src/context_accessor.js +20 -0
- package/dist/src/context_accessor.js.map +1 -0
- package/dist/src/define_config.d.ts +109 -0
- package/dist/src/define_config.d.ts.map +1 -0
- package/dist/src/define_config.js +38 -0
- package/dist/src/define_config.js.map +1 -0
- package/dist/src/diagnostics_registry.d.ts +46 -0
- package/dist/src/diagnostics_registry.d.ts.map +1 -0
- package/dist/src/diagnostics_registry.js +34 -0
- package/dist/src/diagnostics_registry.js.map +1 -0
- package/dist/src/diagnostics_watcher.d.ts +72 -0
- package/dist/src/diagnostics_watcher.d.ts.map +1 -0
- package/dist/src/diagnostics_watcher.js +119 -0
- package/dist/src/diagnostics_watcher.js.map +1 -0
- package/dist/src/entry.d.ts +81 -0
- package/dist/src/entry.d.ts.map +1 -0
- package/dist/src/entry.js +34 -0
- package/dist/src/entry.js.map +1 -0
- package/dist/src/exception_family_hash.d.ts +29 -0
- package/dist/src/exception_family_hash.d.ts.map +1 -0
- package/dist/src/exception_family_hash.js +30 -0
- package/dist/src/exception_family_hash.js.map +1 -0
- package/dist/src/exception_watcher.d.ts +66 -0
- package/dist/src/exception_watcher.d.ts.map +1 -0
- package/dist/src/exception_watcher.js +94 -0
- package/dist/src/exception_watcher.js.map +1 -0
- package/dist/src/extension/registry.d.ts +17 -0
- package/dist/src/extension/registry.d.ts.map +1 -0
- package/dist/src/extension/registry.js +56 -0
- package/dist/src/extension/registry.js.map +1 -0
- package/dist/src/extension/types.d.ts +158 -0
- package/dist/src/extension/types.d.ts.map +1 -0
- package/dist/src/extension/types.js +5 -0
- package/dist/src/extension/types.js.map +1 -0
- package/dist/src/index.d.ts +36 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +28 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/redaction/redact.d.ts +93 -0
- package/dist/src/redaction/redact.d.ts.map +1 -0
- package/dist/src/redaction/redact.js +184 -0
- package/dist/src/redaction/redact.js.map +1 -0
- package/dist/src/redaction/redacting_store.d.ts +28 -0
- package/dist/src/redaction/redacting_store.d.ts.map +1 -0
- package/dist/src/redaction/redacting_store.js +49 -0
- package/dist/src/redaction/redacting_store.js.map +1 -0
- package/dist/src/registry.d.ts +26 -0
- package/dist/src/registry.d.ts.map +1 -0
- package/dist/src/registry.js +28 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/request_watcher.d.ts +44 -0
- package/dist/src/request_watcher.d.ts.map +1 -0
- package/dist/src/request_watcher.js +37 -0
- package/dist/src/request_watcher.js.map +1 -0
- package/dist/src/service.d.ts +36 -0
- package/dist/src/service.d.ts.map +1 -0
- package/dist/src/service.js +65 -0
- package/dist/src/service.js.map +1 -0
- package/dist/src/store.d.ts +56 -0
- package/dist/src/store.d.ts.map +1 -0
- package/dist/src/store.js +2 -0
- package/dist/src/store.js.map +1 -0
- package/dist/src/stores/factory.d.ts +61 -0
- package/dist/src/stores/factory.d.ts.map +1 -0
- package/dist/src/stores/factory.js +42 -0
- package/dist/src/stores/factory.js.map +1 -0
- package/dist/src/stores/lucid.d.ts +138 -0
- package/dist/src/stores/lucid.d.ts.map +1 -0
- package/dist/src/stores/lucid.js +257 -0
- package/dist/src/stores/lucid.js.map +1 -0
- package/dist/src/stores/memory.d.ts +31 -0
- package/dist/src/stores/memory.d.ts.map +1 -0
- package/dist/src/stores/memory.js +117 -0
- package/dist/src/stores/memory.js.map +1 -0
- package/dist/src/telescope_middleware.d.ts +19 -0
- package/dist/src/telescope_middleware.d.ts.map +1 -0
- package/dist/src/telescope_middleware.js +56 -0
- package/dist/src/telescope_middleware.js.map +1 -0
- package/dist/src/ui/api.d.ts +49 -0
- package/dist/src/ui/api.d.ts.map +1 -0
- package/dist/src/ui/api.js +155 -0
- package/dist/src/ui/api.js.map +1 -0
- package/dist/src/ui/dashboard.d.ts +8 -0
- package/dist/src/ui/dashboard.d.ts.map +1 -0
- package/dist/src/ui/dashboard.html +626 -0
- package/dist/src/ui/dashboard.js +29 -0
- package/dist/src/ui/dashboard.js.map +1 -0
- package/dist/src/ui/define_config.d.ts +87 -0
- package/dist/src/ui/define_config.d.ts.map +1 -0
- package/dist/src/ui/define_config.js +104 -0
- package/dist/src/ui/define_config.js.map +1 -0
- package/dist/src/ui/extension_api.d.ts +23 -0
- package/dist/src/ui/extension_api.d.ts.map +1 -0
- package/dist/src/ui/extension_api.js +50 -0
- package/dist/src/ui/extension_api.js.map +1 -0
- package/dist/src/ui/guard.d.ts +33 -0
- package/dist/src/ui/guard.d.ts.map +1 -0
- package/dist/src/ui/guard.js +47 -0
- package/dist/src/ui/guard.js.map +1 -0
- package/dist/src/ui/http.d.ts +47 -0
- package/dist/src/ui/http.d.ts.map +1 -0
- package/dist/src/ui/http.js +43 -0
- package/dist/src/ui/http.js.map +1 -0
- package/dist/src/ui/index.d.ts +12 -0
- package/dist/src/ui/index.d.ts.map +1 -0
- package/dist/src/ui/index.js +13 -0
- package/dist/src/ui/index.js.map +1 -0
- package/dist/src/watchers/cache_watcher.d.ts +60 -0
- package/dist/src/watchers/cache_watcher.d.ts.map +1 -0
- package/dist/src/watchers/cache_watcher.js +72 -0
- package/dist/src/watchers/cache_watcher.js.map +1 -0
- package/dist/src/watchers/define_config.d.ts +38 -0
- package/dist/src/watchers/define_config.d.ts.map +1 -0
- package/dist/src/watchers/define_config.js +17 -0
- package/dist/src/watchers/define_config.js.map +1 -0
- package/dist/src/watchers/emitter.d.ts +32 -0
- package/dist/src/watchers/emitter.d.ts.map +1 -0
- package/dist/src/watchers/emitter.js +2 -0
- package/dist/src/watchers/emitter.js.map +1 -0
- package/dist/src/watchers/http_client_watcher.d.ts +74 -0
- package/dist/src/watchers/http_client_watcher.d.ts.map +1 -0
- package/dist/src/watchers/http_client_watcher.js +168 -0
- package/dist/src/watchers/http_client_watcher.js.map +1 -0
- package/dist/src/watchers/index.d.ts +19 -0
- package/dist/src/watchers/index.d.ts.map +1 -0
- package/dist/src/watchers/index.js +19 -0
- package/dist/src/watchers/index.js.map +1 -0
- package/dist/src/watchers/logs_watcher.d.ts +82 -0
- package/dist/src/watchers/logs_watcher.d.ts.map +1 -0
- package/dist/src/watchers/logs_watcher.js +145 -0
- package/dist/src/watchers/logs_watcher.js.map +1 -0
- package/dist/src/watchers/lucid_query_watcher.d.ts +64 -0
- package/dist/src/watchers/lucid_query_watcher.d.ts.map +1 -0
- package/dist/src/watchers/lucid_query_watcher.js +84 -0
- package/dist/src/watchers/lucid_query_watcher.js.map +1 -0
- package/dist/src/watchers/mail_watcher.d.ts +51 -0
- package/dist/src/watchers/mail_watcher.d.ts.map +1 -0
- package/dist/src/watchers/mail_watcher.js +93 -0
- package/dist/src/watchers/mail_watcher.js.map +1 -0
- package/dist/src/watchers/normalize_http_target.d.ts +17 -0
- package/dist/src/watchers/normalize_http_target.d.ts.map +1 -0
- package/dist/src/watchers/normalize_http_target.js +41 -0
- package/dist/src/watchers/normalize_http_target.js.map +1 -0
- package/dist/src/watchers/query_family_hash.d.ts +8 -0
- package/dist/src/watchers/query_family_hash.d.ts.map +1 -0
- package/dist/src/watchers/query_family_hash.js +31 -0
- package/dist/src/watchers/query_family_hash.js.map +1 -0
- package/dist/src/watchers/record.d.ts +22 -0
- package/dist/src/watchers/record.d.ts.map +1 -0
- package/dist/src/watchers/record.js +48 -0
- package/dist/src/watchers/record.js.map +1 -0
- package/dist/stubs/config/telescope.stub +56 -0
- package/dist/stubs/config/telescope_ai.stub +36 -0
- package/dist/stubs/config/telescope_alerts.stub +47 -0
- package/dist/stubs/config/telescope_ui.stub +40 -0
- package/dist/stubs/config/telescope_watchers.stub +30 -0
- package/dist/stubs/database/migrations/create_telescope_entries_table.stub +39 -0
- package/dist/stubs/main.d.ts +6 -0
- package/dist/stubs/main.d.ts.map +1 -0
- package/dist/stubs/main.js +7 -0
- package/dist/stubs/main.js.map +1 -0
- package/package.json +140 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { currentTraceId } from '../context_accessor.js';
|
|
2
|
+
import { getTelescopeRuntime } from '../registry.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the active telescope store WITHOUT dependency injection. `@adonis-agora/telescope`'s
|
|
5
|
+
* provider publishes the live store on a cross-copy-stable global slot at boot
|
|
6
|
+
* (see its `registry.ts`); the request middleware records through that same handle.
|
|
7
|
+
* Reusing it here lets these watchers record from inside synchronous emitter
|
|
8
|
+
* subscribers — where there is no container to `inject()` from — and degrade to a
|
|
9
|
+
* no-op when telescope is disabled or not booted.
|
|
10
|
+
*/
|
|
11
|
+
export function resolveStore() {
|
|
12
|
+
return getTelescopeRuntime().store;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Record one entry through the runtime store, swallowing every failure. Watchers
|
|
16
|
+
* run inside emitter subscribers on the host's hot paths, so this is strictly
|
|
17
|
+
* fire-and-forget: a missing store, a throwing `record`, or a rejected promise can
|
|
18
|
+
* never break (or block) the emit it is observing.
|
|
19
|
+
*
|
|
20
|
+
* The active `@adonis-agora/context` trace id is backfilled when the caller did not set
|
|
21
|
+
* `traceId` explicitly, mirroring how the core watchers correlate entries.
|
|
22
|
+
*/
|
|
23
|
+
export function safeRecord(input, source) {
|
|
24
|
+
let store;
|
|
25
|
+
try {
|
|
26
|
+
store = resolveStore();
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
reportError(source, err);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!store)
|
|
33
|
+
return;
|
|
34
|
+
try {
|
|
35
|
+
const resolved = input.traceId === undefined ? { ...input, traceId: currentTraceId() } : input;
|
|
36
|
+
// Fire-and-forget: the store is async but the subscriber is sync. Swallow
|
|
37
|
+
// rejections so an observed code path is never affected by telescope.
|
|
38
|
+
void Promise.resolve(store.record(resolved)).catch((err) => reportError(source, err));
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
reportError(source, err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function reportError(source, err) {
|
|
45
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
46
|
+
console.error(`${source}: failed to record telescope entry: ${message}`);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../src/watchers/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,mBAAmB,EAAE,CAAC,KAAK,CAAC;AACrC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,KAAkB,EAAE,MAAc;IAC3D,IAAI,KAA4B,CAAC;IACjC,IAAI,CAAC;QACH,KAAK,GAAG,YAAY,EAAE,CAAC;IACzB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACzB,OAAO;IACT,CAAC;IACD,IAAI,CAAC,KAAK;QAAE,OAAO;IAEnB,IAAI,CAAC;QACH,MAAM,QAAQ,GACZ,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAChF,0EAA0E;QAC1E,sEAAsE;QACtE,KAAK,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACxF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,MAAc,EAAE,GAAY;IAC/C,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,uCAAuC,OAAO,EAAE,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.configPath('telescope.ts') })
|
|
3
|
+
}}}
|
|
4
|
+
import { defineConfig, storage } from '@adonis-agora/telescope'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for `@adonis-agora/telescope`. Everything is optional — the defaults use
|
|
8
|
+
* the in-memory store with both watchers (`request` + `diagnostics`) enabled and a
|
|
9
|
+
* 1000-entry cap.
|
|
10
|
+
*/
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
/**
|
|
13
|
+
* Master switch. Set to `false` to disable all recording (zero overhead).
|
|
14
|
+
*/
|
|
15
|
+
// enabled: true,
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Which named store backs telescope. The active driver is selected by `store`
|
|
19
|
+
* and built from the `stores` map below.
|
|
20
|
+
*/
|
|
21
|
+
store: 'memory',
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Named store drivers, built with the `storage` factory. Each is a lazy thunk —
|
|
25
|
+
* its peer dependency is only imported when that driver is the active one.
|
|
26
|
+
*
|
|
27
|
+
* To persist entries across restarts, install `@adonisjs/lucid`, publish the
|
|
28
|
+
* migration (`node ace make:migration create_telescope_entries_table`, copying the
|
|
29
|
+
* body from this package's stub) or pass `autoCreateTable: true`, switch
|
|
30
|
+
* `store` to `'lucid'`, and uncomment the lucid driver:
|
|
31
|
+
*/
|
|
32
|
+
stores: {
|
|
33
|
+
memory: storage.memory({ limit: 1000 }),
|
|
34
|
+
// lucid: storage.lucid({ connection: 'pg' }),
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Active watchers. Omit one to disable it.
|
|
39
|
+
* - 'request' — records each HTTP request (method, url, status, duration).
|
|
40
|
+
* - 'diagnostics' — records every `agora:<lib>:<event>` diagnostics publish.
|
|
41
|
+
*/
|
|
42
|
+
// watchers: ['request', 'diagnostics'],
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Sensitive-data redaction. Every entry's content is scrubbed before it is
|
|
46
|
+
* persisted — a built-in set of sensitive keys (`authorization`, `cookie`,
|
|
47
|
+
* `password`, `token`, `api_key`, `secret`, `set-cookie`, …) is masked with
|
|
48
|
+
* `[REDACTED]`, case-insensitively, at any depth. ENABLED by default.
|
|
49
|
+
*
|
|
50
|
+
* Add your own keys, or disable redaction entirely:
|
|
51
|
+
*/
|
|
52
|
+
// redact: {
|
|
53
|
+
// enabled: true,
|
|
54
|
+
// keys: ['ssn', 'credit_card'],
|
|
55
|
+
// },
|
|
56
|
+
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.configPath('telescope_ai.ts') })
|
|
3
|
+
}}}
|
|
4
|
+
import env from '#start/env'
|
|
5
|
+
import { defineConfig } from '@adonis-agora/telescope/ai'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for `@adonis-agora/telescope/ai`. Diagnosis is on when an Anthropic API
|
|
9
|
+
* key resolves from the environment; with no key the diagnoser is a safe no-op.
|
|
10
|
+
*
|
|
11
|
+
* Add `ANTHROPIC_API_KEY` to your `.env` and validate it in `start/env.ts`:
|
|
12
|
+
* ANTHROPIC_API_KEY: Env.schema.string.optional()
|
|
13
|
+
*/
|
|
14
|
+
export default defineConfig({
|
|
15
|
+
/**
|
|
16
|
+
* Master switch. Set to `false` to disable diagnosis entirely.
|
|
17
|
+
*/
|
|
18
|
+
// enabled: true,
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The Anthropic API key — sourced from the environment, never hardcoded.
|
|
22
|
+
*/
|
|
23
|
+
apiKey: env.get('ANTHROPIC_API_KEY'),
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Claude model id. Defaults to `claude-sonnet-4-6` (best speed/intelligence
|
|
27
|
+
* balance). Use `claude-opus-4-8` for the most capable diagnosis, or
|
|
28
|
+
* `claude-haiku-4-5-20251001` for the cheapest.
|
|
29
|
+
*/
|
|
30
|
+
// model: 'claude-sonnet-4-6',
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Hard cap on generated tokens per diagnosis. Default 1024.
|
|
34
|
+
*/
|
|
35
|
+
// maxTokens: 1024,
|
|
36
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.configPath('telescope_alerts.ts') })
|
|
3
|
+
}}}
|
|
4
|
+
import { defineConfig } from '@adonis-agora/telescope/alerts'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for `@adonis-agora/telescope/alerts`. By default alerting is on, polls the
|
|
8
|
+
* telescope store every 30s for brand-new exception families, and logs each alert
|
|
9
|
+
* to the console. Add a Slack or generic webhook channel to ship alerts off-box.
|
|
10
|
+
*/
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
/**
|
|
13
|
+
* Master switch. Set to `false` to disable alerting entirely.
|
|
14
|
+
*/
|
|
15
|
+
// enabled: true,
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Delivery destinations. Each fired alert is sent to every channel concurrently;
|
|
19
|
+
* one channel failing never blocks the others. Accepts declarative specs or
|
|
20
|
+
* pre-built channel objects (slackChannel/webhookChannel/customChannel).
|
|
21
|
+
*/
|
|
22
|
+
// channels: [
|
|
23
|
+
// { type: 'console' },
|
|
24
|
+
// { type: 'slack', url: env.get('TELESCOPE_SLACK_WEBHOOK') },
|
|
25
|
+
// { type: 'webhook', url: env.get('TELESCOPE_ALERT_WEBHOOK') },
|
|
26
|
+
// ],
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Rules to evaluate.
|
|
30
|
+
* - { type: 'new-exception', window } — page the first time an exception family
|
|
31
|
+
* is seen within `window` (and again after it elapses / on resolve).
|
|
32
|
+
* - { type: 'exception-rate', window, threshold } — page when >= threshold
|
|
33
|
+
* exceptions are recorded in the trailing `window`.
|
|
34
|
+
*/
|
|
35
|
+
// rules: [{ type: 'new-exception', window: '1h' }],
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* External dashboard URL — when set, Slack alerts include a deep link to the entry.
|
|
39
|
+
*/
|
|
40
|
+
// dashboardUrl: 'https://telescope.example.com/',
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Poll cadence and re-notify cooldown (duration strings).
|
|
44
|
+
*/
|
|
45
|
+
// every: '30s',
|
|
46
|
+
// cooldown: '15m',
|
|
47
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.configPath('telescope_ui.ts') })
|
|
3
|
+
}}}
|
|
4
|
+
import { defineConfig } from '@adonis-agora/telescope/ui'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for `@adonis-agora/telescope/ui`. By default the dashboard mounts at
|
|
8
|
+
* `/telescope` and is reachable automatically outside production. In production it
|
|
9
|
+
* is denied unless you set a `token` / `basic` credential below, or supply your
|
|
10
|
+
* own `authorize` hook delegating to your app's auth.
|
|
11
|
+
*/
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
/**
|
|
14
|
+
* Master switch. Set to `false` to register no routes at all.
|
|
15
|
+
*/
|
|
16
|
+
// enabled: true,
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* URL prefix. The dashboard is served here; the JSON API lives at `<path>/api/*`.
|
|
20
|
+
*/
|
|
21
|
+
// path: '/telescope',
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Access-decision hook. Return `true` to allow the request, `false` to reject it
|
|
25
|
+
* (the guard answers 401 when no credential was presented, 403 when one was and
|
|
26
|
+
* was rejected). Delegate to your own app auth here, e.g.:
|
|
27
|
+
*/
|
|
28
|
+
// authorize: (ctx) => ctx.auth?.user?.isAdmin === true,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Built-in credentials for the default policy (ignored when `authorize` is set).
|
|
32
|
+
* Gate a production dashboard without writing a hook:
|
|
33
|
+
* - token: allow `Authorization: Bearer <token>` or `?token=<token>`
|
|
34
|
+
* - basic: allow HTTP Basic auth
|
|
35
|
+
*/
|
|
36
|
+
// credentials: {
|
|
37
|
+
// token: env.get('TELESCOPE_UI_TOKEN'),
|
|
38
|
+
// basic: { username: 'admin', password: env.get('TELESCOPE_UI_PASSWORD') },
|
|
39
|
+
// },
|
|
40
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.configPath('telescope_watchers.ts') })
|
|
3
|
+
}}}
|
|
4
|
+
import { defineConfig } from '@adonis-agora/telescope/watchers'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for `@adonis-agora/telescope/watchers`. By default only the Lucid
|
|
8
|
+
* `query` watcher is enabled — its `db:query` event is verified against the
|
|
9
|
+
* installed `@adonisjs/lucid` types. The `mail` and `cache` watchers are opt-in.
|
|
10
|
+
*/
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
/**
|
|
13
|
+
* Master switch. Set to `false` to start no per-technology watcher.
|
|
14
|
+
*/
|
|
15
|
+
// enabled: true,
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Active watchers. Omit one to disable it.
|
|
19
|
+
* - 'query' — records every Lucid SQL query (sql, bindings, duration, connection).
|
|
20
|
+
* - 'mail' — records every email sent (mail:sent).
|
|
21
|
+
* - 'cache' — records @adonisjs/cache hit/miss/write/delete events.
|
|
22
|
+
* - 'http-client' — records every outbound fetch call (method, url, status, duration).
|
|
23
|
+
* - 'logs' — records AdonisJS logger output (level, message, structured fields).
|
|
24
|
+
*
|
|
25
|
+
* Note: the 'mail' and 'cache' event contracts are best-effort — those packages
|
|
26
|
+
* are not present in this repo, so their event names/payloads could not be
|
|
27
|
+
* verified against their types. See the package README.
|
|
28
|
+
*/
|
|
29
|
+
// watchers: ['query'],
|
|
30
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.migrationsPath(`${new Date().getTime()}_create_telescope_entries_table.ts`) })
|
|
3
|
+
}}}
|
|
4
|
+
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates the table the `lucid` telescope store persists entries into.
|
|
8
|
+
*
|
|
9
|
+
* `content` and `tags` are JSON text columns; `created_at` is stored as epoch
|
|
10
|
+
* milliseconds (a plain integer) so newest-first ordering and age-based pruning
|
|
11
|
+
* are driver-agnostic integer comparisons across sqlite / Postgres / MySQL.
|
|
12
|
+
*/
|
|
13
|
+
export default class extends BaseSchema {
|
|
14
|
+
protected tableName = 'telescope_entries'
|
|
15
|
+
|
|
16
|
+
async up() {
|
|
17
|
+
this.schema.createTable(this.tableName, (table) => {
|
|
18
|
+
table.string('id').primary().notNullable()
|
|
19
|
+
table.string('type').notNullable()
|
|
20
|
+
table.string('family_hash').nullable()
|
|
21
|
+
table.text('content').notNullable()
|
|
22
|
+
table.text('tags').notNullable()
|
|
23
|
+
table.integer('sequence').notNullable()
|
|
24
|
+
table.integer('duration_ms').nullable()
|
|
25
|
+
table.string('origin').notNullable()
|
|
26
|
+
table.string('trace_id').nullable()
|
|
27
|
+
table.bigInteger('created_at').notNullable()
|
|
28
|
+
|
|
29
|
+
table.index(['created_at'])
|
|
30
|
+
table.index(['type'])
|
|
31
|
+
table.index(['trace_id'])
|
|
32
|
+
table.index(['family_hash'])
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async down() {
|
|
37
|
+
this.schema.dropTable(this.tableName)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../stubs/main.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAgD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
/**
|
|
3
|
+
* Absolute path to the published stubs directory, resolved from this compiled
|
|
4
|
+
* module's location (`dist/stubs/main.js`). Passed to `codemods.makeUsingStub`.
|
|
5
|
+
*/
|
|
6
|
+
export const stubsRoot = fileURLToPath(new URL('./', import.meta.url));
|
|
7
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../stubs/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adonis-agora/telescope",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Laravel Telescope-style headless observability for AdonisJS — records HTTP requests and every Agora diagnostics event as queryable entries, plus opt-in subpaths for per-technology watchers, a web dashboard, AI exception diagnosis, and alerting.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/DavideCarvalho/adonis-telescope.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
11
|
+
"author": "Davi Carvalho <davi@goflip.ai>",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/src/index.js",
|
|
14
|
+
"types": "./dist/src/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/src/index.d.ts",
|
|
18
|
+
"import": "./dist/src/index.js",
|
|
19
|
+
"default": "./dist/src/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./telescope_provider": {
|
|
22
|
+
"types": "./dist/providers/telescope_provider.d.ts",
|
|
23
|
+
"import": "./dist/providers/telescope_provider.js",
|
|
24
|
+
"default": "./dist/providers/telescope_provider.js"
|
|
25
|
+
},
|
|
26
|
+
"./telescope_middleware": {
|
|
27
|
+
"types": "./dist/src/telescope_middleware.d.ts",
|
|
28
|
+
"import": "./dist/src/telescope_middleware.js",
|
|
29
|
+
"default": "./dist/src/telescope_middleware.js"
|
|
30
|
+
},
|
|
31
|
+
"./configure": {
|
|
32
|
+
"types": "./dist/configure.d.ts",
|
|
33
|
+
"import": "./dist/configure.js",
|
|
34
|
+
"default": "./dist/configure.js"
|
|
35
|
+
},
|
|
36
|
+
"./watchers": {
|
|
37
|
+
"types": "./dist/src/watchers/index.d.ts",
|
|
38
|
+
"import": "./dist/src/watchers/index.js",
|
|
39
|
+
"default": "./dist/src/watchers/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./watchers_provider": {
|
|
42
|
+
"types": "./dist/providers/telescope_watchers_provider.d.ts",
|
|
43
|
+
"import": "./dist/providers/telescope_watchers_provider.js",
|
|
44
|
+
"default": "./dist/providers/telescope_watchers_provider.js"
|
|
45
|
+
},
|
|
46
|
+
"./ui": {
|
|
47
|
+
"types": "./dist/src/ui/index.d.ts",
|
|
48
|
+
"import": "./dist/src/ui/index.js",
|
|
49
|
+
"default": "./dist/src/ui/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./ui_provider": {
|
|
52
|
+
"types": "./dist/providers/telescope_ui_provider.d.ts",
|
|
53
|
+
"import": "./dist/providers/telescope_ui_provider.js",
|
|
54
|
+
"default": "./dist/providers/telescope_ui_provider.js"
|
|
55
|
+
},
|
|
56
|
+
"./ai": {
|
|
57
|
+
"types": "./dist/src/ai/index.d.ts",
|
|
58
|
+
"import": "./dist/src/ai/index.js",
|
|
59
|
+
"default": "./dist/src/ai/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./ai_provider": {
|
|
62
|
+
"types": "./dist/providers/telescope_ai_provider.d.ts",
|
|
63
|
+
"import": "./dist/providers/telescope_ai_provider.js",
|
|
64
|
+
"default": "./dist/providers/telescope_ai_provider.js"
|
|
65
|
+
},
|
|
66
|
+
"./alerts": {
|
|
67
|
+
"types": "./dist/src/alerts/index.d.ts",
|
|
68
|
+
"import": "./dist/src/alerts/index.js",
|
|
69
|
+
"default": "./dist/src/alerts/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./alerts_provider": {
|
|
72
|
+
"types": "./dist/providers/telescope_alerts_provider.d.ts",
|
|
73
|
+
"import": "./dist/providers/telescope_alerts_provider.js",
|
|
74
|
+
"default": "./dist/providers/telescope_alerts_provider.js"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"files": [
|
|
78
|
+
"dist/",
|
|
79
|
+
"README.md",
|
|
80
|
+
"CHANGELOG.md"
|
|
81
|
+
],
|
|
82
|
+
"//sideEffects": "registry.ts publishes the telescope runtime handle on a Symbol.for() global slot at import time — process-global state a bundler told sideEffects:false could tree-shake. The rest is pure.",
|
|
83
|
+
"sideEffects": [
|
|
84
|
+
"**/registry.js",
|
|
85
|
+
"**/registry.ts"
|
|
86
|
+
],
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"@adonisjs/core": "^6.12.0",
|
|
89
|
+
"@adonisjs/lucid": "^21.0.0",
|
|
90
|
+
"@adonisjs/mail": "^9.0.0",
|
|
91
|
+
"@adonisjs/cache": "^1.0.0",
|
|
92
|
+
"@anthropic-ai/sdk": "^0.32.0"
|
|
93
|
+
},
|
|
94
|
+
"peerDependenciesMeta": {
|
|
95
|
+
"@adonisjs/lucid": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"@adonisjs/mail": {
|
|
99
|
+
"optional": true
|
|
100
|
+
},
|
|
101
|
+
"@adonisjs/cache": {
|
|
102
|
+
"optional": true
|
|
103
|
+
},
|
|
104
|
+
"@anthropic-ai/sdk": {
|
|
105
|
+
"optional": true
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"devDependencies": {
|
|
109
|
+
"@adonisjs/assembler": "^7.8.0",
|
|
110
|
+
"@adonisjs/core": "^6.17.0",
|
|
111
|
+
"@adonisjs/lucid": "^21.6.1",
|
|
112
|
+
"@anthropic-ai/sdk": "^0.32.0",
|
|
113
|
+
"@types/better-sqlite3": "^7.6.0",
|
|
114
|
+
"@types/node": "^20.0.0",
|
|
115
|
+
"better-sqlite3": "^12.0.0",
|
|
116
|
+
"luxon": "^3.4.4",
|
|
117
|
+
"typescript": "^5.4.0",
|
|
118
|
+
"vitest": "^3.0.0"
|
|
119
|
+
},
|
|
120
|
+
"engines": {
|
|
121
|
+
"node": ">=20.6.0"
|
|
122
|
+
},
|
|
123
|
+
"keywords": [
|
|
124
|
+
"adonisjs",
|
|
125
|
+
"adonis",
|
|
126
|
+
"telescope",
|
|
127
|
+
"observability",
|
|
128
|
+
"diagnostics",
|
|
129
|
+
"tracing",
|
|
130
|
+
"agora"
|
|
131
|
+
],
|
|
132
|
+
"scripts": {
|
|
133
|
+
"build": "tsc -p tsconfig.json && pnpm run copy:stubs && pnpm run copy:assets",
|
|
134
|
+
"copy:stubs": "mkdir -p dist/stubs/config dist/stubs/database/migrations && cp stubs/config/telescope.stub dist/stubs/config/telescope.stub && cp stubs/config/telescope_watchers.stub dist/stubs/config/telescope_watchers.stub && cp stubs/config/telescope_ui.stub dist/stubs/config/telescope_ui.stub && cp stubs/config/telescope_ai.stub dist/stubs/config/telescope_ai.stub && cp stubs/config/telescope_alerts.stub dist/stubs/config/telescope_alerts.stub && cp stubs/database/migrations/create_telescope_entries_table.stub dist/stubs/database/migrations/create_telescope_entries_table.stub",
|
|
135
|
+
"copy:assets": "mkdir -p dist/src/ui && cp src/ui/dashboard.html dist/src/ui/dashboard.html",
|
|
136
|
+
"test": "vitest run --passWithNoTests",
|
|
137
|
+
"test:watch": "vitest",
|
|
138
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
139
|
+
}
|
|
140
|
+
}
|