shield360 1.0.1 → 1.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/README.md +65 -37
- package/dist/__tests__/build-info.test.d.ts +1 -0
- package/dist/__tests__/build-info.test.js +189 -0
- package/dist/__tests__/build-info.test.js.map +1 -0
- package/dist/__tests__/code-location.test.d.ts +1 -0
- package/dist/__tests__/code-location.test.js +180 -0
- package/dist/__tests__/code-location.test.js.map +1 -0
- package/dist/__tests__/pricing-claude-5.test.js +3 -0
- package/dist/__tests__/pricing-claude-5.test.js.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/guard/__tests__/findings.test.js +27 -8
- package/dist/guard/__tests__/findings.test.js.map +1 -1
- package/dist/guard/base.d.ts +2 -0
- package/dist/guard/base.js +4 -0
- package/dist/guard/base.js.map +1 -1
- package/dist/guard/findings.d.ts +12 -2
- package/dist/guard/findings.js +19 -49
- package/dist/guard/findings.js.map +1 -1
- package/dist/guard/integration.d.ts +24 -3
- package/dist/guard/integration.js +102 -30
- package/dist/guard/integration.js.map +1 -1
- package/dist/guard/pipeline.d.ts +10 -1
- package/dist/guard/pipeline.js +14 -0
- package/dist/guard/pipeline.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +34 -3
- package/dist/index.js.map +1 -1
- package/dist/instrumentation/mcp/wrapper.js +7 -1
- package/dist/instrumentation/mcp/wrapper.js.map +1 -1
- package/dist/otel/build-info.d.ts +22 -0
- package/dist/otel/build-info.js +175 -0
- package/dist/otel/build-info.js.map +1 -0
- package/dist/otel/code-location.d.ts +49 -0
- package/dist/otel/code-location.js +233 -0
- package/dist/otel/code-location.js.map +1 -0
- package/dist/otel/tracing.js +7 -0
- package/dist/otel/tracing.js.map +1 -1
- package/dist/pricing.json +100 -42
- package/dist/protect/__tests__/protect.test.d.ts +1 -0
- package/dist/protect/__tests__/protect.test.js +206 -0
- package/dist/protect/__tests__/protect.test.js.map +1 -0
- package/dist/protect/index.d.ts +103 -0
- package/dist/protect/index.js +191 -0
- package/dist/protect/index.js.map +1 -0
- package/dist/protect/mcp.d.ts +13 -0
- package/dist/protect/mcp.js +49 -0
- package/dist/protect/mcp.js.map +1 -0
- package/dist/protect/mode.d.ts +89 -0
- package/dist/protect/mode.js +134 -0
- package/dist/protect/mode.js.map +1 -0
- package/dist/types.d.ts +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shield Protect -- the enforcement mode of this process.
|
|
3
|
+
*
|
|
4
|
+
* observe every check runs and its finding is recorded (span event,
|
|
5
|
+
* decision report); nothing is refused. For seeing what enforced
|
|
6
|
+
* mode would stop before turning it on.
|
|
7
|
+
* warn as observe, and the finding is logged as a warning.
|
|
8
|
+
* enforced a finding refuses the call; a guard that throws refuses the
|
|
9
|
+
* call (fail closed, whatever guardFailOpen says); a provider
|
|
10
|
+
* named in `required` that could not be wrapped stops startup;
|
|
11
|
+
* a streamed completion that postflight guards cannot inspect
|
|
12
|
+
* is refused; input past the scan bound is refused rather than
|
|
13
|
+
* scanned in part.
|
|
14
|
+
*
|
|
15
|
+
* The mode set in code is a floor: SHIELD360_PROTECT_MODE can raise it and
|
|
16
|
+
* never lower it, so an environment variable in a shell or a container
|
|
17
|
+
* cannot weaken what the application was deployed with. With no mode set
|
|
18
|
+
* anywhere, guards behave as they always have (each guard's own action,
|
|
19
|
+
* guardFailOpen as given): that is `legacy`, and nothing changes for an
|
|
20
|
+
* application that never asked for Protect.
|
|
21
|
+
*
|
|
22
|
+
* What this layer can and cannot claim: it runs inside the application's
|
|
23
|
+
* process. Code that can disable the SDK, import a provider the SDK does
|
|
24
|
+
* not wrap, or reach a network directly is not stopped by it. The
|
|
25
|
+
* mandatory boundary is the Shield360 gateway; this layer is monitored or
|
|
26
|
+
* partially protected, and its readiness report says so.
|
|
27
|
+
*
|
|
28
|
+
* Must stay in sync with: sdk/python/src/shield360/protect/_mode.py
|
|
29
|
+
*/
|
|
30
|
+
export type ProtectMode = 'observe' | 'warn' | 'enforced';
|
|
31
|
+
export declare const PROTECT_MODES: readonly ProtectMode[];
|
|
32
|
+
export declare const PROTECT_MODE_ENV = "SHIELD360_PROTECT_MODE";
|
|
33
|
+
export declare const PROTECT_REQUIRED_ENV = "SHIELD360_PROTECT_REQUIRED";
|
|
34
|
+
export declare function isProtectMode(value: unknown): value is ProtectMode;
|
|
35
|
+
/** The stricter of two modes; undefined counts as nothing. */
|
|
36
|
+
export declare function strictestMode(a?: ProtectMode, b?: ProtectMode): ProtectMode | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The mode this process runs under: what the code set, raised by the
|
|
39
|
+
* environment when the environment asks for more. An environment value
|
|
40
|
+
* that is not a mode is ignored, never a downgrade.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveProtectMode(fromCode?: ProtectMode, env?: NodeJS.ProcessEnv): ProtectMode | undefined;
|
|
43
|
+
/** Providers that must be wrapped: the code's list plus the environment's. */
|
|
44
|
+
export declare function resolveRequired(fromCode?: string[], env?: NodeJS.ProcessEnv): string[];
|
|
45
|
+
export type ProtectConfig = {
|
|
46
|
+
mode?: ProtectMode;
|
|
47
|
+
/** npm package names whose provider methods must be wrapped, or startup fails in enforced mode: "openai", "@anthropic-ai/sdk". */
|
|
48
|
+
required?: string[];
|
|
49
|
+
};
|
|
50
|
+
export type ResolvedProtect = {
|
|
51
|
+
mode?: ProtectMode;
|
|
52
|
+
required: string[];
|
|
53
|
+
};
|
|
54
|
+
export declare function resolveProtect(config: ProtectConfig | undefined, env?: NodeJS.ProcessEnv): ResolvedProtect;
|
|
55
|
+
export declare const refuses: (mode: ProtectMode | undefined) => boolean;
|
|
56
|
+
export declare class ProtectError extends Error {
|
|
57
|
+
constructor(message?: string);
|
|
58
|
+
}
|
|
59
|
+
/** A call refused by Protect for a reason that is not a guard finding: oversized input, uninspectable streaming, a failed check. */
|
|
60
|
+
export declare class ProtectDeniedError extends ProtectError {
|
|
61
|
+
readonly code: 'oversized' | 'streaming' | 'guard_failed' | 'not_authorized' | 'authorize_failed';
|
|
62
|
+
constructor(code: ProtectDeniedError['code'], message: string);
|
|
63
|
+
}
|
|
64
|
+
/** Enforced mode could not be set up: a required provider is not wrapped, or guards are missing. Thrown from init. */
|
|
65
|
+
export declare class ProtectReadinessError extends ProtectError {
|
|
66
|
+
readonly missing: string[];
|
|
67
|
+
constructor(missing: string[], message: string);
|
|
68
|
+
}
|
|
69
|
+
export type ProtectReadiness = {
|
|
70
|
+
mode: ProtectMode | 'legacy';
|
|
71
|
+
/** Provider packages whose methods were wrapped. */
|
|
72
|
+
wrapped: string[];
|
|
73
|
+
/** Provider packages named as required that were not wrapped. */
|
|
74
|
+
missing: string[];
|
|
75
|
+
/** monitored: in-process checks that code in the same process can bypass. Never "enforced": that is the gateway's claim. */
|
|
76
|
+
level: 'monitored' | 'partially_protected';
|
|
77
|
+
note: string;
|
|
78
|
+
};
|
|
79
|
+
/** @internal */
|
|
80
|
+
export declare function setProtectState(next: {
|
|
81
|
+
mode?: ProtectMode;
|
|
82
|
+
wrapped: string[];
|
|
83
|
+
missing: string[];
|
|
84
|
+
}): void;
|
|
85
|
+
/** @internal */
|
|
86
|
+
export declare function currentProtectMode(): ProtectMode | undefined;
|
|
87
|
+
export declare function protectReadiness(): ProtectReadiness;
|
|
88
|
+
/** @internal for tests */
|
|
89
|
+
export declare function resetProtectState(): void;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shield Protect -- the enforcement mode of this process.
|
|
4
|
+
*
|
|
5
|
+
* observe every check runs and its finding is recorded (span event,
|
|
6
|
+
* decision report); nothing is refused. For seeing what enforced
|
|
7
|
+
* mode would stop before turning it on.
|
|
8
|
+
* warn as observe, and the finding is logged as a warning.
|
|
9
|
+
* enforced a finding refuses the call; a guard that throws refuses the
|
|
10
|
+
* call (fail closed, whatever guardFailOpen says); a provider
|
|
11
|
+
* named in `required` that could not be wrapped stops startup;
|
|
12
|
+
* a streamed completion that postflight guards cannot inspect
|
|
13
|
+
* is refused; input past the scan bound is refused rather than
|
|
14
|
+
* scanned in part.
|
|
15
|
+
*
|
|
16
|
+
* The mode set in code is a floor: SHIELD360_PROTECT_MODE can raise it and
|
|
17
|
+
* never lower it, so an environment variable in a shell or a container
|
|
18
|
+
* cannot weaken what the application was deployed with. With no mode set
|
|
19
|
+
* anywhere, guards behave as they always have (each guard's own action,
|
|
20
|
+
* guardFailOpen as given): that is `legacy`, and nothing changes for an
|
|
21
|
+
* application that never asked for Protect.
|
|
22
|
+
*
|
|
23
|
+
* What this layer can and cannot claim: it runs inside the application's
|
|
24
|
+
* process. Code that can disable the SDK, import a provider the SDK does
|
|
25
|
+
* not wrap, or reach a network directly is not stopped by it. The
|
|
26
|
+
* mandatory boundary is the Shield360 gateway; this layer is monitored or
|
|
27
|
+
* partially protected, and its readiness report says so.
|
|
28
|
+
*
|
|
29
|
+
* Must stay in sync with: sdk/python/src/shield360/protect/_mode.py
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.ProtectReadinessError = exports.ProtectDeniedError = exports.ProtectError = exports.refuses = exports.PROTECT_REQUIRED_ENV = exports.PROTECT_MODE_ENV = exports.PROTECT_MODES = void 0;
|
|
33
|
+
exports.isProtectMode = isProtectMode;
|
|
34
|
+
exports.strictestMode = strictestMode;
|
|
35
|
+
exports.resolveProtectMode = resolveProtectMode;
|
|
36
|
+
exports.resolveRequired = resolveRequired;
|
|
37
|
+
exports.resolveProtect = resolveProtect;
|
|
38
|
+
exports.setProtectState = setProtectState;
|
|
39
|
+
exports.currentProtectMode = currentProtectMode;
|
|
40
|
+
exports.protectReadiness = protectReadiness;
|
|
41
|
+
exports.resetProtectState = resetProtectState;
|
|
42
|
+
exports.PROTECT_MODES = ['observe', 'warn', 'enforced'];
|
|
43
|
+
const RANK = { observe: 0, warn: 1, enforced: 2 };
|
|
44
|
+
exports.PROTECT_MODE_ENV = 'SHIELD360_PROTECT_MODE';
|
|
45
|
+
exports.PROTECT_REQUIRED_ENV = 'SHIELD360_PROTECT_REQUIRED';
|
|
46
|
+
function isProtectMode(value) {
|
|
47
|
+
return typeof value === 'string' && exports.PROTECT_MODES.includes(value);
|
|
48
|
+
}
|
|
49
|
+
/** The stricter of two modes; undefined counts as nothing. */
|
|
50
|
+
function strictestMode(a, b) {
|
|
51
|
+
if (!a)
|
|
52
|
+
return b;
|
|
53
|
+
if (!b)
|
|
54
|
+
return a;
|
|
55
|
+
return RANK[a] >= RANK[b] ? a : b;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The mode this process runs under: what the code set, raised by the
|
|
59
|
+
* environment when the environment asks for more. An environment value
|
|
60
|
+
* that is not a mode is ignored, never a downgrade.
|
|
61
|
+
*/
|
|
62
|
+
function resolveProtectMode(fromCode, env = process.env) {
|
|
63
|
+
const raw = (env[exports.PROTECT_MODE_ENV] || '').trim().toLowerCase();
|
|
64
|
+
const fromEnv = isProtectMode(raw) ? raw : undefined;
|
|
65
|
+
return strictestMode(fromCode, fromEnv);
|
|
66
|
+
}
|
|
67
|
+
/** Providers that must be wrapped: the code's list plus the environment's. */
|
|
68
|
+
function resolveRequired(fromCode = [], env = process.env) {
|
|
69
|
+
const fromEnv = (env[exports.PROTECT_REQUIRED_ENV] || '')
|
|
70
|
+
.split(',')
|
|
71
|
+
.map((s) => s.trim())
|
|
72
|
+
.filter(Boolean);
|
|
73
|
+
return Array.from(new Set([...fromCode, ...fromEnv]));
|
|
74
|
+
}
|
|
75
|
+
function resolveProtect(config, env = process.env) {
|
|
76
|
+
return { mode: resolveProtectMode(config?.mode, env), required: resolveRequired(config?.required, env) };
|
|
77
|
+
}
|
|
78
|
+
const refuses = (mode) => mode === 'enforced';
|
|
79
|
+
exports.refuses = refuses;
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Errors
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
class ProtectError extends Error {
|
|
84
|
+
constructor(message) {
|
|
85
|
+
super(message);
|
|
86
|
+
this.name = 'ProtectError';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.ProtectError = ProtectError;
|
|
90
|
+
/** A call refused by Protect for a reason that is not a guard finding: oversized input, uninspectable streaming, a failed check. */
|
|
91
|
+
class ProtectDeniedError extends ProtectError {
|
|
92
|
+
constructor(code, message) {
|
|
93
|
+
super(message);
|
|
94
|
+
this.name = 'ProtectDeniedError';
|
|
95
|
+
this.code = code;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.ProtectDeniedError = ProtectDeniedError;
|
|
99
|
+
/** Enforced mode could not be set up: a required provider is not wrapped, or guards are missing. Thrown from init. */
|
|
100
|
+
class ProtectReadinessError extends ProtectError {
|
|
101
|
+
constructor(missing, message) {
|
|
102
|
+
super(message);
|
|
103
|
+
this.name = 'ProtectReadinessError';
|
|
104
|
+
this.missing = missing;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.ProtectReadinessError = ProtectReadinessError;
|
|
108
|
+
let state = { wrapped: [], missing: [] };
|
|
109
|
+
/** @internal */
|
|
110
|
+
function setProtectState(next) {
|
|
111
|
+
state = { mode: next.mode, wrapped: [...next.wrapped], missing: [...next.missing] };
|
|
112
|
+
}
|
|
113
|
+
/** @internal */
|
|
114
|
+
function currentProtectMode() {
|
|
115
|
+
return state.mode;
|
|
116
|
+
}
|
|
117
|
+
function protectReadiness() {
|
|
118
|
+
const mode = state.mode ?? 'legacy';
|
|
119
|
+
const partial = mode === 'enforced' && state.missing.length === 0 && state.wrapped.length > 0;
|
|
120
|
+
return {
|
|
121
|
+
mode,
|
|
122
|
+
wrapped: [...state.wrapped],
|
|
123
|
+
missing: [...state.missing],
|
|
124
|
+
level: partial ? 'partially_protected' : 'monitored',
|
|
125
|
+
note: partial
|
|
126
|
+
? 'Supported provider calls in this process are refused before they leave when a guard finds a violation, and fail closed. Code in this process that bypasses the SDK is not covered; the mandatory boundary is the Shield360 gateway.'
|
|
127
|
+
: 'Findings are recorded; calls are not refused by this layer. The mandatory boundary is the Shield360 gateway.',
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** @internal for tests */
|
|
131
|
+
function resetProtectState() {
|
|
132
|
+
state = { wrapped: [], missing: [] };
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode.js","sourceRoot":"","sources":["../../src/protect/mode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AASH,sCAEC;AAGD,sCAIC;AAOD,gDAIC;AAGD,0CAMC;AAUD,wCAEC;AAqDD,0CAEC;AAGD,gDAEC;AAED,4CAYC;AAGD,8CAEC;AA9HY,QAAA,aAAa,GAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AACrF,MAAM,IAAI,GAAgC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AAElE,QAAA,gBAAgB,GAAG,wBAAwB,CAAC;AAC5C,QAAA,oBAAoB,GAAG,4BAA4B,CAAC;AAEjE,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,qBAAmC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3F,CAAC;AAED,8DAA8D;AAC9D,SAAgB,aAAa,CAAC,CAAe,EAAE,CAAe;IAC5D,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjB,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjB,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,C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IAAI;QACJ,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;QAC3B,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;QAC3B,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,WAAW;QACpD,IAAI,EAAE,OAAO;YACX,CAAC,CAAC,qOAAqO;YACvO,CAAC,CAAC,8GAA8G;KACnH,CAAC;AACJ,CAAC;AAED,0BAA0B;AAC1B,SAAgB,iBAAiB;IAC/B,KAAK,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACvC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Resource } from '@opentelemetry/resources';
|
|
|
2
2
|
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
3
3
|
import { metrics } from '@opentelemetry/api';
|
|
4
4
|
import type { Guard } from './guard/base';
|
|
5
|
+
import type { ProtectConfig, ResolvedProtect } from './protect/mode';
|
|
5
6
|
export type InstrumentationType = 'openai' | 'anthropic' | 'cohere' | 'groq' | 'mistral' | 'google-ai' | 'vertexai' | 'together' | 'ollama' | 'vllm' | 'vercel-ai' | 'langchain' | 'langgraph' | 'pinecone' | 'bedrock' | 'llamaindex' | 'huggingface' | 'replicate' | 'chroma' | 'qdrant' | 'milvus' | 'astra' | 'azure-ai-inference' | 'openai-agents' | 'strands' | 'google-adk' | 'claude-agent-sdk' | 'cursor-sdk' | 'ai21' | 'gradient' | 'browser-use' | 'mcp' | 'mem0' | 'elevenlabs' | 'assemblyai' | 'transformers' | 'pg' | 'firecrawl' | 'letta';
|
|
6
7
|
export type Shield360Instrumentations = Partial<Record<InstrumentationType, any>>;
|
|
7
8
|
export type PricingObject = Record<string, Record<string, unknown>>;
|
|
@@ -41,6 +42,9 @@ export interface Shield360ConfigInterface {
|
|
|
41
42
|
* Python: max_content_length → JS: maxContentLength
|
|
42
43
|
* Python: custom_span_attributes → JS: customSpanAttributes
|
|
43
44
|
* Python: collect_gpu_stats → JS: collectGpuStats
|
|
45
|
+
* Python: capture_code_location → JS: captureCodeLocation
|
|
46
|
+
* Python: code_root → JS: codeRoot
|
|
47
|
+
* Python: service_version → JS: serviceVersion
|
|
44
48
|
*/
|
|
45
49
|
export type Shield360Options = {
|
|
46
50
|
environment?: string;
|
|
@@ -61,7 +65,21 @@ export type Shield360Options = {
|
|
|
61
65
|
shield360Url?: string;
|
|
62
66
|
guards?: Guard[];
|
|
63
67
|
guardFailOpen?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Shield Protect: the enforcement mode (observe | warn | enforced; env
|
|
70
|
+
* SHIELD360_PROTECT_MODE can raise it, never lower it) and the provider
|
|
71
|
+
* packages that must be wrapped for protected startup (env
|
|
72
|
+
* SHIELD360_PROTECT_REQUIRED adds to the list). In enforced mode, init()
|
|
73
|
+
* throws ProtectReadinessError instead of starting unguarded.
|
|
74
|
+
*/
|
|
75
|
+
protect?: ProtectConfig;
|
|
64
76
|
collectGpuStats?: boolean;
|
|
77
|
+
/** Add code.* call-site attributes to GenAI spans (default true; env SHIELD360_CAPTURE_CODE_LOCATION). */
|
|
78
|
+
captureCodeLocation?: boolean;
|
|
79
|
+
/** Root stripped from code.file.path (env SHIELD360_CODE_ROOT). */
|
|
80
|
+
codeRoot?: string;
|
|
81
|
+
/** service.version resource attribute (env SHIELD360_SERVICE_VERSION). */
|
|
82
|
+
serviceVersion?: string;
|
|
65
83
|
};
|
|
66
84
|
/**
|
|
67
85
|
* Resolved options used internally after merging args, env vars, and defaults.
|
|
@@ -85,7 +103,11 @@ export interface ResolvedOptions {
|
|
|
85
103
|
shield360Url?: string;
|
|
86
104
|
guards?: Guard[];
|
|
87
105
|
guardFailOpen: boolean;
|
|
106
|
+
protect: ResolvedProtect;
|
|
88
107
|
collectGpuStats: boolean;
|
|
108
|
+
captureCodeLocation: boolean;
|
|
109
|
+
codeRoot?: string;
|
|
110
|
+
serviceVersion?: string;
|
|
89
111
|
}
|
|
90
112
|
export type SetupTracerOptions = ResolvedOptions & {
|
|
91
113
|
resource: Resource;
|