@untangle-code/observability 0.0.0-stage → 0.1.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 +661 -0
- package/NOTICE +90 -0
- package/README.md +114 -2
- package/THIRD_PARTY_LICENSES.md +24 -0
- package/dist/correlation.d.ts +36 -0
- package/dist/correlation.d.ts.map +1 -0
- package/dist/correlation.js +12 -0
- package/dist/correlation.js.map +1 -0
- package/dist/errors.d.ts +74 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +100 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +52 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +108 -0
- package/dist/logger.js.map +1 -0
- package/dist/metrics.d.ts +62 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +121 -0
- package/dist/metrics.js.map +1 -0
- package/dist/profiling.d.ts +75 -0
- package/dist/profiling.d.ts.map +1 -0
- package/dist/profiling.js +107 -0
- package/dist/profiling.js.map +1 -0
- package/dist/redact.d.ts +29 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +123 -0
- package/dist/redact.js.map +1 -0
- package/package.json +59 -3
- package/src/correlation.ts +44 -0
- package/src/errors.ts +133 -0
- package/src/index.ts +26 -0
- package/src/logger.ts +192 -0
- package/src/metrics.ts +157 -0
- package/src/profiling.ts +171 -0
- package/src/redact.ts +144 -0
package/NOTICE
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# NOTICE
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2026 Luke Bölling and contributors.
|
|
4
|
+
|
|
5
|
+
This attribution covers original Untangle work. Contributors retain copyright in
|
|
6
|
+
their contributions. Third-party packages, grammars and other materials retain
|
|
7
|
+
their own copyright holders, licenses and notices; this line does not replace them.
|
|
8
|
+
|
|
9
|
+
## License — binding decision
|
|
10
|
+
|
|
11
|
+
Untangle is licensed under the **GNU Affero General Public License, Version 3
|
|
12
|
+
(AGPL-3.0-only)**. See [`LICENSE`](./LICENSE).
|
|
13
|
+
|
|
14
|
+
This decision is **final, not provisional**, and was explicitly instructed by
|
|
15
|
+
the project owner. No contributor, agent or tool may change it without a new
|
|
16
|
+
explicit instruction.
|
|
17
|
+
|
|
18
|
+
The repository-wide license covers Untangle's first-party source code, scripts,
|
|
19
|
+
tests, fixtures, configuration, documentation, website and brand artwork, including
|
|
20
|
+
the logo and 3D yarn illustrations. Every workspace `package.json` declares
|
|
21
|
+
`"license": "AGPL-3.0-only"`. There is no separately licensed enterprise component
|
|
22
|
+
or separate permissive license for documentation or brand assets.
|
|
23
|
+
|
|
24
|
+
Third-party code, embedded grammars, dependency assets and their notices retain
|
|
25
|
+
their original licenses. Their inclusion does not relicense those works. The
|
|
26
|
+
repository license does not grant trademark rights or change the license of a
|
|
27
|
+
repository analyzed with Untangle. See the repository's `docs/LICENSING.md` for
|
|
28
|
+
scope and verification details.
|
|
29
|
+
|
|
30
|
+
This resolves the license question left open in `vision.md` §14 and completes
|
|
31
|
+
`product.md` §16, item 2.
|
|
32
|
+
|
|
33
|
+
## Rationale
|
|
34
|
+
|
|
35
|
+
- **Network copyleft fits the intended product model.** AGPL §13 sets source
|
|
36
|
+
availability requirements for modified versions used through a computer network.
|
|
37
|
+
The current local CLI/stdio-MCP entry and future shared-server modes share the
|
|
38
|
+
same license.
|
|
39
|
+
- **Local-first analysis has a clear boundary.** Running Untangle against a codebase
|
|
40
|
+
does not replace that codebase's own license with Untangle's license.
|
|
41
|
+
- **First-party components share one license.** Implemented components and future
|
|
42
|
+
official plugins use this repository's licensing policy. Planned integrations do
|
|
43
|
+
not establish implemented or published products.
|
|
44
|
+
|
|
45
|
+
## Deliberately accepted consequence
|
|
46
|
+
|
|
47
|
+
The project deliberately chooses AGPL rather than a permissive embedding license.
|
|
48
|
+
Redistribution, modifications and combined works must be assessed against the
|
|
49
|
+
actual terms in `LICENSE`, including applicable Corresponding Source requirements.
|
|
50
|
+
No permissive exception, commercial dual license or special contract-only package
|
|
51
|
+
license is granted or promised by this notice.
|
|
52
|
+
|
|
53
|
+
## Dependencies
|
|
54
|
+
|
|
55
|
+
Third-party runtime dependencies are checked against the allowlist in
|
|
56
|
+
`scripts/check-licenses.mjs`. Their licenses and copyright notices remain unchanged
|
|
57
|
+
and traceable through package `THIRD_PARTY_LICENSES.md` files, grammar provenance,
|
|
58
|
+
the lockfile and release SBOM. The allowlist includes MIT / Apache-2.0 / BSD / ISC
|
|
59
|
+
and other explicitly listed licenses; it is not a license grant for dependencies.
|
|
60
|
+
|
|
61
|
+
The allowlist in `scripts/check-licenses.mjs` applies to **dependencies**, not
|
|
62
|
+
workspace packages. Untangle's own packages carry AGPL-3.0-only and are excluded
|
|
63
|
+
from that check.
|
|
64
|
+
|
|
65
|
+
## Clean room
|
|
66
|
+
|
|
67
|
+
Untangle is an independent implementation with its own data models, APIs, tool
|
|
68
|
+
names, tests and sources. Feature ideas may be derived from publicly observable
|
|
69
|
+
behavior and generally known techniques. Third-party source code is not copied,
|
|
70
|
+
including from AGPL projects even where the license would permit it.
|
|
71
|
+
|
|
72
|
+
## Contribution terms
|
|
73
|
+
|
|
74
|
+
Pull requests are welcome under the repository's existing AGPL-3.0-only license.
|
|
75
|
+
No separate CLA, copyright assignment or DCO sign-off is required. Contributors
|
|
76
|
+
must have the right to submit their work under those terms. See CONTRIBUTING.md.
|
|
77
|
+
|
|
78
|
+
## Release decisions
|
|
79
|
+
|
|
80
|
+
- [x] Copyright attribution: Luke Bölling, with contributors retaining their rights.
|
|
81
|
+
- [x] Contributions use AGPL-3.0-only without an additional CLA or DCO gate.
|
|
82
|
+
|
|
83
|
+
## Open legal items before public beta
|
|
84
|
+
|
|
85
|
+
- [ ] Trademark search for the product name `Untangle`.
|
|
86
|
+
- [ ] Registration and legal review of the npm scope `@untangle-code`.
|
|
87
|
+
- [ ] Verify source availability and notices for each released network daemon/server
|
|
88
|
+
mode (WP-59). The current stdio MCP `untangle_about` already reports the license,
|
|
89
|
+
source repository and build commit when supplied; metadata alone does not prove
|
|
90
|
+
that a concrete deployed version's source is available.
|
package/README.md
CHANGED
|
@@ -1,3 +1,115 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @untangle-code/observability
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An internal private package, not published to npm. It builds error, logging, redaction,
|
|
4
|
+
correlation, metric and profiling components on `@untangle-code/domain`. Its only direct I/O is
|
|
5
|
+
`process.stderr` for logging and `process.memoryUsage()` for profiling; no network or filesystem.
|
|
6
|
+
|
|
7
|
+
Normative sources: [`spec.md`](../../spec.md) §23 (health/observability), §24 (security/privacy),
|
|
8
|
+
§25.1 (error classes), taking precedence in conflicts; [`architecture.md`](../../architecture.md)
|
|
9
|
+
§22 (error architecture) and §24 (observability).
|
|
10
|
+
|
|
11
|
+
Every exported domain type (`UntangleError`, `ErrorCode`, `ERROR_CODES`, `LoggerPort`, `LogEvent`,
|
|
12
|
+
`LogLevel`, `Clock`, `Random`, `ToolResponseEnvelopeV1`, …) is imported from
|
|
13
|
+
`@untangle-code/domain`, never redefined locally.
|
|
14
|
+
|
|
15
|
+
<a id="modulübersicht-alles-re-exportiert-aus-srcindexts"></a>
|
|
16
|
+
|
|
17
|
+
## Modules (all re-exported from `src/index.ts`)
|
|
18
|
+
|
|
19
|
+
| Module | Contents | Normative source |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| `errors.ts` | `ERROR_FACTORIES` (one factory per `ErrorCode`, generated from `ERROR_CODES`) and 28 named convenience exports (`configInvalidError`, `lockHeldError`, …); `toErrorEnvelope(error)` maps **any** thrown value to `ToolResponseEnvelopeV1.error`; domain re-exports `UntangleError`, `ErrorCode`, `ERROR_CODES`, `isUntangleError`, `isErrorCode` | spec §25.1, §21.2; portfolio §15; arch §22.1 |
|
|
22
|
+
| `redact.ts` | Pure `redact(value, options?)`, recursive over objects/arrays; masks known secret keys and secret-like values, suppresses source fields by default (opt in through `includeSourceText`) | spec §24, §23.2 |
|
|
23
|
+
| `correlation.ts` | `createRequestContext({ clock, random })`, IDs exclusively through injected `Clock`/`Random` ports | arch §24.1 |
|
|
24
|
+
| `logger.ts` | `createLogger(options): Logger`, implementing `LoggerPort`: stderr JSON lines, level filtering, `child()` with inherited context, automatic redaction before writing | arch §24.2 |
|
|
25
|
+
| `metrics.ts` | `MetricsRegistry`, exactly the 11 counters from spec §23.3 (8 counters, 1 histogram, 2 ratio gauges); pure-object `snapshot()` | spec §23.3 |
|
|
26
|
+
| `profiling.ts` | `ProfileCollector`: stage timing through injected `Clock`, file counts, cache-hit rates, embedding/Qdrant latency and bytes, parser/language breakdown, memory high-water mark through `process.memoryUsage()` | arch §24.3 |
|
|
27
|
+
|
|
28
|
+
<a id="verwendung-durch-andere-packages"></a>
|
|
29
|
+
|
|
30
|
+
## Use by other packages
|
|
31
|
+
|
|
32
|
+
- **core-engine** throws `UntangleError` using `*Error` factories at adapter boundaries and builds
|
|
33
|
+
`ToolResponseEnvelopeV1.error` through `toErrorEnvelope()`.
|
|
34
|
+
- **cli/mcp-server** create a `RequestContext` (`createRequestContext`) and child logger
|
|
35
|
+
(`logger.child({ requestId, workspaceId, … })`) per tool invocation for the operation's lifetime.
|
|
36
|
+
- **index-pipeline** increments `MetricsRegistry` counters during scanning/chunking and populates
|
|
37
|
+
a `ProfileCollector` with `--profile`.
|
|
38
|
+
|
|
39
|
+
<a id="entscheidungen"></a>
|
|
40
|
+
|
|
41
|
+
## Decisions
|
|
42
|
+
|
|
43
|
+
Choices left open by spec.md/architecture.md; additive extensions are welcome, local redefinitions are not:
|
|
44
|
+
|
|
45
|
+
1. **`toErrorEnvelope()` for non-`UntangleError` values.** spec.md §21.2 defines the error shape,
|
|
46
|
+
not behavior for raw `Error`, string or object throws. Such values receive
|
|
47
|
+
`code: "UNKNOWN_ERROR"` (exported as `UNKNOWN_ERROR_CODE`) and `retryable: false`, never one of
|
|
48
|
+
the 28 known `ErrorCode` values. Spec §25.2 forbids equating absence and infrastructure failure,
|
|
49
|
+
and a raw `Error` cannot be safely assigned to either. Envelope `error.code` is specified as
|
|
50
|
+
`string`, not `ErrorCode`, so this conforms to the spec.
|
|
51
|
+
2. **Generated factory map rather than 28 handwritten classes.** `ERROR_FACTORIES` derives from
|
|
52
|
+
domain's `ERROR_CODES`, so factories cannot diverge from the code list. The 28 named exports
|
|
53
|
+
(`configInvalidError`, …) alias map entries rather than provide another source of truth.
|
|
54
|
+
3. **Correlation IDs beyond `requestId`/`jobId` belong in `context`.** Domain's fixed `LogEvent`
|
|
55
|
+
(architecture.md §24.2) has only these two top-level fields. `generationId`, `workspaceId`,
|
|
56
|
+
`repoId`, `refId` from §24.1 have no dedicated slots and enter `context` under those names through
|
|
57
|
+
`logger.child({...})`; the nearer `child()` wins collisions. This does not break or extend the
|
|
58
|
+
domain-pinned `LogEvent` shape.
|
|
59
|
+
4. **`createRequestContext()` creates only `requestId`.** `jobId`/`generationId` belong to the
|
|
60
|
+
subsystem actually starting a job/generation (job engine/index pipeline), not blind advance
|
|
61
|
+
generation without an existing job. Those subsystems should use the same injected `Random`
|
|
62
|
+
(`random.uuid()`) once built. `workspaceId`/`repoId`/`refId` are content-addressed domain
|
|
63
|
+
identities (`buildWorkspaceId` etc.), not random IDs; callers attach them to request context.
|
|
64
|
+
5. **Three metric kinds, not two.** Spec §23.3 calls all eleven names counters, but
|
|
65
|
+
`search_latency_ms` is a distribution (histogram), and
|
|
66
|
+
`resolved_import_ratio`/`resolved_call_ratio` are snapshot ratios, not monotonic counts. A true
|
|
67
|
+
counter would misrepresent them. The remaining eight are cumulative counters. The name set
|
|
68
|
+
stays exactly the eleven from spec §23.3 and cannot be extended with new names.
|
|
69
|
+
6. **Redaction-key and source-field lists are local choices, not normatively prescribed.**
|
|
70
|
+
Spec §24 lists apiKey, token, password, authorization, cookie as examples and generally requires
|
|
71
|
+
no unsolicited logging of secrets or complete source. `SECRET_KEY_PATTERN` and
|
|
72
|
+
`SOURCE_TEXT_KEYS` (mirroring `CodeChunkPayloadV1`/`CodeChunkDraft`) are additive WP-04 choices.
|
|
73
|
+
Later packages with more secret/source fields should extend these lists rather than implement
|
|
74
|
+
another redactor.
|
|
75
|
+
7. **`Logger` is a superset of domain's `LoggerPort`.** `Logger extends LoggerPort` adds
|
|
76
|
+
`error()/warn()/info()/debug()/trace()` convenience methods that obtain timestamps from injected
|
|
77
|
+
`Clock`. Domain's `log(event: LogEvent)` remains the low-level interface, used internally by
|
|
78
|
+
convenience methods; every `createLogger()` instance stays fully `LoggerPort`-conformant.
|
|
79
|
+
8. **Redaction runs inside the logger, not at call sites.** `createLogger()` automatically applies
|
|
80
|
+
`redact()` to every `context` before writing, so callers need not remember it.
|
|
81
|
+
`debugIncludeSourceText` defaults to `false` and provides spec §24's explicit opt-in exception
|
|
82
|
+
for source fields; secret keys remain masked regardless.
|
|
83
|
+
|
|
84
|
+
<a id="offene-punkte"></a>
|
|
85
|
+
|
|
86
|
+
## Open issues
|
|
87
|
+
|
|
88
|
+
- `docs/BUILD_PLAN.md` had not been created in this working directory when this package was built
|
|
89
|
+
(only spec.md, architecture.md, product.md, vision.md, portfolio.md existed). The package
|
|
90
|
+
therefore follows the requested spec.md §23/§25.1 and architecture.md §22/§24 only. A later
|
|
91
|
+
`docs/BUILD_PLAN.md` contract register should be checked against these decisions, not silently
|
|
92
|
+
overwrite them.
|
|
93
|
+
- Root `tsconfig.json` reference orchestration is outside this package's ownership. The root owner
|
|
94
|
+
must add `{ "path": "packages/observability" }` to `references` for `tsc -b tsconfig.json` to
|
|
95
|
+
include it. Its own scripts (`pnpm --filter @untangle-code/observability run typecheck/test`)
|
|
96
|
+
are independent and pass.
|
|
97
|
+
- No external metric exporter such as Prometheus: optional under spec §23.3 and deliberately
|
|
98
|
+
unbuilt. `snapshot()` returns a pure object callers can export themselves.
|
|
99
|
+
|
|
100
|
+
<a id="lizenz"></a>
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
**AGPL-3.0-only.** This package includes the complete license in [`LICENSE`](./LICENSE), the
|
|
106
|
+
license-choice rationale in [`NOTICE`](./NOTICE), and licenses for all third-party production
|
|
107
|
+
dependencies in [`THIRD_PARTY_LICENSES.md`](./THIRD_PARTY_LICENSES.md). All three ship in the npm
|
|
108
|
+
tarball: AGPL-3.0-only §4 and §5 require recipients to receive the license; a README alone is not
|
|
109
|
+
a copy of the license.
|
|
110
|
+
|
|
111
|
+
Local use alone does not trigger an obligation. Copyleft obligations apply to redistribution and
|
|
112
|
+
providing a network service (AGPL §13).
|
|
113
|
+
|
|
114
|
+
Corresponding TypeScript source ships under `src/` in the same tarball; the complete repository
|
|
115
|
+
is available at <https://github.com/lboel/untangle>.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Third-party licenses — @untangle-code/observability
|
|
2
|
+
|
|
3
|
+
Generated by `pnpm third-party-licenses` from this package's installed
|
|
4
|
+
production dependency tree: transitive `dependencies`, across
|
|
5
|
+
workspace edges, with no `devDependencies` included. The generator reads
|
|
6
|
+
each resolved package's `package.json` in `node_modules`; nothing is maintained by hand
|
|
7
|
+
or estimated.
|
|
8
|
+
|
|
9
|
+
Do not edit manually: `pnpm third-party-licenses --check` fails on drift,
|
|
10
|
+
and `pnpm check-publishable` rejects packages without a current file.
|
|
11
|
+
|
|
12
|
+
This file exists because `docs/BUILD_PLAN.md`, risk R6, makes
|
|
13
|
+
per-package `THIRD_PARTY_LICENSES.md` a release gate for npm publication.
|
|
14
|
+
|
|
15
|
+
Untangle itself is **AGPL-3.0-only** (see `LICENSE` and `NOTICE` in
|
|
16
|
+
this package). The packages below are third-party works; their own
|
|
17
|
+
licenses and copyright notices continue to apply unchanged. Workspace
|
|
18
|
+
packages (`@untangle-code/*`) are not listed here; they belong to the same
|
|
19
|
+
work and use the same AGPL-3.0-only license.
|
|
20
|
+
|
|
21
|
+
## Result: no third-party dependencies
|
|
22
|
+
|
|
23
|
+
This package has no production dependencies outside the workspace.
|
|
24
|
+
The list is empty because none exist, not because they were not checked.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Correlation ids (architecture.md §24.1).
|
|
3
|
+
*
|
|
4
|
+
* Ids are drawn exclusively from the injected `Clock`/`Random` ports so that
|
|
5
|
+
* request contexts are reproducible in tests — never `Date.now()` or
|
|
6
|
+
* `Math.random()` (BUILD_PLAN global determinism rule).
|
|
7
|
+
*
|
|
8
|
+
* `request_id` is the only id created here. `job_id` and `generation_id`
|
|
9
|
+
* are owned by the subsystems that create the underlying job/generation
|
|
10
|
+
* (job-engine, index pipeline) — they mint them the same way, via
|
|
11
|
+
* `Random.uuid()`, once those packages exist; minting them here would just
|
|
12
|
+
* move the decision of *when* a job/generation begins out of its owner.
|
|
13
|
+
* `workspace_id`/`repo_id`/`ref_id` are never random — they are the
|
|
14
|
+
* content-derived identities `@untangle-code/domain` already builds
|
|
15
|
+
* (`buildWorkspaceId` et al.) and are attached to a request context by the
|
|
16
|
+
* caller, not generated by observability.
|
|
17
|
+
*/
|
|
18
|
+
import type { Clock, Random } from "@untangle-code/domain";
|
|
19
|
+
export interface RequestContextDeps {
|
|
20
|
+
clock: Clock;
|
|
21
|
+
random: Random;
|
|
22
|
+
}
|
|
23
|
+
export interface RequestContext {
|
|
24
|
+
/** Random per-operation id (architecture.md §24.1: `request_id`). */
|
|
25
|
+
requestId: string;
|
|
26
|
+
/** Epoch-ms creation time, via `Clock` — never `Date.now()`. */
|
|
27
|
+
createdAtEpochMs: number;
|
|
28
|
+
/** ISO-8601 creation time, via `Clock`. */
|
|
29
|
+
createdAtIso: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a fresh request context. Deterministic given a deterministic
|
|
33
|
+
* `Clock`/`Random` (e.g. in tests): same fakes in, same ids out.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createRequestContext(deps: RequestContextDeps): RequestContext;
|
|
36
|
+
//# sourceMappingURL=correlation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correlation.d.ts","sourceRoot":"","sources":["../src/correlation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC;IACzB,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,cAAc,CAM7E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a fresh request context. Deterministic given a deterministic
|
|
3
|
+
* `Clock`/`Random` (e.g. in tests): same fakes in, same ids out.
|
|
4
|
+
*/
|
|
5
|
+
export function createRequestContext(deps) {
|
|
6
|
+
return {
|
|
7
|
+
requestId: deps.random.uuid(),
|
|
8
|
+
createdAtEpochMs: deps.clock.nowEpochMs(),
|
|
9
|
+
createdAtIso: deps.clock.nowIso(),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=correlation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correlation.js","sourceRoot":"","sources":["../src/correlation.ts"],"names":[],"mappings":"AAiCA;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAwB;IAC3D,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;QAC7B,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;QACzC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;KAClC,CAAC;AACJ,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error helpers on top of `@untangle-code/domain`'s `UntangleError`
|
|
3
|
+
* (architecture.md §22.1, spec.md §25.1, portfolio.md §15).
|
|
4
|
+
*
|
|
5
|
+
* `UntangleError`, `ErrorCode`, `ERROR_CODES` and `isUntangleError` are
|
|
6
|
+
* already fully defined in domain (BUILD_PLAN §3 contract register) — this
|
|
7
|
+
* module does not redefine them, only adds:
|
|
8
|
+
*
|
|
9
|
+
* - one factory function per error class (`ERROR_FACTORIES`, plus a named
|
|
10
|
+
* export per code for ergonomic call sites), and
|
|
11
|
+
* - `toErrorEnvelope()`, which turns *any* thrown value into the `error`
|
|
12
|
+
* field shape of `ToolResponseEnvelopeV1` (spec.md §21.2), including
|
|
13
|
+
* values that are not `UntangleError` at all (adapter throws, programmer
|
|
14
|
+
* errors) so that MCP/CLI response building never has to branch on the
|
|
15
|
+
* error's runtime type itself.
|
|
16
|
+
*/
|
|
17
|
+
import { UntangleError, type ErrorCode, type ToolResponseEnvelopeV1, type UntangleErrorOptions } from "@untangle-code/domain";
|
|
18
|
+
export { ERROR_CODES, CORE_ERROR_CODES, PORTFOLIO_ERROR_CODES, STORAGE_ERROR_CODES, isErrorCode, isUntangleError, UntangleError, } from "@untangle-code/domain";
|
|
19
|
+
export type { ErrorCode, UntangleErrorOptions } from "@untangle-code/domain";
|
|
20
|
+
/** Envelope `error` field shape (spec.md §21.2), derived from domain's envelope type. */
|
|
21
|
+
export type EnvelopeErrorV1 = NonNullable<ToolResponseEnvelopeV1<unknown>["error"]>;
|
|
22
|
+
/** Code used for `toErrorEnvelope()` when the input is not an `UntangleError`. */
|
|
23
|
+
export declare const UNKNOWN_ERROR_CODE = "UNKNOWN_ERROR";
|
|
24
|
+
export type ErrorFactory = (message: string, options?: UntangleErrorOptions) => UntangleError;
|
|
25
|
+
/**
|
|
26
|
+
* One factory per {@link ErrorCode} (spec.md §25.1 ∪ portfolio.md §15).
|
|
27
|
+
*
|
|
28
|
+
* Built from `ERROR_CODES` itself so this map can never drift out of sync
|
|
29
|
+
* with domain's code list — see `errors.test.ts` for the completeness check.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ERROR_FACTORIES: Readonly<Record<ErrorCode, ErrorFactory>>;
|
|
32
|
+
export declare const configInvalidError: ErrorFactory;
|
|
33
|
+
export declare const workspaceNotFoundError: ErrorFactory;
|
|
34
|
+
export declare const pathOutsideWorkspaceError: ErrorFactory;
|
|
35
|
+
export declare const parserUnavailableError: ErrorFactory;
|
|
36
|
+
export declare const embeddingUnavailableError: ErrorFactory;
|
|
37
|
+
export declare const embeddingDimensionMismatchError: ErrorFactory;
|
|
38
|
+
export declare const qdrantUnavailableError: ErrorFactory;
|
|
39
|
+
export declare const qdrantSchemaIncompatibleError: ErrorFactory;
|
|
40
|
+
export declare const lanceDbUnavailableError: ErrorFactory;
|
|
41
|
+
export declare const lanceDbSchemaIncompatibleError: ErrorFactory;
|
|
42
|
+
export declare const indexIncompleteError: ErrorFactory;
|
|
43
|
+
export declare const indexProfileMismatchError: ErrorFactory;
|
|
44
|
+
export declare const lockHeldError: ErrorFactory;
|
|
45
|
+
export declare const jobCancelledError: ErrorFactory;
|
|
46
|
+
export declare const graphIncompleteError: ErrorFactory;
|
|
47
|
+
export declare const analysisIncompleteError: ErrorFactory;
|
|
48
|
+
export declare const pointTooLargeError: ErrorFactory;
|
|
49
|
+
export declare const pluginEngineIncompatibleError: ErrorFactory;
|
|
50
|
+
export declare const portfolioIncompleteError: ErrorFactory;
|
|
51
|
+
export declare const portfolioGenerationMissingError: ErrorFactory;
|
|
52
|
+
export declare const portfolioStaleError: ErrorFactory;
|
|
53
|
+
export declare const manifestParseFailedError: ErrorFactory;
|
|
54
|
+
export declare const technologyUnknownError: ErrorFactory;
|
|
55
|
+
export declare const blueprintKindUnknownError: ErrorFactory;
|
|
56
|
+
export declare const blueprintEvidenceInsufficientError: ErrorFactory;
|
|
57
|
+
export declare const blueprintTargetNotEmptyError: ErrorFactory;
|
|
58
|
+
export declare const blueprintTargetOutsideAllowedError: ErrorFactory;
|
|
59
|
+
export declare const blueprintWriteFailedError: ErrorFactory;
|
|
60
|
+
export declare const enrichmentDisabledError: ErrorFactory;
|
|
61
|
+
export declare const enrichmentUnavailableError: ErrorFactory;
|
|
62
|
+
/**
|
|
63
|
+
* Turns any thrown value into the `error` field of `ToolResponseEnvelopeV1`
|
|
64
|
+
* (spec.md §21.2).
|
|
65
|
+
*
|
|
66
|
+
* - An `UntangleError` round-trips through its own `toEnvelopeError()`.
|
|
67
|
+
* - A plain `Error` (adapter throw, programmer error) is mapped to
|
|
68
|
+
* {@link UNKNOWN_ERROR_CODE} with `retryable: false` — never silently
|
|
69
|
+
* promoted to a known {@link ErrorCode}, since "not found" and
|
|
70
|
+
* "infrastructure failure" must never be conflated (spec.md §25.2).
|
|
71
|
+
* - Any other thrown value is stringified the same way.
|
|
72
|
+
*/
|
|
73
|
+
export declare function toErrorEnvelope(error: unknown): EnvelopeErrorV1;
|
|
74
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAEL,aAAa,EAEb,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7E,yFAAyF;AACzF,MAAM,MAAM,eAAe,GAA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eAAO,MAAM,sBAAsB,cAAqC,CAAC;AACzE,eAAO,MAAM,yBAAyB,cAAyC,CAAC;AAChF,eAAO,MAAM,kCAAkC,cAAkD,CAAC;AAClG,eAAO,MAAM,4BAA4B,cAA6C,CAAC;AACvF,eAAO,MAAM,kCAAkC,cAAmD,CAAC;AACnG,eAAO,MAAM,yBAAyB,cAAyC,CAAC;AAChF,eAAO,MAAM,uBAAuB,cAAsC,CAAC;AAC3E,eAAO,MAAM,0BAA0B,cAAyC,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAiB/D"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error helpers on top of `@untangle-code/domain`'s `UntangleError`
|
|
3
|
+
* (architecture.md §22.1, spec.md §25.1, portfolio.md §15).
|
|
4
|
+
*
|
|
5
|
+
* `UntangleError`, `ErrorCode`, `ERROR_CODES` and `isUntangleError` are
|
|
6
|
+
* already fully defined in domain (BUILD_PLAN §3 contract register) — this
|
|
7
|
+
* module does not redefine them, only adds:
|
|
8
|
+
*
|
|
9
|
+
* - one factory function per error class (`ERROR_FACTORIES`, plus a named
|
|
10
|
+
* export per code for ergonomic call sites), and
|
|
11
|
+
* - `toErrorEnvelope()`, which turns *any* thrown value into the `error`
|
|
12
|
+
* field shape of `ToolResponseEnvelopeV1` (spec.md §21.2), including
|
|
13
|
+
* values that are not `UntangleError` at all (adapter throws, programmer
|
|
14
|
+
* errors) so that MCP/CLI response building never has to branch on the
|
|
15
|
+
* error's runtime type itself.
|
|
16
|
+
*/
|
|
17
|
+
import { ERROR_CODES, UntangleError, isUntangleError, } from "@untangle-code/domain";
|
|
18
|
+
export { ERROR_CODES, CORE_ERROR_CODES, PORTFOLIO_ERROR_CODES, STORAGE_ERROR_CODES, isErrorCode, isUntangleError, UntangleError, } from "@untangle-code/domain";
|
|
19
|
+
/** Code used for `toErrorEnvelope()` when the input is not an `UntangleError`. */
|
|
20
|
+
export const UNKNOWN_ERROR_CODE = "UNKNOWN_ERROR";
|
|
21
|
+
function factory(code) {
|
|
22
|
+
return (message, options) => new UntangleError(code, message, options);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* One factory per {@link ErrorCode} (spec.md §25.1 ∪ portfolio.md §15).
|
|
26
|
+
*
|
|
27
|
+
* Built from `ERROR_CODES` itself so this map can never drift out of sync
|
|
28
|
+
* with domain's code list — see `errors.test.ts` for the completeness check.
|
|
29
|
+
*/
|
|
30
|
+
export const ERROR_FACTORIES = Object.freeze(Object.fromEntries(ERROR_CODES.map((code) => [code, factory(code)])));
|
|
31
|
+
// Named convenience exports — one per error class (spec.md §25.1).
|
|
32
|
+
export const configInvalidError = ERROR_FACTORIES.CONFIG_INVALID;
|
|
33
|
+
export const workspaceNotFoundError = ERROR_FACTORIES.WORKSPACE_NOT_FOUND;
|
|
34
|
+
export const pathOutsideWorkspaceError = ERROR_FACTORIES.PATH_OUTSIDE_WORKSPACE;
|
|
35
|
+
export const parserUnavailableError = ERROR_FACTORIES.PARSER_UNAVAILABLE;
|
|
36
|
+
export const embeddingUnavailableError = ERROR_FACTORIES.EMBEDDING_UNAVAILABLE;
|
|
37
|
+
export const embeddingDimensionMismatchError = ERROR_FACTORIES.EMBEDDING_DIMENSION_MISMATCH;
|
|
38
|
+
export const qdrantUnavailableError = ERROR_FACTORIES.QDRANT_UNAVAILABLE;
|
|
39
|
+
export const qdrantSchemaIncompatibleError = ERROR_FACTORIES.QDRANT_SCHEMA_INCOMPATIBLE;
|
|
40
|
+
export const lanceDbUnavailableError = ERROR_FACTORIES.LANCEDB_UNAVAILABLE;
|
|
41
|
+
export const lanceDbSchemaIncompatibleError = ERROR_FACTORIES.LANCEDB_SCHEMA_INCOMPATIBLE;
|
|
42
|
+
export const indexIncompleteError = ERROR_FACTORIES.INDEX_INCOMPLETE;
|
|
43
|
+
export const indexProfileMismatchError = ERROR_FACTORIES.INDEX_PROFILE_MISMATCH;
|
|
44
|
+
export const lockHeldError = ERROR_FACTORIES.LOCK_HELD;
|
|
45
|
+
export const jobCancelledError = ERROR_FACTORIES.JOB_CANCELLED;
|
|
46
|
+
export const graphIncompleteError = ERROR_FACTORIES.GRAPH_INCOMPLETE;
|
|
47
|
+
export const analysisIncompleteError = ERROR_FACTORIES.ANALYSIS_INCOMPLETE;
|
|
48
|
+
export const pointTooLargeError = ERROR_FACTORIES.POINT_TOO_LARGE;
|
|
49
|
+
export const pluginEngineIncompatibleError = ERROR_FACTORIES.PLUGIN_ENGINE_INCOMPATIBLE;
|
|
50
|
+
// Named convenience exports — one per error class (portfolio.md §15).
|
|
51
|
+
export const portfolioIncompleteError = ERROR_FACTORIES.PORTFOLIO_INCOMPLETE;
|
|
52
|
+
export const portfolioGenerationMissingError = ERROR_FACTORIES.PORTFOLIO_GENERATION_MISSING;
|
|
53
|
+
export const portfolioStaleError = ERROR_FACTORIES.PORTFOLIO_STALE;
|
|
54
|
+
export const manifestParseFailedError = ERROR_FACTORIES.MANIFEST_PARSE_FAILED;
|
|
55
|
+
export const technologyUnknownError = ERROR_FACTORIES.TECHNOLOGY_UNKNOWN;
|
|
56
|
+
export const blueprintKindUnknownError = ERROR_FACTORIES.BLUEPRINT_KIND_UNKNOWN;
|
|
57
|
+
export const blueprintEvidenceInsufficientError = ERROR_FACTORIES.BLUEPRINT_EVIDENCE_INSUFFICIENT;
|
|
58
|
+
export const blueprintTargetNotEmptyError = ERROR_FACTORIES.BLUEPRINT_TARGET_NOT_EMPTY;
|
|
59
|
+
export const blueprintTargetOutsideAllowedError = ERROR_FACTORIES.BLUEPRINT_TARGET_OUTSIDE_ALLOWED;
|
|
60
|
+
export const blueprintWriteFailedError = ERROR_FACTORIES.BLUEPRINT_WRITE_FAILED;
|
|
61
|
+
export const enrichmentDisabledError = ERROR_FACTORIES.ENRICHMENT_DISABLED;
|
|
62
|
+
export const enrichmentUnavailableError = ERROR_FACTORIES.ENRICHMENT_UNAVAILABLE;
|
|
63
|
+
/**
|
|
64
|
+
* Turns any thrown value into the `error` field of `ToolResponseEnvelopeV1`
|
|
65
|
+
* (spec.md §21.2).
|
|
66
|
+
*
|
|
67
|
+
* - An `UntangleError` round-trips through its own `toEnvelopeError()`.
|
|
68
|
+
* - A plain `Error` (adapter throw, programmer error) is mapped to
|
|
69
|
+
* {@link UNKNOWN_ERROR_CODE} with `retryable: false` — never silently
|
|
70
|
+
* promoted to a known {@link ErrorCode}, since "not found" and
|
|
71
|
+
* "infrastructure failure" must never be conflated (spec.md §25.2).
|
|
72
|
+
* - Any other thrown value is stringified the same way.
|
|
73
|
+
*/
|
|
74
|
+
export function toErrorEnvelope(error) {
|
|
75
|
+
if (isUntangleError(error)) {
|
|
76
|
+
return error.toEnvelopeError();
|
|
77
|
+
}
|
|
78
|
+
if (error instanceof Error) {
|
|
79
|
+
return {
|
|
80
|
+
code: UNKNOWN_ERROR_CODE,
|
|
81
|
+
message: error.message,
|
|
82
|
+
retryable: false,
|
|
83
|
+
details: { name: error.name },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
code: UNKNOWN_ERROR_CODE,
|
|
88
|
+
message: typeof error === "string" ? error : safeStringify(error),
|
|
89
|
+
retryable: false,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function safeStringify(value) {
|
|
93
|
+
try {
|
|
94
|
+
return JSON.stringify(value) ?? String(value);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return String(value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,WAAW,EACX,aAAa,EACb,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,WAAW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AC;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,eAAe,CAAC,sBAAsB,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO;YACL,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;SAC9B,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;QACjE,SAAS,EAAE,KAAK;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @untangle-code/observability — the only public export of this package.
|
|
3
|
+
*
|
|
4
|
+
* Errors (architecture.md §22.1), structured logging (§24.2), redaction
|
|
5
|
+
* (spec.md §24), correlation ids (§24.1), metrics (spec.md §23.3) and
|
|
6
|
+
* `--profile` collection (architecture.md §24.3). No I/O beyond
|
|
7
|
+
* `process.stderr`/`process.memoryUsage`; no network, no filesystem.
|
|
8
|
+
*/
|
|
9
|
+
export * from "./errors.js";
|
|
10
|
+
export * from "./redact.js";
|
|
11
|
+
export * from "./correlation.js";
|
|
12
|
+
export * from "./logger.js";
|
|
13
|
+
export * from "./metrics.js";
|
|
14
|
+
export * from "./profiling.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,cAAc,aAAa,CAAC;AAG5B,cAAc,aAAa,CAAC;AAG5B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,aAAa,CAAC;AAG5B,cAAc,cAAc,CAAC;AAG7B,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @untangle-code/observability — the only public export of this package.
|
|
3
|
+
*
|
|
4
|
+
* Errors (architecture.md §22.1), structured logging (§24.2), redaction
|
|
5
|
+
* (spec.md §24), correlation ids (§24.1), metrics (spec.md §23.3) and
|
|
6
|
+
* `--profile` collection (architecture.md §24.3). No I/O beyond
|
|
7
|
+
* `process.stderr`/`process.memoryUsage`; no network, no filesystem.
|
|
8
|
+
*/
|
|
9
|
+
// Errors — factories on top of domain's UntangleError, plus envelope mapping.
|
|
10
|
+
export * from "./errors.js";
|
|
11
|
+
// Redaction.
|
|
12
|
+
export * from "./redact.js";
|
|
13
|
+
// Correlation ids.
|
|
14
|
+
export * from "./correlation.js";
|
|
15
|
+
// Structured logger (LoggerPort implementation).
|
|
16
|
+
export * from "./logger.js";
|
|
17
|
+
// Metrics registry (spec.md §23.3).
|
|
18
|
+
export * from "./metrics.js";
|
|
19
|
+
// Profiling collector (architecture.md §24.3).
|
|
20
|
+
export * from "./profiling.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,8EAA8E;AAC9E,cAAc,aAAa,CAAC;AAE5B,aAAa;AACb,cAAc,aAAa,CAAC;AAE5B,mBAAmB;AACnB,cAAc,kBAAkB,CAAC;AAEjC,iDAAiD;AACjD,cAAc,aAAa,CAAC;AAE5B,oCAAoC;AACpC,cAAc,cAAc,CAAC;AAE7B,+CAA+C;AAC/C,cAAc,gBAAgB,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logger (architecture.md §24.2) implementing domain's
|
|
3
|
+
* `LoggerPort`: JSON lines on stderr, level filtering, and a child logger
|
|
4
|
+
* with bound context.
|
|
5
|
+
*
|
|
6
|
+
* `LogEvent` (architecture.md §24.2, fixed in domain) only carries
|
|
7
|
+
* `requestId`/`jobId` as first-class correlation fields; `generationId`,
|
|
8
|
+
* `workspaceId`, `repoId` and `refId` (architecture.md §24.1's full
|
|
9
|
+
* correlation set) have no first-class slot in that shape. This module's
|
|
10
|
+
* decision (README "Entscheidungen"): those four travel inside `context`
|
|
11
|
+
* under their own keys, merged in the same way `context` itself is —
|
|
12
|
+
* closest (call-site) binding wins over an ancestor `child()`'s binding.
|
|
13
|
+
*/
|
|
14
|
+
import type { Clock, LoggerPort, LogLevel } from "@untangle-code/domain";
|
|
15
|
+
/** Bindings a child logger merges into every event it emits. */
|
|
16
|
+
export interface LoggerBindings {
|
|
17
|
+
component?: string;
|
|
18
|
+
requestId?: string;
|
|
19
|
+
jobId?: string;
|
|
20
|
+
generationId?: string;
|
|
21
|
+
workspaceId?: string;
|
|
22
|
+
repoId?: string;
|
|
23
|
+
refId?: string;
|
|
24
|
+
context?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/** `LoggerPort` plus per-level convenience methods that fill in `timestamp` via `Clock`. */
|
|
27
|
+
export interface Logger extends LoggerPort {
|
|
28
|
+
error(event: string, context?: Record<string, unknown>): void;
|
|
29
|
+
warn(event: string, context?: Record<string, unknown>): void;
|
|
30
|
+
info(event: string, context?: Record<string, unknown>): void;
|
|
31
|
+
debug(event: string, context?: Record<string, unknown>): void;
|
|
32
|
+
trace(event: string, context?: Record<string, unknown>): void;
|
|
33
|
+
child(bindings: LoggerBindings): Logger;
|
|
34
|
+
}
|
|
35
|
+
export interface CreateLoggerOptions {
|
|
36
|
+
/** Time source for auto-timestamped convenience methods (`info()`, …). Never `Date.now()`. */
|
|
37
|
+
clock: Clock;
|
|
38
|
+
/** Minimum level emitted; events below it are dropped without touching `sink`. Default `"info"`. */
|
|
39
|
+
level?: LogLevel;
|
|
40
|
+
/** Where a finished JSON line is written. Default: one `process.stderr.write` call per event. */
|
|
41
|
+
sink?: (line: string) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Opt-in escape hatch (spec.md §24): when `false` (default), source-text
|
|
44
|
+
* fields in `context` are suppressed rather than logged verbatim.
|
|
45
|
+
*/
|
|
46
|
+
debugIncludeSourceText?: boolean;
|
|
47
|
+
/** Initial bound context, equivalent to calling `.child(bindings)` once up front. */
|
|
48
|
+
bindings?: LoggerBindings;
|
|
49
|
+
}
|
|
50
|
+
/** Creates a structured, JSON-lines-on-stderr {@link Logger} (architecture.md §24.2). */
|
|
51
|
+
export declare function createLogger(options: CreateLoggerOptions): Logger;
|
|
52
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,KAAK,EAAY,UAAU,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAYnF,gEAAgE;AAChE,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,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