@pinta-ai/mcp-logger 0.4.1 → 0.4.2-dev.1010
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/dist/cli/index.js +1 -1
- package/node_modules/@pinta-ai/core/README.md +180 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.d.ts +9 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.js +20 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.d.ts +20 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.js +156 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/env-file.d.ts +17 -0
- package/node_modules/@pinta-ai/core/dist/env-file.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/env-file.js +81 -0
- package/node_modules/@pinta-ai/core/dist/env-file.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.d.ts +26 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.js +202 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/guard.d.ts +196 -0
- package/node_modules/@pinta-ai/core/dist/guard.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/guard.js +275 -0
- package/node_modules/@pinta-ai/core/dist/guard.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/index.d.ts +23 -0
- package/node_modules/@pinta-ai/core/dist/index.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/index.js +85 -0
- package/node_modules/@pinta-ai/core/dist/index.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/json-text.d.ts +45 -0
- package/node_modules/@pinta-ai/core/dist/json-text.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/json-text.js +116 -0
- package/node_modules/@pinta-ai/core/dist/json-text.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.d.ts +143 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.js +20 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/matches.d.ts +24 -0
- package/node_modules/@pinta-ai/core/dist/matches.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/matches.js +39 -0
- package/node_modules/@pinta-ai/core/dist/matches.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.d.ts +15 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.js +375 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.d.ts +41 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.js +7 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp.d.ts +142 -0
- package/node_modules/@pinta-ai/core/dist/otlp.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp.js +638 -0
- package/node_modules/@pinta-ai/core/dist/otlp.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.d.ts +69 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.js +105 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/redact.d.ts +65 -0
- package/node_modules/@pinta-ai/core/dist/redact.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/redact.js +193 -0
- package/node_modules/@pinta-ai/core/dist/redact.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.d.ts +47 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.js +177 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.d.ts +47 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.js +377 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.d.ts +50 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.js +103 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.d.ts +117 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.js +592 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/trace.d.ts +17 -0
- package/node_modules/@pinta-ai/core/dist/trace.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/trace.js +78 -0
- package/node_modules/@pinta-ai/core/dist/trace.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/transport.d.ts +75 -0
- package/node_modules/@pinta-ai/core/dist/transport.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/transport.js +260 -0
- package/node_modules/@pinta-ai/core/dist/transport.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.d.ts +46 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.js +279 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.d.ts +22 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.js +243 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.js.map +1 -0
- package/node_modules/@pinta-ai/core/package.json +50 -0
- package/package.json +3 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { OtlpPayload } from "./otlp-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* What an adaptor sends to `/guard/evaluate`: the very OTLP payload it is
|
|
4
|
+
* about to relay for the same event, before any `pinta.guard.*` attribute is
|
|
5
|
+
* on it. One span, built by `buildPayload`.
|
|
6
|
+
*
|
|
7
|
+
* Until 0.8.0 this was a hand-assembled five-field `GuardInput` — a second
|
|
8
|
+
* reading of the hook payload beside the one the span carried, and the two
|
|
9
|
+
* were free to disagree. The manager now projects the span through the same
|
|
10
|
+
* AgentEvent assembly its relay and the backend use, so the verdict a hook
|
|
11
|
+
* gets is the verdict the stored event would get.
|
|
12
|
+
*
|
|
13
|
+
* Since PTA-735 there are two versions of that span with the same ids and
|
|
14
|
+
* time. The one `buildPayload` returns is relayed and stored: the original
|
|
15
|
+
* text with only the ranges of secret values replaced. The one the guard
|
|
16
|
+
* judges is attached to it (`guardVersionOf`) and is the text `pinta-core` has
|
|
17
|
+
* always built, so the sidecar's verdicts do not move. `evaluateGuard` sends
|
|
18
|
+
* the attached version, or the payload itself when none is attached.
|
|
19
|
+
*/
|
|
20
|
+
export type GuardPayload = OtlpPayload;
|
|
21
|
+
export declare const GUARD_HOLD_PROTOCOL = "hold-v1";
|
|
22
|
+
export declare const GUARD_MODE_HEADER = "x-pinta-guard-mode";
|
|
23
|
+
export declare const GUARD_REQUIRED_RULES_HEADER = "x-pinta-required-rules";
|
|
24
|
+
export declare const GUARD_HOLD_REASONS: readonly ["configuration_invalid", "endpoint_unavailable", "inspection_disabled", "policy_not_loaded", "policy_stale", "required_rule_missing", "rule_error", "target_unresolved", "unsupported_input", "unsupported_manager", "timeout", "refused", "error"];
|
|
25
|
+
export type GuardHoldReason = typeof GUARD_HOLD_REASONS[number];
|
|
26
|
+
export interface GuardAssessment {
|
|
27
|
+
protocol: typeof GUARD_HOLD_PROTOCOL;
|
|
28
|
+
status: "assessed" | "unavailable";
|
|
29
|
+
reason?: GuardHoldReason;
|
|
30
|
+
}
|
|
31
|
+
export interface GuardResult {
|
|
32
|
+
decision: "ALLOW" | "DENY" | "REVIEW";
|
|
33
|
+
reason: string | null;
|
|
34
|
+
userMessage: string | null;
|
|
35
|
+
/**
|
|
36
|
+
* The manager's self-reported handler time when it sends one, else our own
|
|
37
|
+
* wall-clock. Kept for backwards compatibility — prefer `clientRttMs` when you
|
|
38
|
+
* mean "how long did the caller actually block".
|
|
39
|
+
*/
|
|
40
|
+
durationMs: number;
|
|
41
|
+
/**
|
|
42
|
+
* Wall-clock RTT (ms) this client observed for the guard call: measured from
|
|
43
|
+
* just before the request until the decision is in hand. Never overwritten by
|
|
44
|
+
* the manager's self-reported value, so `clientRttMs - durationMs` is the
|
|
45
|
+
* transport/IPC overhead the manager cannot see from inside its own handler.
|
|
46
|
+
* Emitted on the span as `pinta.client.rtt_ms` (see otlp.ts `clientAttrs`).
|
|
47
|
+
*
|
|
48
|
+
* `evaluateGuard` always sets this. It is optional only so that hand-built
|
|
49
|
+
* results (test fakes, older callers) stay assignable; when absent,
|
|
50
|
+
* `buildPayload` simply emits no `pinta.client.*` attributes.
|
|
51
|
+
*/
|
|
52
|
+
clientRttMs?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Why an ALLOW lacks a complete assessment rather than being a clean pass.
|
|
55
|
+
* Also accepted from a 200 Manager response, only when decision=ALLOW.
|
|
56
|
+
*
|
|
57
|
+
* - `timeout`: the manager did not answer inside `timeoutMs`, or explicitly
|
|
58
|
+
* allowed after an inspection/lookup deadline.
|
|
59
|
+
* - `refused`: the manager answered `410` — it no longer accepts what this
|
|
60
|
+
* client sends. Since 0.8.0 that is the legacy `{input: GuardInput}` body;
|
|
61
|
+
* a client on this version cannot produce it, so seeing `refused` from a
|
|
62
|
+
* 0.8.0+ build means a forked or hand-assembled request.
|
|
63
|
+
* - `error`: any other non-200, a malformed 200, a transport failure, or an
|
|
64
|
+
* explicit Manager ALLOW with unavailable/incomplete assessment.
|
|
65
|
+
*/
|
|
66
|
+
failOpenReason?: "timeout" | "refused" | "error";
|
|
67
|
+
/** Inspection availability, separate from a policy match or host execution receipt. */
|
|
68
|
+
assessment?: GuardAssessment;
|
|
69
|
+
holdReason?: GuardHoldReason;
|
|
70
|
+
/**
|
|
71
|
+
* The manager's id for this evaluation, when it sent one (manager 0.1.16+).
|
|
72
|
+
* Surfaced to the user in denial messages so a false positive can be
|
|
73
|
+
* reported by reference. Absent — not null — when the manager did not send a
|
|
74
|
+
* non-empty string.
|
|
75
|
+
*/
|
|
76
|
+
evaluationId?: string;
|
|
77
|
+
/**
|
|
78
|
+
* How a tool-output DENY should be delivered (PTA-695). The manager sets it
|
|
79
|
+
* only when `decision === "DENY"` for a tool-output inspection and a policy
|
|
80
|
+
* rule fired:
|
|
81
|
+
*
|
|
82
|
+
* - `mask`: every signal the rule read carried the matched value, so the
|
|
83
|
+
* output can be delivered with just those values replaced (`redactions`).
|
|
84
|
+
* - `withhold`: at least one signal had no value to mask (prompt injection,
|
|
85
|
+
* package deny, ...), so the output is withheld entirely.
|
|
86
|
+
*
|
|
87
|
+
* Absent on an older manager, on ALLOW/REVIEW, and on an input DENY. Absent
|
|
88
|
+
* also when the manager sent anything other than these two strings — the
|
|
89
|
+
* field is advice about delivery, never part of the decision, so a bad value
|
|
90
|
+
* is dropped rather than failing open. Use `buildOutputDenial` to apply it;
|
|
91
|
+
* without this field it withholds.
|
|
92
|
+
*/
|
|
93
|
+
outputAction?: "mask" | "withhold";
|
|
94
|
+
/**
|
|
95
|
+
* The detected values to replace when `outputAction === "mask"`, each with
|
|
96
|
+
* the detector category that becomes the `[REDACTED:<category>]` marker.
|
|
97
|
+
* Only entries whose `match` is a non-empty string survive parsing; absent
|
|
98
|
+
* when none does.
|
|
99
|
+
*
|
|
100
|
+
* These are the secrets themselves. They travel only in this synchronous
|
|
101
|
+
* loopback response and must never be copied onto a span (`attachGuard`
|
|
102
|
+
* ignores them), into a log line, or into an audit event.
|
|
103
|
+
*/
|
|
104
|
+
redactions?: Array<{
|
|
105
|
+
category: string;
|
|
106
|
+
match: string;
|
|
107
|
+
}>;
|
|
108
|
+
}
|
|
109
|
+
export interface GuardOptions {
|
|
110
|
+
/** Trusted installation setting. Default open preserves existing adaptor behavior. */
|
|
111
|
+
failureMode?: "open" | "hold";
|
|
112
|
+
/** Required enabled DENY rules. Removing one must not silently downgrade this installation. */
|
|
113
|
+
requiredRules?: readonly string[];
|
|
114
|
+
/**
|
|
115
|
+
* Hard timeout. Adapters disagree by two orders of magnitude — pinta-cc
|
|
116
|
+
* waits 10_000ms, the snappy ones (codex/copilot/gemini/opencode) 100ms —
|
|
117
|
+
* so each passes its own. Defaults to 10_000.
|
|
118
|
+
*
|
|
119
|
+
* Also declared to the manager as `x-pinta-guard-budget-ms`, so it bounds
|
|
120
|
+
* its own work by this number instead of guessing it (see
|
|
121
|
+
* `GUARD_BUDGET_HEADER`). Changing it here is the only change needed.
|
|
122
|
+
*/
|
|
123
|
+
timeoutMs?: number;
|
|
124
|
+
/** Sent as the x-pinta-relay-token header. */
|
|
125
|
+
token?: string;
|
|
126
|
+
/** Force-disable even when an endpoint is configured. */
|
|
127
|
+
disabled?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Value of the `user-agent` header so the manager's guard route can
|
|
130
|
+
* attribute calls to a specific adapter (it parses the `pinta-<name>` and
|
|
131
|
+
* version out of the UA). Each adapter passes its own `pinta-<name>/<version>`.
|
|
132
|
+
*/
|
|
133
|
+
userAgent?: string;
|
|
134
|
+
/**
|
|
135
|
+
* The agent this run belongs to, sent as `x-pinta-agent-type`.
|
|
136
|
+
*
|
|
137
|
+
* Separate from `userAgent` because the two answer different questions. The
|
|
138
|
+
* UA names the adapter — the wrapper — and one adapter can serve more than
|
|
139
|
+
* one agent: `pinta-gemini` is both Gemini CLI and Antigravity, and the
|
|
140
|
+
* manager cannot tell them apart from the id alone. This names the agent
|
|
141
|
+
* actually running, which the adapter is the only party to know.
|
|
142
|
+
*
|
|
143
|
+
* Omitted when unset, so an adapter that does not pass it leaves the manager
|
|
144
|
+
* exactly where it was rather than sending an empty claim.
|
|
145
|
+
*/
|
|
146
|
+
agentType?: string;
|
|
147
|
+
/**
|
|
148
|
+
* How long to wait when the body is long (PTA-735). The manager's verdict on
|
|
149
|
+
* a long body takes longer than on a short one, and an adapter that waits
|
|
150
|
+
* only its short budget (100ms) stops waiting before the deny can arrive, so
|
|
151
|
+
* the command runs. A body of `LONG_INPUT_BYTES` UTF-8 bytes or more waits
|
|
152
|
+
* `max(timeoutMs, min(longInputTimeoutMs ?? 3000, 10000))`: the wait only
|
|
153
|
+
* grows, and the 10,000 ms ceiling applies to the added value, never to an
|
|
154
|
+
* adapter's own `timeoutMs`. `0` turns this off, for the call that answers a
|
|
155
|
+
* tool's output and so is not a pre-execution gate. `Infinity` asks for the
|
|
156
|
+
* ceiling (10,000 ms); a negative number or `NaN` is ignored (3,000 ms).
|
|
157
|
+
*
|
|
158
|
+
* The header `x-pinta-guard-budget-ms` carries the wait this call really
|
|
159
|
+
* uses, so the manager's own deadline (80% of it) grows with it.
|
|
160
|
+
*/
|
|
161
|
+
longInputTimeoutMs?: number;
|
|
162
|
+
}
|
|
163
|
+
/** A body this long (UTF-8 bytes of the serialized payload) waits `longInputTimeoutMs`. */
|
|
164
|
+
export declare const LONG_INPUT_BYTES = 16384;
|
|
165
|
+
/** `longInputTimeoutMs` when the adapter passes none. */
|
|
166
|
+
export declare const DEFAULT_LONG_INPUT_TIMEOUT_MS = 3000;
|
|
167
|
+
/** Ceiling for the added wait. An adapter's own `timeoutMs` may be larger. */
|
|
168
|
+
export declare const MAX_LONG_INPUT_TIMEOUT_MS = 10000;
|
|
169
|
+
/**
|
|
170
|
+
* The wait for a body of `bodyBytes`. Pure, so the boundary is testable
|
|
171
|
+
* without a server: below `LONG_INPUT_BYTES`, with `longInputTimeoutMs: 0`, or
|
|
172
|
+
* with a base that is not a positive number, nothing changes.
|
|
173
|
+
*/
|
|
174
|
+
export declare function guardWaitMs(bodyBytes: number, opts?: GuardOptions): number;
|
|
175
|
+
/**
|
|
176
|
+
* Header that tells the manager how long this call will wait before it
|
|
177
|
+
* fail-opens on its own, in ms.
|
|
178
|
+
*
|
|
179
|
+
* The manager spends up to 80% of it and then answers without the parts still
|
|
180
|
+
* in flight — the backend package check in particular — because an answer
|
|
181
|
+
* after the caller's timeout is thrown away. Absent the header it falls back
|
|
182
|
+
* to a table of adaptor timeouts copied into its own repo, which goes stale
|
|
183
|
+
* the moment an adaptor changes its number (PTA-579). Manager 0.1.10+ reads
|
|
184
|
+
* it; older managers ignore it.
|
|
185
|
+
*/
|
|
186
|
+
export declare const GUARD_BUDGET_HEADER = "x-pinta-guard-budget-ms";
|
|
187
|
+
/**
|
|
188
|
+
* HTTP status the manager answers when it recognises the body as a shape it
|
|
189
|
+
* has stopped accepting. Distinct from other non-200s on purpose: an adaptor
|
|
190
|
+
* that sees it is not facing a manager outage, it is out of date (or has been
|
|
191
|
+
* modified), and the span records that as `refused` rather than `error`.
|
|
192
|
+
*/
|
|
193
|
+
export declare const GUARD_STATUS_REFUSED = 410;
|
|
194
|
+
export declare function holdGuard(reason: GuardHoldReason, elapsedMs?: number): GuardResult;
|
|
195
|
+
export declare function evaluateGuard(payload: GuardPayload, endpoint: string | undefined, opts?: GuardOptions): Promise<GuardResult | null>;
|
|
196
|
+
//# sourceMappingURL=guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE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ports.MAX_LONG_INPUT_TIMEOUT_MS = exports.DEFAULT_LONG_INPUT_TIMEOUT_MS = exports.LONG_INPUT_BYTES = exports.GUARD_HOLD_REASONS = exports.GUARD_REQUIRED_RULES_HEADER = exports.GUARD_MODE_HEADER = exports.GUARD_HOLD_PROTOCOL = void 0;
|
|
4
|
+
exports.guardWaitMs = guardWaitMs;
|
|
5
|
+
exports.holdGuard = holdGuard;
|
|
6
|
+
exports.evaluateGuard = evaluateGuard;
|
|
7
|
+
const otlp_js_1 = require("./otlp.js");
|
|
8
|
+
exports.GUARD_HOLD_PROTOCOL = "hold-v1";
|
|
9
|
+
exports.GUARD_MODE_HEADER = "x-pinta-guard-mode";
|
|
10
|
+
exports.GUARD_REQUIRED_RULES_HEADER = "x-pinta-required-rules";
|
|
11
|
+
exports.GUARD_HOLD_REASONS = [
|
|
12
|
+
"configuration_invalid", "endpoint_unavailable", "inspection_disabled",
|
|
13
|
+
"policy_not_loaded", "policy_stale", "required_rule_missing", "rule_error",
|
|
14
|
+
"target_unresolved", "unsupported_input", "unsupported_manager", "timeout", "refused", "error",
|
|
15
|
+
];
|
|
16
|
+
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
17
|
+
/** A body this long (UTF-8 bytes of the serialized payload) waits `longInputTimeoutMs`. */
|
|
18
|
+
exports.LONG_INPUT_BYTES = 16_384;
|
|
19
|
+
/** `longInputTimeoutMs` when the adapter passes none. */
|
|
20
|
+
exports.DEFAULT_LONG_INPUT_TIMEOUT_MS = 3_000;
|
|
21
|
+
/** Ceiling for the added wait. An adapter's own `timeoutMs` may be larger. */
|
|
22
|
+
exports.MAX_LONG_INPUT_TIMEOUT_MS = 10_000;
|
|
23
|
+
/**
|
|
24
|
+
* The wait for a body of `bodyBytes`. Pure, so the boundary is testable
|
|
25
|
+
* without a server: below `LONG_INPUT_BYTES`, with `longInputTimeoutMs: 0`, or
|
|
26
|
+
* with a base that is not a positive number, nothing changes.
|
|
27
|
+
*/
|
|
28
|
+
function guardWaitMs(bodyBytes, opts = {}) {
|
|
29
|
+
const base = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
30
|
+
if (opts.longInputTimeoutMs === 0 || bodyBytes < exports.LONG_INPUT_BYTES)
|
|
31
|
+
return base;
|
|
32
|
+
const asked = opts.longInputTimeoutMs;
|
|
33
|
+
const longMs = typeof asked === "number" && asked > 0 ? asked : exports.DEFAULT_LONG_INPUT_TIMEOUT_MS;
|
|
34
|
+
const added = Math.min(longMs, exports.MAX_LONG_INPUT_TIMEOUT_MS);
|
|
35
|
+
// A base that is NaN or negative keeps its old meaning (no budget header, an
|
|
36
|
+
// immediate abort); do not turn a broken value into a working one here.
|
|
37
|
+
return Number.isFinite(base) && base > 0 ? Math.max(base, added) : base;
|
|
38
|
+
}
|
|
39
|
+
const DEFAULT_UA = "pinta-core";
|
|
40
|
+
/**
|
|
41
|
+
* Header that tells the manager how long this call will wait before it
|
|
42
|
+
* fail-opens on its own, in ms.
|
|
43
|
+
*
|
|
44
|
+
* The manager spends up to 80% of it and then answers without the parts still
|
|
45
|
+
* in flight — the backend package check in particular — because an answer
|
|
46
|
+
* after the caller's timeout is thrown away. Absent the header it falls back
|
|
47
|
+
* to a table of adaptor timeouts copied into its own repo, which goes stale
|
|
48
|
+
* the moment an adaptor changes its number (PTA-579). Manager 0.1.10+ reads
|
|
49
|
+
* it; older managers ignore it.
|
|
50
|
+
*/
|
|
51
|
+
exports.GUARD_BUDGET_HEADER = "x-pinta-guard-budget-ms";
|
|
52
|
+
/**
|
|
53
|
+
* Fail-open result. No manager handler time exists on these paths (it never
|
|
54
|
+
* answered, or answered non-200), so the caller's wall-clock is all we have and
|
|
55
|
+
* `durationMs` necessarily equals `clientRttMs`. Consumers deriving transport
|
|
56
|
+
* overhead as `clientRttMs - durationMs` must therefore skip results carrying a
|
|
57
|
+
* `failOpenReason` — it would read as 0 here.
|
|
58
|
+
*/
|
|
59
|
+
function failOpen(clientRttMs, failOpenReason) {
|
|
60
|
+
return {
|
|
61
|
+
decision: "ALLOW",
|
|
62
|
+
reason: null,
|
|
63
|
+
userMessage: null,
|
|
64
|
+
durationMs: clientRttMs,
|
|
65
|
+
clientRttMs,
|
|
66
|
+
failOpenReason,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Valid guard decisions. A 200 body must carry one of these, else we fail open. */
|
|
70
|
+
const VALID_DECISIONS = new Set(["ALLOW", "DENY", "REVIEW"]);
|
|
71
|
+
function isFailOpenReason(value) {
|
|
72
|
+
return value === "timeout" || value === "refused" || value === "error";
|
|
73
|
+
}
|
|
74
|
+
function isOutputAction(value) {
|
|
75
|
+
return value === "mask" || value === "withhold";
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Keep only the redaction entries an adaptor can act on: an object whose
|
|
79
|
+
* `category` is a string and whose `match` is a non-empty string. Anything
|
|
80
|
+
* else — a non-array, a bare string, an entry with an empty match — is dropped
|
|
81
|
+
* silently. Returns undefined (field absent) when nothing survives, so a
|
|
82
|
+
* consumer checking `redactions?.length` treats "all malformed" like "none".
|
|
83
|
+
*/
|
|
84
|
+
function parseRedactions(value) {
|
|
85
|
+
if (!Array.isArray(value))
|
|
86
|
+
return undefined;
|
|
87
|
+
const out = [];
|
|
88
|
+
for (const entry of value) {
|
|
89
|
+
if (typeof entry !== "object" || entry === null)
|
|
90
|
+
continue;
|
|
91
|
+
const { category, match } = entry;
|
|
92
|
+
if (typeof category !== "string" || typeof match !== "string" || match.length === 0)
|
|
93
|
+
continue;
|
|
94
|
+
out.push({ category, match });
|
|
95
|
+
}
|
|
96
|
+
return out.length > 0 ? out : undefined;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* HTTP status the manager answers when it recognises the body as a shape it
|
|
100
|
+
* has stopped accepting. Distinct from other non-200s on purpose: an adaptor
|
|
101
|
+
* that sees it is not facing a manager outage, it is out of date (or has been
|
|
102
|
+
* modified), and the span records that as `refused` rather than `error`.
|
|
103
|
+
*/
|
|
104
|
+
exports.GUARD_STATUS_REFUSED = 410;
|
|
105
|
+
/**
|
|
106
|
+
* Query the external guard policy server with the span about to be relayed.
|
|
107
|
+
* Fail-open on every error path (no endpoint / disabled / non-200 / timeout /
|
|
108
|
+
* throw → ALLOW). Returns null when guarding is not active (no endpoint or
|
|
109
|
+
* explicitly disabled).
|
|
110
|
+
*
|
|
111
|
+
* `payload` is `buildPayload`'s object: the body sent is its guard version
|
|
112
|
+
* (see `GuardPayload`), with no envelope. Build it first, ask, then
|
|
113
|
+
* `attachGuard` the answer onto the same object before relaying it; both
|
|
114
|
+
* versions carry the same trace id, span id and time, so the manager judges
|
|
115
|
+
* and stores one span.
|
|
116
|
+
*
|
|
117
|
+
* Options are passed explicitly rather than read from process.env so this works
|
|
118
|
+
* for both the short-lived hook adapters (which resolve env up front) and the
|
|
119
|
+
* long-lived opencode plugin (whose config is resolved at init).
|
|
120
|
+
*/
|
|
121
|
+
async function evaluateOpenGuard(payload, endpoint, opts = {}) {
|
|
122
|
+
if (!endpoint)
|
|
123
|
+
return null;
|
|
124
|
+
if (opts.disabled)
|
|
125
|
+
return null;
|
|
126
|
+
const start = Date.now();
|
|
127
|
+
// Abort the fetch on timeout so the losing request is torn down (socket
|
|
128
|
+
// closed) and no timer leaks — mirrors postOtlp in transport.ts. The old
|
|
129
|
+
// Promise.race([fetch, sleep]) left the fetch running and the timer pending.
|
|
130
|
+
const controller = new AbortController();
|
|
131
|
+
let timer;
|
|
132
|
+
try {
|
|
133
|
+
// Serialized once: its length picks the wait, and the same string is sent.
|
|
134
|
+
const requestBody = JSON.stringify((0, otlp_js_1.guardVersionOf)(payload));
|
|
135
|
+
const timeoutMs = guardWaitMs(Buffer.byteLength(requestBody, "utf-8"), opts);
|
|
136
|
+
timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
137
|
+
const res = await fetch(endpoint, {
|
|
138
|
+
method: "POST",
|
|
139
|
+
headers: {
|
|
140
|
+
"content-type": "application/json",
|
|
141
|
+
"user-agent": opts.userAgent ?? DEFAULT_UA,
|
|
142
|
+
"x-pinta-relay-token": opts.token ?? "",
|
|
143
|
+
// Spread rather than defaulted: an empty string is not "unknown" to the
|
|
144
|
+
// manager, it is a claim that fails validation, and sending one would
|
|
145
|
+
// make every adapter that never sets this look like it tried.
|
|
146
|
+
...(opts.agentType ? { "x-pinta-agent-type": opts.agentType } : {}),
|
|
147
|
+
...(opts.failureMode === "hold" ? {
|
|
148
|
+
[exports.GUARD_MODE_HEADER]: exports.GUARD_HOLD_PROTOCOL,
|
|
149
|
+
[exports.GUARD_REQUIRED_RULES_HEADER]: (opts.requiredRules ?? DEFAULT_REQUIRED_RULES).join(","),
|
|
150
|
+
} : {}),
|
|
151
|
+
// Same rule: the manager discards a non-positive or non-numeric budget
|
|
152
|
+
// and falls back to its table, so such a value is not sent at all.
|
|
153
|
+
...(Number.isFinite(timeoutMs) && timeoutMs > 0
|
|
154
|
+
? { [exports.GUARD_BUDGET_HEADER]: String(timeoutMs) }
|
|
155
|
+
: {}),
|
|
156
|
+
},
|
|
157
|
+
body: requestBody,
|
|
158
|
+
signal: controller.signal,
|
|
159
|
+
});
|
|
160
|
+
if (res.status === exports.GUARD_STATUS_REFUSED) {
|
|
161
|
+
return failOpen(Date.now() - start, "refused");
|
|
162
|
+
}
|
|
163
|
+
if (res.status !== 200) {
|
|
164
|
+
return failOpen(Date.now() - start, "error");
|
|
165
|
+
}
|
|
166
|
+
const body = (await res.json());
|
|
167
|
+
// Validate the 200 body: a malformed/empty response ({} or wrong types)
|
|
168
|
+
// would otherwise propagate `decision: undefined`, which later throws in
|
|
169
|
+
// buildPayload (otlp.ts `guard.decision.toLowerCase()`). Fail open instead.
|
|
170
|
+
// `durationMs` stays optional (the manager may omit it — see GuardResult
|
|
171
|
+
// docs — and the client falls back to clientRttMs), but if it IS present it
|
|
172
|
+
// must be a finite number, else the payload is malformed → fail open.
|
|
173
|
+
const durationMsOk = body?.durationMs === undefined ||
|
|
174
|
+
(typeof body.durationMs === "number" && Number.isFinite(body.durationMs));
|
|
175
|
+
if (!body || !VALID_DECISIONS.has(body.decision) || !durationMsOk) {
|
|
176
|
+
return failOpen(Date.now() - start, "error");
|
|
177
|
+
}
|
|
178
|
+
const failOpenReason = body.decision === "ALLOW" ? body.failOpenReason : undefined;
|
|
179
|
+
if (failOpenReason != null && !isFailOpenReason(failOpenReason))
|
|
180
|
+
return failOpen(Date.now() - start, "error");
|
|
181
|
+
// Measured after the body is parsed: that is the point the caller actually
|
|
182
|
+
// has its decision, so it is the full wall-clock it blocked for.
|
|
183
|
+
const clientRttMs = Date.now() - start;
|
|
184
|
+
// Output-denial fields (PTA-695). Each is parsed with an explicit type
|
|
185
|
+
// check and dropped when it does not fit; none of them can fail open — the
|
|
186
|
+
// decision above was already validated, and these only say how to deliver
|
|
187
|
+
// it. Spread so an absent field stays absent (`"x" in result` is false),
|
|
188
|
+
// which is what distinguishes an older manager from one that sent null.
|
|
189
|
+
const evaluationId = typeof body.evaluationId === "string" && body.evaluationId.length > 0 ? body.evaluationId : undefined;
|
|
190
|
+
const outputAction = isOutputAction(body.outputAction) ? body.outputAction : undefined;
|
|
191
|
+
const redactions = parseRedactions(body.redactions);
|
|
192
|
+
const assessment = parseAssessment(body.assessment);
|
|
193
|
+
return {
|
|
194
|
+
decision: body.decision,
|
|
195
|
+
reason: body.reason ?? null,
|
|
196
|
+
userMessage: body.userMessage ?? null,
|
|
197
|
+
durationMs: body.durationMs ?? clientRttMs,
|
|
198
|
+
clientRttMs,
|
|
199
|
+
...(isFailOpenReason(failOpenReason) ? { failOpenReason } : {}),
|
|
200
|
+
...(evaluationId !== undefined ? { evaluationId } : {}),
|
|
201
|
+
...(outputAction !== undefined ? { outputAction } : {}),
|
|
202
|
+
...(redactions !== undefined ? { redactions } : {}),
|
|
203
|
+
...(assessment ? { assessment } : {}),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
// AbortError (our timeout) → "timeout"; anything else (network/parse) → "error".
|
|
208
|
+
const name = err.name;
|
|
209
|
+
const reason = name === "AbortError" || name === "TimeoutError" ? "timeout" : "error";
|
|
210
|
+
return failOpen(Date.now() - start, reason);
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
clearTimeout(timer);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const DEFAULT_REQUIRED_RULES = ["deny_credentials", "deny_create_system_path"];
|
|
217
|
+
function isHoldReason(value) {
|
|
218
|
+
return typeof value === "string" && exports.GUARD_HOLD_REASONS.some((reason) => reason === value);
|
|
219
|
+
}
|
|
220
|
+
function parseAssessment(value) {
|
|
221
|
+
if (!value || typeof value !== "object")
|
|
222
|
+
return undefined;
|
|
223
|
+
const candidate = value;
|
|
224
|
+
if (candidate.protocol !== exports.GUARD_HOLD_PROTOCOL)
|
|
225
|
+
return undefined;
|
|
226
|
+
if (candidate.status === "assessed" && candidate.reason === undefined) {
|
|
227
|
+
return { protocol: exports.GUARD_HOLD_PROTOCOL, status: "assessed" };
|
|
228
|
+
}
|
|
229
|
+
if (candidate.status === "unavailable" && isHoldReason(candidate.reason)) {
|
|
230
|
+
return { protocol: exports.GUARD_HOLD_PROTOCOL, status: "unavailable", reason: candidate.reason };
|
|
231
|
+
}
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
function holdGuard(reason, elapsedMs = 0) {
|
|
235
|
+
return {
|
|
236
|
+
decision: "DENY",
|
|
237
|
+
reason: "guard_inspection_unavailable",
|
|
238
|
+
userMessage: `Pinta high-risk protection cannot complete inspection (${reason}). Restore the guard configuration or connection and retry.`,
|
|
239
|
+
durationMs: elapsedMs,
|
|
240
|
+
clientRttMs: elapsedMs,
|
|
241
|
+
assessment: { protocol: exports.GUARD_HOLD_PROTOCOL, status: "unavailable", reason },
|
|
242
|
+
holdReason: reason,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
async function evaluateGuard(payload, endpoint, opts = {}) {
|
|
246
|
+
if (opts.failureMode === undefined || opts.failureMode === "open") {
|
|
247
|
+
return evaluateOpenGuard(payload, endpoint, opts);
|
|
248
|
+
}
|
|
249
|
+
const required = opts.requiredRules ?? DEFAULT_REQUIRED_RULES;
|
|
250
|
+
if (opts.failureMode !== "hold" || !Array.isArray(required) || required.length === 0
|
|
251
|
+
|| required.length > 32 || new Set(required).size !== required.length
|
|
252
|
+
|| required.some((name) => typeof name !== "string" || !/^[A-Za-z0-9_-]{1,128}$/.test(name))) {
|
|
253
|
+
return holdGuard("configuration_invalid");
|
|
254
|
+
}
|
|
255
|
+
if (opts.disabled)
|
|
256
|
+
return holdGuard("inspection_disabled");
|
|
257
|
+
if (!endpoint)
|
|
258
|
+
return holdGuard("endpoint_unavailable");
|
|
259
|
+
const result = await evaluateOpenGuard(payload, endpoint, opts);
|
|
260
|
+
if (!result)
|
|
261
|
+
return holdGuard("endpoint_unavailable");
|
|
262
|
+
const elapsed = result.clientRttMs ?? result.durationMs;
|
|
263
|
+
if (result.failOpenReason)
|
|
264
|
+
return holdGuard(result.failOpenReason, elapsed);
|
|
265
|
+
if (!result.assessment)
|
|
266
|
+
return holdGuard("unsupported_manager", elapsed);
|
|
267
|
+
if (result.assessment.status === "unavailable") {
|
|
268
|
+
return {
|
|
269
|
+
...holdGuard(result.assessment.reason ?? "error", elapsed),
|
|
270
|
+
...(result.evaluationId ? { evaluationId: result.evaluationId } : {}),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
return result;
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":";;;AA0LA,kCAUC;AAuND,8BAUC;AAED,sCA4BC;AAncD,uCAA2C;AAuB9B,QAAA,mBAAmB,GAAG,SAAS,CAAC;AAChC,QAAA,iBAAiB,GAAG,oBAAoB,CAAC;AACzC,QAAA,2BAA2B,GAAG,wBAAwB,CAAC;AACvD,QAAA,kBAAkB,GAAG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SACtE,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { redact, truncate, truncateTo, collectMatches, resolveOverlaps, applyMatches, PATTERNS, MAX_BYTES, } from "./redact.js";
|
|
2
|
+
export type { RedactOptions, Pattern } from "./redact.js";
|
|
3
|
+
export { inspectCredentialSemantics } from "./credential-semantics.js";
|
|
4
|
+
export type { CredentialSemantics, FetchCredentialOption } from "./credential-semantics.js";
|
|
5
|
+
export { createValueMasker, decodeJsonTextForScan, maskJsonValue, maskOtlpEnvelope, sensitiveValues } from "./value-masking.js";
|
|
6
|
+
export type { MaskingSignal, ValueMaskRule, ValueMasker } from "./value-masking.js";
|
|
7
|
+
export type { OtlpAttribute, OtlpSpan, ResourceSpans, OtlpPayload, } from "./otlp-types.js";
|
|
8
|
+
export { ulidToTraceId, newSpanId, snakeCase, toOtlpValue, attrsFromRecord, guardAttrs, clientAttrs, buildPayload, attachGuard, guardVersionOf, mergeBatch, enforceSpanBudget, MAX_SPAN_BYTES, } from "./otlp.js";
|
|
9
|
+
export type { AttrPolicy, BuildPayloadArgs, ClientCallTiming } from "./otlp.js";
|
|
10
|
+
export { evaluateGuard, guardWaitMs, GUARD_STATUS_REFUSED, GUARD_BUDGET_HEADER, LONG_INPUT_BYTES, DEFAULT_LONG_INPUT_TIMEOUT_MS, MAX_LONG_INPUT_TIMEOUT_MS, holdGuard, GUARD_HOLD_PROTOCOL, GUARD_MODE_HEADER, GUARD_REQUIRED_RULES_HEADER, GUARD_HOLD_REASONS, } from "./guard.js";
|
|
11
|
+
export type { GuardPayload, GuardResult, GuardOptions, GuardAssessment, GuardHoldReason } from "./guard.js";
|
|
12
|
+
export { buildOutputDenial, buildNotice, DEFAULT_NOTICE, GUIDANCE_MASK, GUIDANCE_WITHHOLD, WITHHELD_TEXT, TRUNCATION_MARKER, } from "./output-denial.js";
|
|
13
|
+
export type { OutputDenial, BuildOutputDenialArgs } from "./output-denial.js";
|
|
14
|
+
export { DiskRetryQueue, MemoryRetryQueue } from "./retry-queue.js";
|
|
15
|
+
export type { QueueEntry } from "./retry-queue.js";
|
|
16
|
+
export { DiskTransport, MemoryTransport, postOtlp, envOptionsResolver, parseHeadersEnv, MAX_POST_BYTES, } from "./transport.js";
|
|
17
|
+
export type { OtlpTransportOptions, OptionsResolver } from "./transport.js";
|
|
18
|
+
export { TraceManager, generateUlid } from "./trace.js";
|
|
19
|
+
export { DiskSessionTraceManager, MemorySessionTraceManager, } from "./session-trace.js";
|
|
20
|
+
export type { SessionTraceManager } from "./session-trace.js";
|
|
21
|
+
export { envFilePath, parseEnvFile, loadEnvFile } from "./env-file.js";
|
|
22
|
+
export type { TranscriptSemantics, TranscriptFile, TranscriptClass, TranscriptSource, } from "./lifecycle.js";
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,QAAQ,EACR,UAAU,EACV,cAAc,EACd,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAE5F,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChI,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGpF,YAAY,EACV,aAAa,EACb,QAAQ,EACR,aAAa,EACb,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,aAAa,E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EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGvE,YAAY,EACV,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoryTransport = exports.DiskTransport = exports.MemoryRetryQueue = exports.DiskRetryQueue = exports.TRUNCATION_MARKER = exports.WITHHELD_TEXT = exports.GUIDANCE_WITHHOLD = exports.GUIDANCE_MASK = exports.DEFAULT_NOTICE = exports.buildNotice = exports.buildOutputDenial = exports.GUARD_HOLD_REASONS = exports.GUARD_REQUIRED_RULES_HEADER = exports.GUARD_MODE_HEADER = exports.GUARD_HOLD_PROTOCOL = exports.holdGuard = exports.MAX_LONG_INPUT_TIMEOUT_MS = exports.DEFAULT_LONG_INPUT_TIMEOUT_MS = exports.LONG_INPUT_BYTES = exports.GUARD_BUDGET_HEADER = exports.GUARD_STATUS_REFUSED = exports.guardWaitMs = exports.evaluateGuard = exports.MAX_SPAN_BYTES = exports.enforceSpanBudget = exports.mergeBatch = exports.guardVersionOf = exports.attachGuard = exports.buildPayload = exports.clientAttrs = exports.guardAttrs = exports.attrsFromRecord = exports.toOtlpValue = exports.snakeCase = exports.newSpanId = exports.ulidToTraceId = exports.sensitiveValues = exports.maskOtlpEnvelope = exports.maskJsonValue = exports.decodeJsonTextForScan = exports.createValueMasker = exports.inspectCredentialSemantics = exports.MAX_BYTES = exports.PATTERNS = exports.applyMatches = exports.resolveOverlaps = exports.collectMatches = exports.truncateTo = exports.truncate = exports.redact = void 0;
|
|
4
|
+
exports.loadEnvFile = exports.parseEnvFile = exports.envFilePath = exports.MemorySessionTraceManager = exports.DiskSessionTraceManager = exports.generateUlid = exports.TraceManager = exports.MAX_POST_BYTES = exports.parseHeadersEnv = exports.envOptionsResolver = exports.postOtlp = void 0;
|
|
5
|
+
// Redaction (Tier 1) + truncation (Tier 3)
|
|
6
|
+
var redact_js_1 = require("./redact.js");
|
|
7
|
+
Object.defineProperty(exports, "redact", { enumerable: true, get: function () { return redact_js_1.redact; } });
|
|
8
|
+
Object.defineProperty(exports, "truncate", { enumerable: true, get: function () { return redact_js_1.truncate; } });
|
|
9
|
+
Object.defineProperty(exports, "truncateTo", { enumerable: true, get: function () { return redact_js_1.truncateTo; } });
|
|
10
|
+
Object.defineProperty(exports, "collectMatches", { enumerable: true, get: function () { return redact_js_1.collectMatches; } });
|
|
11
|
+
Object.defineProperty(exports, "resolveOverlaps", { enumerable: true, get: function () { return redact_js_1.resolveOverlaps; } });
|
|
12
|
+
Object.defineProperty(exports, "applyMatches", { enumerable: true, get: function () { return redact_js_1.applyMatches; } });
|
|
13
|
+
Object.defineProperty(exports, "PATTERNS", { enumerable: true, get: function () { return redact_js_1.PATTERNS; } });
|
|
14
|
+
Object.defineProperty(exports, "MAX_BYTES", { enumerable: true, get: function () { return redact_js_1.MAX_BYTES; } });
|
|
15
|
+
var credential_semantics_js_1 = require("./credential-semantics.js");
|
|
16
|
+
Object.defineProperty(exports, "inspectCredentialSemantics", { enumerable: true, get: function () { return credential_semantics_js_1.inspectCredentialSemantics; } });
|
|
17
|
+
var value_masking_js_1 = require("./value-masking.js");
|
|
18
|
+
Object.defineProperty(exports, "createValueMasker", { enumerable: true, get: function () { return value_masking_js_1.createValueMasker; } });
|
|
19
|
+
Object.defineProperty(exports, "decodeJsonTextForScan", { enumerable: true, get: function () { return value_masking_js_1.decodeJsonTextForScan; } });
|
|
20
|
+
Object.defineProperty(exports, "maskJsonValue", { enumerable: true, get: function () { return value_masking_js_1.maskJsonValue; } });
|
|
21
|
+
Object.defineProperty(exports, "maskOtlpEnvelope", { enumerable: true, get: function () { return value_masking_js_1.maskOtlpEnvelope; } });
|
|
22
|
+
Object.defineProperty(exports, "sensitiveValues", { enumerable: true, get: function () { return value_masking_js_1.sensitiveValues; } });
|
|
23
|
+
// OTLP primitives + redaction-aware attribute building
|
|
24
|
+
var otlp_js_1 = require("./otlp.js");
|
|
25
|
+
Object.defineProperty(exports, "ulidToTraceId", { enumerable: true, get: function () { return otlp_js_1.ulidToTraceId; } });
|
|
26
|
+
Object.defineProperty(exports, "newSpanId", { enumerable: true, get: function () { return otlp_js_1.newSpanId; } });
|
|
27
|
+
Object.defineProperty(exports, "snakeCase", { enumerable: true, get: function () { return otlp_js_1.snakeCase; } });
|
|
28
|
+
Object.defineProperty(exports, "toOtlpValue", { enumerable: true, get: function () { return otlp_js_1.toOtlpValue; } });
|
|
29
|
+
Object.defineProperty(exports, "attrsFromRecord", { enumerable: true, get: function () { return otlp_js_1.attrsFromRecord; } });
|
|
30
|
+
Object.defineProperty(exports, "guardAttrs", { enumerable: true, get: function () { return otlp_js_1.guardAttrs; } });
|
|
31
|
+
Object.defineProperty(exports, "clientAttrs", { enumerable: true, get: function () { return otlp_js_1.clientAttrs; } });
|
|
32
|
+
Object.defineProperty(exports, "buildPayload", { enumerable: true, get: function () { return otlp_js_1.buildPayload; } });
|
|
33
|
+
Object.defineProperty(exports, "attachGuard", { enumerable: true, get: function () { return otlp_js_1.attachGuard; } });
|
|
34
|
+
Object.defineProperty(exports, "guardVersionOf", { enumerable: true, get: function () { return otlp_js_1.guardVersionOf; } });
|
|
35
|
+
Object.defineProperty(exports, "mergeBatch", { enumerable: true, get: function () { return otlp_js_1.mergeBatch; } });
|
|
36
|
+
Object.defineProperty(exports, "enforceSpanBudget", { enumerable: true, get: function () { return otlp_js_1.enforceSpanBudget; } });
|
|
37
|
+
Object.defineProperty(exports, "MAX_SPAN_BYTES", { enumerable: true, get: function () { return otlp_js_1.MAX_SPAN_BYTES; } });
|
|
38
|
+
// Guard (external policy server query, fail-open)
|
|
39
|
+
var guard_js_1 = require("./guard.js");
|
|
40
|
+
Object.defineProperty(exports, "evaluateGuard", { enumerable: true, get: function () { return guard_js_1.evaluateGuard; } });
|
|
41
|
+
Object.defineProperty(exports, "guardWaitMs", { enumerable: true, get: function () { return guard_js_1.guardWaitMs; } });
|
|
42
|
+
Object.defineProperty(exports, "GUARD_STATUS_REFUSED", { enumerable: true, get: function () { return guard_js_1.GUARD_STATUS_REFUSED; } });
|
|
43
|
+
Object.defineProperty(exports, "GUARD_BUDGET_HEADER", { enumerable: true, get: function () { return guard_js_1.GUARD_BUDGET_HEADER; } });
|
|
44
|
+
Object.defineProperty(exports, "LONG_INPUT_BYTES", { enumerable: true, get: function () { return guard_js_1.LONG_INPUT_BYTES; } });
|
|
45
|
+
Object.defineProperty(exports, "DEFAULT_LONG_INPUT_TIMEOUT_MS", { enumerable: true, get: function () { return guard_js_1.DEFAULT_LONG_INPUT_TIMEOUT_MS; } });
|
|
46
|
+
Object.defineProperty(exports, "MAX_LONG_INPUT_TIMEOUT_MS", { enumerable: true, get: function () { return guard_js_1.MAX_LONG_INPUT_TIMEOUT_MS; } });
|
|
47
|
+
Object.defineProperty(exports, "holdGuard", { enumerable: true, get: function () { return guard_js_1.holdGuard; } });
|
|
48
|
+
Object.defineProperty(exports, "GUARD_HOLD_PROTOCOL", { enumerable: true, get: function () { return guard_js_1.GUARD_HOLD_PROTOCOL; } });
|
|
49
|
+
Object.defineProperty(exports, "GUARD_MODE_HEADER", { enumerable: true, get: function () { return guard_js_1.GUARD_MODE_HEADER; } });
|
|
50
|
+
Object.defineProperty(exports, "GUARD_REQUIRED_RULES_HEADER", { enumerable: true, get: function () { return guard_js_1.GUARD_REQUIRED_RULES_HEADER; } });
|
|
51
|
+
Object.defineProperty(exports, "GUARD_HOLD_REASONS", { enumerable: true, get: function () { return guard_js_1.GUARD_HOLD_REASONS; } });
|
|
52
|
+
// Output denial (what the model receives when the guard denies a tool output)
|
|
53
|
+
var output_denial_js_1 = require("./output-denial.js");
|
|
54
|
+
Object.defineProperty(exports, "buildOutputDenial", { enumerable: true, get: function () { return output_denial_js_1.buildOutputDenial; } });
|
|
55
|
+
Object.defineProperty(exports, "buildNotice", { enumerable: true, get: function () { return output_denial_js_1.buildNotice; } });
|
|
56
|
+
Object.defineProperty(exports, "DEFAULT_NOTICE", { enumerable: true, get: function () { return output_denial_js_1.DEFAULT_NOTICE; } });
|
|
57
|
+
Object.defineProperty(exports, "GUIDANCE_MASK", { enumerable: true, get: function () { return output_denial_js_1.GUIDANCE_MASK; } });
|
|
58
|
+
Object.defineProperty(exports, "GUIDANCE_WITHHOLD", { enumerable: true, get: function () { return output_denial_js_1.GUIDANCE_WITHHOLD; } });
|
|
59
|
+
Object.defineProperty(exports, "WITHHELD_TEXT", { enumerable: true, get: function () { return output_denial_js_1.WITHHELD_TEXT; } });
|
|
60
|
+
Object.defineProperty(exports, "TRUNCATION_MARKER", { enumerable: true, get: function () { return output_denial_js_1.TRUNCATION_MARKER; } });
|
|
61
|
+
// Retry queues
|
|
62
|
+
var retry_queue_js_1 = require("./retry-queue.js");
|
|
63
|
+
Object.defineProperty(exports, "DiskRetryQueue", { enumerable: true, get: function () { return retry_queue_js_1.DiskRetryQueue; } });
|
|
64
|
+
Object.defineProperty(exports, "MemoryRetryQueue", { enumerable: true, get: function () { return retry_queue_js_1.MemoryRetryQueue; } });
|
|
65
|
+
// Transport (OTLP POST + retry orchestration)
|
|
66
|
+
var transport_js_1 = require("./transport.js");
|
|
67
|
+
Object.defineProperty(exports, "DiskTransport", { enumerable: true, get: function () { return transport_js_1.DiskTransport; } });
|
|
68
|
+
Object.defineProperty(exports, "MemoryTransport", { enumerable: true, get: function () { return transport_js_1.MemoryTransport; } });
|
|
69
|
+
Object.defineProperty(exports, "postOtlp", { enumerable: true, get: function () { return transport_js_1.postOtlp; } });
|
|
70
|
+
Object.defineProperty(exports, "envOptionsResolver", { enumerable: true, get: function () { return transport_js_1.envOptionsResolver; } });
|
|
71
|
+
Object.defineProperty(exports, "parseHeadersEnv", { enumerable: true, get: function () { return transport_js_1.parseHeadersEnv; } });
|
|
72
|
+
Object.defineProperty(exports, "MAX_POST_BYTES", { enumerable: true, get: function () { return transport_js_1.MAX_POST_BYTES; } });
|
|
73
|
+
// Trace id management
|
|
74
|
+
var trace_js_1 = require("./trace.js");
|
|
75
|
+
Object.defineProperty(exports, "TraceManager", { enumerable: true, get: function () { return trace_js_1.TraceManager; } });
|
|
76
|
+
Object.defineProperty(exports, "generateUlid", { enumerable: true, get: function () { return trace_js_1.generateUlid; } });
|
|
77
|
+
var session_trace_js_1 = require("./session-trace.js");
|
|
78
|
+
Object.defineProperty(exports, "DiskSessionTraceManager", { enumerable: true, get: function () { return session_trace_js_1.DiskSessionTraceManager; } });
|
|
79
|
+
Object.defineProperty(exports, "MemorySessionTraceManager", { enumerable: true, get: function () { return session_trace_js_1.MemorySessionTraceManager; } });
|
|
80
|
+
// Env-file loading
|
|
81
|
+
var env_file_js_1 = require("./env-file.js");
|
|
82
|
+
Object.defineProperty(exports, "envFilePath", { enumerable: true, get: function () { return env_file_js_1.envFilePath; } });
|
|
83
|
+
Object.defineProperty(exports, "parseEnvFile", { enumerable: true, get: function () { return env_file_js_1.parseEnvFile; } });
|
|
84
|
+
Object.defineProperty(exports, "loadEnvFile", { enumerable: true, get: function () { return env_file_js_1.loadEnvFile; } });
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,2CAA2C;AAC3C,yCASqB;AARnB,mGAAA,MAAM,OAAA;AACN,qGAAA,QAAQ,OAAA;AACR,uGAAA,UAAU,OAAA;AACV,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,yGAAA,YAAY,OAAA;AACZ,qGAAA,QAAQ,OAAA;AACR,sGAAA,SAAS,OAAA;AAGX,qEAAuE;AAA9D,qIAAA,0BAA0B,OAAA;AAGnC,uDAAgI;AAAvH,qHAAA,iBAAiB,OAAA;AAAE,yHAAA,qBAAqB,OAAA;AAAE,iHAAA,aAAa,OAAA;AAAE,oHAAA,gBAAgB,OAAA;AAAE,mHAAA,eAAe,OAAA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